/* ============================================================
   HydroBassin Tunisie — UI v2
   Design system : Manrope, dark/light, bleu-cyan premium
   ============================================================ */

/* ------------------------------------------------------------------ Variables */
:root {
  /* Palette sombre (défaut) — navy profond, accents cyan/bleu */
  --bg-deep:        #0c1c2e;
  --bg-deep-2:      #07111e;
  --bg-deep-3:      #050d17;

  --panel-bg:       rgba(12, 26, 44, 0.92);
  --panel-border:   rgba(86, 158, 214, 0.16);
  --panel-border-m: rgba(86, 158, 214, 0.26);

  --sidebar-bg:     rgba(8, 18, 30, 0.82);
  --sidebar-border: rgba(86, 158, 214, 0.17);

  --cyan:  #33c7e6;
  --blue:  #2f7af0;
  --blue2: #2161d8;
  --teal:  #16a9c6;
  --green: #37d896;
  --amber: #fbbf24;
  --red:   #f87171;

  --text:       #d6e8f5;
  --text-2:     #e2eef8;
  --text-muted: #8cafc8;
  --text-dim:   #6d8ea6;

  --card-bg:    rgba(14, 30, 50, 0.60);
  --card-bg-2:  rgba(14, 30, 50, 0.40);
  --input-bg:   rgba(8, 18, 30, 0.78);

  --radius:     12px;
  --radius-sm:  9px;

  /* Couleurs des couches cartographiques — synchronisées avec constants.js */
  --map-stream:      #22d3ee;
  --map-watershed:   #3b82f6;
  --map-outlet:      #f87171;
  --map-outlet-test: #9aa8b8;
  --map-admin:       #7e92a6;
}

[data-theme="light"] {
  --bg-deep:        #eff3f8;
  --bg-deep-2:      #e5ecf3;
  --bg-deep-3:      #dae3ed;

  --panel-bg:       rgba(255, 255, 255, 0.97);
  --panel-border:   rgba(34, 62, 98, 0.11);
  --panel-border-m: rgba(34, 62, 98, 0.19);

  --sidebar-bg:     rgba(255, 255, 255, 0.97);
  --sidebar-border: rgba(34, 62, 98, 0.12);

  --text:       #1a3349;
  --text-2:     #0f2337;
  --text-muted: #4a6278;
  --text-dim:   #7a92a8;

  --card-bg:    rgba(248, 252, 255, 0.95);
  --card-bg-2:  rgba(243, 248, 253, 0.95);
  --input-bg:   rgba(238, 245, 252, 0.97);
}

/* ---- Light mode — overrides pour éléments avec valeurs codées en dur ---- */
[data-theme="light"] body {
  background: radial-gradient(120% 90% at 50% -10%, #eff3f8 0%, #e5ecf3 55%, #dae3ed 100%);
}

[data-theme="light"] .app-header {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(240, 245, 252, 0.96));
}

[data-theme="light"] .chart-wrap {
  background: rgba(234, 243, 252, 0.72);
}
[data-theme="light"] .chart-empty {
  background: rgba(234, 243, 252, 0.88);
  color: #6a8299;
}

[data-theme="light"] .sidebar-legend {
  background: rgba(241, 246, 252, 0.60);
  border-color: rgba(47, 122, 240, 0.14);
}

[data-theme="light"] .leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.92) !important;
  color: #7a92a8 !important;
}
[data-theme="light"] .leaflet-control-attribution a { color: var(--blue) !important; }
/* Zoom Leaflet en thème clair : même conteneur/boutons que .map-tools
   (spécification harmonisée, cf. section « Contrôles de carte »). */
[data-theme="light"] .leaflet-control-zoom.leaflet-bar {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(47, 122, 240, 0.20);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .leaflet-control-zoom.leaflet-bar a {
  background: none;
  border-color: transparent;
  color: #4a6278;
}
[data-theme="light"] .leaflet-control-zoom.leaflet-bar a:hover {
  background: rgba(47, 122, 240, 0.08);
  border-color: rgba(47, 122, 240, 0.28);
  color: var(--blue);
}

[data-theme="light"] .btn-import {
  background: rgba(241, 246, 252, 0.95);
  border-color: rgba(47, 122, 240, 0.22);
}

/* .btn-icon-sq (bouton thème du header) : le cyan brut tombe sous 3:1 de
   contraste sur fond quasi-blanc. Même substitution cyan→blue déjà utilisée
   pour .fscale-bar et .btn-reset-link en thème clair. */
[data-theme="light"] .btn-icon-sq { color: var(--blue); }


[data-theme="light"] .error-banner {
  background: rgba(220, 38, 38, 0.07);
  border-bottom-color: rgba(220, 38, 38, 0.22);
  color: #991b1b;
}
[data-theme="light"] .error-banner button { color: #991b1b; }

/* ------------------------------------------------------------------ Reset */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: radial-gradient(120% 90% at 50% -10%, var(--bg-deep) 0%, var(--bg-deep-2) 55%, var(--bg-deep-3) 100%);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 1;
  transition: background 0.3s ease, color 0.3s ease;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

#app-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ------------------------------------------------------------------ Scrollbar */
.hb-scroll::-webkit-scrollbar { width: 6px; }
.hb-scroll::-webkit-scrollbar-track { background: transparent; }
.hb-scroll::-webkit-scrollbar-thumb {
  background: rgba(90, 150, 200, 0.18);
  border-radius: 6px;
}
.hb-scroll:hover::-webkit-scrollbar-thumb { background: rgba(90, 150, 200, 0.32); }

/* ================================================================ HEADER */
.app-header {
  height: 72px;
  flex: 0 0 72px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 22px;
  background: linear-gradient(180deg, var(--panel-bg), rgba(8, 17, 28, 0.80));
  border-bottom: 1px solid var(--panel-border);
  position: relative;
  z-index: 20;
  backdrop-filter: blur(14px);
  transition: background 0.3s ease;
}

/* Logo + titre */
.hdr-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  flex-shrink: 0;
  min-width: 0;
}

.logo-mark {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(150deg, #1f6fd6, #16b6d8);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 20px -6px rgba(28, 150, 210, 0.65),
              inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.hdr-title-group { line-height: 1.15; min-width: 0; }

.title-main {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text-2);
  white-space: nowrap;
}
.title-cyan { color: var(--cyan); }
.title-sub {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 500;
  white-space: nowrap;
}

/* Centre */
.hdr-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

/* La pastille d'en-tête annonçant le moteur de délimitation (.engine-status,
   .status-dot, @keyframes status-blink) a été retirée de l'interface : ses
   règles n'avaient plus d'usage. .hdr-center subsiste, vide, comme unique
   élément d'espacement flexible entre la marque et les actions. */

/* Actions droite */
.hdr-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hdr-sep {
  width: 1px; height: 28px;
  background: var(--panel-border-m);
  margin: 0 3px;
}

/* ================================================================ EXPORT SIG (Lot 4) */
.sig-export { position: relative; }

.sig-export-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border-m);
  border-radius: 10px;
  box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.35);
  z-index: 30;
}
.sig-export-menu[hidden] { display: none; }

.sig-export-item {
  display: flex;
  align-items: center;
  width: 100%;
  border: none;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.sig-export-item:hover { background: var(--card-bg-2); color: var(--cyan); }
[data-theme="light"] .sig-export-item:hover { color: var(--blue); }

/* Contenu réservé aux lecteurs d'écran (ex. détail de progression d'analyse) :
   jamais affiché visuellement, jamais dans le libellé d'un bouton. */
.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;
}

/* ================================================================ BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  border-radius: 11px;
  padding: 0 16px;
  height: 42px;
  white-space: nowrap;
  /* Sans effet sur un <button> (jamais souligné) — nécessaire pour que .btn
     appliqué à un <a> (ex. "Nous contacter", lien mailto: natif) rende
     identiquement à un bouton. */
  text-decoration: none;
  color: inherit;
  transition: background 0.18s, border-color 0.18s, opacity 0.18s, transform 0.15s, box-shadow 0.18s;
}
.btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none !important; }
.btn svg { flex-shrink: 0; }
.btn[hidden] { display: none; }
/* [hidden] seul ne suffit pas sur <svg> (spécificité/UA) — sans cette règle
   les deux icônes du bouton thème (lune/soleil) restaient visibles ensemble. */
svg[hidden] { display: none; }

/* Anneau de focus clavier — vocabulaire cyan déjà établi (.coord-input:focus,
   .btn-reset-link:focus-visible). Scopé au header pour ne pas affecter les
   boutons .btn de la sidebar/du panneau résultats qui partagent la classe. */
.app-header .btn:focus-visible {
  outline: none;
  border-color: rgba(51, 199, 230, 0.55);
  box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.10);
}

.btn-blue {
  background: linear-gradient(180deg, var(--blue), var(--blue2));
  color: #fff;
  border: 1px solid rgba(60, 140, 235, 0.55);
  box-shadow: 0 6px 18px -8px rgba(47, 122, 240, 0.85);
}
.btn-blue:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px -6px rgba(47, 122, 240, 0.9);
}

.btn-teal {
  background: linear-gradient(180deg, var(--teal), #0d8ba8);
  color: #fff;
  border: 1px solid rgba(30, 180, 205, 0.5);
  box-shadow: 0 6px 18px -8px rgba(22, 169, 198, 0.85);
}
.btn-teal:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px -6px rgba(22, 169, 198, 0.9);
}

.btn-ghost {
  background: var(--card-bg-2);
  color: var(--text-2);
  border: 1px solid var(--panel-border-m);
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(86, 158, 214, 0.12);
  border-color: rgba(86, 158, 214, 0.28);
}

.btn-primary {
  background: linear-gradient(180deg, #3d88f5, var(--blue2));
  color: #fff;
  border: 1px solid rgba(60, 140, 235, 0.55);
  box-shadow: 0 8px 22px -8px rgba(47, 122, 240, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  height: 48px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.2px;
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px -6px rgba(47, 122, 240, 0.92), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.btn-block {
  width: 100%;
  justify-content: center;
}

/* Spinner de traitement du bouton principal d'analyse : remplace l'icône
   flèche à l'identique (même emplacement, mêmes dimensions 15x15) pour ne
   provoquer aucun décalage de largeur/alignement — cf. correctif "Analyse en
   cours" qui déformait le bouton. */
.btn-spinner { animation: btn-spinner-rotate 0.8s linear infinite; transform-origin: 50% 50%; }
@keyframes btn-spinner-rotate { to { transform: rotate(360deg); } }

.btn-icon-sq {
  width: 40px; height: 40px;
  padding: 0;
  border-radius: 11px;
  background: var(--card-bg-2);
  color: var(--cyan);
  border: 1px solid var(--panel-border-m);
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.btn-icon-sq:hover {
  border-color: rgba(51, 199, 230, 0.5);
  box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.12);
}

.flex-1 { flex: 1; }

/* ================================================================ ERROR BANNER */
.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: rgba(248, 113, 113, 0.12);
  border-bottom: 1px solid rgba(248, 113, 113, 0.30);
  color: #ffd9d6;
  font-size: 13px;
  font-weight: 500;
  flex-shrink: 0;
}
.error-banner[hidden] { display: none; }
.error-banner button {
  background: none; border: none;
  font-size: 20px; line-height: 1;
  color: #ffd9d6; cursor: pointer; padding: 0 4px;
}

/* ================================================================ LAYOUT BODY */
.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 8px;
  padding: 8px;
  overflow: hidden;
}

/* ================================================================ LEFT SIDEBAR */
.sidebar-left {
  display: flex;
  flex-direction: column;
  width: 296px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: 16px;
  backdrop-filter: blur(14px);
  overflow: hidden;
  transition: background 0.3s ease;
}

/* Tab bar */
.stab-bar {
  display: flex;
  padding: 6px 6px 0;
  gap: 4px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}

.stab {
  flex: 1;
  padding: 12px 6px 11px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  text-align: center;
  border-radius: 9px 9px 0 0;
  transition: color 0.18s;
  font-family: inherit;
}
.stab:hover { color: var(--text); }
.stab.is-active {
  color: var(--text-2);
}
.stab.is-active::after {
  content: '';
  position: absolute;
  left: 16%; right: 16%;
  bottom: -1px;
  height: 2.5px;
  border-radius: 2px;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}

/* Tab panels */
.stab-panel {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.stab-panel[hidden] { display: none; }

/* Layer list */
.layer-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.layer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border-radius: 11px;
  border: 1px solid var(--panel-border);
  background: var(--card-bg-2);
  transition: border-color 0.18s, background 0.18s;
}
.layer-item.is-active {
  border-color: rgba(86, 158, 214, 0.22);
  background: rgba(86, 158, 214, 0.07);
}

.layer-avail {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  flex-shrink: 0;
  box-shadow: 0 0 5px rgba(51, 199, 230, 0.6);
}

.layer-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.layer-info { flex: 1; min-width: 0; }
.layer-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  line-height: 1.2;
}
.layer-desc {
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.35;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-check {
  width: 16px; height: 16px;
  flex-shrink: 0;
  accent-color: var(--cyan);
  cursor: pointer;
}

/* Import button */
.btn-import {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 14px;
  margin-top: 4px;
  border-radius: 12px;
  border: 1.5px dashed rgba(51, 199, 230, 0.28);
  background: rgba(13, 28, 46, 0.3);
  color: var(--text-muted);
  font-family: inherit;
  cursor: not-allowed;
  opacity: 0.7;
  text-align: left;
}
.import-label { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.import-desc  { font-size: 10px; color: var(--text-dim); margin-top: 1px; }

/* ================================================================ GUIDE
   Onglet "Guide" (remplace l'ancien onglet "Sources"). Deux vues dans le
   même panneau, jamais de popup/modale : #guide-home (carte "Premiers pas")
   et #guide-steps (contenu détaillé). Piloté par webapp/js/guide.js. */

/* "Premiers pas" est désormais une carte compacte au même modèle que FAQ et
   Besoin d'aide (.guide-mini-card, plus bas) — plus de structure CSS dédiée
   et volumineuse : seule la variante "métadonnée" (5 étapes · environ 2 min)
   est propre à cette carte, cf. .guide-mini-card-meta. */

/* -------- Vue détaillée par étapes -------- */

/* "Retour au Guide" — élément propre au Guide (ne réutilise pas
   .btn-reset-link, partagée avec "Réinitialiser le point" ailleurs dans
   l'app) : alignement à gauche assumé (pas de centrage), zone cliquable
   généreuse, contraste plus soutenu qu'un simple lien discret, sans devenir
   un bouton principal. */
.guide-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px 7px 8px;
  margin: 0 0 2px -8px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.guide-back-btn:hover { color: var(--text-2); background: rgba(86, 158, 214, 0.10); }
.guide-back-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.20);
}
[data-theme="light"] .guide-back-btn { color: #4a6278; }
[data-theme="light"] .guide-back-btn:hover { color: var(--blue); background: rgba(47, 122, 240, 0.08); }
[data-theme="light"] .guide-back-btn:focus-visible { box-shadow: 0 0 0 3px rgba(47, 122, 240, 0.22); }

.guide-steps-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}
.guide-step-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  white-space: nowrap;
}

/* Indicateur de progression à 5 étapes — même vocabulaire visuel que
   .phase-indicator (pastille numérotée + segment de liaison), décliné pour
   le Guide. Le numéro reste toujours affiché (jamais uniquement une couleur
   qui porterait seule le sens de la progression). */
.guide-progress {
  display: flex;
  align-items: flex-start;
  margin: 10px 0 8px;
  padding: 0;
  list-style: none;
}
.guide-progress-step {
  position: relative;
  flex: 1;
  display: flex;
  justify-content: center;
}
.guide-progress-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 8px;
  left: calc(50% + 11px);
  right: calc(-50% + 11px);
  height: 2px;
  background: var(--panel-border-m);
  transition: background 0.3s ease;
}
.guide-progress-step.is-done:not(:last-child)::after { background: var(--green); }

.guide-progress-dot {
  width: 18px; height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  /* Étape future : contour net + fond transparent (plutôt qu'un simple
     disque teinté peu contrasté) — le numéro reste identifiable sans
     dépendre de la seule couleur. */
  background: transparent;
  border: 1.5px solid var(--panel-border-m);
  font-size: 9px;
  font-weight: 800;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
.guide-progress-step.is-done .guide-progress-dot {
  background: var(--green);
  border-color: var(--green);
  color: #04141f;
}
.guide-progress-step.is-active .guide-progress-dot {
  background: var(--cyan);
  border-color: var(--cyan);
  color: #04141f;
  box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.16);
}
[data-theme="light"] .guide-progress-step.is-active .guide-progress-dot { background: var(--blue); border-color: var(--blue); }
[data-theme="light"] .guide-progress-step.is-done .guide-progress-dot,
[data-theme="light"] .guide-progress-step.is-done:not(:last-child)::after { background: #0e8a5c; border-color: #0e8a5c; }

.guide-step-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.guide-step-title {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text-2);
  margin: 0;
  line-height: 1.3;
}
.guide-step-text {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}
/* Parcours discret "Exutoire → Délimitation → Analyse → Export" (étape 1) */
.guide-journey {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.1px;
}

/* Encadré conseil / méthode — même habillage que .coming-soon-info */
.guide-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid rgba(60, 140, 235, 0.22);
  background: rgba(30, 80, 160, 0.08);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
}
.guide-tip svg { color: #6fb6f0; flex-shrink: 0; margin-top: 2px; }

/* Légende à 3 lignes (étape 3 : point rouge / point cyan / ligne pointillée).
   Symboles volontairement autonomes (dimensions propres, jamais la classe
   partagée .legend-swatch) : sa règle "ligne" (22x4, définie plus loin dans
   ce fichier) écrasait sinon le cercle cyan par ordre de cascade à
   spécificité égale — seul le rouge s'en sortait car .swatch-outlet est
   déclarée juste après .legend-swatch. Couleurs reprises telles quelles des
   marqueurs déjà utilisés sur la carte (--map-outlet, --map-stream), même
   diamètre pour les deux cercles. */
.guide-legend { display: flex; flex-direction: column; gap: 8px; }
.guide-legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
.guide-swatch-outlet,
.guide-swatch-used {
  width: 11px; height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}
.guide-swatch-outlet { background: var(--map-outlet); }
.guide-swatch-used   { background: var(--map-stream); }
.guide-swatch-line {
  width: 26px; height: 0;
  border-top: 2px dashed var(--map-stream);
  flex-shrink: 0;
}

/* Liste d'items icône + titre + description (étape 5) — réutilise le
   gabarit visuel de .layer-item/.layer-icon/.layer-info, sans troncature
   (une description plus longue doit rester lisible en entier). */
.guide-item-list { display: flex; flex-direction: column; gap: 7px; }
.guide-item-desc {
  font-size: 10.5px;
  color: var(--text-dim);
  line-height: 1.4;
  margin-top: 2px;
}
.guide-final-message {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2);
  line-height: 1.5;
  margin: 4px 0 0;
}

/* Boutons principaux du Guide : halo sensiblement réduit par rapport au
   .btn-primary global (ex. "Délimiter le bassin") — un onboarding n'a pas
   besoin de la même intensité lumineuse qu'une action de calcul déclenchée.
   Volontairement scopé à #panel-guide : le composant global .btn-primary
   n'est pas modifié, ni les autres boutons de l'app. */
#panel-guide .btn-primary {
  box-shadow: 0 3px 10px -5px rgba(47, 122, 240, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.10);
}
#panel-guide .btn-primary:hover:not(:disabled) {
  box-shadow: 0 5px 14px -5px rgba(47, 122, 240, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

/* En-tête sticky de la vue détaillée (retour + titre/compteur + progression)
   — reste visible en haut du panneau pendant le défilement de l'étape.
   Fond opaque (--panel-bg, plus couvrant que --sidebar-bg) pour éviter toute
   superposition visible avec le texte qui défile dessous. */
.guide-steps-header {
  position: sticky;
  top: -16px;
  z-index: 2;
  margin: -16px -14px 0;
  padding: 14px 14px 10px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
}

.guide-step-content {
  /* Respiration verticale entre la bordure de l'en-tête sticky (progression)
     et le titre de l'étape — jusqu'ici absente (0), le titre touchait
     directement la bordure. */
  padding-top: 18px;
  /* Espace réservé sous le dernier contenu pour qu'il ne soit jamais masqué
     par la navigation sticky en pied de panneau (~73px de haut avec ses
     propres paddings) — marge de sécurité incluse. */
  padding-bottom: 84px;
}

.guide-nav {
  display: flex;
  gap: 8px;
  margin: 4px -14px -14px;
  padding: 10px 14px 14px;
  position: sticky;
  bottom: -14px;
  z-index: 2;
  background: var(--panel-bg);
  border-top: 1px solid var(--panel-border);
}
.guide-nav .btn { flex: 1; justify-content: center; }

/* Élargissement temporaire du panneau pendant la consultation détaillée de
   "Premiers pas" (400-440px demandés) — ne recouvre jamais la sidebar
   droite : .map-area (flex:1, min-width:0) absorbe la différence. */
.sidebar-left { transition: width 0.22s ease; }
.sidebar-left.is-guide-detail { width: 420px; }

/* -------- Cartes compactes de l'accueil (FAQ / Besoin d'aide) --------
   Plus discrètes que .guide-card (Premiers pas) : padding réduit, pas de
   bloc de texte long. */
.guide-mini-card {
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  background: var(--card-bg-2);
}

/* Carte FAQ : la carte entière EST le bouton (icône + texte + chevron). */
button.guide-mini-card {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
}
button.guide-mini-card:hover { border-color: rgba(86, 158, 214, 0.32); background: rgba(86, 158, 214, 0.08); }
button.guide-mini-card:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.20); }
[data-theme="light"] button.guide-mini-card:hover { border-color: rgba(47, 122, 240, 0.28); background: rgba(47, 122, 240, 0.06); }
[data-theme="light"] button.guide-mini-card:focus-visible { box-shadow: 0 0 0 3px rgba(47, 122, 240, 0.22); }

/* Carte "Besoin d'aide ?" : conteneur non interactif (div) contenant deux
   boutons FRÈRES — le déclencheur (icône+texte+chevron) et "Nous
   contacter" — jamais un bouton imbriqué dans un bouton, donc aucun risque
   de double activation par propagation d'événement. */
.guide-mini-card-help {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.guide-mini-card-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 2px;
  margin: -2px;
  border-radius: 8px;
  background: none;
  border: none;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s;
}
.guide-mini-card-trigger:hover { background: rgba(86, 158, 214, 0.08); }
.guide-mini-card-trigger:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.20); }
[data-theme="light"] .guide-mini-card-trigger:hover { background: rgba(47, 122, 240, 0.06); }
[data-theme="light"] .guide-mini-card-trigger:focus-visible { box-shadow: 0 0 0 3px rgba(47, 122, 240, 0.22); }

.guide-mini-card-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(51, 199, 230, 0.14);
  color: var(--cyan);
  flex-shrink: 0;
}
[data-theme="light"] .guide-mini-card-icon { background: rgba(47, 122, 240, 0.10); color: var(--blue); }

.guide-mini-card-body { flex: 1; min-width: 0; }
.guide-mini-card-title { font-size: 13px; font-weight: 800; color: var(--text-2); }
.guide-mini-card-preview { font-size: 11px; color: var(--text-dim); line-height: 1.45; margin: 2px 0 0; }
/* Métadonnée compacte propre à "Premiers pas" (5 étapes · environ 2 min) —
   justifie que cette carte reste légèrement plus haute que FAQ/Besoin
   d'aide, jamais une troisième ligne de description. */
.guide-mini-card-meta { font-size: 10.5px; font-weight: 700; color: var(--text-dim); margin: 3px 0 0; }
.guide-mini-card-chevron { color: var(--text-dim); flex-shrink: 0; }

/* -------- Vue FAQ (accordéon) -------- */
.guide-faq-item { border-bottom: 1px solid var(--panel-border); }
.guide-faq-item:last-child { border-bottom: none; }
.guide-faq-q-wrap { margin: 0; }
.guide-faq-question {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 13px 2px;
  background: none;
  border: none;
  color: var(--text-2);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  text-align: left;
  line-height: 1.4;
  cursor: pointer;
}
.guide-faq-question:hover { color: var(--cyan); }
[data-theme="light"] .guide-faq-question:hover { color: var(--blue); }
.guide-faq-question:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.20);
  border-radius: 6px;
}
.guide-faq-question svg {
  flex-shrink: 0;
  color: var(--text-dim);
  transition: transform 0.2s ease;
}
.guide-faq-question.is-open svg { transform: rotate(180deg); }
.guide-faq-question.is-open { color: var(--cyan); }
[data-theme="light"] .guide-faq-question.is-open { color: var(--blue); }

/* Réponse légèrement en retrait (repère visuel supplémentaire, pas
   uniquement la couleur/rotation du chevron). */
.guide-faq-answer {
  margin-left: 4px;
  padding: 0 2px 14px 12px;
  border-left: 2px solid var(--panel-border-m);
}
.guide-faq-answer p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

/* -------- Vue "Besoin d'aide ?" -------- */
.guide-help-info-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}
.guide-help-info-list li {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}
/* Discret, sous la liste — informe sans demander à l'utilisateur d'identifier
   un mode de données ou de délimitation (ajoutés automatiquement à la copie). */
.guide-help-auto-note {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 10px 0 0;
}
.guide-help-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}
.guide-copy-status {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--green);
  margin: 2px 0 0;
}
.guide-copy-status:empty { display: none; }
[data-theme="light"] .guide-copy-status { color: #0e8a5c; }

/* Indicateur de phase compact (Exutoire → Analyse → Résultats → Exports).
   Piloté par webapp/js/phase-indicator.js via is-active/is-done. */
.phase-indicator {
  display: flex;
  align-items: flex-start;
  margin-bottom: 16px;
}
.phase-step {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.phase-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 8px;
  left: calc(50% + 11px);
  right: calc(-50% + 11px);
  height: 2px;
  background: var(--panel-border-m);
  transition: background 0.4s ease;
}
/* Étape validée : vert doux (var(--green), déjà utilisé pour le statut moteur
   du header) — volontairement distinct du cyan/bleu de l'étape active, pour
   que "validé" et "en cours" ne se lisent jamais comme le même état. Segment
   de ligne parcouru marqué dans la même teinte. */
.phase-step.is-done:not(:last-child)::after { background: var(--green); }

/* Pastille numérotée (1-4) — le numéro est le contenu texte de l'élément,
   jamais un libellé séparé. Taille suffisante pour rester lisible tout en
   restant compacte (une petite pastille de stepper, pas un gros badge). */
.phase-dot {
  width: 18px; height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--panel-border-m);
  font-size: 9px;
  font-weight: 800;
  color: var(--text-dim);
  position: relative;
  z-index: 1;
  transition: background 0.3s ease, box-shadow 0.3s ease, color 0.3s ease;
}
/* Étape validée : pastille pleine vert doux, numéro conservé (pas remplacé
   par une coche) — l'ordre reste lisible d'un coup d'œil. Pas de halo ni
   d'animation : reste plus discrète que l'étape active, qui elle pulse et
   colore aussi son libellé — le regard doit d'abord aller à l'étape en cours. */
.phase-step.is-done .phase-dot {
  background: var(--green);
  color: #04141f;
}
.phase-step.is-active .phase-dot {
  background: var(--cyan);
  color: #04141f;
  box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.16);
  animation: phase-pulse 2.2s ease-in-out infinite;
}

.phase-label {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  text-align: center;
  transition: color 0.3s ease;
}
/* Libellé de l'étape validée : reste neutre (ni cyan ni vert) — seul le
   point change de couleur. Évite que "validé" rivalise visuellement avec
   "actif", qui lui colore aussi son libellé. */
.phase-step.is-done .phase-label { color: var(--text-muted); }
.phase-step.is-active .phase-label { color: var(--cyan); }

@keyframes phase-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.16), 0 0 8px rgba(51, 199, 230, 0.65); }
  50%      { box-shadow: 0 0 0 5px rgba(51, 199, 230, 0.08), 0 0 3px rgba(51, 199, 230, 0.35); }
}

/* Cyan brut sous 3:1 de contraste sur fond quasi-blanc — même substitution
   cyan→blue qu'ailleurs (.fscale-bar, .btn-reset-link) en thème clair. Le
   vert (var(--green)) n'est pas mieux loti (≈1.8:1 sur blanc) : variante plus
   soutenue dédiée à l'étape validée en thème clair. */
[data-theme="light"] .phase-step.is-active .phase-dot { background: var(--blue); }
[data-theme="light"] .phase-step.is-active .phase-label { color: var(--blue); }
[data-theme="light"] .phase-step.is-active .phase-dot {
  box-shadow: 0 0 0 3px rgba(47, 122, 240, 0.16);
  animation: phase-pulse-light 2.2s ease-in-out infinite;
}
[data-theme="light"] .phase-step.is-done:not(:last-child)::after,
[data-theme="light"] .phase-step.is-done .phase-dot { background: #0e8a5c; }
@keyframes phase-pulse-light {
  0%, 100% { box-shadow: 0 0 0 3px rgba(47, 122, 240, 0.16), 0 0 8px rgba(47, 122, 240, 0.5); }
  50%      { box-shadow: 0 0 0 5px rgba(47, 122, 240, 0.08), 0 0 3px rgba(47, 122, 240, 0.3); }
}

/* Délimitation panel */
.delim-mode-cards { display: flex; flex-direction: column; gap: 8px; }

.delim-mode-card {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 12px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--card-bg-2);
}
.delim-mode-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}
.delim-mode-desc {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Coord inputs */
.coord-row {
  display: flex;
  gap: 8px;
}
.coord-field { flex: 1; }
.coord-label {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.9px;
}
.coord-input {
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid var(--panel-border-m);
  background: var(--input-bg);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.coord-input:focus {
  border-color: rgba(51, 199, 230, 0.55);
  box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.10);
}
.coord-input::placeholder { color: var(--text-dim); font-weight: 400; }

/* État invalide (validation latitude/longitude) — même vocabulaire que le
   focus cyan ci-dessus, en rouge d'alerte (--red), cohérent avec l'usage
   existant de --red sur error-banner et le marqueur d'exutoire. */
.coord-input.is-invalid {
  border-color: rgba(248, 113, 113, 0.6);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.10);
}
.coord-error-msg {
  font-size: 10.5px;
  color: var(--red);
  line-height: 1.4;
  margin: -2px 0 0;
}
.coord-error-msg[hidden] { display: none; }

/* Static field */
.field-static-row { display: flex; flex-direction: column; gap: 5px; }
.field-static-val {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border-m);
  background: var(--input-bg);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

/* Lien discret "Réinitialiser le point" */
.btn-reset-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  padding: 5px 8px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  margin-top: 2px;
}
.btn-reset-link:hover { color: var(--text-muted); background: rgba(86, 158, 214, 0.07); }
.btn-reset-link:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.10);
}
.btn-reset-link:disabled { opacity: 0.42; cursor: default; pointer-events: none; }
[data-theme="light"] .btn-reset-link { color: #7a92a8; }
[data-theme="light"] .btn-reset-link:hover { color: #4a6a88; background: rgba(47, 122, 240, 0.06); }

/* ================================================================ CENTER MAP */
.map-area {
  flex: 1;
  min-width: 0;
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(86, 158, 214, 0.16);
  background: #0c1f1a;
}

#map {
  width: 100%;
  height: 100%;
  filter: saturate(1.1) contrast(1.03) brightness(0.92);
}

/* ---- Basemap control : panneau horizontal flottant à gauche ---- */
/* ---- Contrôles de carte : colonne unique en haut à droite ----
   Le zoom Leaflet (+/−) et la barre d'outils (contrôle Leaflet custom,
   cf. measure.js) partagent le même coin et EXACTEMENT la même
   spécification visuelle : conteneur, taille de bouton, rayon, survol. */
.leaflet-control-zoom.leaflet-bar,
.map-tools {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 5px;
  background: rgba(9, 20, 33, 0.88);
  border: 1px solid rgba(86, 158, 214, 0.20);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}

/* Boutons : même gabarit pour les <a> du zoom Leaflet et nos <button>. */
.leaflet-control-zoom.leaflet-bar a,
.map-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}
/* Neutralise le style natif .leaflet-bar (bordures internes, coins carrés). */
.leaflet-control-zoom.leaflet-bar a {
  line-height: 28px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  text-indent: 0;
}
.leaflet-control-zoom.leaflet-bar a:first-child,
.leaflet-control-zoom.leaflet-bar a:last-child { border-radius: 9px; }

.leaflet-control-zoom.leaflet-bar a:hover,
.map-tool-btn:hover:not(:disabled) {
  background: rgba(51, 199, 230, 0.10);
  border-color: rgba(51, 199, 230, 0.28);
  color: var(--cyan);
}
.map-tool-btn.is-active {
  background: rgba(51, 199, 230, 0.15);
  border-color: rgba(51, 199, 230, 0.40);
  color: var(--cyan);
}
.map-tool-btn:disabled,
.leaflet-control-zoom.leaflet-bar a.leaflet-disabled {
  opacity: 0.38;
  cursor: not-allowed;
  background: none;
  border-color: transparent;
}
.map-tools-sep {
  height: 1px;
  margin: 2px 4px;
  background: rgba(86, 158, 214, 0.20);
}

/* Curseur croix pendant une mesure */
#map.is-measuring { cursor: crosshair; }

/* Readout des mesures : à gauche de la colonne de contrôles */
.map-measure-readout {
  position: absolute;
  top: 12px;
  right: 60px;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 240px;
  padding: 8px 11px;
  background: rgba(9, 20, 33, 0.88);
  border: 1px solid rgba(86, 158, 214, 0.20);
  border-radius: 10px;
  backdrop-filter: blur(12px);
  font-size: 11px;
  color: var(--text-dim);
  font-feature-settings: 'tnum' 1;
}
.map-measure-readout strong { color: var(--text-2); font-size: 12px; }
.map-measure-readout[hidden] { display: none; }

/* Étiquette permanente des mesures figées */
.measure-tooltip {
  background: rgba(9, 20, 33, 0.92);
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: 8px;
  color: #fbd57c;
  font-family: 'Manrope', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  font-feature-settings: 'tnum' 1;
  padding: 3px 8px;
  box-shadow: none;
}
.measure-tooltip::before { display: none; }

[data-theme="light"] .map-tools,
[data-theme="light"] .map-measure-readout {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(47, 122, 240, 0.20);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .map-tool-btn { color: #4a6278; }
[data-theme="light"] .map-tool-btn:hover:not(:disabled),
[data-theme="light"] .map-tool-btn.is-active {
  color: var(--blue);
  background: rgba(47, 122, 240, 0.08);
  border-color: rgba(47, 122, 240, 0.28);
}
[data-theme="light"] .measure-tooltip {
  background: rgba(255, 255, 255, 0.95);
  color: #92600a;
  border-color: rgba(217, 119, 6, 0.45);
}

.basemap-control {
  position: absolute;
  left: 14px;
  bottom: 10px;
  z-index: 8;
  display: flex;
  flex-direction: row;
  gap: 3px;
  padding: 5px;
  background: rgba(9, 20, 33, 0.88);
  border: 1px solid rgba(86, 158, 214, 0.20);
  border-radius: 12px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.32);
}

/* Vignette individuelle */
.basemap-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 5px 6px 5px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, box-shadow 0.16s;
}
.basemap-thumb:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(86, 158, 214, 0.28);
}
.basemap-thumb.active {
  border-color: var(--cyan);
  background: rgba(51, 199, 230, 0.08);
  box-shadow: 0 0 0 1px rgba(51, 199, 230, 0.18), inset 0 0 0 1px rgba(51, 199, 230, 0.10);
}

/* Miniature — vraie tuile depuis le même serveur que la carte */
.basemap-swatch {
  width: 62px;
  height: 36px;
  border-radius: 5px;
  display: block;
  flex-shrink: 0;
  border: 1px solid rgba(86, 158, 214, 0.15);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
/* Tuile z=8 x=134 y=100 — Siliana / nord-ouest de la Tunisie */
.basemap-hillshade .basemap-swatch {
  background-image: url('https://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/8/100/134');
  background-color: #484848; /* fallback */
}
.basemap-satellite .basemap-swatch {
  background-image: url('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/8/100/134');
  background-color: #0b2818; /* fallback */
}
.basemap-plan .basemap-swatch {
  background-image: url('https://a.tile.openstreetmap.org/8/134/100.png');
  background-color: #cee3f5; /* fallback */
}
.basemap-terrain .basemap-swatch {
  background-image: url('https://a.tile.opentopomap.org/8/134/100.png');
  background-color: #284618; /* fallback */
}

/* Libellé */
.basemap-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-dim);
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: color 0.16s;
}
.basemap-thumb:hover .basemap-label      { color: var(--text-muted); }
.basemap-thumb.active .basemap-label     { color: var(--cyan); }

/* Mode clair */
[data-theme="light"] .basemap-control {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(47, 122, 240, 0.20);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .basemap-thumb:hover {
  background: rgba(47, 122, 240, 0.06);
  border-color: rgba(47, 122, 240, 0.28);
}
[data-theme="light"] .basemap-thumb.active {
  border-color: var(--blue);
  background: rgba(47, 122, 240, 0.08);
  box-shadow: 0 0 0 1px rgba(47, 122, 240, 0.18), inset 0 0 0 1px rgba(47, 122, 240, 0.10);
}
[data-theme="light"] .basemap-label           { color: #6a8099; }
[data-theme="light"] .basemap-thumb:hover .basemap-label  { color: var(--text); }
[data-theme="light"] .basemap-thumb.active .basemap-label { color: var(--blue); }
[data-theme="light"] .basemap-plan .basemap-swatch { border-color: rgba(47, 122, 240, 0.22); }

/* Sidebar legend (dans le panneau Délimitation) — poussée en bas du panneau
   flex (même rôle d'ancrage que l'ancienne ligne technique retirée). */
.sidebar-legend {
  margin-top: auto;
  padding: 10px 12px;
  background: rgba(9, 20, 33, 0.45);
  border: 1px solid rgba(86, 158, 214, 0.14);
  border-radius: 10px;
}
.sidebar-legend-title {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-dim);
  margin-bottom: 8px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.legend-row:last-child { margin-bottom: 0; }
.legend-swatch {
  width: 22px; height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}
.swatch-outlet      { background: var(--map-outlet); height: 10px; width: 10px; border-radius: 50%; }
/* « Exutoire ajusté » — reprend trait pour trait .outlet-used-marker-dot :
   même couleur (--map-stream), même liseré blanc, même proportion réduite
   face au point rouge sélectionné. La pastille de légende et le marqueur de
   la carte ne peuvent donc pas diverger. */
.swatch-outlet-snapped {
  background: var(--map-stream);
  height: 10px; width: 10px;
  border-radius: 50%;
  border: 1.5px solid #fff;
}
/* « Ligne d'ajustement » — reproduit le pointillé cyan de la polyline tracée
   entre les deux marqueurs (cf. showOutletSnapDiagnostic, dashArray '4 5').
   Un `border: dashed` a été écarté : sur 22 px de large, le navigateur ajuste
   lui-même la longueur des tirets et le trait devenait indiscernable du trait
   plein du réseau hydrographique juste en dessous. Le dégradé répété impose
   au contraire le motif exact 4 px pleins / 5 px vides. */
.swatch-snap-line {
  height: 2px;
  background: repeating-linear-gradient(
    to right,
    var(--map-stream) 0 4px,
    transparent 4px 9px
  );
}
.swatch-outlet-test { background: var(--map-outlet-test); height: 8px; width: 8px; border-radius: 50%; border: 1.5px solid #fff; }
.swatch-stream      { background: var(--map-stream); }
.swatch-basin       { background: var(--map-watershed); }
.swatch-admin       { background: var(--map-admin); border-top: 2px dashed var(--map-admin); background: none; }

/* Leaflet overrides */
.leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(9, 20, 33, 0.75) !important;
  color: var(--text-dim) !important;
  border-radius: 6px 0 0 0 !important;
}
.leaflet-control-attribution a { color: var(--cyan) !important; }
/* (l'ancien restyling !important des boutons zoom vivait ici — remplacé par
   la spécification harmonisée « Contrôles de carte » plus haut, qui couvre
   zoom Leaflet et outils cartographiques d'un seul tenant, deux thèmes.) */

/* Outlet marker */
.outlet-marker-icon { background: transparent; border: none; }
.outlet-marker-dot {
  display: block;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--map-outlet);
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.4), 0 3px 8px rgba(0,0,0,0.5);
  animation: outlet-pulse 2.4s ease-in-out infinite;
}
@keyframes outlet-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.4), 0 3px 8px rgba(0,0,0,0.5); }
  50%       { box-shadow: 0 0 0 7px rgba(248, 113, 113, 0.15), 0 3px 8px rgba(0,0,0,0.5); }
}

/* Marqueur "exutoire utilisé" (snapping hydrologique, mode hybride) — cf.
   docs/hybrid_delineation.md. Même famille visuelle que le marqueur rouge,
   couleur --map-stream (cyan) pour le distinguer sans ambiguïté. */
.outlet-used-marker-dot {
  display: block;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--map-stream);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.4), 0 2px 6px rgba(0,0,0,0.5);
}

/* ================================================================ RIGHT SIDEBAR */
.sidebar-right {
  display: flex;
  flex-direction: column;
  width: 340px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: 16px;
  backdrop-filter: blur(14px);
  overflow: hidden;
  transition: background 0.3s ease;
}

/* Icon tab bar */
.rtab-bar {
  display: flex;
  padding: 10px 10px 0;
  gap: 4px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}

.rtab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px 12px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  border-radius: 9px 9px 0 0;
  transition: color 0.18s;
  line-height: 1;
}
.rtab:hover { color: var(--text); }
.rtab.is-active { color: var(--text-2); }
.rtab.is-active::after {
  content: '';
  position: absolute;
  left: 12%; right: 12%;
  bottom: -1px;
  height: 2.5px;
  border-radius: 2px;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}
.rtab svg { flex-shrink: 0; }

/* Result panels */
.result-panel {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}
.result-panel[hidden] { display: none; }

/* Empty state — bandeau en haut du panneau morpho */
.panel-empty-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 15px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--card-bg-2);
  margin-bottom: 14px;
}
.panel-empty-banner[hidden] { display: none; }
.panel-empty-banner svg { opacity: 0.35; flex-shrink: 0; }
.panel-empty-banner .empty-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0 0 3px;
}
.panel-empty-banner .empty-sub {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.45;
  margin: 0;
}

/* Encart méthode (discret, non bloquant) — cf. section "Information sur la
   méthode" : réutilise les tokens de couleur existants (thème clair/sombre),
   aucune nouvelle couleur littérale. */
.method-info-note {
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-dim);
  background: var(--card-bg-2);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 11px;
  margin: 0 0 14px;
}
.method-info-note[hidden] { display: none; }
.method-info-note .method-warning {
  display: block;
  margin-top: 3px;
  color: var(--text-muted);
}

/* Snapping hydrologique de l'exutoire — variante "warning" (distance entre
   90 et 500 m) : léger accent ambre, même encart discret sinon (cf.
   #outlet-snapping-note, docs/hybrid_delineation.md). */
.method-info-note.is-warning { border-left: 3px solid var(--amber); }

/* Empty state plein-panneau (non utilisé actuellement, conservé pour usage futur) */
.panel-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}
.panel-empty-state svg { opacity: 0.35; margin-bottom: 16px; }
.empty-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0 0 8px;
}
.empty-sub {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.55;
  max-width: 240px;
  margin: 0;
}

/* Results panel head */
.results-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text-2);
  line-height: 1;
}
.panel-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 6px 0 0;
}

/* Section labels */
.section-label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
.mt-section { margin-top: 18px; margin-bottom: 10px; }

.info-tip {
  font-size: 11px;
  color: var(--text-dim);
  cursor: help;
  margin-left: 4px;
}

/* Titre de graphique (sous l'eyebrow "Graphiques") — sentence case, moins
   proéminent que .section-label, distingue les deux courbes sans surcharger
   la hiérarchie. */
.chart-title {
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.mt-chart-title { margin-top: 16px; }

/* Bouton "agrandir" en haut à droite du bloc Courbe hypsométrique */
.chart-expand-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: auto;
  padding: 0;
  border-radius: 7px;
  border: 1px solid var(--panel-border-m);
  background: var(--card-bg-2);
  color: var(--cyan);
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s, opacity 0.18s;
}
.chart-expand-btn:hover:not(:disabled) {
  border-color: rgba(51, 199, 230, 0.5);
  box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.12);
}
.chart-expand-btn:focus-visible {
  outline: none;
  border-color: rgba(51, 199, 230, 0.55);
  box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.10);
}
.chart-expand-btn:disabled { opacity: 0.42; cursor: not-allowed; }
/* Cyan brut sous 3:1 de contraste sur fond quasi-blanc — même substitution
   cyan→blue qu'ailleurs (.fscale-bar, .btn-icon-sq) en thème clair. */
[data-theme="light"] .chart-expand-btn { color: var(--blue); }
[data-theme="light"] .chart-expand-btn:hover:not(:disabled) {
  border-color: rgba(47, 122, 240, 0.5);
  box-shadow: 0 0 0 3px rgba(47, 122, 240, 0.12);
}
/* Dans .climate-head-actions, l'alignement à droite vient déjà du conteneur
   (justify-content: flex-end) — pas besoin (et pas souhaitable, ça créerait
   un espacement irrégulier) que chaque bouton pousse aussi avec margin-left: auto. */
.climate-head-actions .chart-expand-btn { margin-left: 0; }

/* ================================================================ MODALE COURBE HYPSOMÉTRIQUE */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 11, 19, 0.72);
  backdrop-filter: blur(6px);
  animation: modal-fade-in 0.18s ease-out;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 760px;
  max-height: min(88vh, 820px);
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border-m);
  border-radius: 16px;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  animation: modal-scale-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal:focus-visible { outline: none; }

@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-scale-in {
  from { opacity: 0; transform: scale(0.97) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal { animation: none; }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}
.modal-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-2);
}
.modal-subtitle {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 3px;
}
.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.modal-hi-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(51, 199, 230, 0.14);
  border: 1px solid rgba(51, 199, 230, 0.30);
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  white-space: nowrap;
}
.modal-hi-badge[hidden] { display: none; }

/* Badge générique d'en-tête de modale (même style que .modal-hi-badge, nom
   neutre pour un usage hors hypsométrie — ex. année du diagramme climatique). */
.modal-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(51, 199, 230, 0.14);
  border: 1px solid rgba(51, 199, 230, 0.30);
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan);
  white-space: nowrap;
}
[data-theme="light"] .modal-badge { color: var(--blue); border-color: rgba(47, 122, 240, 0.30); background: rgba(47, 122, 240, 0.10); }

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 9px;
  border: 1px solid var(--panel-border-m);
  background: var(--card-bg-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, color 0.18s;
}
.modal-close:hover {
  color: var(--text-2);
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.08);
}
.modal-close:focus-visible {
  outline: none;
  border-color: rgba(51, 199, 230, 0.55);
  box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.10);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-chart-wrap { height: 320px; margin-bottom: 4px; }

.modal-table-scroll {
  max-height: 220px;
  overflow-y: auto;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
}
/* Seule table restante dans la popup (plus de "Table des données" au-dessus) :
   plus de hauteur disponible, meilleure lisibilité pour les classes d'altitude. */
.modal-table-scroll-tall { max-height: 320px; }
.modal-table-scroll table { width: 100%; }
.modal-table-scroll thead th {
  position: sticky;
  top: 0;
  background: var(--sidebar-bg);
}

/* Repères H5/H50/H95 dans la table des classes : ligne discrètement teintée,
   badge cyan compact dans la colonne "Repère". */
.modal-table-scroll tr.is-marked-row { background: rgba(51, 199, 230, 0.06); }
.modal-hyp-marker-cell {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--cyan);
  white-space: nowrap;
}

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--panel-border);
  flex-shrink: 0;
}
.modal-footer .btn { flex: 1; justify-content: center; }

@media (max-width: 640px) {
  .modal-footer { flex-direction: column; }
}

/* Badges */
.badge-done {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(55, 216, 150, 0.14);
  border: 1px solid rgba(55, 216, 150, 0.30);
  font-size: 11px;
  font-weight: 700;
  color: #7ee9b8;
}
.badge-done[hidden] { display: none; }

.badge-soon-sm {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(60, 140, 235, 0.14);
  border: 1px solid rgba(60, 140, 235, 0.28);
  font-size: 10px;
  font-weight: 700;
  color: #6fb6f0;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-soon-lg {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 10px;
  background: rgba(60, 140, 235, 0.14);
  border: 1px solid rgba(60, 140, 235, 0.30);
  font-size: 12.5px;
  font-weight: 700;
  color: #6fb6f0;
}

/* ================================================================ MORPHOLOGIE */

/* 4 résumé cards */
.morpho-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}

.morpho-card {
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--card-bg-2);
  padding: 13px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.morpho-card svg { opacity: 0.9; }
.morpho-card-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}
.morpho-card-value {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-2);
  line-height: 1.1;
}
.kpi-unit {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
}

/* Indices grid */
.indices-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}

.index-card {
  border-radius: 11px;
  border: 1px solid var(--panel-border);
  background: var(--card-bg-2);
  padding: 11px 10px;
}
.index-label {
  font-size: 10px;
  color: var(--text-muted);
  line-height: 1.3;
  margin-bottom: 7px;
}
.index-value {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-2);
}
.value-pending { color: var(--text-dim) !important; font-weight: 500 !important; font-size: 12px !important; }

/* Terrain stats row */
.terrain-stats-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.terrain-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--card-bg-2);
}
.terrain-stat-label { font-size: 10px; color: var(--text-dim); font-weight: 600; }
.terrain-stat-value { font-size: 13px; font-weight: 800; color: var(--text-2); }

/* Chart wraps */
.chart-wrap {
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(8, 17, 28, 0.45);
  padding: 10px;
  margin-bottom: 4px;
  overflow: hidden;
}
.chart-wrap canvas { display: block; width: 100% !important; }
.chart-empty {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(8, 17, 28, 0.45);
  line-height: 1.5;
}
.chart-wrap.is-empty .chart-empty { display: flex; }
.chart-wrap.is-empty canvas { opacity: 0.15; }

/* ================================================================ STATISTIQUES */

/* Thematic layout: chart centré + table pleine largeur */
.landcover-layout {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.landcover-layout .chart-wrap {
  width: 130px;
  height: 130px;
  align-self: center;
  flex: none;
  margin-bottom: 0;
}
.landcover-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5px;
}
.landcover-table thead tr {
  border-bottom: 1px solid var(--panel-border-m);
}
.landcover-table th {
  padding: 3px 4px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.landcover-table th.lc-th-num { text-align: right; }
.landcover-table tr {
  border-bottom: 1px solid var(--panel-border);
}
.landcover-table td {
  padding: 4px 4px;
  color: var(--text-muted);
  vertical-align: middle;
}
.landcover-table .landcover-pct {
  text-align: right;
  font-weight: 700;
  color: var(--text-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.lc-code {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 10px;
  padding-right: 6px !important;
}
.landcover-swatch {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: middle;
  flex-shrink: 0;
}
.chart-source {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  line-height: 1.4;
}

/* ================================================================ ONGLETS THÉMATIQUES */
/* Grille de pills (3 colonnes, 2 lignes pour 5 onglets) — remplace l'ancienne
   ligne flex unique où 5 boutons flex:1 se compressaient jusqu'à tronquer
   leurs libellés ("Occup...", "Bioclim...", etc.). Chaque libellé est un mot
   court et complet (Climat, Occupation, Pédologie, Géologie, Bioclimat) :
   plus besoin d'ellipse. */
.theme-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.ttab {
  padding: 7px 4px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--card-bg-2);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  line-height: 1.3;
}
.ttab:hover {
  color: var(--text);
  border-color: var(--cyan);
}
.ttab.is-active {
  background: color-mix(in srgb, var(--cyan) 15%, transparent);
  border-color: var(--cyan);
  color: var(--cyan);
}
[data-theme="light"] .ttab.is-active { color: var(--blue); border-color: var(--blue); }

.theme-panel { margin-top: 12px; }
.theme-panel[hidden] { display: none; }
/* Titre clair au-dessus du graphique/tableau (Occupation du sol, Pédologie,
   Géologie, Bioclimatique) — reprend le nom complet, les onglets eux-mêmes
   restant courts pour tenir dans la grille. */
.theme-panel > .section-label { margin-bottom: 8px; }

/* Onglet Climat — en-tête (titre + sélecteur d'année) et grille de
   métadonnées (réutilise les classes rmeta-* du bloc Détails techniques). */
/* Titre/sous-titre en pleine largeur, actions (année + agrandir/PNG/CSV) sur
   leur propre ligne alignée à droite juste en dessous — évite de comprimer
   le titre "Diagramme climatique" contre les boutons dans la sidebar étroite. */
.climate-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.climate-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.climate-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-2);
}
.climate-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.climate-year-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-dim);
}
.climate-year-label[hidden] { display: none; }
/* Même vocabulaire que .coord-input (fond input, hairline, focus cyan). */
.climate-year-select {
  height: 28px;
  padding: 0 6px;
  border-radius: 9px;
  border: 1px solid var(--panel-border-m);
  background: var(--input-bg);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  font-feature-settings: 'tnum' 1;
  cursor: pointer;
}
.climate-year-select:focus {
  outline: none;
  border-color: rgba(51, 199, 230, 0.55);
  box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.10);
}
.climate-meta { margin-top: 12px; }
.climate-meta[hidden] { display: none; }
.climate-note {
  margin: 8px 0 0;
  font-size: 10.5px;
  color: var(--text-dim);
  line-height: 1.5;
}
.climate-note[hidden] { display: none; }

/* ================================================================ RAPPORT */
/* Panneau volontairement court : titre, description, deux actions, historique.
   Les métadonnées vivent repliées dans .tech-details en bas de panneau. */
.report-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}
.report-meta-item { display: flex; flex-direction: column; gap: 3px; }
.rmeta-label  { font-size: 10.5px; color: var(--text-dim); font-weight: 600; }
.rmeta-value  { font-size: 12px;   color: var(--text-2);   font-weight: 700; }

.report-actions { margin-top: 10px; }

/* Accordéon "Détails techniques" — délibérément discret : pas de carte,
   juste un disclosure natif en fin de panneau. */
.tech-details {
  margin-top: 14px;
  border-top: 1px solid var(--panel-border);
  padding-top: 10px;
}
.tech-details summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  user-select: none;
}
.tech-details summary::-webkit-details-marker { display: none; }
.tech-details summary::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 4px solid currentColor;
  border-top: 3.5px solid transparent;
  border-bottom: 3.5px solid transparent;
  transition: transform 0.15s ease-out;
}
.tech-details[open] summary::before { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) {
  .tech-details summary::before { transition: none; }
}
.tech-details summary:hover { color: var(--text-muted); }
.tech-details .report-meta-grid { margin-top: 10px; }
.tech-details-note {
  margin: 10px 0 0;
  font-size: 10.5px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ================================================================ AUTH MVP */
/* .btn force display:inline-flex, qui l'emporte sur le [hidden] du navigateur
   — règle explicite nécessaire, même motif que .save-badge[hidden] etc. */
#btn-auth-login[hidden] { display: none; }

/* Bloc utilisateur unique : initiales + nom + chevron, menu déroulant
   (Déconnexion). #auth-user-chip porte la visibilité globale (piloté par
   refreshAuthUI) et sert d'ancre de positionnement pour le menu. */
.auth-user-chip { position: relative; }
.auth-user-chip[hidden] { display: none; }

.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--panel-border-m);
  background: var(--card-bg-2);
  color: inherit;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.user-menu-trigger:hover {
  border-color: rgba(51, 199, 230, 0.5);
  box-shadow: 0 0 0 3px rgba(51, 199, 230, 0.12);
}

.user-avatar-sm {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--blue), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #04141f;
  flex-shrink: 0;
}

.auth-user-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron-icon {
  color: var(--text-dim);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.user-menu-trigger[aria-expanded="true"] .chevron-icon { transform: rotate(180deg); }

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border-m);
  border-radius: 10px;
  box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.35);
  z-index: 30;
}
.user-menu-dropdown[hidden] { display: none; }

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: none;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.user-menu-item:hover { background: var(--card-bg-2); color: var(--cyan); }
[data-theme="light"] .user-menu-item:hover { color: var(--blue); }

.modal-auth { max-width: 400px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-field { display: flex; flex-direction: column; gap: 5px; }
.auth-field[hidden] { display: none; }
.auth-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}
.auth-optional { font-weight: 400; color: var(--text-dim); }
.auth-input { width: 100%; }
.auth-error {
  font-size: 11.5px;
  line-height: 1.5;
  margin: 0;
  color: var(--red);
}
.auth-error[hidden] { display: none; }
.auth-success {
  font-size: 11.5px;
  line-height: 1.5;
  margin: 0;
  color: var(--green);
}
.auth-success[hidden] { display: none; }
/* Lien "Mot de passe oublié ?" — même vocabulaire que .auth-switch-btn,
   aligné à droite sous le champ mot de passe. */
.auth-forgot-link {
  align-self: flex-end;
  background: none;
  border: none;
  padding: 0;
  margin-top: -6px;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
}
.auth-forgot-link:hover { color: var(--cyan); }
.auth-forgot-link[hidden] { display: none; }
.auth-switch {
  font-size: 11.5px;
  color: var(--text-dim);
  margin: 2px 0 0;
  text-align: center;
}
.auth-switch-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--cyan);
  cursor: pointer;
  text-decoration: underline;
}

/* Modale métadonnées (sauvegarde / renommage) */
.meta-textarea {
  resize: vertical;
  min-height: 64px;
  font-family: inherit;
  line-height: 1.5;
}

/* Mes analyses sauvegardées (onglet Rapport) */
.saved-analyses { display: flex; flex-direction: column; gap: 10px; }
.saved-analyses-toolbar { display: flex; justify-content: flex-end; }
.saved-analyses-state,
.saved-analyses-message {
  font-size: 11px;
  line-height: 1.5;
  margin: 0;
  color: var(--text-dim);
}
.saved-analyses-message.is-ok    { color: var(--green); }
.saved-analyses-message.is-error { color: var(--red); }
.saved-analyses-state[hidden],
.saved-analyses-message[hidden] { display: none; }
.saved-analyses-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* Carte compacte : titre + date, 2 blocs métriques, exutoire + action
   principale. Actions secondaires (Renommer/Supprimer) dans un menu ⋯. */
.saved-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--panel-border);
  background: var(--card-bg-2);
}
/* Analyse actuellement ouverte : état actif → vocabulaire cyan existant
   (bordure accent + teinte de fond légère), cf. .layer-item.is-active. */
.saved-item.is-current {
  border-color: rgba(51, 199, 230, 0.35);
  background: rgba(51, 199, 230, 0.06);
}

.saved-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.saved-item-id { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.saved-item-title {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.saved-item-date {
  font-size: 10.5px;
  color: var(--text-dim);
  font-feature-settings: 'tnum' 1;
}
.saved-item-desc {
  font-size: 10.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Menu ⋯ (actions secondaires) */
.saved-menu-wrap { position: relative; flex-shrink: 0; }
.saved-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 6px; /* {rounded.xs} */
  border: 1px solid transparent;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
}
.saved-menu-btn:hover,
.saved-menu-btn[aria-expanded="true"] {
  background: var(--card-bg);
  border-color: var(--panel-border);
  color: var(--text-2);
}
.saved-menu {
  position: absolute;
  top: 30px;
  right: 0;
  z-index: 30; /* au-dessus des cartes voisines, sous les modales (100) */
  display: flex;
  flex-direction: column;
  min-width: 136px;
  padding: 4px;
  border-radius: 9px;
  border: 1px solid var(--panel-border-m);
  background: var(--panel-bg);
}
.saved-menu[hidden] { display: none; }
.saved-menu button {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  background: none;
  text-align: left;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.saved-menu button:hover { background: var(--card-bg); }
.saved-menu .saved-delete { color: var(--red); }

/* Blocs métriques : même grammaire que les morpho-cards (label 9.5px
   uppercase + valeur bold tabulaire), valeur insécable avec son unité. */
.saved-item-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.saved-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 9px;
  border-radius: 9px;
  border: 1px solid var(--panel-border);
  background: var(--card-bg);
  min-width: 0;
}
.saved-stat-label {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--text-dim);
}
.saved-stat-value {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-2);
  font-feature-settings: 'tnum' 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.saved-item-outlet {
  flex: 1;
  min-width: 0;
  font-size: 10.5px;
  color: var(--text-dim);
  font-feature-settings: 'tnum' 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-open {
  flex-shrink: 0;
  height: 30px;
  padding: 0 12px;
  font-size: 11.5px;
  font-weight: 700;
}

/* Sauvegarde en base (bouton + badge d'état + message de retour) */
.btn-save { margin-top: 8px; }
.save-badge {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(109, 142, 166, 0.14);
  border: 1px solid rgba(109, 142, 166, 0.30);
  color: var(--text-muted);
}
.save-badge.is-saved {
  background: rgba(55, 216, 150, 0.14);
  border-color: rgba(55, 216, 150, 0.30);
  color: var(--green);
}
.save-badge[hidden] { display: none; }
.save-status {
  font-size: 11px;
  line-height: 1.5;
  margin: 8px 0 0;
  color: var(--text-muted);
}
.save-status.is-ok    { color: var(--green); }
.save-status.is-error { color: var(--red); }
.save-status[hidden]  { display: none; }

/* ================================================================ CARTES */
.coming-soon-card {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.coming-soon-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}
.coming-soon-item { display: flex; flex-direction: column; gap: 7px; }
.csi-preview {
  height: 110px;
  border-radius: 11px;
  border: 1px solid var(--panel-border);
  display: flex; align-items: center; justify-content: center;
}
.csi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.coming-soon-info {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 15px;
  border-radius: 11px;
  border: 1px solid rgba(60, 140, 235, 0.22);
  background: rgba(30, 80, 160, 0.08);
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
}
.coming-soon-info svg { color: #6fb6f0; flex-shrink: 0; margin-top: 2px; }

/* ================================================================ FOOTER */
.app-footer {
  height: 38px;
  flex: 0 0 38px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 22px;
  background: var(--panel-bg);
  border-top: 1px solid var(--panel-border);
  font-size: 11px;
  color: var(--text-dim);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}
.footer-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.footer-item strong { color: var(--text-muted); font-weight: 600; }
.footer-brand { font-weight: 600; }
.footer-flag { font-size: 13px; margin-left: 4px; }

/* Échelle graphique dans le footer */
.footer-scale-item { gap: 5px; }
.fscale-bar {
  display: inline-block;
  width: 60px;           /* valeur initiale, mise à jour via JS */
  height: 6px;
  border: 1.5px solid var(--cyan);
  border-top: none;      /* forme ⊔ : tirets verticaux + ligne basse */
  min-width: 16px;
  max-width: 120px;
  transition: width 0.18s ease;
  vertical-align: middle;
  flex-shrink: 0;
}
[data-theme="light"] .fscale-bar { border-color: var(--blue); }

/* Position du curseur dans le footer */
#footer-cursor-coords { font-variant-numeric: tabular-nums; display: inline-block; min-width: 190px; }

/* ================================================================ STEPPER (caché, compat workflow.js) */
.step, .step-dot, .step-label,
.stepper { display: none !important; }

/* ================================================================ RESPONSIVE */
@media (max-width: 1400px) {
  .title-sub { display: none; }
  .sidebar-left { width: 272px; }
  .sidebar-right { width: 312px; }
  .morpho-summary-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1160px) {
  .sidebar-left  { width: 260px; }
  .sidebar-right { width: 290px; }
  .indices-grid  { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 960px) {
  .app-footer { display: none; }
  .sidebar-left, .sidebar-right { display: none; }
}
