.civic-page { max-width: 1160px; }
.civic-header { max-width: 820px; }

.section-nav {
  position: sticky;
  top: 12px;
  z-index: 10;
  display: flex;
  gap: 8px;
  margin: 28px 0 44px;
  padding: 8px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.93);
  box-shadow: 0 10px 30px rgba(20,42,67,.08);
  backdrop-filter: blur(10px);
}
.section-nav a { flex: 0 0 auto; padding: 9px 12px; border-radius: 9px; color: var(--soft-ink); font-size: .82rem; font-weight: 680; text-decoration: none; }
.section-nav a:hover { background: var(--panel-soft); color: var(--navy); }
.section-nav a:focus-visible { outline: 3px solid rgba(52,127,172,.25); }

.data-section { padding: 28px 0 54px; scroll-margin-top: 84px; }
.data-section + .data-section { border-top: 1px solid var(--line); }
.section-heading-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.section-heading-row > div { max-width: 790px; }
.section-heading-row h2 { margin: 0; color: var(--navy); font-size: clamp(1.75rem, 3.5vw, 2.55rem); font-weight: 650; letter-spacing: -.04em; line-height: 1.08; }
.measure-explainer { max-width: 750px; margin: 12px 0 0; color: var(--soft-ink); font-size: .93rem; line-height: 1.6; }
.measure-explainer strong { color: var(--ink); }
.date-chip { flex: 0 0 auto; display: inline-flex; padding: 8px 11px; border-radius: 999px; background: var(--panel-soft); color: var(--navy); font-size: .75rem; font-weight: 700; }
.date-chip.strong { background: var(--good-bg); color: var(--good-ink); }

.headline-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
.metric-card { display: flex; min-height: 170px; flex-direction: column; padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); box-shadow: var(--shadow); }
.metric-card.feature { background: linear-gradient(145deg,#173c63,#245984); color: white; border-color: transparent; }
.metric-label { color: var(--soft-ink); font-size: .78rem; font-weight: 680; line-height: 1.35; }
.feature .metric-label { color: #dcecf4; }
.metric-card strong { margin: auto 0 9px; color: var(--navy); font-size: clamp(2.2rem,5vw,3.55rem); font-weight: 680; letter-spacing: -.055em; line-height: .95; }
.metric-card.feature strong { color: white; }
.metric-card > span:last-child { color: var(--soft-ink); font-size: .78rem; line-height: 1.45; }
.metric-card.feature > span:last-child { color: #dcecf4; }

.chart-card, .table-card { padding: clamp(19px,3vw,28px); border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: var(--shadow); }
.chart-card h3, .table-card h3, .about-grid h3, .source-panel h3 { margin: 0; color: var(--ink); font-size: 1.18rem; font-weight: 680; letter-spacing: -.02em; }
.card-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 24px; }
.card-heading p:not(.eyebrow) { max-width: 700px; margin: 8px 0 0; color: var(--soft-ink); font-size: .86rem; line-height: 1.5; }
.legend { display: flex; flex: 0 0 auto; gap: 12px; flex-wrap: wrap; color: var(--soft-ink); font-size: .72rem; font-weight: 650; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 11px; height: 11px; border-radius: 3px; }
.swatch.local { background: var(--navy); }
.swatch.nz { background: var(--sky); }

.compare-chart { display: grid; gap: 10px; }
.compare-row { display: grid; grid-template-columns: 64px minmax(0,1fr); gap: 12px; align-items: center; padding: 6px 8px; border-radius: 10px; }
.compare-row.youth { background: #f4f8fb; }
.age { color: var(--ink); font-size: .8rem; font-weight: 700; }
.bars, .table-bars { display: grid; gap: 4px; }
.bar { position: relative; display: block; width: calc(var(--value) * 1%); min-width: 54px; height: 20px; border-radius: 4px; background: var(--navy); }
.bar.nz { background: var(--sky); }
.bar b { position: absolute; right: 6px; top: 50%; color: white; font-size: .67rem; font-weight: 760; transform: translateY(-50%); white-space: nowrap; }
.bar.nz b { color: var(--navy); }
.bar.over { border-radius: 4px 0 0 4px; }

.source-line { margin: 24px 0 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--soft-ink); font-size: .75rem; line-height: 1.55; }
.source-line a, .source-panel a { color: var(--blue-text); text-underline-offset: 2px; }

.enrolment-summary { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)) minmax(240px,.9fr); gap: 14px; margin-bottom: 16px; }
.boundary-note { display: flex; flex-direction: column; justify-content: flex-end; padding: 20px; border: 1px solid #ead8bd; border-radius: 17px; background: #fbf5ec; }
.boundary-note strong { color: #7a4a17; font-size: .82rem; }
.boundary-note span { margin-top: 8px; color: #785d40; font-size: .78rem; line-height: 1.5; }
.table-wrap { overflow-x: auto; }
.enrolment-table { width: 100%; border-collapse: collapse; }
.enrolment-table { table-layout: fixed; min-width: 0; }
.enrolment-table tr > :first-child { width: 70px; }
.enrolment-table th, .enrolment-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.enrolment-table thead th { color: var(--soft-ink); font-size: .68rem; font-weight: 700; line-height: 1.35; }
.enrolment-table tbody th { color: var(--ink); font-size: .76rem; }
.enrolment-table tbody td { color: var(--soft-ink); font-size: .73rem; }
.enrolment-table tr.youth { background: #f4f8fb; }
.enrolment-table .table-bars { width: 100%; min-width: 0; }
.enrolment-table .bar { width: calc(var(--value) / 110 * 100%); min-width: 0; max-width: 100%; box-sizing: border-box; }
.enrolment-table .bar.over { border-radius: 4px; }
.table-note { margin: 15px 0 0; color: var(--soft-ink); font-size: .76rem; line-height: 1.55; }

.about-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.about-grid article { padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.82); }
.about-grid h3 { font-size: 1rem; }
.about-grid p { margin: 10px 0 0; color: var(--soft-ink); font-size: .81rem; line-height: 1.58; }
.source-panel { display: grid; grid-template-columns: minmax(220px,.65fr) minmax(0,1.35fr); gap: 28px; margin-top: 16px; padding: 24px; border-radius: 17px; background: var(--navy); color: white; }
.source-panel h3 { color: white; }
.source-panel .eyebrow { color: var(--sky); }
.source-panel ul { margin: 0; padding-left: 19px; color: #dcecf4; font-size: .82rem; line-height: 1.8; }
.source-panel a { color: white; }
.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: 900px) {
  .headline-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .enrolment-summary { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .boundary-note { grid-column: 1 / -1; min-height: 130px; }
  .about-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 680px) {
  .section-nav { margin-bottom: 28px; }
  .enrolment-table tr > :first-child { width: 56px; }
  .enrolment-table th, .enrolment-table td { padding-inline: 5px; }
  .section-heading-row { flex-direction: column; gap: 13px; }
  .headline-grid, .enrolment-summary, .about-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 150px; }
  .card-heading { flex-direction: column; gap: 13px; }
  .source-panel { grid-template-columns: 1fr; gap: 16px; }
}

@media (max-width: 460px) {
  .compare-row { grid-template-columns: 50px minmax(0,1fr); padding-inline: 2px; }
  .bar { min-width: 50px; }
  .bar b { font-size: .62rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
