html, body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bs-body-bg);
}

/* Panneau latéral + carte occupent toute la hauteur restante */
.stare-corps {
  flex: 1;
  display: flex;
  min-height: 0;
}

.stare-panneau {
  overflow-y: auto;
  overflow-x: hidden;
}

/* Les libellés par défaut sont des Code_Indicateur longs et sans espaces : on autorise la coupure. */
.stare-panneau .form-check-label,
.stare-panneau .list-group-item > span,
.stare-fiche dd {
  overflow-wrap: anywhere;
  min-width: 0;
}

@media (min-width: 992px) {
  .stare-panneau {
    width: 360px;
    flex: 0 0 360px;
  }
}

.stare-carte {
  position: relative;
  flex: 1;
  min-width: 0;
}

/* Bandeaux en haut de la carte : la carte reste utilisable dessous */
.stare-carte-vide,
.stare-chargement {
  position: absolute;
  top: .75rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, .95);
  border-radius: .5rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  z-index: 1000;
  padding: .5rem 1rem;
  text-align: center;
  pointer-events: none;
  max-width: calc(100% - 7rem);
}

.stare-chargement .spinner-border {
  width: 1.25rem;
  height: 1.25rem;
}

.stare-carte-vide[hidden],
.stare-chargement[hidden] {
  display: none;
}

.stare-erreur {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  max-width: 90%;
}

/* Arbre : rubriques repliables (<details>) et feuilles cochables */
.stare-arbre ul {
  list-style: none;
  padding-left: 1rem;
  margin: 0;
}

.stare-arbre > ul {
  padding-left: 0;
}

.stare-arbre summary {
  font-weight: 600;
  padding: .2rem 0;
  cursor: pointer;
}

.stare-arbre summary:focus-visible,
.stare-arbre .btn-link:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

.stare-feuille {
  display: flex;
  align-items: flex-start;
  gap: .25rem;
  padding: .2rem 0;
}

.stare-feuille .form-check {
  flex: 1;
  margin-bottom: 0;
}

.stare-feuille .btn-link {
  padding: 0 .25rem;
  line-height: 1.5;
  text-decoration: none;
}

.stare-rubrique-vide {
  font-style: italic;
  color: var(--bs-secondary-color);
  font-size: .875em;
}

/* Fiche */
.stare-fiche dt {
  font-weight: 600;
}

.stare-fiche dd {
  margin-bottom: .5rem;
}

/* Légendes des calques MapOR2S : titres longs (codes sans espaces) coupés, et colonne de légendes
   défilante si elle dépasse la hauteur de la carte (place laissée en haut pour le choix du fond de carte). */
#carte .legendeTitreCalque {
  overflow-wrap: anywhere;
}

#carte .leaflet-bottom.leaflet-right {
  max-height: calc(100% - 80px);
  overflow-y: auto;
  pointer-events: auto;
}

/* Choix des couleurs d'une couche affichée */
.stare-couleurs summary {
  cursor: pointer;
}

.stare-couleurs .form-control-color {
  width: 2rem;
  height: 1.5rem;
  padding: .1rem;
  flex-shrink: 0;
}

/* Arbre secondaire des indicateurs déposés par les partenaires, en attente de validation */
.stare-nonvalides {
  border-left: 3px solid var(--bs-warning);
  padding-left: .5rem;
}

/* Page de dépôt : défilement normal ; carte d'aperçu fixée à droite sur grand écran */
html:has(body.stare-depot) {
  height: auto;
}

body.stare-depot {
  display: block;
  height: auto;
  min-height: 100%;
}

.stare-depot-carte {
  height: 70vh;
  display: flex;
  flex-direction: column;
}

.stare-depot-carte .card-body {
  flex: 1;
  min-height: 0;
}

@media (min-width: 992px) {
  .stare-depot-carte {
    position: sticky;
    top: 1rem;
    height: calc(100vh - 6rem);
  }
}

.stare-depot .stare-champs {
  max-height: 12rem;
  overflow-y: auto;
}

.stare-depot .stare-champs td,
.stare-depot .card-title {
  overflow-wrap: anywhere;
}

/* Bandeau des couleurs de la palette du classement automatique */
.stare-palette {
  display: flex;
  height: .6rem;
  border-radius: .2rem;
  overflow: hidden;
}

.stare-palette span {
  flex: 1;
}

/* Page d'aide (procédure d'intégration) */
.stare-aide {
  max-width: 60rem;
}

.stare-aide h2 {
  margin-top: 2rem;
  scroll-margin-top: 1rem;
}

.stare-aide h3 {
  margin-top: 1.25rem;
  font-size: 1.1rem;
}

.stare-aide table {
  font-size: .9rem;
}

.stare-aide pre {
  background: var(--bs-tertiary-bg);
  padding: .75rem;
  border-radius: .375rem;
  font-size: .85rem;
  white-space: pre-wrap;
}
