/* ===== Mise en page application (UX carto-cma) ============================== */
html, body { height: 100%; }
body { margin: 0; display: flex; flex-direction: column; min-height: 100vh; }
#content { flex: 1 1 auto; display: flex; min-height: 0; }

.app-shell { flex: 1 1 auto; display: flex; min-height: 0; width: 100%; }

#lang-switch { margin-right: .5rem; }

/* ===== Volet lentilles ====================================================== */
.lens-pane {
  flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column;
  overflow-y: auto; padding: 1rem 1.25rem 2rem;
  background: var(--background-alt-grey, #f6f6f6);
}
.lens-head { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem 1.25rem; }
.lens-help { color: var(--text-mention-grey, #666); margin: .1rem 0 .9rem; flex: 1 1 320px; }

.lens-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; align-items: start; }
.lens-grid.compare { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
.lens-panel {
  background: #fff; border: 1px solid var(--border-default-grey, #ddd);
  border-radius: 8px; padding: 1rem 1.1rem 1.1rem; min-width: 0;
}
.panel-title { margin: 0 0 .75rem; }
.panel-note { color: #777; margin: .8rem 0 0; }

/* ---- tuiles de stats ---- */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.stat-tile { border: 1px solid var(--border-default-grey, #e3e3e3); border-radius: 6px; padding: .55rem .7rem; background: var(--background-alt-grey, #f8f8f8); }
.stat-tile .st-num { font-size: 1.25rem; font-weight: 700; line-height: 1.15; }
.stat-tile .st-lab { font-size: .68rem; color: #555; text-transform: uppercase; letter-spacing: .02em; }

/* ---- barres formation ---- */
.bar-row {
  display: grid; grid-template-columns: minmax(180px, 300px) 1fr 74px;
  gap: .6rem; align-items: center; padding: .22rem .3rem; border-radius: 4px;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  font-size: .8rem; color: #1e1e1e;
}
.bar-row:hover { background: rgba(0,0,145,.05); }
.bar-row.selected { background: rgba(0,0,145,.09); }
.bar-row.dimmed { opacity: .35; }
.bar-name { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.bar-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { position: relative; height: 14px; background: #eef0f4; border-radius: 3px; overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 3px; min-width: 2px; }
.bar-row.sparse .bar-fill { opacity: .45; }
.bar-val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-row.sparse .bar-val { color: #888; font-weight: 500; }

.sna-dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.15); }

/* ---- badges ---- */
.chip {
  display: inline-block; flex: 0 0 auto; padding: 0 .34rem; border-radius: 8px;
  font-size: .62rem; font-weight: 700; line-height: 1.5; vertical-align: middle;
}
.chip-theme { background: #e8edff; color: #000091; border: 1px solid #bcc8ff; }
.chip-sparse { background: #fff0e5; color: #b34000; border: 1px solid #ffd0b0; }
.badge-key { margin-top: .7rem; color: #666; line-height: 1.9; }
.badge-key .chip { margin-right: .25rem; }

/* ===== Carte (lentille tension) ============================================= */
.map-wrap { position: relative; height: 520px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border-default-grey, #ddd); }
#map { position: absolute; inset: 0; background: #eef1f5; }
.lens-grid.compare .map-wrap { height: 560px; }

.map-legend {
  position: absolute; left: 10px; bottom: 10px; z-index: 800;
  background: rgba(255,255,255,.94);
  border: 1px solid var(--border-default-grey, #ddd);
  border-radius: 6px; padding: .55rem .7rem;
  font-size: .74rem; line-height: 1.25; max-width: 240px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.map-legend h3 { font-size: .76rem; margin: 0 0 .35rem; font-weight: 700; }
.legend-grad { height: 12px; border-radius: 2px; margin: .2rem 0; }
.legend-scale-labels { display: flex; justify-content: space-between; color: #555; font-size: .68rem; }
.legend-note { color: #777; font-size: .66rem; margin-top: .3rem; }
.legend-row { display: flex; align-items: center; gap: .4rem; margin: .12rem 0; }
.legend-swatch { width: 15px; height: 11px; border-radius: 2px; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.15); }

.leaflet-tooltip.obs-tip {
  border: 1px solid #ccc; border-left: 4px solid #000091; border-radius: 5px;
  box-shadow: 0 4px 14px rgba(0,0,0,.16); font-size: .78rem; line-height: 1.3;
  padding: .45rem .6rem; max-width: 270px; white-space: normal;
}
.obs-tip .tt-title { font-weight: 700; margin-bottom: .2rem; }
.obs-tip .tt-row { display: flex; justify-content: space-between; gap: 1rem; }
.obs-tip .tt-row span:last-child { font-weight: 600; }
.obs-tip .tt-sub { color: #666; font-size: .7rem; margin-top: .2rem; }
.dom-label { font: 600 10px/1 Marianne, sans-serif; color: #3a3a3a; white-space: nowrap; text-shadow: 0 0 2px #fff, 0 0 2px #fff; }

/* ---- bandeau BMO ---- */
.bmo-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .6rem; margin-top: .8rem;
}
.bmo-strip .stat-tile { background: #fff; }
.bmo-note { grid-column: 1 / -1; color: #777; font-size: .7rem; margin: 0; }

/* ===== Panneau de contrôle (droite) ========================================= */
.ctrl-pane {
  flex: 0 0 372px; max-width: 372px;
  border-left: 1px solid var(--border-default-grey, #ddd);
  background: var(--background-default-grey, #fff);
  overflow: hidden; display: flex;
}
.ctrl-scroll { overflow-y: auto; padding: 1rem 1.25rem 2rem; width: 100%; }

.sna-head { display: flex; justify-content: space-between; align-items: baseline; }
.sna-hint { color: #777; margin: .1rem 0 .5rem; }
.sna-macro { margin-bottom: .55rem; }
.sna-macro-title {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: #444; margin: 0 0 .2rem; display: flex; align-items: center; gap: .35rem;
}
.sna-macro-title .chip { text-transform: none; letter-spacing: 0; }
.sna-macro-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.sna-item {
  display: flex; align-items: center; gap: .4rem; width: 100%;
  border: none; background: none; text-align: left; cursor: pointer;
  padding: .16rem .2rem; border-radius: 4px; font-size: .76rem; color: #1e1e1e;
}
.sna-item:hover { background: rgba(0,0,145,.06); }
.sna-item .sna-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sna-item .sna-count { margin-left: auto; color: #888; font-size: .7rem; font-variant-numeric: tabular-nums; }
.sna-item.inactive { opacity: .32; }
.sna-item.active { background: rgba(0,0,145,.10); }
.sna-item.active .sna-name { font-weight: 600; }

/* ===== Panneau détail SNA =================================================== */
.detail-panel {
  border: 1px solid var(--border-default-grey, #ddd);
  border-radius: 6px; padding: .85rem; margin-top: 1rem;
  background: var(--background-alt-grey, #f6f6f6);
}
.detail-panel h2 { font-size: 1rem; margin: 0 0 .1rem; }
.detail-panel .dp-sub { color: #666; font-size: .78rem; margin: 0 0 .6rem; }
.dp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .9rem; margin-bottom: .5rem; }
.dp-stat .dp-num { font-size: 1.1rem; font-weight: 700; line-height: 1.1; }
.dp-stat .dp-lab { font-size: .68rem; color: #555; text-transform: uppercase; letter-spacing: .02em; }
.dp-close { float: right; }
.dp-types { margin: .4rem 0 0; }
.dp-type-row { display: flex; justify-content: space-between; gap: 1rem; font-size: .74rem; padding: .08rem 0; }
.dp-type-row span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.dp-alert { font-size: .72rem; color: #b34000; margin: .5rem 0 0; }
.dp-cross { font-size: .72rem; color: #555; margin: .5rem 0 0; }

/* ===== Responsive =========================================================== */
@media (max-width: 1200px) {
  .lens-grid.compare { grid-template-columns: 1fr; }
}
@media (max-width: 920px) {
  #content { display: block; }
  .app-shell { flex-direction: column; }
  .ctrl-pane { flex-basis: auto; max-width: none; border-left: none; border-top: 1px solid var(--border-default-grey, #ddd); }
  .map-wrap { height: 62vh; min-height: 380px; }
}

.leaflet-control-attribution { font-size: 10px; }
