:root {
  color-scheme: dark;

  /* === Brand colors === */
  --primary: #60a5fa;
  --primary-rgb: 96, 165, 250;
  --primary-hover: #93c5fd;
  --primary-action: #2563eb;
  --primary-action-hover: #1d4ed8;
  --primary-soft: rgba(96, 165, 250, 0.12);
  --primary-border: rgba(96, 165, 250, 0.32);

  --accent: #10b981;
  --accent-hover: #059669;

  /* === Backgrounds === */
  --bg-page: #101a2a;
  --bg-card: #16212f;
  --bg-card-soft: #131d2b;
  --bg-input: #0f172a;
  --bg-elevated: #1e2d42;
  --bg-inset: rgba(8, 13, 24, 0.55);

  /* === Borders === */
  --border-subtle: rgba(148, 163, 184, 0.16);
  --border: #1c2a3d;
  --border-strong: #2a3850;
  --border-focus: #3b82f6;

  /* === Text === */
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  /* === Semantic colors === */
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.28);

  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.28);

  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --danger-border: rgba(248, 113, 113, 0.32);

  /* === Radius === */
  --radius-sm: 10px;
  --radius: 12px;
  --radius-md: 14px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* === Shadows === */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.38);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);

  /* === Spacing === */
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;

  /* === Typography === */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --transition-fast: 0.1s ease;
  --transition-base: 0.18s ease;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text-primary);
  line-height: 1.6;
  background:
    radial-gradient(circle at top right, rgba(96, 165, 250, 0.08), transparent 32%),
    var(--bg-page);
  min-height: 100vh;
}

.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.hero, .card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.hero { margin-bottom: 20px; }
.card { margin-bottom: 20px; }

.mode-switch-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}

.mode-switch-card p {
  margin-top: 4px;
}

.validation-banner {
  color: var(--warning);
  padding: 0.9rem 1.2rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.4rem;
}

h1, h2, h3, h4 { margin: 0 0 12px; color: var(--text-primary); }

h1 {
  font-size: clamp(1.7rem, 2.5vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

h2 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
}

h3 { font-size: 0.98rem; font-weight: 700; margin-top: 1rem; }
h4 { font-size: 0.88rem; font-weight: 700; color: var(--text-secondary); }

p {
  color: var(--text-secondary);
  margin: 0;
  max-width: 70ch;
  line-height: 1.55;
}

ul { margin: 0.4rem 0; padding-left: 1.2rem; color: var(--text-secondary); }
li { margin-bottom: 0.25rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 18px;
}
.form-grid h2, .form-grid button { grid-column: 1 / -1; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-weight: 600;
}

label.has-error {
  color: var(--danger);
}

label.has-error input,
label.has-error select {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.field-error-message {
  font-size: 0.78rem;
  color: var(--danger);
  font-weight: 600;
}

input, select, button {
  font: inherit;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 0.5rem 0.85rem;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
}

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

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

input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

button {
  cursor: pointer;
  width: fit-content;
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
}

button:hover {
  border-color: var(--primary-border);
  color: var(--text-primary);
}

button.primary, #upload-btn {
  background: var(--primary-action);
  color: white;
  border-color: var(--primary-action);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

button.primary:hover, #upload-btn:hover {
  background: var(--primary-action-hover);
  border-color: var(--primary-action-hover);
  color: white;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.summary {
  white-space: pre-wrap;
  background: var(--bg-inset);
  border: 1px solid var(--border-subtle);
  padding: 14px;
  border-radius: var(--radius);
  min-height: 80px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.5;
}

.summary.compact {
  min-height: 40px;
  margin: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-variant-numeric: tabular-nums;
}

th, td {
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 8px;
  text-align: right;
  color: var(--text-primary);
}

th {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

th:first-child, td:first-child { text-align: left; }

.warning {
  color: var(--warning);
}

.legal-disclaimer {
  margin-top: 1.25rem;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--bg-inset);
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.legal-disclaimer strong {
  color: var(--text-secondary);
}

.legal-disclaimer.footer-disclaimer {
  margin-top: 2rem;
  margin-bottom: 0;
  text-align: center;
}

.chart-card,
.recommendation-card {
  background: var(--bg-card-soft);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 14px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.chart-head p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.chart-shell {
  width: 100%;
  overflow-x: auto;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
}

.chart-grid {
  stroke: rgba(148, 163, 184, 0.16);
  stroke-width: 1;
}

.chart-axis {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: var(--font-sans);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.recommendation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.incentive-field {
  transition: opacity var(--transition-fast);
}

/* ====== Wizard progress stepper ====== */
.wizard-progress {
  display: flex;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 20px;
  padding: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.wizard-step-pill {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  width: auto;
}

.wizard-step-pill:hover:not(:disabled) {
  border-color: var(--border);
  color: var(--text-secondary);
}

.wizard-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.75rem;
  flex-shrink: 0;
}

.wizard-step-pill.is-active {
  background: var(--primary-soft);
  color: var(--text-primary);
  border-color: var(--primary-border);
}

.wizard-step-pill.is-active .wizard-step-num {
  background: var(--primary-action);
  color: white;
}

.wizard-step-pill.is-complete .wizard-step-num {
  background: var(--success);
  color: white;
}

.wizard-step-pill.is-complete { color: var(--text-secondary); }

.wizard-step-pill.is-error {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--text-primary);
}

.wizard-step-pill.is-error .wizard-step-num {
  background: var(--danger);
  color: white;
}

.wizard-step-pill:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.wizard-step { display: none; }
.wizard-step.is-active { display: block; }

.step-hint {
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.wizard-nav {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}

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

button.ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* ====== Results overview: headline stat cards ====== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--bg-card-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
}

.stat-card-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.stat-card-value {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.stat-card-value .unit {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 0.25rem;
}

.stat-card.tone-positive .stat-card-value { color: var(--success); }
.stat-card.tone-negative .stat-card-value { color: var(--danger); }

.overview-blockers { margin-top: 0.5rem; }

/* ====== Collapsible details blocks ====== */
details.details-block, details.wizard-advanced {
  margin-top: 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 0.1rem 1rem 0.9rem;
  background: var(--bg-inset);
}

details.wizard-advanced { padding: 0.1rem 1.5rem 1.5rem; }

details.details-block summary, details.wizard-advanced summary {
  cursor: pointer;
  padding: 0.85rem 0;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-secondary);
  list-style: none;
}

details.details-block summary::-webkit-details-marker,
details.wizard-advanced summary::-webkit-details-marker { display: none; }

details.details-block summary::before,
details.wizard-advanced summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.5rem;
  color: var(--primary);
  transition: transform var(--transition-fast);
}

details[open].details-block summary::before,
details[open].wizard-advanced summary::before {
  transform: rotate(90deg);
}

details.details-block summary:hover, details.wizard-advanced summary:hover {
  color: var(--text-primary);
}

@media (max-width: 720px) {
  .shell { padding: 20px 14px 40px; }
  .wizard-progress { flex-wrap: nowrap; }
  .wizard-step-label { display: none; }
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
}

.auth-tab.is-active {
  background: var(--bg-card);
  border-color: var(--text-primary);
  font-weight: 600;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form[hidden] {
  display: none;
}

.auth-message {
  min-height: 1.2em;
  font-size: 0.9rem;
}

.auth-message.is-error { color: var(--danger, #c0392b); }
.auth-message.is-success { color: var(--success, #0e9a63); }
