/* SysBin Invoicing */

@font-face {
  font-family: "Lexend";
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/lexend-latin-400.woff2") format("woff2");
}
@font-face {
  font-family: "Lexend";
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/lexend-latin-600.woff2") format("woff2");
}
@font-face {
  font-family: "Lexend";
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/lexend-latin-700.woff2") format("woff2");
}

:root {
  --bg: #f5f5f2;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --text: #17181c;
  --muted: #676c75;
  --border: #e2e2dd;
  --border-strong: #c9c9c2;
  --ink: #111111;
  --ink-contrast: #ffffff;
  --focus: #2457d6;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --warn: #93370d;
  --warn-bg: #fffaeb;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --info: #1849a9;
  --info-bg: #eff4ff;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-brand: "Lexend", var(--font);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}

h1, h2, h3 { font-family: var(--font-brand); line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; font-weight: 600; }
h2 { font-size: 1.05rem; font-weight: 600; }
h3 { font-size: .95rem; font-weight: 600; margin-top: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--info); text-underline-offset: 2px; }
a:hover { color: var(--ink); }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 .3em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.big { font-family: var(--font-brand); font-size: 1.8rem; font-weight: 600; margin: 0; }
.empty { color: var(--muted); padding: 1.5rem 0; text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: .25rem 0; }

/* ---- Top bar ---------------------------------------------------------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--ink); text-decoration: none; font-family: var(--font-brand); font-size: 1.05rem; }
.brand img { display: block; }
.mainnav, .subnav { display: flex; gap: .25rem; flex-wrap: wrap; }
.mainnav a, .subnav a { color: var(--muted); text-decoration: none; padding: .4rem .7rem; border-radius: 8px; font-weight: 500; }
.mainnav a:hover, .subnav a:hover { color: var(--ink); background: var(--surface-2); }
.mainnav a[aria-current="page"], .subnav a[aria-current="page"] { color: var(--ink); background: #ecece7; }
.usermenu { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.usermenu a { color: var(--text); text-decoration: none; font-size: .9rem; }
.usermenu form { margin: 0; }
.subnav { max-width: 1240px; margin: 0 auto; padding: 0 1rem .5rem; }

.container { max-width: 1240px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

/* ---- Page structure --------------------------------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.crumbs { margin: 0 0 .2rem; font-size: .85rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.card-danger { border-color: #f4c7c3; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + section { margin-top: 1.25rem; }

/* ---- Stats ------------------------------------------------------------ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { display: flex; flex-direction: column; gap: .2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.15rem; color: inherit; text-decoration: none; }
a.stat:hover { border-color: var(--border-strong); color: inherit; }
.stat-label { color: var(--muted); font-size: .85rem; font-weight: 500; }
.stat-value { font-family: var(--font-brand); font-size: 1.55rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: .8rem; }
.stat-alert { border-color: #f4c7c3; background: var(--danger-bg); }
.stat-alert .stat-value { color: var(--danger); }

/* ---- Tables ----------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .6rem .7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:hover { background: var(--surface-2); }
.table a:not(.btn) { color: var(--ink); text-decoration: none; }
.table a:not(.btn):hover { text-decoration: underline; }
.table .total-row th, .table .total-row td { font-weight: 600; border-bottom: 0; }
.table.audit td { font-size: .88rem; }
pre.json { font: .8rem/1.4 var(--mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: .6rem; overflow-x: auto; max-height: 320px; white-space: pre-wrap; word-break: break-word; }

/* ---- Badges ----------------------------------------------------------- */
.badge { display: inline-block; font: 600 .72rem/1 var(--font); letter-spacing: .02em; padding: .32rem .55rem; border-radius: 999px; white-space: nowrap; vertical-align: middle; border: 1px solid transparent; }
.badge-draft { background: #f2f4f7; color: #344054; border-color: #d0d5dd; }
.badge-issued { background: var(--info-bg); color: var(--info); border-color: #c7d7fe; }
.badge-overdue { background: var(--danger-bg); color: var(--danger); border-color: #fecdca; }
.badge-paid { background: var(--ok-bg); color: var(--ok); border-color: #abefc6; }
.badge-cancelled { background: #f9fafb; color: #667085; border-color: #eaecf0; text-decoration: none; }

/* ---- Alerts ----------------------------------------------------------- */
.alert { border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid; }
.alert-info { background: var(--info-bg); color: #1d2f6f; border-color: #c7d7fe; }
.alert-error { background: var(--danger-bg); color: #7a271a; border-color: #fecdca; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #fedf89; }

/* ---- Buttons ---------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: 600 .9rem/1.2 var(--font); padding: .6rem 1rem; border-radius: 8px; border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--ink); color: var(--ink-contrast); }
.btn-primary:hover { background: #333; color: var(--ink-contrast); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #fda29b; }
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn-sm { padding: .4rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--muted); width: 2.1rem; height: 2.1rem; border-radius: 6px; font-size: 1.15rem; line-height: 1; cursor: pointer; }
.icon-btn:hover { color: var(--danger); border-color: #fda29b; }

/* ---- Forms ------------------------------------------------------------ */
.form { display: flex; flex-direction: column; gap: 1rem; }
.form > form { margin: 0; }
.form label, .filters label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .88rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-narrow { max-width: 760px; }
.form-inline { flex-direction: row; align-items: flex-end; flex-wrap: wrap; gap: .6rem; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="search"],
input[type="date"], input[type="month"], input[type="number"], select, textarea {
  font: 400 .95rem/1.4 var(--font);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: .55rem .7rem;
  width: 100%;
  min-height: 2.5rem;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
.field-error { color: var(--danger); font-weight: 500; font-size: .82rem; margin: .1rem 0 0; }
label.check, .form label.check { flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: .5rem; font-weight: 500; }
label.check .hint { flex-basis: 100%; margin-left: 1.6rem; }
input[type="checkbox"], input[type="radio"] { width: 1.05rem; height: 1.05rem; accent-color: var(--ink); }
.code-input { font: 600 1.4rem/1 var(--mono) !important; letter-spacing: .25em; text-align: center; max-width: 12rem; }

fieldset.kind-choice { border: 0; padding: 0; margin: 0 0 1rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .75rem; }
fieldset.kind-choice legend { font-weight: 600; font-size: .88rem; margin-bottom: .4rem; }
.choice { display: flex !important; flex-direction: row !important; gap: .7rem; align-items: flex-start; border: 1px solid var(--border-strong); border-radius: 8px; padding: .8rem; cursor: pointer; font-weight: 400 !important; }
.choice:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.choice input { margin-top: .2rem; }

.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.filters label { min-width: 150px; flex: 1 1 150px; }
.filters label.check { flex: 0 0 auto; min-width: 0; padding-bottom: .6rem; }
.filters-actions { display: flex; gap: .5rem; }

/* Line-item editor */
.items-table { width: 100%; border-collapse: collapse; margin-bottom: .75rem; }
.items-table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 0 .4rem .4rem; }
.items-table td { padding: .3rem .4rem; vertical-align: top; }
.items-table .col-sac { width: 7.5rem; }
.items-table .col-rate { width: 6rem; }
.items-table .col-amount { width: 11rem; text-align: right; }
.items-table .col-remove { width: 2.8rem; }

.summary-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; flex-wrap: wrap; margin-top: 1rem; }
.summary-row .advance { max-width: 260px; }
.summary { display: grid; grid-template-columns: auto auto; gap: .35rem 1.5rem; margin: 1rem 0 0 auto; min-width: 260px; font-variant-numeric: tabular-nums; }
.summary-row .summary { margin-top: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; text-align: right; }
.summary .grand { font-family: var(--font-brand); font-weight: 600; font-size: 1.1rem; color: var(--text); border-top: 1px solid var(--border); padding-top: .35rem; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0 0 1rem; font-size: .92rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.side .card form + form { margin-top: .5rem; }
.side .card form { margin-bottom: .5rem; }
.note { background: var(--warn-bg); border-radius: 6px; padding: .6rem .75rem; font-size: .88rem; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; flex-direction: column; padding: .55rem 0 .55rem .9rem; border-left: 2px solid var(--border); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: .85rem; width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.timeline-what { font-size: .9rem; }

.pager { display: flex; justify-content: space-between; margin-top: 1rem; }

/* ---- Auth ------------------------------------------------------------- */
.auth-card { max-width: 420px; margin: 3rem auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 2rem; }
.auth-card-wide { max-width: 640px; }
.steps { padding-left: 1.2rem; display: flex; flex-direction: column; gap: 1rem; }
.qr { margin: .75rem 0; }
.qr img { display: block; image-rendering: pixelated; border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: #fff; }
.secret { font-size: 1rem; letter-spacing: .08em; word-break: break-all; }
.backup-codes { columns: 2; font-size: 1.05rem; padding-left: 1.6rem; }
.backup-codes li { padding: .2rem 0; }

/* ---- Invoice page layout ---------------------------------------------- */
.invoice-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.sheet-frame { background: #e9e9e4; border-radius: var(--radius); padding: 1.25rem; overflow-x: auto; }
@media (max-width: 1080px) {
  .invoice-layout { grid-template-columns: 1fr; }
}

/* ---- The invoice sheet -------------------------------------------------
   Mirrors the spreadsheet template: columns A+B (61%) and C (39%), Lexend,
   black INVOICE banner, bordered item table. Sized for A4. */
.sheet {
  --sheet-left: 61%;
  position: relative;
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 14mm 12mm;
  background: #fff;
  color: #000;
  font-family: "Lexend", Arial, sans-serif;
  font-size: 11pt;
  line-height: 1.45;
  box-shadow: 0 2px 10px rgb(0 0 0 / 12%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet p { margin: 0; }
.sheet-head { display: grid; grid-template-columns: var(--sheet-left) 1fr; align-items: stretch; min-height: 24mm; }
.sheet-logo { height: 20mm; width: auto; align-self: start; }
.sheet-title {
  background: #000; color: #fff;
  font-weight: 700; font-size: 34pt; letter-spacing: .02em;
  display: flex; align-items: center; justify-content: center;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.sheet-gst .sheet-title { font-size: 25pt; }
/* GST invoices carry extra lines (GSTIN, PAN, place of supply, tax rows, amount
   in words), so they use tighter spacing to stay on one A4 page. */
.sheet-gst { padding-top: 11mm; padding-bottom: 11mm; }
.sheet-gst .sheet-grid { margin-top: 5mm; }
.sheet-gst .sheet-parties { margin-top: 5mm; }
.sheet-gst .sheet-items { margin-top: 5mm; }
.sheet-gst .sheet-totals { margin-top: 3mm; }
.sheet-gst .sheet-thanks { margin-top: 5mm !important; }
.sheet-gst .sheet-foot { margin-top: 4mm; }
.sheet-grid { display: grid; grid-template-columns: var(--sheet-left) 1fr; margin-top: 6mm; }
.sheet-company { font-size: 14pt; }
.sheet-meta { text-align: right; font-size: 12pt; }
.sheet-parties { margin-top: 7mm; }
.sheet-parties > div:last-child { font-size: 12pt; }
.sheet-label { font-size: 13pt; margin-bottom: 1mm !important; }
.sheet-client { font-size: 14pt; }
.sheet-tax-id { font-weight: 600; }

.sheet-items { width: 100%; border-collapse: collapse; margin-top: 7mm; font-size: 12pt; }
.sheet-items th, .sheet-items td { border: 1px solid #000; padding: .7mm 1.6mm; vertical-align: top; }
.sheet-items th { font-weight: 400; font-size: 14pt; text-align: center; }
.sheet-items .sheet-amount { width: calc(100% - var(--sheet-left)); text-align: right; white-space: nowrap; }
.sheet-items th.sheet-amount { text-align: center; }
.sheet-items .sheet-narrow { width: 15mm; text-align: center; font-size: 10pt; }
.sheet-filler td { height: 6mm; }

/* The totals block spans columns B+C (61% of the sheet); its amount cell lines up with column C. */
.sheet-totals { margin: 5mm 0 0 auto; width: 61%; border-collapse: collapse; font-size: 13pt; }
.sheet-totals th { font-weight: 400; text-align: right; padding: 1mm 4mm 1mm 0; }
.sheet-totals td { text-align: right; padding: 1mm 2.4mm; width: 64%; white-space: nowrap; font-variant-numeric: tabular-nums; }
.sheet-grand th, .sheet-grand td { font-size: 14pt; }

.sheet-words { margin-top: 4mm !important; font-size: 10pt; font-style: italic; }
.sheet-thanks { margin-top: 6mm !important; font-weight: 700; font-size: 14pt; }
/* As in the spreadsheet: terms straight after the thank-you line, signature below them on the right. */
.sheet-foot { display: grid; grid-template-columns: var(--sheet-left) 1fr; margin-top: 6mm; }
.sheet-terms { font-size: 11pt; max-width: 92mm; }
.sheet-terms .sheet-label { font-size: 13pt; }
.sheet-sign { grid-column: 2; grid-row: 2; text-align: right; font-size: 11pt; margin-top: 4mm; }
.sheet-sign p { text-decoration: underline; text-underline-offset: 2px; }
.sheet-sign img { width: 42mm; height: auto; display: block; margin-left: auto; }

.watermark {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font: 700 96pt/1 "Lexend", Arial, sans-serif;
  color: rgb(180 35 24 / 10%);
  transform: rotate(-28deg);
  pointer-events: none;
  z-index: 1;
}

/* Standalone print page */
.print-page { background: #e9e9e4; }
.print-bar { position: sticky; top: 0; display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; background: var(--surface); border-bottom: 1px solid var(--border); padding: .6rem 1rem; margin-bottom: 1.5rem; z-index: 2; }
.print-page .sheet { margin-bottom: 2rem; }

@page { size: A4; margin: 0; }
@media print {
  body, .print-page { background: #fff; }
  .topbar, .side, .page-head, .alert, .no-print, .print-bar { display: none !important; }
  .container { padding: 0; max-width: none; }
  .invoice-layout { display: block; }
  .sheet-frame { padding: 0; background: none; overflow: visible; }
  /* At least one full A4 page; a very long invoice continues onto a second page. */
  .sheet { box-shadow: none; margin: 0; width: 210mm; height: auto; min-height: 296mm; }
  .sheet-items tr, .sheet-totals tr { break-inside: avoid; }
}

@media (max-width: 640px) {
  .container { padding: 1rem .75rem 3rem; }
  .card { padding: 1rem; }
  .usermenu { margin-left: 0; width: 100%; justify-content: space-between; }
  .auth-card { margin: 1.5rem auto; padding: 1.25rem; }
  .backup-codes { columns: 1; }
  .items-table .col-sac, .items-table .col-rate { width: 5rem; }
  .items-table .col-amount { width: 7.5rem; }
}

/* ---- Payments, expenses, reports --------------------------------------- */
.text-danger { color: var(--danger); }
.row-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: 0; }
.row-form input[type="text"] { flex: 1 1 160px; width: auto; }
.row-form select { flex: 0 1 260px; width: auto; }
.apply-credit { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .4rem 0; }
.apply-credit input { width: 8rem; flex: 0 0 8rem; }
.apply-credit span { flex: 1 1 100%; }
.export-card { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; }
.export-card > p { flex-basis: 100%; margin: 0; }
.files li { display: flex; flex-wrap: wrap; gap: .6rem; align-items: baseline; padding: .4rem 0; border-bottom: 1px solid var(--border); }
form.inline { display: inline; margin: 0; }
.linklike { background: none; border: 0; padding: 0; color: var(--danger); cursor: pointer; text-decoration: underline; font: inherit; }
.statement-head { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.statement-head p { margin: 0; }
@media print {
  .statement { box-shadow: none; border: 0; }
  .no-print, .subnav { display: none !important; }
}

/* ---- Books, banking, payroll ------------------------------------------------ */
.ok-text { color: var(--ok); }
.grid-dash { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 1.25rem; align-items: start; margin-bottom: 1.25rem; }
.grid-dash > .card { margin-bottom: 0; }
@media (max-width: 900px) { .grid-dash { grid-template-columns: 1fr; } }

/* Chart: validated palette (blue #2a78d6 / orange #eb6834 on white). */
:root { --series-in: #2a78d6; --series-out: #eb6834; --chart-grid: #ececE8; --chart-axis: #8a8f98; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { fill: var(--chart-axis); font: 11px var(--font); }
.chart .bar-in { fill: var(--series-in); }
.chart .bar-out { fill: var(--series-out); }
.chart .hit { fill: transparent; }
.chart .bar-group:hover .hit { fill: rgb(0 0 0 / 4%); }
.legend { display: flex; gap: 1rem; align-items: center; font-size: .85rem; color: var(--muted); margin-bottom: .4rem; }
.swatch { display: inline-block; width: .75rem; height: .75rem; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.swatch-in { background: var(--series-in); }
.swatch-out { background: var(--series-out); margin-left: .5rem; }

.fin-table th, .fin-table td { border-bottom: 1px solid var(--border); }
.fin-table thead th { font-size: .82rem; }
.fin-table .group-row th, .fin-table .group-row td { background: var(--surface-2); font-weight: 600; }
.fin-table .indent { padding-left: 1.6rem; }
.fin-table .grand-row th, .fin-table .grand-row td { font-family: var(--font-brand); font-size: 1.1rem; font-weight: 600; border-top: 2px solid var(--ink); }
.fin-table + .fin-table { margin-top: 1rem; }
.fy-picker label { flex-direction: row; align-items: center; gap: .5rem; }

.recon .recon-matched td { color: var(--muted); }
.recon .recon-matched td:last-child { color: var(--ok); }
.recon .recon-unmatched { background: var(--warn-bg); }
.recon .actions { margin-top: .3rem; }

input.tiny { width: 6rem !important; display: inline-block; min-height: 2rem; padding: .3rem .5rem; }
.edit-row td { background: var(--surface-2); padding-top: .4rem; padding-bottom: .6rem; }
.edit-row label { font-weight: 500; flex-direction: row; align-items: center; gap: .35rem; }

.payslip-title { font-size: 28pt; }
.payslip-table td.nested { padding: 0; vertical-align: top; width: 50%; }
.payslip-table td.nested table { width: 100%; border-collapse: collapse; }
.payslip-table td.nested td { border: 0; padding: 1.4mm 2.4mm; }
.payslip-table tr.totals th, .payslip-table tr.totals td { font-weight: 600; }
.payslip .sheet-foot { margin-top: 10mm; }
.payslip-table { table-layout: fixed; }
.payslip-table th { width: 25%; text-align: left; }
.payslip-table thead th { text-align: center; }
.payslip-table .sheet-amount { width: auto; }
.payslip-table tr.totals th { text-align: left; }
.mainnav a { padding: .4rem .55rem; }
.topbar-inner { gap: 1rem; }
.form-inline { display: flex; }
.form-inline > label { display: flex; flex-direction: column; gap: .2rem; font-weight: 600; font-size: .85rem; }
.form-inline > label input, .form-inline > label select { width: auto; }

/* ==== App shell: sidebar sections + top tabs ================================ */
:root { --sidebar: #15171c; --sidebar-2: #20232a; --sidebar-text: #b9bec8; --sidebar-active: #ffffff; --sidebar-w: 248px; }
body.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; padding: 1.1rem .8rem; gap: 1.2rem; }
.sidebar-brand { display: flex; align-items: center; gap: .65rem; color: #fff; text-decoration: none; font-family: var(--font-brand); font-size: 1.05rem; padding: .2rem .5rem .6rem; }
.sidebar-brand img { filter: invert(1); }
.side-nav { display: flex; flex-direction: column; gap: .2rem; }
.side-nav a, .sidebar-account { display: flex; align-items: center; gap: .75rem; padding: .62rem .75rem; border-radius: 9px; color: var(--sidebar-text);
  text-decoration: none; font-weight: 500; font-size: .95rem; }
.side-nav a:hover, .sidebar-account:hover { background: var(--sidebar-2); color: #fff; }
.side-nav a[aria-current="page"] { background: #fff; color: var(--sidebar); font-weight: 600; }
.side-nav a[aria-current="page"] .icon { color: var(--sidebar); }
.icon { flex: 0 0 auto; }
.sidebar-user { margin-top: auto; border-top: 1px solid #2c3038; padding-top: .8rem; display: flex; flex-direction: column; gap: .3rem; }
.sidebar-account .who { display: block; color: #fff; font-weight: 600; font-size: .9rem; }
.sidebar-account .role { display: block; color: #8b919c; font-size: .74rem; line-height: 1.3; }
.sidebar-account[aria-current="page"] { background: var(--sidebar-2); }
.sidebar-signout { background: none; border: 0; color: #8b919c; font: 500 .85rem var(--font); text-align: left; padding: .45rem .75rem; cursor: pointer; border-radius: 8px; width: 100%; }
.sidebar-signout:hover { color: #fff; background: var(--sidebar-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.pagebar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 1rem 2rem 0; position: sticky; top: 0; z-index: 5; }
.pagebar-title { display: flex; align-items: center; gap: .55rem; font-family: var(--font-brand); font-weight: 600; font-size: 1.15rem; padding-bottom: .9rem; color: var(--ink); }
.pagebar-title .icon { color: var(--muted); }
.tabs { display: flex; gap: .15rem; overflow-x: auto; scrollbar-width: thin; margin-bottom: -1px; }
.tabs a { white-space: nowrap; padding: .6rem .85rem .7rem; color: var(--muted); text-decoration: none; font-weight: 500; font-size: .92rem;
  border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; }
.tabs a:hover { color: var(--ink); background: var(--surface-2); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.content { padding: 1.6rem 2rem 4rem; width: 100%; max-width: 1360px; }

body.plain { min-height: 100vh; }
.plain-top { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.plain-top .brand img { display: block; }
.content-plain { margin: 0 auto; }

/* Dashboard pieces */
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; margin-bottom: 1.25rem; align-items: start; }
.grid-3 > .card { margin-bottom: 0; }
.in-text { color: var(--ok); }
.out-text { color: var(--text); }
dl.kv { display: grid; grid-template-columns: 1fr auto; gap: .55rem 1rem; margin: 0 0 .6rem; font-size: .93rem; }
dl.kv dt a { color: var(--text); text-decoration: none; }
dl.kv dt a:hover { text-decoration: underline; }
dl.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.todo { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.todo li a { display: block; padding: .55rem .7rem .55rem .9rem; border-radius: 8px; background: var(--surface-2); border-left: 3px solid var(--border-strong);
  color: var(--text); text-decoration: none; font-size: .9rem; }
.todo li a:hover { background: #f0f0ec; }
.todo li.todo-bad a { border-left-color: var(--danger); }
.todo li.todo-warn a { border-left-color: #f79009; }
.todo li.todo-date a { border-left-color: var(--info); }
.movements { list-style: none; padding: 0; margin: 0; }
.movements li { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr) auto; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; align-items: baseline; }
.movements .mv-date { color: var(--muted); font-size: .82rem; }
.movements .mv-what a { color: var(--text); }
.movements .mv-amt { font-weight: 600; }
.flow .group-row th, .flow .group-row td { background: var(--surface-2); font-weight: 600; }
.flow .indent { padding-left: 1.4rem; }
.compliance tr.past td { color: var(--muted); }

@media (max-width: 960px) {
  body.app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: .5rem .75rem; gap: .5rem; overflow-x: auto; }
  .sidebar-brand span { display: none; }
  .sidebar-brand { padding: .2rem; }
  .side-nav { flex-direction: row; gap: .15rem; }
  .side-nav a { padding: .5rem .6rem; white-space: nowrap; font-size: .85rem; }
  .sidebar-user { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; }
  .sidebar-account .role { display: none; }
  .pagebar { padding: .75rem 1rem 0; position: static; }
  .content { padding: 1rem; }
}
@media print {
  .sidebar, .pagebar, .plain-top { display: none !important; }
  body.app { display: block; }
  .content { padding: 0; max-width: none; }
}
.segmented { display: inline-flex; gap: .2rem; padding: .25rem; background: #ebebe6; border-radius: 10px; margin-bottom: 1.1rem; flex-wrap: wrap; }
.segmented a { padding: .4rem .85rem; border-radius: 7px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: .88rem; }
.segmented a:hover { color: var(--ink); }
.segmented a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.tabs a { padding: .6rem .75rem .7rem; }
.list-summary { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .65rem 1rem; margin-bottom: .9rem; }
.list-summary p { margin: 0; }
