/* Layout: one working surface per role; controls on the left rail, evidence (charts, tables) on the right; stacks on narrow screens. */
:root {
  --bg: #f3f5f4; --panel: #ffffff; --ink: #14201f; --muted: #556664; --line: #d5dcda; --accent: #0b6e69; --accent-ink: #ffffff; --soft: #e4eeec;
  --heat: #c2410c; --good: #1a7f4b; --warn: #a15c00; --bad: #b3261e; --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #7a5cc4; --grid: #e6ebe9;
  --plot-bg: #0a1020; --plot-grid: #1b2740; --plot-edge: #2a3a5c; --plot-ink: #e8f1ff; --plot-cursor: #7dd3fc; --plot-thr: #f472b6; --plot-y2: #fbbf24; --plot-span: rgba(56,189,248,.10);
  --display: "Space Grotesk", "Segoe UI", system-ui, sans-serif; --body: "Inter", "Segoe UI", system-ui, sans-serif; --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0f1716; --panel: #172221; --ink: #e6efed; --muted: #9db0ad; --line: #2c3b39; --accent: #4fc4bb; --accent-ink: #06201e; --soft: #1f302e;
  --heat: #fb923c; --good: #5fd08f; --warn: #f0b24a; --bad: #ff8a80; --s1: #5aa2f0; --s2: #f58a5c; --s3: #3fd09a; --s4: #a48cf0; --grid: #243230; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0f1716; --panel: #172221; --ink: #e6efed; --muted: #9db0ad; --line: #2c3b39; --accent: #4fc4bb; --accent-ink: #06201e; --soft: #1f302e;
  --heat: #fb923c; --good: #5fd08f; --warn: #f0b24a; --bad: #ff8a80; --s1: #5aa2f0; --s2: #f58a5c; --s3: #3fd09a; --s4: #a48cf0; --grid: #243230; color-scheme: dark }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); }
h1, h2, h3 { font-family: var(--display); line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1rem; }
p { margin: 0; max-width: 68ch; } small, .muted { color: var(--muted); }
.wrap { max-width: 1280px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
header.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
header.top .wrap { display: flex; gap: 12px 24px; align-items: center; flex-wrap: wrap; padding-block: 10px; }
.brand { font-family: var(--display); font-weight: 700; font-size: 1.05rem; letter-spacing: .01em; }
.brand span { color: var(--accent); }
nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
nav.tabs a { text-decoration: none; color: var(--muted); padding: 7px 12px; border-radius: 6px; font-weight: 600; font-size: .92rem; }
nav.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
nav.tabs a:hover:not([aria-current="page"]) { background: var(--soft); color: var(--ink); }
.sim-note { margin-left: auto; font-size: .78rem; color: var(--warn); border: 1px solid currentColor; border-radius: 4px; padding: 2px 8px; }
main { padding-block: 22px 60px; display: flex; flex-direction: column; gap: 22px; }
.lead { display: flex; flex-direction: column; gap: 8px; }
.grid { display: grid; gap: 16px; }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.bench { grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .bench { grid-template-columns: minmax(0, 1fr); } .sim-note { margin-left: 0; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.panel > h3 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.role { text-decoration: none; color: inherit; border-top: 4px solid var(--accent); }
.role:hover { border-color: var(--heat); }
.role b { font-family: var(--display); font-size: 1.1rem; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.row { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: center; }
label.f { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: .86rem; color: var(--muted); align-items: center; }
label.f output, .val { font-family: var(--mono); color: var(--ink); font-size: .84rem; }
label.f input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
label.c { display: flex; gap: 8px; align-items: center; font-size: .9rem; }
input[type=number], input[type=text], select { font: inherit; font-size: .86rem; padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); color: var(--ink); min-width: 0; }
input[type=number] { width: 5.2em; font-family: var(--mono); }
button { font: inherit; font-weight: 600; font-size: .88rem; padding: 7px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--bad); border-color: currentColor; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--heat); outline-offset: 2px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: .88rem; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-family: var(--mono); font-size: .84rem; overflow-wrap: anywhere; }
.pill { display: inline-block; border-radius: 99px; padding: 1px 9px; font-size: .76rem; font-weight: 700; border: 1px solid currentColor; white-space: nowrap; }
.pill.ok { color: var(--good); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); } .pill.off { color: var(--muted); }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .84rem; font-variant-numeric: tabular-nums; }
th, td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; } th.l, td.l { text-align: left; }
td.w { white-space: normal; min-width: 11em; overflow-wrap: anywhere; }
.log { font-family: var(--mono); font-size: .78rem; max-height: 190px; overflow: auto; background: var(--soft); border-radius: 6px; padding: 8px; white-space: pre-wrap; }
.chart { width: 100%; min-width: 0; position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .tip { position: absolute; pointer-events: none; background: #0f1a30; color: #e8f1ff; border: 1px solid #2f4a7a; box-shadow: 0 0 14px rgba(56,189,248,.25); font-size: .76rem; padding: 5px 8px; border-radius: 5px; white-space: nowrap; transform: translate(-50%, -125%); display: flex; flex-direction: column; gap: 1px; z-index: 3; }
.chart .tip b { font-family: var(--mono); font-weight: 600; } .chart .tip span { color: #9fb6d8; font-family: var(--mono); }
.chart .ser { transition: opacity .12s; }
.legend { display: flex; gap: 4px 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.plate { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
.well { border: 1px solid var(--line); border-radius: 6px; padding: 5px 4px; font-size: .74rem; text-align: center; cursor: pointer; background: var(--panel); color: var(--ink); line-height: 1.25; min-width: 0; font-weight: 500; }
.well b { display: block; font-family: var(--mono); font-size: .8rem; } .well span { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.well[aria-pressed="true"] { outline: 2px solid var(--heat); }
.well.standard { border-top: 3px solid var(--s1); } .well.unknown { border-top: 3px solid var(--s2); } .well.ntc { border-top: 3px solid var(--s3); } .well.empty { opacity: .45; }
.bars { display: grid; grid-template-columns: auto 1fr auto; gap: 5px 10px; font-size: .8rem; align-items: center; }
.bars .bar { height: 9px; background: var(--soft); border-radius: 5px; overflow: hidden; } .bars .bar i { display: block; height: 100%; background: var(--accent); }
.bars .n { font-family: var(--mono); font-size: .78rem; }
.chainsvg text { font: 11px var(--body); fill: var(--ink); } .chainsvg .t2 { fill: var(--muted); font-size: 10px; }
.flag { display: grid; grid-template-columns: auto 1fr; gap: 8px; font-size: .88rem; align-items: baseline; }
.note { font-size: .84rem; color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; }
progress { width: 100%; accent-color: var(--accent); }
footer { color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); padding-block: 16px 30px; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }

/* live run animation */
.matrix { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 7px; background: var(--plot-bg); border-radius: 8px; padding: 12px; }
.matrix .tube { aspect-ratio: 1; border-radius: 50%; border: 1.5px solid #2a3a5c; display: grid; place-items: center; font: 600 .68rem var(--mono); color: #9fb6d8; background: radial-gradient(circle at 50% 55%, rgba(74,222,128,var(--glow,0)) 0%, rgba(34,197,94,calc(var(--glow,0) * .55)) 45%, #0d1528 72%); cursor: pointer; padding: 0; min-width: 0; }
.matrix .tube.reading { border-color: #7dd3fc; box-shadow: 0 0 0 2px rgba(125,211,252,.35), 0 0 16px rgba(125,211,252,.8); color: #e8f1ff; }
.matrix .tube.sel { border-color: var(--plot-thr); } .matrix .tube.off { opacity: .28; } .matrix .tube.dim { opacity: .35; }
.phase { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 6px; }
.phase span { border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: .78rem; color: var(--muted); text-align: center; }
.phase span.on { background: var(--heat); border-color: var(--heat); color: #fff; font-weight: 600; }
.big { font: 500 1.9rem/1.1 var(--mono); } .big small { font-size: .8rem; color: var(--muted); font-family: var(--body); }
.readbars { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 3px; align-items: end; height: 84px; background: var(--plot-bg); border-radius: 8px; padding: 8px 8px 4px; }
.readbars i { display: block; background: #22c55e; border-radius: 2px 2px 0 0; min-height: 1px; opacity: .55; } .readbars i.new { opacity: 1; box-shadow: 0 0 8px rgba(74,222,128,.8); } .readbars i.cur { background: #7dd3fc; opacity: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; } .chips button { padding: 3px 10px; font-size: .78rem; border-radius: 99px; } .chips button[aria-pressed="true"] { background: var(--soft); border-color: var(--accent); color: var(--ink); } .chips button[aria-pressed="false"] { opacity: .5; }

#q-plate .well[aria-pressed] { outline: none; } .plate .well.off { opacity: .35; } .plate .well.dim { opacity: .45; }
.chart .thr { touch-action: none; }
select, input[type=text], textarea { max-width: 100%; }
.panel h3 { flex-wrap: wrap; row-gap: 4px; } .panel h3 select { max-width: 100%; min-width: 0; }
#g-card table { table-layout: fixed; width: 100%; } #g-card th:first-child { width: 4.6em; } #g-card th:nth-child(2) { width: 30%; } #g-card td { overflow-wrap: anywhere; }
.subtabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.subtabs button { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 6px 13px; font: inherit; font-size: .86rem; cursor: pointer; }
.subtabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.subtabs button small { opacity: .7; margin-left: 3px; } .subtabs button.done::after { content: " ✓"; }
.explist { display: grid; gap: 4px; } .explist button { text-align: left; border: 1px solid transparent; background: none; color: var(--ink); padding: 7px 9px; border-radius: 8px; font: inherit; font-size: .86rem; cursor: pointer; }
.explist button b { display: inline-block; min-width: 1.7em; color: var(--muted); } .explist button:hover { background: var(--soft, rgba(127,127,127,.12)); } .explist button[aria-pressed="true"] { border-color: var(--accent); background: var(--soft, rgba(127,127,127,.12)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); align-items: start; }
.stepnav { justify-content: space-between; margin-top: 4px; }
.subtabs button:disabled { opacity: .45; cursor: not-allowed; }
#tech-body .panel > label, #tech-body .panel > .row { margin-top: 2px; }
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); padding: 18px 20px; } dialog::backdrop { background: rgba(0,0,0,.5); }
body.noscroll { overflow: hidden; }
#run-stage.fs { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow: auto; padding: 12px 16px 20px; display: grid; gap: 10px; align-content: start; }
#run-stage:not(.fs) { display: grid; gap: 10px; } #run-stage[hidden] { display: none; }
.runbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; } .runbar .big { font-size: 1.45rem; }
.rungrid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .rungrid { grid-template-columns: minmax(0, 1fr); } }
tr.cur td { background: var(--soft); }
.explist button i { float: right; font-style: normal; font: 600 .7rem var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; }
.explist button i.part { color: var(--warn, #b45309); border-color: currentColor; } .explist button i.full { color: var(--good, #15803d); border-color: currentColor; }
.explist button i { float: right; font-style: normal; font: 600 .7rem var(--mono); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; }
.explist button i.part { color: var(--warn, #b45309); border-color: currentColor; } .explist button i.full { color: var(--good, #15803d); border-color: currentColor; }

/* Stable well labels and material metadata on the technician bench. */
.technician-plate { min-width: 350px; }
#view-technician .well.positive { border-top: 3px solid #a855f7; }
.sample-naming { margin: 1rem 0; border: 1px solid var(--line); border-radius: 6px; }
.sample-naming small { display: block; margin-top: .4rem; }
#g-manual-wrap:not([hidden]), #g-extractions label { display: grid; gap: .25rem; }
#g-extractions label { justify-items: start; }
#t-matrix .tube[aria-pressed="true"] { outline: 2px solid var(--plot-thr); outline-offset: 2px; }
#run-after h3 { margin-bottom: .25rem; }
#t-trace-key { max-height: 8rem; overflow: auto; }

/* 384-well plate (16 × 24) */
.plate384 { display: grid; grid-template-columns: 1.2em repeat(24, minmax(13px, 1fr)); gap: 2px; min-width: 430px; }
.plate384 .ph { font: 600 .58rem var(--mono); color: var(--muted); text-align: center; align-self: center; }
.w384 { aspect-ratio: 1; padding: 0; border: 1px solid var(--line); border-radius: 3px; background: var(--panel); color: var(--ink); font: 600 .52rem var(--mono); line-height: 1; min-width: 0; cursor: pointer; overflow: hidden; }
.w384.unknown { background: color-mix(in srgb, var(--s2) 30%, var(--panel)); border-color: var(--s2); }
.w384.positive { background: color-mix(in srgb, #a855f7 30%, var(--panel)); border-color: #a855f7; }
.w384.ntc { background: color-mix(in srgb, var(--s3) 25%, var(--panel)); border-color: var(--s3); }
.w384.standard { background: color-mix(in srgb, var(--s1) 30%, var(--panel)); border-color: var(--s1); }
.w384.empty { opacity: .35; cursor: default; }
.w384[aria-pressed="true"] { outline: 2px solid var(--heat); outline-offset: 0; }
.w384.off { opacity: .3; } .w384.dim { opacity: .4; }
.matrix.m384 { grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; padding: 8px; }
.matrix.m384 .tube { font-size: 0; border-width: 1px; }
.readbars.r24 { grid-template-columns: repeat(24, minmax(0, 1fr)); }
.sample-table input[type=date] { width: 9.5em; } .sample-table td { white-space: nowrap; }

/* Run display tabs and a full-size intensity plate. */
.run-views { display:grid; gap:.65rem; margin-block: .75rem; }
.run-views [role="tab"][aria-selected="true"] { background:var(--accent); color:white; }
.detector-plate { min-width:760px; max-width:1120px; gap:3px; }
.det-pixel { padding:0; min-height:27px; font-size:.63rem; font-variant-numeric:tabular-nums; border:1px solid #42556b; color:white;
  background: color-mix(in srgb, #23bcac calc(var(--brightness, 0) * 100%), #071323); text-shadow:0 1px 2px #061325; }
.det-pixel.off { opacity:.38; }
.det-pixel[aria-pressed="true"] { box-shadow: inset 0 -2px var(--group); }
.det-pixel[aria-pressed="false"]:not(:disabled) { border-color:#42556b; }
.det-scale { display:flex; gap:.6rem; align-items:center; margin-top:.7rem; font-size:.8rem; }
.det-scale div { width:min(245px,45vw); height:9px; border-radius:4px; background:linear-gradient(90deg,#071323,#23bcac); }
.plate-axis { padding:0; min-width:0; cursor:pointer; border:0; background:transparent; }
.plate-axis:hover,.plate-axis:focus-visible { background:var(--line); }
.range-preview { outline:2px dashed #40a6e3 !important; outline-offset:-2px; }
#q-plate .w384[aria-pressed="true"],#x-plate .w384[aria-pressed="true"] { outline:1px solid var(--accent); outline-offset:-1px; }

/* Quality review uses the window width and gives the evidence its own rows. */
body:has(#view-quality:not([hidden])) .wrap { max-width: none; padding-inline: clamp(16px, 2vw, 36px); }
#q-body { min-width: 0; }
#q-body > .bench { grid-template-columns: minmax(240px, 310px) minmax(0, 1fr); }
#q-table td:nth-child(2), #q-table td:last-child { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 860px) { #q-body > .bench { grid-template-columns: minmax(0, 1fr); } }

.quality-supplement { grid-template-columns: repeat(auto-fit,minmax(min(100%,300px),1fr)); }

/* ---- Levels of complexity (js/ui/levels.js): Beginner, Intermediate, Expert, Administrator ---- */
.levelbar { padding: 10px 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; border-radius: 0; padding: 6px 13px; background: var(--panel); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.lv-help { color: var(--muted); flex: 1 1 260px; }
[data-level="beginner"] .lv-full, [data-level="intermediate"] .lv-full { display: none !important; }
[data-level="expert"] .lv-guided, [data-level="admin"] .lv-guided { display: none !important; }
.lv-admin { display: none !important; }
[data-level="admin"] .lv-admin { display: flex !important; }
[data-level="beginner"] .lv-i, [data-level="intermediate"] .lv-b { display: none !important; }
[data-level].lv-run #tech-body { display: flex !important; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.cards > button { text-align: left; display: flex; flex-direction: column; gap: 4px; font-weight: 400; padding: 10px 12px; min-height: 92px; }
.cards > button b { font-weight: 700; }
.cards > button small { color: var(--muted); }
.cards > button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.cards > button .pill { align-self: flex-start; }
.choices { display: flex; flex-direction: column; gap: 6px; }
.choices > button { text-align: left; font-weight: 500; }
.choices > button.right { border-color: var(--good); color: var(--good); }
.choices > button.wrong { border-color: var(--bad); color: var(--bad); }
.wizard { display: flex; gap: 6px; flex-wrap: wrap; counter-reset: wz; }
.wizard span { border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; font-size: .84rem; color: var(--muted); }
.wizard span::before { counter-increment: wz; content: counter(wz) " · "; }
.wizard span.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.wizard span.done { color: var(--good); border-color: var(--good); }
.inst { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; background: var(--soft); border-radius: 8px; padding: 10px; }
.inst div { display: flex; flex-direction: column; gap: 2px; }
.inst small { color: var(--muted); font-size: .74rem; }
.inst b { font: 600 1.05rem/1.2 var(--mono); }
.inst .led::before { content: ""; display: inline-block; width: .7em; height: .7em; border-radius: 50%; margin-right: 6px; background: var(--muted); vertical-align: baseline; }
.inst .led.on::before { background: var(--good); } .inst .led.err::before { background: var(--bad); } .inst .led.amber::before { background: var(--warn); }
.inst .disp { grid-column: 1 / -1; font-family: var(--mono); font-size: .8rem; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
table.cq td, table.cq th { white-space: nowrap; }
table.cq td.badcell { color: var(--bad); font-weight: 700; } table.cq td.warncell { color: var(--warn); font-weight: 700; }
.choices > button.right:disabled, .choices > button.wrong:disabled { opacity: 1; }

/* Welcome bibliography link uses the same button treatment. */
.welcome-actions .welcome-sources{display:inline-flex;align-items:center;justify-content:center;padding:12px 22px;min-height:44px;border:1px solid #c99bcd;border-radius:24px;background:#170f22;color:#f4ebff;font-weight:600;text-decoration:none}.welcome-actions .welcome-sources:hover{background:#302039}.welcome-actions .welcome-sources:focus-visible{outline:3px solid #ff9b64;outline-offset:4px}
