/* ============================================================================
   styles.css — all presentation for Qetaab.

   THE LOOK
   --------
   A bound ledger. Black ink on warm paper by day, bone ink on black by
   night, and one colour in the whole design: the gold of the seal. The
   accountant's own marks remain — hairline rules between rows, a heavier
   rule above a total, and the double rule beneath a figure that has been
   proved. Everything else stays quiet so the numbers read first.

   TWO THEMES
   ----------
   :root holds the light theme. [data-theme="dark"] redefines the same
   tokens and nothing else — no component knows which theme it is in.
   A boot script in index.html sets data-theme before first paint (saved
   choice first, the operating system's preference otherwise), so the
   attribute is always present and always explicit.

   Type: Fraunces for the few words that carry the page (titles, headline
   figures); IBM Plex Sans for everything people read; IBM Plex Mono for
   every number in a column, so digits line up the way they do on paper.

   Design tokens live in :root. Change a colour there and it changes
   everywhere, including the chart, which reads the same variables from SVG.
   No component defines a raw hex value.
   ========================================================================= */

:root {
  color-scheme: light;

  /* Surfaces */
  --surface-0: #f7f5f0;   /* page: warm paper */
  --surface-1: #fffefb;   /* cards, inputs */
  --surface-2: #f1eee7;   /* subtle fills, total rows */
  /* In the light theme the sidebar is PAPER (decision 0052) — the black
     cover belongs to the dark theme, where the yellow mark burns on it. */
  --sidebar:   #f1eee7;

  /* Ink */
  --text-primary:   #1a1814;
  --text-secondary: #55524a;
  --text-muted:     #807c72;
  --sidebar-ink:    #55524a;
  --sidebar-ink-hi: #1a1814;

  /* Overlays and hairlines on the sidebar's own ground — they flip with it. */
  --sidebar-line:        #ddd8cb;
  --sidebar-soft:        rgba(26,24,20,.06);
  --sidebar-strong:      rgba(26,24,20,.1);
  --sidebar-border-soft: rgba(26,24,20,.16);

  /* The switchers need an OPAQUE ground. A translucent one leaks into the
     native dropdown popup, which the browser paints from the select box own
     background -- see the note on .company-switcher select. */
  --switcher-bg:  #e6e3dc;
  --switcher-ink: #1a1814;

  /* Lines — the ledger rules */
  --border:        #e6e2d8;
  --border-strong: #cdc8bb;
  --grid:          #ebe8e0;
  --rule-ink:      #1a1814;

  /* The metals (decision 0052). --gold is the metal on the SIDEBAR'S
     ground: brass here, because the light theme's sidebar is paper; the
     dark theme redefines it to true yellow, where yellow shines. --accent
     is the metal as TEXT on paper — brass, always, because bright metal
     as text on a light ground fails contrast. Never swap the two. */
  --gold:        #8a6c14;
  --accent:      #8a6c14;
  --accent-deep: #6f5710;
  --accent-soft: #f6f0dc;
  --accent-line: #e2d5a6;

  /* Data series — validated for colour-vision deficiency.
     Do not substitute without re-checking contrast and separation. */
  --series-1: #2f6fcb;   /* revenue  */
  --series-2: #e0702f;   /* expenses */

  /* Status */
  --good:     #23a57a;
  --good-ink: #1e6b4f;
  --warning:  #d9912a;
  --critical: #b5382f;
  --info-soft: #e8f0fb;
  --info-line: #c9dbf5;
  --info-ink:  #245a9e;

  /* The warning and critical families, each a fill, a line and an ink.
     These existed as literals in a dozen components before they were named,
     which is exactly what makes a change of brand painful — see the note at
     the top of this file. */
  --warn-soft: #fbf4e6;
  --warn-line: #eddcb9;
  --warn-ink:  #7a5200;
  --warn-ink-strong: #8a6100;

  --critical-soft: #fbf1ef;
  --critical-line: #ebc7c2;
  --critical-ink:  #8f2a22;
  --critical-deep: #7a2520;
  --critical-tint: #fbeceb;
  --critical-hover: #f7e4e1;

  --lock-soft: #fbeee5;
  --lock-line: #f1d3c2;
  --lock-ink:  #a4441a;

  /* Ink that sits on the sidebar's own ground, and on it alone. */
  --sidebar-muted: #8d887b;
  --sidebar-bad:   #b5382f;
  --on-accent:     #fff;
  --on-dark:       #0e0d0b;
  --border-hover:  #b9b3a3;
  --hairline-warm: #e8c3c0;

  --radius: 8px;
  --shadow: 0 1px 0 rgba(21,32,27,.04), 0 1px 3px rgba(21,32,27,.05);
  --font: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* The dark theme. Every colour token from :root, redefined once — if a new
   token is added above without a line here, it will leak light values into
   dark screens, so keep the two lists in step. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --surface-0: #131211;
  --surface-1: #1c1a17;
  --surface-2: #24211c;
  --sidebar:   #0b0a09;   /* the ledger's black cover lives here */

  --text-primary:   #ece8dd;
  --text-secondary: #b5afa2;
  --text-muted:     #8b867a;
  --sidebar-ink:    #a9a293;
  --sidebar-ink-hi: #f4f1e8;

  --sidebar-line:        rgba(255,255,255,.07);
  --sidebar-soft:        rgba(255,255,255,.06);
  --sidebar-strong:      rgba(255,255,255,.1);
  --sidebar-border-soft: rgba(255,255,255,.14);

  --switcher-bg:  #1a1918;
  --switcher-ink: #f4f1e8;

  --border:        #2f2c26;
  --border-strong: #444037;
  --grid:          #272420;
  --rule-ink:      #ece8dd;

  /* On dark grounds the metal is TRUE YELLOW (decision 0052) — the mark
     burns on the black cover, and yellow as text is readable here, so the
     accent family goes yellow too; hover brightens further. */
  --gold:        #f2c200;
  --accent:      #f2c200;
  --accent-deep: #ffd21c;
  --accent-soft: #2a2405;
  --accent-line: #57490a;

  /* Data series — the light values lightened one step for a dark ground;
     hue and order unchanged so the two remain separable. */
  --series-1: #6d9ee0;
  --series-2: #ee9257;

  --good:     #34c08d;
  --good-ink: #45c795;
  --warning:  #e0a339;
  --critical: #e05a4f;
  --info-soft: #1a2333;
  --info-line: #2e4468;
  --info-ink:  #8ab4ee;

  --warn-soft: #2a2312;
  --warn-line: #57481e;
  --warn-ink:  #d9b45a;
  --warn-ink-strong: #e5c470;

  --critical-soft: #2e1a17;
  --critical-line: #5a2f29;
  --critical-ink:  #ef968d;
  --critical-deep: #f3aba3;
  --critical-tint: #2a1b18;
  --critical-hover: #3a221e;

  --lock-soft: #2b1f16;
  --lock-line: #55402c;
  --lock-ink:  #e09a67;

  --sidebar-muted: #6f6a5e;
  --sidebar-bad:   #ff9a93;
  --on-accent:     #1a1608;   /* near-black on gold */
  --on-dark:       #0e0d0b;
  --border-hover:  #565146;
  --hairline-warm: #5a3531;

  --shadow: 0 1px 0 rgba(0,0,0,.35), 0 1px 3px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html { background: var(--surface-0); }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.45;
  background: var(--surface-0); color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: flex; min-height: 100vh; }

/* The hidden attribute must win over display rules on .app and .login. */
[hidden] { display: none !important; }

/* ------------------------------- Sidebar ------------------------------- */
.sidebar {
  width: 232px; flex: 0 0 232px; padding: 18px 12px 16px;
  background: var(--sidebar); color: var(--sidebar-ink);
  border-right: 1px solid var(--sidebar-line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; }
/* The mark: the Closed Book (decision 0052) — pages as ledger rules,
   closed with the double rule. It wears the metal of its ground: true
   yellow on the dark cover, brass on paper. */
.brand-seal { width: 26px; height: 26px; display: block; flex: none; color: var(--gold); }
/* The wordmark's full stop wears the metal too — the one gold letterform. */
.brand-dot { color: var(--gold); }
/* ™ until the registration lands; small enough to claim, not to shout. */
.brand-tm {
  font-size: .42em; font-weight: 700; letter-spacing: 0;
  vertical-align: top; position: relative; top: -.15em; margin-left: 2px;
  color: var(--sidebar-muted);
}
.login-brand .brand-tm { color: var(--text-muted); }

/* The wordmark: Sora 800, exactly as the identity canvas types it. An
   earlier build drew an extra tail bar over the Q "so it would not read as
   an O" — it read as a slash through the Q instead, and the owner caught
   it. Sora's own Q is the agreed letterform; nothing is drawn on top of
   it. Decision 0060. */
.brand-name {
  position: relative; display: inline-block; white-space: nowrap;
  color: var(--sidebar-ink-hi);
  font-family: Sora, var(--display), system-ui, sans-serif;
  font-weight: 800; font-size: 18px; letter-spacing: -.045em; line-height: 1;
}

/* The old OL tile, kept only so nothing that still references it collapses. */
.brand-mark { display: none; }

.company-switcher { margin: 0 4px 16px; }
/* The background here MUST be opaque. The open dropdown is painted by the
   browser from this element own background, so a translucent one composites
   over the popup default light surface and the list comes out pale -- while
   the options, inheriting CanvasText under color-scheme: dark, draw white on
   it. White on white: the company name vanished in dark mode. Name the ground
   and the ink outright rather than borrowing system colours. */
.company-switcher select {
  width: 100%; padding: 8px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 500;
  background: var(--switcher-bg); border: 1px solid var(--sidebar-border-soft);
  color: var(--switcher-ink); appearance: none;
}
.company-switcher option { background: var(--switcher-bg); color: var(--switcher-ink); }

.nav-group { margin-bottom: 14px; }
/* In the sidebar the wrapper is invisible; the top-menu layout turns it
   into the dropdown panel. */
.nav-items { display: block; }
/* A submenu (a labelled section inside a group): only the top layout
   renders it as a flyout. Everywhere else it flattens away, so the sidebar
   and the phone read exactly as they always have. */
.nav-sub, .nav-sub-items { display: contents; }
.nav-sub-label { display: none; }
.nav-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--sidebar-muted); font-weight: 600; padding: 0 10px 6px;
}
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 10px; border: 0; border-radius: 6px; text-align: left;
  background: none; color: var(--sidebar-ink); font-size: 13px; font-weight: 500;
  position: relative;
}
.nav button:hover { background: var(--sidebar-soft); color: var(--sidebar-ink-hi); }
.nav button[aria-current="page"] { background: var(--sidebar-strong); color: var(--sidebar-ink-hi); font-weight: 600; }
/* The ledger's margin line marks the page you are on — gold, like the seal. */
.nav button[aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 2px;
  background: var(--gold); border-radius: 2px;
}
.nav svg { width: 16px; height: 16px; flex: 0 0 16px; opacity: .75; }

.integrity-footer {
  margin-top: auto; padding: 14px 10px 0;
  border-top: 1px solid var(--sidebar-line);
  font-size: 11.5px; line-height: 1.6;
}
.integrity-label { color: var(--sidebar-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .08em; font-size: 10px; font-weight: 600; }
.integrity-count { color: var(--sidebar-muted); margin-top: 6px; font-family: var(--mono); font-size: 11px; }
.is-ok  { color: var(--good); }
.is-bad { color: var(--sidebar-bad); font-weight: 600; }
.is-muted { color: var(--sidebar-muted); }

.save-footer { padding: 10px 10px 0; font-size: 11.5px; line-height: 1.6; }
.save-status { min-height: 18px; }
.signed-in { color: var(--sidebar-muted); font-size: 11px; margin-top: 2px; word-break: break-all; }
.linklike { border: 0; background: none; padding: 0; color: var(--sidebar-ink); text-decoration: underline; text-underline-offset: 2px; font-size: 11px; }
.linklike:hover { color: var(--sidebar-ink-hi); }

/* This month's AI spend — decision 0068. */
.usage-total { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; }
.usage-head { display: flex; align-items: baseline; justify-content: space-between; }
.usage-bar {
  margin-top: 10px; height: 6px; border-radius: 3px;
  background: var(--border); overflow: hidden;
}
.usage-bar-fill { height: 100%; background: var(--accent, #7a6a3f); border-radius: 3px; }
.usage-bar-fill.is-high { background: #b4442e; }

/* The account switcher — decision 0066. Only rendered when a person belongs
   to more than one set of books, which in practice means an accountant. */
.books-switcher { margin-top: 8px; }
.books-switcher-label {
  display: block; color: var(--sidebar-muted); font-size: 10px;
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 3px;
}
/* color used var(--ink), which is not a token this file defines -- the
   declaration was invalid and the colour fell back to whatever was inherited.
   Same opaque-ground rule as the company switcher above. */
.books-switcher select {
  width: 100%; font-size: 12px; padding: 4px 6px;
  background: var(--switcher-bg); color: var(--switcher-ink); border: 1px solid var(--border);
  border-radius: 4px;
}
.books-switcher option { background: var(--switcher-bg); color: var(--switcher-ink); }

/* -------------------------------- Main -------------------------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface-0); border-bottom: 1px solid var(--border);
  padding: 18px 32px 14px; display: flex; align-items: flex-end; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 {
  margin: 0; font-family: var(--display); font-size: 24px; font-weight: 500;
  letter-spacing: -.015em; line-height: 1.1;
  font-variation-settings: "opsz" 24, "SOFT" 30;
}
.topbar .subtitle { color: var(--text-muted); font-size: 12.5px; margin-top: 4px; }
.toolbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.content { padding: 22px 32px 80px; max-width: 1380px; }
.view { display: none; }
.view.is-active { display: block; }

/* ------------------------------ Buttons ------------------------------ */
.btn {
  padding: 7px 13px; border-radius: 6px; font-size: 13px; font-weight: 500;
  background: var(--surface-1); border: 1px solid var(--border-strong); color: var(--text-primary);
  transition: background .12s, border-color .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-hover); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-danger { background: var(--critical-soft); border-color: var(--critical-line); color: var(--critical); }
.btn-danger:hover { background: var(--critical-hover); }
.btn-sm { padding: 4px 9px; font-size: 12px; border-radius: 5px; }
.btn-lg { padding: 11px 20px; font-size: 14.5px; border-radius: 7px; }
.align-left { margin-right: auto; }

/* ------------------------------- Cards ------------------------------- */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px;
}
/* Reference material rather than work: same card, less voice. Used where a
   table is something to consult, not something to act on — so it stops
   competing with the queue above it. */
.card-quiet { background: var(--surface-2); box-shadow: none; }
.card-quiet .card-title { font-family: var(--font); font-size: 14px; font-weight: 600; }

.card-head { padding: 16px 20px 0; display: flex; align-items: flex-start; gap: 12px; }
/* A card whose page header already named it keeps the head's spacing without
   an empty heading sitting in it. */
.card-head > div:first-child:empty { display: none; }
.card-title { margin: 0; font-family: var(--display); font-size: 17px; font-weight: 500; letter-spacing: -.01em; }
.card-sub { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }
.card-body { padding: 14px 20px 18px; }
.card-body.tight { padding-top: 8px; }
.card-body.table-body { padding: 12px 20px 6px; }
.card-body.statement { padding: 6px 20px 18px; }

.two-column { display: grid; grid-template-columns: minmax(0,1.3fr) minmax(0,1fr); gap: 18px; align-items: start; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px,1fr)); gap: 18px; align-items: start; }

/* ------------------------------- Tables ------------------------------- */
/* Hairline rules between rows, as on ruled paper. Numbers in the data face. */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 0 10px 8px; border-bottom: 1px solid var(--border-strong);
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-muted); font-weight: 600;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable:hover { background: var(--accent-soft); cursor: pointer; }
.num { text-align: right; font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
th.num { text-align: right; font-family: var(--font); font-size: 10.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.strong { font-weight: 600; }
.subtle { color: var(--text-secondary); }
.small { font-size: 12px; }
.capitalise { text-transform: capitalize; }
.neg { color: var(--critical); }
.indent { padding-left: 24px; }

.section-head td {
  padding-top: 18px; border-bottom: 1px solid var(--border-strong);
  font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-secondary);
}
.sub-head td { font-weight: 600; padding-top: 11px; }
.total-row td { font-weight: 600; background: var(--surface-2); }
.grand-total td { font-weight: 600; font-size: 14px; }
.grand-total td.num { font-size: 13.5px; font-weight: 600; }
/* The accountant's marks: a single rule above a total, a double rule under a proved figure. */
.rule-top td { border-top: 1.5px solid var(--rule-ink); }
.rule-double td { border-bottom: 3px double var(--rule-ink); }
.statement-note { margin: 14px 0 0; color: var(--text-muted); font-size: 12.5px; }

/* ----------------------------- Stat tiles ----------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px,1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px 12px; box-shadow: var(--shadow); }
.stat .label { font-size: 11px; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.stat .value {
  font-family: var(--display); font-size: 30px; font-weight: 500; letter-spacing: -.02em;
  margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1.1;
  padding-bottom: 6px; border-bottom: 3px double var(--border-strong);
}
.stat .note { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }

/* A stat you can click to see the report that proves it. The button wrapper
   resets to nothing so the tile inside renders exactly as a plain one. */
.stat-link { display: block; padding: 0; border: 0; background: none; text-align: left; border-radius: var(--radius); }
.stat-link .stat { height: 100%; }
.stat-link:hover .stat { border-color: var(--accent-line); }
.stat-link:hover .value { border-bottom-color: var(--accent); }

/* ---------------------------- Proof score ---------------------------- */
.proof-head { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.proof-ring { width: 56px; height: 56px; flex: none; }
.proof-ring .ring-track { fill: none; stroke: var(--border); stroke-width: 4; }
/* The ring sits on a light card in the light theme, so it wears --accent:
   brass on paper, yellow in the dark theme — never bright metal on white. */
.proof-ring .ring-fill { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; }
.proof-ring.proof-broken .ring-fill { stroke: var(--critical); }
.proof-ring .ring-text { fill: var(--text-primary); font-family: var(--mono); font-size: 13px; font-weight: 600; }
.proof-words { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.proof-buttons { display: flex; gap: 6px; }
.proof-grade { font-family: var(--display); font-size: 14px; color: var(--accent); }
.proof-grade.proof-broken { color: var(--critical-ink); }

/* ----------------------------- Watchdog -------------------------------- */
.watchdog-card.watchdog-look { border-left: 3px solid var(--warning); }
.watchdog-card.watchdog-note { border-left: 3px solid var(--border-strong); }

/* ---------------------------- Firm cockpit ----------------------------- */
.cockpit-score { font-family: var(--mono); font-weight: 600; color: var(--accent); }
.cockpit-score.cockpit-low { color: var(--warn-ink-strong); }

/* -------------------------- Monthly letter ---------------------------- */
.letter-card { max-width: 680px; }
.letter-body { font-family: var(--display); font-size: 15px; line-height: 1.75; padding: 28px 36px 24px; }
.letter-head { display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 3px double var(--rule-ink); padding-bottom: 8px; margin-bottom: 20px; }
.letter-company { font-size: 18px; font-weight: 600; }
.letter-title { font-size: 20px; font-weight: 500; margin: 0 0 16px; }
.letter-body p { margin: 0 0 13px; }
.letter-sign { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 8px; font-family: var(--font); }

/* ---------------------------- Deadlines ------------------------------- */
.deadline-chip {
  flex: none; font-family: var(--mono); font-size: 11px; white-space: nowrap;
  padding: 3px 8px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-secondary);
}
.deadline-chip.deadline-urgent {
  background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-ink);
}

/* ------------------------ Mode bar (past / sandbox) -------------------- */
.mode-bar {
  display: flex; align-items: center; gap: 14px; justify-content: space-between;
  padding: 10px 24px; font-size: 13px; line-height: 1.45;
}
.mode-past { background: var(--accent-soft); border-bottom: 2px solid var(--accent); color: var(--text-primary); }
.mode-sandbox { background: var(--info-soft); border-bottom: 2px solid var(--info-ink); color: var(--text-primary); }
.mode-bar .btn { flex: none; }

/* --------------------------- Approval queue --------------------------- */
.proposal-card { border-left: 3px solid var(--accent); }
.proposal-amount { font-family: var(--display); font-size: 22px; margin-left: auto; white-space: nowrap; }
.proposal-lines { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.proposal-lines th { text-align: left; font-size: 11px; color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.proposal-lines td { padding: 6px 8px; border-bottom: 1px solid var(--grid); }
.proposal-why { background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; }
.proposal-why-title { font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--accent); margin-bottom: 4px; }
.proposal-why ol { margin: 0; padding-left: 18px; }
.proposal-why li { margin: 3px 0; font-size: 13px; }
.proposal-actions { display: flex; gap: 8px; }
.approvals-section { font-family: var(--display); font-size: 16px; font-weight: 500; margin: 4px 0 10px; }
.card + .approvals-section { margin-top: 22px; }
.request-card .card-title { font-style: italic; font-weight: 500; }
.ask-offer-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ------------------------ The review screen -------------------------- */
/* One row per bank transaction, and the reasoning sits OPEN inside the row
   rather than behind a disclosure — a person should never approve a draft
   whose why they have not seen. Decision 0063. */
.review-table { width: 100%; border-collapse: collapse; }
.review-table th { text-align: left; font-size: 11px; color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.review-table td { padding: 10px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.review-table .num.pos { color: var(--good, #157f4d); }
.review-desc { font-weight: 500; margin-bottom: 6px; }
.review-table .proposal-why { margin-bottom: 0; }
.review-table .proposal-why-title { display: flex; align-items: center; gap: 8px; }
.review-facts { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--accent-line);
  font-size: 12px; color: var(--text-muted); }
.review-account { width: 100%; }
.review-actions { display: flex; flex-direction: column; gap: 6px; }
.btn-small { padding: 4px 10px; font-size: 12px; }
.review-bulk { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }
.review-bulk li { margin: 3px 0; }

/* --------------------- Multi-column statements ----------------------- */
.toolbar-label { font-size: 12px; color: var(--text-muted); align-self: center; }
.statement .share { color: var(--text-muted); }
/* A by-month statement can be wider than the screen; the account names
   stay put while the months scroll under them. */
.by-month th:first-child, .by-month td:first-child {
  position: sticky; left: 0; background: var(--surface-1); min-width: 180px;
}

/* "Show me" appears when the row is under the pointer — quiet until asked. */
.btn-trace { opacity: 0; flex: none; }
.trust-item:hover .btn-trace, .btn-trace:focus-visible { opacity: 1; }
@media (hover: none) { .btn-trace { opacity: 1; } }

/* ------------------------------ Banners ------------------------------ */
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-radius: 6px; font-size: 13px; line-height: 1.5;
  margin-bottom: 14px; border: 1px solid;
}
.banner svg { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 2px; }
.banner-ok   { background: var(--accent-soft); border-color: var(--accent-line); color: var(--good-ink); }
.banner-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn-ink); }
.banner-bad  { background: var(--critical-soft); border-color: var(--critical-line); color: var(--critical-ink); }
.banner-info { background: var(--info-soft); border-color: var(--info-line); color: var(--info-ink); }

/* -------------------------------- Pills -------------------------------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  border: 1px solid transparent; letter-spacing: .01em;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok    { background: var(--accent-soft); color: var(--good-ink); border-color: var(--accent-line); }
.pill-muted { background: var(--surface-2); color: var(--text-muted); border-color: var(--border); }
.pill-type  { background: var(--info-soft); color: var(--info-ink); border-color: var(--info-line); }
.pill-lock  { background: var(--lock-soft); color: var(--lock-ink); border-color: var(--lock-line); }
.pill-warn  { background: var(--warn-soft); color: var(--warn-ink-strong); border-color: var(--warn-line); }

/* -------------------------------- Forms -------------------------------- */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--surface-1); color: var(--text-primary);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent-line); outline-offset: 0; border-color: var(--accent); }
.field input.readonly { background: var(--surface-2); color: var(--text-muted); }
.field small { display: block; font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.toolbar { display: flex; gap: 9px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .field { margin-bottom: 0; }
.toolbar .field.wide { min-width: 300px; }
.toolbar input, .toolbar select { padding: 6px 9px; }

.stat-list { margin: 0; font-size: 13px; }
.stat-list div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.stat-list dt { color: var(--text-secondary); }
.stat-list dd { margin: 0; font-weight: 600; text-align: right; }

/* -------------------------- Journal entry form -------------------------- */
.entry-lines { margin-top: 4px; }
.entry-lines th { padding-bottom: 6px; }
.entry-lines td { padding: 4px 5px; border-bottom: 0; }
.entry-lines select, .entry-lines input {
  width: 100%; padding: 6px 8px; border-radius: 6px; font-size: 13px;
  border: 1px solid var(--border-strong); background: var(--surface-1);
}
.entry-lines input.amount { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.line-remove { border: 0; background: none; color: var(--text-muted); font-size: 17px; line-height: 1; padding: 0 5px; }
.line-remove:hover { color: var(--critical); }

.entry-totals {
  display: flex; align-items: center; gap: 18px;
  margin-top: 12px; padding-top: 12px; border-top: 1.5px solid var(--rule-ink);
  font-variant-numeric: tabular-nums;
}
.entry-totals .total { font-size: 13px; color: var(--text-secondary); }
.entry-totals .total b { font-family: var(--mono); font-size: 14px; color: var(--text-primary); margin-left: 6px; }
.balance-flag { margin-left: auto; padding: 5px 12px; border-radius: 6px; font-weight: 600; font-size: 13px; }
.balance-flag.is-balanced { background: var(--accent-soft); color: var(--good-ink); border-bottom: 3px double var(--good-ink); }
.balance-flag.is-off { background: var(--critical-soft); color: var(--critical-ink); }

/* -------------------------------- Modal -------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 150; padding: 34px 20px; overflow-y: auto;
  background: rgba(19,32,26,.5); display: none;
  align-items: flex-start; justify-content: center;
}
.modal-backdrop.is-open { display: flex; }
.modal { background: var(--surface-1); border-radius: 10px; width: 100%; max-width: 480px; box-shadow: 0 24px 64px rgba(19,32,26,.35); }
.modal.modal-wide { max-width: 820px; }
.modal-head { padding: 20px 22px 0; }
.modal-head h3 { margin: 0; font-family: var(--display); font-size: 19px; font-weight: 500; letter-spacing: -.01em; }
.modal-head .modal-subtitle { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }
.modal-body { padding: 15px 22px; }
.modal-foot { padding: 0 22px 20px; display: flex; gap: 8px; justify-content: flex-end; align-items: center; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 13px; margin-bottom: 14px; }
.detail-grid span { display: block; color: var(--text-muted); font-size: 11.5px; }
.entry-memo { font-weight: 500; margin: 0 0 12px; }

/* -------------------------- Dashboard activity -------------------------- */
.activity-row { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--border); }
.activity-main { flex: 1; min-width: 0; }
.activity-memo { font-weight: 500; font-size: 13px; }
.activity-meta { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.activity-amount { font-family: var(--mono); font-weight: 500; font-size: 12.5px; white-space: nowrap; }

/* --------------------------- Chart and tooltip --------------------------- */
.legend { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-secondary); }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; }
.swatch-1 { background: var(--series-1); }
.swatch-2 { background: var(--series-2); }

#tooltip {
  position: fixed; pointer-events: none; opacity: 0; transition: opacity .1s; z-index: 400;
  background: var(--sidebar); color: var(--on-accent); padding: 8px 10px; border-radius: 6px;
  font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.22);
}
#tooltip .tt-title { font-weight: 600; margin-bottom: 5px; }
#tooltip .tt-row { display: flex; justify-content: space-between; gap: 16px; opacity: .92; }
#tooltip .tt-row b { font-family: var(--mono); font-variant-numeric: tabular-nums; }
#tooltip .tt-total { margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(255,255,255,.2); }

/* -------------------------------- Toast -------------------------------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; z-index: 300;
  transform: translateX(-50%) translateY(14px); opacity: 0; transition: opacity .22s, transform .22s;
  background: var(--sidebar); color: var(--on-accent); padding: 11px 18px; border-radius: 8px;
  font-size: 13.5px; font-weight: 500; max-width: 520px;
  box-shadow: 0 8px 26px rgba(0,0,0,.25);
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { background: var(--critical-deep); }

.empty { text-align: center; padding: 36px 16px; color: var(--text-muted); }

/* -------------------------------- Login -------------------------------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 32px 20px;
  background:
    linear-gradient(180deg, rgba(30,107,79,.06), transparent 40%),
    repeating-linear-gradient(180deg, transparent 0 31px, var(--grid) 31px 32px),
    var(--surface-0);
}
.login-card {
  width: 100%; max-width: 440px; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 10px; padding: 30px 32px 28px;
  box-shadow: 0 24px 60px rgba(19,32,27,.12);
  position: relative; overflow: hidden;
}
/* The ledger's margin line. */
.login-card::before { content: ""; position: absolute; left: 22px; top: 0; bottom: 0; width: 1px; background: var(--hairline-warm); }
.login-brand { padding: 0 0 22px; color: var(--text-primary); }
.login-brand .brand-name { color: var(--text-primary); }
/* On the light card the seal wears the darkened gold that holds contrast. */
.login-brand .brand-seal { color: var(--accent); }
.login h1 {
  margin: 0 0 10px; font-family: var(--display); font-size: 30px; font-weight: 500;
  letter-spacing: -.02em; line-height: 1.1; font-variation-settings: "opsz" 30, "SOFT" 40;
}
.login-lede { margin: 0 0 24px; color: var(--text-secondary); font-size: 14px; line-height: 1.55; }
.login-actions { display: flex; flex-direction: column; gap: 10px; }
.login-message { min-height: 20px; margin: 14px 0 0; color: var(--critical); font-size: 13px; }

/* ------------------------------ Responsive ------------------------------ */
@media (max-width: 980px) {
  .two-column { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  /* Phone: the sidebar becomes a scrolling icon strip along the bottom,
     the way a phone app's tab bar works, and every table scrolls sideways
     inside its card rather than the page. */
  .app { flex-direction: column; min-height: 100vh; }
  .sidebar {
    order: 2; width: auto; flex: 0 0 auto; height: auto; position: sticky; top: auto; bottom: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); overflow-x: auto; overflow-y: hidden;
    border-top: 1px solid var(--sidebar-line); z-index: 30;
  }
  /* The brand and the integrity readout go: the tab bar is 56px tall and
     every pixel of it is navigation. The SWITCHERS do not go — decision
     0069. They used to, and it made the app unusable for the two people it
     is aimed at: an owner with two companies could only ever open one, and
     an accountant could not reach a single client. They move to the top of
     the screen instead, where a phone app puts them. */
  .brand, .integrity-footer, .nav-label { display: none; }
  .company-switcher, .save-footer { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav-group, .nav-items { display: contents; }
  .nav button { flex-direction: column; gap: 3px; padding: 6px 8px; min-width: 64px; font-size: 10px; text-align: center; }
  .nav button span { white-space: nowrap; }
  .nav button[aria-current="page"]::before { left: 8px; right: 8px; top: auto; bottom: 0; width: auto; height: 2px; }
  .main { order: 1; max-width: 100vw; overflow-x: hidden; }
  html, body { overflow-x: hidden; }
  .content { max-width: 100vw; }
  .card, .stat, .banner { min-width: 0; }
  .banner { word-break: break-word; }
  .content, .topbar { padding-left: 14px; padding-right: 14px; }
  .content { padding-bottom: 24px; }
  .topbar { position: static; padding-top: 14px; }
  .topbar h1 { font-size: 20px; }
  .toolbar-actions { margin-left: 0; width: 100%; justify-content: flex-start; }
  .field-row, .form-row { grid-template-columns: 1fr; }
  .card-body.table-body, .card-body.statement { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card-body.table-body table { min-width: 560px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px 14px 10px; }
  .stat .value { font-size: 22px; }
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal, .modal.modal-wide { max-width: none; border-radius: 0; min-height: 100vh; display: flex; flex-direction: column; }
  .modal-body { flex: 1; overflow-y: auto; }
  .modal-foot { position: sticky; bottom: 0; background: var(--surface-1); padding-top: 10px; border-top: 1px solid var(--border); flex-wrap: wrap; }
  .btn, .field input, .field select { min-height: 40px; }
  .entry-lines td { padding: 3px 2px; }
  .workflow-lanes { grid-template-columns: 1fr; }
}
/* The phone header — decision 0069. Holds what the sidebar holds on a
   desktop and the bottom tab bar has no room for: which company, and whose
   books. Hidden above 760px, where the sidebar already shows both. */
.phone-bar { display: none; }
@media (max-width: 760px) {
  .phone-bar {
    display: flex; gap: 8px; align-items: center;
    padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
    background: var(--surface-1); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 25;
  }
  .phone-bar select {
    flex: 1 1 0; min-width: 0; font-size: 13px; padding: 7px 8px;
    background: var(--surface-0); color: var(--ink);
    border: 1px solid var(--border); border-radius: 6px;
  }
  /* One switcher on its own takes the width; two share it. */
  .phone-bar select[hidden] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ------------------------- Top-menu layout ------------------------- */
/* A per-browser preference (decision 0060): the same sidebar markup laid
   along the top, each nav group a dropdown. Desktop only — below 760px the
   phone tab bar always wins, whatever the preference says. */
@media (min-width: 761px) {
  html[data-layout="top"] .app { flex-direction: column; }
  html[data-layout="top"] .sidebar {
    width: auto; flex: 0 0 auto; height: auto; overflow: visible;
    position: sticky; top: 0; z-index: 40;
    flex-direction: row; align-items: center; gap: 8px;
    padding: 8px 16px;
    border-right: 0; border-bottom: 1px solid var(--sidebar-line);
  }
  html[data-layout="top"] .brand { padding: 0 8px 0 0; }
  html[data-layout="top"] .company-switcher { margin: 0; flex: 0 0 160px; }
  html[data-layout="top"] .nav { display: flex; align-items: center; gap: 2px; }
  html[data-layout="top"] .nav-group { margin: 0; position: relative; }
  html[data-layout="top"] .nav-label {
    display: flex; align-items: center; gap: 5px;
    padding: 8px 10px; border-radius: 6px; cursor: pointer; user-select: none;
    white-space: nowrap;   /* one line per group, always — the owner's rule */
  }
  html[data-layout="top"] .nav-label::after { content: "▾"; font-size: 8px; opacity: .7; }
  html[data-layout="top"] .nav-group:hover .nav-label,
  html[data-layout="top"] .nav-group:focus-within .nav-label {
    background: var(--sidebar-soft); color: var(--sidebar-ink-hi);
  }
  /* The gold margin line moves to the group holding the open page. */
  html[data-layout="top"] .nav-group:has(button[aria-current="page"]) .nav-label {
    color: var(--sidebar-ink-hi); box-shadow: inset 0 -2px 0 var(--gold); border-radius: 6px 6px 0 0;
  }
  html[data-layout="top"] .nav-items {
    display: none; position: absolute; top: 100%; left: 0; min-width: 218px;
    background: var(--sidebar); border: 1px solid var(--sidebar-line); border-radius: 0 8px 8px 8px;
    padding: 6px; box-shadow: 0 14px 34px rgba(0, 0, 0, .35); z-index: 50;
  }
  /* DIRECT child only — a nested submenu must not open with its parent. */
  html[data-layout="top"] .nav-group:hover > .nav-items,
  html[data-layout="top"] .nav-group:focus-within > .nav-items { display: block; }
  /* The last group's menu must not run off the right edge. */
  html[data-layout="top"] .nav-group:last-child > .nav-items { left: auto; right: 0; border-radius: 8px 0 8px 8px; }

  /* Submenus: a row with a side arrow; its panel flies out to the right. */
  html[data-layout="top"] .nav-sub { display: block; position: relative; }
  html[data-layout="top"] .nav-sub-label {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px; border-radius: 6px; cursor: pointer; user-select: none;
    color: var(--sidebar-ink); font-size: 13px; font-weight: 500;
  }
  html[data-layout="top"] .nav-sub-label svg { width: 16px; height: 16px; flex: 0 0 16px; opacity: .75; }
  html[data-layout="top"] .nav-sub-label::after { content: "▸"; margin-left: auto; font-size: 9px; opacity: .7; }
  html[data-layout="top"] .nav-sub:hover > .nav-sub-label,
  html[data-layout="top"] .nav-sub:focus-within > .nav-sub-label { background: var(--sidebar-soft); color: var(--sidebar-ink-hi); }
  html[data-layout="top"] .nav-sub-items { left: 100%; top: -7px; border-radius: 8px; }
  html[data-layout="top"] .nav-sub:hover > .nav-sub-items,
  html[data-layout="top"] .nav-sub:focus-within > .nav-sub-items { display: block; }

  /* The trust readouts stay on screen, compressed to a line. */
  html[data-layout="top"] .integrity-footer {
    margin: 0 0 0 auto; padding: 0; border: 0;
    display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 11px;
  }
  html[data-layout="top"] .integrity-label, html[data-layout="top"] .integrity-count { display: none; }
  html[data-layout="top"] .save-footer { padding: 0; white-space: nowrap; }
  html[data-layout="top"] .save-footer .signed-in { display: none; }
  html[data-layout="top"] .help-row { margin: 0; padding: 0; display: flex; gap: 2px; }
  html[data-layout="top"] .help-row .nav-help { width: auto; padding: 7px 8px; }
  html[data-layout="top"] .help-row .nav-help span { display: none; }
}
/* One line, always — the owner's rule. On a window too narrow for the
   readouts they step aside whole rather than clipping mid-word; the
   dashboard banner still announces balance state on every load. */
@media (min-width: 761px) and (max-width: 1180px) {
  html[data-layout="top"] .integrity-footer, html[data-layout="top"] .save-footer { display: none; }
}

/* ------------------------ Tabs, form rows, worksheet ------------------------ */

/* Tab strip inside a view toolbar (Checks). */
.tab-row { display: flex; gap: 8px; align-items: flex-end; margin-left: auto; }

/* Two fields side by side in a modal. Collapses on a narrow screen. */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 620px) { .form-row { grid-template-columns: 1fr; } }

/*
 * The ten-column worksheet.
 *
 * Ten numeric columns do not fit comfortably, so the type is small and the
 * container scrolls sideways rather than the page doing it. Column-pair
 * borders are what make it readable — without them nobody can tell which Dr
 * belongs to which Cr.
 */
.worksheet { font-size: 12px; min-width: 1100px; }
.worksheet th, .worksheet td { padding: 4px 6px; }
.worksheet td.num { font-size: 11.5px; }
.worksheet .ws-group {
  text-align: center;
  border-left: 2px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-secondary);
}
.worksheet thead tr:last-child th { border-bottom: 1px solid var(--border); }
.worksheet th:nth-child(2n+3), .worksheet td:nth-child(2n+3) { border-left: 1px solid var(--border); }
.worksheet .ws-group:first-of-type { border-left: 2px solid var(--border); }

/* Net income carried into the last two pairs — the row people misread. */
.ws-balancing td { background: var(--info-soft); }

/* Plain checkbox + label, inline, matching a .field's sizing so it lines up
   next to a real .field in a .form-row (see Write Check's "Print later"). */
.checkbox-row {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  margin-top: 22px;
}
.checkbox-row input { width: 15px; height: 15px; accent-color: var(--accent); }

/* ---------------------------- Workflow map ---------------------------- */
.workflow .card-body { padding: 14px 20px 12px; }
.workflow-lanes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.lane-title { font-family: var(--display); font-size: 15px; font-weight: 500; margin-bottom: 8px; }
.lane-note { font-family: var(--font); font-size: 11.5px; color: var(--text-muted); margin-left: 6px; }
.lane-steps { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.step {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px 5px 6px; border-radius: 6px; font-size: 12.5px; font-weight: 500;
  background: var(--surface-1); border: 1px solid var(--border-strong); color: var(--text-primary);
}
.step:hover { border-color: var(--accent); background: var(--accent-soft); }
.step-n {
  width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); font-family: var(--mono); font-size: 10.5px;
}
.step-arrow { color: var(--border-strong); font-size: 13px; }
.workflow-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.linklike-dark { border: 0; background: none; padding: 0; color: var(--accent); font-size: 12.5px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.linklike-dark:hover { color: var(--accent-deep); }
.glossary td, .glossary th { font-size: 12.5px; }
.guide-list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.55; }
.guide-list li { margin-bottom: 8px; }
@media (max-width: 980px) { .workflow-lanes { grid-template-columns: 1fr; } }

/* ---------------------------- Reconciliation ---------------------------- */
.rec-start .btn-lg { margin-top: 6px; }
.rec-extras { margin: 4px 0 14px; }
.rec-extras summary { font-weight: 600; font-size: 13px; color: var(--text-secondary); }
.rec-bar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 18px; margin-bottom: 14px;
}
.rec-account { font-family: var(--display); font-size: 16px; font-weight: 500; }
.rec-figures { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.rec-figure { display: flex; flex-direction: column; min-width: 120px; }
.rec-figure span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 600; }
.rec-figure b { font-family: var(--mono); font-size: 17px; font-weight: 500; margin-top: 2px; }
.rec-figure small { font-size: 11px; color: var(--text-muted); }
.rec-op { font-size: 18px; color: var(--text-muted); min-width: 0; }
.rec-diff b { color: var(--critical); padding-bottom: 3px; border-bottom: 3px double var(--critical); }
.rec-diff.is-zero b { color: var(--good-ink); border-bottom-color: var(--good-ink); }
.rec-diff.is-zero small { color: var(--good-ink); font-weight: 600; }
.rec-actions { display: flex; gap: 8px; }
.rec-tools { align-items: center; }
.rec-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.rec-col { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.rec-col-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border-strong); }
.rec-all { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.rec-table { max-height: 60vh; overflow: auto; }
.rec-table th { position: sticky; top: 0; background: var(--surface-1); padding-top: 8px; }
.rec-table td { padding: 6px 10px; }
.rec-row { cursor: pointer; }
.rec-row:hover { background: var(--accent-soft); }
.rec-row.is-ticked { background: var(--accent-soft); }
.rec-row.is-ticked .num { font-weight: 600; }
.rec-payee { font-weight: 500; }
.rec-pill { margin-left: 6px; vertical-align: middle; }
.rec-report h4 { margin: 16px 0 6px; font-family: var(--display); font-weight: 500; font-size: 15px; }
.rec-report .stat-list .rule-double { border-bottom: 3px double var(--rule-ink); }
@media (max-width: 980px) { .rec-cols { grid-template-columns: 1fr; } .rec-figures { margin-left: 0; width: 100%; justify-content: space-between; } .rec-figure { min-width: 0; } }
@media print { .sidebar, .topbar, .toast, .modal-foot { display: none !important; } .modal-backdrop { position: static; background: none; padding: 0; } .modal { box-shadow: none; max-width: none; } }
/* Paper is always the light theme. Without this, printing from dark mode
   asks the printer for black pages with bone ink. */
@media print {
  :root[data-theme="dark"] {
    color-scheme: light;
    --surface-0: #fff; --surface-1: #fff; --surface-2: #f1eee7;
    --text-primary: #1a1814; --text-secondary: #55524a; --text-muted: #807c72;
    --border: #e6e2d8; --border-strong: #cdc8bb; --grid: #ebe8e0; --rule-ink: #1a1814;
    --gold: #8a6c14; --accent: #8a6c14; --accent-deep: #6f5710;
    --accent-soft: #f6f0dc; --accent-line: #e2d5a6; --on-accent: #fff;
    --series-1: #2f6fcb; --series-2: #e0702f;
    --good: #23a57a; --good-ink: #1e6b4f; --warning: #d9912a; --critical: #b5382f;
    --shadow: none;
  }
}

/* ------------------------------- Setup wizard ------------------------------- */
.setup { min-height: 100vh; background: var(--surface-0); }
.setup-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
.setup-side { background: var(--sidebar); color: var(--sidebar-ink); padding: 24px 22px; display: flex; flex-direction: column; }
.setup-side h2 { font-family: var(--display); font-weight: 500; font-size: 22px; color: var(--sidebar-ink-hi); margin: 18px 0 6px; }
.setup-steps { list-style: none; padding: 0; margin: 22px 0; display: flex; flex-direction: column; gap: 10px; }
.setup-steps li { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--sidebar-muted); }
.setup-steps li span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-family: var(--mono); font-size: 11px; border: 1px solid var(--sidebar-border-soft); }
.setup-steps li.is-current { color: var(--sidebar-ink-hi); font-weight: 600; }
.setup-steps li.is-current span { background: var(--good); color: var(--on-dark); border-color: var(--good); }
.setup-steps li.is-done { color: var(--sidebar-ink); }
.setup-steps li.is-done span { color: var(--good); border-color: var(--good); }
.setup-side .linklike-dark { margin-top: auto; color: var(--sidebar-ink); text-align: left; }
.setup-main { padding: 40px 48px; max-width: 860px; }
.setup-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 30px 34px; box-shadow: var(--shadow); }
.setup-card h1 { font-family: var(--display); font-weight: 500; font-size: 26px; margin: 0 0 6px; letter-spacing: -.015em; }
.setup-lede { color: var(--text-secondary); margin: 0 0 20px; line-height: 1.5; }
.setup-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.industry-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.industry-choice { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: 8px; cursor: pointer; background: var(--surface-1); font-size: 12.5px; }
.industry-choice input { position: absolute; opacity: 0; }
.industry-choice strong { font-size: 13.5px; }
.industry-choice span { color: var(--text-secondary); line-height: 1.4; }
.industry-choice:hover { border-color: var(--accent); }
.industry-choice.is-selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.setup-choice-row { margin-top: 8px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-0); }
.setup-accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px 24px; }
.setup-group h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); font-weight: 600; }
.setup-account { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; cursor: pointer; }
.setup-account span:first-of-type { flex: 1; }
.setup-account input { accent-color: var(--accent); width: 15px; height: 15px; }
.welcome-choice.is-selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.setup-next li { margin-bottom: 10px; }
@media (max-width: 860px) { .setup-shell { grid-template-columns: 1fr; } .setup-side { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px; } .setup-side h2, .setup-side p { display: none; } .setup-steps { margin: 0; flex-direction: row; gap: 8px; } .setup-steps li { font-size: 0; } .setup-steps li span { font-size: 11px; } .setup-main { padding: 16px; } .setup-card { padding: 20px; } }

/* ----------------------------- Onboarding ----------------------------- */
.help-row { margin-top: auto; padding: 6px 0 0; }
.integrity-footer { margin-top: 0; }
.nav-help { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; border-radius: 6px; background: none; color: var(--sidebar-ink); font-size: 13px; font-weight: 500; }
.nav-help:hover { background: var(--sidebar-soft); color: var(--sidebar-ink-hi); }
.nav-help svg { width: 16px; height: 16px; opacity: .75; }
.gs-list { list-style: none; margin: 0; padding: 0; }
.gs-list li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.gs-list li:last-child { border-bottom: 0; }
.gs-list .gs-text { flex: 1; min-width: 0; }
.gs-list .is-done { color: var(--text-muted); }
.gs-list .is-done strong { font-weight: 500; text-decoration: line-through; text-decoration-color: var(--border-strong); }
.gs-mark { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 22px; background: var(--surface-2); color: var(--text-secondary); font-family: var(--mono); font-size: 11px; border: 1px solid var(--border-strong); }
.is-done .gs-mark { background: var(--accent-soft); color: var(--good-ink); border-color: var(--accent-line); }
.welcome-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.welcome-choice { text-align: left; padding: 14px 16px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface-1); display: flex; flex-direction: column; gap: 6px; font-size: 13px; line-height: 1.45; }
.welcome-choice strong { font-family: var(--display); font-size: 16px; font-weight: 500; }
.welcome-choice span { color: var(--text-secondary); }
.welcome-choice:hover { border-color: var(--accent); background: var(--accent-soft); }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 28px; }
.help-grid h4 { margin: 0 0 8px; font-family: var(--display); font-size: 16px; font-weight: 500; }
kbd { font-family: var(--mono); font-size: 11px; background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px; }
@media (max-width: 760px) { .welcome-choices, .help-grid { grid-template-columns: 1fr; } .help-row { display: none; } }

/* ---------------------------- Attachments ---------------------------- */
.attachments { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.attachments-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.attachment-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 10px; }
.attachment { margin: 0; }
.attachment img, .attachment-doc { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); display: grid; place-items: center; font-weight: 600; color: var(--text-muted); }
.attachment figcaption { display: flex; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--text-secondary); margin-top: 4px; }
.attachment figcaption span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------- Time ------------------------------- */
.time-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 12px; align-items: start; }
@media (max-width: 980px) { .time-form { grid-template-columns: 1fr 1fr; } }

/* ------------------------------ Import ------------------------------ */
.file-pick { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.file-pick:last-of-type { border-bottom: 0; }
details summary { cursor: pointer; font-weight: 600; }

/* ------------------------------ Quick Add ------------------------------ */

/*
 * The inline "you typed something new — add it?" prompt. Renders directly
 * under the field that triggered it, never as a second modal — see the
 * note at the top of quick-add.js for why.
 */
.quick-add {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 6px 0 10px; padding: 8px 10px;
  background: var(--info-soft); border: 1px solid var(--info-line); border-radius: 6px;
  font-size: 12.5px;
}
.quick-add > span { color: var(--text-secondary); }
.quick-add label { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-secondary); }
.quick-add label select, .quick-add label input {
  padding: 3px 6px; border-radius: 5px; border: 1px solid var(--border-strong);
  background: var(--surface-1); font-size: 12.5px;
}
.quick-add-account { align-items: flex-end; }
.quick-add-error { flex-basis: 100%; color: var(--critical); font-size: 12px; }

@media (max-width: 430px) {
  .stats { grid-template-columns: 1fr; }
  .step { font-size: 12px; padding: 4px 8px 4px 5px; }
}

/* ============================================================================
   Ask — the assistant (decision 0023)

   A conversation, not a report, so this is the one screen that abandons the
   ledger's column grid. It keeps the paper and the green ink; what changes is
   that the reader's eye follows a thread down the page rather than across a
   row. The read-only notice is deliberately the first thing on it.
   ========================================================================= */

.ask { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }

.ask-notice {
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: var(--radius); padding: 11px 14px; color: var(--text-secondary);
}

.ask-transcript {
  min-height: 240px; max-height: 58vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  padding: 4px 2px;
}

.ask-empty { padding: 22px 2px; }
.ask-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.ask-turn { display: flex; }
.ask-you { justify-content: flex-end; }

/* The question, as the person asked it. */
.ask-bubble {
  background: var(--sidebar); color: var(--sidebar-ink-hi);
  padding: 9px 14px; border-radius: 14px 14px 3px 14px; max-width: 80%;
}

/* The answer sits on the page rather than in a bubble — it is the content. */
.ask-answer { max-width: 92%; }
.ask-answer p { margin: 0 0 10px; }
.ask-answer p:last-of-type { margin-bottom: 0; }
.ask-answer ul { margin: 0 0 10px; padding-left: 20px; }
.ask-answer li { margin-bottom: 4px; }

/* What it actually looked at, so an answer can be checked rather than trusted. */
.ask-tools {
  margin-top: 8px; padding-top: 7px;
  border-top: 1px solid var(--border);
}

.ask-composer { display: flex; gap: 10px; }
.ask-input {
  flex: 1; padding: 11px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface-1);
}
.ask-foot { margin: 0; }

@media (max-width: 640px) {
  .ask-transcript { max-height: none; }
  .ask-bubble, .ask-answer { max-width: 100%; }
}

/* ============================================================================
   Dashboard: the work queue and the trust panel

   Both are lists of statements about the business, so they share a shape: a
   mark, a line that says what, a quieter line that says why. The trust panel
   deliberately shows its unproved rows in the same list as its settled ones —
   hiding them behind a toggle would make the panel a boast instead of a report.
   ========================================================================= */

.worklist, .trust-list { list-style: none; margin: 0; padding: 0; }

.work-item, .trust-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.work-item:last-child, .trust-item:last-child { border-bottom: 0; }

.work-text, .trust-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.work-amount { font-family: var(--mono); font-weight: 500; white-space: nowrap; }

/* Overdue money gets the one red mark on the screen. */
.work-urgent { border-left: 3px solid var(--critical); }
.work-urgent .work-amount { color: var(--critical); }

/* The mark carries the verdict, so it must read at a glance and never rely on
   colour alone — hence a tick, a question mark and an exclamation. */
.trust-mark {
  flex: 0 0 22px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 600; line-height: 1;
}
.trust-ok   { background: var(--accent-soft); color: var(--accent); }
.trust-open { background: var(--surface-2); color: var(--text-secondary); }
.trust-bad  { background: var(--critical-tint); color: var(--critical); }

/* An unproved row is not a failure, and must not look like one. It is quieter
   than a settled row, not louder. */
.trust-unproved strong { color: var(--text-secondary); font-weight: 500; }
.trust-broken { background: var(--critical-tint); }

@media (max-width: 640px) {
  .work-item, .trust-item { align-items: flex-start; }
  .work-amount { align-self: center; }
}

/* ---- Receipt review: the paper beside the boxes ---- */
.receipt-review { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.receipt-image { position: sticky; top: 0; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px; }
.receipt-image img { width: 100%; border-radius: 4px; display: block; }
/* Under 900px the two columns would each be too narrow to read, so the
   photograph goes above the fields rather than beside them. */
@media (max-width: 900px) {
  .receipt-review { grid-template-columns: 1fr; }
  .receipt-image { position: static; max-height: 240px; overflow: hidden; }
}

/* ---- Dimension pickers on an entry line ---- */
.dim-cell { white-space: nowrap; }
.dim-cell select { max-width: 108px; font-size: 12px; padding: 4px 6px; }

/* ---- The Reports hub: the catalogue tiles ---- */
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 10px;
}
.report-tile {
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: flex-start;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-1);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.report-tile:hover {
  border-color: var(--border-hover);
  background: var(--surface-2);
}
.report-tile-name { font-weight: 600; }
.report-tile-note { font-size: 12px; color: var(--text-secondary); line-height: 1.35; }

/* Saved-report row buttons: keep them on one line, destructive one muted. */
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { margin-left: 4px; }
.btn-quiet { color: var(--text-secondary); }

/* ---- Printed report letterhead ----
   Invisible on screen: the app chrome already says which company and which
   report you are looking at. On paper the chrome is gone, and a statement
   that does not name the company, the period and the basis is not a
   document anybody can rely on. See src/ui/views/letterhead.js. */
#letterhead, #letterfoot { display: none; }

@media print {
  #letterhead, #letterfoot { display: block; }

  .letterhead {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    padding-bottom: 10px;
    margin-bottom: 18px;
    border-bottom: 1.5px solid var(--rule-ink, #1a1814);
  }
  .letterhead-top { display: flex; align-items: center; gap: 12px; }
  .letterhead-logo { max-height: 46px; max-width: 150px; }
  .letterhead-name { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
  .letterhead-contact { font-size: 10.5px; color: var(--text-secondary); margin-top: 2px; }
  .letterhead-what { text-align: right; }
  .letterhead-title { font-size: 15px; font-weight: 600; }
  .letterhead-period { font-size: 11.5px; color: var(--text-secondary); }
  /* The basis is the one line on a printed statement that changes what the
     numbers MEAN, so it is never allowed to be the quietest thing on it. */
  .letterhead-basis { font-size: 11.5px; font-weight: 600; margin-top: 1px; }

  .letterfoot {
    margin-top: 20px;
    padding-top: 8px;
    border-top: 1px solid var(--border, #e6e2d8);
    font-size: 10px;
    color: var(--text-secondary);
  }
  .letterfoot-note { font-style: italic; }
  .letterfoot-stamp { margin-top: 2px; }
  /* Whose mark closes the document — decisions 0038 and 0076. Discreet by
     design: the practice's mark, or our one line, never both. */
  .letterfoot-preparedby {
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .letterfoot-mark { max-height: 18px; max-width: 90px; }

  /* Toolbars are controls, not content — a date picker on paper is noise. */
  .toolbar, .row-actions, .report-tile { display: none !important; }
}
