:root {
  --bleu: #1d4ed8;
  --bleu-fonce: #1e3a8a;
  --bleu-hover: #1e40af;
  --bleu-pale: #dbeafe;
  --bleu-pale-2: #eff6ff;
  --or: #fbbf24;
  --or-fonce: #92400e;
  --or-pale: #fef3c7;
  --rouge: #ce0500;
  --rouge-pale: #ffe9e9;
  --vert: #18753c;
  --vert-pale: #dffee6;
  --orange: #b34000;
  --orange-pale: #ffe9d9;
  --texte: #161616;
  --texte-2: #666;
  --fond: #f5f6f8;
  --carte: #ffffff;
  --bord: #e5e5e5;
  --radius: 12px;
  --ombre: 0 1px 3px rgba(15, 40, 90, 0.08), 0 4px 12px rgba(15, 40, 90, 0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--fond);
  color: var(--texte);
  line-height: 1.45;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

#app { max-width: 640px; margin: 0 auto; }

button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
a { color: var(--bleu); }

/* ---------- En-tête ---------- */
.entete {
  background: linear-gradient(135deg, var(--bleu-fonce), var(--bleu));
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.entete .logo {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.entete .logo span { color: var(--or); }
.entete .commune {
  font-size: 13px;
  opacity: 0.85;
  margin-top: 1px;
}
.entete .profil-chip {
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.entete .retour {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  padding: 4px 6px 4px 0;
}
.entete .titre-page {
  font-size: 17px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Contenu ---------- */
.contenu { padding: 16px; }

.section-titre {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--texte-2);
  margin: 22px 4px 10px;
}
.section-titre:first-child { margin-top: 4px; }

/* ---------- Bannière alertes ---------- */
.banniere-alerte {
  background: var(--rouge-pale);
  border: 1px solid #ffc2c2;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
}
.banniere-alerte .ico { font-size: 18px; line-height: 1.3; }
.banniere-alerte strong { color: var(--rouge); }
.banniere-alerte ul { margin: 4px 0 0 16px; }
.banniere-alerte li { margin-top: 2px; }
.banniere-alerte a { color: var(--rouge); font-weight: 600; }

/* ---------- Carte événement ---------- */
.carte-evt {
  background: var(--carte);
  border-radius: var(--radius);
  box-shadow: var(--ombre);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
}
.carte-evt:active { border-color: var(--bleu); }
.carte-evt .ligne1 {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.carte-evt .emoji { font-size: 22px; }
.carte-evt h3 { font-size: 16.5px; font-weight: 700; flex: 1; }
.carte-evt .jmoins {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--or-fonce);
  background: var(--or-pale);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.carte-evt .jmoins.urgent { color: var(--rouge); background: var(--rouge-pale); }
.carte-evt .jmoins.passe { color: var(--texte-2); background: var(--fond); }
.carte-evt .meta {
  font-size: 13.5px;
  color: var(--texte-2);
  margin-top: 3px;
}
.carte-evt .retard-note {
  font-size: 13px;
  color: var(--rouge);
  font-weight: 600;
  margin-top: 6px;
}

/* barre de progression */
.progress {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.progress .barre {
  flex: 1;
  height: 7px;
  background: var(--bord);
  border-radius: 999px;
  overflow: hidden;
}
.progress .barre > div {
  height: 100%;
  background: var(--bleu);
  border-radius: 999px;
  transition: width 0.3s;
}
.progress .barre > div.complet { background: var(--vert); }
.progress .pct {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--texte-2);
  min-width: 34px;
  text-align: right;
}

/* ---------- Fiche événement ---------- */
.fiche-tete {
  background: var(--carte);
  border-radius: var(--radius);
  box-shadow: var(--ombre);
  padding: 16px;
  margin-bottom: 16px;
}
.fiche-tete h2 {
  font-size: 20px;
  font-weight: 800;
  display: flex;
  gap: 8px;
  align-items: center;
}
.fiche-tete .infos {
  margin-top: 10px;
  display: grid;
  gap: 6px;
  font-size: 14.5px;
}
.fiche-tete .infos div { display: flex; gap: 8px; }
.fiche-tete .infos .lbl { color: var(--texte-2); min-width: 92px; }
.fiche-tete .desc {
  margin-top: 10px;
  font-size: 14px;
  color: var(--texte-2);
  border-top: 1px solid var(--bord);
  padding-top: 10px;
}

/* ---------- Bloc service ---------- */
.bloc-service {
  background: var(--carte);
  border-radius: var(--radius);
  box-shadow: var(--ombre);
  margin-bottom: 12px;
  overflow: hidden;
}
.bloc-service .tete {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--bord);
}
.bloc-service .pastille {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.bloc-service .tete h4 { font-size: 15px; font-weight: 700; flex: 1; }
.bloc-service .tete .compte {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--texte-2);
}
.bloc-service .tete .compte.ok { color: var(--vert); }
.bloc-service.mien { border: 2px solid var(--bleu); }
.bloc-service.mien .tete { background: var(--bleu-pale-2); }
.badge-moi {
  font-size: 11px;
  font-weight: 700;
  color: var(--bleu);
  background: var(--bleu-pale);
  padding: 2px 5px;
  border-radius: 999px;
}

.tache {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--fond);
}
.tache:last-of-type { border-bottom: none; }
.tache input[type="checkbox"] {
  width: 21px; height: 21px;
  accent-color: var(--bleu);
  margin-top: 1px;
  flex-shrink: 0;
}
.tache .lib { flex: 1; font-size: 14.5px; }
.tache.faite .lib { color: var(--texte-2); text-decoration: line-through; }
.tache .echeance {
  font-size: 12px;
  font-weight: 600;
  color: var(--texte-2);
  white-space: nowrap;
  margin-top: 2px;
}
.tache .echeance.retard { color: var(--rouge); }

.ajout-tache {
  display: flex;
  gap: 8px;
  padding: 10px 14px 12px;
}
.ajout-tache input {
  flex: 1;
  border: 1px solid var(--bord);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 16px;
}
.ajout-tache button {
  background: var(--bleu-pale);
  color: var(--bleu);
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 14px;
}

/* ---------- Commentaires ---------- */
.commentaires {
  background: var(--carte);
  border-radius: var(--radius);
  box-shadow: var(--ombre);
  padding: 14px;
  margin-bottom: 12px;
}
.commentaires h4 { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.commentaire {
  padding: 10px 12px;
  background: var(--fond);
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 14px;
}
.commentaire .auteur {
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 3px;
}
.commentaire .auteur .quand {
  font-weight: 400;
  color: var(--texte-2);
  margin-left: auto;
}
.form-commentaire { display: flex; gap: 8px; margin-top: 10px; }
.form-commentaire input {
  flex: 1;
  border: 1px solid var(--bord);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 16px;
}
.form-commentaire button {
  background: var(--bleu);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 700;
  font-size: 14px;
}

/* ---------- Formulaires ---------- */
.formulaire {
  background: var(--carte);
  border-radius: var(--radius);
  box-shadow: var(--ombre);
  padding: 16px;
  display: grid;
  gap: 14px;
}
.champ { display: grid; gap: 5px; }
.champ label { font-size: 13.5px; font-weight: 600; }
.champ input, .champ select, .champ textarea {
  border: 1px solid var(--bord);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
  background: #fff;
  width: 100%;
}
.champ textarea { resize: vertical; min-height: 70px; }
.champ-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
}
.champ-check input { width: 20px; height: 20px; accent-color: var(--bleu); flex-shrink: 0; }
.champ-check .aide { color: var(--texte-2); font-size: 12.5px; }

.btn-principal {
  background: var(--bleu);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 15.5px;
  font-weight: 700;
  width: 100%;
}
.btn-principal:active { background: var(--bleu-hover); }

/* ---------- Mes tâches ---------- */
.groupe-taches { margin-bottom: 18px; }
.groupe-taches .evt-lien {
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  margin: 0 4px 8px;
}
.groupe-taches .evt-lien h4 { font-size: 15px; font-weight: 700; }
.groupe-taches .evt-lien .date { font-size: 12.5px; color: var(--texte-2); }
.groupe-taches .liste {
  background: var(--carte);
  border-radius: var(--radius);
  box-shadow: var(--ombre);
  overflow: hidden;
}
.vide {
  text-align: center;
  color: var(--texte-2);
  padding: 40px 20px;
  font-size: 14.5px;
}
.vide .ico { font-size: 40px; display: block; margin-bottom: 10px; }

/* ---------- Choix du profil ---------- */
.ecran-profil {
  padding: 40px 24px;
  text-align: center;
}
.ecran-profil .logo-grand {
  font-size: 34px;
  font-weight: 800;
  color: var(--bleu);
  letter-spacing: -0.5px;
}
.ecran-profil .logo-grand span { color: #f59e0b; }
.ecran-profil .sous-titre {
  color: var(--texte-2);
  margin: 8px 0 30px;
  font-size: 15px;
}
.ecran-profil h3 { font-size: 16px; margin-bottom: 14px; }
.choix-service {
  display: grid;
  gap: 10px;
}
.choix-service button {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--radius);
  box-shadow: var(--ombre);
  padding: 15px;
  font-size: 15.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}
.choix-service button:active { border-color: var(--bleu); }
.choix-service .pastille { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

/* ---------- Nav basse ---------- */
.nav-basse {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--carte);
  border-top: 1px solid var(--bord);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 10;
}
.nav-basse a {
  text-decoration: none;
  color: var(--texte-2);
  font-size: 10px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 2px 5px;
  border-radius: 10px;
  position: relative;
  white-space: nowrap;
}
.nav-basse a .ico { font-size: 20px; }
.nav-basse a.actif { color: var(--bleu); }
.nav-basse a .badge {
  position: absolute;
  top: -2px; right: 8px;
  background: var(--rouge);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  min-width: 17px;
  height: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ---------- Demandes inter-services / duplication / planning ---------- */
.tache .par {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--bleu);
  margin-top: 1px;
}
.btn-secondaire {
  margin-top: 12px;
  width: 100%;
  background: var(--bleu-pale);
  color: var(--bleu);
  border: none;
  border-radius: 10px;
  padding: 11px;
  font-size: 14.5px;
  font-weight: 700;
}
.carte-evt.compacte { padding: 12px 14px; }
.section-titre .charge {
  text-transform: none;
  letter-spacing: 0;
  color: var(--orange);
  font-weight: 700;
}

/* ---------- Tableau de bord élus ---------- */
.grille-tb {
  margin-top: 10px;
  border-top: 1px solid var(--fond);
  padding-top: 6px;
}
.ligne-tb {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 0;
  font-size: 13.5px;
}
.ligne-tb .pastille { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.ligne-tb .nom { flex: 1; color: var(--texte-2); font-weight: 600; }
.ligne-tb .statut { font-weight: 700; color: var(--texte-2); font-size: 12.5px; }
.ligne-tb .statut.ok { color: var(--vert); }
.ligne-tb .statut.retard { color: var(--rouge); }

.note-bas {
  text-align: center;
  font-size: 12px;
  color: var(--texte-2);
  margin: 24px 0 8px;
}
.aide { color: var(--texte-2); font-size: 12.5px; }

/* ---------- Bandeau notifications ---------- */
.banniere-notifs {
  background: var(--bleu-pale-2);
  border: 1px solid var(--bleu-pale);
  border-radius: var(--radius);
  padding: 11px 14px;
  margin-bottom: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13.5px;
}
.banniere-notifs span { flex: 1; }
.banniere-notifs button {
  background: var(--bleu);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 13.5px;
  white-space: nowrap;
}

/* ---------- Journal d'activité & météo ---------- */
.ligne-journal {
  font-size: 13px;
  color: var(--texte-2);
  padding: 6px 2px;
  border-bottom: 1px solid var(--fond);
}
.ligne-journal:last-child { border-bottom: none; }
.ligne-journal .quand {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--texte-2);
  opacity: 0.7;
  margin-right: 4px;
}
.ligne-journal strong { color: var(--texte); }
#meteo-slot:empty { display: none; }

/* ---------- Centre de notifications ---------- */
.notif {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  background: var(--carte);
  border-radius: var(--radius);
  box-shadow: var(--ombre);
  padding: 12px 14px;
  margin-bottom: 10px;
  text-decoration: none;
  color: inherit;
  border-left: 3px solid transparent;
}
.notif.nouvelle {
  border-left-color: var(--or);
  background: linear-gradient(90deg, var(--or-pale), var(--carte) 30%);
}
.notif .ico { font-size: 19px; line-height: 1.3; }
.notif .corps { flex: 1; font-size: 14px; }
.notif .corps .evt {
  display: block;
  font-size: 12px;
  color: var(--texte-2);
  margin-top: 3px;
}

/* iOS : pas de zoom au double-tap, pas de zoom pincement (app figée comme une native) */
html { touch-action: manipulation; }
input, select, textarea { touch-action: manipulation; }

/* ---------- Balayage pour effacer ---------- */
.notif-wrap { position: relative; margin-bottom: 10px; }
.notif-wrap .notif { margin-bottom: 0; position: relative; z-index: 1; }
.notif-fond {
  position: absolute;
  inset: 0;
  background: var(--rouge);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 20px;
  font-size: 20px;
}
.ligne-titre { display: flex; align-items: baseline; justify-content: space-between; }
.ligne-titre a {
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--bleu);
}
