/* ==========================================================================
   OpenAwakeMap — High-Contrast OR Tablet & Printable Pathology Report Styles
   Zero external dependencies, optimized for landscape tablets & low-light ORs.
   ========================================================================== */

:root {
  --bg: #0b111b;
  --surface: #131c2c;
  --surface-2: #1b273c;
  --border: #2a3952;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #38bdf8;
  --primary-strong: #0284c7;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --l1-color: #0284c7;
  --l2-color: #d97706;
  --radius: 12px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.88rem; margin: 4px 0 0; }
.muted-sm { color: var(--muted); font-size: 0.8rem; }

/* ---------- Top Navigation ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: #080d16;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.brand-title {
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: 0.01em;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--muted);
}

.nav-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-tab {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  color: var(--text);
  border-color: var(--primary);
}

.nav-tab.active {
  background: var(--primary-strong);
  border-color: var(--primary);
  color: #ffffff;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  font-size: 0.75rem;
  font-weight: 700;
  color: #4ade80;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  padding: 4px 10px;
  border-radius: 999px;
}

/* ---------- Buttons & Pills ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-2);
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--primary-strong);
  border-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover { background: #0369a1; }

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); background: rgba(56, 189, 248, 0.08); }

.btn-light {
  background: #ffffff;
  color: #0f172a;
}

.btn-danger-text { color: #fca5a5; border-color: rgba(239, 68, 68, 0.4); }
.btn-danger-text:hover { background: rgba(239, 68, 68, 0.15); border-color: var(--danger); }

.btn-sm { padding: 6px 10px; font-size: 0.78rem; }
.btn-xs { padding: 5px 9px; font-size: 0.76rem; border-radius: 7px; }
.btn-lg { padding: 12px 20px; font-size: 0.96rem; }

.btn-seizure {
  background: rgba(239, 68, 68, 0.18);
  border-color: var(--danger);
  color: #fecaca;
}
.btn-seizure:hover { background: var(--danger); color: #ffffff; }

.tag-pill {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.tag-pill.warn { background: rgba(245, 158, 11, 0.16); color: #fcd34d; border: 1px solid rgba(245, 158, 11, 0.4); }
.tag-pill.ok { background: rgba(34, 197, 94, 0.15); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.4); }

.pill-btn {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.pill-btn.active {
  background: var(--primary-strong);
  color: #ffffff;
  border-color: var(--primary);
}

/* ---------- Main Container & Cards ---------- */
.main-shell {
  padding: 14px 16px 24px;
  max-width: 1560px;
  margin: 0 auto;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card, .control-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

/* ---------- TAB 1: Setup & Pre-Op Baseline ---------- */
.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 16px;
  align-items: start;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  min-width: 0;
}

.field.full-span { grid-column: 1 / -1; }

.field input, .field select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 40px;
  background: #0d1523;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.86rem;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
}

.setup-toggles {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 0.83rem;
  color: #cbd5e1;
  cursor: pointer;
}
.toggle-row input { margin-top: 3px; accent-color: var(--primary); }

.setup-footer-actions {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.baseline-counts {
  display: flex;
  align-items: center;
  gap: 8px;
}

.baseline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
  max-height: 68vh;
  overflow-y: auto;
  padding-right: 4px;
}

.baseline-item {
  background: #fdfcf8;
  color: #0f172a;
  border: 2.5px solid #22c55e;
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  transition: opacity 0.15s ease, transform 0.08s ease;
}

.baseline-item:active { transform: scale(0.96); }

.baseline-item svg {
  width: 66px;
  height: 66px;
}

.baseline-item .b-name {
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.15;
}

.baseline-item .b-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 5px;
  background: #16a34a;
  color: #ffffff;
}

.baseline-item.excluded {
  opacity: 0.42;
  border-color: #ef4444;
  background: #1e293b;
  color: #cbd5e1;
}

.baseline-item.excluded .b-badge {
  background: #dc2626;
}

.b-edit-btn {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(15, 23, 42, 0.12);
  color: #0f172a;
  border: 1px solid rgba(15, 23, 42, 0.25);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 0.7rem;
  font-weight: 800;
  cursor: pointer;
}
.b-edit-btn:hover { background: #0284c7; color: #ffffff; border-color: #0284c7; }
.baseline-item.excluded .b-edit-btn { color: #e2e8f0; border-color: rgba(255, 255, 255, 0.25); }

/* ---------- TAB 2: LIVE OR MAPPING CONSOLE ---------- */
.protocol-advisor-bar {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 10px;
  padding: 8px 13px;
  margin-bottom: 10px;
  font-size: 0.8rem;
  color: #e0f2fe;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.or-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.stimulus-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.task-toolbar-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-group-row {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.task-group-tag {
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  padding: 4px 7px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
  min-width: 88px;
  text-align: center;
}
.task-group-tag.cog-tag {
  background: rgba(168, 85, 247, 0.18);
  color: #d8b4fe;
}

.task-pills, .stage-controls {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.stage-controls { margin-left: auto; }

.patient-stage {
  flex: 1;
  min-height: 410px;
  border-radius: 16px;
  border: 6px solid var(--l1-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 16px;
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.15s ease;
}

.patient-stage.stage-light {
  background: #fdfcf8;
  color: #0f172a;
}

.patient-stage.stage-dark {
  background: #0f172a;
  color: #f8fafc;
}

.patient-stage.lang-l2 {
  border-color: var(--l2-color);
}

.patient-stage.stim-active {
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.55);
}

.stage-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lang-badge {
  font-size: 0.8rem;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 999px;
  color: #ffffff;
}
.lang-badge.badge-l1 { background: var(--l1-color); }
.lang-badge.badge-l2 { background: var(--l2-color); }

.stage-counter {
  font-size: 0.8rem;
  font-weight: 700;
  opacity: 0.65;
}

.stim-live-dot {
  font-size: 0.8rem;
  font-weight: 900;
  color: #ffffff;
  background: #ef4444;
  padding: 4px 10px;
  border-radius: 999px;
  animation: blinkLive 0.8s infinite;
}
@keyframes blinkLive {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.stage-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
}

.stage-content > svg {
  width: min(320px, 68%);
  height: min(320px, 44vh);
}

.stage-caption {
  text-align: center;
  font-size: 1.45rem;
  font-weight: 800;
  padding-top: 6px;
}

/* Semantic Association Triplet View */
.semantic-grid {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.semantic-target-box {
  width: 152px;
  height: 152px;
  border: 4px solid #0f172a;
  border-radius: 18px;
  padding: 10px;
  background: #ffffff;
}

.semantic-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  width: 100%;
  max-width: 420px;
}

.semantic-option-box {
  height: 146px;
  border: 3px dashed #64748b;
  border-radius: 18px;
  padding: 10px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.semantic-option-box.examiner-correct {
  border-color: #16a34a;
}

.semantic-target-box svg, .semantic-option-box svg {
  width: 100%;
  height: 100%;
}

/* Motor + Dual-Tasking View */
.dual-stage-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  gap: 18px;
  flex-wrap: wrap;
}

.motor-metronome-disc {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  border: 6px solid #0284c7;
  background: #e0f2fe;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: dualPulse 1.2s ease-in-out infinite;
}
@keyframes dualPulse {
  0%, 100% { transform: scale(0.92); background: #e0f2fe; }
  50% { transform: scale(1.06); background: #bae6fd; }
}
.motor-hand-glyph { font-size: 4.2rem; line-height: 1; }
.motor-sub { font-size: 0.72rem; font-weight: 800; color: #0369a1; margin-top: 6px; letter-spacing: 0.04em; }

.dual-stim-svg {
  width: 220px;
  height: 220px;
}
.dual-stim-svg svg { width: 100%; height: 100%; }

/* Cognitive: Interactive Line Bisection */
.bisect-stage-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px 8px;
}

.bisect-touch-area {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: crosshair;
  position: relative;
}

.bisect-bar {
  height: 14px;
  background: #111827;
  border-radius: 7px;
  position: relative;
  touch-action: none;
}
.patient-stage.stage-dark .bisect-bar { background: #f8fafc; }

.bisect-true-mid {
  position: absolute;
  top: -12px;
  left: 50%;
  width: 2px;
  height: 38px;
  background: #16a34a;
  opacity: 0.45;
  pointer-events: none;
}

.bisect-user-mark {
  position: absolute;
  top: -24px;
  width: 6px;
  height: 62px;
  background: #ef4444;
  border-radius: 3px;
  transform: translateX(-50%);
  pointer-events: none;
}

.bisect-readout {
  font-size: 0.92rem;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
}
.bisect-readout.neglect-alert {
  background: #fee2e2;
  color: #991b1b;
  border: 1.5px solid #dc2626;
}

/* Cognitive: Executive Flanker & Go/No-Go */
.flanker-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.flanker-arrows {
  display: flex;
  gap: 14px;
  font-size: clamp(2.8rem, 6.2vw, 4.4rem);
  font-weight: 900;
  align-items: center;
}
.flanker-arrows .center-arrow {
  color: #0284c7;
  transform: scale(1.16);
}

.nogo-octagon {
  width: 196px;
  height: 196px;
  background: #dc2626;
  color: #ffffff;
  clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4.5rem;
  font-weight: 900;
}

.go-disc {
  width: 196px;
  height: 196px;
  border-radius: 50%;
  background: #16a34a;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4.5rem;
  font-weight: 900;
}

/* Phonology & Calculation Stage */
.auditory-stage, .calc-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 12px;
}
.auditory-icon { font-size: 4.2rem; }
.auditory-prompt { font-size: 2rem; font-weight: 900; letter-spacing: 0.06em; }
.calc-prompt { font-size: clamp(2.3rem, 4.8vw, 3.6rem); font-weight: 900; letter-spacing: 0.04em; }
.stage-subhint { font-size: 0.85rem; opacity: 0.72; max-width: 440px; }

/* Examiner Cue Bar */
.examiner-cue-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.cue-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.cue-tag {
  font-size: 0.66rem;
  font-weight: 800;
  color: var(--primary);
  background: rgba(56, 189, 248, 0.14);
  padding: 3px 7px;
  border-radius: 5px;
}

.cue-word { font-size: 1.1rem; color: #ffffff; }
.cue-phonetic { font-size: 0.85rem; color: #fcd34d; font-family: ui-monospace, monospace; }
.cue-carrier { font-size: 0.8rem; color: var(--muted); }

/* Right Column Controls */
.control-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.metro-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.metro-status {
  font-size: 0.84rem;
  font-weight: 700;
  color: #e2e8f0;
  margin-top: 2px;
}

.metro-head-right {
  display: flex;
  gap: 6px;
}

.metro-visual-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.metro-timer-readout {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  font-size: 1.55rem;
  min-width: 96px;
}
.metro-unit { font-size: 0.76rem; font-weight: 700; color: var(--muted); }

.metro-progress-track {
  height: 24px;
  background: #0a101b;
  border: 1px solid var(--border);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}

.metro-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e 0%, #f59e0b 75%, #ef4444 100%);
  transition: width 0.05s linear;
}

.metro-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px dashed rgba(255, 255, 255, 0.28);
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.65);
  padding-left: 3px;
  display: flex;
  align-items: center;
  pointer-events: none;
}

.btn-stim {
  background: #16a34a;
  border-color: #4ade80;
  color: #ffffff;
  min-width: 152px;
  padding: 12px 14px;
  font-size: 0.9rem;
}
.btn-stim:hover { background: #15803d; }
.btn-stim.running {
  background: #dc2626;
  border-color: #fca5a5;
}

.seizure-banner {
  margin-top: 10px;
  background: #7f1d1d;
  border: 1.5px solid #ef4444;
  border-radius: 9px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.82rem;
}

.seizure-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.seizure-clock {
  font-family: ui-monospace, monospace;
  font-size: 1.05rem;
  font-weight: 900;
  color: #fef08a;
}

/* Tag & Current Parameters */
.tag-row-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 5px;
}

.tag-chip {
  min-width: 38px;
  height: 36px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #0d1523;
  color: var(--text);
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  position: relative;
}
.tag-chip.active {
  background: var(--primary-strong);
  border-color: var(--primary);
  color: #ffffff;
}
.tag-chip.confirmed {
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.35);
}
.tag-chip.confirmed::after {
  content: '★';
  position: absolute;
  top: -6px;
  right: -4px;
  font-size: 0.65rem;
  color: #f87171;
}

.custom-tag-wrap {
  display: flex;
  gap: 5px;
}

.input-compact {
  width: 62px;
  background: #0d1523;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 0.82rem;
  font-weight: 700;
}

.params-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.param-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.seg-control {
  display: inline-flex;
  background: #0d1523;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.seg-btn {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.seg-btn.active {
  background: var(--primary-strong);
  color: #ffffff;
}

.stepper {
  display: inline-flex;
  align-items: center;
  background: #0d1523;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.step-btn {
  width: 34px;
  height: 32px;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
}
.step-btn:hover { background: var(--primary-strong); }
.step-val {
  min-width: 68px;
  text-align: center;
  font-weight: 800;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.tag-status-box {
  background: #0d1523;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 11px;
  min-width: 138px;
}
.tag-status-box.eloquent {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.14);
}
.tag-stat-val {
  font-size: 0.84rem;
  font-weight: 800;
  margin-top: 2px;
}

/* 1-Tap Outcome Buttons */
.outcome-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.input-note {
  flex: 1;
  min-width: 180px;
  background: #0d1523;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 0.8rem;
}

.outcome-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.outcome-btn {
  position: relative;
  min-height: 54px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  text-align: left;
  transition: transform 0.06s ease, filter 0.12s ease;
}
.outcome-btn:hover { filter: brightness(1.14); }
.outcome-btn:active { transform: scale(0.97); }

.key-hint {
  position: absolute;
  top: 5px;
  right: 7px;
  font-size: 0.65rem;
  opacity: 0.55;
  font-family: ui-monospace, monospace;
}

.out-normal { background: rgba(22, 163, 74, 0.24); border-color: #22c55e; }
.out-arrest { background: rgba(220, 38, 38, 0.28); border-color: #ef4444; }
.out-anomia { background: rgba(234, 88, 12, 0.25); border-color: #f97316; }
.out-semantic { background: rgba(217, 119, 6, 0.24); border-color: #f59e0b; }
.out-phonemic { background: rgba(202, 138, 4, 0.22); border-color: #eab308; }
.out-dysarthria { background: rgba(219, 39, 119, 0.22); border-color: #ec4899; }
.out-motor { background: rgba(185, 28, 28, 0.28); border-color: #f87171; }
.out-bilingual { background: rgba(147, 51, 234, 0.25); border-color: #a855f7; }
.out-neglect { background: rgba(8, 145, 178, 0.26); border-color: #06b6d4; }
.out-cognitive { background: rgba(109, 40, 217, 0.26); border-color: #8b5cf6; }

/* Recent Trials Strip */
.recent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.recent-actions { display: flex; gap: 6px; }

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 150px;
  overflow-y: auto;
}

.trial-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #0d1523;
  border-left: 4px solid #22c55e;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.78rem;
}
.trial-row.is-deficit { border-left-color: #ef4444; }

.empty-msg {
  color: var(--muted);
  font-size: 0.8rem;
  font-style: italic;
  padding: 6px 0;
}

/* ---------- TAB 3: CORTICAL MAP & BIOPSY VIALS ---------- */
.cortex-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.map-mode-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.cortical-map-container {
  width: 100%;
  aspect-ratio: 640 / 420;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: crosshair;
}

.tag-summary-strip {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.tag-summary-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.summary-chip {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  background: #0d1523;
  border: 1px solid var(--border);
}
.summary-chip.eloquent {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.16);
  color: #fecaca;
}

.biopsy-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.qc-warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid #f59e0b;
  color: #fde68a;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.35;
}

.biopsy-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.biopsy-list-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.biopsy-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  max-height: 290px;
  overflow-y: auto;
}

.biopsy-item {
  background: #0d1523;
  border: 1px solid var(--border);
  border-left: 4px solid #9333ea;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.8rem;
}

/* ---------- TAB 4: REPORT & PRINT STYLES ---------- */
.export-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.export-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.file-upload-btn { cursor: pointer; }

.report-preview-wrap {
  background: #ffffff;
  color: #0f172a;
  border-radius: 12px;
  padding: 24px 28px;
  max-width: 960px;
  margin: 0 auto;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.print-report h2 { margin: 0; font-size: 1.35rem; color: #0f172a; }
.print-report h3 { margin: 18px 0 8px; font-size: 1rem; border-bottom: 2px solid #0f172a; padding-bottom: 4px; }
.report-sub { margin: 4px 0 0; font-size: 0.8rem; color: #475569; }

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #0f172a;
}

.report-case-badge {
  border: 1.5px solid #0f172a;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.84rem;
  min-width: 170px;
}

.report-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 14px;
  margin: 12px 0;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.82rem;
}

.report-alert {
  background: #fef2f2;
  border: 1.5px solid #dc2626;
  color: #7f1d1d;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  margin-bottom: 12px;
}

.report-map-box {
  width: 100%;
  max-width: 580px;
  margin: 10px auto 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  overflow: hidden;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.report-table th, .report-table td {
  border: 1px solid #cbd5e1;
  padding: 6px 8px;
  text-align: left;
}
.report-table th { background: #f1f5f9; font-weight: 800; }
.empty-cell { text-align: center; color: #64748b; font-style: italic; }

.badge-eloquent {
  display: inline-block;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #dc2626;
  font-weight: 800;
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.warn-flag {
  color: #b45309;
  font-weight: 700;
}

.report-footer-note {
  margin-top: 16px;
  font-size: 0.74rem;
  color: #475569;
  border-top: 1px solid #cbd5e1;
  padding-top: 8px;
}

/* ---------- TAB 5: PROTOCOLS & VERIFIED REFERENCES ---------- */
.refs-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.matrix-table-wrap { overflow-x: auto; }

.dark-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.dark-table th, .dark-table td {
  border: 1px solid var(--border);
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
}
.dark-table th {
  background: var(--surface-2);
  color: #7dd3fc;
  font-weight: 800;
}

.references-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ref-category-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 4px 0 8px;
}

.ref-item {
  background: #0d1523;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary-strong);
  border-radius: 9px;
  padding: 10px 13px;
  margin-bottom: 8px;
}

.ref-citation {
  font-size: 0.86rem;
  line-height: 1.45;
  color: #f1f5f9;
}

.ref-relevance {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 5px;
}

.ref-links {
  margin-top: 6px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ref-link-pill {
  font-size: 0.74rem;
  font-weight: 700;
  color: #7dd3fc;
  text-decoration: none;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 2px 8px;
  border-radius: 6px;
}
.ref-link-pill:hover { background: rgba(56, 189, 248, 0.25); }

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
}

.toast {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid var(--primary);
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* ---------- Responsive (Portrait Tablet / Small Laptop) ---------- */
@media (max-width: 1080px) {
  .setup-grid, .or-workspace, .cortex-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .patient-stage { min-height: 320px; }
  .report-meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .form-grid, .form-row-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- Print Media (Clean B&W Hospital Paper Chart) ---------- */
@media print {
  body { background: #ffffff !important; color: #000000 !important; }
  .no-print { display: none !important; }
  .main-shell { padding: 0; max-width: 100%; }
  #tab-report { display: block !important; }
  .report-preview-wrap {
    box-shadow: none;
    padding: 0;
    max-width: 100%;
    border-radius: 0;
  }
}
