:root {
  --bg: #0a0c0f;
  --surface: #0f1318;
  --surface-2: #151a22;
  --border: rgba(255, 255, 255, 0.07);
  --border-bright: rgba(255, 255, 255, 0.14);
  --text: #e8edf5;
  --text-muted: #6b7a8d;
  --text-dim: #3d4a5c;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --accent-glow: rgba(59, 130, 246, 0.25);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.1);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.1);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.1);
  --highlight: rgba(251, 191, 36, 0.15);
  --highlight-border: rgba(251, 191, 36, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Sora", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* LAYOUT */
.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 28px 0;
  display: flex;
  flex-direction: column;
}

.logo {
  padding: 0 24px 28px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  font-family: "DM Serif Display", serif;
  font-size: 18px;
  color: var(--text);
  letter-spacing: -0.3px;
}

.logo-sub {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2px;
}

.nav {
  padding: 20px 0;
  flex: 1;
}

.nav-section {
  padding: 0 16px;
  margin-bottom: 6px;
}

.nav-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 8px 8px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 400;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}

.nav-item.active .nav-dot {
  background: var(--accent);
}

/* MAIN */
.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.breadcrumb-sep {
  color: var(--text-dim);
}
.breadcrumb-active {
  color: var(--text);
  font-weight: 500;
}

.model-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
}

.model-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

/* CONTENT */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

body[data-page="audit"] .content {
  padding: 20px 28px;
}

/* STEP PROGRESS */
.step-track {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 36px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
}

.step-item.active {
  color: var(--text);
}
.step-item.done {
  color: var(--accent);
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-family: "DM Mono", monospace;
}

.step-item.active .step-num {
  border-color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.step-item.done .step-num {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.step-connector {
  flex: 1;
  height: 1px;
  background: var(--border);
  margin: 0 12px;
  min-width: 40px;
}

/* SECTION HEADERS */
.section-header {
  margin-bottom: 24px;
}

body[data-page="audit"] .section-header {
  margin-bottom: 14px;
}

.section-eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.section-title {
  font-family: "DM Serif Display", serif;
  font-size: 26px;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.section-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 300;
}

/* STEP PANELS */
.step-panel {
  display: none;
}
.step-panel.visible {
  display: block;
  animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === STEP 1: SETUP === */
.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.suggestion-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.suggestion-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background 0.2s;
}

.suggestion-card:hover {
  border-color: var(--border-bright);
  background: var(--surface-2);
  transform: translateY(-1px);
}

.suggestion-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.suggestion-card.selected::before {
  background: var(--accent);
}

.card-risk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 12px;
}

.card-risk.high {
  color: var(--danger);
  background: var(--danger-soft);
}
.card-risk.medium {
  color: var(--warn);
  background: var(--warn-soft);
}

.card-cohort {
  font-family: "DM Serif Display", serif;
  font-size: 16px;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.3;
}

.card-detail {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  font-weight: 300;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  font-family: "DM Mono", monospace;
}

.card-check {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  transition: all 0.2s;
}

.suggestion-card.selected .card-check {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.divider-or {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 20px 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.divider-or::before,
.divider-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.nl-input-wrap {
  position: relative;
}

.nl-input {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  color: var(--text);
  font-family: "Sora", sans-serif;
  font-size: 14px;
  font-weight: 300;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  line-height: 1.6;
}

.nl-input::placeholder {
  color: var(--text-dim);
}
.nl-input:focus {
  border-color: var(--border-bright);
}

.nl-input-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hint-spark {
  font-size: 12px;
}

/* mirror-grid removed — replaced by inspector-layout */

.mirror-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11px;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-swatch.perturbed {
  background: var(--highlight);
  border: 1px solid var(--highlight-border);
}

.legend-swatch.unchanged {
  background: var(--surface-2);
  border: 1px solid var(--border);
}

/* === STEP 3: EXECUTION === */
.run-stage {
  text-align: center;
  padding: 40px 0;
}

.run-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 16px 36px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  font-family: "Sora", sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.2px;
}

.run-btn:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
}

.run-btn.running {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: default;
  transform: none;
  box-shadow: none;
}

.progress-log {
  margin-top: 32px;
  text-align: left;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.progress-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  font-size: 13px;
  opacity: 0;
  transform: translateY(4px);
  transition: all 0.4s ease;
}

.progress-step.show {
  opacity: 1;
  transform: translateY(0);
}

.progress-step.done {
  color: var(--text-muted);
}
.progress-step.active {
  color: var(--text);
}

.progress-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
  margin-top: 1px;
}

.progress-icon.done-icon {
  background: var(--success-soft);
  color: var(--success);
}
.progress-icon.spin-icon {
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.progress-sub {
  font-size: 11px;
  font-family: "DM Mono", monospace;
  color: var(--text-dim);
  margin-top: 2px;
}

/* === STEP 4: RESULTS === */
.verdict-banner {
  border-radius: 12px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  border: 1.5px solid;
}

.verdict-banner.fail {
  background: var(--danger-soft);
  border-color: rgba(239, 68, 68, 0.3);
}

.verdict-banner.pass {
  background: var(--success-soft);
  border-color: rgba(34, 197, 94, 0.3);
}

.verdict-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.verdict-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.verdict-banner.fail .verdict-icon {
  background: var(--danger-soft);
}
.verdict-banner.pass .verdict-icon {
  background: var(--success-soft);
}

.verdict-label {
  font-family: "DM Serif Display", serif;
  font-size: 18px;
}

.verdict-banner.fail .verdict-label {
  color: #fca5a5;
}
.verdict-banner.pass .verdict-label {
  color: #86efac;
}

.verdict-desc {
  font-size: 12px;
  margin-top: 2px;
  color: var(--text-muted);
}

.verdict-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 20px;
}

.verdict-banner.fail .verdict-badge {
  background: var(--danger-soft);
  color: var(--danger);
}
.verdict-banner.pass .verdict-badge {
  background: var(--success-soft);
  color: var(--success);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}

.metric-card.critical {
  border-color: rgba(239, 68, 68, 0.2);
}

.metric-num {
  font-family: "DM Serif Display", serif;
  font-size: 32px;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}

.metric-card.critical .metric-num {
  color: #fca5a5;
}

.metric-label {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  font-weight: 300;
}

.metric-shift {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  margin-top: 8px;
  padding: 2px 7px;
  border-radius: 4px;
}

.metric-shift.up {
  color: var(--danger);
  background: var(--danger-soft);
}
.metric-shift.neutral {
  color: var(--text-dim);
  background: var(--surface-2);
}

.path-forward {
  background: var(--surface);
  border: 1.5px solid rgba(59, 130, 246, 0.25);
  border-radius: 12px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.path-forward-text {
  flex: 1;
}

.path-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.path-title {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 4px;
}

.path-desc {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 300;
  line-height: 1.5;
}

.path-action {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--accent-soft);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  font-family: "Sora", sans-serif;
}

.path-action:hover {
  background: rgba(59, 130, 246, 0.18);
}

/* ACTIONS BAR */
.actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: "Sora", sans-serif;
  border: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
}

/* ============================================
   STEP 2 — VALIDATION LAYER
============================================ */

/* --- Section 1: Clinical Footprint --- */
.footprint-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px 18px;
  margin-bottom: 18px;
  position: relative;
  overflow: visible;
}

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

.fp-title-block {
}
.fp-eyebrow {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.fp-title {
  font-family: "DM Serif Display", serif;
  font-size: 17px;
  color: var(--text);
  letter-spacing: -0.3px;
}

.fp-legend {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
  margin-top: 2px;
}

.fp-leg-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-muted);
  position: relative;
}

.fp-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.fp-swatch.training {
  background: rgba(140, 150, 170, 0.45);
  border: 1px solid rgba(140, 150, 170, 0.4);
}
.fp-swatch.stress {
  background: rgba(59, 130, 246, 0.45);
  border: 1px solid rgba(59, 130, 246, 0.5);
}

.fp-canvas-wrap {
  position: relative;
  width: 100%;
  height: 160px;
  margin-bottom: 14px;
}

#footprintCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Dimension tabs */
.fp-dim-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.fp-dim-btn {
  padding: 4px 11px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  font-family: "Sora", sans-serif;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s;
}

.fp-dim-btn:hover {
  border-color: var(--border-bright);
  color: var(--text);
}
.fp-dim-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Insight callout */
.fp-insight {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  background: rgba(59, 130, 246, 0.07);
  border: 1px solid rgba(59, 130, 246, 0.18);
  border-radius: 8px;
  padding: 10px 13px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.fp-insight-icon {
  color: var(--accent);
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 1px;
}

.fp-insight strong {
  color: var(--text);
  font-weight: 600;
}

/* --- Section 2: Patient Delta --- */
.delta-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 18px;
}

.delta-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.delta-panel-title {
  font-family: "DM Serif Display", serif;
  font-size: 16px;
  color: var(--text);
  letter-spacing: -0.2px;
}

.delta-panel-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 300;
  margin-top: 1px;
}

.delta-count-badge {
  font-size: 11px;
  font-family: "DM Mono", monospace;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px 10px;
}

/* Stress case rows */
.stress-row {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}

.stress-row:last-child {
  border-bottom: none;
}
.stress-row:hover .stress-row-head {
  background: var(--surface-2);
}
.stress-row.open .stress-row-head {
  background: var(--surface-2);
}

.stress-row-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  transition: background 0.12s;
  position: relative;
  z-index: 1;
}

.stress-num {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--text-dim);
  width: 28px;
  flex-shrink: 0;
}

.stress-info {
  flex: 1;
}

.stress-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}

.stress-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.stress-chip {
  font-size: 10px;
  font-weight: 600;
  font-family: "DM Mono", monospace;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 4px;
  padding: 1px 7px;
  letter-spacing: 0.2px;
}

.stress-chevron {
  color: var(--text-dim);
  font-size: 11px;
  transition: transform 0.2s;
  flex-shrink: 0;
}

.stress-row.open .stress-chevron {
  transform: rotate(90deg);
}

/* Expanded delta card */
.stress-delta-card {
  display: none;
  padding: 0 20px 16px 20px;
  animation: fadeUp 0.18s ease;
  position: relative;
  z-index: 0;
}

.stress-row.open .stress-delta-card {
  display: block;
}

.delta-card-inner {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

/* Source patient context bar */
.delta-source-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(59, 130, 246, 0.04);
}

.delta-source-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent);
}

.delta-source-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}

.delta-source-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: "DM Mono", monospace;
}

/* Pair layout for source vs synthetic */
.delta-pair {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  align-items: flex-start;
}

.delta-left,
.delta-right {
  flex: 1;
  min-width: 0;
}

.delta-synth-bar {
  padding: 10px 12px;
  border-radius: 8px;
  background: linear-gradient(
    180deg,
    rgba(59, 130, 246, 0.06),
    rgba(59, 130, 246, 0.03)
  );
  border: 1px solid rgba(59, 130, 246, 0.08);
}

.delta-synth-label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(59, 130, 246, 0.9);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.delta-synth-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-top: 4px;
}

.delta-synth-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-family: "DM Mono", monospace;
  margin-top: 4px;
}

/* synth-values removed; details shown in diff below */

/* Delta rows — the key comparison */
.delta-rows {
  padding: 12px 16px;
}

/* header row for column titles */
.delta-row-header {
  display: flex;
  padding: 0 16px;
  gap: 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.delta-row-header .header-left {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
}
.delta-row-header .header-right {
  flex: 1;
  text-align: right;
}

.delta-row-item {
  display: flex;
  padding: 0 16px;
  gap: 12px;
  align-items: center;
  margin-bottom: 6px;
}
.delta-row-item .row-left {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  z-index: 1;
}
.delta-row-item .row-right {
  display: flex;
  flex: 1;
  justify-content: flex-end;
  gap: 8px;
  z-index: 1;
}

.delta-row-item:last-child {
  margin-bottom: 0;
}

.delta-row-item.changed {
  position: relative;
}

/* highlight only the right-half (synthetic) section */
.delta-row-item.changed::after {
  content: "";
  position: absolute;
  top: -2px;
  bottom: -2px;
  /* right-half highlight begins at flex boundary (50% + half gap) */
  left: calc(50% + 6px);
  right: 0;
  background: var(--success-soft);
  border-radius: 4px;
  z-index: 0;
}

.delta-row-item.changed .delta-from {
  text-decoration: line-through;
  color: var(--text-muted);
}

.delta-field-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  width: 100px;
  flex-shrink: 0;
}

.delta-from {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--text);
  min-width: 80px;
  text-align: right;
}

.delta-arrow {
  font-size: 11px;
  color: var(--text-dim);
  width: 32px;
  text-align: center;
  flex-shrink: 0;
}

.delta-to {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  min-width: 80px;
  text-align: right;
}

.delta-row-item.changed .delta-to {
  font-weight: 600;
  color: var(--success);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

/* Dataset Info Dropdown */
.ds-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s;
  flex-shrink: 0;
}
.ds-info-btn:hover {
  color: var(--text-muted);
}
.ds-info-btn:active {
  color: var(--accent);
}
.ds-info-btn svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ds-dropdown {
  display: none;
  position: fixed;
  transform: translateY(-6px);
  width: 240px;
  background: var(--surface-2);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  padding: 10px;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  white-space: nowrap;
  will-change: transform, top, left;
}
.ds-dropdown.visible {
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
  animation: slideDown 0.2s ease-out;
}
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ds-header {
  padding: 0 10px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.ds-item {
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================
   SHARED UTILITIES
============================================ */

.mono {
  font-family: "DM Mono", monospace;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  font-family: "Sora", sans-serif;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.ghost-btn:hover {
  border-color: var(--border-bright);
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.docked-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--accent-soft);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 4px;
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
}

.model-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  background: var(--accent-soft);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--accent);
  font-family: "DM Mono", monospace;
  flex-shrink: 0;
}

/* CTA bar — used on ingestion + assessment pages */
.cta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.cta-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  font-family: "Sora", sans-serif;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.cta-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.cta-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 13px;
  font-weight: 600;
  font-family: "Sora", sans-serif;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.cta-primary:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

/* ============================================
   INVENTORY (Home page)
============================================ */

.inventory-layout {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 28px;
  align-items: start;
}

.inventory-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.inventory-col-eyebrow {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Dataset cards */
.dataset-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}

.dataset-card:hover {
  border-color: var(--border-bright);
}

.dataset-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.dataset-name {
  font-family: "DM Serif Display", serif;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.2px;
}

.dataset-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: "DM Mono", monospace;
  margin-bottom: 14px;
}

.dataset-status {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.status--linked {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.status--available {
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.dataset-quality {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 8px;
}

.quality-gauge {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.quality-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.quality-pct {
  font-family: "DM Mono", monospace;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
}

.quality-sub {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 2px;
}

.cohort-bar-wrap {
  flex: 1;
  min-width: 0;
}

.cohort-bar-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.cohort-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  gap: 1px;
  margin-bottom: 4px;
}

.cohort-seg {
  height: 100%;
  border-radius: 2px;
  flex-shrink: 0;
}

.cohort-bar-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--text-dim);
  font-family: "DM Mono", monospace;
}

.dataset-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

/* Model cards */
.model-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}

.model-card:hover {
  border-color: var(--border-bright);
}

.model-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.model-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.model-docked {
  margin-bottom: 12px;
}

.model-stats {
  display: flex;
  gap: 16px;
}

.model-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.model-stat-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.model-stat-val {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.model-stat-val.mono {
  font-family: "DM Mono", monospace;
  font-weight: 400;
  font-size: 11px;
  color: var(--text-muted);
}

/* ============================================
   MODEL BANNER (simulation topbars)
============================================ */

.model-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 32px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}

.model-banner.banner-warn {
  background: rgba(245, 158, 11, 0.06);
  color: var(--warn);
}

.model-banner.banner-success {
  background: rgba(34, 197, 94, 0.06);
  color: var(--success);
}

.banner-grade {
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}

.grade-d {
  background: var(--warn-soft);
  color: var(--warn);
}

.grade-a {
  background: var(--success-soft);
  color: var(--success);
}

/* Model-specific visibility toggles */
body[data-model="v24"] .v30-only {
  display: none !important;
}
body[data-model="v30"] .v24-only {
  display: none !important;
}
body:not([data-model="v24"]) .v24-only {
  display: none !important;
}

/* Breadcrumb link style */
.breadcrumb-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.breadcrumb-link:hover {
  color: var(--text);
}

/* ============================================
   CLINICAL LIBRARY (Home page)
============================================ */

.library-models-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 16px;
}

.library-model-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
  position: relative;
}

.library-model-card:hover {
  border-color: var(--border-bright);
}

.library-model-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.lmc-top {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 16px;
}

.lmc-title-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 2px;
}

.lmc-name {
  font-family: "DM Serif Display", serif;
  font-size: 18px;
  color: var(--text);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.lmc-version {
  color: var(--text-muted);
}

/* Grade ring */
.grade-ring-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.grade-ring {
  display: block;
}

.grade-ring-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "DM Serif Display", serif;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.grade-ring-label.warn {
  color: var(--warn);
}
.grade-ring-label.success {
  color: var(--success);
}

/* Model state chip */
.model-state-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.chip-failing {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(245, 11, 11, 0.2);
}

.chip-validated {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.chip-conditional {
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Model synthesis */
.model-synthesis {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
  font-weight: 300;
  margin-bottom: 16px;
}

/* Pillar scores */
.pillar-scores {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 8px;
}

.pillar-score {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}

.ps-icon {
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.ps-icon.pass {
  color: var(--success);
}
.ps-icon.fail {
  color: var(--danger);
}
.ps-icon.warn {
  color: var(--warn);
}

/* Enter workspace button */
.lmc-enter-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: "Sora", sans-serif;
  cursor: pointer;
  transition: all 0.15s;
}

.lmc-enter-btn:hover {
  background: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

/* Checkbox */
.lmc-checkbox-wrap {
  cursor: pointer;
  flex-shrink: 0;
}

.lmc-checkbox {
  display: none;
}

.lmc-check-box {
  display: flex;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--border-bright);
  background: var(--surface-2);
  transition: all 0.15s;
  position: relative;
}

.lmc-checkbox:checked + .lmc-check-box {
  background: var(--accent);
  border-color: var(--accent);
}

.lmc-checkbox:checked + .lmc-check-box::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 11px;
  font-weight: 700;
}

/* Compare CTA bar */
.compare-cta-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: 12px;
  margin-bottom: 8px;
  animation: fadeUp 0.25s ease;
}

.compare-cta-bar.visible {
  display: flex;
}

.compare-cta-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Upload buttons in section headers */
body[data-page="home"] .section-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 0 16px;
}

body[data-page="home"] .section-header .lib-upload-btn {
  grid-column: 2;
  grid-row: 1 / 4;
  align-self: center;
}

.lib-upload-btn {
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border-bright);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  font-family: "Sora", sans-serif;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
  white-space: nowrap;
}

.lib-upload-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* Simplified dataset grid */
.lib-datasets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 32px;
}

.lib-dataset-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  transition: border-color 0.15s;
}

.lib-dataset-card:hover {
  border-color: var(--border-bright);
}

.lib-dataset-card .dataset-meta {
  margin-bottom: 12px;
}
