/* Tableau de bord client. Polices système : aucune requête externe (CSP stricte, confidentialité). */
:root {
  color-scheme: light dark;
  --fond: #f4f5f7;
  --surface: #ffffff;
  --bordure: #e2e5ea;
  --texte: #17202b;
  --texte-doux: #4d596a;
  --accent: #1b2436;
  --attention: #b42318;
  --attention-fond: #fef3f2;
  --repere: #e9ecf0;
  --ombre: 0 1px 2px rgba(16, 24, 40, 0.05), 0 2px 8px rgba(16, 24, 40, 0.06);
  --rayon: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0e131a;
    --surface: #161d27;
    --bordure: #273142;
    --texte: #e9edf3;
    --texte-doux: #a7b2c2;
    --attention: #ff8a7a;
    --attention-fond: #2a1716;
    --repere: #222b39;
    --ombre: none;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.evitement { position: absolute; left: -9999px; }
.evitement:focus { left: 16px; top: 16px; padding: 8px 12px; background: var(--surface); border-radius: 8px; z-index: 10; }
.visuellement-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.entete, main, .pied { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

.entete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding-top: 28px;
  padding-bottom: 20px;
}

.marque { display: flex; align-items: center; gap: 14px; min-width: 0; }

.logo {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--logo-fond, #1b2436);
  color: var(--logo-texte, #ffffff);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  overflow: hidden;
}
.logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }

h1 { margin: 0; font-size: clamp(1.35rem, 1.1rem + 1vw, 1.85rem); line-height: 1.15; letter-spacing: -0.01em; }
.sous-titre, .maj { margin: 2px 0 0; color: var(--texte-doux); font-size: 0.95rem; }

.etat {
  margin: 48px 0;
  padding: 20px;
  border: 1px dashed var(--bordure);
  border-radius: var(--rayon);
  color: var(--texte-doux);
  text-align: center;
}

.titre-section {
  margin: 8px 0 12px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--texte-doux);
}

/* Indicateurs du mois */
.indicateurs {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.indicateur {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
}
.indicateur .libelle { margin: 0; font-size: 0.9rem; color: var(--texte-doux); }
.indicateur .valeur {
  margin: 4px 0 0;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.indicateur .detail { margin: 6px 0 0; font-size: 0.85rem; color: var(--texte-doux); }
.indicateur.attention { border-color: var(--attention); background: var(--attention-fond); }
.indicateur.attention .valeur, .indicateur.depasse .detail { color: var(--attention); }

.jauge { margin-top: 10px; height: 8px; border-radius: 99px; background: var(--repere); overflow: hidden; }
.jauge span { display: block; height: 100%; width: calc(var(--part, 0) * 1%); background: var(--accent); border-radius: inherit; }
.indicateur.depasse .jauge span { background: var(--attention); }

/* Cartes */
.grille { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) {
  .grille { grid-template-columns: 1fr 1fr; }
  .large { grid-column: span 2; }
}

.carte {
  min-width: 0;
  padding: 18px 20px 20px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
}
.carte h2 { margin: 0 0 14px; font-size: 1.05rem; }

.figure { margin: 0; }
.graphique { display: block; width: 100%; height: auto; }
.graphique .barre { fill: var(--accent); }
.graphique .barre:hover { opacity: 0.8; }
.graphique .repere { stroke: var(--repere); stroke-width: 1; }
.graphique .axe { fill: var(--texte-doux); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Motifs */
.motifs { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.motif { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.motif-nombre { font-weight: 600; font-variant-numeric: tabular-nums; }
.motif-barre { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--repere); overflow: hidden; }
.motif-barre span { display: block; height: 100%; width: calc(var(--part, 0) * 1%); background: var(--accent); border-radius: inherit; }

/* Appels */
.appels { list-style: none; margin: 0; padding: 0; }
.appel { padding: 12px 0; border-top: 1px solid var(--bordure); }
.appel:first-child { border-top: 0; padding-top: 0; }
.appel-tete { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.appel-quand { font-weight: 600; }
.appel-motif { color: var(--texte-doux); font-size: 0.9rem; }
.appel-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 2px; font-size: 0.9rem; color: var(--texte-doux); font-variant-numeric: tabular-nums; }
.appel-tel { color: var(--texte); font-weight: 600; }
a.appel-tel { text-decoration: underline; text-underline-offset: 3px; }
a.appel-tel:hover { text-decoration-thickness: 2px; }
.appel-resume { margin: 6px 0 0; font-size: 0.95rem; }
.a-rappeler .appel-quand::before {
  content: "À rappeler";
  margin-right: 8px;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--attention-fond);
  color: var(--attention);
  font-size: 0.75rem;
  font-weight: 700;
}
.vide { margin: 0; color: var(--texte-doux); }

a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.pied { padding-top: 28px; padding-bottom: 32px; color: var(--texte-doux); font-size: 0.85rem; }

/* Connexion */
.entete__droite { display: flex; align-items: center; gap: 16px; }
.lien-bouton {
  background: none; border: 0; padding: 4px 2px; font: inherit; font-size: 0.9rem; font-weight: 600;
  color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.lien-bouton:hover { text-decoration-thickness: 2px; }
.connexion { display: grid; place-items: center; min-height: 60vh; padding: 24px 0 48px; }
.connexion__carte {
  width: min(400px, 100%); display: grid; gap: 6px;
  background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon);
  padding: 28px 24px 24px; box-shadow: var(--ombre);
}
.connexion__carte h2 { margin: 0; font-size: 1.35rem; }
.connexion__aide { margin: 2px 0 14px; color: var(--texte-doux); font-size: 0.93rem; }
.connexion label { font-weight: 600; font-size: 0.92rem; margin-top: 8px; }
.connexion input[type="text"], .connexion input:not([type]), .connexion input[type="password"] {
  width: 100%; font: inherit; color: var(--texte); background: var(--fond);
  border: 1px solid var(--bordure); border-radius: 10px; padding: 11px 12px;
}
.connexion input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.champ-mdp { position: relative; }
.champ-mdp input { padding-right: 84px !important; }
.champ-mdp .lien-bouton { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
.connexion .case { display: flex; align-items: center; gap: 8px; font-weight: 400; margin-top: 12px; }
.case input { width: 18px; height: 18px; accent-color: var(--accent); }
.erreur { margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--attention-fond); color: var(--attention); font-size: 0.92rem; font-weight: 600; }
.bouton {
  margin-top: 14px; font: inherit; font-weight: 700; color: #fff; background: var(--accent);
  border: 0; border-radius: 10px; padding: 12px 16px; cursor: pointer;
}
.bouton:hover { filter: brightness(1.12); }
.bouton:disabled { opacity: 0.7; cursor: wait; }
@media (prefers-color-scheme: dark) {
  .bouton { color: #0e131a; }
}
/* Avant le chargement des données (page de connexion) : accent par défaut lisible en mode sombre */
@media (prefers-color-scheme: dark) {
  :root { --accent: #9db4d8; }
}
