/* web/public/style.css
 *
 * An accountant reads this for an hour at a time. Dense, quiet, high contrast,
 * numbers in a tabular font so columns line up. Colour is used for one thing
 * only — the evidence behind a row — so it never becomes decoration.
 *
 * RESTYLED 13 Sept to match the marketing site. The palette, type scale, radii
 * and spacing now come from /tokens.css, which both front ends link — see the
 * note at the top of that file. Nothing here was renamed: every selector is the
 * one it was, because `app.js` writes several of these class names into markup
 * it builds at runtime and a rename would fail silently in whichever screen was
 * not open at the time.
 *
 * What changed is the look. What did not change is the density: this is still a
 * working screen, not a landing page, so it keeps its own tighter type sizes
 * rather than inheriting the site's.
 */

/* ── the app's own reading of the shared tokens ──────────────────────────
 * Short aliases, because the rules below are dense and `var(--text-secondary)`
 * three times in one line is harder to read than `var(--ink-2)`. These are
 * pointers, not new values — the palette is still stated once, in tokens.css. */
:root {
  --bg:         var(--bg-page);
  --panel:      var(--bg-surface);
  --ink:        var(--text-primary);
  --ink-2:      var(--text-secondary);
  --ink-3:      var(--text-tertiary);
  --line:       var(--border-default);
  --line-2:     var(--border-subtle);
  --accent-ink: var(--text-inverse);
  --ok:         var(--success);
  --ok-bg:      var(--success-bg);
  --warn:       var(--warning);
  --warn-bg:    var(--warning-bg);
  --bad:        var(--danger);
  --bad-bg:     var(--danger-bg);
  --radius:     var(--radius-lg);
  --mono:       var(--font-mono);
}

/* Dark mode is the application's alone. The marketing site is light-only and
 * would break here — it carries hand-tinted badge backgrounds that assume a
 * light ground. These override the tokens themselves rather than the aliases
 * above, so every rule in this file follows without being restated.
 *
 * The hues are the same family desaturated and inverted, not a second palette:
 * the accent stays blue, the semantic three stay green/amber/red, and the
 * borders keep the same two-step relationship they have in the light theme. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-page:        #15171B;
    --bg-surface:     #1C1F25;
    --bg-muted:       #23272F;
    --text-primary:   #E9ECF1;
    --text-secondary: #9AA3B2;
    --text-tertiary:  #6F7888;
    --text-inverse:   #0D1017;
    --border-subtle:  #23272F;
    --border-default: #2C313A;
    --border-strong:  #3A4150;
    --accent:         #6D9BD1;
    --accent-hover:   #8AB0DE;
    --accent-muted:   #1E2833;
    --border-focus:   #6D9BD1;
    --success:        #5FD39B;  --success-bg: #13291F;
    --warning:        #E5AB55;  --warning-bg: #2C2415;
    --danger:         #FF8A80;  --danger-bg:  #2E1A19;
  }
  /* The PDF canvas is a white page whatever the theme — it is a photograph of
     paper. Give it a border that reads against the dark panel behind it. */
  #pdf { border-color: var(--border-strong); }
}

* { box-sizing: border-box; }

/* An explicit `display` beats the hidden attribute's UA default, and several
 * rules below set one (.screen, .btn). Without this the app renders all four
 * screens stacked on top of each other. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font: var(--font-regular) var(--text-sm)/var(--leading-normal) var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1 { font-size: var(--text-xl); font-weight: var(--font-medium); margin: 0 0 6px; letter-spacing: -0.02em; line-height: var(--leading-snug); }
h2 { font-size: var(--text-lg); font-weight: var(--font-medium); margin: 0 0 6px; letter-spacing: -0.015em; line-height: var(--leading-snug); }
p { margin: 0 0 var(--space-3); }
.muted { color: var(--ink-2); }
.small { font-size: var(--text-xs); }
.err { color: var(--bad); }
.centre-text { text-align: center; padding: var(--space-6); }

/* ── chrome ─────────────────────────────────────────────────────────────── */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-6); border-bottom: 1px solid var(--line);
  background: var(--bg); position: sticky; top: 0; z-index: 10;
}
/* The same lockup as the site nav — mark, then wordmark at 600 — so crossing
   from the homepage into the app does not look like arriving at a second
   company. It links to the public site; "New job" is how you get back to a
   blank upload screen. */
.brand { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--ink); text-decoration: none; }
.brand svg { display: block; color: var(--accent); }
.brand-word { font-size: var(--text-base); font-weight: 600; letter-spacing: -0.01em; }
.bar-right { display: flex; align-items: center; gap: var(--space-2); }

.btn {
  font-family: var(--font-sans); font-size: var(--text-sm); font-weight: var(--font-medium);
  line-height: var(--leading-snug); cursor: pointer;
  padding: var(--space-2) var(--space-4); min-height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: var(--panel); color: var(--ink);
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  /* inline-flex lets a two-word label break across lines when a flex parent
     squeezes it — "Run it" became "Run" over "it" in the estimate footer.
     Both of these are needed: one stops the text wrapping, the other stops
     the button being compressed into wanting to. */
  white-space: nowrap; flex-shrink: 0;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:hover { background: var(--bg-muted); border-color: var(--ink-3); }
.btn:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-lg { padding: var(--space-3) var(--space-5); font-size: var(--text-base); min-height: 44px; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--bg-muted); color: var(--ink); border-color: transparent; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:disabled:hover { background: var(--panel); border-color: var(--border-strong); }

.screen { display: block; }
.centre { max-width: 780px; margin: 0 auto; padding: var(--space-10) var(--space-5); }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--space-5);
}

/* ── upload ─────────────────────────────────────────────────────────────── */
.drop {
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  padding: var(--space-16) var(--space-6); text-align: center; background: var(--panel);
  transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-muted); }
.drop-icon { font-size: 32px; color: var(--ink-3); margin-bottom: var(--space-2); line-height: 1; }
.drop p { max-width: 42ch; margin: 0 auto var(--space-5); }

/* ── estimate ───────────────────────────────────────────────────────────── */
.stats { display: flex; gap: var(--space-6); margin: var(--space-4) 0 var(--space-3); flex-wrap: wrap; }
.stat-n { font-family: var(--mono); font-size: var(--text-xl); font-weight: var(--font-medium); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-l { color: var(--ink-2); font-size: var(--text-xs); }

.filetable { width: 100%; border-collapse: collapse; margin-bottom: var(--space-5); font-size: var(--text-xs); }
.filetable td { padding: var(--space-2) var(--space-2); border-bottom: 1px solid var(--line-2); }
.filetable td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }

/* WHICH COLUMN GETS THE SLACK DEPENDS ON THE TABLE, NOT ON BEING FIRST.
 *
 * Both screens use .filetable, and the rule here used to be
 * `td:first-child { width: 100% }` — right for one of them and wrong for the
 * other. On the estimate screen the first column IS the filename. On Your jobs
 * the first column is a date and the filenames are SECOND, so the date was
 * handed all the free width and the filenames were squeezed into wrapping over
 * three lines beside it.
 *
 * width: 100% on a table cell is a request, not an instruction: it asks for
 * everything left after the other columns have taken what they need. Exactly
 * one column per table should ask. */
#est-files td:first-child { width: 100%; }

#jobs-list td:nth-child(2) { width: 100%; }
/* Everything that is not the filename is a short, known value — a timestamp, a
   count, a state, a button. None of them should ever wrap to make room. */
#jobs-list td:first-child { white-space: nowrap; color: var(--ink-2); }
#jobs-list td:nth-child(n+3) { white-space: nowrap; }
.route { font-size: 10px; font-weight: var(--font-medium); letter-spacing: .04em; padding: 2px var(--space-2); border-radius: var(--radius-full); white-space: nowrap; border: 1px solid transparent; }
.route-text { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.route-vision { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }

.estimate-line {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-5);
  border-top: 1px solid var(--line); padding-top: var(--space-4);
}
.est-figure { font-family: var(--mono); font-size: var(--text-2xl); font-weight: var(--font-medium); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; line-height: 1.1; }

/* ── progress ───────────────────────────────────────────────────────────── */
.progress { height: 6px; border-radius: var(--radius-full); background: var(--bg-muted); overflow: hidden; margin: var(--space-4) 0 var(--space-2); }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }
.log {
  list-style: none; margin: var(--space-4) 0; padding: var(--space-3); max-height: 260px; overflow: auto;
  font-family: var(--mono); font-size: var(--text-xs); color: var(--ink-2);
  background: var(--bg-muted); border: 1px solid var(--line); border-radius: var(--radius-md);
}
.log li { padding: 1px 0; }
.log li.hi { color: var(--ink); }

/* ── review ─────────────────────────────────────────────────────────────── */
/* THE SPLIT, AND WHY THESE TWO NUMBERS GO TOGETHER.
 *
 * The row table is seven columns, six of them fixed widths that either fit or
 * clip. Name is the only elastic one, so it absorbs the entire shortfall — and
 * under `table-layout: fixed` a shortfall bigger than Name takes it to ZERO.
 * The supplier name simply vanishes, with no scrollbar and no other symptom.
 *
 * The fixed six total 642px. At the old 1.15fr the list pane only cleared that
 * at about 1290px, so a 1152px laptop lost the column outright and a 1280 one
 * had 29px of it — and raising the stacking breakpoint alone would not have
 * helped, because the pane was still too narrow on the side-by-side side of it.
 * The ratio was the cause; the breakpoint only decided where it stopped hurting.
 *
 * 1.5fr gives the list 60%, which clears 642 + a readable Name from 1251px up.
 * The breakpoint is set to meet it exactly: at 1250 and below the panes stack
 * and the table gets the full width instead.
 *
 * Stacking is the worse layout — a row beside the page it was read from is the
 * product — so the breakpoint is deliberately as LOW as the arithmetic allows.
 * 1280 and 1440 both keep the split. The document pane never falls below 500px. */
.review { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); height: calc(100vh - 61px); }
@media (max-width: 1250px) { .review { grid-template-columns: 1fr; height: auto; } }

.pane { min-width: 0; display: flex; flex-direction: column; }
.pane-list { border-right: 1px solid var(--line); }
.pane-doc { background: var(--panel); }

.filters { padding: var(--space-3); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--space-2); }
.tabs { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.tab {
  font-family: var(--font-sans); font-size: var(--text-xs); font-weight: var(--font-medium);
  cursor: pointer; padding: var(--space-1) var(--space-3); min-height: 28px;
  border-radius: var(--radius-full); border: 1px solid var(--line); background: var(--panel); color: var(--ink-2);
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.tab:hover { border-color: var(--border-strong); color: var(--ink); }
.tab .n { font-family: var(--mono); font-variant-numeric: tabular-nums; opacity: .75; margin-left: var(--space-1); }
.tab[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tab[aria-selected="true"]:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.search {
  font-family: var(--font-sans); font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: var(--panel); color: var(--ink); width: 100%;
}
.search:focus { outline: 2px solid var(--border-focus); outline-offset: -1px; border-color: var(--accent); }

.tablewrap { overflow: auto; flex: 1; }
/* Fixed layout, or the Name column collapses to fit the widest Reference and
 * every description wraps to six lines. An accountant scans this list top to
 * bottom; row height is the difference between seeing twelve rows and four. */
/* min-width is the backstop the arithmetic above should never need: 642px of
 * fixed columns plus 96px of Name. If some width we did not think of squeezes
 * the pane below that, `.tablewrap` scrolls sideways and every column keeps
 * its head. A scrollbar is a bad outcome; a column silently disappearing is a
 * worse one, and it is the one that happens without this line. */
.rows { width: 100%; min-width: 738px; border-collapse: collapse; font-size: var(--text-xs); table-layout: fixed; }
/* 100px, not the 86 this was when the column was set in the system font.
   JetBrains Mono is a wider face per character, and 86px turned
   "03/04/2026" into "03/04/2..." — on the one column this product makes
   a selling point of reading correctly. */
.rows col.c-date { width: 100px; }
/* 104px fits "WR-2026-118" with room to spare; the 14px saved goes to Name. */
.rows col.c-ref { width: 104px; }
.rows col.c-money { width: 96px; }
/* Wide enough for the longest label checksPill() can produce — "no figures
   to check" at 19 characters. These four pills are the product's whole
   claim; a clipped "does not bala…" is the one truncation this table must
   never show. */
.rows col.c-checks { width: 150px; }
.rows th {
  position: sticky; top: 0; background: var(--bg); text-align: left;
  padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line);
  font-weight: var(--font-medium); font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); cursor: pointer; white-space: nowrap;
}
.rows th:hover { color: var(--ink); }
.rows th.num, .rows td.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.rows td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line-2); vertical-align: top; color: var(--ink-2); }
.rows td { overflow: hidden; text-overflow: ellipsis; }
.rows td.num { color: var(--ink); }
.rows tr { cursor: pointer; }
.rows tr:hover td { background: var(--bg-muted); }
.rows tr[aria-selected="true"] td { background: var(--accent-muted); }
.cell-name {
  color: var(--ink); font-weight: var(--font-medium);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
/* One line. The full text is in the document pane and in the workbook; here it
 * exists to tell two rows from the same supplier apart, not to be read. */
.cell-desc {
  color: var(--ink-3); font-size: 11px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mono { font-family: var(--mono); font-size: 11px; }

.pill { font-size: 10px; font-weight: var(--font-medium); letter-spacing: .04em; padding: 2px var(--space-2); border-radius: var(--radius-full); white-space: nowrap; display: inline-block; border: 1px solid transparent; }
.pill-ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.pill-warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.pill-bad { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 22%, transparent); }

/* ── document pane ──────────────────────────────────────────────────────── */
.doc-empty { display: grid; place-items: center; height: 100%; padding: var(--space-8); text-align: center; }
#doc-view { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.doc-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line);
}
.doc-title { font-weight: var(--font-medium); }
.pager { display: flex; align-items: center; gap: var(--space-1); white-space: nowrap; }
.pager .btn { min-height: 28px; padding: var(--space-1) var(--space-3); }
.checks { padding: var(--space-3) var(--space-4) 0; }
.flags { padding: var(--space-2) var(--space-4) 0; display: flex; gap: var(--space-1); flex-wrap: wrap; }
.flag {
  font-family: var(--mono); font-size: 11px; padding: 2px var(--space-2);
  border-radius: var(--radius-sm); background: var(--bg-muted); color: var(--ink-2);
}
.flag.bad { background: var(--bad-bg); color: var(--bad); }
.notes {
  margin: var(--space-3) var(--space-4) 0; padding: var(--space-3);
  font-size: var(--text-xs); line-height: var(--leading-relaxed);
  background: var(--warn-bg); color: var(--warn);
  border-left: 2px solid var(--warn); border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.canvaswrap { flex: 1; overflow: auto; padding: var(--space-4); min-height: 0; }
#pdf { width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius-md); background: #fff; }

/* Sign-in — the same quiet box as the drop zone, so the first screen someone
   ever sees already looks like the app rather than a different product. */
.signin-form {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--space-4);
}
.signin-form .search { min-width: 16rem; width: auto; }

/* What the Xero CSV leaves out. Deliberately quiet — it is a statement of fact
   about a secondary download, not an error — but always visible, never hidden
   behind a hover. */
.csv-omits { font-size: var(--text-xs); color: var(--ink-2); line-height: var(--leading-normal); border-top: 1px solid var(--line); padding-top: var(--space-2); }
.csv-omits b { color: var(--ink); font-weight: var(--font-medium); }
.csv-omits ul { margin: var(--space-1) 0 0; padding-left: var(--space-4); }
.csv-omits li { margin: 1px 0; }
.csv-omits .refs { color: var(--ink-3); }
.csv-omits .unconfirmed { margin-top: var(--space-2); }
