:root {
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --navy: #0f172a;
  --navy-2: #111827;
  --blue: #1d4ed8;
  --blue-soft: #dbeafe;
  --teal: #14b8a6;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --shadow: 0 24px 80px rgba(15, 23, 42, .08);
  --radius: 22px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(29,78,216,.12), transparent 28rem),
    linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
  min-height: 100vh;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, var(--navy) 0%, #172554 100%);
  color: #fff;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--blue), var(--teal));
  font-weight: 800;
  box-shadow: 0 14px 30px rgba(20,184,166,.25);
}

.brand strong { display: block; font-size: 18px; }
.brand small { color: #cbd5e1; }

.nav { display: grid; gap: 8px; }
.nav-item {
  width: 100%;
  text-align: left;
  border: 0;
  color: #cbd5e1;
  background: transparent;
  padding: 14px 15px;
  border-radius: 14px;
  transition: .18s ease;
}
.nav-item:hover, .nav-item.active {
  color: #fff;
  background: rgba(255,255,255,.11);
}

.sidebar-card {
  margin-top: auto;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.12);
}
.sidebar-card small { color: #bfdbfe; }
.sidebar-card strong { display: block; margin: 6px 0; }
.sidebar-card p { margin: 0; color: #cbd5e1; font-size: 13px; line-height: 1.5; }

.main { padding: 30px; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 22px;
}
.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.04em; color: var(--navy); }
h2 { margin-bottom: 0; font-size: 21px; letter-spacing: -0.02em; color: var(--navy); }
.eyebrow { margin-bottom: 6px; text-transform: uppercase; letter-spacing: .12em; font-weight: 800; font-size: 11px; color: var(--blue); }
.muted { color: var(--muted); line-height: 1.65; }

.session-box {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  background: rgba(255,255,255,.76);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(15,23,42,.06);
  font-weight: 700;
}
.dot { width: 10px; height: 10px; border-radius: 999px; background: var(--green); }
.dot.offline { background: var(--red); }

.page { display: none; }
.page.active { display: grid; gap: 20px; }
.grid { display: grid; gap: 20px; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.invoice-layout { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }

.card {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(226,232,240,.86);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 18px; }
.metric span { color: var(--muted); font-weight: 700; font-size: 13px; }
.metric strong { display: block; color: var(--navy); font-size: 30px; letter-spacing: -0.04em; margin: 8px 0; }
.metric small { color: var(--muted); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
label { display: grid; gap: 7px; color: var(--navy); font-weight: 800; font-size: 13px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 13px;
  padding: 11px 12px;
  outline: none;
  transition: border .16s ease, box-shadow .16s ease;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(29,78,216,.12);
}
.wide { grid-column: 1 / -1; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.actions.vertical { display: grid; }
.btn {
  border: 0;
  border-radius: 13px;
  padding: 11px 15px;
  font-weight: 800;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, var(--blue), #2563eb); color: #fff; box-shadow: 0 14px 30px rgba(29,78,216,.22); }
.btn.secondary { background: var(--blue-soft); color: #1e40af; }
.btn.ghost { background: #f1f5f9; color: var(--navy); }
.btn.danger { background: #fee2e2; color: #991b1b; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}
.pill.ok { background: #dcfce7; color: #166534; }
.pill.warn { background: #fef3c7; color: #92400e; }

.checklist { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.7; }
.checklist li::marker { color: var(--teal); }

.summary-card { position: sticky; top: 24px; }
.summary-row, .summary-total {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.summary-row span { color: var(--muted); }
.summary-total {
  border-bottom: 0;
  margin-top: 8px;
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--navy), #172554);
  color: #fff;
}
.summary-total strong { font-size: 25px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 18px; }
table { width: 100%; border-collapse: collapse; min-width: 840px; background: #fff; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; vertical-align: middle; }
th { background: #f8fafc; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; }
tr:last-child td { border-bottom: 0; }
.items-table input, .items-table select { min-width: 90px; padding: 9px; }
.items-table .name { min-width: 190px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

.alert {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: #eff6ff;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
  font-weight: 700;
  white-space: pre-wrap;
}
.alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.hidden { display: none !important; }

.customer-list { display: grid; gap: 12px; }
.customer-card {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.customer-card strong { display: block; color: var(--navy); }
.customer-card small { color: var(--muted); }

.palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0; }
.palette span {
  min-height: 92px;
  border-radius: 18px;
  display: flex;
  align-items: end;
  padding: 12px;
  background: var(--swatch);
  color: #fff;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.palette span:nth-child(4) { color: var(--navy); }

.sms-box {
  margin: 18px 0;
  padding: 16px;
  border-radius: 18px;
  border: 1px dashed #93c5fd;
  background: #eff6ff;
}

dialog {
  width: min(980px, calc(100vw - 30px));
  border: 0;
  border-radius: 22px;
  box-shadow: 0 30px 100px rgba(15,23,42,.35);
  padding: 0;
}
dialog::backdrop { background: rgba(15,23,42,.55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
#modalContent { margin: 0; padding: 20px; max-height: 70vh; overflow: auto; background: #0f172a; color: #e2e8f0; white-space: pre-wrap; font-size: 13px; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .nav { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .metrics, .two, .invoice-layout, .form-grid.three, .form-grid.four { grid-template-columns: 1fr 1fr; }
  .summary-card { position: static; }
}

@media (max-width: 720px) {
  .main { padding: 18px; }
  .topbar { align-items: flex-start; flex-direction: column; gap: 14px; }
  .nav, .metrics, .two, .invoice-layout, .form-grid, .form-grid.three, .form-grid.four { grid-template-columns: 1fr; }
  .palette { grid-template-columns: 1fr 1fr; }
}

.app-hidden { display: none !important; }
.btn:disabled { opacity: .48; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(20,184,166,.18), transparent 28rem),
    radial-gradient(circle at 80% 0%, rgba(29,78,216,.24), transparent 34rem),
    linear-gradient(135deg, #0f172a 0%, #111827 44%, #172554 100%);
}
.login-card {
  width: min(560px, 100%);
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 28px;
  padding: 34px;
  box-shadow: 0 34px 120px rgba(0,0,0,.36);
}
.login-brand { margin-bottom: 26px; color: var(--navy); }
.login-card h1 { margin-bottom: 12px; font-size: clamp(30px, 5vw, 48px); }
.login-form { margin-top: 22px; }
.login-submit { width: 100%; margin-top: 18px; padding: 14px 18px; }
.login-note { display: block; margin-top: 14px; color: var(--muted); text-align: center; }
.quick-login { display: flex; gap: 8px; margin-top: 12px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
}

.feedback-modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 12, 24, .62);
  backdrop-filter: blur(3px);
}
.feedback-card {
  width: min(416px, 100%);
  min-height: 318px;
  border-radius: 5px;
  background: #1d1d2d;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 38px 28px;
  box-shadow: 0 30px 100px rgba(0,0,0,.45);
}
.feedback-ring {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 3px solid rgba(34,197,94,.35);
  border-top-color: #4ade80;
  margin-bottom: 18px;
  animation: feedback-spin .75s linear 1;
  position: relative;
}
.feedback-ring::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 32px;
  border: solid #4ade80;
  border-width: 0 4px 4px 0;
  left: 25px;
  top: 14px;
  transform: rotate(45deg);
}
.feedback-card h2 { color: #fff; margin: 4px 0 16px; font-size: 18px; letter-spacing: 0; }
.feedback-card p { color: #c9c9d7; line-height: 1.6; margin-bottom: 28px; white-space: pre-wrap; }
.feedback-card .btn { min-width: 50px; border-radius: 4px; background: #6d5dfc; box-shadow: none; }
.feedback-modal.error .feedback-ring { border-color: rgba(239,68,68,.32); border-top-color: #f87171; }
.feedback-modal.error .feedback-ring::after {
  width: 36px;
  height: 4px;
  border: 0;
  background: #f87171;
  left: 16px;
  top: 33px;
  transform: rotate(45deg);
  box-shadow: 0 0 0 0 #f87171;
}
.feedback-modal.error .feedback-ring::before {
  content: '';
  position: absolute;
  width: 36px;
  height: 4px;
  background: #f87171;
  left: 16px;
  top: 33px;
  transform: rotate(-45deg);
}
.feedback-modal.warn .feedback-ring { border-color: rgba(245,158,11,.32); border-top-color: #fbbf24; }
.feedback-modal.warn .feedback-ring::after {
  content: '!';
  border: 0;
  color: #fbbf24;
  font-size: 42px;
  font-weight: 800;
  left: 26px;
  top: 8px;
  width: auto;
  height: auto;
  transform: none;
}
@keyframes feedback-spin { from { transform: rotate(-40deg); opacity: .4; } to { transform: rotate(0); opacity: 1; } }

.settings-readout { display: grid; gap: 10px; margin: 18px 0; }
.settings-readout div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.settings-readout span { color: var(--muted); font-weight: 700; }
.settings-readout strong { color: var(--navy); }
.compact-list { font-size: 13px; }

@media (max-width: 720px) {
  .login-card { padding: 24px; }
  .feedback-card { min-height: 280px; }
}

.small-status {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
}
.error-text { color: var(--red) !important; }
