:root {
  --fond: #f4f2ee; --carte: #ffffff; --carte-2: #f8f6f2; --trait: #e5e0d8;
  --texte: #1f1d1a; --texte-2: #6d675f; --accent: #2f5d50; --accent-doux: #e3eee9;
  --ok: #2e7d4f; --ok-doux: #e3f2e8; --alerte: #b26b00; --alerte-doux: #fbf0dc;
  --erreur: #b42318; --erreur-doux: #fbe4e1; --ombre: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #151716; --carte: #1e2120; --carte-2: #232726; --trait: #2f3432;
    --texte: #ecebe7; --texte-2: #a3a39c; --accent: #7fc4ad; --accent-doux: #1f3530;
    --ok: #6fcf97; --ok-doux: #1d3327; --alerte: #f0b35a; --alerte-doux: #3a2e1a;
    --erreur: #f2877d; --erreur-doux: #3d2220; --ombre: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }

/* en-tête */
.entete {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--fond) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--trait);
}
.entete h1 { font-size: 1.15rem; margin: 0; flex: 1; letter-spacing: -.01em; }
.maj { font-size: .75rem; color: var(--texte-2); }
.bouton-icone { background: none; border: 0; padding: 8px; border-radius: 10px; cursor: pointer; color: var(--texte-2); }
.bouton-icone:hover { background: var(--carte-2); }
.bouton-icone svg { width: 20px; height: 20px; display: block; }
.tourne svg { animation: tourne 1s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }

main { max-width: 1100px; margin: 0 auto; padding: 14px 16px 24px; }
.vue { display: none; }
.vue.active { display: block; }

/* navigation basse (mobile) / latérale (grand écran) */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: var(--carte);
  border-top: 1px solid var(--trait); padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  flex: 1; background: none; border: 0; padding: 8px 2px 7px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .68rem; color: var(--texte-2); cursor: pointer; position: relative;
}
.nav button svg { width: 22px; height: 22px; }
.nav button[aria-current="page"] { color: var(--accent); font-weight: 600; }
.pastille {
  position: absolute; top: 4px; left: 50%; margin-left: 6px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--erreur); color: #fff; font-size: .65rem; font-weight: 700; line-height: 17px; text-align: center;
}
.pastille.douce { background: var(--accent); }
@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 92px; }
  .nav { top: 0; right: auto; width: 92px; flex-direction: column; border-top: 0; border-right: 1px solid var(--trait); padding-top: 70px; }
  .nav button { flex: 0; padding: 12px 4px; font-size: .72rem; }
}

/* blocs */
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--texte-2); margin: 22px 0 10px; font-weight: 600; }
h2:first-child { margin-top: 4px; }
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: 14px; padding: 14px; box-shadow: var(--ombre); }
.carte + .carte { margin-top: 10px; }
.grille { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grille-2 { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.chiffre { background: var(--carte); border: 1px solid var(--trait); border-radius: 14px; padding: 12px 14px; box-shadow: var(--ombre); }
.chiffre .libelle { font-size: .75rem; color: var(--texte-2); }
.chiffre .valeur { font-size: 1.5rem; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.chiffre .detail { font-size: .75rem; color: var(--texte-2); margin-top: 2px; }
.hausse { color: var(--ok); } .baisse { color: var(--erreur); }

.alerte { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: 12px; font-size: .9rem; margin-bottom: 8px; }
.alerte.erreur { background: var(--erreur-doux); color: var(--erreur); }
.alerte.attention { background: var(--alerte-doux); color: var(--alerte); }
.alerte.ok { background: var(--ok-doux); color: var(--ok); }
.alerte b { font-weight: 650; }
.alerte .texte { flex: 1; color: var(--texte); }
.alerte .texte small { display: block; color: var(--texte-2); }

.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--trait); font-size: .9rem; }
.liste li:last-child { border-bottom: 0; }
.liste .nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.liste .val { font-variant-numeric: tabular-nums; color: var(--texte-2); white-space: nowrap; }
.barre { height: 4px; background: var(--accent-doux); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.barre i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

.point { width: 9px; height: 9px; border-radius: 50%; background: var(--texte-2); flex: none; }
.point.ok { background: var(--ok); } .point.erreur { background: var(--erreur); } .point.attention { background: var(--alerte); } .point.pause { background: var(--trait); border: 1px solid var(--texte-2); }

.etiquette { display: inline-block; font-size: .7rem; padding: 2px 8px; border-radius: 20px; background: var(--carte-2); color: var(--texte-2); border: 1px solid var(--trait); white-space: nowrap; }
.etiquette.accent { background: var(--accent-doux); color: var(--accent); border-color: transparent; }
.etiquette.erreur { background: var(--erreur-doux); color: var(--erreur); border-color: transparent; }

/* filtres */
.filtres { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin: 0 -16px 8px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.filtres::-webkit-scrollbar { display: none; }
.filtres button { flex: none; border: 1px solid var(--trait); background: var(--carte); border-radius: 20px; padding: 6px 12px; font-size: .82rem; cursor: pointer; }
.filtres button[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
@media (prefers-color-scheme: dark) { .filtres button[aria-pressed="true"] { color: #10201b; } }
.recherche { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--trait); background: var(--carte); color: var(--texte); font: inherit; margin-bottom: 10px; }

/* rapports */
.rapport { display: block; width: 100%; text-align: left; background: var(--carte); border: 1px solid var(--trait); border-radius: 14px; padding: 12px 14px; cursor: pointer; box-shadow: var(--ombre); }
.rapport + .rapport { margin-top: 8px; }
.rapport .haut { display: flex; align-items: center; gap: 8px; font-size: .75rem; color: var(--texte-2); }
.rapport .haut .quand { margin-left: auto; white-space: nowrap; }
.rapport .titre { font-weight: 600; margin: 4px 0 2px; font-size: .95rem; }
.rapport .extrait { font-size: .84rem; color: var(--texte-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rapport.nonlu { border-left: 3px solid var(--accent); }
.rapport.nonlu .titre::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 6px; vertical-align: middle; }
.plus { display: block; margin: 12px auto; background: var(--carte); border: 1px solid var(--trait); border-radius: 20px; padding: 8px 18px; cursor: pointer; }

/* lecteur de rapport */
.lecteur { position: fixed; inset: 0; z-index: 20; background: var(--fond); overflow-y: auto; display: none; }
.lecteur.ouvert { display: block; }
.lecteur .entete h1 { font-size: 1rem; }
.lecteur article { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); overflow-wrap: anywhere; }
.lecteur article h1, .lecteur article h2, .lecteur article h3 { text-transform: none; letter-spacing: -.01em; color: var(--texte); font-size: 1.1rem; margin: 20px 0 8px; }
.lecteur article h1 { font-size: 1.25rem; }
.lecteur article table { border-collapse: collapse; display: block; overflow-x: auto; font-size: .85rem; }
.lecteur article td, .lecteur article th { border: 1px solid var(--trait); padding: 5px 8px; }
.lecteur article pre { background: var(--carte-2); padding: 10px; border-radius: 10px; overflow-x: auto; font-size: .8rem; }
.lecteur article code { font-size: .85em; }
.lecteur article blockquote { margin: 10px 0; padding: 4px 12px; border-left: 3px solid var(--trait); color: var(--texte-2); }
.meta-rapport { font-size: .8rem; color: var(--texte-2); margin-bottom: 8px; }

/* tâches */
.tache { background: var(--carte); border: 1px solid var(--trait); border-radius: 14px; padding: 12px 14px; box-shadow: var(--ombre); }
.tache + .tache { margin-top: 8px; }
.tache .ligne { display: flex; align-items: center; gap: 9px; }
.tache .nom { font-weight: 600; flex: 1; min-width: 0; font-size: .92rem; }
.tache .infos { font-size: .78rem; color: var(--texte-2); margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.tache .err { font-size: .78rem; color: var(--erreur); margin-top: 6px; overflow-wrap: anywhere; }
.tache .actions { display: flex; gap: 6px; margin-top: 10px; }
.action { border: 1px solid var(--trait); background: var(--carte-2); border-radius: 9px; padding: 6px 11px; font-size: .8rem; cursor: pointer; }
.action:disabled { opacity: .5; cursor: default; }
.action.principale { background: var(--accent); color: #fff; border-color: var(--accent); }
@media (prefers-color-scheme: dark) { .action.principale { color: #10201b; } }
details.consigne summary { font-size: .78rem; color: var(--texte-2); cursor: pointer; margin-top: 6px; }
details.consigne p { font-size: .8rem; white-space: pre-wrap; color: var(--texte-2); margin: 6px 0 0; max-height: 220px; overflow-y: auto; }

/* graphiques */
.graphe { width: 100%; height: 120px; display: block; }
.graphe .aire { fill: var(--accent-doux); }
.graphe .courbe { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.legende-graphe { display: flex; justify-content: space-between; font-size: .7rem; color: var(--texte-2); margin-top: 4px; }
.tunnel li .nom { white-space: normal; }

.onglets-site { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.vide { color: var(--texte-2); font-size: .9rem; text-align: center; padding: 26px 10px; }
.petit { font-size: .78rem; color: var(--texte-2); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); background: var(--texte); color: var(--fond); padding: 10px 16px; border-radius: 12px; font-size: .88rem; z-index: 30; max-width: calc(100vw - 32px); box-shadow: 0 4px 20px rgba(0,0,0,.2); }

/* connexion */
.connexion { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.connexion form { width: 100%; max-width: 340px; }
.connexion h1 { font-size: 1.3rem; margin: 14px 0 4px; }
.connexion p { color: var(--texte-2); margin: 0 0 18px; font-size: .9rem; }
.connexion input { width: 100%; padding: 12px 14px; font: inherit; border: 1px solid var(--trait); background: var(--carte); color: var(--texte); border-radius: 12px; }
.connexion button { width: 100%; margin-top: 10px; padding: 12px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
@media (prefers-color-scheme: dark) { .connexion button { color: #10201b; } }
.connexion .erreur { color: var(--erreur); font-size: .85rem; margin-top: 10px; min-height: 1.2em; }
.logo { width: 56px; height: 56px; border-radius: 14px; }
