:root {
  --fond: #ffffff;
  --texte: #0f172a;
  --texte-2: #475569;
  --texte-3: #94a3b8;
  --bord: #e2e8f0;
  --accent: #059669;
  --largeur-panneau: 340px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--texte); }
#carte { position: absolute; inset: 0; }

#panneau {
  position: absolute; top: 12px; left: 12px; bottom: 12px; width: var(--largeur-panneau);
  background: var(--fond); border: 1px solid var(--bord); border-radius: 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12); overflow-y: auto; z-index: 5;
  display: flex; flex-direction: column;
}
.panneau-tete { padding: 18px 18px 10px; border-bottom: 1px solid var(--bord); }
.panneau-tete h1 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.sous-titre { margin: 4px 0 0; font-size: 12px; color: var(--texte-2); }
.bloc { padding: 12px 18px; border-bottom: 1px solid var(--bord); }
.etiquette { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--texte-3); margin-bottom: 8px; }
.bouton-plie { background: none; border: 0; padding: 0; cursor: pointer; width: 100%; text-align: left; font: inherit; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--texte-3); }
select { width: 100%; padding: 9px 10px; border: 1px solid var(--bord); border-radius: 10px; background: #f8fafc; font-size: 13px; color: var(--texte); }
.aide { font-size: 12px; color: var(--texte-2); margin: 8px 0 0; line-height: 1.45; }

.couche { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; cursor: pointer; }
.couche input { margin: 0; }
.couche-nom { flex: 1; }
.couche-nb { font-size: 11px; color: var(--texte-3); font-variant-numeric: tabular-nums; }
.couche.indisponible { opacity: 0.5; cursor: not-allowed; }

.pastille { display: inline-block; width: 12px; height: 12px; border-radius: 4px; flex: none; border: 1px solid rgba(15, 23, 42, 0.15); }
.legende-zone { margin: 8px 0 4px; }
.legende-zone-titre { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--texte-2); margin-bottom: 4px; }
.legende-ligne { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; padding: 5px 6px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; color: var(--texte); text-align: left; }
.legende-ligne:hover { background: #f1f5f9; }
.legende-num { width: 22px; font-weight: 700; color: var(--texte-2); font-variant-numeric: tabular-nums; }
.legende-nom { flex: 1; }

.badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: #f1f5f9; color: var(--texte-2); text-transform: uppercase; letter-spacing: 0.06em; }
.badge-approx { background: #fef3c7; color: #92400e; }
.badge-tracer { background: #e2e8f0; color: #475569; }
.badge-trace { background: #ede9fe; color: #5b21b6; }
.legende-a-tracer { opacity: 0.65; cursor: default; }
.legende-info { margin: 0 0 4px; }
.badge-osm { background: #d1fae5; color: #065f46; }

.attribution { margin-top: auto; padding: 12px 18px; font-size: 10px; color: var(--texte-3); line-height: 1.4; }

#fiche {
  position: absolute; top: 12px; right: 12px; width: 360px; max-height: calc(100% - 24px);
  background: var(--fond); border: 1px solid var(--bord); border-radius: 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12); overflow-y: auto; z-index: 6; padding: 18px;
}
#fiche.cache { display: none; }
#fermer-fiche { position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border: 0; border-radius: 8px; background: #f1f5f9; cursor: pointer; font-weight: 700; color: var(--texte-2); }
.fiche-tete { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 3px solid; margin-bottom: 10px; }
.fiche-num { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.25); flex: none; }
.fiche-tete h2 { margin: 0; font-size: 17px; }
.fiche-zone { font-size: 12px; color: var(--texte-2); }
.fiche-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
#fiche h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--texte-3); margin: 14px 0 6px; }
.fiche-bloc { border: 1px solid var(--bord); border-radius: 10px; overflow: hidden; }
.fiche-ligne { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 10px; font-size: 13px; border-bottom: 1px solid var(--bord); }
.fiche-ligne:last-child { border-bottom: 0; }
.a-venir { font-size: 11px; color: var(--texte-3); font-style: italic; text-align: right; }
.fiche-details { margin-top: 12px; font-size: 12px; color: var(--texte-2); }
.fiche-details summary { cursor: pointer; }
.fiche-details ul { margin: 6px 0 0; padding-left: 18px; }

.numero {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(15, 23, 42, 0.35); cursor: pointer; user-select: none;
}
.numero:hover { transform: scale(1.15); }

.numero.numero-petit { width: 22px; height: 22px; font-size: 11px; border-width: 1.5px; }
.numero.numero-cache { display: none; }

.couche.chargement { opacity: 0.6; }
.couche.chargement .couche-nom::after { content: " (chargement)"; color: var(--texte-3); font-size: 11px; }

.fiche-lib { display: flex; flex-direction: column; gap: 2px; }
.fiche-val { text-align: right; line-height: 1.2; }
.fiche-val strong { font-size: 14px; }
.densite { display: block; font-size: 10px; color: var(--texte-3); font-weight: 500; }
.compare { font-size: 10px; font-weight: 600; }
.compare.sup { color: #047857; }
.compare.inf { color: #b45309; }
.compare.egal { color: var(--texte-3); }

.legende-prix { margin-top: 8px; font-size: 11px; color: var(--texte-2); }
.legende-prix.cache { display: none; }
.legende-prix .barre { height: 10px; border-radius: 5px; background: linear-gradient(90deg, #FEF3C7, #F59E0B, #B91C1C, #7F1D1D); margin: 4px 0; }
.legende-prix .bornes { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.source { display: block; font-size: 10px; color: var(--texte-3); margin-top: 2px; font-weight: 500; }
.source a { color: inherit; text-decoration: underline; }
.a-renseigner { font-size: 11px; color: var(--texte-3); font-style: italic; }
.fourchette { display: block; font-size: 10px; color: var(--texte-3); font-weight: 500; }
.ecart.sup { color: #b45309; }
.ecart.inf { color: #047857; }
.ecart.egal { color: var(--texte-2); }

.signaux { display: flex; flex-direction: column; gap: 8px; }
.signal { border: 1px solid var(--bord); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.signal-tete { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.signal-titre { font-size: 13px; line-height: 1.3; }
.signal-desc { margin: 6px 0 0; font-size: 12px; color: var(--texte-2); line-height: 1.45; }
.signal-pied { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.signal-pied .source { margin: 0; }
.badge-type { background: #e0f2fe; color: #075985; flex: none; }
.badge-confiance-forte { background: #d1fae5; color: #065f46; }
.badge-confiance-moyenne { background: #fef3c7; color: #92400e; }
#signaux-ville .aide { margin-top: 8px; }

.maplibregl-popup-content { font-size: 13px; padding: 8px 10px; border-radius: 8px; }
.popup-zone { font-size: 11px; color: var(--texte-2); }
.erreur { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 10; background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 10px; font-size: 13px; }

@media (max-width: 860px) {
  #panneau { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 48vh; border-radius: 16px 16px 0 0; }
  #fiche { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 70vh; border-radius: 16px 16px 0 0; }
}

/* Recherche de quartier */
.recherche { display: flex; gap: 6px; align-items: center; }
.recherche input {
  flex: 1; min-width: 0; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--bord);
  background: #fff; font: inherit; font-size: 14px; color: var(--texte-1);
}
.recherche input:focus { outline: none; border-color: #2563EB; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.recherche input.introuvable { border-color: #DC2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12); }
.recherche button {
  flex: none; width: 32px; height: 34px; border-radius: 9px; border: 1px solid var(--bord);
  background: #fff; cursor: pointer; color: var(--texte-2); font-size: 14px; line-height: 1;
}
.recherche button:hover { background: var(--fond-2); }

/* Nom du quartier sous son numero */
.etiquette-quartier {
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  margin-top: 4px; padding: 2px 7px; border-radius: 6px; white-space: nowrap;
  background: rgba(255, 255, 255, 0.92); color: #0f172a; font-size: 11px; font-weight: 700;
  letter-spacing: 0.01em; box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25); pointer-events: none;
}
.numero.numero-petit .etiquette-quartier { display: none; }
.numero.numero-cache .etiquette-quartier { display: none; }
