:root {
  color-scheme: light;
  --color-canvas: #f7f5ef;
  --color-surface: #fff;
  --color-surface-soft: #fbfaf7;
  --color-text: #142321;
  --color-text-muted: #68706e;
  --color-border: #dddcd6;
  --color-border-control: #cfd2d0;
  --color-fire: #164b39;
  --color-fire-dark: #103a2d;
  --color-fire-soft: #eaf1ed;
  --color-pension: #dda72c;
  --color-pension-soft: #fbf3dc;
  --color-pension-line: #b77a08;
  --color-pension-fill: #d9a328;
  --color-free-funds: #2f709d;
  --color-free-funds-soft: #eaf2f7;
  --color-free-funds-line: #276b98;
  --color-free-funds-fill: #3b7aa5;
  --color-danger: #a6392f;

  --background: var(--color-canvas);
  --surface: var(--color-surface);
  --surface-soft: var(--color-surface-soft);
  --ink: var(--color-text);
  --muted: var(--color-text-muted);
  --line: var(--color-border);
  --green: var(--color-fire);
  --green-dark: var(--color-fire-dark);
  --gold: var(--color-pension);
  --blue: var(--color-free-funds);
  --blue-soft: var(--color-free-funds-soft);
  --green-soft: var(--color-fire-soft);
  --gold-soft: var(--color-pension-soft);
  --danger: var(--color-danger);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;

  --radius-control: 4px;
  --radius-phase: 10px;
  --radius-plot: 12px;
  --radius-card: 14px;
  --radius-round: 999px;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --text-display-xl-size: clamp(2rem, 3vw, 2.5rem);
  --text-display-xl-line: 1;
  --text-display-lg-size: clamp(1.8rem, 3vw, 2.25rem);
  --text-display-lg-line: 1.1;
  --text-metric-lg-size: 1.5rem;
  --text-metric-lg-line: 1.333;
  --text-body-lg-size: 1.125rem;
  --text-body-lg-line: 1.333;
  --text-heading-sm-size: 0.9375rem;
  --text-heading-sm-line: 1.467;
  --text-body-md-size: 0.875rem;
  --text-body-md-line: 1.429;
  --text-label-sm-size: 0.75rem;
  --text-label-sm-line: 1.333;
  --text-data-md-size: 1rem;
  --text-data-md-line: 1.5;
  --text-data-sm-size: 0.8125rem;
  --text-data-sm-line: 1.385;
  --text-caption-size: 0.6875rem;
  --text-caption-line: 1.455;
  --text-overline-size: 0.625rem;
  --text-overline-line: 1.4;
  --text-chart-tick-size: 0.5rem;
  --text-tooltip-title-size: 0.625rem;
  --text-tooltip-size: 0.5625rem;
  --text-info-icon-size: 0.5625rem;
  --text-disclosure-marker-size: 1.125rem;

  --control-height: 38px;
  --control-padding-inline: 10px;
  --control-stepper-width: 28px;
  --focus-ring: 0 0 0 3px rgba(22, 75, 57, 0.12);
  --shadow: 0 10px 24px rgba(29, 43, 39, 0.09);
  --sans: "Instrument Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  --data: "Instrument Sans", "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.4;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
textarea {
  font: inherit;
}

button,
summary {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.page-shell {
  margin: 0 auto;
  max-width: 1680px;
  padding: var(--space-6) clamp(var(--space-5), 2vw, var(--space-8)) var(--space-10);
}

.page-header {
  display: grid;
  gap: var(--space-5) var(--space-7);
  grid-template-columns: minmax(0, 2.12fr) minmax(330px, 0.96fr);
  margin: 0 0 var(--space-4);
}

.page-header-planner {
  align-items: flex-end;
  display: flex;
  gap: var(--space-5);
  justify-content: space-between;
  min-width: 0;
  padding-left: var(--space-1);
}

.page-header-copy h1 {
  font-size: var(--text-display-xl-size);
  font-weight: var(--weight-bold);
  letter-spacing: -0.045em;
  line-height: var(--text-display-xl-line);
  margin: 0 0 var(--space-1);
}

.page-header-copy p {
  color: #414846;
  font-size: var(--text-body-lg-size);
  line-height: var(--text-body-lg-line);
  margin: 0;
}

.error-message {
  background: #fff3f0;
  border-left: 4px solid var(--danger);
  color: var(--danger);
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
}

.dashboard {
  align-items: stretch;
  display: grid;
  gap: var(--space-5) var(--space-7);
  grid-template-columns: minmax(0, 2.12fr) minmax(330px, 0.96fr);
}

#results {
  display: contents;
}

.planner-card,
.result-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}

.planner-card {
  min-width: 0;
  overflow: hidden;
}

.form-surface {
  margin: var(--space-4);
  padding: var(--space-5) var(--space-6);
}

.plan-code-toolbar {
  align-items: center;
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
  margin: 0;
  min-height: var(--control-height);
}

.plan-code-toolbar-status {
  color: var(--green);
  font-size: var(--text-data-sm-size);
  font-weight: var(--weight-semibold);
  margin: 0 auto 0 0;
}

.plan-code-toolbar-actions {
  display: flex;
  gap: var(--space-2);
}

.plan-code-trigger {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-control);
  color: var(--green);
  cursor: pointer;
  display: inline-flex;
  font-size: var(--text-data-sm-size);
  font-weight: var(--weight-semibold);
  gap: var(--space-2);
  justify-content: center;
  min-height: var(--control-height);
  padding: 8px var(--space-3);
}

.plan-code-trigger:hover {
  background: var(--green-soft);
  border-color: var(--green);
}

.plan-code-trigger svg {
  fill: none;
  height: 17px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.4;
  width: 17px;
}

.plan-code-dialog {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: 0 24px 70px rgba(20, 35, 33, 0.24);
  color: var(--ink);
  max-height: calc(100dvh - 32px);
  max-width: min(640px, calc(100vw - 32px));
  overflow: auto;
  padding: 0;
  width: 100%;
}

.plan-code-dialog::backdrop {
  background: rgba(20, 35, 33, 0.46);
}

.plan-code-dialog-shell {
  display: grid;
}

.plan-code-dialog-header {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6) var(--space-4);
}

.plan-code-dialog-header p {
  color: var(--green);
  font-size: var(--text-overline-size);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  line-height: var(--text-overline-line);
  margin: 0 0 var(--space-1);
  text-transform: uppercase;
}

.plan-code-dialog-header h2 {
  font-size: var(--text-metric-lg-size);
  line-height: var(--text-metric-lg-line);
  margin: 0;
}

.plan-code-dialog-close {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-round);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 34px;
  height: 34px;
  justify-content: center;
  padding: 0;
}

.plan-code-dialog-close:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.plan-code-dialog-close svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.7;
  width: 18px;
}

.plan-code-privacy {
  background: var(--green-soft);
  border-left: 3px solid var(--green);
  color: var(--green-dark);
  font-size: var(--text-data-sm-size);
  line-height: var(--text-data-sm-line);
  margin: 0 var(--space-6) var(--space-2);
  padding: var(--space-3) var(--space-4);
}

.plan-code-section {
  padding: var(--space-4) var(--space-6) var(--space-5);
}

.plan-code-section + .plan-code-section {
  border-top: 1px solid var(--line);
}

.plan-code-section-heading {
  align-items: flex-end;
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.plan-code-section-heading h3 {
  font-size: var(--text-heading-sm-size);
  line-height: var(--text-heading-sm-line);
  margin: 0 0 2px;
}

.plan-code-section-heading p {
  color: var(--muted);
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  margin: 0;
}

.plan-code-inline-status {
  color: var(--green) !important;
  flex: 0 0 auto;
  font-weight: var(--weight-semibold);
}

.plan-code-value {
  background: var(--surface-soft);
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-control);
  color: var(--ink);
  display: block;
  font-family: var(--mono);
  font-size: var(--text-caption-size);
  line-height: 1.55;
  min-height: 112px;
  outline: 0;
  padding: var(--space-3);
  resize: vertical;
  width: 100%;
}

.plan-code-value:focus {
  border-color: var(--green);
  box-shadow: var(--focus-ring);
}

.plan-code-value[readonly] {
  color: #354441;
}

.plan-code-error {
  background: #fff3f0;
  border-left: 3px solid var(--danger);
  color: var(--danger);
  font-size: var(--text-data-sm-size);
  margin: var(--space-3) 0 0;
  padding: var(--space-2) var(--space-3);
}

.plan-code-section-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-3);
}

.plan-code-primary-action {
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: var(--radius-control);
  color: #fff;
  cursor: pointer;
  font-size: var(--text-data-sm-size);
  font-weight: var(--weight-semibold);
  min-height: var(--control-height);
  padding: 8px var(--space-4);
}

.plan-code-primary-action:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
}

.plan-code-primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

fieldset {
  border: 0;
  border-bottom: 1px solid var(--line);
  margin: 0;
  padding: 0 0 var(--space-5);
}

fieldset + fieldset {
  margin-top: var(--space-5);
  padding-top: 0;
}

#savings-section {
  border-bottom: 0;
  padding-bottom: 0;
}

legend,
.assumptions summary {
  font-size: var(--text-heading-sm-size);
  font-weight: var(--weight-bold);
  line-height: var(--text-heading-sm-line);
  margin-bottom: var(--space-2);
  padding: 0;
}

.form-grid {
  align-items: end;
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(var(--field-columns), minmax(0, 1fr));
}

.plan-grid {
  --field-columns: 5;
}

.wealth-grid,
.savings-grid {
  --field-columns: 6;
}

.assumptions-grid {
  --field-columns: 3;
}

.field {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.field > span:first-child {
  font-size: var(--text-label-sm-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-label-sm-line);
  min-height: 1em;
}

.contribution-lock {
  align-items: center;
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 26px;
  height: 26px;
  justify-content: center;
  margin: 0;
  padding: 0;
}

.contribution-lock:hover {
  background: var(--surface-soft);
  color: var(--green);
}

.contribution-lock:focus-visible {
  outline: 3px solid rgba(22, 75, 57, 0.18);
  outline-offset: 1px;
}

.contribution-lock[aria-pressed="true"] {
  background: var(--gold-soft);
  border-color: var(--color-pension-line);
  color: #8a5b08;
}

.contribution-lock svg {
  fill: none;
  height: 17px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
  width: 17px;
}

.contribution-lock .lock-icon-closed,
.contribution-lock[aria-pressed="true"] .lock-icon-open {
  display: none;
}

.contribution-lock[aria-pressed="true"] .lock-icon-closed {
  display: block;
}

.field i,
.inflation-field i,
.result-card footer i {
  align-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  color: var(--muted);
  display: inline-flex;
  font-size: var(--text-info-icon-size);
  font-style: normal;
  height: 13px;
  justify-content: center;
  vertical-align: 0.1em;
  width: 13px;
}

.field-disabled {
  opacity: 0.48;
}

.field-disabled .amount-step-button {
  cursor: not-allowed;
}

@media (min-width: 1280px) {
  .plan-grid .field > span:first-child {
    white-space: nowrap;
  }
}

.field input,
.field select {
  background: #fff;
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-control);
  color: var(--ink);
  font-family: var(--data);
  font-size: var(--text-data-sm-size);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-medium);
  line-height: var(--text-data-sm-line);
  min-height: var(--control-height);
  min-width: 0;
  outline: 0;
  padding: 9px var(--control-padding-inline);
  width: 100%;
}

.field > input,
.field > select {
  height: var(--control-height);
}

.field input:focus,
.field select:focus,
.input-suffix:focus-within {
  border-color: var(--green);
  box-shadow: var(--focus-ring);
}

.stepper-input {
  background: #fff;
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-control);
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--control-stepper-width);
  height: var(--control-height);
  overflow: hidden;
}

.stepper-input:focus-within {
  border-color: var(--green);
  box-shadow: var(--focus-ring);
}

.field .stepper-input input {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  min-height: 0;
  padding-right: 8px;
}

.field.limit-exceeded .stepper-input {
  background: #fff8e6;
  border-color: #b7791f;
}

.field.limit-exceeded .stepper-input input,
.field.limit-exceeded .amount-step-button {
  background: #fff8e6;
}

.contribution-adjustment-message {
  margin: 0.75rem 0 0;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--color-pension-line);
  border-radius: 0.75rem;
  color: var(--ink);
  background: var(--gold-soft);
  font-size: 0.875rem;
}

.field input[type="number"] {
  appearance: textfield;
}

.field input[type="number"]::-webkit-inner-spin-button,
.field input[type="number"]::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}

.amount-stepper {
  border-left: 1px solid var(--line);
  display: grid;
  flex: 0 0 var(--control-stepper-width);
  grid-template-rows: 1fr 1fr;
}

.amount-step-button {
  align-items: center;
  appearance: none;
  background: var(--surface-soft);
  border: 0;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  justify-content: center;
  min-height: 0;
  padding: 0;
  width: var(--control-stepper-width);
}

.amount-step-button + .amount-step-button {
  border-top: 1px solid var(--line);
}

.amount-step-button:hover {
  background: var(--green-soft);
  color: var(--green);
}

.amount-step-button:active {
  background: #dce9e2;
}

.amount-step-button:disabled,
.amount-step-button:disabled:hover {
  background: var(--surface-soft);
  color: var(--muted);
}

.amount-step-button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: -2px;
}

.amount-step-button svg {
  fill: none;
  height: 5px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
  width: 9px;
}

.input-suffix {
  align-items: stretch;
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius-control);
  display: flex;
  height: var(--control-height);
  overflow: hidden;
}

.input-suffix input,
.input-suffix input:focus {
  border: 0;
  box-shadow: none;
  min-height: 0;
}

.input-suffix b {
  align-items: center;
  border-left: 1px solid var(--line);
  color: var(--muted);
  display: flex;
  font-size: var(--text-caption-size);
  font-weight: var(--weight-medium);
  line-height: var(--text-caption-line);
  padding: 0 var(--control-padding-inline);
}

.inflation-field {
  cursor: pointer;
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.inflation-field > span:first-child {
  font-size: var(--text-label-sm-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-label-sm-line);
}

.inflation-input {
  align-items: center;
  background: var(--green-soft);
  border: 1px solid #c9d9d0;
  border-radius: var(--radius-control);
  display: flex;
  height: var(--control-height);
  justify-content: space-between;
  padding: 0 var(--control-padding-inline);
  position: relative;
}

.inflation-input input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.inflation-switch {
  background: #b7bbb8;
  border-radius: var(--radius-round);
  flex: 0 0 auto;
  height: 22px;
  position: relative;
  width: 38px;
}

.inflation-switch::after {
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  content: "";
  height: 16px;
  left: 3px;
  position: absolute;
  top: 3px;
  transition: transform 160ms ease;
  width: 16px;
}

.inflation-input input:checked + .inflation-switch {
  background: var(--green);
}

.inflation-input input:checked + .inflation-switch::after {
  transform: translateX(16px);
}

.inflation-input input:focus-visible + .inflation-switch {
  outline: 3px solid rgba(22, 75, 57, 0.18);
  outline-offset: 2px;
}

.inflation-input b {
  color: var(--green-dark);
  font-size: var(--text-caption-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-caption-line);
  margin-right: var(--space-2);
}

.optimization-disclosure {
  border-bottom: 1px solid var(--line);
}

#savings-section + .optimization-disclosure {
  padding-top: var(--space-2);
}

.optimization-disclosure[open] > summary {
  margin-bottom: var(--space-2);
}

.optimization-actions {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.optimization-disclosure:not(.optimization-has-result)
  .optimization-actions {
  grid-template-columns: 1fr;
}

.optimization-button,
.apply-optimization-button {
  align-items: center;
  border-radius: var(--radius-control);
  cursor: pointer;
  display: inline-flex;
  font-size: var(--text-data-sm-size);
  font-weight: var(--weight-semibold);
  justify-content: center;
  min-height: var(--control-height);
  padding: 8px var(--space-4);
  width: 100%;
}

.optimization-button {
  background: var(--surface);
  border: 1px solid var(--green);
  color: var(--green);
  gap: var(--space-2);
}

.optimization-button:hover {
  background: var(--green-soft);
}

.optimization-button:disabled,
.apply-optimization-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.apply-optimization-button:disabled {
  background: var(--surface-soft);
  border-color: var(--color-border-control);
  color: var(--muted);
  cursor: not-allowed;
}

.optimization-button svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
  width: 18px;
}

.optimization-result {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: var(--radius-phase);
  margin-top: var(--space-3);
  overflow: hidden;
}

.optimization-header {
  align-items: center;
  display: flex;
  gap: var(--space-5);
  justify-content: space-between;
  padding: var(--space-4) var(--space-5) var(--space-3);
}

.optimization-header p {
  color: var(--muted);
  font-size: var(--text-overline-size);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.06em;
  line-height: var(--text-overline-line);
  margin: 0 0 2px;
  text-transform: uppercase;
}

.optimization-header h3 {
  font-size: var(--text-body-lg-size);
  line-height: var(--text-body-lg-line);
  margin: 0;
}

.optimization-fire-shift {
  align-items: center;
  background: var(--green-soft);
  border: 1px solid #c9d9d0;
  border-radius: var(--radius-round);
  display: flex;
  flex: 0 0 auto;
  gap: var(--space-2);
  padding: 7px var(--space-3);
  white-space: nowrap;
}

.optimization-fire-shift span,
.optimization-fire-shift strong {
  font-size: var(--text-data-sm-size);
  font-variant-numeric: tabular-nums;
}

.optimization-fire-shift span {
  color: var(--muted);
  text-decoration: line-through;
}

.optimization-fire-shift strong {
  color: var(--green-dark);
}

.optimization-fire-shift svg {
  fill: none;
  height: 12px;
  stroke: var(--green);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
  width: 24px;
}

.optimization-comparison {
  border-block: 1px solid var(--line);
  padding: var(--space-3) var(--space-5) var(--space-4);
}

.optimization-column-headings,
.optimization-row {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: minmax(120px, 1fr) minmax(80px, auto) 18px minmax(80px, auto);
}

.optimization-result:not(.optimization-has-result)
  .optimization-column-headings,
.optimization-result:not(.optimization-has-result) .optimization-row {
  grid-template-columns: minmax(120px, 1fr) minmax(140px, auto);
}

.optimization-column-headings {
  color: var(--muted);
  font-size: var(--text-label-sm-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-overline-line);
  padding-bottom: var(--space-1);
  text-align: right;
  text-transform: uppercase;
}

.optimization-comparison dl {
  margin: 0;
}

.optimization-row {
  align-items: baseline;
  padding: 5px 0;
}

.optimization-row dt {
  align-items: center;
  display: flex;
  font-size: var(--text-body-md-size);
  gap: var(--space-2);
  line-height: var(--text-body-md-line);
}

.optimization-row dt i {
  background: var(--gold);
  border-radius: 50%;
  flex: 0 0 7px;
  height: 7px;
  width: 7px;
}

.optimization-row-free dt i {
  background: var(--blue);
}

.optimization-row-tax dt,
.optimization-row-reserve dt {
  color: var(--muted);
  padding-left: 15px;
}

.optimization-row dd {
  font-family: var(--data);
  font-size: var(--text-data-md-size);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-medium);
  margin: 0;
  text-align: right;
  white-space: nowrap;
}

.optimization-current-value {
  align-items: center;
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.optimization-row-locked dt {
  font-weight: var(--weight-semibold);
}

.optimization-row > span {
  color: var(--muted);
  text-align: center;
}

.optimization-row dd:last-child {
  color: var(--green-dark);
  font-weight: var(--weight-semibold);
}

.optimization-allocation-bar {
  background: var(--line);
  border-radius: var(--radius-round);
  display: flex;
  height: 6px;
  margin-top: var(--space-3);
  overflow: hidden;
  width: 100%;
}

.optimization-allocation-bar i:nth-child(1) {
  background: var(--color-pension-line);
  flex: 0 0 var(--rate-share, 0%);
}

.optimization-allocation-bar i:nth-child(2) {
  background: #c98d19;
  flex: 0 0 var(--life-share, 0%);
}

.optimization-allocation-bar i:nth-child(3) {
  background: var(--color-pension-fill);
  flex: 0 0 var(--age-share, 0%);
}

.optimization-allocation-bar i:nth-child(4) {
  background: var(--blue);
  flex: 0 0 var(--free-share, 0%);
}

.optimization-footer {
  padding: var(--space-3) var(--space-5);
}

.optimization-footer p {
  color: var(--muted);
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  margin: 0;
}

.apply-optimization-button {
  background: var(--green);
  border: 1px solid var(--green);
  color: #fff;
}

.apply-optimization-button:hover {
  background: var(--green-dark);
}

.assumptions {
  padding: var(--space-3) 0;
}

.assumptions summary,
.projection-card summary,
.key-figures summary {
  cursor: pointer;
  list-style: none;
}

.assumptions summary::-webkit-details-marker,
.projection-card summary::-webkit-details-marker,
.key-figures summary::-webkit-details-marker {
  display: none;
}

.assumptions summary,
.projection-card > summary,
.key-figures > summary {
  align-items: center;
  display: flex;
  gap: var(--space-2);
}

.assumptions summary {
  margin: 0;
}

.assumptions summary::before,
.projection-card > summary::before,
.key-figures > summary::before {
  content: "+";
  flex: 0 0 auto;
  font-size: var(--text-disclosure-marker-size);
  font-weight: var(--weight-regular);
  line-height: 1;
}

.assumptions[open] summary::before,
.projection-card[open] > summary::before,
.key-figures[open] > summary::before {
  content: "−";
}

.assumptions[open] summary {
  margin-bottom: var(--space-3);
}

.result-card {
  align-self: start;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  overflow: hidden;
}

.result-card > header {
  background: linear-gradient(135deg, #164b39 0%, #113e31 100%);
  color: #fff;
  padding: var(--space-8);
}

.result-card > header p {
  font-size: var(--text-body-md-size);
  line-height: var(--text-body-md-line);
  margin: 0 0 var(--space-4);
}

.result-card h2 {
  font-size: var(--text-display-lg-size);
  font-weight: var(--weight-bold);
  letter-spacing: -0.035em;
  line-height: var(--text-display-lg-line);
  margin: 0 0 var(--space-2);
}

.result-card > header strong {
  color: #f0bd39;
  display: block;
  font-size: var(--text-metric-lg-size);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-semibold);
  line-height: var(--text-metric-lg-line);
}

.result-milestones {
  align-content: center;
  display: grid;
  padding: var(--space-6) var(--space-8) var(--space-3);
}

.result-milestone {
  display: grid;
  grid-template-columns: 54px 16px minmax(0, 1fr);
  min-height: 68px;
}

.result-milestone > strong {
  font-family: var(--data);
  font-size: var(--text-data-md-size);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-semibold);
  line-height: var(--text-data-md-line);
  padding-top: 1px;
  white-space: nowrap;
}

.result-milestone-rail {
  position: relative;
}

.result-milestone-rail::before {
  background: var(--line);
  content: "";
  height: 100%;
  left: 7px;
  position: absolute;
  top: 10px;
  width: 2px;
}

.result-milestone:last-child .result-milestone-rail::before {
  display: none;
}

.result-milestone-rail i {
  background: var(--surface);
  border: 3px solid var(--green);
  border-radius: 50%;
  display: block;
  height: 16px;
  position: relative;
  width: 16px;
}

.result-milestone-fire .result-milestone-rail i {
  border-color: var(--gold);
}

.result-milestone-copy {
  min-width: 0;
  padding-left: var(--space-3);
}

.result-milestone-copy b {
  display: block;
  font-size: var(--text-body-md-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-body-md-line);
}

.result-milestone-copy small {
  color: var(--muted);
  display: block;
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  margin-top: var(--space-1);
}

.result-card > footer {
  border-top: 1px solid var(--line);
  margin: 0 var(--space-8);
  padding: var(--space-5) 0 var(--space-6);
}

.result-card > footer p {
  font-size: var(--text-data-sm-size);
  line-height: var(--text-data-sm-line);
  margin: 0 0 var(--space-1);
}

.result-card > footer > strong {
  color: var(--green);
  display: block;
  font-family: var(--data);
  font-size: var(--text-metric-lg-size);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-semibold);
  line-height: var(--text-metric-lg-line);
  letter-spacing: -0.025em;
  margin-bottom: 0;
}

.timeline-card {
  grid-column: 1 / -1;
  min-width: 0;
  overflow: hidden;
  padding: 0;
}

.timeline-viewport {
  overflow-x: auto;
}

.timeline-plot {
  min-width: 720px;
}

.phase-groups {
  display: flex;
  margin: 0 6.785714% var(--space-2);
}

.phase-group {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: var(--text-overline-size);
  font-weight: var(--weight-semibold);
  gap: var(--space-2);
  letter-spacing: 0.08em;
  line-height: var(--text-overline-line);
  min-width: 0;
  padding-inline: var(--space-3);
  text-transform: uppercase;
}

.phase-group::before,
.phase-group::after {
  background: var(--line);
  content: "";
  flex: 1 1 auto;
  height: 1px;
  min-width: 8px;
}

.phase-group-saving span {
  color: var(--blue);
}

.phase-group-drawdown span {
  color: var(--green);
}

.phase-strip {
  display: flex;
  margin-bottom: var(--space-8);
  margin-left: 6.785714%;
  margin-right: 6.785714%;
  overflow: visible;
}

.phase {
  align-items: center;
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  min-height: 58px;
  min-width: 0;
  padding: var(--space-3) var(--space-5);
  position: relative;
}

.phase::before {
  background: var(--phase-background);
  border-radius: var(--radius-phase);
  content: "";
  inset: 0 6px;
  position: absolute;
  z-index: 0;
}

.phase > :not(.phase-connector) {
  position: relative;
  z-index: 1;
}

.phase-connector {
  border-left: 1px dashed currentColor;
  bottom: calc(var(--space-8) * -1);
  color: var(--phase-marker);
  height: var(--space-8);
  left: 0;
  position: absolute;
  width: 1px;
  z-index: 3;
}

.phase-connector::after {
  background: currentColor;
  border: 4px solid var(--surface);
  border-radius: 50%;
  bottom: -7px;
  box-shadow: 0 1px 4px rgba(29, 43, 39, 0.16);
  box-sizing: border-box;
  content: "";
  height: 14px;
  left: -7px;
  position: absolute;
  width: 14px;
}

.phase-icon {
  fill: none;
  grid-row: 1 / 3;
  height: 32px;
  margin-right: var(--space-3);
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 32px;
}

.phase-icon-pig circle {
  fill: currentColor;
  stroke: none;
}

.phase b {
  font-size: var(--text-label-sm-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-label-sm-line);
}

.phase small {
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
}

.phase-saving {
  --phase-background: linear-gradient(135deg, #2f709d, #28668f);
  --phase-marker: var(--blue);
}

.phase-saving-free {
  --phase-background: linear-gradient(135deg, #6e9fc1, #5488ad);
  --phase-marker: #5d91b5;
}

.phase-saving-pension,
.phase-saving-free {
  padding-inline: var(--space-3);
}

.phase-saving-pension b,
.phase-saving-free b {
  font-size: var(--text-label-sm-size);
}

.phase-saving-pension .phase-icon,
.phase-saving-free .phase-icon {
  height: 29px;
  margin-right: var(--space-2);
  width: 29px;
}

.phase-fire {
  --phase-background: linear-gradient(135deg, #164b39, #103e30);
  --phase-marker: var(--green);
}

.phase-pension {
  --phase-background: linear-gradient(135deg, #d9a328, #e7b739);
  --phase-marker: var(--gold);
}

.phase-saving > :not(.phase-connector),
.phase-saving-free > :not(.phase-connector),
.phase-fire > :not(.phase-connector),
.phase-pension > :not(.phase-connector) {
  color: #fff;
}

.timeline-visual-frame {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  overflow: hidden;
  padding-top: var(--space-4);
}

.wealth-chart {
  min-height: 0;
}

.wealth-chart svg {
  display: block;
  height: auto;
  width: 100%;
}

.chart-phase-saving-pension {
  fill: var(--blue-soft);
}

.chart-phase-saving-free {
  fill: #f1f6f9;
}

.chart-phase-fire {
  fill: var(--green-soft);
}

.chart-phase-pension {
  fill: var(--gold-soft);
}

.chart-plot-surface {
  fill: var(--surface-soft);
  stroke: none;
}

.chart-grid-line {
  stroke: #cfd4d1;
  stroke-dasharray: 2 4;
  stroke-width: 1;
}

.chart-boundary {
  stroke: #b6bbb8;
  stroke-dasharray: 3 3;
  stroke-width: 1;
}

.chart-line-pension,
.chart-line-free-funds {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.6;
}

.chart-area-pension {
  fill: var(--color-pension-fill);
  opacity: 0.16;
}

.chart-area-free-funds {
  fill: var(--color-free-funds-fill);
  opacity: 0.15;
}

.chart-line-pension {
  stroke: var(--color-pension-line);
}

.chart-line-free-funds {
  stroke: var(--color-free-funds-line);
}

.chart-axis-label {
  fill: #606967;
  font-family: var(--sans);
  font-size: var(--text-caption-size);
}

.chart-legend {
  align-items: center;
  display: flex;
  gap: var(--space-6);
  justify-content: center;
  padding: var(--space-1) 0 var(--space-3);
}

.chart-legend span {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: var(--text-label-sm-size);
  font-weight: var(--weight-semibold);
  gap: var(--space-2);
  line-height: var(--text-label-sm-line);
}

.chart-legend i {
  border-radius: var(--radius-round);
  display: block;
  height: 3px;
  width: 26px;
}

.legend-pension {
  background: var(--color-pension-line);
}

.legend-free-funds {
  background: var(--color-free-funds-line);
}

.chart-year-tick {
  stroke: #9fa8a4;
  stroke-width: 0.8;
}

.chart-year-label {
  fill: #68706e;
  font-family: var(--sans);
  font-size: var(--text-chart-tick-size);
  text-anchor: middle;
}

.chart-now-label {
  fill: #68706e;
  font-family: var(--sans);
  font-size: var(--text-chart-tick-size);
  text-anchor: middle;
}

.chart-hover-target {
  cursor: crosshair;
  fill: transparent;
  pointer-events: all;
}

.chart-hover-line {
  stroke: #59625f;
  stroke-dasharray: 3 3;
  stroke-width: 1;
}

.chart-hover-point-pension,
.chart-hover-point-free-funds {
  fill: #fff;
  stroke-width: 2.5;
}

.chart-hover-point-pension {
  stroke: var(--color-pension-line);
}

.chart-hover-point-free-funds {
  stroke: var(--color-free-funds-line);
}

.chart-tooltip {
  pointer-events: none;
}

.chart-tooltip-box {
  fill: #fff;
  filter: drop-shadow(0 4px 8px rgba(29, 43, 39, 0.14));
  stroke: #d6d8d4;
}

.chart-tooltip-title,
.chart-tooltip-label,
.chart-tooltip-value {
  fill: var(--ink);
  font-family: var(--sans);
}

.chart-tooltip-title {
  font-size: var(--text-tooltip-title-size);
  font-weight: var(--weight-bold);
}

.chart-tooltip-label {
  fill: var(--muted);
  font-size: var(--text-tooltip-size);
}

.chart-tooltip-value {
  font-size: var(--text-tooltip-size);
  font-weight: var(--weight-semibold);
  text-anchor: end;
}

.chart-tooltip-total-rule {
  stroke: #e1e2df;
  stroke-width: 1;
}

.projection-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  margin-top: var(--space-3);
  overflow: hidden;
}

.projection-card > summary {
  font-size: var(--text-data-sm-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-data-sm-line);
  padding: var(--space-3) var(--space-7);
}

.table-wrap {
  border-top: 1px solid var(--line);
  margin-top: var(--space-3);
  overflow-x: auto;
}

.projection-note {
  color: var(--muted);
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  margin: var(--space-3) var(--space-4) var(--space-4);
}

table {
  border-collapse: collapse;
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  min-width: 1420px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: var(--space-2) var(--space-3);
  text-align: right;
  white-space: nowrap;
}

td {
  font-variant-numeric: tabular-nums;
}

th {
  background: #f4f4f1;
  color: var(--muted);
  font-size: var(--text-overline-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-overline-line);
  text-transform: uppercase;
}

th:first-child,
td:first-child,
th:nth-child(3),
td:nth-child(3),
th:last-child,
td:last-child {
  text-align: left;
}

.key-figures,
.disclaimer {
  grid-column: 1 / -1;
}

.key-figures {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 0 var(--space-7);
}

.key-figures > summary {
  font-size: var(--text-data-sm-size);
  font-weight: var(--weight-semibold);
  line-height: var(--text-data-sm-line);
  padding: var(--space-3) 0;
}

.key-figures dl {
  display: grid;
  gap: 0 var(--space-6);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 var(--space-4);
}

.key-figures dl div {
  border-top: 1px solid var(--line);
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
  padding: var(--space-2) 0;
}

.key-figures dt {
  color: var(--muted);
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
}

.key-figures dd {
  font-family: var(--data);
  font-size: var(--text-caption-size);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-medium);
  line-height: var(--text-caption-line);
  margin: 0;
  text-align: right;
}

.disclaimer {
  color: var(--muted);
  font-size: var(--text-caption-size);
  line-height: var(--text-caption-line);
  margin: calc(var(--space-1) * -1) var(--space-1) 0;
}

.disclaimer .source-link {
  color: inherit;
  margin-left: var(--space-1);
  text-underline-offset: 3px;
}

.disclaimer-links {
  display: block;
}

.disclaimer-links .source-link:first-child {
  margin-left: 0;
}

.disclaimer .source-link:hover {
  color: var(--ink);
}

.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

button:focus-visible,
summary:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(22, 75, 57, 0.2);
  outline-offset: 2px;
}

@media (max-width: 1350px) {
  .page-header {
    grid-template-columns: 1fr;
  }

  .dashboard {
    grid-template-columns: 1fr;
  }

  .result-card {
    grid-column: 1;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    margin-top: 0;
  }

  .result-card > header {
    grid-column: 1;
  }

  .result-milestones {
    grid-column: 2;
    grid-row: 1 / 3;
    padding-block: 24px;
  }

  .result-card > footer {
    grid-column: 1;
    margin-inline: 28px;
  }
}

@media (max-width: 1100px) {
  .wealth-grid,
  .savings-grid {
    --field-columns: 3;
  }
}

@media (max-width: 1080px) {
  .form-surface {
    padding-inline: 18px;
  }
}

@media (max-width: 900px) {
  .plan-grid {
    --field-columns: 3;
  }
}

@media (max-width: 820px) {
  .key-figures dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .wealth-grid,
  .savings-grid {
    --field-columns: 2;
  }
}

@media (max-width: 560px) {
  .field input,
  .field select,
  .plan-code-value {
    font-size: var(--text-data-md-size);
  }

  .page-shell {
    padding-inline: 12px;
  }

  .page-header {
    margin-bottom: 14px;
  }

  .page-header-planner {
    align-items: stretch;
    flex-direction: column;
    gap: var(--space-3);
    padding-left: 0;
  }

  .form-surface {
    margin-inline: 8px;
    padding-inline: 14px;
  }

  .plan-code-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .plan-code-toolbar-status {
    margin-right: 0;
  }

  .plan-code-toolbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .plan-code-trigger {
    width: 100%;
  }

  .plan-code-dialog {
    max-height: calc(100dvh - 16px);
    max-width: calc(100vw - 16px);
  }

  .plan-code-dialog-header {
    padding: var(--space-4);
  }

  .plan-code-privacy {
    margin-inline: var(--space-4);
  }

  .plan-code-section {
    padding-inline: var(--space-4);
  }

  .plan-code-section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .plan-code-section-actions,
  .plan-code-primary-action {
    width: 100%;
  }

  .form-grid {
    --field-columns: 1;
  }

  .optimization-header,
  .optimization-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .optimization-header,
  .optimization-comparison,
  .optimization-footer {
    padding-inline: var(--space-3);
  }

  .optimization-fire-shift {
    align-self: flex-start;
  }

  .optimization-column-headings,
  .optimization-row {
    grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr);
  }

  .optimization-column-headings span:first-child {
    display: none;
  }

  .optimization-row dt {
    grid-column: 1 / -1;
    margin-top: var(--space-1);
  }

  .result-card {
    display: block;
  }

  .result-milestones {
    padding-bottom: 8px;
  }

  .key-figures dl {
    grid-template-columns: 1fr;
  }
}

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

@media print {
  .page-shell {
    max-width: none;
    padding: 0;
  }

  .planner-card {
    display: none;
  }

  .plan-code-dialog {
    display: none;
  }

  .dashboard {
    display: block;
  }

  .result-card,
  .timeline-card {
    box-shadow: none;
    margin-bottom: 16px;
  }

}
