/*
 * KasaTRY design system
 * Palette (brand): Midnight Navy #10253E · Emerald #10B981 · Cloud White #F4F7FA
 * Idea: "ledger" — money is the hero. Figures are set large in tabular numerals and sit
 * on a hairline emerald baseline, KPIs are one divided strip (like a ledger row), not a card pile.
 */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --navy: #10253E; --navy-2: #183455; --navy-3: #0B1B2E;
  --emerald: #10B981; --emerald-ink: #047857; --emerald-soft: #E7F7F0;
  --cloud: #F4F7FA;
  --bg: var(--cloud); --surface: #FFFFFF; --surface-2: #F8FAFC; --raised: #FFFFFF;
  --ink: #0E1A2B; --muted: #5B6B80; --faint: #8A98AA;
  --line: #DDE4EC; --line-strong: #C6D0DC;
  --danger: #C62828; --danger-soft: #FDECEC; --warn: #B45309; --warn-soft: #FEF3E2; --info: #1D4ED8; --info-soft: #E8EEFD;
  --focus: 0 0 0 3px rgba(16,185,129,.35);
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --shadow-pop: 0 12px 32px -8px rgba(16,37,62,.22), 0 2px 6px rgba(16,37,62,.08);
  --sidebar-w: 252px; --sidebar-w-collapsed: 72px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
html.theme-dark {
  --bg: #0A1422; --surface: #0F1D30; --surface-2: #12233A; --raised: #152A44;
  --ink: #E8EEF6; --muted: #93A4BA; --faint: #6D7F96;
  --line: #1F3350; --line-strong: #2C4466;
  --emerald-soft: rgba(16,185,129,.14); --emerald-ink: #34D399;
  --danger: #F87171; --danger-soft: rgba(248,113,113,.12); --warn: #FBBF24; --warn-soft: rgba(251,191,36,.12); --info: #93B4FF; --info-soft: rgba(147,180,255,.12);
  --shadow-pop: 0 16px 40px -8px rgba(0,0,0,.55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.55; color: var(--ink); background: var(--bg);
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.012em; }
h1 { font-size: 1.6rem; font-weight: 680; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 640; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num, .money { font-variant-numeric: tabular-nums; font-feature-settings: "tnum", "cv11"; white-space: nowrap; }
.neg { color: var(--danger); }
.pos { color: var(--emerald-ink); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.icon { width: 18px; height: 18px; flex: none; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; transition: grid-template-columns .18s ease; }
html.sidebar-collapsed .shell { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

.sidebar { background: var(--navy); color: #D5DEEA; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow: hidden; z-index: 40; }
html.theme-dark .sidebar { background: var(--navy-3); border-right: 1px solid var(--line); }
.sidebar-brand { display: flex; align-items: center; gap: 10px; height: 64px; padding: 0 18px; flex: none; }
.sidebar-brand img.wordmark { height: 30px; width: auto; }
.sidebar-brand img.mark { height: 30px; width: auto; display: none; }
html.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
html.sidebar-collapsed .sidebar-brand img.wordmark { display: none; }
html.sidebar-collapsed .sidebar-brand img.mark { display: block; }

.tenant-switch { margin: 4px 12px 10px; }
.tenant-switch details { position: relative; }
.tenant-switch summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-md); background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); color: #fff; }
.tenant-switch summary::-webkit-details-marker { display: none; }
.tenant-avatar { width: 28px; height: 28px; border-radius: 7px; background: var(--emerald); color: #03251A; display: grid; place-items: center; font-weight: 750; font-size: 13px; flex: none; }
.tenant-meta { min-width: 0; line-height: 1.2; }
.tenant-meta strong { display: block; font-size: 13px; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tenant-meta span { font-size: 11.5px; color: #93A6BE; }
.tenant-switch .menu { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--raised); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-pop); padding: 6px; z-index: 60; }
.tenant-switch .menu button { width: 100%; text-align: left; }
html.sidebar-collapsed .tenant-meta, html.sidebar-collapsed .tenant-switch .chev { display: none; }
html.sidebar-collapsed .tenant-switch summary { justify-content: center; padding: 8px 0; }

.nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.nav-group { margin-top: 14px; }
.nav-group-title { font-size: 11.5px; font-weight: 600; color: #7F93AD; padding: 0 10px 6px; letter-spacing: .01em; }
html.sidebar-collapsed .nav-group-title { visibility: hidden; height: 6px; padding: 0; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: #C9D4E2; text-decoration: none; font-size: 13.8px; font-weight: 500; position: relative; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(16,185,129,.14); color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--emerald); }
.nav a .icon { color: #8FA2BB; }
.nav a.active .icon, .nav a:hover .icon { color: var(--emerald); }
.nav a .badge-maint { margin-left: auto; font-size: 10.5px; color: #FBBF24; }
html.sidebar-collapsed .nav a { justify-content: center; padding: 10px 0; }
html.sidebar-collapsed .nav a span { display: none; }

.sidebar-foot { border-top: 1px solid rgba(255,255,255,.08); padding: 10px; display: flex; gap: 6px; }
.sidebar-foot button, .sidebar-foot a { flex: 1; }
.side-btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 36px; border-radius: 8px; border: 0; background: transparent; color: #AFBDD0; cursor: pointer; font: inherit; font-size: 13px; text-decoration: none; }
.side-btn:hover { background: rgba(255,255,255,.07); color: #fff; }
html.sidebar-collapsed .sidebar-foot { flex-direction: column; }
html.sidebar-collapsed .side-btn span { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: 64px; display: flex; align-items: center; gap: 14px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar .burger { display: none; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); min-width: 0; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.crumbs .icon { width: 14px; height: 14px; color: var(--faint); }
.crumbs strong { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.cmdk-trigger { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px 0 12px; min-width: 240px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer; font: inherit; font-size: 13px; }
.cmdk-trigger kbd { margin-left: auto; }
kbd { font-family: var(--font); font-size: 11px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--muted); }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.user-menu summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 4px; border-radius: 999px; }
.user-menu summary::-webkit-details-marker { display: none; }
.avatar { width: 32px; height: 32px; border-radius: 999px; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 12.5px; font-weight: 650; }
html.theme-dark .avatar { background: var(--navy-2); }

.content { padding: 28px; max-width: 1320px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* dropdown (details-based, no JS required) */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-pop); padding: 6px; z-index: 70; }
.dropdown-menu .menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dropdown-menu .menu-head strong { display: block; font-size: 13.5px; }
.dropdown-menu .menu-head span { font-size: 12px; color: var(--muted); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 7px; font: inherit; font-size: 13.5px; color: var(--ink); text-decoration: none; cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--surface-2); }
.menu-item .icon { color: var(--muted); }
.menu-item.current { font-weight: 600; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 0; }

/* ------------------------------------------------------------------ surfaces */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.panel-body { padding: 20px; }
.panel + .panel, .stack > * + * { margin-top: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }

/* Ledger strip: the signature element. One band, divided cells, figures on an emerald baseline. */
.ledger { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.ledger-cell { padding: 18px 20px 16px; border-left: 1px solid var(--line); min-width: 0; }
.ledger-cell:first-child { border-left: 0; }
.ledger-label { font-size: 12.5px; color: var(--muted); font-weight: 520; display: flex; align-items: center; gap: 6px; }
.ledger-figure { margin-top: 8px; font-size: 1.62rem; font-weight: 640; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1;
  padding-bottom: 8px; background: linear-gradient(var(--emerald), var(--emerald)) left bottom / 28px 2px no-repeat; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ledger-note { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.ledger-note .delta { font-weight: 600; }

/* ------------------------------------------------------------------ controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid transparent; font: inherit; font-size: 13.8px; font-weight: 580; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s, color .12s; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-2); }
html.theme-dark .btn-primary { background: var(--emerald); color: #04251A; }
html.theme-dark .btn-primary:hover { background: #34D399; }
.btn-accent { background: var(--emerald); color: #04251A; }
.btn-accent:hover { background: #0EA371; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--line-strong); background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .55; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 580; color: var(--ink); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; transition: border-color .12s, box-shadow .12s; }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:hover { border-color: var(--faint); }
.input:focus { outline: none; border-color: var(--emerald); box-shadow: var(--focus); }
.input.money-input { text-align: right; font-variant-numeric: tabular-nums; }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.input-prefix .input { padding-left: 28px; }
.has-error .input { border-color: var(--danger); }
.field-error { margin: 0; font-size: 12.5px; color: var(--danger); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 6px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--emerald); }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); gap: 2px; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: inline-block; padding: 6px 12px; border-radius: 6px; font-size: 13px; cursor: pointer; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16,37,62,.12); font-weight: 600; }
.segmented input:focus-visible + span { box-shadow: var(--focus); }

/* ------------------------------------------------------------------ table */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.8px; }
.table th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .r, .table th.r { text-align: right; }
.table td.money, .table td.num { text-align: right; }
.table tfoot td { font-weight: 650; border-top: 1px solid var(--line-strong); background: var(--surface-2); }
.table .row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.cell-main { font-weight: 560; }
.cell-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.filters .field { min-width: 150px; }
.filters .field.grow { flex: 1; min-width: 200px; }
.filters .input { height: 36px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 16px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 12.5px; color: var(--muted); text-decoration: none; }
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip.active { background: var(--emerald-soft); border-color: transparent; color: var(--emerald-ink); font-weight: 600; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.pagination .pages { display: flex; gap: 4px; }

/* ------------------------------------------------------------------ badges, alerts */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 580; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--emerald-soft); color: var(--emerald-ink); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge .dot { width: 6px; height: 6px; border-radius: 99px; background: currentColor; }

.alert { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); font-size: 13.5px; }
.alert .icon { margin-top: 1px; }
.alert.info { background: var(--info-soft); border-color: transparent; color: var(--ink); }
.alert.info .icon { color: var(--info); }
.alert.warn { background: var(--warn-soft); border-color: transparent; }
.alert.warn .icon { color: var(--warn); }
.alert.danger { background: var(--danger-soft); border-color: transparent; }
.alert.danger .icon { color: var(--danger); }
.alert.ok { background: var(--emerald-soft); border-color: transparent; }
.alert.ok .icon { color: var(--emerald-ink); }
.alert p:last-child { margin: 0; }

.empty { display: grid; place-items: center; text-align: center; padding: 56px 20px; }
.empty .empty-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--emerald-soft); color: var(--emerald-ink); margin-bottom: 14px; }
.empty h3 { margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 46ch; }

/* ------------------------------------------------------------------ toasts, modal, drawer, palette */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { display: flex; align-items: flex-start; gap: 10px; min-width: 280px; max-width: 420px; padding: 12px 14px; border-radius: var(--r-md); background: var(--navy); color: #fff; box-shadow: var(--shadow-pop); font-size: 13.5px; animation: toast-in .22s ease-out; }
html.theme-dark .toast { background: var(--raised); border: 1px solid var(--line-strong); }
.toast .icon { color: var(--emerald); margin-top: 1px; }
.toast.error .icon { color: #FCA5A5; }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; padding: 0; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

dialog.modal { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0; width: min(440px, calc(100vw - 32px)); background: var(--raised); color: var(--ink); box-shadow: var(--shadow-pop); }
dialog.modal::backdrop { background: rgba(10,20,34,.48); backdrop-filter: blur(2px); }
.modal-body { padding: 22px 22px 8px; }
.modal-body h3 { margin-bottom: 6px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; }

dialog.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(480px, 100vw); border: 0; border-left: 1px solid var(--line); padding: 0; background: var(--raised); color: var(--ink); }
dialog.drawer::backdrop { background: rgba(10,20,34,.4); }
dialog.drawer[open] { animation: drawer-in .2s ease-out; }
@keyframes drawer-in { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer-body { padding: 20px; overflow-y: auto; }

dialog.palette { margin-top: 12vh; width: min(600px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--raised); color: var(--ink); box-shadow: var(--shadow-pop); }
dialog.palette::backdrop { background: rgba(10,20,34,.45); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.palette-input input { flex: 1; height: 52px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 15px; outline: none; }
.palette-list { max-height: 360px; overflow-y: auto; padding: 6px; margin: 0; list-style: none; }
.palette-list li a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; text-decoration: none; font-size: 14px; }
.palette-list li a small { margin-left: auto; color: var(--faint); font-size: 12px; }
.palette-list li.active a, .palette-list li a:hover { background: var(--emerald-soft); }
.palette-empty { padding: 22px; text-align: center; color: var(--muted); font-size: 13.5px; }

.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 6px; min-height: 14px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: shimmer 1.3s infinite; }
html.theme-dark .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }

/* ------------------------------------------------------------------ tabs, misc */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; font-size: 13.8px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 540; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--emerald); font-weight: 620; }

.dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 22px; font-size: 13.8px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

.meter { height: 6px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--emerald); border-radius: 99px; }
.meter.warn > span { background: var(--warn); }
.meter.danger > span { background: var(--danger); }

.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.module-card { display: flex; flex-direction: column; gap: 12px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.module-card.is-active { border-color: color-mix(in srgb, var(--emerald) 55%, var(--line)); }
.module-card .mc-head { display: flex; align-items: center; gap: 12px; }
.module-ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--navy); border: 1px solid var(--line); flex: none; }
html.theme-dark .module-ico { color: var(--emerald); }
.module-card.is-active .module-ico { background: var(--emerald-soft); color: var(--emerald-ink); border-color: transparent; }
.module-card ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.module-card .mc-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 13px; }

.widgets { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 18px; }
.widget { grid-column: span 6; margin: 0 !important; }
.widget.size-sm { grid-column: span 4; }
.widget.size-lg { grid-column: span 12; }
.widget .panel-head h2 { font-size: 1rem; }
.widget-tools { display: flex; gap: 2px; }
.bar-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.bar-list .bl-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; margin-bottom: 5px; }
.bar-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-track span { display: block; height: 100%; background: var(--navy); border-radius: 99px; }
html.theme-dark .bar-track span { background: var(--emerald); }

.welcome { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; padding: 22px 24px; background: var(--navy); color: #E6EDF6; border-radius: var(--r-lg); margin-bottom: 18px; position: relative; overflow: hidden; }
.welcome h1 { color: #fff; font-size: 1.45rem; }
.welcome p { color: #AFC0D6; margin: 6px 0 0; }
.welcome::after { content: ""; position: absolute; right: -40px; bottom: -60px; width: 240px; height: 240px; border-radius: 50%; border: 28px solid rgba(16,185,129,.16); pointer-events: none; }
html.theme-dark .welcome { background: var(--raised); border: 1px solid var(--line); }

.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 99px; background: var(--faint); }
.status-dot.ok { background: var(--emerald); }
.status-dot.warn { background: var(--warn); }
.status-dot.danger { background: var(--danger); }

.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; word-break: break-all; }
pre.code { padding: 12px; white-space: pre-wrap; }

/* ------------------------------------------------------------------ auth pages */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.auth-brand { background: var(--navy); color: #D6E0EC; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-brand img { height: 40px; width: auto; align-self: flex-start; }
.auth-brand .claim { font-size: 2.4rem; line-height: 1.1; letter-spacing: -0.03em; font-weight: 700; color: #fff; max-width: 13ch; }
.auth-brand .claim-sub { margin-top: 16px; color: #A9BBD1; max-width: 42ch; font-size: 15px; }
.auth-ledger { margin-top: 36px; border-top: 1px solid rgba(255,255,255,.14); max-width: 420px; }
.auth-ledger div { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.08); font-size: 14px; }
.auth-ledger div span:last-child { font-variant-numeric: tabular-nums; color: #fff; font-weight: 600; }
.auth-ledger div.total span:last-child { color: var(--emerald); }
.auth-brand footer { font-size: 12.5px; color: #7F93AD; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: min(400px, 100%); }
.auth-card h1 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: 26px; }
.auth-card form { display: flex; flex-direction: column; gap: 16px; }
.auth-card .row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.auth-card .row a { color: var(--emerald-ink); text-decoration: none; font-weight: 560; }
.auth-mobile-logo { display: none; height: 34px; width: auto; margin-bottom: 26px; }
.auth.admin .auth-brand { background: #0A1524; }

.install { max-width: 880px; margin: 40px auto; padding: 0 20px; }
.req-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px 22px; font-size: 13.5px; }
.req-list li { display: flex; align-items: center; gap: 8px; }

/* error page */
.error-page { min-height: 70vh; display: grid; place-items: center; text-align: center; padding: 40px 20px; }
.error-code { font-size: 4.5rem; font-weight: 750; letter-spacing: -0.04em; color: var(--navy); font-variant-numeric: tabular-nums; line-height: 1; }
html.theme-dark .error-code { color: var(--emerald); }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .ledger { --cols: 2 !important; }
  .ledger-cell:nth-child(odd) { border-left: 0; }
  .ledger-cell:nth-child(n+3) { border-top: 1px solid var(--line); }
  .widget, .widget.size-sm { grid-column: span 12; }
  .split { grid-template-columns: 1fr; }
  .cmdk-trigger { min-width: 0; }
  .cmdk-trigger .label-text, .cmdk-trigger kbd { display: none; }
}
@media (max-width: 860px) {
  .shell, html.sidebar-collapsed .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-100%); transition: transform .2s ease; }
  html.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-pop); }
  html.sidebar-collapsed .sidebar .wordmark { display: block !important; }
  html.sidebar-collapsed .sidebar .mark { display: none !important; }
  html.sidebar-collapsed .nav a span, html.sidebar-collapsed .tenant-meta, html.sidebar-collapsed .side-btn span { display: initial; }
  html.sidebar-collapsed .nav a { justify-content: flex-start; padding: 8px 10px; }
  .sidebar-scrim { position: fixed; inset: 0; background: rgba(10,20,34,.45); z-index: 35; }
  .topbar { padding: 0 16px; }
  .topbar .burger { display: grid; }
  .topbar .collapse-btn { display: none; }
  .content { padding: 20px 16px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-mobile-logo { display: block; }
  .req-list { grid-template-columns: 1fr; }
  .table .hide-sm { display: none; }
  .welcome { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .ledger { --cols: 1 !important; }
  .ledger-cell { border-left: 0 !important; border-top: 1px solid var(--line); }
  .ledger-cell:first-child { border-top: 0; }
  .page-head { align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  .sidebar, .topbar, .page-actions, .filters, .pagination, .toasts { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
}
.tabular { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* =====================================================================
   Faz 2 components — admin console, matrix, support, 2FA
   ===================================================================== */
.grow { flex: 1 1 auto; min-width: 0; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; }
.small { font-size: 12.5px; }
.h-sm { font-size: 14px; font-weight: 650; margin: 0 0 8px; }
.is-muted { opacity: .62; }
.narrow { max-width: 760px; }
.input-sm { height: 32px; padding: 0 8px; font-size: 13px; }
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 200px; }
.empty.compact { padding: 28px 16px; gap: 8px; }
.empty.compact p { margin: 0; }
.tag-estimate { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .02em;
  color: var(--warn); background: var(--warn-soft); vertical-align: 1px; }
.ledger-figure.sm { font-size: 1.15rem; }
.btn-light { background: #fff; color: var(--navy); border-color: transparent; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-row.tight { gap: 4px; }
.chip { display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 13px; text-decoration: none; }
.chip:hover { color: var(--ink); border-color: var(--line-strong); }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
html.theme-dark .chip.active { background: var(--emerald); color: #03251A; border-color: var(--emerald); }
.seg-link { display: inline-block; padding: 6px 12px; border-radius: 6px; font-size: 13px; color: var(--muted); text-decoration: none; }
.seg-link.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16,37,62,.12); font-weight: 600; }
.row-actions.start { justify-content: flex-start; }
.inline-form { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.inline-form .field { margin: 0; }
td .inline-form { justify-content: flex-end; align-items: center; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; padding: 14px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.plain-list, .check-list, .steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.plain-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.check-list li { display: flex; gap: 10px; align-items: flex-start; color: var(--muted); }
.check-list .icon { color: var(--emerald-ink); flex: none; margin-top: 3px; }
.steps { counter-reset: step; }
.steps li { counter-increment: step; position: relative; padding-left: 32px; color: var(--muted); }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--emerald-soft); color: var(--emerald-ink); font-size: 12px; font-weight: 700; }
.pick-list { max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; }
.nav-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--emerald); color: #03251A; font-size: 11px; font-weight: 700; display: grid; place-items: center; }

/* status rows (dashboard) */
.status-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.status-list li { display: grid; grid-template-columns: 130px 1fr 44px; align-items: center; gap: 12px; }
.status-list .num { text-align: right; }
.bar-track { display: block; height: 6px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.bar-track > span { display: block; height: 100%; background: var(--emerald); }
.health-tally { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.health-tally.big { font-size: 14px; font-weight: 600; color: var(--ink); }
.meter.mini { height: 4px; margin-top: 4px; width: 80px; margin-left: auto; }
.meter.mini > span.hot { background: var(--warn); }

/* receipt-style price breakdown */
.receipt { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 0; }
.receipt dt { color: var(--muted); }
.receipt dd { margin: 0; text-align: right; }
.receipt .total { padding-top: 10px; border-top: 1px dashed var(--line-strong); color: var(--ink); font-weight: 650; }
.change-list > div { font-size: 13px; line-height: 1.5; }

/* module × feature matrix — the core of tenant independence */
.matrix { display: grid; }
.matrix-module { border-top: 1px solid var(--line); }
.matrix-module:first-child { border-top: 0; }
.matrix-head { display: flex; align-items: center; gap: 14px; padding: 14px 20px; cursor: pointer; }
.matrix-head.static { cursor: default; }
.matrix-head > input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--emerald); flex: none; }
.matrix-head .cell-sub { display: block; }
.module-ico { width: 34px; height: 34px; border-radius: 9px; background: var(--emerald-soft); color: var(--emerald-ink); display: grid; place-items: center; flex: none; }
.matrix-body { padding: 0 20px 12px 68px; display: grid; gap: 2px; }
.matrix-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); }
.matrix-row > span:first-child { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.matrix-row select { width: 210px; flex: none; }
.matrix-row.has-error { outline: 1px solid var(--danger); }
.matrix-row .field-error { flex-basis: 100%; }
.limit-ctl { display: flex; align-items: center; gap: 6px; flex: none; }
.limit-ctl .input-sm.num { width: 110px; }
.input-prefix.sm .input { height: 32px; width: 120px; }
.mode-switch { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); flex: none; }
.mode-switch form { margin: 0; }
.mode-switch button { border: 0; background: transparent; padding: 5px 11px; border-radius: 6px; font: inherit; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.mode-switch button:hover { color: var(--ink); }
.mode-switch button.active { background: var(--surface); color: var(--ink); font-weight: 650; box-shadow: 0 1px 2px rgba(16,37,62,.12); }
.mode-switch form:last-child button.active { color: var(--danger); }
.mode-switch button:focus-visible { box-shadow: var(--focus); outline: none; }

/* notes, threads, grants */
.note-list, .grant-list, .log-list { list-style: none; margin: 0; padding: 0; }
.note-list li { padding: 14px 20px; border-top: 1px solid var(--line); }
.note-list li:first-child { border-top: 0; }
.note-list li.pinned { background: var(--warn-soft); }
.note-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.note-meta .row-actions { margin-left: auto; }
.note-body { margin-top: 6px; white-space: normal; }
.thread { display: grid; gap: 0; }
.msg { padding: 16px 20px; border-top: 1px solid var(--line); }
.msg:first-child { border-top: 0; }
.msg header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; font-size: 13px; }
.msg.staff { background: linear-gradient(90deg, var(--emerald-soft), transparent 40%); }
.msg.internal { background: var(--warn-soft); }
.msg-body { overflow-wrap: anywhere; }
tr.needs-reply td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.grant { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 20px; border-top: 1px solid var(--line); }
.grant:first-child { border-top: 0; }
.grant.pending { background: var(--warn-soft); }
.grant-reason { margin: 8px 0 4px; font-size: 15px; }
.support-banner { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--warn); color: #241400; }
html.theme-dark .support-banner { color: #241400; }
.support-banner p { margin: 0; flex: 1; }
.maint-banner { padding: 8px 24px; background: var(--warn-soft); color: var(--warn); font-size: 13px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.alert.announcement .grow p { margin: 0; }

/* logs, mail preview */
.log-list li { padding: 12px 20px; border-top: 1px solid var(--line); }
.log-head { display: flex; gap: 10px; align-items: center; font-size: 12.5px; }
.log-msg { margin-top: 4px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; overflow-wrap: anywhere; }
.log-list pre, .mail-preview pre { margin: 8px 0 0; padding: 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.mail-preview { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: var(--surface); }
.mail-subject { font-weight: 650; }
.probe-list li { font-size: 13px; }

/* 2FA */
.totp-setup { display: grid; grid-template-columns: 200px 1fr; gap: 24px; align-items: start; }
.qr-box { width: 200px; height: 200px; padding: 10px; border-radius: 12px; background: #fff; border: 1px solid var(--line); display: grid; place-items: center; }
.qr-box svg { width: 100%; height: 100%; }
.code-input { font-size: 20px; letter-spacing: .25em; text-align: center; }
.manual-secret summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.recovery-codes { list-style: none; margin: 0; padding: 14px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px; border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--surface-2); }
.recovery-codes code { font-size: 15px; letter-spacing: .06em; }

@media (max-width: 860px) {
  .totp-setup { grid-template-columns: 1fr; }
  .matrix-body { padding-left: 20px; }
  .matrix-head { flex-wrap: wrap; }
  .matrix-row { flex-wrap: wrap; }
  .matrix-row select { width: 100%; }
  .status-list li { grid-template-columns: 110px 1fr 36px; }
  .grant { flex-direction: column; }
}
@media print {
  .no-print, .sidebar, .topbar { display: none !important; }
  .recovery-codes { background: #fff; }
}
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.table .row-actions { gap: 4px; }
.grant .row-actions { flex: none; }
.auth-form .totp-setup { grid-template-columns: 1fr; justify-items: start; }
.auth-form .qr-box { width: 184px; height: 184px; }
.auth-form .recovery-panel { box-shadow: none; }
.matrix-body, .matrix-row { min-width: 0; max-width: 100%; box-sizing: border-box; }
.matrix-head .grow { flex: 1 1 220px; }
@media (max-width: 860px) {
  .matrix-head { align-items: flex-start; }
  .matrix-head .grow { flex: 1 1 0; }
  .matrix-head .mode-switch { flex-basis: 100%; justify-content: space-between; margin-left: 48px; }
  .matrix-body { padding: 0 12px 12px; }
  .matrix-row > span:first-child { flex: 1 1 100%; }
  .matrix-row form, .matrix-row .limit-ctl { width: 100%; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
}
.matrix { grid-template-columns: minmax(0, 1fr); }
.matrix > *, .matrix-body > * { min-width: 0; }
@media (max-width: 860px) {
  .matrix-head .mode-switch { flex-basis: auto; width: calc(100% - 48px); box-sizing: border-box; }
  .mode-switch form { flex: 1; }
  .mode-switch button { width: 100%; }
}
