.retirement-tool {
  --retirement-ink: #18332b;
  --retirement-muted: #687a73;
  --retirement-green: #1f765c;
  --retirement-green-dark: #155843;
  --retirement-mint: #d9eee5;
  --retirement-cream: #fbfaf5;
  --retirement-gold: #d8a947;
  --retirement-coral: #dd745f;
  --retirement-line: #d8e1dc;
  width: 100%;
  max-width: 52rem;
  margin: 0 auto 5rem;
  color: var(--retirement-ink);
}

.retirement-panel {
  margin-bottom: 1.2rem;
  padding: clamp(1rem, 4vw, 1.7rem);
  border: 1px solid var(--retirement-line);
  border-radius: 18px;
  background: rgba(251, 250, 245, .88);
  box-shadow: 0 18px 50px rgba(24, 51, 43, .06);
}
.retirement-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.3rem;
}
.retirement-section-heading h2 {
  margin: 0;
  color: var(--retirement-ink);
  font-size: 1.35rem;
  letter-spacing: -.03em;
}
.retirement-form {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(7rem, .65fr) auto;
  align-items: end;
  gap: .8rem;
}
.retirement-field { display: grid; min-width: 0; gap: .42rem; margin: 0; }
.retirement-field > span, .retirement-field legend { color: var(--retirement-muted); font-size: .72rem; font-weight: 600; }
.retirement-field > input, .retirement-field > select {
  width: 100%;
  height: 2.75rem;
  margin: 0;
  padding: 0 .78rem;
  border: 1px solid var(--retirement-line);
  border-radius: 9px;
  outline: none;
  background: #fff;
  color: var(--retirement-ink);
  font-size: .78rem;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.retirement-field > select {
  padding-right: 1.8rem;
  cursor: pointer;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--retirement-green) 50%),
    linear-gradient(135deg, var(--retirement-green) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) calc(50% - 2px),
    calc(100% - 9px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
#birth-month { font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.retirement-field > input:focus, .retirement-field > select:focus {
  border-color: var(--retirement-green);
  box-shadow: 0 0 0 3px rgba(31, 118, 92, .12);
}
.gender-field { min-width: 0; padding: 0; border: 0; }
.gender-field legend { margin-bottom: .42rem; padding: 0; }
.gender-buttons { display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem; }
.gender-buttons label { position: relative; margin: 0; }
.gender-buttons input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.gender-buttons span {
  display: grid;
  place-items: center;
  height: 2.75rem;
  border: 1px solid var(--retirement-line);
  border-radius: 9px;
  background: #fff;
  color: var(--retirement-muted);
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, color .2s ease, box-shadow .2s ease;
}
.gender-buttons span:hover { border-color: var(--retirement-green); }
.gender-buttons input:focus-visible + span { box-shadow: 0 0 0 3px rgba(31, 118, 92, .12); }
.gender-buttons input:checked + span {
  border-color: var(--retirement-green);
  background: var(--retirement-green);
  color: #fff;
}
.retirement-submit {
  height: 2.75rem;
  padding: 0 1rem;
  border: 0;
  border-radius: 9px;
  background: var(--retirement-green);
  color: #fff;
  font-size: .74rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s ease, transform .2s ease;
}
.retirement-submit:hover { background: var(--retirement-green-dark); transform: translateY(-1px); }
.retirement-submit span { margin-left: .35rem; }
.retirement-error {
  margin: .8rem 0 0;
  color: var(--retirement-muted);
  font-size: .67rem;
  line-height: 1.6;
}
.retirement-error { color: #a63f34; }

.retirement-results[hidden], .retirement-error[hidden] { display: none; }
.retirement-date-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: .35rem 0 1.5rem;
  border-bottom: 1px solid var(--retirement-line);
}
.retirement-date {
  color: var(--retirement-green-dark);
  font-size: clamp(2rem, 7vw, 3.6rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.055em;
}
.retirement-date-row p { margin: .65rem 0 0; color: var(--retirement-muted); font-size: .75rem; }
.retirement-countdown {
  max-width: 12rem;
  color: var(--retirement-muted);
  font-size: .78rem;
  line-height: 1.6;
  text-align: right;
}
.retirement-countdown strong { color: var(--retirement-ink); font-size: 1.2rem; }

.retirement-stats {
  display: grid;
  grid-template-columns: 1fr;
  padding-top: .35rem;
}
.retirement-stats article {
  display: grid;
  grid-template-columns: minmax(6rem, .7fr) repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 1rem;
  min-width: 0;
  padding: 1rem 0;
  border-top: 1px solid var(--retirement-line);
}
.retirement-stats article:first-child { border-top: 0; }
.retirement-stats .schedule-name {
  color: var(--retirement-ink);
  font-size: .9rem;
  font-weight: 700;
}
.retirement-stats .schedule-name small {
  display: block;
  margin-top: .2rem;
  color: var(--retirement-muted);
  font-size: .54rem;
  font-weight: 400;
}
.schedule-metric small { display: block; color: var(--retirement-muted); font-size: .56rem; }
.schedule-metric strong { display: block; margin-top: .2rem; color: var(--retirement-ink); font-size: 1.45rem; line-height: 1.2; }
.published-holiday-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 0 0;
  border-top: 1px solid var(--retirement-line);
  color: var(--retirement-muted);
  font-size: .66rem;
}
.published-holiday-summary strong { color: var(--retirement-ink); font-size: .9rem; }
.calculation-note {
  margin-top: 1.2rem;
  padding: .72rem .85rem;
  border-radius: 8px;
  background: #eef4f0;
  color: var(--retirement-muted);
  font-size: .65rem;
  line-height: 1.6;
}
.calculation-note[hidden] { display: none; }

.calendar-heading { align-items: center; }
.calendar-controls { display: flex; gap: .35rem; }
.calendar-controls button {
  min-height: 2rem;
  padding: 0 .58rem;
  border: 1px solid var(--retirement-line);
  border-radius: 7px;
  background: #fff;
  color: var(--retirement-green-dark);
  font-size: .62rem;
  font-weight: 600;
  cursor: pointer;
}
.calendar-controls button:hover { border-color: var(--retirement-green); background: var(--retirement-mint); }
.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  margin: -.25rem 0 1rem;
  color: var(--retirement-muted);
  font-size: .58rem;
}
.calendar-legend span { display: flex; align-items: center; gap: .3rem; }
.calendar-legend i { width: .55rem; height: .55rem; border-radius: 3px; background: #fff; }
.calendar-legend .legend-work { border: 1px solid var(--retirement-line); }
.calendar-legend .legend-weekend { background: #edf0ee; }
.calendar-legend .legend-holiday { background: #f8ddd6; }
.calendar-legend .legend-adjusted { background: #faeac8; }
.calendar-legend .legend-estimated { border: 1px dashed var(--retirement-green); }
.retirement-calendar { overflow: hidden; border: 1px solid var(--retirement-line); border-radius: 12px; background: #fff; }
.calendar-weekdays, .calendar-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays { border-bottom: 1px solid var(--retirement-line); background: #f4f6f3; }
.calendar-weekdays span { padding: .55rem 0; color: var(--retirement-muted); font-size: .57rem; font-weight: 700; text-align: center; }
.calendar-day {
  position: relative;
  min-height: 4.25rem;
  padding: .48rem;
  border-right: 1px solid #e8ece9;
  border-bottom: 1px solid #e8ece9;
  background: #fff;
}
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day.is-empty { background: #fafbf9; }
.calendar-day.is-weekend { background: #f3f5f3; }
.calendar-day.is-holiday { background: #fff2ee; }
.calendar-day.is-adjusted { background: #fff5de; }
.calendar-day.is-estimated::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px dashed rgba(31, 118, 92, .32);
  border-radius: 6px;
  pointer-events: none;
}
.calendar-day.is-today { box-shadow: inset 0 0 0 2px var(--retirement-green); }
.calendar-day.is-retirement { box-shadow: inset 0 0 0 2px var(--retirement-coral); }
.calendar-day-number { display: block; color: var(--retirement-ink); font-size: .72rem; font-weight: 600; }
.calendar-day-label {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 100%;
  margin-top: .35rem;
  overflow: hidden;
  color: var(--retirement-muted);
  font-size: .48rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.is-holiday .calendar-day-label { color: #a44939; }
.is-adjusted .calendar-day-label { color: #946311; }
.is-retirement .calendar-day-label { color: #ac4635; font-weight: 700; }
.month-arrangement { margin-top: .85rem; color: var(--retirement-muted); font-size: .65rem; line-height: 1.65; }
.month-arrangement strong { color: var(--retirement-ink); }

@media (max-width: 46em) {
  .retirement-form { grid-template-columns: 1fr; }
  .retirement-submit { width: 100%; }
  .calendar-heading { align-items: flex-start; flex-direction: column; }
  .calendar-controls { width: 100%; }
  .calendar-controls button { flex: 1; }
}

@media (max-width: 31em) {
  .retirement-panel { border-radius: 13px; }
  .retirement-section-heading { margin-bottom: 1rem; }
  .retirement-date-row { align-items: flex-start; flex-direction: column; }
  .retirement-countdown { max-width: none; text-align: left; }
  .retirement-stats article { grid-template-columns: minmax(4.5rem, .7fr) repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .schedule-metric strong { font-size: 1.05rem; }
  .calendar-day { min-height: 3.25rem; padding: .35rem; }
  .calendar-day-label { margin-top: .18rem; font-size: .43rem; }
}
