:root {
  color-scheme: light;
  --plan: #f9f9f7;
  --surface: #fcfcfb;
  --encre: #0b0b0b;
  --encre-2: #52514e;
  --discret: #6f6d68;
  --grille: #e1e0d9;
  --axe: #c3c2b7;
  --bordure: rgba(11, 11, 11, 0.1);
  --serie-1: #2a78d6;
  --serie-2: #eb6834;
  --succes: #006300;
  --critique: #d03b3b;
  --attention: #8a5a00;
  --survol: rgba(11, 11, 11, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --plan: #0d0d0d;
    --surface: #1a1a19;
    --encre: #f0efec;
    --encre-2: #c3c2b7;
    --discret: #9a9892;
    --grille: #2c2c2a;
    --axe: #383835;
    --bordure: rgba(255, 255, 255, 0.1);
    --serie-1: #3987e5;
    --serie-2: #d95926;
    --succes: #0ca30c;
    --critique: #e66767;
    --attention: #fab219;
    --survol: rgba(255, 255, 255, 0.07);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--plan);
  color: var(--encre);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

[hidden] { display: none !important; }

h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 14px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 20px 0 8px; color: var(--encre-2); }

input, select, button { font: inherit; color: inherit; }

input, select {
  background: var(--surface);
  border: 1px solid var(--axe);
  border-radius: 6px;
  padding: 6px 8px;
}

input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible, svg:focus-visible {
  outline: 2px solid var(--serie-1);
  outline-offset: 1px;
}

button { cursor: pointer; border-radius: 6px; padding: 6px 12px; border: 1px solid transparent; background: none; }
button:disabled { opacity: 0.55; cursor: default; }
.principal { background: var(--encre); color: var(--surface); font-weight: 600; }
.discret { border-color: var(--bordure); color: var(--encre-2); }
.discret:hover { background: var(--survol); }

.lien {
  padding: 0;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--axe);
  text-underline-offset: 2px;
  text-align: left;
}

.carte {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  min-width: 0;
}

.connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.connexion form { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; margin: 0; }
.connexion label { display: flex; flex-direction: column; gap: 4px; }

.erreur { color: var(--critique); margin: 0; min-height: 1em; }
.erreur:empty { display: none; }
.note { color: var(--encre-2); margin: 8px 0 0; font-size: 13px; }

.entete {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--bordure);
  flex-wrap: wrap;
}
.marque { font-size: 15px; }
.onglets { display: flex; gap: 4px; flex: 1; }
.onglet { color: var(--encre-2); }
.onglet:hover { background: var(--survol); }
.onglet[aria-pressed="true"] { background: var(--survol); color: var(--encre); font-weight: 600; }

.contenu { max-width: 1180px; margin: 0 auto; padding: 16px; }

.filtres { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.filtres label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--encre-2); }
.filtres select { font-size: 14px; color: var(--encre); min-width: 180px; }
.filtre-multi { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--encre-2); }
.multi { position: relative; }
.multi summary {
  list-style: none; cursor: pointer; position: relative;
  font-size: 14px; color: var(--encre); background: var(--surface);
  border: 1px solid var(--axe); border-radius: 6px; padding: 6px 28px 6px 8px;
  min-width: 180px; max-width: min(340px, calc(100vw - 32px));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.multi summary::-webkit-details-marker { display: none; }
.multi summary::after {
  content: ''; position: absolute; right: 11px; top: 50%; width: 6px; height: 6px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-70%) rotate(45deg);
}
.multi[open] summary::after { transform: translateY(-25%) rotate(225deg); }
.multi-liste {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 100%;
  max-width: calc(100vw - 32px); max-height: 60vh; overflow: auto;
  margin: 0; padding: 4px; background: var(--surface);
  border: 1px solid var(--bordure); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}
/* .filtres .multi-option : l'emporte sur « .filtres label » (étiquette en colonne). */
.filtres .multi-option {
  display: flex; flex-direction: row; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px;
  font-size: 14px; color: var(--encre); cursor: pointer; white-space: nowrap;
}
.filtres .multi-option:hover { background: var(--survol); }
.filtres .multi-option:first-child { border-bottom: 1px solid var(--bordure); border-radius: 6px 6px 0 0; margin-bottom: 2px; }
.filtres .multi-option input { margin: 0; width: 16px; height: 16px; accent-color: var(--serie-1); }
.visuel-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#donnees { transition: opacity 120ms; }
#donnees.charge { opacity: 0.55; }

.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 12px; }
.tuile { background: var(--surface); border: 1px solid var(--bordure); border-radius: 10px; padding: 12px 14px; }
.tuile .libelle { color: var(--encre-2); font-size: 13px; }
.tuile .valeur { font-size: 26px; font-weight: 600; line-height: 1.25; }
.tuile .ecart { font-size: 12px; color: var(--discret); }
.ecart.hausse { color: var(--succes); }
.ecart.baisse { color: var(--critique); }

.bande { color: var(--encre-2); margin: 0 0 16px; }
.bande b { color: var(--encre); font-weight: 600; }

.titre-carte { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.legende { display: flex; gap: 14px; list-style: none; margin: 0 0 8px; padding: 0; color: var(--encre-2); font-size: 13px; }
.legende li { display: flex; align-items: center; gap: 6px; }
.pastille { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.pastille.appels { background: var(--serie-1); }
.pastille.formulaires { background: var(--serie-2); }

.graphique { position: relative; }
.graphique svg { display: block; width: 100%; height: 240px; border-radius: 4px; }
.graphique .grille-h { stroke: var(--grille); stroke-width: 1; }
.graphique .base { stroke: var(--axe); stroke-width: 1; }
.graphique text { fill: var(--discret); font-size: 11px; font-variant-numeric: tabular-nums; }
.graphique .m-appels { fill: var(--serie-1); }
.graphique .m-formulaires { fill: var(--serie-2); }
.graphique .colonne.actif path { filter: brightness(1.12); }
.graphique .cible { fill: transparent; }
.graphique .colonne.actif .cible { fill: var(--survol); }

.infobulle {
  position: absolute;
  top: 0;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  font-size: 13px;
  min-width: 130px;
  z-index: 2;
}
.infobulle .quand { color: var(--encre-2); margin-bottom: 4px; }
.infobulle .rang { display: flex; align-items: center; gap: 6px; }
.infobulle .rang b { font-variant-numeric: tabular-nums; min-width: 24px; }
.infobulle .rang span { color: var(--encre-2); }
.infobulle .trait { width: 12px; height: 2px; border-radius: 1px; }

.tableau-donnees { margin-top: 10px; color: var(--encre-2); }
.tableau-donnees summary { cursor: pointer; font-size: 13px; }

.deux { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; }

.barre-rang { display: grid; grid-template-columns: minmax(90px, 34%) 1fr; align-items: center; gap: 10px; padding: 4px 0; }
.barre-rang .nom { overflow-wrap: anywhere; }
.barre-rang .famille { display: block; font-size: 11px; color: var(--encre-2); }
.familles { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.familles li { font-size: 12px; color: var(--encre-2); border: 1px solid var(--bordure); border-radius: 999px; padding: 3px 9px; }
.familles b { color: var(--encre); font-weight: 600; font-variant-numeric: tabular-nums; }
.barre-rail { display: flex; align-items: center; gap: 6px; min-width: 0; }
.barre { height: 12px; background: var(--serie-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.barre-rail b { font-weight: 600; font-variant-numeric: tabular-nums; }

.defile { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th {
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--encre-2);
  padding: 6px 10px 6px 0;
  border-bottom: 1px solid var(--axe);
  white-space: nowrap;
}
td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--grille); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.sous { color: var(--encre-2); font-size: 12px; }
.detail-texte { max-width: 300px; overflow-wrap: anywhere; }

.etat { white-space: nowrap; }
.etat.repondu, .etat.recu { color: var(--succes); }
.etat.manque { color: var(--critique); }
.etat.en_cours { color: var(--attention); }

.vide { color: var(--encre-2); padding: 12px 0; margin: 0; }

.pile { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.pile label, .grille-form label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--encre-2); }
.pile input, .grille-form input, .grille-form select { color: var(--encre); font-size: 14px; }
.pile button { align-self: flex-start; }

.grille-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 10px; align-items: end; }
.grille-form .case { flex-direction: row; align-items: center; gap: 6px; }

.code { display: flex; gap: 8px; align-items: flex-start; }
.code pre {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 10px;
  background: var(--plan);
  border: 1px solid var(--bordure);
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12.5px;
}
code { font-size: 12.5px; }

.moi { color: var(--encre-2); font-size: 13px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.actions .lien { white-space: nowrap; }
.resultat { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--bordure); }
.resultat p:first-child { margin-top: 0; }
.avis { margin: 0 0 16px; padding: 10px 12px; border: 1px solid var(--bordure); border-radius: 8px; background: var(--surface); color: var(--attention); }
.connexion .note { margin: 0; }
.erreur a { color: inherit; }

/* Filtres : type de lead (segments), provenance, source */
.filtre-type { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--encre-2); }
.segments { display: inline-flex; border: 1px solid var(--axe); border-radius: 6px; overflow: hidden; background: var(--surface); }
.segments button { border: 0; border-radius: 0; padding: 6px 12px; font-size: 14px; color: var(--encre-2); background: transparent; }
.segments button + button { border-left: 1px solid var(--axe); }
.segments button[aria-pressed="true"] { background: var(--encre); color: var(--surface); font-weight: 600; }
#filtres-effacer { align-self: flex-end; }
.familles button { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.familles li:has(button[aria-pressed="true"]) { border-color: var(--encre); color: var(--encre); background: var(--survol); }
.barre-rang .nom .lien { text-align: left; }

/* Derniers leads : chaque ligne ouvre sa fiche */
tr.lead { cursor: pointer; }
tr.lead:hover td { background: var(--survol); }
.ouvrir-lead { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.ouvrir-lead > div:first-child { text-decoration: underline; text-decoration-color: var(--axe); text-underline-offset: 3px; }

/* Fiche d'un lead */
.fiche {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); margin: auto; padding: 0;
  border: 1px solid var(--bordure); border-radius: 12px; background: var(--surface); color: var(--encre);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}
.fiche::backdrop { background: rgba(11, 11, 11, 0.45); }
.fiche-tete {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 16px 20px 12px; background: var(--surface); border-bottom: 1px solid var(--bordure);
}
.fiche-tete h2 { margin: 0; font-size: 17px; }
.fiche-tete .sous { margin: 2px 0 0; }
#fiche-contenu { padding: 4px 20px 20px; }
.fiche-bloc { padding: 14px 0; border-bottom: 1px solid var(--bordure); }
.fiche-bloc:last-child { border-bottom: 0; }
.fiche-bloc h3 { margin: 0 0 8px; font-size: 13px; color: var(--encre-2); text-transform: none; }
.infos { display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.infos dt { color: var(--encre-2); }
.infos dd { margin: 0; overflow-wrap: anywhere; }
.message { white-space: pre-wrap; margin: 10px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--survol); font-size: 14px; }
.champs { margin-top: 10px; font-size: 14px; }
.champs summary { cursor: pointer; color: var(--encre-2); }
.champs .infos, .champs .liste-fiche { margin-top: 8px; }
.liste-fiche { margin: 0; padding-left: 18px; font-size: 14px; }
.liste-fiche li { margin: 3px 0; }
.fiche audio { width: 100%; margin-top: 10px; }
.fiche a { color: var(--serie-1); }
.bouton-analytics { font-weight: 600; border-color: var(--axe); }
.bouton-analytics[aria-expanded="true"] { background: var(--encre); color: var(--surface); }
.fiche-ga4 { margin-top: 12px; }
@media (max-width: 520px) {
  .infos { grid-template-columns: 1fr; gap: 0 0; }
  .infos dd { margin-bottom: 8px; }
}

