:root {
  color-scheme: light dark;
  --background: light-dark(#f5f7f5, #111412);
  --foreground: light-dark(#152019, #f6faf7);
  --muted-foreground: light-dark(#607068, #9eaaa3);
  --card: light-dark(#ffffff, #1c211e);
  --border: light-dark(#dce4df, #303833);
  --input: light-dark(#eef2ef, #282e2a);
  --primary: light-dark(#176a46, #72d3a3);
  --primary-foreground: light-dark(#ffffff, #092418);
  --accent: light-dark(#e1f4e9, #163c2b);
  --danger: light-dark(#a43c30, #ff9a8e);
  --series-1: light-dark(#239062, #72d3a3);
  --series-2: light-dark(#e1833d, #f3a569);
  --series-3: light-dark(#4f83d1, #84acf0);
  --shadow: 0 16px 48px light-dark(rgb(25 45 34 / 8%), rgb(0 0 0 / 22%));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--background);
  color: var(--foreground);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--background); }
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.page-shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 48px 0 64px; }
.hero { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end; margin-bottom: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-size: .74rem; letter-spacing: .13em; font-weight: 500; }
h1, h2 { margin: 0; font-weight: 500; letter-spacing: -.025em; }
h1 { max-width: 680px; font-size: clamp(2rem, 5vw, 3.8rem); line-height: 1.02; }
h2 { font-size: 1.2rem; }
p { line-height: 1.5; }
.hero-copy { max-width: 62ch; margin: 12px 0 0; color: var(--muted-foreground); }
.session-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted-foreground); background: var(--card); font-size: .8rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-foreground); }
.status-pill[data-state="synced"] .status-dot { background: var(--series-1); }
.status-pill[data-state="saving"] .status-dot { background: var(--series-2); }
.status-pill[data-state="offline"] .status-dot { background: var(--danger); }
.card { padding: 20px; border: 1px solid var(--border); border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.gate { max-width: 640px; margin: 56px auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: center; padding: 28px; }
.gate-copy p:last-child { margin-bottom: 0; color: var(--muted-foreground); }
.gate-form { display: grid; gap: 12px; }
.form-label { display: grid; gap: 7px; color: var(--muted-foreground); font-size: .86rem; }
.form-control { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--input); color: var(--foreground); }
.form-control:focus-visible, .button:focus-visible, input[type="range"]:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 2px; }
.button { min-height: 38px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); cursor: pointer; }
.button:hover { background: var(--accent); }
.button-primary { border-color: var(--primary); background: var(--primary); color: var(--primary-foreground); }
.button-primary:hover { background: color-mix(in srgb, var(--primary) 88%, var(--foreground)); }
.button-ghost { background: transparent; }
.button-block { width: 100%; }
.form-hint, .form-message, .section-head p, .footer-note, .chart-note, .stat small { margin: 0; color: var(--muted-foreground); font-size: .8rem; }
.warning { margin: 0; color: var(--danger); font-size: .82rem; }
.success-message { margin: 0; color: var(--primary); }
.form-message.error { color: var(--danger); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { display: grid; gap: 5px; }
.stat > span { color: var(--muted-foreground); font-size: .82rem; }
.stat strong { font-size: 1.55rem; font-weight: 500; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; }
.section-head, .progress-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.section-head { margin-bottom: 18px; }
.section-head p { margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.money-field { position: relative; display: flex; align-items: center; }
.money-field > span { position: absolute; left: 12px; color: var(--muted-foreground); pointer-events: none; }
.money-field .form-control { padding-left: 29px; }
.money-field.suffix > span { left: auto; right: 12px; }
.money-field.suffix .form-control { padding-left: 11px; padding-right: 30px; }
#plan-message, #split-message, #safety-note { margin-top: 14px; }
.checklist { display: grid; gap: 13px; }
.check-row { display: flex; gap: 11px; align-items: flex-start; cursor: pointer; }
.check-row input { margin-top: 3px; accent-color: var(--primary); }
.check-row span { font-size: .9rem; }
.check-row small { display: block; margin-top: 3px; color: var(--muted-foreground); }
.allocation-bar { display: flex; height: 14px; overflow: hidden; border-radius: 999px; background: var(--input); }
.allocation-bar span:nth-child(1) { background: var(--series-1); }
.allocation-bar span:nth-child(2) { background: var(--series-2); }
.allocation-bar span:nth-child(3) { background: var(--series-3); }
.allocation-values { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 18px; }
.allocation-values div { min-width: 0; }
.allocation-values span { display: flex; align-items: center; gap: 7px; color: var(--muted-foreground); font-size: .8rem; }
.allocation-values strong { display: block; margin-top: 5px; font-weight: 500; }
.swatch { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }
.swatch.safety { background: var(--series-1); }.swatch.debt { background: var(--series-2); }.swatch.life { background: var(--series-3); }
.range-list { display: grid; gap: 12px; }
.range-list label > span { display: flex; justify-content: space-between; font-size: .85rem; }
.range-list b, .range-list em { font-style: normal; font-weight: 400; }
.range-list em { color: var(--muted-foreground); }
input[type="range"] { width: 100%; margin: 8px 0 0; accent-color: var(--primary); }
.progress-head { margin-bottom: 9px; font-size: .9rem; }
.progress-head strong { font-weight: 500; }.progress-head span { color: var(--muted-foreground); }
.progress-track { height: 11px; overflow: hidden; border-radius: 999px; background: var(--input); }
.progress-track div { width: 0; height: 100%; border-radius: inherit; background: var(--series-1); transition: width .2s ease; }
.chart-wrap { position: relative; }
#debt-chart { display: block; width: 100%; height: auto; min-height: 240px; }
#chart-grid line { stroke: var(--border); stroke-width: 1; }
#chart-labels text { fill: var(--muted-foreground); font-size: 12px; }
#chart-area { fill: var(--series-1); opacity: .14; }
#chart-line { fill: none; stroke: var(--series-1); stroke-width: 3; vector-effect: non-scaling-stroke; }
#chart-dot { fill: var(--series-1); stroke: var(--card); stroke-width: 2; }
#chart-empty { display: none; min-height: 240px; place-items: center; margin: 0; color: var(--muted-foreground); text-align: center; }
.chart-note { display: flex; justify-content: space-between; gap: 12px; }
.footer-note { margin: 20px 0 0; text-align: center; }
dialog { width: min(480px, calc(100% - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 18px; background: var(--card); color: var(--foreground); box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(0 0 0 / 55%); }
.dialog-content { display: grid; gap: 15px; padding: 24px; }
.dialog-content p { margin: 6px 0 0; color: var(--muted-foreground); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 760px) {
  .page-shell { width: min(100% - 24px, 680px); padding-top: 28px; }
  .hero, .gate, .dashboard-grid { grid-template-columns: 1fr; }
  .session-tools { justify-content: flex-start; }
  .gate { margin-top: 32px; }
  .stats { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .form-grid, .allocation-values { grid-template-columns: 1fr; }
  .section-head { display: grid; }
  .chart-note { display: grid; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
