/* =============================================================================
   MEDIABAR v2 — DESIGN SYSTEM
   -----------------------------------------------------------------------------
   UN seul stylesheet, 0 build (pas de Tailwind, pas de node), servi tel quel
   depuis public/. Organisé en sections : TOKENS en tête, puis un bloc par
   composant (delimite par des commentaires "=== Nom ==="). Toucher un composant ne casse pas
   les autres ; tout descend des tokens (cf specs/35-design-system.md).

   RÈGLE D'OR : la marque (orange/logo/typo) != le statut (ok/warn/crit/unknown).
   Ne JAMAIS peindre un état fonctionnel en orange de marque.
   ============================================================================= */

/* ================================ TOKENS =================================== */
:root {
  /* -- Marque (identité — jamais utilisée pour du statut) -- */
  --brand: #FF750F;
  --brand-hover: #e0670a;
  --brand-active: #c95905;
  --brand-ink: #1B1B18;
  --brand-contrast: #ffffff;

  /* -- Neutres -- */
  --gray-900: #1B1B18;
  --gray-700: #3E3E3A;
  --gray-500: #77776d;
  --gray-300: #c7c7bd;
  --gray-200: #e3e3e0;
  --gray-100: #f4f4f2;
  --white: #ffffff;

  /* -- Sémantique statut (SÉPARÉE de la marque) -- */
  --ok: #1a9c5b;
  --ok-bg: #e6f5ee;
  --warn: #c98a1a;
  --warn-bg: #faf1de;
  --crit: #c9372c;
  --crit-bg: #fbe9e8;
  --unknown: #8b8b86;
  --unknown-bg: #eeeeec;

  /* -- Surfaces (thème clair = défaut) -- */
  --bg: var(--gray-100);
  --surface: var(--white);
  --surface-2: var(--gray-100);
  --surface-raised: var(--white);
  --border: var(--gray-200);
  --fg: var(--gray-900);
  --fg-muted: var(--gray-700);
  --fg-subtle: var(--gray-500);
  --focus-ring: 0 0 0 3px rgba(255, 117, 15, .35);
  --overlay: rgba(27, 27, 24, .48);

  /* -- Typo -- */
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --text-xs: .75rem;
  --text-sm: .8125rem;
  --text-md: .9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --leading-tight: 1.2;
  --leading-normal: 1.5;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* -- Forme -- */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(27, 27, 24, .08), 0 1px 1px rgba(27, 27, 24, .04);
  --shadow-md: 0 6px 16px rgba(27, 27, 24, .12), 0 2px 4px rgba(27, 27, 24, .06);

  /* -- Espacement (échelle 4px) -- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* -- Mouvement -- */
  --motion-fast: 120ms;
  --motion-base: 200ms;
  --motion-slow: 320ms;
  --ease: cubic-bezier(.4, 0, .2, 1);

  /* -- Dimensions du shell -- */
  --header-h: 60px;
  --nav-h: 44px;
  --toolbar-h: 48px;
  --footer-h: 40px;
  --dock-width: 340px;
}

[data-theme="dark"] {
  --bg: #131311;
  --surface: #1e1e1a;
  --surface-2: #232320;
  --surface-raised: #26261f;
  --border: #38382f;
  --fg: #f4f4f2;
  --fg-muted: #c9c9bf;
  --fg-subtle: #96968b;
  --overlay: rgba(0, 0, 0, .6);
  --brand-hover: #ff8c33;
  --brand-active: #ffa658;
  --ok-bg: rgba(26, 156, 91, .18);
  --warn-bg: rgba(201, 138, 26, .18);
  --crit-bg: rgba(201, 55, 44, .2);
  --unknown-bg: rgba(139, 139, 134, .18);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 10px 24px rgba(0, 0, 0, .5);
}

/* =============================== RESET / BASE =============================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }  /* le shell gère le scroll par zone -> pas de scroll page (fini le « 500km ») */

/* Scrollbars theme-aware (suivent le dark, cf recette) */
* { scrollbar-width: thin; scrollbar-color: var(--gray-300) transparent; }
[data-theme="dark"] * { scrollbar-color: var(--gray-700) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--radius-pill); border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--gray-700); }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--text-md);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
a:hover { color: var(--brand-hover); }
h1, h2, h3, h4 { font-weight: var(--weight-semibold); line-height: var(--leading-tight); margin: 0 0 var(--space-2); color: var(--fg); }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
[x-cloak] { display: none !important; }

.tt-wrap { display: inline-block; }

/* =============================== APP SHELL =================================== */
/* height:100vh + overflow:auto LOCAL par zone -> header/toolbar/footer figés,
   seul .app-main scrolle (jamais de position:fixed, cf 35-design-system §4). */
.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: var(--header-h) var(--nav-h) var(--toolbar-h) 1fr var(--footer-h);
  grid-template-columns: minmax(0, 1fr); /* borne la colonne au viewport : sans ça, la colonne auto se dimensionne au contenu large (barre KPI) et fait deborder tout le shell hors ecran (Mon activite inatteignable, chart coupe) — catch recette navigateur */
  overflow: hidden;
  background: var(--bg);
}

.app-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-header__logo { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.app-header__logo img { height: 26px; display: block; }
.app-header__logo .logo--dark { display: none; }
[data-theme="dark"] .app-header__logo .logo--light { display: none; }
[data-theme="dark"] .app-header__logo .logo--dark { display: block; }
.app-header__search { flex: 1 1 auto; min-width: 120px; max-width: 440px; }
/* audit #31/#41 : l'entonnoir + les répartitions (12 tuiles) ne tiennent plus
   sur une ligne à largeur fixe -> flex-shrink:1 + overflow-x:auto pour que la
   bande défile SUR PLACE (jamais de scroll parasite sur .app-main, jamais de
   croissance du header figé, cf .app-shell "header/toolbar/footer figés"). */
.app-header__kpis { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 1; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.app-header__kpis-sep { width: 1px; align-self: stretch; margin: var(--space-2) 0; background: var(--border); flex-shrink: 0; }
.app-header__spacer { flex: 1 1 auto; }
.app-header__actions { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }

.app-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  white-space: nowrap;
}
.app-toolbar__label { font-size: var(--text-xs); color: var(--fg-subtle); text-transform: uppercase; letter-spacing: .04em; margin-right: var(--space-1); flex-shrink: 0; }
.app-toolbar__group { display: flex; align-items: center; gap: var(--space-1); min-width: 0; }
.app-toolbar__sep { width: 1px; align-self: stretch; margin: var(--space-2) 0; background: var(--border); flex-shrink: 0; }
.app-toolbar__spacer { flex: 1 1 auto; }
.app-toolbar__cmd {
  font-size: var(--text-xs); font-family: ui-monospace, monospace;
  color: var(--fg-muted); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 2px 6px;
  min-width: 0; max-width: min(46ch, 40vw); flex: 0 1 auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.app-footer__legend { display: flex; align-items: center; gap: var(--space-2); }
.app-footer__legend .chip { font-size: .68rem; }

.app-main-row {
  display: flex;
  min-height: 0;
  overflow: hidden;
}
.app-main {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: hidden;   /* jamais de scroll horizontal parasite ; le contenu large scrolle dans SON conteneur (DataTable) */
  overflow-y: auto;
  padding: var(--space-6);
}
.app-dock {
  flex: 0 0 auto;
  width: 0;
  overflow: hidden;
  background: var(--surface);
  border-left: 1px solid transparent;
  transition: width var(--motion-base) var(--ease), border-color var(--motion-base) var(--ease);
}
.app-dock.is-open {
  width: min(var(--dock-width), 92vw);
  overflow-y: auto;
  border-left-color: var(--border);
}
.app-dock__inner { padding: var(--space-4); width: var(--dock-width); max-width: 92vw; }

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0 var(--space-4);
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  color: var(--fg-subtle);
}

@media (max-width: 900px) {
  .app-header__kpis { display: none; }
  .app-toolbar__label { display: none; }
  .app-dock.is-open {
    position: fixed;
    inset: var(--header-h) 0 0 0;
    width: auto;
    z-index: 40;
    box-shadow: var(--shadow-md);
  }
  .app-dock__inner { width: auto; max-width: none; }
}

/* ================================= Button ==================================== */
/* variants: primary (brand) / ghost / icon / toggle (on-off) / danger. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  height: 32px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease);
}
.btn:hover { border-color: var(--fg-subtle); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

.btn--sm { height: 26px; padding: 0 var(--space-2); font-size: var(--text-xs); }

.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }
.btn--primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn--primary:active { background: var(--brand-active); border-color: var(--brand-active); }

.btn--ghost { background: transparent; border-color: transparent; color: var(--fg-muted); }
.btn--ghost:hover { background: var(--surface-2); color: var(--fg); }

.btn--icon { width: 32px; height: 32px; padding: 0; background: transparent; border-color: transparent; color: var(--fg-muted); border-radius: var(--radius-md); }
.btn--icon:hover { background: var(--surface-2); color: var(--fg); }

.btn--toggle { background: var(--surface); color: var(--fg-muted); }
.btn--toggle.is-on { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }

.btn--danger { background: transparent; border-color: var(--crit); color: var(--crit); }
.btn--danger:hover { background: var(--crit-bg); }
.btn--danger.btn--primary { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn--danger.btn--primary:hover { background: #a92c23; border-color: #a92c23; }

.btn__kbd { font-size: .68rem; opacity: .7; border: 1px solid currentColor; border-radius: var(--radius-sm); padding: 0 3px; margin-left: 2px; }

/* ================================ StatusChip ================================= */
/* LE composant central. severity: good/warn/crit/unknown ; variant verdict ;
   count?/age? optionnels. Encode l'état en FORME + COULEUR (accessibilité). */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  border: 1px solid transparent;
  line-height: 1.4;
  cursor: default;
}
.chip--good { color: var(--ok); background: var(--ok-bg); border-color: rgba(26,156,91,.35); }
.chip--warn { color: var(--warn); background: var(--warn-bg); border-color: rgba(201,138,26,.35); }
.chip--crit { color: var(--crit); background: var(--crit-bg); border-color: rgba(201,55,44,.35); }
.chip--unknown { color: var(--unknown); background: var(--unknown-bg); border-color: rgba(139,139,134,.3); border-style: dashed; }

.chip__shape { font-size: .85em; line-height: 1; }
.chip__count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: var(--radius-pill); background: currentColor;
  font-size: .65rem; font-weight: var(--weight-bold);
}
.chip__count span { color: var(--surface); }

/* variant verdict : diagnostic plus verbeux (utilisé pour dépôt-mort / écran-noir / etc) */
.chip--verdict { padding: 3px var(--space-3); font-weight: var(--weight-semibold); border-radius: var(--radius-sm); }

/* =============================== SourceBadge ================================= */
/* Provenance d'une valeur (C1). Distinct de StatusChip : sémantique = provenance, pas santé. */
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: .66rem;
  font-weight: var(--weight-medium);
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--fg-subtle);
  margin-left: var(--space-1);
  text-transform: lowercase;
  letter-spacing: .01em;
  vertical-align: middle;
}
.source-badge--box { color: var(--brand); border-color: rgba(255,117,15,.35); background: rgba(255,117,15,.08); }
.source-badge--confirmed { color: var(--ok); border-color: rgba(26,156,91,.3); background: var(--ok-bg); }
.source-badge--approx, .source-badge--alias, .source-badge--fuzzy { color: var(--warn); border-color: rgba(201,138,26,.3); background: var(--warn-bg); border-style: dashed; }
.source-badge--csv { color: var(--fg-subtle); }
.source-badge__check { color: var(--ok); font-weight: var(--weight-bold); }

/* =============================== FreshnessTag ================================= */
/* "vu il y a X · prochain refresh Y · [rafraîchir]" — C2, réutilisé partout. */
.freshness-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--fg-subtle);
}
.freshness-tag__refresh {
  border: none; background: transparent; cursor: pointer; color: var(--brand);
  font-size: .95rem; line-height: 1; padding: 2px; border-radius: var(--radius-sm);
  transition: transform var(--motion-fast) var(--ease);
}
.freshness-tag__refresh:hover { background: var(--surface-2); transform: rotate(45deg); }

/* ================================ Input / Select ============================== */
.field { display: inline-flex; flex-direction: column; gap: 2px; }
.field__label { font-size: var(--text-xs); color: var(--fg-muted); font-weight: var(--weight-medium); }
.input, .select {
  height: 32px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  font-size: var(--text-sm);
  width: 100%;
}
.input::placeholder { color: var(--fg-subtle); }
.input:focus, .select:focus { border-color: var(--brand); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--fg-subtle) 50%), linear-gradient(135deg, var(--fg-subtle) 50%, transparent 50%); background-position: calc(100% - 16px) center, calc(100% - 11px) center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: var(--space-6); }
.input--sm, .select--sm { height: 26px; font-size: var(--text-xs); padding: 0 var(--space-2); }

/* ================================ PlayerName ================================== */
.player-name { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 2px; font-weight: var(--weight-medium); color: var(--fg); }
.player-name__bar { cursor: copy; }
.player-name__bar:hover { text-decoration: underline dotted; }
.player-name__tvid-copy {
  border: none; background: transparent; cursor: pointer; color: var(--fg-subtle);
  font-size: .78rem; padding: 0 2px; border-radius: var(--radius-sm);
}
.player-name__tvid-copy:hover { color: var(--brand); background: var(--surface-2); }
.player-name__tw-link { font-size: .78rem; color: var(--fg-subtle); }
.player-name__tw-link:hover { color: var(--brand); }
.player-name__reconcile { color: var(--ok); font-weight: var(--weight-bold); font-size: .75rem; margin-left: 1px; }

/* ================================ LogIndicator ================================= */
/* 3 états : vide (ligne de base) / contenu (normal) / frais (vient d'écrire = à consulter). */
.log-indicator {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; cursor: pointer;
  color: var(--fg-subtle); font-size: 1rem; position: relative;
}
.log-indicator:hover { background: var(--surface-2); }
.log-indicator--empty { opacity: .35; cursor: default; }
.log-indicator--content { color: var(--fg-muted); }
.log-indicator--fresh { color: var(--brand); }
.log-indicator--fresh::after {
  content: ''; position: absolute; top: 3px; right: 3px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--brand);
  box-shadow: 0 0 0 2px var(--surface);
  animation: log-pulse 1.6s var(--ease) infinite;
}
@keyframes log-pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* ================================== KpiTile ==================================== */
.kpi-tile {
  display: flex; align-items: baseline; gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--fg-muted);
  font-size: var(--text-sm);
}
.kpi-tile:hover { background: var(--surface-2); border-color: var(--border); }
.kpi-tile__value { font-size: var(--text-lg); font-weight: var(--weight-bold); color: var(--fg); font-variant-numeric: tabular-nums; }
.kpi-tile--good .kpi-tile__value { color: var(--ok); }
.kpi-tile--warn .kpi-tile__value { color: var(--warn); }
.kpi-tile--crit .kpi-tile__value { color: var(--crit); }
.kpi-tile__label { white-space: nowrap; }
.kpi-tile--card { flex-direction: column; align-items: flex-start; gap: 2px; padding: var(--space-4); background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm); }
.kpi-tile--card .kpi-tile__value { font-size: var(--text-2xl); }

/* =================================== Toolbar ==================================== */
/* Molécule filtres/tri/densité (distincte de la barre-outils du shell). */
.toolbar {
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
  padding: var(--space-2) 0; margin-bottom: var(--space-2);
}
.toolbar__group { display: flex; align-items: center; gap: var(--space-1); }
.toolbar__spacer { flex: 1 1 auto; }
.toolbar__count { font-size: var(--text-xs); color: var(--fg-subtle); white-space: nowrap; }

/* ==================================== Toast ====================================== */
.toast-host {
  position: fixed; right: var(--space-4); bottom: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-2);
  z-index: 100; width: min(340px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-3); border-radius: var(--radius-md);
  background: var(--surface-raised); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); font-size: var(--text-sm);
}
.toast--ok { border-left: 3px solid var(--ok); }
.toast--warn { border-left: 3px solid var(--warn); }
.toast--crit { border-left: 3px solid var(--crit); }
.toast__icon { font-size: 1rem; line-height: 1.3; }
.toast__body { flex: 1 1 auto; }
.toast__close { border: none; background: transparent; cursor: pointer; color: var(--fg-subtle); }

/* =================================== PlayerRow =================================== */
/* [réseau] [PlayerName] [chips] [version] [log] [actions] — identique partout. */
.player-row {
  display: grid;
  grid-template-columns: 68px minmax(96px, 1.2fr) minmax(150px, 1.9fr) minmax(108px, .7fr) 28px auto;
  gap: var(--space-2);
  align-items: center;
  padding: var(--space-2) var(--space-2);
  border-bottom: 1px solid var(--border);
}
.player-row:hover { background: var(--surface-2); }
.player-row__reseau { font-size: var(--text-xs); color: var(--fg-subtle); white-space: nowrap; }
.player-row__chips { display: flex; gap: var(--space-1); flex-wrap: wrap; }
/* Axe de contrôle : version installée (texte discret) + pastille comparison() + âge court. */
.player-row__version { display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; }
.player-row__version-installed { font-size: var(--text-xs); color: var(--fg-muted); white-space: nowrap; }
.player-row__version-age { font-size: var(--text-xs); color: var(--fg-subtle); white-space: nowrap; }
.player-row__actions { display: flex; gap: var(--space-1); align-items: center; }
.player-row__actions-sep { width: 1px; height: 18px; background: var(--border); margin: 0 2px; }
.player-row__watch { border-radius: var(--radius-pill); color: var(--fg-muted); }
.player-row__watch-icon::before { content: "☆"; }
.player-row__watch:hover, .player-row__watch:focus-visible {
  color: var(--brand); background: var(--surface-2); transform: scale(1.12);
}
.player-row__watch:hover .player-row__watch-icon::before,
.player-row__watch:focus-visible .player-row__watch-icon::before { content: "★"; }

/* densité compacte (togglable) — variante statique .player-row--compact (démo styleguide)
   ET variante interactive via ancêtre .is-compact (toggle Toolbar sur le dashboard réel) */
.player-row--compact,
.is-compact .player-row {
  grid-template-columns: 68px minmax(120px, 1.2fr) minmax(180px, 2fr) minmax(92px, .6fr) 24px auto;
  gap: var(--space-2);
  padding: 3px var(--space-2);
  font-size: var(--text-xs);
}
.player-row--compact .log-indicator,
.is-compact .player-row .log-indicator { width: 20px; height: 20px; font-size: .82rem; }

@media (max-width: 700px) {
  .player-row { grid-template-columns: 1fr; row-gap: var(--space-1); }
}

/* =================================== DataTable ==================================== */
.data-table-wrap { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; background: var(--surface); }
.data-table-wrap__scroll { overflow: auto; max-height: 60vh; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.data-table th {
  position: sticky; top: 0; background: var(--surface-2); text-align: left;
  padding: var(--space-2) var(--space-3); font-size: var(--text-xs);
  color: var(--fg-muted); font-weight: var(--weight-semibold);
  border-bottom: 1px solid var(--border); white-space: nowrap; z-index: 1;
}
.data-table th[data-sortable] { cursor: pointer; user-select: none; }
.data-table th[data-sortable]:hover { color: var(--fg); }
.data-table th .sort-arrow { display: inline-block; margin-left: 3px; opacity: .35; font-size: .7em; }
.data-table th[data-sort="asc"] .sort-arrow, .data-table th[data-sort="desc"] .sort-arrow { opacity: 1; color: var(--brand); }
.data-table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table--compact th, .data-table--compact td { padding: 3px var(--space-2); font-size: var(--text-xs); }

.data-table-wrap__footer {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border-top: 1px solid var(--border);
  background: var(--surface-2); font-size: var(--text-xs); color: var(--fg-subtle);
}
.pager { display: flex; align-items: center; gap: 2px; }
.pager__btn {
  min-width: 24px; height: 24px; padding: 0 var(--space-1); border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--fg-muted); cursor: pointer; font-size: var(--text-xs);
}
.pager__btn:hover { background: var(--surface-raised); border-color: var(--border); }
.pager__btn.is-current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: var(--weight-semibold); }

/* ===================================== Panel ===================================== */
/* header + count + body + repliable. Enveloppe listes/graphes/groupes. */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: var(--space-4); }
.panel__header { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
.panel__title { font-size: var(--text-md); font-weight: var(--weight-semibold); margin: 0; }
.panel__count { font-size: var(--text-xs); color: var(--fg-subtle); background: var(--surface-2); border-radius: var(--radius-pill); padding: 1px var(--space-2); }
.panel__spacer { flex: 1 1 auto; }
.panel__toggle { border: none; background: transparent; cursor: pointer; color: var(--fg-muted); font-size: .8rem; transition: transform var(--motion-fast) var(--ease); }
.panel__body { padding: var(--space-4); }
.panel.is-collapsed .panel__body { display: none; }
.panel.is-collapsed .panel__toggle { transform: rotate(-90deg); }

/* =================================== LineChart ==================================== */
/* SVG 0-lib (Fraîcheur/Tendance/OPS-apt) — dans un Panel. */
.line-chart { display: block; width: 100%; height: auto; max-height: 280px; overflow: visible; }
.line-chart__grid { stroke: var(--border); stroke-width: 1; }
.line-chart__axis { fill: var(--fg-subtle); font-size: 9px; }
.line-chart__path { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.line-chart__area { opacity: .12; }
.line-chart__dot { fill: var(--surface); stroke-width: 2; }
.line-chart__legend { display: flex; gap: var(--space-4); margin-top: var(--space-2); font-size: var(--text-xs); color: var(--fg-muted); flex-wrap: wrap; }
.line-chart__legend-item { display: inline-flex; align-items: center; gap: 4px; }
.line-chart__swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* ================================== MonActivite ==================================== */
.dock__title { font-size: var(--text-lg); margin: 0 0 var(--space-3); display: flex; align-items: center; gap: var(--space-2); }
.dock__list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.dock__item { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: var(--text-sm); background: var(--surface-2); }
.dock__item-label { font-weight: var(--weight-medium); }
.dock__item-age { color: var(--fg-subtle); font-size: var(--text-xs); white-space: nowrap; }
.dock__item-remove { border: none; background: transparent; cursor: pointer; color: var(--crit); font-size: .95rem; }
.dock__empty { color: var(--fg-subtle); font-size: var(--text-sm); padding: var(--space-4) 0; text-align: center; }

/* =================================== Omnisearch ===================================== */
.omnisearch { position: relative; display: flex; align-items: center; }
.omnisearch__icon { position: absolute; left: var(--space-2); color: var(--fg-subtle); font-size: .85rem; pointer-events: none; }
.omnisearch__input {
  width: 100%; height: 34px; padding: 0 var(--space-6) 0 calc(var(--space-2) + 18px);
  border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--fg); font-size: var(--text-sm);
}
.omnisearch__input:focus { background: var(--surface); border-color: var(--brand); }
.omnisearch__kbd {
  position: absolute; right: var(--space-2); font-size: .65rem; color: var(--fg-subtle);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1px 5px; pointer-events: none;
}

/* =================================== NotificationBell ================================= */
.notif-bell { position: relative; display: inline-flex; align-items: center; }
.notif-bell__dot {
  position: absolute; top: 4px; right: 4px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--crit); border: 2px solid var(--surface);
}

/* ===================================== ThemeToggle ===================================== */
.theme-toggle { border: 1px solid var(--border); background: var(--surface); color: var(--fg); border-radius: var(--radius-md); padding: 0 var(--space-3); height: 32px; cursor: pointer; font-size: var(--text-sm); }
.theme-toggle:hover { border-color: var(--fg-subtle); }

/* ============================== Modal / Confirm ==================================== */
.modal-overlay { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: center; justify-content: center; z-index: 200; padding: var(--space-4); }
.modal { width: min(440px, 100%); background: var(--surface-raised); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); border: 1px solid var(--border); }
.modal__header { padding: var(--space-4); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: var(--space-2); }
.modal__title { margin: 0; font-size: var(--text-lg); }
.modal__body { padding: var(--space-4); color: var(--fg-muted); font-size: var(--text-sm); }
.modal__footer { padding: var(--space-3) var(--space-4); display: flex; justify-content: flex-end; gap: var(--space-2); border-top: 1px solid var(--border); }

/* === Tooltip (JS, teleport body) === */
/* Nœud unique appended au <body> (position:fixed -> jamais clippé par un ancêtre
   overflow:hidden, cf header/toolbar de l'app-shell). Positionné/affiché par le script
   en fin de layouts/app.blade.php au survol/focus de tout élément [data-tooltip]. */
.tooltip-float {
  position: fixed; top: 0; left: 0; z-index: 300;
  max-width: 260px; padding: 4px var(--space-2); border-radius: var(--radius-sm);
  background: var(--fg); color: var(--bg);
  font-size: var(--text-xs); line-height: var(--leading-tight); text-align: center;
  box-shadow: var(--shadow-sm); pointer-events: none;
  opacity: 0; transform: translateY(2px);
  transition: opacity var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease);
}
.tooltip-float.is-visible { opacity: 1; transform: translateY(0); }
.tooltip-float.is-below { transform: translateY(-2px); }
.tooltip-float.is-below.is-visible { transform: translateY(0); }

/* =================================== FleetList / Panel body specifics ================== */
.fleet-list__scroll { border-top: 1px solid var(--border); }

/* Backlog #17 bloc A slice 2a (specs/15-cohortes.md §"UX — on PIQUE dans
   la LISTE") : barre de sélection (tout-cocher-le-filtre + panneau
   Basculer/Sauver-comme-cohorte) + la ligne [checkbox][convergence][row]. */
.fleet-list__selection-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.fleet-list__select-all { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-sm); cursor: pointer; }
.fleet-list__selected-count { font-size: var(--text-xs); color: var(--fg-subtle); white-space: nowrap; }
.fleet-list__bascule-panel { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); margin-left: auto; }
.fleet-list__bascule-sep { width: 1px; align-self: stretch; margin: 2px 0; background: var(--border); }

/* Backlog #17 — "👁 Voir une cohorte" : bannière du filtre actif, juste
   au-dessus de la liste (cf fleet-list.blade.php). Accent brand à gauche
   pour signaler "un filtre cache des box" sans être une alerte/erreur. */
.fleet-list__cohorte-banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--brand); background: var(--surface-2);
  font-size: var(--text-sm);
}

.fleet-list__row { display: flex; align-items: center; gap: var(--space-2); }
.fleet-list__row-checkbox { flex-shrink: 0; width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }
.fleet-list__row-convergence { display: flex; gap: var(--space-1); flex-shrink: 0; width: 330px; overflow: hidden; }
.fleet-list__row-body { flex: 1 1 auto; min-width: 0; }

@media (max-width: 900px) {
  .fleet-list__bascule-panel { margin-left: 0; width: 100%; }
  .fleet-list__row-convergence { display: none; }
}

/* ======================================================================================
   /styleguide — styles propres à la page vitrine (section dédiée, toujours dans l'UNIQUE
   stylesheet comme le reste : pas de fichier séparé).
   ====================================================================================== */
.sg-section { margin-bottom: var(--space-10); }
.sg-section__title { font-size: var(--text-xl); border-bottom: 2px solid var(--brand); display: inline-block; padding-bottom: 2px; margin-bottom: var(--space-4); }
.sg-section__subtitle { font-size: var(--text-md); color: var(--fg-muted); margin: var(--space-6) 0 var(--space-3); }
.sg-block { margin-bottom: var(--space-6); }
.sg-label { font-size: var(--text-xs); color: var(--fg-subtle); text-transform: uppercase; letter-spacing: .05em; margin-bottom: var(--space-2); display: block; }
.sg-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-2); }
.sg-row--col { flex-direction: column; align-items: flex-start; }
.sg-row--top { align-items: flex-start; }
.sg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--space-3); }
.sg-demo-card { width: 320px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); padding: var(--space-4); }
.sg-inline-max { max-width: 420px; }
.sg-caption { color: var(--fg-subtle); font-size: var(--text-xs); }
.sg-tt-underline { border-bottom: 1px dotted var(--fg-subtle); cursor: help; }

.sg-swatch { display: flex; flex-direction: column; gap: var(--space-1); }
.sg-swatch__color { height: 56px; border-radius: var(--radius-md); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.sg-swatch__name { font-size: var(--text-xs); font-weight: var(--weight-medium); }
.sg-swatch__value { font-size: .7rem; color: var(--fg-subtle); font-family: ui-monospace, monospace; }

.sg-type-row { display: flex; align-items: baseline; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.sg-type-row__tag { font-size: var(--text-xs); color: var(--fg-subtle); width: 70px; flex-shrink: 0; font-family: ui-monospace, monospace; }

.sg-space-row { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-2); }
.sg-space-row__box { background: var(--brand); border-radius: var(--radius-sm); height: 14px; }
.sg-space-row__tag { font-size: var(--text-xs); font-family: ui-monospace, monospace; color: var(--fg-subtle); width: 46px; }

.sg-radius-row, .sg-shadow-row { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.sg-demo-box { width: 72px; height: 72px; background: var(--surface-raised); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: var(--text-xs); color: var(--fg-subtle); }

.sg-toc { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: var(--space-8); position: sticky; top: 0; z-index: 5; }
.sg-toc a { font-size: var(--text-sm); color: var(--fg-muted); text-decoration: none; }
.sg-toc a:hover { color: var(--brand); }

.sg-hero { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-6); flex-wrap: wrap; }
.sg-hero h1 { font-size: var(--text-2xl); margin: 0; }
.sg-hero p { color: var(--fg-muted); margin: var(--space-1) 0 0; max-width: 60ch; }

/* ============================ NotificationBell dropdown ============================ */
/* Audit gaps #21/#50 : dropdown réel de la cloche header (cf
   resources/views/livewire/notification-bell.blade.php). MÊMES tokens que
   .modal (surface-raised/shadow-md) et .dock__* (liste d'items). */
.notif-bell-wrap { position: relative; display: inline-flex; }
.notif-bell-trigger { cursor: pointer; display: inline-flex; }
.notif-dropdown {
  position: absolute; top: calc(100% + var(--space-2)); right: 0; z-index: 150;
  width: min(320px, 90vw); background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: var(--space-3);
}
.notif-dropdown__header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-2); }
.notif-dropdown__title { margin: 0; font-size: var(--text-md); }
.notif-dropdown__mark-all { border: none; background: transparent; color: var(--brand); cursor: pointer; font-size: var(--text-xs); padding: 0; }
.notif-dropdown__empty { color: var(--fg-subtle); font-size: var(--text-sm); padding: var(--space-4) 0; text-align: center; }
.notif-dropdown__list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-2); max-height: 320px; overflow-y: auto; }
.notif-dropdown__item { display: flex; flex-direction: column; gap: 2px; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: var(--text-sm); background: var(--surface-2); position: relative; }
.notif-dropdown__item.is-read { opacity: .6; }
.notif-dropdown__item-message { font-weight: var(--weight-medium); padding-right: var(--space-5); }
.notif-dropdown__item-age { color: var(--fg-subtle); font-size: var(--text-xs); }
.notif-dropdown__item-mark { position: absolute; top: var(--space-2); right: var(--space-2); border: none; background: transparent; cursor: pointer; color: var(--ok); font-size: .95rem; }

/* ============================ PlayerRow actions (audit gap #46) ============================ */
/* Menu fix/diag/rssh/rescue par player : MÊME pattern dropdown que
   .notif-dropdown (position relative/absolute + surface-raised/shadow-md),
   cf resources/views/livewire/player-row.blade.php. */
.player-row__actions-menu-wrap { position: relative; display: inline-flex; }
.player-row__actions-menu {
  position: absolute; top: calc(100% + var(--space-1)); left: 0; z-index: 150;
  min-width: 220px; background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: var(--space-1);
  display: flex; flex-direction: column; gap: 2px;
}
.player-row__actions-item {
  display: block; width: 100%; text-align: left; border: none; background: transparent;
  cursor: pointer; padding: var(--space-1) var(--space-2); border-radius: var(--radius-md);
  font-size: var(--text-sm); color: var(--fg);
}
.player-row__actions-item:hover, .player-row__actions-item:focus-visible { background: var(--surface-2); }
.player-row__actions-menu .btn--danger { width: 100%; justify-content: flex-start; }

/* ============================ Persona section wrapper (dashboard) ============================ */
/* Regroupe des cockpits sous UNE bannière de persona (backlog #17 bloc A
   slice 2b, cf specs/30-presentation.md §2) sans exiger une page dédiée
   (la persona-paged nav n'existe pas encore, cf dashboard.blade.php) --
   purement additif : ne change ni layout ni comportement des cockpits
   qu'elle enveloppe. */
.persona-section { margin-bottom: var(--space-6); }
.persona-section__title {
  font-size: var(--text-sm); text-transform: uppercase; letter-spacing: .05em;
  color: var(--fg-subtle); margin: 0 0 var(--space-3); padding-left: 2px;
}

/* ============================ CohorteCockpit (backlog #17 bloc A slice 2b) ============================ */
.cohorte-cockpit__form {
  display: flex; flex-direction: column; gap: var(--space-3);
  padding: var(--space-3); margin-bottom: var(--space-4);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.cohorte-cockpit__form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--space-3); }
.cohorte-cockpit__form-actions, .cohorte-cockpit__explicit-edit { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); }
.cohorte-cockpit__note { font-size: var(--text-xs); color: var(--fg-subtle); }
.cohorte-cockpit__def { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.cohorte-cockpit__empty-def { color: var(--fg-subtle); font-size: var(--text-xs); }
.cohorte-cockpit__more { border: none; background: transparent; color: var(--brand); cursor: pointer; font-size: var(--text-xs); padding: 0; }
.cohorte-cockpit__more-list { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-1); }
.cohorte-cockpit__bascule { display: flex; flex-direction: column; gap: var(--space-1); align-items: flex-start; }
.cohorte-cockpit__bascule-summary { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.cohorte-cockpit__counts { font-size: var(--text-xs); color: var(--fg-muted); }
.cohorte-cockpit__perbox { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: var(--space-1) 0; }
.cohorte-cockpit__actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-1); }
.cohorte-cockpit__launch { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-1); }
.cohorte-cockpit__explicit-edit .chip button,
.cohorte-cockpit__def .chip button { border: none; background: transparent; cursor: pointer; color: inherit; margin-left: 2px; padding: 0; }

/* ============================ APP NAV (persona routing) ============================ */
/* Barre de navigation persona (cf specs/30-presentation.md §2) : Suivi / Tech /
   Toute la flotte / Tendances. Remplace l'ancien lien ad-hoc "🛠️ Tech" du
   header. Rangée FIXE du grid .app-shell (--nav-h), jamais de position:fixed
   (même discipline que header/toolbar/footer, cf 35-design-system §4). */
.app-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0 var(--space-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: thin;
}
.app-nav__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease), background var(--motion-fast) var(--ease);
}
.app-nav__link:hover { color: var(--fg); background: var(--surface-2); }
.app-nav__link:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* Etat actif : marque orange (accent de navigation, PAS un statut — cf
   35-design-system §3 "RÈGLE D'OR" — brand ≠ sémantique ok/warn/crit). */
.app-nav__link[aria-current="page"] {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: var(--weight-semibold);
}

/* ============================ Page wrapper (persona pages) ============================ */
/* Chaque page (resources/views/pages/*.blade.php) enveloppe son contenu dans
   .page : espace vertical régulier entre sections + intro courte, pertinence
   d'abord (cf 00-overview §2 "le pertinent d'abord, le reste replié"). */
.page { display: flex; flex-direction: column; gap: var(--space-6); }
.page__intro {
  margin: 0;
  color: var(--fg-subtle);
  font-size: var(--text-sm);
  max-width: 80ch;
}


/* LineChart — enrichissements (repris du graphe v1 validé) : milieu, labels X, dots pleins, tooltip flottant */
.line-chart-wrap { min-width: 0; }
.line-chart__grid--mid { stroke-dasharray: 3 3; opacity: .55; }
.line-chart__dot { stroke-width: 0; }
.line-chart__hz { cursor: crosshair; }
.line-chart__hz:hover { fill: var(--surface-2); opacity: .5; }
.line-chart__tip { position: fixed; z-index: 60; pointer-events: none; background: var(--fg); color: var(--bg); font-size: var(--text-xs); line-height: 1.5; padding: 6px 10px; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); max-width: 240px; }
.line-chart__tip b { display: block; margin-bottom: 2px; }
.line-chart__tip i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.line-chart__legend b { margin-left: 3px; color: var(--fg); font-variant-numeric: tabular-nums; }

/* Palette catégorielle graphes (courbes delta) — hues repris de la v1 validée (violet/bleu) */
:root { --chart-delta: #7048e8; --chart-blindness: #1971c2; }
[data-theme="dark"] { --chart-delta: #9775fa; --chart-blindness: #4dabf7; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --chart-delta: #9775fa; --chart-blindness: #4dabf7; } }
.line-chart__vlabel { font-size: 8.5px; font-weight: 600; }
