/* Style mobile d'abord : gros boutons, champs larges */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { font-family: system-ui, sans-serif; margin: 0; background: #f5f5f0; color: #222; font-size: 18px; }
body > header { display: flex; flex-wrap: wrap; gap: .2rem; padding: .4rem .5rem; background: #2f4f3a; align-items: center; }
body > header a { color: #fff; text-decoration: none; padding: .5rem .55rem; font-size: .95rem; }
body > header .bouton { background: #fff; color: #2f4f3a; padding: .5rem .8rem; }
main { max-width: 42rem; margin: 0 auto; padding: 1rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; margin-top: 1.5rem; }
label { display: block; margin: .8rem 0; font-weight: 600; }
input, select, textarea { display: block; width: 100%; padding: .8rem; margin-top: .3rem; font-size: 1rem;
  border: 1px solid #999; border-radius: 6px; background: #fff; }
.defunt { border: 1px solid #ccc; border-radius: 6px; margin-bottom: .6rem; padding: .5rem; }
.defunt input { margin: .3rem 0; }
.bouton { display: inline-block; padding: .8rem 1.2rem; background: #2f4f3a; color: #fff; border: 0;
  border-radius: 6px; font-size: 1rem; text-decoration: none; cursor: pointer; }
.bouton.secondaire { background: #666; } .bouton.danger { background: #a32020; }
.bouton.gros { width: 100%; padding: 1.1rem; margin-top: 1rem; text-align: center; }
.carte { display: block; background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: .8rem;
  margin-bottom: .6rem; color: inherit; text-decoration: none; }
.badge { font-size: .75rem; padding: .15rem .5rem; border-radius: 10px; color: #fff; background: #777; }
.badge.archive_seule, .badge.non_verifie { background: #888; } .badge.occupe { background: #5c6bc0; } .badge.verifie_terrain { background: #2e7d32; }
.badge.ecart { background: #e65100; } .badge.libre { background: #fff; color: #555; border: 1px solid #999; } .badge.doublon { background: #c62828; }
.message { padding: .8rem; border-radius: 6px; background: #e3f2e5; }
.message.avertissement { background: #fff3cd; }
.discret { color: #666; font-size: .9rem; }
dt { font-weight: 600; margin-top: .6rem; } dd { margin: 0; }

/* ===== Page Plan : la carte occupe tout l'écran, les panneaux sont posés dessus ===== */
body.page-plan { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
body.page-plan header { flex: none; }
body.page-plan main { flex: 1; min-height: 0; max-width: none; margin: 0; padding: 0; }
body.page-plan main > .message { margin: .5rem; }
.zone-plan { position: relative; height: 100%; }
#carte-plan { height: 100%; background: #f7f7f2; }

/* Boutons posés sur la carte (en haut à gauche ; le zoom Leaflet est en haut à droite) */
.outils-carte { position: absolute; top: .6rem; left: .6rem; z-index: 1000; display: flex; gap: .4rem; }
.outils-carte .bouton { padding: .6rem .9rem; box-shadow: 0 1px 5px rgba(0, 0, 0, .4); }
#menu-ajout { position: absolute; z-index: 1000; top: 3.7rem; left: .6rem; width: min(22rem, calc(100% - 1.2rem));
  max-height: calc(100% - 4.5rem); overflow-y: auto; background: #fff; border-radius: 10px; padding: .6rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .4); }
#menu-ajout .bouton { width: 100%; margin-bottom: .4rem; text-align: left; }
#menu-ajout small { display: block; font-weight: 400; opacity: .85; font-size: .8rem; }
#boutons-decor { display: flex; flex-wrap: wrap; gap: .4rem; }
#boutons-decor .bouton { width: auto; margin: 0; padding: .55rem .8rem; }
#consigne { position: absolute; z-index: 1000; top: 3.7rem; left: .6rem; right: .6rem; margin: 0; font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35); display: flex; align-items: center; gap: .6rem; justify-content: space-between; }
#consigne .bouton { padding: .45rem .8rem; flex: none; }

/* Légende repliable, en bas à droite de la carte */
.legende-carte { position: absolute; z-index: 900; right: .6rem; bottom: 1.6rem; background: rgba(255, 255, 255, .95);
  border-radius: 8px; padding: .3rem .6rem; font-size: .85rem; box-shadow: 0 1px 5px rgba(0, 0, 0, .3); }
.legende-carte summary { cursor: pointer; font-weight: 600; }
.legende { list-style: none; padding: 0; margin: .4rem 0 0; }
.legende li { margin: .15rem 0; }
.echantillon { display: inline-block; width: 1.1rem; height: 1.1rem; border: 2px solid #fff;
  outline: 1px solid #aaa; vertical-align: middle; }

/* « Feuilles » : panneaux fixés en bas de l'écran (à droite sur grand écran) */
.feuille { position: fixed; z-index: 1100; left: 0; right: 0; bottom: 0; max-height: 48vh; max-height: 48dvh; overflow-y: auto;
  background: #fff; border-radius: 14px 14px 0 0; padding: .7rem .9rem 1rem; box-shadow: 0 -3px 14px rgba(0, 0, 0, .3); }
.feuille.feuille-haute { max-height: 88vh; max-height: 88dvh; }
.feuille h2 { margin: 0 0 .4rem; font-size: 1.1rem; }
.feuille label { margin: .45rem 0; }
.feuille input, .feuille select { padding: .55rem .7rem; }
.feuille .bouton { padding: .6rem .9rem; margin: 0 .25rem .35rem 0; }
.feuille .bouton.gros { margin-top: .4rem; }
.feuille .message { margin: 0 0 .4rem; }
.feuille p { margin: .4rem 0; }
.feuille fieldset { border: 1px solid #ccc; border-radius: 6px; margin: .6rem 0; padding: .2rem .6rem .5rem; }
.feuille legend { font-weight: 700; padding: 0 .4rem; }
.grille-champs { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.feuille-haute .grille-champs { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 900px) {
  .feuille { left: auto; right: 1rem; bottom: 1rem; width: 25rem; max-height: calc(100vh - 6rem); border-radius: 12px;
    box-shadow: 0 2px 14px rgba(0, 0, 0, .35); }
  .feuille.feuille-haute { max-height: calc(100vh - 6rem); }
  .legende-carte { right: auto; left: .6rem; bottom: 2.4rem; }
}
label.case { display: flex; align-items: center; gap: .6rem; }
label.case input { width: auto; margin: 0; transform: scale(1.5); }

/* Croix de déplacement et étiquettes sur le plan */
.poignee { display: flex; align-items: center; justify-content: center; font-size: 26px; color: #fff;
  background: rgba(255, 143, 0, .9); border-radius: 50%; border: 2px solid #fff; }
.leaflet-tooltip.etiquette-emplacement, .leaflet-tooltip.etiquette-element, .leaflet-tooltip.etiquette-apercu {
  background: none; border: 0; box-shadow: none; padding: 0; font-weight: 700; }
.leaflet-tooltip.etiquette-emplacement { color: #fff; font-size: 11px; text-shadow: 0 0 2px #000; }
.leaflet-tooltip.etiquette-emplacement.etiquette-libre { color: #333; text-shadow: none; }
.leaflet-tooltip.etiquette-element { color: #333; font-size: 13px; }
.leaflet-tooltip.etiquette-apercu { color: #0d3c78; font-size: 11px; }
.leaflet-tooltip.etiquette-emplacement::before, .leaflet-tooltip.etiquette-element::before,
.leaflet-tooltip.etiquette-apercu::before { display: none; }
/* Vue d'ensemble : les numéros des concessions seraient illisibles, on les masque jusqu'au zoom */
#carte-plan.zoom-faible .etiquette-emplacement, #carte-plan.zoom-faible .etiquette-apercu { display: none; }
button:disabled { opacity: .4; cursor: not-allowed; }
.carte-export { background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: .8rem; margin-bottom: .8rem; }
.carte-export h2 { margin-top: 0; }
.zone-danger { border-color: #c62828; margin-top: 2rem; }
.legende-carte .reglage-echelle { display: flex; align-items: center; gap: .4rem; margin: .5rem 0 .1rem; font-size: .85rem; }
.legende-carte .reglage-echelle input { width: auto; margin: 0; transform: none; }
.orientation-decor { display: flex; gap: 1.2rem; margin: .2rem 0 .6rem; }
.orientation-decor label { margin: 0; }

/* Connexion, comptes */
.formulaire-etroit { max-width: 26rem; }
.titre-site { color: #fff; font-weight: 600; padding: .5rem; }
details.compte { margin-left: auto; position: relative; }      /* le menu ☰ reste à droite de la barre */
details.compte summary { list-style: none; cursor: pointer; color: #fff; font-size: 1.3rem; padding: .3rem .6rem; border-radius: 6px; }
details.compte summary::-webkit-details-marker { display: none; }
.menu-compte { position: absolute; right: 0; top: 2.6rem; z-index: 3000; width: 16rem; background: #fff; color: #222;
  border-radius: 10px; padding: .6rem .8rem; box-shadow: 0 2px 12px rgba(0, 0, 0, .4); }
.menu-compte a { display: block; color: #2f4f3a; padding: .55rem 0; font-size: 1rem; }
.menu-compte p { margin: .2rem 0 .4rem; }
.menu-compte .bouton { width: 100%; margin-top: .4rem; }
.actions-compte { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.actions-compte form { margin: 0; }
.actions-compte .bouton { padding: .55rem .8rem; font-size: .95rem; }
.badge.desactive { background: #a32020; } .badge.provisoire { background: #8a6d00; }
.mot-de-passe-provisoire { font-family: monospace; font-size: 1.6rem; letter-spacing: .08em; background: #fff;
  border: 2px dashed #8a6d00; border-radius: 8px; padding: 1rem; text-align: center; user-select: all; word-break: break-all; }

/* En-tête : sur téléphone, Doublons et Export passent dans le menu ☰ pour que tout tienne sur une ligne */
@media (max-width: 699px) { .lien-large { display: none; } }
@media (min-width: 700px) { .lien-etroit { display: none !important; } }

/* Page Réglages */
.formulaire-reglages fieldset { border: 1px solid #ccc; border-radius: 8px; background: #fff; margin: 0 0 1rem; padding: .3rem 1rem .8rem; }
.formulaire-reglages legend { font-weight: 700; padding: 0 .4rem; }
.formulaire-reglages label { font-weight: 500; }
.formulaire-reglages input[inputmode] { max-width: 10rem; }
label.en-erreur input { border-color: #c62828; background: #fdecea; }
.erreur { color: #c62828; font-size: .9rem; display: block; }

/* Plusieurs cimetières */
.choix-cimetiere { margin: 0; flex: 1 1 5rem; min-width: 0; max-width: 11rem; }
.choix-cimetiere select { width: 100%; margin: 0; padding: .35rem .4rem; font-size: .9rem; border-radius: 6px; }
.puce-cimetiere { position: absolute; z-index: 900; left: 50%; bottom: 1.6rem; transform: translateX(-50%); max-width: 55%;
  background: rgba(255, 255, 255, .95); color: #2f4f3a; font-weight: 600; font-size: .85rem; padding: .3rem .8rem;
  border-radius: 999px; text-decoration: none; box-shadow: 0 1px 5px rgba(0, 0, 0, .3); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
form.renommer { display: flex; gap: .4rem; flex: 1 1 14rem; }
form.renommer input { margin: 0; padding: .5rem; }
/* Plusieurs cimetières : sur téléphone, le bouton « + Concession » se réduit à « + » pour laisser la place à la liste des cimetières */
@media (max-width: 699px) { .choix-cimetiere { max-width: 9rem; } }

/* Recherche */
.recherche { margin-bottom: 1rem; }
.ligne-recherche { display: flex; gap: .5rem; }
.ligne-recherche input { margin: 0; flex: 1; }
.recherche details { background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: .3rem .8rem .8rem; margin-top: .6rem; }
.recherche summary { cursor: pointer; font-weight: 600; padding: .4rem 0; }
.recherche details .bouton { margin: .4rem .4rem 0 0; }
.badge.non-placee { background: #fff; color: #666; border: 1px solid #aaa; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: 1rem 0; }

/* Journal */
.evenement .entete-evenement { display: flex; flex-wrap: wrap; gap: .3rem .8rem; align-items: baseline; }
.changements { margin: .4rem 0; padding-left: 1.2rem; font-size: .95rem; }
.changements .champ { color: #555; }
.changements s { color: #a32020; }
details.brut summary { cursor: pointer; font-size: .85rem; color: #666; }
details.brut pre { white-space: pre-wrap; word-break: break-word; font-size: .8rem; background: #f3f3ee; padding: .5rem; border-radius: 6px; }
.grille-champs.deux { grid-template-columns: 1fr 1fr; }
.entete-evenement a { color: #2f4f3a; font-weight: 600; }

/* Photos */
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: .5rem; margin-bottom: .8rem; }
.galerie img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid #ddd; background: #eee; display: block; }
.formulaire-photos { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.formulaire-photos label.bouton { margin: 0; text-align: center; }
.formulaire-photos label.occupe { opacity: .5; pointer-events: none; }
.formulaire-photos .message { flex: 1 1 100%; margin: 0; }
.photo-grande { margin: 0 0 1rem; }
.photo-grande img { max-width: 100%; height: auto; border-radius: 8px; display: block; }
.navigation-photos { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.badge.photos { background: #455a64; }

/* ===== Page d'une concession ===== */
main a:not(.bouton):not(.carte):not(.puce):not(.lien-large) { color: #2f4f3a; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.badge { white-space: nowrap; }
@media (min-width: 900px) { body.page-large main { max-width: 68rem; } }
.fil-concession { display: flex; justify-content: space-between; align-items: center; gap: 1rem; font-size: .95rem; }
.fil-concession .voisines { display: flex; gap: .4rem; }
.fil-concession .voisines a { background: #fff; border: 1px solid #ccc; border-radius: 999px; padding: .3rem .8rem; text-decoration: none; }
.entete-concession { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; margin: .8rem 0 .2rem; }
.entete-concession h1 { margin: 0; font-size: 1.7rem; line-height: 1.2; }
.entete-concession .libelle-numero { font-size: 1rem; font-weight: 400; color: #666; display: block; }
.badge.grand { font-size: .9rem; padding: .3rem .8rem; border-radius: 999px; }
.puces { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0 .8rem; }
.puce { background: #fff; border: 1px solid #d5d5cc; border-radius: 999px; padding: .2rem .7rem; font-size: .85rem; text-decoration: none; color: #333; }
.puce.ok { border-color: #2e7d32; color: #2e7d32; }
.puce.alerte { border-color: #c62828; background: #fdecea; color: #c62828; font-weight: 600; }
.actions-concession { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.actions-concession .bouton { flex: 1 1 8rem; text-align: center; }
.bloc { background: #fff; border: 1px solid #ddd; border-radius: 10px; padding: .6rem 1rem 1rem; margin-bottom: .9rem; }
.bloc h2 { margin: .4rem 0 .6rem; font-size: 1.05rem; color: #2f4f3a; }
.alerte-bloc { border-color: #c62828; background: #fff8f7; }
.alerte-bloc h2 { color: #c62828; }
.defunt-ligne { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid #eee; }
.defunt-ligne:last-child { border-bottom: 0; }
.defunt-ligne .dates { color: #666; white-space: nowrap; }
.champs { margin: 0; }
.champs dt { font-weight: 600; font-size: .85rem; color: #666; margin-top: .6rem; }
.champs dt:first-child { margin-top: 0; }
.champs dd { margin: .1rem 0 0; }
.champs dd.observations { white-space: pre-wrap; }
.vide { color: #999; font-style: italic; margin: .2rem 0; }
.colonnes-concession { display: grid; gap: 0; }
@media (min-width: 900px) { .colonnes-concession { grid-template-columns: 1fr 1fr; gap: 1rem; } }
.bas-de-page { margin: 1.5rem 0 2rem; padding-top: 1rem; border-top: 1px solid #ddd; }

/* ===== Photo aérienne de fond du plan ===== */
.fond-plan { position: absolute; left: 0; top: 0; max-width: none; max-height: none; pointer-events: none; user-select: none;
  transform-origin: 50% 50% !important; }
#fond-vide .bouton, #panneau-fond input[type=range] { width: 100%; }
#panneau-fond input[type=range] { padding: 0; }
