/* Layout: header with the 8-step stepper; left panel = current window; right = imaging stage (toolbar, 2x2 views, readout).
   Single dark look on purpose (imaging workstation). */
:root {
  --bg: #0e1214; --panel: #161c1f; --panel-2: #1d2529; --line: #2a3438;
  --fg: #e4eaec; --muted: #8d9aa0; --accent: #46c2c6; --accent-ink: #062224;
  --hot: #ff8a3d; --ok: #57c78a; --bad: #ff6b6b; --warn: #f0b84a;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 13px/1.45 var(--sans); }
.app { display: grid; grid-template-columns: 380px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: 100%; }
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 18px; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; }
.brand { display: flex; flex-direction: column; line-height: 1.2; }
.brand b { font-size: 15px; }
.brand span { color: var(--muted); font-size: 11.5px; }
.stepper { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.stepper button { display: flex; align-items: center; gap: 6px; background: transparent; border: 1px solid transparent; color: var(--muted); padding: 5px 9px; border-radius: 6px; font: inherit; cursor: pointer; }
.stepper button .n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line); font-family: var(--mono); font-size: 11px; }
.stepper button.done .n { background: var(--panel-2); border-color: var(--accent); color: var(--accent); }
.stepper button[aria-current="step"] { color: var(--fg); border-color: var(--line); background: var(--panel-2); }
.stepper button[aria-current="step"] .n { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.stepper button:disabled { opacity: .4; cursor: not-allowed; }
.jobchip { font-family: var(--mono); font-size: 12px; color: var(--accent); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; cursor: pointer; }
.panel { overflow-y: auto; padding: 14px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.panel h2 { margin: 0; font-size: 18px; font-weight: 600; }
.panel .lede { color: var(--muted); margin: 0; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 9px; }
.box h3 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row > span:first-child, .row > label:first-child { color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field > span { color: var(--muted); font-size: 12px; }
input[type="number"], input[type="text"], input[type="search"], select {
  background: var(--panel-2); color: var(--fg); border: 1px solid var(--line); border-radius: 5px; padding: 5px 7px; font: inherit; min-width: 0; width: 100%;
}
input[type="number"] { font-family: var(--mono); text-align: right; }
input[type="range"] { accent-color: var(--accent); width: 100%; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { background: var(--panel-2); color: var(--muted); border: 0; padding: 5px 9px; font: inherit; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn { background: var(--panel-2); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; gap: 8px; justify-content: space-between; margin-top: auto; padding-top: 6px; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.note { color: var(--muted); font-size: 12px; margin: 0; }
.pad { padding: 12px; }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
dd.big { font-size: 16px; color: var(--hot); }
.results { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
.results button { display: flex; width: 100%; gap: 8px; align-items: baseline; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line); color: var(--fg); padding: 6px 8px; font: inherit; cursor: pointer; }
.results button:hover, .results button[aria-selected="true"] { background: var(--panel-2); }
.results .acr { font-family: var(--mono); color: var(--accent); min-width: 4.5em; }
.results .vol { margin-left: auto; color: var(--muted); font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
.bars { display: flex; flex-direction: column; gap: 4px; }
.bar { display: grid; grid-template-columns: minmax(0, 1fr) 56px; gap: 8px; align-items: center; font-size: 12px; }
.bar .track { position: relative; height: 16px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bar .fill { position: absolute; inset: 0 auto 0 0; background: #5d6b72; }
.bar.tgt .fill { background: var(--bad); }
.bar .lbl { position: absolute; left: 6px; top: 0; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; right: 4px; }
.bar .num { font-family: var(--mono); text-align: right; color: var(--muted); }
.warn { border-left: 3px solid var(--warn); padding: 6px 9px; background: rgba(240,184,74,.08); border-radius: 0 5px 5px 0; font-size: 12.5px; }
.checklist { display: flex; flex-direction: column; gap: 4px; }
.check { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 6px; align-items: baseline; font-size: 12.5px; }
.check .dot { width: 10px; height: 10px; border-radius: 50%; align-self: center; }
.check.ok .dot { background: var(--ok); } .check.bad .dot { background: var(--bad); }
.check .v { font-family: var(--mono); color: var(--muted); }
.progress { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tiles div { background: var(--panel); padding: 9px 11px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tiles .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tiles .v { font-family: var(--mono); font-size: 18px; }
.tiles .s { font-size: 11.5px; color: var(--muted); }
table.t { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.t td, table.t th { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: right; }
table.t td:first-child, table.t th:first-child { text-align: left; }
table.t th { color: var(--muted); font-weight: 500; font-size: 11.5px; }
table.t td { font-family: var(--mono); }
table.t td:first-child { font-family: var(--sans); }
.joblist { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.joblist button { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; text-align: left; background: var(--panel-2); border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 6px 8px; font: inherit; cursor: pointer; }
.joblist button[aria-current="true"] { border-color: var(--accent); }
.st { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--panel); }
.st.done { color: var(--ok); } .st.error { color: var(--bad); } .st.running, .st.queued { color: var(--warn); }
canvas.chart { width: 100%; height: 180px; display: block; background: var(--panel-2); border-radius: 6px; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }
/* stage */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 10px; gap: 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; color: var(--muted); }
.tgroup { display: flex; align-items: center; gap: 6px; }
.tgroup input[type="range"] { width: 90px; }
.tgroup.checks { gap: 12px; }
.tgroup.checks label { display: flex; gap: 5px; align-items: center; cursor: pointer; }
.views { flex: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 8px; min-height: 0; }
.view { background: #000; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.vhead { display: flex; align-items: center; gap: 10px; padding: 5px 9px; background: var(--panel); border-bottom: 1px solid var(--line); }
.vhead b { font-size: 12.5px; font-weight: 600; }
.vhead .slice { flex: 1; }
.vhead .pos { font-family: var(--mono); color: var(--accent); font-size: 12px; min-width: 7em; text-align: right; }
.vhead .hint { flex: 1; color: var(--muted); font-size: 11.5px; }
.cwrap { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; overflow: hidden; }
.cwrap canvas { display: block; cursor: crosshair; touch-action: none; }
.view3d .cwrap canvas { position: absolute; inset: 0; cursor: grab; }
.layers { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 3px 8px; padding: 6px 9px; background: var(--panel); border-top: 1px solid var(--line); font-size: 12px; }
.layers label { display: flex; align-items: center; gap: 5px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout { font-family: var(--mono); font-size: 12px; color: var(--muted); min-height: 1.5em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.readout b { color: var(--fg); font-family: var(--sans); font-weight: 500; }
@media (max-width: 1100px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(600px, 1fr); height: auto; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .views { min-height: 640px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
