:root {
  color-scheme: light;
  --navy: #0f1f3d;
  --navy-2: #1b4d8e;
  --teal: #006b5e;
  --mint: #e8f3f0;
  --paper: #f7f8fa;
  --card: #ffffff;
  --ink: #182235;
  --muted: #6b7a8f;
  --line: #d1d8e3;
  --danger: #9a2e2e;
  --shadow: none;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: calc(21px + env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) 24px max(22px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.96);
  color: var(--navy);
}

.eyebrow, .step {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .13em;
}

h1 { margin: 0; font-size: 38px; font-weight: 650; line-height: 1; letter-spacing: -.025em; }

.tax-year { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.tax-year select { min-height: 38px; padding: 0 32px 0 12px; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--navy); font-size: 14px; font-weight: 700; }

main { width: min(100%, 780px); margin: 0 auto; padding: 0 18px 48px; }

.hero-card {
  position: relative;
  overflow: hidden;
  margin: 18px 0;
  padding: 26px 24px 23px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  box-shadow: none;
  color: var(--navy);
}

.hero-card::after { content: ""; position: absolute; width: 5px; left: 0; top: 0; bottom: 0; background: var(--teal); }
.hero-label { margin: 0; color: var(--muted); font-size: 13px; font-weight: 650; }
.hero-value {
  margin: 4px 0 22px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-size: clamp(43px, 12vw, 64px);
  font-weight: 650;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  line-height: 1.05;
  letter-spacing: -.035em;
}
.hero-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); padding-top: 16px; }
.hero-stats div { display: grid; gap: 2px; }
.hero-stats div + div { padding-left: 20px; border-left: 1px solid var(--line); }
.hero-stats span { overflow: hidden; color: var(--teal); font-size: 11px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.hero-stats strong { color: var(--navy); font-size: 17px; }
.hero-stats small { color: var(--muted); font-size: 10px; }

.card { margin: 0 0 16px; padding: 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); box-shadow: var(--shadow); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading h2 { margin: 0; font-size: 24px; font-weight: 650; letter-spacing: -.015em; }
.section-heading > p { max-width: 220px; margin: 4px 0 0; color: var(--muted); font-size: 12px; text-align: right; }

.field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.employment-mode { min-height: 58px; margin: -6px 0 18px; padding: 0 2px 13px; }
.nhs-panel { margin: -3px 0 20px; padding: 15px; border: 1px solid #b8d8d2; border-radius: 6px; background: var(--mint); }
.nhs-selectors { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 14px; }
.nhs-selectors .stack-field { margin: 0; }
.nhs-selectors p { margin: 0 0 13px; color: var(--muted); font-size: 10px; }
.nhs-steps { margin: 14px 0 0; padding: 0; border: 0; }
.nhs-steps legend { margin-bottom: 7px; color: var(--navy); font-size: 11px; font-weight: 800; }
#nhsStepChoices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.nhs-step { display: grid; gap: 3px; min-height: 59px; padding: 8px; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--muted); text-align: left; }
.nhs-step span { font-size: 9px; line-height: 1.2; }
.nhs-step strong { color: var(--navy); font-size: 14px; }
.nhs-step.selected { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); background: #f7fffd; }
.nhs-hint { margin: 10px 0 0; color: var(--muted); font-size: 10px; }
.nhs-only-note { color: var(--teal); font-size: 9px; font-weight: 700; }
.field input:disabled, .row-field input:disabled, .toggle-row input:disabled, select:disabled { cursor: not-allowed; opacity: .55; }
.field { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.money-input { display: flex; align-items: center; min-height: 54px; padding: 0 14px; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--navy); }
.money-input:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,126,112,.12); }
.money-input b { font-size: 25px; font-weight: 600; line-height: 1; }
.money-input input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--navy);
  font-size: 25px;
  font-weight: 600;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  line-height: 1;
}
.days-input { display: flex; align-items: center; min-height: 54px; padding: 0 14px; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--muted); }
.days-input:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,126,112,.12); }
.days-input input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--navy);
  font-size: 25px;
  font-weight: 600;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  line-height: 1;
}
.days-input b { font-size: 12px; }

.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 4px 4px 0 0; background: #f3f5f8; }
.segmented button { min-height: 42px; border: 0; border-right: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 750; }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-selected="true"] { background: white; color: var(--navy); box-shadow: inset 0 -3px 0 var(--teal); }

.option-panel { padding-top: 5px; }
.row-field, .toggle-row, .calculated-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 65px; margin: 0; border-bottom: 1px solid #e5e5e1; }
.row-field > span:first-child, .toggle-row > span:first-child { display: grid; gap: 2px; }
.row-field b, .toggle-row b { color: var(--ink); font-size: 14px; }
.row-field small, .toggle-row small { color: var(--muted); font-size: 11px; }
.row-field > input { width: 82px; min-height: 40px; padding: 8px; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--navy); font-weight: 750; text-align: right; }
.compact-money { display: flex; align-items: center; min-width: 90px; padding: 0 9px; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--muted); }
.compact-money input { width: 68px; min-height: 40px; border: 0; outline: 0; background: transparent; color: var(--navy); font-weight: 750; text-align: right; }
.calculated-row { color: var(--muted); font-size: 13px; }
.calculated-row strong { color: var(--teal); font-size: 17px; }

.stack-field { display: grid; gap: 7px; margin: 15px 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.stack-field select, .breakdown-toolbar select { width: 100%; min-height: 46px; padding: 0 38px 0 12px; border: 1px solid var(--line); border-radius: 4px; background: white; color: var(--navy); font-size: 14px; font-weight: 650; }

.toggle-row input { appearance: none; width: 48px; height: 28px; padding: 2px; border: 0; border-radius: 20px; background: #cbd0d5; transition: background .2s; }
.toggle-row input::after { content: ""; display: block; width: 24px; height: 24px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .2s; }
.toggle-row input:checked { background: var(--teal); }
.toggle-row input:checked::after { transform: translateX(20px); }
[hidden] { display: none !important; }

.breakdown-card { padding: 0; overflow: hidden; }
.breakdown-card summary { display: flex; align-items: center; justify-content: space-between; min-height: 70px; padding: 0 22px; cursor: pointer; list-style: none; }
.breakdown-card summary::-webkit-details-marker { display: none; }
.breakdown-card summary > span:first-child { display: flex; align-items: center; gap: 13px; }
.breakdown-card summary .step { margin: 0; }
.chevron { color: var(--teal); font-size: 24px; transition: transform .2s; }
.breakdown-card[open] .chevron { transform: rotate(180deg); }
.breakdown-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 15px 22px; border-top: 1px solid var(--line); background: #f7f7f3; color: var(--muted); font-size: 12px; }
.breakdown-toolbar select { width: 145px; min-height: 38px; }
.working-assumptions { padding: 6px 22px 10px; border-top: 1px solid var(--line); background: #fffefa; }
.working-title { margin: 12px 0 2px; color: var(--navy); font-size: 10px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.break-section { padding: 9px 22px; background: #edf0f2; color: var(--navy); font-size: 10px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.break-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 13px 22px; border-top: 1px solid #ecece8; font-size: 13px; }
.break-row span { color: var(--muted); }
.break-row strong { color: var(--navy); white-space: nowrap; }
.break-row.deduction strong { color: var(--danger); }
.break-row.total { background: #f7fbfa; font-weight: 750; }
.break-note { grid-column: 1 / -1; margin-top: -7px; color: #8a919d !important; font-size: 10px; }

.notice { padding: 5px 5px 8px; color: var(--muted); font-size: 11px; }
.notice strong { color: var(--navy); font-size: 12px; }
.notice p { margin: 3px 0 0; }
footer { display: flex; justify-content: space-between; padding: 20px max(24px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); background: var(--navy); color: #aebcd0; font-size: 11px; }
footer span:first-child { color: white; font-size: 14px; font-weight: 650; }

@media (max-width: 520px) {
  .app-header { align-items: center; padding-bottom: 31px; }
  .tax-year span { display: none; }
  main { padding-left: 12px; padding-right: 12px; }
  .card { padding: 19px 17px; border-radius: 8px; }
  .hero-card { border-radius: 8px; padding: 23px 19px 20px; }
  .field-grid { grid-template-columns: 1fr; }
  .nhs-selectors { grid-template-columns: 1fr; }
  .nhs-selectors p { margin: -6px 0 2px; }
  #nhsStepChoices { grid-template-columns: 1fr; }
  .nhs-step { grid-template-columns: minmax(0, 1fr) auto; align-items: center; min-height: 48px; }
  .section-heading > p { display: none; }
  .hero-stats strong { font-size: 13px; }
}

@media (display-mode: standalone) {
  .app-header { padding-top: calc(18px + env(safe-area-inset-top)); }
}
