:root {
  color-scheme: light;
  /* Charte Artyseo : noir, blanc, jaune-orange. Le jaune est un ACCENT,
     jamais une couleur de texte sur fond clair (contraste insuffisant). */
  --plane:        #ffffff;
  --surface:      #ffffff;
  --surface-2:    #f4f4f2;
  --ink:          #1d1d1b;
  --ink-2:        #55554f;
  --muted:        #9a9a9a;
  --grid:         #e8e8e5;
  --rule:         #dcdcd8;
  --ring:         rgba(29,29,27,0.12);
  --brand:        #fdb913;   /* jaune Artyseo : aplats, jauges, etats actifs */
  --brand-deep:   #f59e0b;   /* jaune fonce : bordures, survol */
  --brand-ink:    #8a5a00;   /* accent LISIBLE en texte sur fond clair */
  --on-brand:     #1d1d1b;   /* texte pose sur un aplat jaune */
  --brand-soft:   #fff5da;
  --data:         #9a9a9a;   /* serie unique : neutre graphiques de la charte */

  /* Palette categorielle (pages de reporting web uniquement, cf. CLAUDE.md).
     La charte artyseo-brand impose le gris pour une serie unique et reserve le
     jaune aux jauges : cette regle reste en vigueur pour les livrables Google
     Docs. Ici, une repartition par source compte 5 a 12 categories que le gris
     seul ne sait pas distinguer, d'ou cette echelle ancree sur un jaune franc.
     Teintes espacees en luminosite autant qu'en teinte, pour rester lisibles
     en vision dichromate. */
  --cat-1:        #f5a300;   /* jaune Artyseo pousse, categorie dominante */
  --cat-2:        #2f6fb0;
  --cat-3:        #1f7a45;
  --cat-4:        #c0392b;
  --cat-5:        #7a4fbf;
  --cat-6:        #0f9a9a;
  --cat-7:        #e2701e;
  --cat-8:        #b8336a;
  --cat-9:        #5c6b7a;
  --cat-10:       #8a8a82;
  --data-soft:    #ececea;
  --seg-a:        #ffd873;   /* acomptes  - pas clair du degrade jaune */
  --seg-b:        #f59e0b;   /* factures  - pas fonce du degrade jaune */
  --good:         #1f7a45;
  --info:         #2f6fb0;
  --warn:         #b47407;
  --crit:         #c0392b;
  --shadow:       0 1px 2px rgba(29,29,27,.05), 0 8px 24px -18px rgba(29,29,27,.30);

  /* Largeur utile. Pas 100% : au-dela de ~1600 px le tableau de detail et les
     paragraphes s'etirent en lignes trop longues pour etre lues d'un trait.
     Sur un ecran courant (<= 1600 px) la page occupe donc toute la largeur. */
  --page:         1600px;
  /* Rythme vertical entre blocs de contenu. Un seul endroit pour l'ajuster. */
  --stack:        38px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane:      #121211;
    --surface:    #1a1a18;
    --surface-2:  #232320;
    --ink:        #f5f5f2;
    --ink-2:      #b5b5ae;
    --muted:      #8d8d87;
    --grid:       #2d2d29;
    --rule:       #3a3a35;
    --ring:       rgba(245,245,242,0.14);
    --brand:      #fdb913;
    --brand-deep: #ffd873;
    --brand-ink:  #fdb913;
    --on-brand:   #1d1d1b;
    --brand-soft: #33280c;
    --data:       #9a9a9a;
    --data-soft:  #2d2d29;
    /* Memes teintes eclaircies : sur fond sombre les versions claires perdent
       trop de contraste avec le fond des panneaux. */
    --cat-1:      #ffc233;
    --cat-2:      #5b9ede;
    --cat-3:      #45c07d;
    --cat-4:      #e8695b;
    --cat-5:      #a684e0;
    --cat-6:      #35c9c9;
    --cat-7:      #f59247;
    --cat-8:      #e0699a;
    --cat-9:      #94a5b5;
    --cat-10:     #b0b0a8;
    --seg-a:      #ffe3a3;
    --seg-b:      #fdb913;
    --good:       #35a86a;
    --info:       #5b9ede;
    --warn:       #e0a013;
    --crit:       #e06a5c;
    --shadow:     0 1px 2px rgba(0,0,0,.45), 0 10px 28px -20px rgba(0,0,0,.9);
  }
}
:root[data-theme="dark"] {
    color-scheme: dark;
  --plane:      #121211;
  --surface:    #1a1a18;
  --surface-2:  #232320;
  --ink:        #f5f5f2;
  --ink-2:      #b5b5ae;
  --muted:      #8d8d87;
  --grid:       #2d2d29;
  --rule:       #3a3a35;
  --ring:       rgba(245,245,242,0.14);
  --brand:      #fdb913;
  --brand-deep: #ffd873;
  --brand-ink:  #fdb913;
  --on-brand:   #1d1d1b;
  --brand-soft: #33280c;
  --data:       #9a9a9a;
  --data-soft:  #2d2d29;
  /* Memes teintes eclaircies que le bloc precedent : le theme force doit rendre
     exactement comme le theme systeme, sinon le basculement change les couleurs. */
  --cat-1:      #ffc233;
  --cat-2:      #5b9ede;
  --cat-3:      #45c07d;
  --cat-4:      #e8695b;
  --cat-5:      #a684e0;
  --cat-6:      #35c9c9;
  --cat-7:      #f59247;
  --cat-8:      #e0699a;
  --cat-9:      #94a5b5;
  --cat-10:     #b0b0a8;
  --seg-a:      #ffe3a3;
  --seg-b:      #fdb913;
  --good:       #35a86a;
  --info:       #5b9ede;
  --warn:       #e0a013;
  --crit:       #e06a5c;
  --shadow:     0 1px 2px rgba(0,0,0,.45), 0 10px 28px -20px rgba(0,0,0,.9);
}

* { box-sizing: border-box; }

/* L'attribut hidden ne pose que `display: none` via la feuille du navigateur :
   n'importe quelle regle auteur `display: flex` le neutralise en silence.
   Concerne ici #toolbar-inner, #custom-compare et #pager. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--page);
  margin: 0 auto;
  padding: 40px 24px 72px;
  display: flex;
  flex-direction: column;
  gap: var(--stack);
}

/* #content porte les tuiles et tous les panneaux. Sans regle ici, ses enfants
   se collaient bord a bord : la gouttiere de .wrap ne separe que l'en-tete,
   les bandeaux, ce bloc et le pied de page — pas ce qu'il contient. */
#content {
  display: flex;
  flex-direction: column;
  gap: var(--stack);
}

/* ---------- masthead ---------- */
.masthead { display: flex; flex-direction: column; gap: 10px; }
.eyebrow {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11.5px; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--brand-ink);
  display: flex; align-items: center; gap: 10px;
}
.eyebrow::after { content: ""; flex: 1; height: 1px; background: var(--rule); }
h1 {
  font-family: "Zilla Slab", Rockwell, Georgia, serif;
  font-weight: 700; font-size: clamp(30px, 5vw, 46px);
  line-height: 1.05; letter-spacing: -.015em;
  margin: 0; text-wrap: balance;
}
.lede { margin: 0; max-width: 68ch; color: var(--ink-2); font-size: 15.5px; }
.lede b { color: var(--ink); font-weight: 600; }

.note {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--brand);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 13.5px; color: var(--ink-2);
  display: flex; gap: 12px; align-items: flex-start;
}
.note span:last-child { max-width: 110ch; }
.note b { color: var(--ink); font-weight: 600; }
.note .n-key {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--brand-ink); flex: none; padding-top: 2px; white-space: nowrap;
}

/* ---------- kpi ---------- */
.kpis {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
}
/* Les six tuiles reprennent la ligne de statistiques Sellsy : elles se lisent
   comme une bande. Au-dela de 1000 px on fige six colonnes, sinon l'auto-fit
   laisse une tuile orpheline sur un second rang. */
@media (min-width: 1000px) {
  .kpis { grid-template-columns: repeat(6, 1fr); gap: 22px; }
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: 10px;
  padding: 18px 20px 20px;
  display: flex; flex-direction: column; gap: 5px;
  box-shadow: var(--shadow);
}
.kpi .k-label {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--muted);
}
.kpi .k-value {
  font-family: "Zilla Slab", Rockwell, Georgia, serif;
  font-weight: 600; font-size: 26px; line-height: 1.12;
  letter-spacing: -.01em;
}
.kpi .k-note { font-size: 12.5px; color: var(--ink-2); }
.kpi.accent { border-color: color-mix(in srgb, var(--brand) 40%, var(--ring)); }
.kpi.accent .k-value { color: var(--brand-ink); }

.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; display: flex; gap: 2px; margin-top: 7px; }
.meter i { display: block; height: 100%; border-radius: 3px; }

/* ---------- panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: 12px;
  padding: 20px 22px 22px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px;
  min-width: 0;
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.panel h2 {
  font-family: "Zilla Slab", Rockwell, Georgia, serif;
  font-size: 19px; font-weight: 600; margin: 0; letter-spacing: -.005em;
}
.panel .sub { margin: 3px 0 0; font-size: 13px; color: var(--muted); max-width: 58ch; }
.duo { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* ---------- toggle ---------- */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 3px; gap: 3px; }
.seg button {
  font: inherit; font-size: 12.5px; font-weight: 500;
  border: 0; background: transparent; color: var(--ink-2);
  padding: 5px 12px; border-radius: 6px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg button:focus-visible, .chip:focus-visible, th button:focus-visible, input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- svg chart ---------- */
.chart-scroll { overflow-x: auto; }
svg.col { width: 100%; min-width: 560px; height: auto; display: block; }
svg.col .gridline { stroke: var(--grid); stroke-width: 1; }
svg.col .baseline { stroke: var(--rule); stroke-width: 1; }
svg.col text { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 9.5px; fill: var(--muted); }
svg.col .wk { fill: var(--surface-2); }

/* ---------- h-bars ---------- */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row {
  display: grid; grid-template-columns: minmax(96px, 30%) 1fr auto;
  align-items: center; gap: 12px;
}
.bar-row .name { font-size: 13.5px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .name small { display: block; color: var(--muted); font-size: 11px; line-height: 1.2; }
.bars.roomy .bar-row { grid-template-columns: minmax(150px, 38%) 1fr auto; }
.bars.roomy .bar-row .name { white-space: normal; line-height: 1.25; }
.track { background: var(--surface-2); border-radius: 4px; height: 16px; position: relative; }
.fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--data); min-width: 3px; }
.bar-row .val {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--ink-2); white-space: nowrap;
}
.bar-row .val b { color: var(--ink); font-weight: 600; }

/* ---------- legend / stacks ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; box-shadow: 0 0 0 2px var(--surface); }
.split-note { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.split-note div { border-left: 2px solid var(--rule); padding-left: 11px; }
.split-note b { font-family: "Zilla Slab", Rockwell, Georgia, serif; font-size: 20px; font-weight: 600; display: block; }
.split-note em { font-style: normal; font-size: 12px; color: var(--muted); }

/* ---------- retards ---------- */
.rlist { display: flex; flex-direction: column; }
.rrow {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: baseline;
  padding: 9px 0; border-bottom: 1px solid var(--grid);
}
.rrow:last-child { border-bottom: 0; }
.rrow .who { font-size: 13.5px; }
.rrow .who small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.3; }
.rrow .amt {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums; font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.track.split { display: flex; gap: 2px; }
.track.split .fill { border-radius: 0; }
.track.split .fill:last-child { border-radius: 0 4px 4px 0; }

/* ---------- table ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  font: inherit; font-size: 12.5px; border: 1px solid var(--ring); background: var(--surface);
  color: var(--ink-2); border-radius: 999px; padding: 4px 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
}
.chip[aria-pressed="true"] { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 45%, transparent); color: var(--ink); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sep { width: 1px; height: 20px; background: var(--rule); margin: 0 2px; }
input[type="search"] {
  font: inherit; font-size: 13px; padding: 6px 11px; border-radius: 8px;
  border: 1px solid var(--ring); background: var(--surface-2); color: var(--ink);
  min-width: 180px; flex: 1 1 180px;
}
.table-scroll { overflow: auto; max-height: 460px; border: 1px solid var(--ring); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; min-width: 900px; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); text-align: left; white-space: nowrap;
  font-weight: 500; color: var(--ink-2);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  border-bottom: 1px solid var(--rule);
}
thead th button { all: unset; cursor: pointer; padding: 9px 12px; display: block; width: 100%; box-sizing: border-box; }
thead th.num button { text-align: right; }
tbody td { padding: 8px 12px; border-bottom: 1px solid var(--grid); vertical-align: middle; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }
td.ref { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 11.5px; color: var(--muted); white-space: nowrap; }
td.cli { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 11.5px; padding: 2px 9px 2px 7px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--ring); color: var(--ink-2);
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.type {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 4px; white-space: nowrap;
}
.type.f { background: color-mix(in srgb, var(--seg-b) 18%, transparent); color: var(--ink); }
.type.a { background: color-mix(in srgb, var(--seg-a) 24%, transparent); color: var(--ink); }
.count-note { font-size: 12.5px; color: var(--muted); }

/* ---------- tooltip ---------- */
#tip {
  position: fixed; pointer-events: none; opacity: 0; transform: translate(-50%, -100%);
  background: var(--ink); color: var(--surface); padding: 7px 10px; border-radius: 7px;
  font-size: 12px; line-height: 1.45; white-space: nowrap; z-index: 50;
  transition: opacity .1s; box-shadow: 0 6px 20px -8px rgba(0,0,0,.5);
}
#tip b { font-family: "IBM Plex Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }

footer { color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--rule); padding-top: 16px; max-width: 90ch; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (max-width: 560px) {
  .bar-row { grid-template-columns: 1fr auto; }
  .bar-row .track { grid-column: 1 / -1; }
  .note { flex-direction: column; gap: 6px; }
}

/* ==========================================================================
   Ajouts du portage : barre de periode, comparaison, etats, connexion.
   Les jetons de couleur sont ceux du prototype - aucune nouvelle teinte.
   ========================================================================== */

/* ---------------------------- page de connexion --------------------------- */
.login-body {
  background: var(--plane); color: var(--ink);
  display: grid; place-items: center; min-height: 100vh; padding: 24px;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  /* La carte n'est plus seule : la mention de copyright forme une seconde
     rangee, et le bloc doit rester centre verticalement. */
  align-content: center;
}
.login-card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 14px;
  box-shadow: var(--shadow); padding: 32px; width: min(420px, 100%);
}
.login-card h1 { font-family: "Zilla Slab", Rockwell, Georgia, serif; font-size: 26px; margin: 4px 0 8px; }
.login-card .lede { font-size: 14px; color: var(--ink-2); margin: 0 0 20px; }
.login-card label {
  display: block; font-family: "IBM Plex Mono", monospace; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 6px;
}
.login-card input {
  width: 100%; padding: 10px 12px; font: inherit; border-radius: 8px;
  border: 1px solid var(--rule); background: var(--surface-2); color: var(--ink);
}
.login-card button {
  margin-top: 16px; width: 100%; padding: 11px; font: inherit; font-weight: 600;
  border: 0; border-radius: 8px; background: var(--brand); color: var(--on-brand); cursor: pointer;
}
.login-card button:hover { filter: brightness(1.08); }
.login-error {
  background: var(--brand-soft); border-left: 3px solid var(--crit); color: var(--ink);
  padding: 10px 12px; border-radius: 6px; font-size: 13.5px; margin: 0 0 16px;
}

/* ------------------------------ barre de periode -------------------------- */
.toolbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--plane) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  margin: 0 0 24px; padding: 12px 0;
}
.toolbar-inner {
  max-width: var(--page); margin: 0 auto; padding: 0 24px;
  display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: flex-end;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span {
  font-family: "IBM Plex Mono", monospace; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted);
}
.field-row { display: flex; gap: 6px; align-items: center; }
.toolbar input[type="date"], .toolbar select {
  font: inherit; font-size: 13.5px; padding: 7px 9px; border-radius: 8px;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.toolbar .dash { color: var(--muted); font-size: 13px; }
.btn {
  font: inherit; font-size: 13.5px; font-weight: 600; padding: 8px 16px;
  border-radius: 8px; border: 1px solid var(--rule); background: var(--surface);
  color: var(--ink); cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand-deep); color: var(--on-brand); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: progress; }
.toolbar-meta {
  margin-left: auto; text-align: right;
  font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--muted);
  line-height: 1.5;
}
.toolbar-meta b { color: var(--ink-2); font-weight: 500; }
.toolbar-meta .stale { color: var(--warn); }

/* raccourcis de periode */
.shortcuts { display: flex; flex-wrap: wrap; gap: 6px; }
.shortcuts button {
  font-family: "IBM Plex Mono", monospace; font-size: 11px; padding: 5px 9px;
  border-radius: 999px; border: 1px solid var(--rule); background: var(--surface);
  color: var(--ink-2); cursor: pointer;
}
.shortcuts button:hover { background: var(--surface-2); color: var(--ink); }
.shortcuts button[aria-pressed="true"] {
  background: var(--brand-soft); border-color: var(--brand-deep); color: var(--brand-ink);
}

/* ------------------------------ bandeaux ---------------------------------- */
.banner {
  display: flex; gap: 12px; align-items: flex-start;
  border-radius: 10px; padding: 12px 14px; margin-bottom: 16px;
  font-size: 13.5px; line-height: 1.55; border: 1px solid var(--rule);
  background: var(--surface);
}
.banner .b-key {
  font-family: "IBM Plex Mono", monospace; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .1em; white-space: nowrap; padding-top: 2px;
}
.banner.error { border-left: 3px solid var(--crit); }
.banner.error .b-key { color: var(--crit); }
.banner.warn { border-left: 3px solid var(--warn); }
.banner.warn .b-key { color: var(--warn); }
.banner ul { margin: 4px 0 0; padding-left: 18px; }
.banner .btn { margin-left: auto; }

/* -------------------------- etats de chargement --------------------------- */
/* Les tuiles gardent leurs valeurs en attenuation : ne jamais vider l'ecran. */
.is-loading .fade { opacity: .45; transition: opacity .18s ease; }
.is-loading { cursor: progress; }

.empty {
  text-align: center; padding: 48px 24px; color: var(--ink-2);
  border: 1px dashed var(--rule); border-radius: 12px; background: var(--surface);
}
.empty h2 { font-family: "Zilla Slab", Rockwell, Georgia, serif; font-size: 20px; margin: 0 0 8px; }
.empty p { margin: 0; font-size: 14px; max-width: 52ch; margin-inline: auto; }
.empty code { font-family: "IBM Plex Mono", monospace; font-size: 13px; color: var(--ink); }

/* ------------------------------ comparaison ------------------------------- */
.k-delta {
  display: flex; align-items: baseline; gap: 6px; margin-top: 6px;
  font-family: "IBM Plex Mono", monospace; font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.k-delta .arrow { font-size: 12px; line-height: 1; }
.k-delta.up { color: var(--good); }
.k-delta.down { color: var(--crit); }
.k-delta.flat { color: var(--muted); }
.k-delta .abs { color: var(--muted); }

/* --------------------------- tableau : pagination ------------------------- */
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: 12px; font-family: "IBM Plex Mono", monospace; font-size: 11.5px;
  color: var(--muted);
}
.pager .btn { padding: 5px 12px; font-size: 12px; }
.pager-pages { display: flex; gap: 6px; align-items: center; }

/* --------------------------------- divers --------------------------------- */
:where(button, input, select, a):focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (max-width: 720px) {
  .toolbar-inner { padding: 0 16px; }
  .toolbar-meta { margin-left: 0; text-align: left; width: 100%; }
}

/* --------------------- barre d'outils : tablette et mobile ----------------
   Collante, elle est utile sur desktop ou elle tient sur une ligne. Sous
   900 px elle se replie sur plusieurs rangs : la garder collante lui ferait
   manger un tiers de l'ecran. Elle redevient donc un simple en-tete.
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .toolbar { position: static; backdrop-filter: none; padding: 10px 0 12px; }
  .toolbar-inner { gap: 10px 14px; }
  /* Les raccourcis defilent au lieu de pousser les autres controles au rang
     suivant : la barre reste sur deux rangs au lieu de cinq. */
  .shortcuts {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin;
    padding-bottom: 2px; -webkit-overflow-scrolling: touch;
  }
  .shortcuts button { flex: 0 0 auto; }
  .toolbar-inner > .field:nth-child(2) { flex: 1 1 220px; min-width: 0; }
  .toolbar-inner > .field:nth-child(3) { flex: 1 1 200px; min-width: 0; }
  .toolbar select { width: 100%; }
  .toolbar-meta { margin-left: 0; text-align: left; width: 100%; }
}

@media (max-width: 620px) {
  .toolbar-inner { padding: 0 16px; }
  /* Chaque controle prend toute la largeur : plus lisible que deux demi-colonnes. */
  .toolbar-inner > .field { flex: 1 1 100%; }
  .field-row { width: 100%; }
  .toolbar input[type="date"] { flex: 1 1 0; min-width: 0; }
  .toolbar select { width: 100%; }
  #refresh { width: 100%; }
  .pager { flex-direction: column; gap: 8px; align-items: stretch; text-align: center; }
}

/* --------------------------------- logo -----------------------------------
   Le logo porte le nom : quand il est present, on n'ecrit pas « Artyseo » a
   cote (regle de la charte). Si le fichier manque, le texte alternatif prend
   le relais - la page reste identifiable.
   -------------------------------------------------------------------------- */
.brand-logo {
  /* .masthead est un flex en colonne : sans align-self, l'image est etiree sur
     toute la largeur et le logo se deforme. */
  align-self: flex-start;
  height: 32px; width: auto; max-width: 100%; display: block;
  object-fit: contain;
  margin-bottom: 2px;
  font-family: "Zilla Slab", Rockwell, Georgia, serif;  /* rendu du alt si absent */
  font-size: 20px; font-weight: 700; color: var(--ink);
}
.login-card .brand-logo { height: 34px; margin-bottom: 18px; }

/* Sur fond sombre, le logo noir s'inverse en blanc. Jamais recolore en jaune. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo { filter: invert(1) brightness(1.7); }
}
:root[data-theme="dark"] .brand-logo { filter: invert(1) brightness(1.7); }

/* ====================== bandeau permanent + filtres repliables =============
   Le bandeau ne se replie jamais : il porte l'identite de la periode affichee
   et le bouton Actualiser. Replier les filtres ne doit pas faire perdre de vue
   CE QUI est affiche - c'est tout l'interet de la ligne de resume.
   ========================================================================== */
.toolbar-bar {
  max-width: var(--page); margin: 0 auto; padding: 0 24px 0;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.toolbar-bar + .toolbar-inner { padding-top: 14px; margin-top: 12px; border-top: 1px solid var(--rule); }

.btn.ghost {
  display: inline-flex; align-items: center; gap: 7px;
  background: transparent; border-color: transparent; color: var(--ink-2);
  padding: 7px 10px; font-weight: 500;
}
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.ghost svg { flex: none; }
.btn.ghost .chev { transition: transform .18s ease; margin-left: 1px; opacity: .75; }
#toggle-filters[aria-expanded="false"] .chev { transform: rotate(-90deg); }
#toggle-filters[aria-expanded="true"] { color: var(--ink); background: var(--surface-2); }

.toolbar-summary {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums;
  padding-left: 4px; border-left: 2px solid var(--brand); padding-block: 2px;
  line-height: 1.45;
}
.toolbar-summary b { color: var(--ink); font-weight: 500; }
.toolbar-summary em { font-style: normal; color: var(--muted); }
.toolbar-bar .toolbar-meta { margin-left: auto; }
.toolbar-bar #refresh { flex: none; }

@media (max-width: 900px) {
  .toolbar-bar { padding: 0 16px; gap: 8px; }
  .toolbar-bar .toolbar-meta { margin-left: 0; order: 9; width: 100%; }
  .toolbar-summary { order: 8; width: 100%; }
}
@media (max-width: 620px) {
  .toolbar-bar #refresh { flex: 1 1 auto; }
}

/* ---------------------------- sélecteur de thème --------------------------
   Trois états parce que la feuille de style en gère trois. « Système » est le
   défaut : ne rien poser laisse prefers-color-scheme décider.
   -------------------------------------------------------------------------- */
.theme-switch { padding: 2px; gap: 2px; flex: none; }
.theme-switch button {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px 9px; color: var(--muted);
}
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { color: var(--ink); }

/* ========================================================================== */
/* Navigation laterale                                                        */
/* ========================================================================== */

.shell { display: flex; align-items: flex-start; min-height: 100vh; }
.shell-main { flex: 1 1 auto; min-width: 0; }

.sidenav {
  flex: 0 0 auto;
  width: 236px;
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  padding: 14px 12px;
  gap: 18px;
  z-index: 30;
  transition: width .16s ease;
}
.shell[data-nav="collapsed"] .sidenav { width: 62px; }

.sidenav-head { display: flex; align-items: center; gap: 10px; padding: 2px 4px 0; }
.sidenav-mark {
  flex: none; width: 28px; height: 28px; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--brand); color: var(--on-brand);
  font-family: "Zilla Slab", Rockwell, Georgia, serif; font-weight: 700; font-size: 16px;
}
.sidenav-title {
  font-family: "Zilla Slab", Rockwell, Georgia, serif;
  font-size: 15.5px; font-weight: 600; white-space: nowrap; overflow: hidden;
}
.sidenav-toggle {
  margin-left: auto; flex: none;
  border: 1px solid var(--rule); background: var(--surface); color: var(--muted);
  border-radius: 8px; padding: 5px; cursor: pointer;
  display: inline-flex; transition: transform .16s ease, color .12s ease;
}
.sidenav-toggle:hover { color: var(--ink); }
.shell[data-nav="collapsed"] .sidenav-toggle { transform: rotate(180deg); }

.sidenav-nav { display: flex; flex-direction: column; gap: 3px; }
.sidenav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

.navlink {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 9px;
  color: var(--ink-2); text-decoration: none;
  font-size: 13.5px; line-height: 1.25;
  border: 1px solid transparent;
  white-space: nowrap;
}
.navlink svg { flex: none; }
.navlink:hover { background: var(--surface-2); color: var(--ink); }
.navlink[aria-current="page"] {
  background: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand) 42%, var(--ring));
  color: var(--ink); font-weight: 600;
}
.navlink.quiet { color: var(--muted); }
.navlink.quiet:hover { color: var(--ink); }

.sidenav-copy {
  margin: 0; padding: 0 10px 2px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px; letter-spacing: .06em; color: var(--muted);
  white-space: nowrap; overflow: hidden;
}

/* Replie : seules les icones restent. Les libelles sortent du flux plutot que
   d'etre masques par overflow, sinon ils elargissent la barre au survol. */
.shell[data-nav="collapsed"] .navlink-label,
.shell[data-nav="collapsed"] .sidenav-title,
.shell[data-nav="collapsed"] .sidenav-copy { display: none; }
.shell[data-nav="collapsed"] .navlink { justify-content: center; padding-inline: 8px; }
.shell[data-nav="collapsed"] .sidenav-head { flex-direction: column; gap: 12px; }
.shell[data-nav="collapsed"] .sidenav-toggle { margin-left: 0; }

.nav-scrim {
  position: fixed; inset: 0; z-index: 25;
  background: rgba(29,29,27,.42); border: 0; cursor: pointer;
}
.nav-open { display: none; }

@media (max-width: 900px) {
  /* La barre passe en tiroir : sur mobile elle mangerait sinon la moitie de
     l'ecran utile. */
  .sidenav {
    position: fixed; inset: 0 auto 0 0;
    width: 244px !important;
    transform: translateX(-100%);
    transition: transform .18s ease;
    box-shadow: 0 0 40px -10px rgba(0,0,0,.4);
  }
  .shell[data-drawer="open"] .sidenav { transform: none; }
  .shell[data-nav="collapsed"] .navlink-label,
  .shell[data-nav="collapsed"] .sidenav-title,
  .shell[data-nav="collapsed"] .sidenav-copy { display: revert; }
  .shell[data-nav="collapsed"] .navlink { justify-content: flex-start; padding-inline: 10px; }
  .shell[data-nav="collapsed"] .sidenav-head { flex-direction: row; }
  .nav-open { display: inline-flex; }
}

/* ========================================================================== */
/* Voile d'attente                                                            */
/* ========================================================================== */

.busy {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--plane) 62%, transparent);
  backdrop-filter: blur(2px);
}
.busy-card {
  background: var(--surface);
  border: 1px solid var(--ring);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 22px 28px 24px;
  text-align: center;
  min-width: 260px;
}
.busy-spin {
  display: block; width: 26px; height: 26px; margin: 0 auto 12px;
  border-radius: 50%;
  border: 3px solid var(--data-soft);
  border-top-color: var(--brand);
  animation: busy-turn .8s linear infinite;
}
@keyframes busy-turn { to { transform: rotate(360deg); } }
/* Respecte le reglage systeme : une animation permanente peut gener. */
@media (prefers-reduced-motion: reduce) {
  .busy-spin { animation-duration: 2.4s; }
}
.busy-title {
  margin: 0; font-family: "Zilla Slab", Rockwell, Georgia, serif;
  font-size: 17px; font-weight: 600;
}
.busy-msg { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }

/* ========================================================================== */
/* Page Leads                                                                 */
/* ========================================================================== */

.page[hidden] { display: none; }

.sub-head {
  margin: 22px 0 10px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--muted); font-weight: 500;
}
.panel > .sub-head:first-of-type { margin-top: 18px; }

.synthese { margin: 10px 0 0; font-size: 14px; line-height: 1.62; max-width: 78ch; }

/* Ecarts : le vert et le rouge portent le sens, la fleche le double pour qui ne
   distingue pas les deux couleurs. */
.k-trend, .trend {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.k-trend { margin-top: 2px; }
.k-trend.up, .trend.up { color: var(--good); }
.k-trend.down, .trend.down { color: var(--crit); }
.k-trend.flat, .trend.flat { color: var(--muted); }

/* Entonnoir compare : deux barres empilees dans la meme piste. */
.duo-track { height: 24px; display: flex; flex-direction: column; gap: 2px; padding: 2px 0; }
.duo-track .fill { height: 9px; }
.duo-bars .fill.ink { background: var(--ink); }
.duo-bars .fill.grey { background: var(--data); }
.bar-row .val .prev { color: var(--muted); font-weight: 400; }

.utm-block + .utm-block { margin-top: 6px; }

.field.inline { flex-direction: row; align-items: center; gap: 9px; }
.field.inline > span { padding-bottom: 0; }

.login-copy {
  margin: 14px 0 0; text-align: center;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10.5px; letter-spacing: .08em; color: var(--muted);
}

/* ========================================================================== */
/* Fenetre d'information, puces info                                          */
/* ========================================================================== */

.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px; }
.modal-scrim { position: absolute; inset: 0; background: rgba(29,29,27,.5); backdrop-filter: blur(2px); }
.modal-card {
  position: relative;
  background: var(--surface); border: 1px solid var(--ring); border-radius: 14px;
  box-shadow: var(--shadow); width: min(720px, 100%);
  max-height: min(82vh, 900px); display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 20px 12px; border-bottom: 1px solid var(--rule);
}
.modal-head h2 {
  margin: 0; font-family: "Zilla Slab", Rockwell, Georgia, serif;
  font-size: 19px; font-weight: 600;
}
.modal-x {
  flex: none; border: 1px solid var(--rule); background: var(--surface);
  color: var(--muted); border-radius: 8px; padding: 6px; cursor: pointer; display: inline-flex;
}
.modal-x:hover { color: var(--ink); }
.modal-body { padding: 16px 20px 22px; overflow-y: auto; font-size: 14px; line-height: 1.62; color: var(--ink-2); }
.modal-body p { margin: 0 0 10px; max-width: 72ch; }
.modal-body p:last-child { margin-bottom: 0; }
.modal-body b { color: var(--ink); font-weight: 600; }

.info-chip {
  align-self: flex-start; margin-top: 2px;
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 13px;
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--rule); border-left: 3px solid var(--brand);
  border-radius: 9px; padding: 7px 13px; cursor: pointer;
}
.info-chip:hover { color: var(--ink); border-color: var(--brand-deep); }

.info-dot {
  display: inline-grid; place-items: center; margin-left: 6px;
  width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid var(--rule); background: var(--surface);
  color: var(--muted); cursor: pointer;
  font-family: "Zilla Slab", Georgia, serif; font-size: 10.5px; font-weight: 700;
  line-height: 1; padding: 0;
}
.info-dot:hover { color: var(--ink); border-color: var(--brand-deep); }

/* ========================================================================== */
/* Cases a cocher des periodes                                                */
/* ========================================================================== */

.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--rule); border-radius: 8px;
  padding: 6px 11px; font-size: 13px; cursor: pointer;
  background: var(--surface); color: var(--ink-2);
}
.check:hover { border-color: var(--brand-deep); color: var(--ink); }
.check input { accent-color: var(--brand-deep); margin: 0; cursor: pointer; }
.check:has(input:checked) {
  background: var(--brand-soft);
  border-color: color-mix(in srgb, var(--brand) 45%, var(--ring));
  color: var(--ink); font-weight: 500;
}

/* ========================================================================== */
/* Graphiques categoriels                                                     */
/* ========================================================================== */

.chart-duo {
  display: grid; gap: 22px; align-items: center;
  grid-template-columns: minmax(190px, 260px) 1fr;
}
@media (max-width: 760px) { .chart-duo { grid-template-columns: 1fr; } }

.donut { width: 100%; height: auto; display: block; }
.donut path { cursor: pointer; transition: opacity .12s ease; }
.donut path:hover { opacity: .82; }
.donut-hole {
  font-family: "Zilla Slab", Rockwell, Georgia, serif;
  font-weight: 600; fill: var(--ink);
}
.donut-hole-sub {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  /* Pas de font-size ici : il est pose par leads.js selon la longueur du
     libelle. Une regle CSS l'emporterait sur l'attribut et figerait la taille. */
  letter-spacing: .08em; fill: var(--muted); text-transform: uppercase;
}

.cat-legend { display: flex; flex-direction: column; gap: 7px; }
.cat-legend .row {
  display: grid; grid-template-columns: 12px 1fr auto auto;
  align-items: center; gap: 10px; font-size: 13px; cursor: default;
  padding: 3px 6px; border-radius: 6px;
}
.cat-legend .row:hover { background: var(--surface-2); }
.cat-legend .sw { width: 12px; height: 12px; border-radius: 3px; }
.cat-legend .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-legend .qt, .cat-legend .pc {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums; font-size: 12.5px;
}
.cat-legend .qt { color: var(--ink); font-weight: 600; }
.cat-legend .pc { color: var(--muted); min-width: 52px; text-align: right; }

/* Entonnoir : trois etages, du plus large au plus etroit. */
.fun { display: flex; flex-direction: column; gap: 10px; }
.fun-row { display: grid; grid-template-columns: minmax(120px, 22%) 1fr auto; align-items: center; gap: 14px; }
.fun-name { font-size: 13.5px; }
.fun-track { background: var(--surface-2); border-radius: 6px; height: 30px; overflow: hidden; }
.fun-bar { height: 100%; border-radius: 0 6px 6px 0; min-width: 4px; transition: width .25s ease; cursor: pointer; }
.fun-val {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap;
}
.fun-val b { font-size: 15px; }
.fun-val .rate { color: var(--muted); }

.period-block + .period-block { margin-top: 34px; }

/* Liens vers Sellsy : discrets dans un tableau dense, mais reperables. */
.ext {
  color: inherit; text-decoration: none;
  border-bottom: 1px dotted color-mix(in srgb, var(--brand-deep) 60%, transparent);
}
.ext:hover { color: var(--brand-ink); border-bottom-style: solid; }
.ext:focus-visible { outline: 2px solid var(--brand-deep); outline-offset: 2px; border-radius: 2px; }

/* ========================================================================== */
/* Rendement des canaux                                                       */
/* ========================================================================== */

.chips-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip-n {
  margin-left: 7px; padding: 1px 6px; border-radius: 20px;
  background: var(--surface-2); color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 11px;
}
.chip[aria-pressed="true"] .chip-n { background: color-mix(in srgb, var(--ink) 12%, transparent); color: inherit; }

.chan { display: flex; flex-direction: column; gap: 11px; }
.chan-row { display: grid; grid-template-columns: minmax(120px, 20%) 1fr auto; align-items: center; gap: 14px; }
.chan-name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* La largeur de la piste porte le VOLUME du canal, son remplissage le TAUX :
   un canal etroit et plein a bien converti sur peu de leads, et cela se voit. */
.chan-track {
  background: var(--data-soft); border-radius: 6px; height: 26px;
  min-width: 26px; overflow: hidden;
}
.chan-fill { height: 100%; border-radius: 6px 0 0 6px; transition: width .25s ease; }
.chan-val {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--ink-2); white-space: nowrap;
}
.chan-val b { color: var(--ink); font-size: 14px; }
.chan-val .sep { color: var(--muted); margin: 0 3px; }
.chan-rate { display: inline-block; min-width: 58px; text-align: right; color: var(--ink); font-weight: 600; }
.chan-rate.thin { color: var(--muted); font-weight: 400; }

.note.compact { padding: 11px 15px; font-size: 12.5px; }
.donut-hole-pc {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  fill: var(--ink-2);
}

/* Entonnoir comparé : deux barres empilées dans la même piste. */
.fun-track.duo { display: flex; flex-direction: column; gap: 3px; padding: 3px 0; }
.fun-track.duo .fun-bar { height: 11px; }
.fun-track.duo .fun-bar.prev { background: var(--data); }
.fun-val .fun-prev { display: block; color: var(--muted); font-size: 11.5px; }

/* Onglets du détail UTM : le compteur de valeurs distinctes prévient qu'une
   dimension très fragmentée sera regroupée en « Autres ». */
.utm-tabs {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.utm-count {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 11px; color: var(--muted); white-space: nowrap;
}
.utm-tabs .seg { flex-wrap: wrap; }
