:root {
  /* Dark theme tokens override */
  --bg: #0b0d1c;
  /* Dark surfaces */
  --surface: #0f172a;
  --text: #e6eefc;
  --primary: #9dd3ff;
  --secondary: #9aa4af;
  --accent: #4da3ff;

  --hero-bg: #0b0d1c;
  --hero-fg: #e6eefc;
  --cta: #22c55e;
  --cta-hover: #16a34a;

  --gray-100: #0f172a;
  --gray-200: #111827;
  --gray-300: #1f2937;
  --gray-400: #374151;
  --gray-500: #4b5563;
  --gray-600: #6b7280;
  --gray-700: #9ca3af;

  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;

  --link: #9dd3ff;
  --link-hover: #c7e6ff;

  --accent-hover: #66b6ff;
  --accent-deep: #2a6fb3;

  /* Cards in dark: subtle dark gradient */
  --card-accent: #4da3ff;
  /* Lighten card surfaces slightly for readability */
  --card-border: #22314f;
  --card-border-hover: #2e4472;
  --card-bg-top: #121a2f;
  --card-bg-bottom: #0f172a;
  --pill-bg: #0c1a2b;
  --pill-border: #143052;
  --chip-bg: #0e1525;
  --chip-border: #152238;
  --muted: #96a3b5;
}

html { color-scheme: dark; background-color: var(--bg); }
body { background: var(--bg); color: var(--text); }

/* Dark cards inside sections */
.search-page .result-card {
  background: linear-gradient(125deg, var(--card-bg-top), var(--card-bg-bottom)) !important;
  border-color: var(--card-border) !important;
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.35) !important;
  color: var(--text) !important;
}
.search-page .summary-card { background: linear-gradient(125deg, var(--card-bg-top), var(--card-bg-bottom)) !important; color: var(--text) !important; }

/* Darken accordion content while keeping cards light */
.search-page .accordion-content { background: #0d111a !important; }
/* Ensure accordion headers remain legible in dark */
body.search-page .results-container .accordion-header { background: linear-gradient(125deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02)) !important; border-bottom: 1px solid rgba(255,255,255,0.08) !important; }
body.search-page .results-container .accordion-header h3,
body.search-page .results-container .accordion-header h4 { color: #e6eefc !important; }
body.search-page .results-container .accordion-toggle { color: #9dd3ff !important; }

/* Sort buttons: dark surface + light text */
body.search-page .results-container .sort-btn { color: #e6eefc !important; background: #111827 !important; border-color: #1f2937 !important; }
body.search-page .results-container .sort-btn:hover { background: #0f172a !important; border-color: #334155 !important; }
body.search-page .results-container .sort-btn.active { background: #0d6efd !important; color: #ffffff !important; border-color: #0d6efd !important; }

/* DVF card content readability on dark */
.dvf-card__addr { color: #e6eefc !important; }
.dvf-card__date { color: #cbd5e1 !important; }
.chip { color: #cbd5e1 !important; }
.pill.price-per-m2-built { background: rgba(245, 158, 11, 0.16) !important; border-color: rgba(245, 158, 11, 0.38) !important; color: #fbbf24 !important; }
.pill.price-per-m2 { background: rgba(34,197,94,0.16) !important; border-color: rgba(34,197,94,0.38) !important; color: #22c55e !important; }

/* Summary cards text and badges on dark */
.summary-label { color: #cbd5e1 !important; }
.summary-detail { color: #9aa4af !important; }
.summary-value { color: #9dd3ff !important; }
.summary-badge { color: #e6eefc !important; background: rgba(255,255,255,0.06) !important; border-color: rgba(255,255,255,0.18) !important; }
.summary-badge-positive { background: rgba(34, 197, 94, 0.18) !important; border-color: rgba(34, 197, 94, 0.4) !important; color: #34d399 !important; }
.summary-badge-neutral { background: rgba(148, 163, 184, 0.18) !important; border-color: rgba(148, 163, 184, 0.4) !important; color: #cbd5e1 !important; }
.summary-badge-warning { background: rgba(245, 158, 11, 0.20) !important; border-color: rgba(245, 158, 11, 0.45) !important; color: #f59e0b !important; }
.summary-badge-critical { background: rgba(239, 68, 68, 0.20) !important; border-color: rgba(239, 68, 68, 0.45) !important; color: #ef4444 !important; }
.summary-badge-info { background: rgba(59, 130, 246, 0.20) !important; border-color: rgba(59, 130, 246, 0.45) !important; color: #60a5fa !important; }

/* ===== Sitadel (Permits) - dark readability ===== */
.sitadel-overview { background: linear-gradient(135deg, rgba(10,16,30,0.85) 0%, rgba(12,20,35,0.85) 100%) !important; border: 1px solid rgba(255,255,255,0.06) !important; }
.construction-score-card { border-left-color: #ffb14a !important; }
.score-description h4 { color: #e6eefc !important; }
.score-description p { color: #9aa4af !important; }
.score-grade { color: #cbd5e1 !important; }
.permit-header { border-bottom-color: #22314f !important; }
.permit-date { color: #cbd5e1 !important; }
.permit-details { color: #e6eefc !important; }
.permit-nature { color: #9aa4af !important; }
.metric { background: #0e1628 !important; border-color: #1f2a44 !important; color: #cbd5e1 !important; }

/* ===== Rent (Loyers) - dark readability ===== */
.rent-summary-card { background: linear-gradient(135deg, #111a2e, #0e172a) !important; border: 1px solid #1f2a44 !important; }
.rent-summary-header h4 { color: #e6eefc !important; }
.rent-subtitle { color: #9aa4af !important; }
.rent-summary-item { background: #0e1628 !important; border: 1px solid #1f2a44 !important; }
.rent-zone-grid .rent-summary-item { background: #101a30 !important; border-color: #203052 !important; }
.rent-zone-header h5 { color: #9dd3ff !important; }
.rent-zone-cities { color: #cbd5e1 !important; }
.rent-label { color: #9aa4af !important; }
.rent-value { color: #e6eefc !important; }

.rent-table { background: #0f172a !important; border-radius: 10px !important; box-shadow: 0 1px 6px rgba(2,6,23,0.35) !important; }
.rent-table th, .rent-table td { border-bottom-color: #22314f !important; color: #cbd5e1 !important; }
.rent-table th { background: #121a2f !important; color: #e6eefc !important; }
.rent-table tr.is-selected { background: rgba(77, 171, 247, 0.12) !important; }
.rent-table tr.is-selected td { border-bottom-color: rgba(77, 171, 247, 0.35) !important; }
.rent-table-value { color: #e6eefc !important; }
.rent-methodology { color: #9aa4af !important; }
.rent-empty { background: rgba(239, 68, 68, 0.15) !important; border-color: rgba(239, 68, 68, 0.35) !important; color: #fecaca !important; }

/* ===== Fiscalité - dark readability ===== */
.fiscalite-section { background: linear-gradient(160deg, #111a2e, #0e172a) !important; border-color: #1f2a44 !important; }
.fiscalite-rates li { color: #e6eefc !important; }
.fiscalite-rates li:hover { background: rgba(77, 171, 247, 0.10) !important; }
.fiscalite-estimate { background: linear-gradient(160deg, #101a30, #0f1629) !important; border-color: #203052 !important; }
.fiscalite-estimate .estimate-label { color: #9aa4af !important; }
.fiscalite-estimate .estimate-value { color: #9dd3ff !important; }
.fiscalite-estimate .estimate-subtle, .fiscalite-estimate .estimate-note { color: #cbd5e1 !important; }
.fiscalite-customizer { background: rgba(14, 22, 40, 0.6) !important; border-color: #1f2a44 !important; }
.fiscalite-customizer label { color: #9aa4af !important; }
.fiscalite-customizer input { background: #0c1424 !important; border-color: #1f2a44 !important; color: #e6eefc !important; }
.fiscalite-customizer input:focus { border-color: #4da3ff !important; box-shadow: 0 0 0 2px rgba(77,171,247,0.25) !important; }
.fiscalite-customizer [data-fiscalite-reset] { background: rgba(77,171,247,0.12) !important; color: #9dd3ff !important; }
.fiscalite-customizer [data-fiscalite-reset]:hover { background: rgba(77,171,247,0.22) !important; }
.fiscalite-warning { background: rgba(245, 158, 11, 0.15) !important; border-color: rgba(245, 158, 11, 0.45) !important; color: #fbbf24 !important; }
.fiscalite-alert { background: rgba(220, 53, 69, 0.12) !important; color: #fecaca !important; }
.fiscalite-breakdown-item { background: #0f172a !important; border-color: #203052 !important; box-shadow: none !important; }
.fiscalite-breakdown-item .breakdown-label { color: #9aa4af !important; }
.fiscalite-breakdown-item .breakdown-label small { color: #cbd5e1 !important; opacity: 0.9 !important; }
.fiscalite-breakdown-item .breakdown-value { color: #e6eefc !important; }
.fiscalite-breakdown-item.is-total { background: linear-gradient(150deg, #13233d, #0f1f38) !important; border-color: #2e4472 !important; box-shadow: 0 6px 18px rgba(2,6,23,0.35) !important; }

/* ===== Démographie (INSEE) - dark readability ===== */
.insee-kpis .kpi-card { background: #101a30 !important; border-color: #203052 !important; box-shadow: 0 1px 6px rgba(2,6,23,0.35) !important; }
.insee-kpis .kpi-label, .subtle { color: #9aa4af !important; }
.insee-kpis .kpi-value { color: #e6eefc !important; }
.insee-section .result-card { background: linear-gradient(135deg, #111a2e, #0e172a) !important; border-color: #22314f !important; }
.insee-legend .legend-item { color: #cbd5e1 !important; background: #0e1628 !important; border-color: #1f2a44 !important; }
.insee-legend .legend-color { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12) !important; }
.insee-chart-empty { color: #9aa4af !important; }
/* Improve donut center label contrast */
.insee-chart svg text { fill: #e6eefc !important; font-weight: 600; }

/* ===== FDEP (Indice de défavorisation) - dark readability ===== */
.fdep-summary { background: linear-gradient(135deg, #111a2e, #0e172a) !important; border-color: #22314f !important; color: #e6eefc !important; }
.fdep-score-label { color: #9aa4af !important; }
.fdep-percentile { color: #cbd5e1 !important; }
.fdep-description { color: #cbd5e1 !important; }
.fdep-meta { color: #9aa4af !important; }
.fdep-components h4, .fdep-extremes h4 { color: #e6eefc !important; }
.fdep-component { background: #0e1628 !important; border-color: #1f2a44 !important; color: #e6eefc !important; }
.fdep-component-label { color: #e6eefc !important; }
.fdep-component-value { color: #9dd3ff !important; }
.fdep-component-hint { color: #9aa4af !important; }
.fdep-extreme-card { background: #0f172a !important; border-color: #203052 !important; color: #e6eefc !important; }
.fdep-extreme-title { color: #e6eefc !important; }
.fdep-extreme-label { color: #cbd5e1 !important; }
.fdep-extreme-score { color: #9dd3ff !important; }
.fdep-extreme-category, .fdep-extreme-population { color: #9aa4af !important; }
.fdep-ranking-column { background: #0e1628 !important; border-color: #1f2a44 !important; color: #e6eefc !important; }
.fdep-ranking-column h5, .fdep-ranking-column li, .fdep-ranking-label { color: #e6eefc !important; }
.fdep-ranking-score { color: #9dd3ff !important; }
.fdep-empty { background: rgba(14, 22, 40, 0.65) !important; border-color: #22314f !important; color: #cbd5e1 !important; }

/* ===== Air Quality - dark readability ===== */
.aq-summary-note { color: #9aa4af !important; }
.aq-summary-warning { color: #fbbf24 !important; }
.aq-measurement-card { background: #101a30 !important; border-color: #203052 !important; color: #e6eefc !important; }
.aq-measurement-card--far { background: #0e1628 !important; border-color: #1f2a44 !important; }
.aq-pollutant { color: #e6eefc !important; }
.aq-value { color: #e6eefc !important; }
.aq-distance { color: #cbd5e1 !important; }
.aq-distance-alert { color: #e6eefc !important; background: #1f2a44 !important; }
.aq-station { color: #e6eefc !important; }
.aq-period { color: #9aa4af !important; }
.aq-meta { color: #cbd5e1 !important; }
.aq-meta-item { background: #0e1628 !important; color: #e6eefc !important; }
.aq-metrics { color: #cbd5e1 !important; }
.aq-metric strong { color: #ffffff !important; }

/* ===== Water Quality - dark readability ===== */
.water-summary-card { background: #101a30 !important; border: 1px solid #203052 !important; }
.quality-score { background: linear-gradient(160deg, #0f5132, #065f46) !important; }
.score-number, .score-grade, .score-label { color: #e6fffa !important; text-shadow: none !important; }
.stat-label { color: #9aa4af !important; }
.stat-value { color: #e6eefc !important; }
.no-water-data { color: #cbd5e1 !important; }

/* Water detail cards and network info */
.network-info { background: #101a30 !important; color: #e6eefc !important; }
.network-info h4 { color: #e6eefc !important; }
.network-label { color: #cbd5e1 !important; }
.network-value { color: #e6eefc !important; }

.sample-card { background: #0f172a !important; border-color: #22314f !important; }
.sample-date { color: #e6eefc !important; }
.sample-info { color: #cbd5e1 !important; }

/* Conclusion banner with softer success tint on dark */
.sample-conclusion { background: rgba(34,197,94,0.15) !important; color: #bbf7d0 !important; }

/* Key parameters tiles */
.key-parameters h5 { color: #e6eefc !important; }
.parameters-grid { gap: 12px !important; }
.parameter-item { background: #0e1628 !important; border-left-color: #3b82f6 !important; }
.parameter-name { color: #cbd5e1 !important; }
.parameter-value { color: #9dd3ff !important; }
.parameter-unit { color: #9aa4af !important; }
.parameter-reference { color: #94a3b8 !important; }

/* Confidence panel */
.quality-confidence { background: #0e1628 !important; color: #cbd5e1 !important; }
.confidence-label { color: #e6eefc !important; }
.confidence-value { color: #9dd3ff !important; }

/* ===== Transports - dark readability ===== */
.transport-intro { color: #9aa4af !important; }
.transport-card { background: #101a30 !important; border-color: #203052 !important; box-shadow: 0 10px 30px rgba(2,6,23,0.35) !important; }
.transport-card::after { background: linear-gradient(120deg, rgba(77, 171, 247, 0.10), transparent 55%) !important; }
.transport-card-name { color: #e6eefc !important; }
.transport-card-address { color: #cbd5e1 !important; }
.transport-card-badge { color: #9dd3ff !important; background: rgba(77, 171, 247, 0.12) !important; border-color: rgba(77, 171, 247, 0.28) !important; }
.transport-card[data-mode="bus"] .transport-card-badge { color: #fbbf24 !important; background: rgba(245, 158, 11, 0.16) !important; border-color: rgba(245, 158, 11, 0.38) !important; }
.transport-card[data-mode="train"] .transport-card-badge { color: #34d399 !important; background: rgba(34, 197, 94, 0.16) !important; border-color: rgba(34, 197, 94, 0.38) !important; }
.transport-mode-chip { background: #0e1628 !important; border-color: #1f2a44 !important; color: #e6eefc !important; }
.transport-mode-chip--primary { background: rgba(77, 171, 247, 0.14) !important; border-color: rgba(77, 171, 247, 0.30) !important; color: #9dd3ff !important; }
.transport-line-chip { background: rgba(77, 171, 247, 0.14) !important; border-color: rgba(77, 171, 247, 0.26) !important; color: #9dd3ff !important; }
.transport-line-chip--more { background: rgba(148, 163, 184, 0.16) !important; border-color: rgba(148, 163, 184, 0.35) !important; color: #e6eefc !important; }

/* ===== Climat (Météo) - dark readability ===== */
.meteo-section h3 { color: #9dd3ff !important; }
.meteo-table { box-shadow: 0 2px 10px rgba(2,6,23,0.35) !important; }
.meteo-table th { background-color: #1a2942 !important; color: #e6eefc !important; }
.meteo-table td { border-bottom-color: #22314f !important; color: #e6eefc !important; }
.meteo-table tr:last-child td { border-bottom: none !important; }
.month-name { background-color: #0f172a !important; color: #cbd5e1 !important; }
.temp-cell, .precip-cell { color: #e6eefc !important; text-shadow: none !important; }
.meteo-tables h4 { color: #cbd5e1 !important; }

/* ===== Criminalité - dark readability ===== */
.crime-section h3 { color: #9dd3ff !important; }
.crime-type { color: #e6eefc !important; }
.rate-value { color: #e6eefc !important; }
.rate-unit { color: #cbd5e1 !important; }
.rate-label { color: #9aa4af !important; }
.trend-indicator.up { background: linear-gradient(135deg, rgba(239,68,68,0.28), rgba(239,68,68,0.18)) !important; color: #fecaca !important; }
.trend-indicator.down { background: linear-gradient(135deg, rgba(34,197,94,0.28), rgba(34,197,94,0.18)) !important; color: #bbf7d0 !important; }
.trend-indicator.stable { background: linear-gradient(135deg, rgba(148,163,184,0.28), rgba(148,163,184,0.18)) !important; color: #e5e7eb !important; }

/* ===== Schools - dark readability ===== */
.school-section .section-header h3 { color: #9dd3ff !important; }
.school-section .address-info { color: #9aa4af !important; }
.stat-card { background: #101a30 !important; color: #e6eefc !important; border: 1px solid #203052 !important; }
.stat-card.total-schools { background: linear-gradient(135deg, #13233d, #0f1f38) !important; color: #9dd3ff !important; border-left-color: #4da3ff !important; }
.type-comparison h4, .top-schools h4 { color: #e6eefc !important; }
.school-name { color: #e6eefc !important; }
.school-location { color: #cbd5e1 !important; }
.school-sector.public { background-color: rgba(77,171,247,0.16) !important; color: #9dd3ff !important; }
.school-sector.private, .school-sector[class*="privé"] { background-color: rgba(245,158,11,0.18) !important; color: #fbbf24 !important; }
.school-sector-badge.public { background-color: rgba(77,171,247,0.16) !important; color: #9dd3ff !important; }
.school-sector-badge[class*="privé"] { background-color: rgba(245,158,11,0.18) !important; color: #fbbf24 !important; }
.metric { background: #0e1628 !important; border: 1px solid #1f2a44 !important; }
.metric-label { opacity: 1 !important; color: #9aa4af !important; }
.metric-value { color: #e6eefc !important; }
.establishment-group { background: #0e1628 !important; border: 1px solid #1f2a44 !important; }
.establishment-name { color: #e6eefc !important; }
.establishment-header { background: #101a30 !important; border-bottom: 1px solid #22314f !important; }
.establishment-location { color: #cbd5e1 !important; }
.establishment-sector.public { background-color: rgba(77,171,247,0.18) !important; color: #9dd3ff !important; }
.establishment-sector[class*="privé"] { background-color: rgba(245,158,11,0.18) !important; color: #fbbf24 !important; }
.years-data { background: #0e1628 !important; }
.year-row { border-bottom-color: #22314f !important; }
.year-row:hover { background: #0f172a !important; }
.year-badge { background: #1a2942 !important; color: #e6eefc !important; }
.students-count { color: #9aa4af !important; }

/* School success-rate tiles and best-rate badge (override inline light backgrounds) */
.year-metrics .metric.success-rate,
.best-rate {
  background: linear-gradient(135deg, #0f2d20, #0c2319) !important;
  border-left: 4px solid #34d399 !important;
  color: #e6eefc !important;
}
.best-rate .rate-value,
.best-rate .rate-label { color: #e6eefc !important; }

/* Summary AI readability on dark */
.summary-ai { background: rgba(15,118,110,0.12) !important; border-color: rgba(45,212,191,0.28) !important; color: #e6eefc !important; }
.summary-ai p { color: #e6eefc !important; }

/* Leaflet controls - dark theme */
.leaflet-bar { background: #101a30 !important; border: 1px solid #22314f !important; box-shadow: 0 4px 12px rgba(2,6,23,0.35) !important; }
.leaflet-bar a { background: #101a30 !important; color: #e6eefc !important; border-bottom: 1px solid #22314f !important; }
.leaflet-bar a:hover { background: #0e1628 !important; color: #9dd3ff !important; }
.leaflet-control-layers { background: #101a30 !important; color: #e6eefc !important; border: 1px solid #22314f !important; }
.leaflet-control-layers-separator { border-top: 1px solid #22314f !important; }
.leaflet-control a { color: #e6eefc !important; }

/* Summary mobile card on dark */
@media (max-width: 640px) {
  .summary-mobile-card {
    background: #101a30 !important;
    border: 1px solid #22314f !important;
    box-shadow: 0 20px 40px -32px rgba(2, 6, 23, 0.45) !important;
  }
  .summary-mobile-ai { color: #e6eefc !important; }
  .summary-mobile-label { color: #e6eefc !important; }
  .summary-mobile-detail { color: #9aa4af !important; }
  .summary-mobile-value { color: #e6eefc !important; }
  .summary-mobile-bar { background: #1f2a44 !important; }
}

/* Hero compare suggestions - dark */
.hero-compare-suggestions { background: #0e1628 !important; border-color: #1f2a44 !important; box-shadow: 0 18px 36px rgba(2,6,23,0.45) !important; }
.hero-compare-suggestion { color: #e6eefc !important; }
.hero-compare-suggestion__label { color: #e6eefc !important; }
.hero-compare-suggestion__context { color: #cbd5e1 !important; }
.hero-compare-suggestion--empty { color: #9aa4af !important; }
.hero-compare-suggestion:hover, .hero-compare-suggestion.is-focused { background: rgba(45,227,197,.14) !important; }

/* Account badge - dark theme */
.account-badge-floating .account-badge {
  background: rgba(13, 27, 45, 0.8) !important;
  color: #f8fafc !important;
  border: 1px solid rgba(148, 163, 184, 0.18) !important;
  box-shadow: 0 12px 32px rgba(2, 6, 23, 0.45) !important;
}
.account-badge__label,
.account-badge__caption { color: #d1d5db !important; }
.account-badge__hint { color: #e2e8f0 !important; }
.account-badge__email,
.account-badge__value { color: #ffffff !important; }
.account-badge__cta { background: #283163 !important; color: #f8fafc !important; }
.account-badge__cta--secondary { background: transparent !important; color: #93c5fd !important; border-color: rgba(147, 197, 253, 0.6) !important; }

/* Chip type color in dark theme */
.chip--type { background: #162866 !important; }
