/* ================================================================
   BIZAPP v4 — app.css
   Sharp, premium, functional. Light + Dark.
   System font stack — no Google Fonts dependency.
   ================================================================ */

/* ── FONT STACK — system fonts render crisply everywhere ── */
:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
          Arial, "Noto Sans", sans-serif, "Apple Color Emoji";
  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Code",
               "Consolas", "Courier New", monospace;
}

/* ── LIGHT MODE ── */
:root {
  --bg:          #f5f6fa;
  --surface:     #ffffff;
  --surface2:    #f8f9fb;
  --surface3:    #eef0f5;
  --border:      #e3e6ef;
  --border2:     #cdd1de;
  --border3:     #b8bdd0;

  --gold:        #d97706;
  --gold-light:  #fef3c7;
  --gold-mid:    #f59e0b;
  --teal:        #0d9488;
  --teal-light:  #ccfbf1;
  --coral:       #dc2626;
  --coral-light: #fee2e2;
  --amber:       #d97706;
  --amber-light: #fef3c7;
  --sky:         #2563eb;
  --sky-light:   #dbeafe;
  --green:       #16a34a;
  --green-light: #dcfce7;
  --purple:      #7c3aed;
  --purple-light:#ede9fe;
  --orange:      #ea580c;
  --orange-light:#ffedd5;

  --text:        #0f172a;
  --text-2:      #334155;
  --text-3:      #64748b;
  --text-4:      #94a3b8;

  --sidebar-bg:    #0f172a;
  --sidebar-s2:    #1e293b;
  --sidebar-bdr:   #1e293b;
  --sidebar-text:  #94a3b8;
  --sidebar-hover: #1e293b;
  --sidebar-gold:  #f59e0b;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --sidebar-w:  264px;
  --topbar-h:   60px;

  --shadow-xs: 0 1px 2px rgba(15,23,42,0.06);
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.1), 0 1px 2px rgba(15,23,42,0.06);
  --shadow:    0 4px 6px rgba(15,23,42,0.07), 0 2px 4px rgba(15,23,42,0.05);
  --shadow-md: 0 10px 15px rgba(15,23,42,0.1), 0 4px 6px rgba(15,23,42,0.05);
  --shadow-lg: 0 20px 25px rgba(15,23,42,0.1), 0 10px 10px rgba(15,23,42,0.04);
  --shadow-xl: 0 25px 50px rgba(15,23,42,0.25);
}

/* ── DARK MODE ── */
[data-theme="dark"] {
  --bg:          #0a0c12;
  --surface:     #111318;
  --surface2:    #181b23;
  --surface3:    #1f2330;
  --border:      #1f2330;
  --border2:     #282d3d;
  --border3:     #333849;

  --gold:        #f59e0b;
  --gold-light:  rgba(245,158,11,0.12);
  --gold-mid:    #fbbf24;
  --teal:        #2dd4bf;
  --teal-light:  rgba(45,212,191,0.12);
  --coral:       #f87171;
  --coral-light: rgba(248,113,113,0.12);
  --amber:       #fbbf24;
  --amber-light: rgba(251,191,36,0.12);
  --sky:         #60a5fa;
  --sky-light:   rgba(96,165,250,0.12);
  --green:       #4ade80;
  --green-light: rgba(74,222,128,0.12);
  --purple:      #a78bfa;
  --purple-light:rgba(167,139,250,0.12);
  --orange:      #fb923c;
  --orange-light:rgba(251,146,60,0.12);

  --text:        #f1f5f9;
  --text-2:      #94a3b8;
  --text-3:      #475569;
  --text-4:      #1e293b;

  --sidebar-bg:    #080a0e;
  --sidebar-s2:    #0f1117;
  --sidebar-bdr:   #151820;
  --sidebar-text:  #64748b;
  --sidebar-hover: #0f1117;
  --sidebar-gold:  #f59e0b;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.4);
  --shadow:    0 4px 12px rgba(0,0,0,0.5);
  --shadow-md: 0 8px 20px rgba(0,0,0,0.5);
  --shadow-lg: 0 16px 32px rgba(0,0,0,0.6);
  --shadow-xl: 0 24px 48px rgba(0,0,0,0.7);
}

/* ── RESET ── */
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html { font-size:16px; -webkit-text-size-adjust:100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
a { color:inherit; text-decoration:none; }
button { font-family:inherit; }
img { max-width:100%; display:block; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top:0; left:0; height:100vh;
  z-index:200;
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}

.sidebar-brand {
  display:flex; align-items:center; gap:10px;
  padding:14px 16px;
  border-bottom:1px solid var(--sidebar-bdr);
  min-height:56px;
}

.brand-icon {
  width:34px; height:34px;
  background:linear-gradient(135deg,#d97706,#f59e0b);
  border-radius:8px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
  box-shadow:0 2px 8px rgba(245,158,11,0.35);
  font-size:15px; color:#1c0f00; font-weight:900; letter-spacing:-1px;
}
.brand-logo {
  width:34px; height:34px; border-radius:8px;
  object-fit:contain; border:1px solid var(--sidebar-bdr);
}
.brand-name { font-size:14px; font-weight:700; color:#f8fafc; letter-spacing:-0.3px; line-height:1.2; }
.brand-tag  { font-size:12px; color:#64748b; font-weight:500; letter-spacing:0.3px; }

.sidebar-nav { flex:1; padding:10px; overflow-y:auto; scrollbar-width:none; }
.sidebar-nav::-webkit-scrollbar { display:none; }

.nav-section-label {
  font-size:11.5px; text-transform:uppercase; letter-spacing:1.2px;
  color:#475569; font-weight:600; padding:14px 8px 4px;
}

.nav-item {
  display:flex; align-items:center; gap:9px;
  padding:9px 11px; border-radius:var(--radius);
  color:var(--sidebar-text); font-size:14px; font-weight:500;
  transition:background 0.12s,color 0.12s;
  cursor:pointer; margin-bottom:1px;
  text-decoration:none;
}
.nav-item:hover  { background:var(--sidebar-hover); color:#cbd5e1; }
.nav-item.active {
  background:rgba(245,158,11,0.12);
  color:var(--sidebar-gold);
  font-weight:600;
  box-shadow:inset 2px 0 0 var(--sidebar-gold);
}
.nav-icon { width:18px; height:18px; display:flex; align-items:center; justify-content:center; flex-shrink:0; opacity:0.7; }
.nav-icon svg { width:15px; height:15px; stroke:currentColor; stroke-width:1.75; fill:none; stroke-linecap:round; stroke-linejoin:round; }
.nav-item.active .nav-icon { opacity:1; }
.nav-badge {
  margin-left:auto; background:var(--coral); color:#fff;
  font-size:11px; font-weight:700; padding:2px 7px; border-radius:10px; line-height:1.6;
}

.sidebar-footer { padding:8px; border-top:1px solid var(--sidebar-bdr); }
.user-pill {
  display:flex; align-items:center; gap:9px;
  padding:9px 10px; background:var(--sidebar-s2);
  border-radius:var(--radius); cursor:default;
}
.user-avatar {
  width:32px; height:32px; border-radius:8px;
  background:linear-gradient(135deg,#d97706,#0d9488);
  display:flex; align-items:center; justify-content:center;
  font-size:13px; font-weight:800; color:#fff; flex-shrink:0;
  letter-spacing:-0.5px;
}
.user-name { font-size:13px; font-weight:600; color:#e2e8f0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-role { font-size:12px; color:#64748b; text-transform:capitalize; }
.user-info { flex:1; min-width:0; }
.logout-btn {
  color:var(--sidebar-text); display:flex; align-items:center;
  padding:5px; border-radius:6px; border:none; background:none; cursor:pointer;
  transition:color 0.12s,background 0.12s;
}
.logout-btn:hover { color:var(--coral); background:rgba(220,38,38,0.1); }
.logout-btn svg { width:14px; height:14px; stroke:currentColor; fill:none; stroke-width:2; }

/* ── MAIN ── */
.main-wrapper { margin-left:var(--sidebar-w); flex:1; display:flex; flex-direction:column; min-height:100vh; }

/* ── TOPBAR ── */
.topbar {
  height:var(--topbar-h);
  background:var(--surface);
  border-bottom:1px solid var(--border);
  display:flex; align-items:center; gap:14px; padding:0 24px;
  position:sticky; top:0; z-index:100;
  box-shadow:var(--shadow-xs);
}
.sidebar-toggle {
  display:none; background:var(--surface2); border:1px solid var(--border);
  border-radius:var(--radius-sm); color:var(--text-2);
  width:32px; height:32px; cursor:pointer; align-items:center; justify-content:center;
  transition:background 0.12s;
}
.sidebar-toggle:hover { background:var(--surface3); }
.sidebar-toggle svg { width:16px; height:16px; stroke:currentColor; fill:none; stroke-width:2; }
.topbar-title { font-size:16px; font-weight:700; flex:1; color:var(--text); letter-spacing:-0.3px; }
.topbar-right { display:flex; align-items:center; gap:8px; }
.topbar-date  { color:var(--text-3); font-size:14px; font-weight:500; }

.theme-toggle {
  width:32px; height:32px; background:var(--surface2); border:1px solid var(--border);
  border-radius:var(--radius-sm); cursor:pointer; display:flex; align-items:center; justify-content:center;
  color:var(--text-2); transition:all 0.12s;
}
.theme-toggle:hover { background:var(--surface3); color:var(--gold); border-color:var(--border2); }
.theme-toggle svg { width:15px; height:15px; stroke:currentColor; fill:none; stroke-width:2; }

.overdue-pill {
  display:flex; align-items:center; gap:5px;
  background:var(--coral-light); border:1px solid rgba(220,38,38,0.2);
  color:var(--coral); font-size:12px; font-weight:700;
  padding:5px 12px; border-radius:20px; text-decoration:none;
  transition:background 0.12s; white-space:nowrap;
}
.overdue-pill:hover { background:rgba(220,38,38,0.2); }
.overdue-pill svg { width:11px; height:11px; stroke:currentColor; fill:none; stroke-width:2.5; }

/* ── PAGE CONTENT ── */
.page-content {
  flex:1; padding:24px 28px;
  max-width:1440px; width:100%;
  animation:fadeUp 0.2s ease;
}
@keyframes fadeUp { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }

/* ── FLASH BANNER (page-level) ── */
.flash-wrap { padding:12px 24px 0; }
.flash {
  display:flex; align-items:center; gap:10px;
  padding:11px 16px; border-radius:var(--radius);
  font-size:13px; font-weight:500;
  border:1px solid; animation:slideDown 0.2s ease;
}
.flash svg { width:15px; height:15px; flex-shrink:0; stroke:currentColor; fill:none; stroke-width:2; }
@keyframes slideDown { from{opacity:0;transform:translateY(-4px)} to{opacity:1;transform:translateY(0)} }
.flash-success { background:var(--green-light); border-color:rgba(22,163,74,0.25); color:var(--green); }
.flash-error   { background:var(--coral-light); border-color:rgba(220,38,38,0.25); color:var(--coral); }
.flash-info    { background:var(--sky-light);   border-color:rgba(37,99,235,0.2);  color:var(--sky); }
.flash-warning { background:var(--amber-light); border-color:rgba(217,119,6,0.25); color:var(--amber); }
.flash-close { background:none; border:none; color:inherit; cursor:pointer; font-size:18px; opacity:0.5; line-height:1; margin-left:auto; }

/* ── TOAST (instant in-page feedback) ── */
#toast-container {
  position:fixed; bottom:20px; right:20px; z-index:9999;
  display:flex; flex-direction:column; gap:8px; max-width:340px;
  pointer-events:none;
}
.toast {
  display:flex; align-items:flex-start; gap:10px;
  padding:12px 14px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-lg);
  font-size:13px;
  pointer-events:all;
  animation:toastIn 0.22s cubic-bezier(0.34,1.4,0.64,1);
  transition:opacity 0.25s,transform 0.25s;
}
.toast.out { opacity:0; transform:translateX(20px); }
@keyframes toastIn { from{opacity:0;transform:translateX(24px) scale(0.96)} to{opacity:1;transform:none} }

.toast-icon { font-size:16px; line-height:1.4; flex-shrink:0; }
.toast-body { flex:1; min-width:0; }
.toast-title { font-weight:700; font-size:13px; line-height:1.3; color:var(--text); }
.toast-msg   { font-size:13px; color:var(--text-2); margin-top:2px; line-height:1.4; }
.toast-close { background:none; border:none; color:var(--text-3); cursor:pointer; font-size:16px; padding:0 0 0 4px; line-height:1; flex-shrink:0; }
.toast-close:hover { color:var(--text); }

.toast.toast-success { border-left:3px solid var(--green); }
.toast.toast-error   { border-left:3px solid var(--coral); }
.toast.toast-warning { border-left:3px solid var(--amber); }
.toast.toast-info    { border-left:3px solid var(--sky); }

/* ── PROGRESS BAR ── */
#progress-bar {
  position:fixed; top:0; left:0; height:2px; width:0%;
  background:linear-gradient(90deg,var(--gold),var(--teal));
  z-index:9999; transition:width 0.3s; border-radius:0 1px 1px 0;
  box-shadow:0 0 6px rgba(245,158,11,0.6);
}

/* ── LOADING OVERLAY ── */
.loading-overlay {
  position:fixed; inset:0; background:rgba(0,0,0,0.35); backdrop-filter:blur(2px);
  z-index:8888; display:flex; align-items:center; justify-content:center;
  opacity:0; transition:opacity 0.18s; pointer-events:none;
}
.loading-overlay.active { opacity:1; pointer-events:all; }
.loading-spinner { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-xl); padding:22px 30px; display:flex; flex-direction:column; align-items:center; gap:12px; box-shadow:var(--shadow-xl); }
.spinner-ring { width:36px; height:36px; border:3px solid var(--border2); border-top-color:var(--gold); border-radius:50%; animation:spin 0.65s linear infinite; }
@keyframes spin { to{transform:rotate(360deg)} }
.spinner-label { font-size:13px; font-weight:600; color:var(--text-2); }

/* ── BTN LOADING ── */
.btn.is-loading { pointer-events:none; opacity:0.7; }
.btn.is-loading::after {
  content:''; position:absolute; right:10px; top:50%; width:12px; height:12px;
  margin-top:-6px; border:2px solid rgba(255,255,255,0.35); border-top-color:#fff;
  border-radius:50%; animation:spin 0.55s linear infinite;
}
.btn { position:relative; }

/* ── PAGE HEADER ── */
.page-header {
  display:flex; align-items:flex-start; justify-content:space-between;
  margin-bottom:24px; gap:12px; flex-wrap:wrap;
}
.page-header h1 { font-size:24px; font-weight:800; letter-spacing:-0.5px; color:var(--text); line-height:1.25; }
.page-header p  { color:var(--text-2); font-size:14px; margin-top:4px; line-height:1.5; font-weight:500; }

/* ── STAT CARDS ── */
.stats-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:14px; margin-bottom:22px; }
.stat-card {
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:20px 22px;
  position:relative; overflow:hidden;
  transition:box-shadow 0.15s, transform 0.15s;
  box-shadow:var(--shadow-xs);
}
.stat-card:hover { box-shadow:var(--shadow); transform:translateY(-1px); }
.stat-card::before {
  content:''; position:absolute; left:0; top:0; bottom:0; width:3px;
  background:var(--card-accent,var(--gold));
  border-radius:3px 0 0 3px;
}
.stat-card.teal   { --card-accent:var(--teal); }
.stat-card.coral  { --card-accent:var(--coral); }
.stat-card.sky    { --card-accent:var(--sky); }
.stat-card.green  { --card-accent:var(--green); }
.stat-card.amber  { --card-accent:var(--amber); }
.stat-card.purple { --card-accent:var(--purple); }
.stat-card.orange { --card-accent:var(--orange); }

.stat-icon { position:absolute; right:14px; top:14px; opacity:0.08; }
.stat-icon svg { width:32px; height:32px; stroke:var(--text); fill:none; stroke-width:1.5; }

.stat-label { font-size:12px; text-transform:uppercase; letter-spacing:0.8px; color:var(--text-2); font-weight:700; margin-bottom:6px; }
.stat-value { font-size:28px; font-weight:800; line-height:1; color:var(--text); margin-bottom:4px; letter-spacing:-0.8px; font-variant-numeric:tabular-nums; }
.stat-value.teal   { color:var(--teal); }
.stat-value.coral  { color:var(--coral); }
.stat-value.green  { color:var(--green); }
.stat-value.amber  { color:var(--amber); }
.stat-value.sky    { color:var(--sky); }
.stat-value.purple { color:var(--purple); }
.stat-sub { font-size:12.5px; color:var(--text-3); font-weight:500; }

/* ── CARDS ── */
.card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); padding:20px 22px; box-shadow:var(--shadow-xs); }
.card-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; gap:10px; }
.card-title  { font-size:15px; font-weight:700; color:var(--text); letter-spacing:-0.2px; display:flex; align-items:center; gap:7px; }
.card-title svg { width:15px; height:15px; stroke:currentColor; fill:none; stroke-width:2; opacity:0.6; }
.card-sub    { color:var(--text-2); font-size:13px; }

/* Tinted card variants */
.card-gold   { border-left:3px solid var(--gold);   background:linear-gradient(135deg,var(--gold-light) 0%,var(--surface) 50%); }
.card-teal   { border-left:3px solid var(--teal);   background:linear-gradient(135deg,var(--teal-light) 0%,var(--surface) 50%); }
.card-coral  { border-left:3px solid var(--coral);  background:linear-gradient(135deg,var(--coral-light) 0%,var(--surface) 50%); }
.card-sky    { border-left:3px solid var(--sky);    background:linear-gradient(135deg,var(--sky-light) 0%,var(--surface) 50%); }
.card-green  { border-left:3px solid var(--green);  background:linear-gradient(135deg,var(--green-light) 0%,var(--surface) 50%); }

/* ── LAYOUT ── */
.grid-2 { display:grid; grid-template-columns:repeat(auto-fit,minmax(300px,1fr)); gap:16px; }
.grid-3 { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:12px; }
.grid-4 { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:12px; }
.mt-1 {margin-top:10px} .mt-2 {margin-top:14px} .mt-3 {margin-top:20px}
.mb-1 {margin-bottom:10px} .mb-2 {margin-bottom:14px} .mb-3 {margin-bottom:20px}

/* ── BUTTONS ── */
.btn {
  display:inline-flex; align-items:center; justify-content:center;
  gap:6px; padding:8px 14px;
  border-radius:var(--radius); font-family:var(--font);
  font-size:14px; font-weight:600; cursor:pointer;
  border:1px solid transparent; transition:all 0.12s ease;
  white-space:nowrap; text-decoration:none; letter-spacing:-0.1px;
  -webkit-tap-highlight-color:transparent;
}
.btn svg { width:14px; height:14px; stroke:currentColor; fill:none; stroke-width:2; flex-shrink:0; }
.btn:hover { transform:translateY(-1px); }
.btn:active { transform:scale(0.98); }

.btn-primary  { background:var(--gold); color:#fff; box-shadow:0 1px 3px rgba(217,119,6,0.4); }
.btn-primary:hover { background:#b45309; box-shadow:0 3px 8px rgba(217,119,6,0.4); }

.btn-teal     { background:var(--teal); color:#fff; box-shadow:0 1px 3px rgba(13,148,136,0.35); }
.btn-teal:hover { background:#0f766e; }

.btn-sky      { background:var(--sky); color:#fff; box-shadow:0 1px 3px rgba(37,99,235,0.3); }
.btn-sky:hover { background:#1d4ed8; }

.btn-green    { background:var(--green); color:#fff; box-shadow:0 1px 3px rgba(22,163,74,0.3); }

.btn-secondary { background:var(--surface2); color:var(--text); border-color:var(--border); }
.btn-secondary:hover { background:var(--surface3); border-color:var(--border2); }

.btn-danger   { background:var(--coral-light); color:var(--coral); border-color:rgba(220,38,38,0.2); }
.btn-danger:hover { background:rgba(220,38,38,0.2); }

.btn-ghost    { background:transparent; color:var(--text-2); border-color:var(--border); }
.btn-ghost:hover { background:var(--surface2); color:var(--text); }

.btn-sm  { padding:6px 11px; font-size:13px; border-radius:var(--radius-sm); gap:4px; }
.btn-sm svg { width:12px; height:12px; }
.btn-lg  { padding:11px 22px; font-size:15px; border-radius:var(--radius-lg); }
.btn-xl  { padding:13px 26px; font-size:15px; border-radius:var(--radius-lg); font-weight:700; }
.btn-block { width:100%; }
.btn-icon { padding:6px; width:32px; height:32px; }

/* ── TABLE ── */
.table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; }
.data-table { width:100%; border-collapse:collapse; font-size:14px; }
.data-table thead th {
  text-align:left; padding:10px 14px; color:var(--text-3);
  font-size:12.5px; text-transform:uppercase; letter-spacing:0.6px;
  font-weight:700; background:var(--surface2);
  border-bottom:2px solid var(--border); white-space:nowrap;
}
.data-table thead th:first-child { border-radius:var(--radius-sm) 0 0 0; }
.data-table thead th:last-child  { border-radius:0 var(--radius-sm) 0 0; }
.data-table tbody td { padding:12px 14px; border-bottom:1px solid var(--border); vertical-align:middle; color:var(--text); }
.data-table tbody tr:last-child td { border-bottom:none; }
.data-table tbody tr:hover td { background:var(--surface2); }
.td-bold  { font-weight:600 !important; color:var(--text) !important; }
.td-mono  { font-family:var(--font-mono); font-size:12.5px; color:var(--text-2) !important; letter-spacing:0.2px; }
.td-right { text-align:right; }

/* ── BADGES ── */
.badge {
  display:inline-flex; align-items:center; gap:4px;
  padding:4px 10px; border-radius:4px;
  font-size:12.5px; font-weight:700; letter-spacing:0.2px;
  text-transform:capitalize; white-space:nowrap;
  border:1px solid transparent;
}
.badge svg { width:9px; height:9px; stroke:currentColor; fill:none; stroke-width:2.5; }
.badge-draft   { background:var(--surface3); color:var(--text-3); border-color:var(--border2); }
.badge-sent    { background:var(--sky-light);    color:var(--sky);    border-color:rgba(37,99,235,0.2); }
.badge-success { background:var(--green-light);  color:var(--green);  border-color:rgba(22,163,74,0.2); }
.badge-danger  { background:var(--coral-light);  color:var(--coral);  border-color:rgba(220,38,38,0.2); }
.badge-warning { background:var(--amber-light);  color:var(--amber);  border-color:rgba(217,119,6,0.2); }
.badge-info    { background:var(--teal-light);   color:var(--teal);   border-color:rgba(13,148,136,0.2); }
.badge-muted   { background:var(--surface3);     color:var(--text-3); }
.badge-purple  { background:var(--purple-light); color:var(--purple); border-color:rgba(124,58,237,0.2); }
.badge-gold    { background:var(--gold-light);   color:var(--gold);   border-color:rgba(217,119,6,0.2); }

/* ── FORMS ── */
.form-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:14px; }
.form-group { display:flex; flex-direction:column; gap:4px; }
.form-group.full { grid-column:1/-1; }
.form-group label { font-size:12.5px; font-weight:700; text-transform:uppercase; letter-spacing:0.6px; color:var(--text-2); }
.form-group input,
.form-group textarea,
.form-group select {
  background:var(--surface); border:1.5px solid var(--border2);
  border-radius:var(--radius); padding:10px 12px;
  color:var(--text); font-family:var(--font); font-size:14px;
  outline:none; transition:border-color 0.12s,box-shadow 0.12s;
  width:100%; line-height:1.4;
  -webkit-appearance:none; appearance:none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color:var(--gold); box-shadow:0 0 0 3px rgba(217,119,6,0.1); }
.form-group input::placeholder { color:var(--text-4); font-style:normal; }
.form-group textarea { resize:vertical; min-height:80px; }
.form-group select { cursor:pointer; padding-right:28px;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 10px center; }
.form-group input[type="date"] { color-scheme:light dark; }
.form-group input[type="file"] { padding:6px; cursor:pointer; border-style:dashed; }
.form-group input[type="file"]:hover { border-color:var(--gold); background:var(--gold-light); }
.form-hint  { font-size:12px; color:var(--text-2); line-height:1.4; }
.form-error { font-size:12px; color:var(--coral); font-weight:600; }

/* Input with prefix */
.input-wrap { position:relative; }
.input-prefix { position:absolute; left:10px; top:50%; transform:translateY(-50%); color:var(--text-3); font-size:12px; font-weight:700; pointer-events:none; }
.input-wrap input { padding-left:32px; }

/* Line items */
.items-table { width:100%; border-collapse:collapse; font-size:13px; }
.items-table th { text-align:left; padding:7px 8px; color:var(--text-3); font-size:10.5px; text-transform:uppercase; letter-spacing:0.7px; border-bottom:2px solid var(--border); font-weight:700; background:var(--surface2); }
.items-table td { padding:4px 3px; vertical-align:middle; }
.items-table input { background:var(--surface); border:1.5px solid var(--border); border-radius:var(--radius-sm); padding:7px 9px; color:var(--text); font-size:13px; width:100%; outline:none; transition:border-color 0.12s; }
.items-table input:focus { border-color:var(--gold); box-shadow:0 0 0 2px rgba(217,119,6,0.08); }
.remove-row-btn { background:none; border:none; color:var(--text-3); cursor:pointer; font-size:18px; padding:4px 8px; border-radius:var(--radius-sm); transition:all 0.12s; line-height:1; }
.remove-row-btn:hover { color:var(--coral); background:var(--coral-light); }

.totals-box { background:var(--surface2); border:1.5px solid var(--border2); border-radius:var(--radius); padding:12px 16px; max-width:300px; margin-left:auto; }
.totals-row { display:flex; justify-content:space-between; align-items:center; padding:5px 0; font-size:14px; color:var(--text-2); }
.totals-row.total { border-top:1.5px solid var(--border2); margin-top:6px; padding-top:11px; color:var(--text); font-weight:800; font-size:17px; }
.totals-row .amount { font-weight:600; color:var(--text); font-variant-numeric:tabular-nums; }
.totals-row.total .amount { color:var(--gold); font-size:19px; }
.totals-row.wht   { color:var(--coral); }
.totals-row.net   { color:var(--teal); font-weight:800; }

/* Toggle switch */
.toggle { position:relative; width:38px; height:20px; background:var(--border2); border-radius:20px; cursor:pointer; transition:background 0.2s; border:none; outline:none; flex-shrink:0; }
.toggle::after { content:''; position:absolute; left:2px; top:2px; width:16px; height:16px; background:#fff; border-radius:50%; transition:transform 0.2s; box-shadow:0 1px 3px rgba(0,0,0,0.2); }
.toggle.on { background:var(--teal); }
.toggle.on::after { transform:translateX(18px); }

/* ── AUTH PAGE ── */
.auth-page {
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  background:var(--bg); padding:20px; position:relative; overflow:hidden;
}
.auth-page::before { content:''; position:absolute; top:-100px; right:-100px; width:400px; height:400px; background:radial-gradient(circle,rgba(217,119,6,0.06) 0%,transparent 70%); pointer-events:none; }
.auth-page::after  { content:''; position:absolute; bottom:-80px; left:-80px; width:300px; height:300px; background:radial-gradient(circle,rgba(13,148,136,0.05) 0%,transparent 70%); pointer-events:none; }
.auth-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-xl); padding:32px; width:100%; max-width:420px; box-shadow:var(--shadow-xl); position:relative; z-index:1; }
.auth-brand { text-align:center; margin-bottom:24px; }
.auth-brand .logo-wrap { width:52px; height:52px; background:linear-gradient(135deg,#d97706,#f59e0b); border-radius:14px; margin:0 auto 12px; display:flex; align-items:center; justify-content:center; font-size:22px; color:#1c0f00; box-shadow:0 4px 14px rgba(217,119,6,0.35); }
.auth-brand h1 { font-size:22px; font-weight:800; letter-spacing:-0.5px; }
.auth-brand p  { color:var(--text-2); font-size:13px; margin-top:3px; }

/* ── MISC ── */
.payment-bar-bg { height:5px; background:var(--surface3); border-radius:10px; overflow:hidden; }
.payment-bar-fill { height:100%; border-radius:10px; background:linear-gradient(90deg,var(--teal),var(--green)); transition:width 0.5s cubic-bezier(0.4,0,0.2,1); }
.payment-bar-wrap { margin-top:4px; }

.empty-state { text-align:center; padding:40px 20px; }
.empty-icon { width:52px; height:52px; background:var(--surface2); border:1.5px solid var(--border2); border-radius:12px; margin:0 auto 12px; display:flex; align-items:center; justify-content:center; }
.empty-icon svg { width:22px; height:22px; stroke:var(--text-3); fill:none; stroke-width:1.5; }
.empty-state h3 { font-size:15px; font-weight:700; margin-bottom:5px; color:var(--text); }
.empty-state p  { font-size:13px; margin-bottom:16px; color:var(--text-2); max-width:260px; margin-left:auto; margin-right:auto; }

.modal-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.4); backdrop-filter:blur(3px); z-index:500; align-items:center; justify-content:center; padding:16px; }
.modal-overlay.open { display:flex; }
.modal { background:var(--surface); border:1px solid var(--border2); border-radius:var(--radius-xl); padding:22px; width:100%; max-width:480px; box-shadow:var(--shadow-xl); animation:modalIn 0.18s ease; }
@keyframes modalIn { from{opacity:0;transform:scale(0.96) translateY(8px)} to{opacity:1;transform:none} }

.divider { border:none; border-top:1px solid var(--border); margin:14px 0; }
.footer  { padding:12px 24px; color:var(--text-3); font-size:11.5px; border-top:1px solid var(--border); text-align:center; }

.currency-badge { display:inline-block; padding:3px 8px; border-radius:4px; font-size:12px; font-weight:700; font-family:var(--font-mono); }
.currency-kes { background:var(--gold-light); color:var(--gold); }
.currency-usd { background:var(--green-light); color:var(--green); }

/* ── UTILS ── */
.text-gold  {color:var(--gold)!important}  .text-teal   {color:var(--teal)!important}
.text-coral {color:var(--coral)!important} .text-green  {color:var(--green)!important}
.text-amber {color:var(--amber)!important} .text-sky    {color:var(--sky)!important}
.text-muted {color:var(--text-2)!important}.text-dim    {color:var(--text-3)!important}
.text-right { text-align:right } .text-center { text-align:center }
.fw-bold  { font-weight:700!important } .fw-black { font-weight:800!important }
.d-flex   { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.flex-1   { flex:1 } .w-100 { width:100% }

::-webkit-scrollbar { width:5px; height:5px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border2); border-radius:10px; }
::-webkit-scrollbar-thumb:hover { background:var(--border3); }

/* ── RESPONSIVE ── */
@media (max-width:900px) {
  .sidebar { transform:translateX(-100%); box-shadow:none; }
  .sidebar.open { transform:translateX(0); box-shadow:var(--shadow-xl); }
  .main-wrapper { margin-left:0; }
  .sidebar-toggle { display:flex; }
  .topbar-date { display:none; }
  .page-content { padding:14px 16px; }
  .stats-grid { grid-template-columns:1fr 1fr; }
  .data-table { font-size:13px; }
  .data-table thead th,.data-table tbody td { padding:8px 10px; }
}
@media (max-width:580px) {
  .stats-grid { grid-template-columns:1fr; }
  .form-grid  { grid-template-columns:1fr; }
  .grid-2,.grid-3 { grid-template-columns:1fr; }
  .page-header { flex-direction:column; align-items:flex-start; }
  .auth-card  { padding:20px; }
  .btn-lg,.btn-xl { padding:10px 16px; font-size:13px; }
  #toast-container { bottom:10px; right:10px; left:10px; max-width:none; }
  .modal { margin:0; border-radius:var(--radius-lg); }
}
@media print {
  .sidebar,.topbar,.flash-wrap,#toast-container,#progress-bar,.btn:not(.print-keep){ display:none!important; }
  .main-wrapper { margin-left:0!important; }
  .page-content { padding:0!important; animation:none!important; }
  body { background:#fff; color:#000; }
  .card { box-shadow:none; border:1px solid #ddd; }
}
