/* ============================================================
   ModelAssist Design System
   Aesthetic: Measured editorial — Swiss data report
   Fonts: Bricolage Grotesque (display) + Albert Sans (body)
   ============================================================ */

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
img, svg { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
table { border-collapse: collapse; }
ol, ul { list-style: none; }

/* --- Design Tokens --- */
:root {
  /* Type */
  --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
  --font-body: 'Albert Sans', system-ui, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;
  --leading-tight: 1.2;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;

  /* Space (4pt scale) */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  --space-4xl: 64px;
  --space-5xl: 96px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  /* Motion */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 120ms;
  --duration-normal: 200ms;
  --duration-slow: 350ms;

  /* Accent (deep muted teal) */
  --accent: oklch(0.52 0.09 185);
  --accent-hover: oklch(0.46 0.10 185);
  --accent-subtle: oklch(0.92 0.03 185);
  --accent-on: oklch(0.98 0.005 185);

  /* Semantic */
  --positive: oklch(0.52 0.11 155);
  --positive-subtle: oklch(0.93 0.03 155);
  --negative: oklch(0.55 0.13 25);
  --negative-subtle: oklch(0.94 0.03 25);
  --caution: oklch(0.62 0.13 70);
  --caution-subtle: oklch(0.94 0.04 70);
}

/* --- Light Theme (default) --- */
:root, [data-theme="light"] {
  --bg-page: oklch(0.975 0.004 185);
  --bg-surface: oklch(0.995 0.002 185);
  --bg-elevated: oklch(0.985 0.003 185);
  --bg-hover: oklch(0.96 0.005 185);
  --text-1: oklch(0.18 0.01 185);
  --text-2: oklch(0.42 0.008 185);
  --text-3: oklch(0.58 0.006 185);
  --border: oklch(0.90 0.005 185);
  --border-subtle: oklch(0.94 0.004 185);
  --ring: oklch(0.52 0.09 185 / 0.3);
  color-scheme: light;
}

/* --- Dark Theme --- */
[data-theme="dark"] {
  --bg-page: oklch(0.155 0.01 185);
  --bg-surface: oklch(0.20 0.01 185);
  --bg-elevated: oklch(0.25 0.01 185);
  --bg-hover: oklch(0.28 0.012 185);
  --text-1: oklch(0.92 0.005 185);
  --text-2: oklch(0.68 0.006 185);
  --text-3: oklch(0.52 0.005 185);
  --border: oklch(0.30 0.008 185);
  --border-subtle: oklch(0.26 0.006 185);
  --ring: oklch(0.52 0.09 185 / 0.4);
  --accent-subtle: oklch(0.25 0.04 185);
  --positive-subtle: oklch(0.22 0.03 155);
  --negative-subtle: oklch(0.22 0.03 25);
  --caution-subtle: oklch(0.24 0.03 70);
  color-scheme: dark;
}

/* --- Base --- */
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-1);
  background: var(--bg-page);
  font-weight: 400;
  font-kerning: normal;
}

[data-theme="dark"] body {
  font-weight: 400;
  letter-spacing: 0.005em;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--text-1);
  letter-spacing: -0.01em;
}

h2 { font-size: var(--text-xl); margin-bottom: var(--space-lg); }
h3 { font-size: var(--text-lg); margin-bottom: var(--space-md); }
h4 { font-size: var(--text-base); margin-bottom: var(--space-sm); }

p { max-width: 65ch; color: var(--text-2); margin-bottom: var(--space-md); }

hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-2xl) 0;
}

strong { font-weight: 600; }
small { font-size: var(--text-sm); color: var(--text-3); }

/* --- Focus --- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

/* --- Links --- */
a { text-decoration: none; transition: color var(--duration-fast); }
a:hover { color: var(--accent); }

/* --- Layout --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

.main-content {
  padding-top: var(--space-2xl);
  padding-bottom: var(--space-4xl);
}

/* --- App Header --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--space-md) var(--space-xl);
  backdrop-filter: blur(8px);
}

.app-header nav {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.theme-toggle {
  appearance: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-3);
  font-size: var(--text-sm);
  transition: color var(--duration-fast), border-color var(--duration-fast);
}

.theme-toggle:hover { color: var(--text-1); border-color: var(--text-3); }

/* --- Buttons --- */
button, .btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--text-sm);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  transition: all var(--duration-fast) var(--ease-out-quart);
  text-decoration: none;
  line-height: 1.4;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary, button:not(.outline):not(.secondary):not(.ghost):not(.theme-toggle):not(.tab-btn) {
  background: var(--accent);
  color: var(--accent-on);
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled), button:not(.outline):not(.secondary):not(.ghost):not(.theme-toggle):not(.tab-btn):hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.outline {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border);
}

.outline:hover:not(:disabled) {
  border-color: var(--text-3);
  color: var(--text-1);
  background: var(--bg-hover);
}

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

.secondary:hover:not(:disabled) { color: var(--text-1); background: var(--bg-hover); }

.ghost {
  background: transparent;
  border: none;
  color: var(--text-2);
  padding: var(--space-sm) var(--space-md);
  min-height: 36px;
}

.ghost:hover { color: var(--accent); }

button[aria-busy="true"] {
  position: relative;
  color: transparent !important;
}

button[aria-busy="true"]::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-on);
  border-radius: 50%;
  animation: spin 0.5s linear infinite;
}

/* --- Form Inputs --- */
input[type="number"],
input[type="text"],
input[type="file"],
select {
  font-size: var(--text-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-1);
  width: 100%;
  transition: border-color var(--duration-fast);
  line-height: 1.4;
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
  outline: none;
}

input:focus:not(:focus-visible), select:focus:not(:focus-visible) {
  box-shadow: none;
}

input::placeholder { color: var(--text-3); }

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: var(--space-xs);
}

label + input, label + select {
  margin-top: var(--space-xs);
}

label input, label select {
  margin-top: var(--space-sm);
}

/* --- Wizard Steps --- */
.wizard-steps {
  margin-bottom: var(--space-3xl);
}

.wizard-steps ol {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  opacity: 0.35;
  transition: opacity var(--duration-normal);
}

.wizard-step.active { opacity: 1; }

.step-num {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
  transition: all var(--duration-normal);
}

.wizard-step.active .step-num {
  width: 10px;
  height: 10px;
  background: var(--accent);
}

.wizard-step.complete .step-num {
  background: var(--positive);
}

.step-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}

.wizard-step.active .step-label { color: var(--text-1); font-weight: 600; }

.wizard-connector {
  width: 48px;
  height: 1px;
  background: var(--border);
  margin: 0 var(--space-sm);
  flex-shrink: 0;
  transition: background var(--duration-normal);
}

.wizard-connector.complete { background: var(--positive); }

/* --- Flash Messages --- */
.flash-msg {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  font-size: var(--text-sm);
  animation: fadeIn 300ms var(--ease-out-quart);
  border: 1px solid;
}

.flash-info { background: var(--accent-subtle); border-color: var(--accent); color: var(--text-1); }
.flash-success { background: var(--positive-subtle); border-color: var(--positive); color: var(--text-1); }
.flash-warning { background: var(--caution-subtle); border-color: var(--caution); color: var(--text-1); }
.flash-error { background: var(--negative-subtle); border-color: var(--negative); color: var(--text-1); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Upload Zone --- */
.upload-zone {
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3xl) var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--duration-fast), background var(--duration-fast);
}

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

.upload-zone p { margin: var(--space-xs) auto; color: var(--text-3); }

/* --- File Slots --- */
.file-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-md);
  margin: var(--space-xl) 0;
}

.file-slot {
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  transition: border-color var(--duration-fast), background var(--duration-fast);
}

.file-slot.uploaded {
  border-color: var(--positive);
  background: var(--positive-subtle);
}

.file-slot .file-name { font-weight: 600; display: block; font-size: var(--text-sm); }
.file-slot .file-status { color: var(--text-3); font-size: var(--text-xs); }
.file-slot.uploaded .file-status { color: var(--positive); }

.required-badge { color: var(--negative); font-weight: 700; font-size: var(--text-xs); vertical-align: super; }

/* --- Classification Table --- */
.classification-section { margin-top: var(--space-3xl); }

.classification-table {
  width: 100%;
  font-variant-numeric: tabular-nums;
}

.classification-table th,
.classification-table td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
}

.classification-table th {
  font-weight: 600;
  color: var(--text-2);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.classification-table tr:hover td { background: var(--bg-hover); }

.classification-table select {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
  min-width: 140px;
  margin: 0;
}

/* --- IO Buttons --- */
.io-buttons {
  display: flex;
  gap: var(--space-sm);
  margin: var(--space-lg) 0;
  flex-wrap: wrap;
}

.io-buttons button, .io-buttons label {
  font-size: var(--text-xs);
  padding: var(--space-xs) var(--space-md);
}

/* --- Config Grid --- */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-lg);
}

.config-section {
  padding: var(--space-xl);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}

.config-section h3 {
  font-size: var(--text-base);
  margin-bottom: var(--space-lg);
  color: var(--accent);
  font-family: var(--font-display);
}

/* --- Summary Stats (not cards — inline stat row) --- */
.summary-cards {
  display: flex;
  gap: var(--space-3xl);
  margin-bottom: var(--space-3xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
}

.summary-card {
  text-align: left;
}

.summary-card .card-value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.summary-card .card-label {
  font-size: var(--text-xs);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: var(--space-xs);
}

.card-total .card-value { color: var(--text-1); }
.card-pass .card-value { color: var(--positive); }
.card-warn .card-value { color: var(--text-2); }
.card-fail .card-value { color: var(--negative); }

/* --- Top Candidates --- */
.top-candidates {
  margin-bottom: var(--space-2xl);
}

.top-candidates h3 {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-md);
  font-family: var(--font-body);
}

.candidate-chips {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.candidate-chip {
  display: flex;
  flex-direction: column;
  padding: var(--space-md) var(--space-xl);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease-out-quart);
}

.candidate-chip:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.chip-id {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--text-1);
}

.chip-score {
  font-size: var(--text-xs);
  color: var(--text-3);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* --- Results Controls --- */
.results-controls {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  align-items: center;
  flex-wrap: wrap;
}

.results-controls select,
.results-controls input {
  max-width: 200px;
  font-size: var(--text-sm);
  padding: var(--space-sm) var(--space-md);
  margin: 0;
}

/* --- Results Table --- */
.results-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.results-table {
  width: 100%;
  font-size: var(--text-sm);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.results-table th {
  background: var(--bg-elevated);
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--border);
}

.results-table th:hover { color: var(--text-1); }

.results-table th .sort-arrow {
  margin-left: 4px;
  opacity: 0.35;
  font-size: 0.7em;
}

.results-table th.sorted .sort-arrow,
.metrics-table th.sorted .sort-arrow { opacity: 1; color: var(--accent); }

.results-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
}

.results-table tr:hover td { background: var(--bg-hover); }

.results-table a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.results-table a:hover { text-decoration: underline; }

/* --- Status Badges --- */
.badge {
  display: inline-block;
  padding: 2px var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-pass { background: var(--positive-subtle); color: var(--positive); }
.badge-warning { background: var(--caution-subtle); color: var(--caution); }
.badge-fail { background: var(--negative-subtle); color: var(--negative); }

/* --- Check Icons --- */
.check-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent-on);
}

.check-pass { background: var(--positive); }
.check-warn { background: var(--caution); }
.check-fail { background: var(--negative); }

/* --- Summary Grid --- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-lg);
}

.summary-item {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-lg) var(--space-xl);
  background: var(--bg-surface);
}

.summary-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.summary-item-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary-item-status {
  font-size: var(--text-xs);
  font-weight: 600;
}

.summary-item-body {
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: var(--leading-relaxed);
}

.summary-item-body strong {
  color: var(--text-1);
}

.summary-item-body .issue-line {
  display: flex;
  justify-content: space-between;
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.summary-item-body .issue-line:last-child {
  border-bottom: none;
}

.summary-item-body .issue-label {
  color: var(--text-2);
}

.summary-item-body .issue-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.issue-ok { color: var(--positive); }
.issue-warn { color: var(--caution); }
.issue-bad { color: var(--negative); }

.summary-item.has-issues {
  border-color: var(--caution);
  background: var(--caution-subtle);
}

.summary-item.has-critical {
  border-color: var(--negative);
  background: var(--negative-subtle);
}

.adstock-flag {
  color: var(--caution);
  font-weight: 600;
}

/* --- Detail Page --- */
.detail-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
}

.detail-header h2 { margin: 0; }

.back-link {
  font-size: var(--text-sm);
  color: var(--text-3);
}

.back-link:hover { color: var(--accent); }

/* --- Fit Bar --- */
.fit-bar {
  display: flex;
  gap: var(--space-2xl);
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
}

.fit-metric { text-align: left; }

.fit-metric .metric-label {
  font-size: var(--text-xs);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.fit-metric .metric-value {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.fit-metric.metric-pass .metric-value { color: var(--positive); }
.fit-metric.metric-fail .metric-value { color: var(--negative); }

/* --- Tabs --- */
.tabs {
  display: flex;
  gap: var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-2xl);
  overflow-x: auto;
}

.tab-btn {
  padding: var(--space-md) 0;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
  transition: color var(--duration-fast), border-color var(--duration-fast);
}

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

.tab-btn.active {
  color: var(--text-1);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  animation: fadeIn 250ms var(--ease-out-quart);
}

/* --- Chart Grid --- */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: var(--space-xl);
}

.chart-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  background: var(--bg-surface);
}

.chart-card h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  margin: 0 0 var(--space-xs) 0;
  word-break: break-all;
}

.chart-card .chart-subtitle {
  font-size: var(--text-xs);
  color: var(--text-3);
  margin-bottom: var(--space-md);
  font-variant-numeric: tabular-nums;
}

/* --- Data Tables (marginal, metrics) --- */
.marginal-table,
.metrics-table {
  width: 100%;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.marginal-table th,
.marginal-table td,
.metrics-table th,
.metrics-table td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.marginal-table th,
.metrics-table th {
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-2);
  background: var(--bg-elevated);
}

.metrics-table td:not(:first-child) { text-align: right; }
.metrics-table th:not(:first-child) { text-align: right; }

.metrics-table th .sort-arrow {
  margin-left: 4px;
  opacity: 0.35;
  font-size: 0.7em;
}

.metrics-table th:hover { color: var(--text-1); }

/* --- Loading --- */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5xl) 0;
  gap: var(--space-md);
  color: var(--text-3);
  font-size: var(--text-sm);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.5s linear infinite;
}

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

/* --- Article (configure explanation) --- */
article {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
  background: var(--bg-surface);
}

article header h3 {
  margin-bottom: var(--space-sm);
}

/* --- Details/Summary --- */
details {
  margin: var(--space-xl) 0;
}

details summary {
  cursor: pointer;
  font-weight: 500;
  font-size: var(--text-sm);
  color: var(--text-2);
  padding: var(--space-md) 0;
  transition: color var(--duration-fast);
}

details summary:hover { color: var(--text-1); }

details[open] summary { margin-bottom: var(--space-lg); }

/* --- Action Bar --- */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-2xl);
  flex-wrap: wrap;
  gap: var(--space-md);
}

/* --- Page-load stagger --- */
main > * {
  animation: fadeUp 400ms var(--ease-out-quart) both;
}

main > *:nth-child(1) { animation-delay: 0ms; }
main > *:nth-child(2) { animation-delay: 60ms; }
main > *:nth-child(3) { animation-delay: 120ms; }
main > *:nth-child(4) { animation-delay: 180ms; }

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

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

/* --- Responsive --- */
@media (max-width: 768px) {
  .container { padding: 0 var(--space-lg); }
  .config-grid { grid-template-columns: 1fr; }
  .summary-cards { flex-wrap: wrap; gap: var(--space-xl); }
  .chart-grid { grid-template-columns: 1fr; }
  .wizard-step .step-label { display: none; }
  .fit-bar { flex-wrap: wrap; gap: var(--space-lg); }
  h2 { font-size: var(--text-lg); }
}
