/* =============================================================================
   CB-CIS — Congo Basin Catchments Information System
   Main Stylesheet
   Version: 1.0.0 — 2026-11-20
   Author: CRREBaC / CB-CIS Team
   ============================================================================= */

/* ---------------------------------------------------------------------------
   CSS Custom Properties — Hydrology Palette
   --------------------------------------------------------------------------- */
:root {
  /* Blues */
  --color-water-deep:    #0d3b6e;
  --color-water-mid:     #1565c0;
  --color-water-light:   #42a5f5;
  --color-water-pale:    #bbdefb;

  /* Greens */
  --color-forest-dark:   #1b5e20;
  --color-forest-mid:    #2e7d32;
  --color-forest-light:  #66bb6a;
  --color-forest-pale:   #c8e6c9;

  /* Earth tones */
  --color-earth-dark:    #3e2723;
  --color-earth-mid:     #5d4037;
  --color-earth-light:   #a1887f;
  --color-earth-pale:    #efebe9;

  /* Neutrals */
  --color-bg:            #f4f6f8;
  --color-surface:       #ffffff;
  --color-surface-alt:   #f0f4f8;
  --color-border:        #cdd8e3;
  --color-border-light:  #e3ecf3;
  --color-text-primary:  #1a2733;
  --color-text-secondary:#4a6070;
  --color-text-muted:    #8fa6b8;

  /* Accent */
  --color-accent:        #0077b6;
  --color-accent-hover:  #005f8e;
  --color-accent-light:  #e3f2fd;

  /* Semantic */
  --color-success:       #2e7d32;
  --color-warning:       #f57f17;
  --color-danger:        #c62828;
  --color-info:          #01579b;

  /* Layout */
  --header-height:       56px;
  --panel-left-width:    300px;
  --panel-right-width:   340px;
  --panel-collapsed-width: 42px;
  --border-radius-sm:    4px;
  --border-radius-md:    8px;
  --border-radius-lg:    12px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.15), 0 2px 4px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.18), 0 4px 8px rgba(0,0,0,0.10);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-mid:  250ms ease;
  --transition-slow: 400ms ease;

  /* Typography */
  --font-sans: 'Roboto', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Roboto Mono', 'Consolas', monospace;
  --font-size-xs:   0.75rem;
  --font-size-sm:   0.875rem;
  --font-size-base: 1rem;
  --font-size-md:   1.0625rem;
  --font-size-lg:   1.25rem;
  --font-size-xl:   1.5rem;
  --font-size-2xl:  2rem;
}

/* ---------------------------------------------------------------------------
   Reset & Base
   --------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

button {
  cursor: pointer;
  font-family: var(--font-sans);
  border: none;
  outline: none;
  transition: all var(--transition-fast);
}

input, select, textarea {
  font-family: var(--font-sans);
  outline: none;
}

/* ---------------------------------------------------------------------------
   App Shell
   --------------------------------------------------------------------------- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------------------------------------------------------------------------
   Header
   --------------------------------------------------------------------------- */
#app-header {
  height: var(--header-height);
  min-height: var(--header-height);
  background: linear-gradient(135deg, var(--color-water-deep) 0%, var(--color-forest-dark) 100%);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 1rem;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.header-logo {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.header-title {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.header-title .acronym {
  font-size: var(--font-size-lg);
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #fff;
}

.header-title .full-name {
  font-size: var(--font-size-xs);
  font-weight: 400;
  color: rgba(255,255,255,0.80);
  letter-spacing: 0.02em;
}

.header-divider {
  width: 1px;
  height: 32px;
  background: rgba(255,255,255,0.25);
  flex-shrink: 0;
}

.header-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.header-search input {
  width: 100%;
  height: 36px;
  padding: 0 2.5rem 0 2.5rem;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 18px;
  color: white;
  font-size: var(--font-size-sm);
  transition: all var(--transition-mid);
}

.header-search input::placeholder {
  color: rgba(255,255,255,0.60);
}

.header-search input:focus {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.50);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.12);
}

.header-search .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,0.65);
  font-size: 1rem;
  pointer-events: none;
}

.header-search .search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  color: rgba(255,255,255,0.65);
  font-size: 0.85rem;
  padding: 0.25rem;
  border-radius: 50%;
  display: none;
}

.header-search .search-clear:hover {
  background: rgba(255,255,255,0.15);
  color: white;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: white;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  z-index: 2000;
  display: none;
}

.search-results-dropdown.visible {
  display: block;
}

.search-result-item {
  padding: 0.6rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border-light);
  transition: background var(--transition-fast);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--color-accent-light);
}

.search-result-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-primary);
}

.search-result-meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 1px;
}

.search-no-results {
  padding: 1rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
  flex-shrink: 0;
}

.stat-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.20);
  border-radius: var(--border-radius-md);
  padding: 0.3rem 0.75rem;
}

.stat-value {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: white;
  line-height: 1;
}

.stat-label {
  font-size: 0.65rem;
  font-weight: 400;
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.9rem;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--border-radius-md);
  color: white;
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.btn-header:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.40);
}

.btn-header .icon {
  font-size: 1rem;
}

/* ---------------------------------------------------------------------------
   Main Content
   --------------------------------------------------------------------------- */
#app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ---------------------------------------------------------------------------
   Map Container
   --------------------------------------------------------------------------- */
#map {
  flex: 1;
  height: 100%;
  z-index: 1;
}

/* ---------------------------------------------------------------------------
   Left Panel — Layer Control
   --------------------------------------------------------------------------- */
#panel-left {
  width: var(--panel-left-width);
  height: 100%;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 100;
  transition: width var(--transition-mid);
  overflow: hidden;
}

#panel-left.collapsed {
  width: var(--panel-collapsed-width);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: linear-gradient(135deg, var(--color-water-deep), var(--color-water-mid));
  color: white;
  flex-shrink: 0;
}

.panel-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.panel-toggle-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 26px;
  height: 26px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.panel-toggle-btn:hover {
  background: rgba(255,255,255,0.28);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.panel-content::-webkit-scrollbar {
  width: 5px;
}

.panel-content::-webkit-scrollbar-track {
  background: var(--color-bg);
}

.panel-content::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

/* Section headers inside panels */
.section-header {
  padding: 0.65rem 1rem;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border-light);
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------------------------------------------------------------------------
   Basemap Selector
   --------------------------------------------------------------------------- */
.basemap-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.75rem;
}

.basemap-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem;
  border: 2px solid var(--color-border);
  border-radius: var(--border-radius-md);
  background: var(--color-surface);
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.basemap-btn .basemap-thumb {
  width: 100%;
  height: 36px;
  border-radius: var(--border-radius-sm);
  object-fit: cover;
  background: var(--color-bg);
}

.basemap-thumb-osm {
  background: linear-gradient(135deg, #e8f5e9 0%, #bbdefb 50%, #c8e6c9 100%);
}

.basemap-thumb-satellite {
  background: linear-gradient(135deg, #1b2838 0%, #2d5a27 40%, #1a3a1a 100%);
}

.basemap-thumb-topo {
  background: linear-gradient(135deg, #f5deb3 0%, #c8a96e 50%, #8b7355 100%);
}

.basemap-thumb-relief {
  background: linear-gradient(135deg, #d7ccc8 0%, #a1887f 50%, #5d4037 100%);
}

.basemap-thumb-dark {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.basemap-btn:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.basemap-btn.active {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
  color: var(--color-accent);
  font-weight: 700;
}

/* ---------------------------------------------------------------------------
   Layer Toggles
   --------------------------------------------------------------------------- */
.layer-item {
  display: flex;
  flex-direction: column;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--color-border-light);
  gap: 0.5rem;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.layer-toggle {
  position: relative;
  flex-shrink: 0;
}

.layer-toggle input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  display: block;
  width: 36px;
  height: 20px;
  background: var(--color-border);
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--transition-mid);
  position: relative;
}

.toggle-track::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: left var(--transition-mid);
}

.layer-toggle input:checked + .toggle-track {
  background: var(--color-accent);
}

.layer-toggle input:checked + .toggle-track::after {
  left: 18px;
}

.layer-swatch {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.layer-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-primary);
  flex: 1;
}

.layer-status {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.layer-status.loading { color: var(--color-info); }
.layer-status.loaded  { color: var(--color-success); }
.layer-status.error   { color: var(--color-danger); }

.opacity-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-left: 42px;
}

.opacity-row label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  min-width: 55px;
}

.opacity-slider {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: linear-gradient(to right, var(--color-accent) 0%, var(--color-border) 0%);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.opacity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  border: 2px solid white;
}

.opacity-value {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  min-width: 30px;
  text-align: right;
}

/* ---------------------------------------------------------------------------
   Legend
   --------------------------------------------------------------------------- */
.legend-section {
  padding: 0.75rem 1rem;
}

.legend-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
}

.legend-gradient {
  height: 16px;
  border-radius: var(--border-radius-sm);
  background: linear-gradient(to right,
    #084594, #2171b5, #4292c6, #6baed6, #9ecae1, #c6dbef,
    #deebf7, #fee090, #fc8d59, #d7301f);
  margin-bottom: 0.4rem;
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--color-text-muted);
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.legend-color {
  width: 20px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.12);
}

/* ---------------------------------------------------------------------------
   Right Panel — Feature Info
   --------------------------------------------------------------------------- */
#panel-right {
  width: var(--panel-right-width);
  height: 100%;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: calc(-1 * var(--shadow-sm));
  z-index: 100;
  transition: width var(--transition-mid);
  overflow: hidden;
}

#panel-right.collapsed {
  width: var(--panel-collapsed-width);
}

#panel-right .panel-header {
  background: linear-gradient(135deg, var(--color-forest-dark), var(--color-forest-mid));
}

/* Info placeholder */
.info-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--color-text-muted);
  flex: 1;
}

.info-placeholder .placeholder-icon {
  font-size: 3rem;
  opacity: 0.4;
}

.info-placeholder p {
  font-size: var(--font-size-sm);
  line-height: 1.6;
}

/* Feature detail card */
.feature-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.feature-card-header {
  padding: 1rem;
  background: linear-gradient(135deg, var(--color-forest-pale), var(--color-water-pale));
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.feature-card-name {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--color-water-deep);
  margin-bottom: 0.3rem;
}

.feature-card-meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.meta-chip {
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0.15rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.feature-card-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}

.feature-card-body::-webkit-scrollbar {
  width: 5px;
}

.feature-card-body::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.prop-group {
  margin-bottom: 0.25rem;
}

.prop-group-title {
  padding: 0.4rem 1rem;
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-water-mid);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--color-accent-light);
  border-top: 1px solid var(--color-border-light);
  border-bottom: 1px solid var(--color-border-light);
}

.prop-row {
  display: flex;
  padding: 0.4rem 1rem;
  border-bottom: 1px solid var(--color-border-light);
  align-items: flex-start;
  gap: 0.5rem;
}

.prop-row:last-child {
  border-bottom: none;
}

.prop-key {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
  min-width: 110px;
  flex-shrink: 0;
}

.prop-val {
  font-size: var(--font-size-xs);
  color: var(--color-text-primary);
  font-family: var(--font-mono);
  flex: 1;
  word-break: break-all;
}

.prop-val.highlight {
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-water-deep);
}

/* Sparkline bars for numeric indicators */
.bar-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
}

.bar-track {
  flex: 1;
  height: 6px;
  background: var(--color-border-light);
  border-radius: 3px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(to right, var(--color-water-mid), var(--color-water-light));
  border-radius: 3px;
  transition: width var(--transition-mid);
}

.bar-fill.green {
  background: linear-gradient(to right, var(--color-forest-mid), var(--color-forest-light));
}

.bar-fill.earth {
  background: linear-gradient(to right, var(--color-earth-mid), var(--color-earth-light));
}

.bar-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-primary);
  font-family: var(--font-mono);
  min-width: 55px;
  text-align: right;
}

/* Close button for feature card */
.btn-close-card {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.75rem 1rem;
  padding: 0.5rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
  font-weight: 600;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-close-card:hover {
  background: var(--color-border-light);
  color: var(--color-text-primary);
}

/* ---------------------------------------------------------------------------
   Loading Overlay
   --------------------------------------------------------------------------- */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 59, 110, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 1.5rem;
  transition: opacity var(--transition-slow);
}

#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-logo {
  font-size: 4rem;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

.loading-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: white;
  letter-spacing: 0.08em;
}

.loading-subtitle {
  font-size: var(--font-size-sm);
  color: rgba(255,255,255,0.65);
  letter-spacing: 0.04em;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255,255,255,0.25);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-status {
  font-size: var(--font-size-xs);
  color: rgba(255,255,255,0.55);
  min-height: 1.2em;
  text-align: center;
  letter-spacing: 0.03em;
}

/* ---------------------------------------------------------------------------
   Notifications
   --------------------------------------------------------------------------- */
#notifications {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  z-index: 5000;
  pointer-events: none;
  min-width: 280px;
  max-width: 480px;
}

.notification {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: white;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  animation: notif-in var(--transition-mid) ease;
  pointer-events: all;
  border-left: 4px solid var(--color-info);
}

.notification.success { border-left-color: var(--color-success); }
.notification.warning { border-left-color: var(--color-warning); }
.notification.error   { border-left-color: var(--color-danger); }

.notification-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

@keyframes notif-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------------------------
   Leaflet Overrides
   --------------------------------------------------------------------------- */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: var(--shadow-md) !important;
  border-radius: var(--border-radius-md) !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  color: var(--color-water-deep) !important;
  background: white !important;
  border: none !important;
  font-weight: 700 !important;
  transition: all var(--transition-fast) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--color-accent-light) !important;
  color: var(--color-accent) !important;
}

.leaflet-control-attribution {
  font-size: 0.65rem !important;
  background: rgba(255,255,255,0.80) !important;
  backdrop-filter: blur(4px);
}

.leaflet-popup-content-wrapper {
  border-radius: var(--border-radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0 !important;
  min-width: 200px;
}

.map-popup {
  padding: 0.75rem 1rem;
}

.map-popup h4 {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-water-deep);
  margin-bottom: 0.4rem;
}

.map-popup p {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.map-popup .popup-action {
  margin-top: 0.5rem;
  font-size: var(--font-size-xs);
  color: var(--color-accent);
  cursor: pointer;
  font-weight: 600;
}

.map-popup .popup-action:hover {
  text-decoration: underline;
}

/* Scale bar */
.leaflet-control-scale-line {
  border: 2px solid var(--color-water-deep) !important;
  border-top: none !important;
  color: var(--color-water-deep) !important;
  font-size: 0.65rem !important;
  background: rgba(255,255,255,0.75) !important;
  backdrop-filter: blur(4px);
}

/* ---------------------------------------------------------------------------
   Map Coordinate Display
   --------------------------------------------------------------------------- */
#map-coords {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(4px);
  border-radius: 10px;
  padding: 0.2rem 0.75rem;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
  z-index: 500;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
}

/* Bouton Mode Éco */
#btn-data-saver.active {
  background: var(--color-success);
  border-color: #059669;
  color: white;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

/* ---------------------------------------------------------------------------
   Poignée Mobile Bottom-Sheet (Panel Right)
   --------------------------------------------------------------------------- */
.bottom-sheet-handle {
  display: none;
  width: 44px;
  height: 5px;
  background: var(--color-border);
  border-radius: 3px;
  margin: 10px auto 4px auto;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.bottom-sheet-handle:hover {
  background: var(--color-text-muted);
}

/* ---------------------------------------------------------------------------
   Responsive & Multi-Appareils (Desktop, Tablette, Mobile)
   --------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  :root {
    --panel-left-width: 260px;
    --panel-right-width: 320px;
  }

  .header-stats {
    display: none;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 52px;
  }

  .mobile-toggle-btn {
    display: flex !important;
  }

  /* Panneau Gauche (Couches) : Volet Glissant latéral */
  #panel-left {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    height: 100%;
    z-index: 400;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform var(--transition-mid);
  }

  #panel-left.mobile-visible {
    transform: translateX(0);
  }

  /* Panneau Droit (Fiche Bassin) : Bottom-Sheet Mobile */
  #panel-right {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-height: 48vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
    z-index: 500;
    transform: translateY(105%);
    transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1), max-height 0.3s ease;
    border-top: 1px solid var(--color-border);
    border-left: none;
  }

  #panel-right.active {
    transform: translateY(0);
  }

  #panel-right.expanded {
    max-height: 78vh;
  }

  .bottom-sheet-handle {
    display: block;
  }

  .header-search {
    max-width: 220px;
    flex: 1;
  }

  .header-title .full-name {
    display: none;
  }

  .btn-header {
    min-height: 40px;
    padding: 0.35rem 0.65rem;
  }
}

@media (max-width: 480px) {
  :root {
    --header-height: 50px;
  }

  .header-brand .acronym {
    font-size: 1rem;
  }

  .header-divider {
    display: none;
  }

  .header-search {
    max-width: 160px;
    font-size: 0.75rem;
  }

  #header-search-input {
    font-size: 0.75rem;
    padding: 0.35rem 0.5rem;
  }

  .btn-header span:not(.icon) {
    display: none;
  }

  .btn-header {
    min-width: 38px;
    padding: 0.4rem;
    justify-content: center;
  }

  #btn-reset-view,
  #services-status-badge {
    display: none;
  }

  #map-coords {
    bottom: 0.3rem;
    font-size: 0.6rem;
    padding: 0.15rem 0.5rem;
  }
}

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

.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }

/* ---------------------------------------------------------------------------
   Modal Dialogue — Présentation & Méthodologie
   --------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 41, 0.65);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-mid);
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--border-radius-lg);
  max-width: 650px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
}

.modal-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.modal-badge {
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--color-water-deep);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
}

.modal-title {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background: rgba(0,0,0,0.06);
  color: var(--color-text-primary);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  line-height: 1.6;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.modal-section {
  margin-bottom: 1.25rem;
}

.modal-section:last-child {
  margin-bottom: 0;
}

.modal-section h3 {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-water-deep);
  margin-bottom: 0.4rem;
}

.modal-section ul {
  padding-left: 1.25rem;
  margin-top: 0.35rem;
}

.modal-section li {
  margin-bottom: 0.35rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: var(--color-surface-alt);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
}

