.map_loader {
    position: absolute;
    inset: 0;
    z-index: 20;
    background: hsl(var(--background));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity .35s;
}
.map_loader.hiding { opacity: 0; pointer-events: none; }

.carte_layout {
    position: fixed;
    top: 0; left: var(--sidebar-w); right: 0; bottom: 0;
    overflow: hidden;
}
#map { width: 100%; height: 100%; }
body { overflow: hidden; }

.filter_toggle {
    position: absolute;
    top: 1rem;
    left: 3rem;
    z-index: 10;
    white-space: nowrap;
}
.filter_toggle.active { background: hsl(var(--primary)) !important; color: hsl(var(--primary-foreground)) !important; border-color: hsl(var(--primary)) !important; }
.filter_toggle.active svg { stroke: hsl(var(--primary-foreground)); }
.filter_active_dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: hsl(var(--destructive));
    margin-left: .1rem;
    vertical-align: middle;
}

.filter_panel {
    position: absolute;
    top: 3.4rem;
    left: 3rem;
    width: 272px;
    z-index: 10;
    display: none;
    overflow: hidden;
}
.filter_panel.open { display: block; }
.filter_section { padding: .65rem 1rem; border-bottom: 1px solid hsl(var(--border)); }
.filter_section:last-of-type { border-bottom: none; }
.filter_section_label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: hsl(var(--muted-foreground));
    margin-bottom: .45rem;
}

.filter_chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.fchip { display: flex; align-items: center; cursor: pointer; }
.fchip input { display: none; }
.fchip span {
    padding: .25rem .6rem;
    border: 1px solid hsl(var(--border));
    border-radius: .25rem;
    font-size: .8rem;
    color: hsl(var(--muted-foreground));
    transition: all .1s;
    user-select: none;
}
.fchip:hover span { border-color: hsl(var(--primary)); color: hsl(var(--primary)); }
.fchip input:checked + span { background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }

.fpreset.active,
.fpreset.active:hover { background: hsl(var(--primary)) !important; border-color: hsl(var(--primary)) !important; color: hsl(var(--primary-foreground)) !important; }

.carte_legend {
    position: absolute;
    bottom: 1.5rem;
    right: 1rem;
    z-index: 10;
    min-width: 200px;
}
.legend_dot      { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend_dot_high { background: #16a34a; }
.legend_dot_med  { background: #d97706; }
.legend_dot_low  { background: #dc2626; }
.legend_dot_none { background: #9ca3af; }

.carte_loader_msg           { margin-top: .9rem; }
.filter_toggle_icon         { margin-right: .3rem; }
.filter_panel_header        { border-bottom: 1px solid var(--s200); background: var(--s50); }
.filter_panel_footer        { border-top: 1px solid var(--s200); background: var(--s50); }
.filter_section_label_notop { margin-top: 0; }
.filter_count_num           { color: var(--s900); }
.carte_input_sm             { width: 80px; }
.legend_rows                { margin-bottom: .4rem; }

.maplibregl-popup-content {
    padding: 0;
    border-radius: .5rem;
    font-size: .84rem;
    line-height: 1.4;
    box-shadow: 0 4px 16px hsl(var(--foreground) / .15);
    overflow: hidden;
    min-width: 210px;
}
button.maplibregl-popup-close-button {
    top: .45rem;
    right: .45rem;
    font-size: .95rem;
    line-height: 1;
    color: hsl(var(--muted-foreground));
    background: hsl(var(--muted));
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
button.maplibregl-popup-close-button:hover { background: hsl(var(--border)); color: hsl(var(--foreground)); }

.popup_header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    padding: .6rem .9rem .5rem;
    padding-right: 2rem;
    border-bottom: 1px solid hsl(var(--border));
}
.popup_nom  { font-weight: 700; font-size: .9rem; line-height: 1.25; }
.popup_dept { font-weight: 400; color: hsl(var(--muted-foreground)); }

.popup_score_badge {
    flex-shrink: 0;
    font-size: .76rem;
    font-weight: 700;
    padding: .18rem .42rem;
    border-radius: .25rem;
    color: #fff;
}
.popup_score_high { background: #16a34a; }
.popup_score_med  { background: #d97706; }
.popup_score_low  { background: #dc2626; }
.popup_score_none { background: #9ca3af; }

.popup_rows { padding: .45rem .9rem; display: flex; flex-direction: column; gap: .28rem; }
.popup_row  { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.popup_lbl  { font-size: .78rem; color: hsl(var(--muted-foreground)); flex-shrink: 0; min-width: 58px; }
.popup_val  { font-weight: 600; font-size: .82rem; }
.popup_vs   { font-size: .76rem; color: hsl(var(--muted-foreground)); }
.popup_pos  { color: #16a34a; }
.popup_neg  { color: #dc2626; }

.popup_fiab_badge {
    font-size: .73rem;
    font-weight: 600;
    padding: .1rem .38rem;
    border-radius: .25rem;
}
.popup_fiab_haute { background: hsl(142 76% 36% / .12); color: #16a34a; }
.popup_fiab_moy   { background: hsl(38 92% 50% / .12);  color: #d97706; }
.popup_fiab_low   { background: hsl(0 72% 51% / .12);   color: #dc2626; }

.popup_link {
    display: block;
    padding: .45rem .9rem;
    border-top: 1px solid hsl(var(--border));
    color: hsl(var(--primary)) !important;
    font-size: .81rem;
    font-weight: 500;
    text-decoration: none;
    margin: 0 !important;
    transition: background .1s;
}
.popup_link:hover { background: hsl(var(--muted)); }

@media (max-width: 959px) {
    .carte_layout { top: 48px; }
    .filter_toggle { left: auto; right: .75rem; top: .75rem; }
    .filter_panel { left: auto; right: .75rem; top: 3rem; width: calc(100vw - 1.5rem); max-width: 340px; }
    .carte_legend { left: .5rem; right: .5rem; bottom: .5rem; min-width: auto; padding: .4rem .65rem !important; }
    .legend_rows { flex-direction: row; flex-wrap: wrap; gap: .15rem .75rem; }
    .carte_legend .filter_section_label { font-size: .62rem; margin-bottom: .25rem; }
    .carte_legend .uk-text-small { font-size: .72rem; }
    .carte_legend > .uk-text-muted { display: none; }
}
