/*
 * MediMind AI — SaaS Navigation & Light Theme
 * Clean light theme. Replaces the old dark theme override.
 * Loaded LAST among CSS files.
 */

/* ── SaaS Navbar ───────────────────────────────────── */
.saas-navbar {
  position: sticky;
  top: 0;
  z-index: 80;
  min-height: var(--topbar-h);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-6);
  padding: 0 var(--sp-8);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.saas-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  white-space: nowrap;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--accent);
  color: #FFFFFF;
  font-size: var(--text-sm);
  font-weight: 700;
}

.saas-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  min-width: 0;
}

.nav-link {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--sp-3);
  border-radius: var(--radius);
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: color var(--duration-fast) var(--ease),
              background var(--duration-fast) var(--ease);
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--accent-muted);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-muted);
  font-weight: 600;
}

.nav-link-separator {
  position: relative;
  margin-left: var(--sp-2);
}
.nav-link-separator::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--sp-2));
  top: 20%;
  height: 60%;
  width: 1px;
  background: var(--border);
}

/* ── Nav Dropdown ───────────────────────────────────── */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-trigger {
  border: none !important;
  background: none !important;
  margin: 0;
  padding: 0 var(--sp-3);
  font-family: var(--font-sans);
  cursor: pointer;
  gap: var(--sp-1);
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}

.nav-dropdown-trigger svg {
  transition: transform var(--duration-fast) var(--ease);
  flex-shrink: 0;
}

.nav-dropdown.open .nav-dropdown-trigger {
  color: var(--text-primary);
  background: var(--accent-muted) !important;
}

.nav-dropdown.open .nav-dropdown-trigger svg {
  transform: rotate(180deg);
}

.nav-dropdown-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 200px;
  display: none;
  padding: var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-dropdown);
  z-index: 90;
}

.nav-dropdown-panel.open {
  display: block !important;
}

.dropdown-item {
  display: block;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background var(--duration-fast) var(--ease),
              color var(--duration-fast) var(--ease);
}

.dropdown-item:hover {
  background: var(--accent-muted);
  color: var(--accent);
}

.dropdown-item.active {
  color: var(--accent);
  background: var(--accent-muted);
  font-weight: 600;
}

.nav-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
}

.nav-menu-button {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
}

.nav-menu-button span {
  display: block;
  width: 16px;
  height: 2px;
  margin: 3px auto;
  border-radius: var(--radius-pill);
  background: currentColor;
}

/* ── User Menu ─────────────────────────────────────── */
/* ── Icon Buttons (notification, etc.) ──────────────── */
.nav-icon-button {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-tertiary);
  transition: border-color var(--duration-fast) var(--ease),
              color var(--duration-fast) var(--ease);
}

.nav-icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.avatar,
.user-menu-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
}

.avatar:hover,
.user-menu-button:hover {
  border-color: var(--accent);
}

.user-menu {
  position: relative;
}

.user-menu-button {
  font-weight: 700;
  cursor: pointer;
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  display: none;
  padding: var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-dropdown);
}

.user-menu-panel.open {
  display: block;
}

.user-menu-meta {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-1);
}

.user-menu-meta strong {
  display: block;
  color: var(--text-primary);
  font-size: var(--text-sm);
}

.user-menu-meta span {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}

.user-menu-panel a {
  display: block;
  padding: var(--sp-3);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
}

.user-menu-panel a:hover {
  background: var(--accent-muted);
  color: var(--accent);
}

/* ── Page Header (saas override) ───────────────────── */
.page-header {
  padding: var(--sp-8);
  margin-bottom: var(--sp-8);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.page-eyebrow {
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-title {
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: clamp(32px, 4vw, 48px);
  line-height: var(--leading-tight);
  letter-spacing: -0.03em;
}

.page-subtitle {
  color: var(--text-tertiary);
  font-size: var(--text-base);
  line-height: var(--leading-loose);
}

/* ── Cards (saas override) ─────────────────────────── */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: var(--sp-6);
  box-shadow: var(--shadow-card);
}

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

.stat-card {
  min-height: 160px;
  border-left: 0;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  transition: border-color var(--duration-fast) var(--ease),
              box-shadow var(--duration-fast) var(--ease);
}

.stat-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(26, 92, 122, 0.08);
}

.stat-icon {
  position: static;
  width: 36px;
  height: 36px;
  margin-bottom: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--accent-muted);
  color: var(--accent);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card:hover .stat-icon {
  transform: none;
  border-color: var(--accent);
}

.stat-label {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-value {
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: var(--text-2xl);
  line-height: 1;
  letter-spacing: -0.02em;
  font-weight: 400;
}

.stat-value--text {
  font-size: var(--text-lg);
  letter-spacing: 0;
  text-transform: capitalize;
}

.stat-note,
.metric-tile small,
.chart-kicker {
  color: var(--text-tertiary);
  font-size: var(--text-sm);
}

.stat-note a {
  color: var(--accent);
  font-weight: 600;
  transition: color var(--duration-fast) var(--ease);
}

.stat-note a:hover {
  color: var(--accent-dark);
}

/* ── Metric Tiles ──────────────────────────────────── */
.metric-tile {
  padding: var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: border-color var(--duration-fast) var(--ease);
}

.metric-tile:hover {
  transform: none;
  border-color: var(--accent);
}

.metric-tile span {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-tile strong {
  display: block;
  margin-top: var(--sp-2);
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  line-height: 1;
  letter-spacing: -0.01em;
}

.metric-tile small {
  display: block;
  margin-top: var(--sp-1);
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}

/* ── Buttons (saas override) ───────────────────────── */
.btn {
  min-height: 40px;
  border-radius: var(--radius);
  font-weight: 600;
  transition: background var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease),
              color var(--duration-fast) var(--ease);
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-secondary {
  border-color: var(--border);
  background: transparent;
  color: var(--text-primary);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-muted);
}

/* ── Forms (saas override) ─────────────────────────── */
input[type="text"],
input:not([type]),
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea,
.input {
  min-height: 42px;
  border-color: var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-primary);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

/* ── Badges (saas override) ────────────────────────── */
.badge {
  min-height: 24px;
  border-radius: var(--radius-pill);
}

.badge-success { color: var(--success); background: var(--accent-light); }
.badge-warning { color: var(--warning); background: var(--warning-soft); }
.badge-danger  { color: var(--error);   background: var(--error-soft); }
.badge-info    { color: var(--info);    background: var(--info-soft); }

/* ── Tables (saas override) ────────────────────────── */
.data-table th {
  padding: var(--sp-3) var(--sp-4);
  color: var(--text-tertiary);
  border-bottom-color: var(--border);
  background: var(--surface-alt);
}

.data-table td {
  padding: var(--sp-4);
  color: var(--text-secondary);
  border-bottom-color: var(--border-light);
}

.data-table tr:hover td {
  background: var(--surface-alt);
}

/* ── Risk Bars (saas override) ─────────────────────── */
.risk-bar {
  min-height: 56px;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
}

.risk-bar:hover {
  border-color: var(--border);
  background: var(--surface-alt);
}

.bar-track {
  height: 8px;
  background: var(--border);
}

/* ── Charts (saas override) ────────────────────────── */
.chart-wrap {
  min-height: 300px;
}

.chart-wrap.small {
  min-height: 220px;
}

.chart-panel-header {
  margin-bottom: var(--sp-5);
}

.chart-panel-header h3 {
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: var(--text-xl);
}

.chart-wrap canvas {
  filter: none;
}

/* ── Empty State (saas override) ───────────────────── */
.empty-state {
  color: var(--text-tertiary);
}

.empty-state strong,
.timeline-content h4,
.form-section h3,
.form-group label,
.field-label,
.score-details h3,
.auth-form h2 {
  color: var(--text-primary);
}

.timeline-content p,
.timeline-date,
.unit,
.hint {
  color: var(--text-tertiary);
}

.timeline-dot {
  box-shadow: none;
}

/* ── Upload Zone (saas override) ───────────────────── */
.upload-zone {
  background: var(--surface);
  border-style: dashed;
  color: var(--text-tertiary);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-muted);
  transform: none;
}

/* ── Image Diagnosis ───────────────────────────────── */
.image-diagnosis-grid {
  align-items: start;
}

.image-result-card {
  overflow: hidden;
}

.image-preview-wrap[hidden],
.empty-state[hidden],
.cnn-result[hidden] {
  display: none !important;
}

.image-diagnosis-form {
  display: grid;
  gap: var(--sp-5);
}

.image-drop-zone {
  min-height: 240px;
  display: grid;
  place-items: center;
  gap: var(--sp-3);
  padding: var(--sp-7);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text-tertiary);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease),
              background var(--duration-fast) var(--ease);
}

.image-drop-zone:hover,
.image-drop-zone.dragover,
.image-drop-zone:focus-within {
  border-color: var(--accent);
  background: var(--accent-muted);
}

.image-drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.image-drop-zone strong {
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: var(--text-lg);
}

.image-drop-zone small {
  max-width: 100%;
  overflow: hidden;
  color: var(--text-tertiary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-drop-icon {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--accent-muted);
  color: var(--accent);
  font-weight: 700;
}

.image-preview-wrap {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-alt);
}

.image-preview-wrap img {
  width: 100%;
  max-height: 360px;
  display: block;
  object-fit: contain;
}

/* ── CNN Result ────────────────────────────────────── */
.cnn-result {
  display: grid;
  gap: var(--sp-5);
}

.clinical-result {
  padding-top: var(--sp-1);
}

.assessment-topline {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.assessment-icon {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--accent-muted);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 700;
}

.assessment-icon.assessment-normal {
  color: var(--success);
  background: var(--accent-light);
  border-color: var(--accent-light);
}

.assessment-icon.assessment-moderate,
.assessment-icon.assessment-low {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: var(--warning-soft);
}

.assessment-icon.assessment-high {
  color: var(--error);
  background: var(--error-soft);
  border-color: var(--error-soft);
}

.assessment-label {
  margin-bottom: var(--sp-1);
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.assessment-topline h3 {
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: clamp(24px, 4vw, 36px);
  line-height: var(--leading-tight);
  letter-spacing: -0.03em;
}

.assessment-badge {
  align-self: start;
  white-space: nowrap;
}

.assessment-badge.assessment-normal {
  color: var(--success);
  background: var(--accent-light);
}

.assessment-badge.assessment-moderate,
.assessment-badge.assessment-low {
  color: var(--warning);
  background: var(--warning-soft);
}

.assessment-badge.assessment-high {
  color: var(--error);
  background: var(--error-soft);
}

.assessment-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
}

.assessment-metric {
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.assessment-metric span,
.assessment-metadata span {
  display: block;
  margin-bottom: var(--sp-1);
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.assessment-metric strong {
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  line-height: 1.15;
}

.assessment-section {
  display: grid;
  gap: var(--sp-3);
  padding: var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.assessment-section h4 {
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: var(--text-base);
}

.assessment-section p,
.recommendation-list {
  color: var(--text-secondary);
  font-size: var(--text-base);
  line-height: var(--leading-loose);
}

.recommendation-list {
  display: grid;
  gap: var(--sp-2);
  margin: 0;
  padding-left: var(--sp-5);
}

/* ── Probability Bars ──────────────────────────────── */
.probability-list {
  display: grid;
  gap: var(--sp-4);
}

.probability-row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) 60px;
  align-items: center;
  gap: var(--sp-3);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
}

.probability-row .bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--border);
}

.probability-row .bar-track div {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 300ms var(--ease);
}

.probability-row.probability-normal .bar-track div {
  background: var(--success);
}

.probability-row.probability-moderate .bar-track div,
.probability-row.probability-low .bar-track div {
  background: var(--warning);
}

.probability-row.probability-high .bar-track div {
  background: var(--error);
}

.probability-row strong {
  color: var(--text-primary);
  text-align: right;
}

/* ── Grad-CAM Visualization ────────────────────────── */
.gradcam-section {
  padding: var(--sp-4) 0;
  border-top: 1px solid var(--border);
}

.gradcam-section[hidden] {
  display: none !important;
}

.gradcam-section h4 {
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: 700;
  margin-bottom: var(--sp-1);
}

.gradcam-subtitle {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--sp-4);
}

.gradcam-toggle-bar {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}

.gradcam-toggle-bar .btn {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 200ms, color 200ms, border-color 200ms;
}

.gradcam-toggle-bar .btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.gradcam-toggle-bar .btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.gradcam-viewport {
  position: relative;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  text-align: center;
}

.gradcam-viewport img {
  display: block;
  max-width: 100%;
  max-height: 420px;
  margin: 0 auto;
  object-fit: contain;
}

.gradcam-viewport figcaption {
  padding: var(--sp-3) var(--sp-4);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-style: italic;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.gradcam-explanation {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  border-left: 3px solid var(--accent);
  background: var(--info-soft);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-loose);
}

.gradcam-disclaimer {
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
}

/* ── Assessment Metadata ───────────────────────────── */
.assessment-metadata {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}

.assessment-metadata div {
  min-width: 0;
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.assessment-metadata strong {
  display: block;
  overflow: hidden;
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clinical-disclaimer {
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--info-soft);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-loose);
}

/* ── Metadata Panel ────────────────────────────────── */
.metadata-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.metadata-panel summary {
  padding: var(--sp-4);
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
}

.metadata-panel pre {
  max-height: 240px;
  overflow: auto;
  margin: 0;
  padding: 0 var(--sp-4) var(--sp-4);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.6;
}

/* ── Loading (saas override) ───────────────────────── */
.loading-overlay {
  background: rgba(244, 243, 239, 0.85);
  backdrop-filter: none;
}

.spinner {
  border-color: var(--border);
  border-top-color: var(--accent);
}

.toast-region {
  top: calc(var(--topbar-h) + var(--sp-5));
}

.toast {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.disclaimer {
  border-color: var(--border);
  background: var(--warning-soft);
  color: var(--text-secondary);
}

.hero-result {
  background: var(--surface) !important;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.hero-result::before {
  display: none;
}

.hero-number {
  color: var(--text-primary);
  font-family: var(--font-serif);
}

.mini-ring {
  background: conic-gradient(var(--accent) calc(var(--risk, 0) * 1%), var(--border) 0);
}

.mini-ring span {
  background: var(--surface);
  color: var(--text-primary);
}

/* ── Auth (saas override) ──────────────────────────── */
.auth-body {
  background: var(--canvas);
  color: var(--text-secondary);
}

.auth-brand {
  background: var(--accent);
  border-right: 1px solid var(--accent-dark);
  color: #FFFFFF;
}

.auth-brand::before,
.auth-brand::after {
  display: none;
}

.auth-copy h1 {
  color: #FFFFFF;
}

.auth-copy p {
  color: rgba(255, 255, 255, 0.7);
}

.feature-item {
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
}

.feature-icon {
  background: rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
}

.auth-panel {
  background: var(--canvas);
}

.auth-form {
  padding: var(--sp-8);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.auth-form .subtitle,
.auth-divider,
.auth-form p {
  color: var(--text-tertiary);
}

.radio-pill span {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text-secondary);
}

.radio-pill input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

.reveal-ready,
.reveal-in {
  opacity: 1 !important;
  transform: none !important;
  animation: none !important;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 1180px) {
  .saas-navbar {
    grid-template-columns: auto auto auto;
  }

  .nav-menu-button {
    display: inline-block;
  }

  .saas-nav {
    position: absolute;
    top: var(--topbar-h);
    left: var(--sp-4);
    right: var(--sp-4);
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-1);
    padding: var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-dropdown);
    z-index: 80;
    max-height: calc(100vh - var(--topbar-h) - var(--sp-8));
    overflow-y: auto;
  }

  .saas-nav.open {
    display: flex;
  }

  .nav-link {
    justify-content: flex-start;
  }

  .nav-dropdown {
    width: 100%;
  }

  .nav-dropdown-panel {
    position: static;
    transform: none;
    display: none;
    min-width: 0;
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0 0 0 var(--sp-4);
  }

  .nav-dropdown-panel.open {
    display: block;
  }

  .nav-dropdown.open .nav-dropdown-trigger svg {
    transform: rotate(180deg);
  }

  .content {
    padding: var(--sp-7) var(--sp-5) var(--sp-12);
  }
}

@media (max-width: 760px) {
  .saas-navbar {
    min-height: 56px;
    padding: 0 var(--sp-4);
    gap: var(--sp-3);
  }

  .saas-brand span:last-child {
    display: none;
  }

  .content {
    padding: var(--sp-5) var(--sp-4) var(--sp-10);
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
    padding: var(--sp-6);
  }

  .page-title {
    font-size: 32px;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .analytics-grid,
  .metric-strip,
  .model-card-grid {
    grid-template-columns: 1fr !important;
  }

  .assessment-topline,
  .assessment-metrics,
  .assessment-metadata {
    grid-template-columns: 1fr;
  }

  .assessment-badge {
    justify-self: start;
  }

  .probability-row {
    grid-template-columns: 80px minmax(0, 1fr) 52px;
    gap: var(--sp-2);
  }
}

/* ── Cross-page UI audit fixes ─────────────────────── */
.grid-2,
.grid-3,
.grid-4 {
  display: grid;
  gap: var(--sp-5);
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.grid > *,
.grid-2 > *,
.grid-3 > *,
.grid-4 > *,
.analytics-grid > *,
.form-grid > * {
  min-width: 0;
}

.model-card-grid > .model-card:last-child:nth-child(5) {
  grid-column: span 2;
}

.page-header-row,
.card-header-row,
.card-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.page-actions,
.inline-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-3);
}

.card-header {
  margin-bottom: var(--sp-4);
}

.card-header .card-title,
.card-header-row .card-title {
  margin-bottom: 0;
}

.card-body {
  min-width: 0;
  overflow-x: auto;
}

.card-body > :first-child { margin-top: 0; }
.card-body > :last-child { margin-bottom: 0; }

.card > p + p,
.card-body > p + p {
  margin-top: var(--sp-2);
}

.card > h4:not(:first-child) {
  margin-top: var(--sp-5);
  margin-bottom: var(--sp-2);
}

.card > .btn:last-child {
  margin-top: var(--sp-5);
}

.text-muted { color: var(--text-tertiary) !important; }
.text-danger { color: var(--error) !important; }
.text-success { color: var(--success) !important; }

.btn-sm {
  min-height: 34px;
  padding-inline: var(--sp-3);
  font-size: var(--text-xs);
}

.btn[aria-busy="true"] {
  cursor: wait;
  opacity: 0.72;
}

.btn[aria-busy="true"]::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.form-control,
.form-label {
  width: 100%;
}

.form-label {
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 600;
}

.metric-strip-item {
  min-width: 0;
  padding: var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.metric-strip-label {
  display: block;
  margin-bottom: var(--sp-2);
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.metric-strip-value {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text-primary);
  font-family: var(--font-serif);
  font-size: var(--text-xl);
  line-height: var(--leading-tight);
}

.finding-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.finding-item {
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-light);
  overflow-wrap: anywhere;
}

.finding-item:last-child { border-bottom: 0; }
.finding-critical { border-left: 3px solid var(--error); padding-left: var(--sp-3); }
.finding-warning { border-left: 3px solid var(--warning); padding-left: var(--sp-3); }
.finding-info { border-left: 3px solid var(--info); padding-left: var(--sp-3); }

.badge-muted,
.badge-unknown,
.badge-discontinued,
.badge-deferred,
.badge-missing_information {
  color: var(--text-secondary);
  background: var(--surface-alt);
}

.data-table {
  table-layout: auto;
}

.data-table th {
  white-space: nowrap;
}

.data-table td {
  max-width: 360px;
  overflow-wrap: anywhere;
}

.data-table .btn {
  min-height: 34px;
  padding-inline: var(--sp-3);
}

.code-block {
  width: 100%;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.upload-zone {
  position: relative;
  padding: var(--sp-6);
}

.upload-zone:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

.file-input-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.embedded-dashboard {
  width: 100%;
  height: min(600px, 70vh);
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-alt);
}

.clinical-disclaimer h4 {
  margin-bottom: var(--sp-2);
}

.clinical-disclaimer p {
  margin: 0;
}

.loading-overlay {
  padding: var(--sp-5);
}

.loading-overlay.active {
  overflow-y: auto;
}

body.is-loading,
body.modal-open {
  overflow: hidden;
}

.toast-region {
  width: min(400px, calc(100vw - 32px));
}

.toast {
  width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  place-items: center;
  overflow-y: auto;
  padding: var(--sp-5);
  background: rgba(26, 29, 35, 0.58);
}

.modal-overlay.active { display: grid; }

.modal-card {
  width: min(560px, 100%);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--sp-7);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-modal);
}

.modal-card h3 { margin-bottom: var(--sp-5); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}

.profile-summary {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  min-width: 0;
}

.span-all { grid-column: 1 / -1; }

.auth-body,
.auth-brand,
.auth-panel,
.auth-form,
.auth-copy,
.feature-item {
  min-width: 0;
}

.auth-copy h1,
.auth-copy p,
.feature-item {
  overflow-wrap: anywhere;
}

.profile-summary > div {
  min-width: 0;
}

.profile-summary p {
  overflow-wrap: anywhere;
}

.risk-factor-row {
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border-light);
}

.risk-factor-row:last-child { border-bottom: 0; }
.risk-factor-row .badge { margin-left: var(--sp-2); }

.result-copy {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  color: inherit;
}

.status-normal { color: var(--success); font-weight: 600; }
.status-abnormal { color: var(--warning); font-weight: 600; }
.status-critical { color: var(--error); font-weight: 600; }
.status-unknown { color: var(--text-tertiary); }

@media (max-width: 1080px) {
  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .model-card-grid > .model-card:last-child:nth-child(5) {
    grid-column: auto;
  }

  .page-header {
    gap: var(--sp-5);
    margin-bottom: var(--sp-5);
  }

  .page-header-row,
  .card-header-row,
  .card-header,
  .chart-panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-actions,
  .page-header > .btn,
  .page-header > .form-actions {
    width: 100%;
  }

  .page-actions .btn,
  .page-header > .btn {
    width: 100%;
  }

  .card {
    padding: var(--sp-5);
  }

  .form-actions,
  .form-actions--center,
  .sim-actions,
  .modal-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .form-actions .btn,
  .form-actions--center .btn,
  .sim-actions .btn,
  .modal-actions .btn {
    width: 100%;
  }

  .hero-metrics {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--sp-5);
  }

  .sticky-actions {
    position: static;
    display: grid;
    grid-template-columns: 1fr;
  }

  .sticky-actions .btn { width: 100%; }

  .risk-bar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .risk-bar .bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .risk-bar .badge {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .probability-row {
    grid-template-columns: minmax(72px, auto) minmax(90px, 1fr) auto;
  }

  .profile-summary {
    align-items: flex-start;
  }

  .auth-panel {
    min-height: auto;
    padding: var(--sp-5);
  }

  .auth-body,
  .auth-form,
  .auth-form .form-grid {
    width: 100%;
    max-width: 100%;
  }

  .auth-form .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-form {
    padding: var(--sp-6);
  }

  .modal-overlay {
    align-items: end;
    padding: var(--sp-3);
  }

  .modal-card {
    max-height: calc(100dvh - 24px);
    padding: var(--sp-5);
  }
}

@media (max-width: 480px) {
  .nav-right { gap: var(--sp-2); }
  .page-title { font-size: 28px; }
  .page-header { padding: var(--sp-5); }
  .auth-brand { padding: var(--sp-6); }
  .auth-copy p { margin-bottom: var(--sp-5); }
  .feature-list { gap: var(--sp-2); }
  .feature-item { padding: var(--sp-2) var(--sp-3); }
  .filter-bar > * { width: 100%; min-width: 0; }
  .assessment-topline { padding: var(--sp-4); }
  .probability-row { grid-template-columns: 1fr auto; }
  .probability-row .bar-track { grid-column: 1 / -1; grid-row: 2; }
}

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

@media print {
  .saas-navbar,
  .sticky-actions,
  .toast-region,
  .loading-overlay {
    display: none !important;
  }

  body,
  .main-content {
    background: #fff;
  }

  .content {
    width: 100%;
    max-width: none;
    padding: 0;
  }

  .card,
  .hero-result {
    break-inside: avoid;
    box-shadow: none;
  }
}
