/* ==========================================================================
   SLBis Books — app.css
   Layered on top of Tabler (Bootstrap 5). Every screen uses these tokens:
   no hard-coded colours, no inline styles.
   ========================================================================== */

/* ---------- Self-hosted fonts ---------- */
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("../vendor/fonts/inter-400.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("../vendor/fonts/inter-500.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("../vendor/fonts/inter-600.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("../vendor/fonts/inter-700.woff2") format("woff2"); }
@font-face { font-family: "Noto Sans Sinhala"; font-weight: 400; font-display: swap; src: url("../vendor/fonts/noto-sans-sinhala-400.woff2") format("woff2"); }
@font-face { font-family: "Noto Sans Sinhala"; font-weight: 600; font-display: swap; src: url("../vendor/fonts/noto-sans-sinhala-600.woff2") format("woff2"); }

/* ==========================================================================
   DESIGN TOKENS
   ========================================================================== */
:root {
  /* Brand (tenant white-label overrides --sb-brand / --sb-brand-rgb at runtime) */
  --sb-brand:        #1d4ed8;   /* SLBis blue — 6.7:1 on white */
  --sb-brand-rgb:    29, 78, 216;
  --sb-brand-hover:  #1e40af;
  --sb-brand-soft:   #e8eefc;
  --sb-on-brand:     #ffffff;

  /* Money meaning only */
  --sb-in:           #0f7a46;   /* money in / profit / paid   5.4:1 */
  --sb-in-soft:      #e3f4ea;
  --sb-out:          #b42318;   /* money out / loss / overdue 6.5:1 */
  --sb-out-soft:     #fdeceb;
  --sb-warn:         #a15c07;   /* due soon, trial, attention 5.3:1 */
  --sb-warn-soft:    #fdf2e1;
  --sb-info:         #0e6f8c;
  --sb-info-soft:    #e2f3f8;

  /* Neutrals */
  --sb-bg:           #f4f6fa;
  --sb-surface:      #ffffff;
  --sb-surface-2:    #f8fafc;
  --sb-border:       #e3e8ef;
  --sb-text:         #101828;
  --sb-text-muted:   #5b6576;   /* 5.9:1 on white */
  --sb-text-faint:   #8a94a6;   /* decorative only, never body text */

  /* Shape */
  --sb-radius-sm:    8px;
  --sb-radius:       10px;
  --sb-radius-lg:    12px;
  --sb-radius-pill:  999px;

  /* Spacing scale (4px base) */
  --sb-space-1: 4px;  --sb-space-2: 8px;  --sb-space-3: 12px; --sb-space-4: 16px;
  --sb-space-5: 20px; --sb-space-6: 24px; --sb-space-8: 32px; --sb-space-10: 40px;

  /* Elevation */
  --sb-shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --sb-shadow:    0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --sb-shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18);

  /* Type scale */
  --sb-font: "Inter", "Noto Sans Sinhala", system-ui, -apple-system, "Segoe UI", sans-serif;
  --sb-fs-xs: .75rem; --sb-fs-sm: .8125rem; --sb-fs-base: .9375rem;
  --sb-fs-lg: 1.125rem; --sb-fs-xl: 1.375rem; --sb-fs-2xl: 1.75rem;

  /* Layout */
  --sb-touch: 44px;
  --sb-sidebar-w: 248px;
  --sb-tabbar-h: 64px;

  /* ---- Map tokens onto Tabler so all its components follow the brand ---- */
  --tblr-primary: var(--sb-brand);
  --tblr-primary-rgb: var(--sb-brand-rgb);
  --tblr-font-sans-serif: var(--sb-font);
  --tblr-body-font-size: var(--sb-fs-base);
  --tblr-border-radius: var(--sb-radius);
  --tblr-border-radius-lg: var(--sb-radius-lg);
  --tblr-success: var(--sb-in);
  --tblr-danger: var(--sb-out);
  --tblr-warning: var(--sb-warn);
}

/* Dark theme: follows device unless user forces light/dark */
:root[data-bs-theme="dark"] {
  --sb-brand:        #6d95f5;
  --sb-brand-rgb:    109, 149, 245;
  --sb-brand-hover:  #8aabf7;
  --sb-brand-soft:   #1b2748;
  --sb-on-brand:     #0b1020;
  --sb-in:           #4cc98a;  --sb-in-soft:   #10301f;
  --sb-out:          #f47a70;  --sb-out-soft:  #3a1714;
  --sb-warn:         #e7a948;  --sb-warn-soft: #36270f;
  --sb-info:         #5cc3e0;  --sb-info-soft: #0f2c36;
  --sb-bg:           #0d1220;
  --sb-surface:      #151b2c;
  --sb-surface-2:    #1b2236;
  --sb-border:       #283149;
  --sb-text:         #e8ecf4;
  --sb-text-muted:   #a3adc2;
  --sb-text-faint:   #6c778f;
  --sb-shadow-sm: none; --sb-shadow: 0 1px 2px rgba(0,0,0,.4); --sb-shadow-lg: 0 12px 32px -8px rgba(0,0,0,.6);
  --tblr-body-bg: var(--sb-bg);
  --tblr-bg-surface: var(--sb-surface);
  --tblr-border-color: var(--sb-border);
}

/* ==========================================================================
   BASE
   ========================================================================== */
body { background: var(--sb-bg); color: var(--sb-text); font-family: var(--sb-font); -webkit-font-smoothing: antialiased; }
:lang(si) body, body:lang(si) { line-height: 1.6; }
a { color: var(--sb-brand); }
:focus-visible { outline: 3px solid rgba(var(--sb-brand-rgb), .45); outline-offset: 2px; border-radius: var(--sb-radius-sm); }
.btn, .form-control, .form-select { min-height: var(--sb-touch); border-radius: var(--sb-radius); }
.btn-primary { background: var(--sb-brand); border-color: var(--sb-brand); color: var(--sb-on-brand); }
.btn-primary:hover { background: var(--sb-brand-hover); border-color: var(--sb-brand-hover); }
.card { border-radius: var(--sb-radius-lg); border-color: var(--sb-border); box-shadow: var(--sb-shadow-sm); background: var(--sb-surface); }
.text-muted, .form-hint { color: var(--sb-text-muted) !important; }
.tabular { font-variant-numeric: tabular-nums; }

/* Money meaning */
.money { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.money-in  { color: var(--sb-in); }
.money-out { color: var(--sb-out); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--sb-radius-pill); font-size: var(--sb-fs-xs); font-weight: 600; }
.chip-in   { background: var(--sb-in-soft);   color: var(--sb-in); }
.chip-out  { background: var(--sb-out-soft);  color: var(--sb-out); }
.chip-warn { background: var(--sb-warn-soft); color: var(--sb-warn); }
.chip-info { background: var(--sb-info-soft); color: var(--sb-info); }
.chip-muted{ background: var(--sb-surface-2); color: var(--sb-text-muted); border: 1px solid var(--sb-border); }

/* ==========================================================================
   APP SHELL — desktop sidebar + topbar; mobile top header + bottom tab bar + FAB
   ========================================================================== */
.sb-shell { min-height: 100vh; display: flex; }
.sb-sidebar { width: var(--sb-sidebar-w); background: var(--sb-surface); border-right: 1px solid var(--sb-border); position: fixed; inset: 0 auto 0 0; display: none; flex-direction: column; padding: var(--sb-space-4); gap: var(--sb-space-1); overflow-y: auto; }
.sb-logo { display: flex; align-items: center; gap: var(--sb-space-2); font-weight: 700; font-size: var(--sb-fs-lg); padding: var(--sb-space-2) var(--sb-space-2) var(--sb-space-4); color: var(--sb-text); text-decoration: none; }
.sb-logo-mark { width: 32px; height: 32px; border-radius: var(--sb-radius-sm); background: var(--sb-brand); color: var(--sb-on-brand); display: grid; place-items: center; font-weight: 700; }
.sb-nav-label { font-size: var(--sb-fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--sb-text-faint); padding: var(--sb-space-4) var(--sb-space-3) var(--sb-space-1); }
.sb-nav-link { display: flex; align-items: center; gap: var(--sb-space-3); min-height: 40px; padding: 0 var(--sb-space-3); border-radius: var(--sb-radius); color: var(--sb-text-muted); text-decoration: none; font-weight: 500; }
.sb-nav-link:hover { background: var(--sb-surface-2); color: var(--sb-text); text-decoration: none; }
.sb-nav-link.active { background: var(--sb-brand-soft); color: var(--sb-brand); }
.sb-nav-link .sb-icon { width: 20px; height: 20px; }

.sb-main { flex: 1; min-width: 0; padding-bottom: calc(var(--sb-tabbar-h) + env(safe-area-inset-bottom) + var(--sb-space-6)); }
.sb-topbar { position: sticky; top: 0; z-index: 20; background: var(--sb-surface); border-bottom: 1px solid var(--sb-border); display: flex; align-items: center; gap: var(--sb-space-3); padding: var(--sb-space-2) var(--sb-space-4); min-height: 60px; }
.sb-topbar .sb-search { flex: 1; max-width: 520px; position: relative; display: none; }
.sb-topbar .sb-search .sb-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--sb-text-faint); }
.sb-topbar .sb-search input { padding-left: 38px; background: var(--sb-surface-2); }
.sb-kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: var(--sb-fs-xs); color: var(--sb-text-faint); border: 1px solid var(--sb-border); border-radius: 4px; padding: 0 6px; }
.sb-icon-btn { width: var(--sb-touch); height: var(--sb-touch); border-radius: var(--sb-radius); display: grid; place-items: center; background: transparent; border: 0; color: var(--sb-text-muted); position: relative; }
.sb-icon-btn:hover { background: var(--sb-surface-2); color: var(--sb-text); }
.sb-icon-btn .sb-icon { width: 22px; height: 22px; }
.sb-dot { position: absolute; top: 10px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--sb-out); border: 2px solid var(--sb-surface); }
.sb-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--sb-brand-soft); color: var(--sb-brand); display: grid; place-items: center; font-weight: 700; font-size: var(--sb-fs-sm); }
.sb-content { padding: var(--sb-space-4); max-width: 1200px; margin: 0 auto; }

.sb-tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--sb-tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--sb-surface); border-top: 1px solid var(--sb-border); display: grid; grid-template-columns: repeat(5, 1fr); }
.sb-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 500; color: var(--sb-text-muted); text-decoration: none; min-height: var(--sb-touch); }
.sb-tab .sb-icon { width: 24px; height: 24px; }
.sb-tab.active { color: var(--sb-brand); }
.sb-tab:hover { text-decoration: none; color: var(--sb-text); }

.sb-fab { position: fixed; right: var(--sb-space-4); bottom: calc(var(--sb-tabbar-h) + env(safe-area-inset-bottom) + var(--sb-space-4)); z-index: 31; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--sb-brand); color: var(--sb-on-brand); box-shadow: var(--sb-shadow-lg); display: grid; place-items: center; }
.sb-fab .sb-icon { width: 30px; height: 30px; transition: transform .2s; }
.sb-fab[aria-expanded="true"] .sb-icon { transform: rotate(45deg); }

/* Bottom sheet (quick add) */
.sb-sheet-backdrop { position: fixed; inset: 0; background: rgba(9, 13, 25, .45); z-index: 40; }
.sb-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--sb-surface); border-radius: 20px 20px 0 0; padding: var(--sb-space-3) var(--sb-space-4) calc(var(--sb-space-6) + env(safe-area-inset-bottom)); box-shadow: var(--sb-shadow-lg); }
.sb-sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--sb-border); margin: 0 auto var(--sb-space-4); }
.sb-sheet-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sb-space-3); }
.sb-sheet-item { display: flex; align-items: center; gap: var(--sb-space-3); padding: var(--sb-space-4); border: 1px solid var(--sb-border); border-radius: var(--sb-radius-lg); color: var(--sb-text); text-decoration: none; font-weight: 600; min-height: 64px; }
.sb-sheet-item:hover { text-decoration: none; background: var(--sb-surface-2); }

@media (min-width: 992px) {
  .sb-sidebar { display: flex; }
  .sb-main { margin-left: var(--sb-sidebar-w); padding-bottom: var(--sb-space-8); }
  .sb-tabbar, .sb-fab, .sb-mobile-only { display: none !important; }
  .sb-topbar .sb-search { display: block; }
  .sb-content { padding: var(--sb-space-6) var(--sb-space-8); }
}
@media (max-width: 991.98px) { .sb-desktop-only { display: none !important; } }

/* ==========================================================================
   COMPONENTS
   ========================================================================== */
.sb-page-title { font-size: var(--sb-fs-xl); font-weight: 700; margin: 0; }
.sb-eyebrow { font-size: var(--sb-fs-sm); color: var(--sb-text-muted); }

/* KPI cards */
.sb-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sb-space-3); }
@media (min-width: 768px) { .sb-kpis { grid-template-columns: repeat(4, 1fr); gap: var(--sb-space-4); } }
.sb-kpi { padding: var(--sb-space-4); }
.sb-kpi-label { display: flex; align-items: center; gap: 6px; font-size: var(--sb-fs-sm); color: var(--sb-text-muted); font-weight: 500; }
.sb-kpi-value { font-size: var(--sb-fs-lg); font-weight: 700; margin-top: var(--sb-space-1); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.sb-kpi-foot { font-size: var(--sb-fs-xs); color: var(--sb-text-muted); margin-top: 2px; }
@media (min-width: 768px) { .sb-kpi-value { font-size: var(--sb-fs-xl); } }
.sb-kpi-hero { grid-column: 1 / -1; background: var(--sb-brand); color: var(--sb-on-brand); border: 0; }
.sb-kpi-hero .sb-kpi-label, .sb-kpi-hero .sb-kpi-foot { color: rgba(255,255,255,.85); }
[data-bs-theme="dark"] .sb-kpi-hero .sb-kpi-label, [data-bs-theme="dark"] .sb-kpi-hero .sb-kpi-foot { color: rgba(11,16,32,.8); }
.sb-kpi-hero .sb-kpi-value { font-size: var(--sb-fs-2xl); }

/* Quick actions */
.sb-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sb-space-2); }
.sb-action { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: var(--sb-space-3) var(--sb-space-1); border-radius: var(--sb-radius-lg); background: var(--sb-surface); border: 1px solid var(--sb-border); color: var(--sb-text); font-size: var(--sb-fs-sm); font-weight: 600; text-decoration: none; min-height: 76px; justify-content: center; }
.sb-action:hover { text-decoration: none; border-color: var(--sb-brand); }
.sb-action-icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; }
.sb-action-icon.in   { background: var(--sb-in-soft);    color: var(--sb-in); }
.sb-action-icon.out  { background: var(--sb-out-soft);   color: var(--sb-out); }
.sb-action-icon.inv  { background: var(--sb-brand-soft); color: var(--sb-brand); }
.sb-action-icon.sal  { background: var(--sb-info-soft);  color: var(--sb-info); }

/* Progress / meter */
.sb-meter { height: 10px; border-radius: var(--sb-radius-pill); background: var(--sb-surface-2); border: 1px solid var(--sb-border); overflow: hidden; }
.sb-meter > span { display: block; height: 100%; background: var(--sb-in); border-radius: inherit; }
.sb-meter.w-82 > span { width: 82%; }
.sb-meter.w-50 > span { width: 50%; background: var(--sb-brand); }

/* Lists */
.sb-list { list-style: none; margin: 0; padding: 0; }
.sb-list li { display: flex; align-items: center; gap: var(--sb-space-3); padding: var(--sb-space-3) var(--sb-space-4); border-top: 1px solid var(--sb-border); min-height: 60px; }
.sb-list li:first-child { border-top: 0; }
.sb-list-icon { width: 38px; height: 38px; flex: none; border-radius: var(--sb-radius); display: grid; place-items: center; font-size: 20px; background: var(--sb-surface-2); color: var(--sb-text-muted); }
.sb-list-main { flex: 1; min-width: 0; }
.sb-list-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-list-sub { font-size: var(--sb-fs-xs); color: var(--sb-text-muted); }

/* Onboarding checklist */
.sb-check { display: flex; align-items: center; gap: var(--sb-space-2); font-size: var(--sb-fs-sm); padding: 6px 0; }
.sb-check .sb-icon { width: 20px; height: 20px; }
.sb-check.done { color: var(--sb-text-muted); text-decoration: line-through; }
.sb-check.done .sb-icon { color: var(--sb-in); }

/* Forms — mobile entry */
.sb-form-page { max-width: 560px; margin: 0 auto; }
.sb-amount { text-align: center; padding: var(--sb-space-5) var(--sb-space-4) var(--sb-space-3); }
.sb-amount-input { display: flex; align-items: baseline; justify-content: center; gap: var(--sb-space-2); }
.sb-amount-input span { font-size: var(--sb-fs-xl); font-weight: 600; color: var(--sb-text-muted); }
.sb-amount-input input { border: 0; background: transparent; font-size: 2.5rem; font-weight: 700; width: 100%; max-width: 280px; text-align: center; color: var(--sb-text); font-variant-numeric: tabular-nums; outline: none; }
.sb-amount-input input::placeholder { color: var(--sb-text-faint); }
.sb-amount-words { font-size: var(--sb-fs-xs); color: var(--sb-text-muted); min-height: 1.2em; }
.sb-seg { display: flex; gap: var(--sb-space-2); overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.sb-seg::-webkit-scrollbar { display: none; }
.sb-seg input { position: absolute; opacity: 0; pointer-events: none; }
.sb-seg label { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: var(--sb-touch); padding: 0 var(--sb-space-4); border: 1px solid var(--sb-border); border-radius: var(--sb-radius-pill); background: var(--sb-surface); font-weight: 500; cursor: pointer; }
.sb-seg input:checked + label { border-color: var(--sb-brand); background: var(--sb-brand-soft); color: var(--sb-brand); font-weight: 600; }
.sb-seg input:focus-visible + label { outline: 3px solid rgba(var(--sb-brand-rgb), .45); outline-offset: 2px; }
.sb-field { margin-bottom: var(--sb-space-4); }
.sb-field .form-label { font-weight: 600; font-size: var(--sb-fs-sm); margin-bottom: 6px; }
.sb-sticky-save { position: sticky; bottom: 0; background: linear-gradient(to top, var(--sb-bg) 70%, transparent); padding: var(--sb-space-4) 0 calc(var(--sb-space-4) + env(safe-area-inset-bottom)); }
.sb-upload { display: flex; align-items: center; gap: var(--sb-space-3); padding: var(--sb-space-3) var(--sb-space-4); border: 1.5px dashed var(--sb-border); border-radius: var(--sb-radius-lg); color: var(--sb-text-muted); cursor: pointer; min-height: 56px; }
.sb-upload:hover { border-color: var(--sb-brand); color: var(--sb-brand); }
.sb-upload input { position: absolute; opacity: 0; width: 1px; height: 1px; }

/* Invoice editor */
.sb-line { border: 1px solid var(--sb-border); border-radius: var(--sb-radius-lg); padding: var(--sb-space-3); background: var(--sb-surface); margin-bottom: var(--sb-space-3); }
.sb-line-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sb-space-2); margin-top: var(--sb-space-2); }
.sb-line-total { display: flex; justify-content: space-between; align-items: center; margin-top: var(--sb-space-2); font-size: var(--sb-fs-sm); color: var(--sb-text-muted); }
@media (min-width: 768px) {
  .sb-line { display: grid; grid-template-columns: 1fr 90px 140px 140px 44px; gap: var(--sb-space-3); align-items: center; border: 0; border-bottom: 1px solid var(--sb-border); border-radius: 0; padding: var(--sb-space-2) 0; margin: 0; background: none; }
  .sb-line-grid, .sb-line-grid > div { display: contents; }
  .sb-line .form-label { display: none; }
  .sb-line-total { margin: 0; justify-content: flex-end; color: var(--sb-text); font-weight: 600; }
  .sb-line-total > span:first-child { display: none; }
  .sb-line-head { display: grid !important; grid-template-columns: 1fr 90px 140px 140px 44px; gap: var(--sb-space-3); font-size: var(--sb-fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--sb-text-muted); padding-bottom: var(--sb-space-2); border-bottom: 1px solid var(--sb-border); }
}
.sb-line-head { display: none; }
.sb-totals { display: grid; gap: var(--sb-space-2); }
.sb-totals-row { display: flex; justify-content: space-between; align-items: center; font-variant-numeric: tabular-nums; }
.sb-totals-row.grand { font-size: var(--sb-fs-lg); font-weight: 700; border-top: 1px solid var(--sb-border); padding-top: var(--sb-space-3); }

/* Skeleton loader */
.sb-skel { background: linear-gradient(90deg, var(--sb-surface-2) 25%, var(--sb-border) 50%, var(--sb-surface-2) 75%); background-size: 200% 100%; animation: sb-shimmer 1.2s infinite; border-radius: var(--sb-radius-sm); height: 14px; }
@keyframes sb-shimmer { to { background-position: -200% 0; } }

/* Toast with Undo */
.sb-toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--sb-tabbar-h) + env(safe-area-inset-bottom) + 90px); z-index: 50; background: var(--sb-text); color: var(--sb-surface); padding: var(--sb-space-3) var(--sb-space-4); border-radius: var(--sb-radius-lg); display: flex; gap: var(--sb-space-4); align-items: center; box-shadow: var(--sb-shadow-lg); font-weight: 500; white-space: nowrap; }
.sb-toast button { background: none; border: 0; color: var(--sb-brand-soft); font-weight: 700; min-height: 36px; }
@media (min-width: 992px) { .sb-toast { bottom: var(--sb-space-6); } }

/* Disclaimer / banners */
.sb-banner { display: flex; gap: var(--sb-space-3); align-items: flex-start; padding: var(--sb-space-3) var(--sb-space-4); border-radius: var(--sb-radius-lg); font-size: var(--sb-fs-sm); }
.sb-banner-warn { background: var(--sb-warn-soft); color: var(--sb-warn); }
.sb-banner-info { background: var(--sb-info-soft); color: var(--sb-info); }

/* Font-size helpers from the type scale */
.fs-t-xs { font-size: var(--sb-fs-xs); } .fs-t-sm { font-size: var(--sb-fs-sm); } .fs-t-base { font-size: var(--sb-fs-base); }
.fs-t-lg { font-size: var(--sb-fs-lg); } .fs-t-xl { font-size: var(--sb-fs-xl); font-weight: 700; } .fs-t-2xl { font-size: var(--sb-fs-2xl); font-weight: 700; }
[x-cloak] { display: none !important; }

/* ---------- Small-phone refinements (360px) ---------- */
@media (max-width: 575.98px) {
  .sb-kpi { padding: var(--sb-space-3); }
  .sb-kpi-value { font-size: clamp(.95rem, 4.3vw, 1.125rem); white-space: nowrap; }
  .sb-kpi-hero .sb-kpi-value { font-size: clamp(1.4rem, 7vw, 1.75rem); }
  .sb-topbar .fw-bold { font-size: var(--sb-fs-sm); }
  input[type="date"].form-control { padding-inline: 10px; font-size: var(--sb-fs-sm); }
  .sb-sticky-save .btn-lg { padding-inline: var(--sb-space-3); font-size: var(--sb-fs-base); }
}

/* Button text colour follows tokens (dark mode uses dark text on lighter fills for AA contrast) */
.btn-primary { --tblr-btn-color: var(--sb-on-brand); --tblr-btn-hover-color: var(--sb-on-brand); --tblr-btn-active-color: var(--sb-on-brand); }
[data-bs-theme="dark"] .btn-success, [data-bs-theme="dark"] .btn-danger { --tblr-btn-color: #0b1020; --tblr-btn-hover-color: #0b1020; }

/* Chart containers (Chart.js needs a sized parent) */
.sb-chart { position: relative; height: 230px; }
.sb-chart-lg { position: relative; height: 300px; }

/* ==========================================================================
   LOGIN
   ========================================================================== */
.sb-auth { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: var(--sb-surface); }
.sb-auth-brand { display: none; background: var(--sb-brand); color: #fff; padding: var(--sb-space-10); flex-direction: column; justify-content: space-between; }
.sb-auth-brand h2 { font-size: var(--sb-fs-2xl); font-weight: 700; line-height: 1.25; margin: var(--sb-space-8) 0 var(--sb-space-6); max-width: 440px; color: #fff; }
.sb-auth-point { display: flex; gap: var(--sb-space-3); align-items: flex-start; margin-bottom: var(--sb-space-4); max-width: 440px; }
.sb-auth-point .sb-icon { width: 22px; height: 22px; flex: none; opacity: .9; }
.sb-auth-point span { opacity: .92; }
.sb-auth-brand .sb-logo-mark { background: #fff; color: #1d4ed8; }
.sb-auth-form { display: flex; flex-direction: column; justify-content: center; padding: var(--sb-space-6) var(--sb-space-4); max-width: 420px; width: 100%; margin: 0 auto; }
.sb-otp { font-size: 1.75rem; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; padding-left: .5em; }
.sb-pw { position: relative; }
.sb-pw .sb-icon-btn { position: absolute; right: 0; top: 0; }
.sb-pw input { padding-right: 48px; }
.sb-divider { display: flex; align-items: center; gap: var(--sb-space-3); color: var(--sb-text-faint); font-size: var(--sb-fs-xs); margin: var(--sb-space-5) 0; }
.sb-divider::before, .sb-divider::after { content: ""; flex: 1; height: 1px; background: var(--sb-border); }
@media (min-width: 992px) { .sb-auth { grid-template-columns: 1.05fr 1fr; } .sb-auth-brand { display: flex; } }
[data-bs-theme="dark"] .sb-auth-brand { background: #172554; }

/* ==========================================================================
   REPORTS (P&L)
   ========================================================================== */
.sb-report-toolbar { display: flex; flex-wrap: wrap; gap: var(--sb-space-2); align-items: center; }
.sb-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sb-pnl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--sb-fs-sm); font-variant-numeric: tabular-nums; min-width: 760px; }
.sb-pnl th, .sb-pnl td { padding: 10px 12px; border-bottom: 1px solid var(--sb-border); white-space: nowrap; }
.sb-pnl td { text-align: right; }
.sb-pnl thead th { font-size: var(--sb-fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--sb-text-muted); text-align: right; background: var(--sb-surface-2); }
.sb-pnl thead th:first-child, .sb-pnl tbody th { text-align: left; font-weight: 500; }
.sb-pnl th:first-child { position: sticky; left: 0; background: var(--sb-surface); z-index: 1; min-width: 190px; }
.sb-pnl thead th:first-child { background: var(--sb-surface-2); }
.sb-pnl tbody th { padding-left: 24px; }
.sb-pnl .sb-pnl-section th { padding-left: 12px; font-weight: 700; color: var(--sb-text); text-transform: uppercase; font-size: var(--sb-fs-xs); letter-spacing: .06em; padding-top: 18px; }
.sb-pnl .sb-pnl-total th, .sb-pnl .sb-pnl-total td { font-weight: 700; background: var(--sb-surface-2); padding-left: 12px; }
.sb-pnl .sb-pnl-total th { background: var(--sb-surface-2); }
.sb-pnl .sb-pnl-net th, .sb-pnl .sb-pnl-net td { font-weight: 700; font-size: var(--sb-fs-base); color: var(--sb-in); border-top: 2px solid var(--sb-text); border-bottom: 3px double var(--sb-text); padding-left: 12px; }
.sb-pnl tbody tr:not(.sb-pnl-section):not(.sb-pnl-total):not(.sb-pnl-net):hover td,
.sb-pnl tbody tr:not(.sb-pnl-section):not(.sb-pnl-total):not(.sb-pnl-net):hover th { background: var(--sb-brand-soft); }
.sb-pnl td a { color: inherit; text-decoration: none; }
.sb-pnl td a:hover { color: var(--sb-brand); text-decoration: underline; }

/* ==========================================================================
   MASTER CONTROL PANEL — same tokens, distinct dark sidebar so it never looks like a tenant
   ========================================================================== */
.sb-admin .sb-sidebar { background: #0b1220; border-right-color: #1c2640; }
.sb-admin .sb-logo { color: #fff; }
.sb-admin .sb-nav-label { color: #6b7894; }
.sb-admin .sb-nav-link { color: #b6c0d4; }
.sb-admin .sb-nav-link:hover { background: #16203a; color: #fff; }
.sb-admin .sb-nav-link.active { background: #1d4ed8; color: #fff; }
.sb-admin-badge { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: #f59e0b; color: #1a1205; border-radius: 4px; padding: 1px 6px; margin-left: 4px; }
.sb-status-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sb-space-3); }
@media (min-width: 768px) { .sb-status-grid { grid-template-columns: repeat(5, 1fr); } }
.sb-status { padding: var(--sb-space-4); border-left: 4px solid var(--sb-border); }
.sb-status.s-active { border-left-color: var(--sb-in); }
.sb-status.s-trial { border-left-color: var(--sb-info); }
.sb-status.s-suspended { border-left-color: var(--sb-warn); }
.sb-status.s-expired { border-left-color: var(--sb-out); }
.sb-status.s-total { border-left-color: var(--sb-brand); }
.sb-health li { min-height: 52px; }


.sb-table { width: 100%; font-size: var(--sb-fs-sm); }
.sb-table th { font-size: var(--sb-fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--sb-text-muted); font-weight: 600; background: var(--sb-surface-2); }
.sb-table th, .sb-table td { padding: 10px 16px; border-bottom: 1px solid var(--sb-border); vertical-align: middle; }
.sb-table tr:last-child td { border-bottom: 0; }
.sb-admin .sb-logo { white-space: nowrap; font-size: var(--sb-fs-base); }
@media (max-width: 767.98px) { .sb-status.s-total { grid-column: 1 / -1; } }

/* ==========================================================================
   PRODUCTION ADDITIONS (Milestone 1)
   ========================================================================== */
[x-cloak] { display: none !important; }
.sb-icon { width: 1.25em; height: 1.25em; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; flex: none; }
.btn .sb-icon { width: 1.1em; height: 1.1em; margin-right: .15em; }
.chip .sb-icon { width: 1em; height: 1em; }
.sb-icon.money-in { color: var(--sb-in); }
.sb-icon.money-out { color: var(--sb-out); }
.min-w-0 { min-width: 0; }
.sb-grow { flex: 1 1 220px; }
.sb-w-auto { width: auto; }
.sb-skip { position: absolute; left: 8px; top: 8px; z-index: 100; background: var(--sb-surface); padding: 8px 12px; border-radius: var(--sb-radius); }

/* Logos and avatars */
.sb-logo-img { width: 32px; height: 32px; object-fit: contain; border-radius: var(--sb-radius-sm); background: #fff; flex: none; }
.sb-logo-mark-lg { width: 64px; height: 64px; font-size: 28px; border-radius: var(--sb-radius-lg); }
.sb-logo-preview { width: 44px; height: 44px; object-fit: contain; border-radius: var(--sb-radius-sm); }
.sb-logo-preview-lg { width: 64px; height: 64px; object-fit: contain; border-radius: var(--sb-radius-lg); border: 1px solid var(--sb-border); background: #fff; }
.sb-avatar-btn { border: 0; background: none; padding: 4px; border-radius: 50%; min-width: var(--sb-touch); min-height: var(--sb-touch); display: grid; place-items: center; }
.sb-avatar { flex: none; }

/* Dropdown menu controlled by Alpine (x-show) */
.dropdown { position: relative; }
.dropdown-menu.sb-menu { display: block; position: absolute; right: 0; left: auto; top: calc(100% + 4px); min-width: 240px; z-index: 60; box-shadow: var(--sb-shadow-lg); border-radius: var(--sb-radius-lg); border-color: var(--sb-border); background: var(--sb-surface); padding: 6px 0; }
.sb-menu .dropdown-item { display: flex; align-items: center; gap: 10px; min-height: 42px; width: 100%; border: 0; background: none; text-align: left; }
.sb-menu .dropdown-item:hover { background: var(--sb-surface-2); }

/* Offline and subscription banners */
.sb-offline { position: fixed; top: 0; left: 0; right: 0; z-index: 70; background: var(--sb-text); color: var(--sb-surface); text-align: center; padding: 6px; font-size: var(--sb-fs-sm); }
.sb-topbanner { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 8px 16px; font-size: var(--sb-fs-sm); font-weight: 600; text-align: center; }
.sb-topbanner-out { background: var(--sb-out-soft); color: var(--sb-out); }
.sb-topbanner-warn { background: var(--sb-warn-soft); color: var(--sb-warn); }
.sb-topbanner-info { background: var(--sb-info-soft); color: var(--sb-info); }
.sb-banner .sb-icon { margin-top: 2px; }
.sb-banner-error { background: var(--sb-out-soft); color: var(--sb-out); }
.sb-card-highlight { border-color: var(--sb-brand); box-shadow: 0 0 0 3px rgba(var(--sb-brand-rgb), .12); }

/* Toast variants */
.sb-toast { max-width: calc(100vw - 32px); white-space: normal; }
.sb-toast .sb-icon { width: 20px; height: 20px; }
.sb-toast-success > .sb-icon:first-child { color: #4cc98a; }
.sb-toast-error > .sb-icon:first-child { color: #f47a70; }
.sb-toast-close { background: none; border: 0; color: inherit; opacity: .7; min-width: 36px; min-height: 36px; }

/* Empty states */
.sb-empty { text-align: center; padding: var(--sb-space-8) var(--sb-space-4); }
.sb-empty-sm { padding: var(--sb-space-5) var(--sb-space-4); }
.sb-empty-icon { width: 56px; height: 56px; margin: 0 auto var(--sb-space-3); border-radius: 50%; background: var(--sb-brand-soft); color: var(--sb-brand); display: grid; place-items: center; }
.sb-empty-icon .sb-icon { width: 28px; height: 28px; }
.sb-action-icon .sb-icon { width: 22px; height: 22px; }

/* Lists with links (More menu, roles) */
.sb-list-links li { padding: 0; }
.sb-list-links li > a, .sb-list-links li > button, .sb-list-links li form > button { display: flex; align-items: center; gap: var(--sb-space-3); width: 100%; min-height: 56px; padding: var(--sb-space-3) var(--sb-space-4); color: var(--sb-text); text-decoration: none; background: none; border: 0; text-align: left; font-weight: 500; }
.sb-list-links li > a:hover, .sb-list-links li > button:hover, .sb-list-links li form > button:hover { background: var(--sb-surface-2); }
.sb-list-links .sb-icon { width: 22px; height: 22px; color: var(--sb-text-muted); }
.sb-list-links .text-danger, .sb-list-links .text-danger .sb-icon { color: var(--sb-out) !important; }
.sb-section-title { font-size: var(--sb-fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--sb-text-muted); margin: 0 0 var(--sb-space-2); }
.sb-timeline li { min-height: 48px; padding-top: 8px; padding-bottom: 8px; }
.sb-member-actions .form-select-sm { min-height: 36px; }

/* Settings tabs */
.sb-tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--sb-border); scrollbar-width: none; }
.sb-tabs a { flex: none; padding: 10px 14px; min-height: var(--sb-touch); display: inline-flex; align-items: center; color: var(--sb-text-muted); font-weight: 600; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sb-tabs a.active { color: var(--sb-brand); border-bottom-color: var(--sb-brand); }

/* Onboarding wizard */
.sb-wizard { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.sb-wizard-step { display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; color: var(--sb-text-muted); font-size: var(--sb-fs-xs); font-weight: 600; text-align: center; }
.sb-wizard-dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--sb-border); background: var(--sb-surface); }
.sb-wizard-step.is-current { color: var(--sb-brand); }
.sb-wizard-step.is-current .sb-wizard-dot { border-color: var(--sb-brand); background: var(--sb-brand); color: var(--sb-on-brand); }
.sb-wizard-step.is-done .sb-wizard-dot { border-color: var(--sb-in); background: var(--sb-in-soft); color: var(--sb-in); }
.sb-role-cards { display: grid; gap: var(--sb-space-2); }
.sb-role-card { display: flex; gap: var(--sb-space-3); align-items: flex-start; padding: var(--sb-space-3); border: 1px solid var(--sb-border); border-radius: var(--sb-radius-lg); cursor: pointer; background: var(--sb-surface); }
.sb-role-card input { margin-top: 4px; accent-color: var(--sb-brand); width: 18px; height: 18px; flex: none; }
.sb-role-card:has(input:checked) { border-color: var(--sb-brand); background: var(--sb-brand-soft); }
.sb-check { color: inherit; text-decoration: none; }
.sb-check:hover { color: var(--sb-brand); }
.sb-selected { border-color: var(--sb-brand); background: var(--sb-brand-soft); }
.sb-form-wide { max-width: 860px; }

/* Meter widths (no inline styles under our CSP) */
.sb-meter > span { background: var(--sb-brand); }
.sb-meter > span.w-0 { width: 0; }
.sb-meter > span.w-25 { width: 25%; }
.sb-meter > span.w-50 { width: 50%; }
.sb-meter > span.w-75 { width: 75%; }
.sb-meter > span.w-100 { width: 100%; }

/* 2FA */
.sb-steps { padding-left: 1.2rem; color: var(--sb-text-muted); }
.sb-steps li { margin-bottom: 4px; }
.sb-qr { display: flex; justify-content: center; padding: var(--sb-space-3); background: #fff; border-radius: var(--sb-radius-lg); border: 1px solid var(--sb-border); }
.sb-qr img { width: 200px; height: 200px; }
.sb-secret { display: inline-block; font-size: var(--sb-fs-base); letter-spacing: .08em; padding: 6px 10px; background: var(--sb-surface-2); border-radius: var(--sb-radius-sm); word-break: break-all; color: var(--sb-text); }
.sb-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; list-style: none; padding: 0; }
.sb-codes code { display: block; text-align: center; padding: 8px; font-size: var(--sb-fs-base); letter-spacing: .08em; background: var(--sb-surface-2); border: 1px dashed var(--sb-border); border-radius: var(--sb-radius-sm); color: var(--sb-text); }

/* Definition list */
.sb-dl { display: grid; grid-template-columns: 110px 1fr; gap: 8px 16px; }
.sb-dl dt { color: var(--sb-text-muted); font-weight: 500; }
.sb-dl dd { margin: 0; word-break: break-word; }

/* Error and minimal pages */
.sb-minimal { min-height: 100vh; display: grid; place-items: center; padding: var(--sb-space-6) var(--sb-space-4); }
.sb-error { text-align: center; max-width: 460px; }
.sb-error-code { font-size: 4rem; font-weight: 800; color: var(--sb-brand); line-height: 1; margin-bottom: var(--sb-space-3); letter-spacing: -.04em; }
.sb-debug { margin-top: var(--sb-space-5); max-width: 90vw; max-height: 50vh; overflow: auto; font-size: 12px; background: var(--sb-surface-2); padding: 12px; border-radius: var(--sb-radius); }

/* Admin additions */
.sb-nav-disabled { opacity: .55; cursor: default; }
.sb-nav-disabled:hover { background: none !important; }
.badge-soon { margin-left: auto; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px; background: #1c2640; color: #b6c0d4; }
.sb-sidebar-backdrop { position: fixed; inset: 0; background: rgba(9, 13, 25, .45); z-index: 39; }
@media (max-width: 991.98px) {
  .sb-sidebar.is-open { display: flex; z-index: 40; box-shadow: var(--sb-shadow-lg); }
}
.sb-auth-admin .sb-auth-brand { background: #0b1220; }
.sb-table a[aria-sort] { color: inherit; text-decoration: none; }
.sb-table a[aria-sort]:hover { color: var(--sb-brand); }
.sb-table td a { font-weight: 600; }

/* Forms */
fieldset[disabled] .form-control, fieldset[disabled] .form-select { background: var(--sb-surface-2); }
.form-control-color { min-width: 64px; }
.invalid-feedback { font-weight: 500; }

/* Charts */
.sb-chart { position: relative; height: 230px; }

@media print {
  .sb-sidebar, .sb-topbar, .sb-tabbar, .sb-fab, .btn, .sb-toast { display: none !important; }
  .sb-main { margin: 0 !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Team list on phones: actions wrap onto their own row under the member */
@media (max-width: 575.98px) {
  .sb-member-actions { flex-basis: 100%; padding-left: 50px; }
  .sb-member-actions form:first-child { flex: 1; }
}

/* Legal pages (Terms of Use, Privacy Policy) */
.sb-legal-bar { display: flex; justify-content: space-between; align-items: center; gap: var(--sb-space-4); flex-wrap: wrap; padding: var(--sb-space-3) var(--sb-space-4); background: var(--sb-surface); border-bottom: 1px solid var(--sb-border); }
.sb-legal { max-width: 760px; margin: 0 auto; padding: var(--sb-space-6) var(--sb-space-4) var(--sb-space-10); background: var(--sb-surface); line-height: 1.65; }
.sb-legal h1 { font-size: var(--sb-fs-2xl); font-weight: 700; margin-bottom: var(--sb-space-3); }
.sb-legal h2 { font-size: var(--sb-fs-lg); font-weight: 700; margin: var(--sb-space-8) 0 var(--sb-space-2); }
.sb-legal-lead { font-size: var(--sb-fs-lg); color: var(--sb-text-muted); }
.sb-legal li { margin-bottom: 6px; }
.sb-legal-table td, .sb-legal-table th { white-space: normal; vertical-align: top; }
@media print { .sb-legal-bar nav { display: none; } }

/* ==========================================================================
   MILESTONE 2: money screens
   ========================================================================== */
.sb-search-results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60; background: var(--sb-surface); border: 1px solid var(--sb-border); border-radius: var(--sb-radius-lg); box-shadow: var(--sb-shadow-lg); max-height: 70vh; overflow-y: auto; }
.sb-search-results:empty { display: none; }
.sb-search-empty { padding: var(--sb-space-3) var(--sb-space-4); }
.sb-receipt-thumb { width: 120px; height: 120px; object-fit: cover; border-radius: var(--sb-radius-lg); border: 1px solid var(--sb-border); }
.sb-toast form { margin: 0; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.sb-list details summary { min-height: var(--sb-touch); }
/* 5% steps for meters (no inline styles under the CSP) */
.sb-meter > span.w-5 { width: 5%; }
.sb-meter > span.w-10 { width: 10%; }
.sb-meter > span.w-15 { width: 15%; }
.sb-meter > span.w-20 { width: 20%; }
.sb-meter > span.w-30 { width: 30%; }
.sb-meter > span.w-35 { width: 35%; }
.sb-meter > span.w-40 { width: 40%; }
.sb-meter > span.w-45 { width: 45%; }
.sb-meter > span.w-55 { width: 55%; }
.sb-meter > span.w-60 { width: 60%; }
.sb-meter > span.w-65 { width: 65%; }
.sb-meter > span.w-70 { width: 70%; }
.sb-meter > span.w-80 { width: 80%; }
.sb-meter > span.w-85 { width: 85%; }
.sb-meter > span.w-90 { width: 90%; }
.sb-meter > span.w-95 { width: 95%; }
.sb-meter.sb-meter-in > span { background: var(--sb-in); }

/* Milestone 3: invoices */
.sb-share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sb-space-2); }
.sb-share-grid > :only-child { grid-column: 1 / -1; }
.sb-avatar-lg { width: 52px; height: 52px; font-size: 1.1rem; }
.sb-line .form-select-sm { font-size: var(--sb-fs-xs); }
.sb-share-grid .btn { white-space: normal; line-height: 1.2; padding-inline: var(--sb-space-2); }
@media (min-width: 992px) {
  .sb-line, .sb-line-head { grid-template-columns: minmax(0, 1fr) 72px 120px 110px 40px !important; }
}
.sb-w-amount { max-width: 130px; flex: 0 0 130px; }
.sb-w-amount-sm { max-width: 104px; flex: 0 0 104px; }

/* Milestone 5: reports */
.sb-report td, .sb-report th { padding: .45rem .75rem; }
.sb-report .sb-r-section td { font-weight: 700; color: var(--sb-brand); padding-top: 1rem; border-bottom: 0; }
.sb-report .sb-r-total td { font-weight: 700; border-top: 1px solid var(--sb-border); }
.sb-report .sb-r-grand td { font-weight: 800; border-top: 2px solid var(--sb-text); border-bottom: 2px solid var(--sb-text); }
.sb-report .sb-r-muted td { color: var(--sb-text-muted); }
.sb-report-wide { font-size: var(--sb-fs-sm); }
.sb-w-rate { max-width: 160px; }
.sb-dl-wide { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } .sb-dl-wide dd { text-align: right; } .sb-dl-wide dt { word-break: normal; }
.sb-pre-line { white-space: pre-line; }
.sb-topbanner-support { background: #c2410c; color: #fff; position: sticky; top: 0; z-index: 1040; }
.sb-checklist { max-height: 220px; overflow-y: auto; border: 1px solid var(--tblr-border-color); border-radius: 8px; padding: 6px 10px; }
.sb-banner-success { background: var(--sb-in-soft); color: var(--sb-in); }
.sb-kpi-alert { border-color: var(--sb-out) !important; } .sb-kpi-alert .sb-kpi-value { color: var(--sb-out); }
