/* JigjigaSale Tally — one stylesheet for the website and the desktop window.
   Tokens first; components only ever use the tokens. Print styles at the end. */
:root {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f8;
  --line: #e1e6ee;
  --line-strong: #c9d1de;
  --text: #0e1630;
  --text-2: #374059;
  --muted: #667089;
  --faint: #97a0b4;

  --nav: #0e1630;
  --nav-2: #18234a;
  --nav-3: #222e5c;
  --nav-text: #cdd4e8;
  --nav-muted: #8089a8;
  --brand: #f2a93b;

  --primary: #1f4fd1;
  --primary-hover: #1943b8;
  --primary-soft: #e9effd;
  --primary-ring: rgba(31, 79, 209, .28);

  --good: #13804b;
  --good-soft: #e5f5ec;
  --bad: #c23a2e;
  --bad-soft: #fcebe9;
  --warn: #9a6514;
  --warn-soft: #fdf3df;
  --dr: #13804b;
  --cr: #b2481f;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-1: 0 1px 2px rgba(14, 22, 48, .05);
  --shadow-2: 0 6px 24px rgba(14, 22, 48, .10), 0 1px 3px rgba(14, 22, 48, .08);
  --shadow-3: 0 18px 48px rgba(14, 22, 48, .22);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", ui-monospace, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 13.5px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num, .tnum { font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
.good { color: var(--good); } .bad { color: var(--bad); }
.dr { color: var(--dr); } .cr { color: var(--cr); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
kbd { font: 11px var(--mono); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--muted); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ----------------------------------------------------------------- shell */
#app { display: flex; min-height: 100vh; }
#nav { width: 248px; flex: 0 0 248px; background: var(--nav); color: var(--nav-text); height: 100vh; position: sticky; top: 0;
  display: none; flex-direction: column; z-index: 30; }
body.authed #nav { display: flex; }
#main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
#view { flex: 1 1 auto; padding: 20px 26px 40px; outline: none; }
body:not(.authed) #topbar { display: none; }
body:not(.authed) #view { padding: 0; }
.boot { display: grid; place-items: center; min-height: 60vh; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 12px; color: #fff; font: 650 16.5px var(--font-display); letter-spacing: -.01em; }
.brand img { width: 26px; height: 26px; }
.brand b { color: var(--brand); font-weight: 650; }
.brand:hover { text-decoration: none; }
.co-switch { margin: 2px 12px 8px; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; background: var(--nav-2);
  color: #fff; border: 1px solid transparent; cursor: pointer; text-align: left; width: calc(100% - 24px); font: inherit; }
.co-switch:hover { border-color: var(--nav-3); }
.co-switch .mono { flex: none; width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; background: var(--primary);
  color: #fff; font-weight: 700; font-size: 12px; overflow: hidden; }
.co-switch .mono img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.co-switch b { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co-switch small { color: var(--nav-muted); }
.nav-search { margin: 0 12px 6px; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; background: transparent;
  border: 1px solid var(--nav-3); color: var(--nav-muted); cursor: pointer; font: inherit; width: calc(100% - 24px); text-align: left; }
.nav-search:hover { color: var(--nav-text); border-color: #34407a; }
.nav-search kbd { margin-left: auto; background: transparent; border-color: var(--nav-3); color: var(--nav-muted); }
.nav-scroll { flex: 1 1 auto; overflow-y: auto; padding: 4px 8px 12px; scrollbar-width: thin; scrollbar-color: var(--nav-3) transparent; }
.nav-sec { margin: 14px 10px 4px; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--nav-muted); font-weight: 600; }
.nav-link { position: relative; display: flex; align-items: center; gap: 10px; padding: 6.5px 10px; border-radius: 7px; color: var(--nav-text); font-size: 13px; }
.nav-link:hover { background: var(--nav-2); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--nav-3); color: #fff; }
.nav-link.active::before { content: ""; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.nav-link svg.i { opacity: .85; }
.nav-link kbd { margin-left: auto; background: transparent; border: 0; color: var(--nav-muted); padding: 0; font-size: 10.5px; }
.nav-foot { border-top: 1px solid var(--nav-2); padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--nav-3); color: #fff; font-weight: 650; font-size: 12.5px; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; background: var(--surface-3); color: var(--text-2); }
.nav-foot .who { flex: 1 1 auto; min-width: 0; }
.nav-foot .who b { display: block; color: #fff; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-foot .who small { color: var(--nav-muted); }
.nav-foot button { background: transparent; border: 0; color: var(--nav-muted); padding: 6px; border-radius: 6px; cursor: pointer; }
.nav-foot button:hover { background: var(--nav-2); color: #fff; }
#nav-scrim { display: none; }

#topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 12px 26px; min-height: 64px;
  background: rgba(242, 244, 248, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
#topbar .menu-btn { display: none; }
.page-title { min-width: 0; }
.page-title h1 { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-title .crumbs { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.page-title .crumbs a { color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* --------------------------------------------------------------- controls */
button, .btn { font: 600 13px var(--font); display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: background .12s, border-color .12s, box-shadow .12s; }
button:hover, .btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; }
button:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
button.secondary, .btn.secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); box-shadow: var(--shadow-1); }
button.secondary:hover, .btn.secondary:hover { background: var(--surface-2); border-color: var(--faint); }
button.ghost, .btn.ghost { background: transparent; color: var(--text-2); border-color: transparent; box-shadow: none; }
button.ghost:hover, .btn.ghost:hover { background: var(--surface-3); }
button.danger, .btn.danger { background: var(--surface); color: var(--bad); border-color: #efc4bf; }
button.danger:hover, .btn.danger:hover { background: var(--bad-soft); }
button.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
button.sm, .btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
button.icon, .btn.icon { width: 34px; padding: 0; }
button.icon.sm { width: 28px; }
.btn-group { display: inline-flex; }
.btn-group > button:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn-group > button:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }

input, select, textarea { font: 13.5px var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  height: 34px; padding: 0 10px; width: 100%; min-width: 0; transition: border-color .12s, box-shadow .12s; }
textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
input.num, .num input { text-align: right; font-variant-numeric: tabular-nums; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--primary); padding: 0; }
input[type="date"] { font-variant-numeric: tabular-nums; }
input[type="color"] { padding: 2px; width: 46px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span, .field > label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; user-select: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.form-error { color: var(--bad); font-size: 12.5px; min-height: 0; }
.form-error:empty { display: none; }

/* ------------------------------------------------------------------ cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { flex: 1 1 auto; }
.card-body { padding: 16px 18px; }
.section-title { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 650; margin: 0 0 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dash { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.note { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); font-size: 12.5px; }
.note.warn { background: var(--warn-soft); border-color: #f1dbb0; color: var(--warn); }
.note.bad { background: var(--bad-soft); border-color: #f3c9c4; color: var(--bad); }
.note.good { background: var(--good-soft); border-color: #bfe5cf; color: var(--good); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 16px; }
@media (max-width: 600px) { .kpis.compact { grid-template-columns: 1fr 1fr; gap: 10px; } .kpis.compact .kpi { padding: 12px; } .kpis.compact .value { font-size: 16px; } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-1); position: relative; overflow: hidden; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .value { font: 650 19px var(--font-display); margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .value small { font: 600 12px var(--font); color: var(--muted); margin-right: 4px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.link { cursor: pointer; }
.kpi.link:hover { border-color: var(--line-strong); }
.kpi .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 650;
  background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.green { background: var(--good-soft); color: var(--good); }
.badge.red { background: var(--bad-soft); color: var(--bad); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.vt { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.vt::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--vt, var(--faint)); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a, .tabs button { height: 38px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: 600 13px var(--font);
  border-radius: 0; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.tabs a:hover, .tabs button:hover { color: var(--text); background: none; text-decoration: none; }
.tabs .active { color: var(--text); border-bottom-color: var(--primary); }

/* ------------------------------------------------------------- data table */
.dt { display: flex; flex-direction: column; }
.dt-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.dt-search { position: relative; flex: 0 1 300px; min-width: 180px; }
.dt-search svg { position: absolute; left: 10px; top: 9px; color: var(--faint); pointer-events: none; }
.dt-search input { padding-left: 32px; height: 32px; background: var(--surface-2); }
.dt-search input:focus { background: var(--surface); }
.dt-count { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }
.dt-chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px 0; }
.dt-chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 4px 0 10px; border-radius: 999px; background: var(--primary-soft);
  color: var(--primary); font-size: 12px; font-weight: 600; border: 1px solid #cbd8fa; }
.chip button { height: 20px; width: 20px; padding: 0; border-radius: 50%; background: transparent; color: var(--primary); border: 0; }
.chip button:hover { background: #d6e1fb; }
.chip.clear { background: transparent; border-color: transparent; color: var(--muted); padding: 0 8px; cursor: pointer; }
.dt-scroll { overflow: auto; max-height: var(--dt-max, calc(100vh - 250px)); }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
.dt table, table.plain { font-size: 13px; }
.dt th, table.plain th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left; font-size: 11.5px; font-weight: 650;
  color: var(--muted); letter-spacing: .02em; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
.dt th.sortable { cursor: pointer; }
.dt th.sortable:hover { color: var(--text); }
.dt th .arrow { display: inline-block; width: 10px; color: var(--primary); }
.dt td, table.plain td { padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.dt tbody tr { cursor: default; }
.dt tbody tr.clickable { cursor: pointer; }
.dt tbody tr:hover td { background: #f6f8fd; }
.dt tbody tr.sel td { background: var(--primary-soft); }
.dt tbody tr.group-row td { background: var(--surface-2); font-weight: 650; }
.dt tbody tr.sub td:first-child { padding-left: 28px; }
.dt tfoot td, table.plain tfoot td { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line-strong); font-weight: 700; padding: 9px 12px; }
.dt td.num, .dt th.num { text-align: right; }
.dt .sub-line { color: var(--muted); font-size: 12px; margin-top: 1px; }
.dt .more { padding: 12px; text-align: center; }
.dt-empty { padding: 44px 16px; text-align: center; color: var(--muted); }
.lvl1 { padding-left: 28px !important; } .lvl2 { padding-left: 46px !important; } .lvl3 { padding-left: 64px !important; } .lvl4 { padding-left: 82px !important; }
.twisty { display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 4px; border-radius: 4px; color: var(--muted); }
.twisty:hover { background: var(--surface-3); }

/* ---------------------------------------------------------- popovers etc */
.pop { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2);
  min-width: 200px; max-width: min(420px, calc(100vw - 20px)); animation: pop-in .12s ease-out; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
.menu { padding: 5px; }
.menu button { width: 100%; justify-content: flex-start; height: 32px; background: transparent; color: var(--text); border: 0; font-weight: 500; padding: 0 10px; border-radius: 6px; }
.menu button:hover, .menu button.hl { background: var(--surface-3); }
.menu button.danger { color: var(--bad); }
.menu button kbd { margin-left: auto; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.menu .menu-label { font-size: 11px; color: var(--muted); padding: 6px 10px 2px; font-weight: 600; }
.filter-pop { padding: 14px; width: 360px; display: flex; flex-direction: column; gap: 14px; max-height: 70vh; overflow: auto; }
.filter-pop .opts { display: flex; flex-wrap: wrap; gap: 6px; }
.toggle-chip { height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); font: 500 12.5px var(--font); }
.toggle-chip:hover { background: var(--surface-2); border-color: var(--faint); }
.toggle-chip.on { background: var(--primary-soft); border-color: #b9cbf7; color: var(--primary); font-weight: 650; }
.range2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.period-btn { height: 34px; display: inline-flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); font: 600 13px var(--font); cursor: pointer; box-shadow: var(--shadow-1); }
.period-btn:hover { background: var(--surface-2); }
.period-btn small { color: var(--muted); font-weight: 500; }
.period-pop { display: grid; grid-template-columns: 170px 1fr; width: 470px; max-width: calc(100vw - 20px); }
.period-pop .presets { border-right: 1px solid var(--line); padding: 6px; }
.period-pop .custom { padding: 14px; display: flex; flex-direction: column; gap: 10px; }

.layer-scrim { position: fixed; inset: 0; background: rgba(14, 22, 48, .42); z-index: 70; display: grid; place-items: center; padding: 20px; animation: fade .12s ease-out; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-3); width: min(520px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop-in .14s ease-out; }
.modal.wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 6px; }
.modal-head h2 { flex: 1 1 auto; }
.modal-body { padding: 10px 20px 16px; overflow: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.drawer-scrim { position: fixed; inset: 0; background: rgba(14, 22, 48, .32); z-index: 70; animation: fade .12s ease-out; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); z-index: 71; box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; animation: slide-in .16s ease-out; }
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { flex: 1 1 auto; }
.drawer-body { flex: 1 1 auto; overflow: auto; padding: 18px 20px; }
.drawer-foot { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }

#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--nav); color: #fff; padding: 10px 14px; border-radius: 9px; box-shadow: var(--shadow-2);
  max-width: 420px; font-size: 13px; animation: pop-in .14s ease-out; }
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #4ade80; flex: none; }
.toast.err::before { background: #f87171; }
.toast.info::before { background: var(--brand); }

/* command palette */
.palette { width: min(620px, 100%); align-self: start; margin-top: 10vh; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-3); overflow: hidden; }
.palette input { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; height: 52px; font-size: 15px; padding: 0 18px; box-shadow: none !important; }
.palette .results { max-height: 52vh; overflow: auto; padding: 6px; }
.palette .res { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 7px; cursor: pointer; }
.palette .res.hl { background: var(--primary-soft); }
.palette .res .kind { margin-left: auto; font-size: 11px; color: var(--muted); }
.palette .group { font-size: 11px; color: var(--muted); padding: 8px 12px 4px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }

/* search-select (combobox) */
.ss { position: relative; }
.ss input { padding-right: 28px; }
.ss .caret { position: absolute; right: 8px; top: 9px; color: var(--faint); pointer-events: none; }
.ss-list { padding: 5px; max-height: 300px; overflow: auto; }
.ss-opt { display: flex; align-items: baseline; gap: 10px; padding: 6px 9px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.ss-opt.hl { background: var(--primary-soft); }
.ss-opt .meta { margin-left: auto; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.ss-opt.create { color: var(--primary); font-weight: 600; border-top: 1px solid var(--line); margin-top: 4px; border-radius: 0 0 6px 6px; }
.ss-empty { padding: 10px; color: var(--muted); font-size: 12.5px; }

/* ----------------------------------------------------------- voucher entry */
.entry { max-width: 1180px; }
.entry-head { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 14px; }
.lines { width: 100%; }
.lines th { text-align: left; font-size: 11.5px; color: var(--muted); font-weight: 650; padding: 6px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.lines td { padding: 5px 6px; vertical-align: top; }
.lines tbody tr + tr td { border-top: 1px dashed var(--line); }
.lines .x { width: 34px; }
.lines .hintline { font-size: 11.5px; color: var(--muted); margin-top: 3px; min-height: 0; }
.curbal { font-size: 11.5px; color: var(--muted); }
.curbal.dr { color: var(--dr); } .curbal.cr { color: var(--cr); } .curbal.low { color: var(--bad); }
.totals { margin-left: auto; width: min(380px, 100%); }
.totals td { padding: 5px 0; font-size: 13px; }
.totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.totals tr.grand td { border-top: 1px solid var(--line-strong); padding-top: 9px; font-weight: 700; font-size: 15px; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(255, 255, 255, .96); backdrop-filter: blur(6px); border-top: 1px solid var(--line);
  padding: 12px 18px; display: flex; gap: 8px; align-items: center; border-radius: 0 0 var(--radius) var(--radius); }
.diff { font-size: 12.5px; font-weight: 600; }
.mode-switch { display: inline-flex; background: var(--surface-3); border-radius: 8px; padding: 3px; }
.mode-switch button { height: 28px; background: transparent; border: 0; color: var(--muted); font-weight: 600; padding: 0 12px; border-radius: 6px; }
.mode-switch button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.mode-switch button:hover { background: var(--surface); }

/* --------------------------------------------------------- report bodies */
.tacct { display: grid; grid-template-columns: 1fr 1fr; }
.tacct > div + div { border-left: 1px solid var(--line); }
.tacct table td { padding: 6px 14px; border-bottom: 1px solid var(--line); }
.tacct .grp td { font-weight: 650; }
.tacct .child td:first-child { padding-left: 30px; color: var(--text-2); }
.tacct .tot td { font-weight: 700; border-top: 1px solid var(--line-strong); background: var(--surface-2); }
.tacct h4 { padding: 10px 14px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.statement-head { display: flex; gap: 24px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.statement-head .stat { min-width: 120px; }
.statement-head .stat .l { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.statement-head .stat .v { font: 650 16px var(--font-display); font-variant-numeric: tabular-nums; margin-top: 2px; }

/* chart */
.chart { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: end; gap: 6px; height: 210px; padding: 8px 4px 0; position: relative; }
.chart .col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.chart .bars { flex: 1 1 auto; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.chart .bars span { width: min(16px, 40%); border-radius: 3px 3px 0 0; min-height: 1px; }
.chart .b1 { background: var(--primary); } .chart .b2 { background: var(--brand); }
.chart small { font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* -------------------------------------------------------------- auth page */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr); }
.auth-art { background: var(--nav); color: var(--nav-text); padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art .brand { padding: 0; font-size: 20px; }
.auth-art h2 { font-size: 34px; line-height: 1.12; color: #fff; max-width: 15ch; margin: 0 0 16px; font-weight: 650; }
.auth-art p { max-width: 46ch; color: var(--nav-text); font-size: 15px; }
.auth-art ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; }
.auth-art li { display: flex; gap: 10px; align-items: center; color: #e6eaf6; }
.auth-art li svg { color: var(--brand); }
.auth-art .ledger-lines { position: absolute; inset: auto -40px -30px auto; width: 380px; opacity: .18; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-form form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; }
.auth-form h1 { font-size: 24px; }

/* -------------------------------------------------------- companies page */
.co-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.co-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); box-shadow: var(--shadow-1); transition: border-color .12s, box-shadow .12s; }
.co-card:hover { border-color: var(--primary); box-shadow: var(--shadow-2); text-decoration: none; }
.co-card .top { display: flex; align-items: center; gap: 12px; }
.co-card .mono { width: 42px; height: 42px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; overflow: hidden; }
.co-card .mono img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.co-card h3 { font-size: 15px; }

/* ---------------------------------------------------- printable documents */
.paper-wrap { background: var(--surface-3); border-radius: var(--radius); padding: 24px; overflow: auto; }
.paper.mini { width: 210mm; max-width: none; min-height: 0; zoom: .62; }
.paper { background: #fff; width: 210mm; max-width: 100%; min-height: 200mm; margin: 0 auto; box-shadow: var(--shadow-2); padding: 14mm 14mm 12mm; color: #111827; }
.doc { --accent: #1f3a93; font: 10.5pt/1.45 var(--font); color: #111827; }
.doc .lh { display: flex; gap: 16px; align-items: flex-start; padding-bottom: 12px; border-bottom: 2.5px solid var(--accent); }
.doc .lh .logo { max-height: 64px; max-width: 160px; object-fit: contain; }
.doc .lh .co { flex: 1 1 auto; }
.doc .lh .co h1 { font-size: 17pt; color: var(--accent); margin: 0 0 3px; font-weight: 700; letter-spacing: -.01em; }
.doc .lh .co div { font-size: 9pt; color: #374151; line-height: 1.5; }
.doc .lh .title { text-align: right; white-space: nowrap; }
.doc .lh .title h2 { font-size: 15pt; text-transform: uppercase; letter-spacing: .08em; color: #111827; margin: 0 0 6px; font-weight: 700; }
.doc .lh .title table td { padding: 1px 0 1px 12px; font-size: 9.5pt; text-align: right; }
.doc .lh .title { max-width: 60%; }
.doc .lh .title table td:last-child { white-space: normal; overflow-wrap: anywhere; }
.doc .lh .title table td:first-child { color: #6b7280; }
.doc .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 14px 0; }
.doc .box-l { font-size: 8pt; text-transform: uppercase; letter-spacing: .09em; color: #6b7280; font-weight: 700; margin-bottom: 3px; }
.doc .box-v { font-size: 10pt; line-height: 1.5; }
.doc .box-v b { font-size: 11pt; }
.doc table.items { width: 100%; border-collapse: collapse; margin-top: 4px; }
.doc table.items th { background: var(--accent); color: #fff; font-size: 8.5pt; text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px; text-align: left; font-weight: 700;
  position: static; border: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc table.items td { padding: 6px 8px; border-bottom: 1px solid #e5e7eb; font-size: 9.5pt; vertical-align: top; }
.doc table.items tr:nth-child(even) td { background: #f9fafb; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc table.items .num { text-align: right; }
.doc .sum { display: grid; grid-template-columns: 1fr 260px; gap: 24px; margin-top: 12px; align-items: start; }
.doc .sum table { width: 100%; border-collapse: collapse; }
.doc .sum table td { padding: 3.5px 0; font-size: 10pt; }
.doc .sum table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.doc .sum table tr.grand td { border-top: 2px solid var(--accent); font-weight: 700; font-size: 12pt; padding-top: 6px; color: var(--accent); }
.doc .words { font-size: 9.5pt; padding: 8px 10px; background: #f3f4f6; border-radius: 4px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc .words b { display: block; font-size: 8pt; text-transform: uppercase; letter-spacing: .08em; color: #6b7280; margin-bottom: 2px; }
.doc .terms { margin-top: 14px; font-size: 9pt; color: #374151; white-space: pre-line; }
.doc .terms b { display: block; font-size: 8pt; text-transform: uppercase; letter-spacing: .08em; color: #6b7280; margin-bottom: 2px; }
.doc .signs { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; margin-top: 46px; }
.doc .signs div { border-top: 1px solid #9ca3af; padding-top: 5px; font-size: 9pt; color: #4b5563; text-align: center; }
.doc .foot { margin-top: 22px; padding-top: 8px; border-top: 1px solid #e5e7eb; font-size: 8pt; color: #9ca3af; display: flex; justify-content: space-between; }
.doc .amount-box { border: 2px solid var(--accent); border-radius: 6px; padding: 10px 16px; text-align: center; }
.doc .amount-box .l { font-size: 8pt; text-transform: uppercase; letter-spacing: .09em; color: #6b7280; font-weight: 700; }
.doc .amount-box .v { font-size: 18pt; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.doc .receipt-line { display: flex; gap: 8px; align-items: baseline; padding: 7px 0; border-bottom: 1px dotted #9ca3af; font-size: 10.5pt; }
.doc .receipt-line span:first-child { color: #6b7280; white-space: nowrap; min-width: 120px; }
.doc .report-meta { display: flex; justify-content: space-between; gap: 16px; margin: 12px 0 8px; font-size: 9.5pt; color: #374151; }
.doc .report-meta .filters { color: #6b7280; }
.doc table.rep { width: 100%; border-collapse: collapse; font-size: 9pt; }
.doc table.rep th { text-align: left; font-size: 8pt; text-transform: uppercase; letter-spacing: .04em; color: #374151; border-bottom: 1.5px solid #111827; padding: 5px 6px;
  position: static; background: none; }
.doc table.rep td { padding: 4.5px 6px; border-bottom: 1px solid #e5e7eb; vertical-align: top; }
.doc table.rep .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc table.rep tr.grp td { font-weight: 700; background: #f3f4f6; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc table.rep tfoot td { font-weight: 700; border-top: 1.5px solid #111827; border-bottom: 0; }
.doc table.rep .sub-line { color: #6b7280; font-size: 8pt; }
.doc thead { display: table-header-group; }
.doc tr { page-break-inside: avoid; break-inside: avoid; }
#print-root { display: none; }

/* ------------------------------------------------------------- responsive */
@media screen and (max-width: 1100px) {
  .dash { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media screen and (max-width: 860px) {
  #nav { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .18s ease-out; box-shadow: var(--shadow-3); }
  body.nav-open #nav { transform: none; }
  body.nav-open #nav-scrim { display: block; position: fixed; inset: 0; background: rgba(14, 22, 48, .4); z-index: 25; }
  #topbar { padding: 10px 16px; flex-wrap: wrap; }
  #topbar .menu-btn { display: inline-flex; }
  #view { padding: 14px 16px 32px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .tacct { grid-template-columns: 1fr; }
  .tacct > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .form-grid .span-2 { grid-column: auto; }
  .period-pop { grid-template-columns: 1fr; }
  .period-pop .presets { border-right: 0; border-bottom: 1px solid var(--line); }
  .paper-wrap { padding: 8px; }
  .paper { padding: 16px; min-height: 0; }
  .doc .parties, .doc .sum { grid-template-columns: 1fr; }
  .dt-search { flex: 1 1 100%; }
}

/* ------------------------------------------------------------------ print */
@page { size: A4; margin: 12mm; }
@media print {
  html, body { background: #fff; height: auto; }
  #app, #layer, #toasts { display: none !important; }
  #print-root { display: block; }
  #print-root .doc { font-size: 10pt; }
  #print-root .page-break { page-break-before: always; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
