:root {
  --bg: #0f1623; --panel: #161f30; --panel-2: #1d2840; --line: #2a3650;
  --text: #e8edf6; --muted: #93a1bd; --accent: #4f8cff; --accent-2: #3a6fd8;
  --good: #34d399; --warn: #fbbf24; --bad: #f87171;
  --radius: 14px; --shadow: 0 10px 30px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; color: var(--text); line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 70% -10%, #1b2740 0%, var(--bg) 55%);
}
.app { max-width: 920px; margin: 0 auto; padding: 28px 20px 60px; }
.masthead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 12px; }
/* The masthead brand is a link back to the landing page now; it must not pick
   up the default link colour or underline. */
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; }
a.brand:hover .logo { filter: brightness(1.12); }
/* An <a> styled as one of the app's buttons (the Admin link, "back to app"). */
.btn-link { display: inline-flex; align-items: center; text-decoration: none; }
.logo { font-size: 26px; width: 48px; height: 48px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #7c3aed); border-radius: 12px; box-shadow: var(--shadow); }
h1 { font-size: 20px; margin: 0; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.badge { background: var(--panel-2); border: 1px solid var(--line); color: var(--good);
  padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }

.howto { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 12px 14px; margin: 0 0 16px; }
.howto-h { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.howto ol { margin: 0; padding-left: 18px; }
.howto li { font-size: 13px; color: var(--muted); line-height: 1.7; }

.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 38px 20px; text-align: center;
  cursor: pointer; transition: border-color .15s, background .15s; background: var(--panel-2); }
.dropzone:hover, .dropzone:focus { border-color: var(--accent); outline: none; }
.dropzone.drag { border-color: var(--accent); background: #1a2540; }
.dz-icon { font-size: 30px; } .dz-text { margin: 10px 0 6px; font-size: 15px; }
.dz-hint { color: var(--muted); font-size: 13px; }
.dz-cam { margin-top: 14px; }

/* Queued page photos: order matters for a multi-page statement, so each row can
   be moved or dropped. */
.scan-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.scan-item { display: flex; align-items: center; gap: 10px; background: var(--panel-2);
  border: 1px solid var(--line); padding: 7px 12px; border-radius: 9px; font-size: 13px; }
.scan-n { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--bg);
  border: 1px solid var(--line); color: var(--muted); font-size: 11.5px; display: grid; place-items: center; }
.scan-name { flex: 1; word-break: break-all; }
.scan-acts { flex: none; display: flex; gap: 2px; }
.scan-acts .link { padding: 2px 6px; font-size: 14px; line-height: 1; }
.scan-acts .link[disabled] { color: var(--line); cursor: default; }

.file-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; background: var(--panel-2);
  border: 1px solid var(--line); padding: 10px 14px; border-radius: 10px; }
.file-name { font-weight: 600; word-break: break-all; }
.link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; }

.bank-pick { display: grid; grid-template-columns: auto minmax(180px, 1fr); gap: 8px 12px; align-items: center; margin-top: 16px; }
.bank-pick label { font-size: 13px; color: var(--muted); font-weight: 600; }
.bank-pick select { background: var(--bg); border: 1px solid var(--line); color: var(--text);
  padding: 9px 11px; border-radius: 9px; font-size: 14px; width: 100%; }
.bank-pick select:focus { outline: none; border-color: var(--accent); }
.bank-hint { grid-column: 2; color: var(--muted); font-size: 12.5px; }

button.primary { display: inline-block; width: 100%; margin-top: 18px; text-align: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none;
  padding: 13px 18px; border-radius: 11px; font-size: 15px; font-weight: 700; cursor: pointer; }
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: .5; cursor: not-allowed; }
.downloads { display: flex; gap: 10px; }
.downloads .primary, .ghost { width: auto; margin-top: 0; }
.ghost { display: inline-block; border: 1px solid var(--line); color: var(--text); background: var(--bg);
  padding: 11px 16px; border-radius: 11px; font-weight: 600; cursor: pointer; font-size: 14px; }
.ghost:hover { border-color: var(--accent); }

.status { display: flex; align-items: center; gap: 14px; justify-content: center; padding: 22px; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--line);
  border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-text { color: var(--muted); }

.summary-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.summary-head h2 { margin: 0; font-size: 17px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kv { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.kv .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.kv .v { font-size: 17px; font-weight: 700; margin-top: 4px; word-break: break-word; }
.kv .v.good { color: var(--good); } .kv .v.bad { color: var(--bad); }

.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { background: var(--panel-2); color: var(--muted); position: sticky; top: 0; font-weight: 600; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.desc { white-space: normal; min-width: 240px; }
.neg { color: var(--bad); } .pos { color: var(--good); }
.muted { color: var(--muted); font-size: 13px; }

.banner { border-radius: 11px; padding: 12px 15px; margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.banner.warn { background: rgba(251,191,36,.1); border-color: rgba(251,191,36,.4); color: #fde68a; }
.banner.info { background: rgba(79,140,255,.1); border-color: rgba(79,140,255,.4); color: #bcd3ff; }
/* Reserved for the one claim the document itself backs: its printed totals
   agree with what we read. Distinct from info so it doesn't read as chatter. */
.banner.ok { background: rgba(52,211,153,.1); border-color: rgba(52,211,153,.4); color: #a7f3d0; }
/* Dashboard */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.card-h { margin: 0 0 14px; font-size: 15px; }
.bars, .months { display: flex; flex-direction: column; gap: 8px; }
.bar-row, .month-row { display: grid; grid-template-columns: 120px 1fr auto; align-items: center; gap: 10px; }
.bar-label { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--bg); border-radius: 6px; height: 12px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 6px; }
.bar-fill.out { background: linear-gradient(90deg, #f87171, #ef4444); }
.bar-fill.in { background: linear-gradient(90deg, #34d399, #10b981); }
.bar-val { font-size: 12.5px; font-variant-numeric: tabular-nums; min-width: 90px; text-align: right; }
.month-bars { display: flex; flex-direction: column; gap: 3px; }
table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tag { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.conf-pill { padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.conf-hi { background: rgba(52,211,153,.15); color: var(--good); }
.conf-mid { background: rgba(251,191,36,.15); color: var(--warn); }
.conf-lo { background: rgba(248,113,113,.15); color: var(--bad); }
tr.flagged td { background: rgba(251,191,36,.08); }
/* A single cell the OCR wasn't sure about — dotted underline so it reads as
   "check this value" rather than "this row failed". */
td.ocr-low { background: rgba(248,113,113,.10); box-shadow: inset 0 -2px 0 rgba(248,113,113,.55);
  cursor: help; }
.preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.preview-head h2 { margin: 0; font-size: 17px; }
.filters { display: flex; gap: 8px; }
.filters input, .filters select { background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: 7px 10px; border-radius: 8px; font-size: 13px; }
.filters input:focus, .filters select:focus { outline: none; border-color: var(--accent); }
/* Affordability panel */
.score-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.score-badge { flex: none; width: 74px; height: 74px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 27px; font-weight: 800; color: #fff; }
.score-badge span { font-size: 12px; font-weight: 600; opacity: .85; }
.score-meta { display: flex; flex-direction: column; gap: 3px; font-size: 13.5px; }
.score-badge.good { background: var(--good); }
.score-badge.ok { background: var(--accent); }
.score-badge.warn { background: var(--warn); color: #1a1300; }
.score-badge.bad { background: var(--bad); }
.af-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.af-stat { background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.af-k { color: var(--muted); font-size: 11.5px; }
.af-v { font-weight: 700; font-size: 14px; margin-top: 2px; }
.af-factors { display: flex; flex-direction: column; gap: 8px; }
.af-factor { display: grid; grid-template-columns: 42px 1fr; gap: 1px 10px; align-items: center; }
.af-impact { grid-row: 1 / span 2; align-self: center; text-align: center; font-weight: 800; border-radius: 7px; padding: 4px 0; font-size: 13px; }
.af-impact.pos { color: var(--good); background: rgba(52,211,153,.12); }
.af-impact.neg { color: var(--bad); background: rgba(248,113,113,.12); }
.af-flabel { grid-column: 2; grid-row: 1; font-weight: 600; font-size: 13px; }
.af-fdetail { grid-column: 2; grid-row: 2; color: var(--muted); font-size: 12.5px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } .bar-row, .month-row { grid-template-columns: 90px 1fr auto; } }

.foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 26px; }

/* ============ Tabs & masthead ============ */
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tab { background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  padding: 10px 16px; border-radius: 11px; font-size: 14px; font-weight: 600; cursor: pointer; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-color: var(--accent); background: var(--panel-2); }
/* Admin sub-navigation. The admin page carries five unrelated jobs — accounts,
   telemetry, parser triage, the specimen generator, invites — and stacking them
   all open made a wall nobody could scan. Grouped into three panes, one at a
   time. Quieter than the main tabs so the hierarchy reads correctly. */
.subtabs { display: flex; gap: 6px; margin: 0 0 16px; flex-wrap: wrap; }
.subtab { background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: 7px 13px; border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer; }
.subtab:hover { color: var(--text); }
.subtab.active { color: var(--text); border-color: var(--accent); background: var(--panel); }
/* How many people are waiting for access — the one number worth seeing from
   whichever pane you happen to be on. Hidden at zero. */
.tabcount { display: inline-block; min-width: 18px; margin-left: 5px; padding: 1px 6px;
  border-radius: 999px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; }

.mast-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.badge.plan { color: var(--accent); }
.pw-note { margin-top: 8px; text-align: center; font-size: 12px; }

/* ============ PDF toolkit ============ */
.howto-p { margin: 0; font-size: 13px; color: var(--muted); }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tool-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  cursor: pointer; text-align: left; transition: border-color .15s, transform .15s; color: var(--text); font: inherit; }
.tool-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.tool-card.active { border-color: var(--accent); }
.tool-icon { font-size: 22px; }
.tool-name { font-weight: 700; font-size: 14px; margin: 6px 0 2px; }
.tool-desc { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.tool-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.tool-head h2 { margin: 0; font-size: 17px; }
.dropzone.small { padding: 22px 16px; }
.tfile-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.tfile { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 10px; font-size: 13px; }
.tfile .nm { flex: 1; word-break: break-all; }
.tfile button { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px;
  cursor: pointer; padding: 2px 7px; font-size: 12px; }
.tfile button:hover { color: var(--text); border-color: var(--accent); }
.tool-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 14px; }
.tool-opts .wide { grid-column: 1 / -1; }
.opt { display: flex; flex-direction: column; gap: 4px; }
.opt label { font-size: 12px; color: var(--muted); font-weight: 600; }
.opt input, .opt select { background: var(--bg); border: 1px solid var(--line); color: var(--text);
  padding: 8px 10px; border-radius: 8px; font-size: 13.5px; width: 100%; }
.opt input:focus, .opt select:focus { outline: none; border-color: var(--accent); }
.progress { height: 8px; background: var(--bg); border-radius: 6px; overflow: hidden; margin-top: 14px; }
.progress > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #7c3aed); transition: width .2s; }
.tool-status { color: var(--muted); font-size: 13px; margin-top: 8px; }

/* ---- page-thumbnail preview grid ---- */
.thumb-hint { margin: 12px 0 0; }
.thumb-hint.bad { color: var(--bad); }
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px; margin-top: 14px; max-height: 520px; overflow-y: auto; padding: 2px; }
.thumb-grid:empty { display: none; }
.thumb { position: relative; border: 2px solid var(--line); border-radius: 8px; background: var(--panel-2);
  padding: 6px; display: flex; align-items: center; justify-content: center; min-height: 96px; }
.thumb-canvas { display: flex; align-items: center; justify-content: center; width: 100%; }
.thumb-canvas canvas { max-width: 100%; height: auto; box-shadow: 0 1px 4px rgba(0,0,0,.4); border-radius: 2px;
  transition: transform .2s; background: #fff; }
.thumb-badge { position: absolute; top: 3px; left: 3px; background: rgba(15,22,35,.85); color: var(--text);
  font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px; }
.thumb-tag { position: absolute; bottom: 3px; right: 3px; font-size: 10px; font-weight: 700; color: #fff;
  padding: 1px 6px; border-radius: 999px; background: hsl(var(--thumb-hue), 65%, 45%); }
.thumb-tagged { border-color: hsl(var(--thumb-hue), 65%, 50%); }
.thumb-dim { opacity: .4; }
/* rotate tool: click-to-select pages */
.thumb-grid.clickable .thumb { cursor: pointer; }
.thumb-grid.clickable .thumb:hover { border-color: var(--accent); }
.thumb.thumb-sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* ============ Authenticity check ============ */
.auth-verdict { margin-left: 8px; padding: 3px 10px; border-radius: 999px; font-size: 12px; vertical-align: 1px; }
.auth-verdict.good { background: rgba(52,211,153,.15); color: var(--good); }
.auth-verdict.warn { background: rgba(251,191,36,.15); color: var(--warn); }
.auth-verdict.bad { background: rgba(248,113,113,.15); color: var(--bad); }
.auth-check { display: grid; grid-template-columns: 24px 1fr; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.auth-check:last-of-type { border-bottom: none; }
.auth-check .lab { font-weight: 600; }
.auth-check .det { grid-column: 2; color: var(--muted); font-size: 12.5px; }

/* ============ Column editor ============ */
.editor-canvas-wrap { max-height: 440px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
#editorCanvas { display: block; }
.editor-fields { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.efield { display: flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 8px; }
.efield .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.efield select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  font-size: 12.5px; padding: 4px 6px; }
.editor-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.editor-actions .primary { width: auto; margin: 0 0 0 auto; }
.ghost.small { padding: 7px 10px; font-size: 12.5px; }

/* ============ Layout match ============ */
.cands { margin-top: 10px; }
.cands summary { cursor: pointer; font-size: 13px; }
.cands table { margin-top: 8px; }

/* ============ Auth & admin ============ */
.auth-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.auth-mail { color: var(--muted); font-size: 12.5px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge.warn-badge { color: var(--warn); }
.badge.bad-badge { color: var(--bad); }
table.users { border-collapse: collapse; width: 100%; font-size: 13px; }
table.users th, table.users td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.users th { background: var(--panel-2); color: var(--muted); font-weight: 600; }
table.users td.desc { white-space: normal; word-break: break-all; min-width: 160px; }
/* The access queue's free-text column holds real sentences, so it wraps on
   words rather than mid-word like td.desc (which exists for long emails). */
table.users td.ctx { white-space: normal; word-break: normal; min-width: 220px; max-width: 420px; }
.uchip { padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--panel-2); color: var(--muted); }
.uchip.good { background: rgba(52,211,153,.15); color: var(--good); }
.uchip.warn { background: rgba(251,191,36,.15); color: var(--warn); }
.uchip.bad { background: rgba(248,113,113,.15); color: var(--bad); }
.uchip.admin { background: rgba(79,140,255,.15); color: var(--accent); }
.uactions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.uactions button, .uactions select { background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 7px; padding: 4px 9px; font-size: 12px; cursor: pointer; }
.uactions button:hover, .uactions select:hover { border-color: var(--accent); }
.uactions button.danger { color: var(--bad); }
.uactions button.danger:hover { border-color: var(--bad); }
.invite-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.invite-row input, .invite-row select { background: var(--bg); border: 1px solid var(--line); color: var(--text);
  padding: 9px 11px; border-radius: 9px; font-size: 13.5px; }
.invite-row input { flex: 1; min-width: 200px; }
.invite-row .primary { width: auto; margin: 0; }

/* ============ Modal ============ */
.modal-back { position: fixed; inset: 0; background: rgba(5,10,20,.7); display: flex; align-items: center;
  justify-content: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px;
  max-width: 420px; width: 92%; box-shadow: var(--shadow); }
.modal.modal-wide { max-width: 860px; max-height: 88vh; overflow-y: auto; }
.modal h3 { margin: 0 0 8px; }
.modal input { width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  padding: 10px 12px; border-radius: 9px; font-size: 14px; margin-top: 10px; }
.modal input:focus { outline: none; border-color: var(--accent); }
.modal-btns { display: flex; gap: 10px; margin-top: 14px; }
.modal-btns .primary { margin-top: 0; width: auto; flex: 1; }
.small { font-size: 12px; }

/* ===========================================================================
   Admin dashboard — the Overview pane and the analytics shared with Insights.
   Scoped to classes only admin.html uses, so the converter's UI is untouched.
   Loaded alongside admin-analytics.js, which generates all of this markup.
   =========================================================================== */

.muted.sub { font-size: 13px; margin: 4px 0 0; line-height: 1.5; }
.card-h + .sub { margin-top: -8px; margin-bottom: 14px; }

/* The subnav reads as navigation, not as a row of buttons. */
.subtabs { gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.subtab {
  border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  padding: 11px 16px; margin-bottom: -1px; font-size: 13.5px; font-weight: 600;
  color: var(--muted); background: transparent;
}
.subtab:hover { color: var(--text); background: rgba(255,255,255,.02); }
.subtab.active { color: var(--text); border-bottom-color: var(--accent); background: transparent; }

/* ---- KPI row ---- */
/* Three across, two rows — six tiles in an auto-fit grid orphan two of them
   on a half-empty second row at most desktop widths. */
.kpis {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; margin-bottom: 22px;
}
/* One hairline grid rather than six floating boxes: fewer edges, and the
   numbers line up as a row the eye can scan. */
.kpi { background: var(--panel); padding: 15px 16px; }
.kpi-l { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.kpi-v { font-size: 25px; font-weight: 700; line-height: 1.25; margin-top: 7px; letter-spacing: -0.02em;
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kpi-v small { font-size: 14px; font-weight: 600; color: var(--muted); }
.kpi-v.good { color: var(--good); } .kpi-v.bad { color: var(--bad); }
.kpi-s { color: var(--muted); font-size: 12px; margin-top: 5px; }
.kpi-s .bad { color: var(--bad); font-weight: 600; }
.kpi-d { font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; letter-spacing: 0; }
.kpi-d.up { background: rgba(52,211,153,.14); color: var(--good); }
.kpi-d.down { background: rgba(248,113,113,.14); color: var(--bad); }
.kpi-d.flat { background: var(--panel-2); color: var(--muted); }

.rangebtn {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: 6px 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.rangebtn:hover { color: var(--text); border-color: var(--accent); }
.rangebtn.active { background: var(--panel-2); color: var(--text); border-color: var(--accent); }

/* ---- daily chart (inline SVG, no library) ---- */
.chart-head { display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: 10px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.chart-head b { color: var(--text); font-size: 15px; }
.chart-key { display: flex; gap: 16px; font-size: 12px; }
.chart-key span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.sw.ok { background: var(--accent); } .sw.bad { background: var(--warn); }
/* A fixed height with a stretched viewBox: bars keep their proportions to each
   other without the SVG rescaling the whole chart as the pane resizes. */
.chart-svg { width: 100%; height: 150px; display: block; }
.bar-ok { fill: var(--accent); }
.bar-bad { fill: var(--warn); }
.bar-0 { fill: var(--line); }
.chart-svg g:hover .bar-ok { fill: #6ea2ff; }
.chart-x { display: flex; justify-content: space-between; color: var(--muted);
  font-size: 11.5px; margin-top: 8px; }

/* ---- funnel ---- */
.funnel { display: flex; flex-direction: column; gap: 16px; }
.fbar { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.fbar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #7c3aed); border-radius: 999px; }
.fmeta { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; margin-top: 7px; font-size: 13px; }
.fmeta b { font-size: 17px; font-weight: 700; }
.flab { color: var(--text); font-weight: 600; }
.fpct { color: var(--accent); font-size: 12px; font-weight: 600; }
.fnote { color: var(--muted); font-size: 12px; margin-left: auto; }

/* ---- health strip ---- */
.hstrip { display: flex; flex-direction: column; gap: 11px; }
.hrow { display: grid; grid-template-columns: 1fr 90px 42px; align-items: center; gap: 12px; font-size: 13px; }
.hl { color: var(--muted); }
.hbar { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.hbar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.hbar i.good { background: var(--good); } .hbar i.warn { background: var(--warn); } .hbar i.bad { background: var(--bad); }
.hn { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.hn.good { color: var(--good); } .hn.warn { color: var(--warn); } .hn.bad { color: var(--bad); }

/* ---- ranked list ---- */
table.rank { width: 100%; border-collapse: collapse; font-size: 13px; }
table.rank td { padding: 7px 0; vertical-align: middle; }
/* The label and its caption stack: inline, a long email plus "6,983 rows"
   truncates every row and the list stops being readable. */
.rk-l { max-width: 0; width: 52%; overflow: hidden; }
.rk-l > * { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-l .link { font-size: 13px; padding: 0; text-align: left; width: 100%; }
.rk-s { color: var(--muted); font-size: 11px; margin-top: 1px; }
.rk-b { padding-left: 12px !important; }
.rk-b i { display: block; height: 6px; border-radius: 999px; background: var(--accent); opacity: .75; min-width: 2px; }
.rk-n { text-align: right; font-weight: 700; padding-left: 12px !important;
  font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi-v { font-size: 21px; }
  .fnote { margin-left: 0; width: 100%; }
  .hrow { grid-template-columns: 1fr 60px 38px; }
  .subtabs { overflow-x: auto; flex-wrap: nowrap; }
  .subtab { white-space: nowrap; }
}
/* Eight stats in an auto-fit grid leave an orphan row; four across is two
   even rows. */
.summary-grid.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .summary-grid.g4 { grid-template-columns: repeat(2, 1fr); } }
/* Explicit column counts: auto-fit orphans the last tiles whenever the item
   count doesn't divide by what happens to fit. */
.kpis.n4 { grid-template-columns: repeat(4, 1fr); }
.kpis.n5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) { .kpis.n4, .kpis.n5 { grid-template-columns: repeat(2, 1fr); } }

/* ===================== Batch tab (batch.js) ===================== */
.bq-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.bq-bar .primary { margin-top: 0; width: auto; }

.bq-progress { margin-top: 14px; }
.bq-track { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.bq-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #7c3aed);
  border-radius: 999px; transition: width .3s ease; }
.bq-progress .status-text { margin-top: 8px; }

.bq-doc { border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; margin-bottom: 10px;
  background: var(--panel-2); }
/* The row being converted is the only one worth highlighting; the rest stay
   quiet so a queue of twenty doesn't read as twenty alerts. */
.bq-doc.running { border-color: var(--accent); }
.bq-doc.failed, .bq-doc.empty { border-color: rgba(248,113,113,.45); }
.bq-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bq-n { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--bg);
  border: 1px solid var(--line); color: var(--muted); font-size: 11.5px; display: grid; place-items: center; }
.bq-name { flex: 1 1 180px; min-width: 120px; background: var(--bg); border: 1px solid var(--line);
  color: var(--text); border-radius: 8px; padding: 6px 9px; font-size: 13px; font-family: inherit; }
.bq-name:focus { outline: none; border-color: var(--accent); }
.bq-acts { margin-left: auto; display: flex; gap: 10px; }
.bq-detail { margin-top: 8px; font-size: 12.5px; }
.bq-ok { color: var(--good); }
.bq-err { color: var(--bad); }
.bq-photos { list-style: none; margin: 10px 0 0; padding: 0 0 0 30px; display: flex;
  flex-direction: column; gap: 5px; }
.bq-photos li { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); }
.bq-photos .scan-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bq-photos .scan-acts { display: flex; gap: 8px; }

@media (max-width: 620px) {
  .bq-acts { margin-left: 0; width: 100%; }
  .bq-photos { padding-left: 0; }
}
/* Six tiles: three across is two even rows (auto-fit orphans the last one). */
.summary-grid.g3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 760px) { .summary-grid.g3 { grid-template-columns: repeat(2, 1fr); } }
