:root {
  color: #17212b;
  background: #e8f3ec;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0;
}

.intro {
  display: block;
  padding: 28px 0 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #386fa4;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  max-width: 720px;
  color: #17212b;
  font-size: clamp(2rem, 6vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.lede {
  max-width: 760px;
  margin-bottom: 0;
  color: #4f5f6d;
  font-size: 1.05rem;
}

.controls-panel {
  display: grid;
  grid-template-columns: minmax(280px, 1.25fr) minmax(170px, 0.65fr) minmax(320px, 1.4fr);
  gap: 18px;
  align-items: start;
  margin: 8px 0 18px;
  padding: 18px;
  border: 1px solid #d8e1e6;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 16px 36px rgb(28 45 56 / 8%);
}

.income-field,
.year-field,
.basis-field {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid #d8e1e6;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 32px rgb(28 45 56 / 8%);
}

.controls-panel .income-field,
.controls-panel .year-field,
.controls-panel .basis-field {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.income-field span:first-child,
.year-field span:first-child,
.basis-field legend {
  color: #4f5f6d;
  font-size: 0.88rem;
  font-weight: 700;
}

.income-field small,
.basis-field small {
  color: #61707d;
  font-size: 0.82rem;
  font-weight: 650;
}

.year-field,
.basis-field {
  padding: 14px 18px;
}

.year-field select {
  width: 100%;
  border: 1px solid #b9c9d3;
  border-radius: 8px;
  background: #fbfdfe;
  color: #17212b;
  font-size: 1rem;
  font-weight: 800;
  padding: 11px 12px;
}

.basis-field {
  margin: 0;
  padding-top: 14px;
}

.controls-panel .basis-field {
  padding: 0;
}

.basis-field legend {
  float: left;
  width: 100%;
  padding: 0;
  margin-bottom: 8px;
  line-height: 1.2;
}

.basis-field legend + * {
  clear: both;
}

.basis-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid #b9c9d3;
  border-radius: 8px;
  background: #edf3f6;
}

.basis-field label {
  position: relative;
  display: grid;
  min-width: 0;
}

.basis-field label span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  text-align: center;
  color: #24313d;
  font-size: 0.86rem;
  font-weight: 750;
  line-height: 1.2;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    color 160ms ease;
}

.basis-field input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.basis-field input:checked + span {
  border-color: #8ab6c9;
  background: #ffffff;
  color: #17465f;
  box-shadow: 0 5px 14px rgb(28 45 56 / 12%);
}

.basis-field input:focus-visible + span {
  outline: 3px solid rgb(56 111 164 / 28%);
  outline-offset: 2px;
}

.basis-field label:hover span {
  color: #17465f;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #b9c9d3;
  border-radius: 8px;
  background: #fbfdfe;
  padding: 0 14px;
}

.input-wrap span {
  color: #386fa4;
  font-size: 1.25rem;
  font-weight: 800;
}

input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #17212b;
  font-size: 1.8rem;
  font-weight: 800;
  padding: 12px 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 22px;
}

.summary-item {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 16px;
  border: 1px solid #d8e1e6;
  border-radius: 8px;
  background: #ffffff;
}

.summary-item span {
  color: #61707d;
  font-size: 0.84rem;
  font-weight: 700;
}

.summary-item strong {
  overflow-wrap: anywhere;
  color: #17212b;
  font-size: clamp(1.25rem, 3vw, 1.8rem);
  line-height: 1.05;
}

.summary-item-strong {
  border-color: #8ab6c9;
  background: #eef8fb;
}

.charts-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(0, 1.28fr);
  gap: 18px;
  align-items: stretch;
}

.chart-panel {
  display: grid;
  gap: 18px;
  min-width: 0;
  border: 1px solid #d8e1e6;
  border-radius: 8px;
  background: #ffffff;
  padding: 22px;
  box-shadow: 0 18px 42px rgb(28 45 56 / 9%);
}

.chart-heading h2 {
  margin-bottom: 4px;
  color: #17212b;
  font-size: 1.24rem;
  letter-spacing: 0;
}

.chart-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.info-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid #b9c9d3;
  border-radius: 999px;
  background: #fbfdfe;
  color: #25556f;
  font-size: 0.92rem;
  font-weight: 900;
  line-height: 1;
}

.info-button:hover,
.info-button:focus-visible,
.info-button[aria-expanded="true"] {
  border-color: #386fa4;
  background: #eef8fb;
  color: #17465f;
}

.chart-info-panel {
  padding: 12px 14px;
  border: 1px solid #d8e1e6;
  border-radius: 8px;
  background: #fbfdfe;
  color: #4f5f6d;
  font-size: 0.9rem;
  font-weight: 650;
}

.chart-heading p {
  margin-bottom: 0;
  color: #61707d;
  font-size: 0.94rem;
}

.chart-subcaption {
  margin-top: 5px;
  color: #334552;
  font-weight: 800;
}

.chart-helper {
  margin-top: 8px;
  color: #386fa4;
  font-weight: 750;
}

.chart-box {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-height: 420px;
  overflow: hidden;
}

.chart-box canvas {
  max-width: 100%;
}

.breakdown-panel {
  margin-top: 18px;
}

.breakdown-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.secondary-button {
  border: 1px solid #b9c9d3;
  border-radius: 8px;
  background: #ffffff;
  color: #25556f;
  font-weight: 800;
  padding: 9px 12px;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: #386fa4;
  background: #eef8fb;
}

.empty-state {
  padding: 18px;
  border: 1px dashed #b9c9d3;
  border-radius: 8px;
  background: #fbfdfe;
  color: #61707d;
  font-weight: 700;
}

.breakdown-chart-box {
  width: 75%;
  min-height: 315px;
  margin: 0 auto;
}

.source-panel {
  margin: 22px 0 0;
  padding: 0;
  border: 1px solid #d8e1e6;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.source-disclosure summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  color: #17212b;
  font-weight: 850;
}

.source-disclosure summary::-webkit-details-marker {
  display: none;
}

.source-disclosure summary::after {
  content: "+";
  float: right;
  color: #386fa4;
  font-weight: 900;
}

.source-disclosure[open] summary {
  border-bottom: 1px solid #d8e1e6;
}

.source-disclosure[open] summary::after {
  content: "−";
}

.source-disclosure[open] summary::after {
  content: "-";
}

.source-panel dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
  padding: 18px 18px 0;
}

.source-panel dt {
  color: #61707d;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.source-panel dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  color: #17212b;
  font-weight: 700;
}

.source-panel a {
  color: #2166ac;
}

.source-notes {
  margin-top: 0;
  padding: 16px 18px 0;
}

.source-notes ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.source-notes li {
  color: #334552;
}

.source-notes li span {
  display: block;
  color: #61707d;
  font-size: 0.9rem;
}

.placeholder-warning {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #efc36b;
  border-radius: 8px;
  background: #fff7df;
  color: #6c4b00;
  font-weight: 750;
}

.warning-mild {
  border-color: #8ab6c9;
  background: #eef8fb;
  color: #25556f;
}

.warning-strong {
  border-color: #d98a8a;
  background: #fff0f0;
  color: #7a2323;
}

.caveat {
  margin: 16px 18px 18px;
  padding: 14px 16px;
  border-left: 4px solid #386fa4;
  border-radius: 0 8px 8px 0;
  background: #eaf2f6;
  color: #334552;
  font-weight: 650;
}

@media (max-width: 900px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .year-field,
  .basis-field {
    grid-column: auto;
  }

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

  .source-panel dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-box {
    min-height: 360px;
  }

  .breakdown-heading {
    display: grid;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 18px 0 28px;
  }

  .intro {
    padding-top: 12px;
  }

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

  .controls-panel {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .basis-options {
    grid-template-columns: 1fr;
  }

  .source-panel dl {
    grid-template-columns: 1fr;
  }

  .chart-panel {
    padding: 16px;
  }

  .chart-box {
    min-height: 330px;
  }

  .breakdown-chart-box {
    width: 100%;
    min-height: 320px;
  }

  input {
    font-size: 1.45rem;
  }
}
