/* FIX Log Desk - one stylesheet, both themes, no external fonts. */

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel2: #1c2330;
  --ink: #e6edf3;
  --ink-dim: #9aa7b4;
  --line: #2a3441;
  --accent: #4c9aff;
  --accent-ink: #08131f;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --crit: #ff7b72;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
}

:root[data-theme="light"] {
  --bg: #f6f8fa;
  --panel: #ffffff;
  --panel2: #f0f3f6;
  --ink: #1f2328;
  --ink-dim: #5b6570;
  --line: #d8dee4;
  --accent: #0969da;
  --accent-ink: #ffffff;
  --ok: #1a7f37;
  --warn: #9a6700;
  --bad: #cf222e;
  --crit: #a40e26;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}

code, pre, .mono { font-family: var(--mono); }
.mono { font-size: 0.92em; }
.small { font-size: 0.85em; }
.muted { color: var(--ink-dim); }
.hidden { display: none !important; }

a { color: var(--accent); }
a:hover { text-decoration: underline; }

/* --- top bar --------------------------------------------------------------- */

.topbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.brand .sep { color: var(--ink-dim); }
.backlink { text-decoration: none; }
.topactions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.credits { font-family: var(--mono); font-size: 0.85em; color: var(--ink-dim); }
.topup { font-size: 0.85em; padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; }

/* --- buttons ---------------------------------------------------------------- */

button { font-family: inherit; font-size: 1em; cursor: pointer; }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 5px 11px; }
.ghost:hover { background: var(--panel2); }
.primary { background: var(--accent); color: var(--accent-ink); border: none; border-radius: 8px; padding: 11px 22px; font-weight: 600; }
.primary:disabled { opacity: 0.45; cursor: not-allowed; }
.big { background: var(--panel2); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; }
.big:hover { border-color: var(--accent); }
.mini { background: var(--panel2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; font-size: 0.85em; }
.mini:hover { border-color: var(--accent); }
.linkish { background: none; border: none; color: var(--accent); padding: 0; font-size: inherit; text-decoration: underline; }

/* --- layout ------------------------------------------------------------------ */

main { max-width: 1000px; margin: 0 auto; padding: 24px 20px 60px; }
.hero h1 { font-size: 1.9rem; line-height: 1.25; margin: 18px 0 10px; }
.lede { font-size: 1.05rem; color: var(--ink); max-width: 74ch; }
.herobtns { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 8px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 18px 0; }
.card h2 { font-size: 1.15rem; margin: 0 0 10px; }
.card h3 { font-size: 1.05rem; margin: 0 0 10px; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 600; margin-bottom: 6px; }
.labelrow { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.labelrow label { font-weight: 600; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row .field { flex: 1 1 240px; }
.row.three .field, .row.three > div { flex: 1 1 220px; }

textarea, select, input[type="file"] {
  width: 100%; background: var(--bg); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; font-family: var(--mono); font-size: 0.88rem; line-height: 1.5;
}
select { font-family: var(--sans); font-size: 0.95rem; }
textarea { resize: vertical; }
textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.dropzone { border: 1px dashed transparent; border-radius: 10px; transition: border-color 0.15s, background 0.15s; }
.dropzone.dragging { border-color: var(--accent); background: rgba(76, 154, 255, 0.06); }
.droprow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.droprow input[type="file"] { width: auto; flex: 0 1 auto; font-size: 0.8rem; padding: 4px; }

.runrow { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 16px; }
.estimate { color: var(--ink-dim); font-size: 0.9rem; }
.estimate strong { color: var(--ink); }

/* --- prescan ------------------------------------------------------------------ */

.prescan { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: var(--panel2); margin-bottom: 14px; }
.prescan h2 { font-size: 1rem; }
.focusitem { padding: 9px 0; border-top: 1px solid var(--line); }
.focusitem:first-child { border-top: none; }
.flaglist { list-style: none; padding: 0; margin: 8px 0 0; }
.flaglist li { padding: 7px 0; border-top: 1px solid var(--line); font-size: 0.92em; }
.flaglist li:first-child { border-top: none; }
.flagid { display: inline-block; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; margin-right: 6px; font-size: 0.82em; color: var(--ink-dim); }

.block { margin: 12px 0; }
.plainlist { margin: 6px 0 0; padding-left: 18px; }
.plainlist li { margin: 3px 0; }
.reslist { list-style: none; padding: 0; margin: 8px 0 0; }
.reslist li { padding: 5px 0; border-top: 1px solid var(--line); font-size: 0.88em; color: var(--ink-dim); }
.reslist li:first-child { border-top: none; }

.exportrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }

/* --- progress ------------------------------------------------------------------ */

.progress h2 { display: flex; gap: 10px; align-items: baseline; }
.steps { list-style: none; padding: 0; margin: 12px 0 0; }
.step { display: flex; align-items: center; gap: 10px; padding: 5px 0; color: var(--ink-dim); }
.step-ic { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--line); flex: 0 0 auto; }
.step.done { color: var(--ink); }
.step.done .step-ic { background: var(--ok); border-color: var(--ok); }
.step.live { color: var(--ink); }
.step.live .step-ic { border-color: var(--accent); background: var(--accent); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* --- lane switcher --------------------------------------------------------------- */

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 12px 0 0; }
.tab { background: var(--panel2); color: var(--ink-dim); border: 1px solid var(--line); border-bottom: none; border-radius: 6px 6px 0 0; padding: 5px 12px; font-size: 0.85em; }
.tab.active { background: var(--bg); color: var(--ink); font-weight: 600; }
.tabstage { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stagename { font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-dim); min-width: 8.5em; }
.lanehead { padding-top: 12px; padding-bottom: 12px; }
.lanehead h2 { margin-bottom: 4px; }

/* --- result shell ------------------------------------------------------------- */

.result .reshead { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.verdict { font-size: 1.03rem; border-left: 3px solid var(--line); padding-left: 12px; margin: 10px 0; }
.verdict.posture-conformant { border-left-color: var(--ok); }
.verdict.posture-minor-issues { border-left-color: var(--warn); }
.verdict.posture-non-conformant { border-left-color: var(--bad); }
.verdict.posture-unparseable { border-left-color: var(--crit); }

.warnline { border: 1px solid var(--warn); border-radius: 8px; padding: 9px 12px; background: rgba(210, 153, 34, 0.09); }
.warnline ul { margin: 6px 0 0; padding-left: 18px; }
.warnline li { margin: 2px 0; word-break: break-word; }
.warn { color: var(--warn); }
.okline { color: var(--ok); }

.handoff { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--accent); border-radius: var(--radius); background: rgba(76, 154, 255, 0.06); }
.handoff p { margin: 0 0 8px; }

.disclaimer { margin-top: 12px; opacity: 0.85; }

/* --- tables --------------------------------------------------------------------- */

.tablewrap { overflow-x: auto; }
.grid { border-collapse: collapse; width: 100%; font-size: 0.88rem; margin: 8px 0 4px; }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: 6px 9px; text-align: left; vertical-align: top; }
.grid th { font-size: 0.74rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-dim); white-space: nowrap; }
.num { font-family: var(--mono); white-space: nowrap; }
.num.neg { color: var(--bad); }

/* --- findings, reasoning, checklists -------------------------------------------- */

.findings, .fix-list { list-style: none; padding: 0; margin: 8px 0 0; }
.findings > li, .fix-list > li { border-left: 3px solid var(--line); padding: 8px 0 8px 12px; margin: 10px 0; }
.findings > li.sev-critical { border-left-color: var(--crit); }
.findings > li.sev-high { border-left-color: var(--bad); }
.findings > li.sev-medium { border-left-color: var(--warn); }
.findings > li.sev-low { border-left-color: var(--ink-dim); }
.findhead { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin: 0 0 4px; }
.findtitle { font-size: 0.98rem; margin: 4px 0; }
.why { margin: 4px 0; color: var(--ink-dim); }
.fix { margin: 4px 0; }
.fid { font-weight: 700; }
.rowid { font-family: var(--mono); font-size: 0.76rem; padding: 1px 5px; border-radius: 4px; background: var(--panel2); border: 1px solid var(--line); white-space: nowrap; }

.covlist { list-style: none; padding: 0; margin: 8px 0 0; }
.covlist li { padding: 5px 0; border-top: 1px solid var(--line); font-size: 0.9em; }
.covlist li:first-child { border-top: none; }
.covmark { display: inline-block; width: 20px; font-weight: 700; }
.covmark.yes { color: var(--ok); }
.covmark.no { color: var(--warn); }
.covmark.missed { color: var(--bad); }
.covnote { color: var(--ink-dim); }
.covnote.warn { color: var(--bad); }

/* --- badges --------------------------------------------------------------------- */

.badge {
  font-family: var(--mono); font-size: 0.74em; border: 1px solid var(--line); border-radius: 20px;
  padding: 1px 8px; color: var(--ink-dim); white-space: nowrap;
}
.badge.b-sev, .badge.b-type, .badge.b-lane, .badge.b-warn {
  font-size: 0.72rem; letter-spacing: 0.04em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap;
}
.badge.v-critical { color: var(--crit); border-color: var(--crit); }
.badge.v-high { color: var(--bad); border-color: var(--bad); }
.badge.v-medium { color: var(--warn); border-color: var(--warn); }
.badge.v-low { color: var(--ink-dim); }
.badge.b-lane { color: var(--accent); border-color: var(--accent); }
.badge.b-warn { color: var(--warn); border-color: var(--warn); }
.badge.b-type { text-transform: none; letter-spacing: 0; color: var(--ink-dim); }

/* --- history -------------------------------------------------------------------- */

.histhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.histactions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.history { list-style: none; padding: 0; margin: 0 0 10px; }
.histbtn {
  width: 100%; text-align: left; background: none; border: none; color: var(--ink);
  padding: 9px 4px; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line);
}
.histbtn:hover { background: var(--panel2); }
.histtitle { font-weight: 600; }
.histmeta { color: var(--ink-dim); }

/* --- faq -------------------------------------------------------------------------- */

.faq details { border-top: 1px solid var(--line); padding: 10px 0; }
.faq details:first-of-type { border-top: none; padding-top: 0; }
.faq summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.faq summary::marker { color: var(--ink-dim); }
.faq details p { margin: 8px 0 2px; color: var(--ink-dim); max-width: 74ch; }

/* --- footer + toasts --------------------------------------------------------------- */

.foot { border-top: 1px solid var(--line); padding: 20px; text-align: center; color: var(--ink-dim); font-size: 0.9em; }
.foot p { margin: 6px 0; max-width: 80ch; margin-left: auto; margin-right: auto; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--panel); border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px; padding: 10px 14px; box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28); font-size: 0.92em; transition: opacity 0.5s; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--bad); }
.toast.gone { opacity: 0; }
.toast a { margin-left: 8px; font-weight: 600; }

/* --- docs pages ------------------------------------------------------------------- */

.doc { max-width: 900px; margin: 0 auto; padding: 24px 20px 60px; }
.doc h1 { font-size: 1.7rem; }
.doc h2 { font-size: 1.2rem; margin-top: 30px; }
.doc h3 { font-size: 1rem; margin-top: 22px; }
.doc p, .doc li { max-width: 80ch; }
.doc table { width: 100%; border-collapse: collapse; font-size: 0.9em; margin: 12px 0; }
.doc th, .doc td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc th { color: var(--ink-dim); }
.doc code { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 0.88em; }
.doc pre code { background: none; border: none; padding: 0; }
.doc pre { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; }

.raw { font-family: var(--mono); font-size: 0.8rem; white-space: pre-wrap; word-break: break-word; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 26rem; overflow: auto; }

.tokenrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.tokenbox { flex: 1 1 320px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-family: var(--mono); font-size: 0.85rem; word-break: break-all; min-height: 44px; }
.statebox { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: var(--panel2); margin: 12px 0; }

.codetabs { gap: 4px; flex-wrap: wrap; margin-bottom: 0; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.codetabs .tab { font-size: 0.8rem; padding: 3px 9px; }
.codegroup { margin: 10px 0 18px; }
.codegroup pre { margin-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.codegroup pre[hidden] { display: none; }

@media (max-width: 640px) {
  .stagename { min-width: 0; width: 100%; }
  .grid { font-size: 0.82rem; }
}
@media (max-width: 620px) {
  .hero h1 { font-size: 1.5rem; }
  main, .doc { padding: 16px 14px 48px; }
}

@media print {
  .topbar, .toasts, .exportrow, form, .prescan, #progressPanel, #historyZone, .herobtns, .foot { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border-color: #ccc; break-inside: avoid; }
}

/* --- Shared desk additions ---------------------------------------------------- */

/* A design location - a designator, a net, a layer - wherever one is displayed.
   Monospaced because a location is
   a coordinate, not prose, and a reader compares it character by character
   against their own message. A location the pasted message does not contain
   gets the ungrounded treatment - visible, not hidden. */
.loc {
  font-family: var(--mono);
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--panel2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.loc.loc-bad {
  border-color: var(--bad);
  color: var(--bad);
  background: rgba(248, 81, 73, 0.10);
  text-decoration: underline wavy;
}
:root[data-theme="light"] .loc.loc-bad { background: rgba(207, 34, 46, 0.08); }

.segname {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.segname-unknown { color: var(--warn); }

/* The key/value table in the free parse read-out. */
td.kcell { color: var(--ink-dim); white-space: nowrap; width: 1%; padding-right: 18px; }

/* The patient-identifier bar. Deliberately the loudest thing on the form when
   it appears: it is the one control whose absence has consequences outside the
   browser tab. */
.phibar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  background: rgba(210, 153, 34, 0.09);
}
:root[data-theme="light"] .phibar { background: rgba(154, 103, 0, 0.07); }
.phitext { display: flex; flex-direction: column; gap: 3px; min-width: 220px; flex: 1 1 320px; }
.phitext strong { color: var(--warn); }
.phiactions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inlinecheck {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-dim);
  cursor: pointer;
}
.inlinecheck input { margin: 0; }

/* The one-clause "what this message is" line, and the ACK/Bundle headline. */
.kindline {
  font-size: 16px;
  line-height: 1.45;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: var(--panel2);
  border-radius: 0 8px 8px 0;
  margin: 0;
}
.ackline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 6px; }

/* A raw HL7 message or a FHIR Bundle. Long segments must scroll rather than
   wrap, because a wrapped HL7 segment is unreadable - the delimiters stop
   lining up and a reader can no longer count fields. */
pre.raw.hl7 {
  white-space: pre;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.7;
  tab-size: 4;
}
pre.raw.json {
  white-space: pre;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.55;
}

/* Status and code badges. */
.badge.b-status, .badge.b-ack, .badge.b-errsev, .badge.b-res {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--panel2);
  text-transform: none;
}
.badge.b-status.s-pass { border-color: var(--ok); color: var(--ok); }
.badge.b-status.s-warn { border-color: var(--warn); color: var(--warn); }
.badge.b-status.s-fail { border-color: var(--bad); color: var(--bad); }
.badge.b-ack { font-size: 13px; padding: 3px 10px; }
.badge.b-ack.ack-AA { border-color: var(--ok); color: var(--ok); }
.badge.b-ack.ack-AE { border-color: var(--warn); color: var(--warn); }
.badge.b-ack.ack-AR { border-color: var(--bad); color: var(--bad); }
.badge.b-errsev.es-E { border-color: var(--bad); color: var(--bad); }
.badge.b-errsev.es-W { border-color: var(--warn); color: var(--warn); }
.badge.b-errsev.es-I { border-color: var(--ink-dim); color: var(--ink-dim); }
.badge.b-res { border-color: var(--accent); color: var(--accent); }
.badge.b-ok { border-color: var(--ok); color: var(--ok); }

/* Wide tables are the norm here - a nine-column mapping table does not fit a
   phone. It scrolls inside its own container so the page body never does. */
.tablewrap { overflow-x: auto; }
.grid { min-width: 520px; }

@media (max-width: 700px) {
  .phibar { flex-direction: column; align-items: stretch; }
  .phiactions { justify-content: flex-start; }
  .tabstage { flex: 1 1 100%; }
}


/* --- KiCad Desk additions --------------------------------------------------- */

.verdict.posture-order-ready { border-left-color: var(--ok); }
.verdict.posture-fix-first { border-left-color: var(--warn); }
.verdict.posture-not-ready { border-left-color: var(--bad); }
.verdict.posture-unreadable { border-left-color: var(--crit); }

.badge.b-bad { border-color: var(--bad); color: var(--bad); }
.badge.b-status.b-ok { border-color: var(--ok); color: var(--ok); }
.badge.b-status.b-warn { border-color: var(--warn); color: var(--warn); }
.badge.b-status.b-bad { border-color: var(--bad); color: var(--bad); }

/* The order state, which is the one word a person reads first in the fab lane. */
.verdictline {
  font-family: var(--mono);
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  border-left: 3px solid var(--line);
  padding-left: 12px;
  margin: 6px 0 2px;
}
.verdictline.order-ready { border-left-color: var(--ok); color: var(--ok); }
.verdictline.order-hold { border-left-color: var(--warn); color: var(--warn); }
.verdictline.order-blocked { border-left-color: var(--bad); color: var(--bad); }
.verdictline.order-unknown { color: var(--muted); }

/* A corrected S-expression fragment. Long lines must scroll rather than wrap:
   a wrapped S-expression loses the indentation that shows its nesting. */
pre.raw.sexpr {
  white-space: pre;
  overflow-x: auto;
  border-left: 3px solid var(--accent);
  tab-size: 2;
}

/* A cell that is empty when it should not be - a missing part number. */
.warncell { color: var(--warn); }

/* The explanatory line under a fab-rule row. It belongs to the row above it, so
   it carries no top border of its own. */
tr.noterow > td { border-top: 0; padding-top: 0; }

/* The browser's own flag list, and the reconciliation list that answers it. */
.covlist > li.flag { line-height: 1.5; margin-bottom: 7px; }
.covlist > li.flag > .badge { margin-right: 6px; }
.covlist > li.cov-optional { opacity: 0.72; }
.covmark.opt { color: var(--muted); }
.covnote.muted { color: var(--muted); }

/* The lane switcher. Four stages with names long enough to be self-explanatory
   ("check the schematic", not "verify") do not fit on one line beside their tab,
   so each stage is a column: its name above its button. The row then reads as
   four labelled groups rather than one run-on strip of words, which is the whole
   point of grouping a switcher by pipeline stage. */
.tabs #laneSwitcher, .tabs.laneswitcher { align-items: stretch; }
#laneSwitcher { gap: 10px; }
#laneSwitcher .tabstage {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  flex: 1 1 190px;
}
#laneSwitcher .stagename { min-width: 0; }
#laneSwitcher .tab {
  border-bottom: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  text-align: left;
}
#laneSwitcher .tab.active { border-color: var(--accent); }

/* A one-line free-text field should use the width it was given. */
.field input[type="text"] { width: 100%; box-sizing: border-box; }

/* Two large paste boxes side by side on a wide screen, stacked on a narrow one.
   Both live inside one dropzone so a dropped file can be routed by what it says
   it is rather than by which box it landed on. */
.dropzone > .field + .field { margin-top: 14px; }
.dropzone textarea { font-family: var(--mono); font-size: 0.84rem; white-space: pre; }
@media (min-width: 1080px) {
  .dropzone {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .dropzone > .field + .field { margin-top: 0; }
  .dropzone > .droprow { grid-column: 1 / -1; }
}

/* --- FIX Log Desk: one log box, not two ------------------------------------- */

/* The reference layout put two paste boxes side by side. This app has exactly one
   work object - the FIX log - so the grid collapses to a single column and the log
   row keeps its full width underneath. */
@media (min-width: 1080px) {
  .dropzone { grid-template-columns: 1fr; }
}

.field input[type="number"] { width: 10rem; max-width: 100%; box-sizing: border-box; }

/* --- the parsed-log preview ---------------------------------------------- */

/* The picture is drawn from the same point chains every measurement runs on, so
   the colours here are a legend for the numbers rather than decoration. */
.preview .svgbox {
  margin: 10px 0 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel2);
  overflow-x: auto;
}
.preview .svgbox svg { display: block; max-width: 100%; height: auto; }

.pv-outline { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: var(--accent); stroke-width: 1.6; }
.pv-hole { fill: var(--panel2); stroke: var(--ink-dim); stroke-width: 1.3; }
.pv-island { fill: color-mix(in srgb, var(--accent) 22%, transparent); stroke: var(--accent); stroke-width: 1.2; }
.pv-open { fill: none; stroke: var(--bad); stroke-width: 2.2; stroke-dasharray: 6 4; }
.pv-gap { fill: var(--bad); stroke: none; }
.pv-bend { stroke: var(--ok); stroke-width: 1.8; stroke-dasharray: 10 5; }
.pv-flag { fill: none; stroke: var(--warn); stroke-width: 1.6; stroke-dasharray: 3 3; }

/* Browsers without color-mix still need a visible fill. */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
  .pv-outline { fill: var(--panel2); }
  .pv-island { fill: var(--panel); }
}

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 4px 0 0; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch {
  display: inline-block; width: 16px; height: 10px; border-radius: 2px;
  border: 1px solid var(--line);
}
.swatch.pv-k-outline { background: var(--accent); }
.swatch.pv-k-hole { background: var(--panel2); border-color: var(--ink-dim); }
.swatch.pv-k-island { background: color-mix(in srgb, var(--accent) 45%, var(--panel)); }
.swatch.pv-k-bend { background: var(--ok); }
.swatch.pv-k-open { background: var(--bad); }
.swatch.pv-k-flag { background: var(--warn); }

/* --- the ordered service sequence ------------------------------------------- */

.steps-list { margin: 8px 0 0; padding-left: 22px; }
.steps-list li { margin: 6px 0; }

/* --- a returned script ------------------------------------------------------ */

pre.raw.code {
  max-height: 30rem;
  overflow: auto;
  font-size: 0.82rem;
  line-height: 1.45;
  tab-size: 4;
}

/* --- the result header badge must wrap ---------------------------------------- */

/* The scope badge carries the whole order in one line - "120 x 80 mm, 2 mm mild
   steel CR4 2.0 mm, Laser cut sheet metal, x5" - and a badge is nowrap by
   default, so on a 390 px screen it was the one element that pushed the page
   sideways. Found by driving the deployed page in a real browser at 390 px;
   nothing in the offline harness could have seen it. */
.reshead { flex-wrap: wrap; }
.reshead .badge {
  white-space: normal;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: left;
}

/* --- FIX Log Desk: additions ------------------------------------------------ */

/* the answer to the question the user actually typed, rendered before anything
   else because it is the first thing they look for */
.answerbox {
  border-left: 4px solid var(--accent, #4cc9f0);
  background: var(--panel-2, rgba(76, 201, 240, 0.06));
  padding: 0.7rem 0.9rem;
  border-radius: 0 8px 8px 0;
  margin: 0.9rem 0 1.1rem;
}
.answerbox h4 { margin: 0 0 0.35rem; font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase; opacity: 0.75; }
.answerbox p { margin: 0; }

/* a reference that could not be verified against the pasted log */
.ref { font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); font-size: 0.85em; white-space: nowrap; }
.ref-ok { opacity: 0.9; }
.ref-bad { text-decoration: line-through; color: var(--bad, #ef6c6c); }
.refs .ref + .ref { margin-left: 0.3rem; }

/* the state path across an order chain */
.statepath { display: flex; flex-wrap: wrap; gap: 0.15rem 0.3rem; align-items: center; margin: 0.4rem 0; }
.statepath .state { font-size: 0.85em; padding: 0.1rem 0.45rem; border-radius: 999px; border: 1px solid currentColor; opacity: 0.85; }
.statepath .arrow { opacity: 0.5; }

/* the surveillance disclaimer, which must not read as decoration */
.notconcluded {
  border: 1px solid var(--warn, #f7b801);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  margin: 0.6rem 0 1rem;
  font-size: 0.95em;
}

/* the benchmark statement, same reasoning */
.benchmark { border: 1px dashed currentColor; border-radius: 8px; padding: 0.7rem 0.9rem; margin: 0.6rem 0 1rem; opacity: 0.95; }
.benchmark h4 { margin: 0 0 0.35rem; }

/* a wide table must scroll inside its own box, never push the page sideways */
.resblock table, .scansub table { display: block; overflow-x: auto; max-width: 100%; }
.grid { border-collapse: collapse; }
.grid th, .grid td { text-align: left; padding: 0.3rem 0.55rem; border-bottom: 1px solid rgba(128,128,128,0.25); vertical-align: top; }
.grid td.num, .grid th.num { text-align: right; }
.grid td.bad { color: var(--bad, #ef6c6c); font-weight: 600; }

/* the reconciliation table's unanswered rows */
.recon { width: 100%; border-collapse: collapse; }
.recon th, .recon td { text-align: left; padding: 0.3rem 0.55rem; border-bottom: 1px solid rgba(128,128,128,0.25); vertical-align: top; }
.recon tr.unaccounted td { background: rgba(239, 108, 108, 0.12); }
.recon tr.extra td { opacity: 0.85; }

/* the free read-out */
.scanhead { display: flex; flex-wrap: wrap; gap: 0.8rem 1.6rem; margin-bottom: 0.6rem; }
.stat { display: flex; flex-direction: column; }
.statv { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.statl { font-size: 0.78rem; opacity: 0.7; }
.scansub { margin-top: 1rem; }
.scansub h4 { margin: 0 0 0.4rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip { font-size: 0.8rem; padding: 0.12rem 0.5rem; border-radius: 999px; border: 1px solid rgba(128,128,128,0.4); }
.flaglist { display: flex; flex-direction: column; gap: 0.5rem; }
.flag { border-left: 3px solid currentColor; padding: 0.4rem 0.7rem; }
.flaghead { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: baseline; }
.findid { font-family: var(--mono, ui-monospace, monospace); opacity: 0.7; }

/* severity colours, one place */
.sev-critical, .sevbox-critical { --sev: #ef6c6c; }
.sev-high, .sevbox-high { --sev: #f0883e; }
.sev-medium, .sevbox-medium { --sev: #f7b801; }
.sev-low, .sevbox-low { --sev: #7ac74f; }
.sev-info, .sevbox-info { --sev: #4cc9f0; }
.pill.sev-critical, .pill.sev-high, .pill.sev-medium, .pill.sev-low, .pill.sev-info {
  border-color: var(--sev); color: var(--sev);
}
.sevbox-critical, .sevbox-high, .sevbox-medium, .sevbox-low, .sevbox-info { border-left-color: var(--sev); }
.tone-ok { border-color: #7ac74f; color: #7ac74f; }
.tone-warn { border-color: #f7b801; color: #f7b801; }
.tone-bad { border-color: #ef6c6c; color: #ef6c6c; }

/* result blocks */
.resblock { margin-top: 1.1rem; }
.resblock h4 { margin: 0 0 0.4rem; }
.findings { display: flex; flex-direction: column; gap: 0.7rem; }
.finding { border-left: 3px solid currentColor; padding: 0.45rem 0.75rem; }
.findhead { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: baseline; }
.orders { display: flex; flex-direction: column; gap: 0.8rem; }
.ordercard, .subcard { border: 1px solid rgba(128,128,128,0.3); border-radius: 8px; padding: 0.6rem 0.8rem; }
.orderhead { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: baseline; margin-bottom: 0.35rem; }
.kvgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0.25rem 0.9rem; margin: 0.4rem 0; }
.kv { display: flex; flex-direction: column; }
.kvk { font-size: 0.75rem; opacity: 0.65; }
.kvv { font-size: 0.92rem; overflow-wrap: anywhere; }
.timeline { padding-left: 1.1rem; }
.tlhead { display: flex; gap: 0.4rem; align-items: baseline; flex-wrap: wrap; }
.checklist .owner { opacity: 0.6; font-size: 0.85em; margin-left: 0.4rem; }
.psteps { list-style: none; padding: 0; margin: 0.4rem 0 0; }
.pstep { display: flex; gap: 0.5rem; align-items: baseline; padding: 0.15rem 0; opacity: 0.55; }
.pstep.current { opacity: 1; font-weight: 600; }
.pstep.done { opacity: 0.85; }
.pstep.failed { color: var(--bad, #ef6c6c); opacity: 1; }
.pdot { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: currentColor; flex: none; }
.ptime { margin-left: auto; font-family: var(--mono, ui-monospace, monospace); font-size: 0.8rem; opacity: 0.7; }
.raw { white-space: pre-wrap; overflow-x: auto; max-width: 100%; }
.histlist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.histitem { border: 1px solid rgba(128,128,128,0.3); border-radius: 8px; padding: 0.5rem 0.7rem; }
.histtop { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: baseline; }
.histbtns { display: flex; gap: 0.35rem; margin-top: 0.35rem; }

/* nothing on this page may push the document sideways at 390px */
.resulthead, .scantop, .runrow, .herobtns, .droprow, .scanbtns, .topactions, .tabs {
  flex-wrap: wrap;
}
.pill, .verdict { white-space: normal; overflow-wrap: anywhere; }

/* A wide table scrolls inside its own box. This wrapper is what actually holds:
   `display:block; overflow-x:auto` applied to the <table> itself did not, and a
   real browser found the read-out pushing the document 163px sideways at 390px
   while every offline check passed. */
.tablewrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.tablewrap > table { min-width: max-content; }
main, .card, .scansub, .resblock, .ordercard, .subcard { min-width: 0; }
.kvv, .story, .what, .why, .remedy, .summary, .headline { overflow-wrap: anywhere; }
pre, code { overflow-wrap: anywhere; }
