:root {
  --bg: #071018;
  --bg-2: #0b1620;
  --panel: #10202b;
  --line: rgba(125, 211, 192, 0.18);
  --teal: #7dd3c0;
  --teal-2: #4aa392;
  --ink: #e7f0ea;
  --muted: #8aa0a6;
  --paper: #f4efe4;
  --paper-ink: #1c241f;
  --danger: #e08b8b;
  --warn: #d7b56a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Manrope, sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(125, 211, 192, 0.08), transparent 50%),
    linear-gradient(180deg, #08131b, var(--bg));
  color: var(--ink);
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 380px;
  grid-template-rows: 64px 1fr;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 16, 24, 0.9);
  backdrop-filter: blur(12px);
}

.brand { display: flex; gap: 12px; align-items: center; }
.brand strong {
  font-family: Syne, sans-serif;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  display: block;
}
.brand span { color: var(--muted); font-size: 0.78rem; }

.mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: conic-gradient(from 140deg, var(--teal), #1d4e45, var(--teal));
  position: relative;
}
.mark::after {
  content: "";
  position: absolute; inset: 8px;
  border: 1.5px solid #071018;
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px transparent, 0 0 0 1px rgba(7,16,24,.4);
}

.top-actions { display: flex; gap: 8px; }
.rail, .viewport-col, .report-col { min-height: 0; }
.rail {
  border-right: 1px solid var(--line);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(11, 22, 32, 0.7);
}

.dropzone {
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(125,211,192,0.06), transparent);
}
.dropzone.hot { border-color: var(--teal); background: rgba(125,211,192,0.1); }
.drop-kicker {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.68rem;
  color: var(--teal);
  margin: 0 0 6px;
}
h2, h3 { margin: 0 0 8px; font-family: Syne, sans-serif; }
.muted { color: var(--muted); font-size: 0.86rem; line-height: 1.45; }
.intake-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

label.btn, .btn, .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 8px 14px;
  font: 600 0.82rem Manrope, sans-serif;
  color: var(--ink);
  background: #132531;
  cursor: pointer;
}
label.btn input { display: none; }
.btn.primary, label.btn.primary {
  background: var(--teal);
  color: #062019;
  border-color: transparent;
}
.ghost { background: transparent; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.panel {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  overflow: auto;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.chip {
  font-size: 0.72rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
}
.chip.ok { color: #062019; background: var(--teal); border-color: transparent; }
.chip.warn { color: #3b2a08; background: var(--warn); border-color: transparent; }
.series-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.series-card {
  text-align: left;
  width: 100%;
  border: 1px solid var(--line);
  background: #0d1c26;
  color: var(--ink);
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
}
.series-card.active { border-color: var(--teal); }
.series-card small { display: block; color: var(--muted); margin-top: 4px; }
.empty { color: var(--muted); }

.viewport-col {
  display: grid;
  grid-template-rows: 1fr auto auto;
  padding: 16px;
  gap: 10px;
}
.viewer-frame {
  position: relative;
  background: #000;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
}
#dicomCanvas { max-width: 100%; max-height: 62vh; image-rendering: pixelated; cursor: crosshair; }
.crosshair {
  pointer-events: none;
  position: absolute; inset: 0;
  background:
    linear-gradient(#7dd3c033, #7dd3c033) center/1px 28% no-repeat,
    linear-gradient(#7dd3c033, #7dd3c033) center/28% 1px no-repeat;
}
.viewer-meta, .viewer-hud {
  position: absolute;
  font-size: 0.75rem;
  color: #d7efe8;
  text-shadow: 0 1px 8px #000;
}
.viewer-meta { top: 12px; left: 14px; }
.viewer-hud { bottom: 12px; left: 14px; right: 14px; display: flex; justify-content: space-between; }
.viewer-tools input { width: 100%; accent-color: var(--teal); }
.tool-hint { color: var(--muted); font-size: 0.75rem; margin-top: 6px; }
.filmstrip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  min-height: 72px;
}
.filmstrip canvas, .filmstrip .thumb {
  width: 64px; height: 64px; border-radius: 8px; border: 1px solid var(--line); cursor: pointer;
}
.filmstrip .thumb.active { outline: 2px solid var(--teal); }

.report-col {
  border-left: 1px solid var(--line);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(11, 22, 32, 0.55);
}
.report-toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.report-paper {
  flex: 1;
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 16px;
  padding: 22px;
  overflow: auto;
  font-family: "IBM Plex Serif", serif;
  box-shadow: var(--shadow);
}
.report-paper h1 { font-size: 1.15rem; margin: 0 0 4px; }
.report-paper h2 { font-size: 0.95rem; margin: 16px 0 6px; font-family: Manrope, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; }
.report-placeholder { color: #6d6456; }
.finding { border-left: 3px solid #c8b48a; padding: 6px 10px; margin: 8px 0; background: #ebe3d4; }
.finding.significant { border-color: #b85c5c; }
.finding.incidental { border-color: #b8943a; }
.disclaimer { color: var(--muted); font-size: 0.72rem; line-height: 1.4; }

.overlay {
  position: fixed; inset: 0;
  background: rgba(5, 10, 14, 0.72);
  display: grid; place-items: center;
  z-index: 20;
}
.overlay.hidden { display: none; }
.progress-card {
  width: min(420px, 90vw);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.scan-line {
  position: absolute; left: 0; right: 0; height: 2px; background: var(--teal);
  animation: scan 1.4s linear infinite;
}
@keyframes scan { from { top: 0; } to { top: 100%; } }
.progress-card ol { margin: 12px 0 0; padding-left: 18px; color: var(--muted); }
.progress-card li.active { color: var(--teal); }
.progress-card li.done { color: var(--ink); }

dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg-2);
  color: var(--ink);
  width: min(420px, 92vw);
}
.settings-form { display: flex; flex-direction: column; gap: 10px; }
.settings-form input {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0b1820;
  color: var(--ink);
}
menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: auto auto auto auto; }
  .rail, .report-col { border: 0; }
}
