/* ==========================================================================
   AI CLINICAL TREATMENT AUDITOR — MODERN DASHBOARD STYLESHEET
   Medical-Grade Decision Support System
   ========================================================================== */

:root {
  /* Surface & Canvas (Light Mode) */
  --ground: #f5f7fb;
  --surface: #fdfdfe;
  --surface-card: #fdfdfe;
  --raised: #eef1f5;
  --raised-hover: #e4e8ee;
  --border: #e3e7ed;
  --border-subtle: #edf2f7;
  --border-light: #eef2f6;
  --border-strong: #cbd5e1;
  --rule: #f1f5f9;
  --control: #cbd5e1;
  --control-focus: #3b82f6;

  /* Typography */
  --text: #1e2633;
  --text-secondary: #3d4757;
  --muted: #667085;
  --muted-light: #94a3b8;

  /* Brand Accents */
  --primary: #1f4b99;
  --primary-hover: #183c7d;
  --primary-glow: rgba(37, 99, 235, 0.12);
  --primary-light: #e8eef8;
  --focus: #f26b21;
  --accent: #f26b21;
  --accent-hover: #dc5a14;
  --accent-light: #fff1e8;
  --navy: #1f4b99;
  --font-display: "Lexend", "Inter", system-ui, sans-serif;

  /* Semantic Status Palette (Light) */
  --match: #10b981;
  --match-bg: #ecfdf5;
  --match-ink: #065f46;
  --match-border: #a7f3d0;

  --partial: #f59e0b;
  --partial-bg: #fffbeb;
  --partial-ink: #92400e;
  --partial-border: #fde68a;

  --conflict: #ef4444;
  --conflict-bg: #fef2f2;
  --conflict-ink: #991b1b;
  --conflict-border: #fecaca;

  --ai: #8b5cf6;
  --ai-bg: #f5f3ff;
  --ai-ink: #5b21b6;
  --ai-border: #ddd6fe;

  --doctor: #0284c7;
  --doctor-bg: #f0f9ff;
  --doctor-ink: #0369a1;
  --doctor-border: #bae6fd;

  --other: #64748b;
  --other-bg: #f8fafc;
  --other-ink: #475569;
  --other-border: #e2e8f0;

  /* Layout dimensions */
  --radius-card: 12px;
  --radius-control: 8px;
  --radius-chip: 6px;
  --radius-pill: 9999px;
  --gap: 16px;
  --pad: 24px;
  --bar-h: 56px;
  --tabs-h: 46px;
  --stick: calc(var(--bar-h) + var(--tabs-h));

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.03);
  --shadow-md: 0 2px 8px -2px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 6px 16px -4px rgba(15, 23, 42, 0.07);
  --shadow-popover: 0 12px 28px -4px rgba(15, 23, 42, 0.15), 0 4px 12px -2px rgba(15, 23, 42, 0.08);

  /* Fonts & Transitions */
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --transition: 180ms var(--ease);
}

/* ================= DARK MODE OVERRIDES ================= */
[data-theme="dark"] {
  --ground: #0b0f19;
  --surface: #111827;
  --surface-card: #141e33;
  --raised: #1f293d;
  --raised-hover: #28354f;
  --border: #232f48;
  --border-subtle: #1a2336;
  --border-light: #1e293b;
  --border-strong: #334155;
  --rule: #1e293b;
  --control: #334155;
  --control-focus: #60a5fa;

  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --muted: #94a3b8;
  --muted-light: #64748b;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-glow: rgba(59, 130, 246, 0.2);
  --primary-light: #1e3a8a33;

  /* Semantic Status (Dark) */
  --match-bg: #064e3b33;
  --match-ink: #34d399;
  --match-border: #05966955;

  --partial-bg: #78350f33;
  --partial-ink: #fbbf24;
  --partial-border: #d9770655;

  --conflict-bg: #7f1d1d33;
  --conflict-ink: #f87171;
  --conflict-border: #dc262655;

  --ai-bg: #312e8133;
  --ai-ink: #c4b5fd;
  --ai-border: #6366f155;

  --doctor-bg: #0c4a6e33;
  --doctor-ink: #7dd3fc;
  --doctor-border: #0284c755;

  --other-bg: #1e293b;
  --other-ink: #94a3b8;
  --other-border: #334155;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, 0.6);
  --shadow-popover: 0 12px 30px -4px rgba(0, 0, 0, 0.8);
}

/* ================= RESET & BASE ================= */
* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--stick) + 12px);
  color-scheme: light dark;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--ground);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
  transition: background-color var(--transition), color var(--transition);
}

::selection {
  background: var(--primary-light);
  color: var(--primary);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

button, input, select {
  font: inherit;
  color: inherit;
}

/* ================= TOP APP BAR ================= */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--bar-h);
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 0 var(--pad);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  cursor: pointer;
  justify-self: start;
}

.brand-logo {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--match);

}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Patient Form in App Bar - Centered Command Capsule */
.pid-form {
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  width: 100%;
}

.search-capsule {
  display: flex;
  align-items: center;
  background: var(--ground);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px 4px 3px 14px;
  width: 440px;
  max-width: 100%;
  transition: all var(--transition);
  position: relative;
}

.search-capsule:focus-within {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px var(--primary-glow), 0 4px 14px rgba(15, 23, 42, 0.06);
}

.search-capsule-icon {
  color: var(--muted);
  flex: none;
  margin-right: 8px;
}

.search-capsule input[type="text"] {
  border: none !important;
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  height: 34px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  min-width: 0;
  padding: 0 4px;
}

.search-capsule input[type="text"]::placeholder {
  color: var(--muted-light);
  font-weight: 400;
}

.input-clear-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--border);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  margin-right: 6px;
  flex: none;
}
.input-clear-btn:hover { background: var(--control); color: var(--text); }

.search-kbd-hint {
  font-size: 10.5px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  margin: 0 6px;
  flex: none;
  pointer-events: none;
}

.search-run-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background var(--transition);
  flex: none;
  white-space: nowrap;
}

.search-run-btn:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.4);
}

.search-run-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.search-run-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Quick Sample Patient Pills */
.quick-samples {
  display: flex;
  align-items: center;
  gap: 6px;
}

.quick-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sample-chip {
  height: 26px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--ground);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  cursor: pointer;
  transition: all var(--transition);
}

.sample-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.sample-tag {
  font-size: 10px;
  padding: 1px 4px;
  background: var(--border);
  border-radius: 3px;
  color: var(--muted);
  font-family: var(--font);
}

/* Config Popover (Data Mode Options) */
.config-popover-wrap {
  position: relative;
  display: inline-flex;
}

.config-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 320px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-popover);
  display: none;
  flex-direction: column;
  gap: 12px;
  z-index: 50;
  animation: popover-slide 150ms var(--ease);
}

.config-popover.open {
  display: flex;
}

@keyframes popover-slide {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.popover-header h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.popover-desc {
  font-size: 11px;
  color: var(--muted);
}
.popover-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.popover-row label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

select {
  height: 34px;
  width: 100%;
  padding: 0 10px;
  font-size: 12px;
  background: var(--ground);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  cursor: pointer;
  transition: border-color var(--transition);
}

select:focus {
  outline: none;
  border-color: var(--control-focus);
}

/* Buttons */
.btn {
  height: 36px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  cursor: pointer;
  transition: all var(--transition);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4338ca);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px var(--primary-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--ground);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--raised);
  border-color: var(--control);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--ground);
  color: var(--text);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover:not(:disabled) {
  background: var(--ground);
  border-color: var(--control);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

/* App Bar Right */
.app-bar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: none;
  justify-self: end;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-control);
  background: var(--ground);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
}
.theme-toggle:hover {
  background: var(--raised);
  color: var(--text);
}

#fetch-status {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
  text-align: right;
  padding: 0 4px;
}
#fetch-status:empty {
  display: none;
}
#fetch-status.loading { color: var(--primary); }
#fetch-status.success { color: var(--match); }
#fetch-status.error { color: var(--conflict); }

.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= CANVAS / MAIN CONTAINER ================= */
.dashboard-container {
  max-width: 1540px;
  margin: 0 auto;
  padding: 20px var(--pad) 48px;
}

body.no-audit #audit-view,
body.is-loading #audit-view {
  display: none !important;
}

body.is-loading #empty-state {
  display: none !important;
}

body:not(.no-audit):not(.is-loading) #empty-state {
  display: none !important;
}

/* ================= LIVE CASE REVIEW (while the audit runs) ================= */
.thinking-card.loading-state-card {
  text-align: left; max-width: 860px; padding: 24px 28px 20px; margin: 28px auto;
}
.thinking-head { display: flex; align-items: center; gap: 14px; }
.thinking-titles { flex: 1; min-width: 0; }
.thinking-card h3 { font-size: 1.05rem; margin: 0 0 2px; }
.thinking-stage {
  margin: 0; font-size: 0.86rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thinking-timer { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.thinking-orb {
  flex: none; width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #93b4ff, var(--primary));
  box-shadow: 0 0 0 0 var(--primary-glow);
  animation: thinkingPulse 1.8s ease-in-out infinite;
}
@keyframes thinkingPulse {
  0%, 100% { transform: scale(0.85); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.25); }
  50% { transform: scale(1); box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
}

.thinking-facts { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 0; }
.thinking-fact {
  display: inline-flex; gap: 6px; align-items: baseline; padding: 3px 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--raised);
  font-size: 0.8rem; animation: factIn 0.35s ease both;
}
.thinking-fact .k { color: var(--muted); }
.thinking-fact .v { color: var(--text); font-weight: 600; }
@keyframes factIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.thinking-body {
  margin-top: 16px; padding: 4px 14px 4px 16px; border-left: 2px solid var(--primary-light);
  max-height: min(52vh, 520px); overflow-y: auto; scroll-behavior: smooth;
}
.thinking-text h4, .thinking-body h4 {
  margin: 14px 0 4px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--primary);
}
.thinking-text h4:first-child, .thinking-body h4:first-child { margin-top: 4px; }
.thinking-text p, .thinking-body p {
  margin: 0 0 8px; font-size: 0.93rem; line-height: 1.65; color: var(--text-secondary); max-width: 72ch;
}
.thinking-caret {
  display: inline-block; width: 7px; height: 1.05em; margin-left: 2px; vertical-align: -2px;
  background: var(--primary); border-radius: 1px; animation: caretBlink 1s steps(1) infinite;
}
@keyframes caretBlink { 50% { opacity: 0; } }

.thinking-steps {
  display: flex; flex-wrap: wrap; gap: 6px 18px; list-style: none; padding: 12px 0 0; margin: 16px 0 0;
  border-top: 1px solid var(--border-subtle); font-size: 0.8rem; color: var(--muted-light);
}
.thinking-steps li { display: inline-flex; align-items: center; gap: 6px; }
.thinking-steps li::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid currentColor;
}
.thinking-steps li.active { color: var(--primary); }
.thinking-steps li.active::before { background: currentColor; animation: thinkingPulse 1.8s ease-in-out infinite; }
.thinking-steps li.done { color: var(--match-ink); }
.thinking-steps li.done::before { background: var(--match); border-color: var(--match); }

@media (prefers-reduced-motion: reduce) {
  .thinking-orb, .thinking-caret, .thinking-steps li.active::before, .thinking-fact { animation: none; }
}
@media (max-width: 640px) {
  .thinking-card.loading-state-card { padding: 18px 16px; margin: 16px auto; }
}

/* The finished review, kept above the results */
.case-review {
  margin: 0 0 16px; border: 1px solid var(--border); border-radius: var(--radius-lg, 10px);
  background: var(--surface);
}
.case-review summary {
  display: flex; align-items: baseline; gap: 10px; padding: 10px 16px; cursor: pointer; list-style: none;
}
.case-review summary::-webkit-details-marker { display: none; }
.case-review summary::before { content: "\25B8"; font-size: 11px; color: var(--muted); transition: transform .15s; }
.case-review[open] summary::before { transform: rotate(90deg); }
.case-review-label { font-weight: 600; font-size: 0.9rem; }
.case-review-hint { font-size: 0.82rem; color: var(--muted); }
.case-review-body { padding: 0 20px 12px 34px; }

/* ================= IN-PROGRESS LOADING STATE ================= */
#loading-state {
  display: none;
}

body.is-loading #loading-state {
  display: block !important;
}

.loading-state-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 56px 36px;
  text-align: center;
  max-width: 700px;
  margin: 40px auto;
  box-shadow: var(--shadow-md);
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.loading-pulse-ring {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 24px;
}

.spinner-large {
  width: 52px;
  height: 52px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-right-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.loading-state-card h3 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.loading-target-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto 28px;
  line-height: 1.55;
}

.loading-progress-bar {
  width: 100%;
  max-width: 440px;
  height: 6px;
  background: var(--border-light);
  border-radius: 999px;
  overflow: hidden;
  margin: 0 auto 32px;
  position: relative;
}

.loading-progress-indeterminate {
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #6366f1);
  border-radius: 999px;
  position: absolute;
  animation: indeterminateBar 1.6s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
}

@keyframes indeterminateBar {
  0% { left: -40%; }
  100% { left: 100%; }
}

.loading-stages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.loading-stage-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 14px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: all 0.3s ease;
}

.loading-stage-item .stage-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.loading-stage-item.active {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--primary-bg);
  box-shadow: 0 0 0 1px var(--primary);
}

.loading-stage-item.active .stage-dot {
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
  animation: pulseDot 1.5s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.loading-stage-arrow {
  color: var(--text-muted);
  font-size: 0.85rem;
  user-select: none;
}

/* Alerts */
.alert-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--gap);
  padding: 12px 16px;
  border-radius: var(--radius-control);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.alert-error {
  background: var(--conflict-bg);
  border-color: var(--conflict-border);
  color: var(--conflict-ink);
}

/* ================= LANDING / EMPTY STATE ================= */
.empty-state-hero {
  max-width: 1140px;
  margin: 32px auto 48px;
}

.landing-head {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 40px;
  align-items: end;
  padding-bottom: 28px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.landing-kicker {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px;
}

.hero-headline {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.25;
  margin: 0 0 10px;
}

.hero-subhead {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 62ch;
  margin: 0;
}

.landing-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.landing-steps li {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.landing-steps strong {
  color: var(--text);
  font-weight: 600;
}

.step-num {
  flex: none;
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.hero-cohorts-section {
  margin-bottom: 20px;
}

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

.cohorts-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.cohorts-desc {
  font-size: 0.85rem;
  color: var(--muted);
}

.cohorts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.cohort-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.cohort-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.cohort-card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.cohort-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.cohort-badge {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cohort-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-light);
}

.cohort-badge.sev-high::before {
  background: var(--conflict);
}

.cohort-pid {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.cohort-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin: 0 0 6px;
}

.cohort-detail {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 16px;
  flex: 1;
}

.cohort-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.cohort-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.cohort-tag {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-chip);
  background: var(--raised);
  color: var(--text-secondary);
  white-space: nowrap;
}

.tag-alert {
  background: var(--conflict-bg);
  color: var(--conflict-ink);
}

.tag-warning {
  background: var(--partial-bg);
  color: var(--partial-ink);
}

.cohort-action {
  flex: none;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.cohort-action .arrow {
  transition: transform var(--transition);
}

.cohort-card:hover .cohort-action .arrow {
  transform: translateX(3px);
}

.landing-disclaimer {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
}

/* ================= TITLE ROW & EXECUTIVE KPIS ================= */
.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: var(--gap);
}

.title-main {
  min-width: 0;
}

.patient-id-badge {
  display: inline-block;
  padding: 2px 8px;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-mono);
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-chip);
}

h1 {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
}

.title-sub {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* KPIs Card */
.kpis {
  display: flex;
  flex: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.kpi {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
}

.kpi + .kpi {
  border-left: 1px solid var(--border);
}

.kpi-label-block dt {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  white-space: nowrap;
}

.kpi-label-block dd {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  margin-top: 2px;
}

.kpi-subtext {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

/* Agreement Score Radial Gauge */
.kpi-gauge-wrap {
  position: relative;
  width: 52px;
  height: 52px;
  flex: none;
}

.kpi-gauge-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.kpi-gauge-bg {
  fill: none;
  stroke: var(--raised);
  stroke-width: 4.5;
}

.kpi-gauge-meter {
  fill: none;
  stroke: var(--match);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-dasharray: 144.5; /* 2 * PI * 23 */
  stroke-dashoffset: 20;
  transition: stroke-dashoffset 800ms var(--ease), stroke 300ms ease;
}

.kpi-gauge-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-lead dd#card-agreement-val {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.kpi-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--ground);
  color: var(--muted);
  flex: none;
}
.kpi-icon-wrap.info-icon-wrap { background: var(--primary-light); color: var(--primary); }
.kpi-icon-wrap.calendar-icon-wrap { background: var(--raised); color: var(--text-secondary); }

/* ================= PATIENT DETAILS CARD ================= */
.patient-dashboard {
  margin-bottom: var(--gap);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.patient-dashboard:hover {
  box-shadow: var(--shadow-md);
}

.disclosure {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  background: none;
  border: 0;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--transition);
}

.disclosure:hover {
  background: var(--ground);
}

.disclosure-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.disclosure-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}

.disclosure-hint {
  min-width: 0;
  flex: 1;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

.disclosure-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  background: var(--raised);
  color: var(--muted);
  border-radius: var(--radius-chip);
  white-space: nowrap;
}

.chev {
  flex: none;
  color: var(--muted);
  transition: transform 200ms var(--ease);
}
[aria-expanded="true"] .chev {
  transform: rotate(90deg);
}

.patient-body {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.patient-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 14px 0;
  border-bottom: 1px solid var(--border);
  background: var(--ground);
}

.patient-tab {
  height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
}

.patient-tab:hover {
  color: var(--text);
}

.patient-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--surface);
  border-top-left-radius: 6px;
  border-top-right-radius: 6px;
}

.patient-tab-panel {
  display: none;
  padding: 16px;
  max-height: 400px;
  overflow: auto;
}
.patient-tab-panel.active { display: block; }

.patient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px 24px;
}
.patient-grid-overview {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.patient-info-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  background: var(--ground);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-chip);
}

.patient-info-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.patient-info-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.patient-section-block + .patient-section-block { margin-top: 14px; }
.patient-section-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.patient-section-text {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  background: var(--ground);
  padding: 12px;
  border-radius: var(--radius-chip);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ================= STATUS BREAKDOWN PROGRESS & FILTER ================= */
.status-strip {
  margin-bottom: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}

.status-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.status-bar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.status-bar-desc {
  font-size: 11px;
  color: var(--muted-light);
}

.status-bar {
  display: flex;
  gap: 3px;
  height: 8px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--ground);
  margin-bottom: 10px;
}

.status-bar > span {
  min-width: 4px;
  background: var(--other);
  transition: flex-grow 300ms var(--ease);
}

.status-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  height: 28px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  background: var(--ground);
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition);
}

.chip:hover:not(:disabled) {
  background: var(--raised);
  color: var(--text);
  border-color: var(--control);
}

.chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--other);
}

.chip .count {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 5px;
  background: var(--border);
  border-radius: 4px;
  color: var(--muted);
}

.chip[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px var(--primary-glow);
}
.chip[aria-pressed="true"] .count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.chip:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Critical or conflict chip */
.chip-flag.has-flags:not([aria-pressed="true"]) {
  border-color: var(--conflict-border);
  background: var(--conflict-bg);
  color: var(--conflict-ink);
}
.chip-flag.has-flags:not([aria-pressed="true"]) .count {
  background: var(--conflict);
  color: #fff;
}

[data-status="match"] { --s-bg: var(--match-bg); --s-ink: var(--match-ink); --s: var(--match); }
[data-status="partial"] { --s-bg: var(--partial-bg); --s-ink: var(--partial-ink); --s: var(--partial); }
[data-status="conflict"] { --s-bg: var(--conflict-bg); --s-ink: var(--conflict-ink); --s: var(--conflict); }
[data-status="ai"] { --s-bg: var(--ai-bg); --s-ink: var(--ai-ink); --s: var(--ai); }
[data-status="doctor"] { --s-bg: var(--doctor-bg); --s-ink: var(--doctor-ink); --s: var(--doctor); }
[data-status="other"] { --s-bg: var(--other-bg); --s-ink: var(--other-ink); --s: var(--other); }
.status-bar > span[data-status], .chip[data-status] .dot { background: var(--s); }

/* ================= TABS AND SEARCH TOOLBAR ================= */
.filter-toolbar {
  position: sticky;
  top: var(--bar-h);
  z-index: 30;
  height: var(--tabs-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 calc(var(--pad) * -1) var(--gap);
  padding: 0 var(--pad);
  background: var(--ground);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-chip);
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition);
}

.tab:hover {
  background: var(--surface);
  color: var(--text);
}

.tab.active {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.tab .tab-icon {
  font-size: 12px;
}

.tab .count {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 1px 5px;
  background: var(--raised);
  border-radius: 4px;
  color: var(--muted);
}
.tab.active .count {
  background: var(--primary-light);
  color: var(--primary);
}

/* Filter Right: Switch & Search */
.filter-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
}

/* Switch */
.switch-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.switch-wrap input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: relative;
  width: 32px;
  height: 18px;
  background: var(--border);
  border-radius: 20px;
  transition: background-color var(--transition);
}
.switch-slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition);
}
.switch-wrap input:checked + .switch-slider {
  background: var(--primary);
}
.switch-wrap input:checked + .switch-slider::before {
  transform: translateX(14px);
}
.switch-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

/* Search Box */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 220px;
}
.search-icon {
  position: absolute;
  left: 9px;
  color: var(--muted);
  pointer-events: none;
}
#search-input {
  height: 32px;
  padding-left: 28px;
  padding-right: 28px;
  font-size: 12px;
}
.search-kbd {
  position: absolute;
  right: 8px;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--border);
  color: var(--muted);
  pointer-events: none;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.no-results {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.no-results[hidden], #no-results[hidden] {
  display: none !important;
}

/* ================= AUDIT TABLE SECTIONS ================= */
.section-card {
  margin-bottom: var(--gap);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.section-card:hover {
  box-shadow: var(--shadow-md);
}

.section-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 0 var(--gap);
  align-items: start;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.section-title-icon {
  font-size: 15px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-badge {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 2px 7px;
  background: var(--ground);
  color: var(--muted);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
}

.section-collapse-btn, .info-eye {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: none;
  border: none;
  border-radius: var(--radius-chip);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
}
.section-collapse-btn:hover, .info-eye:hover {
  background: var(--ground);
  color: var(--text);
}

.section-collapse-btn .chev { transform: rotate(90deg); }
.section-card.collapsed .section-collapse-btn .chev,
.final-summary-card.collapsed .section-collapse-btn .chev { transform: rotate(0deg); }
.section-card.collapsed .table-responsive { display: none; }

/* Info popover */
.info-eye-wrap { position: relative; display: inline-flex; }
.info-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 50;
  width: 320px;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  background: var(--text);
  color: var(--ground);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-popover);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: all var(--transition);
}
.info-eye-wrap.open .info-popover {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ================= DATA TABLES ================= */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

/* ================= MASTER 3-SPLIT SCREEN STRIP ================= */
.master-split-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1.15fr;
  gap: 16px;
  margin-bottom: 24px;
}

.split-pillar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}

.split-pillar:hover {
  box-shadow: var(--shadow-md);
}

.pillar-doctor {
  border-top: 3.5px solid #2563eb;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.04) 0%, var(--surface) 100%);
}

.pillar-ai {
  border-top: 3.5px solid #7c3aed;
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.04) 0%, var(--surface) 100%);
}

.pillar-diff {
  border-top: 3.5px solid #059669;
  background: linear-gradient(180deg, rgba(5, 150, 105, 0.04) 0%, var(--surface) 100%);
}

.pillar-badge-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.pillar-tag {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 4px;
}

.pillar-doctor .pillar-tag {
  background: rgba(37, 99, 235, 0.12);
  color: #2563eb;
}

.pillar-ai .pillar-tag {
  background: rgba(124, 58, 237, 0.12);
  color: #7c3aed;
}

.pillar-diff .pillar-tag {
  background: rgba(5, 150, 105, 0.12);
  color: #059669;
}

.pillar-source {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.pillar-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.pillar-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.pillar-title-wrap h3 {
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}

.pillar-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0 0 14px 0;
}

.pillar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.pillar-stat-chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.pillar-stat-chip .stat-number {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.pillar-dot-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.pillar-dot-ai {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.2);
}

.pillar-live-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Pillar 3 Diff/Match Filter Buttons */
.pillar-actions {
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}

.split-toggle-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.split-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: var(--radius-control);
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface-card);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.split-toggle-btn:hover {
  background: var(--control-hover);
  border-color: var(--border-strong);
}

.split-toggle-btn.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

.split-toggle-btn .pill-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--border);
  color: var(--text);
}

.split-toggle-btn.active .pill-badge {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.filter-dot-warning {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
}

.filter-dot-match {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
}

/* ================= 3-SPLIT TABLE HEADERS & CELLS ================= */
.split-thead-row th {
  padding: 12px 16px;
  font-size: 0.82rem;
}

.split-th-doctor {
  background: rgba(37, 99, 235, 0.05) !important;
  border-bottom: 2.5px solid #2563eb !important;
}

.split-th-ai {
  background: rgba(124, 58, 237, 0.05) !important;
  border-bottom: 2.5px solid #7c3aed !important;
}

.split-th-diff {
  background: rgba(5, 150, 105, 0.05) !important;
  border-bottom: 2.5px solid #059669 !important;
}

.split-th-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.split-col-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: -0.01em;
}

.badge-doc { color: #1d4ed8; }
.badge-ai { color: #6d28d9; }
.badge-diff { color: #047857; }

[data-theme="dark"] .badge-doc { color: #60a5fa; }
[data-theme="dark"] .badge-ai { color: #a78bfa; }
[data-theme="dark"] .badge-diff { color: #34d399; }

.split-col-hint {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Split Columns in Table Rows */
.col-doctor {
  background: rgba(37, 99, 235, 0.015);
  border-right: 1px solid var(--border-light);
  vertical-align: top;
  padding: 14px 16px;
}

.col-ai {
  background: rgba(124, 58, 237, 0.015);
  border-right: 1px solid var(--border-light);
  vertical-align: top;
  padding: 14px 16px;
}

.col-diff {
  background: var(--surface);
  vertical-align: top;
  padding: 14px 16px;
}

.split-cell-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.split-item-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

.source-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
}

.doc-tag {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.ai-tag {
  background: rgba(124, 58, 237, 0.1);
  color: #7c3aed;
}

/* Empty split cell placeholder */
.empty-split-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius-control);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

.empty-split-cell .empty-icon {
  font-size: 0.9rem;
  opacity: 0.6;
}

/* Split 3 Differences & Matches Content */
.diff-content-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diff-top-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.diff-chips-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.18);
  border-radius: var(--radius-control);
}

.diff-field-pill {
  font-size: 0.78rem;
  color: var(--text);
  line-height: 1.4;
}

.diff-field-pill strong {
  color: #dc2626;
  font-weight: 600;
}

[data-theme="dark"] .diff-field-pill strong {
  color: #f87171;
}

.match-summary-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-control);
  font-size: 0.8rem;
  font-weight: 600;
  color: #059669;
}

[data-theme="dark"] .match-summary-chip {
  color: #34d399;
}

.safety-remark-box {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-muted);
  padding: 8px 12px;
  background: var(--surface-card);
  border-left: 3px solid var(--border-strong);
  border-radius: 4px;
}

.safety-remark-box.has-critical {
  border-left-color: #ef4444;
  background: rgba(239, 68, 68, 0.04);
  color: var(--text);
}

/* Presence badges in 3-split */
.presence-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  width: fit-content;
}

.presence-yes {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.presence-no {
  background: rgba(156, 163, 175, 0.12);
  color: var(--text-muted);
}

.audit-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12.5px;
}

.audit-table th {
  position: static;
  padding: 10px 14px;
  text-align: left;
  vertical-align: middle;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--ground);
  border-bottom: 1px solid var(--border);
}

.audit-table td {
  padding: 10px 14px;
  vertical-align: top;
  border-top: 1px solid var(--border-subtle);
  overflow-wrap: break-word;
  transition: background-color 100ms ease;
}

.audit-table tbody tr:hover td {
  background: var(--ground);
}

/* Side Specific Column Styling */
.th-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: var(--radius-chip);
  font-size: 11px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: normal;
}
.th-doctor {
  background: var(--doctor-bg);
  color: var(--doctor-ink);
  border: 1px solid var(--doctor-border);
}
.th-ai {
  background: var(--ai-bg);
  color: var(--ai-ink);
  border: 1px solid var(--ai-border);
}

.audit-table td.col-doctor {
  background: rgba(2, 132, 199, 0.015);
}
.audit-table td.col-ai {
  background: rgba(139, 92, 246, 0.015);
}

/* Flagged & Critical Rows */
.audit-table tbody tr.flagged td {
  background: #fff5f5;
  border-top-color: var(--conflict-border);
}
[data-theme="dark"] .audit-table tbody tr.flagged td {
  background: #3c121444;
}
.audit-table tbody tr.critical td {
  background: var(--conflict-bg);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  white-space: nowrap;
  background: var(--s-bg, var(--other-bg));
  color: var(--s-ink, var(--other-ink));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
}

.badge-critical {
  background: var(--conflict);
  color: #ffffff;
  border-color: transparent;
}

/* Spec & Diffs */
.spec {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.spec-item {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.spec-item .k {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.spec-item.diff .v {
  padding: 1px 5px;
  background: var(--partial-bg);
  color: var(--partial-ink);
  border: 1px solid var(--partial-border);
  border-radius: 4px;
  font-weight: 600;
}

/* Fluid Times */
.fluid-times summary {
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--ground);
  cursor: pointer;
  user-select: none;
}
.fluid-times summary:hover {
  background: var(--raised);
  color: var(--text);
}

/* ================= EXECUTIVE AUDIT SUMMARY ================= */
.final-summary-card {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.final-summary-top {
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.final-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border-subtle);
}

.final-panel {
  padding: 16px 18px;
  min-width: 0;
}
.final-panel + .final-panel {
  border-left: 1px solid var(--border);
}

.final-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.panel-icon {
  font-size: 14px;
}

.final-panel-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.final-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.final-bullets {
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.final-bullets li + li {
  margin-top: 6px;
}

.final-panel-wide {
  grid-column: 1 / -1;
  border-left: 0 !important;
  border-top: 1px solid var(--border);
  background: var(--ground);
}

.final-text-wide {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  max-width: 120ch;
}

/* ================= TOAST NOTIFICATIONS ================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 12px 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 200ms var(--ease);
  transition: opacity 200ms ease, transform 200ms ease;
}

.toast.toast-success { border-left: 4px solid var(--match); }
.toast.toast-error { border-left: 4px solid var(--conflict); }
.toast.toast-info { border-left: 4px solid var(--primary); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Back to Top */
.back-to-top {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 30;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  box-shadow: var(--shadow-md);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all var(--transition);
}
.back-to-top:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-2px);
}

/* ================= RESPONSIVE DESIGN SYSTEM ================= */

/* --- Large Desktops & Tablets Landscape (<= 1200px) --- */
@media (max-width: 1200px) {
  .master-split-strip {
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  .pillar-doctor { grid-column: 1; }
  .pillar-ai { grid-column: 2; }
  .pillar-diff { grid-column: 1 / -1; }

  .cohorts-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .workflow-steps {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
  .final-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .final-panel:nth-child(3) { border-left: 0; }
  .final-panel:nth-child(n+3) { border-top: 1px solid var(--border); }
}

/* --- Tablets & Small Laptops (<= 1024px) --- */
@media (max-width: 1024px) {
  :root {
    --pad: 16px;
  }
  .dashboard-container {
    padding: 16px var(--pad) 40px;
  }
  .title-row {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  .kpis {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
  }
  .kpi {
    border: none !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 12px 18px;
  }
  .kpi:nth-child(odd) {
    border-right: 1px solid var(--border) !important;
  }
  .kpi:nth-child(3),
  .kpi:nth-child(4) {
    border-bottom: none !important;
  }

  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .split-table {
    min-width: 760px;
  }
}

/* --- Phablets & Tablets Portrait (<= 900px) --- */
@media (max-width: 900px) {
  .cohorts-grid {
    grid-template-columns: 1fr;
  }
  .workflow-steps {
    grid-template-columns: 1fr;
  }
  .patient-grid-overview {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

/* --- Mobile Phones (<= 768px) --- */
@media (max-width: 768px) {
  :root {
    --pad: 12px;
    --bar-h: auto;
  }

  /* Compact Multi-Row Mobile App Bar */
  .app-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand actions"
      "form form";
    gap: 10px;
    padding: 10px 12px;
    height: auto;
    position: static;
  }

  .brand {
    grid-area: brand;
  }
  .app-bar-right {
    grid-area: actions;
    gap: 8px;
  }

  .pid-form {
    grid-area: form;
    display: flex;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 100%;
  }

  .search-capsule {
    width: 100%;
    padding: 2px 3px 2px 10px;
  }
  .search-kbd-hint {
    display: none;
  }

  .landing-head {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .hero-headline {
    font-size: 1.45rem;
  }

  /* Main Container */
  .dashboard-container {
    padding: 12px var(--pad) 36px;
  }

  /* Patient Details Accordion */
  .patient-dashboard {
    margin-bottom: 16px;
  }
  .patient-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .patient-tabs::-webkit-scrollbar {
    display: none;
  }
  .patient-tab {
    padding: 8px 12px;
    font-size: 11px;
    white-space: nowrap;
  }
  .patient-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
  }
  .patient-grid-overview {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  /* Status / Distribution Summary */
  .summary-strip {
    padding: 12px 14px;
    margin-bottom: 16px;
  }
  .status-bar-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .status-bar {
    height: 6px;
  }
  .status-filter {
    gap: 6px;
  }
  .chip {
    height: 26px;
    padding: 0 8px;
    font-size: 11px;
    gap: 5px;
  }

  /* Filter Toolbar */
  .filter-toolbar {
    position: static;
    flex-direction: column;
    height: auto;
    padding: 8px 0;
    margin: 0 0 14px 0;
    gap: 10px;
    align-items: stretch;
    background: transparent;
    border-bottom: 1px solid var(--border);
    backdrop-filter: none;
  }
  .tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .filter-right {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }
  .search-wrap {
    flex: 1;
    min-width: 0;
  }

  /* Master 3-Split Header Strip */
  .master-split-strip {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 16px;
  }
  .split-pillar {
    padding: 14px 16px;
  }
  .split-toggle-group {
    width: 100%;
    gap: 6px;
  }
  .split-toggle-btn {
    flex: 1 1 auto;
    justify-content: center;
    padding: 6px 8px;
    font-size: 0.74rem;
  }

  /* ================= 3-SPLIT TABLE -> CARD TRANSFORMATION ================= */
  .table-responsive {
    overflow-x: visible;
  }

  .split-table {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    border: none !important;
    border-collapse: separate;
  }

  .split-table thead {
    display: none !important;
  }

  .split-table tbody {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    padding: 6px 0 !important;
    width: 100% !important;
  }

  .split-table tbody tr {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 2px;
    box-sizing: border-box;
    transition: border-color var(--transition);
  }

  .split-table tbody tr.row-conflict {
    border-left: 4.5px solid var(--conflict) !important;
  }
  .split-table tbody tr.row-match {
    border-left: 4.5px solid var(--match) !important;
  }
  .split-table tbody tr.row-partial {
    border-left: 4.5px solid var(--partial) !important;
  }
  .split-table tbody tr.row-doctor {
    border-left: 4.5px solid var(--doctor) !important;
  }
  .split-table tbody tr.row-ai {
    border-left: 4.5px solid var(--ai) !important;
  }

  .split-table tbody tr td {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 12px 14px !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border-light) !important;
  }

  .split-table tbody tr td:last-child {
    border-bottom: none !important;
  }

  .col-doctor {
    background: rgba(37, 99, 235, 0.02) !important;
  }
  .col-ai {
    background: rgba(124, 58, 237, 0.02) !important;
  }
  .col-diff {
    background: rgba(5, 150, 105, 0.02) !important;
  }

  /* Clear split section badges above card cells on mobile */
  .split-table .col-doctor::before {
    content: "👨‍⚕️ DOCTOR PRESCRIPTION";
    display: block;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #2563eb;
    margin-bottom: 8px;
  }

  .split-table .col-ai::before {
    content: "🤖 AI RECOMMENDATION";
    display: block;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #7c3aed;
    margin-bottom: 8px;
  }

  .split-table .col-diff::before {
    content: "⚖️ DIFFERENCES & CONCORDANCE";
    display: block;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #059669;
    margin-bottom: 8px;
  }

  /* Section cards */
  .section-card {
    margin-bottom: 14px;
    border-radius: var(--radius-card);
  }
  .section-header {
    padding: 12px 14px;
  }
  .section-title h2 {
    font-size: 0.95rem;
  }

  /* Final summary card */
  .final-grid {
    grid-template-columns: 1fr;
  }
  .final-panel + .final-panel {
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  /* Popovers on Mobile */
  .info-popover {
    left: 8px !important;
    right: 8px !important;
    width: auto !important;
    max-width: calc(100vw - 16px);
  }

  /* Toasts */
  .toast-container {
    bottom: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: 100%;
  }
  .toast {
    max-width: 100%;
  }

  /* Empty & Loading states */
  .loading-state-card {
    padding: 32px 16px;
  }
  .loading-state-card h3 {
    font-size: 1.15rem;
  }
  .empty-card {
    padding: 32px 16px;
  }
}

/* --- Small Mobile Phones (<= 480px) --- */
@media (max-width: 480px) {
  :root {
    --pad: 10px;
  }
  .brand-title {
    font-size: 14px;
  }
  .brand-logo {
    width: 28px;
    height: 28px;
  }
  .btn {
    height: 34px;
    padding: 0 10px;
    font-size: 12px;
  }
  .input-with-icon {
    width: 100%;
    flex: 1 0 100%;
  }
  #run-audit-btn {
    flex: none;
  }

  .kpis {
    grid-template-columns: 1fr 1fr;
  }
  .kpi {
    padding: 8px 10px;
    gap: 8px;
  }
  .kpi-gauge-wrap {
    width: 40px;
    height: 40px;
  }
  .kpi-label-block dd {
    font-size: 14px;
  }

  .split-toggle-group {
    flex-direction: column;
  }
  .split-toggle-btn {
    width: 100%;
  }

  .back-to-top {
    bottom: 12px;
    right: 12px;
    width: 38px;
    height: 38px;
  }
}

/* ================= PRINT / PDF ================= */
@media print {
  body { background: #fff !important; color: #000 !important; font-size: 11px; }
  .app-bar, .filter-toolbar, .status-strip, .section-collapse-btn, .info-eye-wrap,
  .patient-tabs, #alert-banner, .no-results, .back-to-top, .toast-container,
  .quick-samples, .config-popover-wrap, .theme-toggle { display: none !important; }
  .dashboard-container { max-width: 100%; padding: 0; margin: 0; }
  .patient-dashboard, .patient-body, .patient-tab-panel, .section-card,
  .final-summary-card { border: 1px solid #ccc !important; box-shadow: none !important; }
  .audit-table th { position: static; background: #f0f0f0 !important; color: #000 !important; }
  .patient-tab-panel { display: block !important; max-height: none; }
  .patient-body { display: block !important; }
  .final-summary-card.collapsed > * { display: revert !important; }
  tr, .final-panel { break-inside: avoid; }
  thead { display: table-header-group; }
}


/* ================= MEDVANTAGE BRAND THEME ================= */
[data-theme="dark"] {
  --accent: #ff8a4c;
  --accent-hover: #ff9d66;
  --accent-light: #ff8a4c22;
  --navy: #7fa6ea;
}

.brand { gap: 12px; }
.brand-logo-img { display: block; height: 28px; width: auto; }
.brand-divider { width: 1px; height: 22px; background: var(--border-strong); }
.brand-product {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
}
[data-theme="dark"] .brand-logo-img {
  background: #fff;
  padding: 3px 6px;
  border-radius: 6px;
  box-sizing: content-box;
}

/* Orange primary action, as on the MedVantage portal */
.search-run-btn {
  background: var(--accent);
  box-shadow: 0 4px 12px -4px rgba(242, 107, 33, 0.55);
}
.search-run-btn:hover:not(:disabled) { background: var(--accent-hover); }
.search-capsule:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

/* Hero: soft sky-to-peach wash with frosted panels */
body.no-audit {
  background:
    radial-gradient(1100px 520px at 88% -10%, rgba(242, 107, 33, 0.10), transparent 60%),
    radial-gradient(900px 600px at -5% 10%, rgba(31, 75, 153, 0.10), transparent 60%),
    linear-gradient(180deg, #eef3fb 0%, var(--ground) 55%);
  background-attachment: fixed;
}
[data-theme="dark"] body.no-audit { background: var(--ground); }

.landing-head { border-bottom-color: transparent; padding-bottom: 8px; }

.landing-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--navy);
  font-weight: 700;
  letter-spacing: 0.12em;
}
.kicker-rule {
  width: 28px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.hero-headline {
  font-family: var(--font-display);
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 8px;
}
.hl-navy { color: var(--navy); }
.hl-orange { color: var(--accent); font-weight: 500; }
.hero-tagline {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 10px;
}

.landing-steps {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 16px;
  padding: 18px 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px -12px rgba(31, 75, 153, 0.18);
}
[data-theme="dark"] .landing-steps {
  background: var(--surface);
  border-color: var(--border);
}
.step-num {
  border: none;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 700;
}

.cohorts-label { font-family: var(--font-display); color: var(--navy); }

.cohort-card {
  position: relative;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px -10px rgba(31, 75, 153, 0.20);
  overflow: hidden;
}
.cohort-card::after {
  content: "";
  position: absolute;
  left: 18px;
  top: 0;
  width: 32px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
}
.cohort-card:hover {
  border-color: rgba(242, 107, 33, 0.45);
  box-shadow: 0 10px 28px -10px rgba(31, 75, 153, 0.28);
}
[data-theme="dark"] .cohort-card {
  background: var(--surface);
  border-color: var(--border);
}
.cohort-title { font-family: var(--font-display); font-weight: 600; color: var(--navy); }
[data-theme="dark"] .cohort-title { color: var(--text); }
.cohort-action { color: var(--accent); }

@media (max-width: 768px) {
  .hero-headline { font-size: 1.9rem; }
  .brand-divider, .brand-product { display: none; }
  .brand-logo-img { height: 22px; }
}

.nav-chat-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color var(--transition), color var(--transition);
}
.nav-chat-link:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 768px) { .nav-chat-link span { display: none; } }
.nav-chat-link { white-space: nowrap; flex: none; }
/* The same message appears as a toast; on narrower screens it would run under the search bar. */
@media (max-width: 1500px) { #fetch-status { display: none; } }

/* ================= PDF REPORT (Export PDF) ================= */
/* downloadFullReport() builds #print-report on this page and prints it. */
#print-report { display: none; }

@page { size: A4 landscape; margin: 12mm; }

@media print {
  body.printing-report > *:not(#print-report) { display: none !important; }
  body.printing-report #print-report { display: block !important; }
  body.printing-report {
    background: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  #print-report .dashboard-container { max-width: none; margin: 0; padding: 0; display: block !important; }
  #print-report #audit-view,
  #print-report .patient-dashboard,
  #print-report .patient-body,
  #print-report .patient-tab-panel { display: block !important; max-height: none; overflow: visible; }
  #print-report .disclosure .chev,
  #print-report .disclosure-hint,
  #print-report .thinking-card { display: none !important; }
  #print-report .table-responsive { overflow: visible !important; }
}

.report-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 0 12px;
  margin-bottom: 16px;
  border-bottom: 2px solid #f26b21;
}
.report-head img { height: 30px; width: auto; }
.report-head-text { display: flex; flex-direction: column; font-size: 13px; color: #1e2633; }
.report-head-text strong { font-size: 15px; color: #1f4b99; }
.report-disclaimer { margin-top: 18px; font-size: 11px; color: #667085; }
@media print {
  #print-report .disclosure-badge { display: none !important; }
  #print-report .patient-support-table { width: 100%; border-collapse: collapse; }
  #print-report .patient-support-table th,
  #print-report .patient-support-table td { padding: 3px 10px 3px 0; text-align: left; white-space: nowrap; }
  #print-report .patient-support-table th { border-bottom: 1px solid #ccc; }
}
@media print {
  #print-report .split-toggle-group { display: none !important; }
}
