/* Vascular Vision — clinician dashboard v2
   Palette: "lead-glass" graphite-teal neutrals (cath-lab screens), one periwinkle
   accent for interaction, and a severity scale that is reserved for findings only. */

/* Fonts are linked from index.html (preconnect + swap) so they never block the first paint. */

:root {
  --bg: #0B1315;
  --panel: #111C1F;
  --panel-2: #16242A;
  --panel-3: #1C2D33;
  --line: #22343A;
  --line-2: #2F474E;
  --ink: #E4ECEA;
  --ink-2: #A3B5B2;
  --ink-3: #6F8784;
  --accent: #8C9BFF;
  --accent-2: #B3BDFF;
  --accent-soft: rgba(140, 155, 255, .14);
  --on-accent: #0B1315;

  --sev-normal: #3DBE8B;
  --sev-mild: #C9C35A;
  --sev-moderate: #F2994A;
  --sev-severe: #F0524F;
  --sev-occlusion: #D454A3;
  --sev-unknown: #6F8784;
  --review: #F6C344;
  --ok: #3DBE8B;
  --danger: #F0524F;

  --viewer: #050808;
  --radius-s: 6px;
  --radius: 10px;
  --radius-l: 14px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.25);
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-ar: 'IBM Plex Sans Arabic', 'IBM Plex Sans', 'Segoe UI', Tahoma, sans-serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #EDF2F1;
  --panel: #FFFFFF;
  --panel-2: #F4F8F7;
  --panel-3: #E9F0EE;
  --line: #D6E1DF;
  --line-2: #C1D0CD;
  --ink: #0E1D1C;
  --ink-2: #4A5E5B;
  --ink-3: #74898A;
  --accent: #4757D6;
  --accent-2: #3341B8;
  --accent-soft: rgba(71, 87, 214, .10);
  --on-accent: #FFFFFF;
  --sev-normal: #1D9A69;
  --sev-mild: #8E8712;
  --sev-moderate: #D16F17;
  --sev-severe: #D2342F;
  --sev-occlusion: #AE2D7E;
  --review: #A87A00;
  --ok: #1D9A69;
  --danger: #D2342F;
  --shadow: 0 1px 2px rgba(14,29,28,.06), 0 6px 20px rgba(14,29,28,.06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
[dir="rtl"], .ar { font-family: var(--font-ar); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 24px; line-height: 1.2; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 12px; }
.xs { font-size: 11px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack > * + * { margin-top: 12px; }
.grow { flex: 1; min-width: 0; }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.s { width: 14px; height: 14px; }
.icon.l { width: 20px; height: 20px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Top bar ───────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: 1480px; margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; font-size: 15px; }
.brand:hover { color: var(--ink); }
.brand svg { width: 28px; height: 28px; }
.brand small { display: block; font-weight: 400; color: var(--ink-3); font-size: 11px; margin-top: -2px; }
.nav { display: flex; gap: 2px; }
.nav a {
  color: var(--ink-2); padding: 7px 12px; border-radius: 8px; font-weight: 500; font-size: 13px;
  display: inline-flex; gap: 6px; align-items: center;
}
.nav a:hover { color: var(--ink); background: var(--panel-2); }
.nav a.active { color: var(--ink); background: var(--panel-3); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; border-left: 1px solid var(--line); margin-left: 6px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 600; font-size: 12px; }
.role-tag { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ── Layout ────────────────────────────────────────────────────────── */
main { max-width: 1480px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { color: var(--ink-2); margin-top: 4px; max-width: 64ch; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow); }
.panel-pad { padding: 18px 20px; }
.panel-head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head h2, .panel-head h3 { display: flex; align-items: center; gap: 8px; }
.sub { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); }

/* ── Buttons & inputs ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--ink); font-weight: 500; font-size: 13px; cursor: pointer;
  transition: background-color .12s, border-color .12s, color .12s; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--panel-3); border-color: var(--ink-3); color: var(--ink); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); border-color: var(--accent-2); color: var(--on-accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover:not(:disabled) { background: var(--panel-2); border-color: transparent; color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn.danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.icon-only { width: 34px; padding: 0; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 14px; }
.btn.block { width: 100%; }

.field { display: block; }
.field > .seg { display: flex; }
.field > .seg button { flex: 1; justify-content: center; height: 32px; }
.field > .seg button.on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.field > span { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); margin-bottom: 5px; }
.input, select.input, textarea.input {
  width: 100%; background: var(--panel-2); color: var(--ink); border: 1px solid var(--line-2);
  border-radius: 8px; padding: 8px 11px; font: inherit; font-size: 13px; min-height: 36px;
}
textarea.input { resize: vertical; min-height: 64px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[readonly] { color: var(--ink-3); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }

.alert { padding: 10px 12px; border-radius: 9px; font-size: 13px; display: flex; gap: 9px; align-items: flex-start; border: 1px solid; }
.alert.err { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.alert.warn { color: var(--review); background: color-mix(in srgb, var(--review) 10%, transparent); border-color: color-mix(in srgb, var(--review) 40%, transparent); }
.alert.info { color: var(--ink-2); background: var(--panel-2); border-color: var(--line); }

/* ── Badges / severity ─────────────────────────────────────────────── */
.sev-NORMAL { --c: var(--sev-normal); }
.sev-MILD { --c: var(--sev-mild); }
.sev-MODERATE { --c: var(--sev-moderate); }
.sev-SEVERE { --c: var(--sev-severe); }
.sev-OCCLUSION { --c: var(--sev-occlusion); }
.sev-UNKNOWN { --c: var(--sev-unknown); }
.sev-LOWCONF { --c: var(--sev-unknown); }
.lowconf { margin-top: 12px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink-2); display: grid; gap: 4px; }
.acard.sev-LOWCONF { opacity: .9; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  color: var(--c, var(--ink-2)); background: color-mix(in srgb, var(--c, var(--ink-3)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, var(--ink-3)) 35%, transparent);
}
.badge.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.review { --c: var(--review); border-style: dashed; }
.badge.ok { --c: var(--ok); }
.badge.err { --c: var(--danger); }
.badge.neutral { --c: var(--ink-3); color: var(--ink-2); }
.badge.accent { --c: var(--accent); }

/* ── Dashboard ─────────────────────────────────────────────────────── */
.overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 2.2fr); gap: 12px; margin-bottom: 18px; }
.overview.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.now > *, .workspace > *, .lower > *, .upload-grid > * { min-width: 0; }
.tile { padding: 16px 18px; display: flex; flex-direction: column; justify-content: space-between; min-height: 112px; }
.tile .k { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 7px; }
.tile .v { font-size: 30px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; margin-top: 10px; }
.tile .d { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.tile.attn .v { color: var(--review); }
.tile.occl .v { color: var(--sev-occlusion); }
.dist .bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; gap: 2px; margin: 14px 0 12px; background: var(--panel-2); }
.dist .bar span { background: var(--c); min-width: 3px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: var(--c); margin-right: 6px; vertical-align: -1px; }
.legend b { color: var(--ink); font-weight: 600; margin-left: 3px; }

.jobs { margin-bottom: 18px; }
.job-row { display: grid; grid-template-columns: minmax(180px, 1.1fr) 3fr auto; gap: 18px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--line); }
.job-row:first-of-type { border-top: 0; }
.mini-track { display: flex; gap: 3px; }
.mini-track span { flex: 1; height: 6px; border-radius: 3px; background: var(--panel-3); }
.mini-track span.done { background: color-mix(in srgb, var(--accent) 55%, var(--panel-3)); }
.mini-track span.active { background: var(--accent); animation: pulse 1.6s ease-in-out infinite; }
.mini-track span.fail { background: var(--danger); }
@keyframes pulse { 50% { opacity: .45; } }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--ink-2); font-size: 12.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--bg); font-weight: 600; }
.chip .n { font-size: 11px; opacity: .75; }
.search { position: relative; }
.search .icon { position: absolute; left: 10px; top: 10px; color: var(--ink-3); }
.search input { padding-left: 32px; width: 240px; }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 500; font-size: 12px; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13px; }
.tbl tbody tr { transition: background-color .1s; }
.tbl tbody tr:hover { background: var(--panel-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.tbl tr.clickable { cursor: pointer; }
.tbl input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }
.study-name { font-weight: 600; color: var(--ink); }
.study-id { font-size: 11.5px; color: var(--ink-3); }
.pills { display: flex; gap: 4px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 7px 0 5px; border-radius: 5px; background: color-mix(in srgb, var(--c, var(--sev-unknown)) 14%, transparent); color: var(--c, var(--sev-unknown)); font-size: 11.5px; font-weight: 600; }
.pill::before { content: ''; width: 4px; height: 12px; border-radius: 2px; background: var(--c, var(--sev-unknown)); }
.pill.rv { outline: 1px dashed var(--review); outline-offset: 1px; }
.empty { padding: 56px 20px; text-align: center; }
.empty > .icon { width: 36px; height: 36px; color: var(--ink-3); margin-bottom: 10px; }
.empty h3 { margin-bottom: 6px; }
.empty p { color: var(--ink-2); max-width: 44ch; margin: 0 auto 16px; }
.table-wrap { overflow-x: auto; }

/* ── Upload ────────────────────────────────────────────────────────── */
.upload-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.drop {
  border: 1.5px dashed var(--line-2); border-radius: var(--radius-l); padding: 48px 24px; text-align: center; cursor: pointer;
  background: repeating-linear-gradient(135deg, transparent 0 14px, color-mix(in srgb, var(--panel-3) 50%, transparent) 14px 15px), var(--panel);
  transition: border-color .15s, background-color .15s; display: block;
}
.drop:hover, .drop.over { border-color: var(--accent); }
.drop .icon { width: 34px; height: 34px; color: var(--accent); }
.drop h2 { margin: 12px 0 4px; }
.file-card { display: flex; gap: 14px; align-items: center; padding: 14px 16px; }
.file-ico { width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.progress { height: 8px; border-radius: 4px; background: var(--panel-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s ease; }
.progress.big { height: 12px; border-radius: 6px; }
.progress.est > span { background: repeating-linear-gradient(-45deg, var(--accent) 0 8px, color-mix(in srgb, var(--accent) 70%, transparent) 8px 16px); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; color: var(--ink); text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stats4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.stats4 > div { background: var(--panel-2); padding: 10px 12px; }
.stats4 .k { font-size: 11.5px; color: var(--ink-3); }
.stats4 .v { font-size: 16px; font-weight: 600; margin-top: 2px; }
.steps-list { counter-reset: s; list-style: none; margin: 0; padding: 0; }
.steps-list li { counter-increment: s; display: flex; gap: 12px; padding: 8px 0; font-size: 13px; color: var(--ink-2); }
.steps-list li::before { content: counter(s); width: 22px; height: 22px; flex: none; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; font-size: 11px; color: var(--ink-3); }

/* ── Stage track (signature #1) ───────────────────────────────────── */
.track { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: relative; padding: 22px 20px 18px; }
.step { position: relative; text-align: center; padding: 0 4px; }
.step::before { content: ''; position: absolute; top: 15px; left: calc(-50% + 18px); right: calc(50% + 18px); height: 2px; background: var(--line-2); }
.step:first-child::before { display: none; }
.step.done::before, .step.active::before, .step.fail::before { background: var(--accent); }
.dotc { width: 32px; height: 32px; border-radius: 50%; margin: 0 auto 10px; display: grid; place-items: center; border: 2px solid var(--line-2); background: var(--panel); color: var(--ink-3); position: relative; z-index: 1; }
.step.done .dotc { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.step .dotc .icon { stroke-width: 3; }
.step.active .dotc { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.step.fail .dotc { border-color: var(--danger); background: var(--danger); color: #fff; }
.step.skip { opacity: .4; }
.step .t { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.step.active .t, .step.done .t { color: var(--ink); }
.step .s { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.now { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.now-title { font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.clock { font-size: 40px; font-weight: 600; letter-spacing: -.02em; line-height: 1; }

/* ── Result workspace ──────────────────────────────────────────────── */
.result-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 14px; }
.result-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meta-line { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--ink-2); font-size: 12.5px; margin-top: 6px; }
.meta-line span { display: inline-flex; align-items: center; gap: 5px; }
.disclaimer { display: flex; gap: 10px; align-items: center; padding: 9px 14px; border-radius: 9px; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2); font-size: 12.5px; margin-bottom: 16px; }
.workspace { display: grid; grid-template-columns: 340px minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.col-scroll { max-height: calc(100vh - 210px); overflow-y: auto; padding-right: 2px; }

/* Artery card (signature #2) */
.acard { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 14px 16px 14px 18px; cursor: pointer; transition: border-color .12s, background-color .12s; text-align: left; width: 100%; display: block; }
.acard::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 3px 3px 0; background: var(--c, var(--sev-unknown)); }
.acard:hover { border-color: var(--line-2); }
.acard.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, var(--panel)); box-shadow: 0 0 0 1px var(--accent); }
.acard + .acard { margin-top: 10px; }
.acard .name { font-weight: 600; font-size: 14.5px; }
.acard .name-ar { font-family: var(--font-ar); color: var(--ink-2); font-size: 13px; }
.acard .vid { font-size: 11.5px; color: var(--ink-3); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.metric .k { font-size: 11px; color: var(--ink-3); }
.metric .v { font-size: 15px; font-weight: 600; white-space: nowrap; }
.metric .v small { font-size: 11px; font-weight: 500; color: var(--ink-3); margin-left: 1px; }
.flags { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.flag { display: flex; gap: 7px; align-items: flex-start; font-size: 12px; line-height: 1.4; padding: 7px 9px; border-radius: 7px; border: 1px dashed color-mix(in srgb, var(--review) 55%, transparent); color: var(--review); background: color-mix(in srgb, var(--review) 8%, transparent); }
.flag.neutral { border-style: solid; border-color: var(--line); color: var(--ink-2); background: var(--panel-2); }
.flag.occl { border-style: solid; border-color: color-mix(in srgb, var(--sev-occlusion) 50%, transparent); color: var(--sev-occlusion); background: color-mix(in srgb, var(--sev-occlusion) 9%, transparent); }

/* Stenosis gauge */
.gauge { margin-top: 12px; }
.gauge-bar { position: relative; height: 12px; border-radius: 6px; display: flex; overflow: visible; }
.gauge-bar .z { height: 100%; opacity: .26; }
.gauge-bar .z:first-child { border-radius: 6px 0 0 6px; }
.gauge-bar .z:last-child { border-radius: 0 6px 6px 0; }
.gauge-bar .tol { position: absolute; top: -3px; bottom: -3px; border-radius: 4px; background: color-mix(in srgb, var(--ink) 14%, transparent); border: 1px solid color-mix(in srgb, var(--ink) 30%, transparent); }
.gauge-bar .mk { position: absolute; top: -5px; width: 4px; height: 22px; margin-left: -2px; border-radius: 2px; background: var(--c, var(--ink)); box-shadow: 0 0 0 2px var(--panel); }
.gauge-bar.occl { background: repeating-linear-gradient(-45deg, color-mix(in srgb, var(--sev-occlusion) 70%, transparent) 0 5px, color-mix(in srgb, var(--sev-occlusion) 25%, transparent) 5px 10px); border-radius: 6px; }
.gauge-scale { position: relative; height: 16px; font-size: 10.5px; color: var(--ink-3); margin-top: 3px; }
.gauge-scale span { position: absolute; transform: translateX(-50%); }
.gauge-scale span:first-child { transform: none; }
.gauge-scale span:last-child { transform: translateX(-100%); }
.acard .wire-line { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-2); display: flex; justify-content: space-between; gap: 8px; }

/* Viewer */
.viewer-panel { overflow: hidden; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; height: 28px; padding: 0 11px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.2); }
:root[data-theme="light"] .seg button.on { background: #fff; }
/* The whole frame is always visible: the stage is a square capped by the viewport height,
   and the media is absolutely positioned and letterboxed inside it. */
#vbody { background: var(--viewer); }
.stage { background: var(--viewer); position: relative; width: 100%; max-width: min(100%, calc(100vh - 290px)); min-width: 260px; aspect-ratio: 1 / 1; margin: 0 auto; overflow: hidden; }
.stage video, .stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; -webkit-user-drag: none; }
.stage .msg { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); }
.stage .tag { position: absolute; top: 10px; left: 10px; font-size: 11.5px; padding: 3px 8px; border-radius: 6px; background: rgba(0,0,0,.6); color: #E4ECEA; }
.stage .tag.r { left: auto; right: 10px; }
.stage .msg { color: #8FA3A0; margin: auto; font-size: 13px; text-align: center; padding: 20px; max-width: 40ch; }
.vctrl { background: #0E1517; color: #D5E0DE; padding: 10px 14px 12px; border-top: 1px solid #1B282B; }
.vctrl .btn.ghost { color: #A9BBB8; }
.vctrl .btn.ghost:hover { background: #1A272A; color: #fff; }
.scrub { position: relative; height: 22px; margin-bottom: 6px; }
.scrub input[type=range] { position: absolute; inset: 0; width: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 2; }
.scrub .rail { position: absolute; left: 0; right: 0; top: 9px; height: 4px; border-radius: 2px; background: #24343A; }
.scrub .fill { position: absolute; left: 0; top: 9px; height: 4px; border-radius: 2px; background: var(--accent); }
.scrub .knob { position: absolute; top: 4px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px var(--accent); }
.scrub .tick { position: absolute; top: 2px; width: 2px; height: 18px; margin-left: -1px; background: var(--review); border-radius: 1px; opacity: .9; }
.scrub .tick.best { background: #fff; width: 3px; }
.thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 12px 14px; border-top: 1px solid var(--line); }
.thumb { flex: none; width: 84px; border-radius: 8px; overflow: hidden; border: 2px solid transparent; cursor: pointer; background: var(--viewer); padding: 0; position: relative; }
.thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.thumb span { position: absolute; left: 4px; bottom: 4px; font-size: 10.5px; padding: 1px 5px; border-radius: 4px; background: rgba(0,0,0,.7); color: #fff; }
.thumb.on { border-color: var(--accent); }

/* Detail column */
.big-sev { display: flex; align-items: baseline; gap: 10px; }
.big-sev .ds { font-size: 40px; font-weight: 600; line-height: 1; letter-spacing: -.02em; color: var(--c); }
.ffr { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ffr > div { background: var(--panel-2); padding: 12px 14px; }
.ffr .k { font-size: 11.5px; color: var(--ink-3); }
.ffr .v { font-size: 26px; font-weight: 600; letter-spacing: -.01em; margin-top: 2px; }
.ffr .n { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.ffr .ffr-in { font-size: 24px; font-weight: 600; height: 44px; margin-top: 2px; padding: 4px 10px; }
.ffr .full { grid-column: 1 / -1; padding: 8px 14px; font-size: 12px; color: var(--ink-2); }
.lesions { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.lesions td, .lesions th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.lesions th { color: var(--ink-3); font-weight: 500; }
.entry { padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); font-size: 12.5px; }
.entry + .entry { margin-top: 8px; }
.agree { font-weight: 600; }
.agree.y { color: var(--ok); }
.agree.n { color: var(--review); }
details.fold > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px; font-weight: 600; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .chev { transition: transform .15s; color: var(--ink-3); }
details.fold[open] > summary .chev { transform: rotate(180deg); }
details.fold > .fold-body { padding: 0 20px 18px; }
.timeline { display: flex; height: 26px; border-radius: 6px; overflow: hidden; gap: 2px; }
.timeline span { background: var(--c, var(--panel-3)); min-width: 4px; }
.lower { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
pre.summary { white-space: pre-wrap; font-size: 12px; color: var(--ink-2); margin: 0; max-height: 320px; overflow: auto; }

/* ── Auth ─────────────────────────────────────────────────────────── */
.auth { min-height: calc(100vh - 60px); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.auth-art { position: relative; background: #050707; color: #DDE7E5; padding: 48px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; }
.auth-art .tree { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.auth-art::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 45%; background: linear-gradient(to top, rgba(5,7,7,.95), rgba(5,7,7,0)); pointer-events: none; }
.auth-art .copy { position: relative; z-index: 1; max-width: 46ch; }
.auth-art h1 { font-size: 34px; line-height: 1.15; letter-spacing: -.02em; color: #fff; }
.auth-art p { color: #9DB0AD; margin-top: 12px; font-size: 15px; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 400px; }
.auth-box h2 { font-size: 22px; margin-bottom: 4px; }

/* ── Markdown (limitations) ───────────────────────────────────────── */
.md { font-size: 14px; line-height: 1.7; max-width: 92ch; }
.md h1 { font-size: 22px; margin: 4px 0 14px; }
.md h2 { font-size: 17px; margin: 26px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 15px; margin: 18px 0 6px; }
.md p { margin: 8px 0; color: var(--ink); }
.md ul { padding-inline-start: 20px; margin: 6px 0; }
.md li { margin: 4px 0; }
.md blockquote { margin: 12px 0; padding: 10px 14px; border-inline-start: 3px solid var(--accent); background: var(--panel-2); border-radius: 6px; }
.md code { background: var(--panel-3); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.md pre.mdpre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: 10px 0; }
.md pre.mdpre code { background: none; padding: 0; font-size: 13px; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.md .tw { overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; margin: 12px 0; }
.md table { border-collapse: collapse; width: 100%; font-size: 13px; }
.md th, .md td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.md th { background: var(--panel-2); font-weight: 600; }

/* ── Toasts / modal ───────────────────────────────────────────────── */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 9px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.35); max-width: 380px; animation: tin .18s ease-out; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 90; padding: 20px; }
.modal { width: 100%; max-width: 420px; padding: 22px; }
.modal h3 { font-size: 16px; margin-bottom: 6px; }
.modal p { color: var(--ink-2); }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .workspace { grid-template-columns: 300px minmax(0, 1fr); }
  .workspace > .detail-col { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .workspace > .detail-col > * + * { margin-top: 0; }
  .overview { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .overview .dist { grid-column: 1 / -1; }
}
@media (max-width: 960px) {
  .workspace, .workspace > .detail-col, .now, .upload-grid, .lower, .auth { grid-template-columns: 1fr; }
  .col-scroll { max-height: none; }
  .auth-art { min-height: 260px; padding: 28px; }
  .overview, .overview.four { grid-template-columns: 1fr 1fr; }
  .track { grid-auto-flow: row; grid-auto-columns: auto; padding: 16px 20px; }
  .step { display: grid; grid-template-columns: 32px 1fr; column-gap: 12px; text-align: left; padding: 0 0 14px; }
  .step::before { top: calc(-50% + 16px); bottom: calc(50% + 16px); left: 15px; right: auto; width: 2px; height: auto; }
  .step .dotc { margin: 0; grid-row: span 2; }
  .nav a span { display: none; }
  .job-row { grid-template-columns: 1fr; gap: 8px; }
  .search input { width: 100%; }
  .stats4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  main { padding: 20px 14px 48px; }
  /* Mobile: brand + account on the first row, navigation scrolls on its own second row */
  .topbar-in { padding: 8px 14px 0; gap: 8px; height: auto; flex-wrap: wrap; }
  .nav { order: 3; width: 100%; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a span { display: inline; }
  .user-chip { margin-left: 0; padding-left: 6px; }
  .page-head { align-items: flex-start; }
  .page-head .seg { max-width: 100%; overflow-x: auto; }
  .stats4 .v { font-size: 14px; }
  .auth-art { min-height: 200px; padding: 20px; }
  .auth-art h1 { font-size: 24px; }
  .auth-art p { display: none; }
  .brand small, .user-chip .uname { display: none; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* Result header: side / segment chip */
.site-chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px 2px 8px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--panel-2); color: var(--ink); }
.site-chip .btn.sm { height: 24px; padding: 0 8px; }

/* Printable report */
#print-root { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body.printing > *:not(#print-root) { display: none !important; }
  body.printing #print-root { display: block; }
  body:not(.printing) .topbar, body:not(.printing) .btn, body:not(.printing) .vctrl, body:not(.printing) .thumbs, body:not(.printing) form { display: none !important; }
  html, body { background: #fff !important; color: #000; }
  .rp { font: 11pt/1.4 'IBM Plex Sans', Arial, sans-serif; color: #111; }
  .rp-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #111; padding-bottom: 6px; margin-bottom: 10px; }
  .rp-brand { font-size: 9pt; letter-spacing: .08em; text-transform: uppercase; color: #555; }
  .rp h1 { font-size: 16pt; margin: 2px 0 0; }
  .rp-meta { text-align: right; font-size: 9pt; color: #555; }
  .rp table { width: 100%; border-collapse: collapse; margin: 8px 0; }
  .rp-kv th { text-align: left; font-weight: 600; color: #555; width: 16%; padding: 3px 6px; font-size: 9.5pt; }
  .rp-kv td { padding: 3px 6px; font-size: 10pt; }
  .rp-t th { background: #eee; text-align: left; padding: 5px; font-size: 9pt; border-bottom: 1px solid #999; }
  .rp-t td { padding: 5px; border-bottom: 1px solid #ddd; font-size: 9.5pt; vertical-align: top; }
  .rp-note td { font-size: 8.5pt; color: #444; border-bottom: 1px solid #ccc; padding-top: 0; }
  .rp-sm { font-size: 8.5pt; color: #555; }
  .rp-warn { border: 1px solid #b38600; background: #fff7e0; padding: 5px 8px; font-size: 9pt; }
  .rp-imgs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; page-break-inside: avoid; }
  .rp-imgs figure { margin: 0; }
  .rp-imgs img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #000; }
  .rp-imgs figcaption { font-size: 8pt; color: #444; margin-top: 2px; }
}

/* ── Multi-file upload, account ───────────────────────────────────── */
.file-rows { border-bottom: 1px solid var(--line); max-height: 360px; overflow-y: auto; }
.file-rows.sub { border: 1px solid var(--line); border-radius: var(--radius); }
.file-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); }
.file-row:first-child { border-top: 0; }
.file-row.bad { background: color-mix(in srgb, var(--danger) 6%, transparent); }
.file-row .fname { font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.file-ico.sm { width: 32px; height: 32px; border-radius: 8px; }
.input.sm-in { width: auto; min-height: 30px; height: 30px; padding: 0 8px; font-size: 12px; }
.pw-rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; color: var(--ink-3); }
.pw-rules li { display: flex; align-items: center; gap: 6px; }
.pw-rules li.ok { color: var(--ok); }
@media (max-width: 640px) { .file-row { flex-wrap: wrap; } .input.sm-in { flex: 1; } }

/* FFR (est.) must never look like a measured wire value */
.ffr .ffr-est { background: repeating-linear-gradient(135deg, var(--panel-2) 0 10px, color-mix(in srgb, var(--panel-3) 60%, var(--panel-2)) 10px 11px); }
.ffr .ffr-est .v { color: var(--ink-2); font-style: italic; font-weight: 500; }
.ffr .ffr-est .k .icon { width: 12px; height: 12px; vertical-align: -1px; }
.ffr .na, .metric .v.na { font-size: 15px; font-style: normal; color: var(--ink-3); }
.metric[title] { cursor: help; }
.metric.est .v { font-style: italic; font-weight: 500; color: var(--ink-2); }
