:root {
  --vert: #275317;
  --vert-fonce: #1b3a10;
  --vert-clair: #e8f0e4;
  --or: #c9a227;
  --or-clair: #fbf5df;
  --gris: #6b7280;
  --gris-clair: #f3f4f1;
  --bord: #e2e4dc;
  --texte: #1f2a1a;
  --rouge: #b42318;
  --rouge-clair: #fdecea;
  --orange: #b54708;
  --orange-clair: #fef0e1;
  --bleu: #175cd3;
  --bleu-clair: #e8f0fd;
  --rayon: 12px;
  --ombre: 0 1px 3px rgba(20, 40, 10, .08), 0 4px 14px rgba(20, 40, 10, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--texte); background: var(--gris-clair); font-size: 15px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; color: var(--vert); margin: 0 0 .6em; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
a { color: var(--vert); }
.cache { display: none !important; }
.muted { color: var(--gris); font-size: .9em; }
.centre { text-align: center; }

/* ---------- Écran de connexion ---------- */
.connexion { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: linear-gradient(160deg, #fff 0%, var(--or-clair) 55%, var(--vert-clair) 100%); }
.connexion .carte { width: 100%; max-width: 380px; }
.connexion img.logo { display: block; width: 120px; margin: 0 auto 10px; }
.connexion .slogan { text-align: center; color: var(--or); font-style: italic; margin-bottom: 18px; font-family: Georgia, serif; }
.signature { text-align: center; font-size: .8rem; color: var(--gris); margin-top: 18px; }

/* ---------- Barre du haut + menu latéral ---------- */
.barre { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  background: var(--vert); color: #fff; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
.barre .titre { flex: 1; font-family: Georgia, serif; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icone-btn { background: none; border: 0; color: inherit; width: 40px; height: 40px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.icone-btn:active { background: rgba(255,255,255,.15); }
.icone-btn svg { width: 24px; height: 24px; }
.pastille { position: absolute; top: 3px; right: 3px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--or);
  color: #1b1b1b; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

.voile { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; opacity: 0; pointer-events: none; transition: opacity .2s; }
.voile.ouvert { opacity: 1; pointer-events: auto; }
.tiroir { position: fixed; top: 0; bottom: 0; left: 0; width: 280px; max-width: 85vw; background: #fff; z-index: 31;
  transform: translateX(-102%); transition: transform .22s ease; display: flex; flex-direction: column; overflow-y: auto; }
.tiroir.ouvert { transform: none; }
.tiroir .entete { padding: 18px 16px 14px; padding-top: max(18px, env(safe-area-inset-top)); border-bottom: 1px solid var(--bord);
  display: flex; gap: 12px; align-items: center; }
.tiroir .entete img { width: 44px; }
.tiroir .entete .nom { font-weight: 600; }
.tiroir nav { padding: 8px 0; flex: 1; }
.tiroir .groupe { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gris); padding: 12px 18px 4px; }
.tiroir a { display: flex; align-items: center; gap: 12px; padding: 11px 18px; color: var(--texte); text-decoration: none; }
.tiroir a.actif { background: var(--vert-clair); color: var(--vert); font-weight: 600; border-right: 3px solid var(--vert); }
.tiroir a .compte { margin-left: auto; background: var(--or); color: #1b1b1b; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.tiroir .pied { padding: 12px 18px 20px; font-size: .78rem; color: var(--gris); border-top: 1px solid var(--bord); }

main { padding: 14px; max-width: 980px; margin: 0 auto; padding-bottom: 60px; }

/* ---------- Cartes, listes ---------- */
.carte { background: #fff; border-radius: var(--rayon); box-shadow: var(--ombre); padding: 16px; margin-bottom: 14px; }
.grille { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: #fff; border-radius: var(--rayon); box-shadow: var(--ombre); padding: 12px 14px; }
.stat .val { font-size: 1.6rem; font-weight: 700; color: var(--vert); font-family: Georgia, serif; }
.stat .lib { font-size: .82rem; color: var(--gris); }
.ligne { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--bord); }
.ligne:last-child { border-bottom: 0; }
.ligne .corps { flex: 1; min-width: 0; }
.ligne .corps .t { font-weight: 600; }
.ligne.cliquable { cursor: pointer; }
.vide { text-align: center; color: var(--gris); padding: 18px 8px; }

.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.b-vert { background: var(--vert-clair); color: var(--vert); }
.b-rouge { background: var(--rouge-clair); color: var(--rouge); }
.b-orange { background: var(--orange-clair); color: var(--orange); }
.b-bleu { background: var(--bleu-clair); color: var(--bleu); }
.b-gris { background: #eceee8; color: var(--gris); }
.b-or { background: var(--or-clair); color: #7a5d00; }

/* ---------- Formulaires ---------- */
label { display: block; font-weight: 600; font-size: .88rem; margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 11px 12px; border: 1px solid var(--bord); border-radius: 10px; background: #fff; color: var(--texte);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(39,83,23,.25); border-color: var(--vert); }
.case { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 12px 0; }
.case input { width: auto; margin-top: 3px; }
.rangee { display: flex; gap: 10px; flex-wrap: wrap; }
.rangee > * { flex: 1 1 140px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; border: 0;
  border-radius: 10px; padding: 11px 16px; cursor: pointer; background: var(--vert); color: #fff; text-decoration: none; }
.btn:active { background: var(--vert-fonce); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.large { width: 100%; padding: 14px; font-size: 1rem; }
.btn.or { background: var(--or); color: #1b1b1b; }
.btn.clair { background: var(--vert-clair); color: var(--vert); }
.btn.rouge { background: var(--rouge); }
.btn.lien { background: none; color: var(--vert); padding: 6px 4px; }
.btn.petit { padding: 7px 11px; font-size: .85rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.onglets { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.onglets button { flex: 0 0 auto; border: 1px solid var(--bord); background: #fff; border-radius: 999px; padding: 8px 14px; font: inherit;
  font-size: .9rem; cursor: pointer; color: var(--texte); }
.onglets button.actif { background: var(--vert); color: #fff; border-color: var(--vert); }

/* ---------- Pointage ---------- */
.horloge { font-family: Georgia, serif; font-size: 2.6rem; color: var(--vert); text-align: center; letter-spacing: .02em; }
.etat-jour { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.etat-jour div { background: var(--gris-clair); border-radius: 10px; padding: 10px; text-align: center; }
.etat-jour b { display: block; font-size: 1.2rem; }
.camera { position: relative; background: #000; border-radius: var(--rayon); overflow: hidden; aspect-ratio: 3 / 4; max-height: 62vh; margin: 0 auto; }
.camera video, .camera canvas, .camera img { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera .cadre { position: absolute; inset: 18%; border: 3px solid var(--or); border-radius: 16px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.camera .rond { position: absolute; inset: 12% 15%; border: 3px solid var(--or); border-radius: 50%; }
.camera .info { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px; color: #fff; text-align: center;
  background: linear-gradient(transparent, rgba(0,0,0,.7)); font-size: .9rem; }
.miroir { transform: scaleX(-1); }
.etapes { display: flex; gap: 6px; justify-content: center; margin-bottom: 12px; }
.etapes span { width: 34px; height: 5px; border-radius: 3px; background: var(--bord); }
.etapes span.fait { background: var(--vert); }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--bord); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gris); font-weight: 600; }

/* ---------- Rapport ---------- */
.champ-rapport { margin-bottom: 12px; }
.champ-rapport .lib { font-size: .8rem; font-weight: 700; color: var(--vert); text-transform: uppercase; letter-spacing: .04em; }
.champ-rapport .txt { white-space: pre-wrap; }
.commentaire { background: var(--or-clair); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }

/* ---------- Modale, toast ---------- */
.modale-fond { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modale { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 18px 16px 24px; }
@media (min-width: 700px) { .modale-fond { align-items: center; } .modale { border-radius: 18px; } }
.modale .fermer { float: right; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--texte); color: #fff; padding: 11px 18px;
  border-radius: 10px; z-index: 60; max-width: 90vw; box-shadow: var(--ombre); font-size: .92rem; }
.toast.erreur { background: var(--rouge); }
.toast.ok { background: var(--vert); }
.chargement { text-align: center; padding: 30px; color: var(--gris); }
.photo-mini { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--gris-clair); cursor: pointer; }
.qr-boite { display: flex; justify-content: center; padding: 10px; background: #fff; }
.qr-boite svg, .qr-boite img { width: 220px; height: 220px; }
.alerte { border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: .92rem; }
.alerte.rouge { background: var(--rouge-clair); color: var(--rouge); }
.alerte.or { background: var(--or-clair); color: #6b5200; }
.alerte.vert { background: var(--vert-clair); color: var(--vert); }

/* Rappel : mot de passe par défaut */
.bandeau-mdp { background: var(--or-clair); color: #6b5200; padding: 10px 14px; font-size: .9rem; display: flex; align-items: center;
  gap: 10px; flex-wrap: wrap; justify-content: center; border-bottom: 1px solid #efe1a8; }
.champ-mdp { display: flex; gap: 6px; align-items: center; }
.champ-mdp input { flex: 1; }
