        * { margin: 0; padding: 0; box-sizing: border-box; }
        body {
            font-family: "Google Sans Text", "Google Sans", Roboto, Arial, sans-serif;
            font-size: 0.875rem; /* 14px — taille adaptée à ce line-height/letter-spacing */
            font-weight: 400;
            letter-spacing: 0.00625rem;
            line-height: 1.25rem;
            background: var(--bg-body); overflow: hidden;
        }
        #loader {
            border: 6px solid #f3f3f3; border-top: 6px solid #f0625e;
            border-right: 6px solid #f5a25c; border-bottom: 6px solid #8da28c;
            border-radius: 50%; width: 60px; height: 60px;
            animation: spin 1s linear infinite; position: fixed;
            top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 10000;
        }
        .qgis-label {
            background: transparent !important;
            border: none !important;
            box-shadow: none !important;
            font-weight: bold;
            padding: 0 !important;
        }
        @keyframes spin {
            0%   { transform: translate(-50%, -50%) rotate(0deg); }
            100% { transform: translate(-50%, -50%) rotate(360deg); }
        }
        .loading-active #container { visibility: hidden; }
        #container { display: flex; flex-direction: column; width: 100vw; height: 100vh; }
        #header {
            background: var(--header-color); padding: 10px 20px;
            display: flex; justify-content: space-between; align-items: center;
            color: white; box-shadow: 0 2px 15px rgba(0,0,0,0.4); z-index: 1000; min-height: 65px;
        }
        .header-left { display: flex; align-items: center; gap: 15px; }
        .logo-container img { max-height: 45px; max-width: 120px; object-fit: contain; }
        .btn-sidebar-toggle {
            background: rgba(255,255,255,0.12); border: none; color: #fff; cursor: pointer;
            width: 36px; height: 36px; border-radius: 6px; font-size: 18px; flex-shrink: 0;
            display: flex; align-items: center; justify-content: center; transition: background 0.2s;
        }
        .btn-sidebar-toggle:hover { background: rgba(255,255,255,0.25); }
        #main-zone { display: flex; flex-direction: row; flex: 1; min-height: 0; position: relative; }
        #map { flex: 1; height: 100%; }
        #sidebar {
            width: 300px; background: var(--bg-sidebar); order: -1;
            padding: 20px; color: var(--text-main); overflow-y: auto;
            border-right: 1px solid var(--border); box-shadow: 5px 0 20px rgba(0,0,0,0.2);
            transition: width 0.25s ease, padding 0.25s ease, transform 0.25s ease;
        }
        /* Sidebar repliable (desktop) : se réduit à 0 sans démonter le DOM */
        #sidebar.sidebar-hidden {
            width: 0; padding: 20px 0; overflow: hidden; border-right: none; box-shadow: none;
        }
        #sidebar-overlay {
            display: none; position: absolute; inset: 0; background: rgba(0,0,0,0.5);
            z-index: 1400;
        }
        #sidebar-overlay.visible { display: block; }
        h3 { margin-bottom: 15px; font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
              color: var(--accent); border-bottom: 2px solid var(--accent); padding-bottom: 5px; }
        .group-couche { margin-bottom: 18px; background: var(--bg-panel); padding: 10px;
                         border-radius: 6px; border: 1px solid var(--border); }
        .item-couche-tit { display: flex; align-items: center; justify-content: space-between;
            font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text-main); }
        .item-couche-tit-gauche { display: flex; align-items: center; flex: 1; min-width: 0; }
        .item-couche-tit input[type="checkbox"] { margin-right: 8px; accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; flex-shrink: 0; }
        .item-couche-tit label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .btn-collapse {
            background: none; border: none; cursor: pointer; color: var(--text-muted);
            font-size: 12px; padding: 2px 6px; flex-shrink: 0; transition: transform 0.2s, color 0.2s;
            display: flex; align-items: center; justify-content: center;
        }
        .btn-collapse:hover { color: var(--accent); }
        .btn-collapse.is-collapsed { transform: rotate(-90deg); }
        .group-couche-corps {
            overflow: hidden; max-height: 500px; transition: max-height 0.25s ease, opacity 0.2s ease;
            opacity: 1;
        }
        .group-couche-corps.is-collapsed { max-height: 0; opacity: 0; }
        #legende-toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
        .btn-legende-toolbar {
            flex: 1; padding: 5px; border: 1px solid var(--border); border-radius: 5px;
            background: var(--bg-panel); color: var(--text-muted); font-size: 10px;
            cursor: pointer; transition: background 0.2s, color 0.2s;
        }
        .btn-legende-toolbar:hover { background: var(--bg-select); color: var(--accent); }
        .sous-legende-item { display: flex; align-items: center; gap: 8px; padding: 3px 0 3px 22px;
                              font-size: 12px; color: var(--text-muted); }
        .img-legend-icon { width: 16px; height: 16px; object-fit: contain; }
        .legend-poly-swatch {
            display: inline-block;
            width: 14px;
            height: 14px;
            border-radius: 2px;
            border: 1px dashed #e67e22;
            background-color: rgba(230, 126, 34, 0.2);
            flex-shrink: 0;
        }
        .legend-line-swatch {
            display: inline-block; width: 22px; height: 3px;
            border-radius: 2px; background-color: #3388ff; flex-shrink: 0;
        }
        .cluster-toggle-row { display:flex; align-items:center; gap:6px; padding: 4px 0 2px 22px;
            font-size: 10px; color: var(--text-muted); }
        .cluster-toggle-row input { accent-color: var(--accent); cursor: pointer; }
        .leaflet-popup-content-wrapper { background: var(--popup-bg); color: var(--popup-text);
            border: 1px solid var(--border); border-radius: 8px; }
        .leaflet-popup-tip { background: var(--popup-bg); }
        .custom-popup-table { width: 100%; border-collapse: collapse; margin-top: 5px; }
        .custom-popup-table td { padding: 4px 6px; border-bottom: 1px solid var(--border); font-size: 12px; }
        .popup-title { color: var(--accent); font-weight: bold; font-size: 13px;
                        margin-bottom: 6px; border-bottom: 1px solid var(--accent); padding-bottom: 3px; }
        #filtre-panel { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
        #filtre-panel h3 { color: #f9ca24; border-bottom-color: #f9ca24; }
        .filtre-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
        .filtre-row label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.8px; }
        .filtre-select, .filtre-input {
            width: 100%; padding: 6px 8px; border-radius: 5px;
            background: var(--bg-select); color: var(--text-main); border: 1px solid var(--border);
            font-size: 12px; outline: none;
        }
        .filtre-select:focus, .filtre-input:focus { border-color: #f9ca24; }
        .filtre-btns { display: flex; gap: 6px; margin-top: 4px; }
        .btn-filtre {
            flex: 1; padding: 7px; border: none; border-radius: 5px;
            font-size: 12px; font-weight: 600; cursor: pointer; transition: opacity 0.2s;
        }
        .btn-filtre:hover { opacity: 0.85; }
        .btn-appliquer { background: #f9ca24; color: #1a1a2e; }
        .btn-reset     { background: var(--bg-panel); color: var(--text-main); }
        #filtre-resultat { font-size: 11px; color: #f9ca24; margin-top: 5px; min-height: 16px; }
        .filtre-valeurs-liste {
            max-height: 120px; overflow-y: auto; background: var(--bg-select);
            border: 1px solid var(--border); border-radius: 5px; margin-top: 4px;
        }
        .filtre-valeur-item { padding: 4px 8px; font-size: 11px; cursor: pointer; color: var(--text-muted); }
        .filtre-valeur-item:hover { background: rgba(249,202,36,0.2); color: #f9ca24; }
        .leaflet-tooltip.qgis-label {
            background: transparent; border: none; box-shadow: none; font-weight: 600;
            white-space: nowrap; padding: 0;
        }
        /* Surbrillance des entités sélectionnées par le filtre */
        @keyframes pulseSelection {
            0%   { filter: drop-shadow(0 0 2px #f9ca24) drop-shadow(0 0 2px #f9ca24); }
            50%  { filter: drop-shadow(0 0 10px #f9ca24) drop-shadow(0 0 14px #f9ca24); }
            100% { filter: drop-shadow(0 0 2px #f9ca24) drop-shadow(0 0 2px #f9ca24); }
        }
        .entite-filtree-pulse {
            animation: pulseSelection 1.2s ease-in-out infinite;
        }
        .marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
            background: transparent !important;
        }
        .custom-marker-cluster {
            display: flex; align-items: center; justify-content: center;
            border-radius: 50%; color: #fff; font-weight: bold; font-family: Arial, sans-serif;
            font-size: 12px; box-shadow: 0 0 8px rgba(0,0,0,0.35);
        }
        /* ── Sélecteur de fond de carte façon Google Maps (bas-gauche) ── */
        .map-layers-control { position: relative; }
        .map-layers-thumb {
            /* Miniature centrée façon vignette de fond de plan */
            background-repeat: no-repeat !important;
            background-position: center !important;
            background-size: cover !important;
        }
        .map-layers-thumb-plan {
            background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2MCA2MCI+CjxyZWN0IHdpZHRoPSI2MCIgaGVpZ2h0PSI2MCIgZmlsbD0iI2VlZjFlNiIvPgo8cGF0aCBkPSJNMCAyMCBINjAgTTAgNDAgSDYwIiBzdHJva2U9IiNjZGQ2YzAiIHN0cm9rZS13aWR0aD0iMyIvPgo8cGF0aCBkPSJNMTggMCBWNjAgTTQyIDAgVjYwIiBzdHJva2U9IiNjZGQ2YzAiIHN0cm9rZS13aWR0aD0iMyIvPgo8cGF0aCBkPSJNMCAzMSBINjAiIHN0cm9rZT0iI2YyYzE0ZSIgc3Ryb2tlLXdpZHRoPSI0Ii8+CjxwYXRoIGQ9Ik0yOCAwIFY2MCIgc3Ryb2tlPSIjZjJjMTRlIiBzdHJva2Utd2lkdGg9IjQiLz4KPC9zdmc+");
        }
        .map-layers-thumb-sat {
            background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2MCA2MCI+CjxyZWN0IHdpZHRoPSI2MCIgaGVpZ2h0PSI2MCIgZmlsbD0iIzNiNGEyZiIvPgo8Y2lyY2xlIGN4PSIxNCIgY3k9IjE0IiByPSIxMSIgZmlsbD0iIzRmNWYzYSIvPgo8Y2lyY2xlIGN4PSI0NiIgY3k9IjI0IiByPSIxNSIgZmlsbD0iIzJmM2EyNCIvPgo8Y2lyY2xlIGN4PSIxOSIgY3k9IjQ2IiByPSIxMyIgZmlsbD0iIzVhNmI0MCIvPgo8Y2lyY2xlIGN4PSI0OSIgY3k9IjQ5IiByPSI5IiBmaWxsPSIjNDQ1NDMwIi8+Cjwvc3ZnPg==");
        }
        .map-layers-btn {
            width: 48px; height: 48px; border-radius: 4px;
            border: 2px solid #fff; cursor: pointer; user-select: none;
            box-shadow: 0 1px 4px rgba(0,0,0,0.4);
            transition: box-shadow 0.15s ease;
        }
        .map-layers-btn:hover { box-shadow: 0 1px 8px rgba(0,0,0,0.55); }
        .map-layers-panel {
            display: none; position: absolute; bottom: calc(100% + 8px); left: 0;
            background: var(--bg-select); border: 1px solid var(--border);
            border-radius: 8px; box-shadow: 0 2px 14px rgba(0,0,0,0.4);
            padding: 6px; min-width: 190px;
        }
        .map-layers-panel.open { display: block; }
        .map-layers-option {
            display: flex; align-items: center; gap: 8px; padding: 6px 8px;
            border-radius: 6px; cursor: pointer; font-size: 12px;
            color: var(--text-main); white-space: nowrap; transition: background 0.15s;
        }
        .map-layers-option:hover { background: var(--bg-panel); }
        .map-layers-option.active { background: var(--accent); color: #fff; }
        .map-layers-opt-icon.map-layers-thumb {
            width: 28px; height: 28px; border-radius: 4px; flex-shrink: 0;
            border: 1px solid rgba(0,0,0,0.15);
        }
        .icon-map, .icon-sat { font-size: 13px; }

        /* ── Outil de mesure de distance (règle) ─────────────────────── */
        .map-measure-btn {
            display: block; width: 30px; height: 30px; line-height: 30px;
            text-align: center; font-size: 16px; text-decoration: none;
            background: var(--bg-select); color: var(--text-main);
        }
        .map-measure-btn.active { background: var(--accent) !important; }
        .map-measure-tooltip {
            background: rgba(26,26,46,0.85); color: #fff; border: none;
            font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 4px;
            box-shadow: 0 1px 4px rgba(0,0,0,0.3);
        }
        .map-measure-tooltip::before { display: none; }

        /* ── Responsive : tablette / mobile ──────────────────────────── */
        @media (max-width: 768px) {
            #header { padding: 8px 12px; min-height: 52px; flex-wrap: wrap; gap: 8px; }
            #header h2 { font-size: 15px; }
            .logo-container img { max-height: 30px; max-width: 80px; }
            .map-layers-btn { width: 40px; height: 40px; }

            #sidebar {
                position: absolute; top: 0; left: 0; height: 100%;
                width: 86vw; max-width: 340px; max-height: none;
                transform: translateX(-100%); z-index: 1500;
                box-shadow: 8px 0 30px rgba(0,0,0,0.5);
            }
            #sidebar.sidebar-open { transform: translateX(0); }
            #sidebar.sidebar-hidden { width: 86vw; max-width: 340px; padding: 20px; }

            .filtre-btns { flex-direction: column; }
        }

        @media (max-width: 420px) {
            #header h2 { display: none; }
        }

        @media print {
            body, html { margin:0 !important; padding:0 !important; width:100% !important; height:100% !important;
                -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
            #loader, #sidebar, #sidebar-overlay, .leaflet-control-container { display: none !important; }
            #header { display: none !important; }
            #main-zone { display:block !important; width:100% !important; height:100% !important; }
            #map { position:absolute !important; top:0 !important; left:0 !important;
                width:100vw !important; height:100vh !important; visibility:visible !important; }
        }
        .leaflet-tooltip.qgis-label {
            background: transparent !important;
            border: none !important;
            box-shadow: none !important;
            font-size: 11px !important;
            /* Taille d'étiquette idéale sur le Web */
            font-weight: 600;
            line-height: 1.1;
            padding: 0 !important;
            white-space: nowrap;
            pointer-events: none;
            /* Empêche l'étiquette d'interférer avec les clics */
        }

/* Thème sombre : Si la page ou le body utilise un thème sombre, 
   on passe les cartes de couches (.group-couche) en fond sombre */
[data-theme="dark"] .group-couche,
body.dark-theme .group-couche,
body.dark-mode .group-couche {
    background: #252a38 !important; /* Fond sombre ajusté */
    border-color: #383e50 !important;
}

[data-theme="dark"] .item-couche-tit,
body.dark-theme .item-couche-tit,
body.dark-mode .item-couche-tit {
    color: #ffffff !important; /* Titre de la couche en blanc */
}

[data-theme="dark"] .sous-legende-item,
[data-theme="dark"] .cluster-toggle-row,
body.dark-theme .sous-legende-item,
body.dark-mode .sous-legende-item {
    color: #cbd5e1 !important; /* Sous-catégories et textes secondaires en gris très clair */
}


.group-couche {
    color: var(--text-main);
}

.item-couche-tit label {
    color: inherit;
}

[data-theme="dark"] .group-couche,
body.dark-theme .group-couche,
body.dark-mode .group-couche {
    background: #252a38 !important; /* Fond sombre ajusté */
    border-color: #383e50 !important;
}

[data-theme="dark"] .item-couche-tit,
body.dark-theme .item-couche-tit,
body.dark-mode .item-couche-tit {
    color: #ffffff !important; /* Titre de la couche en blanc */
}

[data-theme="dark"] .sous-legende-item,
[data-theme="dark"] .cluster-toggle-row,
body.dark-theme .sous-legende-item,
body.dark-mode .sous-legende-item {
    color: #cbd5e1 !important; /* Sous-catégories et textes secondaires en gris très clair */
}


.group-couche {
    color: var(--text-main);
}

.item-couche-tit label {
    color: inherit;
}




.group-couche {
    background-color: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
}

.item-couche-tit,
.item-couche-tit label,
.item-couche-tit-gauche {
    color: #0f172a !important;
    /* Noir / bleu nuit très foncé */
}

.sous-legende-item {
    color: #334155 !important;
}


.cluster-toggle-row {
    color: #475569 !important;
}

.btn-legende-toolbar {
    color: #334155 !important;
    background-color: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
}

.btn-legende-toolbar:hover {
    color: var(--accent) !important;
    background-color: #f1f5f9 !important;
}

/* ── Table attributaire (fenêtre flottante) ───────────────── */
.btn-table {
    background: white; border: none; cursor: pointer; color: var(--text-muted);
    padding: 2px 5px; margin-right: 4px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; transition: color 0.2s;
}
.btn-table:hover:not(:disabled) { color: var(--accent); }
.btn-table:disabled { opacity: 0.35; cursor: default; }

.attr-win {
    position: fixed; width: 640px; height: 420px; min-width: 280px; min-height: 200px;
    max-width: 96vw; max-height: 92vh; resize: both; overflow: hidden;
    display: flex; flex-direction: column;
    background: #ffffff; color: #222222;
    border: 1px solid var(--border, #ccc); border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.35); font-size: 12px;
}
.attr-win-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 7px 10px; cursor: move; touch-action: none; user-select: none;
    background: var(--header-color, #34495e); color: #fff; font-weight: 600;
}
.attr-win-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attr-win-close {
    background: none; border: none; color: #fff; font-size: 20px; line-height: 1;
    cursor: pointer; padding: 0 4px;
}
.attr-win-close:hover { color: #ffeb3b; }
.attr-win-info { padding: 6px 10px; font-size: 11px; color: var(--text-muted, #666); }
.attr-win-tools { display: flex; align-items: center; gap: 8px; padding: 0 10px 8px; flex-wrap: wrap; }
.attr-btn {
    padding: 4px 10px; border: 1px solid var(--border, #ccc); border-radius: 4px; cursor: pointer;
    background: var(--bg-select, #f3f3f3); color: var(--text-main, #222); font-size: 12px;
}
.attr-btn:hover:not(:disabled) { color: var(--accent, #2980b9); border-color: var(--accent, #2980b9); }
.attr-btn:disabled { opacity: 0.4; cursor: default; }
.attr-search {
    flex: 1; min-width: 120px; padding: 4px 8px; border-radius: 4px; font-size: 12px;
    border: 1px solid var(--border, #ccc); background: var(--bg-select, #fff); color: var(--text-main, #222);
}
.attr-count { font-size: 11px; color: var(--text-muted, #666); white-space: nowrap; }
.attr-win-scroll { flex: 1; min-height: 0; overflow: auto; border-top: 1px solid var(--border, #ccc); }
.attr-table { border-collapse: collapse; width: max-content; min-width: 100%; }
.attr-table th, .attr-table td {
    padding: 4px 8px; text-align: left; border: 1px solid var(--border, #ddd);
    white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis;
}
.attr-table thead th {
    position: sticky; top: 0; z-index: 2; cursor: pointer;
    background: #eeeeee; color: #222222;
}
.attr-table thead tr:nth-child(2) th { top: 27px; cursor: default; padding: 3px; }
.attr-filter-cell input {
    width: 100%; min-width: 70px; box-sizing: border-box; padding: 2px 5px; font-size: 11px;
    border: 1px solid var(--border, #ccc); border-radius: 3px;
    background: var(--bg-panel, #fff); color: var(--text-main, #222);
}
.attr-table tbody tr:nth-child(even) { background: rgba(127,127,127,0.08); }
.attr-table tbody tr:hover { background: rgba(255,235,59,0.35); cursor: pointer; }
.attr-table tbody tr.attr-selected { background: rgba(41,128,185,0.28); }
.attr-empty { text-align: center; padding: 14px; color: var(--text-muted, #666); }
.attr-win-pager {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 6px 10px; border-top: 1px solid var(--border, #ccc); font-size: 11px;
}
@media (max-width: 700px) {
    .attr-win { left: 2vw !important; top: 8vh !important; width: 96vw; height: 70vh; resize: none; }
}
