/* cansr.css — shared stylesheet */

/* ── fonts ── */
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/AtkinsonHyperlegibleNext-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/AtkinsonHyperlegibleNext-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/AtkinsonHyperlegibleNext-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

/* ── design tokens ── */
:root {
  /* colour */
  --primary: oklch(0.322 0.065 161);
  --brand: var(--primary);
  --accent: oklch(0.58 0.128 161);
  --accent-soft: oklch(0.91 0.05 161);
  --bg-dark: oklch(0.943 0.003 265);
  --bg: oklch(0.968 0.003 265);
  --bg-light: #fff;
  --surface: #fff;
  --text: oklch(0.221 0.01 264);
  --text-2: oklch(0.35 0.012 265);
  --muted: oklch(0.50 0.014 265);
  --border: oklch(0.88 0.009 258);
  --border-soft: oklch(0.93 0.007 258);
  --attention: oklch(0.32 0.2 240);
  --attention-tint: oklch(0.95 0.025 240);
  --attention-line: oklch(0.32 0.2 240 / 0.35);
  --danger: oklch(0.579 0.214 27);
  --gold: oklch(0.786 0.16 85);

  /* alpha variants and state colours */
  --primary-dark: oklch(0.3 0.07 162); /* darkened brand — hover state only */
  --bg-dark-50: oklch(94% 0.005 255 / 0.5); /* bg-dark at 50% alpha */
  --ai-line: oklch(55% 0.12 245 / 0.15); /* AI signal border */
  --ok-line: oklch(72% 0.09 155 / 0.35); /* positive signal border */
  --ok-line-30: oklch(72% 0.09 155 / 0.3); /* ok-line at 30% alpha */
  --warn-line: oklch(70% 0.12 70 / 0.4); /* warning signal border */
  --err-line: oklch(68% 0.15 28 / 0.35); /* error signal border */
  --err-line-30: oklch(68% 0.15 28 / 0.3); /* err-line at 30% alpha */
  --backdrop: oklch(20% 0.01 264 / 0.45); /* modal backdrop */
  --danger-shadow: oklch(0.579 0.214 27 / 0.08); /* danger at 8% alpha */
  --accent-focus:  oklch(0.58 0.128 161 / 0.12); /* accent focus ring shadow */
  --gloss-sm:      oklch(100% 0 none / 0.12);    /* white inset button gloss */
  --shadow-sm: oklch(0% 0 none / 0.08); /* small shadow colour */
  --shadow-md: oklch(0% 0 none / 0.16); /* medium shadow colour */

  /* pipeline state dot tokens */
  --state-queued-dot:     oklch(0.62 0.09 255);
  --state-processing-dot: oklch(0.78 0.16 85);
  --state-complete-dot:   var(--accent);
  --state-errored-dot:    var(--danger);

  /* stuck-label tokens */
  --state-stuck-bg:     oklch(0.95 0.03 85);
  --state-stuck-text:   oklch(0.52 0.14 85);
  --state-stuck-border: var(--warn-line);

  /* outcome chip tokens */
  --chip-running-bg:        oklch(0.94 0.025 255);
  --chip-running-text:      oklch(0.40 0.06 255);
  --chip-running-border:    oklch(0.62 0.09 255 / 0.4);
  --chip-processing-bg:     oklch(0.95 0.03 85);
  --chip-processing-text:   oklch(0.52 0.14 85);
  --chip-processing-border: oklch(0.70 0.12 85 / 0.4);
  --chip-complete-bg:       oklch(0.94 0.03 155);
  --chip-complete-text:     oklch(0.35 0.12 155);
  --chip-complete-border:   oklch(0.50 0.12 155 / 0.35);
  --chip-partial-bg:        oklch(0.95 0.03 85);
  --chip-partial-text:      oklch(0.52 0.14 85);
  --chip-failed-bg:         oklch(0.95 0.025 27);
  --chip-failed-text:       oklch(0.45 0.18 27);

  /* user badge tokens */
  --badge-super-admin-bg:     oklch(0.93 0.03 161);
  --badge-super-admin-text:   oklch(0.32 0.065 161);
  --badge-super-admin-border: oklch(0.58 0.128 161 / 0.3);
  --badge-current-user-bg:    var(--chip-running-bg);

  /* shadows */
  --shadow-row: 0 1px 2px oklch(0% 0 none / 0.03);
  --shadow-row-hover:
    0 1px 2px oklch(0% 0 none / 0.04), 0 6px 18px -8px oklch(0% 0 none / 0.1);

  /* radii */
  --radius-sm: 0.3rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-full: 999px;

  /* layout */
  --size-topbar-height: 3.5rem;

  /* type scale — φ^(n/2) */
  --text-minus-2: 0.618rem;
  --text-minus-1: 0.786rem;
  --text-0: 1rem;
  --text-plus-1: 1.272rem;
  --text-plus-2: 1.618rem;
  --text-plus-3: 2.058rem;
  --text-plus-4: 2.618rem;
  --lh: 1.618;

  /* spacing — φ^n, used in radiologist */
  --space-xs: 0.236rem;
  --space-sm: 0.382rem;
  --space-md: 0.618rem;
  --space-lg: 1rem;
  --space-xl: 1.618rem;
  --space-2xl: 2.618rem;
}

/* ── reset ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg-dark);
  font-family:
    "Atkinson Hyperlegible Next",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  color: var(--text);
  line-height: var(--lh);
}

a {
  text-decoration: none;
  color: inherit;
}

/* ── utility ── */
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ── form field ── */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}
.field label {
  font-size: var(--text-minus-1);
  font-weight: 600;
  color: var(--text);
  line-height: 1.618;
  transition: color 150ms;
}
.field:has(input:focus-visible, select:focus-visible) label {
  color: var(--brand);
}
.field input,
.field select {
  font: 400 1rem/1.618 inherit;
  color: var(--text);
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-md) var(--space-lg);
  min-height: 44px;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 150ms, box-shadow 150ms, background-color 150ms;
}
.field input:hover,
.field select:hover {
  border-color: var(--muted);
}
.field input:focus-visible,
.field select:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--accent-focus);
}
/* ── buttons ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #fff;
  font: 500 var(--text-minus-1)/1 inherit;
  padding: var(--space-md) var(--space-lg);
  min-height: 44px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: opacity 150ms;
}
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary:not(:disabled):hover { opacity: 0.88; }
.btn-primary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font: 500 var(--text-minus-1)/1 inherit;
  padding: var(--space-md) var(--space-lg);
  min-height: 44px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 150ms, border-color 150ms;
}
.btn-ghost:hover {
  background: var(--bg);
  border-color: var(--muted);
}
.btn-ghost:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.btn-submit {
  display: block;
  width: 100%;
  min-height: 44px;
  background: var(--brand);
  border: 1px solid var(--brand);
  color: #fff;
  font: 600 1rem/1 inherit;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 150ms, border-color 150ms, transform 100ms, opacity 150ms;
}
.btn-submit:hover:not(:disabled) {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}
.btn-submit:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.btn-submit:active:not(:disabled) {
  transform: scale(0.98);
}
.btn-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── topbar ── */
body > header {
  background: var(--surface);
  border-bottom: 0.25rem solid var(--brand);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--size-topbar-height);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

body > header nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.topbar__brand {
  display: flex;
  align-items: center;
  margin-right: 1.5rem;
  color: var(--brand);
}

.topbar__nav-links {
  display: flex;
  align-items: center;
  gap: 0.125rem;
}

.topbar__nav-link {
  display: flex;
  align-items: center;
  padding: 0 0.875rem;
  font: 500 var(--text-minus-1)/var(--size-topbar-height) inherit;
  color: var(--text-2);
  transition: color 150ms;
}

.topbar__nav-link:hover {
  color: var(--brand);
}
.topbar__nav-link.active {
  color: var(--brand);
  font-weight: 600;
}

body > header aside {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar__bell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: none;
  color: var(--text-2);
  font: inherit;
  cursor: pointer;
  transition:
    border-color 150ms,
    color 150ms;
}

.topbar__bell:disabled {
  cursor: default;
}

.topbar__bell:not(:disabled):hover {
  border-color: var(--brand);
  color: var(--brand);
}

.topbar__profile {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  cursor: pointer;
  transition: opacity 150ms;
}

.topbar__profile:hover {
  opacity: 0.8;
}

.topbar__avatar {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  background: var(--brand);
  color: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-minus-2);
  font-weight: 600;
  flex-shrink: 0;
}

.topbar__profile-name {
  font-size: var(--text-0);
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.topbar__profile-role {
  font-size: var(--text-minus-1);
  color: var(--muted);
  line-height: 1.3;
}

.topbar__hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 0.3rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
}

.topbar__hamburger span {
  display: block;
  width: 1.25rem;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition:
    transform 200ms,
    opacity 200ms;
}

.topbar__hamburger.open span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.topbar__hamburger.open span:nth-child(2) {
  opacity: 0;
}
.topbar__hamburger.open span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.topbar__drawer {
  display: none;
  flex-direction: column;
  position: fixed;
  top: var(--size-topbar-height);
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 0.5rem 1rem oklch(0% 0 none / 0.08);
  transform: translateY(-110%);
  opacity: 0;
  transition:
    transform 200ms ease,
    opacity 200ms ease;
  z-index: 999;
}

.topbar__drawer.open {
  transform: translateY(0);
  opacity: 1;
}

.topbar__drawer-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.5rem;
  font: 500 var(--text-0)/1 inherit;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition:
    background 150ms,
    color 150ms;
}

.topbar__drawer-link:last-child {
  border-bottom: none;
}
.topbar__drawer-link:hover {
  background: var(--bg);
  color: var(--brand);
}
.topbar__drawer-link svg {
  color: var(--muted);
  flex-shrink: 0;
  transition: color 150ms;
}
.topbar__drawer-link:hover svg {
  color: var(--brand);
}

/* ── case list layout (clinician + coordinator) ── */
main {
  flex: 1;
  padding: calc(var(--size-topbar-height) + 2rem)
    max(1.5rem, calc((100% - 72rem) / 2 + 1.5rem)) 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0 0.25rem;
}

h1.page-title {
  font-size: var(--text-plus-3);
  font-weight: 600;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -0.01em;
}
h1.page-title .count {
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.date-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

details.date-group {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 150ms;
}
details.date-group[open] {
  border-color: var(--border);
}

details.date-group > summary {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  cursor: pointer;
  list-style: none;
  padding: var(--space-lg);
  user-select: none;
}
details.date-group > summary::-webkit-details-marker {
  display: none;
}

.summary__chev {
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--muted);
  transition:
    transform 200ms,
    color 150ms;
}
details.date-group[open] .summary__chev {
  transform: rotate(90deg);
  color: var(--brand);
}

.summary__date {
  font-size: var(--text-plus-1);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}

.summary__count {
  font-size: var(--text-minus-2);
  font-weight: 600;
  color: var(--brand);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  border: 1px solid oklch(from var(--accent-soft) calc(l - 0.05) c h);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.summary__rule {
  flex: 1;
  height: 1px;
  background: var(--border-soft);
  margin: 0 var(--space-sm);
}

.case-table-wrap {
  padding: 0 var(--space-md) 0.75rem;
}

.case-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.375rem;
  table-layout: auto;
}

.case-table th {
  font-size: var(--text-minus-1);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-2);
  text-align: left;
  padding: 0.25rem 1.272rem;
  white-space: nowrap;
}

.case-table tbody tr {
  background: var(--surface);
  box-shadow: var(--shadow-row);
  cursor: pointer;
  transition:
    box-shadow 150ms,
    border-color 150ms;
}
.case-table tbody tr:hover {
  box-shadow: var(--shadow-row-hover);
}
.case-table tbody tr:hover td {
  border-color: var(--border);
}
.case-table tbody tr:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.case-table td {
  padding: 0.75rem 1.272rem;
  vertical-align: middle;
  text-align: left;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  transition: border-color 150ms;
}
.case-table td:first-child {
  border-left: 1px solid var(--border-soft);
  border-radius: var(--radius) 0 0 var(--radius);
}
.case-cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.618rem;
  font-size: var(--text-0);
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.case-table td:nth-last-child(3),
.case-table td:nth-last-child(2),
.case-table th:nth-child(2),
.case-table th:nth-child(3) {
  white-space: nowrap;
  text-align: left;
}
.case-table td:last-child {
  border-right: 1px solid var(--border-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  width: 1%;
  white-space: nowrap;
}

.chip {
  display: inline-block;
  padding: var(--space-xs) 0.618rem;
  border-radius: 4px;
  font-size: var(--text-minus-1);
  font-weight: 600;
  color: var(--attention);
  border: 1px solid color-mix(in oklch, var(--attention) 30%, transparent);
  background: color-mix(in oklch, var(--attention) 8%, white);
  white-space: nowrap;
  flex-shrink: 0;
}

.classification-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-minus-1);
  font-weight: 600;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-weight: 600;
  font-size: var(--text-minus-1);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
}
.status-chip.queued {
  background: var(--chip-running-bg);
  color: var(--chip-running-text);
  border: 1px solid var(--chip-running-border);
}
.status-chip.processing {
  background: var(--chip-processing-bg);
  color: var(--chip-processing-text);
  border: 1px solid var(--chip-processing-border);
}
.status-chip.complete {
  background: var(--chip-complete-bg);
  color: var(--chip-complete-text);
  border: 1px solid var(--ok-line);
}
.status-chip.errored {
  background: var(--chip-failed-bg);
  color: var(--chip-failed-text);
  border: 1px solid var(--err-line);
}

/* ── verdict chip (NS-12) — streamlining recommendation on queues/lists.
   Three variants mirror the MDT-banner verdict states (green/attention/red);
   colour is always paired with the chip text. Reuses existing tokens. ── */
.verdict-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-weight: 600;
  font-size: var(--text-minus-1);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.verdict-chip.soc {
  background: var(--chip-complete-bg);
  color: var(--chip-complete-text);
  border: 1px solid var(--ok-line);
}
.verdict-chip.mdt {
  background: var(--attention-tint);
  color: var(--attention);
  border: 1px solid var(--attention-line);
}
.verdict-chip.returned {
  background: var(--chip-failed-bg);
  color: var(--chip-failed-text);
  border: 1px solid var(--err-line);
}

/* ── modal ── */
dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: 0 2px 8px var(--shadow-sm), 0 16px 48px var(--shadow-md);
  background: var(--bg-light);
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}
dialog::backdrop {
  background: var(--backdrop);
}
.modal-inner {
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  padding-top: var(--space-sm);
}

/* action feedback (.action-feedback) — in-context success/error for mutating
   POSTs (UX-01 #146). Block-level live region; colour always paired with text. */
.action-feedback {
  display: none;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font: 500 var(--text-0)/1.272 inherit;
}
.action-feedback.is-visible {
  display: block;
}
.action-feedback.success {
  background: var(--chip-complete-bg);
  color: var(--chip-complete-text);
  border-color: var(--chip-complete-border);
}
.action-feedback.error {
  background: var(--chip-failed-bg);
  color: var(--chip-failed-text);
  border-color: var(--err-line);
}

body > footer {
  text-align: left;
  padding: 1rem max(2rem, calc((100% - 72rem) / 2 + 2rem));
  border-top: 1px solid var(--border-soft);
  font-size: var(--text-minus-1);
  color: var(--muted);
  background: var(--bg-dark);
}

@media (max-width: 768px) {
  main {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .topbar__nav-links,
  .topbar__bell,
  .topbar__profile {
    display: none !important;
  }
  body > header aside {
    display: flex !important;
  }
  .topbar__hamburger {
    display: flex;
  }
  .topbar__drawer {
    display: flex;
  }

  .case-table-wrap {
    padding: 0 0.5rem 0.5rem;
  }
}

/* ── shell layout (clinician + coordinator) ── */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  --panel-w: 720px;
  grid-template-columns: 1fr 0px;
  overflow: hidden;
}
.layout.panel-open {
  grid-template-columns: minmax(300px, 380px) 1fr;
}
.layout.panel-closing {
  grid-template-columns: minmax(300px, 380px) 1fr;
}
.layout.no-transition #detail-panel {
  transition: none;
}
.layout > main {
  overflow-y: auto;
  min-height: 0;
  min-width: 560px;
}
.layout.panel-open > main {
  min-width: 0;
}

/* split-panel: full-screen takeover on mobile. Must follow the desktop .layout
   rules above: equal specificity, so the later rule wins (#485). */
@media (max-width: 768px) {
  .layout > main {
    min-width: 0;
  }
  .layout.panel-open {
    grid-template-columns: 0 1fr;
  }
  .layout.panel-closing {
    grid-template-columns: 0 1fr;
  }
  .layout.panel-open > main {
    overflow: hidden;
  }
  .layout.panel-open #detail-panel {
    border-left: none;
  }
}

@media (min-width: 1920px) {
  .layout {
    --panel-w: 780px;
  }
}

@media (max-width: 1440px) {
  .layout {
    --panel-w: 560px;
  }
}

#detail-panel {
  position: relative;
  overflow-y: auto;
  min-height: 0;
  border-left: 1px solid var(--border-soft);
  transform: translateX(100%);
  transition: transform 300ms ease, border-color 300ms ease;
}
.layout.panel-open #detail-panel {
  transform: translateX(0);
  border-left-color: var(--brand);
}
.layout.panel-closing #detail-panel {
  transform: translateX(100%);
}
#detail-panel[hidden] {
  display: block !important;
  overflow: hidden;
}
.panel-close {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font: 500 0.786rem/1 inherit;
  color: #fff;
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: var(--r-sm);
  padding: var(--space-sm) 0.618rem;
  min-height: 44px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.panel-close:hover {
  opacity: 0.88;
}
.panel-close:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ── detail panel scoped styles (clinician + coordinator) ── */
#detail-panel {
  --brand: oklch(34% 0.07 162);
  --brand-soft: oklch(34% 0.07 162 / 0.08);
  --bg-dark: oklch(94% 0.005 255);
  --bg: oklch(97% 0.003 255);
  --bg-light: #fff;
  --page: var(--bg-dark);
  --surface: var(--bg-light);
  --text: oklch(22% 0.015 260);
  --muted: oklch(52% 0.015 260);
  --border: oklch(91% 0.006 255);
  --border-strong: oklch(84% 0.008 255);
  --ok-fg: oklch(38% 0.09 155);
  --ok-bg: oklch(95% 0.04 155);
  --ok-line: oklch(72% 0.09 155);
  --warn-fg: oklch(42% 0.11 70);
  --warn-bg: oklch(96% 0.05 80);
  --warn-line: oklch(70% 0.12 70);
  --err-fg: oklch(42% 0.14 28);
  --err-bg: oklch(96% 0.03 28);
  --err-line: oklch(68% 0.15 28);
  --ai-line: oklch(55% 0.12 245);
  --ai-bg: oklch(98% 0.012 245);
  --r-sm: 0.381rem;
  --r-md: 0.618rem;
  --r-lg: 1rem;
  --shadow-sm: 0 1px 2px oklch(20% 0.02 260 / 0.04);
  --shadow-md:
    0 1px 2px oklch(20% 0.02 260 / 0.04), 0 4px 12px oklch(20% 0.02 260 / 0.04);
  --ring: 0 0 0 3px oklch(34% 0.07 162 / 0.18);
  background: var(--page);
}

#detail-panel *:focus {
  outline: none;
}
#detail-panel *:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--space-xs);
}

#detail-panel a {
  text-decoration: none;
  color: inherit;
}

#detail-panel time,
#detail-panel .case-meta time,
#detail-panel .signals-table,
#detail-panel .kv-list dd,
#detail-panel .context-strip dd,
#detail-panel .mdt-banner-status {
  font-variant-numeric: tabular-nums;
}

#detail-panel .detail-main {
  flex: 1;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: calc(var(--size-topbar-height) + 1.618rem) 2.058rem 2.618rem;
}

.case-header {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.618rem;
}
.case-meta {
  margin-right: auto;
}
.case-meta h1 {
  font-size: 2.058rem;
  font-weight: 600;
  line-height: 1.272;
  letter-spacing: -0.02em;
  color: var(--text);
}
.case-meta time {
  font-size: 0.786rem;
  color: var(--muted);
  display: block;
  margin-top: var(--space-xs);
}

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* ── case tabs (UX-09 #480, ADR-0021) — clinician + coordinator case view.
   Boxed tabs: uniform 1px border, --space-xs apart; the selected tab takes the
   card's --bg and a card-coloured bottom border so it joins its panel, and the
   card gives up its top border and top-left radius. Selection is also carried by
   weight and aria-selected, never colour alone. ── */
.case-tabs {
  display: flex;
  gap: var(--space-xs);
}
.case-tab {
  min-height: 44px;
  padding: var(--space-md) var(--space-lg);
  font: inherit;
  font-size: var(--text-0);
  font-weight: 500;
  color: var(--muted);
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--r-md) var(--r-md) 0 0;
  cursor: pointer;
  transition: color 0.15s;
}
.case-tab:not([aria-selected="true"]):hover {
  color: var(--text);
}
.case-tab[aria-selected="true"] {
  background: var(--bg);
  color: var(--brand);
  font-weight: 600;
  border-bottom-color: var(--bg);
}
.case-tabs + .card {
  border-top: 0;
  border-top-left-radius: 0;
}
.case-tabpanel {
  padding: var(--space-xl);
}
.case-tabpanel > .fidelity-note {
  display: block;
  margin: 0 0 var(--space-lg);
}

.fidelity-note {
  font-weight: 400;
  font-size: 0.786rem;
  letter-spacing: 0;
  color: var(--muted);
  margin-left: 0.618rem;
}

.h3 {
  font-size: 0.786rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.618rem;
  line-height: 1.618;
}

.context-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.618rem;
  margin-bottom: 1.272rem;
}
.context-strip > div {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: 1rem;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  min-width: 0;
  box-shadow: var(--shadow-sm);
}
.context-strip dt {
  font-size: 0.786rem;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.618;
}
.context-strip dd {
  font-size: 1.272rem;
  color: var(--text);
  line-height: 1.618;
  margin: 0;
  font-weight: 500;
  letter-spacing: -0.005em;
}

.ph-layer {
  margin-bottom: 0.618rem;
  padding: 1.272rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-light);
}
.ph-layer:last-of-type {
  margin-bottom: 0;
}
.ph-layer-label {
  font-size: 0.786rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.618rem;
  line-height: 1.618;
}

.radiology-summary {
  font-size: 1rem;
  line-height: 1.618;
  color: var(--text);
}
.radiology-summary p {
  text-wrap: pretty;
}
.radiology-summary p + p {
  margin-top: 0.618rem;
}
.care-block .radiology-summary {
  font-size: 1.272rem;
}
.ph-layer .radiology-summary {
  font-size: 1.272rem;
}
.kv-list.ph-inputs > div {
  font-size: 1rem;
}
.kv-list.ph-inputs dt {
  font-size: 1rem;
}

.kv-list {
  display: flex;
  flex-direction: column;
}
.kv-list > div {
  display: flex;
  gap: 1rem;
  font-size: 0.786rem;
  line-height: 1.618;
  padding: 0.618rem 0;
  border-bottom: 1px solid var(--border);
}
.kv-list > div:first-child {
  padding-top: 0;
}
.kv-list > div:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.kv-list dt {
  width: 13rem;
  flex-shrink: 0;
  color: var(--text);
  font-weight: 600;
  font-size: 0.786rem;
}
.kv-list dd {
  flex: 1;
  margin: 0;
  color: var(--text);
  font-weight: 400;
}
.kv-list > div.unavailable dt {
  color: var(--muted);
  font-weight: 400;
}
.kv-list > div.unavailable dd {
  color: var(--muted);
}

.ph-nondep {
  margin-top: 1.272rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 1rem;
  color: var(--muted);
  line-height: 1.618;
}

.l2-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  margin-top: 0.618rem;
  font-size: 0.786rem;
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
  transition: gap 0.15s;
}
.l2-link:hover {
  text-decoration: underline;
}
.l2-link::after {
  content: "→";
  transition: transform 0.15s;
}
.l2-link:hover::after {
  transform: translateX(2px);
}


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}

/* AUTH-05: sign-in loader overlay. Full-screen branded transition cover —
   logo + spinner + status text. See docs/DESIGN.md → Loader overlay. */
.loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  background: var(--bg-dark);
}
.loader-overlay img {
  display: block;
  height: 2.618rem;
  width: auto;
}
.loader-spinner {
  width: 2.618rem;
  height: 2.618rem;
  border: 0.236rem solid var(--border);
  border-top-color: var(--accent);
  border-radius: var(--radius-full);
  animation: spin 720ms linear infinite;
}
.loader-status {
  font-size: var(--text-0);
  font-weight: 500;
  color: var(--muted);
  line-height: 1.618;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.ai-block {
  position: relative;
  padding: 1.272rem;
  background: var(--ai-bg);
  border: 1px solid var(--ai-line);
  border-radius: var(--r-md);
  margin-bottom: 0.618rem;
}
.ai-block:last-of-type {
  margin-bottom: 0;
}
.ai-block-label {
  font-size: 0.786rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.618rem;
  line-height: 1.618;
  display: flex;
  align-items: center;
  gap: 0.618rem;
}
.ai-block-label::before {
  content: "";
  width: var(--space-sm);
  height: var(--space-sm);
  border-radius: 50%;
  background: var(--ai-line);
  flex-shrink: 0;
}

.signals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
  line-height: 1.618;
  margin-top: var(--space-xs);
}
.signals-table thead th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.786rem;
  padding: 0.618rem;
  border-bottom: 1px solid var(--border-strong);
}
.signals-table thead th:first-child {
  padding-left: 0;
}
.signals-table thead th:last-child {
  padding-right: 0;
}
.signals-table tbody td {
  padding: 1rem 0.618rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text);
}
.signals-table tbody td:first-child {
  padding-left: 0;
  font-weight: 600;
}
.signals-table tbody td:last-child {
  padding-right: 0;
}
.signals-table.evidence tbody td:nth-child(2) {
  font-weight: 600;
}
.signals-table.evidence thead th:last-child,
.signals-table.evidence tbody td:last-child {
  text-align: left;
  white-space: normal;
}
.stage-hl {
  color: var(--text);
  font-weight: 600;
}
.signals-table tbody tr:last-child td {
  border-bottom: none;
}
.ai-block .signals-table {
  font-size: 1.272rem;
}
.ai-block .signals-table thead th {
  font-size: 1rem;
}
.signals-table td:nth-last-child(2) {
  white-space: nowrap;
  font-weight: 500;
}
.signals-table td:last-child,
.signals-table th:last-child {
  text-align: right;
  white-space: nowrap;
}
/* Staging Summary per-axis evidence rows carry long narrative text in the value
   column — wrap and left-align so they do not inherit the table-wide nowrap and
   clip off the panel edge. The compact TNM/AJCC rows above stay right-aligned. */
#staging-evidence-body td:last-child,
[data-demo-staging-body] td:last-child {
  text-align: left;
  white-space: normal;
}

.mdt-banner {
  padding: 1rem 1.272rem;
  border-radius: var(--r-md);
  margin-bottom: 1.272rem;
  border: 1px solid var(--border);
  position: relative;
}
.mdt-banner[data-mdt="green"] {
  background: var(--ok-bg);
  border-color: var(--ok-line-30);
}
/* NS-10 (#283, ADR-0014 Fork #5 Q4): attention = full_mdt_review. --attention
   (hue 240 blue) signals "requires specialist attention", not a pass/fail — the
   old red wrongly implied failure. */
.mdt-banner[data-mdt="attention"] {
  background: var(--attention-tint);
  border-color: var(--attention-line);
}
/* NS-10 (#283): red = cannot_verify — the workflow could not verify an HPB primary
   (a process exception; RTS = the disposition label). --err, not --danger. The old
   neutral state (cool-grey rts) is retired: the engine set has no pass-through verdict. */
.mdt-banner[data-mdt="red"] {
  background: var(--err-bg);
  border-color: var(--err-line-30);
}
.mdt-banner-status {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-sm);
  line-height: 1.618;
  display: flex;
  align-items: center;
  gap: 0.618rem;
}
.mdt-banner-status::before {
  content: "";
  width: 0.618rem;
  height: 0.618rem;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.mdt-banner[data-mdt="green"] .mdt-banner-status {
  color: var(--ok-fg);
}
.mdt-banner[data-mdt="attention"] .mdt-banner-status {
  color: var(--attention);
}
.mdt-banner[data-mdt="red"] .mdt-banner-status {
  color: var(--err-fg);
}
.mdt-banner p {
  font-size: 1rem;
  line-height: 1.618;
  color: var(--text);
  margin: 0;
  text-wrap: pretty;
}

.care-block {
  margin-bottom: 1.618rem;
}
.care-block:last-child {
  margin-bottom: 0;
}
.care-block-label {
  font-size: 0.786rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.618rem;
  line-height: 1.618;
}

.kv-list.care-summary > div {
  font-size: 1rem;
}
.kv-list.care-summary dt {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.action-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.381rem;
  font-size: 1rem;
  line-height: 1.618;
}
.action-list li {
  padding-left: 1.272rem;
  position: relative;
  color: var(--text);
  text-wrap: pretty;
}
.action-list li::before {
  content: "";
  position: absolute;
  left: var(--space-sm);
  top: 0.618rem;
  width: var(--space-sm);
  height: var(--space-sm);
  background: var(--brand);
  border-radius: 50%;
}

@media (max-width: 768px) {
  #detail-panel .detail-main {
    padding: calc(var(--size-topbar-height) + 1rem) 1rem 2.058rem;
  }
  .case-tabpanel {
    padding: var(--space-lg);
  }
  .context-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .kv-list > div {
    flex-direction: column;
    gap: var(--space-xs);
  }
  .kv-list dt {
    width: auto;
  }
  #detail-panel .case-header {
    position: sticky;
    top: var(--size-topbar-height);
    z-index: 10;
    background: var(--bg-light);
    margin-left: -1rem;
    margin-right: -1rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-soft);
    flex-wrap: wrap;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .case-meta h1 {
    font-size: 1.618rem;
  }
  .case-table th:nth-child(2),
  .case-table td:nth-child(2) {
    display: none;
  }
  .case-cell {
    white-space: normal;
  }
}
