:root {
  color-scheme: dark;
  --bg: #0b0d0f;
  --surface-0: #101316;
  --surface-1: #15191d;
  --surface-2: #1b2025;
  --surface-3: #22282e;
  --border: #343b42;
  --border-strong: #4b555f;
  --text: #e4e8eb;
  --muted: #929ca5;
  --dim: #68737d;
  --active: #55a7d9;
  --active-soft: #173b50;
  --success: #65b88a;
  --warning: #d5a449;
  --error: #d66a65;
  --reference: #c59748;
  --rail-width: 326px;
  --top-height: 36px;
  --footer-height: 34px;
  --control-height: 24px;
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; color: inherit; }
button, select, input[type="number"], input[type="search"] {
  height: var(--control-height); border: 1px solid var(--border); border-radius: 2px;
  background: #11161a; outline: none;
}
button { padding: 0 8px; cursor: pointer; background: var(--surface-2); }
button:hover { border-color: var(--border-strong); background: var(--surface-3); }
button:focus-visible, input:focus, select:focus { border-color: var(--active); box-shadow: 0 0 0 1px var(--active); }
button:disabled { color: var(--dim); cursor: not-allowed; }
input[type="number"], input[type="search"], select { min-width: 0; padding: 0 5px; }
input[type="checkbox"] { accent-color: var(--active); }

.app-shell { height: 100vh; display: grid; grid-template-rows: var(--top-height) minmax(0, 1fr) var(--footer-height); }
.topbar { display: flex; align-items: stretch; min-width: 0; background: var(--surface-1); border-bottom: 1px solid var(--border); }
.icon-button { width: 34px; height: 35px; border: 0; border-right: 1px solid var(--border); border-radius: 0; background: transparent; }
.workflow-tabs { display: flex; min-width: 0; }
.tab { height: 35px; padding: 0 11px; border: 0; border-right: 1px solid #262c31; border-radius: 0; background: transparent; color: var(--muted); }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { color: #fff; background: #1a242b; box-shadow: inset 0 -2px var(--active); }
.topbar-spacer { flex: 1; min-width: 8px; }
.top-field { display: grid; grid-template-columns: auto minmax(100px, 180px); gap: 6px; align-items: center; padding: 0 8px; border-left: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.top-field select { height: 23px; }
.profile-field { position: relative; }
.profile-field i { display: none; position: absolute; right: 3px; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--warning); }
.profile-field i.visible { display: block; }
.status-chip { align-self: center; min-width: 69px; margin: 0 7px; padding: 3px 7px; border: 1px solid var(--border); border-radius: 2px; text-align: center; font: 600 10px/1.2 "SFMono-Regular", Consolas, monospace; }
.status-chip.ready, .status-chip.complete { color: var(--success); border-color: #345d48; }
.status-chip.running { color: var(--active); border-color: #315d76; }
.status-chip.stale, .status-chip.warning { color: var(--warning); border-color: #6a5630; }
.status-chip.failed, .status-chip.invalid { color: var(--error); border-color: #6a3633; }
.run-button { height: 35px; border: 0; border-left: 1px solid #2f6d8d; border-radius: 0; background: #1d5775; font-weight: 600; padding: 0 14px; }
.run-button:hover { background: #246789; }

.workspace { min-height: 0; display: grid; grid-template-columns: var(--rail-width) minmax(0, 1fr); }
.workspace.rail-hidden { grid-template-columns: 0 minmax(0, 1fr); }
.tool-rail { min-width: 0; overflow: hidden auto; background: var(--surface-1); border-right: 1px solid var(--border); }
.rail-hidden .tool-rail { visibility: hidden; }
.rail-panel { display: none; min-width: var(--rail-width); }
.rail-panel.active { display: block; }
.rail-heading { height: 29px; padding: 0 9px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-weight: 650; font-size: 10.5px; letter-spacing: .06em; }
.rail-heading small { margin-left: auto; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.text-button { border: 0; height: 22px; margin-left: auto; color: var(--active); background: transparent; }
.coordinate-key { padding: 7px 9px; color: var(--muted); border-bottom: 1px solid var(--border); font: 10.5px/1.3 "SFMono-Regular", Consolas, monospace; }
.coordinate-key b { color: var(--text); }
.property-table-wrap { overflow: auto; max-height: 49vh; border-bottom: 1px solid var(--border); }
table { border-collapse: collapse; width: 100%; }
.property-table { table-layout: fixed; font-variant-numeric: tabular-nums; }
.property-table th { position: sticky; top: 0; z-index: 1; height: 23px; padding: 0 4px; background: #181d21; color: var(--muted); border-bottom: 1px solid var(--border); text-align: right; font-size: 10px; }
.property-table th:first-child { width: 66px; text-align: left; padding-left: 9px; }
.property-table td { height: 25px; padding: 1px 3px; border-bottom: 1px solid #252b30; text-align: right; }
.property-table td:first-child { padding-left: 9px; text-align: left; color: #cbd2d7; font: 600 10.5px "SFMono-Regular", Consolas, monospace; }
.property-table input { width: 100%; height: 21px; border-color: transparent; background: #111518; text-align: right; font: 11px "SFMono-Regular", Consolas, monospace; }
.property-table tr:hover td { background: #192027; }
.property-table tr.selected td { background: var(--active-soft); }
details { border-bottom: 1px solid var(--border); }
summary { height: 28px; display: flex; align-items: center; padding: 0 9px; background: #171b1f; color: #c8cfd4; cursor: pointer; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .035em; }
summary::marker { color: var(--muted); }
.property-grid { padding: 4px 0; }
.property-grid label { min-height: 27px; display: grid; grid-template-columns: minmax(0, 1fr) 92px 31px; align-items: center; padding: 1px 7px 1px 10px; gap: 5px; }
.property-grid label:hover { background: #192027; }
.property-grid label span { color: #b6bec4; }
.property-grid label input, .property-grid label select { width: 100%; text-align: right; font-variant-numeric: tabular-nums; }
.property-grid label em { color: var(--dim); font-style: normal; font-size: 10px; }
.property-grid .check-row input { width: auto; justify-self: end; }
.rail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 7px; }
.rail-actions button { min-height: 26px; height: auto; }
.full-button { width: calc(100% - 14px); margin: 7px; }
.stack-field, .search-field { display: grid; gap: 4px; padding: 8px; color: var(--muted); }
.stack-field select, .search-field input { width: 100%; }

.test-list { padding: 4px 0; }
.test-row { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; min-height: 38px; align-items: center; padding: 3px 8px; border-bottom: 1px solid #242a2f; }
.test-row:hover { background: #192027; }
.test-row strong { display: block; color: #d4d9dc; font-size: 11px; }
.test-row small { display: block; color: var(--dim); margin-top: 2px; }
.test-state { padding: 2px 4px; font: 9px Consolas, monospace; color: var(--muted); border: 1px solid var(--border); }
.test-state.complete { color: var(--success); border-color: #345d48; }
.test-state.warning, .test-state.not_implemented { color: var(--warning); border-color: #6a5630; }
.test-state.not_applicable { color: var(--dim); }
.category-list, .signal-list { padding: 4px 0; }
.category-button, .signal-button { width: 100%; height: 29px; border: 0; border-radius: 0; border-bottom: 1px solid #242a2f; background: transparent; text-align: left; color: #c4cbd0; }
.category-button.active, .signal-button.active { background: var(--active-soft); color: #fff; box-shadow: inset 2px 0 var(--active); }
.category-button span, .signal-button span { float: right; color: var(--dim); }
.inline-notice { margin: 0 7px 7px; padding: 7px; color: var(--muted); border: 1px solid var(--border); background: #111518; }
.history-list { max-height: 260px; overflow: auto; }
.history-row { padding: 6px 9px; border-bottom: 1px solid #252b30; }
.history-row b, .history-row span { display: block; }
.history-row span { color: var(--dim); margin-top: 2px; font: 10px Consolas, monospace; }
.validation-list { padding: 7px; }
.validation-item { margin-bottom: 5px; padding: 7px; border-left: 2px solid var(--active); background: #12171b; color: #bec6cc; }
.validation-item.warning { border-color: var(--warning); }
.validation-item.error { border-color: var(--error); }
.diagnostic-summary { padding: 7px; }
.diagnostic-summary dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 9px; }
.diagnostic-summary dt { color: var(--muted); }
.diagnostic-summary dd { margin: 0; font: 11px Consolas, monospace; }
.help-panel { padding-bottom: 16px; }
.help-panel h3, .help-panel p { margin: 9px; }
.help-panel h3 { margin-top: 14px; color: #d6dcdf; font-size: 11px; text-transform: uppercase; }
.help-panel p { color: #a9b2b9; line-height: 1.5; }

.analysis-workspace { min-width: 0; min-height: 0; display: grid; grid-template-columns: minmax(360px, 58fr) 5px minmax(300px, 42fr); background: var(--bg); }
.pane { min-width: 0; min-height: 0; position: relative; background: var(--surface-0); overflow: hidden; }
.pane-toolbar { height: 30px; display: flex; align-items: center; gap: 8px; padding-left: 9px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: 10.5px; font-weight: 650; letter-spacing: .05em; }
.readout-strip { display: flex; align-items: stretch; gap: 0; margin-left: 10px; height: 29px; }
.readout-strip span { display: flex; align-items: center; gap: 5px; padding: 0 8px; border-left: 1px solid var(--border); color: var(--muted); letter-spacing: 0; font-weight: 400; }
.readout-strip b { color: var(--text); font: 11px Consolas, monospace; }
.toolbar-buttons { margin-left: auto; height: 29px; display: flex; }
.toolbar-buttons button, .pane-toolbar > button { height: 29px; border-width: 0 0 0 1px; border-radius: 0; font-size: 10px; }
.viewer { position: absolute; inset: 30px 0 0; }
.viewer canvas { display: block; }
.viewer-overlay { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 8px; padding: 5px 7px; border: 1px solid rgba(70,79,87,.9); background: rgba(16,19,22,.9); color: #b5bdc3; }
.viewer-overlay label { white-space: nowrap; }
.splitter { background: #2b3238; cursor: col-resize; border-left: 1px solid #0a0c0e; border-right: 1px solid #0a0c0e; }
.splitter:hover, .splitter:focus { background: var(--active); outline: none; }
.cursor-readout { margin-left: auto; color: var(--muted); letter-spacing: 0; font: 10.5px Consolas, monospace; }
.result-view { display: none; position: absolute; inset: 30px 0 0; min-height: 0; }
.result-view.active { display: block; }
#plot-view canvas { width: 100%; height: 100%; display: block; }
.plot-legend { position: absolute; left: 62px; top: 10px; display: flex; gap: 13px; padding: 4px 7px; background: rgba(14,17,20,.84); border: 1px solid #30373d; }
.plot-legend span::before { content: ""; display: inline-block; width: 14px; height: 2px; margin: 0 5px 3px 0; background: var(--active); }
.plot-legend .baseline-key::before { background: var(--reference); }
.plot-legend .cursor-key::before { background: var(--warning); width: 2px; height: 10px; margin-bottom: -2px; }
.hidden { display: none !important; }
.table-scroll { height: 100%; overflow: auto; }
.result-table { font-variant-numeric: tabular-nums; }
.result-table th { position: sticky; top: 0; z-index: 1; height: 28px; padding: 0 8px; background: #181d21; color: var(--muted); border-bottom: 1px solid var(--border); text-align: right; font-size: 10px; }
.result-table th:first-child { text-align: left; }
.result-table td { height: 29px; padding: 0 8px; border-bottom: 1px solid #252b30; text-align: right; white-space: nowrap; }
.result-table td:first-child { text-align: left; white-space: normal; }
.result-table tr:hover td { background: #192027; }
.result-table .value { font: 11px Consolas, monospace; color: #f0f2f3; }
.result-table .delta { color: var(--reference); font: 11px Consolas, monospace; }
.result-table .unavailable { color: var(--dim); }
.result-table .source { color: var(--muted); font-size: 10px; }
.status-text { font: 9px Consolas, monospace; text-transform: uppercase; }
.status-text.valid, .status-text.complete { color: var(--success); }
.status-text.warning, .status-text.not_implemented { color: var(--warning); }
.status-text.unavailable, .status-text.not_applicable { color: var(--dim); }
.help-document { overflow: auto; padding: 14px 18px 30px; color: #b8c0c6; line-height: 1.5; }
.help-document h2 { margin: 0 0 12px; font-size: 16px; color: var(--text); }
.help-document h3 { margin: 18px 0 5px; font-size: 11px; color: var(--text); text-transform: uppercase; }
.results-maximized .viewer-pane, .results-maximized .splitter { display: none; }
.results-maximized .analysis-workspace { grid-template-columns: 1fr; }

.playback-bar { display: flex; align-items: center; gap: 5px; min-width: 0; padding: 0 7px; border-top: 1px solid var(--border); background: var(--surface-1); color: var(--muted); }
.playback-bar button { height: 24px; }
.play-button { width: 31px; color: var(--active); }
.playback-bar input[type="range"] { flex: 1; min-width: 80px; accent-color: var(--active); }
.playback-bar label { display: flex; align-items: center; gap: 4px; }
.playback-bar select { height: 22px; }
.footer-spacer { flex: 1; }
#test-status-line { color: #c3cbd1; }
#provenance-line { font: 10px Consolas, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38vw; }

@media (max-width: 1080px) {
  :root { --rail-width: 294px; }
  .tab { padding: 0 7px; }
  .top-field span { display: none; }
  .top-field { grid-template-columns: minmax(90px, 140px); }
  .readout-strip span:nth-child(n+3) { display: none; }
}
@media (max-width: 760px) {
  html, body { overflow: auto; }
  .app-shell { min-height: 100vh; height: auto; grid-template-rows: auto auto auto; }
  .topbar { flex-wrap: wrap; height: auto; }
  .workflow-tabs { order: 2; width: 100%; overflow-x: auto; border-top: 1px solid var(--border); }
  .workspace { display: block; }
  .tool-rail { position: fixed; z-index: 10; left: 0; top: 72px; bottom: 34px; width: min(90vw, var(--rail-width)); box-shadow: 10px 0 25px #0009; }
  .rail-hidden .tool-rail { display: none; }
  .analysis-workspace { height: calc(100vh - 106px); display: grid; grid-template: minmax(260px, 55%) 5px minmax(220px, 45%) / 1fr; }
  .splitter { cursor: row-resize; }
  .playback-bar { position: sticky; bottom: 0; }
  .profile-field { display: none; }
}
