:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #16202e;
  --muted: #64748b;
  --line: #dfe3e9;
  --accent: #1f5f8b;
  --accent-soft: #e8f1f8;
  --ok: #157347;
  --warn: #b45309;
  --suggest: #fff8e1;
  --suggest-line: #f0c860;
  --radius: 8px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 12px; align-items: center; }
.mark {
  width: 38px; height: 38px; border-radius: 8px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 20px;
}
h1 { margin: 0; font-size: 18px; letter-spacing: .2px; }
h2 { margin: 0; font-size: 15px; }
h3 { margin: 0; font-size: 15px; }
h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.batch { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.batch label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.batch input { font-size: 14px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
.batch input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.folder { display: flex; flex-direction: column; gap: 4px; }
.folder .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.folder code { font-family: var(--mono); font-size: 11.5px; background: var(--accent-soft); color: #14405e; padding: 6px 9px; border-radius: 6px; max-width: 520px; overflow-wrap: anywhere; }

/* ---------- panel ---------- */
main { padding: 18px 22px 40px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.actions { display: flex; gap: 8px; }

.btn {
  font: inherit; font-size: 13px; padding: 6px 13px;
  border: 1px solid var(--accent); border-radius: 6px;
  background: var(--accent); color: #fff; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: #fff; color: var(--accent); }
.btn.mini { padding: 4px 9px; font-size: 12px; }
.btn.save { background: var(--ok); border-color: var(--ok); }
.btn.link { background: none; border: none; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- grid ---------- */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 1180px; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: middle; }
thead th { background: #f8fafc; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; white-space: nowrap; }
thead th span { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 10.5px; }
tbody tr.suggested { background: var(--suggest); box-shadow: inset 3px 0 0 var(--suggest-line); }
tbody tr.saved { background: #f6fbf7; box-shadow: inset 3px 0 0 var(--ok); }
tbody tr.busy { opacity: .6; }

td input, td select {
  font: inherit; width: 100%; padding: 5px 6px;
  border: 1px solid transparent; border-radius: 5px;
  background: rgba(255,255,255,.75); color: var(--ink);
}
td input:hover, td select:hover { border-color: var(--line); }
td input:focus, td select:focus { outline: none; border-color: var(--accent); background: #fff; }
td input.num { text-align: right; font-family: var(--mono); font-size: 13px; }
td.readonly { text-align: right; font-family: var(--mono); font-weight: 600; }

/* A setting that is present but unusable - louder than "not configured",
   because nothing will work and nothing is obviously missing. */
.bad { color: #b42318; font-weight: 600; }

/* Head office handed this statement back; the reason sits above the grid. */
.returned-note {
  margin: 0 0 12px;
  background: #fdf0e2; border: 1px solid var(--suggest-line);
  border-left: 4px solid var(--warn);
  border-radius: var(--radius); padding: 12px 14px; font-size: 13px;
}
.returned-note strong { color: var(--warn); }
.returned-note .sub { display: block; margin-top: 4px; }

/* Remarks on one line, and the line they belong to. */
tr.flagged td { background: #fffaf2; }
tr.note-row td { background: #fffaf2; border-top: 0; padding-top: 0; }
.line-notes { display: grid; gap: 4px; padding: 2px 0 6px 6px; }
.line-note {
  font-size: 12px; color: var(--warn);
  border-left: 3px solid var(--suggest-line); padding-left: 8px;
}

/* The number a claim is tracked by. */
.docket {
  font-family: var(--mono); font-weight: 700; color: var(--accent);
  background: var(--accent-soft); padding: 1px 6px; border-radius: 5px;
}
.pill.returned { background: #fdf0e2; color: var(--warn); }

.c-date { width: 116px; } .c-vendor { width: 150px; } .c-desc { min-width: 210px; }
.c-acct { width: 190px; } .c-class { width: 130px; } .c-tax { width: 175px; } .c-num { width: 104px; text-align: right; }
.c-rcpt { width: 128px; } .c-save { width: 78px; } .c-cur { width: 82px; }
th.c-num, td.c-num { text-align: right; }
.total { color: var(--accent); }

/* The CAD translation of a foreign line: same columns, visibly subordinate to
   the line it belongs to rather than reading as a second expense. */
tr.fx-row td {
  background: #f6f9fc;
  border-top: 0;
  padding-top: 2px; padding-bottom: 6px;
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}
tr.fx-row td.c-num { text-align: right; }
tr.fx-row td.total { color: var(--accent); font-weight: 600; }
tr.fx-row .fx-label {
  font-family: inherit; font-size: 11px; text-transform: none;
  letter-spacing: .2px; color: var(--muted); text-align: right; padding-right: 10px;
}
tr.fx-row .fx-rate { white-space: nowrap; }
tr.fx-row .fx-rate input.rate { width: 84px; font-size: 12px; }
tr.fx-row .fx-note { display: block; font-family: inherit; font-size: 11px; color: #b45309; }

tfoot td { background: #f8fafc; font-family: var(--mono); font-weight: 600; border-top: 2px solid var(--line); }
tfoot .foot-label { font-family: inherit; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; color: var(--muted); }

.rcpt { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.rcpt .name { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; max-width: 120px; }

.hint { padding: 10px 16px; margin: 0; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }
.hint.small { border: none; padding: 10px 0 0; }

/* ---------- viewer ---------- */
.viewer { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: grid; place-items: center; padding: 24px; z-index: 50; }
/* `display: grid` above outranks the browser's [hidden] rule - restate it. */
.viewer[hidden] { display: none; }
.viewer-box { background: var(--panel); border-radius: 10px; width: min(1180px, 100%); height: min(88vh, 900px); display: flex; flex-direction: column; overflow: hidden; }
.viewer-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.viewer-body { flex: 1; display: grid; grid-template-columns: 1fr 340px; min-height: 0; }
.viewer-doc { background: #1e293b; display: grid; place-items: center; overflow: auto; padding: 12px; }
.viewer-doc img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; }
.viewer-doc iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-side { border-left: 1px solid var(--line); padding: 14px 16px; overflow: auto; }

.fields { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.fields dt { color: var(--muted); }
.fields dd { margin: 0; font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.notes { margin-top: 12px; font-size: 12.5px; color: var(--warn); }
.badge { display: inline-block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; padding: 2px 7px; border-radius: 99px; background: var(--accent-soft); color: #14405e; }
.badge.low { background: #fdecec; color: #9b1c1c; }
.badge.medium { background: #fef4e2; color: #92400e; }
.badge.high { background: #e6f5ec; color: #14683c; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #16202e; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; z-index: 80; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 70vw;
}
.toast.err { background: #9b1c1c; }

/* ---------- login / register ---------- */
body.gate { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 26px 28px; width: min(420px, 100%);
  box-shadow: 0 10px 40px rgba(15,23,42,.07);
}
.card-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.card h2 { margin: 0 0 16px; font-size: 16px; }
.card form { display: flex; flex-direction: column; gap: 14px; }
.card label { display: flex; flex-direction: column; gap: 5px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.card input { font-size: 14px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); }
.card input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.card .note { text-transform: none; letter-spacing: 0; font-size: 11.5px; color: var(--muted); }
.btn.wide { width: 100%; padding: 10px; font-size: 14px; margin-top: 4px; }
.alt { margin: 18px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.alt a, .card a { color: var(--accent); }
.err { margin: 14px 0 0; padding: 9px 11px; border-radius: 7px; background: #fdecec; color: #9b1c1c; font-size: 13px; }

/* ---------- welcome banner ---------- */
.welcome {
  margin: 14px 22px 0; padding: 13px 18px; border-radius: 8px;
  background: linear-gradient(90deg, var(--accent-soft), #fff);
  border: 1px solid #cfe0ee; color: #14405e; font-size: 15px;
}

/* Sign-in lands on an empty grid; this says what is already in the statement. */
.existing {
  margin: 10px 22px 0; padding: 9px 14px; border-radius: 8px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #f8fafc; border: 1px solid var(--line);
  color: var(--muted); font-size: 12.5px;
}
.existing strong { color: var(--ink); }
.existing .btn.link { font-size: 12.5px; }

/* ---------- nav / status ---------- */
.nav { display: flex; align-items: center; gap: 10px; }
.who { font-size: 13px; color: var(--muted); }
.btn.submit { background: var(--ok); border-color: var(--ok); }
.pill {
  display: inline-block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 9px; border-radius: 99px; vertical-align: middle; margin-left: 8px;
  background: #eef2f7; color: #475569; font-weight: 600;
}
.pill.submitted { background: #e6f5ec; color: #14683c; }
.pill.draft { background: #fef4e2; color: #92400e; }
.pill.under_process { background: #e8f1f8; color: #14405e; }
.pill.paid { background: #157347; color: #fff; }

.c-pick { width: 34px; text-align: center; }

/* status journey on a statement */
.step { color: var(--muted); font-size: 12px; }
.step.done { color: var(--ink); font-weight: 600; }
.step em { font-style: normal; color: var(--muted); font-weight: 400; }
.arrow { color: var(--line); margin: 0 8px; }
.ref {
  display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 99px;
  background: var(--accent-soft); color: #14405e; font-family: var(--mono); font-size: 11px;
}
.ref.pay { background: #e6f5ec; color: #14683c; }
.refs { white-space: nowrap; }
table.editable tr.paidline { background: #f3f7f4; color: var(--muted); }
table.editable tr.paidline input, table.editable tr.paidline select { background: transparent; }

/* ---------- carry on with the phone ---------- */
/* Sized to its contents rather than to the screen: the receipt viewer fills
   the window because a receipt needs the room, and a QR code does not. */
.viewer-box.phone-box { width: min(660px, 100%); height: auto; max-height: 88vh; }
.phone-body { display: grid; grid-template-columns: auto 1fr; gap: 20px; padding: 18px; overflow: auto; }
.phone-qr {
  width: 232px; height: 232px;
  display: grid; place-items: center;
  /* Read off the screen by a camera, so it keeps its own white quiet zone
     whatever the panel behind it is doing. */
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px;
}
.phone-qr svg { width: 100%; height: 100%; display: block; }
.phone-side { min-width: 0; }
.phone-steps { margin: 0 0 12px; padding-left: 20px; font-size: 13px; display: grid; gap: 6px; }
.phone-url { font-size: 11px; overflow-wrap: anywhere; }
.phone-live {
  margin: 12px 0 0; padding: 9px 11px; border-radius: 6px;
  background: var(--accent-soft); color: #14405e; font-size: 12.5px;
}
@media (max-width: 620px) {
  .phone-body { grid-template-columns: 1fr; justify-items: center; }
}

/* ---------- history ---------- */
table.history tbody tr.clickable { cursor: pointer; }
table.history tbody tr.clickable:hover { background: var(--accent-soft); }
td.empty { text-align: center; color: var(--muted); padding: 26px; }
.viewer-box.wide { width: min(1280px, 100%); }
.viewer-body.detail { grid-template-columns: 1fr; overflow: auto; }
.detail-main { padding: 16px 18px; }
table.mini { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 900px; }
table.mini th { background: #f8fafc; color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; text-align: left; padding: 6px 8px; }
table.mini td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.mini tr.foot td { font-weight: 700; background: #f8fafc; border-top: 2px solid var(--line); }
table.mini a { color: var(--accent); }

.audit { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.audit-row { display: grid; grid-template-columns: 170px 1fr; gap: 12px; padding: 8px 10px; background: #f8fafc; border-radius: 6px; }
.audit-when { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }
.tag { display: inline-block; font-family: var(--mono); font-size: 11px; background: #e2e8f0; color: #334155; padding: 1px 7px; border-radius: 4px; margin-right: 6px; }
.chg { margin-top: 4px; font-size: 12px; color: var(--muted); }
.chg span:first-child { display: inline-block; min-width: 120px; color: var(--ink); }
.chg .from { color: #9b1c1c; text-decoration: line-through; }
.chg .to { color: #157347; }

/* ---------- admin ---------- */
.tabs { display: flex; gap: 4px; padding: 0 22px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tab {
  font: inherit; font-size: 13px; padding: 10px 14px; cursor: pointer;
  background: none; border: none; border-bottom: 2px solid transparent; color: var(--muted);
}
.tab:hover { color: var(--ink); }
.tab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab .count { background: #9b1c1c; color: #fff; border-radius: 99px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.tab .count:empty { display: none; }

.stack { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.card-row {
  display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 16px; align-items: center;
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: #fff;
}
.card-row.col { display: block; }
.card-row .between { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.companies .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 4px; }
.chks { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; white-space: nowrap; }
.chk input { accent-color: var(--accent); }
.inline-input { font: inherit; font-size: 13px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; }
.qboname { display: flex; flex-direction: column; gap: 3px; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.qboname input { width: 150px; font-size: 12.5px; padding: 4px 8px; text-transform: none; letter-spacing: 0; }
.src { font-family: var(--mono); font-size: 11.5px; }
.src.qbo { color: var(--ok); font-weight: 600; }
.chart { margin-top: 12px; }
.chart textarea {
  width: 100%; font-family: var(--mono); font-size: 12.5px; padding: 10px;
  border: 1px solid var(--line); border-radius: 6px; resize: vertical;
}
.chart .row-actions { margin-top: 8px; }
/* every invoice in the statement, side by side */
.invoice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.invoice { margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.invoice-doc { height: 210px; background: #1e293b; display: grid; place-items: center; overflow: hidden; }
.invoice-doc img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; }
.invoice-doc iframe { width: 100%; height: 100%; border: 0; background: #fff; pointer-events: none; }
.invoice figcaption { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; font-size: 12px; }
.invoice figcaption .sub { font-size: 11px; overflow-wrap: anywhere; }
.invoice .amt { font-family: var(--mono); color: var(--accent); font-weight: 600; }
.invoice .unmatched { color: var(--warn); font-weight: 400; }
.invoice .row-actions { margin-top: 4px; }

/* editable admin line grid */
table.editable td { padding: 3px 5px; }
table.editable input, table.editable select {
  font: inherit; font-size: 12.5px; width: 100%; padding: 4px 6px;
  border: 1px solid transparent; border-radius: 5px; background: #f8fafc;
}
table.editable input:hover, table.editable select:hover { border-color: var(--line); }
table.editable input:focus, table.editable select:focus { outline: none; border-color: var(--accent); background: #fff; }
table.editable input.num { text-align: right; font-family: var(--mono); }
table.editable tr.dirty { background: var(--suggest); }
table.editable .c-num { width: 92px; }

.files { display: flex; flex-direction: column; gap: 6px; }
.file-row { display: flex; align-items: center; gap: 12px; font-size: 12.5px; padding: 6px 8px; background: #f8fafc; border-radius: 6px; }
.file-row a { color: var(--accent); overflow-wrap: anywhere; }
.done h3 { margin: 0 0 8px; font-size: 15px; color: var(--ok); }
.done p { margin: 0 0 8px; font-size: 13px; }

@media (max-width: 900px) {
  .card-row { grid-template-columns: 1fr; }
  .viewer-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .viewer-side { border-left: none; border-top: 1px solid var(--line); max-height: 40%; }
}

/* --- Access map + creating an account ------------------------------------ */
/* Destructive actions read as destructive. Ghost keeps them visually quieter
   than the primary action next to them; the colour is what stops a reflex
   click on "Delete" when "Approve" was meant. */
.btn.danger { color: var(--bad, #c0392b); border-color: var(--bad, #c0392b); }
.btn.danger:hover { background: var(--bad, #c0392b); color: #fff; }
.btn.link.danger { border: none; background: none; }

.newuser { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 6px; }
.newuser input { flex: 1 1 190px; min-width: 0; }
.newuser-apps { padding: 4px 16px 0; }
.newuser-apps .lbl { font-size: 12px; color: var(--muted); margin-bottom: 4px; }

/* One tick per application per person, so the columns need to stay narrow
   enough that the whole grid is readable without scrolling sideways. */
#accessTable th { white-space: normal; }
#accessTable td input[type=checkbox] { transform: scale(1.15); }

/* Company boxes inside the access map. One per line and width-capped so a long
   company list stacks in its own column instead of stretching the whole grid.
   text-align is set explicitly: the cell inherits the centring used by the tick
   columns either side, which leaves these labels ragged down the left. */
/* Company boxes inside the access map. The base .chk is inline-flex and nowrap,
   which is right in the Users table where the column is wide; here the column is
   narrow, so the only overrides needed are a width for the cell and permission
   for a long company name to wrap instead of running into "Lands on". */
#accessTable td.companycol, #accessTable th.companycol { width: 300px; }
#accessTable .chks.narrow { flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; }

/* ================================================================== */
/* Credit Card Expense Tracker                                        */
/* ================================================================== */

/* ---------- the ticker: what is still to match ---------- */
.ticker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}
.tick { background: var(--panel); padding: 11px 14px; }
.tick .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.tick .v { font-size: 20px; font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums; }
.tick .s { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tick.warn { background: #fff9f0; }
.tick.warn .v { color: var(--warn); }
.tick.bad { background: #fdf2f2; }
.tick.bad .v { color: #9b1c1c; }
.tick.good .v { color: var(--ok); }

/* ---------- the statement header ---------- */
.stmt-head {
  display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-end;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.stmt-head .fld { display: flex; flex-direction: column; gap: 4px; }
.stmt-head .fld > span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.stmt-head input {
  font: inherit; font-size: 13.5px; padding: 5px 8px; width: 128px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stmt-head input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.stmt-head input.num { text-align: right; }

/* The tie-out. Green when it foots, red when it does not - there is no
   in-between state worth a third colour. */
.footing {
  padding: 10px 16px; font-size: 12.5px; border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
  font-variant-numeric: tabular-nums;
}
.footing.ok { background: #f2fbf5; color: #14683c; }
.footing.off { background: #fdf2f2; color: #9b1c1c; }
.footing strong { font-weight: 600; }

/* ---------- the line table ---------- */
table.cc { min-width: 1280px; }
table.cc tbody tr { cursor: pointer; }
table.cc tbody tr:hover { background: var(--accent-soft); }
table.cc td.num, table.cc th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.cc td.desc { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.cc tr.credit td.num.amt { color: var(--ok); }
table.cc tr.open { box-shadow: inset 3px 0 0 var(--accent); }
table.cc tr.row-unmatched { background: #fdf2f2; }
table.cc tr.row-partial { background: #fff9f0; }
table.cc tr.row-matched, table.cc tr.row-auto { background: #f8fbf9; }
table.cc tr.row-no_doc { background: #fffdf3; }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.tag.matched { background: #e6f5ec; color: #14683c; }
.tag.auto { background: #eef2f7; color: #445; }
.tag.no_doc { background: #fef4e2; color: #92400e; }
.tag.partial { background: #fdf0e2; color: var(--warn); }
.tag.unmatched { background: #fdecec; color: #9b1c1c; }

/* The no-document ticker on a line: a mark you can see down a column. */
.nodoc-flag { color: var(--warn); font-weight: 700; letter-spacing: .5px; }
.doc-count { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.doc-count.has { color: var(--ok); font-weight: 600; }

/* ---------- the line drawer ---------- */
.drawer-grid { display: grid; grid-template-columns: 1fr 420px; min-height: 0; height: 100%; }
.drawer-doc { background: #1e293b; display: grid; place-items: center; overflow: auto; padding: 12px; }
.drawer-doc img { max-width: 100%; max-height: 100%; object-fit: contain; background: #fff; }
.drawer-doc iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.drawer-doc .empty { color: #94a3b8; font-size: 13px; text-align: center; padding: 24px; max-width: 360px; }
.drawer-side { border-left: 1px solid var(--line); padding: 14px 16px 24px; overflow: auto; display: grid; gap: 14px; align-content: start; }

.factbox { background: #f8fafc; border: 1px solid var(--line); border-radius: 7px; padding: 10px 12px; }
.factbox .amt { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }
.factbox .amt.credit { color: var(--ok); }
.factbox .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.field input, .field select, .field textarea {
  font: inherit; font-size: 13.5px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink);
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:disabled, .field select:disabled, .field textarea:disabled {
  background: #f1f5f9; color: #94a3b8; cursor: not-allowed;
}
.field.disabled > span { color: #b0bac6; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.docrow {
  display: flex; gap: 8px; align-items: center; justify-content: space-between;
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 6px;
  font-size: 12.5px;
}
.docrow.active { border-color: var(--accent); background: var(--accent-soft); }
.docrow .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docrow .amt { font-variant-numeric: tabular-nums; white-space: nowrap; }

.variance { font-size: 12.5px; color: var(--warn); }
.variance.ok { color: var(--ok); }

.toggle { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 7px; background: #fffdf3; }
.toggle input { margin-top: 2px; }
.toggle .why { font-size: 11.5px; color: var(--muted); display: block; margin-top: 2px; }

.thread { display: grid; gap: 7px; }
.remark { border-left: 3px solid var(--line); padding: 4px 0 4px 9px; font-size: 12.5px; }
.remark.reviewer { border-left-color: var(--warn); }
.remark .who { color: var(--muted); font-size: 11px; }

/* ---------- setup ---------- */
.setup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.stack { display: grid; gap: 11px; padding: 14px 16px; }
.masked { font-family: var(--mono); letter-spacing: 1px; }
.muted-note { font-size: 12px; color: var(--muted); }

/* ---------- history and admin lists ---------- */
.list-row {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
  padding: 11px 16px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.list-row:hover { background: var(--accent-soft); }
.list-row .ttl { font-weight: 600; }
.list-row .sub2 { font-size: 12px; color: var(--muted); margin-top: 2px; }
.list-row .rt { text-align: right; font-variant-numeric: tabular-nums; }

.jrnl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.jrnl th, .jrnl td { border-bottom: 1px solid var(--line); padding: 5px 8px; }
.jrnl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.jrnl tr.total td { font-weight: 600; border-top: 2px solid var(--ink); }

/* The two statuses this app adds. "under_process" and "paid" belong to the
   Expense Logger's flow and are left in place — a shared stylesheet that
   quietly drops a class is worse than one carrying two it does not use. */
.pill.approved { background: #e8f1f8; color: #14405e; }
.pill.posted { background: #157347; color: #fff; }

/* A second line under a heading, wherever one is needed — the statement list
   had it first, the match tables want the same thing. */
.sub2 { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- which statement am I looking at ---------- */
/* The question the screen used to leave unanswered. Everything that identifies
   a statement is in one block above the figures, not spread through a title
   bar, a folder chip and a status pill three panels apart. */
.stmt-id {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.stmt-id-main {
  display: flex; flex-wrap: wrap; gap: 18px;
  justify-content: space-between; align-items: flex-start;
  padding: 14px 16px 12px;
}
.stmt-id-card { font-size: 19px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.stmt-id-period { font-size: 14px; color: var(--ink); margin-top: 2px; }
.stmt-id-meta { font-size: 12px; color: var(--muted); margin-top: 5px; }
.stmt-id-figures { display: flex; gap: 26px; }
.stmt-id-figures .k { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.stmt-id-figures .v { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stmt-id-foot {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center;
  padding: 8px 16px; border-top: 1px solid var(--line); background: #f8fafc;
  border-radius: 0 0 var(--radius) var(--radius);
}
.stmt-id-foot code { font-family: var(--mono); font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.stmt-id-foot span { display: flex; gap: 14px; white-space: nowrap; }

/* ---------- navigation ---------- */
/* Which page you are on, and how much is waiting on the ones you are not. */
.btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
  pointer-events: none;
}
.count {
  display: inline-block; min-width: 17px; padding: 0 5px; margin-left: 4px;
  border-radius: 999px; background: var(--accent-soft); color: #14405e;
  font-size: 11px; font-weight: 700; text-align: center;
}
.btn.active .count { background: rgba(255,255,255,.25); color: #fff; }

/* The statement picker carries a whole sentence, so it needs the room. */
select.wide-select { min-width: 330px; max-width: 460px; }
.batch select {
  font-size: 14px; padding: 6px 9px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; color: var(--ink);
}
.batch select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* ---------- logging an expense: the drop zone ---------- */
/* This is the whole purpose of the Expenses screen, so it is the first thing
   on the page and it is sized to be the obvious target rather than a file
   input tucked under a label. */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 10px;
  background: #fbfcfd;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.over {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
}
.dropzone.busy { cursor: progress; border-style: solid; border-color: var(--accent); }
.dropzone.disabled { opacity: .5; pointer-events: none; }
.dz-icon { font-size: 30px; line-height: 1; color: var(--accent); margin-bottom: 8px; }
.dz-main { font-size: 15px; }
.dz-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.dz-busy {
  margin-top: 12px; font-size: 13px; color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* Sent to a panel by a button elsewhere on the page: say which one, briefly.
   Scrolling to a panel that looks like every other panel does not tell you
   where you have been sent. */
@keyframes panel-flash {
  0%   { box-shadow: 0 0 0 0 rgba(31,95,139,.55); }
  100% { box-shadow: 0 0 0 12px rgba(31,95,139,0); }
}
.panel.flash {
  border-color: var(--accent);
  animation: panel-flash 1.4s ease-out;
}

/* The top-bar button sits on the baseline with the pickers beside it. */
.batch > .btn { margin-bottom: 1px; }

/* ---------- the read is not to be trusted ---------- */
/* Loud on purpose. A statement read by the fallback parser looks finished —
   it has lines, totals and a status — and the only thing wrong with it is that
   a third of it is missing. That has to be visible above the numbers, not
   inferable from them. */
.read-alarm {
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
  background: #fdf2f2;
  border: 1px solid #f0c2c2;
  border-left: 4px solid #9b1c1c;
  border-radius: var(--radius);
  padding: 13px 16px;
  margin-bottom: 16px;
}
.read-alarm h3 { margin: 0 0 6px; font-size: 15px; color: #9b1c1c; }
.read-alarm ul { margin: 0; padding-left: 18px; font-size: 13px; }
.read-alarm li { margin-bottom: 4px; }
.read-alarm li + li { margin-top: 4px; }
.read-alarm p { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.read-alarm code { font-family: var(--mono); font-size: 12px; }
.ra-body { flex: 1; min-width: 340px; }
.ra-act .btn { background: #9b1c1c; border-color: #9b1c1c; white-space: nowrap; }

/* ---------- choosing and removing lines ---------- */
th.c-pick, td.c-pick { width: 30px; text-align: center; padding-left: 10px; }
td.c-pick input { cursor: pointer; }
table.cc tbody tr:has(.pick:checked) { background: #fff4f4; box-shadow: inset 3px 0 0 #9b1c1c; }

.btn.danger { color: #9b1c1c; border-color: #e6b3b3; }
.btn.danger:hover { background: #fdf2f2; }
.btn.link.danger-link { color: #9b1c1c; }

/* ---------- somebody else's statement ---------- */
/* An administrator correcting a claimant's statement must never be able to
   forget whose it is. */
.stmt-id.theirs { border-left-color: var(--warn); }
.stmt-id-theirs {
  background: #fff8ec;
  border-bottom: 1px solid #f0dcb8;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 9px 16px;
  font-size: 12.5px;
  color: #7a4a06;
}
.stmt-id-theirs a { color: var(--accent); margin-left: 8px; }
