:root {
  --app-max-width: 1200px;
  --app-radius: 1.25rem;
  --app-radius-sm: 0.95rem;
  --app-section-space: 1.75rem;
  --app-grid-gap: 1.25rem;
  --app-shadow: 0 20px 44px -32px rgba(15, 23, 42, 0.28);
  --app-shadow-strong: 0 24px 52px -34px rgba(15, 23, 42, 0.38);
  --app-surface: #ffffff;
  --app-surface-muted: #f8fafc;
  --app-border: #dbe4f0;
  --app-text: #334155;
  --app-heading: #0f172a;
  --app-muted: #64748b;
  --app-muted-strong: #475569;
  --app-navbar-bg: rgba(9, 14, 26, 0.92);
  --app-navbar-border: rgba(148, 163, 184, 0.18);
  --app-hero: linear-gradient(145deg, #f8fbff 0%, #eef5ff 100%);
  --app-input-bg: #ffffff;
  --app-search-shadow: 0 18px 40px -28px rgba(15, 23, 42, 0.2);
  --app-faible: #0f766e;
  --app-modere: #b45309;
  --app-eleve: #b91c1c;
  --app-critique: #7f1d1d;
}

html[data-bs-theme="dark"] {
  --bs-body-bg: #111827;
  --bs-body-color: #e5edf7;
  --bs-border-color: #334155;
  --bs-secondary-color: #a8b6c7;
  --bs-secondary-color-rgb: 168, 182, 199;
  --bs-tertiary-bg: #0f172a;
  --bs-tertiary-bg-rgb: 15, 23, 42;
  --bs-link-color: #7dd3fc;
  --bs-link-hover-color: #bae6fd;
  --bs-card-bg: #162033;
  --bs-card-border-color: #334155;
  --bs-primary: #3b82f6;
  --bs-primary-rgb: 59, 130, 246;
  --bs-primary-bg-subtle: #102748;
  --bs-emphasis-color: #f8fafc;
  --app-surface: #162033;
  --app-surface-muted: #0f172a;
  --app-border: #334155;
  --app-text: #d7e4f3;
  --app-heading: #f8fafc;
  --app-muted: #a8b6c7;
  --app-muted-strong: #d7e4f3;
  --app-navbar-bg: rgba(9, 14, 26, 0.96);
  --app-navbar-border: rgba(148, 163, 184, 0.16);
  --app-hero: linear-gradient(145deg, #132033 0%, #0f172a 100%);
  --app-input-bg: #0f172a;
  --app-search-shadow: 0 24px 52px -36px rgba(0, 0, 0, 0.75);
  --app-faible: #14b8a6;
  --app-modere: #f59e0b;
  --app-eleve: #ef4444;
  --app-critique: #fb7185;
}

html,
body {
  min-height: 100%;
}

body {
  background: var(--bs-body-bg);
  color: var(--app-text);
}

p,
li,
td,
dd,
dt,
label,
.form-label {
  color: var(--app-text);
}

h1,
h2,
h3,
h4,
h5,
h6,
th,
strong,
legend {
  color: var(--app-heading);
}

a {
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

.app-main {
  padding-block: 1.25rem 3rem;
}

.app-main > .container-app > * + * {
  margin-top: var(--app-section-space);
}

.container-app {
  width: min(calc(100% - 1rem), var(--app-max-width));
  margin-inline: auto;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: linear-gradient(to bottom, rgba(9, 14, 26, 0.98), rgba(9, 14, 26, 0.88));
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--app-navbar-border);
}

.environment-banner {
  background: #7c2d12;
  color: #fff7ed;
  border-bottom: 1px solid rgba(255, 237, 213, 0.18);
  font-size: 0.92rem;
}

.environment-banner .container-app {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  align-items: center;
  padding-block: 0.55rem;
}

.app-navbar {
  background: transparent;
  padding-block: 0.8rem;
}

.app-navbar .navbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-navbar .brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 0.45rem;
  flex: 0 0 auto;
}

.app-navbar .nav-link {
  color: rgba(241, 245, 249, 0.86);
  font-weight: 500;
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link[aria-current="page"] {
  color: #ffffff;
}

.app-navbar .navbar-toggler {
  border: 1px solid rgba(241, 245, 249, 0.2);
}

.app-navbar .navbar-toggler:focus {
  box-shadow: 0 0 0 0.2rem rgba(96, 165, 250, 0.25);
}

.theme-toggle {
  display: grid;
  gap: 0.35rem;
  min-width: 10rem;
}

.theme-toggle-label {
  color: rgba(226, 232, 240, 0.92);
  font-size: 0.85rem;
  font-weight: 600;
}

.theme-toggle .form-select {
  background-color: rgba(15, 23, 42, 0.72);
  border-color: rgba(148, 163, 184, 0.22);
  color: #f8fafc;
}

.section-block {
  margin-block: 0;
}

.search-section {
  margin-block: 0;
}

.page-breadcrumb {
  margin-block: 0.4rem 1rem;
}

.page-breadcrumb .breadcrumb {
  margin: 0;
}

.page-breadcrumb .breadcrumb-item,
.page-breadcrumb .breadcrumb-item.active,
.page-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
  color: var(--app-muted);
}

.accordion {
  --bs-accordion-bg: var(--app-surface);
  --bs-accordion-border-color: var(--app-border);
  --bs-accordion-btn-bg: var(--app-surface);
  --bs-accordion-btn-color: var(--app-heading);
  --bs-accordion-active-bg: color-mix(in srgb, var(--bs-primary) 10%, var(--app-surface));
  --bs-accordion-active-color: var(--app-heading);
  --bs-accordion-color: var(--app-text);
}

.section-heading {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 0.95rem;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--app-muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-header,
.hero {
  margin-block: 0;
}

.page-header h1,
.hero h1 {
  margin-bottom: 0.6rem;
  color: var(--app-heading);
  font-size: clamp(2rem, 1.55rem + 2.1vw, 3.45rem);
  line-height: 1.03;
  letter-spacing: -0.03em;
}

.page-header p,
.hero p {
  max-width: 70ch;
}

.lede {
  color: var(--app-muted-strong);
}

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

.hero,
.surface-card,
.metric-card,
.notice,
.list-card,
.highlight,
.sparkline-box,
.map-card,
.table-card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  box-shadow: var(--app-shadow);
}

.hero {
  background: var(--app-hero);
  padding: 1.5rem;
}

.surface-card,
.metric-card,
.notice,
.list-card,
.highlight,
.sparkline-box,
.table-card {
  padding: 1.35rem;
}

.highlight {
  display: grid;
  gap: 1.35rem;
}

.metric-card {
  height: 100%;
}

.metric-card,
.notice,
.list-card,
.highlight,
.sparkline-box,
.table-card,
.surface-card,
.hero {
  color: var(--app-text);
}

.metric-card h2,
.metric-card h3,
.metric-card .h1,
.notice h2,
.notice h3,
.highlight h2,
.highlight h3,
.sparkline-box h2,
.sparkline-box h3,
.list-card h2,
.list-card h3 {
  color: var(--app-heading);
}

.metric-label {
  margin-bottom: 0.35rem;
  color: var(--app-muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.metric-card .muted,
.notice .muted,
.highlight .muted,
.sparkline-box .muted,
.list-card .muted,
.hero .muted,
.page-header .muted {
  color: var(--app-muted);
}

.hero-score {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.metrics-grid,
.grid-2,
.card-grid {
  display: grid;
  gap: var(--app-grid-gap);
}

.metrics-grid > *,
.grid-2 > *,
.card-grid > * {
  min-width: 0;
}

.metrics-grid {
  grid-template-columns: 1fr;
}

.grid-2,
.card-grid {
  grid-template-columns: 1fr;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  padding: 0.32rem 0.78rem;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.2;
  color: #ffffff;
}

.pill-faible {
  background: var(--app-faible);
}

.pill-modere {
  background: var(--app-modere);
}

.pill-eleve {
  background: var(--app-eleve);
}

.pill-critique {
  background: var(--app-critique);
}

.search-box {
  display: grid;
  gap: 0.85rem;
  width: 100%;
  max-width: min(100%, 72rem);
}

.search-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.85rem;
  align-items: center;
  width: 100%;
  min-height: 5rem;
  padding: 0.8rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 1.75rem;
  box-shadow: var(--app-search-shadow);
}

.search-input-wrap {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
  padding-inline: 0.45rem;
}

.search-icon {
  color: var(--app-muted);
  font-size: 1.45rem;
  line-height: 1;
}

.search-shell .form-control {
  min-width: 0;
  min-height: 3.6rem;
  padding: 0.35rem 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--app-heading);
  font-size: clamp(1.2rem, 1rem + 0.9vw, 1.75rem);
  font-weight: 500;
}

.search-shell .form-control:focus {
  box-shadow: none;
}

.search-shell .form-control::placeholder {
  color: var(--app-muted);
}

.search-shell .btn {
  min-height: 3.8rem;
  border-radius: 999px;
  padding-inline: 1.6rem;
  font-weight: 700;
  font-size: 1.08rem;
}

.search-hint {
  margin: 0;
  padding-inline: 0.2rem;
  color: var(--app-muted);
  font-size: 0.98rem;
}

.search-suggestions {
  position: relative;
}

.search-suggestions-list {
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 1.15rem;
  box-shadow: var(--app-shadow-strong);
}

.search-suggestions-list li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-suggestion {
  display: grid;
  gap: 0.2rem;
  width: 100%;
  padding: 0.8rem 0.95rem;
  background: transparent;
  border: 0;
  border-radius: 0.95rem;
  color: var(--app-text);
  text-align: left;
  cursor: pointer;
}

.search-suggestion:hover,
.search-suggestion[aria-selected="true"] {
  background: color-mix(in srgb, var(--bs-primary) 12%, transparent);
}

.search-suggestion-label {
  color: var(--app-heading);
  font-weight: 700;
}

.search-suggestion-meta {
  color: var(--app-muted);
  font-size: 0.92rem;
}

.table-card {
  padding: 0;
  overflow: hidden;
}

.app-main section > h2,
.app-main article > h2,
.app-main section > h3,
.app-main article > h3 {
  margin-bottom: 1rem;
}

.app-main section > p:last-child,
.app-main article > p:last-child {
  margin-bottom: 0;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

.table {
  margin: 0;
  width: max-content;
  min-width: 100%;
  --bs-table-bg: transparent;
  --bs-table-color: var(--app-text);
  --bs-table-border-color: var(--app-border);
}

.table > :not(caption) > * > * {
  padding: 0.9rem 1rem;
}

.table thead th {
  color: var(--app-heading);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  background: color-mix(in srgb, var(--app-surface-muted) 85%, transparent);
}

.filters .form-control,
.filters .form-select {
  background: var(--app-surface);
  border-color: var(--app-border);
  color: var(--app-heading);
}

.filters .form-control::placeholder {
  color: var(--app-muted);
}

.link-list,
.facts-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.link-list li,
.facts-list li {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-block: 0.75rem;
  border-bottom: 1px solid var(--app-border);
}

.link-list li:last-child,
.facts-list li:last-child {
  border-bottom: 0;
}

.facts-list strong {
  color: var(--app-heading);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1rem;
  color: var(--app-muted);
  font-size: 0.92rem;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.legend-dot {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
  display: inline-block;
}

.legend-faible {
  background: var(--app-faible);
}

.legend-modere {
  background: var(--app-modere);
}

.legend-eleve {
  background: var(--app-eleve);
}

.legend-critique {
  background: var(--app-critique);
}

.map-card {
  overflow: hidden;
}

.map-canvas {
  min-height: 20rem;
  width: 100%;
}

.leaflet-container {
  background: var(--app-surface-muted);
  font-family: inherit;
}

.map-popup {
  color: #1f2937;
  line-height: 1.4;
}

.sparkline {
  width: 100%;
  height: auto;
  color: var(--bs-primary);
}

.nearby-results {
  margin-top: 1rem;
}

.site-footer {
  padding-block: 1.5rem 2.5rem;
  color: var(--app-muted);
}

.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;
}

@media (min-width: 576px) {
  .container-app {
    width: min(calc(100% - 1.5rem), var(--app-max-width));
  }

  .search-shell {
    grid-template-columns: minmax(0, 1fr) auto;
    border-radius: 999px;
    padding: 0.75rem 0.8rem 0.75rem 1.15rem;
  }

  .search-shell .btn {
    width: auto;
  }
}

@media (min-width: 768px) {
  .app-main {
    padding-block: 1.75rem 3.5rem;
  }

  :root {
    --app-section-space: 2rem;
    --app-grid-gap: 1.5rem;
  }

  .section-block {
    margin-block: 0;
  }

  .hero {
    padding: 1.9rem;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .highlight {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-heading {
    flex-direction: row;
    align-items: end;
    justify-content: space-between;
  }

  .link-list li,
  .facts-list li {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .map-canvas {
    min-height: 25rem;
  }
}

@media (min-width: 992px) {
  .metrics-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .map-canvas {
    min-height: 30rem;
  }

  .app-navbar .navbar-nav {
    gap: 0.3rem;
  }
}
