/* Budget Builder — dark, premium, cutting-edge UI
   Class structure matches app.js exactly; this is a pure visual layer.
   Print styles (bottom) force a clean light look for the PDF export. */

:root {
  /* Surfaces */
  --bg: #070a10;
  --bg-2: #0b0f17;
  --panel: #10151f;
  --panel-2: #141b27;
  --elevate: #182231;
  --glass: rgba(22, 30, 44, 0.62);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);

  /* Text */
  --ink: #eaf1f8;
  --ink-soft: #b8c4d2;
  --muted: #7c8a9c;

  /* Accent — teal→cyan, fintech */
  --accent: #2dd4bf;
  --accent-2: #22d3ee;
  --accent-strong: #14b8a6;
  --accent-ink: #06231f;
  --accent-wash: rgba(45, 212, 191, 0.12);
  --accent-line: rgba(45, 212, 191, 0.30);
  --violet: #7c8cf8;

  /* Status */
  --danger: #f87171;
  --danger-wash: rgba(248, 113, 113, 0.12);
  --warning: #fbbf24;
  --warning-wash: rgba(251, 191, 36, 0.12);
  --good: #34d399;
  --good-wash: rgba(52, 211, 153, 0.12);

  /* Effects */
  --glow: 0 0 40px rgba(45, 212, 191, 0.28);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 40px 90px rgba(0, 0, 0, 0.7);
  --r-xl: 22px;
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 9px;
  --focus: 0 0 0 3px rgba(45, 212, 191, 0.4);

  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(900px 520px at -8% -12%, rgba(45, 212, 191, 0.16) 0, transparent 42%),
    radial-gradient(820px 480px at 108% -6%, rgba(124, 140, 248, 0.16) 0, transparent 42%),
    radial-gradient(1200px 700px at 50% 120%, rgba(34, 211, 238, 0.08) 0, transparent 50%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: rgba(45, 212, 191, 0.3); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); background-clip: content-box; }

.noscript {
  margin: 24px; padding: 18px;
  background: var(--danger-wash); border: 1px solid rgba(248, 113, 113, 0.4); border-radius: var(--r-md);
}

/* ---------- Layout ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  gap: 22px;
  padding: 22px;
  max-width: 1320px;
  margin: 0 auto;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 22px;
  height: calc(100vh - 44px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 20px;
  box-shadow: var(--shadow);
}

.brand-block { display: flex; gap: 12px; align-items: center; }
.logo-mark {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  color: var(--accent-ink); font-weight: 800; font-size: 22px;
  box-shadow: 0 8px 22px rgba(45, 212, 191, 0.45);
}
.brand-text h1 { font-size: 1.02rem; letter-spacing: -0.01em; }

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.68rem;
  color: var(--accent);
  font-weight: 700;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.14; letter-spacing: -0.02em; }
h1 { font-size: 1.05rem; }
h2 { font-size: clamp(1.5rem, 3.4vw, 2.15rem); }
h3 { font-size: 1.24rem; }
h4 { font-size: 1rem; }
p { line-height: 1.55; }

/* ---------- Sidebar nav ---------- */
.step-nav { display: grid; gap: 4px; }
.nav-phase {
  margin: 12px 0 3px;
  font-size: 0.64rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted);
  padding-left: 4px;
}
.nav-phase:first-child { margin-top: 0; }
.step-button {
  width: 100%;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.93rem;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.step-button:hover { background: rgba(255, 255, 255, 0.04); color: var(--ink); }
.step-button.active {
  background: var(--accent-wash);
  border-color: var(--accent-line);
  color: #eafffb;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.08);
}
.step-dot {
  width: 22px; height: 22px; display: grid; place-items: center;
  border-radius: 999px; background: rgba(255, 255, 255, 0.06); color: var(--muted);
  font-size: 0.72rem; font-weight: 800;
}
.step-button.active .step-dot { background: linear-gradient(150deg, var(--accent), var(--accent-2)); color: var(--accent-ink); }
.step-button.done .step-dot { background: var(--good-wash); color: var(--good); }
.step-check { font-size: 0.82rem; color: var(--accent); font-weight: 900; }

/* ---------- Sidebar snapshot ---------- */
.sidebar-snapshot {
  display: grid; gap: 8px;
  padding: 14px;
  border-radius: var(--r-lg);
  background: linear-gradient(160deg, rgba(45, 212, 191, 0.1), rgba(124, 140, 248, 0.06));
  border: 1px solid var(--accent-line);
}
.snap-title { font-size: 0.66rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.snap-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.snap-row span { color: var(--muted); font-size: 0.82rem; }
.snap-row strong { font-size: 0.98rem; font-variant-numeric: tabular-nums; color: var(--ink); }
.snap-row strong.neg { color: var(--danger); }
.snap-row strong.pos { color: var(--good); }

.sidebar-actions { display: grid; gap: 7px; margin-top: auto; }
.save-status {
  margin: 0;
  padding: 8px 11px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

/* ---------- Main panel ---------- */
.main-panel { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
  margin: 2px 0 14px;
}
.topbar-actions, .footer-nav, .button-row {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
}
.progress-wrap {
  width: 100%; height: 6px; background: rgba(255, 255, 255, 0.05); border-radius: 999px; overflow: hidden; margin-bottom: 18px;
  border: 1px solid var(--line);
}
.progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: inherit;
  box-shadow: 0 0 18px rgba(45, 212, 191, 0.7);
  transition: width 300ms cubic-bezier(.22,.61,.36,1);
}
.content-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)) , var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  padding: clamp(20px, 3vw, 38px);
  flex: 1;
}
.footer-nav { justify-content: space-between; margin-top: 18px; }

/* ---------- Buttons ---------- */
.primary-button, .secondary-button, .ghost-button, .small-button {
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 10px 20px;
  font-weight: 700;
  font-size: 0.94rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 90ms ease, background 140ms ease, box-shadow 160ms ease, border-color 140ms ease;
}
.primary-button {
  background: linear-gradient(150deg, var(--accent), var(--accent-strong));
  color: var(--accent-ink);
  box-shadow: 0 8px 24px rgba(45, 212, 191, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.primary-button:hover { box-shadow: 0 10px 32px rgba(45, 212, 191, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.25); transform: translateY(-1px); }
.primary-button:active { transform: translateY(0); }
.secondary-button { background: rgba(255, 255, 255, 0.05); color: var(--ink); border-color: var(--line-strong); }
.secondary-button:hover { background: rgba(255, 255, 255, 0.09); border-color: var(--accent-line); }
.ghost-button { background: transparent; color: var(--ink-soft); border-color: var(--line); width: 100%; font-weight: 600; font-size: 0.88rem; min-height: 40px; }
.ghost-button:hover { background: rgba(255, 255, 255, 0.04); color: var(--ink); border-color: var(--line-strong); }
.ghost-button.danger { color: var(--danger); }
.ghost-button.danger:hover { background: var(--danger-wash); border-color: rgba(248, 113, 113, 0.4); }
.small-button {
  min-height: 36px; padding: 7px 14px; border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.04); color: var(--ink); font-size: 0.86rem; font-weight: 600;
}
.small-button:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--accent-line); }
.small-button.danger { color: var(--danger); border-color: rgba(248, 113, 113, 0.3); }
.small-button.danger:hover { background: var(--danger-wash); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
.import-label { cursor: pointer; }

/* ---------- Content primitives ---------- */
.stack { display: grid; gap: 18px; }
.stack-sm { display: grid; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.section-intro { color: var(--muted); max-width: 72ch; margin-top: 7px; }
.divider { height: 1px; background: var(--line); margin: 6px 0; }
.tiny { font-size: 0.82rem; }
.muted { color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 5px 12px;
  font-weight: 700; font-size: 0.74rem; letter-spacing: 0.01em;
  background: var(--accent-wash); color: var(--accent); border: 1px solid var(--accent-line);
}
.badge.warn { background: var(--warning-wash); color: var(--warning); border-color: rgba(251, 191, 36, 0.35); }
.badge.danger { background: var(--danger-wash); color: var(--danger); border-color: rgba(248, 113, 113, 0.35); }
.badge.good { background: var(--good-wash); color: var(--good); border-color: rgba(52, 211, 153, 0.35); }

.pill-hint {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.82rem; color: var(--muted);
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; width: fit-content;
}

/* Callouts */
.help-box, .warning-box, .good-box, .callout {
  border-radius: var(--r-lg); padding: 15px 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03);
  font-size: 0.92rem; line-height: 1.5; color: var(--ink-soft);
}
.help-box { background: var(--accent-wash); border-color: var(--accent-line); color: #c9fff5; }
.warning-box { background: var(--warning-wash); border-color: rgba(251, 191, 36, 0.35); color: #fde8bf; }
.good-box { background: var(--good-wash); border-color: rgba(52, 211, 153, 0.35); color: #c5f6e2; }
.help-box strong, .warning-box strong, .good-box strong, .callout strong { display: block; margin-bottom: 4px; color: var(--ink); }
.callout { text-align: center; padding: 28px; }
.callout .emoji { font-size: 1.8rem; display: block; margin-bottom: 8px; filter: drop-shadow(0 4px 12px rgba(45, 212, 191, 0.3)); }
.callout strong { color: var(--ink); }

.reassure { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 0.88rem; }
.reassure::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: var(--accent); box-shadow: 0 0 10px var(--accent); flex: none; }

/* ---------- Forms ---------- */
.form-field { display: grid; gap: 6px; }
.form-field label { font-weight: 700; font-size: 0.94rem; color: var(--ink); }
.form-field .hint { color: var(--muted); font-size: 0.86rem; line-height: 1.4; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 11px 13px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--ink);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
input::placeholder, textarea::placeholder { color: #566172; }
input:hover, select:hover, textarea:hover { border-color: rgba(255, 255, 255, 0.22); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--focus); outline: none; background: rgba(255, 255, 255, 0.05); }
select option { background: var(--panel-2); color: var(--ink); }
textarea { min-height: 92px; resize: vertical; }
.input-prefix { position: relative; }
.input-prefix > span {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-weight: 600; pointer-events: none;
}
.input-prefix input { padding-left: 26px; }
input[type="checkbox"] { width: auto; transform: scale(1.2); accent-color: var(--accent); }
.checkbox-row { display: flex; gap: 11px; align-items: flex-start; }
.checkbox-row label { font-weight: 600; }

/* Optional-detail drawer */
details.drawer {
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 0 14px; background: rgba(255, 255, 255, 0.02);
}
details.drawer > summary {
  cursor: pointer; list-style: none; padding: 12px 0;
  font-weight: 600; font-size: 0.9rem; color: var(--ink-soft);
  display: flex; align-items: center; gap: 8px;
}
details.drawer > summary::-webkit-details-marker { display: none; }
details.drawer > summary::before { content: "＋"; color: var(--accent); font-weight: 800; }
details.drawer[open] > summary::before { content: "－"; }
details.drawer > .drawer-body { padding: 0 0 14px; display: grid; gap: 14px; }

/* ---------- Item cards ---------- */
.item-card {
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)) , var(--panel-2);
  box-shadow: var(--shadow-sm);
}
.item-card-header {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px;
}
.item-card-title { display: grid; gap: 3px; }
.item-card-title h4 { color: var(--ink); }
.item-card-title p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.item-card-title strong { color: var(--accent); }

/* ---------- Cost picker chips + compact cost rows ---------- */
.chip-picker { display: grid; gap: 10px; }
.chip-picker-label { font-weight: 700; font-size: 0.94rem; color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.04);
  color: var(--ink-soft); border-radius: 999px; padding: 8px 14px;
  font-size: 0.88rem; font-weight: 600; min-height: 40px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.chip:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--accent-line); color: var(--ink); }
.chip.on {
  background: var(--accent-wash); border-color: var(--accent-line); color: #eafffb;
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.12);
}
.chip.add { border-style: dashed; color: var(--accent); }
.chip.add:hover { background: var(--accent-wash); }

.cost-rows { display: grid; gap: 10px; }
.cost-row {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--panel-2); padding: 8px 12px;
}
.cost-row-main { display: flex; align-items: center; gap: 10px; }
.cost-row-name {
  flex: 1 1 auto; min-width: 0;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-sm);
  font-weight: 600; padding: 8px 10px;
}
.cost-row-name:hover { border-color: var(--line-strong); }
.cost-row-value { display: flex; align-items: center; gap: 6px; flex: none; }
.cost-row-value .input-prefix input { width: 112px; }
.cost-row-value .input-prefix.pct input { width: 92px; }
.cost-row-unit { color: var(--muted); font-size: 0.86rem; }
.cost-row-varies { color: var(--ink-soft); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.cost-row-remove {
  flex: none; width: 32px; height: 32px; border-radius: 999px;
  border: 1px solid transparent; background: transparent; color: var(--muted);
  font-size: 0.9rem; line-height: 1;
}
.cost-row-remove:hover { background: var(--danger-wash); color: var(--danger); }
.cost-row-more { border: 0; padding: 0; background: transparent; margin-top: 2px; }
.cost-row-more > summary { padding: 6px 0 2px; font-size: 0.82rem; }

/* Segmented (simple / month-by-month) control */
.segmented {
  display: inline-flex; padding: 3px; gap: 3px;
  background: rgba(255, 255, 255, 0.04); border-radius: 999px; border: 1px solid var(--line);
}
.seg {
  border: 0; background: transparent; color: var(--muted);
  padding: 6px 14px; border-radius: 999px; font-size: 0.84rem; font-weight: 700;
  transition: background 140ms ease, color 140ms ease;
}
.seg.active { background: linear-gradient(150deg, var(--accent), var(--accent-strong)); color: var(--accent-ink); box-shadow: 0 4px 14px rgba(45, 212, 191, 0.35); }
.entry-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.entry-head .label { font-weight: 700; font-size: 0.94rem; color: var(--ink); }

/* Month grid */
.month-grid {
  display: grid; grid-template-columns: repeat(12, minmax(66px, 1fr));
  gap: 8px; overflow-x: auto; padding-bottom: 6px;
}
.month-cell { min-width: 66px; display: grid; gap: 4px; }
.month-cell label { font-size: 0.72rem; color: var(--muted); font-weight: 700; }
.month-cell input { padding: 8px 7px; border-radius: 9px; text-align: right; }
.quick-fill { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin: 4px 0 12px; }
.quick-fill .form-field { min-width: 180px; }

/* ---------- Seasonal month strip ---------- */
.season-strip { margin: 6px 0 2px; }
.season-months {
  display: grid; grid-template-columns: repeat(12, minmax(52px, 1fr));
  gap: 6px; overflow-x: auto; padding-bottom: 4px;
}
.season-cell {
  display: grid; gap: 3px; padding: 8px 4px; min-width: 52px; text-align: center;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.03); color: var(--ink-soft);
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.season-cell:hover { border-color: var(--accent-line); }
.season-m { font-size: 0.7rem; font-weight: 700; color: var(--muted); }
.season-s { font-size: 0.72rem; font-weight: 800; }
.season-cell.busy { background: var(--good-wash); border-color: rgba(52, 211, 153, 0.4); color: var(--good); }
.season-cell.busy .season-m { color: var(--good); }
.season-cell.quiet { background: var(--warning-wash); border-color: rgba(251, 191, 36, 0.4); color: var(--warning); }
.season-cell.quiet .season-m { color: var(--warning); }

/* ---------- KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpi-card {
  position: relative; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)) , var(--panel-2);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.kpi-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent); opacity: 0.5;
}
.kpi-card p { margin: 0 0 6px; color: var(--muted); font-size: 0.86rem; }
.kpi-card strong { display: block; font-size: clamp(1.2rem, 2.6vw, 1.7rem); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; color: var(--ink); }
.kpi-card.negative strong { color: var(--danger); }
.kpi-card.negative::before { background: linear-gradient(90deg, var(--danger), transparent); }
.kpi-card.positive strong { color: var(--good); }
.kpi-card.positive::before { background: linear-gradient(90deg, var(--good), transparent); }
.kpi-card .sub { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel-2); }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--panel-2); z-index: 1; }
th { background: rgba(255, 255, 255, 0.03); font-size: 0.82rem; color: var(--ink-soft); font-weight: 700; }
td { font-size: 0.9rem; color: var(--ink-soft); }
tbody tr:hover td { background: rgba(255, 255, 255, 0.03); }
tbody tr:hover td:first-child { background: var(--elevate); }
tr:last-child td { border-bottom: 0; }
.negative { color: var(--danger); }
.positive { color: var(--good); }
.row-emph td { font-weight: 700; color: var(--ink); background: rgba(45, 212, 191, 0.05); }
.row-emph:hover td { background: rgba(45, 212, 191, 0.08); }

/* ---------- Chart ---------- */
.chart-card {
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.05), rgba(255, 255, 255, 0)) , var(--panel-2);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.chart-card h4 { margin-bottom: 10px; color: var(--ink); }
.chart-card svg { width: 100%; height: auto; display: block; }
.chart-axis { stroke: rgba(255, 255, 255, 0.14); stroke-width: 1; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; filter: drop-shadow(0 0 8px rgba(45, 212, 191, 0.6)); }
.chart-fill { fill: rgba(45, 212, 191, 0.14); }
.chart-zero { stroke: var(--warning); stroke-width: 1.4; stroke-dasharray: 5 5; opacity: 0.7; }
.chart-label { font-size: 11px; fill: var(--muted); }
.chart-marker-line { stroke: rgba(124, 140, 248, 0.5); stroke-width: 1; stroke-dasharray: 3 4; }
.chart-marker-dot { fill: none; stroke: var(--violet); stroke-width: 2.5; }
.chart-marker-label { font-size: 11px; font-weight: 700; fill: var(--violet); }

/* ---------- Insights ---------- */
.insights-card {
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(129, 140, 248, 0.07), rgba(255, 255, 255, 0)) , var(--panel-2);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.insights-card h4 { margin-bottom: 8px; color: var(--ink); }
.insight-narrative { color: var(--ink-soft); max-width: 74ch; line-height: 1.6; margin: 0 0 14px; }
.insights-kpis { margin-top: 4px; }

/* ---------- Suggested next step ---------- */
.next-step {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  border: 1px solid var(--accent-line); border-radius: var(--r-lg);
  background: linear-gradient(160deg, rgba(45, 212, 191, 0.08), rgba(124, 140, 248, 0.05));
  padding: 14px 16px;
}
.next-step-body { min-width: 0; flex: 1 1 320px; }
.next-step-eyebrow {
  display: block; margin-bottom: 4px;
  font-size: 0.66rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent);
}
.next-step p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; max-width: 70ch; }
.next-step button { flex: none; }

/* ---------- What-if sliders ---------- */
.whatif-card {
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.06), rgba(255, 255, 255, 0)) , var(--panel-2);
  padding: 18px; box-shadow: var(--shadow-sm); display: grid; gap: 14px;
}
.whatif-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.whatif-head h4 { color: var(--ink); }
.whatif-slider { display: grid; gap: 8px; }
.whatif-slider label { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-weight: 600; font-size: 0.9rem; color: var(--ink-soft); }
.whatif-val { color: var(--accent); font-weight: 800; font-variant-numeric: tabular-nums; }
.whatif-card input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; padding: 0;
  background: linear-gradient(90deg, var(--accent-wash), rgba(124, 140, 248, 0.18));
  border: 1px solid var(--line-strong); border-radius: 999px;
}
.whatif-card input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 999px;
  background: linear-gradient(150deg, var(--accent), var(--accent-2)); border: 2px solid var(--bg-2);
  box-shadow: 0 4px 14px rgba(45, 212, 191, 0.5); cursor: grab;
}
.whatif-card input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 999px; border: 2px solid var(--bg-2);
  background: var(--accent); box-shadow: 0 4px 14px rgba(45, 212, 191, 0.5); cursor: grab;
}
.whatif-out { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.whatif-metric { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.whatif-metric span { color: var(--muted); font-size: 0.88rem; }
.whatif-metric strong { font-variant-numeric: tabular-nums; font-size: 1rem; }
.whatif-metric strong.neg { color: var(--danger); }
.whatif-metric strong.pos { color: var(--good); }
.whatif-from { color: var(--muted); font-weight: 500; text-decoration: line-through; }

/* ---------- Review ---------- */
.review-list { display: grid; gap: 10px; }
.review-item {
  display: grid; grid-template-columns: 30px 1fr; gap: 12px;
  padding: 14px; border-radius: var(--r-md); background: var(--panel-2); border: 1px solid var(--line);
}
.review-item strong { color: var(--ink); }
.review-item .icon {
  width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center;
  font-weight: 900; font-size: 0.9rem; color: #06120e;
}
.review-item.good { border-color: rgba(52, 211, 153, 0.28); }
.review-item.good .icon { background: var(--good); }
.review-item.warn { border-color: rgba(251, 191, 36, 0.28); }
.review-item.warn .icon { background: var(--warning); }
.review-item.danger { border-color: rgba(248, 113, 113, 0.28); }
.review-item.danger .icon { background: var(--danger); color: #2a0b0b; }

/* ---------- Hero (welcome) ---------- */
.hero { display: grid; gap: 22px; }
.hero-top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(240px, 0.75fr); gap: 26px; align-items: center; }
.hero h3 {
  font-size: clamp(1.7rem, 4.4vw, 2.9rem); line-height: 1.06;
  background: linear-gradient(120deg, #ffffff 0%, #c7fff4 45%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
}
.hero-copy p { max-width: 60ch; color: var(--ink-soft); font-size: 1.02rem; }
.hero-panel {
  background: linear-gradient(160deg, rgba(45, 212, 191, 0.1), rgba(124, 140, 248, 0.06));
  border: 1px solid var(--accent-line); border-radius: var(--r-lg); padding: 20px; display: grid; gap: 12px;
}
.hero-panel h4 { color: var(--accent); }
.hero-panel .snap-row span { color: var(--ink-soft); font-size: 0.92rem; }
.feature-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.feature {
  padding: 18px; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--panel-2); transition: transform 160ms ease, border-color 160ms ease;
}
.feature:hover { transform: translateY(-3px); border-color: var(--accent-line); }
.feature .emoji { font-size: 1.4rem; filter: drop-shadow(0 4px 10px rgba(45, 212, 191, 0.35)); }
.feature strong { display: block; margin: 8px 0 3px; color: var(--ink); }
.feature p { margin: 0; color: var(--muted); font-size: 0.88rem; }

/* ---------- Guided tour ---------- */
.tour-overlay { position: fixed; inset: 0; z-index: 900; display: none; }
.tour-overlay.show { display: block; }
.tour-spot {
  position: absolute; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(3, 6, 11, 0.78), 0 0 0 1px var(--accent), 0 0 30px rgba(45, 212, 191, 0.5);
  border: 1px solid var(--accent);
  transition: all 260ms cubic-bezier(.22,.61,.36,1);
}
.tour-banner {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 902; pointer-events: none;
  display: flex; align-items: center; gap: 9px;
  max-width: calc(100vw - 32px);
  padding: 9px 16px; border-radius: 999px;
  background: rgba(20, 27, 39, 0.92); backdrop-filter: blur(10px);
  border: 1px solid var(--accent-line);
  color: var(--ink); font-size: 0.84rem; font-weight: 600;
  box-shadow: var(--shadow-lg);
}
.tour-banner.hidden { display: none; }
.tour-banner-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--accent); box-shadow: 0 0 10px var(--accent); flex: none; }
.tour-banner-text { min-width: 0; }
.tour-banner-close {
  pointer-events: auto; flex: none;
  margin: -2px -6px -2px 2px; border: 0; background: transparent;
  color: var(--muted); font-size: 0.82rem; line-height: 1; font-weight: 700;
  padding: 6px 8px; border-radius: 999px; cursor: pointer;
}
.tour-banner-close:hover { background: rgba(255, 255, 255, 0.12); color: var(--ink); }

.tour-tip {
  position: absolute; width: min(360px, calc(100vw - 32px));
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)) , var(--elevate);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  padding: 18px; z-index: 901;
}
.tour-tip-head {
  display: flex; align-items: center; gap: 7px;
  margin: -4px -4px 8px; padding: 4px 6px;
  cursor: grab; user-select: none; touch-action: none;
  color: var(--muted); font-size: 0.76rem; font-weight: 600;
  border-radius: 8px;
}
.tour-tip-head:hover { background: rgba(255, 255, 255, 0.05); color: var(--ink-soft); }
.tour-tip-head:active { cursor: grabbing; }
.tour-grip { letter-spacing: -2px; font-size: 0.9rem; line-height: 1; color: var(--accent); }
.tour-tip h4 { margin-bottom: 6px; color: var(--ink); }
.tour-tip p { color: var(--ink-soft); font-size: 0.94rem; margin: 0 0 14px; }
.tour-tip .tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tour-dots { display: flex; gap: 5px; }
.tour-dots i { width: 7px; height: 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.18); display: block; transition: background 160ms ease; }
.tour-dots i.on { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.tour-btns { display: flex; gap: 8px; }
.tour-skip { position: absolute; top: 12px; right: 14px; background: none; border: 0; color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.tour-skip:hover { color: var(--ink); }

/* ---------- Modal ---------- */
.modal-root { position: fixed; inset: 0; z-index: 1000; display: none; }
.modal-root.show { display: block; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(3, 6, 11, 0.7); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 20px;
  animation: fade 160ms ease;
}
.modal {
  width: min(460px, 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0)) , var(--elevate);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); padding: 26px;
  animation: pop 200ms cubic-bezier(.22,.61,.36,1);
}
.modal h3 { margin-bottom: 10px; color: var(--ink); }
.modal-body { color: var(--ink-soft); font-size: 0.96rem; line-height: 1.55; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Quick setup interview ---------- */
.modal.interview { width: min(560px, 100%); }
.interview-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.interview-top .tour-skip { position: static; }
.interview-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 6px; }
.interview-option {
  display: grid; gap: 3px; text-align: left; padding: 14px 16px; min-height: 62px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.03); color: var(--ink);
  transition: background 140ms ease, border-color 140ms ease, transform 90ms ease;
}
.interview-option:hover { border-color: var(--accent-line); background: var(--accent-wash); transform: translateY(-1px); }
.interview-option strong { font-size: 0.98rem; color: var(--ink); }
.interview-option span { color: var(--muted); font-size: 0.82rem; }

/* "Add a section" affordance in the nav for hidden sell steps */
.nav-add { margin-top: 12px; display: grid; gap: 6px; }
.nav-add-btn {
  width: 100%; text-align: left; padding: 8px 11px;
  border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  background: transparent; color: var(--muted); font-size: 0.86rem; font-weight: 600;
}
.nav-add-btn:hover { color: var(--accent); border-color: var(--accent-line); background: var(--accent-wash); }

/* ---------- Toast ---------- */
.toast-root { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 1100; display: grid; gap: 8px; }
.toast {
  background: var(--elevate); color: var(--ink); padding: 12px 18px; border-radius: 999px;
  font-size: 0.9rem; font-weight: 600; box-shadow: var(--shadow-lg);
  border: 1px solid var(--accent-line);
  opacity: 0; transform: translateY(10px); transition: opacity 240ms ease, transform 240ms ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }

/* Subtle page transitions between steps (only on real navigation) */
@keyframes pageFwd { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pageBack { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
.content-card.page-fwd { animation: pageFwd 300ms cubic-bezier(.22,.61,.36,1); }
.content-card.page-back { animation: pageBack 300ms cubic-bezier(.22,.61,.36,1); }

/* ---------- Mobile sticky bar + nav toggle (hidden on desktop) ---------- */
.mobile-bar { display: none; }
.nav-toggle { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 1fr; padding: 12px; padding-bottom: 88px; gap: 12px; }

  /* Sidebar becomes a slim sticky top bar; the step list and actions collapse behind a toggle,
     so the content of the current step is the first thing on screen, not a wall of navigation. */
  .sidebar {
    position: sticky; top: 0; z-index: 700; height: auto; overflow: visible;
    flex-direction: column; gap: 0; padding: 12px 14px;
    background: rgba(11, 15, 23, 0.96);
    border-radius: var(--r-lg);
  }
  body.nav-open .sidebar { max-height: calc(100vh - 24px); overflow-y: auto; }
  .brand-block { align-items: center; }
  .brand-text h1 { font-size: 0.98rem; }
  .nav-toggle {
    display: inline-flex; align-items: center; gap: 6px; margin-left: auto;
    min-height: 40px; padding: 8px 14px; border-radius: 999px;
    border: 1px solid var(--line-strong); background: rgba(255, 255, 255, 0.05);
    color: var(--ink); font-weight: 700; font-size: 0.88rem;
  }
  .nav-toggle-caret { transition: transform 160ms ease; }
  body.nav-open .nav-toggle-caret { transform: rotate(180deg); }

  /* Collapsed by default; revealed when the menu is open. */
  .step-nav, .sidebar-actions { display: none; }
  body.nav-open .step-nav { display: grid; grid-template-columns: 1fr; gap: 4px; margin-top: 12px; }
  body.nav-open .sidebar-actions { display: grid; gap: 7px; margin-top: 12px; }
  .nav-phase { grid-column: 1 / -1; }

  /* The fixed sticky bottom bar carries the live numbers, so hide the sidebar snapshot + save line. */
  .sidebar-snapshot, .save-status { display: none; }
  /* Exports live on the Results page on mobile; drop them from the top bar to save space. */
  .topbar-actions { display: none; }
  .topbar { margin-bottom: 10px; }

  .hero-top { grid-template-columns: 1fr; }
  .feature-row { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .kpi-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }

  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 800;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    background: rgba(11, 15, 23, 0.94);
    backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
    border-top: 1px solid var(--accent-line);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
  }
  .mobile-bar-stats { display: flex; gap: 16px; min-width: 0; flex-wrap: wrap; align-items: baseline; }
  .mobile-bar-stats span { color: var(--muted); font-size: 0.82rem; }
  .mobile-bar-stats strong { color: var(--ink); font-variant-numeric: tabular-nums; font-size: 0.98rem; }
  .mobile-bar-stats strong.neg { color: var(--danger); }
  .mobile-bar-stats strong.pos { color: var(--good); }
  .mobile-bar .primary-button { flex: none; min-height: 42px; padding: 9px 22px; }
}
@media (max-width: 620px) {
  .step-nav { grid-template-columns: 1fr; }
  .interview-options { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .topbar-actions { width: 100%; }
  .topbar-actions button { flex: 1 1 auto; }
  .kpi-grid { grid-template-columns: 1fr; }
  .content-card { padding: 18px; }
  /* Bigger touch targets and clearer horizontal-scroll hints on phones. */
  .cost-row-remove { width: 38px; height: 38px; }
  .season-cell { min-width: 58px; }
  .month-grid, .season-months, .table-wrap { scrollbar-width: thin; }
  .footer-nav .primary-button, .footer-nav .secondary-button { flex: 1 1 auto; }
  .button-row .primary-button, .button-row .secondary-button { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ---------- Print (PDF summary) — force clean light look ---------- */
.print-only { display: none; }
@media print {
  :root { color-scheme: light; }
  body { background: #fff !important; color: #111 !important; }
  .sidebar, .topbar, .progress-wrap, .footer-nav, .no-print, .tour-overlay, .modal-root, .toast-root, .mobile-bar { display: none !important; }
  .app-shell { display: block; padding: 0; max-width: none; }
  .content-card { box-shadow: none; border: 0; padding: 0; background: #fff !important; }
  .print-only { display: block; }

  h1, h2, h3, h4, .item-card-title h4, .kpi-card strong, .modal h3, strong { color: #111 !important; -webkit-text-fill-color: #111 !important; }
  .hero h3 { background: none !important; -webkit-text-fill-color: #111 !important; color: #111 !important; }
  p, td, .section-intro, .muted, .kpi-card p, .snap-row span, .insight-narrative { color: #333 !important; }
  .kpi-card, .item-card, .chart-card, .table-wrap, .help-box, .warning-box, .good-box, .review-item, .insights-card {
    background: #fff !important; border-color: #ccc !important; box-shadow: none !important;
  }
  .kpi-card::before { display: none; }
  .badge { border-color: #bbb !important; color: #111 !important; background: #f2f2f2 !important; }
  th { background: #f2f2f2 !important; color: #111 !important; }
  th:first-child, td:first-child { background: #fff !important; }
  .chart-line { stroke: #0b7d73 !important; filter: none !important; }
  .chart-fill { fill: rgba(13, 148, 136, 0.12) !important; }
  .chart-label, .chart-axis { fill: #555 !important; stroke: #999 !important; }
  .chart-marker-line { stroke: #aaa !important; }
  .chart-marker-dot { stroke: #555 !important; }
  .chart-marker-label { fill: #333 !important; }

  /* Bank-ready cover block at the top of the printed forecast. */
  .print-cover { border-bottom: 2px solid #111 !important; padding-bottom: 12px !important; margin-bottom: 8px !important; }
  .print-cover h2 { font-size: 20pt; margin-bottom: 4px; }
  .print-cover p { margin: 2px 0; color: #333 !important; }
  .print-cover-meta { font-size: 10pt; color: #666 !important; }
  .negative { color: #b42318 !important; }
  .positive { color: #157347 !important; }
  .table-wrap { border: 0; overflow: visible; }
  table { min-width: 0; font-size: 10pt; }
  th, td { padding: 5px 6px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-card, .kpi-card, .item-card, .insights-card { break-inside: avoid; }
}
