/* Charte AX'ION CLEAN (logo et affiches) : bleu nuit, bleu ciel, blanc, et le vert de « CLEAN ».
   --vert* = couleur principale de l'interface (bleu), --ok* = vert des statuts « à jour / payé ». */
:root {
  --marine: #172f6b;
  --ciel: #29a9e1;
  --vert-marque: #2e9b45;
  --vert: #1f4a9c;
  --vert-fonce: #172f6b;
  --vert-clair: #e5f1fb;
  --ok: #2e8b3f;
  --ok-clair: #e4f4e7;
  --orange: #f2a20c;
  --rouge: #c62f2f;
  --rouge-clair: #fbe7e7;
  --orange-clair: #fdf1dc;
  --bleu: #1f5fa8;
  --bleu-clair: #e5eef9;
  --fond: #f3f6fb;
  --carte: #ffffff;
  --texte: #14202e;
  --texte-doux: #5a6778;
  --bord: #dce3ed;
  --ombre: 0 1px 3px rgba(16, 40, 28, .08), 0 4px 14px rgba(16, 40, 28, .05);
  --rayon: 12px;
  --haut: 56px;
  --bas: 64px;
}
/* Mode jour / nuit : « Automatique » suit le réglage du téléphone ; le choix « Clair » ou « Sombre »
   (bouton soleil/lune en haut, ou Plus → Apparence) est posé sur <html data-theme="clair|sombre">. */
:root[data-theme="clair"] { color-scheme: light; }
:root[data-theme="sombre"] {
  color-scheme: dark;
  --vert: #4fa3ea; --vert-fonce: #2f86d0; --vert-clair: #15243a; --ok: #4cc06a; --ok-clair: #15322a; --vert-marque: #4cc06a;
  --rouge: #ef6b6b; --rouge-clair: #3a1d1d; --orange-clair: #3a2c12; --bleu: #6aa6ee; --bleu-clair: #172a42;
  --fond: #0d131c; --carte: #162030; --texte: #e6edf6; --texte-doux: #9aa9bb; --bord: #26344a;
  --ombre: 0 1px 3px rgba(0,0,0,.4);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="clair"]) {
    color-scheme: dark;
    --vert: #4fa3ea; --vert-fonce: #2f86d0; --vert-clair: #15243a; --ok: #4cc06a; --ok-clair: #15322a; --vert-marque: #4cc06a;
    --rouge: #ef6b6b; --rouge-clair: #3a1d1d; --orange-clair: #3a2c12; --bleu: #6aa6ee; --bleu-clair: #172a42;
    --fond: #0d131c; --carte: #162030; --texte: #e6edf6; --texte-doux: #9aa9bb; --bord: #26344a;
    --ombre: 0 1px 3px rgba(0,0,0,.4);
  }
}
.btn-theme .lune { display: none; }
:root[data-theme="sombre"] .btn-theme .soleil { display: none; }
:root[data-theme="sombre"] .btn-theme .lune { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="clair"]) .btn-theme .soleil { display: none; }
  :root:not([data-theme="clair"]) .btn-theme .lune { display: inline; }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond); color: var(--texte); font-size: 15px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
a { color: var(--vert); }
[hidden] { display: none !important; }

/* Barres */
.barre-haut {
  position: sticky; top: 0; z-index: 900; height: var(--haut);
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: linear-gradient(90deg, #132a62, #1f4a9c 70%, #2a7fc7); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.15);
}
.titre-app { flex: 1; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; min-width: 0; }
.titre-app img { border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.role-pastille { font-size: .68rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,.18); white-space: nowrap; }
.role-pastille.direction { background: #f2c14e; color: #3b2a00; }
.role-pastille.chef { background: var(--ciel); color: #04263b; }
.role-pastille.terrain { background: var(--vert-marque); color: #fff; }
@media (max-width: 420px) { .role-pastille { display: none; } }
.titre-app span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-icone {
  border: 0; background: transparent; color: inherit; font-size: 1.3rem; width: 40px; height: 40px;
  border-radius: 50%; cursor: pointer; display: grid; place-items: center; flex: none;
}
.btn-icone:hover { background: rgba(255,255,255,.15); }
.utilisateur { background: rgba(255,255,255,.2); font-size: .85rem; font-weight: 700; }
.sync { border: 0; border-radius: 99px; padding: 4px 10px; font: inherit; font-size: .75rem; font-weight: 700; cursor: pointer; background: rgba(255,255,255,.2); color: #fff; white-space: nowrap; }
.sync.attente { background: var(--orange); color: #3a2600; }
.sync.erreur { background: var(--rouge); }

.barre-bas {
  /* --decal-badge : place laissée sous les onglets pour le badge « Powered by Netlify » (offre gratuite) */
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 900; height: calc(var(--bas) + env(safe-area-inset-bottom) + var(--decal-badge, 0px));
  padding-bottom: calc(env(safe-area-inset-bottom) + var(--decal-badge, 0px));
  display: flex; background: var(--carte); border-top: 1px solid var(--bord);
}
.barre-bas a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--texte-doux); font-size: .72rem; font-weight: 600;
}
.barre-bas a .ico { font-size: 1.35rem; line-height: 1; }
.barre-bas a.actif { color: var(--vert); }
.icone { width: 26px; height: 26px; display: block; }
.barre-bas a .ico { display: grid; place-items: center; width: 44px; height: 30px; border-radius: 99px; transition: background .15s; }
.barre-bas a.actif .ico { background: var(--vert-clair); }
.menu-plus a .ico .icone { width: 26px; height: 26px; color: var(--vert); }

.vue { max-width: 980px; margin: 0 auto; padding: 16px 16px calc(var(--bas) + 24px + var(--decal-badge, 0px)); }

/* Cartes et grilles */
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px; box-shadow: var(--ombre); margin-bottom: 12px; }
.grille { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 12px; }
@media (min-width: 720px) { .grille { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 12px; box-shadow: var(--ombre); }
.kpi .lib { font-size: .75rem; color: var(--texte-doux); text-transform: uppercase; letter-spacing: .02em; font-weight: 600; }
.kpi .val { font-size: 1.35rem; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sous { font-size: .78rem; color: var(--texte-doux); }
.kpi.alerte .val { color: var(--rouge); }
.kpi.ok .val { color: var(--ok); }

.entete-section { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 18px 0 8px; flex-wrap: wrap; }
.entete-section h2 { margin: 0; }

/* Listes */
.liste { list-style: none; margin: 0; padding: 0; background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); overflow: hidden; box-shadow: var(--ombre); margin-bottom: 12px; }
.liste > li { padding: 12px 14px; border-bottom: 1px solid var(--bord); }
.liste > li:last-child { border-bottom: 0; }
.liste > li.cliquable { cursor: pointer; }
.liste > li.cliquable:hover { background: var(--vert-clair); }
.ligne { display: flex; align-items: center; gap: 10px; }
.ligne .grow { flex: 1; min-width: 0; }
.nom { font-weight: 700; }
.meta { font-size: .82rem; color: var(--texte-doux); }
.tronque { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rang { width: 30px; height: 30px; border-radius: 50%; background: var(--vert-clair); color: var(--vert); display: grid; place-items: center; font-weight: 800; font-size: .85rem; flex: none; }
.vide { text-align: center; color: var(--texte-doux); padding: 24px 12px; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .72rem; font-weight: 700; background: var(--bord); color: var(--texte); white-space: nowrap; }
.badge.vert { background: var(--ok-clair); color: var(--ok); }
.badge.rouge { background: var(--rouge-clair); color: var(--rouge); }
.badge.orange { background: var(--orange-clair); color: #a76a00; }
.badge.bleu { background: var(--bleu-clair); color: var(--bleu); }
:root[data-theme="sombre"] .badge.orange { color: var(--orange); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="clair"]) .badge.orange { color: var(--orange); } }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--bord); background: var(--carte); color: var(--texte);
  padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  min-height: 40px;
}
.btn:hover { border-color: var(--vert); }
.btn.principal { background: var(--vert); border-color: var(--vert); color: #fff; }
.btn.principal:hover { background: var(--vert-fonce); }
.btn.danger { color: var(--rouge); border-color: var(--rouge); }
.btn.petit { padding: 5px 10px; min-height: 32px; font-size: .85rem; }
.btn.plein { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* Formulaires */
.champ { margin-bottom: 12px; }
.champ label { display: block; font-size: .82rem; font-weight: 700; margin-bottom: 4px; color: var(--texte-doux); }
input, select, textarea {
  width: 100%; font: inherit; color: var(--texte); background: var(--carte);
  border: 1px solid var(--bord); border-radius: 10px; padding: 10px 12px; min-height: 42px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--vert); outline-offset: -1px; }
textarea { min-height: 80px; resize: vertical; }
.deux-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.filtres { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filtres > * { flex: 1 1 140px; }
.recherche { flex: 2 1 220px !important; }

/* Tableaux */
.table-wrap { overflow-x: auto; background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre); margin-bottom: 12px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--bord); text-align: left; white-space: nowrap; }
th { font-size: .75rem; text-transform: uppercase; color: var(--texte-doux); background: var(--fond); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 800; background: var(--fond); }

.barre-prog { height: 8px; background: var(--bord); border-radius: 99px; overflow: hidden; }
.barre-prog > div { height: 100%; background: var(--vert); }

/* Carte géographique */
#carte { height: calc(100vh - var(--haut) - var(--bas) - 150px); min-height: 360px; border-radius: var(--rayon); border: 1px solid var(--bord); z-index: 1; }
.pin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.3); }

/* Guidage client par client (superviseur) */
#carte.carte-guidage { height: min(45vh, 380px); min-height: 260px; }
.num-pin { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; background: #1f4a9c; color: #fff; font: 800 .72rem/1 system-ui, sans-serif; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.num-pin.suivant { background: #2e9b45; font-size: .95rem; border-width: 3px; box-shadow: 0 0 0 4px rgba(46,155,69,.3), 0 1px 4px rgba(0,0,0,.35); }
.num-pin.fait { background: #9aa3ad; }
.guidage-suivant { border: 2px solid var(--ok, #2e9b45); }
.guidage-rang { width: 40px; height: 40px; font-size: 1rem; background: #2e9b45; color: #fff; }
.guidage-dist { font-size: 1.15rem; font-weight: 800; color: var(--vert); margin: 6px 0; }
.guidage-boutons { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 6px; margin-top: 12px; }
.guidage-boutons .btn { min-height: 52px; font-size: .95rem; padding: 6px 4px; white-space: nowrap; justify-content: center; }
.guidage-boutons .btn.ok { font-size: 1.05rem; }
.chrono-mini .chrono-val { font-size: 1rem; font-weight: 800; }
.btn.ok { background: #2e9b45; border-color: #2e9b45; color: #fff; }
.rattrapages { border: 2px solid var(--orange, #f2a20c); }
/* Impression (bilan mensuel → PDF) : seulement le contenu, en clair */
@media print {
  .barre-haut, .barre-bas, .filtres, .actions, .toast, .modale-fond, button { display: none !important; }
  :root { color-scheme: light; --fond: #fff; --carte: #fff; --texte: #14202e; --texte-doux: #5a6778; --bord: #dce3ed; }
  body { background: #fff !important; color: #14202e !important; }
  .vue { padding: 0 !important; max-width: none !important; }
  .kpi, .carte, table { break-inside: avoid; box-shadow: none !important; }
}
.choix-secteurs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.choix-secteurs .puce-choix { padding: 8px; font-size: .85rem; font-weight: 500; }
.choix-motifs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.puce-choix { display: flex; align-items: center; gap: 8px; padding: 12px 10px; border: 1px solid var(--bord); border-radius: 10px; font-weight: 600; cursor: pointer; }
.puce-choix:has(input:checked) { border-color: var(--vert); background: var(--vert-clair); color: var(--vert); }
.legende { display: flex; gap: 12px; flex-wrap: wrap; font-size: .8rem; margin-top: 8px; color: var(--texte-doux); }
.legende span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; background: var(--c); }

/* Connexion */
.connexion { max-width: 460px; margin: 0 auto; text-align: center; }
.hero { position: relative; margin: -16px -16px 0; height: 250px; overflow: hidden; background: var(--marine); }
.hero img.photo-fond { width: 100%; height: 100%; object-fit: cover; object-position: center 22%; opacity: .9; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(19,42,98,.05) 30%, var(--fond) 100%); }
.connexion .logo-rond { width: 104px; height: 104px; margin-top: -60px; position: relative; z-index: 1; border-radius: 50%; background: #fff; box-shadow: 0 6px 20px rgba(23,47,107,.35); }
.marque { font-size: 1.7rem; font-weight: 900; letter-spacing: .02em; margin: 10px 0 0; color: var(--marine); }
.marque span { color: var(--vert-marque); }
:root[data-theme="sombre"] .marque { color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="clair"]) .marque { color: #fff; } }
.connexion .slogan { color: var(--texte-doux); margin: 2px 0 18px; font-style: italic; }
.connexion .liste li { text-align: left; }

/* Bandeau d'accueil avec affiche */
.bandeau { display: flex; overflow: hidden; padding: 0; background: linear-gradient(120deg, #132a62, #1f4a9c); color: #fff; border: 0; }
.bandeau img { width: 36%; max-width: 190px; object-fit: cover; object-position: 30% 30%; flex: none; }
.bandeau .texte { padding: 14px 16px; display: flex; flex-direction: column; justify-content: center; gap: 4px; min-width: 0; }
.bandeau .texte h1 { color: #fff; margin: 0; font-size: 1.25rem; }
.bandeau .texte .meta { color: rgba(255,255,255,.8); }
.bandeau .texte .conseil { margin-top: 6px; font-size: .85rem; background: rgba(255,255,255,.12); border-left: 3px solid var(--vert-marque); padding: 6px 8px; border-radius: 6px; }
.affiche-pied { display: block; width: 100%; max-width: 420px; margin: 16px auto 0; border-radius: var(--rayon); box-shadow: var(--ombre); }

/* Inscription : choix de formule et jours */
.choix-formules { display: grid; gap: 8px; }
@media (min-width: 640px) { .choix-formules { grid-template-columns: repeat(3, 1fr); } }
.choix-formule { display: flex; flex-direction: column; gap: 4px; border: 2px solid var(--bord); border-radius: 12px; padding: 10px 12px; cursor: pointer; position: relative; }
.choix-formule input { position: absolute; opacity: 0; pointer-events: none; }
.choix-formule .tete { display: flex; justify-content: space-between; gap: 8px; }
.choix-formule .tete span { font-weight: 800; color: var(--vert); white-space: nowrap; }
.choix-formule:has(input:checked) { border-color: var(--vert); background: var(--vert-clair); }
.choix-formule:has(input:focus-visible) { outline: 2px solid var(--vert); outline-offset: 2px; }
.puces { display: flex; gap: 6px; flex-wrap: wrap; }
.puce { padding: 6px 10px; border-radius: 99px; font-size: .8rem; font-weight: 700; background: var(--fond); color: var(--texte-doux); border: 1px solid var(--bord); }
.puce.on { background: var(--vert); color: #fff; border-color: var(--vert); }

/* Chronomètre de tournée */
.chrono-val { font-size: 1.8rem; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.chrono.depasse { border-color: var(--rouge); }
.chrono.depasse .chrono-val { color: var(--rouge); }
.btn .icone { width: 18px; height: 18px; }

/* Cloche des notifications */
.btn-notif { position: relative; }
.btn-notif .compteur { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--orange); color: #3a2600; font-size: .7rem; font-weight: 800; display: grid; place-items: center; }
.vignette { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none; background: var(--fond); border: 1px solid var(--bord); }
li.nouveau { background: var(--vert-clair); }

/* Graphique en barres simple (évolution mensuelle) */
.barres { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding: 10px 4px 0; }
.barres .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.barres .paire { display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; flex: 1; }
.barres .b { width: 42%; max-width: 22px; border-radius: 4px 4px 0 0; min-height: 2px; }
.barres .b.att { background: var(--bord); }
.barres .b.enc { background: var(--vert); }
.barres .lib { font-size: .7rem; color: var(--texte-doux); white-space: nowrap; }

/* Modale et toast */
.modale-fond { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 2000; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .modale-fond { align-items: center; } }
.modale { background: var(--carte); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0; }
@media (min-width: 640px) { .modale { border-radius: 16px; } }
.modale-tete { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 0 16px; position: sticky; top: 0; background: var(--carte); z-index: 1; }
.modale-tete h2 { margin: 0; }
.modale-corps { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--bas) + 16px); transform: translateX(-50%) translateY(20px);
  background: #17211c; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 3000;
  opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100% - 32px); text-align: center;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.photo { max-width: 100%; max-height: 220px; border-radius: 10px; border: 1px solid var(--bord); display: block; margin-top: 6px; }
.info { background: var(--bleu-clair); color: var(--bleu); padding: 10px 12px; border-radius: 10px; font-size: .88rem; margin-bottom: 12px; }
.avert { background: var(--orange-clair); color: #8a5800; padding: 10px 12px; border-radius: 10px; font-size: .88rem; margin-bottom: 12px; }
:root[data-theme="sombre"] .avert { color: var(--orange); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="clair"]) .avert { color: var(--orange); } }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 10px; font-size: .9rem; }
.kv dt { color: var(--texte-doux); }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.onglets { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; }
.onglets button { border: 1px solid var(--bord); background: var(--carte); color: var(--texte); padding: 7px 12px; border-radius: 99px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.onglets button.actif { background: var(--vert); color: #fff; border-color: var(--vert); }
.menu-plus a { display: flex; gap: 12px; align-items: center; padding: 12px 4px; text-decoration: none; color: var(--texte); font-weight: 600; border-bottom: 1px solid var(--bord); }
.menu-plus a .ico { font-size: 1.3rem; width: 28px; text-align: center; }
