/* ============================================================================
   Stats v2 — the drill-navigation stats view. Tokens only.

   Scoped on .spv-root, the module's own wrapper, NOT on the route container.
   These rules were once scoped to #stats-v2-preview, and every one of them
   would have silently stopped applying the moment the module moved to
   #stats-v2 — a naked page with no error anywhere. Scoping on what the module
   renders means the styling travels with it wherever it is mounted.
   ========================================================================== */

.spv-root { max-width: 560px; margin: 0 auto; }

.spv-root .spv-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding: 9px 14px;
  border-radius: var(--qz-r-card);
  border: 1px dashed var(--qz-warning, var(--qz-line-strong));
  background: var(--qz-warning-bg, var(--qz-accent-soft));
  color: var(--qz-warning-ink, var(--qz-text));
  font-size: .8rem;
  font-weight: var(--qz-fw-strong, 700);
  text-align: left;
}

/* Scope tabs — pill row, in the app's vNext language */
.spv-root .spv-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 10px;
}
.spv-root .spv-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--qz-r-pill);
  border: 1px solid var(--qz-line);
  background: var(--qz-surface);
  color: var(--qz-text);
  font-size: .85rem;
  font-weight: var(--qz-fw-strong, 700);
  cursor: pointer;
  white-space: nowrap;
}
.spv-root .spv-tab.is-active {
  background: var(--qz-accent);
  border-color: var(--qz-accent);
  color: var(--qz-on-accent);
}

/* « Vue et filtres » trigger — values copied verbatim from the component in
   style/features/stats-v2.css, which is scoped to .stats-v2-shell and so no
   longer reaches this markup. Kept identical because users knew that control. */
/* Chips sit to the LEFT of the trigger and wrap with it; the group stays
   centred like the tabs and CTAs above and below it. */
.spv-root .spv-filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}
.spv-root .spv-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.spv-root .spv-chips.is-empty { display: none; }

/* Same box as the trigger — identical padding, border width and type — so a
   chip and the trigger are exactly the same height on the same line. */
.spv-root .spv-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 9px 14px;
  border: 1px solid var(--qz-accent-mid, var(--qz-line));
  border-radius: var(--qz-r-pill);
  background: var(--qz-accent-soft);
  color: var(--qz-accent-ink);
  font-size: 0.9rem;
  font-weight: var(--qz-fw-strong);
}
.spv-root .spv-chip__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* A quiz title can be long; without a ceiling one chip pushes the trigger
     off the row on a phone. */
  max-width: 20ch;
}
.spv-root .spv-chip__x {
  flex: 0 0 auto;
  /* 20px is the box the count badge already occupies inside the trigger
     without stretching it, so the chip inherits the same height. */
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--qz-accent-ink);
  font-size: 0.72rem;
  line-height: 1;
  cursor: pointer;
}
.spv-root .spv-chip__x:hover,
.spv-root .spv-chip__x:focus-visible {
  background: var(--qz-surface);
  outline: none;
}
.spv-root .stats-v2-filters-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  border: 1px solid var(--qz-line);
  border-radius: var(--qz-r-pill);
  background: var(--qz-surface);
  color: var(--qz-text);
  font-size: 0.9rem;
  font-weight: var(--qz-fw-strong);
  cursor: pointer;
  transition: border-color var(--qz-dur-ui), background var(--qz-dur-ui);
}
.spv-root .stats-v2-filters-trigger:hover,
.spv-root .stats-v2-filters-trigger:focus-visible {
  border-color: var(--qz-accent-mid);
  background: var(--qz-accent-soft);
  outline: none;
}
.spv-root .stats-v2-filters-trigger-ic {
  color: var(--qz-accent-ink);
  font-size: 1rem;
}
.spv-root .stats-v2-filters-trigger-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: var(--qz-fw-strong);
  line-height: 1;
  background: var(--qz-accent);
  color: var(--qz-on-accent);
  border-radius: var(--qz-r-pill);
}
/* Zero applied filters is now reachable (the view choice no longer counts), so
   the badge goes away rather than reading "0". */
.spv-root .stats-v2-filters-trigger-count.is-empty { display: none; }

/* CSV export — same box as the trigger it stands beside (see .spv-chip for the
   same reasoning), but quieter: it is an action on the view, not the control
   that shapes it. Locked (free) users get the crown treatment. */
.spv-root .spv-export {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--qz-line);
  border-radius: var(--qz-r-pill);
  background: var(--qz-surface);
  color: var(--qz-muted);
  font-size: 0.9rem;
  font-weight: var(--qz-fw-strong);
  cursor: pointer;
  transition: border-color var(--qz-dur-ui), color var(--qz-dur-ui);
}
.spv-root .spv-export:hover,
.spv-root .spv-export:focus-visible {
  border-color: var(--qz-accent-mid);
  color: var(--qz-accent-ink);
  outline: none;
}
.spv-root .spv-export.is-pro-locked { color: var(--qz-warning-ink, var(--qz-accent-ink)); }
.spv-root .spv-export.d-none { display: none; }

/* The filter sheet (small form — natural height, unlike the drill sheet) */
.spv-filter-sheet .mp-modal__panel {
  animation: none !important;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.22, .61, .36, 1);
}
.spv-filter-sheet.is-open .mp-modal__panel { transform: translateY(0); }
.spv-filter-sheet__body { display: grid; gap: 14px; }
.spv-filter-sheet__section { display: grid; gap: 8px; }
.spv-filter-sheet__label {
  margin: 0;
  font-size: .78rem;
  font-weight: var(--qz-fw-strong, 700);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--qz-muted);
}
.spv-filter-sheet__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.spv-filter-sheet__actions .spv-cta--apply { flex: 1 1 auto; margin: 0; }
.spv-filter-sheet__reset {
  border: 0;
  background: transparent;
  color: var(--qz-muted);
  font-size: .84rem;
  font-weight: var(--qz-fw-strong, 700);
  cursor: pointer;
  padding: 8px 10px;
}
.spv-filter-sheet__reset:hover { color: var(--qz-text); }

.spv-dates {
  display: flex;
  gap: 10px;
  font-size: .8rem;
  color: var(--qz-muted);
}
.spv-dates label { display: flex; align-items: center; gap: 6px; }
.spv-dates input {
  border: 1px solid var(--qz-line);
  border-radius: 10px;
  background: var(--qz-surface);
  color: var(--qz-text);
  padding: 5px 8px;
  font-size: .8rem;
}

/* ── L0 hero charts ──────────────────────────────────────────────────────
   Single-hue by design (accent on accent-soft): the app's success/error poles
   fail CVD separation as series colours, and one hue survives all 12 themes.
   Identity always comes from text, never from colour. */
.spv-charts {
  display: grid;
  /* grid-template-columns: 1fr 1fr; */
  gap: 10px;
  margin-bottom: 12px;
}
.spv-chart-card {
  position: relative;
  border: 1px solid var(--qz-line);
  border-radius: var(--qz-r-card);
  background: var(--qz-surface);
  padding: 12px;
  min-width: 0;
}
.spv-chart-card--wide { grid-column: 1 / -1; }
.spv-chart-title {
  font-size: .72rem;
  font-weight: var(--qz-fw-strong, 700);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--qz-muted);
  margin-bottom: 8px;
}

/* Gauge ring */
.spv-ring { position: relative; width: 110px; margin: 0 auto; }
.spv-ring svg { display: block; width: 100%; height: auto; }
.spv-ring__centre {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  text-align: center;
  pointer-events: none;
}
.spv-ring__centre strong { font-size: 1.05rem; color: var(--qz-text); line-height: 1; }
.spv-ring__centre span { font-size: .58rem; color: var(--qz-muted); max-width: 64px; line-height: 1.2; }

/* Sparkline */
.spv-spark { display: block; width: 100%; height: 110px; }
.spv-spark circle { cursor: pointer; }
.spv-spark__last {
  font-size: 12px;
  font-weight: 700;
  fill: var(--qz-text);
}

/* Hero number tile */
.spv-big {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 96px;
  text-align: center;
}
.spv-big strong { font-size: 1.7rem; color: var(--qz-text); line-height: 1.1; }
.spv-big span { font-size: .7rem; color: var(--qz-muted); }

/* Magnitude bars — one hue, labels carry identity */
.spv-hbars { display: grid; gap: 8px; }
.spv-hbar {
  display: grid;
  grid-template-columns: minmax(72px, auto) 1fr auto;
  align-items: center;
  gap: 10px;
}
.spv-hbar__label {
  font-size: .78rem;
  color: var(--qz-text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spv-hbar__track {
  position: relative;
  height: 10px;
  border-radius: var(--qz-r-pill);
  background: var(--qz-accent-soft);
  overflow: hidden;
}
.spv-hbar__track i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: var(--qz-r-pill);
  background: var(--qz-accent);
}
.spv-hbar__value {
  font-size: .78rem;
  font-weight: var(--qz-fw-strong, 700);
  color: var(--qz-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Shared chart tooltip */
.spv-root { position: relative; }
.spv-tip {
  position: absolute;
  transform: translate(-50%, -100%);
  background: var(--qz-text);
  color: var(--qz-surface);
  font-size: .72rem;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 8px;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--qz-dur-ui) ease;
  z-index: 30;
}
.spv-tip.is-on { opacity: 1; }

/* KPI grid — 2 cols, the same rhythm the rest of the app uses */
.spv-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.spv-kpi {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 12px;
  border: 1px solid var(--qz-line);
  border-radius: var(--qz-r-card);
  background: var(--qz-surface);
  text-align: center;
  /* A grid item's default min-width:auto lets a long value (an id, a date)
     push the column past the panel and scroll the whole sheet sideways. */
  min-width: 0;
}
.spv-kpi strong {
  font-size: 1.15rem;
  color: var(--qz-text);
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.spv-kpi span { font-size: .74rem; color: var(--qz-muted); overflow-wrap: anywhere; }

/* Drill CTAs — L0's only route into the details (rows never render inline) */
.spv-ctas { display: grid; gap: 8px; margin-bottom: 4px; }
.spv-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 11px 16px;
  border-radius: var(--qz-r-pill);
  border: 0;
  background: var(--qz-accent);
  color: var(--qz-on-accent);
  font-weight: var(--qz-fw-strong, 700);
  cursor: pointer;
}
.spv-cta--ghost {
  background: var(--qz-surface);
  color: var(--qz-text);
  border: 1.5px solid var(--qz-line-strong, var(--qz-line));
}
.spv-cta--ghost:hover { border-color: var(--qz-accent); color: var(--qz-accent-ink, var(--qz-accent)); }

/* The launch lives ONLY on the quiz level — the tables drill, this one plays
   (see the QUIZ COLUMN note in stats.ui.view.js). It sits between the hero
   and the rows, so it carries its own separation from both. */
.spv-cta--play { margin: 2px 0 14px; }

/* A quiz cell is the drill handle into that quiz's own stats */
.spv-quiz-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--qz-accent-ink, var(--qz-accent));
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.spv-quiz-link:hover { text-decoration: underline; }

/* Inapplicable filters are DISABLED, never hidden — nothing shifts when the
   context changes. */
.spv-filter-disabled { opacity: .45; pointer-events: none; }

/* Contextual search — present at every level */
.spv-search {
  position: relative;
  margin-bottom: 10px;
}
.spv-search .fa-search {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--qz-muted);
  font-size: .8rem;
}
.spv-search__input {
  width: 100%;
  border: 1.5px solid var(--qz-line);
  border-radius: 12px;
  background: var(--qz-surface);
  color: var(--qz-text);
  padding: .5rem .8rem .5rem 2.1rem;
  font-size: .88rem;
}
.spv-search__input:focus {
  outline: none;
  border-color: var(--qz-accent);
  box-shadow: 0 0 0 3px var(--qz-accent-soft);
}

/* Tables — lean, data-label cells keep them readable when narrow */
.spv-table-wrap {
  border: 1px solid var(--qz-line);
  border-radius: var(--qz-r-card);
  background: var(--qz-surface);
  margin-bottom: 12px;
  overflow-x: auto;
}
.spv-table-title {
  padding: 10px 12px 4px;
  font-size: .82rem;
  font-weight: var(--qz-fw-strong, 700);
  color: var(--qz-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.spv-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.spv-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--qz-muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--qz-line);
  white-space: nowrap;
}
.spv-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--qz-line);
  color: var(--qz-text);
  vertical-align: middle;
}
.spv-table tbody tr:last-child td { border-bottom: 0; }
.spv-table a { color: var(--qz-accent-ink, var(--qz-accent)); font-weight: 600; }
/* A refused view: a named wall with a way out, not a red string. Same surface
   as a card so it reads as content rather than as breakage. */
.spv-guided {
  display: grid;
  gap: 10px;
  padding: 22px 18px;
  border: 1px solid var(--qz-line);
  border-radius: var(--qz-r-card);
  background: var(--qz-surface);
  text-align: center;
}
.spv-guided__title {
  font-size: 1rem;
  font-weight: var(--qz-fw-strong, 700);
  color: var(--qz-text);
}
.spv-guided__body {
  font-size: .86rem;
  line-height: 1.45;
  color: var(--qz-muted);
}
.spv-guided__actions { display: grid; gap: 8px; margin-top: 4px; }
.spv-cta--guided { width: auto; justify-self: center; padding-left: 22px; padding-right: 22px; }

.spv-row-hidden { display: none !important; }
.spv-empty, .spv-loading, .spv-error {
  padding: 22px 12px;
  text-align: center;
  color: var(--qz-muted);
  font-size: .86rem;
}
.spv-error { color: var(--qz-error-ink, var(--qz-error)); }

/* Sort bar (leaderboard levels) */
/* ── Ranking = the hall-of-champions ─────────────────────────────────────
   The board is hosted in a `.stats-v2-shell` wrapper ON PURPOSE: every champion
   rule in stats-v2.css (:542-730) is scoped to that class, so the cards, the
   medals, the current-player highlight, the flash, the sort control and the
   jump button are INHERITED rather than restated here. `.spv-sortbar` IS
   .stats-v2-table-toolbar, so "styled identically" is a fact of the markup.

   The only thing to undo is the host's own page box — 1rem of vertical padding
   and a 560px centred column belong to a full page, not to a block inside a
   480px sheet. */
.spv-root .spv-champ-host {
  padding: 0;
  max-width: none;
  margin: 0;
}
/* That wrap is a bordered table card; here the sheet is already the card. */
.spv-root .spv-champ-host .stats-v2-table-wrap {
  border: 0;
  padding: 0;
  background: transparent;
}
/* Pager — its stats-v2.css rules are bound to the page column, so it gets its
   own box here rather than inheriting one sized for a full-width page. */
.spv-root .spv-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}
.spv-root .spv-pager .stats-v2-page-nav {
  padding: 8px 14px;
  border: 1px solid var(--qz-line);
  border-radius: var(--qz-r-pill);
  background: var(--qz-surface);
  color: var(--qz-text);
  font-size: .82rem;
  font-weight: var(--qz-fw-strong);
  cursor: pointer;
}
.spv-root .spv-pager .stats-v2-page-nav:hover:not(:disabled) { border-color: var(--qz-accent-mid); }
.spv-root .spv-pager .stats-v2-page-nav:disabled { opacity: .45; cursor: default; }
.spv-root .spv-pager .stats-v2-page-status {
  font-size: .78rem;
  color: var(--qz-muted);
  text-align: center;
}

/* ── The drill sheet ─────────────────────────────────────────────────────
   .mp-modal chrome comes from vnext-groupes-detail.css. Same two adjustments
   as every other sheet: class-triggered slide (mpSheetUp freezes on re-show)
   and a taller panel — drill content is a full view, not a menu. */
.spv-sheet .mp-modal__panel {
  animation: none !important;
  transform: translateY(100%);
  transition: transform .3s cubic-bezier(.22, .61, .36, 1);
  max-height: 88vh;
  height: 88vh;
  display: flex;
  flex-direction: column;
}
.spv-sheet.is-open .mp-modal__panel { transform: translateY(0); }
.spv-sheet__head { gap: 8px; }
.spv-sheet__head .mp-modal__title {
  flex: 1 1 auto;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spv-sheet__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 40%;
  border: 0;
  background: transparent;
  color: var(--qz-accent-ink, var(--qz-accent));
  font-size: .84rem;
  font-weight: var(--qz-fw-strong, 700);
  cursor: pointer;
  padding: 4px 6px;
}
.spv-sheet__back span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.spv-sheet__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  /* The BODY never scrolls sideways — only a wide table does, inside its own
     .spv-table-wrap. Without this a single long cell drags the whole sheet. */
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.spv-sheet__body > * { max-width: 100%; }

/* A quiz handle resolving its id: busy on the control, never on the body —
   overwriting the body would be snapshotted as the parent level's cache. */
.spv-quiz-link.is-busy { opacity: .5; pointer-events: none; }
