/* ──────────────────────────────────────────────────────────────────────
   v4_ui_theme.css — design tokens + components ported from
   data/MWG/v4_ui_mockup.html. Light + dark theme via CSS custom
   properties + [data-theme="dark"] override + prefers-color-scheme.

   Loads BEFORE the inline <style> in templates/v4/base.html so the
   existing v4 component styles inherit our tokens. Legacy aliases at
   the bottom map old (--surface, --text-2, --text-3, --accent-bg,
   --green, --green-bg, --amber, --amber-bg, --red, --red-bg) onto
   the new mockup tokens so v4_1/site.html and v4_1/portfolio.html
   keep working without HTML edits.
   ────────────────────────────────────────────────────────────────────── */

/* ── Light theme (default) ─────────────────────────────────────────── */
:root, [data-theme="light"] {
  --bg: #fafaf9;
  --bg-alt: #ffffff;
  --bg-subtle: #f5f5f4;
  --bg-hover: #f0efee;
  --text: #18181b;
  --text-muted: #71717a;
  --text-subtle: #a1a1aa;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --accent: #ea580c;
  --accent-hover: #c2410c;
  --accent-bg: #fff7ed;
  --accent-border: #fed7aa;
  --green: #16a34a;
  --green-bg: #f0fdf4;
  --green-strong: #15803d;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --purple: #7c3aed;
  --purple-bg: #f5f3ff;
  --topbar-bg: rgba(255, 255, 255, 0.85);
  --hero-bg: linear-gradient(135deg, #18181b 0%, #27272a 100%);
  --hero-text: #ffffff;
  --hero-text-muted: rgba(255,255,255,0.7);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.04);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.06);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.06), 0 2px 4px -2px rgb(0 0 0 / 0.04);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --r: 6px;
  --r-lg: 10px;
  color-scheme: light;
}

/* ── Dark theme ────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-alt: #141414;
  --bg-subtle: #1f1f1f;
  --bg-hover: #262626;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-subtle: #71717a;
  --border: #262626;
  --border-strong: #3f3f46;
  --accent: #fb923c;
  --accent-hover: #ea580c;
  --accent-bg: rgba(234, 88, 12, 0.12);
  --accent-border: rgba(234, 88, 12, 0.35);
  --green: #4ade80;
  --green-bg: rgba(34, 197, 94, 0.12);
  --green-strong: #22c55e;
  --amber: #fbbf24;
  --amber-bg: rgba(217, 119, 6, 0.12);
  --red: #f87171;
  --red-bg: rgba(220, 38, 38, 0.12);
  --blue: #60a5fa;
  --blue-bg: rgba(37, 99, 235, 0.12);
  --purple: #a78bfa;
  --purple-bg: rgba(124, 58, 237, 0.14);
  --topbar-bg: rgba(20, 20, 20, 0.85);
  --hero-bg: linear-gradient(135deg, #1a1a1a 0%, #27272a 100%);
  --hero-text: #fafafa;
  --hero-text-muted: rgba(255,255,255,0.65);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.5), 0 1px 2px -1px rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

/* Auto-dark when user prefers it (overridden by data-theme=light) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a;
    --bg-alt: #141414;
    --bg-subtle: #1f1f1f;
    --bg-hover: #262626;
    --text: #fafafa;
    --text-muted: #a1a1aa;
    --text-subtle: #71717a;
    --border: #262626;
    --border-strong: #3f3f46;
    --accent: #fb923c;
    --accent-bg: rgba(234, 88, 12, 0.12);
    --accent-border: rgba(234, 88, 12, 0.35);
    --green: #4ade80;
    --green-bg: rgba(34, 197, 94, 0.12);
    --amber: #fbbf24;
    --amber-bg: rgba(217, 119, 6, 0.12);
    --red: #f87171;
    --red-bg: rgba(220, 38, 38, 0.12);
    --blue: #60a5fa;
    --blue-bg: rgba(37, 99, 235, 0.12);
    --purple: #a78bfa;
    --purple-bg: rgba(124, 58, 237, 0.14);
    --topbar-bg: rgba(20, 20, 20, 0.85);
    --hero-bg: linear-gradient(135deg, #1a1a1a 0%, #27272a 100%);
    --hero-text: #fafafa;
    --hero-text-muted: rgba(255,255,255,0.65);
    color-scheme: dark;
  }
}

/* ── Legacy aliases for templates/v4/base.html ─────────────────────── */
/* Existing v4 class definitions reference --surface, --surface-2,
   --surface-3, --text-2, --text-3, --text-4. Map them onto the new
   tokens so .side, .item, .strip, .first-empty etc. keep working. */
:root, [data-theme="light"], [data-theme="dark"] {
  --surface: var(--bg-alt);
  --surface-2: var(--bg-subtle);
  --surface-3: var(--bg-hover);
  --text-2: var(--text-muted);
  --text-3: var(--text-subtle);
  --text-4: var(--text-subtle);
  --chart-1: var(--accent);
  --chart-2: var(--blue);
  --chart-3: var(--green);
  --chart-4: var(--amber);
  --chart-5: var(--purple);
  --chart-6: var(--red);
}

/* ── Body — single source of truth for app-wide font size ──────────── */
body {
  font-size: 14px;
  line-height: 1.5;
}

/* ── Theme toggle button ───────────────────────────────────────────── */
.theme-toggle {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  transition: all 0.15s;
}
.theme-toggle:hover { color: var(--text); background: var(--bg-alt); border-color: var(--border-strong); }
.theme-toggle .sun-icon { display: none; }
.theme-toggle .moon-icon { display: inline; }
[data-theme="dark"] .theme-toggle .sun-icon { display: inline; }
[data-theme="dark"] .theme-toggle .moon-icon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun-icon { display: inline; }
  :root:not([data-theme="light"]) .theme-toggle .moon-icon { display: none; }
}

/* ── Tab nav (post-results layout) ─────────────────────────────────── */
.tab-nav {
  position: sticky; top: 51px; z-index: 40;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex; gap: 2px;
  overflow-x: auto;
}
.tab-nav .tab {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  transition: all 0.15s;
  white-space: nowrap;
  user-select: none;
  font-family: inherit;
}
.tab-nav .tab:hover { color: var(--text); background: var(--bg-subtle); }
.tab-nav .tab.active, .tab-nav .tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab-nav .tab[aria-disabled="true"], .tab-nav .tab.locked { color: var(--text-subtle); cursor: not-allowed; }
.tab-nav .tab[aria-disabled="true"]:hover, .tab-nav .tab.locked:hover { background: transparent; color: var(--text-subtle); }
.tab-nav .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }
.tab-nav .tab .num { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--bg-subtle); font-size: 11px; font-weight: 600; color: var(--text-muted); }
.tab-nav .tab.active .num, .tab-nav .tab[aria-selected="true"] .num { background: var(--accent); color: white; }
.tab-nav .tab .lock-icon { font-size: 11px; color: var(--text-subtle); }
.tab-nav .tab .check { color: var(--green); font-size: 12px; }

/* ── Tab content panes ─────────────────────────────────────────────── */
.tab-pane { display: none; animation: fadeInUp 0.15s ease; }
.tab-pane.active { display: block; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }

/* ── Cards ─────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; justify-content: space-between;
}
.card-title { font-size: 17px; font-weight: 700; letter-spacing: -0.015em; }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.card-body { padding: 22px 24px; }

/* ── KPI grid ──────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }
.kpi {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: all 0.2s;
}
.kpi:hover { background: var(--bg-alt); border-color: var(--border-strong); }
.kpi .label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; margin-bottom: 6px; }
.kpi .value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .value.green { color: var(--green); }
.kpi .value.red { color: var(--red); }
.kpi .delta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.kpi .delta.up { color: var(--green); }
.kpi .delta.down { color: var(--red); }

/* ── Recommendation hero ───────────────────────────────────────────── */
.recommendation {
  background: var(--hero-bg);
  color: var(--hero-text);
  border-radius: var(--radius);
  padding: 26px 30px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}
.recommendation::before {
  content: ''; position: absolute; top: 0; right: 0; width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(234,88,12,0.18) 0%, transparent 65%);
  pointer-events: none;
}
.recommendation .label { font-size: 11px; color: var(--hero-text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; margin-bottom: 10px; position: relative; }
.recommendation .headline { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin-bottom: 14px; position: relative; color: var(--hero-text); }
.recommendation .meta { font-size: 13px; color: var(--hero-text-muted); display: flex; gap: 18px; flex-wrap: wrap; position: relative; }
.recommendation .meta .item { display: flex; align-items: center; gap: 6px; }
.recommendation .meta .item .dot { color: var(--accent); }

/* ── Insight box ───────────────────────────────────────────────────── */
.insight {
  background: var(--blue-bg);
  border: 1px solid color-mix(in srgb, var(--blue) 40%, transparent);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 13px;
  color: var(--blue);
  margin-top: 14px;
}
.insight strong { color: var(--blue); filter: brightness(0.85); }
[data-theme="dark"] .insight strong { filter: brightness(1.15); }

/* ── Chart wrappers ────────────────────────────────────────────────── */
.chart-wrap { background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.chart-wrap .chart-title { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.chart-wrap canvas { max-height: 240px; }

/* ── Two-column layout ─────────────────────────────────────────────── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 768px) { .two-col { grid-template-columns: 1fr; } }

/* ── Chip rows ─────────────────────────────────────────────────────── */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.chip:hover { background: var(--accent-bg); border-color: var(--accent-border); color: var(--accent); }
.chip .x { color: var(--text-subtle); margin-left: 2px; }

/* ── Slider row ────────────────────────────────────────────────────── */
.slider-row { display: grid; grid-template-columns: 100px 1fr 130px; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--bg-subtle); }
.slider-row:last-child { border-bottom: none; }
.slider-row .slabel { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.slider-row .slider { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; background: var(--bg-subtle); border-radius: 2px; outline: none; }
.slider-row .slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--text); cursor: pointer; box-shadow: var(--shadow); border: 2px solid white; }
.slider-row .svalue { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }

/* ── Status pills (mockup variants) ────────────────────────────────── */
.pill-success { background: var(--green-bg); color: var(--green); border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.pill-success .dot { background: var(--green); }
.pill-warning { background: var(--amber-bg); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.pill-warning .dot { background: var(--amber); }
.pill-error { background: var(--red-bg); color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.pill-error .dot { background: var(--red); }
.pill-info { background: var(--blue-bg); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 35%, transparent); }
.pill-info .dot { background: var(--blue); }
.pill-muted { background: var(--bg-subtle); color: var(--text-muted); border-color: var(--border); }
.pill-muted .dot { background: var(--text-subtle); }
.pill-purple { background: var(--purple-bg); color: var(--purple); border-color: color-mix(in srgb, var(--purple) 35%, transparent); }
.pill-purple .dot { background: var(--purple); }

/* ── Section heading ───────────────────────────────────────────────── */
h3.section-h, .section-h { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 22px 0 10px; }

/* ── Live dot ──────────────────────────────────────────────────────── */
.live-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); margin-right: 4px;
  animation: livepulse 2s ease-in-out infinite;
}
@keyframes livepulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ── Reduce motion respect ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ── Wizard / co-pilot input flow (3-col layout) ─────────────────────
   Used by templates/v4_1/site_wizard.html. Wizard tokens now alias the
   global theme tokens so the wizard follows the user's light/dark
   choice (matches portfolio + dashboard, no jarring jump on navigate). */
.wiz-shell {
  --wiz-bg: var(--bg);
  --wiz-surface: var(--bg-alt);
  --wiz-surface-2: var(--bg-subtle);
  --wiz-border: var(--border);
  --wiz-border-strong: var(--border-strong);
  --wiz-text: var(--text);
  --wiz-text-muted: var(--text-muted);
  --wiz-text-subtle: var(--text-subtle);
  --wiz-amber: var(--accent);
  --wiz-amber-bg: var(--accent-bg);
  --wiz-green: var(--green);
  --wiz-green-bg: var(--green-bg);
  --wiz-blue: var(--blue);
  --wiz-rose: var(--red);
  background: var(--wiz-bg); color: var(--wiz-text);
  min-height: 100vh; display: grid;
  grid-template-rows: auto 1fr;
  font-family: 'Inter', system-ui, sans-serif;
}

/* M11h 2026-05-06: 3-column wizard with explicit visual separation.
   Left = wizard steps (170px), middle = form (1fr), right = right-rail
   summary (300px). Vertical separator rules between columns instead of
   relying on whitespace; prevents the "everything-on-one-page" feel.
   Tightened left sidebar width + reduced gap so middle has more room. */
.wiz-grid-inline {
  display: grid;
  /* minmax(0,1fr) so the middle column can shrink below its content's intrinsic
     min-width instead of forcing the whole grid wider than the container and
     overlapping the right rail (seen in constrained/embedded widths). */
  grid-template-columns: 170px minmax(680px, 1fr) minmax(240px, 280px);
  column-gap: 0;  /* gap replaced by padding + dividers below */
  align-items: start;
  margin: -22px -28px -80px;
  padding: 22px 0 80px;
  /* M11k 2026-05-06: same fly.io-style soft gradient bg as the results
     dashboard. Was a flat var(--bg) (white-ish) which made the form feel
     like blank paper. Now the wiz-card panels float visually. */
  background:
    radial-gradient(circle at 0% 0%, #f3e8ff 0%, transparent 35%),
    radial-gradient(circle at 100% 100%, #e0e7ff 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, #faf5ff 0%, transparent 60%),
    #fafaf9;
  min-height: calc(100vh - 46px);
}
.wiz-grid-inline .wiz-sidebar {
  position: sticky; top: 70px;
  padding: 4px 24px 4px 28px;
  border-right: 1px solid #e7e5e4;
  background: transparent;
}
.wiz-grid-inline .wiz-main {
  padding: 4px 36px;
  max-width: 1040px;
  margin: 0 auto;
  min-width: 0;   /* allow the grid child to shrink (prevents column overflow) */
}
.wiz-grid-inline .wiz-sidebar, .wiz-grid-inline .wiz-rail { min-width: 0; overflow-wrap: anywhere; }
.wiz-grid-inline .wiz-rail {
  position: sticky; top: 70px;
  padding: 4px 28px 4px 28px;
  border-left: 1px solid #e7e5e4;
  background: transparent;
}
[data-theme="dark"] .wiz-grid-inline .wiz-sidebar,
[data-theme="dark"] .wiz-grid-inline .wiz-rail {
  border-color: #27272a;
}
@media (max-width: 1280px) {
  .wiz-grid-inline { grid-template-columns: 140px minmax(0, 1fr); }
  .wiz-grid-inline .wiz-main { padding: 4px 28px; max-width: 960px; }
  .wiz-grid-inline .wiz-rail { display: none; }
}
@media (max-width: 1024px) {
  .wiz-grid-inline { grid-template-columns: 1fr; }
  .wiz-grid-inline .wiz-sidebar,
  .wiz-grid-inline .wiz-rail {
    position: static; border: none; padding: 12px 24px;
  }
  .wiz-grid-inline .wiz-main { padding: 4px 24px; max-width: none; }
}
.wiz-topbar {
  background: var(--wiz-surface); border-bottom: 1px solid var(--wiz-border);
  padding: 14px 28px; display: flex; align-items: center; justify-content: space-between;
}
.wiz-topbar .frame-label { font-size: 12px; color: var(--wiz-amber); }
.wiz-topbar .step-pill {
  background: var(--wiz-amber); color: #18181b;
  padding: 6px 14px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.wiz-grid {
  display: grid; grid-template-columns: 280px 1fr 360px;
  min-height: 0;
}
.wiz-sidebar {
  background: var(--wiz-bg); border-right: 1px solid var(--wiz-border);
  padding: 28px 20px; overflow-y: auto;
}
.wiz-brand { color: var(--wiz-amber); font-weight: 700; font-size: 14px; letter-spacing: 0.04em; }
.wiz-tagline { color: var(--wiz-text-muted); font-size: 12px; margin-top: 4px; line-height: 1.5; }
.wiz-steps { margin-top: 32px; display: flex; flex-direction: column; gap: 4px; }
.wiz-step {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--wiz-text-muted); font-size: 13.5px;
  cursor: pointer; transition: background 0.15s, color 0.15s;
  border: none; background: transparent; text-align: left; font-family: inherit;
}
.wiz-step:hover:not(:disabled) { background: rgba(124, 58, 237, 0.06); color: var(--wiz-text); }
.wiz-step:disabled { cursor: not-allowed; opacity: 0.55; }
/* M11k 2026-05-06: active step gets the same purple-tinted floating-pill
   treatment as the results-tab pill bar, so wizard + dashboard read as
   one design system. */
.wiz-step.is-active {
  background: linear-gradient(180deg, #ffffff 0%, #faf5ff 100%);
  color: #6d28d9; font-weight: 600;
  box-shadow: 0 1px 2px rgba(109, 40, 217, 0.08), 0 0 0 1px rgba(109, 40, 217, 0.10);
}
.wiz-step .num {
  width: 26px; height: 26px; border-radius: 50%;
  background: transparent; border: 1.5px solid var(--wiz-border-strong); color: var(--wiz-text-muted);
  display: grid; place-items: center; font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.wiz-step.is-active .num { background: var(--wiz-amber); color: #18181b; border-color: var(--wiz-amber); }
.wiz-step.is-done .num { background: var(--wiz-green); color: #052e16; border-color: var(--wiz-green); }
.wiz-step.is-done .num::before { content: "✓"; }
.wiz-step.is-done .num span { display: none; }

.wiz-main { padding: 36px 56px; overflow-y: auto; min-width: 0; }
.wiz-question { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin-bottom: 12px; color: var(--wiz-text); }
.wiz-rationale { font-size: 14.5px; color: var(--wiz-text-muted); line-height: 1.6; max-width: 720px; margin-bottom: 32px; }
.wiz-rationale strong { color: var(--wiz-text); font-weight: 600; }

.wiz-field { margin-bottom: 28px; max-width: 720px; }
/* M11h 2026-05-06: form rhythm. Outside a card, rows have margin-only.
   Inside a card, rows have a thin divider so they don't blur together. */
.wiz-field-row {
  display: grid; grid-template-columns: minmax(160px, 200px) minmax(0, 1fr); gap: 24px;
  align-items: flex-start; margin-bottom: 18px;
}
.wiz-field-row > * { min-width: 0; }
.wiz-card .wiz-field-row {
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid #f1efed;
}
.wiz-card .wiz-field-row:last-child {
  border-bottom: none; padding-bottom: 0; margin-bottom: 0;
}
/* M11h: Card wrapper for visually grouping related fields. White surface
   against the off-white page background, soft border, gentle shadow.
   M11i 2026-05-06: subtle topic-based tinting via [data-tint] so a long
   wizard reads as visually chunked sections instead of a flat field list.
   Tints are very low alpha (~5%) — never compete with content. A 3px left
   accent stripe carries most of the categorical signal. */
.wiz-card {
  background: #ffffff;
  border: 1px solid #ece9e6;
  border-radius: 14px;
  padding: 28px 32px;
  margin-bottom: 18px;
  max-width: 100%;
  /* M11k 2026-05-06: deeper layered shadow to match results dashboard
     panels. Was nearly flat (0 2px 4px @ 3% alpha) \u2014 now reads as a
     proper floating card on the gradient page background. */
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
  position: relative;
  border-left: 3px solid #e7e5e4;
}
.wiz-card[data-tint="site"]      { background: #f0f9ff; border-left-color: #0ea5e9; }  /* sky / location */
.wiz-card[data-tint="hardware"]  { background: #fff7ed; border-left-color: #ea580c; }  /* orange / chargers */
.wiz-card[data-tint="ops"]       { background: #f0fdf4; border-left-color: #16a34a; }  /* green / pricing */
.wiz-card[data-tint="der"]       { background: #fefce8; border-left-color: #ca8a04; }  /* amber / PV+BESS */
.wiz-card[data-tint="chem"]      { background: #faf5ff; border-left-color: #9333ea; }  /* purple / chemistry */
.wiz-card[data-tint="vpp"]       { background: #ecfeff; border-left-color: #0891b2; }  /* cyan / markets */
.wiz-card[data-tint="financial"] { background: #ecfdf5; border-left-color: #059669; }  /* emerald / NPV */
.wiz-card[data-tint="costs"]     { background: #f8fafc; border-left-color: #64748b; }  /* slate / equipment costs */
.wiz-card[data-tint="solve"]     { background: #fdf4ff; border-left-color: #c026d3; }  /* fuchsia / final review */
[data-theme="dark"] .wiz-card,
:root[style*="dark"] .wiz-card {
  background: #18181b; border-color: #27272a;
  box-shadow: 0 2px 4px rgba(0,0,0,0.20);
}

/* M11k 2026-05-06: Steps 4-6 use raw wiz-field-row + wiz-rev-grid without
   a wiz-card wrapper. Apply the same topic-coded tint at the pane level so
   the long form still reads as visually chunked. Each pane gets a soft
   left-edge accent + tinted bg via a faux-card wrapper effect. */
.wiz-pane[data-pane="4"],
.wiz-pane[data-pane="5"],
.wiz-pane[data-pane="6"] {
  border-radius: 14px;
  padding: 24px 28px;
  border: 1px solid #e7e5e4;
  border-left: 3px solid #e7e5e4;
  margin-top: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.03), 0 1px 1px rgba(0,0,0,0.02);
}
.wiz-pane[data-pane="4"] { background: #ecfeff; border-left-color: #0891b2; }   /* cyan / markets+VPP */
.wiz-pane[data-pane="5"] { background: #ecfdf5; border-left-color: #059669; }   /* emerald / financials */
.wiz-pane[data-pane="6"] { background: #f8fafc; border-left-color: #64748b; }   /* slate / equipment costs */

/* M11h: section heading inside a card — small caps label, divider */
.wiz-section-h {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: #78716c;
  margin: 0 0 22px 0;
  padding-bottom: 14px;
  border-bottom: 1px solid #f1efed;
}
[data-theme="dark"] .wiz-section-h { color: #a1a1aa; border-color: #27272a; }
.wiz-field-label { font-size: 14px; font-weight: 500; color: var(--wiz-text); padding-top: 9px; }
.wiz-field-label .req { color: var(--wiz-rose); }
.wiz-field-label .hint { display: block; font-size: 11.5px; color: var(--wiz-text-subtle); font-weight: 400; margin-top: 4px; line-height: 1.4; }
/* M11g 2026-05-06: input bg was var(--wiz-bg) = page bg = #fafaf9 — input
   was invisible on page. Use white in light mode so the field has visible
   contrast; border bumped to mid-gray so the box is clearly defined. */
.wiz-field-input {
  width: 100%; padding: 9px 12px;
  background: #ffffff; border: 1px solid #94a3b8;
  color: var(--wiz-text); font-size: 14px; border-radius: 8px;
  font-family: inherit; transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
[data-theme="dark"] .wiz-field-input,
:root[style*="dark"] .wiz-field-input {
  background: #18181b; border-color: #52525b;
}
.wiz-field-input:focus { outline: none; border-color: var(--wiz-amber); }
.wiz-field-input::placeholder { color: var(--wiz-text-subtle); }
.wiz-field-suffix { display: flex; align-items: stretch; gap: 0; max-width: 100%; min-width: 0; }
.wiz-field-suffix input { min-width: 0; flex: 1 1 auto; }
.wiz-field-suffix input { border-radius: 8px 0 0 8px; }
.wiz-field-suffix .suffix {
  padding: 9px 14px; background: var(--wiz-surface);
  border: 1px solid var(--wiz-border-strong); border-left: none; border-radius: 0 8px 8px 0;
  color: var(--wiz-text-muted); font-size: 13px;
  display: inline-flex; align-items: center; flex: 0 0 auto; white-space: nowrap;
}
.wiz-field-help { font-size: 12px; color: var(--wiz-text-muted); margin-top: 6px; }
.wiz-field-help .src { color: var(--wiz-amber); font-weight: 500; }
.wiz-field-help a { color: var(--wiz-blue); text-decoration: none; }
.wiz-field-help a:hover { text-decoration: underline; }
.wiz-wide-help {
  margin: -12px 0 24px 224px;
  max-width: 680px;
}

.wiz-loading-card[hidden] { display: none; }
.wiz-loading-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}
.wiz-loading-row strong {
  color: var(--wiz-text);
  font-size: 14px;
}
.wiz-loading-row p {
  margin: 4px 0 0;
  color: var(--wiz-text-muted);
  font-size: 13px;
  line-height: 1.5;
}
.wiz-spinner {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 3px solid #dbeafe;
  border-top-color: #2563eb;
  animation: wizSpin 0.9s linear infinite;
}
@keyframes wizSpin {
  to { transform: rotate(360deg); }
}

.wiz-advanced-trigger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; background: transparent;
  border: 1px dashed var(--wiz-border-strong); border-radius: 8px;
  color: var(--wiz-blue); font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: inherit; margin-top: 8px;
}
.wiz-advanced-trigger:hover { border-color: var(--wiz-blue); }
.wiz-advanced-body { display: none; padding: 16px; border: 1px solid var(--wiz-border); border-radius: 8px; margin-top: 12px; background: var(--wiz-surface-2); }
.wiz-advanced-body.is-open { display: block; }

.wiz-cta-row { display: flex; gap: 12px; align-items: center; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--wiz-border); }
/* M11h: explicit colors + box-shadow so buttons are unambiguously buttons,
   not relying on CSS-var inheritance that may not load in every theme. */
.wiz-cta-primary {
  background: #ea580c; color: #ffffff;
  padding: 12px 24px; border-radius: 8px;
  font-size: 14px; font-weight: 600;
  border: 1px solid #c2410c;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 1px 2px rgba(234, 88, 12, 0.18), 0 2px 6px rgba(234, 88, 12, 0.12);
  transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
}
.wiz-cta-primary:hover { background: #c2410c; box-shadow: 0 2px 4px rgba(234, 88, 12, 0.28), 0 4px 10px rgba(234, 88, 12, 0.18); }
.wiz-cta-primary:active { transform: translateY(1px); }
.wiz-cta-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.wiz-cta-secondary {
  background: #ffffff; color: #18181b;
  padding: 12px 22px; border: 1px solid #94a3b8; border-radius: 8px;
  font-size: 14px; font-weight: 500;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: border-color 0.15s, background 0.15s;
}
.wiz-cta-secondary:hover { border-color: #475569; background: #f8fafc; }
.wiz-cta-tertiary {
  background: transparent; color: #0369a1;
  padding: 11px 16px; border: none;
  font-size: 14px; font-weight: 500;
  cursor: pointer; font-family: inherit;
}
.wiz-cta-tertiary:hover { text-decoration: underline; }
/* M11h: input-plus-action layout — input grows, button hugs right edge,
   status sits inline-right of the button, helper text wraps below the
   whole row. The whole thing is one flex container with proper rhythm. */
.wiz-input-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.wiz-input-with-action .wiz-verify-status {
  grid-column: 1 / -1;
}
.wiz-input-with-action .wiz-field-help {
  grid-column: 1 / -1;
  margin-top: 8px;
}
/* M11h: inline action button — solid filled, matches primary colour
   language but smaller; clearly a button, not a chip. */
.wiz-inline-action {
  background: #18181b; color: #ffffff;
  border: 1px solid #18181b;
  padding: 9px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  transition: background 0.15s;
}
.wiz-inline-action:hover { background: #27272a; }
.wiz-inline-action:active { transform: translateY(1px); }
.wiz-inline-action:disabled { opacity: 0.5; cursor: not-allowed; }
.wiz-verify-status {
  display: inline-block;
  font-size: 13px; font-weight: 500;
  white-space: normal;
  min-width: 0;
  line-height: 1.35;
}
.wiz-verify-status:empty { display: none; }
.wiz-verify-status.ok { color: #15803d; }
.wiz-verify-status.busy { color: #78716c; font-style: italic; }
.wiz-verify-status.err { color: #dc2626; }
.wiz-tariff-notice {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #d6d3d1;
  background: #fafaf9;
  color: #44403c;
  font-size: 13px;
  line-height: 1.45;
}
.wiz-tariff-notice[hidden] { display: none; }
.wiz-tariff-notice.ok {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}
.wiz-tariff-notice.warn {
  border-color: #fbbf24;
  background: #fffbeb;
  color: #92400e;
}
.wiz-tariff-notice.err {
  border-color: #fca5a5;
  background: #fef2f2;
  color: #991b1b;
}
.wiz-tariff-line {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}
.wiz-tariff-action {
  border: 1px solid currentColor;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 4px 8px;
  white-space: nowrap;
}
.wiz-tariff-override {
  grid-column: 1 / -1;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--wiz-border);
  border-radius: 8px;
  background: #fff;
}
.wiz-tariff-override[hidden] { display: none; }
.wiz-tariff-override-title {
  margin-bottom: 8px;
  color: var(--wiz-text-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.wiz-tariff-agent-btn {
  width: 100%;
  margin-bottom: 10px;
  border: 1px solid #1d4ed8;
  border-radius: 7px;
  background: #eff6ff;
  color: #1e40af;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 9px 10px;
}
.wiz-tariff-agent-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}
.wiz-tariff-candidates {
  display: grid;
  gap: 8px;
  margin: 8px 0 12px;
}
.wiz-tariff-candidates[hidden] { display: none; }
.wiz-tariff-candidate {
  border: 1px solid var(--wiz-border);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}
.wiz-tariff-candidate .title {
  color: var(--wiz-text-main);
  font-weight: 800;
}
.wiz-tariff-candidate .meta {
  margin-top: 3px;
  color: var(--wiz-text-muted);
  font-size: 12px;
}
.wiz-tariff-candidate .actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  margin-top: 8px;
}
.wiz-tariff-candidate a {
  color: #1d4ed8;
  font-size: 12px;
}
.wiz-tariff-candidate button {
  border: 0;
  border-radius: 6px;
  background: #1d4ed8;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}
.wiz-radio-row,
.wiz-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  color: var(--wiz-text-main);
  font-size: 13px;
  line-height: 1.35;
}
.wiz-tariff-manual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 6px;
}
.wiz-tariff-manual-grid .wiz-field-input:last-child {
  grid-column: 1 / -1;
}
.wiz-kbd-hint { margin-left: auto; color: var(--wiz-text-subtle); font-size: 12px; }
.wiz-kbd-hint .k { background: var(--wiz-surface-2); border: 1px solid var(--wiz-border); padding: 2px 8px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--wiz-text-muted); }

@media (max-width: 900px) {
  .wiz-main { padding: 28px 24px; }
  .wiz-card { padding: 22px 24px; max-width: 100%; }
  .wiz-field-row { grid-template-columns: 1fr; gap: 8px; }
  .wiz-field-label { padding-top: 0; }
  .wiz-input-with-action { grid-template-columns: 1fr; }
  .wiz-inline-action { width: 100%; justify-content: center; }
  .wiz-tariff-line { align-items: flex-start; flex-direction: column; }
  .wiz-tariff-manual-grid { grid-template-columns: 1fr; }
  .wiz-wide-help { margin: -6px 0 22px; max-width: 100%; }
}

/* Inferences callout — green left-bordered card */
.wiz-inferences {
  border: 1px solid var(--wiz-border); border-left: 3px solid var(--wiz-green);
  border-radius: 8px; padding: 20px 24px; margin-bottom: 24px;
  background: var(--wiz-surface);
}
.wiz-inferences-label { font-size: 11px; color: var(--wiz-green); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 16px; }
.wiz-inf-row { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: baseline; padding: 8px 0; }
.wiz-inf-row + .wiz-inf-row { border-top: 1px solid var(--wiz-border); }
.wiz-inf-key { font-size: 13.5px; color: var(--wiz-text-muted); }
.wiz-inf-val { font-size: 14px; color: var(--wiz-text); font-weight: 500; text-align: right; }
.wiz-inf-src { font-size: 12px; color: var(--wiz-text-subtle); grid-column: 1 / -1; margin-top: 4px; }

/* Amber callout — "Two things I'm guessing" */
.wiz-callout-amber {
  border: 1px solid var(--wiz-border); border-left: 3px solid var(--wiz-amber);
  border-radius: 8px; padding: 16px 20px; margin-bottom: 24px;
  background: var(--wiz-surface);
}
.wiz-callout-amber .label { color: var(--wiz-amber); font-weight: 600; font-size: 13.5px; }
.wiz-callout-amber ul { margin-top: 8px; padding-left: 20px; color: var(--wiz-text-muted); font-size: 13px; line-height: 1.6; }

/* Right rail — "What I know so far" */
.wiz-rail {
  background: var(--wiz-bg); border-left: 1px solid var(--wiz-border);
  padding: 28px 24px; overflow-y: auto;
}
.wiz-rail-title { font-size: 11px; color: var(--wiz-text-muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; margin-bottom: 16px; }
.wiz-rail-card {
  background: var(--wiz-surface); border: 1px solid var(--wiz-border);
  border-radius: 8px; padding: 14px 16px; margin-bottom: 12px;
}
.wiz-rail-card.is-empty { color: var(--wiz-text-subtle); font-style: italic; font-size: 13px; }
.wiz-rail-card.is-explainer { background: transparent; border-style: dashed; }
.wiz-rail-card .l { font-size: 11px; color: var(--wiz-text-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; margin-bottom: 6px; }
.wiz-rail-card .v { font-size: 14px; color: var(--wiz-text); font-weight: 500; line-height: 1.4; }
.wiz-rail-card .sub { font-size: 11.5px; color: var(--wiz-text-muted); margin-top: 4px; }
.wiz-rail-card .body { font-size: 13px; color: var(--wiz-text-muted); line-height: 1.55; }
.wiz-rail-card .body strong { color: var(--wiz-text); font-weight: 600; }

/* Step 4 revenue line cards (R1/R2/W1/W2/W3/U1) */
.wiz-rev-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.wiz-rev-card {
  border: 1.5px solid var(--wiz-green);
  background: var(--wiz-surface); border-radius: 10px;
  padding: 14px 12px; text-align: left; cursor: pointer;
  transition: opacity 0.15s, border-color 0.15s;
  position: relative;
}
.wiz-rev-card.is-disabled { border-color: var(--wiz-border); opacity: 0.5; }
.wiz-rev-card.is-disabled .v { color: var(--wiz-text-subtle); }
.wiz-rev-card .id { font-size: 9.5px; color: var(--wiz-text-muted); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 4px; }
.wiz-rev-card .name { font-size: 13px; color: var(--wiz-text); font-weight: 600; margin-bottom: 8px; line-height: 1.25; }
.wiz-rev-card .v { font-size: 14px; color: var(--wiz-green); font-weight: 700; font-family: 'JetBrains Mono', monospace; line-height: 1.25; }
.wiz-rev-card .unit { font-size: 10px; color: var(--wiz-text-muted); margin-top: 4px; }
.wiz-rev-card.is-disabled .v { color: var(--wiz-text-subtle); }

/* M11i 2026-05-06: solver status was a black terminal-style box exposing
   raw MILP/HiGHS jargon. Customer-facing demo audience doesn't care about
   solver internals — they want plain-English progress. Switched to a
   clean light-surface panel with the same Inter font as the rest of the
   wizard. Old class kept for legacy back-compat. */
.wiz-solver-status, .wiz-solver-log {
  background: #f8fafc;
  border: 1px solid #e7e5e4;
  border-radius: 10px;
  padding: 16px 20px;
  font-size: 13.5px;
  color: #334155;
  line-height: 1.65;
  max-height: 360px;
  overflow-y: auto;
}
.wiz-solver-status .ok, .wiz-solver-log .ok { color: #15803d; font-weight: 500; }
.wiz-solver-status .err, .wiz-solver-log .err { color: #b91c1c; font-weight: 500; }
.wiz-solver-status .step, .wiz-solver-log .step {
  display: inline-block; min-width: 22px; height: 22px; border-radius: 50%;
  background: #e7e5e4; color: #57534e; text-align: center; font-size: 11px;
  font-weight: 600; margin-right: 8px; line-height: 22px;
}
.wiz-solver-status .timestamp, .wiz-solver-log .timestamp { display: none; }
/* M11i 2026-05-06: progress bar made tall + visibly filled + animated
   stripes during solve so user knows it's actually working. Old 6px-tall
   bar with single-color fill looked frozen — couldn't tell if it was
   moving or stuck. Stripe animation gives constant motion even when the
   percentage isn't ticking forward. */
.wiz-progress-bar {
  height: 14px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin: 18px 0 8px;
}
.wiz-progress-bar .fill {
  height: 100%;
  background: linear-gradient(
    45deg,
    #ea580c 25%, #fb923c 25%, #fb923c 50%,
    #ea580c 50%, #ea580c 75%, #fb923c 75%
  );
  background-size: 24px 24px;
  animation: wizProgressStripes 1.2s linear infinite;
  border-radius: 999px;
  transition: width 0.5s ease-out;
  box-shadow: 0 0 8px rgba(234, 88, 12, 0.4);
}
@keyframes wizProgressStripes {
  0% { background-position: 0 0; }
  100% { background-position: 24px 0; }
}
.wiz-solver-meta {
  display: flex; justify-content: space-between;
  font-size: 13px; color: #57534e;
  margin: 0 4px 14px; font-variant-numeric: tabular-nums;
}
.wiz-solver-meta strong { color: #18181b; font-weight: 600; }
/* M11i 2026-05-06: removed flat-amber override that was killing the striped
   accent fill above (was making the bar barely visible). */

/* Two-col grid for financials/equipment */
.wiz-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; max-width: 720px; }
.wiz-2col h4 { font-size: 11px; color: var(--wiz-amber); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; margin-bottom: 14px; }

/* Responsive */
@media (max-width: 1280px) {
  .wiz-grid { grid-template-columns: 240px 1fr 320px; }
  .wiz-main { padding: 28px 32px; }
}
@media (max-width: 1024px) {
  .wiz-grid { grid-template-columns: 1fr; }
  .wiz-sidebar, .wiz-rail { display: none; }
  .wiz-main { padding: 24px 20px; }
}
