/* Menu down the left, content filling the rest.
   --brand comes from the reseller (white label), set inline on <body>. */
:root {
  --brand: #F87C18;
  --ink: #172333;
  --nav: #151D2C;
  --nav-text: #C2CBDA;
  --nav-line: #2B3648;
  --bg: #F5F7F9;
  --surface: #FFFFFF;
  --line: #E0E4E8;
  --copy: #4C5766;
  --muted: #7B8594;
  --ok: #1E6B2C; --ok-bg: #E9F5EA;
  --warn: #8A4408; --warn-bg: #FFF1E3;
  --bad: #9A2E1F; --bad-bg: #FBEDEA;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; color: var(--copy); background: var(--bg); }
a { color: var(--ink); }
h1, h2, h3 { color: var(--ink); margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
h3 { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
code { font-family: var(--mono); font-size: 12px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.nav { width: 230px; flex-shrink: 0; background: var(--nav); color: var(--nav-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.nav .brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 15px; }
.nav .brand img { max-height: 28px; max-width: 150px; }
.nav .brand .dot { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); flex-shrink: 0; }
.nav .org { margin: 0 12px 10px; padding: 9px 10px; border: 1px solid var(--nav-line); border-radius: var(--radius); color: #fff; text-decoration: none; display: block; font-size: 13px; }
.nav .org small { display: block; color: var(--nav-text); font-size: 11px; }
.nav .org:hover { border-color: var(--brand); }
.nav .group { padding: 12px 18px 4px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: #8590A3; }
.nav a.item { display: flex; align-items: center; gap: 10px; padding: 7px 18px 7px 22px; color: var(--nav-text); text-decoration: none; font-size: 13.5px; border-left: 3px solid transparent; }
.nav a.item:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav a.item.on { color: #fff; background: rgba(255,255,255,.08); border-left-color: var(--brand); }
.nav .bottom { margin-top: auto; border-top: 1px solid var(--nav-line); padding: 10px 0 14px; }
.nav .bottom form { margin: 0; }
.nav .bottom button { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: var(--nav-text); padding: 7px 18px 7px 22px; font: inherit; font-size: 13px; cursor: pointer; width: 100%; text-align: left; }
.nav .bottom button:hover { color: #fff; }
.nav .who { padding: 4px 22px; font-size: 12px; color: #8590A3; word-break: break-all; }
.main { flex: 1; min-width: 0; padding: 26px 34px 60px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head .sub { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

.nav .ico { flex-shrink: 0; opacity: .75; }
.nav a.item:hover .ico, .nav a.item.on .ico { opacity: 1; }
.nav a.item.on .ico { color: var(--brand); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 16px 20px 0; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; display: block; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat .n { font-size: 22px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--muted); }
.stat .s.bad { color: var(--bad); }
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: #CFE9D2; }
.flash.error { background: var(--bad-bg); color: var(--bad); border-color: #F2CFC8; }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: #F5D9BC; }
.t tr.muted td { color: var(--muted); }
.note { font-size: 12.5px; color: var(--muted); }
.muted { color: var(--muted); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* ---------- tables ---------- */
table.t { width: 100%; border-collapse: collapse; background: var(--surface); }
table.t th, table.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.t th { font-size: 12px; font-weight: 600; color: var(--muted); background: #FAFBFC; white-space: nowrap; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: #FAFBFC; }
table.t td.n, table.t th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tr.total td { font-weight: 600; color: var(--ink); border-top: 2px solid var(--line); background: #FAFBFC; }
table.t tr.sub td { font-weight: 600; color: var(--ink); }
table.t tr.section td { background: #FAFBFC; font-weight: 600; color: var(--ink); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
table.t td.indent { padding-left: 28px; }
table.t a { text-decoration: none; }
table.t a:hover { text-decoration: underline; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 13.5px; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
.tabs a .c { font-size: 11px; background: #EEF0F3; border-radius: 10px; padding: 1px 7px; margin-left: 4px; }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--line); background: #F3F5F7; color: var(--copy); white-space: nowrap; }
.badge.draft { background: #F3F5F7; }
.badge.approved { background: var(--warn-bg); color: var(--warn); border-color: #F3D9BC; }
.badge.overdue, .badge.failed, .badge.void { background: var(--bad-bg); color: var(--bad); border-color: #F2CFC8; }
.badge.paid, .badge.ok, .badge.posted { background: var(--ok-bg); color: var(--ok); border-color: #CFE9D2; }
.badge.running { background: var(--warn-bg); color: var(--warn); }
.badge.void { text-decoration: line-through; }

/* ---------- forms ---------- */
.btn { display: inline-block; font: inherit; font-weight: 600; font-size: 13.5px; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--brand); background: var(--brand); color: #fff; text-decoration: none; cursor: pointer; line-height: 1.3; }
.btn:hover { filter: brightness(1.05); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { border-color: #C5CBD3; }
.btn.danger { background: var(--surface); color: var(--bad); border-color: #F2CFC8; }
.btn.small { padding: 4px 9px; font-size: 12.5px; font-weight: 500; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  font: inherit; font-size: 14px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.check input { width: auto; }
.form-grid { display: grid; gap: 14px 18px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.field { margin-bottom: 14px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin: 0; }
.inline-form input, .inline-form select { width: auto; }
fieldset { border: 0; padding: 0; margin: 0; }

/* ---------- document editor ---------- */
table.lines { width: 100%; border-collapse: collapse; }
table.lines th { font-size: 12px; color: var(--muted); text-align: left; padding: 6px 4px; font-weight: 600; }
table.lines td { padding: 4px; vertical-align: top; }
table.lines input, table.lines select { padding: 6px 8px; font-size: 13.5px; }
table.lines td.amt { text-align: right; padding-top: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
table.lines .rm { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 6px; }
table.lines .rm:hover { color: var(--bad); }
.totals { margin-left: auto; width: 320px; max-width: 100%; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 17px; font-weight: 700; color: var(--ink); border-top: 2px solid var(--line); padding-top: 8px; margin-top: 4px; }
.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 24px; }
.doc-meta .k { font-size: 12px; color: var(--muted); }
.doc-meta .v { color: var(--ink); font-weight: 500; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--nav); }
.login .box { background: var(--surface); width: 360px; max-width: 100%; border-radius: 12px; padding: 30px 28px; }
.login .mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); margin-bottom: 14px; }
.login h1 { margin-bottom: 18px; }
.login .btn { width: 100%; padding: 10px; }

pre.log { background: #14201B; color: #D7E7DD; font-family: var(--mono); font-size: 12px; padding: 12px 14px; border-radius: 6px; max-height: 340px; overflow: auto; white-space: pre-wrap; word-break: break-word; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .nav { width: 100%; height: auto; position: static; }
  .main { padding: 18px 14px 40px; }
  table.lines thead { display: none; }
  table.lines tr { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); padding: 6px 0; }
  table.lines td:first-child { grid-column: 1 / -1; }
}
@media print {
  .nav, .actions, .no-print { display: none !important; }
  .main { padding: 0; }
  .card { border: 0; }
  body { background: #fff; }
}

/* ---------- public invoice page ---------- */
body.public { background: var(--bg); }
.pub { max-width: 820px; margin: 0 auto; padding: 32px 18px 50px; }
.pub-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; border-top: 5px solid var(--brand); padding-top: 18px; }
.pub-from { font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.pub-amount { text-align: right; }
.pub-amount .l { font-size: 12px; color: var(--muted); }
.pub-amount .n { font-size: 30px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.2; }
.pub-pay { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.pub-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.btn.big { padding: 13px 22px; font-size: 15px; }
.pub-foot { text-align: center; }
@media (max-width: 600px) { .pub-amount { text-align: left; } .pub-buttons .btn { flex: 1; text-align: center; } }
.qr { width: 200px; height: 200px; background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.qr svg { width: 100%; height: 100%; display: block; }

/* ---------- bank reconciliation ---------- */
.bank-line { padding: 14px 18px; }
.bl-top { display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }
.bl-date { width: 92px; color: var(--muted); font-size: 13px; flex-shrink: 0; }
.bl-desc { flex: 1; min-width: 200px; }
.bl-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bl-amt.in { color: var(--ok); }
.bl-amt.out { color: var(--ink); }
.bl-tips { margin: 10px 0 0 108px; display: grid; gap: 6px; }
.bl-tips .tip { display: flex; gap: 12px; align-items: center; justify-content: space-between; background: var(--ok-bg); border: 1px solid #CFE9D2; border-radius: var(--radius); padding: 8px 12px; margin: 0; }
.bl-more { margin: 8px 0 0 108px; }
.bl-more summary { cursor: pointer; color: var(--brand); font-weight: 600; font-size: 13.5px; padding: 4px 0; }
.bl-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin: 8px 0; }
.bl-form select { max-width: 240px; }
.bl-row { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.bl-done { margin: 8px 0 0 108px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
@media (max-width: 700px) { .bl-tips, .bl-more, .bl-done { margin-left: 0; } }
.t.payrun input { padding: 5px 6px; font-size: 13px; }
.t.payrun td { padding: 6px 6px; }

/* Dashboard charts */
.chart-card h2 { margin: 0; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-head .muted { font-size: 12px; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--copy); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend strong { color: var(--ink); font-variant-numeric: tabular-nums; margin-left: 4px; }
.big-number { font-size: 22px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; margin: 2px 0 10px; }
.big-number .muted { font-size: 12px; font-weight: 400; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid-line { stroke: var(--line); stroke-width: 1; }
svg.chart .grid-line.zero { stroke: #B9C0C8; }
svg.chart .tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
svg.chart .hit { fill: transparent; cursor: default; outline: none; }
svg.chart .hit:hover, svg.chart .hit:focus { fill: rgba(23, 35, 51, 0.04); }
svg.chart .line { fill: none; stroke: #0A8F7A; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .area { fill: #0A8F7A; opacity: 0.08; }
svg.chart .dot { fill: #0A8F7A; stroke: var(--surface); stroke-width: 2; }
svg.chart .hover-pt .dot, svg.chart .hover-pt .cross { opacity: 0; }
svg.chart .hover-pt .cross { stroke: #B9C0C8; stroke-width: 1; stroke-dasharray: 3 3; }
svg.chart .hover-pt.on .dot, svg.chart .hover-pt.on .cross { opacity: 1; }
.hbars { display: grid; gap: 10px; }
.hbar { outline: none; border-radius: 6px; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--copy); margin-bottom: 4px; }
.hbar-top span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-top strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.hbar-track { height: 8px; background: #EEF1F3; border-radius: 4px; }
.hbar-fill { height: 8px; background: #0A8F7A; border-radius: 4px; }
.hbar-fill.other { background: #8FA3A0; }
.hbar.on .hbar-fill, .hbar:focus .hbar-fill { filter: brightness(0.9); }
.chart-table { margin-top: 10px; font-size: 13px; }
.chart-table summary { cursor: pointer; color: var(--muted); }
.chart-table table { margin-top: 8px; }
.chart-tip { position: absolute; z-index: 50; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; line-height: 1.5; padding: 7px 10px; border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.18); font-variant-numeric: tabular-nums; }
.chart-tip .tt { font-weight: 600; }
@media (max-width: 900px) { .grid.charts { grid-template-columns: 1fr !important; } }
.grid.charts .card { margin-bottom: 0; }
.chart-scroll { overflow-x: auto; } @media (max-width: 600px) { .chart-scroll svg.chart { min-width: 560px; } }
.grid.charts > * { min-width: 0; }
.pub-logo { display: block; max-width: 200px; max-height: 64px; margin-bottom: 12px; }

/* Invoice design */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.design { display: grid; grid-template-columns: minmax(340px, 1fr) minmax(380px, 1.15fr); gap: 20px; align-items: start; }
.design-preview { position: sticky; top: 16px; }
.preview-frame { width: 100%; height: calc(100vh - 120px); min-height: 560px; border: 1px solid var(--line); border-radius: var(--radius); background: #e9ecef; }
.preview-tabs { margin-bottom: 10px; }
.design-save { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 24px; }
.logo-pick { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.logo-box { width: 220px; height: 90px; border: 1px dashed var(--line); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; background: #fff; padding: 8px; }
.logo-box img { max-width: 100%; max-height: 100%; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px 16px; }
.colour-pick { display: flex; gap: 8px; align-items: center; }
.colour-pick input[type=color] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.colour-pick input[type=text] { width: 110px; font-family: var(--mono); }
.template-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.template-opt { display: flex; flex-direction: column; gap: 4px; cursor: pointer; font-weight: 400; }
.template-opt input { position: absolute; opacity: 0; }
.template-opt .note { line-height: 1.35; }
.tpl { display: block; height: 92px; border: 1px solid var(--line); border-radius: 6px; background: #fff; padding: 10px; position: relative; overflow: hidden; }
.template-opt input:checked + .tpl { outline: 2px solid var(--brand); outline-offset: 1px; }
.template-opt input:focus-visible + .tpl { outline: 2px solid var(--ink); }
.tpl i { display: block; width: 46%; height: 8px; border-radius: 2px; background: var(--accent, #0A7A69); margin-bottom: 12px; }
.tpl b { display: block; height: 6px; border-radius: 2px; background: #E3E6EA; margin-bottom: 6px; }
.tpl-classic b:first-of-type { background: var(--accent, #0A7A69); height: 9px; }
.tpl-modern::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--accent, #0A7A69); }
.tpl-modern i { background: #172333; }
.tpl-modern b:first-of-type { background: color-mix(in srgb, var(--accent, #0A7A69) 15%, white); height: 9px; }
.tpl-minimal i { background: #172333; height: 7px; }
.tpl-minimal b:first-of-type { background: none; border-bottom: 1.5px solid var(--accent, #0A7A69); border-radius: 0; }
@media (max-width: 1100px) { .design { grid-template-columns: 1fr; } .design-preview { position: static; } .preview-frame { height: 640px; } }
tr.best td { background: #EEF8F5; }
.checklist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.checklist li { display: flex; gap: 10px; align-items: baseline; }
.checklist .tick { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none; }
.checklist .ok .tick { background: var(--ok-bg); color: var(--ok); }
.checklist .todo .tick { background: var(--warn-bg); color: var(--warn); }
ol.steps { padding-left: 20px; margin: 0; display: grid; gap: 14px; }
