:root {
  --color-bg-canvas: #eef1ef;
  --color-panel-bg: #ffffff;
  --color-panel-border: #d4d8d6;
  --color-text: #24302b;
  --color-text-muted: #5c6b64;
  --color-accent: #3d5c4e;
  --color-turbine: #8a3b1f;
  --color-rotor: #c9791f;
  --color-edd: #7a7a7a;
  --color-audit-b: #1f5c8a;
  --color-audit-c: #7f8c8d;
  --color-audit-water: #2ea8a8;
  --color-audit-biodiversity: #3f8f52;
  --color-audit-security: #cc4e0c;
  --color-audit-implantation: #96591c;
  --color-audit-landscape: #b0286b;
  --color-audit-acoustic: #4a4a9c;
  /* SESSION D2.G — G = cadre du projet (demantelement/aviation/gouvernance/engagements/
     urbanisme/immobilier), teinte or/olive distincte des six autres categories. */
  --color-audit-framework: #a3821b;
  /* SESSION D2.B — couleur active du panneau Audit, permutee en JS selon l'onglet
     de categorie affiche (A=eau, B=biodiversite, ...) ; ne change jamais la semiologie
     des couches SIG officielles, uniquement l'identite visuelle du sujet d'audit. */
  --audit-active-color: var(--color-audit-water);
  --font-main: "Segoe UI", Arial, sans-serif;

  /* SESSION D1.1A — grille commune top/left 2D <-> 3D (shell unifie) */
  --ui-margin: 8px;
  --ui-gap: 8px;
  --ui-left-width: 268px;
  --ui-header-height: 48px;
  --ui-shortcut-height: 32px;

  /* SESSION D1.1A — vocabulaire de style temporaire commun (shell uniquement) */
  --ui-shell-bg: rgba(24, 26, 28, 0.88);
  --ui-shell-border: rgba(255, 255, 255, 0.14);
  --ui-shell-text: #eee;
  --ui-shell-text-muted: rgba(238, 238, 238, 0.65);
  --ui-shell-radius: 6px;
  --ui-shell-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  --ui-shell-accent: #4a7c4e;
  --ui-shell-accent-border: #6ab06e;

  /* SESSION D1.1B — panneaux de contexte bas-droite + footer commun 2D/3D */
  --ui-context-width: 252px;
  --ui-footer-height: 28px;
  --ui-warning-bg: #7a4a00;

  /* SESSION D1.2 — polish visuel final : surfaces/controles communs 2D<->3D
     (Couches, Context Panels, checkboxes/radios). Reutilise les tokens
     --ui-shell-* existants comme base ; ajoute uniquement ce qui manquait. */
  --ui-bg-secondary: #2a2d30;
  --ui-bg-hover: #3a3d40;
  --ui-border-subtle: rgba(255, 255, 255, 0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-main);
  color: var(--color-text);
}

#map {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--color-bg-canvas);
  z-index: 0;
}

/* Fond neutre : le conteneur Leaflet garde le meme gris-vert clair quand aucune
   couche de tuiles n'est chargee, pour rester lisible hors ligne. */
.leaflet-container {
  background-color: var(--color-bg-canvas);
  font-family: var(--font-main);
}

/* SESSION D1.1A — header commun top/left, meme grille que le panneau Couches
   et le panneau 3D equivalent (#title-panel). Remplace l'ancien bandeau
   pleine largeur + son gros titre/sous-titre technique. */
#app-header.unified-header {
  position: absolute;
  top: var(--ui-margin);
  left: var(--ui-margin);
  width: var(--ui-left-width);
  height: var(--ui-header-height);
  z-index: 600;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  background: var(--ui-shell-bg);
  border: 1px solid var(--ui-shell-border);
  border-radius: var(--ui-shell-radius);
  box-shadow: var(--ui-shell-shadow);
  pointer-events: auto;
}
.header-titles {
  min-width: 0;
  overflow: hidden;
}
.header-titles h1 {
  margin: 0;
  font-size: 10px;
  line-height: 1.15;
  font-weight: 600;
  color: var(--ui-shell-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-titles p {
  margin: 1px 0 0;
  font-size: 9px;
  color: var(--ui-shell-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* SESSION D1.1A — switch segmente [2D | 3D], remplace l'ancien bouton-lien
   "TERRITOIRE 3D ->" / "<- CARTE 2D". Reutilise strictement le meme bouton
   #mode-switch-btn et sa logique de clic existante (Session C.7) : seule
   l'habillage visuel change (deux segments au lieu d'un bouton plein). */
.segmented-switch {
  position: static;
  display: flex;
  flex-shrink: 0;
  border: 1px solid var(--ui-shell-border);
  border-radius: 4px;
  overflow: hidden;
}
.segmented-switch .segment {
  font-family: var(--font-main);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 4px 6px;
  border: none;
  background: transparent;
  color: var(--ui-shell-text-muted);
}
.segmented-switch button.segment {
  cursor: pointer;
  color: var(--ui-shell-text);
}
.segmented-switch button.segment:hover {
  background: rgba(255, 255, 255, 0.1);
}
.segmented-switch .segment.active {
  background: var(--ui-shell-accent);
  color: #fff;
}

/* SESSION D1.2 — panneau Couches/Context Panels aligne sur le theme sombre
   3D (etait blanc, cf. D1.2 §2/§5/§8). Skin uniquement : structure/handlers
   inchanges (.panel n'est utilise que par #layers-panel/#measure-panel/
   #legend-panel en 2D, aucune popup ne reutilise cette classe). */
.panel {
  position: absolute;
  z-index: 500;
  background: var(--ui-shell-bg);
  border: 1px solid var(--ui-shell-border);
  border-radius: var(--ui-shell-radius);
  box-shadow: var(--ui-shell-shadow);
  font-size: 12.5px;
  color: var(--ui-shell-text);
}

/* SESSION D1.1A — ShortcutBar haut-droite (remplace l'ancien menu de vues
   vertical #view-buttons a gauche). Handlers de clic inchanges (map.js). */
.shortcut-bar {
  position: absolute;
  top: var(--ui-margin);
  right: var(--ui-margin);
  width: var(--ui-context-width);
  height: var(--ui-shortcut-height);
  z-index: 600;
  box-sizing: border-box;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0 8px;
  background: var(--ui-shell-bg);
  border: 1px solid var(--ui-shell-border);
  border-radius: var(--ui-shell-radius);
  box-shadow: var(--ui-shell-shadow);
}
.shortcut-bar button {
  font-family: var(--font-main);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 7px;
  border: 1px solid var(--ui-shell-border);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ui-shell-text);
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
}
.shortcut-bar button:hover {
  background: rgba(255, 255, 255, 0.16);
}
.shortcut-bar button.active,
.shortcut-bar button:active {
  background: var(--ui-shell-accent);
  border-color: var(--ui-shell-accent-border);
  color: #fff;
}

/* SESSION D1.1A — panneau Couches deplace a gauche (etait a droite), sous
   le header commun ; largeur alignee sur --ui-left-width (meme largeur que
   le header, cf. §2). Contenu/handlers inchanges. */
#layers-panel {
  top: calc(var(--ui-margin) + var(--ui-header-height) + var(--ui-gap));
  left: var(--ui-margin);
  width: var(--ui-left-width);
  max-height: 70vh;
  overflow-y: auto;
}

/* SESSION D1.1B — panneaux de contexte (Outils de mesure + Légende) regroupés
   dans un empilement commun bas-droite, symétrique du Debug+Sources 3D.
   Wrapper léger en CSS pur (aucun JS ajouté) : le wrapper porte l'ancrage
   absolu bas-droite, les panneaux redeviennent des enfants flex normaux pour
   s'empiler sans chevaucher, quel que soit leur état replié/déplié. */
.context-panels {
  position: absolute;
  right: var(--ui-margin);
  bottom: calc(var(--ui-footer-height) + var(--ui-margin));
  width: var(--ui-context-width);
  z-index: 550;
  display: flex;
  flex-direction: column;
  gap: var(--ui-gap);
  /* HOTFIX 2D — plafond recalcule pour reserver l'espace du panneau AUDIT
     (haut-droite, max-height 70vh, jamais reduit) au-dessus de ce bloc, afin
     qu'aucun chevauchement ne soit possible meme quand Audit + Mesure + Legende
     sont tous developpes en meme temps. overflow-y assure un defilement interne
     plutot qu'un debordement visuel au lieu d'un chevauchement. */
  max-height: calc(100vh - var(--ui-margin) - var(--ui-shortcut-height) - var(--ui-gap) - 70vh - var(--ui-gap) - var(--ui-footer-height) - var(--ui-margin));
  overflow-y: auto;
}
.context-panels .panel {
  position: relative;
  top: auto; left: auto; right: auto; bottom: auto;
  width: 100%;
  flex-shrink: 0;
}

#measure-panel { width: 100%; max-height: 24vh; overflow: hidden; }
#measure-panel #measure-body {
  padding: 6px 10px 8px;
  max-height: calc(24vh - 34px);
  overflow-y: auto;
}

#legend-panel {
  width: 100%;
  max-height: 24vh;
  overflow: hidden;
}
#legend-panel #legend-body {
  padding: 6px 10px 8px;
  max-height: calc(24vh - 34px);
  overflow-y: auto;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px solid var(--ui-shell-border);
  border-radius: var(--ui-shell-radius) var(--ui-shell-radius) 0 0;
  user-select: none;
}
.panel-header .chevron { transition: transform 0.15s ease; font-size: 11px; color: var(--ui-shell-text-muted); }
.panel.collapsed .panel-header { border-radius: var(--ui-shell-radius); border-bottom: none; }
.panel.collapsed .panel-header .chevron { transform: rotate(-90deg); }

/* HOTFIX 2D — en-tetes compactes des panneaux secondaires (Mesure/Legende)
   uniquement ; Layers/Audit gardent leur padding d'origine (inchange). */
#measure-panel .panel-header,
#legend-panel .panel-header {
  padding: 6px 10px;
}

#layers-body, #legend-body, #audit-body {
  padding: 8px 10px 10px;
}

.layer-group { margin-bottom: 10px; }
.layer-group:last-child { margin-bottom: 0; }
.layer-group h3 {
  margin: 0 0 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ui-shell-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.layer-group label {
  display: block;
  padding: 2px 0;
  cursor: pointer;
}
.layer-group input { margin-right: 6px; vertical-align: middle; }

/* SESSION D1.2 §6 — accent commun 2D/3D pour checkboxes/radios natifs
   (aucun remplacement JS, juste la couleur du controle natif). */
.panel input[type="checkbox"],
.panel input[type="radio"] {
  accent-color: var(--ui-shell-accent);
}

.turbine-subgroup { margin: 2px 0 6px 4px; padding-left: 6px; border-left: 2px solid var(--ui-border-subtle); }
.turbine-subgroup h4 {
  margin: 0 0 2px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ui-shell-text-muted);
}
.turbine-bulk-buttons { display: flex; gap: 6px; margin-top: 4px; }
.turbine-bulk-buttons button {
  flex: 1 1 auto;
  font-family: var(--font-main);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 4px;
  border: 1px solid var(--ui-shell-border);
  border-radius: 4px;
  background: var(--ui-bg-secondary);
  color: var(--ui-shell-text);
  cursor: pointer;
}
.turbine-bulk-buttons button:hover { background: var(--ui-bg-hover); }
.turbine-bulk-buttons button:active { background: var(--ui-shell-accent); color: #fff; }

.group-tag {
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 1px 5px;
  border-radius: 8px;
  font-weight: 600;
  color: #fff;
}
.group-tag.factuel { background: #607d6f; }
.group-tag.audit { background: #4a6a8a; }

/* SESSION D2.A — panneau AUDIT (lecture thematique), distinct du panneau
   LAYERS (donnees generales). Positionne sous la ShortcutBar, haut-droite. */
.audit-panel {
  top: calc(var(--ui-margin) + var(--ui-shortcut-height) + var(--ui-gap));
  right: var(--ui-margin);
  width: var(--ui-context-width);
  max-height: 70vh;
  overflow-y: auto;
  z-index: 550;
}
.audit-tabs {
  display: flex;
  gap: 3px;
  margin-bottom: 8px;
}
.audit-tab {
  flex: 1 1 auto;
  font-family: var(--font-main);
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 2px;
  border: 1px solid var(--ui-shell-border);
  border-radius: 4px;
  background: var(--ui-bg-secondary);
  color: var(--ui-shell-text);
  cursor: pointer;
}
.audit-tab:hover:not(:disabled) { background: var(--ui-bg-hover); }
.audit-tab.active { background: var(--audit-active-color); border-color: var(--audit-active-color); color: #fff; }
.audit-tab:disabled { opacity: 0.35; cursor: default; }
.audit-tab-content h4 {
  margin: 0 0 8px;
  font-size: 11.5px;
  color: var(--ui-shell-text);
}
.audit-activate-btn {
  display: block;
  width: 100%;
  font-family: var(--font-main);
  font-size: 10.5px;
  font-weight: 600;
  padding: 6px 4px;
  border: 1px solid var(--ui-shell-border);
  border-radius: 4px;
  background: var(--ui-bg-secondary);
  color: var(--ui-shell-text);
  cursor: pointer;
  margin-bottom: 8px;
}
.audit-activate-btn:hover { background: var(--ui-bg-hover); }
.audit-activate-btn.active { background: var(--audit-active-color); border-color: var(--audit-active-color); color: #fff; }
.audit-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.audit-toolbar .audit-activate-btn { margin-bottom: 0; flex: 1 1 auto; }
.audit-reset-btn {
  flex: 0 0 auto;
  font-family: var(--font-main);
  font-size: 10px;
  font-weight: 600;
  padding: 6px 8px;
  border: 1px solid var(--ui-shell-border);
  border-radius: 4px;
  background: var(--ui-bg-secondary);
  color: var(--ui-shell-text-muted);
  cursor: pointer;
}
.audit-reset-btn:hover { background: var(--ui-bg-hover); color: var(--ui-shell-text); }

.audit-subtopic-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}
.audit-subtopic-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
  font-family: var(--font-main);
  padding: 5px 6px;
  border: 1px solid var(--ui-shell-border);
  border-radius: 4px;
  background: var(--ui-bg-secondary);
  color: var(--ui-shell-text);
  cursor: pointer;
}
.audit-subtopic-item:hover { background: var(--ui-bg-hover); }
.audit-subtopic-item.active { background: var(--audit-active-color); border-color: var(--audit-active-color); color: #fff; }
.audit-subtopic-tag {
  flex: 0 0 auto;
  font-size: 8.5px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--ui-bg-hover);
  color: var(--ui-shell-text-muted);
}
.audit-subtopic-item.active .audit-subtopic-tag { background: rgba(255,255,255,0.25); color: #fff; }
.audit-priority-p0 { color: #fff; font-weight: 800; }
.audit-priority-p1 { color: #eee; }
.audit-priority-p2 { opacity: 0.75; }
.audit-priority-p3 { opacity: 0.55; }
.audit-subtopic-label { font-size: 10px; line-height: 1.25; }
.audit-priority-hint {
  margin: 0 0 8px;
  font-size: 8.5px;
  line-height: 1.3;
  color: var(--ui-shell-text-muted);
  opacity: 0.8;
}

.audit-a-summary {
  margin: 0 0 8px;
  font-size: 10px;
  line-height: 1.35;
  color: var(--ui-shell-text-muted);
}

.audit-a-detail { margin-bottom: 8px; }
.audit-detail-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.audit-detail-back {
  flex: 0 0 auto;
  font-family: var(--font-main);
  font-size: 12px;
  line-height: 1;
  padding: 3px 6px;
  border: 1px solid var(--ui-shell-border);
  border-radius: 4px;
  background: var(--ui-bg-secondary);
  color: var(--ui-shell-text);
  cursor: pointer;
}
.audit-detail-back:hover { background: var(--ui-bg-hover); }
.audit-detail-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--ui-shell-text);
  line-height: 1.3;
}
.audit-status-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 6px;
  border-radius: 3px;
  margin-bottom: 6px;
}
.audit-status-source { background: #2e6b3e; color: #fff; }
.audit-status-partial { background: #7a5a00; color: #fff; }
.audit-status-unavailable { background: #6a2f2f; color: #fff; }
/* D2.A RETAKE — Spec A3/A4 : statut "point d'audit" (subtopics sans mapFeatureId),
   distinct de .audit-status-badge — le sujet d'audit prime, la donnee SIG passe en second plan. */
.audit-subject-status {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}
.audit-subject-status-primary {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--audit-active-color);
}
.audit-subject-status-secondary {
  font-size: 9px;
  color: var(--ui-shell-text-muted);
}
.audit-detail-body {
  margin: 0 0 8px;
  font-size: 10px;
  line-height: 1.4;
  color: var(--ui-shell-text);
}
.audit-detail-nomap {
  margin: 0 0 8px;
  font-size: 9.5px;
  font-style: italic;
  color: var(--ui-shell-text-muted);
}
.audit-detail-map-btn {
  display: block;
  width: 100%;
  font-family: var(--font-main);
  font-size: 10px;
  font-weight: 600;
  padding: 5px 4px;
  border: 1px solid var(--ui-shell-accent-border);
  border-radius: 4px;
  background: var(--ui-shell-accent);
  color: #fff;
  cursor: pointer;
  margin-bottom: 8px;
}
.audit-detail-map-btn:hover { filter: brightness(1.1); }
.audit-detail-accordion {
  margin-bottom: 6px;
  border-top: 1px solid var(--ui-border-subtle);
  padding-top: 6px;
}
.audit-detail-accordion summary {
  font-size: 10px;
  font-weight: 600;
  color: var(--ui-shell-text-muted);
  cursor: pointer;
}
.audit-detail-accordion summary:hover { color: var(--ui-shell-text); }
.audit-detail-accordion p {
  margin: 6px 0 0;
  font-size: 9.5px;
  line-height: 1.35;
  color: var(--ui-shell-text-muted);
}
.audit-detail-accordion ul {
  margin: 6px 0 0;
  padding-left: 14px;
  font-size: 9.5px;
  line-height: 1.4;
  color: var(--ui-shell-text-muted);
}

.audit-mini-legend { margin-bottom: 8px; }
.audit-missing-note {
  margin: 0 0 6px;
  font-size: 9.5px;
  line-height: 1.35;
  color: var(--ui-shell-text-muted);
}
.audit-missing-note:last-child { margin-bottom: 0; }
.audit-water-line { border-top: 2px solid #2f6f8f; }
.audit-water-plui { border-top: 2px dashed #1f5c8a; }

/* --- Legende --- */
.legend-section { margin-bottom: 8px; }
.legend-section:last-child { margin-bottom: 0; }
.legend-section-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ui-shell-text-muted);
  border-bottom: 1px solid var(--ui-shell-border);
  padding-bottom: 2px;
  margin-bottom: 4px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
}
.legend-swatch {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.25);
}
.legend-swatch.line {
  width: 16px;
  height: 0;
  border-radius: 0;
  border: none;
  border-top: 2px dashed #999;
}
.legend-swatch.circle { border-radius: 50%; }
.legend-swatch.legend-diamond {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  transform: rotate(45deg);
  margin: 0 2px;
}
/* D2.A RETAKE — Spec A3/A4 : miniature legende du pin "sujet d'audit" (meme forme que .audit-subject-pin). */
.legend-swatch.legend-subject-pin {
  width: 11px;
  height: 11px;
  border-radius: 50% 50% 50% 0;
  border: 2px solid #241108;
  transform: rotate(-45deg);
  margin: 0 2px;
}
.legend-label { font-size: 11.5px; }

/* SESSION D1.1B — footer commun 2D/3D : bande fine pleine largeur en overlay
   bas de page. Contenu/logique JS (setStatus/textContent) inchangés, seule
   la présentation change (pastille bas-gauche -> barre pleine largeur). */
#status-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--ui-footer-height);
  z-index: 500;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  background: var(--ui-shell-bg);
  border-top: 1px solid var(--ui-shell-border);
  padding: 0 12px;
  font-size: 10.5px;
  color: var(--ui-shell-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Le footer pleine largeur passe sous le controle d'echelle Leaflet
   (bas-gauche par defaut) : on le remonte pour eviter le chevauchement,
   sans toucher a sa logique (L.control.scale inchange). */
.leaflet-bottom.leaflet-left {
  margin-bottom: calc(var(--ui-footer-height) + 4px);
}

/* --- Popups --- */
.leaflet-popup-content-wrapper {
  border-radius: 6px;
}
.popup-content { font-size: 12.5px; line-height: 1.4; max-width: 300px; }
.popup-content h4 {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--color-text);
}
.popup-grade {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  color: #fff;
  margin-left: 6px;
  vertical-align: middle;
}
.popup-grade.grade-b { background: var(--color-audit-b); }
.popup-grade.grade-c { background: var(--color-audit-c); }
.popup-field { margin: 4px 0; }
.popup-field .k { color: var(--color-text-muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; }
.popup-field .v { margin-top: 1px; }
.popup-section {
  margin: 8px 0 3px;
  padding-top: 6px;
  border-top: 1px solid #e2e6e2;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-accent);
}
.popup-section:first-of-type { margin-top: 6px; }
.popup-note {
  margin-top: 6px;
  padding: 5px 7px;
  background: #f4f6f4;
  border-left: 3px solid var(--color-accent);
  font-size: 11px;
  color: var(--color-text-muted);
}
.popup-note.manual {
  border-left-color: var(--color-rotor);
}

/* D2.A RETAKE — Spec A3/A4 : popup du pin "sujet d'audit" (jamais une donnee SIG). */
/* Addendum D2.E — règle commune à tous les popups Audit : les couleurs de thème
   restent réservées aux badges et accents ; aucun texte long ne dépend d'un thème clair. */
.audit-popup, .audit-subject-popup { color: var(--color-text); }
.audit-popup h4, .audit-subject-popup h4,
.audit-popup .popup-field .v, .audit-subject-popup .popup-field .v,
.audit-subject-popup p, .audit-subject-popup .popup-section { color: var(--color-text); }
.audit-popup .popup-field .k, .audit-subject-popup .popup-field .k { color: var(--color-text-muted); }
.audit-popup .popup-note, .audit-subject-popup .audit-subject-popup-disclaimer { color: var(--color-text-muted); }
.audit-e2-popup-summary { margin: 0 0 7px; font-size: 11px; line-height: 1.35; color: var(--color-text); }
.audit-e2-popup-note { margin: 0; font-size: 10.5px; line-height: 1.35; color: var(--color-text); }

.audit-subject-popup-tag {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 1px 6px;
  border-radius: 8px;
  margin-bottom: 6px;
  background: var(--audit-active-color);
  color: #fff;
}
.audit-subject-popup-disclaimer {
  margin-top: 6px;
  padding: 5px 7px;
  background: #f4f6f4;
  border-left: 3px solid var(--audit-active-color);
  font-size: 10px;
  font-style: italic;
  line-height: 1.35;
  color: var(--color-text-muted);
}

/* --- Graticule labels --- */
.graticule-label {
  font-size: 9.5px;
  color: #8a938e;
  background: transparent;
  border: none;
  box-shadow: none;
  font-family: var(--font-main);
  white-space: nowrap;
}

/* --- Tooltips permanents (labels turbines / distances) --- */
.turbine-label {
  font-weight: 800;
  font-size: 13.5px;
  letter-spacing: 0.01em;
  color: #4a1c0c;
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--color-turbine);
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  padding: 1px 6px;
}
.link-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--color-text);
  background: rgba(255,255,255,0.94);
  border: 1px solid var(--color-panel-border);
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
  padding: 1px 5px;
  white-space: nowrap;
  cursor: default;
}
.link-label-active {
  border-color: var(--color-accent);
  color: var(--color-accent);
  font-weight: 700;
}

/* --- Toponymes / repères locaux (secondaires par rapport aux turbines) --- */
.territorial-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: rgba(255,255,255,0.75);
  border: none;
  box-shadow: none;
  padding: 0 3px;
  white-space: nowrap;
}

/* --- Toponymes IGN (B2.4) : couche additionnelle, visuellement distincte et plus
   discrète que .territorial-label (italique, opacité réduite) pour ne jamais se
   confondre avec les repères locaux déjà validés en B2.2. --- */
.ign-toponym-label {
  font-size: 9.5px;
  font-style: italic;
  font-weight: 400;
  color: #9a9384;
  background: rgba(255,255,255,0.6);
  border: none;
  box-shadow: none;
  padding: 0 3px;
  white-space: nowrap;
}

/* --- Photomontages : miniature + invite dans le popup --- */
.pm-thumb-wrap { margin: 6px 0; text-align: center; }
.pm-thumb {
  max-width: 100%;
  border: 1px solid var(--color-panel-border);
  border-radius: 3px;
  cursor: zoom-in;
  display: block;
}
.pm-thumb-hint {
  font-size: 10px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Session C.7 — bouton "voir en 3D" dans les popups photomontage */
.pm-3d-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px 8px;
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--color-accent);
  border-radius: 4px;
  background: var(--color-accent);
  color: #fff;
  cursor: pointer;
}
.pm-3d-btn:hover {
  filter: brightness(1.08);
}

/* --- Lightbox (vue agrandie d'un photomontage) --- */
.lightbox {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 2000;
  background: rgba(20, 24, 22, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox.hidden { display: none; }
.lightbox-box {
  position: relative;
  background: #fff;
  border-radius: 6px;
  padding: 10px;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 4px 18px rgba(0,0,0,0.4);
}
.lightbox-box img {
  max-width: 88vw;
  max-height: 78vh;
  display: block;
}
#lightbox-caption {
  margin-top: 8px;
  font-size: 12px;
  color: var(--color-text);
  text-align: center;
}
#lightbox-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--color-panel-border);
  background: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

/* --- B2.5 : marqueurs d'audit (losange, jamais rouge/vert) --- */
.audit-icon-simple, .audit-icon-offset {
  background: transparent;
  border: none;
}
.audit-icon-offset {
  pointer-events: none; /* seul le losange (ci-dessous) reste une cible de clic */
}
.audit-diamond {
  position: absolute;
  width: 15px;
  height: 15px;
  transform: translate(-50%, -50%) rotate(45deg);
  border: 2px solid #241108;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  pointer-events: auto;
  cursor: pointer;
}
.audit-icon-simple .audit-diamond { left: 50%; top: 50%; }
.audit-diamond.audit-grade-b { background: var(--color-audit-b); }
.audit-diamond.audit-grade-c { background: var(--color-audit-c); }
.audit-anchor-dot {
  position: absolute;
  left: 50%; top: 50%;
  width: 5px; height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  background: #241108;
  opacity: 0.55;
}
.audit-leader-line {
  position: absolute;
  left: 50%; top: 50%;
  height: 1.4px;
  background: #241108;
  opacity: 0.55;
  transform-origin: 0 50%;
}

/* D2.A RETAKE — Spec A3/A4 : pin "sujet d'audit" — volontairement une forme distincte
   du losange .audit-diamond (donnee SIG reelle) pour ne jamais etre confondu avec une
   geometrie environnementale. Couleur pilotee par AUDIT_THEME_COLORS (inline style, JS). */
.audit-subject-icon { background: transparent; border: none; }
.audit-subject-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 2px solid #241108;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
  cursor: pointer;
}
.audit-subject-pin-label {
  transform: rotate(45deg);
  font-size: 8.5px;
  font-weight: 700;
  color: #fff;
}

/* --- B2.5.1 : pictogramme des éoliennes environnantes (objectif 1) --- */
.surrounding-turbine-icon {
  background: transparent;
  border: none;
  pointer-events: auto;
  transition: transform 0.12s ease;
}
/* Vue régionale (zoom <= seuil) : pictogramme agrandi pour lire la distribution
   d'ensemble. Vue rapprochée (zoom > seuil, ex. boutons E1-E4) : réduit pour ne
   jamais concurrencer visuellement E1-E4 (cercle plein + étiquette permanente,
   ceux-ci ne changent jamais de taille). */
body.zoom-regional-surrounding .surrounding-turbine-icon { transform: scale(1.15); }
body.zoom-close-surrounding .surrounding-turbine-icon { transform: scale(0.8); opacity: 0.85; }

.surrounding-turbine-tooltip, .audit-tooltip, .sonometer-tooltip, .hydrography-tooltip {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
}
.audit-e2-corcees-label,
.audit-e2-park-label {
/* Addendum D2.E — repères temporaires du contexte régional E2. */
  background: transparent;
  border: none;
  box-shadow: none;
  color: #4a2036;
  font-family: var(--font-main);
  pointer-events: none;
  text-align: center;
}
.audit-e2-corcees-label span {
  display: inline-block;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(255,255,255,0.84);
  border: 1px solid rgba(176,40,107,0.45);
  font-size: 9px;
  font-weight: 700;
}
.audit-e2-park-label span,
.audit-e2-park-label small { display: block; }
.audit-e2-radius-label {
  background: transparent;
  border: none;
  box-shadow: none;
  font-family: var(--font-main);
  pointer-events: none;
  text-align: center;
}
.audit-e2-radius-label span {
  display: inline-block;
  padding: 1px 4px;
  border: 1px solid rgba(176,40,107,0.5);
  border-radius: 3px;
  background: rgba(255,255,255,0.88);
  color: #7a1d4c;
  font-size: 9px;
  font-weight: 700;
}
.audit-e2-park-label span {
  font-size: 9px;
  font-weight: 700;
  line-height: 1.1;
  text-shadow: 0 1px 2px rgba(255,255,255,0.95), 0 -1px 2px rgba(255,255,255,0.95);
}
.audit-e2-park-label small {
  margin-top: 1px;
  font-size: 8px;
  line-height: 1.1;
  color: #603149;
  text-shadow: 0 1px 2px rgba(255,255,255,0.95), 0 -1px 2px rgba(255,255,255,0.95);
}


/* --- B2.5.1 : pictogramme sonomètre (objectif 5) --- */
.sonometer-icon {
  background: transparent;
  border: none;
  pointer-events: auto;
}

/* --- B2.5 : panneau Outils de mesure --- */
.measure-mode-buttons { display: flex; gap: 4px; }
.measure-mode-buttons button {
  flex: 1 1 auto;
  font-family: var(--font-main);
  font-size: 10px;
  font-weight: 600;
  padding: 5px 2px;
  border: 1px solid var(--ui-shell-border);
  border-radius: 4px;
  background: var(--ui-bg-secondary);
  color: var(--ui-shell-text);
  cursor: pointer;
}
.measure-mode-buttons button:hover { background: var(--ui-bg-hover); }
.measure-mode-buttons button.active { background: #d6336c; border-color: #d6336c; color: #fff; }
.measure-mode-buttons button[data-mode="select"].active { background: var(--ui-shell-accent); border-color: var(--ui-shell-accent-border); }
.measure-label-preview { opacity: 0.82; }
.measure-readout {
  margin: 4px 0;
  font-size: 10.5px;
  color: var(--ui-shell-text-muted);
  min-height: 26px;
}
.measure-action-buttons { display: flex; gap: 6px; margin-bottom: 4px; }
.measure-action-buttons button {
  flex: 1 1 auto;
  font-family: var(--font-main);
  font-size: 9.5px;
  font-weight: 600;
  padding: 4px 3px;
  border: 1px solid var(--ui-shell-border);
  border-radius: 4px;
  background: var(--ui-bg-secondary);
  color: var(--ui-shell-text);
  cursor: pointer;
}
.measure-action-buttons button:hover { background: var(--ui-bg-hover); }
.measure-hint {
  margin: 0;
  font-size: 9.5px;
  line-height: 1.35;
  color: var(--ui-shell-text-muted);
}

/* --- B2.5 : géométries de mesure temporaires (jamais confondues avec R60/R500) --- */
.measure-dot {
  border-radius: 50%;
  background: #d6336c;
  border: 1px solid #fff;
  box-shadow: 0 0 0 1px #d6336c;
}
.measure-label {
  font-size: 10px;
  font-weight: 700;
  color: #000;
  background: #fff;
  border: 1px solid #d6336c;
  border-radius: 3px;
  padding: 1px 5px;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

/* --- B2.5 : capture de clic garantie pour les outils de mesure actifs (cf. §7) ---
   Leaflet accorde pointer-events:auto à chaque path/icône/tooltip via des règles
   ".leaflet-interactive" (leaflet.css) plus spécifiques qu'un simple ".leaflet-pane" -
   un blocage au niveau de la pane seule ne suffit donc pas (l'élément interactif
   garde sa propre règle explicite, non écrasée par l'héritage du parent). On neutralise
   donc directement ".leaflet-interactive" (la classe commune à tous les objets
   cliquables : PLUi, buffers, IGN, marqueurs, tooltips) pendant une mesure active, avec
   !important pour garantir la priorité sur leaflet.css quel que soit l'ordre de
   chargement. Le clic atteint alors toujours la carte elle-même
   (gestionnaire map.on('click')), jamais un popup sous-jacent. N'affecte ni les
   contrôles Leaflet (zoom, échelle) ni nos panneaux HTML, qui vivent hors de
   .leaflet-pane. */
body.measuring-active .leaflet-interactive {
  pointer-events: none !important;
  cursor: crosshair !important;
}
body.measuring-active .leaflet-container {
  cursor: crosshair;
}
/* Les losanges d'audit (span interne) portent leur propre règle explicite
   "pointer-events: auto" (necessaire pour rester cliquables hors mesure, cf.
   §7) - cette regle directe n'est pas couverte par ".leaflet-interactive"
   ci-dessus (seul le conteneur .leaflet-marker-icon porte cette classe, pas
   le span lui-meme), donc elle doit etre neutralisee separement pendant une
   mesure active, sinon un clic sur un losange audit rouvre son popup au lieu
   d'aller au gestionnaire de mesure. */
body.measuring-active .audit-diamond,
body.measuring-active .audit-anchor-dot {
  pointer-events: none !important;
}

/* --- B2.9 : Habitat & distances aux eoliennes (premiere passe) --- */
/* Style volontairement distinct : ni le bleu/gris de l'audit (--color-audit-b/c), ni le
   pictogramme sonometre, ni la vignette photomontage. Carre plein (habitat confirme) ou
   carre a bord pointille (usage non etabli - ni confirme ni exclu), teinte prune sobre
   propre a cette couche. */
.habitat-icon { background: transparent; border: none; }
.habitat-square {
  position: absolute;
  left: 50%; top: 50%;
  width: 12px; height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.habitat-square.habitat-confirme {
  background: #5c4a75;
  border: 1.5px solid #3c2f4d;
}
.habitat-square.habitat-non-etabli {
  background: rgba(92, 74, 117, 0.25);
  border: 1.5px dashed #5c4a75;
}
.habitat-tooltip {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  color: #3c2f4d;
}

@media (max-width: 1400px) {
  :root { --ui-left-width: 210px; }
}
