:root {
  --couleur-marque: #3454d1;
  --couleur-marque-fin: #7c3aed;
  --degrade-marque: linear-gradient(135deg, var(--couleur-marque) 0%, var(--couleur-marque-fin) 100%);
  --couleur-selection: #7c3aed;
  --neutre-texte: #1f2328;
  --neutre-fond: #f7f7f5;
  --neutre-bordure: #d9dad6;
  --statut-libre: #2f8f46;
  --statut-reprise: #c98a1d;
  --statut-utilisee: #8a8f98;
  --etat-succes: #2f8f46;
  --etat-attention: #c98a1d;
  --etat-erreur: #c23b3b;
  --selection-carte: #ff2d95; /* point sélectionné sur le plan : distinct du violet d'accent (boutons) */
  --rayon: 10px;
  --ombre: 0 2px 10px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  color: var(--neutre-texte);
  background: var(--neutre-fond);
}

.entete {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--degrade-marque);
  color: #fff;
  flex-wrap: wrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
  position: relative;
  z-index: 1;
}

.entete strong {
  font-size: 18px;
  letter-spacing: .2px;
}

.logo-mairie {
  width: 34px;
  height: auto;
  border-radius: 6px;
  background: #fff;
  padding: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  flex-shrink: 0;
}

.entete input {
  flex: 1 1 260px;
  min-height: 44px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  font-size: 16px;
}

.badge-maquette {
  font-size: 13px;
  opacity: .85;
  margin-left: auto;
}

.sync-badge {
  font-size: 13px;
  background: rgba(255, 255, 255, .2);
  padding: 4px 10px;
  border-radius: 10px;
  margin-left: auto;
  white-space: nowrap;
}

.utilisateur-connecte {
  font-size: 14px;
  margin-left: auto;
  white-space: nowrap;
}

.utilisateur-connecte a { color: #fff; }

.btn-modifier {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  min-height: 44px;
  margin: 8px 0 16px;
  padding: 0 16px;
  background: var(--couleur-selection);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: .5px;
  cursor: pointer;
  transition: filter .15s ease;
}

.btn-modifier:hover { filter: brightness(1.08); }

.connexion-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.connexion-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
  padding: 24px;
  border: 1px solid var(--neutre-bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
}

.connexion-form h1 { font-size: 20px; margin: 0 0 8px; }

.logo-mairie-connexion {
  width: 64px;
  height: auto;
  align-self: center;
  margin-bottom: 4px;
}

.connexion-form label { font-weight: 600; }

.connexion-form input {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--neutre-bordure);
  border-radius: 6px;
  font-size: 16px;
}

.connexion-form button {
  min-height: 44px;
  margin-top: 8px;
  background: var(--couleur-marque);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: filter .15s ease;
}

.connexion-form button:hover { filter: brightness(1.08); }

.connexion-form .erreur {
  background: #fdecec;
  color: var(--etat-erreur, #c23b3b);
  padding: 8px 10px;
  border-radius: 6px;
  margin: 0;
}

.contenu {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  gap: 16px;
  padding: 16px;
  box-sizing: border-box;
}

@media (min-width: 1024px) {
  .contenu { flex-direction: row; }
  .plan-zone { flex: 1 1 65%; }
  .plan-zone-v2 { flex: 1 1 65%; }
  .fiche { flex: 1 1 35%; }
}

.plan-zone-v2 {
  aspect-ratio: 4000 / 1502;
  align-self: flex-start;
  width: 100%;
}

@media (max-width: 1023px) {
  /* Le ratio 4000x1502 (très plat) rend la carte minuscule en portrait mobile
     et fait déborder les boutons de zoom hors du cadre arrondi (overflow:
     hidden plus bas) : on fixe une hauteur généreuse à la place du ratio. */
  .plan-zone-v2 {
    aspect-ratio: auto;
    height: 65vh;
    min-height: 320px;
    transition: height .2s ease;
  }

  /* Une fois une concession sélectionnée, la carte cède la place à la fiche
     (lecture/édition) plutôt que de garder 65% de l'écran en permanence. */
  .contenu.a-selection .plan-zone-v2 {
    height: 30vh;
    min-height: 200px;
  }
}

/* Téléphone tourné à l'horizontale : écran large et court, comme un ordinateur
   — carte et fiche côte à côte plutôt qu'empilées (demande du 23/10/2026). */
@media (max-width: 1023px) and (orientation: landscape) {
  .contenu { flex-direction: row; }
  .plan-zone-v2 {
    aspect-ratio: auto;
    height: auto;
    min-height: 0;
    flex: 1 1 60%;
  }
  .contenu.a-selection .plan-zone-v2 { height: auto; min-height: 0; }
  .fiche { flex: 1 1 40%; }
}

.plan-zone {
  overflow: auto;
  background: #111;
  position: relative;
}

.plan-cadre {
  position: relative;
  width: 4000px;
}

#planImg {
  display: block;
  width: 100%;
  height: auto;
}

#marqueurs { position: absolute; inset: 0; }

.marqueur {
  position: absolute;
  width: 26px;
  height: 26px;
  margin-left: -13px;
  margin-top: -13px;
  border-radius: 50%;
  border: 2px solid #fff;
  cursor: pointer;
  background: var(--statut-utilisee);
}

.marqueur.statut-libre { background: var(--statut-libre); }
.marqueur.statut-en_cours_reprise { background: var(--statut-reprise); }
.marqueur.sel {
  background: var(--couleur-selection);
  box-shadow: 0 0 0 4px rgba(30, 111, 217, .4);
}

.badge-v2 {
  font-size: 12px;
  background: rgba(255, 255, 255, .25);
  padding: 1px 8px;
  border-radius: 8px;
  margin-left: 6px;
  vertical-align: middle;
}

.plan-zone-v2 {
  position: relative;
  background: #111;
  overflow: hidden;
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  border: 1px solid var(--neutre-bordure);
}

#svgPlan {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  /* empêche le menu contextuel natif (copier/télécharger/partager l'image) que
     l'appui long sur la photo aérienne déclenche sur mobile, en plus de notre
     vignette — iOS/Safari. Android/Chrome géré en JS (contextmenu, plan-v2.js). */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.zone {
  fill: var(--statut-utilisee);
  fill-opacity: .55;
  stroke: #fff;
  stroke-width: 4;
  cursor: pointer;
}

.zone.statut-libre, .zone.statut-en_cours_reprise {
  fill-opacity: 1;
  stroke: #1f2328; /* contour sombre : se distingue du blanc des points "utilisée" voisins */
  stroke-width: 5;
}
.zone.statut-libre { fill: var(--statut-libre); }
.zone.statut-en_cours_reprise { fill: var(--statut-reprise); }
.zone.sel {
  fill: var(--selection-carte);
  fill-opacity: 1;
  stroke: #1f2328;
  stroke-width: 7;
}
.zone.sel-edition {
  fill: var(--etat-erreur);
  fill-opacity: .9;
  stroke: #fff;
  stroke-width: 7;
}
.zone.zone-masquee { fill-opacity: .08; stroke-opacity: .15; pointer-events: none; }

#filtreStatut {
  min-height: 44px;
  padding: 0 10px;
  border-radius: 6px;
  border: none;
  font-size: 15px;
}

.controles-zoom {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ma-position {
  fill: #1e6fd9;
  stroke: #fff;
  stroke-width: 3;
  pointer-events: none;
}

.precision-position {
  fill: #1e6fd9;
  fill-opacity: .15;
  stroke: #1e6fd9;
  stroke-opacity: .3;
  pointer-events: none;
}

#btnMaPosition.actif { background: var(--couleur-selection); color: #fff; }
#btnNumeros.actif { background: var(--couleur-selection); color: #fff; }

#etiquettes { display: none; }
#etiquettes.visible { display: block; }
.numero-zone {
  font-size: 20px;
  font-weight: 700;
  fill: #fff;
  stroke: #000;
  stroke-width: 3px;
  paint-order: stroke;
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}

.survol-concession {
  display: none;
  position: absolute;
  z-index: 20;
  top: 0;
  left: 0;
  max-width: 180px;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--ombre);
  padding: 8px;
  font-size: 13px;
  pointer-events: none;
}
.survol-concession.visible { display: block; }
.survol-concession img {
  display: block;
  width: 100%;
  max-height: 110px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 6px;
}
.survol-concession strong { display: block; }
.survol-concession span { color: #555; }

.btn-superadmin {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 6px;
  border: none;
  background: rgba(255, 255, 255, .2);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  transition: filter .15s ease;
}

.btn-superadmin:hover { filter: brightness(1.1); }

#btnModeDeplacement.actif { background: var(--etat-attention); color: #fff; }

#svgPlan.mode-deplacement { cursor: default; }
#svgPlan.mode-deplacement .zone { cursor: grab; }

.bandeau-placement {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .3);
  font-size: 14px;
  max-width: calc(100% - 100px);
}

.bandeau-placement select { min-height: 36px; }
.bandeau-placement button { min-height: 36px; }
.bandeau-placement #indicationPlacement { display: block; margin-top: 4px; color: var(--etat-attention); font-weight: 600; }

.controles-zoom button {
  width: 44px;
  height: 44px;
  font-size: 20px;
  border: none;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  cursor: pointer;
  transition: filter .15s ease;
}

.controles-zoom button:hover { filter: brightness(.95); }

.fiche {
  overflow: auto;
  padding: 20px;
  background: #fff;
  border: 1px solid var(--neutre-bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
}

.fiche-vide { color: #666; }

.fiche h2 { margin-top: 0; }

.fiche .row {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--neutre-bordure);
}

.fiche .row label { flex: 0 0 160px; font-weight: 600; color: #555; }
.fiche .row span { flex: 1; }

.fiche ul { margin: 4px 0; padding-left: 20px; }

.fiche .statut-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  color: #fff;
  font-size: 13px;
}

.fiche .photo { max-width: 100%; border-radius: 6px; margin-top: 8px; }

.galerie-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.galerie-photos img {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--neutre-bordure);
  cursor: zoom-in;
  transition: transform .15s ease, box-shadow .15s ease;
}

.galerie-photos img:hover { transform: scale(1.03); box-shadow: var(--ombre); }

.galerie-photos img.photo-en-attente { opacity: .6; border-style: dashed; cursor: default; }
.galerie-photos img.photo-en-attente:hover { transform: none; box-shadow: none; }

.photo-item {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 160px;
}

.photo-item figcaption { font-size: 12px; color: #666; }

.btn-photo-principale {
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--neutre-bordure);
  border-radius: 6px;
  background: #fff;
  color: #555;
  cursor: pointer;
}

.btn-photo-principale.actif {
  background: var(--etat-attention);
  border-color: var(--etat-attention);
  color: #fff;
  font-weight: 600;
}

.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}

.lightbox-overlay.ouvert { display: flex; }

.lightbox-overlay img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .5);
  cursor: default;
}

.lightbox-fermer {
  position: absolute;
  top: 16px;
  right: 20px;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.note-auteur { color: #777; font-size: 13px; }

.form-inline-ajout {
  display: flex;
  gap: 8px;
  margin: 10px 0 20px;
  flex-wrap: wrap;
}

.form-inline-ajout textarea {
  flex: 1 1 100%;
  min-height: 60px;
  padding: 8px 10px;
  border: 1px solid var(--neutre-bordure);
  border-radius: 6px;
  font-family: inherit;
  font-size: 16px;
}

.form-inline-ajout input[type="file"] { flex: 1 1 auto; }

.form-inline-ajout button {
  min-height: 44px;
  padding: 0 14px;
  background: var(--couleur-marque);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: filter .15s ease;
}

.form-inline-ajout button:hover { filter: brightness(1.08); }

datalist { display: none; }

.edition-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

.edition-page-large { max-width: 900px; }

.confirmation {
  background: #eaf6ec;
  color: var(--etat-succes);
  padding: 8px 10px;
  border-radius: 6px;
}

.form-fiche {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
  padding: 16px;
  border: 1px solid var(--neutre-bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  margin-bottom: 20px;
}

.form-fiche label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 600;
}

.form-fiche input,
.form-fiche select,
.form-fiche textarea {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--neutre-bordure);
  border-radius: 6px;
  font-size: 16px;
  font-weight: normal;
  font-family: inherit;
}

.form-fiche textarea { padding: 10px 12px; min-height: 80px; }

.radios-statut {
  border: 1px solid var(--neutre-bordure);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.radios-statut legend { font-weight: 600; padding: 0 4px; }

.radio-statut {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: normal;
  min-height: 44px;
}

.radio-statut input { width: 20px; height: 20px; }

.form-fiche button {
  min-height: 44px;
  background: var(--couleur-marque);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: filter .15s ease;
}

.form-fiche button:hover { filter: brightness(1.08); }

.liste-defunts { list-style: none; padding: 0; }

.liste-defunts li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--neutre-bordure);
}

.form-inline { display: inline; margin-left: auto; }

.table-historique {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

.table-historique th,
.table-historique td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--neutre-bordure);
  vertical-align: top;
}

.table-historique th { background: var(--neutre-fond); }

.lien-secondaire {
  display: inline-block;
  margin: 4px 0 16px;
  color: var(--couleur-selection);
}

.liens-secondaires {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.liens-secondaires .lien-secondaire { margin: 0; font-size: 14px; }

.form-inline button {
  min-height: 36px;
  padding: 0 10px;
  background: var(--etat-erreur);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
