/* ============================================================
   Aximetra — Design system
   « Registre de certification » : encre marine + sceau laiton sur
   papier crème. Grotesk pour les titres, Inter pour le texte courant,
   chiffres en monospace pour la lecture des donnees.
   ============================================================ */

:root {
  /* Surfaces & fonds (papier chaud, pas de gris froid) */
  --bg: #f5f3ec;
  --bg-deep: #ece8db;
  --surface: #ffffff;
  --surface-2: #faf8f2;
  --surface-3: #f1eee2;

  /* Lignes */
  --border: #e4e0d0;
  --border-strong: #d2ccb4;

  /* Texte (encre marine) */
  --ink: #1a2230;
  --ink-soft: #3d4552;
  --ink-muted: #656d78;
  --ink-faint: #767d87;

  /* Accent primaire (marine profond, encre d'un acte officiel) */
  --accent: #1f3a5c;
  --accent-strong: #142943;
  --accent-bright: #3568a3;
  --accent-soft: #e7ecf2;
  --accent-softer: #f1f4f8;
  --accent-ring: rgba(31, 58, 92, 0.18);

  /* Accent secondaire (laiton — le sceau : reserve aux etats positifs/confirmes) */
  --gold: #a67c3d;
  --gold-strong: #7d5c28;
  --gold-soft: #f4ecd9;
  --gold-ring: rgba(166, 124, 61, 0.2);

  /* États — succes dissocie de la couleur de marque */
  --success: #2f6b4f;
  --success-soft: #e3ede5;
  --danger: #ae3c26;
  --danger-soft: #fae7e0;
  --info: #1f3a5c;

  /* Typographie */
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Rayons — coins nets pour les repères "système", arrondis pour le contenu */
  --r-xs: 4px;
  --r-sm: 9px;
  --r-md: 13px;
  --r-lg: 17px;
  --r-xl: 21px;
  --r-pill: 999px;

  /* Ombres (teintées marine, plus chaudes que du gris neutre) */
  --shadow-xs: 0 1px 2px rgba(15, 20, 32, 0.06);
  --shadow-sm: 0 1px 3px rgba(15, 20, 32, 0.08), 0 1px 2px rgba(15, 20, 32, 0.05);
  --shadow-md: 0 8px 20px rgba(15, 20, 32, 0.1);
  --shadow-lg: 0 22px 48px rgba(15, 20, 32, 0.18);

  color-scheme: light;
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* Numéraux tabulaires + monospace partout où un chiffre doit "peser" */
.kpi-tile__value,
.display-limit__value,
.chart-legend-value,
.frequency-table td:last-child,
.numeric-cell,
.ranking-row__value,
.export-progress-value,
.cross-table__cell,
.cross-table__total,
.cross-table__grand {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   En-tête
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(245, 243, 236, 0.9);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.app-header__inner {
  width: min(96vw, 1540px);
  margin: 0 auto;
  padding: 1.35rem clamp(0.85rem, 2.3vw, 2rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand__text h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 2.4vw, 1.6rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.subtitle {
  margin: 0.25rem 0 0;
  max-width: 720px;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink-muted);
}

.header-status {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.header-status.is-live {
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* ============================================================
   Structure principale
   ============================================================ */
main {
  flex: 1;
  width: min(96vw, 1540px);
  margin: 0 auto;
  padding: clamp(1.5rem, 3vw, 2.25rem) clamp(0.85rem, 2.3vw, 2rem) 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.panel {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: clamp(1.25rem, 2.4vw, 1.85rem);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Panneau d'import — dropzone
   ============================================================ */
.upload-panel {
  padding: 0;
  overflow: hidden;
}

.import-tabs {
  display: flex;
  gap: 0.2rem;
  padding: 0.9rem 1.6rem 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.import-tab {
  padding: 0.65rem 0.9rem;
  border: none;
  background: none;
  color: var(--ink-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.import-tab:hover {
  color: var(--accent);
}

.import-tab.active {
  color: var(--accent-strong);
  border-bottom-color: var(--accent);
}

.import-method {
  display: none;
  padding: 1.6rem;
}

.import-method.active {
  display: block;
}

.dropzone {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
  padding: 1.25rem 1.4rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.dropzone:hover {
  border-color: var(--accent);
}

.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-softer);
}

.dropzone__copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-right: auto;
}

.dropzone__title {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.94rem;
}

.dropzone__hint {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

/* ============================================================
   Contrôles d'import
   ============================================================ */
.upload-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.sheets-controls {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.url-input-group {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.sheets-url-input {
  flex: 1;
  min-width: 240px;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font: inherit;
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sheets-url-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.sheets-help {
  margin: 0;
  font-size: 0.86rem;
  color: var(--ink-muted);
  line-height: 1.55;
}

/* ============================================================
   Boutons
   ============================================================ */
.file-input {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  padding: 0.7rem 1.2rem;
  background: var(--accent);
  border-radius: var(--r-md);
  cursor: pointer;
  color: #fff;
  font-weight: 600;
  font-size: 0.92rem;
  box-shadow: var(--shadow-xs);
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.file-input input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-input:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.primary-button {
  padding: 0.7rem 1.2rem;
  background: var(--accent);
  border: none;
  border-radius: var(--r-md);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.primary-button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.primary-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ghost-button {
  padding: 0.7rem 1.2rem;
  border-radius: var(--r-md);
  border: 1px solid var(--border-strong);
  background-color: var(--surface);
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, transform 0.15s ease;
}

.ghost-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.mini-button {
  border: 1px solid var(--border-strong);
  background-color: var(--surface);
  color: var(--ink-soft);
  border-radius: var(--r-sm);
  padding: 0.4rem 0.7rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.mini-button:hover {
  background-color: var(--accent-softer);
  border-color: var(--accent);
  color: var(--accent);
}

.mini-button.danger {
  border-color: rgba(174, 60, 38, 0.4);
  background-color: var(--danger-soft);
  color: var(--danger);
}

.mini-button.danger:hover {
  border-color: var(--danger);
  background-color: rgba(174, 60, 38, 0.12);
  color: var(--danger);
}

.primary-outline {
  background-color: var(--surface);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: var(--r-sm);
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.primary-outline:hover:not(:disabled) {
  background-color: var(--accent-soft);
}

.primary-outline:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ============================================================
   Messages d'état
   ============================================================ */
.feedback {
  margin: 1rem 1.6rem 0;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

.status-area {
  margin: 1rem 1.6rem 0;
  padding: 0.75rem 1rem;
  border-radius: var(--r-md);
  border: 1px solid var(--accent-ring);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.45;
  background-color: var(--accent-soft);
  color: var(--accent-strong);
}

.status-area.success {
  background-color: var(--success-soft);
  border-color: rgba(35, 89, 67, 0.28);
  color: var(--accent-strong);
}

.status-area.error {
  background-color: var(--danger-soft);
  border-color: rgba(174, 60, 38, 0.3);
  color: var(--danger);
}

.status-area.info {
  background-color: var(--accent-soft);
  border-color: var(--accent-ring);
  color: var(--accent-strong);
}

/* ============================================================
   Sélecteur de feuille
   ============================================================ */
.sheet-picker {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin: 1.25rem 1.6rem 1.6rem;
  padding: 0.75rem 1rem;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background-color: var(--surface-2);
  color: var(--ink-soft);
  font-weight: 500;
}

.sheet-picker select {
  flex: 1;
  padding: 0.55rem 0.7rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background-color: var(--surface);
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
}

/* ============================================================
   Navigation principale (vues) — contrôle segmenté
   ============================================================ */
.view-tabs {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.tab-button {
  flex: 1 1 160px;
  padding: 0.68rem 1rem;
  border-radius: var(--r-md);
  border: none;
  background-color: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tab-button:hover {
  background-color: var(--surface-3);
  color: var(--ink);
}

.tab-button.active {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Vues
   ============================================================ */
.view {
  display: none;
}

.view.active {
  display: block;
}

.view-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.export-button {
  border: 1px solid var(--accent);
  border-radius: var(--r-md);
  padding: 0.6rem 1.05rem;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.export-button:hover {
  background: var(--accent);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.filters-toggle {
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 0.6rem 1.05rem;
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.filters-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filters-toggle.is-open {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* ============================================================
   Filtre des colonnes
   ============================================================ */
.filter-panel {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.filter-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.filter-title {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
}

.filter-list {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  max-height: 260px;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  background-color: var(--surface-2);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.88rem;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.filter-option:hover {
  border-color: var(--accent);
  background-color: var(--accent-softer);
}

.filter-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* ============================================================
   Grilles de cartes
   ============================================================ */
.cards-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.04rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: -0.005em;
  color: var(--ink);
}

.card small {
  color: var(--ink-muted);
  font-size: 0.82rem;
}

.placeholder {
  grid-column: 1 / -1;
  margin: 0;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.92rem;
  background: var(--surface-2);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r-lg);
}

/* La carte conserve un placeholder simple (sans encadré) */
.card .placeholder {
  padding: 1.5rem 0.5rem;
  background: none;
  border: none;
}

/* ============================================================
   Tableaux de fréquences
   ============================================================ */
.table-scroll {
  max-height: 360px;
  overflow-y: auto;
  overflow-x: auto;
  margin-top: 0.25rem;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background-color: var(--surface);
}

.table-scroll table {
  margin: 0;
}

/* Vue comparaison avant/apres (meme intitule en ligne et en colonne) :
   contenu plus riche qu'un simple tableau, pas de limite de hauteur. */
.table-scroll.table-scroll--comparison {
  max-height: none;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.frequency-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.frequency-table td {
  padding: 0.45rem 0.65rem;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.frequency-table tbody tr:last-child td {
  border-bottom: none;
}

.frequency-table tbody tr:hover {
  background-color: var(--accent-softer);
}

.frequency-table td:first-child {
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--ink);
}

.frequency-table td:last-child {
  text-align: right;
  color: var(--ink-soft);
}

/* ============================================================
   Graphiques & légendes
   ============================================================ */
.chart-wrapper {
  position: relative;
  width: 100%;
  min-height: 300px;
}

.chart-legend-grid {
  list-style: none;
  margin: 0.9rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  font-size: 0.83rem;
}

.chart-legend-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.6rem;
}

.chart-legend-color {
  width: 11px;
  height: 11px;
  border-radius: var(--r-xs);
  background-color: var(--legend-color, var(--accent));
  box-shadow: 0 0 0 1px rgba(17, 26, 20, 0.08);
}

.chart-legend-text {
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-legend-value {
  color: var(--ink);
  font-weight: 600;
}

/* ============================================================
   Statistiques numériques
   ============================================================ */
.stats-section {
  display: grid;
  gap: 0.8rem;
}

.metric-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.metric-chip {
  background-color: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: var(--r-sm);
  padding: 0.3rem 0.7rem;
  font-size: 0.76rem;
  font-weight: 600;
}

.stats-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--ink-muted);
  font-size: 0.86rem;
  display: grid;
  gap: 0.25rem;
}

.stats-list li strong {
  font-family: var(--font-mono);
  color: var(--ink);
}

.top10-note {
  margin: 0;
  color: var(--ink-faint);
  font-size: 0.78rem;
}

/* ============================================================
   Puces (chips)
   ============================================================ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.32rem 0.7rem;
  background-color: var(--surface-3);
  color: var(--ink-soft);
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  font-weight: 600;
}

/* ============================================================
   Bandeau de résumé
   ============================================================ */
.summary-banner {
  background: var(--accent-soft);
  border: 1px solid var(--accent-ring);
  border-radius: var(--r-lg);
  padding: 1rem 1.25rem;
  margin: 0 0 1.25rem;
  color: var(--accent-strong);
  font-weight: 500;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ============================================================
   Mise en page : Addition / 3 tables / évolution
   ============================================================ */
.addition-layout,
.three-tables-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 1.5rem;
  align-items: start;
}

.addition-controls,
.three-tables-controls {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 1.5rem;
}

.addition-controls h2,
.three-tables-controls h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
}

.addition-note,
.three-tables-note {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.addition-results,
.three-tables-results {
  display: grid;
  gap: 1.25rem;
}

/* Champs de contrôle */
.control-field {
  display: grid;
  gap: 0.4rem;
}

.control-label {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.9rem;
}

.control-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.control-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.control-select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  font: inherit;
  font-size: 0.9rem;
  color: var(--ink);
  background-color: var(--surface);
  outline: none;
  color-scheme: light;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Force la liste deroulante native en clair (sinon certains navigateurs
   affichent le popup en sombre si le systeme est en mode sombre). */
.control-select option {
  background-color: var(--surface);
  color: var(--ink);
}

.control-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Menu deroulant personnalise : remplace le rendu du <select> (Safari
   ignore le style des options natives et affiche un popup systeme sombre). */
.custom-select {
  position: relative;
}

.custom-select__native {
  display: none;
}

.custom-select__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  color: var(--ink);
  background-color: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.custom-select__trigger::after {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border-right: 1.5px solid var(--ink-muted);
  border-bottom: 1.5px solid var(--ink-muted);
  transform: rotate(45deg);
}

.custom-select__trigger:hover {
  border-color: var(--ink-faint);
}

.custom-select__trigger:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.custom-select__panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.35rem 0;
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}

.custom-select__option {
  border: none;
  background: none;
  text-align: left;
  margin: 0 0.35rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--r-sm);
  font: inherit;
  font-size: 0.84rem;
  line-height: 1.35;
  color: var(--ink);
  white-space: normal;
  cursor: pointer;
}

.custom-select__option:hover,
.custom-select__option:focus-visible {
  outline: none;
  background-color: var(--accent-soft);
}

.custom-select__option.is-selected {
  color: var(--accent-strong);
  font-weight: 600;
}

/* En-tete de section (reprend les blocs colores du fichier Excel source :
   Informations generales / Origine / 6 mois / Long terme...). Reste visible
   en haut du panneau pendant le defilement (comme les listes de contacts). */
.custom-select__group {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0.35rem 0 0.15rem;
  padding: 0.4rem 0.75rem 0.3rem;
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent-strong);
}

.custom-select__group:first-child {
  margin-top: 0;
  border-top: none;
}

.control-multiselect {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.control-checkbox-list {
  display: grid;
  gap: 0.4rem;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.35rem;
}

.control-checkbox {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.45rem 0.6rem;
  font-size: 0.88rem;
}

.control-checkbox input {
  accent-color: var(--accent);
}

/* Groupes de filtres (addition) */
.addition-filters {
  display: grid;
  gap: 0.85rem;
}

.filters-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.filter-groups {
  display: grid;
  gap: 1rem;
}

.filter-group {
  background-color: var(--surface-2);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
}

.filter-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.filter-step-title {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.92rem;
}

.filter-values {
  display: grid;
  gap: 0.6rem;
}

.filter-summary-list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.3rem;
  font-size: 0.88rem;
  color: var(--ink-muted);
}

.filter-summary-list strong {
  color: var(--ink);
}

/* ============================================================
   Cartes addition / tables détaillées
   ============================================================ */
.addition-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 1.4rem;
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 0.85rem;
}

.addition-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
}

.addition-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.addition-summary .chip {
  background-color: var(--accent-soft);
  color: var(--accent-strong);
}

.addition-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.addition-table thead {
  background-color: var(--surface-3);
}

.addition-table th,
.addition-table td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.addition-table th {
  font-weight: 600;
  color: var(--ink-soft);
}

.addition-table td:last-child,
.addition-table th:last-child {
  text-align: right;
}

.addition-table tbody tr:last-child td {
  border-bottom: none;
}

.addition-table tbody tr:hover {
  background-color: var(--accent-softer);
}

.numeric-cell {
  text-align: right;
}

/* 3 tables */
.three-tables-card h4 {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--ink);
}

.three-tables-meta {
  margin: 0.35rem 0 1rem;
  color: var(--ink-muted);
  font-size: 0.84rem;
}

.three-tables-divider {
  margin: 1.5rem 0;
  border: none;
  border-top: 1px solid var(--border);
}

.three-tables-stats thead,
.three-tables-evolution thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* ============================================================
   Filtre par année
   ============================================================ */
.year-filter-panel {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.1rem;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
}

.year-filter-label {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.9rem;
}

.year-filter-select {
  min-width: 220px;
  padding: 0.55rem 0.7rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
}

.year-filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.metier-filter-panel {
  margin-bottom: 0;
}

/* ============================================================
   Parcours & évaluation
   ============================================================ */
#parcours-evaluation-container {
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.parcours-evaluation-card {
  gap: 0.9rem;
  padding: 1.5rem 1.6rem;
}

.parcours-section-title {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-strong);
}

.parcours-evaluation-card .table-scroll {
  overflow-x: auto;
}

.parcours-evaluation-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 560px;
}

.parcours-evaluation-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background-color: var(--surface-3);
}

.parcours-evaluation-table th,
.parcours-evaluation-table td {
  padding: 0.6rem 0.8rem;
  text-align: left;
  vertical-align: top;
  line-height: 1.4;
  border-bottom: 1px solid var(--border);
}

.parcours-evaluation-table th {
  font-weight: 600;
  color: var(--ink-soft);
}

.parcours-evaluation-table tbody tr:last-child td {
  border-bottom: none;
}

.parcours-evaluation-table tbody tr:hover {
  background-color: var(--accent-softer);
}

.parcours-chart-wrapper {
  min-height: 220px;
}

.parcours-legend-grid {
  margin-top: 0.4rem;
  grid-template-columns: 1fr;
  font-size: 0.8rem;
}

/* ============================================================
   Vue Insertion
   ============================================================ */
.insertion-kpi {
  margin-bottom: 1.2rem;
}

.insertion-kpi .chip.kpi-strong {
  background: var(--gold);
  color: #fff;
  font-weight: 700;
}

.insertion-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.4rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.85rem;
}

.insertion-subtab {
  cursor: pointer;
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--ink-muted);
  border-radius: var(--r-md);
  padding: 0.45rem 1.05rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.insertion-subtab:hover {
  background-color: var(--surface-3);
  color: var(--ink);
}

.insertion-subtab.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

/* Bandeau de section coloré (reprend les couleurs de l'Excel) */
.insertion-section-band {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0.4rem 0 0.2rem;
  padding: 0.7rem 1.1rem;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--section-soft, var(--surface-3));
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
}

.insertion-section-band::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: var(--r-xs);
  background: var(--section-color, var(--accent));
  flex: 0 0 auto;
}

.insertion-section-band small {
  font-family: var(--font-body);
  font-weight: 500;
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.card.insertion-card {
  border-top: 3px solid var(--section-color, var(--accent));
}

.insertion-card .insertion-col-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* Note de comparaison */
.insertion-compare-note {
  margin: 0 0 1.2rem;
  padding: 0.85rem 1.1rem;
  border-radius: var(--r-md);
  background: var(--accent-softer);
  border: 1px solid var(--border);
  line-height: 1.55;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

/* Tableau de comparaison des vagues */
.insertion-compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.insertion-compare-table th,
.insertion-compare-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
  text-align: center;
}

.insertion-compare-table th:first-child,
.insertion-compare-table td:first-child {
  text-align: left;
  font-weight: 600;
}

.insertion-compare-table thead th {
  background: var(--surface-3);
  font-weight: 700;
  color: var(--ink-soft);
}

.insertion-compare-table .wave-old {
  background: var(--surface-2);
}

.insertion-compare-table .wave-recent {
  background: var(--accent-softer);
}

.insertion-compare-table .delta-up {
  color: var(--accent);
  font-weight: 700;
}

.insertion-compare-table .delta-down {
  color: var(--danger);
  font-weight: 700;
}

.insertion-compare-table .delta-flat {
  color: var(--ink-muted);
}

.insertion-wave-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0.4rem 0 1rem;
  font-size: 0.84rem;
  color: var(--ink-muted);
}

.insertion-wave-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.insertion-compare-pairs {
  margin: 0.2rem 0 0.6rem;
  padding: 0.55rem 0.9rem;
  border-radius: var(--r-sm);
  background: var(--accent-softer);
  border-left: 3px solid var(--accent);
  font-size: 0.9rem;
  color: var(--ink-soft);
}

#insertion-compare-container {
  grid-template-columns: 1fr;
}

.insertion-compare-card {
  gap: 1.1rem;
}

.insertion-waves-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.insertion-wave-col {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0.9rem 1rem 1rem;
  background: var(--surface-2);
  border-top: 3px solid var(--ink-faint);
}

.insertion-wave-col.is-baseline {
  border-top-color: var(--ink-faint);
}

.insertion-wave-col.is-recent {
  border-top-color: var(--accent);
}

.insertion-wave-col-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent-strong);
}

.insertion-wave-col-head small {
  display: block;
  margin: 0.15rem 0 0.7rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.insertion-evolution-block {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 0.3rem;
}

.insertion-evolution-title {
  margin: 0 0 0.7rem;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-strong);
}

.insertion-retention-block {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0 0 0.9rem;
}

.insertion-retention-row {
  padding: 0.6rem 0 0;
  border-top: 1px solid var(--border);
}

.insertion-retention-row:first-child {
  border-top: none;
  padding-top: 0;
}

.insertion-retention-summary {
  margin: 0 0 0.4rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.insertion-retention-summary small {
  color: var(--ink-muted);
}

.insertion-transition-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.insertion-transition-list li {
  white-space: nowrap;
}

.insertion-transition-count {
  color: var(--ink-faint);
}

.insertion-transition-more {
  font-style: italic;
}

/* ============================================================
   Pied de page
   ============================================================ */
.app-footer {
  padding: 1.5rem clamp(1rem, 6vw, 4rem);
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--ink-muted);
  font-size: 0.82rem;
  text-align: center;
}

.app-footer strong {
  font-family: var(--font-display);
  color: var(--ink-soft);
  font-weight: 600;
}

/* ============================================================
   Overlay de progression d'export
   ============================================================ */
.export-progress-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 26, 20, 0.45);
  backdrop-filter: blur(2px);
}

.export-progress-card {
  width: min(92vw, 420px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-lg);
}

.export-progress-label {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.export-progress-track {
  width: 100%;
  height: 9px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  overflow: hidden;
}

.export-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.2s ease;
}

.export-progress-value {
  margin: 0.6rem 0 0;
  text-align: right;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--accent-strong);
}

/* ============================================================
   Export PDF (capture)
   ============================================================ */
.pdf-capture-root {
  background: #ffffff;
}

.pdf-capture-root .table-scroll {
  max-height: none;
  overflow: visible;
  border: 1px solid var(--border);
  background-color: #fff;
}

.pdf-capture-root .card {
  box-shadow: none;
  border: 1px solid var(--border);
}

.pdf-capture-root .parcours-evaluation-card {
  padding: 1.1rem;
  gap: 0.6rem;
}

.pdf-capture-root .parcours-evaluation-table {
  font-size: 0.8rem;
}

.pdf-capture-root .parcours-chart-wrapper {
  min-height: 180px;
}

.pdf-capture-root .three-tables-stats thead,
.pdf-capture-root .three-tables-evolution thead,
.pdf-capture-root .parcours-evaluation-table thead {
  position: static;
  top: auto;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 980px) {
  .cards-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }

  .addition-layout,
  .three-tables-layout {
    grid-template-columns: 1fr;
  }

  .addition-controls,
  .three-tables-controls {
    position: static;
  }
}

@media (max-width: 640px) {
  .tab-button {
    flex: 1 1 130px;
  }

  .panel {
    padding: 1.25rem;
  }

  .card {
    padding: 1.1rem;
  }

  .chart-wrapper {
    min-height: 260px;
  }

  .brand__text h1 {
    font-size: 1.2rem;
  }

  .header-status {
    display: none;
  }

  .dropzone {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ============================================================
   Finitions : accessibilité, scrollbars, pastille du résumé
   ============================================================ */

/* Pastille devant le bandeau de résumé */
.summary-banner::before {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: var(--r-pill);
  background: var(--accent);
}

.summary-banner.hidden::before {
  display: none;
}

/* Focus clavier visible et cohérent */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
label.file-input:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Scrollbars discrètes (zones défilantes) */
.table-scroll,
.filter-list,
.control-checkbox-list {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.table-scroll::-webkit-scrollbar,
.filter-list::-webkit-scrollbar,
.control-checkbox-list::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.table-scroll::-webkit-scrollbar-thumb,
.filter-list::-webkit-scrollbar-thumb,
.control-checkbox-list::-webkit-scrollbar-thumb {
  background-color: var(--border-strong);
  border-radius: var(--r-pill);
  border: 3px solid var(--surface);
}

.table-scroll::-webkit-scrollbar-thumb:hover,
.filter-list::-webkit-scrollbar-thumb:hover,
.control-checkbox-list::-webkit-scrollbar-thumb:hover {
  background-color: var(--ink-faint);
}

/* Sélections de texte teintées */
::selection {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* ============================================================
   Curseur : nombre de valeurs affichées par colonne
   ============================================================ */
.display-limit {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-right: auto;
  padding: 0.5rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
  font-size: 0.86rem;
}

.display-limit__label {
  font-weight: 600;
  color: var(--ink-soft);
}

.display-limit__range {
  -webkit-appearance: none;
  appearance: none;
  width: 150px;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  outline: none;
  cursor: pointer;
}

.display-limit__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: var(--r-xs);
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.12s ease;
}

.display-limit__range::-webkit-slider-thumb:hover {
  transform: scale(1.12);
  background: var(--accent-strong);
}

.display-limit__range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: var(--r-xs);
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.display-limit__range::-moz-range-track {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
}

.display-limit__range:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.display-limit__value {
  min-width: 2.6rem;
  text-align: center;
  font-weight: 700;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-radius: var(--r-sm);
  padding: 0.2rem 0.55rem;
}

.display-limit__all {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  color: var(--ink-soft);
  font-weight: 500;
  padding-left: 0.5rem;
  border-left: 1px solid var(--border);
}

.display-limit__all input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

@media (max-width: 640px) {
  .display-limit {
    width: 100%;
    margin-right: 0;
  }

  .display-limit__range {
    flex: 1;
    width: auto;
  }
}

/* ============================================================
   Vue Croisements & synthèse
   ============================================================ */
.synthese-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.synthese-block__head {
  margin-bottom: 1.1rem;
}

.synthese-block__head--collapsible {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.synthese-block__toggle {
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 0.45rem 0.9rem;
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.synthese-block__toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.synthese-block__toggle[aria-expanded="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.synthese-block__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.synthese-block__sub {
  margin: 0.25rem 0 0;
  font-size: 0.88rem;
  color: var(--ink-muted);
  line-height: 1.5;
}

/* Tuiles KPI */
.synthese-kpi {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.kpi-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1.1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.kpi-tile::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}

.kpi-tile__value {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--accent-strong);
  line-height: 1.2;
}

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

.kpi-tile__sub {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

/* Classements : un seul classement affiche a la fois, choisi par onglets */
.synthese-rankings {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.ranking-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ranking-card {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.ranking-card__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-strong);
}

.ranking-list {
  display: grid;
  gap: 0.55rem;
}

.ranking-row {
  display: grid;
  grid-template-columns: minmax(90px, 32%) 1fr auto;
  align-items: center;
  gap: 0.7rem;
}

.ranking-row__label {
  font-size: 0.84rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-row__track {
  height: 10px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  overflow: hidden;
}

.ranking-row__bar {
  height: 100%;
  border-radius: var(--r-xs);
  min-width: 4px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.ranking-row__value {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}

/* Contrôles du tableau croisé */
.synthese-cross-controls {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 1rem;
}

.synthese-cross-note {
  margin: 0 0 0.85rem;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.synthese-cross-chart {
  min-height: 360px;
  margin-top: 1.25rem;
}

/* Tableau croisé (heatmap) */
.cross-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.cross-table th,
.cross-table td {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}

.cross-table thead th {
  background: var(--surface-3);
  font-weight: 600;
  color: var(--ink-soft);
  position: sticky;
  top: 0;
  z-index: 1;
}

.cross-table tbody th {
  text-align: left;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-2);
  position: sticky;
  left: 0;
  z-index: 1;
}

.cross-table__corner {
  text-align: left;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.cross-table__cell {
  color: var(--ink);
}

.cross-table__total-head,
.cross-table__total,
.cross-table__total-row td,
.cross-table__total-row th {
  background: var(--accent-soft);
  font-weight: 700;
  color: var(--accent-strong);
}

.cross-table__grand {
  background: var(--accent);
  color: #fff;
}

/* Statistiques inférentielles (Khi-² / Cramér) */
.cross-stats {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0 0 1rem;
}

.cross-stats__verdict {
  align-self: flex-start;
  padding: 0.5rem 0.9rem;
  border-radius: var(--r-md);
  font-size: 0.9rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-3);
  color: var(--ink-soft);
}

.cross-stats__verdict.up {
  background: var(--accent-soft);
  border-color: var(--accent-ring);
  color: var(--accent-strong);
}

.cross-stats__verdict.flat {
  background: var(--surface-3);
  color: var(--ink-muted);
}

.cross-stats__note {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-muted);
}

/* Comparaison de cohortes : deltas colorés */
.cohort-table .delta-up {
  color: var(--accent);
  font-weight: 700;
}

.cohort-table .delta-down {
  color: var(--danger);
  font-weight: 700;
}

.cohort-table .delta-flat {
  color: var(--ink-muted);
}

/* Bloc durée : deux graphes côte à côte */
.synthese-duo-charts {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  margin-top: 1.1rem;
}

.synthese-duo-chart {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.synthese-duo-chart .chart-wrapper {
  min-height: 280px;
}

/* Respect des préférences de mouvement réduit */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
