/* Ledger: a bookkeeper's binder.
   Signature: the binder sidebar with index tabs (the open tab is pulled out into the page), and the accountant's
   double rule under totals. Everything else stays quiet.
   Colour:  ink #182233 · folio #eef2ee · sheet #ffffff · ledger rule #d5e0d7 · bottle #1f5c4b · red pencil #b4322a
   Type:    Archivo (display, set wide) · Public Sans (text) · IBM Plex Mono (codes and references) */

@font-face { font-family: "Archivo"; src: url("fonts/archivo-var.woff2") format("woff2");
  font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; }
@font-face { font-family: "Public Sans"; src: url("fonts/public-sans-var.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Public Sans"; src: url("fonts/public-sans-var-italic.woff2") format("woff2");
  font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("fonts/plex-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("fonts/plex-mono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --ink: #182233; --muted: #5a6676; --folio: #eef2ee; --sheet: #ffffff; --rule: #d5e0d7; --rule-strong: #b9cbbd;
  --bottle: #1f5c4b; --bottle-ink: #ffffff; --bottle-soft: #e3eee8; --pencil: #b4322a; --ok: #1f7a4d;
  --binder: #1d2a35; --binder-ink: #c9d3da; --binder-dim: #8496a3; --tab: var(--folio);
  --amber: #a2681a; --zebra: #f6f9f6;
  --radius: 10px; --shadow: 0 1px 0 rgba(24, 34, 51, .04), 0 1px 3px rgba(24, 34, 51, .06);
  --display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --text: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  /* names used by older screens */
  --bg: var(--folio); --surface: var(--sheet); --line: var(--rule); --accent: var(--bottle); --accent-ink: var(--bottle-ink);
  --danger: var(--pencil); --row: var(--zebra);
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #e4eae6; --muted: #9aa8a0; --folio: #121a17; --sheet: #18221e; --rule: #2a3832; --rule-strong: #3a4c44;
    --bottle: #5fb596; --bottle-ink: #0c1411; --bottle-soft: #1d2f28; --pencil: #ff8a7f; --ok: #6cc79a;
    --binder: #0b1210; --binder-ink: #c3cec8; --binder-dim: #7d8c85; --amber: #e0a24c; --zebra: #1c2722;
    --shadow: none; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--folio); color: var(--ink); font: 15px/1.55 var(--text); }
h1, h2, h3, h4 { margin: 0 0 12px; line-height: 1.15; font-family: var(--display); font-stretch: 112%; letter-spacing: -.005em; }
h2 { font-size: 1.6rem; font-weight: 750; }
h3 { font-size: 1.05rem; font-weight: 700; }
h4 { font-size: .9rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 16px; }
a { color: var(--bottle); text-underline-offset: 3px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .92em; word-break: break-all; }
.error { color: var(--pencil); min-height: 1.2em; margin: 8px 0 0; }
.ok { color: var(--ok); }
.neg { color: var(--pencil); }
::selection { background: var(--bottle-soft); }

/* ---- Wordmark: the double rule is the accountant's mark for a final total ---- */
.wordmark { font-family: var(--display); font-stretch: 125%; font-weight: 850; font-size: 1.5rem; letter-spacing: -.01em;
  margin: 0; display: inline-block; padding-bottom: 3px; border-bottom: 4px double currentColor; line-height: 1; }

/* ---- Sign in ---- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: repeating-linear-gradient(to bottom, transparent 0 27px, var(--rule) 27px 28px), var(--folio); }
.card.auth-card { width: 100%; max-width: 420px; padding: 32px 28px 24px; border-top: 6px solid var(--bottle); }
.auth-card .wordmark { color: var(--bottle); margin-bottom: 22px; }
.auth-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 18px; }
.secret { font-family: var(--mono); font-size: 1.05rem; letter-spacing: .1em; background: var(--zebra);
  border: 1px solid var(--rule); padding: 10px; border-radius: 8px; word-break: break-all; }

/* ---- Shell: binder + page ---- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.shell { background: linear-gradient(to right, var(--binder) 248px, var(--folio) 248px); }
.binder { background: var(--binder); color: var(--binder-ink); padding: 22px 0 24px 16px; position: sticky; top: 0;
  height: 100vh; align-self: start; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; z-index: 5; }
.binder-mark { color: #fff; margin-left: 6px; font-size: 1.25rem; }
@media (prefers-color-scheme: dark) { .binder-mark { color: var(--binder-ink); } }

.org { position: relative; margin-right: 16px; }
.org-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius);
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); color: #fff; text-align: left; }
.org-btn:hover { background: rgba(255, 255, 255, .1); }
.org-mark { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; color: #fff;
  font-family: var(--display); font-stretch: 112%; font-weight: 800; font-size: 13px; letter-spacing: .02em; }
.org-mark.small-mark { width: 26px; height: 26px; border-radius: 6px; font-size: 11px; }
.org-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.org-eyebrow { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--binder-dim); }
#org-name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-chev { width: 8px; height: 8px; border-right: 2px solid var(--binder-dim); border-bottom: 2px solid var(--binder-dim);
  transform: rotate(45deg) translateY(-3px); }
.org-menu { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--sheet); color: var(--ink);
  border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0, 0, 0, .28); padding: 8px; z-index: 20; min-width: 240px; }
.org-menu-head { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 4px 8px 6px; }
.org-menu ul { list-style: none; margin: 0; padding: 0; }
.org-item { width: 100%; display: flex; gap: 10px; align-items: center; text-align: left; border: 0; background: none;
  padding: 8px; border-radius: 8px; color: var(--ink); }
.org-item:hover { background: var(--zebra); }
.org-item.current { background: var(--bottle-soft); font-weight: 650; }
.org-sub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.org-manage { display: block; padding: 8px; margin-top: 6px; border-top: 1px solid var(--rule); font-size: 13.5px; }
.org-cell { display: flex; gap: 10px; align-items: center; }

/* Index tabs: the open section is a tab of page colour that reaches out of the binder into the page. */
#nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin: 14px 0 4px 10px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--binder-dim); }
.nav-group:first-child { margin-top: 0; }
#nav a { position: relative; display: block; padding: 8px 14px 8px 12px; border-radius: 9px 0 0 9px; color: var(--binder-ink);
  text-decoration: none; font-weight: 500; }
#nav a:hover { color: #fff; background: rgba(255, 255, 255, .06); }
#nav a.active { background: var(--tab); color: var(--ink); font-weight: 700; }
#nav a.active::before, #nav a.active::after { content: ""; position: absolute; right: 0; width: 12px; height: 12px; pointer-events: none; }
#nav a.active::before { top: -12px; background: radial-gradient(circle at 0 0, transparent 11.5px, var(--tab) 12px); }
#nav a.active::after { bottom: -12px; background: radial-gradient(circle at 0 100%, transparent 11.5px, var(--tab) 12px); }

.page { min-width: 0; display: flex; flex-direction: column; }
.strip { display: flex; align-items: center; gap: 14px; padding: 12px 28px; border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--folio) 88%, transparent); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 4; }
.strip-org { font-family: var(--display); font-stretch: 112%; font-weight: 700; font-size: .95rem; margin-right: auto; }
.menu-btn { display: none; }
main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 26px 28px 72px; }

/* ---- Surfaces and controls ---- */
.card { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
label { display: block; margin: 0 0 12px; font-weight: 600; font-size: 13.5px; }
input, select, textarea { display: block; width: 100%; margin-top: 5px; padding: 8px 10px; font: 400 15px/1.4 var(--text);
  color: var(--ink); background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: 7px; }
input[type="checkbox"] { display: inline-block; width: auto; margin: 0 6px 0 0; accent-color: var(--bottle); }
.check-label { display: flex; align-items: center; font-weight: 500; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible, .org-btn:focus-visible {
  outline: 2px solid var(--bottle); outline-offset: 2px; }
#nav a:focus-visible, .org-btn:focus-visible { outline-color: #fff; }
button { font: 600 14px/1.2 var(--text); padding: 9px 15px; border-radius: 7px; border: 1px solid var(--rule-strong);
  background: var(--sheet); color: var(--ink); cursor: pointer; }
button:hover { border-color: var(--ink); }
button.primary { background: var(--bottle); border-color: var(--bottle); color: var(--bottle-ink); }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { border-color: var(--rule-strong); }
button.danger { color: var(--pencil); }
button.small { padding: 5px 10px; font-size: 12.5px; }
button.wide { width: 100%; padding: 11px; margin-top: 4px; }
button:disabled { opacity: .5; cursor: not-allowed; }
details summary { cursor: pointer; font-weight: 600; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > * { flex: 1 1 160px; }
.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar h2 { margin: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 18px; }
section + section { margin-top: 26px; }

/* Headline figures: label small and plain, the figure set wide */
.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.stat .value { font-family: var(--display); font-stretch: 108%; font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 4px; }
a.stat-link { text-decoration: none; color: inherit; display: block; transition: border-color .15s, transform .15s; }
a.stat-link:hover, a.stat-link:focus-visible { border-color: var(--bottle); transform: translateY(-1px); }
a.stat-link .small { color: var(--bottle); font-weight: 600; margin-top: 6px; }

/* ---- Tables: ruled like a ledger sheet ---- */
.table-wrap { overflow-x: auto; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); }
.card .table-wrap, .kpi .table-wrap { border: 0; }
table { width: 100%; border-collapse: collapse; background: transparent; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; background: var(--zebra); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.mono { font-size: 13px; }
tfoot td { font-weight: 700; border-top: 1px solid var(--ink); border-bottom: 3px double var(--ink); }
table.report tfoot td { border-bottom: 1px solid var(--ink); }
tr.sub td { background: var(--zebra); font-size: 13px; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 4px; border: 1px solid var(--rule-strong);
  color: var(--muted); white-space: nowrap; }
.tag.rev { color: var(--pencil); border-color: currentColor; }

.lines td { padding: 4px; border-bottom: 0; }
.lines input, .lines select { margin: 0; }
.totals { display: flex; gap: 24px; justify-content: flex-end; margin: 12px 0; font-variant-numeric: tabular-nums; }
.diff-bad { color: var(--pencil); font-weight: 700; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--folio);
  padding: 10px 18px; border-radius: 8px; max-width: calc(100% - 32px); font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); z-index: 30; }

/* ---- Reports ---- */
.report-hub { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.report-list { list-style: none; padding: 0; margin: 0; }
.report-list li { padding: 6px 0; border-bottom: 1px solid var(--rule); }
.report-list li:last-child { border-bottom: 0; }
.report-head { margin: 8px 0 14px; }
article > h2, .report-head h2 { font-size: 1.45rem; }
table.report td, table.report th { padding: 7px 12px; }
tr.row-total td { font-weight: 700; border-top: 1px solid var(--ink); }
/* Final totals (Gross profit, Net profit, Total assets...) get the accountant's double rule; subtotals a single rule. */
table.grand tr.row-total td { border-bottom: 3px double var(--ink); border-top-width: 1px; }
table.grand tr.row-total + tr.row-total td { border-top: 0; }
tr.row-sub td { color: var(--muted); font-style: italic; }
tr.row-heading td { font-weight: 700; background: var(--zebra); }
table.report.aligned { table-layout: fixed; width: 100%; min-width: calc(220px + var(--figs, 1) * 110px); }
table.report.aligned td, table.report.aligned th { overflow-wrap: anywhere; }
a.drill { color: var(--bottle); text-decoration: none; }
a.drill:hover, a.drill:focus-visible { text-decoration: underline; }
tr.row-link:hover td { background: var(--bottle-soft); }
.row-total a.drill, tfoot a.drill { color: inherit; text-decoration: underline dotted; }
.charts { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-bottom: 16px; }
.chart-card { margin: 0; padding: 14px; }
.chart-card figcaption { font-weight: 700; margin-bottom: 6px; font-family: var(--display); font-stretch: 108%; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--rule); stroke-width: 1; }
svg.chart .zero { stroke: var(--muted); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.notes { margin-top: 12px; }
.ok-box { border-left: 4px solid var(--bottle); }
hr.page-break { border: 0; border-top: 2px dashed var(--rule-strong); margin: 30px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Traffic lights and scorecard */
.light { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
  border: 1px solid currentColor; white-space: nowrap; text-transform: uppercase; letter-spacing: .05em; }
.light i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.light-green { color: var(--ok); } .light-amber { color: var(--amber); } .light-red { color: var(--pencil); } .light-grey { color: var(--muted); }
.kpi-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.kpi { border: 1px solid var(--rule); border-top-width: 4px; border-radius: 8px; padding: 12px 14px; background: var(--sheet); }
.kpi-green { border-top-color: var(--ok); } .kpi-amber { border-top-color: var(--amber); } .kpi-red { border-top-color: var(--pencil); } .kpi-grey { border-top-color: var(--rule-strong); }
.kpi-top { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12.5px; color: var(--muted); text-align: right; font-weight: 600; }
.kpi-value { font-family: var(--display); font-stretch: 108%; font-size: 1.6rem; font-weight: 700; margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
table.kpi-inputs { width: 100%; font-size: 12px; margin: 6px 0 8px; border-collapse: collapse; }
table.kpi-inputs td { padding: 2px 0; border: 0; }
.checks .check, .check { display: flex; gap: 12px; align-items: flex-start; padding: 6px 0; }

/* Search box in the strip */
.gsearch { flex: 0 1 320px; }
.gsearch input { margin: 0; padding: 7px 12px; border-radius: 999px; background: var(--sheet); }

/* In-page tabs (Bank) */
nav.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--rule-strong); margin: 18px 0 14px; }
nav.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-radius: 8px 8px 0 0;
  border: 1px solid transparent; margin-bottom: -1px; }
nav.tabs a:hover { color: var(--ink); }
nav.tabs a.active { color: var(--ink); background: var(--sheet); border-color: var(--rule-strong); border-bottom-color: var(--sheet); }

/* ---- Small screens: the binder slides in ---- */
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: var(--folio); }
  .binder { position: fixed; inset: 0 auto 0 0; width: 268px; transform: translateX(-100%); transition: transform .2s ease; }
  body.binder-open .binder { transform: none; box-shadow: 0 0 0 100vmax rgba(10, 16, 14, .45); }
  .menu-btn { display: inline-block; border-color: var(--rule-strong); }
  .strip { padding: 10px 16px; flex-wrap: wrap; }
  .gsearch { order: 3; flex: 1 1 100%; }
  main { padding: 18px 16px 60px; }
  .lines { min-width: 640px; }
  h2 { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media print {
  .binder, .strip, .no-print, #toast { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  .card, .table-wrap { border: 0; padding: 0; box-shadow: none; }
  hr.page-break { break-after: page; border: 0; }
  table { font-size: 11px; }
  .charts { break-inside: avoid; }
  a.drill { color: inherit; }
}
