* { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: 'Poppins', system-ui, -apple-system, sans-serif; color: #1e293b; }

        #map { width: 100%; height: 100vh; }

        /* ── HEADER ── */
        .header-bar {
            position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
            background: #043a34;
            color: white; padding: 10px 24px; min-height: 62px;
            display: flex; align-items: center; justify-content: space-between;
            box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
        }
        .brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
        .brand-mark {
            width: 42px; height: 42px; display: grid; place-items: center;
            color: #ffffff; background: #05665f; border-radius: 8px;
            font-weight: 800; flex: 0 0 auto; padding: 5px;
        }
        .brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
        .header-bar h1 { font-size: 1.08rem; font-weight: 700; letter-spacing: -0.01em; }
        .header-bar .subtitle { font-size: 0.78rem; color: #94a3b8; margin-top: 2px; font-weight: 400; }
        .header-right { display: flex; align-items: center; gap: 14px; }
        .header-actions { display: flex; gap: 8px; }
        .header-btn {
            display: flex; align-items: center; justify-content: center; gap: 5px;
            min-height: 38px;
            background: rgba(255,255,255,0.08); color: white;
            border: 1px solid rgba(255,255,255,0.18); border-radius: 8px;
            padding: 9px 14px; font-size: 0.82rem; font-weight: 700;
            cursor: pointer; font-family: inherit; white-space: nowrap;
            transition: background 0.15s;
            text-decoration: none;
        }
        .header-btn:hover { background: rgba(255,255,255,0.18); }
        .header-btn-dashboard { background: #cfae1f; border-color: #cfae1f; color: #043a34; }
        .header-btn-dashboard:hover { background: #b89718; border-color: #b89718; }
        .header-btn-add { background: #004d40; border-color: #004d40; }
        .header-btn-add:hover { background: #00695c; border-color: #00695c; }
        .header-stats { display: flex; gap: 8px; font-size: 0.75rem; }
        .header-stats .stat {
            background: rgba(255,255,255,0.08); padding: 5px 14px;
            border-radius: 9999px; white-space: nowrap; font-weight: 500;
            border: 1px solid rgba(255,255,255,0.1);
            backdrop-filter: blur(4px);
        }

        /* ── LEGEND ── */
        .legend {
            position: fixed; bottom: 24px; left: 16px; z-index: 1000;
            background: white; border-radius: 12px; padding: 16px 18px;
            box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
            border: 1px solid #e2e8f0; min-width: 230px;
        }
        .legend h3 {
            font-size: 0.65rem; margin-bottom: 12px; color: #94a3b8;
            text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
        }
        .legend-item {
            display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
            cursor: pointer; padding: 4px 6px; border-radius: 8px;
            transition: background 0.15s ease;
        }
        .legend-item:hover { background: #f8fafc; }
        .legend-dot {
            width: 12px; height: 12px; border-radius: 50%;
            flex-shrink: 0;
            box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
        }
        .legend-label { font-size: 0.8rem; color: #334155; font-weight: 500; }
        .legend-count {
            font-size: 0.68rem; color: #94a3b8; margin-left: auto;
            background: #f1f5f9; padding: 2px 8px; border-radius: 9999px; font-weight: 600;
        }

        /* ── FILTER PANEL ── */
        .filter-panel {
            position: fixed; top: 78px; right: 16px; z-index: 1000;
            background: white; border-radius: 12px; padding: 0;
            box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
            border: 1px solid #e2e8f0; width: 300px;
            overflow: hidden; transition: width 0.2s ease;
        }
        .filter-toggle {
            display: flex; align-items: center; justify-content: space-between;
            padding: 10px 16px; cursor: pointer; user-select: none;
            background: #f8fafc; border-bottom: 1px solid #e2e8f0;
        }
        .filter-toggle:hover { background: #f1f5f9; }
        .filter-toggle-title {
            font-size: 0.75rem; font-weight: 700; color: #334155;
            text-transform: uppercase; letter-spacing: 0.04em;
        }
        .filter-toggle-icon {
            font-size: 1rem; color: #94a3b8; transition: transform 0.2s ease;
            line-height: 1;
        }
        .filter-panel.collapsed .filter-toggle-icon { transform: rotate(180deg); }
        .filter-body {
            padding: 16px; transition: max-height 0.25s ease, opacity 0.2s ease;
            max-height: 500px; opacity: 1; overflow: hidden;
        }
        .filter-panel.collapsed .filter-body {
            max-height: 0; opacity: 0; padding: 0 16px;
        }
        .filter-panel label {
            display: block; font-size: 0.65rem; font-weight: 600;
            color: #94a3b8; text-transform: uppercase; letter-spacing: 0.06em;
            margin-bottom: 6px;
        }
        .filter-panel select {
            width: 100%; padding: 9px 12px; border: 1px solid #e2e8f0;
            border-radius: 8px; font-size: 0.85rem; outline: none;
            background: #f8fafc; cursor: pointer; margin-bottom: 12px;
            appearance: auto; font-family: inherit; color: #334155;
            transition: border-color 0.15s ease, box-shadow 0.15s ease;
        }
        .filter-panel select:focus {
            border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
        }
        .filter-panel input {
            width: 100%; padding: 9px 12px; border: 1px solid #e2e8f0;
            border-radius: 8px; font-size: 0.85rem; outline: none;
            background: #f8fafc; font-family: inherit; color: #334155;
            transition: border-color 0.15s ease, box-shadow 0.15s ease;
        }
        .filter-panel input:focus {
            border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
            background: white;
        }
        .filter-panel input::placeholder { color: #94a3b8; }
        .filter-active-tag {
            display: inline-flex; align-items: center; gap: 6px;
            background: #eef2ff; color: #4338ca; padding: 4px 12px;
            border-radius: 9999px; font-size: 0.75rem; font-weight: 600;
            margin-top: 8px; cursor: pointer;
            border: 1px solid #c7d2fe;
            transition: background 0.15s ease;
        }
        .filter-active-tag:hover { background: #e0e7ff; }
        .filter-count {
            font-size: 0.75rem; color: #64748b; margin-top: 8px;
            text-align: center; font-weight: 500;
        }
        .filter-divider {
            height: 1px; background: #e2e8f0; margin: 12px 0;
        }
        .search-results {
            max-height: 280px; overflow-y: auto; margin-top: 10px;
        }
        .search-results::-webkit-scrollbar { width: 4px; }
        .search-results::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
        .search-result-item {
            padding: 10px 8px; border-radius: 8px; cursor: pointer;
            font-size: 0.82rem; border-bottom: 1px solid #f1f5f9;
            transition: background 0.12s ease;
        }
        .search-result-item:last-child { border-bottom: none; }
        .search-result-item:hover { background: #f8fafc; }
        .search-result-item .sr-name { font-weight: 600; color: #1e293b; }
        .search-result-item .sr-info { color: #94a3b8; font-size: 0.72rem; margin-top: 3px; }

        /* ── POPUP ── */
        .leaflet-popup-content-wrapper {
            border-radius: 12px !important;
            box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1) !important;
            border: 1px solid #e2e8f0 !important;
            overflow: hidden;
        }
        .leaflet-popup-content { margin: 0 !important; width: 300px !important; }
        .popup-card { padding: 0; }
        .popup-header {
            padding: 14px 16px; color: white; position: relative;
        }
        .popup-header .popup-type {
            font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.1em;
            opacity: 0.85; margin-bottom: 4px; font-weight: 600;
        }
        .popup-header .popup-name { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
        .popup-header .popup-zone {
            font-size: 0.72rem; opacity: 0.8; margin-top: 3px; font-weight: 400;
        }
        .popup-body { padding: 14px 16px; }
        .popup-row {
            display: flex; gap: 8px; margin-bottom: 10px;
            font-size: 0.8rem; align-items: flex-start;
        }
        .popup-row .icon { flex-shrink: 0; width: 18px; text-align: center; font-size: 0.82rem; }
        .popup-row .label { color: #94a3b8; min-width: 68px; flex-shrink: 0; font-size: 0.72rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.03em; }
        .popup-row .value { color: #334155; font-weight: 500; font-size: 0.8rem; }
        .popup-row a { color: #4338ca; text-decoration: none; font-weight: 600; }
        .popup-row a:hover { text-decoration: underline; }
        .popup-badge {
            display: inline-block; padding: 3px 10px; border-radius: 9999px;
            font-size: 0.68rem; font-weight: 600;
        }
        .popup-obs {
            margin-top: 10px; padding: 10px 12px; background: #fffbeb;
            border-left: 3px solid #f59e0b; border-radius: 0 8px 8px 0;
            font-size: 0.75rem; color: #92400e; font-weight: 500;
        }
        .popup-approx {
            margin-top: 8px; padding: 8px 12px; background: #eef7f5;
            border-left: 3px solid #05665f; border-radius: 0 8px 8px 0;
            font-size: 0.72rem; color: #04524c; font-weight: 500;
        }

        /* ── LIEN PARENT → FILLE (tooltip) ── */
        .line-tooltip {
            background: white; border: 1px solid #e2e8f0;
            border-radius: 8px; padding: 5px 10px;
            font-size: 0.75rem; font-weight: 600; color: #334155;
            box-shadow: 0 2px 8px rgba(0,0,0,0.12);
            white-space: nowrap;
        }
        .line-tooltip::before { display: none; }

        .bg-ah { background: linear-gradient(135deg, #00695c, #004d40); }
        .bg-mh { background: linear-gradient(135deg, #8B4513, #6d3410); }
        .bg-ch { background: linear-gradient(135deg, #e67e22, #d35400); }
        .bg-gem { background: linear-gradient(135deg, #9e9e9e, #757575); }

        /* ── MODALS BASE ── */
        .modal-overlay {
            position: fixed; inset: 0; z-index: 2000;
            background: rgba(15,23,42,0.45); backdrop-filter: blur(3px);
            display: none; align-items: stretch; justify-content: flex-end;
        }
        .modal-overlay.open { display: flex; }
        .modal-center-overlay { justify-content: center; align-items: center; }
        .modal-head {
            display: flex; align-items: center; justify-content: space-between;
            padding: 14px 20px; border-bottom: 1px solid #e2e8f0; background: #f8fafc;
            flex-shrink: 0;
        }
        .modal-head span { font-size: 0.82rem; font-weight: 700; color: #0f172a; text-transform: uppercase; letter-spacing: 0.05em; }
        .modal-close-btn {
            background: none; border: none; cursor: pointer;
            font-size: 1rem; color: #94a3b8; width: 28px; height: 28px;
            display: flex; align-items: center; justify-content: center;
            border-radius: 6px; transition: background 0.12s;
        }
        .modal-close-btn:hover { background: #f1f5f9; color: #334155; }

        /* ── DRAWER (liste) ── */
        .modal-drawer {
            width: 420px; max-width: 100vw; background: white;
            display: flex; flex-direction: column;
            box-shadow: -4px 0 24px rgba(0,0,0,0.15);
            animation: slideInRight 0.22s ease;
        }
        @keyframes slideInRight {
            from { transform: translateX(100%); }
            to   { transform: translateX(0); }
        }
        .modal-drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
        .modal-drawer-body::-webkit-scrollbar { width: 4px; }
        .modal-drawer-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

        .list-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
        .list-tab {
            padding: 5px 14px; border: 1px solid #e2e8f0; border-radius: 9999px;
            background: white; font-size: 0.72rem; font-weight: 600; color: #64748b;
            cursor: pointer; font-family: inherit; transition: all 0.12s;
        }
        .list-tab:hover { background: #f1f5f9; }
        .list-tab.active { background: #0f172a; color: white; border-color: #0f172a; }
        .list-search {
            width: 100%; padding: 8px 12px; border: 1px solid #e2e8f0;
            border-radius: 8px; font-size: 0.82rem; outline: none;
            background: #f8fafc; font-family: inherit; margin-bottom: 12px;
            box-sizing: border-box; color: #334155;
        }
        .list-search:focus { border-color: #6366f1; background: white; }
        .entity-row {
            display: flex; align-items: center; gap: 10px;
            padding: 10px 8px; border-radius: 8px; cursor: pointer;
            border-bottom: 1px solid #f1f5f9; transition: background 0.12s;
        }
        .entity-row:hover { background: #f8fafc; }
        .entity-row:last-child { border-bottom: none; }
        .entity-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
        .entity-info { flex: 1; min-width: 0; }
        .entity-name { font-size: 0.82rem; font-weight: 600; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
        .entity-meta { font-size: 0.7rem; color: #94a3b8; margin-top: 2px; }
        .entity-type-badge {
            font-size: 0.6rem; font-weight: 700; padding: 2px 7px;
            border-radius: 5px; background: #f1f5f9; color: #64748b; flex-shrink: 0;
        }
        .list-empty { text-align: center; color: #94a3b8; font-size: 0.8rem; padding: 30px 0; }

        /* ── MODAL CENTRÉ (ajout) ── */
        .modal-center {
            background: white; border-radius: 16px;
            width: 580px; max-width: calc(100vw - 32px);
            max-height: calc(100vh - 60px);
            display: flex; flex-direction: column;
            box-shadow: 0 20px 60px rgba(0,0,0,0.2);
            animation: popIn 0.2s ease;
        }
        @keyframes popIn {
            from { transform: scale(0.95); opacity: 0; }
            to   { transform: scale(1); opacity: 1; }
        }
        .modal-center-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
        .modal-center-body::-webkit-scrollbar { width: 4px; }
        .modal-center-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

        .form-row { display: flex; gap: 12px; }
        .form-row .form-group { flex: 1; }
        .form-group { margin-bottom: 14px; }
        .form-group label { display: block; font-size: 0.63rem; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 5px; }
        .form-group input, .form-group select, .form-group textarea {
            width: 100%; padding: 8px 10px; border: 1px solid #e2e8f0;
            border-radius: 8px; font-size: 0.82rem; font-family: inherit;
            outline: none; background: #f8fafc; color: #334155;
            transition: border-color 0.15s, box-shadow 0.15s; box-sizing: border-box;
        }
        .form-group input:focus, .form-group select:focus, .form-group textarea:focus {
            border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.15); background: white;
        }
        .form-group textarea { resize: vertical; }
        .form-geo { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
        .form-geo button {
            padding: 7px 14px; background: #eef7f5; color: #05665f;
            border: 1px solid #bcded9; border-radius: 8px; font-size: 0.76rem;
            font-weight: 600; cursor: pointer; font-family: inherit; white-space: nowrap;
            transition: background 0.12s;
        }
        .form-geo button:hover { background: #dcefec; }
        #geoStatus { font-size: 0.73rem; color: #64748b; }
        .form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 10px; }
        .btn-cancel {
            padding: 8px 18px; border: 1px solid #e2e8f0; border-radius: 8px;
            background: white; font-size: 0.8rem; font-weight: 600; color: #64748b;
            cursor: pointer; font-family: inherit; transition: background 0.12s;
        }
        .btn-cancel:hover { background: #f8fafc; }
        .btn-submit {
            padding: 8px 20px; background: #004d40; color: white;
            border: none; border-radius: 8px; font-size: 0.8rem;
            font-weight: 600; cursor: pointer; font-family: inherit; transition: background 0.12s;
        }
        .btn-submit:hover { background: #00695c; }
        .btn-copy {
            padding: 8px 18px; background: #f1f5f9; border: 1px solid #e2e8f0;
            border-radius: 8px; font-size: 0.8rem; font-weight: 600; color: #334155;
            cursor: pointer; font-family: inherit; transition: background 0.12s;
        }
        .btn-copy:hover { background: #e2e8f0; }
        #addFormMsg { font-size: 0.76rem; color: #dc2626; margin-bottom: 8px; min-height: 18px; }
        .success-msg { font-size: 0.9rem; font-weight: 700; color: #065f46; margin-bottom: 8px; }
        .success-hint { font-size: 0.78rem; color: #64748b; margin-bottom: 10px; }
        #addCodeOutput {
            background: #0f172a; color: #e2e8f0; padding: 12px 14px;
            border-radius: 8px; font-size: 0.68rem; overflow-x: auto;
            white-space: pre; margin-bottom: 12px; line-height: 1.6;
            font-family: 'Courier New', monospace;
        }

        @media (max-width: 600px) {
            .header-bar { flex-direction: column; gap: 6px; padding: 8px 16px; height: auto; }
            .header-right { flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
            .filter-panel { width: calc(100% - 32px); right: 16px; top: auto; bottom: 16px; }
            .legend { bottom: auto; top: 78px; left: 16px; }
            .modal-drawer { width: 100vw; }
            .form-row { flex-direction: column; gap: 0; }
        }
