﻿/* ──────────────────────────────────────────────────────────────────
   App stylesheet · FCGS Registry
   Tokens live in tokens.css — load that first.
   ────────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted-strong); }
button { font-family: inherit; cursor: pointer; }

/* ──────────────────────────────────────────────────────────────────
   App shell
   ────────────────────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  background: #0f1525;
  color: #cdd6e3;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #1c2438;
  overflow: hidden;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid #1c2438;
}
.brand-mark { width: 28px; height: 28px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; }
.brand-mark svg { width: 28px; height: 28px; border-radius: var(--radius); }
.brand-name { color: #fff; font-weight: 600; letter-spacing: -0.01em; font-size: 13px; }
.brand-sub { font-size: 10.5px; color: #8a93a8; margin-top: 1px; }

.sidebar-nav {
  flex: 1;
  padding: 8px 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}
.nav-group-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5d6680;
  padding: 14px 10px 4px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: none;
  background: transparent;
  color: #cdd6e3;
  border-radius: var(--radius);
  font-size: 12.5px;
  text-align: left;
}
.nav-item { transition: background 0.12s ease, color 0.12s ease; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.is-active {
  background: rgba(255,255,255,0.10);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-item.is-active .nav-icon { opacity: 1; color: var(--accent); }
.nav-icon { width: 16px; height: 16px; display: flex; opacity: 0.7; transition: opacity 0.12s ease; }
.nav-icon svg { width: 16px; height: 16px; }
.nav-en { flex: 1; font-weight: 500; }
.nav-zh { font-size: 11px; color: #8a93a8; font-family: var(--font-sans); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid #1c2438;
  display: flex; flex-direction: column; gap: 10px;
}
.cohort-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid #1c2438;
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cohort-row { display: flex; justify-content: space-between; color: #8a93a8; font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase; }
.cohort-name { color: #fff; font-weight: 600; font-family: var(--font-mono); font-size: 13px; margin-top: 2px; }
.cohort-sub { color: #8a93a8; font-size: 10.5px; margin-top: 3px; line-height: 1.4; }
.user-row { display: flex; gap: 8px; align-items: center; padding: 2px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #5b21b6); color: white; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; }
.user-name { font-size: 11px; color: #cdd6e3; }
.user-role { font-size: 10px; color: #8a93a8; }

/* Main */
.main {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.crumbs { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted-strong); }
.crumb a { color: var(--accent); cursor: pointer; }
.crumb.is-current { color: var(--text); font-weight: 500; }
.crumb-sep { color: var(--text-3); }
.topbar-right { display: flex; gap: 12px; align-items: center; }
.search {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 8px;
  width: 360px;
}
.search input { border: none; background: transparent; outline: none; flex: 1; font-size: 12.5px; font-family: inherit; color: var(--text); }
.search-icon { width: 14px; height: 14px; color: var(--muted-strong); margin-right: 6px; }
.search-icon svg { width: 14px; height: 14px; }
.kbd { font-family: var(--font-mono); font-size: 10px; color: var(--muted-strong); background: var(--surface); border: 1px solid var(--border); padding: 1px 5px; border-radius: 3px; }

.screen { flex: 1; overflow: auto; padding: 24px 28px 80px; }

/* ──────────────────────────────────────────────────────────────────
   Section header
   ────────────────────────────────────────────────────────────────── */
.section-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; gap: 16px; }
.eyebrow { font-size: 10.5px; color: var(--muted-strong); text-transform: uppercase; letter-spacing: 0.14em; font-weight: 600; margin-bottom: 4px; }
.section-header h2 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }
.section-sub { margin: 4px 0 0; color: var(--muted-strong); font-size: 12.5px; }
.section-right { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.header-actions { display: flex; gap: 8px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease, box-shadow 0.12s ease;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled], .btn.is-loading { opacity: 0.6; pointer-events: none; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); box-shadow: 0 1px 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.ghost { background: transparent; border-color: var(--border-strong); }
.btn.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { display: inline-flex; }
.btn-icon svg { width: 14px; height: 14px; }
.btn-link { background: transparent; border: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 11.5px; padding: 0; }

/* ──────────────────────────────────────────────────────────────────
   Case list
   ────────────────────────────────────────────────────────────────── */
.status-strip {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.strip-cell {
  background: var(--surface);
  padding: 12px 14px;
  text-align: left;
  border: 0;
  position: relative;
  cursor: pointer;
}
.strip-cell:hover { background: var(--surface-2); }
.strip-cell.is-on { background: var(--surface-2); box-shadow: inset 0 2px 0 var(--accent); }
.strip-num { font-size: 22px; font-weight: 600; font-family: var(--font-mono); letter-spacing: -0.02em; }
.strip-label { font-size: 11.5px; color: var(--muted-strong); margin-top: 2px; }
.strip-bar { position: absolute; left: 0; bottom: 0; height: 2px; }

.filter-bar {
  display: flex; gap: 8px; align-items: center;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 0;
}
.filter-search { display: flex; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 8px; flex: 1; max-width: 360px; }
.filter-search input { border: 0; background: transparent; outline: none; flex: 1; font-size: 12.5px; font-family: inherit; }
.filter-select { padding: 5px 8px; font-size: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-family: inherit; color: var(--text); }
.filter-meta { margin-left: auto; color: var(--muted-strong); font-size: 11.5px; }

.data-table-wrap { background: var(--surface); border: 1px solid var(--border); border-top: 0; overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table thead th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-strong);
  font-weight: 600;
  padding: 8px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.data-table th.th-sort { cursor: pointer; user-select: none; }
.data-table th.th-sort:hover { color: var(--text); }
.data-table th.th-num, .data-table td.th-num { text-align: right; }
.data-table .sort { color: var(--accent); margin-left: 4px; }
.data-table tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.1s ease; }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.data-table tbody td { padding: 6px 10px; min-height: var(--row-h); vertical-align: middle; line-height: 1.3; }
.case-id { color: var(--accent); font-weight: 500; }

.cat-cell { display: flex; gap: 8px; align-items: center; }
.cat-avatar { width: 24px; height: 24px; border-radius: 50%; background: linear-gradient(135deg, var(--accent-soft-strong), var(--accent)); color: white; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0; }
.cat-name { font-weight: 500; font-size: 12.5px; line-height: 1.2; }
.cat-meta { color: var(--muted-strong); font-size: 11px; }

.owner-cell { line-height: 1.3; }
.owner-country { color: var(--muted-strong); font-size: 11px; }

.dose-cell { color: var(--text-2); font-size: 11.5px; }

.delta-cell { display: inline-flex; gap: 6px; align-items: center; }
.delta { font-family: var(--font-mono); font-weight: 600; font-size: 11.5px; }
.delta.good { color: var(--success); }
.delta.bad { color: var(--danger); }
.delta.flat { color: var(--muted-strong); }

.ae-count { display: inline-flex; min-width: 22px; padding: 1px 6px; border-radius: 10px; font-family: var(--font-mono); font-size: 11px; justify-content: center; }
.ae-count.ae-0 { color: var(--muted); }
.ae-count.ae-mild { background: var(--warn-soft); color: var(--warn); }
.ae-count.ae-severe { background: var(--danger-soft); color: var(--danger); }

.flag-cell { display: flex; gap: 4px; }
.flag { display: inline-flex; gap: 2px; align-items: center; font-size: 11px; padding: 1px 5px; border-radius: 3px; font-family: var(--font-mono); }
.flag svg { width: 11px; height: 11px; }
.flag-warn { background: var(--warn-soft); color: var(--warn); }
.flag-danger { background: var(--danger-soft); color: var(--danger); }

.row-chev { color: var(--muted); display: inline-flex; }
.row-chev svg { width: 14px; height: 14px; }

.empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted-strong);
  font-size: 13px;
  line-height: 1.6;
}
.empty-soft {
  color: var(--muted-strong);
  font-size: 12px;
  padding: 14px 0;
  text-align: center;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.table-footer { display: flex; justify-content: space-between; padding: 10px 12px; color: var(--muted-strong); font-size: 11.5px; background: var(--surface); border: 1px solid var(--border); border-top: 0; }

/* OGI bar (overview tab) */
.ogi-bar { display: flex; gap: 4px; align-items: flex-end; min-height: 64px; }
.ogi-seg { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ogi-fill { width: 100%; height: 44px; border-radius: 2px; }
.ogi-week { font-size: 10px; color: var(--muted-strong); }

/* Pills */
.pill { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 500; gap: 6px; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.status-active { background: color-mix(in srgb, var(--accent) 10%, white); color: var(--accent); }
.status-completed { background: var(--success-soft); color: var(--success); }
.status-discontinued { background: var(--warn-soft); color: var(--warn); }
.status-lost { background: #f2f4f7; color: var(--muted-strong); }
.status-deceased { background: var(--danger-soft); color: var(--danger); }

.tag { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 3px; font-size: 11px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.tag-positive { background: color-mix(in srgb, var(--accent) 10%, white); color: var(--accent); border-color: transparent; }
.tag-negative { background: var(--surface-2); color: var(--text-2); }
.tag-yes, .tag-full, .tag-resolved, .tag-probable, .tag-definite { background: var(--success-soft); color: var(--success); border-color: transparent; }
.tag-no, .tag-none, .tag-unrelated { background: var(--surface-2); color: var(--text-2); }
.tag-partial, .tag-resolving, .tag-possible { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag-not_tested, .tag-unknown, .tag-unlikely { background: #f2f4f7; color: var(--muted-strong); }
.tag-not_resolved { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

.grade-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 28px; padding: 1px 6px; border-radius: 3px; font-size: 11px; font-family: var(--font-mono); font-weight: 600; }
.grade-pill.g1 { background: #f0f9ff; color: #0369a1; }
.grade-pill.g2 { background: var(--warn-soft); color: var(--warn); }
.grade-pill.g3 { background: #fef2f2; color: #b42318; }
.grade-pill.g4 { background: #b42318; color: #fff; }
.grade-pill.g5 { background: #7a271a; color: #fff; }

/* ──────────────────────────────────────────────────────────────────
   Case detail
   ────────────────────────────────────────────────────────────────── */
.cd-back { margin-bottom: 12px; }
.cd-grid { display: grid; grid-template-columns: 320px 1fr; gap: 16px; }
.cd-side { display: flex; flex-direction: column; gap: 12px; }
.cd-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad-card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.card-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; gap: 8px; }
.card-title { font-weight: 600; font-size: 13px; }
.card-sub { color: var(--muted-strong); font-size: 11px; }
.card-sub.ok { color: var(--success); }
.card-sub.warn { color: var(--warn); }
.card-link { color: var(--accent); cursor: pointer; font-size: 11.5px; }
.grow { flex: 1; min-width: 280px; }
.grow-2 { flex: 2; min-width: 280px; }

.cd-identity { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.cd-avatar { width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, var(--accent-soft-strong), var(--accent)); color: white; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 600; flex-shrink: 0; }
.cd-id { color: var(--muted-strong); font-size: 11px; }
.cd-name { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; }
.cd-meta { display: flex; gap: 6px; align-items: center; margin-top: 4px; font-size: 11.5px; color: var(--muted-strong); flex-wrap: wrap; }
.cd-meta-dot { color: var(--text-3); }

.cd-dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 12px; }
.cd-dl dt { color: var(--muted-strong); }
.cd-dl dd { margin: 0; }

.score-grid { display: flex; flex-direction: column; gap: 8px; }
.score-row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; font-size: 11.5px; }
.score-label { color: var(--text-2); font-size: 11.5px; }
.score-vals { display: flex; gap: 6px; align-items: center; }
.score-arrow { color: var(--muted); }
.score-vals .base { color: var(--muted-strong); }
.score-vals .now { color: var(--text); font-weight: 600; }

.tx-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.chip { padding: 2px 8px; border-radius: 99px; font-size: 10.5px; background: var(--accent-soft); color: var(--accent-strong); border: 1px solid color-mix(in srgb, var(--accent) 30%, white); }

.dq-ok { color: var(--success); font-size: 12px; }
.dq-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.dq-item { display: flex; gap: 8px; align-items: flex-start; font-size: 11.5px; color: var(--warn); }
.dq-icon { display: inline-flex; flex-shrink: 0; }
.dq-icon svg { width: 14px; height: 14px; }

/* Timeline */
.cd-timeline-card { padding: var(--pad-card); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; }
.legend-item { font-size: 10.5px; color: var(--muted-strong); display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-followup { background: var(--accent-soft); border: 1.4px solid var(--accent); }
.dot-lab { background: var(--surface); border: 1.4px solid var(--muted-strong); }
.dot-ae { background: var(--warn); }
.dot-milestone { background: var(--accent); }
.dot-mini { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; display: inline-block; }

.timeline-wrap { overflow: auto; }
.timeline { font: 10px var(--font-sans); display: block; }
.timeline .track-label { fill: var(--muted-strong); font-size: 9.5px; }
.timeline .axis { fill: var(--muted-strong); font-size: 9.5px; }
.timeline .evt-tag { fill: var(--text-2); font-family: var(--font-mono); font-size: 9px; }
.timeline .evt-label { fill: var(--text-2); font-size: 10px; }
.timeline .curve-label { fill: var(--accent); font-size: 9px; }

/* Tabs */
.cd-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab { background: transparent; border: 0; padding: 9px 12px; font-size: 12.5px; color: var(--muted-strong); border-bottom: 2px solid transparent; margin-bottom: -1px; font-family: inherit; display: inline-flex; gap: 6px; align-items: center; }
.tab { transition: color 0.12s ease, border-bottom-color 0.18s ease; }
.tab:hover { color: var(--text); border-bottom-color: var(--border-strong); }
.tab.is-on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab-count { display: inline-flex; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--surface-2); color: var(--muted-strong); font-family: var(--font-mono); font-size: 10.5px; }
.tab.is-on .tab-count { background: var(--accent); color: white; }

.tab-content { min-height: 320px; }

/* Overview tab */
.overview-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 18px; }
.ov-h { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-strong); font-weight: 600; margin-bottom: 8px; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.mini-table th { text-align: left; color: var(--muted-strong); font-weight: 500; padding: 4px 6px; font-size: 10.5px; }
.mini-table td { padding: 5px 6px; border-bottom: 1px solid var(--border); }
.ogi { padding: 1px 7px; border-radius: 99px; font-size: 10.5px; font-weight: 500; }
.ogi-much_better { background: color-mix(in srgb, var(--success-strong) 12%, white); color: var(--success-strong); }
.ogi-better { background: var(--success-soft); color: var(--success); }
.ogi-stable { background: var(--surface-2); color: var(--muted-strong); }
.ogi-worse { background: var(--warn-soft); color: var(--warn); }
.ogi-much_worse { background: var(--danger-soft); color: var(--danger); }
.ae-mini { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.ae-mini li { display: flex; gap: 8px; align-items: center; font-size: 12px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.week-tag { color: var(--muted-strong); margin-left: auto; font-size: 11px; }
.lab-mini { display: flex; flex-direction: column; gap: 6px; }
.lab-mini-row { display: grid; grid-template-columns: 50px 1fr; align-items: center; font-size: 11.5px; }
.mini-trend { display: flex; gap: 8px; align-items: center; }
.mini-trend-val { color: var(--text); font-weight: 600; }
.mini-trend-flag.bad { color: var(--danger); font-family: var(--font-mono); }
.mini-trend-flag.ok { color: var(--muted-strong); font-size: 10px; }

/* Baseline */
.baseline-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.sub-h { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-strong); margin: 0 0 10px; }

/* Followups */
.followup-tab .row-between, .lab-tab .row-between, .ae-tab .row-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.data-table-inner { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.data-table-inner thead th { background: var(--surface-2); }

/* Photos */
.photo-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 14px; }
.photo-slot { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.photo-frame { aspect-ratio: 4/3; background: #0e0e10; border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; position: relative; }
.photo-placeholder { width: 100%; height: 100%; position: relative; display: flex; align-items: center; justify-content: center; }
.photo-svg { width: 100%; height: 100%; }
.ph-week { position: absolute; top: 8px; right: 10px; background: rgba(0,0,0,0.6); color: white; padding: 2px 8px; border-radius: 2px; font-size: 11px; z-index: 1; }
.photo-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 0 4px; }
.photo-label { font-size: 10.5px; letter-spacing: 0.08em; color: var(--muted-strong); font-weight: 600; }
.photo-bar select { font-size: 11.5px; padding: 3px 6px; border-radius: 3px; border: 1px solid var(--border); background: var(--surface); }
.photo-meta { display: flex; gap: 16px; font-size: 11.5px; padding-top: 8px; border-top: 1px solid var(--border); }
.photo-meta > div { display: flex; flex-direction: column; gap: 2px; }
.photo-meta .mono { font-weight: 600; }

.photo-strip { border-top: 1px solid var(--border); padding-top: 12px; }
.strip-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-strong); font-weight: 600; margin-bottom: 8px; }
.strip-row { display: flex; gap: 6px; overflow-x: auto; }
.strip-thumb { background: var(--surface-2); border: 1px solid var(--border); border-radius: 3px; padding: 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.strip-thumb.is-on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.strip-thumb .mono { font-size: 10px; color: var(--muted-strong); }

/* Labs */
.lab-abn { color: var(--danger); font-weight: 600; position: relative; }
.lab-marker { display: inline-block; margin-left: 4px; padding: 0 3px; font-size: 9px; border-radius: 2px; background: var(--danger); color: white; font-family: var(--font-mono); }
.lab-trends { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.lab-trend-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.lab-trend-h { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 12px; font-weight: 600; }
.ok-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }

/* Outcome */
.outcome-hero { padding: 18px 20px; background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 16px; }
.outcome-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); font-weight: 600; }
.outcome-value { font-size: 22px; font-weight: 600; margin: 4px 0; }
.outcome-meta { color: var(--muted-strong); font-size: 11.5px; }
.outcome-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.score-delta { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.sd-label { font-size: 11px; color: var(--muted-strong); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.sd-row { font-size: 18px; margin: 6px 0; }
.sd-delta { font-size: 14px; font-weight: 600; font-family: var(--font-mono); }
.sd-delta.good { color: var(--success); }
.sd-delta.bad { color: var(--danger); }
.sd-delta.flat { color: var(--muted-strong); }

/* ──────────────────────────────────────────────────────────────────
   Dashboards
   ────────────────────────────────────────────────────────────────── */
.dash { display: flex; flex-direction: column; gap: 14px; }
.stat-row-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.stat { background: var(--surface); padding: 14px 16px; }
.stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-strong); font-weight: 600; }
.stat-row { display: flex; align-items: baseline; justify-content: space-between; margin-top: 6px; gap: 8px; }
.stat-value { font-size: 26px; font-weight: 600; letter-spacing: -0.025em; font-family: var(--font-mono); }
.stat-sub { font-size: 11px; color: var(--muted-strong); margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.trend.trend-up { color: var(--success); font-family: var(--font-mono); }
.trend.trend-down { color: var(--danger); font-family: var(--font-mono); }

.progress-mini { display: flex; align-items: center; gap: 6px; min-width: 80px; }
.progress-mini-bar { height: 4px; background: var(--accent); border-radius: 2px; min-width: 4px; }
.progress-mini { background: var(--border); border-radius: 2px; padding: 0; }
.progress-mini .mono { color: var(--muted-strong); font-size: 10px; padding: 0 4px; }

.dash-row { display: flex; gap: 14px; flex-wrap: wrap; }
.chart { display: block; font-family: var(--font-sans); }
.chart .axis { font-size: 10px; fill: var(--muted-strong); font-family: var(--font-mono); }
.chart .axis-value { font-size: 9.5px; fill: var(--text-2); font-family: var(--font-mono); }
.sparkline { display: inline-block; vertical-align: middle; }

.legend-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.legend-li { display: flex; gap: 8px; align-items: center; font-size: 11.5px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend-text { flex: 1; }
.legend-text strong { font-weight: 600; }
.status-dist { display: flex; gap: 18px; align-items: center; }
.donut-center-value { font-size: 20px; font-weight: 700; fill: var(--text); font-family: var(--font-mono); }
.donut-center-label { font-size: 10px; fill: var(--muted-strong); }

.filter-pills { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filter-pill { display: inline-flex; gap: 4px; padding: 5px 10px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 99px; font-size: 11.5px; }

.funnel { display: flex; flex-direction: column; gap: 6px; }
.funnel-row { display: grid; grid-template-columns: 160px 1fr 40px; gap: 8px; align-items: center; font-size: 11.5px; }
.funnel-label { color: var(--text-2); }
.funnel-bar-wrap { position: relative; height: 22px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.funnel-bar { height: 100%; }
.funnel-value { position: absolute; top: 50%; transform: translateY(-50%); left: 8px; color: white; font-size: 11px; font-weight: 600; }
.funnel-pct { color: var(--muted-strong); text-align: right; }

.activity-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1px; }
.activity-list li { display: flex; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 12px; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.activity-dot.followup { background: var(--accent); }
.activity-dot.ae { background: var(--warn); }
.activity-main { display: flex; gap: 8px; align-items: center; flex: 1; flex-wrap: wrap; }
.activity-label { font-weight: 500; }
.activity-sub { font-size: 11px; }
.activity-time { color: var(--muted-strong); font-size: 11px; }
.sep { color: var(--text-3); }

/* Safety */
.heatmap-wrap { overflow-x: auto; }
.heatmap-label { fill: var(--text-2); font-size: 10.5px; }
.heatmap-value { fill: var(--text); font-size: 10px; font-family: var(--font-mono); }
.severity-stack { display: flex; flex-direction: column; gap: 6px; }
.sev-row { display: grid; grid-template-columns: 36px 1fr 1.4fr 40px; gap: 8px; align-items: center; font-size: 11.5px; }
.sev-label { color: var(--text-2); }
.sev-bar-wrap { background: var(--surface-2); height: 14px; border-radius: 2px; overflow: hidden; }
.sev-bar { height: 100%; }
.sev-bar.g1 { background: #7dd3fc; }
.sev-bar.g2 { background: #f59e0b; }
.sev-bar.g3 { background: #ef4444; }
.sev-bar.g4 { background: #b91c1c; }
.sev-bar.g5 { background: #7f1d1d; }
.sev-val { text-align: right; }

.action-list { display: flex; flex-direction: column; gap: 6px; }
.action-row { display: grid; grid-template-columns: 1fr 1.4fr 30px; gap: 8px; align-items: center; font-size: 11.5px; }
.action-label { color: var(--text-2); text-transform: capitalize; }
.action-bar-wrap { background: var(--surface-2); height: 12px; border-radius: 2px; overflow: hidden; }
.action-bar { height: 100%; background: var(--accent); }

/* Efficacy */
.ogi-dist { display: flex; flex-direction: column; gap: 8px; }
.ogi-row { display: grid; grid-template-columns: 1fr 1.4fr 30px; gap: 8px; align-items: center; font-size: 11.5px; }
.ogi-label { color: var(--text-2); }
.ogi-bar-wrap { background: var(--surface-2); height: 14px; border-radius: 2px; overflow: hidden; }
.ogi-bar-fill { height: 100%; }
.outcome-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.outcome-row { display: grid; grid-template-columns: 8px 1fr 40px; gap: 8px; align-items: center; font-size: 11.5px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.outcome-bullet { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.outcome-complete_remission { background: var(--success-strong); }
.outcome-near_remission { background: var(--success); }
.outcome-significant_improvement { background: var(--accent); }
.outcome-partial_improvement { background: var(--accent-soft-strong); }
.outcome-no_response { background: var(--warn); }
.outcome-relapse { background: var(--warn); }
.outcome-discontinued_due_to_AE { background: var(--danger); }
.outcome-deceased { background: var(--critical); }
.outcome-lost_to_follow_up { background: var(--muted-strong); }
.outcome-name { color: var(--text); }

/* Subgroup */
.subgroup-pickers { display: flex; gap: 32px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; }
.picker-group { display: flex; flex-direction: column; gap: 6px; }
.picker-group label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-strong); font-weight: 600; }
.picker-options { display: flex; gap: 4px; flex-wrap: wrap; }
.pill-toggle { padding: 5px 10px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius); font-size: 11.5px; font-family: inherit; }
.pill-toggle:hover { background: var(--surface-2); }
.pill-toggle.is-on { background: var(--accent); color: white; border-color: var(--accent); }
.subgroup-cell { font-weight: 500; }
.rem-cell { display: flex; gap: 8px; align-items: center; }
.rem-bar-wrap { width: 100px; background: var(--surface-2); height: 10px; border-radius: 2px; overflow: hidden; }
.rem-bar { height: 100%; background: var(--success); }
.series-legend { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.series-key { display: inline-flex; gap: 4px; align-items: center; font-size: 11px; color: var(--text-2); }

/* Export */
.export-banner { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.banner-row { display: flex; gap: 6px; align-items: baseline; font-size: 13px; flex-wrap: wrap; }
.banner-num { font-size: 22px; font-weight: 700; color: var(--accent); }
.banner-sub { color: var(--muted-strong); font-size: 11.5px; margin-top: 4px; }
.banner-toggle { display: flex; gap: 16px; align-items: center; }
.toggle { display: flex; gap: 8px; align-items: center; font-size: 12px; cursor: pointer; }
.toggle input { accent-color: var(--accent); }

.export-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.export-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; text-align: left; cursor: pointer; font-family: inherit; transition: border-color 0.15s; display: flex; flex-direction: column; gap: 8px; }
.export-card:hover { border-color: var(--border-strong); }
.export-card.is-on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.export-card-h { display: flex; justify-content: space-between; align-items: center; }
.export-icon { font-size: 22px; }
.export-card-rows { color: var(--muted-strong); font-size: 11px; }
.export-card-title { font-size: 13.5px; font-weight: 600; }
.export-card-desc { color: var(--muted-strong); font-size: 11.5px; line-height: 1.45; flex: 1; }
.export-card-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 8px; border-top: 1px solid var(--border); }
.export-check { width: 18px; height: 18px; border-radius: 3px; border: 1px solid var(--border-strong); display: flex; align-items: center; justify-content: center; color: white; font-size: 12px; }
.export-check.is-on { background: var(--accent); border-color: var(--accent); }

/* Sparkline scorebars */
.scorebar { font-size: 11px; }

/* Onboarding / Next steps card */
.onboarding-card {
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 6%, white), var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.onboarding-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.onboarding-eyebrow {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-strong);
  font-weight: 600;
}
.onboarding-title {
  font-size: 15px;
  font-weight: 600;
  margin-top: 2px;
}
.onboarding-progress {
  flex: 1;
  min-width: 120px;
  max-width: 220px;
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.onboarding-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s ease;
}
.onboarding-steps {
  display: grid;
  gap: 8px;
}
.onboarding-step {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.onboarding-step.is-done {
  opacity: 0.55;
  background: var(--surface-2);
}
.onboarding-step-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
  font-family: var(--font-mono);
}
.onboarding-step.is-done .onboarding-step-icon {
  background: var(--success);
  color: white;
}
.onboarding-step-body { flex: 1; min-width: 0; }
.onboarding-step-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.onboarding-step-desc { font-size: 11.5px; color: var(--muted-strong); line-height: 1.5; }

/* Form helpers */
.field-help {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted-strong);
  line-height: 1.5;
  background: var(--surface-2);
  border-left: 2px solid var(--accent-soft-strong);
  padding: 5px 8px;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.optional-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted-strong);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  text-transform: none;
  vertical-align: middle;
}

/* tag colors fallback */
.tag-much_better, .tag-better { background: var(--success-soft); color: var(--success); }
.tag-worse, .tag-much_worse { background: var(--danger-soft); color: var(--danger); }
.tag-stable { background: var(--surface-2); color: var(--muted-strong); }

/* ──────────────────────────────────────────────────────────────────
   Hamburger / mobile drawer
   ────────────────────────────────────────────────────────────────── */
.hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-right: 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  flex-shrink: 0;
}
.hamburger:hover { background: var(--surface-2); }
.hamburger svg { width: 18px; height: 18px; color: var(--text); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 21, 37, 0.45);
  z-index: 40;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* Responsive chart / table containers — always allow shrink */
.chart, .timeline, .photo-svg, .sparkline {
  max-width: 100%;
  height: auto;
}
.data-table-wrap, .heatmap-wrap, .timeline-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.data-table-wrap::-webkit-scrollbar,
.heatmap-wrap::-webkit-scrollbar,
.timeline-wrap::-webkit-scrollbar { height: 6px; }
.data-table-wrap::-webkit-scrollbar-thumb,
.heatmap-wrap::-webkit-scrollbar-thumb,
.timeline-wrap::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
}

/* ──────────────────────────────────────────────────────────────────
   Mobile breakpoint (≤ 900px)
   ────────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .main { overflow: visible; }
  .screen {
    overflow: visible;
    padding: 16px 14px 60px;
  }

  /* Sidebar slides in from left as overlay */
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 270px;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 6px 0 18px rgba(0,0,0,0.25);
  }
  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }
  .app-shell.sidebar-open .sidebar-backdrop {
    display: block;
  }
  .hamburger { display: inline-flex; }

  /* Topbar tightens */
  .topbar {
    padding: 8px 12px;
    gap: 6px;
    flex-wrap: wrap;
  }
  .search { display: none; }
  .crumbs { font-size: 12px; flex: 1; min-width: 0; }
  .crumb:not(.is-current) { display: none; }  /* hide breadcrumb root */
  .crumb-sep { display: none; }
  .crumb.is-current {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-right .btn { padding: 5px 8px; font-size: 11.5px; }

  /* Section header buttons wrap */
  .section-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .section-header h2 { font-size: 18px; }
  .section-right { justify-content: flex-end; flex-wrap: wrap; }
  .header-actions { flex-wrap: wrap; }

  /* Case list status strip 3 cols */
  .status-strip { grid-template-columns: repeat(3, 1fr); }
  .strip-num { font-size: 18px; }
  .strip-label { font-size: 10.5px; }

  /* Filter bar wraps */
  .filter-bar { flex-wrap: wrap; gap: 6px; }
  .filter-search { flex: 1 1 100%; max-width: none; }
  .filter-meta { margin-left: 0; }

  /* Case detail: stack side + main */
  .cd-grid { grid-template-columns: 1fr; gap: 12px; }
  .cd-identity { gap: 8px; }
  .cd-name { font-size: 16px; }
  .cd-tabs { overflow-x: auto; flex-wrap: nowrap; white-space: nowrap; }
  .tab { flex-shrink: 0; padding: 8px 10px; font-size: 12px; }

  /* Dashboard rows stack */
  .dash-row { flex-direction: column; gap: 12px; }
  .dash-row > .card { width: 100%; min-width: 0; flex: 1 1 auto; }
  .stat-row-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 22px; }
  .overview-grid { grid-template-columns: 1fr; gap: 14px; }

  /* Two-col grids → single col */
  .baseline-grid { grid-template-columns: 1fr; gap: 18px; }
  .photo-compare { grid-template-columns: 1fr; }
  .outcome-grid { grid-template-columns: repeat(2, 1fr); }

  /* Forms: all fields full width */
  .django-field { grid-column: span 12; }
  .detail-kv > div { grid-column: span 12; }

  /* Subgroup pickers: stack groups */
  .subgroup-pickers { flex-direction: column; gap: 14px; }

  /* Card padding tighter */
  .card { padding: 12px; }

  /* Onboarding card */
  .onboarding-head { flex-direction: column; align-items: stretch; }
  .onboarding-progress { max-width: none; }
  .onboarding-step { flex-wrap: wrap; gap: 8px; }
  .onboarding-step .btn { width: 100%; justify-content: center; }
}

/* Case list table — compress columns on smaller screens */
@media (max-width: 900px) {
  /* Hide less-critical columns */
  .data-table th:nth-child(5), .data-table td:nth-child(5),   /* Dose */
  .data-table th:nth-child(6), .data-table td:nth-child(6),   /* FCV */
  .data-table th:nth-child(7), .data-table td:nth-child(7),   /* Extraction */
  .data-table th:nth-child(8), .data-table td:nth-child(8)    /* Wk */
  { display: none; }
}
@media (max-width: 700px) {
  /* Even more aggressive: hide oral delta + sparkline + flags */
  .data-table th:nth-child(9), .data-table td:nth-child(9),    /* Oral Δ */
  .data-table th:nth-child(10), .data-table td:nth-child(10),  /* Trajectory */
  .data-table th:nth-child(12), .data-table td:nth-child(12)   /* Flags */
  { display: none; }
}

/* Loading skeleton (used before React mounts) */
.skel {
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--border) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: skelShift 1.4s ease-in-out infinite;
  border-radius: var(--radius);
}
@keyframes skelShift {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel-row { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.skel-block { height: 14px; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Phone-tight (≤ 480px) — extra compression */
@media (max-width: 480px) {
  .status-strip { grid-template-columns: repeat(2, 1fr); }
  .outcome-grid { grid-template-columns: 1fr; }
  .stat-row-grid { grid-template-columns: 1fr; }
  .topbar-right .btn { font-size: 11px; padding: 4px 7px; }
  .data-table thead th, .data-table tbody td { padding: 5px 8px; font-size: 11.5px; }
}

