/* Concept-Tree Finance v2 - design system (slate + indigo).
   Self-hosted Inter, no external requests. Light, dark and print themes. */

@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
  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;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-rupee.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+20B9;
}

:root {
  color-scheme: light;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-text: #4338ca;
  --primary-soft: #eef2ff;
  --primary-soft-2: #e0e7ff;
  --ring: 0 0 0 3px rgba(79, 70, 229, .22);
  --pos: #047857; --pos-soft: #ecfdf5; --pos-border: #a7f3d0;
  --neg: #be123c; --neg-soft: #fff1f2; --neg-border: #fecdd3;
  --warn: #b45309; --warn-soft: #fffbeb; --warn-border: #fde68a;
  --info: #1d4ed8; --info-soft: #eff6ff; --info-border: #bfdbfe;
  --series-income: #2a78d6;
  --series-expense: #eb6834;
  --heat: 235, 104, 52;
  --grid-line: #e9eef5;
  --axis-line: #cbd5e1;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 20px 45px -12px rgba(15, 23, 42, .25), 0 6px 16px rgba(15, 23, 42, .08);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --sidebar-w: 252px;
  --topbar-h: 60px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120; --surface: #111a2c; --surface-2: #152036; --surface-3: #1b2740;
  --border: #243149; --border-strong: #33425e;
  --text: #e5e9f2; --text-2: #c7cfdd; --muted: #94a3b8; --faint: #64748b;
  --primary: #6366f1; --primary-hover: #818cf8; --primary-text: #a5b4fc;
  --primary-soft: rgba(99, 102, 241, .16); --primary-soft-2: rgba(99, 102, 241, .26);
  --ring: 0 0 0 3px rgba(129, 140, 248, .35);
  --pos: #34d399; --pos-soft: rgba(52, 211, 153, .12); --pos-border: rgba(52, 211, 153, .3);
  --neg: #fb7185; --neg-soft: rgba(251, 113, 133, .12); --neg-border: rgba(251, 113, 133, .3);
  --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .12); --warn-border: rgba(251, 191, 36, .3);
  --info: #60a5fa; --info-soft: rgba(96, 165, 250, .12); --info-border: rgba(96, 165, 250, .3);
  --series-income: #3987e5; --series-expense: #d95926; --heat: 217, 89, 38;
  --grid-line: #1f2b42; --axis-line: #33425e;
  --shadow-sm: none; --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1120; --surface: #111a2c; --surface-2: #152036; --surface-3: #1b2740;
    --border: #243149; --border-strong: #33425e;
    --text: #e5e9f2; --text-2: #c7cfdd; --muted: #94a3b8; --faint: #64748b;
    --primary: #6366f1; --primary-hover: #818cf8; --primary-text: #a5b4fc;
    --primary-soft: rgba(99, 102, 241, .16); --primary-soft-2: rgba(99, 102, 241, .26);
    --ring: 0 0 0 3px rgba(129, 140, 248, .35);
    --pos: #34d399; --pos-soft: rgba(52, 211, 153, .12); --pos-border: rgba(52, 211, 153, .3);
    --neg: #fb7185; --neg-soft: rgba(251, 113, 133, .12); --neg-border: rgba(251, 113, 133, .3);
    --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, .12); --warn-border: rgba(251, 191, 36, .3);
    --info: #60a5fa; --info-soft: rgba(96, 165, 250, .12); --info-border: rgba(96, 165, 250, .3);
    --series-income: #3987e5; --series-expense: #d95926; --heat: 217, 89, 38;
    --grid-line: #1f2b42; --axis-line: #33425e;
    --shadow-sm: none; --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .6);
  }
}

/* ---------------- Base ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 12px); }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.011em; color: var(--text); }
h1 { font-size: 1.55rem; font-weight: 650; }
h2 { font-size: 1.02rem; font-weight: 620; }
h3 { font-size: .95rem; font-weight: 620; }
p { margin: 0 0 .8em; }
small { font-size: .82em; }
code, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
svg { flex-shrink: 0; }
.icon { display: inline-block; vertical-align: middle; }
::selection { background: var(--primary-soft-2); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 200; background: var(--primary); color: #fff; padding: 8px 14px; border-radius: var(--radius-sm); }
.skip-link:focus { top: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------------- Shell ---------------- */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 60;
  display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border);
  transition: transform .22s var(--ease);
}
.sb-brand { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 10px; }
.sb-logo { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.sb-logo:hover { text-decoration: none; }
.sb-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex-shrink: 0;
  background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%); box-shadow: 0 4px 10px -2px rgba(79, 70, 229, .45);
}
.sb-name { font-weight: 650; font-size: .92rem; line-height: 1.2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-name small { display: block; font-weight: 500; font-size: .74rem; color: var(--muted); }
.sidebar .sb-close { display: none; }
.sb-new { padding: 6px 14px 10px; }
.sb-nav { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.sb-section { font-size: .68rem; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); padding: 12px 10px 5px; }
.sb-link {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 6px 10px; margin: 1px 0; border-radius: 9px;
  color: var(--text-2); font-size: .885rem; font-weight: 500; border: 0; background: none; cursor: pointer; font-family: inherit; text-align: left;
  position: relative; transition: background .12s, color .12s;
}
.sb-link .icon { color: var(--muted); transition: color .12s; }
.sb-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.sb-link:hover .icon { color: var(--text-2); }
.sb-link.is-active { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.sb-link.is-active .icon { color: var(--primary-text); }
.sb-link.is-active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.sb-foot { border-top: 1px solid var(--border); padding: 10px; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 4px 4px 8px; }
.sb-user-name { flex: 1; min-width: 0; font-size: .84rem; font-weight: 600; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user-name small { display: block; font-weight: 450; color: var(--muted); font-size: .74rem; }
.sb-logout-form { margin: 0; }
.sb-logout:hover { background: var(--neg-soft); color: var(--neg); }
.sb-logout:hover .icon { color: var(--neg); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: var(--primary-soft); color: var(--primary-text); font-weight: 650; font-size: .82rem;
}
.sb-backdrop { display: none; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: inline-block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: inline-block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}

.main { margin-left: var(--sidebar-w); min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 28px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(10px); backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .topbar-menu { display: none; }
.topbar-search {
  flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 10px 0 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--muted);
}
.topbar-search:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.topbar .topbar-search input { flex: 1; min-width: 0; width: auto; border: 0; outline: 0; background: none; height: 100%; font: inherit; color: var(--text); padding: 0; box-shadow: none; border-radius: 0; }
.topbar .topbar-search input:focus { box-shadow: none; }
.topbar .topbar-search input::-webkit-search-cancel-button { cursor: pointer; }
.kbd { border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; font-size: .72rem; color: var(--muted); background: var(--surface-2); }
.topbar-new { margin-left: auto; }

.page { width: 100%; max-width: 1240px; margin: 0 auto; padding: 26px 32px 48px; flex: 1; }
.page.page-wide { max-width: 1560px; }
.page.page-report { max-width: 1080px; }
.show-sm { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head-text { min-width: 0; }
.page-sub { color: var(--muted); margin: 4px 0 0; font-size: .9rem; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.page-foot { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--faint); font-size: .78rem; }
.print-head { display: none; }

/* ---------------- Layout helpers ---------------- */
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.span-2 { grid-column: span 2; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mt-0 { margin-top: 0 !important; } .mb-0 { margin-bottom: 0 !important; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.small { font-size: .84rem; } .xsmall { font-size: .76rem; }
.pos { color: var(--pos); } .neg { color: var(--neg); } .warn-text { color: var(--warn); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.strong { font-weight: 620; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.hide, [hidden] { display: none !important; }

/* ---------------- Cards ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: .84rem; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head { padding: 16px 20px 0; }
.card-foot { margin-top: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-link { font-size: .84rem; font-weight: 550; display: inline-flex; align-items: center; gap: 4px; }

/* ---------------- KPI tiles ---------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 16px 18px; color: var(--text); min-width: 0;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.kpi:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: 0 6px 18px -8px rgba(15, 23, 42, .18); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-label { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; font-weight: 550; color: var(--muted); }
.kpi-value { font-size: 1.62rem; font-weight: 650; letter-spacing: -.02em; margin-top: 8px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { margin-top: 6px; font-size: .8rem; color: var(--muted); line-height: 1.45; }
.kpi-hero .kpi-value { font-size: 2rem; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: .74rem; font-weight: 650; padding: 2px 7px 2px 5px; border-radius: 999px; }
.delta-good { background: var(--pos-soft); color: var(--pos); }
.delta-bad { background: var(--neg-soft); color: var(--neg); }
.delta-flat { background: var(--surface-3); color: var(--muted); }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px;
  border-radius: 10px; border: 1px solid transparent; font: 550 .88rem/1 var(--font); cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s, transform .06s; text-decoration: none !important;
  position: relative; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .25), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn-ghost { background: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger { background: #e11d48; color: #fff; }
.btn-danger:hover { background: #be123c; }
.btn-danger-soft { background: var(--neg-soft); color: var(--neg); border-color: var(--neg-border); }
.btn-danger-soft:hover { border-color: var(--neg); }
.btn-sm { height: 32px; padding: 0 11px; font-size: .82rem; border-radius: 8px; gap: 5px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: .76rem; border-radius: 7px; gap: 4px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-busy { opacity: .6; pointer-events: none; }
.btn.is-busy::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; margin-left: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 9px; border: 0; background: none;
  color: var(--muted); cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ---------------- Forms ---------------- */
.field { margin-bottom: 14px; min-width: 0; }
.field > label, .label { display: block; font-size: .82rem; font-weight: 580; color: var(--text-2); margin-bottom: 6px; }
.label-opt { font-weight: 450; color: var(--faint); }
input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="password"], input[type="email"], input[type="tel"], input[type="month"], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; font: 400 .92rem/1.2 var(--font); color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; outline: 0;
  transition: border-color .12s, box-shadow .12s; appearance: none; -webkit-appearance: none;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; line-height: 1.5; resize: vertical; }
select {
  padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: var(--ring); }
input[type="date"] { min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--primary); vertical-align: middle; margin: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; cursor: pointer; }
.hint { font-size: .78rem; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 16px; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.input-money { position: relative; }
.input-money > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 550; pointer-events: none; }
.input-money input { padding-left: 28px; font-variant-numeric: tabular-nums; font-weight: 550; }
.input-money.lg input { height: 52px; font-size: 1.35rem; font-weight: 650; padding-left: 34px; border-radius: 12px; }
.input-money.lg > span { font-size: 1.2rem; left: 14px; }
.amount-help { font-size: .8rem; color: var(--muted); margin-top: 6px; min-height: 1.2em; font-variant-numeric: tabular-nums; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

/* ---------------- Type picker (new transaction) ---------------- */
.type-picker { display: flex; flex-wrap: wrap; gap: 8px; padding-bottom: 4px; margin-bottom: 16px; }
.type-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: 550 .86rem var(--font);
  cursor: pointer; white-space: nowrap; transition: all .12s;
}
.type-btn:hover { border-color: var(--border-strong); color: var(--text); }
.type-btn.is-on { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 12px -4px rgba(79, 70, 229, .5); }
.type-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.type-btn.is-on .dot { background: #fff; }
.dot-expense { background: var(--series-expense) !important; }
.dot-income { background: var(--series-income) !important; }
.entry-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.entry-layout > * + * { margin-top: 0 !important; }
.preview-card { position: sticky; top: calc(var(--topbar-h) + 16px); }
.preview-lines { list-style: none; margin: 0; padding: 0; }
.preview-lines li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: .86rem; }
.preview-lines li:last-child { border-bottom: 0; }
.preview-lines .pl-side { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); display: block; }
.impact { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); font-size: .84rem; }
.impact div { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; }
.dropzone {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1.5px dashed var(--border-strong);
  border-radius: 12px; background: var(--surface-2); cursor: pointer; color: var(--muted); font-size: .86rem;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.dropzone input { display: none; }
.dz-name { color: var(--text); font-weight: 550; word-break: break-all; }

/* ---------------- Pills / chips ---------------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 620; white-space: nowrap; border: 1px solid transparent; line-height: 1;
}
.pill-neutral { background: var(--surface-3); color: var(--text-2); border-color: var(--border); }
.pill-income { background: rgba(42, 120, 214, .1); color: #1c5cab; border-color: rgba(42, 120, 214, .22); }
.pill-expense { background: rgba(235, 104, 52, .1); color: #b4471b; border-color: rgba(235, 104, 52, .24); }
.pill-violet { background: rgba(124, 58, 237, .09); color: #6d28d9; border-color: rgba(124, 58, 237, .2); }
.pill-amber { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.pill-teal { background: rgba(13, 148, 136, .1); color: #0f766e; border-color: rgba(13, 148, 136, .22); }
.pill-success { background: var(--pos-soft); color: var(--pos); border-color: var(--pos-border); }
.pill-danger { background: var(--neg-soft); color: var(--neg); border-color: var(--neg-border); }
.pill-info { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }
:root[data-theme="dark"] .pill-income { color: #93c5fd; }
:root[data-theme="dark"] .pill-expense { color: #fdba74; }
:root[data-theme="dark"] .pill-violet { color: #c4b5fd; }
:root[data-theme="dark"] .pill-teal { color: #5eead4; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pill-income { color: #93c5fd; }
  :root:not([data-theme="light"]) .pill-expense { color: #fdba74; }
  :root:not([data-theme="light"]) .pill-violet { color: #c4b5fd; }
  :root:not([data-theme="light"]) .pill-teal { color: #5eead4; }
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 999px; font-size: .82rem; font-weight: 550;
  color: var(--text-2); background: var(--surface); border: 1px solid var(--border); white-space: nowrap;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); text-decoration: none; }
.chip.is-on { background: var(--primary-soft); color: var(--primary-text); border-color: var(--primary-soft-2); }

/* ---------------- Filters / period ---------------- */
.toolbar { display: flex; gap: 12px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.period { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.period-custom { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.period-custom input[type="date"] { width: 150px; height: 32px; font-size: .84rem; border-radius: 8px; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.filters .field { margin: 0; }
.filters input, .filters select { height: 36px; font-size: .86rem; border-radius: 9px; }
.filter-summary { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: .86rem; color: var(--muted); }
.filter-summary strong { color: var(--text); }

/* ---------------- Tables ---------------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card > .table-wrap:first-child { border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; }
.table { font-size: .88rem; }
.table th {
  text-align: left; font-size: .7rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
  background: var(--surface-2); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num, .table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tr.is-void td { color: var(--faint); }
.table tr.is-void .t-desc { text-decoration: line-through; }
.table tr[data-href] { cursor: pointer; }
.table .t-desc { font-weight: 520; color: var(--text); }
.table .t-meta { display: block; font-size: .76rem; color: var(--muted); margin-top: 2px; }
.table .t-actions { white-space: nowrap; text-align: right; width: 1%; }
.table tfoot td { font-weight: 650; border-top: 2px solid var(--border-strong); border-bottom: 0; background: var(--surface-2); }
.card-flush .table th:first-child, .card-flush .table td:first-child { padding-left: 20px; }
.card-flush .table th:last-child, .card-flush .table td:last-child { padding-right: 20px; }
.table-compact td { padding: 7px 10px; }
.table-compact th { padding: 7px 10px; }

/* Statements */
.stmt { font-size: .9rem; }
.stmt td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.stmt th { text-align: left; font-size: .7rem; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--border-strong); }
.stmt .num, .stmt th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stmt tr.sec td { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--primary-text); padding-top: 20px; border-bottom: 1px solid var(--border-strong); background: none; }
.stmt tr.sec:first-child td { padding-top: 8px; }
.stmt tr.grp td { font-weight: 620; color: var(--text); background: var(--surface-2); }
.stmt tr.item td:first-child { padding-left: 26px; color: var(--text-2); }
.stmt tr.solo td:first-child { color: var(--text); font-weight: 560; }
.stmt tr.solo td a { color: inherit; }
.stmt tr.item td a { color: inherit; }
.stmt tr.item td a:hover { color: var(--primary-text); }
.stmt tr.sub td { font-weight: 600; border-bottom: 1px solid var(--border-strong); }
.stmt tr.total td { font-weight: 700; border-top: 1px solid var(--border-strong); border-bottom: 2px solid var(--border-strong); background: var(--surface-2); }
.stmt tr.grand td { font-weight: 750; font-size: .98rem; background: var(--primary-soft); border-bottom: 0; color: var(--text); }
.stmt tr.note td { font-size: .78rem; color: var(--muted); border-bottom: 0; }
.stmt .flag { font-size: .7rem; font-weight: 650; color: var(--neg); margin-left: 6px; }
.stmt td.chg { font-size: .78rem; }
.stmt-wrap { max-width: 880px; }

/* Monthly matrix */
.matrix { font-size: .82rem; }
.matrix th, .matrix td { padding: 7px 9px; white-space: nowrap; }
.matrix td.num { font-variant-numeric: tabular-nums; }
.matrix .sticky-col { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 190px; max-width: 240px; white-space: normal; box-shadow: 1px 0 0 var(--border); }
.matrix thead .sticky-col { background: var(--surface-2); z-index: 2; }
.matrix tr.grp td { background: var(--surface-2); font-weight: 620; }
.matrix tr.grp td.sticky-col { background: var(--surface-2); }
.matrix tr.total td { font-weight: 700; background: var(--surface-3); border-top: 1px solid var(--border-strong); }
.matrix tr.total td.sticky-col { background: var(--surface-3); }
.matrix tr.grand td { font-weight: 750; background: var(--primary-soft); }
.matrix tr.grand td.sticky-col { background: var(--primary-soft); }
.matrix td.col-total { font-weight: 650; background: var(--surface-2); }
.matrix td.future { color: var(--faint); }
.matrix td.h1 { background: rgba(var(--heat), .06); } .matrix td.h2 { background: rgba(var(--heat), .12); }
.matrix td.h3 { background: rgba(var(--heat), .19); } .matrix td.h4 { background: rgba(var(--heat), .27); }
.matrix tr.solo td.sticky-col { font-weight: 560; }
.matrix a { color: inherit; }
.matrix a:hover { color: var(--primary-text); }

/* ---------------- Alerts ---------------- */
.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid; font-size: .88rem;
  margin-bottom: 14px; line-height: 1.5;
}
.alert > .icon { margin-top: 1px; }
.alert p:last-child { margin-bottom: 0; }
.alert-info { background: var(--info-soft); border-color: var(--info-border); color: var(--text); }
.alert-info > .icon { color: var(--info); }
.alert-warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--text); }
.alert-warn > .icon { color: var(--warn); }
.alert-danger { background: var(--neg-soft); border-color: var(--neg-border); color: var(--text); }
.alert-danger > .icon { color: var(--neg); }
.alert-success { background: var(--pos-soft); border-color: var(--pos-border); color: var(--text); }
.alert-success > .icon { color: var(--pos); }
.alert a { font-weight: 600; }
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .87rem; }
.alert-list li:last-child { border-bottom: 0; }
.alert-list .icon { margin-top: 2px; }
.alert-list .i-warn { color: var(--warn); } .alert-list .i-danger { color: var(--neg); } .alert-list .i-info { color: var(--info); } .alert-list .i-ok { color: var(--pos); }

/* ---------------- Empty state ---------------- */
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty > .icon { color: var(--faint); margin-bottom: 8px; }
.empty-title { font-weight: 620; color: var(--text); margin-bottom: 4px; }
.empty p { max-width: 420px; margin: 0 auto 12px; font-size: .88rem; }

/* ---------------- Charts & viz ---------------- */
.chart-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--grid-line); stroke-width: 1; }
.chart .axis { stroke: var(--axis-line); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 12px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .bar-income { fill: var(--series-income); }
.chart .bar-expense { fill: var(--series-expense); }
.chart .bar { transition: opacity .12s; outline: none; }
.chart .hit { fill: transparent; }
.chart:hover .bar { opacity: .55; }
.chart .hit:hover ~ .bar, .chart .bar:hover, .chart .bar:focus { opacity: 1; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8rem; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .l-income { background: var(--series-income); }
.legend .l-expense { background: var(--series-expense); }
.viz-tip {
  position: fixed; z-index: 300; pointer-events: none; background: #0f172a; color: #fff; border-radius: 10px;
  padding: 8px 11px; font-size: .78rem; line-height: 1.5; box-shadow: var(--shadow-lg); max-width: 260px;
}
.viz-tip b { display: block; font-size: .8rem; margin-bottom: 2px; }
.viz-tip .vt-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.viz-tip .vt-key { width: 10px; height: 2px; border-radius: 2px; display: inline-block; }
:root[data-theme="dark"] .viz-tip { background: #e5e9f2; color: #0f172a; }

.barlist { list-style: none; margin: 0; padding: 0; }
.barlist li { padding: 7px 0; }
.bl-head { display: flex; justify-content: space-between; gap: 10px; font-size: .86rem; margin-bottom: 6px; }
.bl-name { color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-name a { color: inherit; }
.bl-val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bl-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bl-fill { display: block; height: 100%; border-radius: 999px; }
.fill-expense { background: var(--series-expense); }
.fill-income { background: var(--series-income); }
.meter { height: 8px; border-radius: 999px; background: var(--primary-soft); overflow: hidden; min-width: 80px; }
.meter-fill { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.meter.m-ok .meter-fill { background: var(--primary); }
.meter.m-warning { background: rgba(250, 178, 25, .18); } .meter.m-warning .meter-fill { background: #e59f00; }
.meter.m-critical { background: rgba(208, 59, 59, .15); } .meter.m-critical .meter-fill { background: #d03b3b; }

.split { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.split b { color: var(--text); font-weight: 620; font-variant-numeric: tabular-nums; }

/* ---------------- Lists ---------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 560; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-meta { font-size: .76rem; color: var(--muted); margin-top: 1px; }
.list-item .li-amt { font-weight: 620; font-variant-numeric: tabular-nums; white-space: nowrap; }
.li-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-3); color: var(--text-2); }
.li-icon.expense { background: rgba(235, 104, 52, .12); color: #c2511f; }
.li-icon.income { background: rgba(42, 120, 214, .12); color: #1c5cab; }
.li-icon.violet { background: rgba(124, 58, 237, .1); color: #6d28d9; }
.li-icon.amber { background: var(--warn-soft); color: var(--warn); }
.li-icon.teal { background: rgba(13, 148, 136, .12); color: #0f766e; }

.dl { display: grid; grid-template-columns: minmax(110px, 180px) 1fr; gap: 8px 16px; margin: 0; font-size: .88rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; word-break: break-word; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 9px 14px; font-size: .87rem; font-weight: 550; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-on { color: var(--primary-text); border-bottom-color: var(--primary); }

.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; font-size: .84rem; }

.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.report-card { display: flex; flex-direction: column; gap: 6px; color: var(--text); padding: 18px; }
.report-card:hover { text-decoration: none; border-color: var(--border-strong); }
.report-card .rc-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); margin-bottom: 6px; }
.report-card .rc-title { font-weight: 620; }
.report-card .rc-text { font-size: .84rem; color: var(--muted); }
.report-card .rc-fig { margin-top: auto; padding-top: 8px; font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------------- Modal & toast ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 250; background: rgba(15, 23, 42, .5); display: flex; align-items: center; justify-content: center;
  padding: 16px; animation: fade-in .15s var(--ease);
}
.modal {
  width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop-in .18s var(--ease);
}
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 6px; }
.modal-head h2 { flex: 1; font-size: 1.05rem; }
.modal-body { padding: 6px 20px 8px; font-size: .9rem; color: var(--text-2); }
.modal-body ul { margin: 6px 0 0; padding-left: 18px; }
.modal-body li { margin: 6px 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; flex-wrap: wrap; }
.modal-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--warn-soft); color: var(--warn); }
.modal-icon.danger { background: var(--neg-soft); color: var(--neg); }
.modal-icon.info { background: var(--primary-soft); color: var(--primary-text); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 260; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 420px; padding: 11px 12px 11px 14px;
  background: #0f172a; color: #f8fafc; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: .87rem; animation: pop-in .2s var(--ease);
}
.toast .icon { flex-shrink: 0; }
.toast.t-success .icon { color: #34d399; } .toast.t-error .icon { color: #fb7185; } .toast.t-info .icon { color: #93c5fd; }
.toast .t-msg { flex: 1; min-width: 0; }
.toast .t-action { background: rgba(255, 255, 255, .12); color: #fff; border: 0; border-radius: 8px; height: 28px; padding: 0 10px; font: 600 .78rem var(--font); cursor: pointer; }
.toast .t-action:hover { background: rgba(255, 255, 255, .2); }
.toast .t-close { background: none; border: 0; color: #94a3b8; cursor: pointer; padding: 2px; display: grid; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: all .18s; }
:root[data-theme="dark"] .toast { background: #e5e9f2; color: #0f172a; }
:root[data-theme="dark"] .toast .t-action { background: rgba(15, 23, 42, .1); color: #0f172a; }

/* ---------------- Bottom nav (phones) ---------------- */
.bottom-nav { display: none; }

/* ---------------- Auth pages ---------------- */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(99, 102, 241, .16), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, rgba(42, 120, 214, .12), transparent 60%), var(--bg);
}
.auth-box { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 22px; }
.auth-brand .sb-mark { width: 42px; height: 42px; border-radius: 12px; }
.auth-brand-name { font-weight: 700; font-size: 1.1rem; line-height: 1.2; }
.auth-brand-name small { display: block; color: var(--muted); font-weight: 500; font-size: .8rem; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 28px; }
.auth-card h1 { font-size: 1.3rem; margin-bottom: 4px; }
.auth-card .muted { font-size: .88rem; }
.auth-foot { text-align: center; color: var(--faint); font-size: .78rem; margin-top: 18px; }

/* ---------------- Voucher ---------------- */
.voucher { max-width: 820px; }
.voucher-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.voucher-no { font-size: .8rem; color: var(--muted); }
.voucher-amount { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; }
.voucher-words { font-size: .84rem; color: var(--text-2); font-style: italic; }
.sign-row { display: none; }
.receipt-preview { max-width: 100%; border-radius: 12px; border: 1px solid var(--border); display: block; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1180px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: minmax(0, 1fr); }
  .entry-layout { grid-template-columns: minmax(0, 1fr); }
  .preview-card { position: static; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-102%); box-shadow: var(--shadow-lg); }
  .sidebar.is-open { transform: none; }
  .sidebar .sb-close { display: inline-grid; }
  .sb-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(15, 23, 42, .45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .sb-backdrop.is-open { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .topbar { padding: 0 16px; }
  .topbar .topbar-menu { display: inline-grid; }
  .page { padding: 20px 20px 40px; }
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .topbar .kbd, .topbar-new span { display: none; }
  .topbar-new { padding: 0 10px; }
  .page { padding: 16px 16px 96px; }
  .page-head { margin-bottom: 14px; align-items: flex-start; }
  h1 { font-size: 1.3rem; }
  .g-2, .g-3, .g-4, .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 13px 14px; }
  .kpi-value { font-size: 1.22rem; }
  .kpi-hero { grid-column: span 2; }
  .kpi-hero .kpi-value { font-size: 1.6rem; }
  .card { padding: 16px; border-radius: 14px; }
  .card-flush { padding: 0; }
  .card-flush > .card-head { padding: 14px 16px 0; }
  .card-flush .table th:first-child, .card-flush .table td:first-child { padding-left: 14px; }
  .card-flush .table th:last-child, .card-flush .table td:last-child { padding-right: 14px; }
  .toast-stack { left: 12px; right: 12px; bottom: 84px; align-items: stretch; }
  .toast { min-width: 0; max-width: none; }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  .page-actions .btn span.lbl { display: none; }
  .period-custom input[type="date"] { width: 132px; }
  .hide-sm { display: none !important; }
  .show-sm { display: inline; }
  .stmt .dec { display: none; }
  .stmt td, .stmt th { padding-left: 8px; padding-right: 8px; }
  .stmt tr.item td:first-child { padding-left: 16px; }

  /* Tables that turn into cards on phones */
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { padding: 12px 14px; border-bottom: 1px solid var(--border); position: relative; }
  .table-cards tbody tr:last-child { border-bottom: 0; }
  .table-cards td { border: 0 !important; padding: 0 !important; background: none !important; }
  .table-cards td.num { text-align: left; }
  .table-cards td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .76rem; }
  .table-cards td.tc-amount { position: absolute; right: 14px; top: 12px; width: auto; font-weight: 650; }
  .table-cards td.tc-amount::before { content: none; }
  .table-cards td.tc-main { padding-right: 110px !important; }
  .table-cards td.tc-hide { display: none; }
  .table-cards td.t-actions { text-align: left; margin-top: 8px; }
  .table-cards tfoot tr { background: var(--surface-2); }

  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    height: calc(64px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  .bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 64px;
    color: var(--muted); font: 550 .68rem var(--font); background: none; border: 0; cursor: pointer; text-decoration: none;
  }
  .bottom-nav a.is-active { color: var(--primary-text); }
  .bottom-nav .bn-fab {
    width: 54px; height: 54px; margin: -22px auto 0; border-radius: 18px; background: var(--primary); color: #fff;
    box-shadow: 0 10px 22px -6px rgba(79, 70, 229, .6);
  }
  .matrix .sticky-col { min-width: 150px; }
  .type-picker { flex-wrap: nowrap; overflow-x: auto; margin-left: -16px; margin-right: -16px; padding: 0 16px 6px; scrollbar-width: none; }
  .type-picker::-webkit-scrollbar { display: none; }
  .chart-scroll .chart { min-width: 600px; }
}
@media (max-width: 380px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .kpi-hero { grid-column: auto; }
}

/* ---------------- Print (A4) ---------------- */
@media print {
  @page { size: A4; margin: 14mm 12mm 14mm; }
  @page wide { size: A4 landscape; margin: 10mm; }
  :root, :root[data-theme="dark"] {
    color-scheme: light; --bg: #fff; --surface: #fff; --surface-2: #f4f6f8; --surface-3: #eef1f4; --border: #d5dbe3;
    --border-strong: #9aa6b5; --text: #000; --text-2: #1f2933; --muted: #4b5563; --faint: #6b7280; --primary-text: #1e1b4b;
    --primary-soft: #eef0fb; --pos: #065f46; --neg: #9f1239;
  }
  body { background: #fff; font-size: 10pt; }
  .sidebar, .sb-backdrop, .topbar, .bottom-nav, .no-print, .page-actions, .toast-stack, .viz-tip, .skip-link, .page-foot { display: none !important; }
  .main { margin: 0; }
  .page, .page.page-wide { max-width: none; padding: 0; }
  .print-landscape { page: wide; }
  .page-head { display: none; }
  .print-head { display: block; text-align: center; border-bottom: 1.5px solid #000; padding-bottom: 8px; margin-bottom: 12px; }
  .ph-org { font-size: 15pt; font-weight: 700; letter-spacing: .01em; }
  .ph-addr { font-size: 8.5pt; color: #333; margin-top: 2px; }
  .ph-title { font-size: 12pt; font-weight: 700; margin-top: 8px; text-transform: uppercase; letter-spacing: .06em; }
  .ph-sub { font-size: 9.5pt; margin-top: 2px; }
  .ph-gen { font-size: 7.5pt; color: #555; margin-top: 4px; }
  .card, .kpi { border: 0; box-shadow: none; padding: 0; border-radius: 0; break-inside: auto; }
  .card + .card { margin-top: 10px; }
  .card-head { margin-bottom: 6px; }
  .grid { gap: 10px; }
  .table-wrap { overflow: visible; }
  .stmt td, .stmt th, .table td, .table th, .matrix td, .matrix th { padding: 3px 6px; }
  .matrix { font-size: 7.5pt; }
  .matrix .sticky-col { position: static; box-shadow: none; min-width: 0; }
  tr, td { break-inside: avoid; }
  thead { display: table-header-group; }
  a { color: inherit !important; text-decoration: none !important; }
  .chart { max-height: 60mm; }
  .sign-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 60px; font-size: 9pt; text-align: center; }
  .sign-row div { border-top: 1px solid #000; padding-top: 4px; }
  .pill { border: 1px solid #999; background: none !important; color: #000 !important; }
}
