/* =========================================================================
   Mes obligations face au risque inondation - Quint-Fonsegrives
   Feuille de style principale
   Mobile-first, variables CSS, thème clair uniquement (contexte réglementaire
   -> on privilégie une lecture stable et imprimable plutôt qu'un mode sombre).
   ========================================================================= */

:root {
  /* Palette neutre de l'interface (volontairement distincte des couleurs
     réglementaires des zones, pour ne jamais les confondre) */
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-surface-alt: #eef1f5;
  --color-border: #d7dce3;
  --color-text: #1c2530;
  --color-text-muted: #545f6d;
  --color-primary: #0b4f6c;
  --color-primary-dark: #08394d;
  --color-primary-contrast: #ffffff;
  --color-focus: #1a73e8;
  --color-danger: #b3261e;
  --color-success: #2e7d32;

  /* Couleurs réglementaires des zones PPRi : DOIVENT rester cohérentes avec
     data/*.geojson (propriété zoneColor) et docs/METHODOLOGIE.md */
  --zone-bleue: #4fa8e0;
  --zone-jaune: #fbc02d;
  --zone-rouge: #e2001a;
  --zone-grise-hachuree: #8a8a8a;
  --zone-pourpre: #9e9e9e;
  --zone-hors: #9e9e9e;

  /* Identité LEXALÉA : nav sombre + un badge de couleur par parcours (voir
     docs/ARCHITECTURE pour l'origine de ces teintes, reprises du prototype
     d'interface). Les bandeaux du panneau Habitants reprennent la palette
     du prototype (proto_lexalea.pptx). */
  --nav-bg: #2a2a2a;
  --nav-bg-dark: #1f1f1f;
  --mode-habitants: #2e3b52;
  --mode-elus: #6b5a1f;
  --mode-services: #2f6f63;
  --band-zonage: #afc2e8;
  --band-profil: #f5d76e;
  --band-estimation: #9fb4dd;
  --band-mesures: #c9ddc2;
  --band-travaux: #f3c8a6;
  /* Variantes très claires des couleurs ci-dessus, utilisées comme fond de
     pastille d'icône et comme léger lavis de l'en-tête quand le bandeau est
     ouvert (voir .band-head-icon / details[open] > .band-head). */
  --band-zonage-soft: #eaf0fb;
  --band-profil-soft: #fdf6df;
  --band-estimation-soft: #e9eff9;
  --band-mesures-soft: #eaf5e7;
  --band-travaux-soft: #fdf0e3;

  /* Codage obligatoire / recommandé / aides (mesures) et neuf / existant
     (travaux) : couleur + icône + libellé, jamais la couleur seule (voir
     bandeaux « Mesures » et « Règles de travaux », src/js/app.js). */
  --color-mandatory: #b3261e;
  --color-mandatory-bg: #fbeceb;
  --color-mandatory-border: #f0cbc8;
  --color-recommended: #0f6a5e;
  --color-recommended-bg: #e9f4f2;
  --color-recommended-border: #c7e6e0;
  --color-aide: #8a5a1e;
  --color-aide-bg: #f8f0e0;
  --color-aide-border: #eaddba;
  --color-neuf-bg: #eef3f8;
  --color-existant-bg: #f8f3ea;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-1: 0 1px 3px rgba(20, 27, 36, 0.12), 0 1px 2px rgba(20, 27, 36, 0.08);
  --shadow-2: 0 8px 24px rgba(20, 27, 36, 0.18);

  --header-h: 56px;
  --panel-peek-h: 96px;

  color-scheme: light;
}

* {
  box-sizing: border-box;
}

/* Les écrans applicatifs (en-tête, accueil, carte) fixent tous un display
   explicite (flex/block) pour leur état visible, ce qui l'emporterait sur
   l'attribut [hidden] du navigateur (règle de spécificité égale, UA vs
   auteur) sans cette surcharge explicite. setMode()/showAccueil() dans
   src/js/app.js basculent ces 3 écrans via l'attribut hidden. */
#app-header[hidden],
#screen-map[hidden],
#screen-accueil[hidden] {
  display: none;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-primary);
}

a:hover {
  color: var(--color-primary-dark);
}

img { max-width: 100%; }

/* ---------- Accessibilité : lien d'évitement + focus visible ---------- */

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--color-primary);
  color: #fff;
  padding: 10px 16px;
  z-index: 2000;
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* ============================== En-tête ============================== */

.app-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--nav-bg);
  color: #fff;
  z-index: 1200;
  box-shadow: var(--shadow-1);
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #333;
  text-decoration: none;
  line-height: 1.15;
  min-width: 0;
  flex: none;
}

.app-header .brand .brand-pill {
  flex: none;
  background: #fff;
  color: #2a2a2a;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.01em;
  padding: 7px 14px;
  border-radius: 9px;
}

.app-header .mode-badge {
  flex: none;
  background: var(--mode-badge, var(--mode-habitants));
  color: #fff;
  font-weight: 600;
  font-size: 12.5px;
  padding: 7px 13px;
  border-radius: 9px;
  white-space: nowrap;
}

.app-header .nav-retour {
  color: #fff;
  opacity: 0.88;
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: none;
}

.app-header .nav-retour:hover { opacity: 1; }

.app-header .brand-text {
  color: #fff;
  opacity: 0.85;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: auto;
  display: none;
}

.app-header nav.nav-pills {
  display: none;
}

.app-header .menu-toggle {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
  margin-left: auto;
}

@media (min-width: 640px) {
  .app-header .nav-retour { display: inline; }
}

@media (min-width: 860px) {
  .app-header .brand-text { display: block; margin-right: 0; }
  .app-header nav.nav-pills {
    display: flex;
    gap: 8px;
    margin-left: auto;
  }
  .app-header nav.nav-pills a {
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.5);
    opacity: 0.92;
    transition: background 0.15s ease, opacity 0.15s ease;
  }
  .app-header nav.nav-pills a:hover,
  .app-header nav.nav-pills a[aria-current="page"] {
    background: rgba(255,255,255,0.15);
    opacity: 1;
  }
  .app-header .menu-toggle {
    display: none;
  }
}

/* Menu mobile déroulant */
.mobile-nav {
  position: fixed;
  top: var(--header-h);
  left: 0;
  right: 0;
  background: var(--nav-bg-dark);
  z-index: 1150;
  display: none;
  flex-direction: column;
  padding: 8px;
  box-shadow: var(--shadow-2);
}

.mobile-nav.open {
  display: flex;
}

.mobile-nav a {
  color: #fff;
  text-decoration: none;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
}

.mobile-nav a:hover {
  background: rgba(255,255,255,0.12);
}

@media (min-width: 860px) {
  .mobile-nav { display: none !important; }
}

/* ============================ Écran d'accueil =========================== */
/* 3 parcours (Habitants / Élus & collectivités / Services techniques), repris
   du prototype d'interface (proto_lexalea.pptx) : carte claire sur fond
   cartographique abstrait, pastille LEXALÉA, un bouton par parcours. */

.screen-accueil {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 60% 50% at 72% 30%, #3a5a78 0%, transparent 60%),
    radial-gradient(ellipse 50% 45% at 22% 75%, #3f6b52 0%, transparent 55%),
    #22303c;
}

.accueil-card {
  background: #fbeac2;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: 44px 40px;
  max-width: 560px;
  width: 100%;
  text-align: center;
}

.accueil-logo {
  display: inline-block;
  background: #fff;
  color: #2a2a2a;
  font-weight: 800;
  font-size: 18px;
  padding: 9px 20px;
  border-radius: 9px;
  margin-bottom: 20px;
}

.accueil-card h1 {
  margin: 0 0 10px;
  font-size: 1.5rem;
  color: #a67c1e;
  font-weight: 800;
}

.accueil-card p {
  margin: 0 0 28px;
  color: #6b5a1f;
  font-size: 0.95rem;
  line-height: 1.55;
}

.accueil-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.accueil-btn {
  border: none;
  border-radius: 10px;
  padding: 16px 14px;
  color: #fff;
  font-weight: 700;
  font-size: 14.5px;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.accueil-btn:hover,
.accueil-btn:focus-visible { filter: brightness(1.08); }

.accueil-btn:active { transform: scale(0.98); }

.accueil-btn-habitants { background: var(--mode-habitants); }
.accueil-btn-elus { background: var(--mode-elus); }
.accueil-btn-services { background: var(--mode-services); }

/* ====================== Page de contenu (non-carte) ==================== */

.content-page {
  padding-top: calc(var(--header-h) + 24px);
  max-width: 820px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
  padding-bottom: 64px;
  line-height: 1.6;
}

.content-page h1 {
  font-size: 1.6rem;
  color: var(--color-primary-dark);
}

.content-page h2 {
  font-size: 1.2rem;
  color: var(--color-primary-dark);
  margin-top: 2em;
}

.content-page .lead {
  font-size: 1.05rem;
  color: var(--color-text-muted);
}

.notice {
  background: #fff8e1;
  border: 1px solid #f2d98a;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 0.95rem;
  margin: 20px 0;
}

.notice.info {
  background: #e8f1f7;
  border-color: #b9d6e6;
}

.faq-item {
  border-bottom: 1px solid var(--color-border);
  padding: 14px 0;
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-primary-dark);
}

.faq-item p {
  margin-top: 10px;
  color: var(--color-text);
}

footer.site-footer {
  border-top: 1px solid var(--color-border);
  margin-top: 40px;
  padding: 20px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-align: center;
}

/* ============================ Application carte ========================= */

.map-app {
  position: fixed;
  inset: var(--header-h) 0 0 0;
  display: block;
}

#map {
  position: absolute;
  inset: 0;
}

/* Boutons flottants (recherche, légende) */
.map-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 900;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  pointer-events: none;
}

.map-toolbar > * {
  pointer-events: auto;
}

.search-box {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 420px;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  display: flex;
  align-items: center;
  padding: 4px 4px 4px 12px;
  position: relative;
}

.search-box input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 15px;
  padding: 10px 6px;
  background: transparent;
  color: var(--color-text);
  min-width: 0;
}

.search-box button {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  cursor: pointer;
  flex: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  max-height: 260px;
  overflow-y: auto;
  display: none;
}

.search-results.open { display: block; }

.search-results button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
  cursor: pointer;
  color: var(--color-text);
}

.search-results button:hover,
.search-results button:focus-visible {
  background: var(--color-surface-alt);
}

.icon-btn {
  background: var(--color-surface);
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  width: 42px;
  height: 42px;
  font-size: 18px;
  cursor: pointer;
  flex: none;
  color: var(--color-text);
}

.icon-btn[aria-pressed="true"] {
  background: var(--color-primary);
  color: #fff;
}

/* Géolocalisation : bouton dédié en bas à droite au-dessus du panneau */
.locate-btn {
  position: absolute;
  right: 12px;
  z-index: 850;
  bottom: calc(var(--panel-peek-h) + 16px);
}

/* ------------------------------- Légende --------------------------------
   Bouton + panneau déroulant (et non un contrôle Leaflet toujours visible)
   pour ne jamais recouvrir la recherche ni le panneau d'information, quelle
   que soit la taille d'écran. */

.legend-wrapper {
  position: relative;
  flex: none;
}

.legend-box {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  padding: 12px 14px;
  font-size: 13px;
  width: 240px;
  max-width: calc(100vw - 24px);
  display: none;
}

.legend-box.open {
  display: block;
}

.legend-box h3 {
  margin: 0 0 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex: none;
  border: 1px solid rgba(0,0,0,0.15);
}

/* --------------------------- Tableau de bord ------------------------------
   Même principe bouton + panneau déroulant que la légende, à l'attention
   des élus/techniciens : agrégats communaux dont chaque donnée est
   cliquable pour surligner les bâtiments correspondants sur la carte
   (voir dashboardHighlight dans src/js/app.js). */

.dashboard-wrapper {
  position: relative;
  flex: none;
}

.dashboard-box {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  padding: 14px 16px;
  font-size: 13px;
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: min(70vh, 560px);
  overflow-y: auto;
  display: none;
}

.dashboard-box.open {
  display: block;
}

body[data-mode="elus"] .dashboard-box {
  width: 420px;
}

.dashboard-box h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.dashboard-intro {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.dashboard-active-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 12px;
  margin-bottom: 10px;
}

/* Le sélecteur ci-dessus a la même spécificité que la règle [hidden] du
   navigateur (display:none) : sans cette surcharge explicite, l'ordre des
   règles ferait gagner .dashboard-active-filter et la puce resterait
   visible même une fois l'attribut hidden posé par le JS. */
.dashboard-active-filter[hidden] {
  display: none;
}

.dashboard-active-filter button {
  flex: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}

.dashboard-group + .dashboard-group {
  margin-top: 14px;
}

.dashboard-group h4 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.dashboard-tile {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-alt);
  cursor: pointer;
  margin-bottom: 6px;
  font: inherit;
  color: var(--color-text);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dashboard-tile:last-child {
  margin-bottom: 0;
}

.dashboard-tile:hover,
.dashboard-tile:focus-visible {
  border-color: var(--color-primary);
}

.dashboard-tile-count {
  flex: none;
  min-width: 32px;
  font-weight: 700;
  font-size: 15px;
  color: var(--color-primary);
  text-align: right;
}

.dashboard-tile-label {
  flex: 1;
  line-height: 1.25;
}

.dashboard-tile.sub {
  margin-left: 18px;
  width: calc(100% - 18px);
  background: transparent;
  border-style: dashed;
}

.dashboard-tile-zone .legend-swatch {
  flex: none;
}

/* Placée après .dashboard-tile.sub (même spécificité que lui) pour que
   l'état actif l'emporte toujours, y compris sur une sous-tuile dont le
   fond transparent écraserait sinon le fond bleu ci-dessous. */
.dashboard-tile[aria-pressed="true"] {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.dashboard-tile[aria-pressed="true"] .dashboard-tile-count {
  color: #fff;
}

/* --------- Parcours : badge de mode, visibilité conditionnelle ----------- */

body[data-mode="habitants"] .mode-badge { background: var(--mode-habitants); }
body[data-mode="elus"] .mode-badge { background: var(--mode-elus); }
body[data-mode="services"] .mode-badge { background: var(--mode-services); }

/* Le tableau de bord communal (agrégats + chapitre 4) est réservé au
   parcours Élus & collectivités : masqué ailleurs plutôt que dupliqué. */
body:not([data-mode="elus"]) .dashboard-wrapper { display: none; }

/* --------- Tableau de bord communal : statistiques + chapitre 4 ---------- */

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.dashboard-stat {
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.dashboard-stat strong {
  display: block;
  font-size: 1.15rem;
  color: var(--mode-elus);
}

.dashboard-stat span {
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1.3;
}

.chapitre4-card {
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  margin-bottom: 8px;
}

.chapitre4-card:last-child { margin-bottom: 0; }

.chapitre4-card .chapitre4-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.chapitre4-card .chapitre4-title {
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--color-text);
}

.chapitre4-card .chapitre4-delai {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e7dec4;
  color: var(--mode-elus);
  white-space: nowrap;
}

.chapitre4-card p {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0 0 4px;
  line-height: 1.5;
}

.chapitre4-card .chapitre4-ref {
  font-size: 10.5px;
  color: #999;
}

/* ----------- Services techniques : panneau « socle commun » par zone ----- */

.zone-exception-callout {
  background: #fbeac2;
  border: 1px solid #f0d898;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.85rem;
  line-height: 1.55;
  color: #7a5c14;
  margin: 10px 0 16px;
}

.socle-theme-card {
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.socle-theme-card:last-child { margin-bottom: 0; }

.socle-theme-card h4 {
  margin: 0 0 4px;
  font-size: 0.86rem;
  color: var(--color-primary-dark);
}

.socle-theme-card p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--color-text);
  line-height: 1.55;
}

.zone-chip-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 16px;
}

.zone-chip {
  border: none;
  border-radius: 9px;
  padding: 11px 13px;
  font-size: 0.83rem;
  font-weight: 700;
  color: #fff;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.zone-chip:hover,
.zone-chip:focus-visible {
  filter: brightness(1.08);
}

.zone-chip:active {
  transform: scale(0.98);
}

.zone-chip[aria-pressed="true"] {
  outline: 3px solid #232323;
  outline-offset: -3px;
}

/* ------------------------------ Panneau info ----------------------------- */

/* Voile qui assombrit la carte pendant l'écran d'accueil du panneau (avant
   toute sélection d'un bâtiment ou d'une zone) : met en valeur la carte
   d'accueil centrée ci-dessous. Se referme au clic, ou dès qu'un bâtiment /
   une zone est sélectionné (voir dismissWelcomeIntro(), src/js/app.js §4). */
.panel-backdrop {
  position: absolute;
  inset: 0;
  z-index: 950;
  background: rgba(15, 23, 32, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.panel-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.info-panel {
  position: absolute;
  z-index: 1000;
  background: var(--color-surface);
  box-shadow: var(--shadow-2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Mobile : bottom sheet */
.info-panel {
  left: 0;
  right: 0;
  bottom: 0;
  top: auto;
  height: var(--panel-peek-h);
  max-height: 82vh;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  transition: height 0.28s ease;
}

.info-panel.expanded {
  height: 82vh;
}

.panel-handle {
  width: 100%;
  border: none;
  background: none;
  padding: 10px 16px 6px;
  cursor: pointer;
  flex: none;
  text-align: left;
}

.panel-handle .grip {
  width: 40px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin: 0 auto 10px;
}

.panel-handle .panel-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-handle .zone-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
}

.panel-handle h2 {
  margin: 0;
  font-size: 1.02rem;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-handle .panel-subtitle {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.panel-body {
  padding: 0 18px 24px;
  overflow-y: auto;
  flex: 1;
}

.panel-body .intro-block p {
  color: var(--color-text-muted);
}

.panel-body .badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
}

.panel-body section.detail-block {
  border-top: 1px solid var(--color-border);
  padding: 14px 0;
}

.panel-body section.detail-block h3 {
  font-size: 0.95rem;
  margin: 0 0 8px;
  color: var(--color-primary-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-body section.detail-block p,
.panel-body section.detail-block li {
  font-size: 0.92rem;
  color: var(--color-text);
}

.panel-body .figure-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0;
}

.figure-chip {
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.85rem;
}

.figure-chip strong {
  display: block;
  font-size: 1.05rem;
  color: var(--color-primary-dark);
}

details.tech-details {
  margin-top: 10px;
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

details.tech-details summary {
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

details.tech-details .tech-row {
  font-size: 0.82rem;
  padding: 6px 0;
  border-top: 1px solid var(--color-border);
}

details.tech-details .tech-row:first-of-type {
  border-top: none;
}

details.tech-details dt {
  font-weight: 600;
  color: var(--color-text-muted);
}

details.tech-details dd {
  margin: 2px 0 0;
}

/* --------------------- Panneau en bandeaux (Habitants / Services) --------
   Accordéon de cartes : chaque bandeau est une carte à bords arrondis avec
   une pastille d'icône colorée (reprenant le code couleur du prototype,
   mais en touche discrète plutôt qu'en aplat plein-largeur) et un chevron
   qui pivote à l'ouverture. Utilisé par renderBuildingPanel() (parcours
   Habitants et Services techniques) et par renderZonePanel() (socle commun,
   parcours Services techniques), voir src/js/app.js §4 et §4ter. */

.band-accordion {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 2px;
}

.band-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
}

.band-item:hover {
  border-color: #c3cad4;
}

.band-item[open] {
  box-shadow: var(--shadow-1);
}

.band-head {
  width: 100%;
  list-style: none;
  text-align: left;
  cursor: pointer;
  padding: 12px 14px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-surface);
  transition: background-color 0.18s ease;
}

.band-head:hover,
.band-head:focus-visible {
  background: var(--color-surface-alt);
}

.band-head::-webkit-details-marker { display: none; }

.band-head-icon {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.band-head-label {
  flex: 1;
  line-height: 1.35;
}

.band-chevron {
  flex: none;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--color-text-muted);
  transition: transform 0.2s ease;
}

details[open] > .band-head .band-chevron {
  transform: rotate(180deg);
}

.band-body {
  padding: 4px 14px 16px;
  background: #fff;
  font-size: 0.88rem;
  line-height: 1.6;
  animation: band-body-reveal 0.2s ease;
}

@keyframes band-body-reveal {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.band-body p { margin: 0 0 8px; }
.band-body p:last-child { margin-bottom: 0; }

.band-estimation-figure {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--mode-habitants);
  margin: 4px 0 8px;
}

.calc-detail {
  margin-top: 8px;
  font-size: 0.82rem;
}

.calc-detail summary {
  cursor: pointer;
  color: var(--color-primary-dark);
  font-weight: 600;
}

.calc-detail ul {
  margin: 6px 0;
  padding-left: 18px;
}

.band-estimation-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #666;
  margin-bottom: 4px;
}

.band-item-zonage .band-head-icon { background: var(--band-zonage-soft); }
.band-item-profil .band-head-icon { background: var(--band-profil-soft); }
.band-item-estimation .band-head-icon { background: var(--band-estimation-soft); }
.band-item-mesures .band-head-icon { background: var(--band-mesures-soft); }
.band-item-travaux .band-head-icon { background: var(--band-travaux-soft); }

.band-item-zonage[open] > .band-head { background: var(--band-zonage-soft); }
.band-item-profil[open] > .band-head { background: var(--band-profil-soft); }
.band-item-estimation[open] > .band-head { background: var(--band-estimation-soft); }
.band-item-mesures[open] > .band-head { background: var(--band-mesures-soft); }
.band-item-travaux[open] > .band-head { background: var(--band-travaux-soft); }

.band-subaction {
  display: block;
  width: 100%;
  text-align: left;
  background: #ededed;
  border: none;
  border-radius: 8px;
  padding: 11px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  font-family: inherit;
  color: #232323;
  cursor: default;
  margin-bottom: 8px;
}

.band-subaction:last-child { margin-bottom: 0; }

/* ---------------------- Correction déclarative du visiteur --------------- */

.correction-active-note {
  margin: 8px 0 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-primary-dark);
}

details.correction-block {
  margin: 10px 0 14px;
  background: var(--color-surface-alt);
  border: 1px dashed var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

details.correction-block summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-primary-dark);
}

.correction-body {
  margin-top: 10px;
}

.correction-body fieldset {
  border: none;
  padding: 0;
  margin: 0 0 12px;
}

.correction-body legend {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: 0 0 6px;
}

.correction-body .radio-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  padding: 3px 0;
  cursor: pointer;
}

.correction-body select,
.correction-body input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 0.88rem;
}

.correction-body label {
  display: block;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.correction-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.correction-note {
  font-size: 0.76rem;
  margin: 10px 0 0;
}

/* ---------------- Mesures recommandées ou obligatoires ------------------- */

.measure-block {
  margin-bottom: 10px;
}

.measure-block:last-child {
  margin-bottom: 0;
}

.measure-block h4 {
  font-size: 0.85rem;
  margin: 0 0 4px;
  color: var(--color-primary-dark);
}

/* ------- Groupes de mesures : obligatoires / recommandées / aides -------
   Distinction par couleur ET icône ET libellé (jamais la couleur seule),
   chacune dans un encart teinté pour un regroupement visuel immédiat
   (principe de proximité). */

.measure-group {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.measure-group:last-child {
  margin-bottom: 0;
}

.measure-group-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
}

.measure-group-icon {
  font-size: 0.95rem;
}

.measure-group .measure-block h4 {
  color: inherit;
}

.measure-group-note {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: -2px 0 10px;
}

.measure-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  vertical-align: middle;
}

.measure-list {
  margin: 0;
  padding-left: 18px;
}

.measure-list li {
  margin-bottom: 6px;
}

.measure-list li:last-child {
  margin-bottom: 0;
}

.measure-group-obligatoire {
  background: var(--color-mandatory-bg);
  border: 1px solid var(--color-mandatory-border);
}

.measure-group-obligatoire .measure-group-head {
  color: var(--color-mandatory);
}

.measure-group-recommandee {
  background: var(--color-recommended-bg);
  border: 1px solid var(--color-recommended-border);
}

.measure-group-recommandee .measure-group-head {
  color: var(--color-recommended);
}

.measure-group-aides {
  background: var(--color-aide-bg);
  border: 1px solid var(--color-aide-border);
}

.measure-group-aides .measure-group-head {
  color: var(--color-aide);
}

/* --------- Règles de travaux : constructions nouvelles / existantes ----- */

.travaux-card {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.travaux-card:last-child {
  margin-bottom: 0;
}

.travaux-card p {
  font-size: 0.86rem;
  color: var(--color-text);
  margin: 0 0 8px;
  line-height: 1.55;
}

.travaux-card p:last-child {
  margin-bottom: 0;
}

.travaux-card-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  margin-bottom: 6px;
}

.travaux-icon {
  font-size: 0.95rem;
}

.travaux-card .travaux-lead {
  font-weight: 500;
  margin-bottom: 8px;
}

.travaux-card .travaux-note {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.travaux-card .travaux-subhead {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin: 12px 0 4px;
}

.travaux-list {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
}

.travaux-list li {
  font-size: 0.84rem;
  line-height: 1.5;
  padding: 8px 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.travaux-list li:first-child {
  border-top: none;
  padding-top: 2px;
}

.travaux-list-common li {
  color: var(--color-text-muted);
}

.travaux-ref {
  white-space: nowrap;
  font-size: 0.72rem;
  color: var(--color-text-muted);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 999px;
  padding: 0 6px;
  margin-left: 2px;
}

.travaux-card-neuf {
  background: var(--color-neuf-bg);
}

.travaux-card-existant {
  background: var(--color-existant-bg);
}

.panel-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--color-surface-alt);
  cursor: pointer;
  font-size: 16px;
}

/* Écran d'accueil du panneau (showWelcomePanel) : grande pastille d'icône,
   titre, texte d'intro, puis actions. Présenté en carte centrée au-dessus
   du voile .panel-backdrop tant qu'aucun bâtiment/zone n'est sélectionné. */
.intro-block-hero {
  text-align: left;
}

.intro-hero-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--band-estimation-soft);
  margin-bottom: 14px;
}

.welcome-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.welcome-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
}

.welcome-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-decoration: none;
}

.welcome-links a:hover,
.welcome-links a:focus-visible {
  color: var(--color-primary);
  text-decoration: underline;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn.primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.btn:hover { filter: brightness(0.97); }

.btn.primary:hover {
  box-shadow: 0 2px 10px rgba(11, 79, 108, 0.3);
}

.btn:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* Desktop : panneau latéral fixe */
@media (min-width: 860px) {
  .info-panel {
    top: 16px;
    right: 16px;
    bottom: 16px;
    left: auto;
    width: 380px;
    height: auto !important;
    max-height: none;
    border-radius: var(--radius-lg);
  }
  .panel-handle { cursor: default; }
  .panel-handle .grip { display: none; }
  .locate-btn { bottom: 16px; }
  .map-toolbar { right: 420px; }

  /* Écran d'accueil (avant toute sélection) : carte centrée au-dessus du
     voile .panel-backdrop plutôt que panneau latéral ancré, pour une
     première impression plus claire et plus engageante (voir
     showWelcomePanel() / dismissWelcomeIntro(), src/js/app.js §4). */
  .info-panel.panel-welcome-intro {
    top: 50%;
    right: auto;
    bottom: auto;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(460px, calc(100vw - 48px));
    max-height: min(85vh, 600px);
    border-radius: var(--radius-lg);
    animation: welcome-pop 0.22s ease;
  }
}

@keyframes welcome-pop {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.info-panel.panel-welcome-intro .panel-handle {
  padding: 26px 26px 6px;
}

.info-panel.panel-welcome-intro .panel-handle .zone-dot {
  display: none;
}

.info-panel.panel-welcome-intro .panel-handle h2 {
  white-space: normal;
  font-size: 1.2rem;
  line-height: 1.3;
}

.info-panel.panel-welcome-intro .panel-body {
  padding: 0 26px 26px;
}

/* ------------------------- Étiquettes / marqueurs ERP -------------------- */

.erp-marker {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md);
}

/* ---------------- Repères clignotants du tableau de bord ----------------
   Voir dashboardBeacons / spawnDashboardBeacon dans src/js/app.js : un
   bâtiment surligné reste minuscule à l'échelle communale, ce cercle en
   pixels fixes (donc de taille constante quel que soit le zoom) clignote
   deux fois puis est retiré de la carte. */

@keyframes dashboard-beacon-ping {
  0% { transform: scale(0.6); opacity: 0.9; }
  70% { transform: scale(2); opacity: 0; }
  100% { transform: scale(2); opacity: 0; }
}

.dashboard-beacon {
  transform-box: fill-box;
  transform-origin: center;
  animation: dashboard-beacon-ping 1.3s ease-out 2;
  pointer-events: none;
}

/* -------------------------------- Utilitaires ---------------------------- */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.text-muted { color: var(--color-text-muted); }
