:root {
  --navy: #06254a;
  --navy-2: #0b3769;
  --green: #2faa16;
  --green-dark: #247d15;
  --green-soft: #eff9ec;
  --ink: #10233d;
  --muted: #58697f;
  --line: #d8e0e9;
  --surface: #ffffff;
  --canvas: #f4f7fa;
  --radius: 10px;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-size: 16px; line-height: 1.45; }
button, input, select { font: inherit; }
button, summary, select { cursor: pointer; }
.page-width { width: min(1440px, calc(100% - 40px)); margin-inline: auto; }
.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; }

.brand-bar { background: white; border-bottom: 1px solid #e5eaf0; }
.brand-inner { height: 88px; display: flex; align-items: center; }
.brand-logo { display: block; width: 285px; max-height: 68px; object-fit: contain; object-position: left center; }
.hero { color: white; background: linear-gradient(120deg, #061f3e 0%, #07315f 100%); padding: 28px 0 26px; }
.hero h1 { max-width: 1050px; margin: 0; font-size: clamp(1.9rem, 3.2vw, 3rem); line-height: 1.12; letter-spacing: -0.025em; }
.hero p { margin: 10px 0 16px; max-width: 980px; font-size: 1.08rem; color: #eff5fb; }
.assumption-badge { display: inline-flex; padding: 7px 13px; border-radius: 7px; color: white; background: #165795; text-decoration: none; font-weight: 700; font-size: .9rem; }
.assumption-badge:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid #79ca67; outline-offset: 2px; }

.calculator-layout { display: grid; grid-template-columns: minmax(0, 1.95fr) minmax(340px, 1fr); gap: 22px; align-items: start; padding-block: 24px; }
.calculator { min-width: 0; }
.input-section, .supporting-content details, .results-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 2px 8px rgba(9, 31, 61, .05); }
.input-section { margin-bottom: 11px; overflow: hidden; }
.input-section > summary { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 18px; list-style: none; font-weight: 700; font-size: 1.12rem; }
.input-section > summary::-webkit-details-marker, .supporting-content summary::-webkit-details-marker, .result-details summary::-webkit-details-marker { display: none; }
.input-section > summary::after, .supporting-content summary::after { content: "⌄"; margin-left: auto; font-size: 1.15rem; color: var(--navy); }
.input-section[open] > summary { color: white; background: var(--navy); }
.input-section[open] > summary::after { content: "⌃"; color: white; }
.section-summary { color: var(--muted); font-weight: 400; font-size: .92rem; margin-left: auto; }
.input-section[open] .section-summary { color: #d9e7f5; }
.section-body { padding: 16px 18px 20px; border-top: 1px solid var(--line); }
.section-intro, .field-help { color: var(--muted); margin: 0 0 14px; }

.field-grid { display: grid; grid-template-columns: minmax(220px, 1.2fr) minmax(150px, .8fr) minmax(150px, .8fr); gap: 10px 18px; align-items: center; margin-bottom: 10px; }
.field-grid-head { margin-bottom: 8px; text-align: center; font-size: .9rem; }
.field-label { font-weight: 600; }
.input-shell { display: flex; align-items: stretch; min-height: 44px; border: 1px solid #bac7d5; border-radius: 7px; background: #fff; overflow: hidden; }
.input-shell:focus-within { border-color: var(--green-dark); box-shadow: 0 0 0 3px rgba(47,170,22,.13); }
.input-shell.currency::before, .input-shell.percent::after { display: grid; place-items: center; flex: 0 0 38px; color: #33465e; background: #f7f9fb; }
.input-shell.currency::before { content: "$"; border-right: 1px solid var(--line); }
.input-shell.percent::after { content: "%"; border-left: 1px solid var(--line); }
.input-shell input { width: 100%; min-width: 0; border: 0; outline: 0; padding: 8px 11px; text-align: right; color: var(--ink); background: transparent; }
label { color: var(--ink); font-weight: 600; }
label > select, label > .input-shell { margin-top: 6px; }
select { width: 100%; min-height: 44px; border: 1px solid #bac7d5; border-radius: 7px; padding: 8px 38px 8px 11px; color: var(--ink); background: #fff; }
fieldset { border: 0; margin: 0 0 22px; padding: 0; }
fieldset:last-child { margin-bottom: 0; }
legend { width: 100%; margin-bottom: 8px; padding-bottom: 7px; border-bottom: 1px solid var(--line); color: var(--navy); font-weight: 700; font-size: 1.05rem; }
.two-field-row, .assumption-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.item-list { display: grid; gap: 12px; margin-bottom: 12px; }
.entry-card { position: relative; display: grid; grid-template-columns: 1.4fr repeat(3, 1fr) auto; gap: 12px; align-items: end; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; }
.entry-card.gain { grid-template-columns: 1.5fr 1fr 1fr auto; }
.entry-card label { font-size: .88rem; }
.entry-card input, .entry-card select { margin-top: 5px; }
.entry-card input[type="text"] { width: 100%; min-height: 44px; border: 1px solid #bac7d5; border-radius: 7px; padding: 8px 11px; color: var(--ink); background: white; }
.entry-card input[type="text"]:focus { border-color: var(--green-dark); outline: 3px solid rgba(47,170,22,.13); outline-offset: 0; }
.remove-button { width: 42px; height: 42px; border: 1px solid #cad3de; border-radius: 7px; color: #8b2430; background: white; font-weight: 700; }
.secondary-button { min-height: 44px; border: 1px solid var(--navy); border-radius: 7px; padding: 9px 14px; color: var(--navy); background: white; font-weight: 700; }
.secondary-button:hover { background: #eff5fa; }

.results-card { position: sticky; top: 18px; overflow: hidden; }
.results-card h2 { margin: 0; padding: 18px 20px 14px; border-bottom: 2px solid var(--green); font-size: 1.35rem; }
.results-card h2 span { color: var(--muted); font-size: .85em; font-weight: 400; }
.result-columns, .result-row { display: grid; grid-template-columns: minmax(135px, 1.3fr) repeat(2, minmax(85px, .7fr)); column-gap: 10px; align-items: center; }
.result-head { padding: 11px 18px; font-size: .87rem; text-align: right; }
.result-row { padding: 15px 18px; border-top: 1px solid var(--line); }
.result-row > span:first-child { font-size: .94rem; }
.result-row strong { text-align: right; color: var(--green-dark); font-size: 1.13rem; }
.key-result strong { display: inline-block; padding: 8px 7px; border-radius: 8px; background: var(--green-soft); }
.result-details { margin: 0 18px 14px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.result-details summary { display: block; padding: 11px 13px; color: white; background: var(--navy); text-align: center; font-weight: 700; list-style: none; }
.detail-result-row { display: grid; grid-template-columns: 1.4fr repeat(2, .7fr); gap: 8px; padding: 9px 11px; border-top: 1px solid var(--line); font-size: .84rem; }
.detail-result-row strong { text-align: right; }
.detail-heading { padding: 10px 11px 5px; color: var(--navy); font-weight: 700; font-size: .86rem; }
.update-note { margin: 0 18px 18px; padding: 12px; border: 1px solid #c9dfc3; border-radius: 8px; color: #294127; background: #f4faf2; font-size: .88rem; text-align: center; }

.supporting-content { display: grid; gap: 9px; padding-bottom: 24px; }
.supporting-content details { overflow: hidden; }
.supporting-content summary { display: flex; align-items: center; padding: 14px 18px; list-style: none; color: var(--navy); font-weight: 700; }
.supporting-content details > div { padding: 0 18px 16px; color: #33465e; }
.supporting-content p { max-width: 1050px; margin: 8px 0; }
.assumption-grid { max-width: 900px; margin-block: 14px; }
.assumption-grid > span { padding: 10px 12px; border-radius: 7px; background: #f1f4f7; }

footer { border-top: 1px solid var(--line); background: white; }
footer .page-width { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 24px; color: #35475d; font-size: .9rem; }
.mobile-spouse-switch { display: none; }

@media (max-width: 920px) {
  .page-width { width: min(100% - 28px, 720px); }
  .brand-inner { height: 70px; }
  .brand-logo { width: 225px; max-height: 54px; }
  .hero { padding: 20px 0; }
  .hero h1 { font-size: clamp(1.65rem, 7vw, 2.2rem); }
  .hero p { font-size: 1rem; }
  .calculator-layout { grid-template-columns: 1fr; gap: 14px; padding-block: 14px; }
  .results-card { position: static; grid-row: 2; }
  .mobile-spouse-switch { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 11px; border: 1px solid var(--navy); border-radius: 8px; overflow: hidden; background: white; }
  .mobile-spouse-switch button { min-height: 46px; border: 0; color: var(--navy); background: white; font-weight: 700; }
  .mobile-spouse-switch button.active { color: white; background: var(--navy); }
  body[data-mobile-spouse="s1"] .spouse-col.s2, body[data-mobile-spouse="s1"] .spouse-result.s2 { display: none; }
  body[data-mobile-spouse="s2"] .spouse-col.s1, body[data-mobile-spouse="s2"] .spouse-result.s1 { display: none; }
  .field-grid { grid-template-columns: minmax(150px, 1.2fr) minmax(140px, .8fr); }
  .field-grid-head { display: none; }
  .result-columns, .result-row { grid-template-columns: minmax(155px, 1.4fr) minmax(105px, .6fr); }
  .result-head { display: none; }
  .entry-card, .entry-card.gain { grid-template-columns: 1fr 1fr; }
  .entry-card label:first-child { grid-column: 1 / -1; }
  .remove-button { position: absolute; top: 10px; right: 10px; }
  .entry-card label:first-child { padding-right: 48px; }
  .two-field-row, .assumption-grid { grid-template-columns: 1fr; }
  footer .page-width { align-items: flex-start; flex-direction: column; justify-content: center; gap: 5px; padding-block: 16px; }
}

@media (max-width: 520px) {
  .page-width { width: calc(100% - 20px); }
  .brand-logo { width: 205px; }
  .hero h1 { font-size: 1.65rem; }
  .input-section > summary { min-height: 52px; padding: 11px 13px; font-size: 1rem; }
  .section-body { padding: 14px 12px 16px; }
  .field-grid { gap: 8px; grid-template-columns: minmax(130px, 1.15fr) minmax(125px, .85fr); }
  .field-label { font-size: .88rem; }
  .section-summary { font-size: .8rem; }
  .results-card h2 { padding-inline: 14px; }
  .result-row { padding-inline: 14px; }
  .entry-card, .entry-card.gain { grid-template-columns: 1fr; }
  .entry-card label { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

.mobile-spouse-note {
  font-size: 0.85rem;
  line-height: 1.4;
  margin: 0.75rem 0 1rem;
  color: #4b5563;
}