/* SCN — Tableau de bord. Mobile d'abord ; barre latérale au-delà de 900 px. */

:root {
  color-scheme: light;
  --marque: #1f3864;
  --marque-texte: #ffffff;
  --page: #f4f5f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --texte: #0b0b0b;
  --texte-2: #52514e;
  --texte-3: #6f6d68;
  --grille: #e1e0d9;
  --axe: #c3c2b7;
  --bordure: rgba(11, 11, 11, 0.10);
  --serie-1: #2a78d6;
  --serie-2: #eb6834;
  --serie-1-clair: #cde2fb;
  --positif: #006300;
  --critique: #d03b3b;
  --serieux: #ec835a;
  --rayon: 12px;
  --police: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #262624;
    --texte: #ffffff;
    --texte-2: #c3c2b7;
    --texte-3: #a3a198;
    --grille: #2c2c2a;
    --axe: #383835;
    --bordure: rgba(255, 255, 255, 0.10);
    --serie-1: #3987e5;
    --serie-2: #d95926;
    --serie-1-clair: #184f95;
    --positif: #0ca30c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #262624;
  --texte: #ffffff;
  --texte-2: #c3c2b7;
  --texte-3: #a3a198;
  --grille: #2c2c2a;
  --axe: #383835;
  --bordure: rgba(255, 255, 255, 0.10);
  --serie-1: #3987e5;
  --serie-2: #d95926;
  --serie-1-clair: #184f95;
  --positif: #0ca30c;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--texte);
  font-family: var(--police);
  font-size: 15px;
  line-height: 1.4;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
.chargement { padding: 32px 16px; color: var(--texte-2); }
.nombre { font-variant-numeric: tabular-nums; white-space: nowrap; }
.discret { color: var(--texte-2); }
.petit { font-size: 13px; }

/* ------------------------------------------------------------ Connexion */
.connexion {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--marque);
}
.connexion form {
  width: min(380px, 100%);
  background: var(--surface);
  border-radius: var(--rayon);
  padding: 28px 24px;
  display: grid;
  gap: 14px;
}
.connexion h1 { margin: 0; font-size: 22px; }
.connexion label { display: grid; gap: 6px; font-size: 14px; color: var(--texte-2); }
.connexion input {
  padding: 12px;
  border: 1px solid var(--axe);
  border-radius: 8px;
  background: var(--surface);
  font-size: 16px;
}
.bouton {
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  background: var(--marque);
  color: var(--marque-texte);
  font-weight: 600;
  cursor: pointer;
}
.bouton[disabled] { opacity: .6; cursor: progress; }
.bouton-lien { background: none; border: 0; padding: 0; color: var(--texte-2); text-decoration: underline; cursor: pointer; font-size: 14px; }
.erreur { color: var(--critique); font-size: 14px; margin: 0; }

/* ---------------------------------------------------------------- Cadre */
.cadre { min-height: 100vh; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
.entete {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--marque);
  color: var(--marque-texte);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.entete .logo { display: flex; align-items: center; flex: none; }
.entete .logo img { width: 36px; height: 36px; display: block; }
.logo-connexion { width: 120px; height: 120px; justify-self: center; }
.entete-impression { display: none; }
.entete .titre { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entete .periode { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.entete .periode input {
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .35);
  color: #fff;
  border-radius: 6px;
  padding: 4px 6px;
  color-scheme: dark;
}
.entete .deconnexion {
  background: none;
  border: 1px solid rgba(255, 255, 255, .35);
  color: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
}
.bandeau {
  background: #fff4d6;
  color: #5c4300;
  padding: 8px 16px;
  font-size: 13px;
}
.navigation {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--bordure);
  padding-bottom: env(safe-area-inset-bottom);
}
.navigation a {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 2px;
  font-size: 11px;
  text-decoration: none;
  color: var(--texte-2);
}
.navigation a svg { width: 22px; height: 22px; }
.navigation .titre-long { display: none; }
.navigation .ordinateur-seulement { display: none; }
.lien-aide { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .5); color: #fff; text-decoration: none; font-weight: 700; flex: none; }
.navigation a[aria-current="page"] { color: var(--marque); font-weight: 700; }
:root[data-theme="dark"] .navigation a[aria-current="page"] { color: var(--serie-1); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .navigation a[aria-current="page"] { color: var(--serie-1); }
}
.contenu {
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
  transition: opacity .15s;
}
.contenu.recharge { opacity: .5; pointer-events: none; }

@media (min-width: 900px) {
  .cadre { padding-bottom: 0; padding-left: 200px; }
  .navigation {
    top: 0;
    right: auto;
    width: 200px;
    grid-template-columns: none;
    grid-auto-rows: min-content;
    align-content: start;
    padding-top: 70px;
    border-top: 0;
    border-right: 1px solid var(--bordure);
  }
  .navigation .titre-long { display: inline; }
  .navigation .titre-court { display: none; }
  .navigation .ordinateur-seulement { display: grid; }
  .lien-aide { display: none; }
  .navigation a { grid-template-columns: 24px 1fr; justify-items: start; align-items: center; gap: 10px; padding: 12px 20px; font-size: 14px; }
  .contenu { padding: 24px; }
}

/* --------------------------------------------------------------- Cartes */
.carte {
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 16px;
  min-width: 0;
}
.carte > h2 { margin: 0 0 12px; font-size: 16px; }
.carte > h2 .discret { font-weight: 400; font-size: 13px; }
.grille-2 { display: grid; gap: 16px; }
@media (min-width: 900px) { .grille-2 { grid-template-columns: 1fr 1fr; } }

.heros .libelle { color: var(--texte-2); font-size: 14px; }
.heros .valeur { font-size: 36px; font-weight: 650; line-height: 1.1; margin: 4px 0; }
.heros .detail { color: var(--texte-2); font-size: 14px; }
@media (min-width: 600px) { .heros .valeur { font-size: 44px; } }
@media (min-width: 900px) { .heros .valeur { font-size: 52px; } }

.tuiles { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .tuiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tuile { background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 14px; min-width: 0; }
.tuile .libelle { color: var(--texte-2); font-size: 13px; }
.tuile .valeur { font-size: 22px; font-weight: 650; margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tuile .detail { color: var(--texte-2); font-size: 12px; }
a.tuile { text-decoration: none; display: block; }

.statut { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--texte); }
.statut::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.statut.critique::before { background: var(--critique); }
.statut.serieux::before { background: var(--serieux); }
.negatif { color: var(--critique); }

/* --------------------------------------------------------------- Listes */
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { border-top: 1px solid var(--bordure); }
.liste li:first-child { border-top: 0; }
.ligne {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 10px 0;
  align-items: center;
  text-decoration: none;
}
a.ligne { cursor: pointer; }
a.ligne:hover .nom { text-decoration: underline; }
.ligne .nom { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne .sous { color: var(--texte-2); font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.ligne .montant { text-align: right; font-weight: 600; }
.barre { height: 6px; border-radius: 3px; background: var(--surface-2); grid-column: 1 / -1; overflow: hidden; }
.barre span { display: block; height: 100%; background: var(--serie-1); border-radius: 3px; }

.recherche {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--axe);
  border-radius: 8px;
  background: var(--surface);
  font-size: 16px;
}
.segments { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.segments a { padding: 6px 14px; border-radius: 6px; text-decoration: none; font-size: 14px; color: var(--texte-2); }
.segments a[aria-current="page"] { background: var(--surface); color: var(--texte); font-weight: 600; box-shadow: 0 0 0 1px var(--bordure); }
.barre-outils { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* -------------------------------------------------------------- Tableaux */
.defile { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--bordure); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--texte-2); font-weight: 600; font-size: 12px; }
td { font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 700; border-top: 2px solid var(--axe); }
.liste li.total { border-top: 2px solid var(--axe); }
.liste li.total .nom, .liste li.total .nombre { font-weight: 700; }
tr.sig td { font-weight: 650; background: var(--surface-2); }
details summary { cursor: pointer; color: var(--texte-2); font-size: 13px; margin-top: 8px; }

/* ------------------------------------------------------------ Graphiques */
.graphique { width: 100%; }
.graphique svg { display: block; width: 100%; overflow: visible; }
.graphique .grille line { stroke: var(--grille); stroke-width: 1; }
.graphique .base { stroke: var(--axe); stroke-width: 1; }
.graphique text { fill: var(--texte-3); font-size: 11px; font-family: var(--police); font-variant-numeric: tabular-nums; }
.graphique .grille, .graphique .base, .graphique text, .graphique .marque,
.graphique .reticule, .graphique circle { pointer-events: none; }
.graphique .zone { fill: transparent; cursor: crosshair; outline: none; }
.graphique .zone:focus-visible { stroke: var(--texte-2); stroke-width: 1; }
.graphique .colonne:hover .marque, .graphique .colonne:focus-within .marque { opacity: .8; }
.graphique .reticule { stroke: var(--texte-3); stroke-width: 1; }
.legende { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--texte-2); margin-bottom: 8px; }
.legende span { display: inline-flex; align-items: center; gap: 6px; }
.legende i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legende i.ligne-cle { height: 2px; border-radius: 1px; }

#infobulle {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  background: var(--surface);
  color: var(--texte);
  border: 1px solid var(--bordure);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  min-width: 140px;
}
#infobulle .titre-bulle { color: var(--texte-2); font-size: 12px; margin-bottom: 4px; }
#infobulle .rangee { display: grid; grid-template-columns: 14px auto 1fr; gap: 6px; align-items: center; }
#infobulle .rangee i { height: 2px; border-radius: 1px; }
#infobulle .rangee strong { font-variant-numeric: tabular-nums; }
#infobulle .rangee span { color: var(--texte-2); text-align: right; }

.pied { color: var(--texte-3); font-size: 12px; text-align: center; padding: 8px 0 16px; }

/* ------------------------------------------------------- États financiers */
.etat-section { display: grid; gap: 16px; }
.masque-ecran { display: none !important; }
table.etat td:nth-child(2), table.etat th:nth-child(2) { text-align: left; white-space: normal; min-width: 180px; }
table.etat td:first-child { color: var(--texte-3); font-size: 12px; }
table.etat tr.retrait td:nth-child(2) { padding-left: 24px; color: var(--texte-2); }
.puces { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.texte-libre { font-weight: 600; white-space: normal; }

@media print {
  .navigation, .entete, .bandeau, .non-imprime, .pied { display: none !important; }
  .entete-impression { display: flex; align-items: center; gap: 14px; padding-bottom: 8px; border-bottom: 2px solid #1f3864; }
  .entete-impression img { width: 64px; height: 64px; }
  .entete-impression .societe { font-weight: 800; color: #1f3864; font-size: 16px; }
  .entete-impression .titre-rapport { font-weight: 600; font-size: 14px; }
  .entete-impression .sous { font-size: 11px; color: #595959; }
  .cadre { padding: 0 !important; }
  .contenu { padding: 0; max-width: none; }
  .masque-ecran:not(.non-imprime) { display: grid !important; }
  .carte { break-inside: avoid-page; border: 0; padding: 8px 0; }
  table.etat { font-size: 11px; }
  table.etat th, table.etat td { padding: 3px 6px; }
}

/* --------------------------------------------------------- Administration */
.formulaire { display: grid; gap: 12px; max-width: 640px; }
.formulaire label { display: grid; gap: 4px; font-size: 14px; color: var(--texte-2); }
.formulaire label.case, label.case { display: flex; align-items: center; gap: 8px; color: var(--texte); }
.formulaire fieldset { border: 1px solid var(--bordure); border-radius: 8px; padding: 8px 12px 12px; }
.formulaire legend { font-size: 14px; color: var(--texte-2); padding: 0 4px; }
.cases { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 12px; }
.formulaire-site { display: grid; gap: 8px; padding: 12px 0; }
table.matrice td.coche { text-align: center; color: var(--marque); font-weight: 700; }
table.matrice th { text-align: center; }
table.matrice td:first-child { white-space: normal; min-width: 220px; }
.erreur { color: var(--critique, #c00000); }
.actions-role { display: flex; gap: 12px; margin-top: 4px; font-size: 13px; }
select.recherche { appearance: auto; }
