/* ============================================================
   Agentic 5-Why RCA  |  design system
   ============================================================ */
:root {
  --accent: #0f6fb5;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 38%, transparent);

  --bg: #0d1117;
  --bg-2: #131a23;
  --panel: #161d27;
  --panel-2: #1c2532;
  --line: #263041;
  --line-soft: #1e2735;

  --text: #e8edf4;
  --text-2: #a3b1c4;
  --text-3: #8594aa; /* darker than it looks needed: verified >=4.5:1 against every dark surface via axe-core */

  /* --ok is darkened from the more vivid #2ea36b: the "done" step-dot puts a
     white checkmark directly on top of it, which needs its own contrast
     independent of theme, verified via axe-core. */
  --ok: #258356;
  --warn: #d99a2b;
  --bad: #d8543f;
  --crit: #c0392b;
  /* Text-color variants of the same four status colors: dark mode can use the
     original vivid tones directly as text on a dark background, but light
     mode cannot (as low as 2.4:1 on white, checked with axe-core) and needs
     darker variants defined in the light-mode block below. Never use --ok
     etc. directly as text color; use these instead. */
  --ok-text: #2ea36b;
  --warn-text: #d99a2b;
  --bad-text: #dd6a58;
  --crit-text: #db6c60;

  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.28);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9; --bg-2: #eaeef4; --panel: #ffffff; --panel-2: #f7f9fc;
    --line: #d8dfe9; --line-soft: #e6ebf2;
    --text: #16202e; --text-2: #4d5b6e; --text-3: #5a6779; /* verified >=4.5:1 against every light surface via axe-core */
    --shadow: 0 1px 2px rgba(16,32,56,.06), 0 8px 24px rgba(16,32,56,.08);
    /* Darker than --ok/--warn/--bad/--crit: those fail as small text on a
       light background (as low as 2.4:1), verified via axe-core. */
    --ok-text: #237f53;
    --warn-text: #92671a;
    --bad-text: #ca3f29;
    --crit-text: #c0392b;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

/* ---------------- accessibility utilities ---------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -50px; z-index: 100;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; text-decoration: none; transition: top .15s ease;
}
.skip-link:focus { top: 8px; }

/* A heading a view moves keyboard/screen-reader focus to when the screen
   changes (intake -> why -> report). Focused via script, not tabbed to, so
   browsers don't always draw a default ring here without help. */
.view-heading:focus { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
main:focus { outline: none; } /* the skip-link lands here; the view-heading inside gets the visible ring instead */

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--accent); }
  .skel { animation: none; }
  .rail, .rail-backdrop, .meter-fill, .btn, .sug { transition: none; }
}
body {
  margin: 0; font-family: var(--sans); background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { margin: 0; font-weight: 600; letter-spacing: -.011em; }
p { margin: 0 0 .7em; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------------- layout ---------------- */
.app { display: flex; flex-direction: column; min-height: 100%; }

.topbar {
  display: flex; align-items: center; gap: 16px; padding: 0 22px; height: 58px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40;
  overflow: hidden;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 auto;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #000));
  color: #fff; font-weight: 700; font-size: 13px; letter-spacing: -.02em;
}
.brand-text { min-width: 0; }
.brand-name { font-size: 14px; font-weight: 650; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11.5px; color: var(--text-3); line-height: 1.2; }
.topbar-spacer { flex: 1; }
.topbar-meta { display: flex; align-items: center; gap: 10px; }

.badge {
  font-size: 11px; font-family: var(--mono); padding: 3px 8px; border-radius: 20px;
  border: 1px solid var(--line); color: var(--text-2); background: var(--panel-2); white-space: nowrap;
}
.badge.live::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); margin-right: 6px; vertical-align: middle; }

.main { flex: 1; display: grid; grid-template-columns: 292px minmax(0,1fr); gap: 0; align-items: start; }

.rail {
  position: sticky; top: 58px; height: calc(100vh - 58px); overflow-y: auto;
  background: var(--bg-2); border-right: 1px solid var(--line); padding: 20px 18px 40px;
}
.stage { padding: 26px 30px 90px; max-width: 900px; width: 100%; }

.hamburger { display: none; }

@media (max-width: 940px) {
  /* The rail becomes an off-canvas drawer instead of stacking above the
     content: on a narrow screen nobody wants to scroll past the whole
     investigation nav before reaching the actual question. */
  /* minmax(0,1fr), not a bare 1fr: a plain 1fr track can't shrink below its
     content's min-content width, so a wide table would force the whole page
     wider instead of scrolling inside .table-wrap's own overflow-x. */
  .main { grid-template-columns: minmax(0,1fr); }

  .hamburger {
    display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
    width: 40px; height: 40px; padding: 0; margin-right: 2px; flex: 0 0 auto;
    background: transparent; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
    -webkit-appearance: none; appearance: none;
  }
  .hamburger span { display: block; height: 2px; width: 18px; background: var(--text-2); border-radius: 1px; }

  .rail {
    position: fixed; top: 0; left: 0; z-index: 60;
    height: 100vh; height: 100dvh; /* dvh accounts for Safari's collapsing address bar; 100vh is the fallback if a browser doesn't support dvh */
    width: min(300px, 84vw); border-right: 1px solid var(--line);
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 0 0 rgba(0,0,0,0); padding-top: 78px;
    -webkit-overflow-scrolling: touch;
  }
  .rail.open { transform: translateX(0); box-shadow: 8px 0 28px rgba(0,0,0,.25); }

  .rail-backdrop {
    display: none; position: fixed; inset: 0; z-index: 55;
    background: rgba(0,0,0,.4); opacity: 0; transition: opacity .22s ease;
  }
  .rail-backdrop.show { display: block; opacity: 1; }

  .stage { padding: 20px 18px 90px; }
}

@media (max-width: 480px) {
  /* At phone width there isn't room for the tagline, a CAPA badge and the
     tenant picker beside the brand without wrapping the header onto a
     second line and overflowing its fixed height. */
  .topbar { gap: 8px; padding: 0 12px; }
  .brand-sub { display: none; }
  .topbar-meta { gap: 6px; }
  #capaBadge { display: none; }
  /* font-size stays >=16px even here: anything smaller makes iOS Safari
     zoom the whole page in when the control is focused. Width comes down
     via max-width and tighter padding instead. */
  #tenantSelect { max-width: 128px; padding: 6px 22px 6px 8px !important; }
}

/* ---------------- rail ---------------- */
.rail-title { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); margin: 0 0 10px; }
.rail-section + .rail-section { margin-top: 26px; }

.steps { list-style: none; margin: 0; padding: 0; }
.step { display: flex; gap: 11px; padding: 7px 0; align-items: flex-start; }
.step-dot {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; border: 1.5px solid var(--line); color: var(--text-3); background: var(--panel);
}
.step.done .step-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.active .step-dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.step-body { min-width: 0; font-size: 12.5px; }
.step-label { color: var(--text-3); font-weight: 600; }
.step.active .step-label, .step.done .step-label { color: var(--text); }
.step-answer { color: var(--text-2); font-size: 12px; margin-top: 1px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
/* A real <button> nested inside the <li>, not role="button" on the <li>
   itself: overriding an <li>'s role breaks the <ol>'s list semantics for
   screen readers (confirmed with axe-core), so the interactive element has
   to be a separate child, not the list item. */
.step-btn {
  all: unset; display: flex; gap: 11px; align-items: flex-start; width: 100%;
  cursor: pointer; border-radius: 8px; margin: 0 -8px; padding: 7px 8px; box-sizing: border-box;
}
.step-btn:hover { background: var(--panel); }
.step-btn:focus-visible { background: var(--panel); outline: 2px solid var(--accent); outline-offset: 2px; }

.facts { font-size: 12.5px; }
.fact { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed var(--line-soft); }
.fact:last-child { border-bottom: 0; }
.fact dt { color: var(--text-3); flex: 0 0 auto; }
.fact dd { margin: 0; text-align: right; color: var(--text-2); min-width: 0; overflow-wrap: anywhere; }

/* ---------------- cards ---------------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 4px; }
.card-head h2 { font-size: 17px; }
.card-head h3 { font-size: 15px; }
.card-sub { color: var(--text-2); font-size: 13px; margin: 2px 0 16px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }

/* ---------------- forms ---------------- */
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--text-3); }
input[type=text], input[type=date], select, textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 11px; outline: none; transition: border-color .12s, box-shadow .12s;
  -webkit-appearance: none; appearance: none; font-size: 16px;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: right 14px center, right 9px center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel-2); cursor: pointer; font-size: 13.5px; font-weight: 550;
  transition: background .12s, border-color .12s, transform .06s;
  -webkit-appearance: none; appearance: none;
}
.btn:hover:not(:disabled) { border-color: var(--text-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, #fff); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.actions .spacer { flex: 1; }

/* ---------------- suggestions ---------------- */
.suggestions { display: grid; gap: 9px; margin: 4px 0 2px; }
.sug {
  display: grid; grid-template-columns: 20px minmax(0,1fr); gap: 11px; align-items: start;
  text-align: left; width: 100%; padding: 13px 15px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .12s, background .12s;
}
.sug:hover { border-color: var(--accent-line); background: color-mix(in srgb, var(--accent) 5%, var(--panel-2)); }
.sug.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.sug-radio { width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid var(--text-3); margin-top: 2px; display: grid; place-items: center; }
.sug.selected .sug-radio { border-color: var(--accent); }
.sug.selected .sug-radio::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.sug-label { display: block; font-size: 14px; line-height: 1.45; }
.sug-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.tag { font-size: 10.5px; font-weight: 650; letter-spacing: .03em; padding: 2px 7px; border-radius: 5px; border: 1px solid var(--line); color: var(--text-2); background: var(--panel); text-transform: uppercase; }
.tag.cat { border-color: var(--accent-line); color: var(--accent); }
.tag.conf-high { border-color: color-mix(in srgb, var(--ok) 45%, transparent); color: var(--ok-text); }
.tag.conf-medium { border-color: color-mix(in srgb, var(--warn) 45%, transparent); color: var(--warn-text); }
.tag.conf-low { border-color: var(--line); color: var(--text-3); }
.sug-evidence { display: block; font-size: 12px; color: var(--text-3); margin-top: 7px; }
.sug-evidence b { color: var(--text-2); font-weight: 600; }

.other-box { border: 1px dashed var(--line); border-radius: var(--radius); padding: 13px 15px; background: var(--panel-2); }
.other-box.active { border-style: solid; border-color: var(--accent); background: var(--accent-soft); }

/* ---------------- chain history ---------------- */
.chain-item { border-left: 2px solid var(--line); padding: 0 0 16px 18px; position: relative; }
.chain-item::before { content: ""; position: absolute; left: -5px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.chain-item:last-child { padding-bottom: 0; }
.chain-q { font-size: 12.5px; color: var(--text-3); }
.chain-a { font-size: 14px; margin-top: 2px; }
.chain-edit { font-size: 11.5px; color: var(--accent); background: none; border: 0; cursor: pointer; padding: 0; margin-top: 5px; }

/* ---------------- callouts ---------------- */
.callout { border-radius: var(--radius); padding: 12px 15px; font-size: 13px; border: 1px solid var(--line); background: var(--panel-2); margin-bottom: 14px; }
.callout.info { border-color: var(--accent-line); background: var(--accent-soft); }
.callout.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 9%, transparent); }
.callout.bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: color-mix(in srgb, var(--bad) 9%, transparent); }
.callout h4 { font-size: 12.5px; margin-bottom: 4px; }
.callout ul { margin: 6px 0 0; padding-left: 18px; }
.callout li { margin: 3px 0; }

/* ---------------- meters ---------------- */
.meter { display: flex; align-items: center; gap: 10px; }
.meter-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 3px; transition: width .5s ease; }
.meter-val { font-family: var(--mono); font-size: 12px; color: var(--text-2); flex: 0 0 auto; }

/* ---------------- report ---------------- */
.rc-hero { border: 1px solid var(--accent-line); background: linear-gradient(160deg, var(--accent-soft), transparent 70%); border-radius: var(--radius-lg); padding: 22px 24px; margin-bottom: 18px; }
.rc-hero .eyebrow { color: var(--accent); }
.rc-statement { font-size: 19px; line-height: 1.42; font-weight: 550; letter-spacing: -.012em; }
.pill-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.pill { font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel); color: var(--text-2); }
.pill.sev-low { color: var(--ok-text); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.sev-medium { color: var(--warn-text); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill.sev-high { color: var(--bad-text); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.pill.sev-critical { color: #fff; background: var(--crit); border-color: var(--crit); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); }
th, td { text-align: left; padding: 10px 13px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); background: var(--panel-2); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
td.num { font-family: var(--mono); white-space: nowrap; color: var(--text-2); }

.kv { display: grid; grid-template-columns: 145px minmax(0,1fr); gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-3); font-size: 12.5px; }
.kv dd { margin: 0; }

.bones { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(230px,1fr)); }
.bone { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--panel-2); }
.bone h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-bottom: 7px; }
.bone ul { margin: 0; padding-left: 17px; font-size: 13px; color: var(--text-2); }
.bone li { margin: 3px 0; }

ul.clean { margin: 0; padding-left: 18px; }
ul.clean li { margin: 5px 0; }

/* ---------------- loading ---------------- */
.thinking { display: flex; align-items: center; gap: 12px; padding: 20px 4px; color: var(--text-2); font-size: 13.5px; }
.spinner { width: 17px; height: 17px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; flex: 0 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { height: 54px; border-radius: var(--radius); background: linear-gradient(90deg, var(--panel-2) 25%, var(--line-soft) 50%, var(--panel-2) 75%); background-size: 220% 100%; animation: shim 1.3s infinite; margin-bottom: 9px; }
@keyframes shim { from { background-position: 120% 0; } to { background-position: -120% 0; } }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--bad);
  padding: 12px 18px; border-radius: var(--radius); box-shadow: var(--shadow); z-index: 90;
  font-size: 13.5px; max-width: min(560px, 92vw);
}
.toast.ok { border-left-color: var(--ok); }
.hidden { display: none !important; }

/* ---------------- print ---------------- */
@media print {
  :root { --bg:#fff; --panel:#fff; --panel-2:#fff; --line:#c3ccd8; --line-soft:#e2e7ee; --text:#000; --text-2:#333; --text-3:#666; --shadow:none; }
  body { font-size: 11pt; }
  .topbar, .rail, .no-print, .actions { display: none !important; }
  .main { display: block; }
  .stage { max-width: none; padding: 0; }
  /* Let tall cards flow across pages, but never split a row, callout or hero. */
  .card { box-shadow: none; border-color: #c3ccd8; break-inside: auto; }
  .rc-hero, .callout, .bone, .kv { break-inside: avoid; }
  tr, .chain-item { break-inside: avoid; }
  thead { display: table-header-group; }
  h2, h3 { break-after: avoid; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* ============================================================
   Admin console
   ============================================================ */

/* The console works with tables and side-by-side review columns, so it gets a
   wider stage than the investigator flow, which is a single column of reading. */
.stage.wide { max-width: 1240px; }

.page-head {
  display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap;
  margin: 0 0 20px;
}
.page-head > div:first-child { flex: 1 1 380px; min-width: 0; }
.page-head h2 { font-size: 21px; letter-spacing: -.015em; }
.page-head .card-sub { margin-bottom: 0; max-width: 76ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; flex: 0 0 auto; }

/* ---------------- console navigation ---------------- */
.navlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.navitem {
  display: flex; gap: 11px; align-items: flex-start; padding: 8px 10px;
  border-radius: 9px; text-decoration: none; color: inherit; border: 1px solid transparent;
}
.navitem:hover { background: var(--panel); }
.navitem:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.navitem.active { background: var(--accent-soft); border-color: var(--accent-line); }
.navicon {
  width: 22px; height: 22px; flex: 0 0 auto; display: grid; place-items: center;
  font-size: 13px; color: var(--text-3);
}
.navitem.active .navicon { color: var(--accent); }
.navtext { min-width: 0; display: block; }
.navlabel { display: block; font-size: 13px; font-weight: 600; }
.navitem.active .navlabel { color: var(--accent); }
.navhint { display: block; font-size: 11.5px; color: var(--text-3); line-height: 1.35; }

.rail-note { margin-top: 12px; font-size: 12px; }
.minirow {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 4px 0; border-bottom: 1px dashed var(--line-soft); color: var(--text-3);
}
.minirow:last-child { border-bottom: 0; }
.minirow span:last-child { color: var(--text-2); }

/* ---------------- stats ---------------- */
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-value { font-size: 22px; font-weight: 650; letter-spacing: -.02em; line-height: 1.1; }
.stat-label { font-size: 11.5px; color: var(--text-3); margin-top: 3px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat.ok .stat-value { color: var(--ok-text); }
.stat.warn .stat-value { color: var(--warn-text); }

/* ---------------- table cells ---------------- */
.cell-title { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.cell-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; overflow-wrap: anywhere; }
.cell-sub.warn-text { color: var(--warn-text); }
.cell-sub.bad-text { color: var(--bad-text); }
.mono { font-family: var(--mono); font-size: .93em; }
td.empty, .empty { text-align: center; color: var(--text-3); padding: 26px 12px; font-size: 13px; }
tr.muted { opacity: .55; }
tr.row-active { background: var(--accent-soft); }
.btn-row { display: flex; gap: 4px; flex-wrap: wrap; }
/* A table's action column is narrow and holds up to five buttons, so they run
   tighter than a button in a form does. */
.btn-row .btn.sm { padding: 5px 9px; font-size: 12px; }
.swatch { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; border: 1px solid rgba(128,128,128,.35); }

.meter.compact .meter-bar { height: 5px; }
.meter.compact .meter-val { font-size: 11px; }

.card.compact { padding: 14px 18px; }

/* ---------------- tags ---------------- */
.tag.ok { border-color: color-mix(in srgb, var(--ok) 45%, transparent); color: var(--ok-text); }
.tag.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); color: var(--warn-text); }
.tag.bad { border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad-text); }

.chiprow { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-block; font-family: var(--mono); font-size: 11px; padding: 3px 8px;
  border-radius: 6px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text-2);
}
.chip.clickable { cursor: pointer; }
.chip.clickable:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------------- buttons ---------------- */
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--bad) 86%, #fff); }
.btn.danger-text { color: var(--bad-text); }
.btn.danger-text:hover:not(:disabled) { border-color: var(--bad); }

/* ---------------- tabs ---------------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent; cursor: pointer;
  padding: 9px 13px; font-size: 13px; font-weight: 550; color: var(--text-3); margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px 4px 0 0; }

.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--text-3);
  margin: 24px 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--line-soft);
}

/* ---------------- wizard ---------------- */
.wizard {
  list-style: none; margin: 0 0 22px; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px;
}
.wstep { min-width: 0; }
.wstep-btn {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 11px 13px; border-top: 2px solid var(--line);
}
.wstep-btn:disabled { cursor: default; opacity: .55; }
.wstep-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wstep.active .wstep-btn { border-color: var(--accent-line); border-top-color: var(--accent); background: var(--accent-soft); }
.wstep.done .wstep-btn { border-top-color: var(--ok); }
.wstep-dot {
  width: 21px; height: 21px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; border: 1.5px solid var(--line); color: var(--text-3); background: var(--panel-2);
}
.wstep.active .wstep-dot { border-color: var(--accent); color: var(--accent); }
.wstep.done .wstep-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.wstep-text { min-width: 0; }
.wstep-label { display: block; font-size: 12.5px; font-weight: 600; }
.wstep-hint { display: block; font-size: 11px; color: var(--text-3); line-height: 1.3; }

/* ---------------- scanned page picker ---------------- */
.pagelist { display: grid; gap: 8px; margin: 6px 0 4px; }
.pageitem {
  display: grid; grid-template-columns: 20px minmax(0,1fr); gap: 11px; align-items: start;
  padding: 12px 14px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.pageitem:hover { border-color: var(--accent-line); }
.pageitem:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.pageitem:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.pageitem input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }
.pageitem-body { min-width: 0; }
.pageitem-title { display: block; font-size: 13.5px; font-weight: 600; }
.pageitem-url { display: block; font-size: 11px; color: var(--text-3); margin-top: 1px; overflow-wrap: anywhere; }
.pageitem-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.pageitem-preview {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 12px; color: var(--text-3); margin-top: 8px; line-height: 1.45;
}

/* ---------------- draft review ---------------- */
.review-block { padding: 16px 0; border-top: 1px solid var(--line-soft); }
.review-block:first-of-type { border-top: 0; }
.review-block h4 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--accent);
  margin-bottom: 9px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.review-block .count {
  font-family: var(--mono); font-size: 10.5px; color: var(--text-3);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 20px; padding: 1px 7px;
  text-transform: none; letter-spacing: 0;
}
.review-block p { font-size: 13.5px; color: var(--text-2); margin: 0; }
.review-block ul.clean, .review-block ol.clean { font-size: 13.5px; }
.review-block.empty-block h4 { color: var(--text-3); }
ol.clean.seq { padding-left: 22px; }
ol.clean.seq li::marker { font-family: var(--mono); font-size: 11px; color: var(--text-3); }

.checklist { margin: 6px 0 0; padding-left: 0; list-style: none; font-size: 13.5px; }
.checklist li { position: relative; padding: 5px 0 5px 26px; color: var(--text-2); }
.checklist li::before {
  content: ""; position: absolute; left: 4px; top: 11px;
  width: 10px; height: 10px; border: 1.5px solid var(--line); border-radius: 3px;
}

/* ---------------- connector types ---------------- */
/* Groups stack, and the cards inside each group flow across the full width.
   Laying the groups out as grid columns instead left a column of five database
   types beside a column of one file type, and a screen of empty space. */
.typegrid { display: grid; gap: 22px; }
.typegroup h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3);
  margin-bottom: 9px; padding-bottom: 6px; border-bottom: 1px solid var(--line-soft);
}
.typegroup { display: grid; }
.typegroup h4 { grid-column: 1 / -1; }
.typegroup {
  grid-template-columns: repeat(auto-fill, minmax(262px, 1fr));
  gap: 8px;
  align-items: start;
}
.typecard {
  display: flex; flex-direction: column; height: 100%; text-align: left; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px;
}
.typecard .typecard-tag { margin-top: auto; padding-top: 8px; }
.typecard:hover { border-color: var(--accent-line); background: color-mix(in srgb, var(--accent) 5%, var(--panel-2)); }
.typecard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.typecard-name { display: block; font-size: 13px; font-weight: 600; }
.typecard-desc { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 3px; line-height: 1.4; }
.typecard-tag { display: block; }

.req {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  color: var(--text-3); margin-left: 6px;
}

.inputrow { display: flex; gap: 8px; }
.inputrow input { flex: 1; min-width: 0; }
.colorrow { display: flex; gap: 8px; align-items: center; }
.colorrow input[type=color] {
  width: 44px; height: 38px; padding: 3px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel-2); cursor: pointer;
}
.colorrow input[type=text] { flex: 1; min-width: 0; }

.checkrow {
  display: flex; gap: 10px; align-items: flex-start; font-size: 13px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2);
  cursor: pointer;
}
.checkrow input { margin-top: 2px; width: 16px; height: 16px; flex: 0 0 auto; accent-color: var(--accent); }
.checkrow:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.checkrow .hint { font-size: 11.5px; }

input[type=password], input[type=number], input[type=file] {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 11px; outline: none; font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
input[type=file] { padding: 8px 10px; font-size: 13px; cursor: pointer; }
input[type=password]:focus, input[type=number]:focus, input[type=file]:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input[readonly] { color: var(--text-3); cursor: not-allowed; }

/* ---------------- disclosure ---------------- */
.disclosure {
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel);
  padding: 14px 20px; margin-bottom: 18px;
}
.disclosure > summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); list-style: none;
  display: flex; align-items: center; gap: 8px;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::before { content: "\25B8"; color: var(--text-3); transition: transform .15s; }
.disclosure[open] > summary::before { transform: rotate(90deg); }
.disclosure > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ---------------- retrieval hits ---------------- */
.hit {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 12px 14px; margin-top: 10px; background: var(--panel-2);
}
.hit-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 7px; }
.hit-title { font-size: 12.5px; font-weight: 650; }
.hit-body { font-size: 12.5px; color: var(--text-2); line-height: 1.5; white-space: pre-wrap; }

.doctext {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.55; white-space: pre-wrap;
  overflow-wrap: anywhere; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; max-height: 52vh; overflow-y: auto; margin: 0;
}

/* ---------------- modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.5);
  display: grid; place-items: center; padding: 20px; overflow-y: auto;
}
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 22px 24px; width: min(480px, 100%); max-height: 90vh; overflow-y: auto;
}
.modal.wide { width: min(920px, 100%); }
.modal h3 { font-size: 16px; }

code, .mono code { font-family: var(--mono); font-size: .92em; background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 4px; padding: 1px 5px; }

@media (max-width: 940px) {
  .page-head { flex-direction: column; gap: 12px; }
  .stage.wide { max-width: none; }
}
