.statistics-analysis {
  --stats-rule: #cbd6ce;
  --stats-soft: #e9f0eb;
  --stats-warm: #f6ede2;
  margin-bottom: clamp(3rem, 6vw, 6rem);
}
.stats-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(18rem, .75fr);
  align-items: end;
  gap: clamp(1.5rem, 4vw, 4rem);
  padding: clamp(1.35rem, 4.15vw, 3.7rem);
  border: 1px solid var(--stats-rule);
  border-radius: 1.2rem 1.2rem 2.35rem 1.2rem;
  background: linear-gradient(116deg, #e3eee9, #edf2e8 55%, #f5ede1);
}
.stats-hero h1 { max-width: 14ch; text-wrap: balance; }
.stats-hero-copy > p { max-width: 43ch; margin-top: .9rem; color: var(--muted); font-size: clamp(1rem, 1.3vw, 1.125rem); }
.stats-geography {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: .55rem .65rem;
  min-width: 0;
  padding: .92rem;
  border: 1px solid var(--stats-rule);
  border-radius: var(--radius);
  background: #fffdf8d9;
}
.stats-geography:has(.stats-compare-fields) { grid-column: 1 / -1; }
.stats-hero:has(.stats-geography-comparing) { row-gap: 1.35rem; }
.stats-compare-fields {
  display: grid;
  grid-row: 2;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .8rem;
  margin: 0;
  padding: 0;
  border: 0;
}
.stats-compare-fields legend { margin-bottom: .35rem; font-size: .89rem; }
.stats-geography-comparing {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .82rem;
}
.stats-geography-comparing > .button { grid-row: 1; grid-column: 2; }
.stats-area-field { position: relative; min-width: 0; }
.stats-area-field label { margin-bottom: .27rem; }
.stats-area-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  width: 100%;
  min-height: 44px;
  padding: .52rem .8rem;
  border: 1px solid var(--control-line);
  border-radius: .55rem;
  background: var(--white);
  color: var(--ink);
  font-weight: 590;
  text-align: left;
  overflow-wrap: anywhere;
}
.stats-area-button:hover { background: #eff4ed; }
.stats-area-button::after {
  content: '';
  flex: 0 0 .64rem;
  height: .64rem;
  margin-right: .13rem;
  transform: translateY(-.125rem) rotate(45deg);
  border-right: 1.6px solid var(--forest);
  border-bottom: 1.6px solid var(--forest);
}
.stats-area-dialog {
  width: min(36rem, calc(100% - 2rem));
  max-height: min(82vh, 45rem);
  max-height: min(82dvh, 45rem);
  padding: clamp(.85rem, 4vw, 1.5rem);
  overflow: hidden;
  border: 1px solid var(--control-line);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 12px 52px #172b263b;
}
.stats-area-dialog[open] { display: flex; flex-direction: column; }
.stats-area-dialog::backdrop { background: #172b2666; }
.stats-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: .85rem; }
.stats-dialog-head h2 { font-size: clamp(1.56rem, 4vw, 2rem); }
.stats-area-dialog input { flex: 0 0 auto; margin-top: .2rem; }
.stats-area-count { margin: .5rem 0 .4rem; }
.stats-area-results { min-height: 0; margin: 0; padding: 0 .25rem 0 0; overflow: auto; list-style: none; overscroll-behavior: contain; }
.stats-area-results li + li { margin-top: .22rem; }
.stats-area-results button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .55rem;
  width: 100%;
  min-height: 44px;
  padding: .42rem .65rem;
  border: 1px solid var(--line);
  border-radius: .45rem;
  background: var(--white);
  color: var(--ink);
  text-align: start;
  overflow-wrap: anywhere;
}
.stats-area-results button:hover, .stats-area-results button[aria-current=true] { border-color: var(--control-line); background: var(--stats-soft); }
.stats-area-result-context { flex-shrink: 0; font-size: .83rem; color: var(--muted); }
.stats-views, .stats-topics { display: flex; align-items: center; flex-wrap: wrap; }
.stats-views { gap: .25rem clamp(.4rem, 2vw, 1.5rem); margin-top: .75rem; border-bottom: 1px solid var(--stats-rule); }
.stats-views a {
  display: flex;
  align-items: center;
  min-height: 49px;
  padding: .6rem .5rem .38rem;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-size: .95rem;
  font-weight: 620;
  text-decoration: none;
}
.stats-views a:hover { color: var(--forest); background: #eaf0e6; }
.stats-views a[aria-current=page] { border-bottom-color: var(--forest); color: var(--forest); font-weight: 750; }
.stats-overview { margin-top: clamp(1.85rem, 4.5vw, 3.55rem); }
.stats-section-head {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  align-items: end;
  gap: .45rem 1.3rem;
  margin-bottom: 1rem;
}
.stats-section-head > p { max-width: 42ch; margin: 0; color: var(--muted); font-size: .92rem; }
.stats-location-level { margin-bottom: .36rem; color: var(--forest); font-size: .9rem; font-weight: 650; }
.stats-overview h2 { font-size: clamp(2.25rem, 4.6vw, 3.72rem); }
.stats-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .72rem;
}
.stats-metric {
  min-width: 0;
  padding: clamp(.85rem, 2vw, 1.18rem);
  border: 1px solid var(--line);
  border-top: 3px solid #719483;
  border-radius: .35rem .35rem .85rem .85rem;
  background: var(--white);
}
.stats-metric h3 { min-height: 1.3em; color: var(--ink); font: 660 .94rem/1.33 var(--sans); }
.stats-reading { margin: .49rem 0 .22rem; line-height: 1.06; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stats-reading strong { display: inline; font: 600 clamp(1.8rem, 3.1vw, 2.65rem)/1.06 var(--serif); letter-spacing: -.035em; }
.stats-reading span { color: var(--muted); font-size: .83rem; }
.stats-metric-period, .stats-source { margin: .12rem 0; color: var(--muted); font-size: .83rem; }
.stats-source a { font-weight: 640; }
.stats-metric details { margin-top: .4rem; font-size: .83rem; }
.stats-metric details summary { width: fit-content; min-height: 32px; padding-block: .25rem; color: var(--forest); font-weight: 620; }
.stats-metric details p { margin-top: .25rem; }
.stats-topics { gap: .38rem .55rem; margin-top: 1.08rem; }
.stats-topics a {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: .35rem .75rem;
  border: 1px solid var(--stats-rule);
  border-radius: 2rem;
  color: var(--forest);
  font-size: .88rem;
  font-weight: 610;
  text-decoration: none;
}
.stats-topics a:hover { border-color: var(--control-line); background: var(--stats-soft); }
.stats-topic {
  margin-top: clamp(2rem, 4.8vw, 4.6rem);
  padding-top: clamp(1.15rem, 2.5vw, 1.9rem);
  border-top: 1px solid var(--stats-rule);
  scroll-margin-top: 1rem;
}
.stats-mode-content { padding-top: 0; border-top: 0; }
.stats-figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .95rem; }
.stats-topic > .stat-chart + .stats-figures { margin-top: .95rem; }
.stats-figures > .stat-chart:only-child { grid-column: 1 / -1; }
.stats-indicator-details, .stats-coverage {
  margin-top: 1rem;
  padding: .48rem .85rem;
  border: 1px solid var(--stats-rule);
  border-radius: .55rem;
  background: var(--stats-soft);
}
.stats-coverage { margin-top: 2rem; }
.stats-indicator-details > summary, .stats-coverage > summary { min-height: 44px; padding-block: .6rem; font-size: .93rem; font-weight: 650; }
.stats-indicator-details > .stats-metrics { margin-block: .34rem .48rem; }
.stats-coverage > p { margin: .28rem 0; }
.stats-coverage > ul { margin-block: .48rem .7rem; padding-inline-start: 1.45rem; }
.stats-availability, .stats-mode-empty {
  margin-top: 1.35rem;
  padding: 1rem 1.25rem;
  border-inline-start: 3px solid #90aa93;
  background: var(--stats-soft);
}
.stats-mode-empty h2 { margin-bottom: .5rem; font-size: 1.8rem; }
.stats-comparison-table { margin-top: 1rem; overflow-x: auto; border: 1px solid var(--stats-rule); border-radius: .68rem; background: var(--white); }
.stats-comparison-table caption { padding: .75rem .9rem; color: var(--ink); font-weight: 680; text-align: start; }
.stats-comparison-table table { min-width: 30rem; }
.stats-comparison-table td { min-width: 7.6rem; }
.stats-missing { color: var(--muted); font-style: italic; }
@media (max-width: 57rem) {
  .stats-hero { grid-template-columns: 1fr; gap: 1.2rem; }
  .stats-geography:not(.stats-geography-comparing) { width: min(100%, 35rem); }
  .stats-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-section-head > p { max-width: none; }
}
@media (max-width: 41rem) {
  .stats-figures, .stats-compare-fields { grid-template-columns: 1fr; }
  .stats-hero { border-radius: .95rem .95rem 1.35rem .95rem; }
  .stats-metric { padding: .7rem; }
  .stats-metric h3 { font-size: .875rem; }
  .stats-views a { padding-inline: .35rem; font-size: .89rem; }
  .stats-geography { padding: .68rem; }
  .stats-geography-comparing { grid-template-columns: minmax(0, 1fr); }
  .stats-geography-comparing > .button { grid-row: 3; grid-column: 1; justify-self: start; }
}
@media (max-width: 23rem) {
  .stats-hero { padding: 1rem; }
  .stats-geography:not(.stats-geography-comparing) { grid-template-columns: 1fr; }
  .stats-geography > .button { justify-self: start; }
  .stats-reading strong { font-size: 1.56rem; }
  .stats-area-result-context { font-size: .76rem; }
}

.stat-chart {
  position: relative;
  min-width: 0;
  padding: clamp(1rem, 3vw, 1.8rem);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stat-chart > header p {
  margin-block: .55rem 0;
  max-width: 66ch;
  color: var(--muted);
  font-size: .94rem;
}
.stat-chart-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: .55rem .75rem;
  padding-block: 1rem .75rem;
}
.stat-chart-controls label { display: grid; gap: .22rem; font-size: .84rem; }
.stat-chart-controls button,
.stat-chart-controls select,
.stat-chart-controls summary {
  min-height: 2.55rem;
  padding: .4rem .66rem;
  color: var(--ink);
  border: 1px solid var(--control-line);
  border-radius: .4rem;
  background: var(--white);
  font-size: .875rem;
}
.stat-chart-controls select { max-width: 100%; }
.stat-chart-controls button:hover,
.stat-chart-controls summary:hover { background: var(--sage); }
.stat-chart-controls details { position: relative; min-width: 0; }
.stat-chart-controls summary { display: flex; align-items: center; gap: .48rem; list-style: none; }
.stat-chart-controls summary::-webkit-details-marker { display: none; }
.stat-chart-controls summary::after {
  content: "";
  width: .4rem;
  height: .4rem;
  margin: -.18rem .12rem 0;
  border: solid currentColor;
  border-width: 0 1.4px 1.4px 0;
  transform: rotate(45deg);
}
.stat-chart-series fieldset,
.stat-chart-download > div {
  position: absolute;
  z-index: 2;
  inset: 100% auto auto 0;
  width: max-content;
  max-width: min(19rem, 74vw);
  padding: .65rem;
  margin: .2rem 0 0;
  background: var(--white);
  border: 1px solid var(--control-line);
  border-radius: .5rem;
  box-shadow: var(--surface-shadow);
}
.stat-chart-download > div { display: flex; gap: .35rem; inset-inline: auto 0; }
.stat-chart-series fieldset label { display: flex; align-items: flex-start; gap: .44rem; padding: .2rem; }
.stat-chart-series input { margin-top: .27rem; accent-color: var(--forest); }
.stat-chart-unit,
.stat-chart-formula {
  margin: .55rem 0 .15rem;
  color: var(--muted);
  font-size: .83rem;
}
.stat-chart-legend {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  gap: .22rem 1.1rem;
  padding: 0;
  margin: .42rem 0 .2rem;
  font-size: .83rem;
}
.stat-chart-legend li { display: flex; align-items: center; gap: .4rem; }
.stat-chart-legend svg { flex: none; }
.stat-chart-figure { position: relative; }
.stat-chart-svg { display: block; width: 100%; height: auto; }
.stat-chart-tooltip {
  position: absolute;
  z-index: 1;
  width: max-content;
  max-width: min(18rem, 100%);
  padding: .38rem .58rem;
  color: var(--white);
  background: var(--forest);
  border-radius: .35rem;
  font-size: .82rem;
  pointer-events: none;
}
.stat-chart-table,
.stat-chart-sources,
.stat-chart-method {
  margin-top: .7rem;
  padding-top: .65rem;
  border-top: 1px solid var(--line);
  font-size: .86rem;
}
.stat-chart-table summary,
.stat-chart-method summary { width: fit-content; font-weight: 650; }
.stat-chart-table-scroll { max-height: 23rem; overflow: auto; margin-top: .5rem; }
.stat-chart-table table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.stat-chart-table caption { text-align: left; font-weight: 650; margin: 0 0 .4rem; }
.stat-chart-table thead { position: sticky; top: 0; background: var(--white); }
.stat-chart-table :is(th,td) { padding: .4rem .55rem; border-bottom: 1px solid var(--line); }
.stat-chart-table :is(th,td):first-child { text-align: left; white-space: nowrap; }
.stat-chart-missing { color: var(--muted); font-style: italic; }
.stat-chart-sources > p { margin: 0; font-weight: 650; }
.stat-chart-sources ul { list-style: none; padding: 0; margin: .25rem 0 0; }
.stat-chart-sources li { margin-block: .18rem; overflow-wrap: anywhere; }
.stat-chart-sources li strong { font-weight: 600; margin-inline-end: .2rem; }
.stat-chart-sources a { color: var(--forest); }
.stat-chart-method p { margin: .4rem 0 0; }
.stat-chart-feedback { margin: .45rem 0 0; font-size: .85rem; }
.stat-chart-feedback:empty { margin: 0; }
.stat-chart:fullscreen,
.stat-chart-dialog {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: auto;
  margin: 0;
  background: var(--white);
  border: 0;
  border-radius: 0;
}
.stat-chart-dialog { padding: 0; }
.stat-chart-dialog > .stat-chart { border: 0; }
.stat-chart:fullscreen > *,
.stat-chart-dialog > .stat-chart > * { max-width: 72rem; margin-inline: auto; }
@media (max-width: 540px) {
  .stat-chart { padding: .95rem .75rem; }
  .stat-chart-controls { gap: .45rem; }
  .stat-chart-controls button,
  .stat-chart-controls select,
  .stat-chart-controls summary { min-height: 2.75rem; }
}
