* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: #eef4ef;
  color: #162d29;
  font: 16px/1.5 system-ui, sans-serif;
}

.shell {
  width: min(1080px, 100% - 32px);
  margin-inline: auto;
}

.top {
  background: #143b33;
  color: white;
  font-weight: 750;
  padding: 17px 0;
}
.top span {
  margin-left: 12px;
  font-size: 0.83rem;
  font-weight: 500;
  color: #c9e7da;
}

.intro {
  padding: 38px 0 26px;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.7rem);
  letter-spacing: -0.055em;
  line-height: 1.06;
}

h2, h3 {
  letter-spacing: -0.025em;
  line-height: 1.15;
}

p {
  margin-top: 0.55rem;
  color: #4e665e;
}

.cards, .metrics {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  background: #fff;
  border: 1px solid #d8e4dd;
  border-radius: 16px;
  padding: clamp(14px, 3vw, 23px);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.86rem;
  font-weight: 650;
}

.input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid #a8beb4;
  border-radius: 8px;
  background: #f9fcfa;
}
.input-wrap span {
  color: #4e665e;
  padding-right: 9px;
  white-space: nowrap;
  font-size: 0.73rem;
}

input, select, button {
  font: inherit;
  color: inherit;
}

input {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: 0;
  padding: 8px;
  border-radius: 8px;
}

select, button {
  border-radius: 8px;
  padding: 8px 12px;
  border: 1px solid #a8beb4;
  background: white;
}

button {
  background: #12634f;
  color: white;
  font-weight: 700;
  cursor: pointer;
  border-color: #12634f;
}

button.secondary {
  background: white;
  color: #12634f;
}

:focus-visible {
  outline: 3px solid #1b876b;
  outline-offset: 3px;
}

summary {
  font-weight: 700;
  cursor: pointer;
}

.assumptions {
  margin-top: 16px;
}

.start-month {
  max-width: 260px;
  margin-top: 16px;
}

.plan-period > .grid:first-of-type {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.asset-grid, .portfolio-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.asset-card {
  min-width: 0;
  margin: 0;
  padding: 10px 16px 16px;
  border: 1px solid #d8e4dd;
  border-radius: 12px;
  background: #f5f9f6;
}
.asset-card legend {
  padding: 0 6px;
  font-weight: 750;
}
.asset-card .grid {
  margin-top: 0;
}

.asset-withdrawal {
  display: grid;
  gap: 9px;
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid #d8e4dd;
}
.asset-withdrawal input[type=range] {
  padding: 0;
  accent-color: #12634f;
}

.asset-assumptions {
  margin-top: 12px;
}
.asset-assumptions .grid {
  margin-top: 11px;
}

.asset-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 650;
}
.asset-checkbox input {
  width: auto;
  margin: 0;
  accent-color: #12634f;
}

.month-portfolio {
  margin-top: 18px;
}
.month-portfolio h4 {
  margin: 0;
}
.month-portfolio p {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
}
.month-portfolio strong {
  color: #12634f;
}

.portfolio-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.portfolio-asset {
  padding: 11px;
  border: 1px solid #d8e4dd;
  border-radius: 8px;
}
.portfolio-asset strong {
  font-size: clamp(1rem, 2.2vw, 1.3rem);
  overflow-wrap: anywhere;
}

.month-cash-details {
  margin-top: 18px;
}

.age-slider {
  margin-top: 16px;
}

.age-slider input {
  padding: 0;
  margin: 3px 0;
  accent-color: #12634f;
}

.withdrawal-period {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 12px;
  margin-top: 14px;
}

#add-period {
  margin-top: 14px;
}

.actions {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.notice {
  padding: 12px;
  background: #fff3ea;
  color: #85341e;
  margin-bottom: 16px;
  border-radius: 8px;
}

#results {
  margin-top: 32px;
}

.metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 12px;
}

.metric {
  display: grid;
  align-content: start;
  gap: 4px;
}
.metric strong {
  font-size: clamp(1.25rem, 3vw, 1.95rem);
  color: #12634f;
}
.metric span {
  font-weight: 650;
}
.metric small {
  color: #4e665e;
}

.month-card {
  margin-top: 12px;
}

.retirement-budget {
  background: #e4f1e8;
}

.retirement-budget strong {
  font-size: clamp(1.9rem, 5vw, 3rem);
}

.pension-summary {
  margin-top: 18px;
  border-top: 1px solid #d8e4dd;
}

.pension-summary h4 {
  margin: 14px 0 0;
}

.pension-summary strong {
  font-size: inherit;
}

#estimated-net-pension {
  color: #12634f;
  font-weight: 750;
}

.month-controls {
  display: grid;
  grid-template-columns: 1fr minmax(135px, 185px);
  align-items: center;
  gap: 10px 12px;
  margin-top: 16px;
}
.month-controls input[type=range] {
  grid-column: 1/-1;
  padding: 0;
  margin: 0;
  accent-color: #12634f;
}
.month-controls button {
  justify-self: start;
}
.month-controls p {
  margin: 0;
}

.market-risk h4 {
  margin: 18px 0 0;
}
.market-risk details {
  margin-top: 13px;
}
.market-risk th:first-child {
  text-align: left;
}
.market-risk th, .market-risk td {
  white-space: nowrap;
}

.market-metrics {
  grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr));
}

.market-legend-band {
  background: #cce9de;
  padding: 0 8px;
  border-radius: 4px;
}

.annual-statement details {
  margin-top: 16px;
}
.annual-statement th, .annual-statement td {
  white-space: nowrap;
}
.annual-statement th:first-child {
  text-align: left;
}
.annual-statement table small {
  display: block;
  font-weight: 400;
  color: #4e665e;
}

.month-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: #eef4ef;
}

.month-breakdown {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 24px;
  margin: 10px 0 0;
}
.month-breakdown div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid #d8e4dd;
}
.month-breakdown dd {
  margin: 0;
  text-align: right;
  font-weight: 650;
}

.chart-card {
  margin-top: 14px;
}

.chart-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.chart-heading select {
  max-width: 100%;
}

canvas {
  display: block;
  width: 100%;
  height: 300px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}

.table-wrap {
  overflow: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 10px;
  text-align: right;
}

th, td {
  padding: 6px 10px;
  border-bottom: 1px solid #d8e4dd;
}

footer {
  padding: 20px 0 26px;
  font-size: 0.86rem;
}

@media (max-width: 650px) {
  .cards, .metrics, .month-breakdown, .month-summary {
    grid-template-columns: 1fr;
  }
  .asset-grid {
    grid-template-columns: 1fr;
  }
  .portfolio-grid, .plan-period > .grid:first-of-type {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .withdrawal-period {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 365px) {
  .grid, .withdrawal-period, .month-summary, .month-controls {
    grid-template-columns: 1fr;
  }
}
