/* Gangotri Lekha — interface stylesheet
   Ledger ink navy, paper, marigold. Serif for statements & titles, sans for work. */

@font-face { font-family: "Instrument Sans"; src: url("../fonts/InstrumentSans-Regular.ttf") format("truetype"); font-weight: 400 600; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("../fonts/InstrumentSans-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("../fonts/InstrumentSans-Italic.ttf") format("truetype"); font-style: italic; font-display: swap; }
@font-face { font-family: "IBM Plex Serif"; src: url("../fonts/IBMPlexSerif-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Serif"; src: url("../fonts/IBMPlexSerif-Bold.ttf") format("truetype"); font-weight: 600 700; font-display: swap; }

:root {
  --ink: #142b4c;
  --ink-2: #1d3a63;
  --ink-3: #2b4c7c;
  --paper: #f4f6f9;
  --sheet: #ffffff;
  --rule: #d9dfe8;
  --rule-2: #e9edf3;
  --text: #1b2434;
  --muted: #5d6a7d;
  --faint: #8b96a6;
  --marigold: #d99a12;
  --marigold-soft: #fff4d9;
  --dr: #0e6e66;
  --dr-soft: #e3f3f1;
  --cr: #8b3a62;
  --cr-soft: #f7e8ef;
  --ok: #1e7a4c;
  --ok-soft: #e4f4ea;
  --warn: #9a6200;
  --warn-soft: #fff1d6;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --info: #24589c;
  --info-soft: #e7effa;
  --sans: "Instrument Sans", "Segoe UI", "Nirmala UI", "Noto Sans", system-ui, sans-serif;
  --serif: "IBM Plex Serif", Georgia, "Nirmala UI", serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  --r-sm: 5px;
  --r-md: 8px;
  --r-lg: 12px;
  --sidebar: 248px;
  --top: 58px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--text); font: 14px/1.5 var(--sans); }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--serif); color: var(--ink); line-height: 1.25; margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 .8em; }
small, .small { font-size: 12.5px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.dr { color: var(--dr); }
.cr { color: var(--cr); }
.neg { color: var(--bad); }
.pos { color: var(--ok); }
.ic { flex: none; vertical-align: -3px; }
:focus-visible { outline: 2px solid var(--marigold); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 99; border-radius: var(--r-sm); }
.skip:focus { left: 8px; }

/* ── Shell ───────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #cdd7e6; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; scrollbar-width: thin; scrollbar-color: var(--ink-3) transparent; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 14px; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand b { display: block; font-family: var(--serif); font-size: 17px; letter-spacing: .2px; }
.brand span { display: block; font-size: 11.5px; color: #9fb0c8; }
.nav { padding: 8px 10px 24px; flex: 1; }
.nav details { border-radius: var(--r-md); }
.nav summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-md); cursor: pointer; color: #dbe3ef; font-weight: 500; user-select: none; }
.nav summary::-webkit-details-marker { display: none; }
.nav summary:hover { background: rgba(255,255,255,.06); }
.nav summary .ic:last-child { margin-left: auto; transition: transform .15s; opacity: .55; }
.nav details[open] > summary .ic:last-child { transform: rotate(90deg); }
.nav details.current > summary { color: #fff; }
.nav details.current > summary .ic:first-child { color: var(--marigold); }
.nav .sub { padding: 2px 0 8px 38px; display: grid; gap: 1px; }
.nav .sub a { color: #b5c3d8; padding: 5px 10px; border-radius: var(--r-sm); font-size: 13.5px; display: block; position: relative; }
.nav .sub a:hover { color: #fff; background: rgba(255,255,255,.05); text-decoration: none; }
.nav .sub a[aria-current="page"] { color: #fff; background: rgba(217,154,18,.16); }
.nav .sub a[aria-current="page"]::before { content: ""; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 3px; border-radius: 2px; background: var(--marigold); }
.nav a.single { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-md); color: #dbe3ef; font-weight: 500; }
.nav a.single:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.nav a.single[aria-current="page"] { background: rgba(217,154,18,.16); color: #fff; }
.nav a.single[aria-current="page"] .ic { color: var(--marigold); }
.nav .locked { opacity: .5; }
.side-foot { padding: 12px 18px 16px; font-size: 12px; color: #8ea0bb; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot b { color: #e9eef6; font-weight: 600; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { height: var(--top); background: var(--sheet); border-bottom: 1px solid var(--rule); display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 20; }
.top .menu-btn { display: none; }
.ctx { display: flex; gap: 8px; align-items: center; min-width: 0; }
.ctx form { display: flex; gap: 6px; align-items: center; margin: 0; }
.ctx select { border: 1px solid var(--rule); background: var(--paper); border-radius: 999px; padding: 5px 28px 5px 12px; font: inherit; font-size: 13px; max-width: 260px; color: var(--ink); font-weight: 600; }
.top .search { flex: 1; max-width: 420px; position: relative; margin-left: auto; }
.top .search input { width: 100%; border: 1px solid var(--rule); background: var(--paper); border-radius: 999px; padding: 7px 14px 7px 34px; font: inherit; }
.top .search .ic { position: absolute; left: 12px; top: 9px; color: var(--faint); }
.search-results { position: absolute; top: 40px; left: 0; right: 0; background: #fff; border: 1px solid var(--rule); border-radius: var(--r-md); box-shadow: 0 12px 32px rgba(20,43,76,.16); max-height: 420px; overflow: auto; padding: 6px; }
.search-results a { display: block; padding: 7px 10px; border-radius: var(--r-sm); color: var(--text); }
.search-results a small { color: var(--muted); margin-left: 6px; }
.search-results a:hover, .search-results a.on { background: var(--paper); text-decoration: none; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--ink); cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--paper); border-color: var(--rule); text-decoration: none; }
.icon-btn .dot { position: absolute; top: 4px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }
.net { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--rule); color: var(--muted); display: inline-flex; gap: 5px; align-items: center; }
.net.off { background: var(--warn-soft); color: var(--warn); border-color: #f0d79f; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 3px 8px 3px 3px; border-radius: 999px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--paper); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; }
.user-menu .who { line-height: 1.15; }
.user-menu .who b { display: block; font-size: 13px; }
.user-menu .who small { color: var(--muted); font-size: 11.5px; }
.drop { position: absolute; right: 0; top: 44px; background: #fff; border: 1px solid var(--rule); border-radius: var(--r-md); box-shadow: 0 12px 32px rgba(20,43,76,.16); min-width: 220px; padding: 6px; z-index: 30; }
.drop a, .drop button { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; padding: 8px 10px; border-radius: var(--r-sm); color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; }
.drop a:hover, .drop button:hover { background: var(--paper); text-decoration: none; }
.drop hr { border: 0; border-top: 1px solid var(--rule-2); margin: 4px 0; }

.content { padding: 22px 24px 64px; min-width: 0; }
.banner { padding: 9px 24px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.banner.warn { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid #f0d79f; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner a { color: inherit; font-weight: 600; text-decoration: underline; }

/* ── Page head ───────────────────────────────────────── */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .t { min-width: 0; flex: 1; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Buttons ─────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: var(--r-md); border: 1px solid var(--rule); background: var(--sheet); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover { border-color: #b9c3d2; text-decoration: none; background: #fafbfd; }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); color: #fff; }
.btn-gold { background: var(--marigold); border-color: var(--marigold); color: #1c1606; }
.btn-gold:hover { background: #c98c0c; color: #1c1606; }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: #f2b8b2; }
.btn-ok { color: var(--ok); }
.btn-ok:hover { background: var(--ok-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: var(--r-sm); }
.btn-link { border: 0; background: none; padding: 0; color: var(--info); font-weight: 500; cursor: pointer; font: inherit; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ── Panels ──────────────────────────────────────────── */
.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-lg); margin-bottom: 18px; }
.panel > .ph { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--rule-2); }
.panel > .ph h2, .panel > .ph h3 { margin: 0; font-size: 16px; }
.panel > .ph .actions { margin-left: auto; }
.panel > .pb { padding: 16px; }
.panel > .pb.flush { padding: 0; }
.panel > .pf { padding: 12px 16px; border-top: 1px solid var(--rule-2); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; background: #fbfcfd; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }

/* ── KPI tiles ───────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-md); padding: 12px 14px; display: block; color: inherit; }
a.kpi:hover { border-color: #b9c3d2; text-decoration: none; }
.kpi .k { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.kpi .v { font-family: var(--serif); font-size: 21px; color: var(--ink); font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .s { font-size: 12px; color: var(--faint); }
.kpi.accent { border-left: 3px solid var(--marigold); }

/* ── Tables ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 9px 12px; border-bottom: 1px solid var(--rule); background: #fafbfc; white-space: nowrap; position: sticky; top: 0; }
table.t td { padding: 8px 12px; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
table.t tbody tr:hover td { background: #fafbfd; }
table.t tfoot td, table.t tr.total td { font-weight: 700; border-top: 1px solid var(--rule); background: #fafbfc; }
table.t tr.group td { background: #f6f8fb; font-weight: 600; color: var(--ink); }
table.t tr.sub td:first-child { padding-left: 28px; }
table.t tr.sub2 td:first-child { padding-left: 44px; }
table.t td.wrap { white-space: normal; }
table.t td .sub-line { color: var(--muted); font-size: 12px; }
table.t .row-actions { white-space: nowrap; text-align: right; }
table.t .row-actions a, table.t .row-actions button { margin-left: 8px; }
table.t.compact td, table.t.compact th { padding: 6px 10px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink); }

/* ── Badges ──────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1.5; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: #eef1f5; color: var(--muted); }
.badge-gold { background: var(--marigold-soft); color: #7a5300; }

/* ── Forms ───────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .half { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field > .lbl { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .req { color: var(--bad); }
.field .hint { font-size: 12px; color: var(--faint); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], input[type=url], input[type=month], input:not([type]), select, textarea {
  font: inherit; color: var(--text); background: #fff; border: 1px solid #cdd5e1; border-radius: var(--r-sm); padding: 7px 10px; width: 100%; min-width: 0;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink-3); box-shadow: 0 0 0 3px rgba(217,154,18,.25); }
input[readonly] { background: #f6f8fb; }
input.amt { text-align: right; font-variant-numeric: tabular-nums; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--text); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 12px 16px; border-bottom: 1px solid var(--rule-2); }
.filters .field { min-width: 140px; }
.filters .grow { flex: 1; min-width: 200px; }
fieldset { border: 1px solid var(--rule); border-radius: var(--r-md); padding: 12px 14px 14px; margin: 0 0 14px; }
legend { font-weight: 600; color: var(--ink); padding: 0 6px; font-family: var(--serif); }

/* ── Flash / alerts ──────────────────────────────────── */
.flash { padding: 10px 14px; border-radius: var(--r-md); margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid; }
.flash.ok { background: var(--ok-soft); border-color: #b9e0c8; color: #14532d; }
.flash.error { background: var(--bad-soft); border-color: #f2b8b2; color: #7a1a12; }
.flash.warn { background: var(--warn-soft); border-color: #f0d79f; color: #6b4500; }
.flash.info { background: var(--info-soft); border-color: #bcd1ee; color: #193f70; }
.note { background: #f7f9fc; border: 1px dashed var(--rule); border-radius: var(--r-md); padding: 10px 14px; color: var(--muted); font-size: 13px; }

/* ── Tabs ────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a[aria-current="page"], .tabs a.active { color: var(--ink); border-bottom-color: var(--marigold); }

/* ── Voucher sheet (the ledger page) ─────────────────── */
.sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r-lg); overflow: hidden; }
.sheet-head { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 16px; padding: 16px; border-bottom: 1px solid var(--rule); background: linear-gradient(#fff, #fbfcfe); }
.sheet-type { display: flex; align-items: baseline; gap: 12px; padding: 14px 16px 0; }
.sheet-type h2 { margin: 0; font-size: 22px; }
.sheet-type .no { font-family: var(--serif); color: var(--muted); }
table.entry { width: 100%; border-collapse: collapse; }
table.entry th { font-size: 12px; color: var(--muted); text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); background: #fafbfc; font-weight: 600; }
table.entry th.dr-h { color: var(--dr); text-align: right; }
table.entry th.cr-h { color: var(--cr); text-align: right; }
table.entry td { padding: 5px 6px; border-bottom: 1px solid var(--rule-2); vertical-align: top; }
table.entry td.dr-c { background: linear-gradient(90deg, transparent, var(--dr-soft) 85%); }
table.entry td.cr-c { background: linear-gradient(90deg, transparent, var(--cr-soft) 85%); }
table.entry input, table.entry select { border-color: transparent; background: transparent; }
table.entry input:hover, table.entry select:hover { border-color: #cdd5e1; background: #fff; }
table.entry input:focus, table.entry select:focus { background: #fff; }
table.entry .bal { font-size: 11.5px; color: var(--faint); padding: 0 10px; }
table.entry .del { color: var(--faint); background: none; border: 0; cursor: pointer; padding: 6px; border-radius: var(--r-sm); }
table.entry .del:hover { color: var(--bad); background: var(--bad-soft); }
table.entry tfoot td { padding: 10px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; border-top: 1px solid var(--rule); background: #fafbfc; }
.dims { display: flex; gap: 6px; flex-wrap: wrap; padding: 2px 4px 4px; }
.dims select, .dims input { font-size: 12px; padding: 3px 6px; max-width: 170px; }
.seal { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--rule); flex-wrap: wrap; }
.seal .stamp { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; border: 2px solid var(--cr); color: var(--cr); font-family: var(--serif); font-weight: 600; font-variant-numeric: tabular-nums; background: var(--cr-soft); }
.seal .stamp.balanced { border-color: var(--marigold); color: #6b4a00; background: var(--marigold-soft); }
.seal .grow { flex: 1; }
.sheet-foot { padding: 14px 16px; border-top: 1px solid var(--rule-2); display: grid; gap: 12px; }

/* totals block on invoices */
.totals { margin-left: auto; width: min(380px, 100%); border-collapse: collapse; }
.totals td { padding: 5px 10px; text-align: right; font-variant-numeric: tabular-nums; }
.totals td:first-child { color: var(--muted); text-align: left; }
.totals tr.grand td { font-family: var(--serif); font-size: 19px; color: var(--ink); border-top: 2px solid var(--ink); padding-top: 9px; }

/* ── Statements (TB, P&L, BS) ────────────────────────── */
.statement { font-family: var(--serif); }
.statement table.t { font-family: var(--serif); font-size: 14px; }
.statement table.t th { font-family: var(--sans); }
.statement .head { text-align: center; margin-bottom: 14px; }
.statement .head h2 { margin: 0; }
.statement .head p { margin: 2px 0 0; color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--rule); border-radius: var(--r-md); overflow: hidden; }
.two-col > div:first-child { border-right: 1px solid var(--rule); }
.check-line { display: inline-flex; align-items: center; gap: 6px; font-family: var(--sans); font-size: 13px; padding: 4px 10px; border-radius: 999px; }
.check-line.ok { background: var(--ok-soft); color: var(--ok); }
.check-line.bad { background: var(--bad-soft); color: var(--bad); }

/* ── Charts ──────────────────────────────────────────── */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--sans); font-size: 11px; fill: var(--muted); }
.chart .axis line, .chart .axis path { stroke: var(--rule); }
.chart .grid line { stroke: var(--rule-2); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); padding: 0 4px 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.bar-list { display: grid; gap: 8px; }
.bar-list .row { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.bar-list .track { display: block; height: 10px; background: var(--rule-2); border-radius: 5px; overflow: hidden; }
.bar-list .fill { display: block; height: 100%; background: var(--ink-3); border-radius: 5px; }

/* ── Misc ────────────────────────────────────────────── */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-flex; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--rule); color: var(--muted); font-size: 12.5px; }
.pill[aria-current="page"], .pill.on { background: var(--ink); border-color: var(--ink); color: #fff; }
a.pill:hover { text-decoration: none; border-color: #b9c3d2; }
.inline-form { display: inline; margin: 0; }
.stack > * + * { margin-top: 12px; }
.hr { border: 0; border-top: 1px solid var(--rule-2); margin: 16px 0; }
.code { font-family: var(--mono); font-size: 12.5px; background: #f2f4f8; padding: 2px 6px; border-radius: 4px; word-break: break-all; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.plan-card { border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 16px; background: #fff; display: flex; flex-direction: column; gap: 8px; }
.plan-card.current { border: 2px solid var(--marigold); }
.plan-card ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.quick { display: none; }
.lock-chip { display: inline-flex; gap: 5px; align-items: center; font-size: 12px; color: var(--warn); }

/* ── Public pages (login / install) ──────────────────── */
.public { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--paper); }
.public .art { background: var(--ink); color: #dfe7f3; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.public .art::after { content: ""; position: absolute; inset: auto -120px -160px auto; width: 520px; height: 520px; border-radius: 50%; border: 1px solid rgba(217,154,18,.35); box-shadow: 0 0 0 40px rgba(217,154,18,.06), 0 0 0 90px rgba(217,154,18,.04); }
.public .art h1 { color: #fff; font-size: 38px; max-width: 14ch; margin-top: 40px; }
.public .art p { max-width: 46ch; color: #b8c6da; font-size: 15px; }
.public .art .ledger-lines { font-family: var(--serif); font-variant-numeric: tabular-nums; border-top: 1px solid rgba(255,255,255,.15); margin-top: 28px; max-width: 420px; position: relative; z-index: 1; }
.public .art .ledger-lines div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,.1); font-size: 14px; }
.public .art .ledger-lines .tot { color: var(--marigold); font-weight: 600; }
.public .form-side { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.public .card { width: 100%; max-width: 420px; }
.public .card.wide { max-width: 760px; }
.public .card h2 { font-size: 24px; }
.public .card .stack { margin-top: 18px; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(10,20,36,.45); }
  .top { padding: 0 12px; gap: 8px; }
  .top .menu-btn { display: inline-grid; }
  .top .search { display: none; }
  .ctx select { max-width: 150px; }
  .user-menu .who { display: none; }
  .content { padding: 16px 14px 96px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .two-col { grid-template-columns: 1fr; }
  .two-col > div:first-child { border-right: 0; border-bottom: 1px solid var(--rule); }
  .public { grid-template-columns: 1fr; }
  .public .art { padding: 28px 24px; }
  .public .art h1 { font-size: 28px; margin-top: 16px; }
  .public .art .ledger-lines { display: none; }
  .quick { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; background: var(--sheet); border-top: 1px solid var(--rule); z-index: 40; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .quick a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--ink); padding: 6px 2px; border-radius: var(--r-sm); }
  .quick a:hover { background: var(--paper); text-decoration: none; }
  table.entry .dims select { max-width: 120px; }
  .page-head .actions { width: 100%; }
}
@media (max-width: 520px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .half { grid-column: auto; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .v { font-size: 18px; }
  .net { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ── Print ───────────────────────────────────────────── */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 11.5px; }
  .side, .top, .quick, .banner, .no-print, .page-head .actions, .filters, .tabs { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  .panel { border: 0; margin: 0 0 10px; }
  .panel > .ph { padding: 4px 0; }
  .panel > .pb { padding: 4px 0; }
  table.t th { background: #fff; position: static; }
  a { color: inherit; }
}

/* ── Financial statements ── */
table.stmt td.n { padding-left: calc(12px + var(--lvl, 0) * 18px); }
table.stmt tr.g0 td { font-weight: 700; color: var(--ink); background: #f7f8fa; }
table.stmt tr.g1 td { font-weight: 600; }
table.stmt tr.lg td { color: var(--ink-2, #2b3647); }
table.stmt tr.virt td.n { font-style: italic; }
table.stmt tr.head td { font-weight: 700; color: var(--ink); padding-top: 14px; border-bottom: 1px solid var(--rule); }
table.stmt tr.sub td { font-weight: 600; border-top: 1px solid var(--rule); }
table.stmt tr.grand td { font-family: var(--serif); font-size: 16px; color: var(--ink); border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); background: #fbf7ec; }
table.stmt td.neg { color: #a12a2a; }
.stmt-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
@media (max-width: 960px) { .stmt-cols { grid-template-columns: 1fr; } }
.agree { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; padding: 4px 10px; border-radius: 99px; background: #e6f4ea; color: #1d6b38; }
.agree.bad { background: #fde8e8; color: #9b1c1c; }
.ratio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.ratio { border: 1px solid var(--rule); border-radius: var(--r-md); padding: 10px 12px; background: var(--sheet); }
.ratio .k { font-size: 12px; color: var(--muted); }
.ratio .v { font-family: var(--serif); font-size: 20px; color: var(--ink); font-variant-numeric: tabular-nums; }
.ratio .h { font-size: 11.5px; color: var(--faint); }
.chart svg { width: 100%; height: auto; display: block; }
.chart .legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.chart .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.alert-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--rule-2); }
.alert-row:last-child { border-bottom: 0; }
.alert-row .lv-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #eef2f8; color: var(--ink-3); }
.alert-row.lv-warn .lv-dot { background: var(--marigold-soft); color: #8a5a00; }
.alert-row.lv-critical .lv-dot { background: #fde8e8; color: #9b1c1c; }
.alert-row.read { opacity: .6; }
.alert-row.read .lv-dot { background: #f1f3f6; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Dashboard money position: the one bold element ── */
.position { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); background: var(--ink); color: #fff; border-radius: var(--r-md); margin-bottom: 18px; overflow: hidden; }
.position .pos { display: flex; flex-direction: column; gap: 2px; padding: 16px 20px; color: inherit; border-right: 1px solid rgba(255,255,255,.12); }
.position .pos:last-child { border-right: 0; }
.position a.pos:hover { background: rgba(255,255,255,.06); }
.position .k { font-size: 12.5px; color: rgba(255,255,255,.72); }
.position .v { font-family: var(--serif); font-size: 26px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.position .s { font-size: 12px; color: rgba(255,255,255,.62); }
.position .s.warn { color: #ffd27a; }
.position .pos-net { background: var(--marigold); color: var(--ink); }
.position .pos-net .k, .position .pos-net .s { color: rgba(20,43,76,.78); }
.dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 18px; }
@media (max-width: 960px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } .position .pos { border-right: 0; border-bottom: 1px solid rgba(255,255,255,.12); } }

.chart { overflow-x: auto; }
@media (max-width: 640px) { .chart svg { min-width: 520px; } }
table.t td.nowrap { white-space: nowrap; }
button.linkish { background: none; border: 0; padding: 0; color: var(--info); font: inherit; cursor: pointer; }
button.linkish:hover { text-decoration: underline; }
button.linkish.danger { color: #a12a2a; }

/* ── Offline quick entry ── */
body.offline-app { background: var(--paper, #f4f6f9); }
.off-top { display: flex; gap: 10px; align-items: center; padding: 10px 16px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 2; }
.off-top div { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; }
.off-top div span { font-size: 12px; color: rgba(255,255,255,.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.off-top .net { color: #fff; border-color: rgba(255,255,255,.3); }
.off-main { max-width: 640px; margin: 0 auto; padding: 16px; }
.off-main .tabs { padding: 0 12px; margin-bottom: 0; }
.off-note { margin: 4px 4px 32px; }
.token-box { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; padding: 10px 12px; border: 1px dashed #e0a63a; border-radius: var(--r-sm); background: #fffaf0; }
