@import url('tokens.css');

/* --- Page shell ----------------------------------------------------------- */
.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-7);
}

.banner-mock {
  margin-bottom: var(--gap-dashboard);
}

.banner-mock strong { color: var(--series-8); } /* 5:1 on the banner fill; the orange was 2.8:1 */

/* --- Summary layer: the plain-language answer, above the charts that back
   it up. Brand-accent border (not the mock-data warning's orange, and not
   a plain white card like every chart below it) so it reads as the
   headline, not one more panel in the list. */
.card--summary {
  border-left: 4px solid var(--brand-primary);
  margin-bottom: var(--gap-dashboard);
}

.card--summary__eyebrow {
  margin: 0 0 var(--space-2);
  font-size: var(--text-caption);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand-primary);
}

.card--summary__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.card--summary__list li {
  font-size: var(--text-h3);
  line-height: var(--leading-body);
  color: var(--text-primary);
}

.page-lede {
  color: var(--text-secondary);
  font-size: var(--text-body);
  max-width: 68ch;
  margin: 0 0 var(--gap-dashboard);
}

/* --- KPI snapshot row --------------------------------------------------
   Guide: KPI values should be the largest, boldest element, kept simple
   and consistent across tiles - one accent colour, not one per tile. */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--gap-dashboard);
  margin-bottom: var(--gap-dashboard);
}

.kpi-tile {
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
}

/* --- Filter bar ------------------------------------------------------------ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: flex-end;
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--gap-dashboard);
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  /* Without these two, a flex item won't shrink below its content's
     natural width (the flexbox "min-width: auto" default) - fine for a
     short region name, but the open-text question filter's longest
     option is a full sentence, which blew the select out to ~780px and
     forced the whole page to scroll sideways on a phone. flex-basis gives
     it a sane width to grow from in a wide filter bar; min-width: 0 lets
     it shrink past that on a narrow one instead of refusing to. */
  flex: 1 1 12rem;
  min-width: 0;
}

.filter-field label {
  font-size: var(--text-caption);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.filter-field select {
  font: inherit;
  font-size: var(--text-small);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-page);
  color: var(--text-primary);
  /* width: 100% (not min-width alone) is what stops a long option's text
     dictating the box's width - the closed select now sizes to its
     .filter-field parent and ellipsis-truncates the selected value
     instead. The dropdown list itself still shows full option text when
     opened; only the closed box is width-constrained. */
  width: 100%;
  min-width: 0;
  transition: border-color 0.15s ease;
}

.filter-field select:hover { border-color: var(--brand-primary-light); }
.filter-field select:focus-visible { border-color: var(--brand-primary); }

.filter-reset {
  font: inherit;
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--brand-primary);
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.filter-reset:hover { background: var(--surface-sunken); border-color: var(--brand-primary-light); }

@media (prefers-reduced-motion: reduce) {
  .filter-field select, .filter-reset { transition: none; }
}

.filter-status {
  font-size: var(--text-small);
  color: var(--text-secondary);
  margin-left: auto;
  align-self: center;
}

/* --- Pager (open-text response list) ---------------------------------------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.pager__button {
  font: inherit;
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--brand-primary);
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
}

.pager__button:hover:not(:disabled) { background: var(--surface-sunken); }

.pager__button:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.6;
}

.pager__status {
  font-size: var(--text-small);
  color: var(--text-secondary);
}

/* --- Section / view grid -----------------------------------------------
   Tightened from gap-dashboard/space-3 (20px/12px): sections were reading
   as more separated from each other than the numbered heading + card
   borders already make them, at the cost of screen real estate on a
   laptop. Kept enough to still read as distinct groups, not compressed
   into one continuous block. */
.view-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}

.view-section {
  display: grid;
  gap: var(--space-2);
}

.view-section__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.view-section__heading h2 {
  font-size: var(--text-h1);
  color: var(--brand-primary);
}

.view-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  background: var(--brand-primary);
  color: var(--text-inverse);
  font-size: var(--text-small);
  font-weight: 700;
  margin-right: var(--space-2);
}

.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: var(--space-4);
  align-items: start;
}

.cards-row--wide { grid-template-columns: 1fr; }

/* --- View toggle (avg / distribution) --------------------------------------- */
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.view-toggle button {
  font: inherit;
  font-size: var(--text-small);
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  background: var(--surface-card);
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
}

.view-toggle button[aria-pressed='true'] {
  background: var(--brand-primary);
  color: var(--text-inverse);
}

.view-toggle button:not(:last-child) { border-right: 1px solid var(--border-strong); }

/* --- Charts (D3 draws into these) ------------------------------------------- */
.chart {
  width: 100%;
  min-height: var(--chart-min-height);
}

.chart-scroll {
  overflow-x: auto;
  overflow-y: hidden;
}

/* No fill here: a stylesheet rule outranks an SVG fill attribute, so a
   blanket fill on every chart label overrode each muted fill set in JS -
   suppressed "×" markers and "suppressed (n<5)" notes rendered solid black
   instead of receding. SVG text already defaults to black (= text-primary). */
svg text { font-family: var(--font-body); }

.axis-label {
  font-size: var(--text-caption);
  fill: var(--text-secondary);
}

.axis path.domain,
.axis line { stroke: var(--border-strong); }
.axis text { fill: var(--text-secondary); font-size: var(--text-caption); }

.gridline { stroke: var(--border-subtle); }

.bar-label {
  font-size: var(--text-caption);
  fill: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.item-row-label {
  font-size: var(--text-small);
  fill: var(--text-primary);
}

.pair-bracket {
  stroke: var(--border-strong);
  stroke-width: 1.5;
  fill: none;
}

.pair-tag {
  font-size: 0.65rem;
  fill: var(--text-muted);
  font-style: italic;
}

/* Thin line joining one row's dots in the gender dot plots. */
.dot-connector { stroke: var(--border-strong); stroke-width: 2; }

/* Grey "hidden" tag for a result hidden for privacy (U.drawHiddenChip). */
.hidden-chip rect { fill: var(--surface-sunken); stroke: var(--border-strong); stroke-dasharray: 3 2; }
.hidden-chip text { fill: var(--text-secondary); font-size: 10.5px; font-weight: 600; }
.hidden-chip:focus-visible { outline: none; }
.hidden-chip:focus-visible rect { stroke: var(--brand-primary); stroke-width: 2; stroke-dasharray: none; }

/* Small "≈" badge on a row whose statement was asked in two wordings. */
.pair-badge circle { fill: var(--surface-sunken); stroke: var(--border-strong); }
.pair-badge text { fill: var(--text-secondary); font-size: 11px; font-weight: 700; }
.pair-badge:focus-visible { outline: none; }
.pair-badge:focus-visible circle { stroke: var(--brand-primary); stroke-width: 2; }

/* --- Legend ------------------------------------------------------------ */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: var(--text-small);
  color: var(--text-secondary);
  margin-top: var(--space-2);
}

.legend__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.legend__swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 3px;
  flex: none;
}

.legend__marker {
  flex: none;
}

.legend__swatch--hatched {
  background-image: repeating-linear-gradient(
    45deg,
    var(--likert-unknown),
    var(--likert-unknown) 2px,
    var(--surface-card) 2px,
    var(--surface-card) 4px
  );
  border: 1px solid var(--border-strong);
}

/* --- Small multiples shared axis ruler ------------------------------------- */
.small-multiples-ruler {
  display: flex;
  justify-content: space-between;
  max-width: 320px;
  margin: 0 0 var(--space-2) 150px;
  font-size: var(--text-caption);
  color: var(--text-muted);
  font-weight: 600;
}

/* --- Tooltip ------------------------------------------------------------- */
.viz-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--brand-primary-dark);
  color: var(--text-inverse);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-small);
  line-height: var(--leading-tight);
  box-shadow: var(--shadow-raised);
  max-width: 22rem;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.1s ease;
}
.viz-tooltip.is-visible { opacity: 1; }
.viz-tooltip strong { display: block; margin-bottom: 2px; }
.viz-tooltip .tt-muted { color: var(--ramp-2); }

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

/* --- Suppression grid (participation by region x school level) ------------ */
/* Region column, then one column per year level; --level-count is set from
   JS. Narrowed on phones (see the max-width: 640px block). */
.suppression-grid {
  display: grid;
  grid-template-columns: 10rem repeat(var(--level-count, 8), minmax(0, 1fr));
  gap: 2px;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: var(--text-small);
}

.suppression-grid__cell {
  background: var(--surface-card);
  padding: var(--space-2);
  text-align: center;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-variant-numeric: tabular-nums;
}

.suppression-grid__cell--header {
  background: var(--surface-sunken);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: var(--text-caption);
}

.suppression-grid__cell--suppressed {
  background: repeating-linear-gradient(
    45deg,
    var(--surface-sunken),
    var(--surface-sunken) 4px,
    var(--surface-card) 4px,
    var(--surface-card) 8px
  );
}

.suppression-grid__cell--zero {
  color: var(--text-muted);
  background: var(--surface-card);
}

.suppression-grid__key { margin-top: var(--space-3); }
.suppression-grid__key-ramp { width: 3rem; height: 0.85rem; border-radius: 3px; flex: none; }
.suppression-grid__key-swatch {
  min-width: 2.25rem; height: 1.5rem; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-subtle); border-radius: 3px;
  font-size: var(--text-caption);
}

.suppression-grid__count {
  font-weight: 700;
  color: var(--brand-primary);
}

/* --- Suppression list: the phone version of the grid above, one region per
   row, expandable to its year levels (U.renderSuppressionList). The summary
   is the tap target - 44px minimum, per the forum's thumb-not-cursor note. */
.suppression-list__region {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  overflow: hidden;
}

.suppression-list__region summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-sunken);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.suppression-list__region summary::-webkit-details-marker { display: none; }
.suppression-list__region summary::after {
  content: '▸';
  color: var(--text-muted);
  transition: transform 0.15s ease;
}
.suppression-list__region[open] summary::after { transform: rotate(90deg); }

.suppression-list__total {
  font-weight: 400;
  color: var(--text-secondary);
  font-size: var(--text-small);
}

.suppression-list__years { padding: var(--space-2) var(--space-4) var(--space-3); }

.suppression-list__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-variant-numeric: tabular-nums;
}
.suppression-list__row:last-child { border-bottom: none; }

.suppression-list__count { font-weight: 700; color: var(--brand-primary); }
.suppression-list__empty { color: var(--text-muted); font-size: var(--text-small); padding: var(--space-2) 0; }

@media (prefers-reduced-motion: reduce) {
  .suppression-list__region summary::after { transition: none; }
}

/* --- Outcomes mobile fallback: one activity, sorted list -------------------
   Reuses the general-outcomes lollipop renderer (outcomes.renderGeneral)
   filtered to the selected activity, so this needs no chart code of its
   own - just a wrapper wide enough for its compact layout. */
#chart-outcomes-mobile { width: 100%; }

/* --- Facet grid (skills & identity, small multiples) ----------------------- */
.facet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
}

.facet-grid__cell {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
}

/* Each panel is drawn at its cell's measured content width (see the chart
   modules), so this renders it 1:1 - no scaling, no sideways scroll. */
.facet-grid__cell svg {
  display: block;
  width: 100%;
  height: auto;
}

.facet-grid__title {
  font-size: var(--text-small);
  font-weight: 600;
  margin-bottom: var(--space-2);
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
}

.facet-grid__n {
  color: var(--text-muted);
  font-weight: 400;
}

.jobs-imagined-more {
  margin-top: var(--space-3);
  text-align: center;
}

/* --- Self-perception panel: visually distinct from the influence charts,
   since these items are about belonging/confidence, not what shapes a
   decision - a different accent colour and a tinted card make that a
   glance-level distinction, not just a line of caption text. */
/* Marked with a label (.card__kind), not a tinted card: a pink tint read as
   decoration and sat oddly next to the inclusive colour choices elsewhere. */
.card__kind {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0 0 var(--space-2);
  padding: 2px var(--space-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: var(--text-caption);
  font-weight: 600;
  color: var(--text-secondary);
}

/* --- Teacher sign-in gate ---------------------------------------------------
   Two states of the same form: a landing card when no school is picked yet
   (.teacher-gate on its own), and a compact "signed in as X" strip once one
   is (.teacher-gate--active). This is an identification step, not
   authentication - there's no password and no account behind it, since the
   dataset has no real credentials to check. Say so in the copy, not just here. */
.teacher-gate {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-raised);
  padding: var(--space-6) var(--space-6) var(--space-5);
  margin-bottom: var(--space-6);
  max-width: 34rem;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  transition: max-width 0.2s ease, padding 0.2s ease;
}

.teacher-gate__title {
  font-size: var(--text-h1);
  color: var(--brand-primary);
  margin-bottom: var(--space-2);
}

.teacher-gate__subtitle {
  color: var(--text-secondary);
  font-size: var(--text-small);
  max-width: 40ch;
  margin: 0 auto var(--space-5);
}

.teacher-gate__form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: stretch;
}

/* flex: none - in this column layout the filter bar's flex-basis would
   otherwise become a 200px height for each field, leaving big gaps. */
.teacher-gate__form .filter-field { text-align: left; flex: none; }
.teacher-gate--active .teacher-gate__form .filter-field { flex: 1 1 12rem; }
.teacher-gate__form .filter-field select { min-width: 0; width: 100%; padding: var(--space-3); font-size: var(--text-body); }

.teacher-gate__form .filter-reset,
.teacher-gate__form .filter-status { display: none; }

/* Compact "signed in" state: shrink to a horizontal strip, reuse the same
   filter-bar look as the provider page so returning here doesn't feel like
   a different app. */
.teacher-gate--active {
  max-width: none;
  text-align: left;
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-card);
}

.teacher-gate--active .teacher-gate__title {
  font-size: var(--text-h3);
  margin-bottom: 0;
}

.teacher-gate--active .teacher-gate__subtitle {
  margin: var(--space-1) 0 var(--space-4);
  max-width: none;
}

.teacher-gate--active .teacher-gate__form {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-4);
}

.teacher-gate--active .teacher-gate__form .filter-field select { width: auto; padding: var(--space-2) var(--space-3); font-size: var(--text-small); }

.teacher-gate--active .teacher-gate__form .filter-reset,
.teacher-gate--active .teacher-gate__form .filter-status { display: block; }

.teacher-gate__badge {
  display: inline-block;
  font-size: var(--text-caption);
  color: var(--text-muted);
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
  padding: 2px var(--space-2);
  margin-bottom: var(--space-3);
}

.teacher-gate--active .teacher-gate__badge { display: none; }

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

/* --- Data notes / footer --------------------------------------------------- */
.data-notes {
  font-size: var(--text-small);
  color: var(--text-secondary);
}

.data-notes ul { margin: 0; padding-left: 1.2em; }
.data-notes li { margin-bottom: var(--space-2); }

.page-footer {
  margin-top: var(--space-7);
}

/* Guide: "The footer should note the contact details for the team
   responsible for the dashboard. On the far right, the date of the data
   snapshot." */
.page-footer__bar {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  background: var(--surface-sunken);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
  font-size: var(--text-caption);
}

.page-footer__bar a { color: var(--brand-primary); }

@media (max-width: 720px) {
  .cards-row { grid-template-columns: 1fr; }
  .filter-status { margin-left: 0; }
}

/* --- Data tables (chart text alternatives, open-text list) ----------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-2);
  font-size: var(--text-small);
}

.data-table th,
.data-table td {
  text-align: left;
  vertical-align: top;
  padding: var(--space-2);
}

.data-table th { border-bottom: 1px solid var(--border-strong); }
.data-table td { border-bottom: 1px solid var(--border-subtle); }
.data-table [data-align='right'] { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Desktop/mobile swaps ---------------------------------------------
   A few charts genuinely don't reflow into something a 390px screen can
   read (seven overlapping series with confidence intervals; an eight-
   column grid) - forum feedback was explicit that these need a different
   representation below the breakpoint, not a squeezed version of the same
   one. Both versions render into the page always; this pair of classes
   picks which one is visible. .filter-field.mobile-only is a specific
   override so a shown mobile field still gets .filter-field's flex column
   layout, not the generic block value below. */
.mobile-only { display: none; }

@media (max-width: 640px) {
  .desktop-only { display: none; }
  .mobile-only { display: block; }
  .filter-field.mobile-only { display: flex; }
  /* Same tie as .filter-field.mobile-only above, the other direction: the
     .view-toggle{display:flex} rule below is equal specificity to
     .desktop-only and comes later in the cascade, so it would otherwise
     win and undo the hide. */
  .view-toggle.desktop-only { display: none; }
}

/* --- Phones ---------------------------------------------------------------
   The charts switch to their own compact layouts in JS below each chart's
   designed width (label above each row, drawn at the card's real width -
   see U.rowGeometry). This block frees up the width they draw into and
   restacks the pieces that are plain HTML. */
@media (max-width: 640px) {
  .page { padding: var(--space-4) var(--space-3) var(--space-6); }
  .card__header { padding: var(--space-3); }
  .card__body { padding: var(--space-3); }
  .kpi-row { gap: var(--space-3); }
  .kpi-tile { padding: var(--space-3); }
  .view-section__heading h2 { font-size: var(--text-h2); }
  .view-toggle { display: flex; width: 100%; }
  .view-toggle button { flex: 1 1 0; padding: var(--space-3) var(--space-1); min-height: 44px; }
  .legend { gap: var(--space-1) var(--space-3); font-size: var(--text-caption); }
  .facet-grid__cell { padding: var(--space-2); }

  /* The filter bar is the most-used control here, and a teacher scrolling
     a long chart shouldn't have to scroll back to the top to reach it -
     it sticks under the (non-sticky) banner/nav above once they scroll
     past it. Same treatment for the teacher page's compact signed-in bar,
     which is that page's equivalent of a filter bar. */
  .filter-bar,
  .teacher-gate--active {
    position: sticky;
    top: var(--sticky-offset, 0px);
    z-index: 20;
    padding: var(--space-3);
    gap: var(--space-3);
    box-shadow: var(--shadow-raised);
  }

  /* Thumb-sized tap targets throughout, not just mouse-sized ones. */
  .filter-reset,
  .pager__button {
    min-height: 44px;
    padding: var(--space-2) var(--space-4);
  }
  summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: var(--space-2) 0;
  }

  /* Tables restack as one card per row: the header row is hidden visually
     but kept for screen readers, and each cell carries its column name as
     a label. The first column (the response, or the thing being counted)
     reads as the card's headline, unlabelled. */
  .data-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td { display: block; width: 100%; }
  .data-table tr { padding: var(--space-2) 0; border-bottom: 1px solid var(--border-subtle); }
  .data-table td {
    display: flex;
    gap: var(--space-3);
    border: 0;
    padding: 2px 0;
    text-align: left;
  }
  .data-table td::before {
    content: attr(data-label);
    flex: 0 0 38%;
    color: var(--text-muted);
    font-size: var(--text-caption);
    font-weight: 600;
  }
  .data-table td:first-child {
    display: block;
    padding-bottom: var(--space-1);
    color: var(--text-primary);
  }
  .data-table td:first-child::before { content: none; }
  .data-table [data-align='right'] { text-align: left; }
}

/* ==========================================================================
   Front-end makeover (frontend-makeover branch)
   Calmer, report-like layout. Rules here come last on purpose, so they win
   over the older ones above without having to edit each of them.
   ========================================================================== */

/* --- Slim header: title, subtitle, page tabs, about button ---------------- */
.site-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-2) var(--space-5);
  padding: var(--space-3) 0 0;
  border-top: 4px solid var(--brand-primary);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-4);
}

.site-header__brand { min-width: 0; padding-bottom: var(--space-3); }

.site-header__title {
  margin: 0;
  font-size: var(--text-h2);
  font-weight: 700;
  color: var(--brand-primary);
  line-height: var(--leading-tight);
}

.site-header__subtitle {
  margin: 2px 0 0;
  font-size: var(--text-small);
  color: var(--text-secondary);
}

.site-tabs {
  display: flex;
  gap: var(--space-1);
  align-self: end;
}

.site-tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-3);
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}

.site-tabs a:hover { color: var(--brand-primary); }
.site-tabs a[aria-current='page'] { color: var(--brand-primary); border-bottom-color: var(--brand-primary); }

.site-header__info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: var(--brand-primary);
  border: 1px solid var(--border-strong);
  margin-bottom: var(--space-3);
}

.site-header__info:hover { background: var(--surface-sunken); }

@media (max-width: 760px) {
  /* Title and about button on one row, tabs on their own scrolling row. */
  .site-header { grid-template-columns: minmax(0, 1fr) auto; }
  .site-tabs { grid-column: 1 / -1; grid-row: 2; overflow-x: auto; scrollbar-width: none; }
  .site-header__info { width: 44px; height: 44px; }
}

/* --- Section nav: sticky jump links, current section highlighted ---------- */
.section-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  margin-bottom: var(--space-4);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  scrollbar-width: none;
}

.section-nav::-webkit-scrollbar,
.site-tabs::-webkit-scrollbar { display: none; }

.section-nav a {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.section-nav a:hover { color: var(--brand-primary); border-color: var(--brand-primary); }
.section-nav a[aria-current='true'] {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--text-inverse);
}

/* Anchored sections land below the sticky nav, not under it. */
.view-section { scroll-margin-top: 64px; }

@media (max-width: 640px) {
  .section-nav a { min-height: 44px; }
  /* On the overview the filter bar sticks just below the section nav. */
  .section-nav ~ .overview-bar .filter-bar { top: 61px; }
}

/* --- KPIs and filters in one band ----------------------------------------- */
.overview-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-4);
  align-items: stretch;
  margin-bottom: var(--gap-dashboard);
}

.overview-bar .kpi-row,
.overview-bar .filter-bar { margin-bottom: 0; }
.overview-bar .filter-field { flex: 1 1 14rem; }
.overview-bar .filter-status { flex-basis: 100%; margin-left: 0; }

.kpi-row {
  display: flex;
  align-items: center;
  gap: 0;
}

/* Lighter tiles: a large number and a small label, no fill, thin dividers. */
.kpi-tile {
  background: none;
  border: 0;
  border-radius: 0;
  padding: var(--space-2) var(--space-5);
}

.kpi-tile + .kpi-tile { border-left: 1px solid var(--border-subtle); }
.kpi-tile:first-child { padding-left: 0; }
.kpi__value { font-size: 2rem; }
.kpi__label { margin-top: var(--space-1); font-size: var(--text-small); }

.filter-bar { border-color: var(--border-subtle); }

.filter-status__count {
  display: inline-block;
  margin-right: var(--space-2);
  padding: 1px var(--space-2);
  border-radius: 999px;
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  font-weight: 600;
  color: var(--text-primary);
}

@media (max-width: 1100px) {
  .overview-bar { grid-template-columns: 1fr; }
  .kpi-row { flex-wrap: wrap; }
}

@media (max-width: 640px) {
  .kpi-row { display: grid; grid-template-columns: repeat(2, 1fr); }
  .kpi-tile { padding: var(--space-2) 0; }
  .kpi-tile + .kpi-tile { border-left: 0; }
  .kpi__value { font-size: 1.5rem; }
}

/* --- Sections -------------------------------------------------------------- */
.view-grid { gap: var(--space-7); }
.view-section { gap: var(--space-4); }
.view-section__heading {
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}
.view-section__heading h2 { font-size: 1.375rem; color: var(--text-primary); }
.view-number {
  background: none;
  color: var(--brand-primary);
  border: 2px solid var(--brand-primary);
}
.card__body { padding: var(--space-4) var(--space-5) var(--space-5); }
.card__note { color: var(--text-secondary); }

/* --- Highlight selector and interactive legends --------------------------- */
.highlight-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: var(--text-small);
}

.highlight-field label { font-weight: 600; color: var(--text-secondary); }
.highlight-field select {
  font: inherit;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  max-width: 100%;
}

.legend__item--button {
  font: inherit;
  color: inherit;
  background: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 2px var(--space-2);
  cursor: pointer;
}

.legend__item--button:hover,
.legend__item--button[aria-pressed='true'] { border-color: var(--border-strong); background: var(--surface-card); }

/* Emphasis: one series stays at full strength, the rest fade. */
.series-mark { transition: opacity 0.15s ease; }
.is-emphasising .series-mark:not(.is-emphasised) { opacity: 0.12; }

/* --- Footer: About card above a one-line bar ------------------------------- */
.data-notes { margin-top: var(--space-7); }
.page-footer { margin-top: var(--space-4); }
.page-footer__bar { align-items: center; margin-bottom: 0; }
.page-footer__reminder { color: var(--text-primary); font-weight: 700; }

/* --- Motion: a short fade on filter changes only -------------------------- */
@keyframes sit-refresh { from { opacity: 0.35; } to { opacity: 1; } }
.view-grid.is-refreshing svg { animation: sit-refresh 0.3s ease; }

@media (prefers-reduced-motion: reduce) {
  .view-grid.is-refreshing svg,
  .series-mark,
  .section-nav a { animation: none; transition: none; }
  html { scroll-behavior: auto; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* --- Print: the overview as a clean PDF ------------------------------------ */
/* The mock-data warning is printed in the top margin of every page (a page
   margin box), so no printed page can be shared without it. The on-screen
   banner still prints in full on page 1. */
@page {
  size: A4;
  margin: 20mm 12mm 14mm;
  @top-center {
    content: "MOCK DATA: every number in this report is made-up test data. Not real survey results.";
    font-family: 'Open Sans', sans-serif;
    font-size: 9pt;
    font-weight: 700;
    color: #AD4206;
    border-bottom: 1.5pt solid #F76919;
    vertical-align: bottom;
    padding-bottom: 2mm;
  }
}

@media print {
  html, body { background: #fff; }
  .page { max-width: none; padding: 0; }
  .site-tabs, .site-header__info, .section-nav, .filter-bar, .view-toggle,
  .highlight-field, .data-table-toggle, details, .jobs-imagined-more,
  .viz-tooltip, #outcomes-single { display: none !important; }
  .overview-bar { grid-template-columns: 1fr; }
  .banner-mock { break-inside: avoid; }
  .card { box-shadow: none; break-inside: avoid; page-break-inside: avoid; }
  .view-section__heading { break-after: avoid; page-break-after: avoid; }
  .view-section { break-before: auto; }
  .card--summary, .kpi-row, .data-notes { break-inside: avoid; }
  /* A card taller than a page has to break; its panels and charts don't. */
  .facet-grid__cell, .chart-scroll, .legend, .card__header, .card__note { break-inside: avoid; page-break-inside: avoid; }
  .chart-scroll { overflow: visible; }
  svg { max-width: 100%; height: auto; }
  a { color: inherit; text-decoration: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
