/* =============================================================
   styles.css - Plateforme de pilotage DFI
   -------------------------------------------------------------
   1. Design system      6. Vue d'ensemble
   2. Base               7. Composants de données
   3. Écran d'accueil    8. Espace de travail
   4. En-tête            9. Détail projet
   5. Filtres           10. Infobulle · Responsive
   ============================================================= */

/* ============================================================
   1. DESIGN SYSTEM
   ============================================================ */
:root {
  /* --- Neutres légèrement chauds : un gris pur durcit les pastels --- */
  --bg:           #FBFAFC;
  --surface:      #FFFFFF;
  --surface-alt:  #F5F4F9;
  --surface-sunk: #EFEDF4;

  --line:         #E6E3EE;
  --line-soft:    #F0EEF5;
  --line-strong:  #D8D4E4;

  /* --- Encre : contrastes vérifiés sur fond blanc --- */
  --ink:          #1E212B;   /* 14.8:1 */
  --ink-soft:     #4E5566;   /* 8.1:1  */
  --ink-faint:    #6E7689;   /* 4.8:1 - conforme AA */
  --ink-ghost:    #9AA0B0;   /* décoratif uniquement */

  /* Repère temporel du déroulé : neutre, pour ne pas être confondu
     avec la couleur d'une phase. */
  --marker:       #5C6478;

  /* --- Accent lavande --- */
  --accent:       #8A86BE;
  --accent-deep:  #55508C;
  --accent-ink:   #423D74;
  --accent-soft:  #EFEDF8;
  --accent-mute:  #F7F6FC;

  /* --- Sémantique --- */
  --late:         #D97A6C;
  --late-deep:    #A8462F;
  --late-soft:    #FBEBE7;
  --ok:           #7FBF9A;
  --ok-deep:      #2F6B48;
  --ok-soft:      #E9F4EE;
  --warn:         #DDBB63;
  --warn-deep:    #7A6210;
  --warn-soft:    #FBF4E2;

  /* --- Phases (miroir de config.js) --- */
  --ph-cadrage:   #7C97CC;
  --ph-dev:       #EA9C6C;
  --ph-recette:   #DDBB63;
  --ph-livraison: #7FBF9A;

  /* --- Échelle d'espacement, base 4 --- */
  --s1: 4px;   --s2: 8px;   --s3: 12px;  --s4: 16px;
  --s5: 20px;  --s6: 24px;  --s7: 32px;  --s8: 40px;  --s9: 56px;

  /* --- Rayons --- */
  --r-xs: 6px;  --r-sm: 9px;  --r-md: 13px;  --r-lg: 18px;  --r-pill: 999px;

  /* --- Élévation : ombres teintées, jamais grises --- */
  --e1: 0 1px 2px rgba(66, 61, 116, .05),
        0 1px 1px rgba(66, 61, 116, .03);
  --e2: 0 2px 4px rgba(66, 61, 116, .05),
        0 6px 16px -6px rgba(66, 61, 116, .10);
  --e3: 0 4px 8px rgba(66, 61, 116, .06),
        0 16px 32px -12px rgba(66, 61, 116, .16);
  --e4: 0 24px 64px -16px rgba(30, 33, 43, .28),
        0 8px 20px -8px rgba(30, 33, 43, .16);

  /* Liseré clair en haut des surfaces : donne l'épaisseur du verre. */
  --sheen: inset 0 1px 0 rgba(255, 255, 255, .9);

  /* --- Mouvement : une seule courbe pour toute l'interface --- */
  --ease:      cubic-bezier(.2, .7, .3, 1);
  --ease-out:  cubic-bezier(.16, 1, .3, 1);
  --t-fast:    120ms;
  --t-base:    180ms;
  --t-slow:    260ms;

  /* --- Divers --- */
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
  --header-h: 116px;
  --tl-label: 132px;
  --gap: 18px;
  --maxw: 1400px;
}

/* ============================================================
   2. BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 520px at 88% -8%, #F3EFFA 0%, transparent 62%),
    radial-gradient(900px 460px at 4% 0%, #EEF4F8 0%, transparent 58%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.018em; }
h1 { font-size: 19px; }
h2 { font-size: 15px; }
p, dl, dd, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* Anneau de focus homogène, visible sur toutes les surfaces. */
:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--r-xs);
}

.is-hidden { display: none !important; }
.muted { color: var(--ink-faint); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Lien d'évitement : premier élément atteint au clavier. */
.skip {
  position: fixed; top: var(--s3); left: var(--s3); z-index: 200;
  padding: 10px 16px; border-radius: var(--r-sm);
  background: var(--ink); color: #fff;
  font-size: 13px; font-weight: 600;
  transform: translateY(-160%);
  transition: transform var(--t-base) var(--ease);
}
.skip:focus { transform: translateY(0); }

/* --- Apparition progressive au défilement --- */
.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--t-slow) var(--ease-out),
              transform var(--t-slow) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}
.reveal.is-in { opacity: 1; transform: none; }

/* ---------- Boutons ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink-soft);
  --btn-bd: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 13px; font-weight: 600;
  box-shadow: var(--e1);
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.btn:hover { --btn-bd: var(--line-strong); --btn-fg: var(--ink); box-shadow: var(--e2); }
.btn:active { transform: translateY(1px); box-shadow: var(--e1); }

.btn-primary {
  --btn-bg: linear-gradient(180deg, #9A96CB 0%, #8A86BE 100%);
  --btn-fg: #fff;
  --btn-bd: transparent;
  box-shadow: var(--e2), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.btn-primary:hover {
  --btn-bg: linear-gradient(180deg, #8F8AC4 0%, #7D79B4 100%);
  --btn-fg: #fff;
  --btn-bd: transparent;
}

.btn-icon { padding: 9px; }
.btn-icon svg {
  width: 16px; height: 16px; display: block;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  transition: transform var(--t-slow) var(--ease);
}
.btn-icon:hover svg { transform: rotate(-40deg); }

.link-btn {
  color: var(--accent-deep);
  font-size: 12.5px; font-weight: 700;
  padding: 4px 2px; border-radius: var(--r-xs);
  transition: color var(--t-fast) var(--ease);
}
.link-btn:hover { color: var(--accent-ink); }
.link-btn::after {
  content: ''; display: block; height: 1px; margin-top: 1px;
  background: currentColor; opacity: .3;
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--t-base) var(--ease);
}
.link-btn:hover::after { transform: scaleX(1); }

/* ============================================================
   3. ÉCRAN D'ACCUEIL
   ============================================================ */
.loader {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: var(--s7) var(--s5);
}

.loader-box {
  max-width: 540px; width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--e3), var(--sheen);
  padding: var(--s8) var(--s7) var(--s6);
  text-align: center;
  animation: rise var(--t-slow) var(--ease-out) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(.99); }
}

.loader-mark, .brand-mark {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 3px; width: 36px; height: 36px;
}
.loader-mark { margin: 0 auto var(--s5); width: 44px; height: 44px; gap: 4px; }
.loader-mark span, .brand-mark span {
  display: block; border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4);
}
.loader-mark span:nth-child(1), .brand-mark span:nth-child(1) { background: var(--ph-cadrage); }
.loader-mark span:nth-child(2), .brand-mark span:nth-child(2) { background: var(--ph-dev); }
.loader-mark span:nth-child(3), .brand-mark span:nth-child(3) { background: var(--ph-recette); }
.loader-mark span:nth-child(4), .brand-mark span:nth-child(4) { background: var(--ph-livraison); }

/* Chaque carreau pulse à son tour pendant la recherche du fichier. */
.loader-mark span { animation: tile 2.4s var(--ease) infinite; }
.loader-mark span:nth-child(2) { animation-delay: .15s; }
.loader-mark span:nth-child(3) { animation-delay: .45s; }
.loader-mark span:nth-child(4) { animation-delay: .3s; }
@keyframes tile {
  0%, 70%, 100% { opacity: 1; transform: none; }
  35%           { opacity: .55; transform: scale(.9); }
}

.loader-box h1 { font-size: 21px; margin-bottom: var(--s2); }
.loader-lead {
  color: var(--ink-faint); font-size: 13.5px;
  margin: 0 auto var(--s6); max-width: 42ch;
}

.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface-alt);
  padding: var(--s7) var(--s5);
  transition: border-color var(--t-base) var(--ease),
              background var(--t-base) var(--ease),
              transform var(--t-base) var(--ease);
}
.dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-mute);
  transform: scale(1.015);
}
.dropzone-main { font-size: 13.5px; color: var(--ink-soft); }
.dropzone-main strong { color: var(--ink); font-weight: 700; }
.dropzone-or {
  font-size: 11.5px; color: var(--ink-ghost); margin: var(--s3) 0;
  text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
}

.loader-status {
  margin-top: var(--s4);
  font-size: 12.5px; color: var(--ink-faint);
  min-height: 20px;
}

.loader-help { margin-top: var(--s5); text-align: left; }
.loader-help summary {
  font-size: 12.5px; color: var(--accent-deep);
  font-weight: 700; cursor: pointer;
  padding: 6px; border-radius: var(--r-xs);
  list-style: none;
}
.loader-help summary::-webkit-details-marker { display: none; }
.loader-help summary::before { content: '＋'; margin-right: 6px; font-weight: 400; }
.loader-help[open] summary::before { content: '－'; }
.loader-help summary:hover { background: var(--accent-mute); }
.loader-help p {
  font-size: 12.5px; color: var(--ink-faint);
  margin-top: var(--s2); padding: 0 6px; line-height: 1.6;
}
.loader-help code {
  background: var(--surface-alt); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px; font-size: 12px;
  color: var(--ink-soft);
}

/* ============================================================
   4. EN-TÊTE
   ============================================================ */
.masthead {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(16px) saturate(1.5);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  border-bottom: 1px solid var(--line);
}

.masthead-inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: var(--s4) var(--s7) var(--s3);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s5);
}

.brand { display: flex; align-items: center; gap: var(--s3); }
.brand h1 { font-size: 16px; line-height: 1.25; }
.brand p { font-size: 12px; color: var(--ink-faint); font-weight: 600; }

.masthead-right { display: flex; align-items: center; gap: var(--s4); }

.team { text-align: right; line-height: 1.3; }
.team-name { display: block; font-size: 13px; font-weight: 700; }
.team-count { display: block; font-size: 11.5px; color: var(--ink-faint); font-weight: 600; }

.logos {
  display: flex; align-items: center; gap: var(--s3);
  padding-left: var(--s4);
  border-left: 1px solid var(--line);
  min-height: 30px;
}
.logos:empty { display: none; }
.logo {
  height: 26px; width: auto; max-width: 100px;
  object-fit: contain; opacity: .88;
  transition: opacity var(--t-base) var(--ease);
}
.logo:hover { opacity: 1; }

/* --- Onglets --- */
.tabs {
  max-width: var(--maxw); margin: 0 auto;
  padding: 0 var(--s7);
  display: flex; gap: var(--s1);
  position: relative;
}
.tab {
  padding: 9px 16px 14px;
  font-size: 13.5px; font-weight: 700;
  color: var(--ink-faint);
  position: relative;
  border-radius: var(--r-xs) var(--r-xs) 0 0;
  transition: color var(--t-fast) var(--ease);
}
.tab:hover { color: var(--ink-soft); }
.tab.is-active { color: var(--accent-ink); }
.tab::after {
  content: ''; position: absolute;
  left: 12px; right: 12px; bottom: 0; height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform var(--t-base) var(--ease);
}
.tab.is-active::after { transform: scaleX(1); }

/* ============================================================
   5. FILTRES
   ============================================================ */
.filterbar {
  position: sticky; top: var(--header-h); z-index: 30;
  background: rgba(251, 250, 252, .88);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line-soft);
}
.filterbar-inner {
  max-width: var(--maxw); margin: 0 auto;
  padding: var(--s3) var(--s7);
  display: flex; flex-direction: column; gap: var(--s2);
}

.filter-primary { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }

.search { position: relative; flex: 1 1 260px; min-width: 200px; }
.search svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px;
  fill: none; stroke: var(--ink-ghost); stroke-width: 2; stroke-linecap: round;
  transition: stroke var(--t-fast) var(--ease);
}
.search input {
  width: 100%;
  padding: 10px 14px 10px 35px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--e1);
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.search input::placeholder { color: var(--ink-ghost); }
.search input:hover { border-color: var(--line-strong); }
.search input:focus {
  border-color: var(--accent);
  box-shadow: var(--e1), 0 0 0 3px var(--accent-soft);
  outline: none;
}
.search:focus-within svg { stroke: var(--accent); }

.filter-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--e1);
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  transition: border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.filter-toggle:hover { border-color: var(--line-strong); color: var(--ink); box-shadow: var(--e2); }
.filter-toggle svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
}
.filter-toggle.is-open {
  border-color: var(--accent); color: var(--accent-ink); background: var(--accent-mute);
}
.filter-toggle .chev { transition: transform var(--t-base) var(--ease); }
.filter-toggle.is-open .chev { transform: rotate(180deg); }

.filter-badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 800;
  display: inline-grid; place-items: center;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
  gap: var(--s2);
  overflow: hidden;
  max-height: 0; opacity: 0;
  transition: max-height var(--t-slow) var(--ease),
              opacity var(--t-base) var(--ease),
              padding var(--t-slow) var(--ease);
}
.filter-grid.is-open {
  max-height: 340px; opacity: 1;
  padding-top: var(--s1); padding-bottom: var(--s2);
}

.filter-grid select {
  width: 100%;
  appearance: none; -webkit-appearance: none;
  padding: 9px 30px 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%236E7689'/></svg>")
    no-repeat right 11px center;
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  box-shadow: var(--e1); cursor: pointer;
  /* Une valeur trop longue est abrégée proprement plutôt que rognée. */
  text-overflow: ellipsis;
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease);
}
.filter-grid select:hover { border-color: var(--line-strong); }
.filter-grid select:focus {
  border-color: var(--accent);
  box-shadow: var(--e1), 0 0 0 3px var(--accent-soft);
  outline: none;
}
/* Une liste renseignée se distingue des listes vides. */
.filter-grid select.has-value {
  border-color: var(--accent);
  background-color: var(--accent-mute);
  color: var(--accent-ink);
}

/* Jetons de filtres actifs */
.chips { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 6px 5px 11px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px; font-weight: 700;
  border: 1px solid transparent;
  animation: chipIn var(--t-base) var(--ease-out) both;
  transition: border-color var(--t-fast) var(--ease);
}
@keyframes chipIn { from { opacity: 0; transform: scale(.9); } }
.chip:hover { border-color: #C9C4E4; }
.chip-key { font-weight: 600; opacity: .7; }
.chip-x {
  width: 17px; height: 17px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(66, 61, 116, .1);
  color: inherit; font-size: 12px; line-height: 1;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.chip-x:hover { background: rgba(66, 61, 116, .22); transform: rotate(90deg); }

.chip-clear {
  font-size: 12px; font-weight: 700; color: var(--ink-faint);
  padding: 5px 10px; border-radius: var(--r-pill);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.chip-clear:hover { background: var(--surface-sunk); color: var(--ink); }

.result-count {
  margin-left: auto;
  font-size: 12.5px; color: var(--ink-faint); font-weight: 600;
  white-space: nowrap;
}
.result-count b { color: var(--ink); font-weight: 800; }

/* ============================================================
   6. VUE D'ENSEMBLE
   ============================================================ */
.view {
  max-width: var(--maxw); margin: 0 auto;
  padding: var(--s6) var(--s7) var(--s8);
  display: flex; flex-direction: column; gap: var(--gap);
}

.foot {
  max-width: var(--maxw); margin: 0 auto;
  padding: 0 var(--s7) var(--s7);
  font-size: 12px; color: var(--ink-faint);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  box-shadow: var(--e1), var(--sheen);
  padding: var(--s5);
  transition: box-shadow var(--t-base) var(--ease),
              border-color var(--t-base) var(--ease);
}
.panel:hover { box-shadow: var(--e2), var(--sheen); border-color: var(--line); }

.panel-title { font-size: 14.5px; letter-spacing: -.01em; }
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s3); margin-bottom: var(--s4);
}
.panel-meta { font-size: 12.5px; color: var(--ink-faint); font-weight: 500; }
.panel > .panel-title { margin-bottom: var(--s4); }
.panel-hint {
  font-size: 12.5px; color: var(--ink-faint);
  margin: -6px 0 var(--s4); max-width: 66ch; line-height: 1.55;
}
.sub-panel { box-shadow: none; background: var(--surface-alt); border-color: transparent; }
.sub-panel:hover { box-shadow: none; border-color: transparent; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }

/* ---------- Cartes KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--s3);
}
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  box-shadow: var(--e1), var(--sheen);
  padding: var(--s4) var(--s4) var(--s4) var(--s5);
  transition: transform var(--t-base) var(--ease),
              box-shadow var(--t-base) var(--ease),
              border-color var(--t-base) var(--ease);
}
.kpi::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--kpi-accent);
  transition: width var(--t-base) var(--ease);
}
/* Voile coloré très léger, révélé au survol : de la profondeur sans
   colorer la carte en permanence. */
.kpi::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(115deg, var(--kpi-accent) 0%, transparent 58%);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-base) var(--ease);
}
.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--e3), var(--sheen);
  border-color: var(--line);
}
.kpi:hover::before { width: 4px; }
.kpi:hover::after { opacity: .05; }

.kpi-value {
  font-size: 28px; font-weight: 800;
  letter-spacing: -.035em; line-height: 1.05;
}
.kpi-label { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); margin-top: var(--s1); }
.kpi-note { font-size: 11.5px; color: var(--ink-faint); margin-top: 5px; line-height: 1.4; }

/* Le KPI le plus actionnable se démarque quand il n'est pas à zéro. */
.kpi.is-alert {
  border-color: #F0D5CE;
  background: linear-gradient(180deg, #FFF9F7 0%, var(--surface) 60%);
}
.kpi.is-alert .kpi-value { color: var(--late-deep); }

/* ============================================================
   7. COMPOSANTS DE DONNÉES
   ============================================================ */

/* ---------- Statistiques ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(106px, 1fr));
  gap: var(--s2);
}
.stat {
  background: var(--surface-alt);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: var(--s3);
  transition: border-color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.stat:hover { transform: translateY(-1px); border-color: var(--line); }
.stat-danger { background: var(--late-soft); }
.stat-ok     { background: var(--ok-soft); }
.stat-warn   { background: var(--warn-soft); }
.stat-value { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.03em; }
.stat-danger .stat-value { color: var(--late-deep); }
.stat-ok .stat-value     { color: var(--ok-deep); }
.stat-warn .stat-value   { color: var(--warn-deep); }
.stat-label {
  display: block; font-size: 11.5px; color: var(--ink-faint);
  font-weight: 700; margin-top: 2px;
}

/* ---------- Barres horizontales ---------- */
.bars { display: flex; flex-direction: column; gap: var(--s2); }
.bar-row {
  display: grid; grid-template-columns: 124px 1fr 44px;
  align-items: center; gap: var(--s3);
  padding: 2px 4px; margin: 0 -4px;
  border-radius: var(--r-xs);
  transition: background var(--t-fast) var(--ease);
}
.bar-row:hover { background: var(--surface-alt); }
.bar-label {
  font-size: 12px; color: var(--ink-soft); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bar-track {
  height: 16px; border-radius: 5px;
  background: var(--surface-sunk);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(66, 61, 116, .05);
}
.bar-fill, .bar-group {
  display: block; height: 100%; border-radius: 5px;
  transform-origin: left;
  animation: growX 620ms var(--ease-out) both;
}
@keyframes growX { from { transform: scaleX(0); } }
.bar-group { display: flex; overflow: hidden; }
.bar-seg { display: block; height: 100%; }
/* Corail clair : la part en retard se distingue sans dominer la barre
   ni effacer la couleur attribuée à la personne. */
.bar-seg-late {
  background: repeating-linear-gradient(135deg,
    #F2C4BB 0 5px, #EDB3A8 5px 10px);
}
.bar-value {
  display: flex; align-items: center; justify-content: flex-end; gap: 5px;
  font-size: 12px; color: var(--ink); font-weight: 800;
}
.bar-late-count {
  font-style: normal; font-size: 10.5px; font-weight: 800;
  color: var(--late-deep); background: var(--late-soft);
  padding: 1px 6px; border-radius: var(--r-pill);
}

/* ---------- Barre empilée ---------- */
.stacked-wrap { display: flex; flex-direction: column; gap: var(--s4); }
.stacked {
  width: 100%; height: 14px;
  border-radius: 6px; overflow: hidden; display: block;
  box-shadow: inset 0 1px 2px rgba(66, 61, 116, .06);
}
.stack-seg { transition: opacity var(--t-fast) var(--ease); }
.stacked:hover .stack-seg { opacity: .5; }
.stacked .stack-seg:hover { opacity: 1; }

.legend { display: flex; flex-wrap: wrap; gap: 7px var(--s5); }
.legend li { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.legend-label { color: var(--ink-soft); font-weight: 500; }
.legend-value { font-weight: 800; }

/* ---------- Respect des délais ---------- */
.rels { display: flex; flex-direction: column; gap: var(--s3); }
.rel-row {
  display: grid; grid-template-columns: 130px 1fr 48px;
  align-items: center; gap: var(--s3);
  padding: 2px 4px; margin: 0 -4px;
  border-radius: var(--r-xs);
  transition: background var(--t-fast) var(--ease);
}
.rel-row:hover { background: var(--surface-alt); }
.rel-label { font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.rel-track {
  display: flex; height: 18px;
  border-radius: 5px; overflow: hidden;
  background: var(--surface-sunk);
  box-shadow: inset 0 1px 2px rgba(66, 61, 116, .05);
  animation: growX 620ms var(--ease-out) both;
  transform-origin: left;
}
.rel-ok, .rel-late { display: block; height: 100%; }
.rel-late { background: var(--late-soft); }
.rel-value { font-size: 12.5px; font-weight: 800; text-align: right; }
.rel-value.is-good  { color: var(--ok-deep); }
.rel-value.is-mixed { color: var(--warn-deep); }
.rel-value.is-poor  { color: var(--late-deep); }

.rel-legend {
  display: flex; flex-wrap: wrap; gap: 7px var(--s5);
  margin-top: var(--s4); padding-top: var(--s3);
  border-top: 1px solid var(--line-soft);
}
.rel-legend span {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--ink-faint); font-weight: 600;
}
.rel-legend i { width: 16px; height: 10px; border-radius: 3px; flex: none; }
.sw-ok {
  background: linear-gradient(90deg, var(--ph-cadrage) 0 25%, var(--ph-dev) 25% 50%,
                              var(--ph-recette) 50% 75%, var(--ph-livraison) 75% 100%);
}
.sw-late { background: var(--late-soft); border: 1px solid #F0D5CE; }
.rel-note { font-style: italic; opacity: .85; font-weight: 500 !important; }

/* ---------- Courbe ---------- */
.chart-line { width: 100%; height: auto; display: block; }
.axis-line { stroke: var(--line); stroke-width: 1; }
.axis-tick { font-size: 11px; fill: var(--ink-faint); font-family: inherit; font-weight: 600; }
.line-dot { transition: r var(--t-fast) var(--ease); }
.line-dot:hover { r: 6; }

.chart-empty {
  font-size: 12.5px; color: var(--ink-faint);
  padding: var(--s6) var(--s4); text-align: center;
  background: var(--surface-alt);
  border-radius: var(--r-sm);
  line-height: 1.55;
}

/* ---------- Pastilles ---------- */
.pill {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 700;
  white-space: nowrap;
  border: 1px solid rgba(0, 0, 0, .03);
}
.pill-late { background: var(--late-soft); color: var(--late-deep); }
.pill-neutral { background: var(--surface-sunk); color: var(--ink-soft); }

.phase-tag {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
}
.phase-tag::before {
  content: ''; width: 8px; height: 8px; flex: none;
  border-radius: 3px; background: var(--c);
}

.phase-dots { display: inline-flex; gap: 3px; }
.phase-dots i {
  width: 15px; height: 4px; border-radius: var(--r-pill); display: block;
  transition: transform var(--t-fast) var(--ease);
}
.phase-dots:hover i { transform: scaleY(1.6); }

.flag {
  font-size: 11px; font-weight: 800;
  padding: 4px 10px; border-radius: var(--r-pill);
  white-space: nowrap;
}
.flag-late { background: var(--late-soft); color: var(--late-deep); }
.flag-warn { background: var(--warn-soft); color: var(--warn-deep); }
.flag-soon { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- Cartes clients ---------- */
.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--s4);
}
.client-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: var(--s4) var(--s4) var(--s5);
  background: var(--surface);
  transition: border-color var(--t-base) var(--ease),
              box-shadow var(--t-base) var(--ease),
              transform var(--t-base) var(--ease);
}
.client-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--e2);
  transform: translateY(-2px);
}
.client-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s3); margin-bottom: var(--s3);
}
.client-head h3 { font-size: 15px; }
.client-bar { margin-top: var(--s4); }

/* ---------- Listes de projets ---------- */
.p-list { display: flex; flex-direction: column; }
.p-line {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s2);
  border-top: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  cursor: pointer; position: relative;
  transition: background var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.p-list > li:first-child { border-top: 0; }
.p-line::before {
  content: ''; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 2px; border-radius: 2px; background: var(--accent);
  transform: scaleY(0);
  transition: transform var(--t-fast) var(--ease);
}
.p-line:hover { background: var(--accent-mute); transform: translateX(2px); }
.p-line:hover::before { transform: scaleY(1); }
.p-line-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.p-line-main strong {
  font-size: 13.5px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.p-line-main em {
  font-size: 11.5px; color: var(--ink-faint); font-style: normal; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Tableau ---------- */
.table-wrap { overflow-x: auto; margin: 0 calc(var(--s5) * -1); padding: 0 var(--s5); }
.table { width: 100%; border-collapse: collapse; }

.table th {
  text-align: left;
  font-size: 11px; font-weight: 800; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .05em;
  padding: 0 var(--s3) var(--s3) 0;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table thead th { cursor: pointer; user-select: none; transition: color var(--t-fast) var(--ease); }
.table thead th:hover { color: var(--ink-soft); }
.table th.is-sorted { color: var(--accent-ink); }
.sort-arrow { margin-left: 4px; font-size: 10px; }

.table td {
  padding: var(--s3) var(--s3) var(--s3) 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px; vertical-align: middle;
}
.table tbody tr { cursor: pointer; transition: background var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--accent-mute); }
.table tbody tr:hover .cell-name strong { color: var(--accent-ink); }

.cell-name { min-width: 240px; }
.cell-name strong {
  display: block; font-size: 13.5px; font-weight: 700;
  max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color var(--t-fast) var(--ease);
}
.cell-id { font-size: 11px; color: var(--ink-faint); font-weight: 600; letter-spacing: .02em; }
.late-cell { color: var(--late-deep); font-weight: 800; font-size: 12.5px; }

.pagination {
  display: flex; align-items: center; justify-content: center; gap: var(--s4);
  padding-top: var(--s4);
  font-size: 12.5px; color: var(--ink-faint); font-weight: 600;
}
.pagination button {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 7px 14px;
  font-size: 12.5px; font-weight: 700; color: var(--ink-soft);
  box-shadow: var(--e1);
  transition: border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.pagination button:hover:not(:disabled) { border-color: var(--line-strong); color: var(--ink); }
.pagination button:active:not(:disabled) { transform: translateY(1px); }
.pagination button:disabled { opacity: .4; cursor: default; box-shadow: none; }

/* ============================================================
   8. ESPACE DE TRAVAIL
   ============================================================ */
.workspace {
  display: grid;
  grid-template-columns: 262px minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}
.workspace-side {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  box-shadow: var(--e1), var(--sheen);
  padding: var(--s3);
  position: sticky; top: calc(var(--header-h) + 74px);
  max-height: calc(100vh - var(--header-h) - 100px);
  display: flex; flex-direction: column; gap: var(--s3);
}
.workspace-main { display: flex; flex-direction: column; gap: var(--gap); }

.segmented {
  display: flex; gap: 3px;
  background: var(--surface-sunk);
  padding: 3px; border-radius: var(--r-sm);
}
.segmented button {
  flex: 1; padding: 8px 12px; border-radius: 7px;
  font-size: 12.5px; font-weight: 700; color: var(--ink-faint);
  transition: background var(--t-base) var(--ease),
              color var(--t-base) var(--ease),
              box-shadow var(--t-base) var(--ease);
}
.segmented button:hover { color: var(--ink-soft); }
.segmented button.is-active {
  background: var(--surface); color: var(--accent-ink);
  box-shadow: var(--e1), var(--sheen);
}

.side-title {
  font-size: 11px; font-weight: 800; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .05em;
  padding: 4px 9px 0;
}
.person-list {
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 2px;
  margin: 0 calc(var(--s1) * -1); padding: 0 var(--s1);
}
.person {
  width: 100%; text-align: left;
  padding: 8px 9px; border-radius: var(--r-sm);
  display: flex; align-items: center; gap: var(--s3);
  transition: background var(--t-fast) var(--ease);
}
.person:hover { background: var(--surface-alt); }
.person.is-active { background: var(--accent-soft); }

.person-avatar {
  flex: none;
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(140deg, #EDEAF8 0%, #E2DEF2 100%);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 800;
  box-shadow: var(--sheen);
  transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease);
}
.person.is-active .person-avatar {
  background: linear-gradient(140deg, #9A96CB 0%, #8A86BE 100%);
  color: #fff;
}
.person-avatar-all { background: var(--surface-sunk); color: var(--ink-soft); font-size: 15px; }

.person-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person-name {
  font-size: 12.5px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.person.is-active .person-name { color: var(--accent-ink); }
.person-meta { font-size: 11px; color: var(--ink-faint); font-weight: 500; }
.person-dot {
  flex: none; width: 7px; height: 7px; border-radius: 50%;
  background: var(--late);
  box-shadow: 0 0 0 3px var(--late-soft);
}

.scope-title { display: flex; align-items: center; gap: var(--s3); }
.scope-title .person-avatar { width: 42px; height: 42px; border-radius: 13px; font-size: 14px; }
.scope .stat-row { margin-bottom: var(--s4); }
.scope-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }

/* ============================================================
   9. DÉTAIL PROJET
   ============================================================ */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(30, 33, 43, .32);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-slow) var(--ease);
}
.overlay.is-open { opacity: 1; pointer-events: auto; }

.detail {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 51;
  width: min(1020px, 96vw);
  background: var(--bg);
  box-shadow: var(--e4);
  transform: translateX(100%);
  transition: transform var(--t-slow) var(--ease-out);
  display: flex; flex-direction: column;
  will-change: transform;
}
.detail.is-open { transform: translateX(0); }

.detail-head {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: var(--s6) var(--s7) var(--s4);
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s4);
}
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s3); }
.detail-head h2 { font-size: 21px; line-height: 1.28; letter-spacing: -.022em; }

.icon-btn {
  flex: none; width: 34px; height: 34px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink-soft);
  font-size: 14px; line-height: 1;
  display: grid; place-items: center;
  transition: background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-sunk); color: var(--ink); transform: rotate(90deg); }

.detail-body { padding: var(--s6) var(--s7) var(--s9); overflow-y: auto; flex: 1; }

.progress { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s6); }
.progress-bar {
  flex: 1; height: 8px; border-radius: var(--r-pill);
  background: var(--surface-sunk); overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(66, 61, 116, .07);
}
.progress-bar span {
  display: block; height: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg, #A29EDA 0%, #8A86BE 100%);
  transform-origin: left;
  animation: growX 700ms var(--ease-out) both;
}
.progress-value { font-size: 13px; font-weight: 800; color: var(--accent-ink); }

.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.detail-grid > div {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: var(--s3);
  transition: border-color var(--t-fast) var(--ease);
}
.detail-grid > div:hover { border-color: var(--line-strong); }
.detail-grid dt {
  font-size: 10.5px; color: var(--ink-faint); font-weight: 800;
  text-transform: uppercase; letter-spacing: .05em;
}
.detail-grid dd { font-size: 13.5px; font-weight: 700; margin-top: 3px; }

.detail-section {
  font-size: 14px; margin: var(--s7) 0 var(--s4);
  display: flex; align-items: center; gap: var(--s3);
}
.detail-section::after { content: ''; flex: 1; height: 1px; background: var(--line-soft); }

.detail-comment {
  background: var(--accent-mute);
  border: 1px solid var(--accent-soft);
  border-radius: var(--r-sm);
  padding: var(--s3) var(--s4);
  font-size: 13px; color: var(--accent-ink); line-height: 1.6;
}


/* ---------- Déroulé du projet ---------- */
.timeline {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  box-shadow: var(--e1), var(--sheen);
  padding: var(--s5) var(--s5) var(--s3);
}

.tl-body { position: relative; }

/* Repères de mois et trait du jour : positionnés sur la seule zone des
   pistes, pour rester alignés avec les barres. */
.tl-overlay {
  position: absolute;
  left: calc(var(--tl-label) + 58px);
  right: 152px; top: 6px; bottom: 4px;
  pointer-events: none;
}
.tl-guide {
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: var(--line-soft);
}
.tl-today {
  position: absolute; top: 0; bottom: 0;
  border-left: 2px dashed var(--marker, #5C6478);
  opacity: .55;
}
.tl-today b {
  position: absolute; top: -4px; left: 6px;
  font-size: 9.5px; font-weight: 800;
  color: #fff; background: var(--marker, #5C6478);
  padding: 2px 7px; border-radius: var(--r-pill);
  white-space: nowrap;
}
.tl-today.is-right b { left: auto; right: 6px; }

.tl-phase { position: relative; margin-bottom: var(--s5); }
.tl-phase:last-child { margin-bottom: var(--s2); }

.tl-phase-head {
  display: flex; align-items: baseline; gap: var(--s3);
  padding-left: 4px; margin-bottom: 5px;
}
.tl-phase-name {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 800; color: var(--c-deep);
}
.tl-phase-name::before {
  content: ''; width: 9px; height: 9px; border-radius: 3px;
  background: var(--c);
}
.tl-phase-len { font-size: 11.5px; color: var(--ink-faint); font-weight: 600; }
.tl-phase-delay {
  font-size: 11px; font-weight: 800;
  color: var(--late-deep); background: var(--late-soft);
  padding: 2px 8px; border-radius: var(--r-pill);
}

/* Trois colonnes fixes : l'œil retrouve toujours l'étiquette à gauche
   et la date à droite, quelle que soit la longueur de la barre. */
.tl-line {
  display: grid;
  grid-template-columns: var(--tl-label) 58px 1fr 152px;
  align-items: center;
  margin-bottom: 5px;
}
.tl-line > .tl-tag   { grid-column: 2; }
.tl-line > .tl-track { grid-column: 3; }
.tl-line > .tl-date  { grid-column: 4; }

.tl-tag {
  font-size: 10.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-faint);
}
.tl-tag-real { color: var(--c-deep); }

.tl-track { position: relative; height: 20px; }

.tl-bar { position: absolute; top: 5px; height: 10px; border-radius: 5px; }
.tl-bar-plan {
  background: var(--c-light);
  border: 1px solid color-mix(in srgb, var(--c) 34%, transparent);
  animation: growX 560ms var(--ease-out) both; transform-origin: left;
}
.tl-bar-real {
  background: var(--c); box-shadow: var(--sheen);
  animation: growX 640ms var(--ease-out) both; transform-origin: left;
}
.tl-bar-real.is-ongoing {
  background-image: linear-gradient(90deg, rgba(255,255,255,.45) 25%, transparent 25%,
                    transparent 50%, rgba(255,255,255,.45) 50%, rgba(255,255,255,.45) 75%, transparent 75%);
  background-size: 10px 10px;
}

.tl-mark {
  position: absolute; top: 4px;
  width: 12px; height: 12px;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 3px;
  animation: pop 420ms var(--ease-out) both;
}
@keyframes pop { from { opacity: 0; transform: translateX(-50%) rotate(45deg) scale(.4); } }
.tl-mark-plan {
  background: var(--c-light);
  border: 1.5px solid color-mix(in srgb, var(--c) 45%, transparent);
}
.tl-mark-real { background: var(--c); border: 2px solid var(--surface); box-shadow: var(--e1); }

.tl-date {
  padding-left: var(--s3);
  font-size: 11.5px; font-weight: 700;
  color: var(--ink-faint); white-space: nowrap;
}
.tl-date-real { color: var(--ink); }
.tl-date-none { color: var(--ink-ghost); font-style: italic; font-weight: 500; }

.tl-slip {
  position: absolute; top: 3px; bottom: 3px;
  background: repeating-linear-gradient(135deg,
    color-mix(in srgb, var(--late) 24%, transparent) 0 4px,
    color-mix(in srgb, var(--late) 9%, transparent) 4px 8px);
  border-left: 1.5px solid var(--late);
  border-right: 1.5px solid var(--late);
  border-radius: 3px;
}

.tl-axis {
  position: relative; height: 18px;
  margin-left: calc(var(--tl-label) + 58px);
  margin-right: 152px;
  border-top: 1px solid var(--line-soft);
  padding-top: 6px;
}
.tl-axis span {
  position: absolute; transform: translateX(-50%);
  font-size: 10.5px; color: var(--ink-faint); font-weight: 700;
  white-space: nowrap;
}

/* ============================================================
   10. INFOBULLE
   ============================================================ */
.tooltip {
  position: fixed; z-index: 100;
  max-width: 280px;
  padding: 10px 13px;
  border-radius: var(--r-sm);
  background: rgba(30, 33, 43, .97);
  color: #fff;
  font-size: 12px; line-height: 1.45; font-weight: 700;
  box-shadow: var(--e3);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px) scale(.98);
  transition: opacity var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.tooltip.is-visible { opacity: 1; transform: none; }
.tooltip b {
  display: block; font-weight: 500;
  color: rgba(255, 255, 255, .9); margin-top: 3px;
}
.tooltip u {
  display: block; text-decoration: none;
  font-weight: 500; font-size: 11px;
  color: rgba(255, 255, 255, .62); margin-top: 3px;
}
.tooltip::after {
  content: ''; position: absolute;
  left: 50%; bottom: -4px;
  width: 9px; height: 9px; margin-left: -4.5px;
  background: inherit; transform: rotate(45deg); border-radius: 2px;
}
.tooltip.is-below::after { bottom: auto; top: -4px; }

[data-tip] { cursor: default; }

/* Le corps ne défile plus quand le panneau latéral est ouvert. */
body.is-locked { overflow: hidden; }

/* ============================================================
   11. ANNUAIRE DES AUTOMATISATIONS
   ============================================================ */
.cat-toolbar { display: flex; flex-direction: column; gap: var(--s4); }
.cat-intro .panel-meta { margin-top: 3px; max-width: 72ch; }

.cat-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.cat-filters .search { flex: 2 1 320px; min-width: 260px; }
.cat-filters select {
  appearance: none; -webkit-appearance: none;
  padding: 9px 30px 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%236E7689'/></svg>")
    no-repeat right 11px center;
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  box-shadow: var(--e1); cursor: pointer; max-width: 190px;
  text-overflow: ellipsis;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.cat-filters select:hover { border-color: var(--line-strong); }
.cat-filters select:focus {
  border-color: var(--accent);
  box-shadow: var(--e1), 0 0 0 3px var(--accent-soft);
  outline: none;
}
.cat-filters select.has-value {
  border-color: var(--accent); background-color: var(--accent-mute); color: var(--accent-ink);
}

.kpi-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Formule du taux : posée à plat plutôt que décrite en prose. */
.formula {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3);
  background: var(--surface-alt);
  border-radius: var(--r-sm);
  padding: var(--s4);
}
.formula-part { font-size: 12.5px; color: var(--ink-faint); font-weight: 600; }
.formula-part b { display: block; font-size: 17px; color: var(--ink); font-weight: 800; }
.formula-op { font-size: 15px; color: var(--ink-ghost); font-weight: 700; }
.formula-result {
  margin-left: auto;
  font-size: 22px; font-weight: 800; color: var(--accent-ink);
  letter-spacing: -.02em;
}
.formula-note { font-size: 12.5px; color: var(--ink-faint); margin-top: var(--s3); }

/* Cartes du catalogue */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--s3);
}
.cat-card {
  display: flex; flex-direction: column; gap: 9px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: var(--s4);
  cursor: pointer;
  transition: border-color var(--t-base) var(--ease),
              box-shadow var(--t-base) var(--ease),
              transform var(--t-base) var(--ease);
}
.cat-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--e2);
  transform: translateY(-2px);
}

.cat-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.cat-entity {
  font-size: 10.5px; font-weight: 800; letter-spacing: .05em;
  text-transform: uppercase; color: var(--accent-ink);
  background: var(--accent-soft);
  padding: 3px 9px; border-radius: var(--r-pill);
}
.cat-flag {
  font-size: 10.5px; font-weight: 800;
  color: var(--ok-deep); background: var(--ok-soft);
  padding: 3px 9px; border-radius: var(--r-pill);
}

.cat-title {
  font-size: 14px; font-weight: 700; line-height: 1.35;
  display: -webkit-box; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 2.7em;
}
.cat-desc {
  font-size: 12px; color: var(--ink-faint); line-height: 1.5;
  display: -webkit-box; -webkit-box-orient: vertical;
  overflow: hidden;
}

.cat-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag-soft {
  font-size: 10.5px; font-weight: 700;
  color: var(--ink-soft); background: var(--surface-alt);
  padding: 3px 9px; border-radius: var(--r-pill);
}

.cat-foot {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s3); margin-top: auto;
  padding-top: var(--s3); border-top: 1px solid var(--line-soft);
}
.cat-metric { display: flex; flex-direction: column; }
.cat-metric-right { text-align: right; }
.cat-metric em { font-size: 10.5px; color: var(--ink-faint); font-style: normal; font-weight: 600; }
.cat-gain { font-size: 17px; font-weight: 800; color: var(--ok-deep); letter-spacing: -.02em; }
.cat-gain.is-empty { color: var(--ink-ghost); }
.cat-date { font-size: 13px; font-weight: 700; }

/* Appel à l'affichage du logigramme : le schéma n'est chargé que si
   l'utilisateur le demande, ce qui garde la fiche courte et légère. */
.logi-ask {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s4); flex-wrap: wrap;
  background: var(--accent-mute);
  border: 1px solid var(--accent-soft);
  border-radius: var(--r-sm);
  padding: var(--s3) var(--s4);
}
.logi-ask-title { font-size: 13px; font-weight: 700; color: var(--accent-ink); }
.logi-ask-note {
  font-size: 11.5px; color: var(--ink-faint); font-weight: 600;
  margin-top: 2px; word-break: break-all;
}

/* Boutons de lot du catalogue */
.cat-more {
  display: flex; align-items: center; justify-content: center;
  gap: var(--s3); flex-wrap: wrap;
  padding-top: var(--s4); margin-top: var(--s4);
  border-top: 1px solid var(--line-soft);
}
.cat-more-note { font-size: 12.5px; color: var(--ink-faint); font-weight: 600; }

/* Fiche du catalogue : panneau resserré, sans la largeur nécessaire
   au déroulé d'un projet. */
.detail.is-compact { width: min(620px, 94vw); }
.detail.is-compact .detail-head { padding: var(--s5) var(--s5) var(--s3); }
.detail.is-compact .detail-head h2 { font-size: 17px; }
.detail.is-compact .detail-body { padding: var(--s4) var(--s5) var(--s7); }
.detail.is-compact .detail-section { margin: var(--s5) 0 var(--s3); font-size: 13px; }
.detail.is-compact .detail-section:first-child { margin-top: 0; }
.detail.is-compact .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.detail.is-compact .detail-grid > div { padding: 8px 10px; }
.detail.is-compact .detail-grid dd { font-size: 12.5px; }
.detail.is-compact .detail-comment { padding: var(--s3); font-size: 12.5px; line-height: 1.55; }
.detail.is-compact .stat { padding: 10px 12px; }
.detail.is-compact .stat-value { font-size: 17px; }

/* Visionneuse plein écran */
.logi-viewer {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(23, 27, 38, .93);
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-base) var(--ease);
}
.logi-viewer.is-open { opacity: 1; pointer-events: auto; }
.logi-bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding: var(--s3) var(--s5);
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.logi-name { color: #fff; font-size: 13.5px; font-weight: 700; }
.logi-actions { display: flex; align-items: center; gap: var(--s2); }
.logi-stage {
  flex: 1; overflow: auto; padding: var(--s5);
  display: flex; align-items: flex-start; justify-content: center;
}
.logi-stage img {
  max-width: 100%; height: auto;
  background: #fff; border-radius: var(--r-sm);
  box-shadow: var(--e4);
}

/* ============================================================
   12. CONNEXION ET SESSION
   ============================================================ */
.login {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  padding: var(--s7) var(--s5);
}
.login-box {
  max-width: 420px; width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--e3), var(--sheen);
  padding: var(--s8) var(--s7) var(--s6);
  text-align: center;
  animation: rise var(--t-slow) var(--ease-out) both;
}
.login-box h1 { font-size: 20px; margin-bottom: var(--s2); }
.login-lead {
  color: var(--ink-faint); font-size: 13px;
  margin: 0 auto var(--s6); max-width: 34ch;
}

.field { display: block; text-align: left; margin-bottom: var(--s3); }
.field-label {
  display: block;
  font-size: 11px; font-weight: 800; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 5px;
}
.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--e1);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.field input::placeholder { color: var(--ink-ghost); }
.field input:hover { border-color: var(--line-strong); }
.field input:focus {
  border-color: var(--accent); outline: none;
  box-shadow: var(--e1), 0 0 0 3px var(--accent-soft);
}

.login-submit { width: 100%; margin-top: var(--s3); padding: 11px; }

.login-error {
  background: var(--late-soft); color: var(--late-deep);
  border-radius: var(--r-sm);
  padding: 9px 12px; margin-top: var(--s2);
  font-size: 12.5px; font-weight: 600; text-align: left;
  animation: chipIn var(--t-base) var(--ease-out) both;
}

.login-note {
  margin-top: var(--s5); padding-top: var(--s4);
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px; color: var(--ink-faint); line-height: 1.55;
}

/* Connexion Microsoft */
.sso { margin-bottom: var(--s5); }
.sso-btn {
  width: 100%; justify-content: center; gap: 10px;
  padding: 11px; font-size: 13.5px; font-weight: 700;
  border-color: var(--line-strong);
}
.sso-btn:disabled { opacity: .6; cursor: progress; }
.sso-logo { width: 17px; height: 17px; flex: none; }
.sso-hint {
  font-size: 11.5px; color: var(--ink-faint);
  margin-top: var(--s2); text-align: center;
}
.sso-sep {
  position: relative; text-align: center;
  margin: var(--s5) 0 var(--s2);
}
.sso-sep::before {
  content: ''; position: absolute; left: 0; right: 0; top: 50%;
  height: 1px; background: var(--line-soft);
}
.sso-sep span {
  position: relative; background: var(--surface);
  padding: 0 var(--s3);
  font-size: 11px; font-weight: 700; color: var(--ink-ghost);
  text-transform: uppercase; letter-spacing: .05em;
}

.foot-source { margin-top: 4px; }
.foot-source strong { color: var(--ink-soft); font-weight: 700; }
.foot-source .link-btn { font-size: 12px; margin-left: 6px; }

/* Message transitoire, en bas d'écran */
.toast {
  position: fixed; left: 50%; bottom: var(--s6); z-index: 90;
  transform: translate(-50%, 12px);
  max-width: min(520px, 92vw);
  padding: 12px 18px;
  border-radius: var(--r-sm);
  background: var(--ink); color: #fff;
  font-size: 13px; font-weight: 600;
  box-shadow: var(--e3);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast-succes  { background: var(--ok-deep); }
.toast-erreur  { background: var(--late-deep); }
.toast-attente { background: var(--ink-soft); }

.foot-alerte { color: var(--late-deep); font-weight: 700; }

/* Bandeau de session dans l'en-tête */
.session {
  display: flex; align-items: center; gap: var(--s2);
  padding-right: var(--s3);
  border-right: 1px solid var(--line);
}
.session-avatar {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 10.5px; font-weight: 800;
}
.session-text { display: flex; flex-direction: column; line-height: 1.25; }
.session-name { font-size: 12.5px; font-weight: 700; }
.session-scope { font-size: 11px; color: var(--ink-faint); font-weight: 600; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* --- Laptop --- */
@media (max-width: 1240px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .masthead-inner, .tabs, .filterbar-inner, .view, .foot {
    padding-left: var(--s5); padding-right: var(--s5);
  }
}

/* --- Tablette --- */
@media (max-width: 960px) {
  :root { --header-h: 108px; }
  .grid-2, .scope-charts, .client-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .workspace { grid-template-columns: minmax(0, 1fr); }
  .workspace-side { position: static; max-height: none; }
  /* La liste des personnes devient une rangée défilante. */
  .person-list {
    flex-direction: row; overflow-x: auto; gap: var(--s2);
    padding-bottom: var(--s2);
    scroll-snap-type: x proximity;
  }
  .person-list li { flex: 0 0 auto; scroll-snap-align: start; }
  .person { width: auto; min-width: 172px; }
}

/* --- Mobile --- */
@media (max-width: 720px) {
  :root { --header-h: 100px; --gap: 14px; --tl-label: 0px; }

  .masthead-inner { padding: var(--s3) var(--s4) var(--s2); }
  .tabs { padding: 0 var(--s4); overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .filterbar-inner, .view, .foot { padding-left: var(--s4); padding-right: var(--s4); }
  .view { padding-top: var(--s5); }

  .brand h1 { font-size: 14.5px; }
  .brand p { display: none; }
  .masthead-right .team { display: none; }
  .session-text { display: none; }
  .session { padding-right: var(--s2); }
  .login-box { padding: var(--s6) var(--s5) var(--s5); }
  .logos { padding-left: 0; border-left: 0; }
  .logo { height: 22px; max-width: 74px; }

  .kpi-grid, .kpi-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .cat-filters select { max-width: none; flex: 1 1 140px; }
  .logi-stage { padding: var(--s3); }
  .kpi { padding: var(--s3) var(--s3) var(--s3) var(--s4); }
  .kpi-value { font-size: 24px; }
  .kpi-note { display: none; }

  .panel { padding: var(--s4); border-radius: var(--r-sm); }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .detail, .detail.is-compact { width: 100vw; }
  .detail.is-compact .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .detail-head, .detail-body { padding-left: var(--s4); padding-right: var(--s4); }
  .detail-head h2 { font-size: 18px; }

  .bar-row { grid-template-columns: 96px 1fr 40px; gap: var(--s2); }
  .rel-row { grid-template-columns: 96px 1fr 42px; gap: var(--s2); }

  /* Le tableau se replie en cartes : plus de défilement horizontal. */
  .table-wrap { overflow: visible; margin: 0; padding: 0; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tbody tr {
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--r-sm);
    padding: var(--s3);
    margin-bottom: var(--s2);
    box-shadow: var(--e1);
  }
  .table td {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--s3);
    padding: 5px 0; border: 0;
    text-align: right;
  }
  .table td::before {
    content: attr(data-label);
    font-size: 10.5px; font-weight: 800; color: var(--ink-faint);
    text-transform: uppercase; letter-spacing: .05em;
    text-align: left; flex: none;
  }
  .table td.cell-name {
    display: block; text-align: left;
    padding-bottom: var(--s3); margin-bottom: var(--s2);
    border-bottom: 1px solid var(--line-soft);
  }
  .table td.cell-name::before { display: none; }
  .cell-name strong { max-width: none; white-space: normal; }

  /* Sur mobile, la date passe sous la barre : quatre colonnes ne
     tiennent pas dans 390 px sans tout comprimer. */
  .tl-line { grid-template-columns: 52px 1fr; row-gap: 2px; }
  .tl-line > .tl-tag   { grid-column: 1; }
  .tl-line > .tl-track { grid-column: 2; }
  .tl-line > .tl-date  { grid-column: 2; padding-left: 0; }
  .tl-overlay { left: 52px; right: 0; }
  .tl-axis { margin-left: 52px; margin-right: 0; }
  .tl-tag { font-size: 9.5px; }
  .tl-date { font-size: 10.5px; }
  .timeline { padding: var(--s4) var(--s3) var(--s2); }

  .p-line { flex-wrap: wrap; gap: var(--s2); }
  .stat-row { grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); }
}

/* --- Petits mobiles --- */
@media (max-width: 400px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
}

/* --- Mouvement réduit --- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* --- Impression --- */
@media print {
  .masthead, .filterbar, .foot, .overlay, .detail, .tooltip { display: none !important; }
  .view { padding: 0; }
  .panel { box-shadow: none; border-color: #DDD; break-inside: avoid; }
}

/* SSO — bouton et séparateur de la page de connexion. La règle reste
   discrète : si le bouton est masqué (hidden), rien ne s'affiche. */
.login-sep {
  display: flex; align-items: center; gap: var(--s2);
  margin: var(--s3) 0; color: var(--ink-soft, #888);
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em;
}
.login-sep::before, .login-sep::after {
  content: ""; flex: 1; height: 1px; background: var(--line, #ddd);
}
.btn-sso { width: 100%; padding: 11px; }
