:root {
  --stats-motion-duration: 220ms;
  --stats-motion-easing: cubic-bezier(0.22, 1, 0.36, 1);
}

.stats-product-page,
.stats-explorer-page {
  --stats-ink: var(--ink);
  --stats-paper: var(--paper);
  --stats-panel: var(--paper);
  --stats-line: var(--line);
  --stats-soft-line: var(--line);
  --stats-muted: var(--muted);
  --stats-orange: var(--orange);
  --stats-orange-dark: var(--orange-dark);
  /* Ranking name colours on the neutral paper (owner-selected set, 2026-09-15):
     red for current champions, brick for retired champions, near-black for
     current drivers, grey for retired drivers. Each keeps at least 4.5:1 on
     both the paper and the row hover background; the hover is kept at #f5f5f5
     for that reason, and the owner's #777777 retired grey became #707070. */
  --stats-champion: #e10600;
  --stats-champion-former: #b94a48;
  --stats-entity-current: #111111;
  --stats-entity-former: #707070;
  --stats-row-line: rgba(26, 26, 26, 0.09);
  --stats-row-hover: #f5f5f5;
  min-width: 0;

  background: var(--stats-paper);
  color: var(--stats-ink);
}

.stats-product-page .wrap,
.stats-explorer-page .wrap {
  box-sizing: border-box;
  width: 100%;
  margin-inline: auto;
  max-width: var(--max);
  padding-inline: var(--gutter);
}

.stats-product-page [hidden],
.stats-explorer-page [hidden],
.single-metric-mode .custom-only,
.custom-table-mode .single-only {
  display: none !important;
}

.stats-product-page button,
.stats-product-page input,
.stats-explorer-page button,
.stats-explorer-page input,
.stats-explorer-page select {
  font: inherit;
}

.stats-product-page a:focus-visible,
.stats-product-page button:focus-visible,
.stats-product-page input:focus-visible,
.stats-product-page summary:focus-visible,
.stats-explorer-page a:focus-visible,
.stats-explorer-page button:focus-visible,
.stats-explorer-page input:focus-visible,
.stats-explorer-page select:focus-visible,
.stats-explorer-page summary:focus-visible {
  outline: 3px solid var(--stats-orange-dark);
  outline-offset: 3px;
}

.stats-product-page .button.secondary:hover,
.stats-product-page .button.ghost:hover,
.stats-explorer-page .button.secondary:hover,
.stats-explorer-page .button.ghost:hover {
  border-color: var(--stats-orange);
  background: #fff6ed;
  color: var(--stats-orange-dark);
  box-shadow: none;
  transform: translateY(-1px);
}

.stats-product-page .button.secondary:active,
.stats-product-page .button.ghost:active,
.stats-explorer-page .button.secondary:active,
.stats-explorer-page .button.ghost:active {
  background: #f5e9dc;
  color: var(--stats-ink);
  transform: translateY(0);
}

.stats-product-hero {
  background: var(--paper);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}

.stats-product-hero-grid,
.stats-ranking-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  min-height: 0;
  align-items: center;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  gap: 1rem;
}

.stats-product-hero .kicker {
  color: var(--orange-dark);
}

.stats-product-hero h1 {
  max-width: none;
  font-size: var(--text-title);
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
  letter-spacing: normal;
}

.stats-product-page[data-stats-catalogue] .stats-product-hero h1 {
  max-width: 930px;
  font-size: var(--text-title);
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
  letter-spacing: normal;
}

.stats-product-page[data-stats-catalogue] .stats-product-hero h1 span,
.stats-product-page[data-stats-catalogue] .stats-product-hero h1 em {
  display: block;
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
  letter-spacing: normal;
}

.stats-product-page[data-stats-catalogue] .stats-product-hero h1 em {
  margin-left: clamp(0px, 6vw, 86px);
  font-style: normal;
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
  letter-spacing: normal;
}

.stats-product-hero .stats-state-label { color: #bababa; }

[data-statistic-detail] .stats-product-hero h1 {
  overflow-wrap: anywhere;
  font-size: var(--text-title);
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
  letter-spacing: normal;
}

.stats-product-hero-copy > p,
.stats-ranking-hero-grid > p {
  max-width: 520px;
  margin: 0;
  line-height: 1.55;
  color: var(--muted);
  font-size: var(--text-body);
}

.stats-product-actions {
  display: flex;
  margin-top: 0;
}

.stats-primary-cta {
  width: min(100%, 420px);
  min-width: 320px;
  justify-content: center;
  min-height: 44px;
}

.stats-catalogue-section {
  padding: 1.5rem 0 3rem;
}

/* The catalogue is taller than a viewport, so section-level intersection
   ratios can otherwise leave its first content blank on shorter screens. */
.stats-product-page .stats-catalogue-section.scene-pending {
  opacity: 1;
  transform: none;
  clip-path: none;
}

.stats-catalogue-head {
  border-bottom: 0;
  padding-bottom: 0;
}

.stats-state-label {
  display: block;
  margin-bottom: 9px;
  color: var(--stats-muted);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
}

.stats-catalogue-head h2,
.stats-metric-group h2,
.lab-results-head h2 {
  margin: 0;
  color: var(--stats-ink);
  letter-spacing: normal;
}

.stats-catalogue-head h2 {
  font-size: var(--text-section);
  line-height: 1.3;
}

.stats-entity-entry-grid {
  display: grid;
  border-bottom: 1px solid var(--stats-line);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats-entity-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  border-right: 1px solid var(--stats-line);
  color: var(--stats-ink);
  transition: color var(--stats-motion-duration) var(--stats-motion-easing),
    box-shadow var(--stats-motion-duration) var(--stats-motion-easing);
  gap: .5rem;
  min-height: 52px;
  padding: .75rem 1rem;
}

.stats-entity-entry:last-child { border-right: 0; }
.stats-entity-entry.is-active { box-shadow: inset 0 -3px 0 var(--stats-orange); }
.stats-entity-entry:hover { color: var(--stats-orange-dark); }
.stats-entity-entry strong { font-size: var(--text-section); letter-spacing: normal; }
.stats-entity-entry small { color: var(--stats-muted); font-size: var(--text-sm); }
.stats-entity-entry > span:last-child { grid-column: 2; grid-row: 1 / span 2; color: var(--stats-orange-dark); }

.stats-catalogue-tools {
  display: grid;
  grid-template-columns: minmax(280px, 620px) minmax(180px, auto);
  gap: 24px;
  align-items: end;
  justify-content: space-between;
  padding: 1.5rem 0;
}

.stats-search-control,
.stats-stacked-control {
  display: grid;
  gap: 7px;
}

.stats-search-control > span,
.stats-stacked-control > span {
  color: var(--stats-muted);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
}

.stats-search-control input,
.stats-stacked-control input,
.stats-stacked-control select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid var(--stats-line);
  border-radius: 0;
  background: var(--stats-panel);
  color: var(--stats-ink);
}

.stats-search-control input { min-height: 54px; border-color: var(--stats-ink); font-size: var(--text-body); }

.stats-catalogue-tools > p {
  margin: 0 0 15px;
  color: var(--stats-muted);
  font-size: var(--text-sm);
}

.stats-data-note {
  margin: 0 0 24px;
  padding: 11px 14px;
  border-left: 3px solid var(--stats-orange);
  background: var(--stats-paper);
  color: #5a5a5a;
  font-size: var(--text-sm);
  line-height: 1.5;
}

.stats-data-note.is-limited { border-left-color: #7d7d7d; }
.stats-data-note.is-published { border-left-color: #227a4b; }
.stats-data-note.is-error { border-left-color: var(--stats-ink); }

.stats-catalogue-layout {
  border-top: 1px solid var(--stats-line);
  border-bottom: 1px solid var(--stats-line);
}

.stats-category-nav {
  display: flex;
  flex-flow: row wrap;
  border-bottom: 1px solid var(--stats-line);
}

.stats-category-button {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 8px 13px;
  border-right: 1px solid var(--stats-soft-line);
  border-bottom: 1px solid var(--stats-soft-line);
  color: var(--stats-ink);
  font-size: var(--text-body);
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
  transition: color var(--stats-motion-duration) var(--stats-motion-easing),
    background-color var(--stats-motion-duration) var(--stats-motion-easing);
}

.stats-category-button.is-active {
  background: transparent;
  color: var(--stats-ink);
  box-shadow: none;
}

.stats-category-button:hover,
.stats-category-button:focus-visible {
  background: var(--stats-orange);
  color: var(--stats-ink);
  box-shadow: none;
}

.stats-product-page .stats-category-button:focus-visible {
  outline: 2px solid var(--stats-ink);
  outline-offset: -3px;
}

.stats-metric-panel,
.records-library-grid.stats-metric-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  padding: 0;
}

.stats-catalogue-group {
  min-width: 0;
  padding-inline: 1rem;
  padding-bottom: 0;
  border-top: 1px solid var(--line);
}

[data-catalogue-category="fastest-laps"],
[data-catalogue-category="race-performance"] {
  grid-column: 1 / -1;
}

.stats-catalogue-group:not([data-catalogue-category="race-performance"])
  > .stats-disclosure-body
  > .stats-disclosure-content
  > .stats-metric-list {
  display: block;
  column-count: 3;
  column-gap: 34px;
}

.stats-catalogue-group:not([data-catalogue-category="race-performance"])
  > .stats-disclosure-body
  > .stats-disclosure-content
  > .stats-metric-list
  > .stats-metric-link {
  break-inside: avoid;
}

.stats-catalogue-group > summary,
.stats-filter-accordion > summary,
.stats-option-group > summary {
  list-style: none;
}

.stats-catalogue-group > summary::-webkit-details-marker,
.stats-filter-accordion > summary::-webkit-details-marker,
.stats-option-group > summary::-webkit-details-marker {
  display: none;
}

.stats-metric-group-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 14px;
  cursor: pointer;
  min-height: 64px;
  padding: 1rem 0;
  align-items: center;
  border-bottom: 0;
}

.stats-catalogue-group .stats-state-label { grid-column: 1 / -1; margin: 0; font-size: var(--text-sm); }
.stats-catalogue-group h3 { margin: 0; letter-spacing: normal;
  font-size: var(--text-card);
  line-height: 1.3;
}

.stats-disclosure-icon {
  position: relative;
  display: block;
  width: 18px;
  height: 18px;
  color: var(--stats-orange-dark);
}

.stats-disclosure-icon::before,
.stats-disclosure-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 2px;
  width: 14px;
  height: 1px;
  background: currentColor;
  transform-origin: center;
  transition: transform var(--stats-motion-duration) var(--stats-motion-easing);
}

.stats-disclosure-icon::after { transform: rotate(90deg); }
details[open]:not(.is-closing) > summary .stats-disclosure-icon::after { transform: rotate(90deg) scaleX(0); }

.stats-disclosure-body {
  opacity: 1;
  transition: height var(--stats-motion-duration) var(--stats-motion-easing),
    opacity var(--stats-motion-duration) ease-out;
}

.stats-disclosure-content { min-height: 0; }

.stats-metric-list { display: grid; }

.stats-statistic-groups {
  display: grid;
  gap: 28px 34px;
}

.stats-statistic-groups-race-performance {
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
}
.stats-statistic-groups-fastest-laps { grid-template-columns: minmax(0, 1fr); }

.stats-statistic-group {
  min-width: 0;
  border-top: 1px solid var(--stats-line);
}

.stats-statistic-group > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 50px;
  padding: 10px 0;
  cursor: pointer;
  list-style: none;
}

.stats-statistic-group > summary::-webkit-details-marker { display: none; }

.stats-statistic-group-title {
  margin: 0;
  color: var(--stats-ink);
  font-weight: 700;
  letter-spacing: normal;
  line-height: 1.2;
  text-transform: none;
  font-size: var(--text-body);
}

.stats-metric-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--stats-soft-line);
  color: var(--stats-ink);
  transition: color var(--stats-motion-duration) var(--stats-motion-easing);
  min-height: 44px;
}

.stats-metric-link:hover { color: var(--stats-orange-dark); }
.stats-metric-link[aria-disabled="true"] { color: #868686; cursor: not-allowed; }
.stats-metric-status-unavailable[aria-disabled="true"] { color: #a7a7a7; }
.stats-metric-name { font-weight: 700;
  font-size: var(--text-body);
}
.stats-metric-meta { display: flex; gap: 7px; align-items: center; color: var(--stats-muted); }
.stats-metric-meta small { font-size: var(--text-sm); font-weight: 700; letter-spacing: normal; line-height: 1.3; text-transform: none; }
.stats-metric-arrow { color: var(--stats-orange); font-size: var(--text-sm); }
.stats-catalogue-empty { padding: 48px 0; }
.stats-catalogue-empty h2 { margin: 0; font-size: var(--text-section); }
.stats-catalogue-empty p { color: var(--stats-muted); }

.stats-detail-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: baseline;
  margin: 0 0 14px;
  color: #bababa;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
}

.stats-detail-status strong { color: #ffffff; font-size: var(--text-sm); }

.stats-detail-sections {
  display: grid;
  gap: clamp(52px, 7vw, 88px);
}

.stats-detail-sections > .stats-metric-group,
[data-explorer-statistic-footer] .stats-metric-group {
  padding-top: 20px;
  border-top: 2px solid var(--stats-ink);
}

.stats-detail-sections > .stats-metric-group > h2,
[data-explorer-statistic-footer] .stats-metric-group > h2 {
  margin-bottom: 18px;
  font-size: var(--text-section);
  line-height: 1.2;
}

.stats-community-close {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(260px, 1.2fr);
  gap: 24px;
  align-items: start;
  margin-top: 30px;
  padding-top: 24px;
  border-top: 1px solid var(--stats-line);
}

.stats-community-close h3 {
  margin: 0;
  font-size: var(--text-card);
  line-height: 1;
  letter-spacing: normal;
}

.stats-community-close p {
  max-width: 560px;
  margin: 0;
  color: var(--stats-muted);
  line-height: 1.55;
}

/* Circuit Foundation */
.stats-circuit-page .stats-product-hero h1 {
  overflow-wrap: anywhere;
  font-size: var(--text-title);
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
  letter-spacing: normal;
}

.stats-circuit-page .stats-product-actions {
  flex-wrap: wrap;
  gap: 10px;
}

.stats-circuit-library-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.65fr);
  gap: 32px;
  align-items: end;
}

.stats-circuit-library-head > p,
.stats-circuit-section-intro,
.stats-circuit-provenance,
.stats-circuit-missing > p {
  max-width: 680px;
  margin: 0;
  color: var(--stats-muted);
  line-height: 1.6;
}

.stats-circuit-library-head > p {
  justify-self: end;
  padding-bottom: 5px;
}

.stats-circuit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 32px;
  border-top: 1px solid var(--stats-line);
  border-left: 1px solid var(--stats-line);
}

.stats-circuit-card {
  display: grid;
  align-content: space-between;
  min-width: 0;
  min-height: 230px;
  padding: 24px;
  border-right: 1px solid var(--stats-line);
  border-bottom: 1px solid var(--stats-line);
  background: rgba(255, 255, 255, 0.22);
  color: var(--stats-ink);
  transition: color var(--stats-motion-duration) var(--stats-motion-easing),
    background var(--stats-motion-duration) var(--stats-motion-easing),
    transform var(--stats-motion-duration) var(--stats-motion-easing);
}

.stats-circuit-card:hover {
  z-index: 1;
  background: var(--stats-panel);
  color: var(--stats-orange-dark);
  transform: translateY(-2px);
}

.stats-circuit-card-head,
.stats-circuit-card-footer,
.stats-circuit-future-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}

.stats-circuit-card .stats-state-label { margin: 0; }

.stats-circuit-status,
.stats-circuit-future-head small {
  color: var(--stats-muted);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: normal;
  text-align: right;
  text-transform: none;
}

.stats-statistic-groups-race-performance .stats-statistic-group.is-long .stats-metric-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 34px;
}

.stats-circuit-card > strong {
  align-self: end;
  margin-top: 42px;
  overflow-wrap: anywhere;
  font-size: var(--text-section);
  line-height: 1.2;
  letter-spacing: normal;
}

.stats-circuit-location {
  margin-top: 10px;
  color: var(--stats-muted);
  font-size: var(--text-sm);
}

.stats-circuit-card-footer {
  align-items: center;
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--stats-soft-line);
}

.stats-circuit-card-footer code {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--stats-muted);
  font: 700 10px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: normal;
}

.stats-circuit-empty {
  grid-column: 1 / -1;
  min-height: 220px;
  padding: 42px 24px;
  border-right: 1px solid var(--stats-line);
  border-bottom: 1px solid var(--stats-line);
}

.stats-circuit-empty h2 { margin: 0 0 10px; font-size: var(--text-section); }
.stats-circuit-empty p { margin: 0; color: var(--stats-muted); }

.stats-circuit-facts {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 22px 0 0;
  border-top: 1px solid var(--stats-line);
  border-left: 1px solid var(--stats-line);
}

.stats-circuit-fact {
  min-width: 0;
  padding: 18px;
  border-right: 1px solid var(--stats-line);
  border-bottom: 1px solid var(--stats-line);
}

.stats-circuit-fact dt {
  margin-bottom: 8px;
  color: var(--stats-muted);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
}

.stats-circuit-fact dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.35;
}

.stats-circuit-layout {
  display: grid;
  min-height: 420px;
  margin-top: 22px;
  padding: clamp(20px, 4vw, 52px);
  place-items: center;
  overflow: hidden;
  border: 1px solid #292927;
  background: var(--stats-ink);
  color: #ffffff;
}

.stats-circuit-layout-figure {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 0.35fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: end;
  width: min(100%, 920px);
  margin: 0;
}

.stats-circuit-layout-figure svg {
  display: block;
  width: 100%;
  max-height: 480px;
}

.stats-circuit-layout-figure polyline {
  fill: none;
  stroke: var(--stats-orange);
  stroke-width: 18;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.stats-circuit-layout-figure figcaption {
  display: grid;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid #4b4b4b;
}

.stats-circuit-layout-figure figcaption span {
  color: #bababa;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
}

.stats-circuit-layout-figure figcaption strong {
  font-size: var(--text-section);
  letter-spacing: normal;
}

.stats-circuit-layout-message {
  max-width: 560px;
  margin: 0;
  text-align: center;
}

.stats-circuit-layout-message strong {
  display: block;
  margin-bottom: 8px;
  font-size: var(--text-section);
  letter-spacing: normal;
}

.stats-circuit-layout-message p { margin: 0; color: #bababa; line-height: 1.55; }
.stats-circuit-provenance { margin-top: 14px; font-size: var(--text-sm); }

.stats-circuit-future-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 22px;
  border-top: 1px solid var(--stats-line);
  border-left: 1px solid var(--stats-line);
}

.stats-circuit-future-card {
  min-width: 0;
  min-height: 150px;
  padding: 20px;
  border-right: 1px solid var(--stats-line);
  border-bottom: 1px solid var(--stats-line);
}

.stats-circuit-future-head h3 {
  margin: 0;
  font-size: var(--text-card);
  line-height: 1;
  letter-spacing: normal;
}

.stats-circuit-future-card p {
  max-width: 560px;
  margin: 24px 0 0;
  color: var(--stats-muted);
  font-size: var(--text-sm);
  line-height: 1.55;
}

/* Explorer shell */
.stats-ranking-hero-grid {
  min-height: 0;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.stats-ranking-hero h1 {
  max-width: 1000px;
  font-size: var(--text-title);
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
  letter-spacing: normal;
}

.stats-context-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
  margin-bottom: 1rem;
  color: var(--muted);
}

.stats-context-breadcrumb a {
  color: var(--muted);
}
.stats-context-breadcrumb a:hover { color: var(--stats-orange); }

.stats-explorer-section {
  padding: 1.5rem 0 3rem;
}

.stats-lab-shell.stats-explorer-v2 {
  display: grid;
  grid-template-columns: minmax(310px, 330px) minmax(0, 1fr);
  align-items: start;
  border: 1px solid var(--stats-line);
  background: var(--stats-panel);
}

/* The site header is sticky at top:0, so the panel must clear its measured
   height (JS keeps --header-height current) and scroll internally when it is
   taller than the space that remains. */
.stats-explorer-v2 .explorer-workbench {
  position: sticky;
  top: calc(var(--header-height, 88px) + 12px);
  width: 100%;
  min-width: 0;
  max-height: calc(100vh - var(--header-height, 88px) - 24px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 20px 0 20px;
  border-right: 1px solid var(--stats-line);
  background: var(--stats-paper);
  scrollbar-width: thin;
  scrollbar-color: #bfbfbf transparent;
  scroll-padding-block: 62px 64px;
}

.stats-explorer-v2 .explorer-workbench::-webkit-scrollbar { width: 8px; }
.stats-explorer-v2 .explorer-workbench::-webkit-scrollbar-track { background: transparent; }
.stats-explorer-v2 .explorer-workbench::-webkit-scrollbar-thumb {
  border: 2px solid var(--stats-paper);
  border-radius: 8px;
  background: #bfbfbf;
}

.stats-filter-heading {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  /* Bleed over the panel's own side padding so nothing shows through behind. */
  margin: 0 -20px;
  padding: 0 20px;
  border-bottom: 2px solid var(--stats-ink);
  background: var(--stats-paper);
}

.stats-filter-heading h2 {
  margin: 0;
  font-size: var(--text-section);
  letter-spacing: normal;
  text-transform: none;
}

.stats-filter-heading-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* A secondary utility: plain text, no border, quieter than the panel title it
   sits beside. Fixed min-width so swapping the label cannot nudge the row. */
.stats-filter-expand-all {
  /* Wide enough for the longer "Collapse all" label, so swapping the two
     cannot change the button's width. */
  min-width: 124px;
  padding: 0;
  border: 0;
  background: transparent;
  color: color-mix(in srgb, var(--stats-ink) 60%, transparent);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: normal;
  line-height: 1;
  text-align: right;
  text-transform: none;
  white-space: nowrap;
  cursor: pointer;
  transition: color 180ms ease;
}

.stats-filter-expand-all:hover:not(:disabled),
.stats-filter-expand-all:focus-visible:not(:disabled) { color: var(--stats-orange-dark); }
.stats-filter-expand-all:focus-visible { outline: 2px solid var(--stats-orange); outline-offset: 3px; }
.stats-filter-expand-all:disabled { color: var(--stats-muted); cursor: default; opacity: 0.6; }

@media (prefers-reduced-motion: reduce) {
  .stats-filter-expand-all { transition: none; }
}

/* Reset lives with the controls it clears, pinned to the foot of the panel. */
.stats-filter-footer {
  position: sticky;
  bottom: 0;
  z-index: 6;
  margin: 18px -20px 0;
  padding: 12px 20px;
  border-top: 1px solid var(--stats-line);
  background: var(--stats-paper);
}

.stats-reset-button {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--stats-ink);
  background: transparent;
  color: var(--stats-ink);
  font: inherit;
  font-size: var(--text-body);
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.stats-reset-button:hover:not(:disabled) {
  border-color: var(--stats-orange);
  background: var(--stats-orange);
  color: #fff;
}

.stats-reset-button:disabled {
  border-color: var(--stats-line);
  color: var(--stats-muted);
  cursor: default;
}

/* Collapsed summaries still have to show that a filter is not at its default. */
.stats-filter-summary-copy.is-modified em {
  position: relative;
  padding-left: 12px;
  color: var(--stats-orange-dark);
  font-weight: 700;
  font-style: normal;
}

.stats-filter-summary-copy.is-modified em::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--stats-orange);
  transform: translateY(-50%);
}

.stats-filter-heading [data-filter-drawer-close],
.stats-mobile-filter-button,
.stats-filter-scrim { display: none; }

.stats-entity-mode {
  min-width: 0;
  margin: 16px 0 8px;
  padding: 0;
  border: 0;
}

.stats-entity-mode legend,
.stats-driver-status legend {
  margin-bottom: 7px;
  color: var(--stats-muted);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
}

.stats-segmented-control {
  display: grid;
  /* The middle option is "Constructors"; give it the room not to break mid-word. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr);
  border: 1px solid var(--stats-line);
  background: var(--stats-panel);
}

.stats-segmented-control label { position: relative; min-width: 0; }
.stats-segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.stats-segmented-control span {
  display: grid;
  place-items: center;
  min-height: 38px;
  min-width: 0;
  padding: 7px 5px;
  border-right: 1px solid var(--stats-line);
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-align: center;
  white-space: normal;
  cursor: pointer;
}
.stats-segmented-control label:last-child span { border-right: 0; }
.stats-segmented-control input:checked + span { background: var(--stats-ink); color: #fff; }
.stats-segmented-control input:focus-visible + span { outline: 3px solid var(--stats-orange); outline-offset: -3px; }

.stats-filter-accordion {
  border-bottom: 1px solid var(--stats-line);
}

.stats-filter-accordion > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px 0;
  cursor: pointer;
}

.stats-filter-summary-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.stats-filter-summary-copy strong {
  letter-spacing: normal;
  text-transform: none;

  font-size: var(--text-body);
}

.stats-filter-summary-copy em {
  color: var(--stats-muted);
  font-size: var(--text-sm);
  font-style: normal;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.stats-filter-accordion-body { padding: 2px 0 16px; }

.stats-range-presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.stats-range-presets button {
  min-height: 36px;
  padding: 6px 7px;
  border: 1px solid var(--stats-line);
  border-radius: 0;
  background: var(--stats-panel);
  color: var(--stats-ink);
  font-size: var(--text-body);
  cursor: pointer;
}

.stats-range-presets button:hover,
.stats-range-presets button.is-active {
  border-color: var(--stats-orange);
  color: var(--stats-orange-dark);
  box-shadow: inset 0 -2px 0 var(--stats-orange);
}

.stats-range-presets button:disabled {
  background: var(--stats-paper);
  cursor: not-allowed;
  box-shadow: none;

  color: var(--muted);
}

.stats-animated-region {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows var(--stats-motion-duration) var(--stats-motion-easing),
    opacity var(--stats-motion-duration) ease-out;
}

.stats-animated-region.is-visible {
  grid-template-rows: 1fr;
  opacity: 1;
}

.stats-animated-region-inner {
  min-height: 0;
  overflow: hidden;
}

.race-range-grid {
  display: grid;
  gap: 8px;
  padding-top: 12px;
}

.race-range-grid fieldset {
  min-width: 0;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--stats-soft-line);
}

.race-range-grid legend,
.race-range-grid label > span {
  color: var(--stats-muted);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
}

.race-range-grid label { display: grid; gap: 4px; margin-top: 6px; }
.race-range-grid select { width: 100%; min-width: 0; min-height: 36px; border: 1px solid var(--stats-line); background: var(--stats-panel); }

.stats-range-status,
.stats-auto-build-status {
  margin: 10px 0 0;
  color: var(--stats-muted);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.stats-range-status.is-correction,
.stats-auto-build-status.is-error { color: #8a2e1d; }

.stats-driver-status {
  display: grid;
  gap: 5px;
  min-width: 0;
  margin: 0 0 10px;
  padding: 0;
  border: 0;
}

.stats-driver-status label,
.stats-check-control {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--stats-line);
  background: var(--stats-panel);
  font-size: var(--text-sm);
  font-weight: 700;
}

.stats-driver-status label:has(input:checked) {
  border-color: var(--stats-orange);
  box-shadow: inset 2px 0 0 var(--stats-orange);
}

.stats-driver-status label:has(input:disabled) { color: #909090; cursor: not-allowed; }
.stats-check-control { margin-bottom: 10px; }

.stats-option-scroll {
  max-height: 380px;
  margin-top: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  border-top: 1px solid var(--stats-line);
  border-bottom: 1px solid var(--stats-line);
}

/* Outrank legacy picker rules from the shared stylesheet. */
.stats-explorer-v2 .stats-option-scroll {
  max-height: 380px;
  overflow-x: hidden;
  overflow-y: auto;
}

.stats-option-group { border-bottom: 1px solid var(--stats-soft-line); }
.stats-option-group:last-child { border-bottom: 0; }

.stats-option-group-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 8px 4px;
  cursor: pointer;
}

.stats-option-group-summary > *,
.stats-group-actions,
.stats-group-actions button {
  min-width: 0;
}

.stats-option-group-summary .stats-filter-summary-copy strong {
  font-size: var(--text-sm);
  text-transform: none;
}

.stats-option-group-body { padding: 0 4px 10px; }
.stats-option-group .stats-option-group { margin-left: 8px; border-left: 1px solid var(--stats-soft-line); }
.stats-option-group .stats-option-group .stats-option-group-summary { padding-left: 8px; }

.stats-group-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  padding: 2px 0 7px;
}

.stats-group-actions button,
.stats-selection-summary button {
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--stats-orange-dark);
  font-size: var(--text-body);
  font-weight: 700;
  cursor: pointer;
}

.picker-option {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 5px 2px;
  border-top: 1px solid #e6e6e6;
  font-size: var(--text-sm);
}

.picker-option input { margin: 0; }
.picker-option-copy { display: grid; gap: 1px; min-width: 0; }
.picker-option-copy strong { font-size: var(--text-sm); font-weight: 650; overflow-wrap: anywhere; }
.picker-option-copy small { color: var(--stats-muted); font-size: var(--text-sm); line-height: 1.3; }
.picker-option:has(input:disabled) { color: #8c8c8c; }

.stats-option-empty,
.control-note {
  margin: 8px 2px;
  color: var(--stats-muted);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.stats-selection-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1px;
  margin-top: 16px;
  border: 1px solid var(--stats-line);
  background: var(--stats-line);
}

.stats-selection-summary > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px 8px;
  align-items: center;
  min-width: 0;
  padding: 8px;
  background: var(--stats-panel);
}

.stats-selection-summary strong { color: var(--stats-orange-dark); font-size: var(--text-body); }
.stats-selection-summary span { min-width: 0; font-size: var(--text-body); font-weight: 700; overflow-wrap: anywhere; text-transform: none; }
.stats-selection-summary button { justify-self: end; white-space: normal; }
.stats-selection-summary .stats-clear-all {
  grid-column: 1 / -1;
  justify-self: stretch;
  min-height: 34px;
  padding-inline: 10px;
  background: var(--stats-panel);
  text-align: center;
}

.stats-build-panel { margin-top: 14px; }
.stats-build-button { width: 100%; min-height: 48px; justify-content: center; }
.stats-build-panel p { margin: 8px 0 0; color: var(--stats-muted); font-size: var(--text-sm); line-height: 1.45; }
.stats-build-panel p.is-error { color: #a52222; }

.stats-active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}

.stats-active-filters > span {
  padding: 6px 8px;
  border: 1px solid var(--stats-line);
  color: var(--stats-muted);
  font-size: var(--text-sm);
}

.stats-active-filters strong { color: var(--stats-ink); }
.stats-as-of-note { margin: 12px 0 0; color: var(--stats-muted); font-size: var(--text-sm); line-height: 1.45; }

.stats-explorer-v2 .lab-results {
  min-width: 0;
  padding: clamp(24px, 4vw, 52px);
  background: var(--stats-panel);
}

.stats-data-in-progress-mode .stats-lab-shell.stats-explorer-v2 {
  grid-template-columns: minmax(0, 1fr);
}

.stats-explorer-v2 .lab-results-head {
  display: flex;
  gap: 24px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 26px;
  padding: 0 0 20px;
  border-bottom: 1px solid var(--stats-ink);
  background: transparent;
  color: var(--stats-ink);
}

.stats-explorer-v2 .lab-results-head h2 {
  font-size: var(--text-section);
  line-height: 1.2;
}

.stats-explorer-v2 .lab-results-head p { margin: 10px 0 0; color: var(--stats-muted);
  font-size: var(--text-body);
}
.lab-results-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; }
.lab-results-actions a,
.lab-results-actions button { border: 0; background: transparent; color: var(--stats-orange-dark); font: inherit; cursor: pointer; }

/* Loading, empty and error states share one height so switching between them
   never jumps the page. */
.stats-entity-unavailable,
.compact-empty,
.stats-loading,
.stats-error {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 208px;
  margin: 28px 0;
  padding: clamp(20px, 3vw, 34px) 0;
  border-top: 1px solid var(--stats-line);
  border-bottom: 1px solid var(--stats-line);
}

.stats-entity-unavailable h3,
.compact-empty h3,
.stats-error h3 {
  margin: 0;
  font-size: var(--text-card);
  line-height: 1;
}

.stats-entity-unavailable p,
.compact-empty p,
.stats-error p { max-width: 650px; margin: 15px 0 0; color: var(--stats-muted); line-height: 1.6; }

.stats-loading p {
  max-width: 650px;
  margin: 10px 0 0;
  color: var(--stats-muted);
  line-height: 1.6;
}

.leaderboard-wrap {
  width: 100%;
  min-width: 0;

  overflow-x: auto;

  overscroll-behavior-inline: contain;
}

.leaderboard-wrap.is-multi-scroll {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}

.custom-leaderboard-table {
  width: 100%;
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.custom-leaderboard-table.is-multi-metric-table {
  min-width: max(720px, 100%);
  table-layout: auto;
}

.custom-leaderboard-table th,
.custom-leaderboard-table td {
  padding: 13px 11px;
  border-bottom: 1px solid var(--stats-soft-line);
  text-align: right;
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.custom-leaderboard-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--stats-panel);
  color: var(--stats-muted);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
}

.custom-leaderboard-table tbody tr:hover td { background: #f2f2f2; }
.stats-explorer-v2 .custom-leaderboard-table tr.leaderboard-row { box-shadow: none; }
.stats-explorer-v2 .custom-leaderboard-table .rank-cell { color: var(--stats-muted); }
.custom-leaderboard-table .rank-heading,
.custom-leaderboard-table .rank-cell { width: 52px; padding-left: 4px; color: var(--stats-muted); text-align: left; }
.custom-leaderboard-table .rank-cell {
  font-size: var(--text-body);
  font-weight: 700;
  line-height: 1;
}

.custom-leaderboard-table .entity-heading,
.custom-leaderboard-table .driver-cell { min-width: 190px; background: var(--stats-panel); text-align: left; }
.custom-leaderboard-table .driver-cell { font-size: var(--text-body); font-weight: 700; overflow-wrap: anywhere; }
.is-multi-metric-table .sticky-driver { position: sticky; left: 0; z-index: 2; }
.is-multi-metric-table th.sticky-driver { z-index: 4; }
.stats-entity-name { display: block; }
.stats-entity-type { display: block; margin-top: 2px; color: var(--stats-muted); font-size: var(--text-sm); font-weight: 700; letter-spacing: normal; text-transform: none; }

.metric-cell.is-selected-metric,
.primary-metric-cell {
  background: rgba(255, 244, 232, 0.5);
  box-shadow: inset 2px 0 0 rgba(232, 106, 26, 0.5);
  color: var(--stats-ink);
  font-size: var(--text-body);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: normal;
}
.secondary-metric-cell { color: var(--stats-muted); font-size: var(--text-sm); }

.metric-sort-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  width: auto;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  white-space: normal;
}

.sort-indicator { color: var(--stats-orange); font-size: var(--text-sm); }

.custom-leaderboard-table .metric-heading .metric-sort-button {
  overflow-wrap: normal;
  word-break: keep-all;
  hyphens: none;
}
.sort-indicator.is-neutral { color: #9a9a9a; }

.stats-filter-portal { display: contents; }

@media (min-width: 861px) {
  /* Panel scrolling and its header offset are defined once on the base rule. */
  .stats-explorer-v2 .driver-picker,
  .stats-explorer-v2 .constructor-picker { max-height: min(30vh, 300px); }
  .stats-explorer-v2 .metric-picker { max-height: min(34vh, 340px); }
}

/* ---------------------------------------------------------------------------
   Clickable ranking rows
   The whole row opens the detail dialog. There is no chevron: nothing expands
   downward, so the affordance is a quiet arrow that appears on hover or focus.
   ------------------------------------------------------------------------ */

.custom-leaderboard-table .single-ranking-row { cursor: pointer; }

.custom-leaderboard-table .single-ranking-row:hover td { background: #f0f0f0; }

.custom-leaderboard-table .single-ranking-row:focus-visible {
  outline: 2px solid var(--stats-orange);
  outline-offset: -2px;
}

.custom-leaderboard-table.is-single-metric-table tr.single-ranking-row:hover::after,

.custom-leaderboard-table .rank-cell {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.custom-leaderboard-table .rank-value { display: block; width: 100%; text-align: right; }

/* ---------------------------------------------------------------------------
   Ranking detail dialog
   Detail lists run past a hundred rows, so the panel is a fixed-height column:
   pinned header, scrolling table, sticky column names.
   ------------------------------------------------------------------------ */

.stats-drilldown-dialog {
  width: min(1040px, calc(100vw - 48px));
  max-width: min(1040px, calc(100vw - 48px));
  max-height: 80vh;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--stats-line);
  border-radius: 0;
  background: #f3f3f3;
  color: var(--stats-ink);
  box-shadow: 0 24px 80px rgba(7, 7, 7, 0.32);
}

.stats-drilldown-dialog[open] { display: flex; }
.stats-drilldown-dialog::backdrop { background: rgba(7, 7, 7, 0.68); }

/* Championship details list one row per title season across six columns, so
   the panel narrows rather than stretching those columns across race-grain
   width. */
.stats-drilldown-dialog[data-detail-view="season"] {
  width: min(880px, calc(100vw - 48px));
  max-width: min(880px, calc(100vw - 48px));
}

.stats-drilldown-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 80vh;
  width: 100%;
}

.stats-drilldown-head {
  flex: 0 0 auto;
  display: flex;
  gap: 20px;
  align-items: start;
  justify-content: space-between;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--stats-line);
}

.stats-drilldown-heading { min-width: 0; text-align: left; }
.stats-drilldown-head h2 { margin: 4px 0 0; font-size: var(--text-section); text-align: left; }

.stats-drilldown-meta {
  margin: 8px 0 0;
  color: var(--stats-muted);
  font-size: var(--text-sm);
  text-align: left;
}

.stats-drilldown-head button {
  flex: 0 0 auto;
  min-width: 48px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--stats-orange-dark);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.stats-drilldown-head button:focus-visible { outline: 2px solid var(--stats-orange); outline-offset: 2px; }

.stats-drilldown-dialog .compact-empty,
.stats-drilldown-error {
  flex: 0 0 auto;
  min-height: 0;
  margin: 0;
  padding: 18px 24px;
  border: 0;
}

.stats-drilldown-error strong { display: block; color: var(--stats-orange-dark); font-size: var(--text-sm); }
.stats-drilldown-error p { margin: 6px 0 0; color: var(--stats-muted); font-size: var(--text-sm); }

.stats-drilldown-table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  overscroll-behavior: contain;
  padding: 0 24px 24px;
  scrollbar-width: thin;
  scrollbar-color: #bfbfbf transparent;
}

.stats-drilldown-table-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.stats-drilldown-table-wrap::-webkit-scrollbar-track { background: transparent; }
.stats-drilldown-table-wrap::-webkit-scrollbar-thumb { border-radius: 8px; background: #bfbfbf; }

/* .table sets overflow:hidden, which would make the table its own containing
   scroller and cancel the sticky header. The scroll container is the wrap. */
.stats-drilldown-table-wrap .stats-results-table {
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.stats-drilldown-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f3f3;
  box-shadow: inset 0 -1px 0 var(--stats-line);
  white-space: nowrap;
}

/* Season-view counts read as a column of figures. */
.stats-drilldown-table-wrap th.is-numeric { text-align: right; }

.stats-drilldown-table-wrap td.is-numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.stats-drilldown-dialog[data-drilldown-state="loading"] .stats-drilldown-table-wrap thead { visibility: hidden; }

.stats-drilldown-skeleton {
  display: block;
  height: 26px;
  background: linear-gradient(90deg, #e8e8e8 0%, #f2f2f2 50%, #e8e8e8 100%);
  background-size: 200% 100%;
  animation: stats-detail-shimmer 1.3s linear infinite;
}

@keyframes stats-detail-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* Background page must not scroll while the dialog owns the view. */
body.stats-drilldown-open { overflow: hidden; }

@media (max-width: 760px) {
  /* Bottom sheet: anchored to the foot of the viewport with a rounded top.
     The season-view selector outranks the base width, so both views are
     pinned to the full-width sheet here explicitly. */
  .stats-drilldown-dialog,
  .stats-drilldown-dialog[data-detail-view="season"] {
    width: 100vw;
    max-width: 100vw;
    max-height: 88vh;
    margin: 0 0 0 0;
    top: auto;
    bottom: 0;
    border-width: 1px 0 0;
    border-radius: 14px 14px 0 0;
  }
  .stats-drilldown-shell { max-height: 88vh; border-radius: 14px 14px 0 0; }
  .stats-drilldown-head { padding: 16px; }
  .stats-drilldown-table-wrap { padding: 0 16px 16px; overflow-x: visible; }
  .stats-drilldown-dialog .compact-empty,
  .stats-drilldown-error { padding: 14px 16px; }

  /* mobile-cards presentation: one card per Grand Prix. The shared card grid
     keys off cell-pos/cell-main classes these cells do not carry, so the
     fields are labelled from their existing data-label instead. */
  .stats-drilldown-dialog .stats-drilldown-table-wrap .stats-results-table { display: block; }
  .stats-drilldown-dialog .stats-drilldown-table-wrap .stats-results-table thead { display: none; }
  .stats-drilldown-dialog .stats-drilldown-table-wrap .stats-results-table tbody {
    display: block;
    border: 1px solid var(--stats-line);
    background: var(--stats-panel);
  }

  .stats-drilldown-dialog .stats-drilldown-table-wrap .stats-results-table tr {
    display: block;
    min-height: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--stats-soft-line);
    box-shadow: none;
  }

  .stats-drilldown-dialog .stats-drilldown-table-wrap .stats-results-table tr:last-child { border-bottom: 0; }

  .stats-drilldown-dialog .stats-drilldown-table-wrap .stats-results-table td {
    display: flex;
    gap: 12px;
    align-items: baseline;
    justify-content: space-between;
    height: auto;
    padding: 3px 0;
    border: 0;
    background: transparent;
    font-size: var(--text-body);
    text-align: right;
    overflow-wrap: anywhere;
  }

  .stats-drilldown-dialog .stats-drilldown-table-wrap .stats-results-table td::before {
    content: attr(data-label);
    flex: 0 0 40%;
    color: var(--stats-muted);
    font-size: var(--text-body);
    font-weight: 700;
    letter-spacing: normal;
    text-align: left;
    text-transform: none;
  }

  .stats-drilldown-dialog .stats-drilldown-table-wrap .stats-results-table td::after { content: none; }
  .stats-drilldown-dialog .stats-drilldown-table-wrap .stats-results-table tbody tr:hover td { background: transparent; }

  /* Skeleton rows are a single full-width bar, not a labelled field. */
  .stats-drilldown-dialog .stats-drilldown-table-wrap .stats-results-table tr.stats-drilldown-skeleton-row td { display: block; }
  .stats-drilldown-dialog .stats-drilldown-table-wrap .stats-results-table tr.stats-drilldown-skeleton-row td::before { content: none; }
}

@media (prefers-reduced-motion: reduce) {
  .custom-leaderboard-table.is-single-metric-table tr.single-ranking-row,

  .stats-drilldown-skeleton { animation: none; }
}

/* ---------------------------------------------------------------------------
   Results toolbar
   Two real buttons in a segmented group. Labels are fixed-width so copy
   feedback (a separate toast) can never reflow the row.
   ------------------------------------------------------------------------ */

.stats-breadcrumb-catalogue {
  margin-left: auto;
  color: var(--stats-orange-dark);
  font-weight: 700;
  white-space: nowrap;
}

.stats-toolbar {
  display: inline-flex;
  border: 1px solid var(--stats-line);
  background: var(--stats-panel);
}

.stats-toolbar-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-width: 148px;
  min-height: 42px;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--stats-ink);
  font: inherit;
  font-size: var(--text-body);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease;
}

.stats-toolbar-button + .stats-toolbar-button { border-left: 1px solid var(--stats-line); }
.stats-toolbar-button svg { flex: 0 0 auto; width: 15px; height: 15px; fill: currentColor; }
.stats-toolbar-button:hover { background: #f2f2f2; color: var(--stats-orange-dark); }
.stats-toolbar-button:focus-visible { outline: 2px solid var(--stats-orange); outline-offset: -2px; }
.stats-toolbar-button[hidden] { display: none; }

.lab-results-actions { position: relative; }

.stats-copy-toast {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--stats-line);
  background: var(--stats-ink);
  color: var(--stats-panel);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: normal;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.stats-copy-toast.is-visible { opacity: 1; }
.stats-copy-toast.is-error { background: var(--stats-orange-dark); }

@media (prefers-reduced-motion: reduce) {
  .stats-copy-toast { transition: none; }
}

@media (max-width: 760px) {
  /* Keep action labels visible on narrow screens. */
  .stats-toolbar-button { min-width: 52px; padding: 8px 12px; }
  .stats-toolbar-label { display:inline; }
  .stats-breadcrumb-catalogue { margin-left: 0; }
}

/* Neutralise the legacy <=860px card transform. Phase 12A keeps a real
   sortable table at every size: compact for one metric, scrollable for many. */
@media (max-width: 860px) {
  .stats-explorer-v2 .leaderboard-wrap { padding: 0; background: transparent; }
  .stats-explorer-v2 .leaderboard-wrap.is-multi-scroll { overflow-x: auto; }

  .stats-explorer-v2 .custom-leaderboard-table .metric-cell::before { content: none !important; }

  .stats-explorer-v2 .custom-leaderboard-table.is-multi-metric-table {
    display: table;
    width: 100%;
    min-width: max(720px, 100%);
  }

  .stats-explorer-v2 .custom-leaderboard-table.is-multi-metric-table thead { display: table-header-group; }
  .stats-explorer-v2 .custom-leaderboard-table.is-multi-metric-table tbody {
    display: table-row-group;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }
  .stats-explorer-v2 .custom-leaderboard-table.is-multi-metric-table tr.leaderboard-row {
    display: table-row;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
  .stats-explorer-v2 .custom-leaderboard-table.is-multi-metric-table th,
  .stats-explorer-v2 .custom-leaderboard-table.is-multi-metric-table td,
  .stats-explorer-v2 .custom-leaderboard-table.is-multi-metric-table td:nth-child(n+1) {
    display: table-cell;
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 13px 11px;
    border-bottom: 1px solid var(--stats-soft-line);
    white-space: normal;
    grid-area: auto;
  }
  .stats-explorer-v2 .custom-leaderboard-table.is-multi-metric-table .sticky-driver {
    position: sticky;
    left: 0;
    min-width: 190px;
    background: var(--stats-panel);
  }
}

@media (min-width: 761px) and (max-width: 1199px) {
  .stats-product-page .wrap,
  .stats-explorer-page .wrap {
  max-width: var(--max);
  padding-inline: var(--gutter);
}
  .stats-catalogue-group {
  padding-inline: 1rem;
  padding-bottom: 0;
  border-top: 1px solid var(--line);
}
  .stats-metric-panel,
  .records-library-grid.stats-metric-panel { grid-template-columns: minmax(0, 1fr); }
  .stats-catalogue-group:not([data-catalogue-category="race-performance"])
    > .stats-disclosure-body
    > .stats-disclosure-content
    > .stats-metric-list { column-count: 2; column-gap: 28px; }
  .stats-lab-shell.stats-explorer-v2 { grid-template-columns: minmax(286px, 304px) minmax(0, 1fr); }
  .stats-explorer-v2 .explorer-workbench { width: 100%; padding-right: 16px; padding-left: 16px; }
  .stats-explorer-v2 .lab-results { padding-right: 18px; padding-left: 18px; }
}

@media (max-width: 980px) {
  .stats-product-hero-grid,
  .stats-ranking-hero-grid {
    grid-template-columns: 1fr;
    gap: 28px;
    align-items: start;
  }
  .stats-entity-entry-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
  .stats-entity-entry-grid .stats-circuit-entry { grid-column: 1 / -1; }
  .stats-circuit-library-head { grid-template-columns: 1fr; gap: 14px; align-items: start; }
  .stats-circuit-library-head > p { justify-self: start; }
  .stats-circuit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-circuit-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .stats-product-page .wrap,
  .stats-explorer-page .wrap {
  max-width: var(--max);
  padding-inline: var(--gutter);
}
  .stats-entity-entry-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
  .stats-entity-entry-grid .stats-circuit-entry { grid-column: auto; }
  .stats-entity-entry { border-right: 0; border-bottom: 1px solid var(--stats-line);
  gap: .5rem;
  min-height: 52px;
  padding: .75rem 1rem;
}
  .stats-catalogue-tools { grid-template-columns: 1fr; gap: 12px;
  padding: 1.5rem 0;
}
  .stats-catalogue-tools > p { margin: 0; }
  .stats-community-close { grid-template-columns: 1fr; gap: 12px; }
  .stats-statistic-groups-race-performance,
  .stats-statistic-groups-fastest-laps { grid-template-columns: 1fr; }
  .stats-category-nav { flex-flow: row nowrap; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-width: thin; }
  .stats-category-button { min-width: max-content; border-bottom: 0; }
  .stats-metric-panel,
  .records-library-grid.stats-metric-panel { grid-template-columns: 1fr; padding: 24px 0 36px; }
  .stats-catalogue-group:not([data-catalogue-category="race-performance"])
    > .stats-disclosure-body
    > .stats-disclosure-content
    > .stats-metric-list { column-count: 1; }
  .stats-catalogue-group { border-top-width: 1px;
  padding-inline: 1rem;
  padding-bottom: 0;
  border-top: 1px solid var(--line);
}
  .stats-catalogue-group .stats-metric-group-head {
  min-height: 64px;
  padding: 1rem 0;
  align-items: center;
  border-bottom: 0;
}
  .stats-catalogue-group[open] .stats-metric-list { padding-bottom: 20px; }
  .stats-statistic-group { border-top-color: var(--stats-soft-line); }
  .stats-statistic-group > summary { min-height: 52px; }
  .stats-statistic-groups-race-performance .stats-statistic-group.is-long .stats-metric-list { grid-template-columns: 1fr; }
  .stats-circuit-grid,
  .stats-circuit-future-grid { grid-template-columns: 1fr; }
  .stats-circuit-card { min-height: 205px; }
  .stats-circuit-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-circuit-layout { min-height: 320px; padding: 20px; }
  .stats-circuit-layout-figure { grid-template-columns: 1fr; gap: 20px; }
  .stats-circuit-layout-figure svg { max-height: 340px; }

  .stats-mobile-filter-button {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    width: 100%;
    min-height: 48px;
    margin-bottom: 10px;
    padding: 9px 12px;
    border: 1px solid var(--stats-line);
    border-radius: 0;
    background: var(--stats-panel);
    color: var(--stats-ink);
    text-align: left;
  }

  .stats-mobile-filter-button span { font-size: var(--text-body); font-weight: 700; letter-spacing: normal; text-transform: none; }
  .stats-mobile-filter-button em { color: var(--stats-muted); font-size: var(--text-body); font-style: normal; text-align: right; }

  .stats-filter-scrim:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(7, 7, 7, 0.58);
  }

  .stats-filter-drawer-open { overflow: hidden; }
  .stats-lab-shell.stats-explorer-v2 { display: block; border: 0; }
  .stats-explorer-v2 .explorer-workbench {
    display: none;
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 1000;
    width: min(340px, calc(100vw - 24px));
    height: 100dvh;
    max-height: 100dvh;
    padding: 0 18px 30px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 0;
    background: var(--stats-paper);
  }

  .stats-explorer-v2 .explorer-workbench.is-open { display: block; }
  .stats-explorer-v2 .stats-option-scroll { max-height: min(42dvh, 340px); }
  .stats-explorer-v2 .explorer-workbench button,
  .stats-explorer-v2 .explorer-workbench input,
  .stats-explorer-v2 .explorer-workbench select,
  .stats-explorer-v2 .explorer-workbench summary { min-height: 44px; }
  .stats-filter-heading [data-filter-drawer-close] {
    display: inline-flex;
    padding: 8px 0;
    border: 0;
    background: transparent;
    color: var(--stats-orange-dark);
    font-size: var(--text-sm);
    font-weight: 700;
    text-transform: none;
  }

  .stats-explorer-v2 .lab-results { padding: 22px 8px 34px; }
  .stats-explorer-v2 .lab-results-head { align-items: start; }
  .lab-results-actions { justify-content: flex-start; }

  .custom-leaderboard-table[data-metric-presentation="last-win"] tr {
    grid-template-columns: 42px minmax(72px, 0.8fr) minmax(104px, 1.45fr) 58px;
  }
  .custom-leaderboard-table[data-metric-presentation="last-win"] .column-lastWin { grid-column: 3; font-size: var(--text-body); line-height: 1.25; }
  .custom-leaderboard-table[data-metric-presentation="last-win"] .column-since { grid-column: 4; font-size: var(--text-body); line-height: 1.25; }

  .custom-leaderboard-table[data-metric-presentation="event"] tr {
    grid-template-columns: 42px minmax(76px, 0.8fr) minmax(100px, 1.35fr) 44px;
  }
  .custom-leaderboard-table[data-metric-presentation="event"] .column-grandPrix { grid-column: 3; font-size: var(--text-body); }
  .custom-leaderboard-table[data-metric-presentation="event"] .column-season { grid-column: 4; font-size: var(--text-body); }

  .custom-leaderboard-table[data-metric-presentation="seasonal"] tr {
    grid-template-columns: 42px minmax(90px, 1fr) 52px 64px;
  }
  .custom-leaderboard-table[data-metric-presentation="seasonal"] .column-season { grid-column: 3; }
  .custom-leaderboard-table[data-metric-presentation="seasonal"] .column-metricValue { grid-column: 4; }
}

@media (max-width: 760px) {
  .stats-catalogue-group {
  padding-inline: 1rem;
  padding-bottom: 0;
  border-top: 1px solid var(--line);
}
}

@media (max-width: 480px) {
  .stats-product-page .wrap,
  .stats-explorer-page .wrap {
  max-width: var(--max);
  padding-inline: var(--gutter);
}
  .stats-product-hero-grid,
  .stats-ranking-hero-grid { min-height: 0; padding-top: 44px; padding-bottom: 38px; }
  .stats-product-hero h1 { font-size: var(--text-title);
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
  letter-spacing: normal;
}
  .stats-product-page[data-stats-catalogue] .stats-product-hero h1 { font-size: var(--text-title);
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
  letter-spacing: normal;
}
  .stats-product-page[data-stats-catalogue] .stats-product-hero h1 em { margin-left: 0;
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
  letter-spacing: normal;
}
  [data-statistic-detail] .stats-product-hero h1 {
    overflow-wrap: normal;
    font-size: var(--text-title);
    hyphens: none;

  color: var(--ink);
  margin: 0;
  line-height: 1.2;
  letter-spacing: normal;
}
  .stats-circuit-page .stats-product-hero h1 { font-size: var(--text-title);
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
  letter-spacing: normal;
}
  .stats-ranking-hero h1 { font-size: var(--text-title);
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
  letter-spacing: normal;
}
  .stats-primary-cta { min-width: 0; width: 100%;
  min-height: 44px;
}
  .stats-catalogue-section { padding-top: 38px;
  padding: 1.5rem 0 3rem;
}
  .stats-catalogue-head h2 {
  font-size: var(--text-section);
  line-height: 1.3;
}
  .stats-circuit-facts { grid-template-columns: 1fr; }
  .stats-explorer-v2 .lab-results-head { display: grid; }
  .stats-selection-summary { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --stats-motion-duration: 0ms; }
  .stats-disclosure-body,
  .stats-disclosure-icon::before,
  .stats-disclosure-icon::after,
  .stats-animated-region,
    .stats-entity-entry,
    .stats-circuit-card,
    .stats-category-button,
  .stats-metric-link {
    transition: none !important;
  }
}

/* ---------------------------------------------------------------------------
   Ranking tables
   A table holding one statistic (a ranking or a record table) reads as a
   ranked list: rank, name, context, value. It runs the full length of the page
   and, on phones, stacks each row so nothing sits off-screen. Tables comparing
   several statistics keep a grid that scrolls across with a sticky name column.
   This block is the single source for those rules; it is last in the file on
   purpose, to settle the older layered table rules above and in styles.css.
   ------------------------------------------------------------------------ */

.custom-leaderboard-table th { overflow-wrap:anywhere; white-space:normal; text-transform:uppercase; font-size:.75rem; letter-spacing:.04em; vertical-align:middle; }
.custom-leaderboard-table .metric-sort-button { white-space:normal; max-width:100%; min-width:0; text-align:inherit; }
.custom-leaderboard-table .driver-cell { overflow-wrap:normal; }
.custom-leaderboard-table .secondary-metric-cell { font-size:var(--text-body); }

/* The wrap is a size container: ranking tables choose their layout from the
   width they actually get, which beside the filter panel is far less than the
   viewport. */
.stats-explorer-v2 .leaderboard-wrap { overflow-x:auto; overflow-y:hidden; container:stats-ranking / inline-size; }
.stats-explorer-v2 .leaderboard-wrap:focus-visible { outline:2px solid var(--stats-orange); outline-offset:3px; }

/* Record tables have no driver/range filters or cross-statistic joins. */
.record-table-mode .explorer-workbench,
.record-table-mode [data-filter-drawer-open] { display:none !important; }
.record-table-mode .stats-lab-shell { grid-template-columns:minmax(0,1fr); }

/* ---- Legend for the name colours ---- */

.stats-standing-legend {
  display:flex;
  flex-wrap:wrap;
  gap:.35rem 1.25rem;
  margin:0 0 .9rem;
  padding:0;
  list-style:none;
  font-size:var(--text-sm);
}
.stats-standing-legend[hidden] { display:none; }
.stats-standing-key { display:inline-flex; align-items:center; gap:.5rem; color:var(--stats-entity-current); font-weight:700; }
.stats-standing-swatch { flex:0 0 auto; width:.5rem; height:.5rem; border-radius:50%; background:currentColor; }
.stats-standing-key.is-champion { color:var(--stats-champion); font-weight:800; }
.stats-standing-key.is-champion.is-former-entity { color:var(--stats-champion-former); font-weight:700; }
.stats-standing-key.is-former-entity:not(.is-champion) { color:var(--stats-entity-former); font-weight:500; }

/* ---- One statistic per table ----
   Selector weight is deliberate. The cell reset doubles the table class so it
   outranks the legacy `td:nth-child(n+1)` rules (0,4,1) by source order; every
   per-cell rule below names its element so it ties the reset and wins by
   coming later. Keep new per-cell rules in that shape. */

.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic { display:table; width:100%; min-width:0; table-layout:auto; border-collapse:separate; border-spacing:0; }
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic thead { display:table-header-group; }
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic tbody { display:table-row-group; border:0; border-radius:0; background:transparent; box-shadow:none; overflow:visible; }
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic tr { display:table-row; padding:0; border:0; box-shadow:none; }

.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic th,
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic td {
  display:table-cell;
  position:static;
  width:auto;
  min-width:0;
  max-width:none;
  padding:.8rem .75rem;
  border:0;
  border-bottom:1px solid var(--stats-row-line);
  background:transparent;
  box-shadow:none;
  color:var(--stats-ink);
  font-size:var(--text-body);
  font-weight:400;
  line-height:1.35;
  text-align:left;
  vertical-align:middle;
  white-space:normal;
  transition:background-color 160ms ease;
}

.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic th {
  padding-block:.6rem;
  border-bottom:2px solid var(--stats-ink);
  color:var(--stats-muted);
  font-size:.75rem;
  font-weight:700;
}

.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic td::before,
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic th::before { content:none; }

.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic th.rank-heading,
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.rank-cell {
  width:3.75rem;
  font-variant-numeric:tabular-nums;
  text-align:right;
  white-space:nowrap;
}
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.rank-cell { color:var(--stats-muted); font-weight:700; }

/* The name column takes the free width; context and value columns hug their content. */
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic th.secondary-heading,
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.secondary-metric-cell,
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic th.metric-heading,
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.metric-cell { width:1%; white-space:nowrap; }

.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.driver-cell { font-weight:700; }
/* Text context (a Grand Prix, a team) may wrap; numbers and seasons never do. */
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.secondary-metric-cell { color:var(--stats-muted); white-space:normal; min-width:7rem; }
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.metric-cell.column-grandPrix { white-space:normal; min-width:9rem; }
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic th.metric-heading { color:var(--stats-orange-dark); text-align:right; }
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic .metric-sort-button { justify-content:flex-end; white-space:nowrap; }

.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.metric-cell {
  color:var(--stats-ink);
  font-size:1.0625rem;
  font-weight:800;
  font-variant-numeric:tabular-nums;
  text-align:right;
}

/* Statistics whose ranked value is a Grand Prix read left, like the other text columns. */
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.metric-cell.column-grandPrix { font-size:var(--text-body); font-weight:700; text-align:left; }
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic th.column-season,
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.column-season,
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic th.column-since,
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.column-since { text-align:right; font-variant-numeric:tabular-nums; }

/* Record tables: descriptions wrap, the value stays compact. */
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic th.record-heading,
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.record-description { white-space:normal; overflow-wrap:break-word; }

/* ---- Name colours: champions in red, entities off the grid quieter ----
   Weight carries the distinction alongside colour (800 / 700 / 700 / 500), and
   each row's accessible name states the standing in words. */

.stats-explorer-v2 .custom-leaderboard-table tr.is-current-entity td.driver-cell { color:var(--stats-entity-current); font-weight:700; }
.stats-explorer-v2 .custom-leaderboard-table tr.is-former-entity td.driver-cell { color:var(--stats-entity-former); font-weight:500; }
.stats-explorer-v2 .custom-leaderboard-table tr.is-champion td.driver-cell { color:var(--stats-champion); font-weight:800; }
.stats-explorer-v2 .custom-leaderboard-table tr.is-champion.is-former-entity td.driver-cell { color:var(--stats-champion-former); font-weight:700; }

/* ---- Rows open the detail dialog: a quiet arrow at the end answers hover and focus ---- */

.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic tr.single-ranking-row { cursor:pointer; }
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic tr.single-ranking-row:hover td { background:var(--stats-row-hover); }
.stats-explorer-v2 .custom-leaderboard-table.is-single-statistic tr.single-ranking-row:focus-visible { outline:2px solid var(--stats-orange); outline-offset:-2px; }
.stats-explorer-v2 .custom-leaderboard-table.is-single-metric-table tr > th:last-child,
.stats-explorer-v2 .custom-leaderboard-table.is-single-metric-table tr > td:last-child { padding-right:2.5rem; }
.stats-explorer-v2 .custom-leaderboard-table.is-single-metric-table tr.single-ranking-row > td:last-child { position:relative; }
.stats-explorer-v2 .custom-leaderboard-table.is-single-metric-table tr.single-ranking-row > td:last-child::after {
  content:"→";
  position:absolute;
  top:50%;
  right:.85rem;
  color:var(--stats-muted);
  font-size:var(--text-body);
  font-weight:700;
  opacity:.4;
  transform:translate(0, -50%);
  transition:opacity 180ms ease, transform 220ms cubic-bezier(0.16, 1, 0.3, 1), color 180ms ease;
}
.stats-explorer-v2 .custom-leaderboard-table.is-single-metric-table tr.single-ranking-row:hover > td:last-child::after,
.stats-explorer-v2 .custom-leaderboard-table.is-single-metric-table tr.single-ranking-row:focus-visible > td:last-child::after {
  color:var(--stats-orange-dark);
  opacity:1;
  transform:translate(4px, -50%);
}

/* ---- Comparisons of several statistics fit their column where they can ---- */

.stats-explorer-v2 .custom-leaderboard-table.is-multi-metric-table:not(.is-single-statistic) { width:100%; min-width:max(720px, 100%); table-layout:auto; }
.stats-explorer-v2 .custom-leaderboard-table.is-multi-metric-table:not(.is-single-statistic) .metric-sort-button { white-space:normal; }
.stats-explorer-v2 .custom-leaderboard-table.is-multi-metric-table:not(.is-single-statistic) th:nth-child(n),
.stats-explorer-v2 .custom-leaderboard-table.is-multi-metric-table:not(.is-single-statistic) td:nth-child(n) { padding-inline:.55rem; }
.stats-explorer-v2 .custom-leaderboard-table.is-multi-metric-table:not(.is-single-statistic) th.entity-heading,
.stats-explorer-v2 .custom-leaderboard-table.is-multi-metric-table:not(.is-single-statistic) td.driver-cell { min-width:10rem; }

@media (prefers-reduced-motion: reduce) {
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic td,
  .stats-explorer-v2 .custom-leaderboard-table.is-single-metric-table tr.single-ranking-row > td:last-child::after { transition:none; }
}

/* ---- Narrow tables: each row stacks as rank · name · value, with context beneath ---- */

@container stats-ranking (max-width: 720px) {
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic,
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic thead,
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic tbody { display:block; width:100%; min-width:0; }

  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic tr {
    display:grid;
    grid-template-columns:2.25rem minmax(0, 1fr) auto;
    grid-template-areas:none;
    align-items:baseline;
    column-gap:.75rem;
    row-gap:.2rem;
    padding:.75rem .25rem;
    border-bottom:1px solid var(--stats-row-line);
  }
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-unranked tr { grid-template-columns:minmax(0, 1fr) auto; }
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic thead tr { padding-block:.5rem; border-bottom:2px solid var(--stats-ink); }

  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic th,
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic td {
    display:block;
    grid-area:auto;
    width:auto;
    padding:0;
    border:0;
    white-space:normal;
  }
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-single-statistic th { padding:0; border:0; }

  .stats-explorer-v2 .custom-leaderboard-table.is-single-metric-table tr > th:last-child,
  .stats-explorer-v2 .custom-leaderboard-table.is-single-metric-table tr > td:last-child { padding-right:0; }
  .stats-explorer-v2 .custom-leaderboard-table.is-single-metric-table tr.single-ranking-row > td:last-child::after { content:none; }
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic tr.single-ranking-row:hover td { background:transparent; }
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic tr.single-ranking-row:active { background:var(--stats-row-hover); }

  /* Row one: rank, the name (or a record's first description) and the value. */
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic th.rank-heading,
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.rank-cell { grid-column:1; grid-row:1; width:auto; }
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic th.rank-heading { overflow-wrap:normal; letter-spacing:0; white-space:nowrap; }

  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic th.entity-heading,
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.driver-cell { grid-column:2; grid-row:1; }

  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic th.metric-heading,
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.metric-cell {
    grid-column:-2;
    grid-row:1;
    width:auto;
    max-width:11rem;
    justify-self:end;
    text-align:right;
  }
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic th.metric-heading .metric-sort-button { white-space:normal; }

  /* Everything else is context under the name, labelled. */
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic th.secondary-heading,
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic th.record-heading { display:none; }

  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.metric-cell.column-grandPrix,
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.secondary-metric-cell,
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.record-description {
    grid-column:2 / -1;
    grid-row:auto;
    width:auto;
    max-width:none;
    justify-self:stretch;
    color:var(--stats-muted);
    font-size:var(--text-sm);
    font-weight:600;
    text-align:left;
  }
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-unranked td.record-description { grid-column:1 / -1; }

  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.secondary-metric-cell::before,
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic td.record-description::before {
    content:attr(data-label);
    margin-right:.45em;
    color:var(--stats-muted);
    font-size:.6875rem;
    font-weight:700;
    letter-spacing:.04em;
    text-transform:uppercase;
  }

  /* A record's first description leads its row, unlabelled. */
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic:not(.is-unranked) th.record-heading:nth-child(2),
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-unranked th.record-heading:nth-child(1) { display:block; grid-row:1; }
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic:not(.is-unranked) th.record-heading:nth-child(2),
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic:not(.is-unranked) td.record-description:nth-child(2) { grid-column:2; grid-row:1; }
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-unranked th.record-heading:nth-child(1),
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-unranked td.record-description:nth-child(1) { grid-column:1; grid-row:1; }
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic:not(.is-unranked) td.record-description:nth-child(2),
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-unranked td.record-description:nth-child(1) { color:var(--stats-ink); font-size:var(--text-body); font-weight:700; }
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic:not(.is-unranked) td.record-description:nth-child(2)::before,
  .stats-explorer-v2 .custom-leaderboard-table.is-single-statistic.is-unranked td.record-description:nth-child(1)::before { content:none; }
}

/* ---------------------------------------------------------------------------
   Statistic hero (2026-09-16)
   One column: breadcrumb, title, then the statistic's definition directly
   under the title. The definition used to sit in a second column beneath the
   right-aligned Statistics Catalogue link, where it read as that link's
   caption. Declared last so it settles the grid rules above.
   ------------------------------------------------------------------------ */
.stats-ranking-hero .stats-ranking-hero-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: .5rem;
  align-items: start;
}

.stats-ranking-hero .stats-ranking-hero-grid > p {
  max-width: 62ch;
  margin-top: .25rem;
}
