@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

:root {
  --brand: #7F5BFF;
  --brand-2: color-mix(in srgb, var(--brand) 70%, #8b5cf6);
  --brand-soft: color-mix(in srgb, var(--brand) 12%, white);
  --brand-tint: color-mix(in srgb, var(--brand) 6%, white);
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --success: #059669;
  --danger:  #dc2626;
  --warning: #d97706;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow:    0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 12px 28px -8px rgba(15, 23, 42, 0.12), 0 6px 10px -6px rgba(15, 23, 42, 0.06);
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* ---- Surface tokens (override per theme) ---- */
  --bg-page:     var(--gray-50);
  --bg-surface:  #ffffff;
  --bg-elevated: #ffffff;
  --bg-subtle:   var(--gray-50);
  --text-strong: var(--gray-900);
  --text-body:   var(--gray-800);
  --text-muted:  var(--gray-500);
  --border:      var(--gray-200);
  --border-soft: var(--gray-100);
  --input-bg:    #ffffff;
}

[data-theme="dark"] {
  --brand-soft: color-mix(in srgb, var(--brand) 22%, #0f0f10);
  --brand-tint: color-mix(in srgb, var(--brand) 12%, #0a0a0b);
  /* True-black neutral scale — Linear / Vercel style */
  --gray-50:  #050505;
  --gray-100: #0e0e10;
  --gray-200: #1f1f22;
  --gray-300: #2a2a2f;
  --gray-400: #52525b;
  --gray-500: #71717a;
  --gray-600: #a1a1aa;
  --gray-700: #d4d4d8;
  --gray-800: #e4e4e7;
  --gray-900: #fafafa;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.7), 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow:    0 8px 18px -4px rgba(0, 0, 0, 0.8), 0 3px 8px -3px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 22px 40px -10px rgba(0, 0, 0, 0.85), 0 10px 18px -8px rgba(0, 0, 0, 0.6);

  /* Pure black page, near-black surfaces, neutral borders */
  --bg-page:     #000000;
  --bg-surface:  #0f0f10;
  --bg-elevated: #09090a;
  --bg-subtle:   #050505;
  --text-strong: #fafafa;
  --text-body:   #d4d4d8;
  --text-muted:  #71717a;
  --border:      #1f1f22;
  --border-soft: #18181a;
  --input-bg:    #09090a;
}

* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  background: var(--bg-page);
  color: var(--text-body);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv02","cv03","cv04","cv11";
}

/* ---------- Navbar ---------- */
.app-navbar {
  background: var(--bg-elevated) !important;
  border-bottom: 1px solid var(--border);
  padding: .65rem 1.25rem;
  box-shadow: var(--shadow-xs);
}
.app-navbar .navbar-brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--gray-900) !important;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.app-navbar .navbar-brand::before {
  content: '';
  width: 24px; height: 24px;
  background: var(--brand);
  border-radius: 7px;
  display: inline-block;
  box-shadow: inset 0 -8px 14px rgba(255,255,255,.22);
}
.app-navbar .nav-link {
  color: var(--gray-600) !important;
  font-weight: 500;
  font-size: .92rem;
  padding: .45rem .9rem !important;
  border-radius: 8px;
  transition: background-color .15s, color .15s;
}
.app-navbar .nav-link:hover { background: var(--gray-100); color: var(--gray-900) !important; }

/* ---------- Headings ---------- */
h1, h2, h3, h4, h5, h6 { color: var(--gray-900); letter-spacing: -0.01em; font-weight: 600; }
.h3, h1.h3 { font-weight: 700; letter-spacing: -0.02em; }
.text-muted { color: var(--gray-500) !important; }
.form-label { font-weight: 500; color: var(--gray-700); font-size: .85rem; margin-bottom: .35rem; }
.form-text { color: var(--gray-500); font-size: .8rem; }

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  background: var(--bg-surface);
  color: var(--text-body);
}
.card.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.card-header { background: var(--bg-surface); border-bottom: 1px solid var(--border); padding: 1rem 1.25rem; font-weight: 600; }

/* ---------- Buttons ---------- */
.btn { font-weight: 500; border-radius: 8px; padding: .5rem 1rem; transition: all .15s; }
.btn-primary { background: var(--brand); border-color: var(--brand); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.btn-primary:hover, .btn-primary:focus {
  background: var(--brand); border-color: var(--brand);
  filter: brightness(0.94);
  box-shadow: 0 4px 12px -2px color-mix(in srgb, var(--brand) 40%, transparent);
}
.btn-outline-secondary { color: var(--text-body); border-color: var(--border); background: var(--bg-surface); }
.btn-outline-secondary:hover { background: var(--bg-subtle); color: var(--text-strong); border-color: var(--border); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); background: transparent; }
.btn-outline-primary:hover { background: var(--brand); color: #fff; }
.btn-outline-danger { color: var(--danger); border-color: var(--border); background: var(--bg-surface); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { font-size: .82rem; padding: .35rem .7rem; border-radius: 7px; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--brand) 50%, transparent); }

/* ---------- Forms ---------- */
.form-control, .form-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .75rem;
  font-size: .92rem;
  background: var(--input-bg);
  transition: border-color .15s, box-shadow .15s;
  color: var(--text-strong);
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
.form-control::placeholder { color: var(--gray-400); }
.form-control-color { padding: .25rem; height: 40px; }

/* ---------- Tables ---------- */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-body);
  --bs-table-striped-color: var(--text-body);
  --bs-table-hover-color: var(--text-strong);
  --bs-table-hover-bg: var(--bg-subtle);
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text-body);
}
.table > :not(caption) > * > * { padding: .85rem 1rem; border-bottom-color: var(--border-soft); color: var(--text-body); }
.table > thead { background: var(--bg-subtle); }
.table > thead th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.table-light { --bs-table-bg: var(--bg-subtle); color: var(--text-body); }
.table-hover tbody tr:hover { background: var(--bg-subtle); }

/* ---------- Badges ---------- */
.badge {
  font-weight: 500;
  font-size: .72rem;
  letter-spacing: 0.02em;
  padding: .35em .65em;
  border-radius: 999px;
}
.bg-secondary { background: var(--gray-200) !important; color: var(--gray-700) !important; }
.bg-primary   { background: color-mix(in srgb, var(--brand) 12%, white) !important; color: var(--brand) !important; }
.bg-success   { background: #d1fae5 !important; color: #065f46 !important; }
.bg-warning   { background: #fef3c7 !important; color: #92400e !important; }
.bg-danger    { background: #fee2e2 !important; color: #991b1b !important; }

/* ---------- Alerts ---------- */
.alert {
  border: none;
  border-radius: var(--radius);
  padding: .8rem 1rem;
  font-weight: 500;
  font-size: .88rem;
}
.alert-success { background: #ecfdf5; color: #065f46; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-danger  { background: #fef2f2; color: #991b1b; }

/* ---------- Dashboard stat cards ---------- */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  box-shadow: var(--shadow-xs);
  color: var(--text-body);
}
.stat-card .stat-label {
  text-transform: uppercase;
  font-size: .72rem;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  font-weight: 600;
}
.stat-card .stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text-strong);
  letter-spacing: -0.02em;
}
.stat-card.danger  .stat-value { color: var(--danger); }
.stat-card.success .stat-value { color: var(--success); }
.stat-icon {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  margin-bottom: .35rem;
}
.stat-card.danger  .stat-icon { background: #fee2e2; color: var(--danger); }
.stat-card.success .stat-icon { background: #d1fae5; color: var(--success); }
.stat-card.warn    .stat-icon { background: #fef3c7; color: var(--warning); }

/* ---------- Auth / login layout ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.auth-side {
  background: linear-gradient(135deg, var(--brand) 0%, color-mix(in srgb, var(--brand) 70%, #000) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}
.auth-side::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(255,255,255,.15) 0%, transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,.1)  0%, transparent 40%);
  pointer-events: none;
}
.auth-side > * { position: relative; z-index: 1; }
.auth-side h1 { color: #fff; font-size: 2rem; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; }
.auth-side .lead { color: rgba(255,255,255,.85); font-size: 1.05rem; line-height: 1.55; }
.auth-side .brand-mark {
  width: 44px; height: 44px;
  background: rgba(255,255,255,.18);
  border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
  font-weight: 700;
  color: #fff;
}
.auth-form-wrap {
  display: flex; flex-direction: column; justify-content: center;
  padding: 3rem; max-width: 520px; width: 100%; margin: 0 auto;
}
@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { padding: 2rem; min-height: 220px; }
}

/* ---------- Invoice paper ---------- */
.invoice-paper {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}
.invoice-paper .accent-bar {
  height: 6px;
  background: linear-gradient(90deg, var(--brand), color-mix(in srgb, var(--brand) 60%, #fff));
}
.invoice-paper .inv-body { padding: 3rem; }
.inv-title {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--brand);
  margin: 0;
  line-height: 1;
}
.inv-meta {
  display: grid;
  grid-template-columns: 130px 1fr;
  row-gap: 6px;
  column-gap: 14px;
  font-size: .88rem;
  margin-top: 1rem;
}
.inv-meta dt { color: var(--gray-500); font-weight: 500; }
.inv-meta dd { margin: 0; color: var(--gray-900); font-weight: 500; }
.inv-section-title {
  text-transform: uppercase;
  font-size: .68rem;
  letter-spacing: .1em;
  color: var(--gray-400);
  font-weight: 600;
  margin-bottom: .5rem;
}
.inv-box {
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 1rem 1.15rem;
  background: var(--gray-50);
}
.inv-items {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .88rem;
}
.inv-items thead th {
  background: var(--gray-900);
  color: rgba(255,255,255,0.9);
  font-weight: 500;
  font-size: .7rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: .85rem .75rem;
  text-align: left;
}
.inv-items thead th.text-end { text-align: right; }
.inv-items thead th:first-child { border-radius: 10px 0 0 10px; }
.inv-items thead th:last-child  { border-radius: 0 10px 10px 0; }
.inv-items tbody td {
  padding: .9rem .75rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
}
.inv-items tfoot th {
  padding: .85rem .75rem;
  font-weight: 600;
  color: var(--gray-900);
  background: var(--gray-50);
}
.inv-totals { width: 100%; border-collapse: collapse; }
.inv-totals th, .inv-totals td {
  padding: .55rem .25rem;
  border-bottom: 1px solid var(--gray-100);
  font-size: .92rem;
}
.inv-totals th { color: var(--gray-600); font-weight: 500; text-align: left; }
.inv-totals td { text-align: right; color: var(--gray-900); font-weight: 500; }
.inv-totals .grand th, .inv-totals .grand td {
  background: var(--brand);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  padding: .9rem 1rem;
  border-bottom: none;
}
.inv-totals .grand th { border-top-left-radius: 10px; border-bottom-left-radius: 10px; }
.inv-totals .grand td { border-top-right-radius: 10px; border-bottom-right-radius: 10px; }
.amount-words {
  background: var(--brand-tint);
  border-left: 3px solid var(--brand);
  border-radius: 8px;
  padding: .85rem 1rem;
  margin-bottom: 1rem;
}
.amount-words .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--brand); font-weight: 600; }
.amount-words .value { font-weight: 600; color: var(--gray-900); margin-top: .15rem; }
.bank-box .label, .sig-box .label { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gray-500); font-weight: 600; }
.bank-grid { display: grid; grid-template-columns: 110px 1fr; row-gap: 4px; column-gap: 10px; font-size: .85rem; margin-top: .5rem; }
.bank-grid > div:nth-child(odd) { color: var(--gray-500); }
.sig-box { margin-top: 3rem; text-align: right; }
.sig-box .for { font-size: .78rem; color: var(--gray-500); }
.sig-box .name { font-weight: 600; color: var(--gray-900); margin-top: 3rem; padding-top: .35rem; border-top: 1px solid var(--gray-300); display: inline-block; min-width: 220px; }
.sig-box .designation { font-size: .8rem; color: var(--gray-500); }
.inv-footer-note { font-size: .78rem; color: var(--gray-400); text-align: center; margin-top: 2.5rem; padding-top: 1rem; border-top: 1px dashed var(--gray-200); }

/* ---------- Modals ---------- */
.modal-content { border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-body); }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); }
.btn-close { filter: var(--btn-close-filter, none); }
[data-theme="dark"] .btn-close { filter: invert(1) opacity(.8); }

/* ---------- Print ---------- */
@media print {
  body { background: #fff !important; }
  .no-print { display: none !important; }
  .invoice-paper { box-shadow: none !important; border: none !important; border-radius: 0 !important; }
  .invoice-paper .inv-body { padding: 1.5rem !important; }
  .inv-totals .grand th, .inv-totals .grand td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .inv-items thead th, .accent-bar { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .amount-words { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { color: inherit !important; text-decoration: none !important; }
}

.text-uppercase { letter-spacing: .03em; }
.container-fluid { padding-left: clamp(1rem, 4vw, 3rem); padding-right: clamp(1rem, 4vw, 3rem); }

/* ================================================================
   DARK THEME final overrides
   ================================================================ */
[data-theme="dark"] .invoice-paper {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(0,0,0,.05);
}
[data-theme="dark"] .invoice-paper .text-muted { color: #64748b !important; }
[data-theme="dark"] .invoice-paper h1,
[data-theme="dark"] .invoice-paper h2,
[data-theme="dark"] .invoice-paper h3,
[data-theme="dark"] .invoice-paper h4,
[data-theme="dark"] .invoice-paper h5,
[data-theme="dark"] .invoice-paper h6 { color: #0f172a; }
[data-theme="dark"] .invoice-paper .inv-box { background: #f8fafc; border-color: #e2e8f0; }
[data-theme="dark"] .invoice-paper .inv-totals th { color: #475569; }
[data-theme="dark"] .invoice-paper .inv-totals td { color: #0f172a; }
[data-theme="dark"] .invoice-paper .inv-totals th,
[data-theme="dark"] .invoice-paper .inv-totals td { border-bottom-color: #f1f5f9; }

[data-theme="dark"] .bg-secondary { background: #1f2a44 !important; color: #cbd5e1 !important; }
[data-theme="dark"] .bg-primary   { background: color-mix(in srgb, var(--brand) 22%, #131d33) !important; color: color-mix(in srgb, var(--brand) 70%, #fff) !important; }
[data-theme="dark"] .bg-success   { background: rgba(5, 150, 105, .18) !important; color: #6ee7b7 !important; }
[data-theme="dark"] .bg-warning   { background: rgba(217, 119, 6, .18) !important; color: #fcd34d !important; }
[data-theme="dark"] .bg-danger    { background: rgba(220, 38, 38, .18) !important; color: #fca5a5 !important; }

[data-theme="dark"] .alert-success { background: rgba(5, 150, 105, .14); color: #6ee7b7; }
[data-theme="dark"] .alert-warning { background: rgba(217, 119, 6, .14); color: #fcd34d; }
[data-theme="dark"] .alert-danger  { background: rgba(220, 38, 38, .14); color: #fca5a5; }

/* Override Bootstrap utility classes that hard-code white/light backgrounds.
   These are widely used across pages (card-header bg-white, table-light, etc.)
   and would otherwise look out of place in dark mode. */
[data-theme="dark"] .bg-white     { background-color: var(--bg-surface) !important; }
[data-theme="dark"] .bg-light     { background-color: var(--bg-subtle)  !important; color: var(--text-body); }
[data-theme="dark"] .text-dark    { color: var(--text-strong) !important; }
[data-theme="dark"] .text-black   { color: var(--text-strong) !important; }
[data-theme="dark"] .border       { border-color: var(--border) !important; }
[data-theme="dark"] .border-top,
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-start,
[data-theme="dark"] .border-end   { border-color: var(--border) !important; }
[data-theme="dark"] .rounded,
[data-theme="dark"] .rounded-3    { background-color: transparent; }

/* Bootstrap thead-light variant used in some lists */
[data-theme="dark"] .table > thead.table-light th,
[data-theme="dark"] thead.table-light th { background: var(--bg-subtle); color: var(--text-muted); }

/* ================================================================
   DARK MODE — premium polish
   richer ambient backgrounds, card depth, glowing accents
   ================================================================ */
/* Pure black body — no brand-tinted ambient gradients */
[data-theme="dark"] body { background: var(--bg-page); }
[data-theme="dark"] .app-main { background: transparent; }

/* Sidebar — pure near-black with a subtle right-edge highlight */
[data-theme="dark"] .app-sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.02);
}
[data-theme="dark"] .app-sidebar .nav-item-link.active {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--brand) 20%, transparent), color-mix(in srgb, var(--brand) 6%, transparent));
  color: color-mix(in srgb, var(--brand) 65%, #fff);
  box-shadow: inset 2px 0 0 var(--brand), 0 0 0 1px color-mix(in srgb, var(--brand) 22%, transparent);
}
[data-theme="dark"] .app-sidebar .nav-section { color: var(--text-muted); }
[data-theme="dark"] .app-sidebar .brand-mark {
  box-shadow: 0 4px 14px -2px color-mix(in srgb, var(--brand) 55%, transparent), inset 0 -8px 14px rgba(0,0,0,.3);
}

/* Cards — lifted with subtle border + glow on hover */
[data-theme="dark"] .card,
[data-theme="dark"] .stat-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), transparent 30%),
    var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.04) inset,
    var(--shadow-xs);
}
[data-theme="dark"] .card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-strong);
}
[data-theme="dark"] .stat-card:hover {
  box-shadow:
    0 1px 0 rgba(255,255,255,0.06) inset,
    0 12px 24px -8px rgba(0,0,0,0.55),
    0 0 0 1px color-mix(in srgb, var(--brand) 14%, transparent);
}

/* Stat card radial wash — make it slightly brighter in dark */
[data-theme="dark"] .stat-card::before {
  background: radial-gradient(circle at top right, color-mix(in srgb, var(--brand) 22%, transparent), transparent 65%);
}
[data-theme="dark"] .stat-card.danger::before  { background: radial-gradient(circle at top right, rgba(239, 68, 68, .22), transparent 65%); }
[data-theme="dark"] .stat-card.success::before { background: radial-gradient(circle at top right, rgba(16, 185, 129, .22), transparent 65%); }
[data-theme="dark"] .stat-card.warn::before    { background: radial-gradient(circle at top right, rgba(245, 158, 11, .22), transparent 65%); }

/* Stat icons — brighter pill in dark */
[data-theme="dark"] .stat-icon {
  background: color-mix(in srgb, var(--brand) 22%, var(--bg-surface));
  color: color-mix(in srgb, var(--brand) 60%, #fff);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--brand) 18%, transparent);
}
[data-theme="dark"] .stat-card.danger  .stat-icon { background: rgba(239, 68, 68, .18); color: #fca5a5; box-shadow: 0 0 0 1px rgba(239,68,68,.25); }
[data-theme="dark"] .stat-card.success .stat-icon { background: rgba(16, 185, 129, .18); color: #6ee7b7; box-shadow: 0 0 0 1px rgba(16,185,129,.25); }
[data-theme="dark"] .stat-card.warn    .stat-icon { background: rgba(245, 158, 11, .18); color: #fcd34d; box-shadow: 0 0 0 1px rgba(245,158,11,.25); }

/* Form inputs — refined dark fill, brand-tinted focus ring */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background: var(--input-bg);
  border-color: var(--border);
  color: var(--text-strong);
}
[data-theme="dark"] .form-control::placeholder { color: var(--text-muted); }
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background: var(--input-bg);
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 24%, transparent), 0 0 18px -4px color-mix(in srgb, var(--brand) 35%, transparent);
}

/* Buttons — primary button glows softly in dark */
[data-theme="dark"] .btn-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 92%, #fff), var(--brand));
  border-color: color-mix(in srgb, var(--brand) 85%, #000);
  box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset, 0 6px 16px -6px color-mix(in srgb, var(--brand) 55%, transparent);
}
[data-theme="dark"] .btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 1px 0 rgba(255,255,255,0.15) inset, 0 10px 24px -6px color-mix(in srgb, var(--brand) 65%, transparent);
}

/* Tables — alternating row hint + sharper header in dark */
[data-theme="dark"] .table > thead { background: var(--bg-subtle); }
[data-theme="dark"] .table > thead th { border-bottom-color: var(--border); }
[data-theme="dark"] .table-hover tbody tr:hover { background: rgba(255,255,255,0.03); }

/* Sidebar CTA new-invoice button — extra glow */
[data-theme="dark"] .app-sidebar .cta-new {
  box-shadow: 0 6px 18px -4px color-mix(in srgb, var(--brand) 55%, transparent), 0 1px 0 rgba(255,255,255,0.1) inset;
}
[data-theme="dark"] .app-sidebar .cta-new:hover {
  box-shadow: 0 10px 24px -4px color-mix(in srgb, var(--brand) 65%, transparent), 0 1px 0 rgba(255,255,255,0.12) inset;
}

/* Theme toggle hover */
[data-theme="dark"] .theme-toggle:hover { background: rgba(255,255,255,0.04); color: var(--text-strong); }

/* Hero card — punchier in dark */
[data-theme="dark"] .hero-card {
  background:
    radial-gradient(circle at 25% 30%, color-mix(in srgb, #fff 18%, transparent), transparent 50%),
    radial-gradient(circle at 80% 70%, color-mix(in srgb, var(--brand-2) 50%, transparent), transparent 50%),
    linear-gradient(120deg, var(--brand) 0%, var(--brand-2) 100%);
  box-shadow: 0 18px 40px -10px color-mix(in srgb, var(--brand) 55%, transparent), inset 0 1px 0 rgba(255,255,255,0.12);
}

/* Empty states + section titles in dark — keep readable */
[data-theme="dark"] .empty-state h5 { color: var(--text-strong); }
[data-theme="dark"] .empty-state p  { color: var(--text-muted); }
[data-theme="dark"] .inv-section-title { color: var(--text-muted); }

/* Links — slightly brighter blue for legibility on dark */
[data-theme="dark"] a { color: color-mix(in srgb, var(--brand) 55%, #fff); }
[data-theme="dark"] a:hover { color: color-mix(in srgb, var(--brand) 35%, #fff); }

/* Scrollbar — subtle dark */
[data-theme="dark"] ::-webkit-scrollbar { width: 12px; height: 12px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: var(--bg-page); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #1f2748; border-radius: 8px; border: 3px solid var(--bg-page); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #2a3358; }

/* Theme toggle button */
.theme-toggle {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem .75rem;
  border-radius: 9px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: .9rem;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: all .15s;
  margin-bottom: 2px;
  font-family: inherit;
}
.theme-toggle:hover { background: var(--bg-subtle); color: var(--text-strong); }
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: inline-block; }
[data-theme="dark"] .theme-toggle .icon-sun  { display: inline-block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.theme-toggle .label-light { display: none; }
.theme-toggle .label-dark  { display: inline; }
[data-theme="dark"] .theme-toggle .label-light { display: inline; }
[data-theme="dark"] .theme-toggle .label-dark  { display: none; }

/* Auth side (login page) stays the same in either theme since it has its own gradient */
.auth-form-wrap {
  background: var(--bg-page);
  color: var(--text-body);
}
.auth-form-wrap h2 { color: var(--text-strong); }

/* ================================================================
   SIDEBAR LAYOUT
   ================================================================ */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.875rem;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex; flex-direction: column;
  z-index: 100;
}
.app-sidebar .brand {
  display: flex; align-items: center; gap: .65rem;
  padding: .5rem .75rem 1.25rem;
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-strong);
  letter-spacing: -.02em;
  text-decoration: none;
}
.app-sidebar .brand-mark {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: .95rem;
  box-shadow: 0 4px 12px -2px color-mix(in srgb, var(--brand) 45%, transparent);
}
.app-sidebar .nav-section {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--gray-400);
  padding: 1rem .9rem .5rem;
}
.app-sidebar .nav-item-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem .75rem;
  border-radius: 9px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: .9rem;
  text-decoration: none;
  transition: all .15s;
  margin-bottom: 2px;
}
.app-sidebar .nav-item-link svg { flex-shrink: 0; opacity: .85; }
.app-sidebar .nav-item-link:hover { background: var(--bg-subtle); color: var(--text-strong); }
.app-sidebar .nav-item-link.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.app-sidebar .nav-item-link.active svg { opacity: 1; }
.app-sidebar .sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.app-sidebar .cta-new {
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  padding: .65rem .9rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: .9rem;
  text-decoration: none;
  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--brand) 55%, transparent);
  margin: 0 .25rem 1rem;
  transition: transform .15s, box-shadow .15s;
}
.app-sidebar .cta-new:hover {
  transform: translateY(-1px);
  text-decoration: none; color: #fff;
  box-shadow: 0 8px 20px -4px color-mix(in srgb, var(--brand) 60%, transparent);
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  background:
    radial-gradient(1200px 600px at 90% -10%, color-mix(in srgb, var(--brand) 6%, transparent), transparent 70%),
    radial-gradient(800px 600px at -10% 110%, color-mix(in srgb, var(--brand-2) 5%, transparent), transparent 60%),
    var(--bg-page);
  color: var(--text-body);
}

/* Mobile drawer */
.sidebar-toggle {
  display: none;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 9px; padding: .45rem;
  box-shadow: var(--shadow-xs);
  color: var(--text-body);
}
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15,23,42,.4);
  backdrop-filter: blur(2px);
  z-index: 99;
}
.mobile-topbar {
  display: none;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}

@media (max-width: 991px) {
  .app-shell { flex-direction: column; }
  .app-sidebar {
    position: fixed; left: 0; top: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 12px 0 30px -10px rgba(15,23,42,.15);
  }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
  .sidebar-toggle, .mobile-topbar { display: flex; }
}

/* ================================================================
   HERO GREETING (Dashboard)
   ================================================================ */
.hero-card {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  padding: 1.15rem 1.5rem;
  margin-bottom: 1.25rem;
  background:
    radial-gradient(circle at 20% 30%, color-mix(in srgb, #fff 22%, transparent), transparent 50%),
    radial-gradient(circle at 80% 70%, color-mix(in srgb, #fff 12%, transparent), transparent 50%),
    linear-gradient(120deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  box-shadow: 0 12px 32px -8px color-mix(in srgb, var(--brand) 45%, transparent);
  margin-bottom: 1.5rem;
}
.hero-card::after {
  content: '';
  position: absolute;
  right: -60px; bottom: -60px;
  width: 220px; height: 220px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  filter: blur(40px);
  pointer-events: none;
}
.hero-card .hero-eyebrow {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  opacity: .8;
  font-weight: 600;
  margin-bottom: .25rem;
}
.hero-card .hero-title {
  font-family: 'Plus Jakarta Sans', 'Inter', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: #fff;
  margin: 0 0 .2rem;
  line-height: 1.2;
}
.hero-card .hero-sub { font-size: .92rem; opacity: .9; max-width: 60ch; }

/* ================================================================
   STAT CARDS — enhanced with hover lift + gradients
   ================================================================ */
.stat-card {
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 100px; height: 100px;
  background: radial-gradient(circle at top right, color-mix(in srgb, var(--brand) 10%, transparent), transparent 70%);
  pointer-events: none;
}
.stat-card.danger::before  { background: radial-gradient(circle at top right, color-mix(in srgb, var(--danger) 10%, transparent), transparent 70%); }
.stat-card.success::before { background: radial-gradient(circle at top right, color-mix(in srgb, var(--success) 10%, transparent), transparent 70%); }
.stat-card.warn::before    { background: radial-gradient(circle at top right, color-mix(in srgb, var(--warning) 10%, transparent), transparent 70%); }

/* ================================================================
   CARDS — gentle hover
   ================================================================ */
.card { transition: box-shadow .2s, transform .2s; }
.card.hover-lift:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

/* ================================================================
   EMPTY STATES
   ================================================================ */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
}
.empty-state .empty-icon {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 14%, #fff), color-mix(in srgb, var(--brand-2) 14%, #fff));
  color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 1rem;
}
.empty-state h5 { margin-bottom: .25rem; font-weight: 600; }
.empty-state p { color: var(--gray-500); font-size: .9rem; margin-bottom: 1.25rem; }

/* ================================================================
   LOGIN — mesh gradient + glass
   ================================================================ */
.auth-side {
  background:
    radial-gradient(circle at 15% 20%, color-mix(in srgb, var(--brand-2) 80%, #fff) 0%, transparent 45%),
    radial-gradient(circle at 85% 70%, color-mix(in srgb, var(--brand) 100%, #000) 0%, transparent 50%),
    linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
}
.auth-side .floaty {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: .35;
  pointer-events: none;
}
.auth-side .floaty.a { width: 320px; height: 320px; top: -80px;  left: -80px;  background: #fff; opacity: .15; }
.auth-side .floaty.b { width: 240px; height: 240px; bottom: -60px; right: -60px; background: #fbbf24; opacity: .22; }
.auth-form-wrap h2 { font-family: 'Plus Jakarta Sans','Inter',sans-serif; font-weight: 800; letter-spacing: -.025em; font-size: 2rem; }

/* ================================================================
   BIG INVOICE TITLE
   ================================================================ */
.inv-title {
  font-family: 'Plus Jakarta Sans','Inter',sans-serif;
  font-weight: 900;
  letter-spacing: -.045em;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: 2.4rem;
}
.inv-num-badge {
  display: inline-flex;
  background: var(--gray-900);
  color: #fff;
  padding: .25rem .65rem;
  border-radius: 8px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: .8rem;
  letter-spacing: .04em;
}

/* ================================================================
   TABLE ROW hover for app tables (not invoice paper)
   ================================================================ */
.table-hover tbody tr { transition: background-color .12s; }

/* ================================================================
   Accent button used on hero
   ================================================================ */
.btn-glass {
  background: rgba(255,255,255,.18);
  color: #fff;
  border: 1px solid rgba(255,255,255,.3);
  backdrop-filter: blur(8px);
}
.btn-glass:hover { background: rgba(255,255,255,.28); color: #fff; }

/* ---------- Responsive: tablet ---------- */
@media (max-width: 991px) {
  .invoice-paper .inv-body { padding: 1.75rem; }
  .inv-title { font-size: 1.75rem; }
  .inv-meta { grid-template-columns: 110px 1fr; }
  .stat-card .stat-value { font-size: 1.55rem; }
}

/* ---------- Responsive: phone ---------- */
@media (max-width: 575px) {
  /* prevent iOS Safari from auto-zooming on tap */
  .form-control, .form-select, .form-control-lg { font-size: 16px; }

  .app-navbar { padding: .5rem .75rem; }
  .app-navbar .navbar-brand { font-size: .98rem; }

  /* roomier tap targets */
  .btn { padding: .55rem 1rem; }
  .btn-sm { padding: .45rem .75rem; font-size: .85rem; }

  .invoice-paper { border-radius: 12px; }
  .invoice-paper .inv-body { padding: 1.25rem; }
  .inv-title { font-size: 1.5rem; }
  .inv-meta { grid-template-columns: 100px 1fr; font-size: .82rem; }

  /* tighten dashboard */
  .stat-card { padding: 1rem; }
  .stat-card .stat-value { font-size: 1.4rem; }

  /* hint that wide tables scroll */
  .table-responsive, .inv-items-wrap {
    -webkit-overflow-scrolling: touch;
    background:
      linear-gradient(to right, #fff 30%, rgba(255,255,255,0)),
      linear-gradient(to right, rgba(255,255,255,0), #fff 70%) 100% 0,
      linear-gradient(to right, rgba(15,23,42,0.06), rgba(255,255,255,0)),
      linear-gradient(to left,  rgba(15,23,42,0.06), rgba(255,255,255,0)) 100% 0;
    background-repeat: no-repeat;
    background-size: 30px 100%, 30px 100%, 12px 100%, 12px 100%;
    background-attachment: local, local, scroll, scroll;
  }
}
