:root {
  --navy: #15324a;
  --navy-dark: #0c2437;
  --teal: #267673;
  --teal-dark: #175b59;
  --teal-light: #e7f3f1;
  --gold: #d79b2e;
  --ink: #1c2b36;
  --muted: #5c6b75;
  --line: #d7e0e4;
  --surface: #ffffff;
  --background: #f5f8f8;
  --danger: #a12b2b;
  --danger-bg: #fff1f0;
  --success: #176b4d;
  --shadow: 0 12px 35px rgba(17, 47, 65, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}
button, input { font: inherit; }
button { cursor: pointer; }
.page-shell { width: min(1160px, calc(100% - 40px)); margin-inline: auto; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 100; padding: 12px 18px; color: white; background: var(--navy-dark); border-radius: 6px; }
.skip-link:focus { top: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.hero {
  position: relative;
  overflow: hidden;
  padding: 72px 0 80px;
  color: white;
  background: linear-gradient(130deg, var(--navy-dark), #184c5b 72%, #236b69);
}
.hero::after { content: ""; position: absolute; width: 420px; height: 420px; right: -130px; top: -180px; border: 70px solid rgba(255,255,255,.045); border-radius: 50%; }
.hero__content { position: relative; z-index: 1; }
.eyebrow, .step-label { margin: 0 0 8px; color: #9ed5cf; font-size: .78rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.hero h1 { max-width: 850px; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.45rem, 6vw, 4.6rem); font-weight: 500; line-height: 1.03; letter-spacing: -.03em; }
.hero h1 span { color: #a6d9d3; }
.hero__subtitle { margin: 18px 0 0; color: #c6ebe7; font-size: clamp(1rem, 2vw, 1.2rem); font-weight: 750; letter-spacing: .04em; }
.hero__intro { max-width: 720px; margin: 16px 0 24px; color: #dce9eb; font-size: 1.14rem; }
.privacy-note { display: inline-flex; align-items: center; gap: 10px; max-width: 720px; padding: 10px 14px; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); border-radius: 8px; }
.privacy-note span { display: grid; place-items: center; flex: 0 0 25px; height: 25px; color: var(--navy-dark); background: #a6d9d3; border-radius: 50%; font-weight: 900; }
.privacy-note p { margin: 0; font-size: .9rem; }

main { padding-block: 48px 64px; }
.scenario-panel, .input-section, .results-section { margin-bottom: 32px; padding: clamp(24px, 4vw, 42px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.section-heading { display: flex; justify-content: space-between; align-items: start; gap: 24px; margin-bottom: 28px; }
.section-heading h2 { margin: 0 0 6px; color: var(--navy); font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.8rem, 4vw, 2.35rem); line-height: 1.15; }
.section-heading p:not(.step-label) { max-width: 690px; margin: 0; color: var(--muted); }
.step-label { color: var(--teal-dark); }
.badge { align-self: center; padding: 5px 10px; color: var(--teal-dark); background: var(--teal-light); border-radius: 999px; font-size: .78rem; font-weight: 800; }

.scenario-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.scenario-card { display: grid; grid-template-columns: auto 1fr; gap: 0 12px; padding: 20px; text-align: left; color: var(--ink); background: white; border: 2px solid var(--line); border-radius: 12px; transition: border-color .15s, background .15s, transform .15s; }
.scenario-card:hover { border-color: #8bb7b4; transform: translateY(-1px); }
.scenario-card:focus-visible, .button:focus-visible, .text-button:focus-visible, input:focus-visible, summary:focus-visible, .comparison-select:focus-visible, .info-tip:focus-visible { outline: 3px solid #e5a93e; outline-offset: 3px; }
.scenario-card.is-selected { color: var(--navy-dark); background: var(--teal-light); border-color: var(--teal); }
.scenario-card__icon { grid-row: 1 / 3; display: grid; place-items: center; width: 40px; height: 40px; color: var(--teal-dark); background: white; border: 1px solid #b7d4d1; border-radius: 50%; }
.scenario-card strong { font-size: 1.04rem; }
.scenario-card > span:last-child { color: var(--muted); font-size: .83rem; }

.assumptions { margin-top: 22px; padding: 24px; background: #f8faf9; border: 1px solid var(--line); border-radius: 12px; }
.assumptions__heading { display: flex; justify-content: space-between; align-items: start; gap: 20px; margin-bottom: 18px; }
.assumptions h3 { margin: 0; color: var(--navy); }
.assumptions__heading p { margin: 2px 0 0; color: var(--muted); font-size: .86rem; }
.assumption-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.text-button { padding: 5px; color: var(--teal-dark); background: transparent; border: 0; font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }

fieldset { min-width: 0; margin: 0; padding: 28px 0; border: 0; border-top: 1px solid var(--line); }
fieldset:first-of-type { padding-top: 4px; border-top: 0; }
legend { margin-bottom: 18px; padding: 0; color: var(--navy); font-size: 1.12rem; font-weight: 800; }
.fieldset-help { margin: -14px 0 18px; color: var(--muted); font-size: .88rem; }
.form-grid { display: grid; gap: 24px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field label { display: block; margin-bottom: 7px; color: var(--navy-dark); font-size: .91rem; font-weight: 750; }
.field > input, .input-prefix, .input-suffix { width: 100%; min-height: 48px; background: white; border: 1px solid #9eacb5; border-radius: 8px; }
.field > input { padding: 10px 12px; }
.input-prefix, .input-suffix { display: flex; align-items: stretch; overflow: hidden; }
.input-prefix span, .input-suffix span { display: grid; place-items: center; min-width: 42px; color: var(--muted); background: #f1f4f5; }
.input-prefix span { border-right: 1px solid var(--line); }
.input-suffix span { border-left: 1px solid var(--line); }
.input-prefix input, .input-suffix input { min-width: 0; width: 100%; padding: 10px 12px; border: 0; outline: 0; }
.field > input:focus, .input-prefix:focus-within, .input-suffix:focus-within { border-color: var(--teal-dark); box-shadow: 0 0 0 3px rgba(38,118,115,.17); }
input[aria-invalid="true"], .input-prefix:has(input[aria-invalid="true"]), .input-suffix:has(input[aria-invalid="true"]) { border-color: var(--danger); }
.field-help, .field-error { min-height: 1.3em; margin: 5px 0 0; font-size: .78rem; }
.field-help { color: var(--muted); }
.field-error { color: var(--danger); font-weight: 650; }
.compact-field .field-help { min-height: 2.5em; }
.error-summary { margin: -8px 0 24px; padding: 12px 15px; color: #742020; background: var(--danger-bg); border-left: 4px solid var(--danger); border-radius: 4px; font-weight: 700; }
.button-row { display: flex; gap: 12px; padding-top: 20px; border-top: 1px solid var(--line); }
.button { min-height: 46px; padding: 10px 18px; border: 2px solid transparent; border-radius: 8px; font-weight: 800; }
.button--secondary { color: white; background: var(--teal-dark); }
.button--secondary:hover, .button--print:hover { background: #104847; }
.button--quiet { color: var(--navy); background: white; border-color: #aebbc2; }
.button--quiet:hover { background: #f2f5f5; }

.results-section { padding: 0; overflow: hidden; }
.results-heading { margin: 0; padding: clamp(24px, 4vw, 42px); color: white; background: var(--navy); }
.results-heading h2, .results-heading .step-label { color: white; }
.results-heading p:not(.step-label) { color: #cbdce2; }
.button--print { align-self: center; color: white; background: var(--teal); border-color: rgba(255,255,255,.25); }
#results-content { padding: clamp(24px, 4vw, 42px); }
.empty-state { margin: 32px; padding: 38px; text-align: center; background: var(--danger-bg); border-radius: 12px; }
.empty-state h3 { margin: 0; color: var(--danger); }
.empty-state p { margin-bottom: 0; }
.status-card { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; margin-bottom: 22px; padding: 22px 24px; color: #124c39; background: #e8f5ee; border: 1px solid #a7d5bd; border-radius: 12px; }
.status-card.is-gap { color: #732323; background: var(--danger-bg); border-color: #e6b7b3; }
.status-card__icon { display: grid; place-items: center; width: 46px; height: 46px; color: white; background: var(--success); border-radius: 50%; font-size: 1.35rem; font-weight: 900; }
.status-card.is-gap .status-card__icon { background: var(--danger); }
.status-label { margin: 0 0 2px; font-size: .77rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.status-card h3 { margin: 0; font-size: 1.35rem; }
.status-card p:last-child { margin: 3px 0 0; font-size: .9rem; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.metric-card { min-width: 0; padding: 20px; background: #f8faf9; border: 1px solid var(--line); border-radius: 11px; }
.metric-card--accent { background: var(--teal-light); border-color: #afd2ce; }
.metric-card p { display: flex; align-items: center; gap: 5px; min-height: 2.5em; margin: 0 0 8px; color: var(--muted); font-size: .8rem; font-weight: 700; }
.metric-card strong { display: block; overflow-wrap: anywhere; color: var(--navy-dark); font-size: clamp(1.35rem, 2.4vw, 1.85rem); line-height: 1.1; }
.metric-card > span { display: block; margin-top: 7px; color: var(--muted); font-size: .72rem; }
.info-tip { position: relative; display: inline-grid; place-items: center; flex: 0 0 19px; height: 19px; padding: 0; color: var(--navy); background: white; border: 1px solid #9fadb5; border-radius: 50%; font-size: .72rem; font-weight: 900; }
.info-tip:hover::after, .info-tip:focus::after { content: attr(data-tooltip); position: absolute; z-index: 5; left: 50%; bottom: calc(100% + 8px); width: 220px; padding: 9px 11px; color: white; background: var(--navy-dark); border-radius: 6px; font-size: .76rem; font-weight: 500; line-height: 1.35; transform: translateX(-50%); }

.chart-card, .comparison-card, .method-card { margin-top: 22px; padding: 24px; background: white; border: 1px solid var(--line); border-radius: 12px; }
.chart-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.chart-heading h3 { margin: 0; color: var(--navy); }
.chart-heading p { margin: 2px 0 0; color: var(--muted); font-size: .85rem; }
.legend { align-self: center; white-space: nowrap; color: var(--muted); font-size: .78rem; }
.legend span { display: inline-block; width: 18px; height: 3px; margin-right: 5px; vertical-align: middle; background: var(--teal); }
.chart { min-height: 250px; overflow: hidden; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { fill: var(--muted); font: 12px system-ui, sans-serif; }
.grid-line { stroke: #e3e9eb; stroke-width: 1; }
.projection-line { fill: none; stroke: var(--teal); stroke-width: 4; stroke-linejoin: round; stroke-linecap: round; }
.retirement-marker { stroke: var(--gold); stroke-width: 2; stroke-dasharray: 5 5; }
.expense-marker { stroke: var(--danger); stroke-width: 2; stroke-dasharray: 3 5; }
.chart .marker-label { fill: var(--navy); font-weight: 750; }
.data-details { margin-top: 14px; }
summary { color: var(--teal-dark); font-weight: 800; cursor: pointer; }
.table-scroll { overflow-x: auto; }
table { width: 100%; margin-top: 14px; border-collapse: collapse; font-size: .86rem; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); }
thead th { color: var(--navy); background: #f2f6f6; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
tbody th { color: var(--navy); }
.comparison-table { min-width: 720px; }
.comparison-row--selected { background: var(--teal-light); }
.comparison-select { padding: 2px; color: var(--teal-dark); background: transparent; border: 0; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.positive { color: var(--success); font-weight: 800; }
.negative { color: var(--danger); font-weight: 800; }
.table-status { display: inline-block; padding: 4px 8px; border-radius: 999px; font-size: .73rem; font-weight: 800; }
.table-status.is-positive { color: var(--success); background: #e4f3eb; }
.table-status.is-negative { color: var(--danger); background: var(--danger-bg); }
.method-card { background: #f8faf9; }
.method-card > div { max-width: 850px; color: var(--muted); font-size: .9rem; }
.method-card p:last-child { margin-bottom: 0; }

.disclaimer { display: grid; grid-template-columns: auto 1fr; gap: 16px; padding: 22px 26px; color: #583d0c; background: #fff7e8; border: 1px solid #e7c77c; border-radius: 12px; }
.disclaimer > div { display: grid; place-items: center; width: 32px; height: 32px; color: white; background: #9a6811; border-radius: 50%; font-weight: 900; }
.disclaimer p { margin: 2px 0 0; font-size: .9rem; }
footer { padding: 26px 0; color: #cbd8dd; background: var(--navy-dark); font-size: .82rem; }
footer .page-shell { display: flex; justify-content: space-between; gap: 20px; }
footer p { margin: 0; }

@media (max-width: 900px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .three-columns { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .page-shell { width: min(100% - 24px, 1160px); }
  .hero { padding: 52px 0 58px; }
  main { padding-top: 24px; }
  .scenario-panel, .input-section { padding: 22px 18px; }
  .scenario-tabs, .assumption-grid, .two-columns, .three-columns { grid-template-columns: 1fr; }
  .scenario-card { padding: 16px; }
  .section-heading, .assumptions__heading, .results-heading, .chart-heading { flex-direction: column; }
  .button--print { align-self: stretch; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card p { min-height: 0; }
  .chart-card, .comparison-card, .method-card { padding: 18px 14px; }
  .chart { min-height: 170px; overflow-x: auto; }
  .chart svg { min-width: 650px; }
  .button-row { flex-direction: column; }
  .button { width: 100%; }
  footer .page-shell { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}

@media print {
  @page { margin: 14mm; }
  body { color: #111; background: white; font-size: 11pt; }
  .skip-link, .hero, .scenario-panel, form, footer, .button--print, .data-details, .info-tip { display: none !important; }
  main, .page-shell { width: 100%; padding: 0; }
  .results-section { border: 0; box-shadow: none; }
  .results-heading { padding: 18px; background: #15324a !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  #results-content { padding: 20px 0; }
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
  .metric-card { padding: 12px; }
  .chart-card, .comparison-card { break-inside: avoid; }
  .comparison-table { min-width: 0; }
  .disclaimer { margin-top: 16px; break-inside: avoid; }
}
