/* app.css — Parrainages 2027 ; :root --languette-* (pliage, rayons sens right/left/bottom/top) + légende interface/legend.css
 * Logs:
 * - Signature : `--parr-signature-reserve-h` (dock entier) ; OSM : `--parr-signature-osm-reserve-h` (panneau seul)
 * - Statsbar : 2 zones (compteurs + languette | actions + 🖨 CSV) ; légende repliée si pas de hover (tactile)
 * - Statsbar actions-row : languette H (_interfaces) sur toute la ligne, overlay right 100px
 * - Header : badge rôle / opérateur en blanc (`--c-text`)
 * - Header : bloc `.header-actions` à gauche après le titre (écart ~18px, plus collé au bord droit)
 * - Statsbar : 1px si compteurs + actions repliés (`:has` + hôtes hauteur 0, languettes en overflow)
 * - Statsbar actions : Zone · max · 🖨 CSV · ⛳ recherche
 * - Boutons CTA : `.btn-secondary.statsbar-zone-btn` — bandeau `--ia-pipeline-accent` (Zone, CSV, fiche)
 */


*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-bg: #1a1a2e;
  --c-surface: #16213e;
  --c-panel: #0f3460;
  --c-accent: #e94560;
  --c-text: #eaeaea;
  --c-muted: #8899aa;
  --c-border: #2a3a5a;
  --c-success: #00cc66;
  --c-warn: #ffaa00;
  --c-danger: #cc3333;
  --c-promesse: #00cc66;
  --c-signature: #ffd700;
  --header-h: 52px;
  --toolbar-h: auto;
  --statsbar-h: 32px; /* hauteur typique dépliée ; repliée → 1px via .statsbar--fully-collapsed */
  /* Pliage/repli des panneaux derrière les languettes toolbar, légende, dock IA (dépli souvent 0s côté CSS) */
  --languette-pliage: 0.2s ease;
  --ui-pliage: var(--languette-pliage); /* alias historique → même durée partout */
  /* Décalage overlay languette filtres (0 = flex-end pleine largeur ; ex. 55px si 2e languette H à droite) */
  --toolbar-filtres-languette-overlay-shift-inline-end: 0;
  /* Typo tirettes (_interfaces/languette.css) — même échelle horizontale pour H et V */
  --languette-font-size: 0.62rem;
  --languette-grip-font-size: 0.5rem;
  --languette-caret-font-size: 0.72rem;
  --languette-letter-spacing: 0.04em;
  /*
   * Rayons des tirettes / bandes languette par bord d’ancrage (ordre CSS : TL TR BR BL).
   * Principe : côté joint au panneau (ou ligne repliée 1px) = coins droits ; côté vers la carte / extérieur = 8px.
   */
  --languette-radius-right: 8px 0 0 8px;
  --languette-radius-left: 0 8px 8px 0;
  /* Glyphes légende / fiche (● ○ ⊙) — police symboles pour taille stable entre OS */
  --parr-glyph-font: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols 2", sans-serif;
  --languette-radius-bottom: 0 0 8px 8px;
  --languette-radius-top: 8px 8px 0 0;
  --parr-signature-reserve-h: var(--languette-min);
  --parr-signature-osm-reserve-h: 0px;
}

html, body { height: 100%; font-family: 'Segoe UI', Arial, sans-serif; font-size: 14px; color: var(--c-text); background: var(--c-bg); overflow: hidden; }

/* ===== HEADER ===== */
.header {
  height: var(--header-h);
  background: var(--c-surface);
  border-bottom: 2px solid var(--c-accent);
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  padding: 0px 5px 0 5px;
  gap: 10px;
  position: relative;
  z-index: 500;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.header-logo { height: 36px; width: auto; display: none; }
.header-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--c-text);
  flex: 0 1 auto;
  min-width: 0;
}
.header-title span { color: var(--c-accent); }
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 18px;
  flex: 0 0 auto;
  flex-shrink: 0;
}
.role-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text);
  padding: 0 4px;
  flex-shrink: 0;
  line-height: 1.2;
}
.role-badge--prospecteur {
  padding: 0 4px;
  max-width: 9ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-icon {
  background: none;
  border: 1px solid var(--c-border);
  color: var(--c-text);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: background .15s;
}
.btn-icon:hover { background: var(--c-border); }
.btn-icon.active { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }

.csv-repo-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  max-width: min(420px, 40vw);
  position: relative;
}
.csv-folder-btn {
  flex-shrink: 0;
  min-width: 36px;
  padding-inline: 6px;
  font-size: 16px;
  line-height: 1;
}
.csv-repo-path-input {
  flex: 1;
  min-width: 72px;
  width: 0;
  max-width: 210px;
  height: 28px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--c-text);
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* CSV memory dropdown */
.csv-dropdown { position: relative; }
.csv-dropdown-btn {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 13px;
  min-width: 120px;
}
/* CSV dropdown : viewport-fixed (voir positionCsvDropdownPanel app.js) — au-dessus légende 765 / ia-dock 780 ; sous overlays 800+. */
.csv-dropdown-panel {
  display: none;
  position: fixed;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  min-width: 260px;
  z-index: 795;
  box-shadow: 0 4px 12px rgba(0,0,0,.5);
  max-height: min(380px, 55vh);
  overflow-y: auto;
}
.csv-dropdown-section {
  padding: 6px 12px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-muted);
  border-bottom: 1px solid var(--c-border);
  cursor: default;
  user-select: none;
}
.csv-dropdown-panel.open { display: block; }
.csv-dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--c-border);
  font-size: 12px;
}
.csv-dropdown-item:hover { background: var(--c-panel); }
.csv-dropdown-item.active { background: var(--c-accent); }
.csv-item-label { font-weight: 600; }
.csv-item-meta { color: var(--c-muted); font-size: 11px; margin-top: 2px; }

/* ===== TOOLBAR ===== */
/* Repli filtres / ligne IA : deux .languette-host (_interfaces/languette.css + index) */

.toolbar {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}
.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 2px 5px;
}
.toolbar-row-ia {
  padding-top: 2px;
  margin-top: 0;
}
.toolbar-select-ai {
  background: var(--c-bg);
  border: 1px solid var(--c-accent);
  color: var(--c-text);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
  max-width: 9.5rem;
}
.toolbar-select-ai:focus {
  outline: none;
  border-color: var(--c-accent-muted, #ff6b86);
}

/* Premier hôte au-dessus : bande languette en absolute sous le panel, sinon le bloc IA suivant capte les clics */
.languette-toolbar-filtres.languette-host {
  z-index: 451;
  --languette-overlay-pad-inline-end: var(--toolbar-filtres-languette-overlay-shift-inline-end);
}
.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--c-border);
  flex-shrink: 0;
}
.toolbar-toggle-btn {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-top: none;
  color: var(--c-muted);
  border-radius: 0 0 6px 6px;
  cursor: pointer;
  font-size: 11px;
  z-index: 399;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  border-right: 1px solid var(--c-border);
  padding-right: 10px;
}
.toolbar-group:last-child { border-right: none; }
.toolbar-group-ia-actions { flex-wrap: wrap; align-items: center; }
.ia-toolbar-sep {
  color: var(--c-muted);
  font-size: 13px;
  font-weight: 700;
  user-select: none;
  padding: 0 3px;
  flex-shrink: 0;
  line-height: 1;
}
.toolbar-label { color: var(--c-muted); font-size: 12px; white-space: nowrap; }

input[type="text"], input[type="number"], select {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 13px;
}
input[type="text"]:focus, input[type="number"]:focus, select:focus {
  outline: none;
  border-color: var(--c-accent);
}
select option { background: var(--c-bg); }

.btn-primary {
  background: var(--c-accent);
  border: none;
  color: #fff;
  border-radius: 4px;
  padding: 5px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity .15s;
}
.btn-primary:hover { opacity: .85; }
.btn-primary:disabled { opacity: .4; cursor: default; }

.btn-secondary {
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  border-radius: 4px;
  padding: 0px 10px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: background .15s;
}
.btn-secondary:hover { background: var(--c-border); }

/* Pipeline IA — couleur sous les boutons = progression (scoreColor → --ia-pipeline-accent) */
#btnIaMaires,
#btnIaParrainages,
#btnIaContactsZone,
#btnDefineZone {
  border-color: var(--ia-pipeline-accent, var(--c-border));
  box-shadow: inset 0 -3px 0 var(--ia-pipeline-accent, rgba(255,255,255,0.03));
}

/* Un seul bouton à la fois ; seule la barre --ia-pipeline-accent (inset -3px) clignote en blanc. */
@keyframes iaPipelinePctPulse {
  0%,
  45% {
    box-shadow: inset 0 -3px 0 var(--ia-pipeline-accent, #8899aa);
  }
  50%,
  92% {
    box-shadow: inset 0 -3px 0 #ffffff;
  }
  100% {
    box-shadow: inset 0 -3px 0 var(--ia-pipeline-accent, #8899aa);
  }
}

#btnIaMaires.ia-pipeline-pct-blink,
#btnIaParrainages.ia-pipeline-pct-blink,
#btnIaContactsZone.ia-pipeline-pct-blink {
  animation: iaPipelinePctPulse var(--ia-pipeline-blink-s, 5s) ease-in-out infinite;
}

/* Jauge Contacts zone — aspect bouton, non interactif */
span.btn-secondary.ia-zone-contacts-gauge {
  cursor: default;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  font-size: 12px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ia-dock-textarea.ia-dock-zone-persisted {
  color: #9aacbb;
}

/* Pop filter slider */
input[type="range"] {
  -webkit-appearance: none;
  width: 90px;
  height: 4px;
  border-radius: 2px;
  background: var(--c-border);
  border: none;
  padding: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c-accent);
  cursor: pointer;
}
.filter-val { font-size: 12px; color: var(--c-warn); font-weight: 600; min-width: 52px; }

/* ===== STATSBAR ===== */
.statsbar {
  container-type: inline-size;
  container-name: parr-statsbar;
  min-height: 1px;
  background: #0a0a1a;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  font-size: 12px;
  color: var(--c-muted);
  z-index: 300;
  flex-shrink: 0;
  overflow: visible;
}
/* Compteurs + actions repliés : bande 1px (fold-px), tirettes H en absolute (pad 50 / 100px) */
.statsbar:has(.statsbar-stats-panel-wrap.languette-panel-collapsed):has(
    .statsbar-actions-panel-wrap.languette-panel-collapsed
  ) {
  height: 1px;
  min-height: 1px;
  max-height: 1px;
}
.statsbar:has(.statsbar-stats-panel-wrap.languette-panel-collapsed):has(
    .statsbar-actions-panel-wrap.languette-panel-collapsed
  )
  > .statsbar-stats-host,
.statsbar:has(.statsbar-stats-panel-wrap.languette-panel-collapsed):has(
    .statsbar-actions-panel-wrap.languette-panel-collapsed
  )
  > .statsbar-actions-host {
  flex: 0 0 0;
  height: 0;
  min-height: 0;
  max-height: 0;
  overflow: visible;
}
.statsbar-stats-host {
  position: relative;
  z-index: 2;
  width: 100%;
  flex-shrink: 0;
  --languette-h-align: flex-end;
  --languette-overlay-pad-inline-end: 50px;
  --c-surface: #0a0a1a;
  --c-panel: #0a0a1a;
}
.statsbar-stats-panel-wrap > .statsbar-stats-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 4px 14px 4px 14px;
  box-sizing: border-box;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.statsbar-stats-host .languetteHorizontale {
  background: var(--c-surface);
  border-color: var(--c-border);
}
.statsbar-stats-host .languetteHorizontale:hover {
  background: var(--c-panel);
  color: var(--c-muted);
}
.statsbar-stats-languette {
  z-index: 3;
}
.stat-item {
  flex: 0 0 auto;
}
.stat-item b { color: var(--c-text); }
.stat-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 3px; vertical-align: middle; }

.statsbar-actions-host {
  position: relative;
  z-index: 1;
  width: 100%;
  flex-shrink: 0;
  --languette-h-align: flex-end;
  --languette-overlay-pad-inline-end: 100px;
  --c-surface: #0a0a1a;
  --c-panel: #0a0a1a;
}
.statsbar-actions-languette {
  z-index: 2;
}
.statsbar-actions-panel-wrap > .statsbar-actions-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
  padding: 4px 14px 6px 14px;
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.statsbar-actions-host .languetteHorizontale {
  background: var(--c-surface);
  border-color: var(--c-border);
}
.statsbar-actions-host .languetteHorizontale:hover {
  background: var(--c-panel);
  color: var(--c-muted);
}
.statsbar-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}
.statsbar-csv-btn {
  flex: 0 0 auto;
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1.2;
  height: 24px;
  box-sizing: border-box;
}

@container parr-statsbar (min-width: 860px) {
  .statsbar {
    flex-direction: row;
    align-items: center;
  }
  .statsbar-stats-host {
    width: auto;
    flex: 0 1 auto;
  }
  .statsbar-actions-host {
    flex: 1 1 auto;
    min-width: 0;
  }
  .statsbar-actions-panel-wrap > .statsbar-actions-row {
    border-top: none;
    border-left: 1px solid var(--c-border);
    padding-top: 4px;
  }
}
.statsbar-zone-btn {
  flex-shrink: 0;
  padding: 2px 10px;
  font-size: 12px;
  line-height: 1.2;
}
.statsbar-zone-max {
  width: 52px;
  min-width: 44px;
  height: 24px;
  padding: 2px 6px;
  font-size: 12px;
  box-sizing: border-box;
  background: #141428;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  color: var(--c-text);
}
.parr-ia-prefs-hidden {
  display: none !important;
}
.btn-secondary.statsbar-zone-btn {
  border-color: var(--ia-pipeline-accent, var(--c-border));
  box-shadow: inset 0 -3px 0 var(--ia-pipeline-accent, rgba(255, 255, 255, 0.03));
}
.statsbar-search-flag {
  flex-shrink: 0;
  font-size: 14px;
  line-height: 1;
}
.statsbar-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.statsbar-search-input {
  width: min(220px, 30vw);
  min-width: 120px;
  height: 24px;
  box-sizing: border-box;
  padding: 2px 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--c-text);
  background: #141428;
  border: 1px solid var(--c-border);
  border-radius: 4px;
}
.statsbar-search-input::placeholder {
  color: var(--c-muted);
}
.map-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: transparent;
}
.map-row {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 0;
  min-width: 0;
  background: transparent;
}
.map-row .map-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  background: transparent;
}

/* Carte : z-index 0 pour que .legend / .ia-dock (sœurs) passent au-dessus du composite Leaflet (tuiles + transforms). Reste < .parr-modal-mask (800). */
#map {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 0;
}

.parr-leaflet-map:focus,
.parr-leaflet-map:focus-visible,
#map .leaflet-container:focus,
#map .leaflet-container:focus-visible,
#map .leaflet-interactive:focus,
#map .leaflet-interactive:focus-visible,
#map path.parr-map-selection-ring:focus,
#map path.parr-map-selection-ring:focus-visible {
  outline: none !important;
}
path.parr-map-selection-ring {
  fill: none !important;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.parr-map-pin-marker {
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}
.parr-map-pin-marker-party {
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 2px rgba(0, 0, 0, 0.65));
}
/* Niveau de zoom sous +/− : même largeur que la barre Leaflet, texte tronqué si besoin */
.leaflet-control-zoom a.leaflet-control-zoom-out {
  border-radius: 0;
}
.leaflet-control-zoom .leaflet-zoom-level-readout {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 2px 1px 3px;
  border-top: 1px solid #ccc;
  background: #fff;
  font-size: 10px;
  line-height: 1.1;
  font-weight: 700;
  text-align: center;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 0 0 4px 4px;
}

/* Liste communes zone IA sur la carte (bord gauche) */
.ia-dock {
  --ia-dock-liste-bg: #000;
  --ia-dock-liste-border: rgba(136, 153, 170, 0.38);
  flex-shrink: 0;
  position: absolute;
  left: 0;
  top: calc(50% - var(--parr-signature-reserve-h, 0px) / 2);
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  overflow: visible;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  /* Ne pas capturer les clics sur toute la hauteur du textarea — seulement enfants ciblés */
  pointer-events: none;
  z-index: 780;
}
.ia-dock:not(.ia-layout-collapsed) {
  flex-direction: row;
  align-items: flex-end;
  width: auto;
  max-width: none;
  gap: 0;
}
.ia-dock.ia-layout-collapsed {
  flex-direction: row;
  align-items: flex-end;
  width: auto;
  max-width: 100%;
  justify-content: flex-start;
  overflow: visible;
}
/* Tirette verticale : 50px fixe, en bas du bloc liste (pas toute la hauteur du dock) */
.ia-dock .ia-dock-languette-toggle.languetteVerticale,
.ia-dock .ia-dock-languette-toggle {
  pointer-events: auto;
  flex: 0 0 auto;
  align-self: flex-end;
  width: var(--languette-min);
  height: var(--languette-max);
  min-height: var(--languette-max);
  max-height: var(--languette-max);
  box-sizing: border-box;
}
.ia-dock-textarea {
  pointer-events: auto;
  flex: 0 1 auto;
  display: block;
  resize: none;
  box-sizing: border-box;
  width: min(280px, 42vw);
  max-width: 320px;
  min-width: 120px;
  margin: 0;
  padding: 6px 8px;
  min-height: 2.75em;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  background: var(--ia-dock-liste-bg);
  border: 1px solid var(--ia-dock-liste-border);
  border-right: none;
  border-left: 1px solid var(--ia-dock-liste-border);
  border-radius: 0;
  color: var(--c-text);
  font-size: 0.61rem;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  line-height: 1.35;
}
/* Replié : bande 1px non cliquable — seule la tirette 50px en bas */
.ia-dock.ia-layout-collapsed .ia-dock-textarea {
  pointer-events: none;
}

/* ===== MODALES PLEIN ÉCRAN (.parr-modal-*) — pas les bandeaux toolbar (voir _interfaces/languette.css .languette-overlay) ===== */
.parr-modal-mask[hidden] {
  display: none !important;
}
.parr-modal-mask:not(.open) {
  display: none !important;
}
.parr-modal-mask.open {
  display: flex !important;
}
.parr-modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 800;
  align-items: center;
  justify-content: center;
}
.parr-modal-dialog {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  width: 560px;
  max-width: 95vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
}
.overlay-header {
  background: var(--c-panel);
  padding: 12px 16px;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--c-border);
}
.overlay-title { font-weight: 700; flex: 1; font-size: 15px; }
.overlay-close {
  background: none;
  border: none;
  color: var(--c-muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
}
.overlay-close:hover { color: var(--c-accent); }
.overlay-body { padding: 16px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.overlay-desc { font-size: 13px; color: var(--c-muted); line-height: 1.5; }
.overlay-textarea {
  width: 100%;
  min-height: 160px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  border-radius: 4px;
  padding: 8px;
  font-size: 12px;
  font-family: monospace;
  resize: vertical;
}
.overlay-textarea:focus { outline: none; border-color: var(--c-accent); }
.overlay-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--c-border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Modale prompt IA — ligne Lancer API + Arrêter */
.ia-prompt-api-launch-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 8px 0 6px;
}

.ia-prompt-box {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  padding: 10px;
  font-size: 12px;
  font-family: monospace;
  color: var(--c-text);
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Ligne d’attente API (sans 2ᵉ popup) sous « Lancer l’API » */
.ia-prompt-api-status-line {
  font-size: 12px;
  line-height: 1.35;
  color: var(--c-accent);
  min-height: 1.35em;
  margin: -2px 0 6px;
  padding-left: 2px;
}
.ia-prompt-api-status-line.ia-prompt-api-status-wait {
  animation: parrIaPromptApiPulse 1.15s ease-in-out infinite alternate;
}
@keyframes parrIaPromptApiPulse {
  from { opacity: 1; }
  to { opacity: 0.38; }
}

/* Modale attente référentiels gouv — sous l’attente LLM (850), au-dessus cartographie (800) */
.parr-gouv-wait.parr-modal-mask {
  z-index: 830;
}
.parr-storage-quota.parr-modal-mask {
  z-index: 860;
}
.ia-prompt-maires-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}
.ia-prompt-maires-tools[hidden] {
  display: none !important;
}
/* Bandeau initDept — voile fullscreen quasi transparent, bloque les clics sous la modale gouv */
.parr-initdept-required.parr-modal-mask.open {
  z-index: 865;
  align-items: flex-start;
  justify-content: center;
  padding: 10px 14px 0;
  background: rgba(0, 0, 0, 0.14);
  pointer-events: auto;
}
.parr-initdept-required.parr-modal-mask.open .parr-modal-dialog {
  width: 100%;
  max-width: 720px;
  max-height: min(42vh, 340px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.2);
}
.parr-initdept-required.parr-modal-mask.open .overlay-body {
  max-height: 28vh;
}
/* Admin : bandeau seul, carte et UI cliquables en dessous */
.parr-initdept-required.parr-modal-mask.open.parr-initdept-admin {
  background: transparent;
  pointer-events: none;
}
.parr-initdept-required.parr-modal-mask.open.parr-initdept-admin .parr-modal-dialog {
  pointer-events: auto;
}
/* Aperçu commercial : modale gouv au-dessus du bandeau admin (fermeture ✕) */
body.parr-partner-initdept-preview .parr-gouv-wait.parr-modal-mask.open {
  z-index: 885;
}
.ia-prompt-maires-tools .btn-secondary {
  font-size: 12px;
}


.parr-ai-api-wait-body {
  align-items: stretch;
  text-align: center;
}

.parr-ai-api-spinner {
  width: 36px;
  height: 36px;
  margin: 14px auto;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: parr-ai-spin 0.75s linear infinite;
}

@keyframes parr-ai-spin {
  to { transform: rotate(360deg); }
}

.parr-ai-api-progress-log {
  text-align: left;
  font-size: 12px;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  color: var(--c-muted);
  line-height: 1.65;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 6px;
}

.parr-ai-api-progress-log .parr-ai-step {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.parr-ai-api-progress-log .parr-ai-step:last-child {
  border-bottom: none;
}

/* ===== NOTIFICATIONS ===== */
.notif {
  position: fixed;
  bottom: calc(var(--parr-signature-reserve-h) + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-panel);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 10px 36px 10px 14px;
  font-size: 13px;
  z-index: 440;
  box-shadow: 0 4px 12px rgba(0,0,0,.5);
  transition: opacity .3s;
  pointer-events: auto;
  max-width: min(96vw, 720px);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}
.notif-msg {
  flex: 1;
  min-width: 0;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-wrap;
  max-height: 40vh;
  overflow-y: auto;
}
.notif-close {
  position: absolute;
  top: 6px;
  right: 8px;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  opacity: 0.85;
  border-radius: 4px;
}
.notif-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}
.notif.ok { border-color: var(--c-success); color: var(--c-success); }
.notif.err { border-color: var(--c-danger); color: var(--c-danger); }

/* ===== LAYOUT ===== */
body { display: flex; flex-direction: column; }
.app-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 1;
  isolation: isolate;
  min-height: 0;
}

/* Signature DNAvatar — dock bas carte (pas footer page) ; pas de règles sur .signature-DNAvatar-* */
.parr-signature-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 460;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  pointer-events: none;
  --languette-h-align: flex-start;
}
.parr-signature-dock .parr-signature-languette-overlay {
  position: relative;
  top: auto;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: var(--languette-h-align, flex-end);
  pointer-events: none;
}
.parr-signature-dock .parr-signature-languette-overlay .languetteHorizontale {
  pointer-events: auto;
  border-top: 1px solid var(--c-border);
  border-bottom: none;
  border-radius: var(--languette-radius-top);
  background: var(--c-bg);
}
.parr-signature-dock [data-languette-role='attached-panel'] {
  pointer-events: auto;
}
.parr-signature-inject {
  width: 100%;
  box-sizing: border-box;
  text-align: center;
}
.parr-signature-panel-wrap > .parr-signature-inject {
  background: var(--c-bg);
  border-top: 1px solid var(--c-border);
  box-sizing: border-box;
}

/* Attribution OSM : décalage = panneau signature DNAvatar seul (pas la languette) */
#map .leaflet-control-attribution {
  z-index: 600 !important;
  margin-bottom: var(--parr-signature-osm-reserve-h, 0px) !important;
  max-width: calc(100% - 12px);
  box-sizing: border-box;
}
.map-and-fiche {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ===== ROLE POPUP ===== */
/* Rôle : .parr-modal-mask — z-index élevé pour passer devant tout */
#roleScreen { z-index: 1100; }

.role-cards { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.role-card {
  background: var(--c-bg);
  border: 2px solid var(--c-border);
  border-radius: 10px;
  padding: 18px 14px;
  width: 150px;
  cursor: pointer;
  transition: border-color .15s, transform .12s;
  text-align: center;
}
.role-card:hover { border-color: var(--c-accent); transform: translateY(-2px); }
.role-card.selected { border-color: var(--c-accent); background: var(--c-panel); }
.role-card-icon { font-size: 28px; margin-bottom: 8px; }
.role-card-name { font-size: 14px; font-weight: 700; margin-bottom: 5px; }
.role-card-desc { font-size: 11px; color: var(--c-muted); line-height: 1.5; }

/* ===== COMMUNES IA — PANEL ÉDITABLE ===== */
/* Au-dessus du conteneur Leaflet (tuiles ~400, contrôles ~1000). */
.ai-communes-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1101;
  pointer-events: auto;
  background: rgba(15,30,62,.93);
  border: 1px solid #f5a623;
  border-radius: 6px;
  min-width: 230px;
  max-width: 290px;
  box-shadow: 0 2px 14px rgba(0,0,0,.5);
  font-size: 12px;
  color: #eaeaea;
}
.ai-communes-header {
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  font-size: 11px;
  font-weight: 700;
  color: #f5a623;
  border-bottom: 1px solid #2a3a5a;
}
.ai-communes-header:hover { background: rgba(255,255,255,.05); }
.ai-communes-toggle { font-size: 10px; margin-left: 8px; }
.ai-communes-edit {
  display: block;
  width: 100%;
  min-height: 140px;
  max-height: 260px;
  background: #0d1224;
  color: #a8c0e0;
  border: none;
  padding: 8px 10px;
  font-size: 10.5px;
  font-family: monospace;
  resize: vertical;
  border-radius: 0 0 6px 6px;
  line-height: 1.5;
}
.ai-communes-panel.collapsed .ai-communes-header { border-bottom: none; border-radius: 6px; }
.ai-communes-panel.collapsed .ai-communes-edit { display: none; }

/* ===== ZONE IA SELECTOR ===== */
.ai-zone-panel {
  position: absolute;
  bottom: 24px;
  right: 8px;
  background: rgba(15,30,62,.92);
  border: 1px solid #f5a623;
  border-radius: 6px;
  padding: 8px 10px;
  z-index: 1101;
  pointer-events: auto;
  min-width: 170px;
  max-width: 220px;
}
.ai-zone-header {
  font-size: 11px;
  font-weight: 700;
  color: #f5a623;
  margin-bottom: 5px;
}
.ai-zone-list {
  font-family: monospace;
  font-size: 10px;
  color: var(--c-muted);
  white-space: pre;
  max-height: 90px;
  overflow-y: auto;
  scrollbar-width: thin;
  background: rgba(255,255,255,.03);
  border-radius: 3px;
  margin-bottom: 7px;
}
.btn-ai-valider {
  width: 100%;
  background: #f5a623;
  color: #1a1a2e;
  border: none;
  border-radius: 4px;
  opacity: 0.88;
}
.ai-zone-hint {
  font-size: 10px;
  color: var(--c-muted);
  line-height: 1.4;
  padding: 2px 0 4px;
}

/* Label posé sur le contour du cercle IA */
.ai-circle-label-wrap { overflow: visible !important; background: transparent !important; border: none !important; }
.ai-circle-label {
  display: inline-block;
  transform: translateX(-50%);
  background: rgba(15,30,62,.82);
  color: #f5a623;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid #f5a623;
  border-radius: 3px;
  padding: 1px 6px;
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: .03em;
}

/* ===== RESPONSIVE ===== */
.input-no-spin { width: 52px; }
.input-no-spin::-webkit-inner-spin-button,
.input-no-spin::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.input-no-spin { -moz-appearance: textfield; }

@media (max-width: 640px) {
  .toolbar-group { border-right: none; }
  .header-title { font-size: 13px; }
  .header-actions { margin-left: 12px; gap: 6px; }
}
