:root {
  color-scheme: light;
  --ink: #142a43;
  --soft-ink: #607386;
  --page: #f3f7fa;
  --panel: #ffffff;
  --panel-soft: #eaf3f7;
  --line: #d8e5ec;
  --navy: #173c63;
  --blue: #347fac;
  --sky: #81b9d0;
  --pale: #dcecf4;
  --warm: #e0a35a;
  --good-bg: #e6f2ee;
  --good-ink: #226857;
  --shadow: 0 18px 45px rgba(20, 42, 67, 0.08);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 92% 3%, rgba(52, 127, 172, 0.12), transparent 24rem),
    radial-gradient(ellipse at 8% 98%, transparent 0 4.5rem, rgba(129, 185, 208, .12) 4.55rem 4.7rem, transparent 4.75rem 7rem, rgba(129, 185, 208, .08) 7.05rem 7.2rem, transparent 7.25rem),
    var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.site-nav {
  display: flex;
  width: min(1160px, calc(100% - 36px));
  min-height: 72px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(216, 229, 236, .9);
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--navy);
  text-decoration: none;
}

.ripple-wordmark { display: flex; min-width: 95px; flex-direction: column; line-height: 1; }
.ripple-wordmark strong { color: var(--navy); font-size: 1.08rem; font-weight: 760; letter-spacing: -.035em; }
.ripple-wordmark small { margin-top: 4px; color: var(--blue); font-size: .58rem; font-weight: 700; letter-spacing: .095em; text-transform: uppercase; }
.brand-divider { width: 1px; height: 32px; background: var(--line); }
.brand-product { color: var(--soft-ink); font-size: .82rem; font-weight: 650; }

.site-menu { position: relative; z-index: 20; }
.site-menu summary { display: flex; min-height: 42px; padding: 0 15px; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.8); color: var(--navy); cursor: pointer; font-size: .84rem; font-weight: 680; list-style: none; box-shadow: 0 6px 20px rgba(20,42,67,.05); }
.site-menu summary::-webkit-details-marker { display: none; }
.site-menu summary::after { width: 7px; height: 7px; border-right: 2px solid var(--blue); border-bottom: 2px solid var(--blue); content: ""; transform: translateY(-2px) rotate(45deg); transition: transform 160ms ease; }
.site-menu[open] summary::after { transform: translateY(2px) rotate(225deg); }
.site-menu-panel { position: absolute; top: calc(100% + 9px); right: 0; display: grid; width: min(330px, calc(100vw - 36px)); padding: 9px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 22px 55px rgba(20,42,67,.16); }
.site-menu-panel a { padding: 10px 12px; border-radius: 9px; color: var(--soft-ink); font-size: .84rem; font-weight: 600; text-decoration: none; }
.site-menu-panel a { order: 2; }
.site-menu-panel a[href="/"] { order: 0; }
.site-menu-panel a[href="/population-and-whanau/"] { order: 1; }
.site-menu-panel a:hover, .site-menu-panel a[aria-current="page"] { background: var(--panel-soft); color: var(--navy); }
.site-menu summary:focus-visible, .site-menu-panel a:focus-visible, .site-brand:focus-visible { outline: 3px solid rgba(52, 127, 172, .25); outline-offset: 2px; }

button, select { font: inherit; }

.app-shell {
  width: min(1160px, calc(100% - 36px));
  margin: 0 auto;
  padding: 34px 0 44px;
}

.page-header { max-width: 770px; }

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

h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.intro {
  max-width: 700px;
  margin: 12px 0 0;
  color: var(--soft-ink);
  font-size: 1rem;
  line-height: 1.6;
}

.selector-panel {
  display: grid;
  grid-template-columns: minmax(260px, 440px) 1fr;
  gap: 24px;
  align-items: end;
  margin: 28px 0 24px;
}

.field-label {
  display: block;
  margin: 0 0 8px 2px;
  color: var(--soft-ink);
  font-size: 0.82rem;
  font-weight: 650;
}

.school-select {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 5px 20px rgba(20, 42, 67, 0.04);
}

.school-select:focus-visible { outline: 3px solid rgba(52, 127, 172, 0.25); outline-offset: 2px; }

.selector-note {
  margin: 0 0 2px;
  color: var(--soft-ink);
  font-size: 0.82rem;
  line-height: 1.45;
}

.profile-heading {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 15px;
}

.profile-heading h2 {
  margin: 0 0 7px;
  color: var(--ink);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 650;
  letter-spacing: -0.035em;
}

.profile-meta, .as-at {
  margin: 0;
  color: var(--soft-ink);
  font-size: 0.86rem;
  line-height: 1.5;
}

.as-at { flex: 0 0 auto; padding-top: 7px; text-align: right; }

.top-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.72fr) minmax(430px, 1.7fr);
  gap: 16px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.45fr) minmax(280px, 0.8fr);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.roll-card, .eqi-card, .ethnicity-card, .details-card { padding: 21px; }

.card-label { color: var(--soft-ink); font-size: 0.8rem; font-weight: 600; }

.roll-number {
  margin-top: 10px;
  color: var(--navy);
  font-size: clamp(2.8rem, 7vw, 4.5rem);
  font-weight: 680;
  letter-spacing: -0.065em;
  line-height: 0.95;
}

.roll-number small {
  color: var(--soft-ink);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0;
}

.donation-pill {
  display: inline-flex;
  align-items: center;
  margin-top: 19px;
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--navy);
  font-size: 0.75rem;
  line-height: 1.3;
}

.eqi-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }

.eqi-band {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 650;
}

.eqi-number { color: var(--navy); font-size: 2.25rem; font-weight: 680; letter-spacing: -0.04em; line-height: 1; text-align: right; }
.eqi-number small { display: block; margin-top: 5px; color: var(--soft-ink); font-size: 0.7rem; font-weight: 500; letter-spacing: 0; }

.eqi-scale { margin-top: 27px; padding: 0 4px; }

.eqi-track {
  position: relative;
  height: 15px;
  border-radius: 999px;
  background: linear-gradient(90deg, #dcecf4 0%, #9bc8d7 48%, #347fac 74%, #173c63 100%);
}

.eqi-marker {
  position: absolute;
  top: -9px;
  left: var(--eqi-position);
  width: 3px;
  height: 33px;
  border-radius: 4px;
  background: var(--warm);
  transform: translateX(-50%);
}

.eqi-marker::before {
  position: absolute;
  top: -4px;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warm);
  content: "";
  transform: translate(-50%, -50%);
}

.eqi-axis, .eqi-groups { display: flex; justify-content: space-between; gap: 10px; color: var(--soft-ink); font-size: 0.7rem; }
.eqi-axis { margin-top: 10px; }
.eqi-groups { margin-top: 5px; }
.eqi-groups span:nth-child(2) { text-align: center; }
.eqi-groups span:last-child { text-align: right; }

.eqi-explainer {
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--soft-ink);
  font-size: 0.8rem;
  line-height: 1.55;
}

.card-title-row { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; margin-bottom: 20px; }
.card-title-row h3, .details-card h3 { margin: 0; color: var(--ink); font-size: 1.08rem; font-weight: 680; }
.card-title-row p { margin: 5px 0 0; color: var(--soft-ink); font-size: 0.78rem; }
.total-label { color: var(--soft-ink); font-size: 0.75rem; text-align: right; }

.bars { display: grid; gap: 15px; }
.bar-row { display: grid; grid-template-columns: 86px minmax(120px, 1fr) 158px; gap: 14px; align-items: center; }
.bar-name { color: var(--ink); font-size: 0.86rem; }
.bar-track { height: 11px; overflow: hidden; border-radius: 999px; background: var(--panel-soft); }
.bar-fill { width: var(--bar-width); height: 100%; border-radius: inherit; background: var(--blue); transition: width 240ms ease; }
.bar-row[data-group="Māori"] .bar-fill { background: var(--navy); }
.bar-value { color: var(--soft-ink); font-size: 0.78rem; text-align: right; white-space: nowrap; }
.bar-value strong { color: var(--ink); font-weight: 680; }

.empty-roll {
  padding: 30px 18px;
  border-radius: 12px;
  background: var(--panel-soft);
  color: var(--soft-ink);
  font-size: 0.9rem;
  line-height: 1.55;
  text-align: center;
}

.footnote, .source-note {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--soft-ink);
  font-size: 0.74rem;
  line-height: 1.5;
}

.details-list { margin: 18px 0 0; }
.detail-row { display: grid; grid-template-columns: 116px 1fr; gap: 13px; padding: 11px 0; border-top: 1px solid var(--line); }
.detail-row:first-child { border-top: 0; padding-top: 0; }
.detail-row dt { color: var(--soft-ink); font-size: 0.75rem; }
.detail-row dd { margin: 0; color: var(--ink); font-size: 0.8rem; line-height: 1.45; }

.data-notes {
  margin-top: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.7);
}

.data-notes summary { color: var(--navy); font-size: 0.88rem; font-weight: 680; }
.data-notes p { margin: 12px 0 0; color: var(--soft-ink); font-size: 0.78rem; line-height: 1.55; }
.loading { margin-top: 30px; color: var(--soft-ink); }

.youth-context-card { margin-top: 16px; padding: 21px; }
.youth-context-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.youth-context-heading h3 { margin: 0; font-size: 1.08rem; font-weight: 680; }
.youth-context-heading p { margin: 5px 0 0; color: var(--soft-ink); font-size: .82rem; line-height: 1.45; }
.youth-context-total { flex: 0 0 auto; text-align: right; }
.youth-context-total strong { display: block; color: var(--navy); font-size: 1.8rem; letter-spacing: -.045em; line-height: 1; }
.youth-context-total span { display: block; margin-top: 5px; color: var(--soft-ink); font-size: .72rem; }
.youth-age-strip { display: flex; height: 15px; overflow: hidden; margin-top: 20px; border-radius: 999px; background: var(--panel-soft); }
.youth-age-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; margin-top: 16px; }
.youth-age-item { padding: 13px 14px; border-radius: 12px; background: var(--panel-soft); }
.youth-age-label { display: flex; align-items: center; gap: 7px; color: var(--soft-ink); font-size: .76rem; }
.youth-age-label::before { width: 8px; height: 8px; border-radius: 50%; background: var(--age-colour); content: ""; }
.youth-age-item strong { display: block; margin-top: 8px; color: var(--navy); font-size: 1.3rem; }
.youth-age-item small { display: block; margin-top: 3px; color: var(--soft-ink); font-size: .69rem; }
.youth-context-note { margin: 15px 0 0; color: var(--soft-ink); font-size: .75rem; line-height: 1.5; }

@media (max-width: 840px) {
  .top-grid, .content-grid { grid-template-columns: 1fr; }
  .selector-panel { grid-template-columns: 1fr; gap: 10px; }
  .selector-note { margin-top: 0; }
}

@media (max-width: 600px) {
  .app-shell { width: min(100% - 24px, 1160px); padding-top: 24px; }
  .profile-heading { display: block; }
  .as-at { margin-top: 7px; padding-top: 0; text-align: left; }
  .roll-card, .eqi-card, .ethnicity-card, .details-card { padding: 17px; }
  .bar-row { grid-template-columns: 72px minmax(90px, 1fr); gap: 10px; }
  .bar-value { grid-column: 2; margin-top: -7px; text-align: left; }
  .eqi-groups { font-size: 0.66rem; }
  .detail-row { grid-template-columns: 96px 1fr; }
  .youth-context-heading { display: block; }
  .youth-context-total { margin-top: 14px; text-align: left; }
  .youth-age-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .site-nav { min-height: 0; padding: 15px 0; align-items: center; gap: 10px; }
  .site-brand { gap: 10px; }
  .brand-product { font-size: .76rem; }
  .site-menu { flex: 0 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  .bar-fill { transition: none; }
}
