:root {
  --fond: #f4f5f1; --carte: #ffffff; --texte: #1c211d; --doux: #5d665f; --ligne: #dfe3dc;
  --vert: #14532d; --vert-clair: #dcefe2; --rouge: #a3241c; --rouge-clair: #f9e2df;
  --orange: #8a5300; --orange-clair: #fbedd4; --bouton: #e9ece6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #111512; --carte: #1b211d; --texte: #edf0ec; --doux: #a3ada5; --ligne: #303832;
    --vert: #7fd19c; --vert-clair: #1c3626; --rouge: #f49b92; --rouge-clair: #3e1d1a;
    --orange: #eabb6d; --orange-clair: #3a2c13; --bouton: #2a322c;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fond); color: var(--texte); }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 21px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; border-radius: 10px; background: var(--bouton); padding: 10px 14px; cursor: pointer; min-height: 44px; }
button.principal { background: var(--vert); color: var(--carte); font-weight: 600; }
button.lien { background: none; padding: 8px 0; min-height: 0; color: var(--vert); text-decoration: underline; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--ligne); border-radius: 10px; background: var(--carte); min-height: 44px; font-size: 16px; }
label { display: block; font-size: 14px; color: var(--doux); margin-bottom: 12px; }
label input, label select { margin-top: 4px; color: var(--texte); }
a { color: var(--vert); }

.haut { position: sticky; top: 0; z-index: 800; background: var(--fond); padding: calc(env(safe-area-inset-top) + 10px) 16px 0; border-bottom: 1px solid var(--ligne); }
.haut-ligne { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.onglets { display: flex; gap: 2px; margin-top: 8px; }
.onglets button { flex: 1; background: none; border-radius: 0; border-bottom: 3px solid transparent; padding: 8px 2px; color: var(--doux); font-size: 15px; }
.onglets button.actif { color: var(--texte); font-weight: 600; border-bottom-color: var(--vert); }
.vues { display: flex; gap: 8px; padding: 12px 16px 0; }
.vues button { flex: 1; min-height: 38px; padding: 6px; font-size: 14px; }
.vues button.actif { background: var(--vert-clair); color: var(--vert); font-weight: 600; }
.icone { min-width: 44px; padding: 8px; }

main { padding: 12px 16px calc(env(safe-area-inset-bottom) + 28px); max-width: 720px; margin: 0 auto; }
.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.annonce { display: block; width: 100%; text-align: left; font-weight: 400; border: 1px solid var(--ligne); background: var(--carte); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.annonce-tete { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.annonce-titre { font-weight: 600; }
.note { flex: none; min-width: 52px; text-align: center; font-weight: 700; border-radius: 10px; padding: 5px 7px; font-variant-numeric: tabular-nums; }
.note.haute { background: var(--vert-clair); color: var(--vert); }
.note.moyenne { background: var(--orange-clair); color: var(--orange); }
.note.basse { background: var(--rouge-clair); color: var(--rouge); }
.doux { color: var(--doux); font-size: 14px; }
.reste { font-weight: 700; font-variant-numeric: tabular-nums; }
.positif { color: var(--vert); } .negatif { color: var(--rouge); }
.etiquettes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.etiquette { font-size: 13px; border-radius: 999px; padding: 2px 9px; background: var(--bouton); }
.etiquette.grave { background: var(--rouge-clair); color: var(--rouge); }
.etiquette.attention { background: var(--orange-clair); color: var(--orange); }
.etiquette.bon { background: var(--vert-clair); color: var(--vert); }
.vide { text-align: center; color: var(--doux); padding: 34px 12px; }

#carte { height: calc(100vh - 210px); min-height: 340px; border-radius: 14px; border: 1px solid var(--ligne); }

.fiche-retour { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gros-chiffre { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.resume { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.resume .note { font-size: 24px; min-width: 72px; padding: 10px 6px; }
.photos { display: flex; gap: 8px; overflow-x: auto; margin: 0 -14px 12px; padding: 0 14px; }
.photos img { height: 150px; border-radius: 10px; object-fit: cover; }
.alerte { border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 15px; }
.alerte.grave { background: var(--rouge-clair); color: var(--rouge); }
.alerte.attention { background: var(--orange-clair); color: var(--orange); }
.alerte.ok { background: var(--vert-clair); color: var(--vert); }
.lignes { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.lignes td { padding: 6px 0; border-bottom: 1px solid var(--ligne); vertical-align: top; }
.lignes td:last-child { text-align: right; white-space: nowrap; padding-left: 12px; }
.lignes tr.total td { font-weight: 700; border-bottom: 0; }
.deux { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.colonne { border: 1px solid var(--ligne); border-radius: 12px; padding: 10px; }
.colonne.meilleure { border-color: var(--vert); border-width: 2px; }
.poste { padding: 10px 0; border-bottom: 1px solid var(--ligne); }
.poste-tete { display: flex; justify-content: space-between; gap: 10px; }
.choix { display: flex; gap: 6px; margin-top: 6px; }
.choix button { flex: 1; min-height: 38px; font-size: 13px; padding: 4px; }
.choix button.actif.ok { background: var(--vert-clair); color: var(--vert); font-weight: 600; }
.choix button.actif.a_faire { background: var(--rouge-clair); color: var(--rouge); font-weight: 600; }
.choix button.actif.inconnu { background: var(--orange-clair); color: var(--orange); font-weight: 600; }
.actions { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 10px 0 calc(env(safe-area-inset-bottom) + 8px); background: var(--fond); }
.actions button { flex: 1; padding: 10px 4px; }
.actions .valider { background: var(--vert); color: var(--carte); font-weight: 600; }
.actions .supprimer { color: var(--rouge); }
.ligne-ajout { display: grid; grid-template-columns: 1fr 100px auto; gap: 6px; margin-top: 10px; }
details summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.section { margin-bottom: 8px; }
.message { position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 18px); z-index: 1000; background: var(--texte); color: var(--fond); padding: 12px 14px; border-radius: 12px; text-align: center; }
.connexion { max-width: 380px; margin: 16vh auto 0; padding: 16px; width: calc(100% - 32px); }
.leaflet-popup-content button { width: 100%; margin-top: 6px; }
@media (min-width: 620px) { .deux { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
