/* Copperslip · GST invoicing
   Design system: copper #B5622E on ledger ink #1F2A24 and ledger cream #F7F2E8.
   Type: IBM Plex Sans for words, IBM Plex Mono for every amount, GSTIN and document number.
   Scale 11 / 12 / 13 / 14 / 16 / 20 / 24 / 32. Space 4 / 8 / 12 / 16 / 24 / 32 / 48.
   Shape: 2px for paper and ledgers, 6px for controls, 10px for windows. Rules before shadows. */

:root {
  --copper: #B5622E;        /* brand copper: marks, rules, key figures */
  --copper-600: #A85525;    /* button fill (white text passes AA) */
  --copper-700: #8C4418;    /* copper text and links on cream */
  --parchment: #F3DFC1;     /* highlight: selected row, changed figure */
  --wash: #FBF1E2;          /* hover wash */
  --on-copper: #FFFDF8;

  --ink: #1F2A24;           /* ledger ink */
  --ink-2: #48534C;
  --ink-3: #626B64;
  --bg: #F7F2E8;            /* ledger cream */
  --paper: #FFFDF8;         /* raised surface */
  --sunk: #EFE8D8;          /* wells, the preview desk */
  --rule: #E3D9C5;          /* ruled line */
  --rule-2: #CFC3AA;        /* control border, strong rule */
  --margin: #D9A186;        /* the red margin line of an account book */

  --ok: #2C6B4A;   --ok-bg: #E3EFE4;
  --info: #35607D; --info-bg: #E2ECF1;
  --warn: #8A5D0B; --warn-bg: #F6EACB;
  --bad: #A63A2B;  --bad-bg: #F6E1DA;
  --mute-bg: #EAE3D3;

  --bar: #1F2A24; --bar-ink: #F1EBDD; --bar-ink-2: #A9B4AB; --bar-rule: #34423A;
  --sheet: #FFFEFA; --sheet-ink: #1F2A24; --sheet-rule: #D9CFBA; --sheet-soft: #5C665F;

  --r-1: 2px; --r-2: 6px; --r-3: 10px;
  --sh-1: 0 1px 2px rgba(31, 42, 36, .07);
  --sh-paper: 0 1px 1px rgba(31, 42, 36, .10), 0 14px 30px -16px rgba(31, 42, 36, .30);
  --sh-pop: 0 2px 6px rgba(31, 42, 36, .10), 0 20px 48px -14px rgba(31, 42, 36, .34);

  --f-sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --f-mono: "IBM Plex Mono", "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --bar-h: 56px;
  color-scheme: light;
}
[data-theme="dark"] {
  --copper: #D38452; --copper-600: #DB8F5E; --copper-700: #E8A77D; --parchment: #43301F; --wash: #232A22; --on-copper: #1B110A;
  --ink: #ECE6D8; --ink-2: #BDB9AA; --ink-3: #979B8F;
  --bg: #131915; --paper: #1A221D; --sunk: #0F1411; --rule: #2A352E; --rule-2: #3D4A42; --margin: #8E5A44;
  --ok: #7FC79D; --ok-bg: #1C3327; --info: #8FBBD8; --info-bg: #1A2E3A; --warn: #E2B75E; --warn-bg: #3A2E12; --bad: #F0907E; --bad-bg: #40201A; --mute-bg: #262F29;
  --bar: #0C100E; --bar-ink: #ECE6D8; --bar-ink-2: #98A398; --bar-rule: #26302A;
  --sheet: #F4EEDF; --sheet-ink: #1F2A24; --sheet-rule: #CFC4AC; --sheet-soft: #56605A;
  --sh-1: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-paper: 0 1px 1px rgba(0, 0, 0, .5), 0 16px 34px -16px rgba(0, 0, 0, .7);
  --sh-pop: 0 2px 6px rgba(0, 0, 0, .4), 0 22px 52px -14px rgba(0, 0, 0, .75);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/20px var(--f-sans); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
h1, h2, h3, h4, p, figure, dl, dd { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--copper-700); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
table { border-collapse: collapse; width: 100%; }
svg { display: block; flex: none; }
:focus-visible { outline: 2px solid var(--copper); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--parchment); color: var(--ink); }
.skip { position: fixed; left: 12px; top: -60px; z-index: 300; background: var(--paper); border: 1px solid var(--rule-2); padding: 8px 12px; border-radius: var(--r-2); }
.skip:focus { top: 12px; }
.m, .num, .amt, kbd { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.num { text-align: right; white-space: nowrap; }
.muted { color: var(--ink-3); }
[hidden] { display: none !important; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ic.s { width: 16px; height: 16px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border: 1px solid var(--rule-2); border-bottom-width: 2px; border-radius: 4px; font-size: 11px; line-height: 1; color: var(--ink-2); background: var(--paper); }

/* ---------- top bar ---------- */
.bar { position: sticky; top: 0; z-index: 50; height: var(--bar-h); display: flex; align-items: stretch; gap: 8px; padding: 0 24px 0 20px; background: var(--bar); color: var(--bar-ink); border-bottom: 1px solid var(--bar-rule); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--bar-ink); font: 600 16px/20px var(--f-sans); letter-spacing: -.01em; padding-right: 20px; }
.brand:hover { text-decoration: none; }
.brand svg { width: 26px; height: 26px; }
.nav { display: flex; align-items: stretch; gap: 2px; min-width: 0; }
.nav a, .nav-more { position: relative; display: flex; align-items: center; padding: 0 12px; color: var(--bar-ink-2); font: 500 13.5px/20px var(--f-sans); white-space: nowrap; }
.nav a:hover, .nav-more:hover { color: var(--bar-ink); text-decoration: none; }
.nav a.on { color: var(--bar-ink); }
.nav a.on::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; background: var(--copper); }
.nav a:focus-visible, .nav-more:focus-visible { outline-offset: -4px; }
.nav-more { display: none; gap: 4px; }
.bar-title { display: none; }
.bar-r { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.find { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px 0 10px; min-width: 200px; border: 1px solid var(--bar-rule); border-radius: var(--r-2); color: var(--bar-ink-2); font-size: 13px; background: rgba(255, 255, 255, .04); }
.find:hover { border-color: #55655B; color: var(--bar-ink); }
.find span { flex: 1; text-align: left; }
.find kbd { background: transparent; border-color: #4A584F; color: var(--bar-ink-2); }
.ib { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-2); color: inherit; position: relative; }
.bar .ib { color: var(--bar-ink-2); }
.bar .ib:hover { color: var(--bar-ink); background: rgba(255, 255, 255, .08); }
.ib:hover { background: var(--mute-bg); }
.av { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--copper); color: #FFFDF8; font: 600 11px/1 var(--f-mono); letter-spacing: .02em; }
[data-theme="dark"] .av { color: #1B110A; }
.who { display: flex; align-items: center; gap: 6px; padding: 2px; border-radius: 999px; }
.split { display: flex; }
.split .btn:first-child { border-radius: var(--r-2) 0 0 var(--r-2); }
.split .btn.caret { border-radius: 0 var(--r-2) var(--r-2) 0; padding: 0 6px; margin-left: 1px; }

/* tooltips: any element with data-tip */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after { content: attr(data-tip); position: absolute; z-index: 60; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--ink); color: var(--bg); font: 500 11.5px/16px var(--f-sans); padding: 4px 8px; border-radius: 4px; pointer-events: none; }
[data-tip].tip-l:hover::after, [data-tip].tip-l:focus-visible::after { left: auto; right: 0; transform: none; }
@media (hover: none) { [data-tip]::after { display: none !important; } }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border: 1px solid var(--rule-2); border-radius: var(--r-2); background: var(--paper); color: var(--ink); font: 500 13.5px/20px var(--f-sans); white-space: nowrap; transition: background .14s, border-color .14s, transform .08s; }
.btn:hover { border-color: var(--ink-3); background: var(--wash); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.pri { background: var(--copper-600); border-color: var(--copper-600); color: var(--on-copper); }
.btn.pri:hover { background: var(--copper-700); border-color: var(--copper-700); }
[data-theme="dark"] .btn.pri:hover { background: #E7A277; border-color: #E7A277; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.quiet:hover { background: var(--mute-bg); color: var(--ink); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--rule-2)); }
.btn.danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; gap: 6px; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn.loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--on-copper); border-right-color: transparent; animation: spin .7s linear infinite; }
.btn:not(.pri).loading::after { border-color: var(--ink-2); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.link { color: var(--copper-700); font-weight: 500; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--copper) 40%, transparent); text-underline-offset: 3px; }
.link:hover { text-decoration-color: currentColor; }

/* ---------- form controls ---------- */
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .lbl { font: 500 12px/16px var(--f-sans); color: var(--ink-2); }
.field > label i { font-style: normal; color: var(--ink-3); font-weight: 400; }
.in { display: block; width: 100%; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid var(--rule-2); border-radius: var(--r-2); background: var(--paper); color: var(--ink); font: 400 14px/20px var(--f-sans); transition: border-color .14s; }
.in::placeholder { color: var(--ink-3); opacity: 1; }
.in:hover { border-color: var(--ink-3); }
.in:focus { outline: 2px solid var(--copper); outline-offset: 1px; border-color: var(--copper); }
.in.m { font-family: var(--f-mono); font-size: 13px; }
.in.num { text-align: right; }
.in[readonly] { background: var(--sunk); color: var(--ink-2); }
textarea.in { height: auto; min-height: 76px; padding: 8px 10px; resize: vertical; line-height: 20px; }
select.in { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23626B64' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
[data-theme="dark"] select.in { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23979B8F' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E"); }
.help { font-size: 12px; line-height: 16px; color: var(--ink-3); }
.err { font-size: 12px; line-height: 16px; color: var(--bad); display: flex; gap: 6px; align-items: flex-start; }
.field.bad .in { border-color: var(--bad); }
.pre { position: relative; }
.pre > span { position: absolute; left: 10px; top: 0; height: 36px; display: grid; place-items: center; color: var(--ink-3); font-family: var(--f-mono); font-size: 13px; pointer-events: none; }
.pre > .in { padding-left: 24px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stack { display: grid; gap: 16px; }

.seg { display: inline-flex; padding: 2px; border: 1px solid var(--rule-2); border-radius: var(--r-2); background: var(--sunk); gap: 2px; max-width: 100%; }
.seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 4px; font: 500 12.5px/16px var(--f-sans); color: var(--ink-2); white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--paper); color: var(--ink); box-shadow: var(--sh-1); }
.seg.sm button { height: 26px; padding: 0 10px; font-size: 12px; }
.seg.fill { display: flex; }
.seg.fill button { flex: 1; padding: 0 6px; }

.switch { position: relative; width: 36px; height: 20px; border-radius: 10px; background: var(--rule-2); transition: background .16s; flex: none; }
.switch::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--paper); box-shadow: var(--sh-1); transition: transform .16s; }
.switch[aria-checked="true"] { background: var(--copper-600); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
[data-theme="dark"] .switch::after { background: #F4EEDF; }

.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--rule-2); border-radius: 14px; background: var(--paper); font: 500 12px/16px var(--f-sans); color: var(--ink-2); white-space: nowrap; }
.chip:hover { border-color: var(--copper); color: var(--copper-700); }
.chip .m { font-size: 11.5px; }

/* ---------- page frame ---------- */
#view { outline: none; }
.page { max-width: 1320px; margin: 0 auto; padding: 28px 32px 72px; }
.page.narrow { max-width: 1040px; }
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; min-height: 52px; }
.ph h1 { font: 600 24px/32px var(--f-sans); letter-spacing: -.015em; }
.ph h1 .m { font-weight: 500; font-size: 21px; letter-spacing: -.02em; }
.eyebrow { font: 500 12px/16px var(--f-sans); color: var(--ink-3); margin-bottom: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.eyebrow a { color: var(--ink-3); }
.ph-act { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.sec { margin-top: 32px; }
.sec:first-child { margin-top: 0; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--ink); margin-bottom: 0; }
.sec-h h2 { font: 600 15px/20px var(--f-sans); display: flex; align-items: baseline; gap: 8px; }
.sec-h h2 .n { font: 500 12px/16px var(--f-mono); color: var(--ink-3); }
.sec-h .more { font-size: 12.5px; }
.sec-note { font-size: 12.5px; line-height: 18px; color: var(--ink-3); padding: 10px 0 0; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 40px; align-items: start; }

/* the position band on the daybook: one ruled strip, not a row of cards */
.position { display: grid; grid-template-columns: 1.15fr 1fr 1fr 1fr 1.1fr; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule-2); margin-bottom: 32px; background: var(--paper); }
.pos { padding: 16px 20px 16px; border-left: 1px solid var(--rule); min-width: 0; display: grid; gap: 4px; align-content: start; text-align: left; color: inherit; }
.pos:first-child { border-left: 0; }
a.pos:hover { text-decoration: none; }
@media (hover: hover) { a.pos:hover { background: var(--wash); } }
.pos .lbl { color: var(--ink-3); }
.fig { font: 500 24px/32px var(--f-mono); letter-spacing: -.03em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos.key .fig { color: var(--copper-700); }
.pos.late .fig { color: var(--bad); }
.pos .sub { font-size: 12px; line-height: 16px; color: var(--ink-3); }
.pos .sub b { font-weight: 500; color: var(--ink-2); }

/* ---------- ledger: every list is a ruled account-book page ---------- */
.tools { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.tools-r { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: var(--r-2); font: 500 13px/20px var(--f-sans); color: var(--ink-2); border: 1px solid transparent; }
.tabs button:hover { background: var(--mute-bg); color: var(--ink); }
.tabs button.on { background: var(--paper); border-color: var(--rule-2); color: var(--ink); box-shadow: var(--sh-1); }
.tabs .n { font: 400 11.5px/16px var(--f-mono); color: var(--ink-3); }
.tabs button.on .n { color: var(--copper-700); }
.searchbox { position: relative; }
.searchbox .ic { position: absolute; left: 9px; top: 9px; color: var(--ink-3); pointer-events: none; }
.searchbox .in { padding-left: 32px; width: 240px; height: 34px; }
.tools select.in { width: auto; height: 34px; }

.ledger-wrap { background: var(--paper); border: 1px solid var(--rule-2); border-radius: var(--r-1); position: relative; }
.sec > .ledger-wrap { border-top: 0; border-radius: 0 0 var(--r-1) var(--r-1); }
.ledger th { text-align: left; font: 500 11px/16px var(--f-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); padding: 10px 12px 9px; border-bottom: 1px solid var(--rule-2); white-space: nowrap; background: var(--paper); }
.ledger th.num { text-align: right; }
.ledger th button { font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; display: inline-flex; gap: 4px; align-items: center; }
.ledger th button:hover { color: var(--ink); }
.ledger th button .ic { width: 12px; height: 12px; opacity: 0; }
.ledger th[aria-sort] button { color: var(--ink); }
.ledger th[aria-sort] button .ic { opacity: 1; }
.ledger td { padding: 0 12px; height: 46px; border-bottom: 1px solid var(--rule); vertical-align: middle; font-size: 13.5px; }
.ledger tbody tr:last-child td { border-bottom: 0; }
.ledger td.num, .ledger td.m { font-size: 13px; }
/* the margin line: the first column is ruled off with a double line, like the date column of a cash book */
.ledger th:first-child, .ledger td:first-child { padding-left: 16px; }
.ledger thead th:first-child, .ledger tbody td:first-child { border-right: 3px double var(--margin); }
.ledger thead th:nth-child(2), .ledger tbody td:nth-child(2) { padding-left: 14px; }
.ledger.nomg thead th:first-child, .ledger.nomg tbody td:first-child { border-right: 0; }
.ledger tbody tr.sk-row td:first-child { border-right: 0; }
.ph-cell { display: none; }
.ledger th:last-child, .ledger td:last-child { padding-right: 16px; }
.ledger tr.row { cursor: pointer; }
@media (hover: hover) { .ledger tr.row:hover td { background: var(--wash); } }
.ledger tr.row:focus-visible { outline-offset: -2px; }
.ledger tr.void td { color: var(--ink-3); }
.ledger tr.void .k-no, .ledger tr.void .k-amt { text-decoration: line-through; }
.ledger tfoot td { height: 44px; border-top: 3px double var(--ink-3); border-bottom: 0; font-weight: 600; background: var(--paper); }
.ledger tfoot td.lblc { font: 500 12px/16px var(--f-sans); color: var(--ink-3); }
.two { display: grid; line-height: 17px; min-width: 0; }
.two b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.two small { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-no { font-family: var(--f-mono); font-size: 12.5px !important; white-space: nowrap; }
.k-date { white-space: nowrap; color: var(--ink-2); }
.late-n { color: var(--bad); font-size: 12px; white-space: nowrap; }
.soon-n { color: var(--warn); font-size: 12px; white-space: nowrap; }
.row-act { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; transition: opacity .12s; }
tr:hover .row-act, tr:focus-within .row-act { opacity: 1; }
.row-act .ib { width: 30px; height: 30px; color: var(--ink-2); }
.row-act .ib:hover { color: var(--copper-700); background: var(--parchment); }
.dr { color: var(--ink); } .cr { color: var(--ok); }
.ledger .zero { color: var(--ink-3); }

.tag { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px 0 7px; border-radius: 3px; font: 600 11px/16px var(--f-sans); letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; background: var(--mute-bg); color: var(--ink-2); }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.s-draft { background: transparent; box-shadow: inset 0 0 0 1px var(--rule-2); color: var(--ink-3); }
.tag.s-draft::before { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.tag.s-sent { background: var(--info-bg); color: var(--info); }
.tag.s-part { background: var(--warn-bg); color: var(--warn); }
.tag.s-part::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%); box-shadow: inset 0 0 0 1.5px currentColor; }
.tag.s-paid { background: var(--ok-bg); color: var(--ok); }
.tag.s-overdue { background: var(--bad-bg); color: var(--bad); }
.tag.s-cancelled { background: transparent; color: var(--ink-3); text-decoration: line-through; box-shadow: inset 0 0 0 1px var(--rule); }
.tag.s-cancelled::before { display: none; }
.tag.plain::before { display: none; }
.tag.plain { padding: 0 7px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0 0; font-size: 12.5px; color: var(--ink-3); }
.pager div { display: flex; gap: 6px; align-items: center; }

.empty { display: grid; justify-items: start; gap: 8px; padding: 36px 32px 40px 32px; max-width: 520px; }
.empty svg { width: 72px; height: 72px; margin-bottom: 8px; color: var(--rule-2); }
.empty h3 { font: 600 16px/24px var(--f-sans); }
.empty p { color: var(--ink-2); font-size: 13.5px; }
.empty .btn { margin-top: 8px; }

/* first-use checklist on a blank daybook */
.steps li { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 0 20px 0 0; border-bottom: 1px solid var(--rule); }
.steps li:last-child { border-bottom: 0; }
.st-n { align-self: stretch; display: grid; place-items: center; font: 500 15px/20px var(--f-mono); color: var(--ink-3); border-right: 3px double var(--margin); }
.steps li > div { padding: 16px 0; }
.steps b { font-weight: 600; font-size: 14.5px; }
.steps p { font-size: 13px; line-height: 19px; color: var(--ink-2); }
.steps li.done b { color: var(--ink-3); text-decoration: line-through; text-decoration-thickness: 1px; }
.steps .ok { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.sk { display: block; height: 10px; border-radius: 2px; background: linear-gradient(90deg, var(--rule) 0%, var(--mute-bg) 40%, var(--rule) 80%); background-size: 300% 100%; animation: sk 1.1s linear infinite; }
@keyframes sk { from { background-position: 100% 0; } to { background-position: -50% 0; } }
.sk-row td { height: 46px; }

/* ---------- small charts ---------- */
.chart { padding: 16px 0 0; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { font: 400 10.5px var(--f-mono); fill: var(--ink-3); }
.chart .ax { stroke: var(--rule); stroke-width: 1; }
.chart .b1 { fill: var(--ink); } .chart .b2 { fill: var(--copper); }
[data-theme="dark"] .chart .b1 { fill: #7C877E; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-2); padding-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; border-radius: 1px; background: var(--copper); }
.legend i.lg-b1 { background: var(--ink); }
[data-theme="dark"] .legend i.lg-b1 { background: #7C877E; }
.age-bar { display: flex; height: 14px; margin: 16px 0 4px; border-radius: 1px; overflow: hidden; background: var(--mute-bg); gap: 2px; }
.age-bar i { display: block; min-width: 3px; }
.a0 { background: #7E9484; } .a1 { background: #D6A54A; } .a2 { background: #C97C3C; } .a3 { background: #B5512E; } .a4 { background: #7E2B20; }
.klist { display: grid; }
.klist > * { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: 13px; color: inherit; }
.klist > *:last-child { border-bottom: 0; }
.klist a:hover, .klist button:hover { text-decoration: none; background: var(--wash); }
.klist .k { display: flex; align-items: center; gap: 8px; color: var(--ink-2); min-width: 0; }
.klist .k i { width: 10px; height: 10px; border-radius: 1px; flex: none; }
.klist .v { font-family: var(--f-mono); font-size: 12.5px; white-space: nowrap; }

/* ---------- windows, sheets, menus, toasts ---------- */
.scrim { position: fixed; inset: 0; z-index: 100; background: rgba(20, 26, 22, .46); display: grid; place-items: center; padding: 24px; animation: fade .16s ease-out; }
[data-theme="dark"] .scrim { background: rgba(0, 0, 0, .62); }
.win { width: 100%; max-width: 520px; max-height: calc(100vh - 48px); display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--rule-2); border-radius: var(--r-3); box-shadow: var(--sh-pop); animation: rise .18s ease-out; overflow: hidden; }
.win.wide { max-width: 760px; }
.win.mid { max-width: 620px; }
.win-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px 14px 24px; border-bottom: 1px solid var(--rule); }
.win-h h2 { font: 600 17px/24px var(--f-sans); }
.win-h p { font-size: 12.5px; line-height: 18px; color: var(--ink-3); margin-top: 2px; }
.win-b { padding: 20px 24px; overflow-y: auto; overflow-x: hidden; display: grid; gap: 16px; align-content: start; }
.win-f { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--rule); background: var(--paper); flex-wrap: wrap; }
.win-f .fine { margin-right: auto; flex: 1 1 0; min-width: 120px; }
.win > form { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.mlist { display: grid; margin: -8px 0; }
.mlist a, .mlist button { display: flex; align-items: center; gap: 14px; min-height: 52px; width: 100%; border-bottom: 1px solid var(--rule); color: var(--ink); font: 400 15px/20px var(--f-sans); text-align: left; }
.mlist > :last-child { border-bottom: 0; }
.mlist a:hover { text-decoration: none; }
.mlist span { flex: 1; display: grid; }
.mlist small { font-size: 12px; color: var(--ink-3); }
.mlist .ic:first-child { color: var(--ink-3); }
.mlist .ic.s { color: var(--rule-2); }
.lockn { display: flex; gap: 8px; margin-top: -12px; }
.lockn .ic { margin-top: 1px; }
.fine { font-size: 11.5px; line-height: 16px; color: var(--ink-3); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.menu { position: fixed; z-index: 90; min-width: 220px; max-width: min(340px, calc(100vw - 16px)); padding: 6px; background: var(--paper); border: 1px solid var(--rule-2); border-radius: 8px; box-shadow: var(--sh-pop); animation: rise .12s ease-out; }
.menu button, .menu a { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 6px 10px; border-radius: 4px; font: 400 13.5px/18px var(--f-sans); color: var(--ink); text-align: left; }
.menu button:hover, .menu a:hover, .menu button:focus-visible { background: var(--parchment); text-decoration: none; outline: none; }
.menu .ic { color: var(--ink-3); }
.menu small { display: block; font-size: 11.5px; color: var(--ink-3); line-height: 15px; }
.menu .sep { height: 1px; background: var(--rule); margin: 6px 0; }
.menu .dng, .menu .dng .ic { color: var(--bad); }
.menu button[disabled] { opacity: .5; cursor: not-allowed; }
.menu .mh { padding: 6px 10px 4px; font: 500 11px/16px var(--f-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.menu kbd { margin-left: auto; }

.combo { position: fixed; z-index: 110; max-height: 280px; overflow-y: auto; padding: 4px; background: var(--paper); border: 1px solid var(--rule-2); border-radius: 8px; box-shadow: var(--sh-pop); }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 7px 10px; border-radius: 4px; text-align: left; font-size: 13.5px; }
.opt.on, .opt:hover { background: var(--parchment); }
.opt .two b { font-weight: 500; }
.opt .m { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.opt.add { color: var(--copper-700); font-weight: 500; justify-content: flex-start; gap: 8px; border-top: 1px solid var(--rule); border-radius: 0 0 4px 4px; margin-top: 4px; padding-top: 9px; }
.combo .none { padding: 10px; font-size: 12.5px; color: var(--ink-3); }

#toasts { position: fixed; left: 24px; bottom: 24px; z-index: 130; display: grid; gap: 8px; justify-items: start; pointer-events: none; }
body:has(.ed-bar) #toasts { bottom: 88px; } /* stay clear of the editor's sticky total */
.toast button { pointer-events: auto; }
.toast { display: flex; align-items: center; gap: 12px; max-width: min(460px, calc(100vw - 32px)); padding: 10px 12px 10px 14px; border-radius: var(--r-2); background: var(--ink); color: var(--bg); font-size: 13.5px; line-height: 18px; box-shadow: var(--sh-pop); animation: rise .18s ease-out; }
.toast .ic { color: #9FD4B4; }
[data-theme="dark"] .toast { background: #F1EBDD; color: #1F2A24; }
[data-theme="dark"] .toast .ic { color: #2C6B4A; }
.toast.bad .ic { color: #F2A696; }
[data-theme="dark"] .toast.bad .ic { color: #A63A2B; }
.toast button { font: 600 13px/18px var(--f-sans); color: #F0B58E; padding: 4px 8px; border-radius: 4px; white-space: nowrap; margin-left: auto; }
[data-theme="dark"] .toast button { color: #8C4418; }
.toast button:hover { background: rgba(255, 255, 255, .1); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .16s, transform .16s; }

/* command palette */
.win.pal { max-width: 600px; align-self: start; margin-top: 9vh; }
.pal-in { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--rule); }
.pal-in input { flex: 1; height: 52px; border: 0; background: transparent; font-size: 16px; outline: none; min-width: 0; }
.pal-list { max-height: 380px; overflow-y: auto; padding: 6px; }
.pal-list .mh { padding: 8px 10px 4px; font: 500 11px/16px var(--f-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.pal-list .opt { padding: 8px 10px; }
.pal-list .opt .ic { color: var(--ink-3); }
.pal-list .opt > span:first-child { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pal-f { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--rule); font-size: 11.5px; color: var(--ink-3); }
.pal-f span { display: flex; gap: 6px; align-items: center; }

.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 32px; }
.keys h3 { grid-column: 1 / -1; font: 600 12px/16px var(--f-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-top: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
.keys h3:first-child { margin-top: 0; }
.keys div { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 32px; font-size: 13.5px; }
.keys span { display: flex; gap: 4px; }

/* ---------- the A4 sheet (invoice, credit note). Fixed 794px wide = 210mm at 96dpi, scaled to fit. ---------- */
.sheet-box { position: relative; margin: 0 auto; }
.sheet { position: absolute; left: 0; top: 0; width: 794px; min-height: 1123px; padding: 46px 50px 40px; background: var(--sheet); color: var(--sheet-ink); box-shadow: var(--sh-paper); transform-origin: 0 0; font: 400 12px/17px var(--f-sans); display: flex; flex-direction: column; border-radius: 1px; }
.sheet h3 { font: 600 9.5px/14px var(--f-sans); letter-spacing: .09em; text-transform: uppercase; color: var(--sheet-soft); margin-bottom: 4px; }
.sheet .m { font-size: 11.5px; }
.sh-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; padding-bottom: 18px; border-bottom: 2px solid var(--sheet-ink); }
.sh-biz { display: flex; gap: 14px; min-width: 0; }
.sh-logo { width: 44px; height: 44px; flex: none; display: grid; place-items: center; background: var(--sheet-ink); color: #F7F2E8; font: 600 15px/1 var(--f-mono); letter-spacing: -.02em; border-radius: 2px; }
.sh-name { display: block; font: 600 18px/24px var(--f-sans); letter-spacing: -.01em; }
.sh-biz p { color: var(--sheet-soft); font-size: 11.5px; line-height: 16px; }
.sh-biz p b { color: var(--sheet-ink); font-weight: 500; }
.sh-title { text-align: right; flex: none; }
.sh-title h2 { font: 600 22px/26px var(--f-sans); letter-spacing: .04em; text-transform: uppercase; color: #A85525; }
.sh-title span { font-size: 10.5px; color: var(--sheet-soft); letter-spacing: .04em; }
.sh-meta { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1.25fr; border-bottom: 1px solid var(--sheet-rule); }
.sh-meta div { padding: 10px 12px 10px 0; }
.sh-meta div + div { padding-left: 12px; border-left: 1px solid var(--sheet-rule); }
.sh-meta b { display: block; font: 500 12.5px/18px var(--f-mono); }
.sh-meta b.s { font-family: var(--f-sans); font-size: 12.5px; }
.sh-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 14px 0 16px; }
.sh-parties b { font: 600 13.5px/19px var(--f-sans); display: block; }
.sh-parties p { color: var(--sheet-soft); font-size: 11.5px; line-height: 16px; }
.sh-parties p .m, .sh-parties p b { color: var(--sheet-ink); display: inline; font-size: 11.5px; font-weight: 500; }
.sh-ghost { color: #A49C8B !important; font-style: italic; font-weight: 400 !important; }
.sh-items { margin-top: 2px; }
.sh-items th { font: 600 9.5px/14px var(--f-sans); letter-spacing: .08em; text-transform: uppercase; color: var(--sheet-soft); text-align: left; padding: 7px 8px; border-top: 1px solid var(--sheet-ink); border-bottom: 1px solid var(--sheet-ink); white-space: nowrap; }
.sh-items td { padding: 8px 8px; border-bottom: 1px solid var(--sheet-rule); vertical-align: top; }
.sh-items th:first-child, .sh-items td:first-child { padding-left: 0; width: 22px; color: var(--sheet-soft); }
.sh-items th:last-child, .sh-items td:last-child { padding-right: 0; }
.sh-items .num { text-align: right; font-size: 11.5px; }
.sh-items td b { font-weight: 500; display: block; }
.sh-items td small { display: block; font-size: 10.5px; line-height: 14px; color: var(--sheet-soft); }
.sh-sum { display: grid; grid-template-columns: 1fr 268px; gap: 28px; padding-top: 16px; margin-top: auto; align-items: start; }
.sh-items + .sh-sum { margin-top: 0; }
.sh-fill { flex: 1; min-height: 12px; }
.sh-words p { font-size: 12px; line-height: 17px; font-weight: 500; max-width: 380px; }
.sh-tax { margin-top: 14px; }
.sh-tax th { font: 600 9px/13px var(--f-sans); letter-spacing: .08em; text-transform: uppercase; color: var(--sheet-soft); text-align: right; padding: 5px 6px; border-bottom: 1px solid var(--sheet-rule); border-top: 1px solid var(--sheet-rule); }
.sh-tax th:first-child, .sh-tax td:first-child { text-align: left; padding-left: 0; }
.sh-tax td { text-align: right; font: 400 11px/15px var(--f-mono); padding: 5px 6px; border-bottom: 1px solid var(--sheet-rule); }
.sh-tax th:last-child, .sh-tax td:last-child { padding-right: 0; }
.sh-totals td { padding: 5px 0; font-size: 12px; }
.sh-totals td.num { font-size: 12px; }
.sh-totals tr.grand td { border-top: 1px solid var(--sheet-ink); border-bottom: 3px double var(--sheet-ink); padding: 9px 0 8px; font-weight: 600; font-size: 13px; }
.sh-totals tr.grand td.num { font-size: 16px; letter-spacing: -.02em; }
.sh-totals tr.due td { padding-top: 8px; color: #A63A2B; font-weight: 600; }
.sh-totals tr.sub td { color: var(--sheet-soft); }
.sh-foot { display: grid; grid-template-columns: 1.25fr 1fr 170px; gap: 24px; margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--sheet-rule); align-items: start; }
.sh-foot p { font-size: 11px; line-height: 16px; color: var(--sheet-soft); white-space: pre-line; }
.sh-foot p b, .sh-foot p .m { color: var(--sheet-ink); font-weight: 500; font-size: 11px; }
.sh-pay { display: flex; gap: 12px; align-items: flex-start; }
.sh-qr { width: 62px; height: 62px; flex: none; }
.sh-sign { text-align: right; display: grid; justify-items: end; gap: 2px; }
.sh-sign svg { width: 120px; height: 44px; color: #26345E; }
.sh-sign span { font-size: 10.5px; color: var(--sheet-soft); border-top: 1px solid var(--sheet-rule); padding-top: 4px; min-width: 130px; text-align: center; }
.sh-sign b { font-size: 11px; font-weight: 500; }
.sh-fine { margin-top: 18px; font-size: 9.5px; line-height: 14px; color: #8A8474; text-align: center; letter-spacing: .02em; }
.sh-stamp { position: absolute; right: 58px; top: 206px; padding: 5px 14px 4px; border: 2.5px solid currentColor; border-radius: 4px; font: 600 20px/26px var(--f-mono); letter-spacing: .14em; transform: rotate(-7deg); opacity: .78; pointer-events: none; }
.sh-stamp small { display: block; font: 500 9px/12px var(--f-mono); letter-spacing: .08em; text-align: center; }
.sh-stamp.paid { color: #2C6B4A; } .sh-stamp.draft { color: #8A8474; } .sh-stamp.cancelled { color: #A63A2B; }
.flash td, .flash-el { animation: flash 1.1s ease-out; }
@keyframes flash { 0%, 30% { background: #F3DFC1; } 100% { background: transparent; } }

/* ---------- invoice editor: form on the left, live paper on the right ---------- */
.ed { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; max-width: 1680px; margin: 0 auto; align-items: start; }
.ed-form { padding: 24px 36px 0 32px; min-width: 0; max-width: 820px; width: 100%; justify-self: end; }
.ed-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.ed-top h1 { font: 600 22px/28px var(--f-sans); letter-spacing: -.01em; }
.saved { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.saved .ic { width: 14px; height: 14px; color: var(--ok); }
.banner { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--rule-2); border-left: 3px solid var(--copper); background: var(--paper); border-radius: var(--r-1); font-size: 13px; margin-bottom: 20px; }
.banner .ic { color: var(--copper-700); }
.banner > span { flex: 1; min-width: 0; }
.banner.bad { border-left-color: var(--bad); background: var(--bad-bg); }
.banner.bad .ic { color: var(--bad); }
.ed-sec { padding: 20px 0 24px; border-top: 1px solid var(--rule-2); }
.ed-sec > h2 { font: 600 13px/20px var(--f-sans); margin-bottom: 12px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.ed-sec > h2 small { font: 400 12px/16px var(--f-sans); color: var(--ink-3); }
.ed-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.span2 { grid-column: span 2; }
.cust-slip { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; padding: 12px 14px; border: 1px solid var(--rule-2); border-radius: var(--r-1); background: var(--paper); align-items: start; }
.cust-slip b { font: 600 15px/20px var(--f-sans); }
.cust-slip p { font-size: 12.5px; line-height: 18px; color: var(--ink-2); }
.cust-slip .hint { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; padding-top: 10px; border-top: 1px dashed var(--rule-2); font-size: 12.5px; color: var(--ink-2); }
.split-ind { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 10px 12px; background: var(--sunk); border-radius: var(--r-2); }
.si-track { position: relative; display: grid; grid-template-columns: 1fr 1fr; width: 216px; flex: none; padding: 2px; border-radius: 5px; background: var(--paper); border: 1px solid var(--rule-2); }
.si-track span { position: relative; z-index: 1; text-align: center; font: 500 11.5px/24px var(--f-mono); color: var(--ink-3); transition: color .18s; }
.si-thumb { position: absolute; z-index: 0; top: 2px; left: 2px; width: calc(50% - 2px); height: 24px; border-radius: 3px; background: var(--copper-600); transition: transform .2s cubic-bezier(.3, .7, .3, 1); }
.split-ind[data-mode="intra"] .si-a, .split-ind[data-mode="inter"] .si-b { color: var(--on-copper); }
.split-ind[data-mode="inter"] .si-thumb { transform: translateX(100%); }
.si-why { font-size: 12.5px; line-height: 17px; color: var(--ink-2); min-width: 0; }
.si-why b { font-weight: 600; color: var(--ink); }

.lines { display: grid; }
.line { display: grid; grid-template-columns: 22px minmax(0, 1fr) 30px; gap: 8px 8px; padding: 12px 0; border-top: 1px solid var(--rule); align-items: center; }
.line:first-child { border-top: 0; padding-top: 0; }
.line-n { font: 400 12px/36px var(--f-mono); color: var(--ink-3); align-self: start; }
.line-top { display: grid; grid-template-columns: minmax(0, 1fr) 132px; gap: 8px; align-items: center; }
.line-amt { font: 500 14px/20px var(--f-mono); text-align: right; white-space: nowrap; }
.line-sub { grid-column: 2; display: grid; grid-template-columns: 1.25fr .8fr .95fr 1.15fr .8fr .95fr; gap: 8px; }
.line-sub .field { gap: 3px; }
.line-sub label { font-size: 11px; line-height: 14px; color: var(--ink-3); font-weight: 400; }
.line-sub .in { height: 32px; font-size: 13px; padding: 0 8px; }
.line-sub select.in { padding-right: 22px; background-position: right 7px center; }
.line .ib { color: var(--ink-3); width: 30px; height: 30px; align-self: start; margin-top: 3px; }
.line .ib:hover { color: var(--bad); background: var(--bad-bg); }
.line-add { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--rule); align-items: center; flex-wrap: wrap; }
.adj { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.adj .field { grid-template-columns: auto; }
.inline { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.disc-row { display: flex; gap: 8px; align-items: center; }
.disc-row .in { width: 110px; }
.tl { display: grid; max-width: 400px; margin-left: auto; }
.tl > div { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; font-size: 13.5px; }
.tl > div span:last-child { font-family: var(--f-mono); font-size: 13px; }
.tl .muted span:first-child { color: var(--ink-3); }
.tl .grand { margin-top: 4px; padding: 10px 0 9px; border-top: 1px solid var(--ink); border-bottom: 3px double var(--ink); font-weight: 600; font-size: 15px; }
.tl .grand span:last-child { font-size: 17px; letter-spacing: -.02em; }
.tl-words { max-width: 400px; margin: 10px 0 0 auto; font-size: 12.5px; line-height: 18px; color: var(--ink-2); }
.ed-bar { position: sticky; bottom: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 8px -36px 0 -32px; padding: 12px 36px 12px 32px; background: var(--paper); border-top: 1px solid var(--rule-2); }
.ed-bar .tot { display: grid; }
.ed-bar .tot span { font-size: 11.5px; line-height: 14px; color: var(--ink-3); }
.ed-bar .tot b { font: 600 19px/26px var(--f-mono); letter-spacing: -.02em; }
.ed-bar > div:last-child { display: flex; gap: 8px; }
.pv { position: sticky; top: var(--bar-h); height: calc(100vh - var(--bar-h)); background: var(--sunk); border-left: 1px solid var(--rule-2); display: flex; flex-direction: column; min-width: 0; }
.pv-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 24px; font-size: 12px; color: var(--ink-3); flex: none; }
.pv-h b { font-weight: 500; color: var(--ink-2); display: flex; gap: 8px; align-items: center; }
.pv-h b i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.pv-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 28px 28px; min-height: 0; }
.seg.pv-tab { display: none; }

/* ---------- document pages (invoice, credit note) ---------- */
.doc { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 40px; align-items: start; }
.doc-paper { background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--r-1); padding: 28px; min-width: 0; }
.doc-side { display: grid; gap: 24px; position: sticky; top: calc(var(--bar-h) + 20px); }
.due-block { display: grid; gap: 6px; padding-bottom: 20px; border-bottom: 1px solid var(--rule-2); }
.due-block .fig { font-size: 30px; line-height: 38px; }
.due-block .when { font-size: 13px; color: var(--ink-2); }
.due-block .when.late { color: var(--bad); font-weight: 500; }
.meter { height: 6px; background: var(--mute-bg); border-radius: 1px; overflow: hidden; margin-top: 6px; display: flex; }
.meter i { background: var(--ok); } .meter i.c { background: var(--info); }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.acts .btn.pri { grid-column: 1 / -1; height: 40px; }
.acts .btn { justify-content: flex-start; }
.acts .btn.pri { justify-content: center; }
.side-h { font: 600 13px/20px var(--f-sans); padding-bottom: 6px; border-bottom: 1px solid var(--ink); display: flex; justify-content: space-between; }
.timeline { display: grid; padding-top: 6px; }
.timeline li { display: grid; grid-template-columns: 16px 1fr; gap: 10px; padding: 7px 0; font-size: 13px; line-height: 18px; position: relative; }
.timeline li::before { content: ""; width: 7px; height: 7px; margin: 6px 0 0 4px; border-radius: 50%; background: var(--rule-2); box-shadow: 0 0 0 3px var(--bg); position: relative; z-index: 1; }
.timeline li::after { content: ""; position: absolute; left: 7px; top: 18px; bottom: -8px; width: 1px; background: var(--rule-2); }
.timeline li:last-child::after { display: none; }
.timeline li.pay::before { background: var(--ok); } .timeline li.rem::before { background: var(--warn); } .timeline li.bad::before { background: var(--bad); } .timeline li.cn::before { background: var(--info); }
.timeline small { display: block; color: var(--ink-3); font-size: 12px; }
.brief { display: none; }

/* customer page */
.slip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--rule-2); background: var(--paper); margin-bottom: 32px; }
.slip > div { padding: 14px 20px; border-left: 1px solid var(--rule); min-width: 0; }
.slip > div:first-child { border-left: 0; }
.slip .lbl { display: block; color: var(--ink-3); margin-bottom: 4px; }
.slip p { font-size: 13px; line-height: 19px; overflow-wrap: anywhere; }
.slip .fig { font-size: 20px; line-height: 28px; }

/* gst summary */
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-nav b { font: 600 14px/20px var(--f-sans); min-width: 132px; text-align: center; }
.rate-bar { display: flex; height: 28px; gap: 2px; margin: 16px 0 6px; }
.rate-bar i { display: grid; place-items: center; font: 500 11px/1 var(--f-mono); font-style: normal; color: #FFFDF8; min-width: 2px; overflow: hidden; white-space: nowrap; }
.rt-0 { background: #8E978F; } .rt-5 { background: #7A8C5A; } .rt-18 { background: #B5622E; } .rt-40 { background: #6E2A1C; } .rt-3 { background: #9C8A4E; } .rt-12 { background: #C38F3F; } .rt-28 { background: #8C4418; }
.due-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 13px; }
.due-list li:last-child { border-bottom: 0; }
.due-list small { grid-column: 1 / -1; color: var(--ink-3); font-size: 12px; }
.due-list b { font-weight: 500; }

/* reminders */
.rule-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.rule-row:last-child { border-bottom: 0; }
.rule-row p { font-size: 12.5px; color: var(--ink-3); }
.rule-row b { font-weight: 500; }
.msg { border: 1px solid var(--rule-2); border-radius: var(--r-2); background: var(--paper); font-size: 13px; line-height: 20px; }
.msg-h { padding: 10px 14px; border-bottom: 1px solid var(--rule); display: grid; gap: 2px; font-size: 12.5px; color: var(--ink-2); }
.msg-h b { color: var(--ink); font-weight: 500; }
.msg-b { padding: 14px; white-space: pre-line; overflow-wrap: anywhere; }
.msg-att { display: inline-flex; align-items: center; gap: 8px; margin: 0 14px 14px; padding: 6px 10px; border: 1px solid var(--rule-2); border-radius: var(--r-2); font: 400 12px/16px var(--f-mono); color: var(--ink-2); }

/* settings */
.set-sec { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; padding: 28px 0; border-top: 1px solid var(--rule-2); }
.set-sec:first-of-type { border-top: 2px solid var(--ink); }
.set-sec > div:first-child h2 { font: 600 15px/20px var(--f-sans); margin-bottom: 4px; }
.set-sec > div:first-child p { font-size: 12.5px; line-height: 18px; color: var(--ink-3); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.set-row:first-child { padding-top: 0; }
.set-row:last-child { border-bottom: 0; padding-bottom: 0; }
.set-row p { font-size: 12.5px; color: var(--ink-3); }
.set-row b { font-weight: 500; }

/* receipt slip */
.rslip { background: var(--sheet); color: var(--sheet-ink); border: 1px solid var(--sheet-rule); padding: 22px 24px 18px; font-size: 12.5px; line-height: 18px; position: relative; border-radius: 1px; }
.rslip::after { content: ""; position: absolute; left: -1px; right: -1px; bottom: -7px; height: 7px; background: linear-gradient(135deg, var(--sheet) 50%, transparent 50%) 0 0 / 10px 7px repeat-x, linear-gradient(225deg, var(--sheet) 50%, transparent 50%) 0 0 / 10px 7px repeat-x; }
.rslip h3 { font: 600 10px/14px var(--f-sans); letter-spacing: .09em; text-transform: uppercase; color: var(--sheet-soft); }
.rslip .rs-top { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 2px solid var(--sheet-ink); }
.rslip .rs-top b { font: 600 15px/20px var(--f-sans); display: block; }
.rslip .rs-top p { font-size: 11.5px; color: var(--sheet-soft); line-height: 16px; }
.rslip .rs-amt { font: 600 26px/34px var(--f-mono); letter-spacing: -.02em; padding: 14px 0 2px; }
.rslip dl { display: grid; grid-template-columns: 120px 1fr; gap: 4px 12px; padding: 12px 0; margin-top: 12px; border-top: 1px solid var(--sheet-rule); }
.rslip dt { color: var(--sheet-soft); } .rslip dd { font-weight: 500; overflow-wrap: anywhere; }
.rslip .fine { color: #8A8474; border-top: 1px dashed var(--sheet-rule); padding-top: 10px; }

/* ---------- sign-in ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(420px, .9fr); background: var(--bg); }
.lg-art { background: #1F2A24; color: #F1EBDD; padding: 44px 56px 0; display: flex; flex-direction: column; overflow: hidden; position: relative; }
[data-theme="dark"] .lg-art { background: #0C100E; }
.lg-art .brand { font-size: 18px; padding: 0; }
.lg-art h1 { font: 600 38px/46px var(--f-sans); letter-spacing: -.025em; margin-top: 56px; max-width: 520px; }
.lg-art h1 em { font-style: normal; color: #E0A074; }
.lg-art > p { font-size: 15px; line-height: 24px; color: #B4BEB5; margin-top: 16px; max-width: 470px; }
.lg-paper { margin-top: 44px; flex: 1; position: relative; min-height: 260px; }
.lg-paper .sheet-box { margin: 0; }
.lg-form { display: grid; align-content: center; justify-items: center; padding: 40px 32px; }
.lg-card { width: 100%; max-width: 372px; display: grid; gap: 18px; }
.lg-card h2 { font: 600 22px/28px var(--f-sans); letter-spacing: -.01em; }
.lg-card > p { color: var(--ink-2); margin-top: -10px; }
.lg-card .btn { height: 42px; font-size: 14px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--rule-2); }
.lg-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

.tabbar { display: none; }

/* ---------- narrower desktops ---------- */
@media (max-width: 1260px) {
  .nav a.low { display: none; }
  .nav-more { display: flex; }
  .find { min-width: 0; }
  .find span, .find kbd { display: none; }
  .cols, .doc { grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; }
}
@media (max-width: 1040px) {
  .cols, .doc { grid-template-columns: minmax(0, 1fr); }
  .doc-side { position: static; }
  .nav a.mid { display: none; }
  .position { grid-template-columns: repeat(6, 1fr); }
  .pos { grid-column: span 2; }
  .pos:nth-child(n+4) { grid-column: span 3; border-top: 1px solid var(--rule); }
  .pos:nth-child(4) { border-left: 0; }
  .ed { grid-template-columns: minmax(0, 1fr); }
  .ed-form { justify-self: stretch; max-width: none; }
  .pv { position: static; height: auto; border-left: 0; border-top: 1px solid var(--rule-2); }
  .pv-scroll { overflow: visible; }
  .login { grid-template-columns: 1fr; }
  .lg-art { padding: 28px 24px 0; }
  .lg-art h1 { font-size: 28px; line-height: 36px; margin-top: 28px; }
  .lg-paper { display: none; }
  .lg-art > p { padding-bottom: 28px; }
}

/* ---------- phone ---------- */
@media (max-width: 760px) {
  :root { --bar-h: 52px; }
  body { font-size: 14.5px; }
  .bar { padding: 0 8px 0 14px; gap: 4px; }
  .bar .brand span, .nav, .find, .bar .split, .bar .who, .bar [data-act="shortcuts"] { display: none; }
  .span2 { grid-column: auto; }
  .ed-grid .span2 { grid-column: 1 / -1; }
  .brand { padding-right: 6px; }
  .bar-title { display: block; align-self: center; font: 600 16px/20px var(--f-sans); color: var(--bar-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .bar .ib { width: 40px; height: 40px; }
  .bar .ib.ph-only { display: inline-grid; }
  .page { padding: 18px 16px 112px; }
  .ph { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 16px; min-height: 0; }
  .ph h1 { font-size: 21px; line-height: 28px; }
  .ph h1 .m { font-size: 18px; }
  .ph-act { justify-content: flex-start; }
  .ph-act .btn { flex: 1; min-width: 0; height: 42px; }
  .ph-act .btn.icon { flex: none; width: 42px; }
  .btn { height: 42px; }
  .btn.sm { height: 34px; }
  .in { height: 44px; font-size: 16px; }
  .in.m { font-size: 15px; }
  .pre > span { height: 44px; }
  .grid2, .grid3 { grid-template-columns: 1fr; gap: 14px; }
  .grid2.keep { grid-template-columns: 1fr 1fr; }
  .seg button { height: 36px; }
  .sec { margin-top: 28px; }

  .position { grid-template-columns: 1fr 1fr; margin: 0 -16px 24px; border-bottom: 1px solid var(--rule-2); }
  .pos, .pos:nth-child(n+4) { grid-column: auto; }
  .pos { padding: 12px 16px; border-left: 0; border-top: 1px solid var(--rule); }
  .pos:nth-child(1) { grid-column: 1 / -1; border-top: 0; }
  .pos:nth-child(odd):not(:first-child) { border-left: 1px solid var(--rule); }
  .pos:nth-child(1) .fig { font-size: 28px; line-height: 36px; }
  .fig { font-size: 19px; line-height: 26px; }

  .tools { gap: 10px; margin-bottom: 10px; }
  .tabs { gap: 4px 2px; }
  .tabs button { height: 34px; padding: 0 9px; }
  .tools-r { width: 100%; flex-wrap: nowrap; }
  .tools-r .searchbox { flex: 1; min-width: 0; }
  .searchbox .in { width: 100%; height: 42px; padding-left: 34px; }
  .searchbox .ic { top: 11px; }
  .tools select.in { height: 42px; max-width: 136px; font-size: 14px; text-overflow: ellipsis; }
  .tools-r .btn { flex: none; }
  .tools-r .btn.csv span { display: none; }

  /* ledgers become stacked two-line rows, still ruled, edge to edge */
  .ledger-wrap { margin: 0 -16px; border-left: 0; border-right: 0; border-radius: 0; }
  .ledger, .ledger tbody, .ledger tfoot { display: block; }
  .ledger thead { display: none; }
  .ledger tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main amt" "meta tag"; gap: 3px 12px; padding: 11px 16px; border-bottom: 1px solid var(--rule); align-items: center; }
  .ledger tbody tr:last-child { border-bottom: 0; }
  .ledger td { display: none; height: auto; padding: 0 !important; border: 0 !important; background: transparent !important; }
  .ledger td.k-main { display: block; grid-area: main; font-size: 14.5px; min-width: 0; }
  .ledger td.k-amt { display: block; grid-area: amt; font-size: 14px; font-weight: 500; }
  .ledger td.k-meta { display: block; grid-area: meta; font-size: 12.5px; color: var(--ink-3); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; font-family: var(--f-sans); }
  span.ph-cell { display: inline; }
  .ledger td.k-tag { display: block; grid-area: tag; justify-self: end; text-align: right; font-size: 12.5px; }
  .ledger td.k-main .two small { display: none; }
  .ledger tfoot tr { border-top: 3px double var(--ink-3); border-bottom: 0; }
  .ledger tfoot td { background: transparent; }
  .ledger tfoot td.k-main { font: 500 12.5px/18px var(--f-sans); color: var(--ink-3); }
  .ledger tr.sk-row { display: block; padding: 18px 16px; }
  .ledger tr.sk-row td { display: none; }
  .ledger tr.sk-row td:first-child { display: block; }
  .ledger tr.pay-act { grid-template-areas: "main amt" "meta tag" "act act"; }
  .ledger td.k-act { display: block; grid-area: act; padding-top: 6px !important; }
  .row-act { opacity: 1; justify-content: flex-start; gap: 8px; }
  .row-act .ib { display: none; }
  .empty { padding: 28px 16px 32px; }
  .steps li { grid-template-columns: 40px minmax(0, 1fr); gap: 0 12px; padding-right: 16px; }
  .steps li > div { padding: 14px 0 10px; }
  .steps li > .btn, .steps li > .ok { grid-column: 2; justify-self: start; margin-bottom: 14px; }
  .st-n { grid-row: 1 / span 2; place-items: start center; padding-top: 14px; }
  .pager { padding: 12px 0 0; }
  .cols { gap: 0; }
  .col-side { margin-top: 28px; }

  .scrim { padding: 0; place-items: end stretch; }
  .win, .win.wide, .win.mid { max-width: none; max-height: 92vh; border-radius: 14px 14px 0 0; border-width: 1px 0 0; animation: sheet .2s ease-out; }
  .win-h { padding: 16px 12px 12px 16px; }
  .win-b { padding: 16px; }
  .win-f { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .win-f .btn { flex: 1; }
  .win-f .fine { flex-basis: 100%; margin: 0 0 4px; }
  .win.pal { align-self: stretch; margin-top: 0; max-height: 100vh; height: 100vh; border-radius: 0; }
  .pal-list { max-height: none; flex: 1; }
  .pal-f { display: none; }
  @keyframes sheet { from { transform: translateY(24px); opacity: 0; } }
  .keys { grid-template-columns: 1fr; }
  #toasts { left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); justify-items: stretch; }
  .toast { max-width: none; }
  body:has(.ed-bar) #toasts { bottom: calc(140px + env(safe-area-inset-bottom)); }
  /* a bottom sheet or menu owns the bottom of the screen, so messages move to the top while one is open */
  body:has(#modal-root .win) #toasts, body:has(#pop-root .menu) #toasts { bottom: auto; top: 6px; }
  .menu { left: 8px !important; right: 8px; max-width: none; top: auto !important; bottom: calc(72px + env(safe-area-inset-bottom)); }
  .menu button, .menu a { min-height: 44px; font-size: 15px; }

  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; height: calc(62px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--paper); border-top: 1px solid var(--rule-2); }
  .tb { display: grid; justify-items: center; align-content: center; gap: 3px; font: 500 10.5px/14px var(--f-sans); color: var(--ink-3); position: relative; }
  .tb:hover { text-decoration: none; }
  .tb.on { color: var(--ink); }
  .tb.on::before { content: ""; position: absolute; top: -1px; left: 26%; right: 26%; height: 3px; background: var(--copper); }
  .tb.new span { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--copper-600); color: var(--on-copper); margin-top: -4px; }

  .ed-form { padding: 16px 16px 0; }
  .ed-top { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 14px; }
  .ed-top h1 { font-size: 20px; }
  .seg.pv-tab { display: flex; margin-bottom: 14px; }
  .ed[data-pane="form"] .pv { display: none; }
  .ed[data-pane="paper"] .ed-form > *:not(.ed-top):not(.pv-tab):not(.ed-bar) { display: none; }
  .ed[data-pane="paper"] .pv { display: flex; padding-bottom: 150px; border-top: 0; }
  .pv-h { padding: 10px 16px; }
  .pv-h .seg { display: none; }
  .pv-scroll { padding: 4px 16px 20px; }
  .ed-grid { grid-template-columns: 1fr 1fr; gap: 14px 12px; }
  .ed-grid .wide { grid-column: 1 / -1; }
  .split-ind { flex-direction: column; align-items: stretch; gap: 8px; }
  .si-track { width: 100%; }
  .si-track span { line-height: 28px; }
  .si-thumb { height: 28px; }
  .line { grid-template-columns: minmax(0, 1fr) 36px; }
  .line-n { display: none; }
  .line-top { grid-template-columns: minmax(0, 1fr); }
  .line-top .line-amt { display: none; }
  .line-sub { grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .line-sub .in { height: 42px; font-size: 16px; }
  .line .ib { width: 36px; height: 44px; margin-top: 0; }
  .line-foot { grid-column: 1 / -1; display: flex !important; justify-content: space-between; font-size: 12.5px; color: var(--ink-3); }
  .line-foot b { font: 500 14px/20px var(--f-mono); color: var(--ink); }
  .tl, .tl-words { max-width: none; }
  .ed-bar { margin: 8px -16px 0; padding: 10px 16px; bottom: calc(62px + env(safe-area-inset-bottom)); }
  .ed-bar .btn.opt-x { display: none; }
  .ed-bar .tot b { font-size: 17px; }
  .adj { gap: 14px; }

  .doc { gap: 20px; }
  .doc-paper { padding: 12px; margin: 0 -16px; border-left: 0; border-right: 0; border-radius: 0; order: 6; }
  .doc-side { display: contents; }
  .due-block { order: 1; }
  .acts { order: 2; }
  .lockn { order: 3; margin-top: -8px; }
  .brief { display: block; order: 4; }
  .side-money { order: 5; }
  .side-act { order: 7; }
  .brief .klist > * { min-height: 0; padding: 9px 0; align-items: flex-start; }
  .brief .klist .k { display: grid; gap: 0; color: var(--ink); }
  .brief .klist .k small { color: var(--ink-3); font-size: 12px; }
  .slip { grid-template-columns: 1fr 1fr; margin: 0 -16px 24px; }
  .slip > div { padding: 12px 16px; border-top: 1px solid var(--rule); }
  .slip > div:nth-child(-n+2) { border-top: 0; }
  .slip > div:nth-child(odd) { border-left: 0; }
  .set-sec { grid-template-columns: 1fr; gap: 16px; padding: 22px 0; }
  .set-row { gap: 14px; }
  .rule-row { grid-template-columns: 36px minmax(0, 1fr); }
  .rule-row > :last-child { grid-column: 2; justify-self: start; }
  .month-nav b { min-width: 0; flex: 1; }
  .month-nav { width: 100%; }
  .lg-form { padding: 28px 20px 40px; align-content: start; }
  .lg-art h1 { font-size: 26px; line-height: 33px; }
  .acts .btn { height: 42px; }
}
.bar .ib.ph-only { display: none; }
@media (max-width: 760px) { .bar .ib.ph-only { display: inline-grid; } }
.line-foot { display: none; }

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

/* ---------- print: only the document, at true A4 ---------- */
#print-root { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  #print-root .sheet { position: static; transform: none !important; width: 210mm; min-height: 296mm; box-shadow: none; background: #fff; padding: 12mm 13mm 10mm; }
  #print-root .rslip { width: 120mm; margin: 14mm auto; background: #fff; }
  #print-root .rslip::after { display: none; }
  .sh-stamp { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sh-logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
