:root {
  color-scheme: light;
  --ink: #1d2f3f;
  --navy: #1d3d59;
  --muted: #5f6c76;
  --soft: #f2f5f7;
  --soft-blue: #e8f0f5;
  --grid: #d9e0e5;
  --line: #a9b4bc;
  --paper: #ffffff;
  --focus: #377eb8;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--navy);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

.site-header {
  border-top: 5px solid var(--navy);
  border-bottom: 1px solid var(--grid);
}

.header-inner,
main,
footer {
  width: min(1080px, calc(100% - 32px));
  margin-inline: auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 62px;
}

.wordmark {
  color: var(--navy);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-decoration: none;
}

nav {
  display: flex;
  gap: 20px;
  font-size: 0.88rem;
}

nav a {
  color: var(--muted);
  text-decoration: none;
}

nav a:hover {
  color: var(--ink);
  text-decoration: underline;
}

main {
  padding: 38px 0 32px;
}

.chart-card {
  border: 1px solid var(--grid);
  background: var(--paper);
  padding: 34px 38px 30px;
}

.chart-heading {
  max-width: 850px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--navy);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: #142b3c;
  font-size: clamp(2rem, 4.4vw, 3.05rem);
  font-weight: 700;
  letter-spacing: -0.038em;
  line-height: 1.05;
}

.subtitle {
  max-width: 760px;
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 1.03rem;
  line-height: 1.48;
}

.view-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: 30px;
  border-bottom: 1px solid var(--grid);
}

.view-tabs {
  display: flex;
  gap: 4px;
}

.view-tab {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 15px 10px;
  font-weight: 700;
  cursor: pointer;
}

.view-tab::after {
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 3px;
  background: transparent;
  content: "";
}

.view-tab:hover {
  color: var(--ink);
  background: var(--soft);
}

.view-tab[aria-selected="true"] {
  color: var(--navy);
}

.view-tab[aria-selected="true"]::after {
  background: var(--navy);
}

.latest-period {
  margin: 0 0 9px;
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: grid;
  grid-template-columns: 1.15fr 0.8fr 1.35fr;
  gap: 20px;
  margin: 22px 0 0;
  padding: 17px 18px 18px;
  border: 1px solid var(--grid);
  background: var(--soft);
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.065em;
  text-transform: uppercase;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.button-group button {
  min-height: 34px;
  border: 1px solid #c6d0d7;
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
  padding: 6px 10px;
  font-size: 0.82rem;
  cursor: pointer;
}

.button-group button:hover {
  border-color: var(--navy);
  background: var(--soft-blue);
}

.button-group button[aria-pressed="true"] {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--paper);
}

.series-picker {
  margin-top: 24px;
}

.series-picker-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.series-picker-heading h2 {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.065em;
  text-transform: uppercase;
}

.series-picker-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--navy);
  padding: 2px 0;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.text-button:hover:not(:disabled) {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.text-button:disabled {
  color: var(--line);
  cursor: default;
}

.series-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.series-toggle {
  --series-color: var(--line);
  display: grid;
  grid-template-columns: 10px auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 52px;
  border: 1px solid var(--grid);
  border-radius: 2px;
  background: var(--paper);
  color: var(--ink);
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
}

.series-toggle:hover:not(:disabled) {
  border-color: #9cabb5;
  background: var(--soft);
}

.series-toggle[aria-pressed="true"] {
  border-color: #b7c2ca;
  box-shadow: inset 0 -3px 0 var(--series-color);
}

.series-toggle[aria-pressed="false"] {
  color: #89949c;
}

.series-toggle[aria-pressed="false"] .series-swatch {
  opacity: 0.22;
}

.series-toggle:disabled {
  background: #fafafa;
  color: #98a1a8;
  cursor: not-allowed;
}

.series-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--series-color);
}

.series-code {
  font-size: 0.83rem;
  font-weight: 700;
}

.series-name {
  min-width: 0;
  overflow: hidden;
  color: inherit;
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.series-value {
  color: inherit;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

.view-panel {
  margin-top: 14px;
}

.view-panel[hidden] {
  display: none;
}

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

.plot-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 400;
}

#chart {
  width: 100%;
  height: 540px;
}

.status {
  min-height: 1.4em;
  margin: 0;
  color: #e31a1c;
  font-size: 0.85rem;
}

.table-wrap {
  max-height: 590px;
  margin-top: 12px;
  overflow: auto;
  border: 1px solid var(--grid);
}

#data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

#data-table th,
#data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--grid);
  text-align: right;
  white-space: nowrap;
}

#data-table th:first-child,
#data-table td:first-child {
  text-align: left;
}

#data-table thead th {
  position: sticky;
  z-index: 1;
  top: 0;
  background: var(--soft);
  color: var(--ink);
  font-weight: 700;
}

#data-table tbody tr:hover {
  background: #f8fafb;
}

.chart-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
  padding: 13px 0;
  border-top: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
}

.action {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid #c4ced5;
  border-radius: 2px;
  background: var(--paper);
  color: var(--navy);
  padding: 6px 11px;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.action:hover {
  border-color: var(--navy);
  background: var(--soft-blue);
}

.source-block {
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.48;
}

.source-block p {
  margin: 5px 0;
}

.source-block strong {
  color: var(--ink);
}

.method-strip {
  max-width: 880px;
  margin: 24px auto 0;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
}

.method-strip p,
footer p {
  margin: 0;
}

footer {
  padding: 22px 0 34px;
  border-top: 1px solid var(--grid);
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 880px) {
  .chart-card {
    padding: 30px 26px 26px;
  }

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

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

@media (max-width: 620px) {
  .header-inner,
  main,
  footer {
    width: min(100% - 24px, 1080px);
  }

  .header-inner {
    min-height: 56px;
  }

  nav {
    gap: 13px;
    font-size: 0.8rem;
  }

  main {
    padding-top: 24px;
  }

  .chart-card {
    border-right: 0;
    border-left: 0;
    padding: 26px 0 22px;
  }

  h1 {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 0.94rem;
  }

  .view-bar {
    align-items: center;
  }

  .latest-period {
    margin-bottom: 9px;
    font-size: 0.75rem;
  }

  .controls {
    padding: 14px;
  }

  .series-control {
    grid-template-columns: 1fr;
  }

  .series-toggle {
    min-height: 46px;
  }

  #chart {
    height: 480px;
  }

  .chart-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .action {
    justify-content: center;
    padding-inline: 7px;
    text-align: center;
  }
}
