:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #16202b;
  --ink-2: #4a5866;
  --muted: #7b8794;
  --line: #e1e6eb;
  --line-2: #cfd7de;
  --primary: #1f5f8b;
  --primary-ink: #ffffff;
  --primary-soft: #e6f0f7;
  --side: #10283d;
  --side-ink: #c4d2de;
  --danger: #c0392b;
  --ok: #157f3b;
  --warn: #a86400;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 40, 61, .06), 0 1px 1px rgba(16, 40, 61, .04);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 650; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 18px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 0; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .2px; }
.num { font-variant-numeric: tabular-nums; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; }
.warn { color: var(--warn); }
.mt { margin-top: 12px; }
.print-only { display: none; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 228px; flex: none; background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; color: #fff; font-weight: 650; }
.brand.big { color: var(--ink); font-size: 20px; padding: 0 0 4px; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.logo-mark {
  flex: none; width: 30px; height: 30px; border-radius: 7px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; letter-spacing: .5px;
}
.side nav { display: flex; flex-direction: column; padding: 4px 8px; gap: 2px; overflow-y: auto; }
.side nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px;
  color: var(--side-ink); text-decoration: none; font-size: 14px;
}
.side nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side nav a.on { background: rgba(255, 255, 255, .13); color: #fff; font-weight: 600; }
.side nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side-foot { margin-top: auto; padding: 14px 16px; font-size: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }
.side-foot a { color: #fff; }
.mode { font-weight: 600; margin-bottom: 2px; }
.mode.cloud { color: #7fd69b; }
.mode.local { color: #f1c27d; }
.mode.file { color: #9cc8ef; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.top-right { display: flex; align-items: center; gap: 10px; }
.fy { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink-2); }
.fy .input { width: auto; padding: 5px 8px; }
.menu-btn { display: none; margin-right: auto; font-size: 20px; }
.content { padding: 22px 24px 60px; max-width: 1280px; width: 100%; }
.scrim { display: none; }

/* ---------- building blocks ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.pad { padding: 16px; }
.pad-x { padding: 14px 16px 6px; }
.card-title { margin-bottom: 12px; font-size: 14px; font-weight: 650; color: var(--ink); }
.card-title.pad { margin: 0; padding-bottom: 4px; }
.nomargin { margin: 0; }
.grid2, .grid3, .grid4, .grid5 { display: grid; gap: 12px 16px; }
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid2.gap { gap: 0 16px; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-inline { display: flex; align-items: center; gap: 6px; }
.row-inline.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 260px; min-width: 0; }
.span4 { grid-column: 1 / -1; }
.company-pick select { max-width: 260px; font-weight: 600; }
.row-on td { background: #f2f7fb; }
.jobs-tbl { margin: 2px 0 8px; font-weight: 400; }
.jobs-tbl td { padding: 6px 8px; vertical-align: middle; }
.attach { display: flex; flex-direction: column; gap: 6px; }
.attach-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.attach-type { font-size: 10px; font-weight: 700; color: #fff; background: var(--primary); border-radius: 3px; padding: 1px 5px; }
.update-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50; background: #1f2937; color: #fff;
  padding: 10px 14px; border-radius: 8px; display: flex; gap: 12px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.lock-note { background: #fff7e6; border: 1px solid #f3d9a4; color: #7a5200; border-radius: 6px; padding: 8px 12px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); min-width: 0; }
.hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.hint.warn { color: var(--warn); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin: 4px 0 10px; cursor: pointer; }
.input {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line-2); border-radius: 6px; background: #fff;
  font: inherit; color: var(--ink); font-weight: 400; min-width: 0;
}
.input:focus { outline: 2px solid rgba(31, 95, 139, .25); border-color: var(--primary); }
.input[readonly], .input:disabled { background: #f3f5f7; color: var(--ink-2); }
textarea.input { resize: vertical; }
.input.num { text-align: right; }
.small-input { width: 110px; padding: 4px 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 14px;
  border: 1px solid var(--line-2); border-radius: 6px; background: #fff; color: var(--ink);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: #f2f5f8; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: #194f75; }
.btn.danger { color: var(--danger); border-color: #e7c1bc; }
.btn.danger:hover { background: #fdf1ef; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 18px; line-height: 1; padding: 4px 7px; border-radius: 5px; color: var(--ink-2); }
.icon-btn:hover { background: #eef1f4; }
.icon-btn.danger:hover { color: var(--danger); background: #fdf1ef; }
.icon-btn:disabled { opacity: .3; cursor: default; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input { width: auto; }
.filters .search { flex: 1 1 260px; }
.period { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.period .input { width: auto; }
.ledger-party { width: 320px; max-width: 100%; }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-2); background: #f7f9fa;
  padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tfoot td { font-weight: 650; border-top: 1px solid var(--line-2); background: #f7f9fa; padding: 9px 10px; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #f5f9fc; }
.tbl tr.grand td { font-weight: 700; }
.tbl tr.sep td { border-top: 2px solid var(--line-2); }
.tbl .empty { text-align: center; color: var(--muted); padding: 26px; }
.tbl.lines td { padding: 6px 6px; vertical-align: middle; }
.tbl.lines th { padding: 8px 6px; }
.tbl.lines .input { padding: 6px 7px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.b-paid { background: #e5f4ea; color: var(--ok); }
.b-partial { background: #fff3dc; color: #8a5300; }
.b-unpaid { background: #fdecea; color: #a8322a; }
.b-draft { background: #eef1f4; color: var(--ink-2); border-color: var(--line-2); }
.b-cancelled { background: #f3f3f3; color: #777; text-decoration: line-through; }

.party-box { margin-top: 10px; padding: 10px 12px; background: #f7f9fa; border-radius: 6px; font-size: 13px; }
.totals-wrap { display: flex; gap: 24px; justify-content: space-between; align-items: flex-start; border-top: 1px solid var(--line); flex-wrap: wrap; }
.totals-wrap .notes { flex: 1 1 280px; }
.totals { border-collapse: collapse; min-width: 300px; }
.totals td { padding: 5px 0 5px 16px; }
.totals td:first-child { padding-left: 0; color: var(--ink-2); }
.totals td.num { text-align: right; }
.totals tr.grand td { font-size: 17px; font-weight: 700; color: var(--ink); border-top: 1px solid var(--line-2); padding-top: 9px; }
.totals .words { max-width: 320px; }
.summary-line { border-top: 1px solid var(--line); }
.note { background: #fff8e6; border: 1px solid #f1dfb0; padding: 10px 12px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; }
.thumb { height: 40px; border: 1px solid var(--line); border-radius: 4px; }
.bank-row { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.welcome ol { padding-left: 20px; }
.welcome li { margin: 4px 0; }

/* search-select */
.ss { position: relative; }
.ss-list {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 2px); background: #fff;
  border: 1px solid var(--line-2); border-radius: 6px; box-shadow: 0 8px 24px rgba(16, 40, 61, .14); max-height: 300px; overflow-y: auto;
}
.ss-item { padding: 7px 10px; cursor: pointer; font-weight: 400; color: var(--ink); }
.ss-item.hi { background: var(--primary-soft); }
.ss-create { color: var(--primary); font-weight: 600; border-top: 1px solid var(--line); }
.ss-empty { padding: 8px 10px; color: var(--muted); font-weight: 400; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(16, 32, 48, .45); display: grid; place-items: start center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 640px; max-width: 100%; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal.wide { width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 10px 10px; }

/* toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: calc(100vw - 32px); }
.toast { background: #17324a; color: #fff; padding: 10px 14px; border-radius: 7px; box-shadow: 0 6px 18px rgba(0, 0, 0, .2); max-width: 420px; }
.toast.err { background: #a8322a; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 9px 12px; font: inherit; font-weight: 550; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.on { color: var(--primary); border-bottom-color: var(--primary); }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 380px; max-width: 100%; display: flex; flex-direction: column; gap: 12px; }
.err { color: var(--danger); font-size: 13px; }

/* dashboard */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi-l { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.kpi-v { font-size: 22px; font-weight: 700; margin: 4px 0 2px; }
.kpi-s { font-size: 12px; color: var(--muted); }

.chart { position: relative; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.sw.s1 { background: var(--series-1); }
.sw.s2 { background: var(--series-2); }
.chart-box { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart path.s1 { fill: var(--series-1); }
.chart path.s2 { fill: var(--series-2); }
.chart .grid { stroke: #e7eaee; stroke-width: 1; }
.chart .axis { stroke: #c3cbd3; stroke-width: 1; }
.chart .tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; }
.chart .hit.on { fill: rgba(31, 95, 139, .06); }
.chart-empty { position: absolute; inset: 0 0 26px 56px; display: grid; place-items: center; color: var(--muted); font-size: 13px; pointer-events: none; }
.tip {
  position: absolute; top: 0; transform: translateX(-50%); background: #fff; border: 1px solid var(--line-2); border-radius: 6px;
  padding: 8px 10px; font-size: 12.5px; box-shadow: 0 6px 18px rgba(16, 40, 61, .14); pointer-events: none; white-space: nowrap; color: var(--ink-2);
}
.tip b { color: var(--ink); margin-left: 4px; }
.tip-h { font-weight: 650; color: var(--ink); margin-bottom: 3px; }

/* ---------- invoice sheet (screen + print) ---------- */
.inv-sheet {
  background: #fff; color: #000; width: 210mm; max-width: 100%; margin: 0 auto 30px; padding: 10mm;
  border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 11.5px; line-height: 1.4; position: relative;
}
.inv-sheet.cancelled::after, .inv-sheet.draft::after {
  content: 'CANCELLED'; position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-25deg);
  font-size: 80px; font-weight: 800; color: rgba(192, 57, 43, .13); pointer-events: none;
}
.inv-sheet.draft::after { content: 'DRAFT'; color: rgba(0, 0, 0, .08); }
.inv-head { display: flex; gap: 14px; align-items: center; border: 1px solid #000; border-bottom: 0; padding: 8px 10px; }
.inv-logo { max-height: 64px; max-width: 120px; }
.inv-co { flex: 1; text-align: center; }
.inv-co-name { font-size: 20px; font-weight: 800; letter-spacing: .3px; }
.inv-title { border: 1px solid #000; text-align: center; font-weight: 800; font-size: 14px; padding: 4px; background: #eef2f5; letter-spacing: .5px; }
.inv-meta { width: 100%; border-collapse: collapse; }
.inv-meta td, .inv-meta th { border: 1px solid #000; border-top: 0; padding: 5px 8px; vertical-align: top; width: 50%; text-align: left; }
.inv-meta th { background: #eef2f5; font-size: 12px; }
.inv-meta span { color: #333; }
.inv-items { width: 100%; border-collapse: collapse; }
.inv-items th, .inv-items td { border: 1px solid #000; border-top: 0; padding: 4px 6px; }
.inv-items th { background: #eef2f5; text-align: left; font-size: 11px; }
.inv-items .r { text-align: right; }
.inv-bottom { display: flex; border: 1px solid #000; border-top: 0; }
.inv-left { flex: 1; padding: 6px 8px; border-right: 1px solid #000; }
.inv-split { border-collapse: collapse; margin-bottom: 6px; font-size: 10.5px; }
.inv-split th, .inv-split td { border: 1px solid #999; padding: 2px 6px; }
.inv-split th { background: #f4f6f8; font-weight: 600; }
.inv-words { margin-top: 4px; }
.inv-totals { border-collapse: collapse; width: 42%; }
.inv-totals td { padding: 3px 8px; border-bottom: 1px solid #ccc; }
.inv-totals tr.grand td { font-weight: 800; font-size: 13px; background: #eef2f5; border-bottom: 0; border-top: 1px solid #000; }
.inv-terms { border: 1px solid #000; border-top: 0; padding: 6px 8px; font-size: 10.5px; }
.inv-foot { display: flex; border: 1px solid #000; border-top: 0; }
.inv-banks { flex: 1; padding: 6px 8px; border-right: 1px solid #000; }
.inv-bank { margin-top: 4px; }
.inv-sign { width: 42%; padding: 6px 8px; text-align: center; display: flex; flex-direction: column; justify-content: space-between; gap: 4px; }
.sign-space { height: 46px; }
.inv-signature { max-height: 60px; max-width: 160px; margin: 0 auto; }

/* ---------- accounting screens ---------- */
.nav-h { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; color: #7f97ad; padding: 12px 10px 3px; font-weight: 700; }
.side nav a { padding: 7px 10px; }
.neg { color: var(--danger); }
.kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.small-kpi .kpi-v { font-size: 18px; }
.tag { font-size: 10.5px; color: var(--muted); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; margin-left: 4px; font-weight: 500; }
.check.nomargin { margin: 0; }
.big-num { font-size: 18px; color: var(--ink); padding-top: 6px; }
.tds-box { border-top: 1px solid var(--line); background: #fbfcfd; }
.summary-line.nob { border-top: 0; padding: 4px 0 0; margin: 0; }
.quick { margin: 0 0 14px; }

.acc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 12px; }
.acc-card { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; font: inherit; color: var(--ink); box-shadow: var(--shadow); }
.acc-card:hover { border-color: var(--line-2); }
.acc-card.on { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(31, 95, 139, .15); }
.acc-name { font-weight: 600; font-size: 13px; }
.acc-bal { font-size: 20px; font-weight: 700; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; margin-bottom: 6px; background: #fff; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 16px; font: inherit; font-weight: 550; color: var(--ink-2); cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--primary); color: #fff; }

.brs { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 16px; margin-bottom: 16px; max-width: 620px; box-shadow: var(--shadow); }
.brs > div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-variant-numeric: tabular-nums; }
.brs > div:last-child { border-bottom: 0; }
.brs .tot { font-weight: 700; border-top: 1px solid var(--line-2); }
.brs .okline { color: var(--ok); font-weight: 600; }
.brs .badline { color: var(--danger); font-weight: 600; }
.tbl tr.unmatched td { background: #fffaf0; }

.coa { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; align-items: start; }
.tbl tr.grp td { background: #f3f6f8; font-weight: 650; font-size: 12.5px; color: var(--ink-2); padding: 6px 10px; }
.tbl td.indent, .fin-tbl td.indent { padding-left: 24px; }
.tbl.daybook tr.first td { border-top: 1px solid var(--line-2); }
.tbl.daybook td { border-bottom: 0; padding-top: 4px; padding-bottom: 4px; }

.fin { max-width: 760px; }
.fin-tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.fin-tbl td { padding: 5px 6px; }
.fin-tbl tr.h td { font-weight: 650; padding-top: 12px; }
.fin-tbl tr.sub td { font-weight: 700; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.fin-tbl tr.total td { font-weight: 800; font-size: 15px; border-top: 2px solid var(--ink); padding-top: 9px; }
.fin-tbl td:nth-child(2), .fin-tbl td:nth-child(3) { width: 150px; }
.bs-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.bs-grid .fin { max-width: none; }

/* ---------- responsive ---------- */
@media screen and (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media screen and (max-width: 860px) {
  .side { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 55; }
  .menu-btn { display: inline-block; }
  .top { padding: 8px 16px; justify-content: space-between; }
  .content { padding: 16px 16px 60px; }
  .grid2, .grid3, .grid4, .grid5 { grid-template-columns: minmax(0, 1fr); }
  .span2, .span3 { grid-column: auto; }
  .grid2.gap { gap: 0; }
  .kpis, .kpis.three, .kpis.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .coa, .bs-grid { grid-template-columns: minmax(0, 1fr); }
  .seg button { padding: 7px 10px; }
  .inv-sheet { padding: 4mm; font-size: 10.5px; }
  .inv-bottom, .inv-foot { flex-direction: column; }
  .inv-left, .inv-banks { border-right: 0; border-bottom: 1px solid #000; }
  .inv-totals, .inv-sign { width: 100%; }
  .filters .input, .period .input { flex: 1 1 140px; }
}

/* ---------- print ---------- */
/* zero page margin: the browser then has no room for its own header / footer (page title, date, web address),
   so the white margin is put on the page content instead — repeated on every printed page */
@page { size: A4; margin: 0; }
@media print {
  body { background: #fff; }
  .no-print, .side, .top, .toasts, .note { display: none !important; }
  .shell, .main { display: block; }
  .content { padding: 9mm 9mm 8mm; max-width: none; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
  .print-only { display: block; }
  .report-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
  .card { box-shadow: none; border: 0; margin-bottom: 10px; }
  .table-wrap { overflow: visible; }
  .tbl { font-size: 10.5px; }
  .tbl th, .tbl td { padding: 4px 5px; }
  .tbl th { background: #eee !important; }
  .inv-sheet { width: auto; margin: 0; padding: 0; border: 0; box-shadow: none; font-size: 11px; }
  .inv-title, .inv-meta th, .inv-items th, .inv-totals tr.grand td { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .inv-items tr { break-inside: avoid; }
  .inv-foot, .inv-terms, .inv-bottom { break-inside: avoid; }
  /* anything the host injects outside the app (e.g. Netlify's "Powered by Netlify" badge) never prints */
  body > :not(#app), #nl-badge-frame { display: none !important; }
  .inv-x * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .inv-x .x-items tr, .inv-x .x-bottom, .inv-x .x-foot, .inv-x .x-parties { break-inside: avoid; }
  a { color: inherit; }
}

/* e-invoice / e-way bill */
.break { word-break: break-all; }
.einv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.qr-img { width: 116px; height: 116px; image-rendering: pixelated; display: block; }
.inv-irn { margin-left: auto; width: 250px; font-size: 8.5px; line-height: 1.35; text-align: left; word-break: break-all; }
.inv-irn .qr-img { margin: 0 0 3px auto; }

/* ---------- invoice templates: modern / minimal ---------- */
.inv-x { --acc: #1f4e79; --acc-soft: #f1f4f8; color: #1d2329; font-size: 11px; line-height: 1.45; }
.inv-x .pre { white-space: pre-line; }
.inv-x .r { text-align: right; }
.inv-x .x-muted { color: #6b7680; }
.inv-x .x-head { display: flex; gap: 18px; align-items: flex-start; padding-bottom: 12px; border-bottom: 3px solid var(--acc); }
.inv-x .x-brand { flex: 1; display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.inv-x .x-logo { max-height: 62px; max-width: 110px; }
.inv-x .x-co { font-size: 19px; font-weight: 800; color: var(--acc); line-height: 1.2; letter-spacing: .2px; }
.inv-x .x-addr { color: #4a545e; margin-top: 3px; }
.inv-x .x-ids { margin-top: 4px; display: flex; gap: 4px 14px; flex-wrap: wrap; color: #6b7680; }
.inv-x .x-ids b { color: #1d2329; font-weight: 600; }
.inv-x .x-contact { color: #4a545e; margin-top: 2px; }
.inv-x .x-titlebox { min-width: 200px; }
.inv-x .x-title { font-size: 19px; font-weight: 800; letter-spacing: 2.5px; text-transform: uppercase; color: var(--acc); text-align: right; line-height: 1.1; margin-bottom: 7px; }
.inv-x .x-status { text-align: right; color: #c0392b; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin: -4px 0 4px; }
.inv-x .x-kv { border-collapse: collapse; margin-left: auto; }
.inv-x .x-kv td { padding: 1.5px 0 1.5px 14px; text-align: right; vertical-align: top; }
.inv-x .x-kv td:first-child { color: #6b7680; }
.inv-x .x-qr .qr-img { width: 104px; height: 104px; }
.inv-x .x-irn { font-size: 8.5px; color: #4a545e; padding: 5px 0; border-bottom: 1px solid #e3e7eb; word-break: break-all; }
.inv-x .x-parties { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 12px; margin: 12px 0 14px; }
.inv-x .x-party { background: var(--acc-soft); border-radius: 6px; padding: 8px 11px; }
.inv-x .x-party b { font-size: 12px; }
.inv-x .x-lbl { font-size: 8.5px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--acc); margin-bottom: 3px; }
.inv-x .x-items { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.inv-x .x-items th { background: var(--acc); color: #fff; font-weight: 600; font-size: 9.5px; text-transform: uppercase; letter-spacing: .5px; padding: 6px 7px; text-align: left; }
.inv-x .x-items th.r { text-align: right; }
.inv-x .x-items td { padding: 6px 7px; border-bottom: 1px solid #e3e7eb; vertical-align: top; }
.inv-x .x-items tbody tr:last-child td { border-bottom: 1.5px solid #c3cbd2; }
.inv-x .x-bottom { display: flex; gap: 22px; margin-top: 12px; align-items: flex-start; }
.inv-x .x-left { flex: 1; min-width: 0; }
.inv-x .x-right { width: 38%; }
.inv-x .x-words { font-weight: 600; margin-bottom: 8px; }
.inv-x .x-split { border-collapse: collapse; font-size: 9.5px; margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.inv-x .x-split th, .inv-x .x-split td { padding: 2px 10px 2px 0; border-bottom: 1px solid #e3e7eb; }
.inv-x .x-split th { color: #6b7680; font-weight: 600; text-align: left; }
.inv-x .x-split th.r { text-align: right; }
.inv-x .x-rc { font-weight: 600; margin-bottom: 8px; }
.inv-x .x-bank { margin-top: 6px; }
.inv-x .x-bank-one { margin-bottom: 4px; }
.inv-x .x-tot { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.inv-x .x-tot td { padding: 4px 9px; border-bottom: 1px solid #e3e7eb; }
.inv-x .x-tot td:last-child { text-align: right; }
.inv-x .x-tot tr.grand td { background: var(--acc); color: #fff; font-weight: 800; font-size: 13.5px; padding: 8px 9px; border: 0; }
.inv-x .x-foot { display: flex; gap: 22px; margin-top: 18px; align-items: flex-end; }
.inv-x .x-terms { flex: 1; font-size: 9.5px; color: #4a545e; min-width: 0; }
.inv-x .x-sign { width: 38%; text-align: center; display: flex; flex-direction: column; gap: 3px; }
.inv-x .x-sigline { border-top: 1px solid #9aa4ad; padding-top: 4px; margin-top: 2px; }
.inv-x .x-note { text-align: center; font-size: 8.5px; color: #8a949d; margin-top: 14px; }
.inv-x.t-minimal .x-head { border-bottom-width: 1.5px; }
.inv-x.t-minimal .x-title { font-weight: 600; letter-spacing: 4px; }
.inv-x.t-minimal .x-party { border: 1px solid #d5d9dd; }
.inv-x.t-minimal .x-items th { background: #fff; color: #111; border-top: 1.5px solid #111; border-bottom: 1.5px solid #111; }
.inv-x.t-minimal .x-tot tr.grand td { background: #fff; color: #111; border-top: 1.5px solid #111; border-bottom: 1.5px solid #111; }
@media screen and (max-width: 860px) {
  .inv-x .x-head, .inv-x .x-bottom, .inv-x .x-foot { flex-direction: column; }
  .inv-x .x-right, .inv-x .x-sign, .inv-x .x-titlebox { width: 100%; }
  .inv-x .x-parties { grid-auto-flow: row; }
}
.tpl-pick { display: inline-flex; gap: 6px; align-items: center; }.swatch { display: inline-block; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line-2); }
.inv-x .x-items td:nth-child(2) { min-width: 150px; }

/* home: one card per company */
.co-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; margin-bottom: 12px; }
.co-card { margin-bottom: 0; display: flex; flex-direction: column; gap: 6px; }
.co-card.co-on { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(31, 95, 139, .12); }
.co-name { font-size: 15.5px; font-weight: 700; color: var(--ink); }
.co-figs { width: 100%; border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.co-figs td { padding: 4px 0; border-bottom: 1px solid var(--line); }
.co-figs td:last-child { padding-left: 10px; width: 90px; }
.co-status { display: grid; gap: 2px; margin-top: 4px; }
.co-card .mt { margin-top: auto; padding-top: 8px; }