/* THE ANY 168 — invoice system
   Palette and proportions follow the original Invoice System concept. */

:root {
  --bg:        #f4f5fb;
  --ink:       #1a1d2e;
  --ink-2:     #4a4f6e;
  --muted:     #7a7f9e;
  --muted-2:   #9aa0c0;
  --line:      #e4e6f2;
  --line-2:    #f0f1f8;
  --card:      #ffffff;
  --navy:      #14172b;
  --navy-2:    #565d85;
  --navy-3:    #8b91b8;
  --primary:   #3b4bd8;
  --primary-d: #2a36a8;
  --primary-l: #eef0fb;
  --green:     #0e8f62;
  --orange:    #d8722b;
  --red:       #d84b4b;
  --mono:      'Space Grotesk', 'Kantumruy Pro', ui-monospace, sans-serif;
  --sans:      'Kantumruy Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius:    14px;
}

* { box-sizing: border-box; }

/* Class rules below set `display`, which would otherwise beat the UA's
   `[hidden] { display: none }` and leave the splash covering the app. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-d); }
input, select, button, textarea { font-family: inherit; font-size: 14px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── boot / login ───────────────────────────────────────────────────────── */

.boot {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--navy); z-index: 100;
}
.boot-mark {
  width: 210px; height: auto; animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .35 } 50% { opacity: 1 } }

.login {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #23294a 0%, var(--navy) 60%);
  padding: 24px; z-index: 90;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border-radius: 18px; padding: 30px 28px 26px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  display: flex; flex-direction: column; gap: 16px;
}
.login-brand {
  display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 4px;
}
/* The artwork already carries the wordmark, so no name text beside it. */
.login-logo { width: 196px; height: auto; }
.login-sub { font-size: 12.5px; color: var(--muted); }
.login-error {
  background: #fdecec; color: #a62b2b; border-radius: 9px;
  padding: 9px 12px; font-size: 13px;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  border: 1px solid #d6d9ea; border-radius: 8px; padding: 9px 11px;
  background: #fff; color: var(--ink); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus,
.cell:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,75,216,.12);
}

/* ── shell ──────────────────────────────────────────────────────────────── */

.shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 230px; flex: none; background: var(--navy);
  display: flex; flex-direction: column; padding: 20px 14px; gap: 4px;
  z-index: 30;
}
.brand { padding: 6px 12px 22px; }
.brand-logo { width: 100%; max-width: 168px; height: auto; display: block; }
.brand-sub { font-size: 12.5px; color: var(--navy-3); margin-top: 6px; }

.nav { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav-item {
  padding: 10px 12px; border-radius: 9px; cursor: pointer;
  color: var(--muted-2); font-size: 14px; font-weight: 500;
  display: flex; flex-direction: column; gap: 1px;
  border: none; background: transparent; text-align: left; width: 100%;
}
.nav-item:hover { filter: brightness(1.35); background: rgba(255,255,255,.05); }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 700; }
.nav-item small { font-size: 11.5px; opacity: .65; font-weight: 400; }

.sidebar-foot { margin-top: auto; padding: 12px; border-top: 1px solid #242844; }
.who { font-size: 12px; color: var(--navy-2); line-height: 1.5; margin-bottom: 6px; }
.who b { color: #c9cde8; font-weight: 600; }
.btn-link {
  background: none; border: none; color: var(--navy-3); cursor: pointer;
  padding: 0; font-size: 12.5px;
}
.btn-link:hover { color: #fff; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 14px; padding: 16px 26px;
  border-bottom: 1px solid var(--line); background: #fff; flex: none;
}
.topbar-titles { flex: 1; min-width: 0; }
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-sub { font-size: 12.5px; color: var(--muted); }
.topbar-actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.view { flex: 1; overflow: auto; padding: 24px 26px 40px; }
.stack { display: flex; flex-direction: column; gap: 18px; }

.scrim { display: none; }
.only-mobile { display: none; }

/* ── buttons ────────────────────────────────────────────────────────────── */

.btn {
  border-radius: 9px; padding: 9px 17px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; border: 1px solid #d6d9ea; background: #fff; color: var(--ink-2);
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: #f6f7fd; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-l); }
.btn-danger { color: var(--red); border-color: #f0cdcd; }
.btn-danger:hover { background: #fdecec; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 9px;
  width: 36px; height: 36px; cursor: pointer; font-size: 16px; color: var(--ink-2);
}

/* ── cards, tables, chips ───────────────────────────────────────────────── */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 22px;
}
.card-tight { padding: 0; overflow: hidden; }
.card-title { font-weight: 700; font-size: 14.5px; margin-bottom: 14px; }

.grid-kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px 19px; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi-value { font-family: var(--mono); font-size: 26px; font-weight: 700; margin-top: 6px; }
.kpi-sub { font-size: 12px; color: var(--muted-2); margin-top: 2px; }

.split { display: grid; grid-template-columns: 1.25fr 1fr; gap: 14px; align-items: start; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid #d6d9ea; background: #fff; color: var(--ink-2);
  border-radius: 99px; padding: 7px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip:hover { background: #f6f7fd; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.table { width: 100%; }
.thead, .trow, .tfoot {
  display: flex; gap: 12px; align-items: center; padding: 12px 18px;
}
.thead {
  background: #f8f9fd; border-bottom: 1px solid var(--line);
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.trow { border-bottom: 1px solid var(--line-2); font-size: 14px; }
.trow.clickable { cursor: pointer; }
.trow.clickable:hover { background: #f6f7fd; }
.tfoot { background: #f8f9fd; font-size: 14px; }
.tnum { text-align: right; font-family: var(--mono); }
.tgrow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-no { font-family: var(--mono); font-weight: 600; color: var(--primary); }
.pos { color: var(--green); font-weight: 600; }
.dim { color: var(--muted-2); }
.soft { color: var(--muted); }

/* Per-row delete, admin only. Reserved in the head and totals rows too, or the
   money columns would sit 34px off the rows they summarise. */
.row-kill-col { width: 34px; flex: none; }
.row-kill {
  width: 34px; flex: none; background: none; border: none; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 4px; border-radius: 7px;
  opacity: .3; transition: opacity .12s, background .12s;
}
.trow:hover .row-kill { opacity: .75; }
.row-kill:hover { opacity: 1; background: #fdecec; }
.row-kill:disabled { opacity: .25; cursor: default; }

.tag {
  display: inline-block; border-radius: 99px; padding: 2px 9px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.tag-paid   { background: #e3f6ee; color: var(--green); }
.tag-unpaid { background: #fdf0e4; color: var(--orange); }
.tag-void   { background: #f1f1f5; color: var(--muted); }
.tag-quotation { background: var(--primary-l); color: var(--primary); }

.empty { padding: 44px 20px; text-align: center; color: var(--muted-2); font-size: 14px; }

/* ── revenue chart ──────────────────────────────────────────────────────── */

.bars { display: flex; align-items: flex-end; gap: 14px; height: 168px; padding: 0 4px; }
.bar-col {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; height: 100%; justify-content: flex-end;
}
.bar-amt { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.bar {
  width: 100%; max-width: 46px; background: #dfe2f3;
  border-radius: 6px 6px 2px 2px; transition: background .15s, height .3s;
  min-height: 4px;
}
.bar-col:hover .bar { background: #c6ccec; }
.bar-col.active .bar { background: var(--primary); }
.bar-label { font-size: 12px; color: var(--muted-2); }
.bar-col.active .bar-label { color: var(--primary); font-weight: 700; }

/* ── invoice editor ─────────────────────────────────────────────────────── */

.editor { max-width: 980px; }
.editor-head { display: grid; grid-template-columns: 110px 1fr 1fr 155px 185px; gap: 12px; }
.lines-head, .line {
  display: flex; gap: 8px; align-items: center;
}
.lines-head {
  margin-top: 22px; padding: 0 0 2px; font-size: 11.5px; font-weight: 600;
  color: var(--muted); letter-spacing: .02em; line-height: 1.3; align-items: flex-end;
}
.line { margin-top: 8px; }
.line .idx { width: 28px; font-family: var(--mono); color: var(--muted-2); font-size: 13px; flex: none; }
.cell {
  border: 1px solid #d6d9ea; border-radius: 8px; padding: 8px 10px;
  background: #fff; color: var(--ink); min-width: 0;
}
.cell.desc { flex: 1; min-width: 90px; }
.cell.qty { width: 66px; flex: none; font-family: var(--mono); }
.cell.price { width: 116px; flex: none; font-family: var(--mono); }
.cell.disc { width: 78px; flex: none; font-family: var(--mono); color: var(--orange); }
.cell.cost { width: 96px; flex: none; font-family: var(--mono); color: var(--muted); border-style: dashed; }
.line .total { width: 88px; flex: none; text-align: right; font-family: var(--mono); font-weight: 600; }
.line .kill {
  width: 26px; flex: none; text-align: center; color: #c4c8de; cursor: pointer;
  font-size: 17px; background: none; border: none; line-height: 1;
}
.line .kill:hover { color: var(--red); }
.h-desc { flex: 1; } .h-qty { width: 66px; } .h-price { width: 116px; }
.h-disc { width: 78px; } .h-cost { width: 96px; } .h-total { width: 88px; text-align: right; }
.h-idx { width: 28px; } .h-kill { width: 26px; }

.totals { width: 310px; display: flex; flex-direction: column; gap: 8px; margin-left: auto; margin-top: 20px; }
.totals .row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted-2); }
.totals .row.big { font-size: 14.5px; color: var(--ink); }
.totals .row.big b { font-family: var(--mono); font-size: 18px; }
.totals .row.income {
  color: var(--green); font-weight: 600;
  border-top: 1px solid var(--line); padding-top: 8px;
}
.editor-actions {
  display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px;
  border-top: 1px solid var(--line-2); padding-top: 17px;
}

.suggest {
  position: absolute; z-index: 40; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 30px rgba(20,23,43,.14);
  max-height: 260px; overflow: auto; min-width: 260px; padding: 4px;
}
.suggest button {
  display: flex; width: 100%; gap: 10px; align-items: center; text-align: left;
  background: none; border: none; padding: 8px 10px; border-radius: 7px; cursor: pointer;
}
.suggest button:hover, .suggest button.on { background: var(--primary-l); }
.suggest .s-desc { flex: 1; min-width: 0; }
.suggest .s-price { font-family: var(--mono); font-size: 13px; color: var(--muted); }

/* ── printable invoice ──────────────────────────────────────────────────── */

.print-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.print-bar { display: flex; gap: 10px; width: 100%; max-width: 680px; align-items: center; }

/* ── the printed document ───────────────────────────────────────────────────
   One set of rules for screen and paper. The sheet is a true A4 page so the
   preview and the PDF are the same object, not two designs kept in step.     */

.sheet {
  /* Accent greys. These fills used to be the logo red and carried white text;
     they are light now, so anything sitting on them is charcoal instead. */
  --accent:     #dfe3e8;        /* the fill that was red */
  --accent-2:   #c9cfd8;        /* one shade down, where a fill must out-rank a plain chip */
  --accent-txt: #4b5563;        /* accent-coloured text on white */
  --char: #22262f;
  position: relative; isolation: isolate;
  width: 210mm; max-width: 100%; min-height: 297mm;
  background: #fff; color: var(--char);
  padding: 16mm 14mm 0 20mm;
  box-shadow: 0 10px 30px rgba(20,23,43,.12);
  display: flex; flex-direction: column;
  font-size: 10.5pt; line-height: 1.45;
}
/* Red spine down the left edge. */
.sheet-edge {
  position: absolute; inset: 0 auto 0 0; width: 4mm; background: var(--accent); z-index: -1;
}
.sheet.is-quote { --accent: #c9cfd8; --accent-2: #aeb7c2; }

/* ── header ─────────────────────────────────────────────────────────────── */
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10mm; }
.sheet-brand { display: flex; align-items: center; gap: 4mm; padding-top: 2mm; }
.sheet-logo { width: 30mm; height: auto; flex: none; }
.sheet-brand-txt .n { font-family: var(--mono); font-weight: 700; font-size: 15pt; line-height: 1.1; }
.sheet-brand-txt .t { font-size: 9pt; color: #6b7280; margin-top: 1mm; }

/* The angled INVOICE banner, mirroring the reference's cut corner. */
.sheet-kind {
  background: var(--accent); color: var(--char); padding: 4mm 8mm 4mm 14mm; margin-right: -14mm;
  clip-path: polygon(6mm 0, 100% 0, 100% 100%, 0 100%);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.sheet-kind-in { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.05; }
.sheet-kind .km { font-size: 13pt; font-weight: 700; }
.sheet-kind .en { font-size: 17pt; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }

/* ── from / bill to ─────────────────────────────────────────────────────── */
.sheet-parties {
  display: grid; grid-template-columns: 1.25fr 1fr; gap: 10mm; margin-top: 7mm;
}
.party-tag {
  display: inline-block; font-size: 8pt; color: #6b7280; letter-spacing: .04em; margin-bottom: 1mm;
}
.party-tag.on {
  background: var(--accent); color: var(--char); padding: .8mm 2.5mm; border-radius: 1mm;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.party-name { font-weight: 700; font-size: 12pt; line-height: 1.2; }
.party-lines { font-size: 9pt; color: #4b5563; margin-top: 1.5mm; line-height: 1.55; }
.party-to { text-align: right; }

/* ── items ──────────────────────────────────────────────────────────────── */
.st {
  width: 100%; margin-top: 7mm; border-collapse: collapse;
  border: .35mm solid #c9cfd8; table-layout: fixed;
}
.st thead th {
  background: var(--accent); color: var(--char); font-weight: 700; font-size: 9pt;
  padding: 2.6mm 4mm; text-align: left; vertical-align: middle;
  border: .35mm solid var(--accent-2);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.st thead .km { display: block; font-size: 8pt; line-height: 1.15; opacity: .88; font-weight: 500; }
.st thead .en { display: block; font-size: 9.5pt; line-height: 1.15; }
.st tbody td {
  padding: 2.4mm 4mm; font-size: 10pt; vertical-align: middle;
  border: .25mm solid #dfe3e9;                 /* the grid the reference shows */
}
.st tbody tr:nth-child(even) td { background: #fafbfc; }
.st-idx   { width: 12mm; color: #6b7280; font-family: var(--mono); text-align: center !important; }
.st-desc  { overflow-wrap: anywhere; }
.st-off   { color: var(--accent-txt); font-size: 8.5pt; }
.st-price { width: 24mm; text-align: right !important; font-family: var(--mono); }
.st-qty   { width: 18mm; text-align: center !important; font-family: var(--mono); }
.st-total { width: 28mm; text-align: right !important; font-family: var(--mono); font-weight: 700; }
.st tbody .st-total { color: var(--char); }
.st-blank td { height: 8mm; }

/* ── totals ─────────────────────────────────────────────────────────────── */
.sheet-sums { display: flex; flex-wrap: wrap; gap: 4mm; margin-top: 6mm; justify-content: flex-end; }
.sum-chip {
  display: flex; gap: 4mm; align-items: baseline; background: #f3f4f6;
  padding: 2.2mm 5mm; border-radius: 1mm; font-size: 9.5pt;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.sum-chip b { font-family: var(--mono); }
.sum-chip.on { background: var(--accent-2); color: var(--char); }
.sheet-due {
  display: flex; align-items: stretch; margin-top: 4mm; margin-right: -14mm;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.sheet-due .due-l {
  background: var(--char); color: #fff; padding: 3.4mm 6mm 3.4mm 9mm; margin-left: auto;
  clip-path: polygon(5mm 0, 100% 0, 100% 100%, 0 100%);
  display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1;
}
.sheet-due .due-l .km { font-size: 9.5pt; }
.sheet-due .due-l .en { font-size: 13pt; font-weight: 700; }
.sheet-due .due-r {
  background: var(--accent); color: var(--char); padding: 3.4mm 14mm 3.4mm 6mm;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
}
.sheet-due .amt { font-family: var(--mono); font-size: 16pt; font-weight: 700; line-height: 1.05; }
.sheet-due .riel { font-size: 9pt; color: var(--accent-txt); }

/* ── payment / meta / signature ─────────────────────────────────────────── */
.sheet-foot-grid {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 10mm;
  margin-top: 8mm; padding-bottom: 8mm;
}
.pay-t { font-weight: 700; font-size: 10.5pt; margin-bottom: 2mm; }
.pay-row { display: flex; font-size: 9pt; line-height: 1.7; }
.pay-row .k { width: 26mm; flex: none; font-weight: 600; }
.pay-row .v { color: #4b5563; overflow-wrap: anywhere; }
.thanks { margin-top: 6mm; }
.thanks-t { font-weight: 700; font-size: 10.5pt; }
.thanks-s { font-size: 8.5pt; color: #6b7280; margin-top: 1mm; line-height: 1.5; }
.sign-cust { margin-top: 8mm; font-size: 8.5pt; color: #6b7280; display: block; }
.sign-cust .rule { display: block; width: 58mm; border-top: 1px solid #9ca3af; margin-top: 9mm; }

.sheet-meta-col { text-align: right; }
.meta-row { display: flex; justify-content: flex-end; gap: 4mm; font-size: 9pt; line-height: 1.9; }
.meta-row .k { color: #6b7280; }
.meta-row .k .km { margin-right: 1.5mm; }
.meta-row .k .en { text-transform: uppercase; letter-spacing: .04em; font-size: 8pt; }
.meta-row b { font-family: var(--mono); }
.meta-row .st-paid   { color: #0e8f62; }
.meta-row .st-unpaid { color: var(--char); }
.meta-row .st-void   { color: #9ca3af; text-decoration: line-through; }
.sign { margin-top: 14mm; display: flex; flex-direction: column; align-items: flex-end; }
.sign .rule { width: 58mm; border-top: 1px solid #9ca3af; }
.sign-n { font-weight: 700; font-size: 10pt; margin-top: 1.5mm; text-transform: uppercase; }
.sign-t { font-size: 8.5pt; color: #6b7280; }

/* ── dark contact band, flush to the bottom of the page ─────────────────── */
.sheet-footer {
  margin: auto -14mm 0 -20mm; background: var(--char); color: #fff;
  padding: 5mm 14mm 5mm 20mm; display: flex; flex-wrap: wrap; gap: 4mm 10mm;
  font-size: 8.5pt; line-height: 1.5;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.foot-item { display: flex; gap: 2.5mm; align-items: flex-start; }
.foot-ico { color: var(--accent); font-size: 11pt; line-height: 1; }

/* ── misc layout helpers ────────────────────────────────────────────────── */

.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.toolbar .search { flex: 1 1 240px; min-width: 180px; max-width: 340px; }
.toolbar input, .toolbar select {
  border: 1px solid #d6d9ea; border-radius: 9px; padding: 8px 12px; background: #fff;
}
.toolbar input { width: 100%; }
.toolbar select { width: auto; min-width: 170px; flex: 0 0 auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.hint { font-size: 12.5px; color: var(--muted-2); line-height: 1.6; }
.mt { margin-top: 16px; }
.rowline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 13.5px; z-index: 200; box-shadow: 0 12px 30px rgba(0,0,0,.25); max-width: 90vw;
}
.toast.bad { background: #a62b2b; }

/* ── responsive ─────────────────────────────────────────────────────────── */

@media screen and (max-width: 960px) {
  .split { grid-template-columns: 1fr; }
  .editor-head { grid-template-columns: 1fr 1fr; }
}

@media screen and (max-width: 760px) {
  .only-mobile { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.4);
  }
  .shell.menu-open .sidebar { transform: none; }
  .shell.menu-open .scrim {
    display: block; position: fixed; inset: 0; background: rgba(10,12,24,.5); z-index: 20;
  }
  .view { padding: 16px 14px 40px; }
  .topbar { padding: 12px 14px; flex-wrap: wrap; }
  .topbar-titles { flex: 1 1 auto; min-width: 0; }
  .topbar-title { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-sub { display: none; }
  .topbar-actions { flex: 0 0 auto; }
  .thead { display: none; }
  .trow {
    display: flex; flex-wrap: wrap; gap: 3px 10px;
    padding: 12px 14px; align-items: baseline;
  }
  .trow > * { width: auto !important; text-align: left !important; flex: 0 0 auto; }
  .trow .tgrow { flex: 1 1 100%; }
  .trow .tnum { text-align: left; }
  /* Cost is the least useful figure on a phone; income and total stay. */
  .col-cost { display: none; }
  .tfoot { flex-wrap: wrap; }
  .line { flex-wrap: wrap; }
  .cell.desc { flex-basis: 100%; }
  .totals { width: 100%; }
  .editor-head { grid-template-columns: 1fr; }
}

/* The sheet keeps A4 proportions everywhere — it is scaled to fit a narrow
   screen, never reflowed, so the preview never lies about the printout. */
@media screen and (max-width: 900px) {
  .print-wrap { overflow-x: auto; align-items: flex-start; }
  .sheet { zoom: .68; }
}
@media screen and (max-width: 620px) {
  .sheet { zoom: .46; }
}

/* ── print ──────────────────────────────────────────────────────────────── */

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .sidebar, .topbar, .print-bar, .toast, .scrim { display: none !important; }
  .shell, .main, .view { display: block; height: auto; overflow: visible; padding: 0; }
  .print-wrap { display: block; }
  .sheet {
    width: 210mm; max-width: none; min-height: 296mm;
    border: none; box-shadow: none; border-radius: 0;
  }
  /* Colour is the design here, not decoration — keep it in the PDF. */
  .sheet, .sheet * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .st tr, .sheet-due, .sheet-foot-grid, .sheet-footer { break-inside: avoid; }
  .st thead { display: table-header-group; }
  /* Fixed boxes repeat on every printed page, which is exactly what the red
     spine wants — otherwise it stops wherever the content happens to end. */
  .sheet-edge { position: fixed; top: 0; bottom: 0; left: 0; height: auto; }
}
