
 
            /* ==========================================================================
           RESET & GLOBALS
           ========================================================================== */
            *,
            *::before,
            *::after {
                box-sizing: border-box;
                margin: 0;
                padding: 0;
            }

            html,
            body {
                height: 100%;
                width: 100%;
                font-family:
                    system-ui,
                    -apple-system,
                    BlinkMacSystemFont,
                    "Segoe UI",
                    Roboto,
                    Oxygen,
                    Ubuntu,
                    Cantarell,
                    "Open Sans",
                    "Helvetica Neue",
                    sans-serif;
                background-color: #020617;
                color: #f1f5f9;
                overflow: hidden;
                user-select: none;
                -webkit-font-smoothing: antialiased;
            }

            body {
                display: flex;
                flex-direction: column;
            }

            /* ==========================================================================
           SCROLLBAR CUSTOMIZATION
           ========================================================================== */
            ::-webkit-scrollbar {
                width: 6px;
                height: 6px;
            }
            ::-webkit-scrollbar-track {
                background: #090d16;
            }
            ::-webkit-scrollbar-thumb {
                background: #1e293b;
                border-radius: 3px;
            }
            ::-webkit-scrollbar-thumb:hover {
                background: #334155;
            }

            /* ==========================================================================
           HEADER
           ========================================================================== */
            .app-header {
                background-color: rgba(15, 23, 42, 0.9);
                backdrop-filter: blur(8px);
                border-bottom: 1px solid #1e293b;
                padding: 5px 5px;
                display: flex;
                align-items: center;
                justify-content: space-between;
                z-index: 20;
                flex-shrink: 0;
            }

            .header-title-container {
                display: flex;
                align-items: center;
                gap: 12px;
            }

            .header-actions {
                display: flex;
                align-items: center;
                gap: 8px;
            }

            .btn-mobile-toggle {
                display: none;
                background-color: #1e293b;
                border: 1px solid #334155;
                color: #e2e8f0;
                padding: 8px;
                border-radius: 12px;
                cursor: pointer;
                transition: background-color 0.2s ease;
            }
            .btn-mobile-toggle:hover {
                background-color: #334155;
            }

            /* ==========================================================================
           LAYOUT & SIDEBAR
           ========================================================================== */
            .app-layout {
                flex: 1;
                display: flex;
                position: relative;
                overflow: hidden;
                height: calc(100% - 60px);
            }

            .sidebar {
                position: absolute;
                top: 0;
                bottom: 0;
                left: 0;
                z-index: 10;
                width: 320px;
                height: 100%;
                background-color: rgba(15, 23, 42, 0.95);
                backdrop-filter: blur(8px);
                border-right: 1px solid #1e293b;
                display: flex;
                flex-direction: column;
                transition: transform 0.3s ease-in-out;
                transform: translateX(-100%);
                box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
            }

            .sidebar.open,
            .sidebar:not(.-translate-x-full) {
                transform: translateX(0);
            }

            .sidebar-inner {
                padding: 16px;
                display: flex;
                flex-direction: column;
                gap: 16px;
                overflow-y: auto;
                flex: 1;
            }

            /* ==========================================================================
           CARDS & SECTIONS
           ========================================================================== */
            .card {
                background-color: rgba(2, 6, 23, 0.6);
                border: 1px solid #1e293b;
                padding: 14px;
                border-radius: 12px;
                display: flex;
                flex-direction: column;
                gap: 12px;
            }

            .card-primary {
                background-color: rgba(2, 6, 23, 0.8);
                border: 1px solid rgba(14, 165, 233, 0.3);
                padding: 14px;
                border-radius: 12px;
                display: flex;
                flex-direction: column;
                gap: 12px;
                outline: 1px solid rgba(14, 165, 233, 0.2);
            }

            .card-header {
                display: flex;
                align-items: center;
                justify-content: space-between;
                border-bottom: 1px solid #1e293b;
                padding-bottom: 8px;
            }

            .card-title {
                font-size: 12px;
                font-weight: 700;
                text-transform: uppercase;
                letter-spacing: 0.05em;
                display: flex;
                align-items: center;
                gap: 8px;
                color: #0ea5e9;
            }

            .icon-badge {
                background-color: rgba(245, 158, 11, 0.2);
                color: #fcd34d;
                font-size: 10px;
                width: 20px;
                height: 20px;
                border-radius: 50%;
                display: inline-flex;
                align-items: center;
                justify-content: center;
                font-weight: 800;
                border: 1px solid rgba(245, 158, 11, 0.4);
            }

            .badge-info {
                font-size: 10px;
                color: #64748b;
                font-family: monospace;
            }

            /* ==========================================================================
           FORM CONTROLS & INPUTS
           ========================================================================== */
            .form-group {
                display: flex;
                flex-direction: column;
                gap: 4px;
            }

            .form-label {
                font-size: 11px;
                font-weight: 600;
                color: #cbd5e1;
                display: flex;
                align-items: center;
                gap: 6px;
            }

            .select-input {
                width: 100%;
                background-color: #0f172a;
                border: 1px solid #334155;
                color: #e2e8f0;
                border-radius: 8px;
                padding: 8px 12px;
                font-size: 12px;
                transition:
                    border-color 0.2s,
                    box-shadow 0.2s;
                outline: none;
            }
            .select-input:focus {
                border-color: #0ea5e9;
                box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.3);
            }

            .checkbox-label {
                display: flex;
                align-items: center;
                gap: 8px;
                cursor: pointer;
                user-select: none;
            }

            .checkbox-input {
                width: 16px;
                height: 16px;
                border-radius: 4px;
                border: 1px solid #334155;
                background-color: #0f172a;
                accent-color: #0ea5e9;
                cursor: pointer;
            }

            .dropzone {
                cursor: pointer;
                background-color: #0f172a;
                border: 1px dashed #334155;
                color: #cbd5e1;
                padding: 12px;
                border-radius: 12px;
                text-align: center;
                transition: all 0.2s ease;
                display: flex;
                flex-direction: column;
                align-items: center;
                gap: 4px;
            }
            .dropzone:hover {
                background-color: rgba(30, 41, 59, 0.8);
                border-color: #0ea5e9;
            }

            .dropzone-icon {
                font-size: 24px;
                color: #94a3b8;
                transition: color 0.2s ease;
            }
            .dropzone:hover .dropzone-icon {
                color: #38bdf8;
            }

            .search-container {
                position: relative;
                width: 100%;
            }

            .search-icon {
                position: absolute;
                left: 12px;
                top: 10px;
                color: #64748b;
                font-size: 12px;
                pointer-events: none;
            }

            .search-input {
                width: 100%;
                background-color: #0f172a;
                border: 1px solid #1e293b;
                color: #e2e8f0;
                font-size: 12px;
                border-radius: 8px;
                padding: 8px 12px 8px 32px;
                outline: none;
                transition:
                    border-color 0.2s,
                    box-shadow 0.2s;
            }
            .search-input:focus {
                border-color: #0ea5e9;
                box-shadow: 0 0 0 1px #0ea5e9;
            }

            /* ==========================================================================
           TIME CONTROL COMPONENTS
           ========================================================================== */
            .year-display-badge {
                background-color: #082f49;
                border: 1px solid rgba(3, 105, 161, 0.6);
                color: #7dd3fc;
                font-family: monospace;
                font-weight: 700;
                font-size: 12px;
                padding: 4px 10px;
                border-radius: 8px;
                box-shadow: inset 0 2px 4px 0 rgba(0, 0, 0, 0.3);
            }

            .mode-switch-container {
                display: flex;
                align-items: center;
                justify-content: space-between;
                background-color: #0f172a;
                padding: 6px;
                border-radius: 8px;
                border: 1px solid #1e293b;
                font-size: 12px;
            }

            .btn-mode {
                padding: 2px 8px;
                border-radius: 4px;
                font-size: 11px;
                font-weight: 700;
                border: none;
                cursor: pointer;
                transition: all 0.2s ease;
            }

            .btn-step-grid {
                display: grid;
                grid-template-columns: repeat(4, 1fr);
                gap: 6px;
                padding-top: 4px;
            }

            .btn-step {
                background-color: #0f172a;
                border: 1px solid #334155;
                color: #cbd5e1;
                padding: 6px 0;
                border-radius: 8px;
                font-size: 11px;
                font-weight: 600;
                cursor: pointer;
                transition: all 0.15s ease;
                text-align: center;
            }
            .btn-step:hover {
                background-color: #1e293b;
            }
            .btn-step:active {
                transform: scale(0.95);
            }

            /* Custom Range Slider Styling */
            input[type="range"] {
                width: 100%;
                height: 8px;
                background-color: #1e293b;
                border-radius: 8px;
                outline: none;
                -webkit-appearance: none;
                cursor: pointer;
            }
            input[type="range"]::-webkit-slider-thumb {
                -webkit-appearance: none;
                height: 22px;
                width: 22px;
                border-radius: 50%;
                background: #0ea5e9;
                cursor: pointer;
                border: 2px solid #ffffff;
                box-shadow: 0 0 12px rgba(14, 165, 233, 0.6);
                transition:
                    transform 0.15s ease,
                    background-color 0.15s ease;
            }
            input[type="range"]::-webkit-slider-thumb:hover {
                transform: scale(1.2);
                background: #38bdf8;
            }
            input[type="range"]:focus {
                outline: none;
            }

            .slider-labels {
                display: flex;
                justify-content: space-between;
                font-size: 10px;
                color: #64748b;
                font-family: monospace;
                padding: 0 2px;
            }

            /* ==========================================================================
           LIST & MAP VIEWPORT
           ========================================================================== */
            .couples-list-container {
                display: flex;
                flex-direction: column;
                gap: 8px;
                max-height: 288px;
                overflow-y: auto;
                padding-right: 4px;
            }

            .main-map-area {
                flex: 1;
                height: 100%;
                position: relative;
                background-color: #020617;
            }

            #map {
                width: 100%;
                height: 100%;
                z-index: 0;
            }

            .leaflet-container {
                background-color: #090d16 !important;
            }

            /* Loading Overlay */
            .loading-overlay {
                position: absolute;
                inset: 0;
                background-color: rgba(2, 6, 23, 0.8);
                backdrop-filter: blur(12px);
                z-index: 30;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                gap: 12px;
            }

            .spinner {
                width: 48px;
                height: 48px;
                border: 4px solid #0ea5e9;
                border-top-color: transparent;
                border-radius: 50%;
                animation: spin 1s linear infinite;
                box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
            }

            @keyframes spin {
                0% {
                    transform: rotate(0deg);
                }
                100% {
                    transform: rotate(360deg);
                }
            }
 /* Décès : couleurs propres au mode décès uniquement.
               Les couleurs des naissances et mariages restent celles de V6. */
            .map-marker-dot.marker-death-male { background:#e11d48 !important; border-color:#fb7185 !important; }
            .map-marker-dot.marker-death-female { background:#fef3a8 !important; border-color:#fde68a !important; }
            .map-marker-dot.marker-death-unknown { background:#22c55e !important; border-color:#86efac !important; }
            #map.death-mode .marker-cluster-small,
            #map.death-mode .marker-cluster-medium,
            #map.death-mode .marker-cluster-large { background-color:#22c55e6b !important; }
            #map.death-mode .marker-cluster-small div,
            #map.death-mode .marker-cluster-medium div,
            #map.death-mode .marker-cluster-large div { background-color:#16a34a !important; color:#fff !important; }
            .dot-death-male { display:inline-block;width:10px;height:10px;border-radius:50%;flex:0 0 10px;background:#e11d48;border:1px solid #fb7185; }
            .dot-death-female { display:inline-block;width:10px;height:10px;border-radius:50%;flex:0 0 10px;background:#fef3a8;border:1px solid #fde68a; }
            .dot-death-cluster { display:inline-block;width:10px;height:10px;border-radius:50%;flex:0 0 10px;background:#16a34a;border:1px solid #86efac; }
       
            /* Map Legend Overlay */
            .legend-card {
                position: absolute;
                bottom: 20px;
                right: 20px;
                background-color: #0f172ae6;
                border: 1px solid #1e293b;
                padding: 12px;
                border-radius: 16px;
                z-index: 10;
                font-size: 12px;
                box-shadow: 0 25px 50px -12px #00000080;
                backdrop-filter: blur(8px);
                max-width: 320px;
                display: flex;
                flex-direction: column;
                gap: 8px;
            }

            .dot-sky {
                width: 12px;
                height: 12px;
                border-radius: 50%;
                background-color: #0ea5e9;
                box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.3);
                display: inline-block;
                flex-shrink: 0;
            }

            .dot-amber {
                width: 12px;
                height: 12px;
                border-radius: 50%;
                background-color: #f59e0b;
                box-shadow: 0 0 0 2px rgba(252, 211, 77, 0.3);
                display: inline-block;
                flex-shrink: 0;
            }

            /* ==========================================================================
           LEAFLET DARK OVERRIDES & CLUSTERS
           ========================================================================== */
            .leaflet-popup-content-wrapper,
            .leaflet-popup-tip {
                background-color: #0f172a !important;
                color: #f1f5f9 !important;
                border: 1px solid #334155;
                box-shadow:
                    0 20px 25px -5px rgba(0, 0, 0, 0.6),
                    0 8px 10px -6px rgba(0, 0, 0, 0.5);
                border-radius: 0.75rem;
            }
            .leaflet-container a.leaflet-popup-close-button {
                color: #94a3b8 !important;
                padding: 8px !important;
            }
            .leaflet-container a.leaflet-popup-close-button:hover {
                color: #f8fafc !important;
            }

            .marker-cluster-small {
                background-color: rgba(14, 165, 233, 0.3) !important;
            }
            .marker-cluster-small div {
                background-color: rgba(14, 165, 233, 0.85) !important;
                color: #ffffff !important;
                font-weight: 700 !important;
            }
            .marker-cluster-medium {
                background-color: rgba(245, 158, 11, 0.3) !important;
            }
            .marker-cluster-medium div {
                background-color: rgba(245, 158, 11, 0.85) !important;
                color: #ffffff !important;
                font-weight: 700 !important;
            }
            .marker-cluster-large {
                background-color: rgba(239, 68, 68, 0.3) !important;
            }
            .marker-cluster-large div {
                background-color: rgba(239, 68, 68, 0.85) !important;
                color: #ffffff !important;
                font-weight: 700 !important;
            }

            /* SVG Graph / D3 Interactions */
            .couple,
            .node-couple,
            g.couple {
                cursor: pointer !important;
            }
            .couple text,
            .couple image,
            .couple icon,
            .node-couple text,
            .node-couple image {
                pointer-events: none;
            }
            .couple rect,
            .couple circle,
            .couple path,
            .node-couple rect,
            .node-couple circle,
            .node-couple path {
                pointer-events: all;
            }
            .custom-div-icon {
                background: transparent !important;
                border: none !important;
            }

            /* ==========================================================================
           UTILITY CLASSES (DYNAMIC JS COMPATIBILITY)
           ========================================================================== */
            .hidden {
                display: none !important;
            }
            .bg-primary-600 {
                background-color: #0284c7 !important;
                color: #ffffff !important;
            }
            .bg-slate-800 {
                background-color: #1e293b !important;
                color: #94a3b8 !important;
            }
            .text-slate-200 {
                color: #e2e8f0 !important;
            }
            .text-slate-400 {
                color: #94a3b8 !important;
            }
            .text-white {
                color: #ffffff !important;
            }
            .-translate-x-full {
                transform: translateX(-100%) !important;
            }

            /* ==========================================================================
           RESPONSIVE MEDIA QUERIES
           ========================================================================== */
            @media (min-width: 768px) {
                .btn-mobile-toggle {
                    display: none;
                }
                .sidebar {
                    position: relative;
                    transform: translateX(0) !important;
                    box-shadow: none;
                }
            }

            @media (max-width: 767px) {
                .btn-mobile-toggle {
                    display: inline-flex;
                    align-items: center;
                    justify-content: center;
                }
            }

            @media (min-width: 1024px) {
                .sidebar {
                    width: 384px;
                }
            }

      /*      @media (max-width: 640px) {
                .legend-card {
                    display: none;
                }*/
@media (max-width: 640px) {
    .legend-card {
        display: flex;
        max-width: 90vw;
        max-height: 35vh;
        overflow-y: auto;
        right: 10px;
        bottom: 10px;
        font-size: 10px;
    }
            }
            .ancestor-popup {
                min-width: 240px;
                color: #f1f5f9;
                font-family:
                    system-ui,
                    -apple-system,
                    BlinkMacSystemFont,
                    "Segoe UI",
                    Roboto,
                    sans-serif;
            }

            .ancestor-popup-header {
                display: flex;
                align-items: center;
                gap: 7px;
                color: #38bdf8;
                font-size: 12px;
                font-weight: 700;
                padding-bottom: 8px;
                border-bottom: 1px solid #334155;
            }

            .ancestor-popup-header i {
                color: #38bdf8;
            }

            .ancestor-popup-names {
                display: flex;
                flex-direction: column;
                gap: 5px;
                margin-top: 10px;
            }

            .ancestor-person {
                display: flex;
                align-items: center;
                gap: 8px;
                font-size: 12px;
                font-weight: 600;
                line-height: 1.4;
            }

            .ancestor-person i {
                width: 16px;
                text-align: center;
            }

            .ancestor-husband i {
                color: #38bdf8;
            }

            .ancestor-wife i {
                color: #f472b6;
            }

            .ancestor-popup-separator {
                height: 1px;
                background: #1e293b;
                margin: 10px 0;
            }

            .ancestor-popup-marriage {
                display: flex;
                align-items: center;
                gap: 7px;
                font-size: 11px;
                font-weight: 600;
            }

            .ancestor-popup-marriage i {
                width: 15px;
                text-align: center;
            }

            .marriage-exact {
                color: #6ee7b7;
            }

            .marriage-exact i {
                color: #34d399;
            }

            .marriage-estimated {
                color: #fcd34d;
            }

            .marriage-estimated i {
                color: #f59e0b;
            }

            .ancestor-popup-location {
                display: flex;
                align-items: center;
                gap: 7px;
                margin-top: 7px;
                color: #cbd5e1;
                font-size: 11px;
            }

            .ancestor-popup-location i {
                width: 15px;
                text-align: center;
                color: #f59e0b;
            }
 /* ==========================================================================
   MARQUEURS
   ========================================================================== */

.custom-div-icon {
    background: transparent !important;
    border: none !important;
}

.map-marker-hitbox {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    cursor: pointer;
}

.map-marker-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease;
}

.marker-exact {
    background-color: #0ea5e9;
    box-shadow:
        0 0 8px #0ea5e9;
}

.marker-estimated {
    background-color: #f59e0b;
    box-shadow:
        0 0 8px #f59e0b;
}

.map-marker-hitbox:hover .map-marker-dot {
    transform: scale(1.25);
}

.marker-exact:hover {
    box-shadow:
        0 0 12px #0ea5e9,
        0 0 20px #0ea5e9;
}

.marker-estimated:hover {
    box-shadow:
        0 0 12px #f59e0b,
        0 0 20px #f59e0b;
}

/* ==========================================================================
   LISTE DES COUPLES
   ========================================================================== */

.couples-list-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 288px;
    overflow-y: auto;
    padding-right: 4px;
}


/* Message aucun résultat */
.couples-list-empty {
    margin: 0;
    padding: 24px 0;
    color: #64748b;
    font-size: 12px;
    font-style: italic;
    text-align: center;
}

/* ==========================================================================
   CARTE D'UN COUPLE
   ========================================================================== */
.couple-list-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background-color: rgba(15, 23, 42, 0.90);
    border: 1px solid #1e293b;
    border-radius: 12px;
    color: #e2e8f0;
    font-size: 12px;
    cursor: pointer;
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        transform 0.15s ease,
        box-shadow 0.2s ease;
}
/* Survol */

.couple-list-card:hover {
    background-color: #1e293b;
    border-color: rgba(14, 165, 233, 0.5);
    transform: translateX(2px);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.25);
}

/* ==========================================================================
   EN-TÊTE DE LA CARTE
   ========================================================================== */
.couple-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
}


.couple-list-names {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 700;
}

.couple-list-separator {
    color: #64748b;
    padding: 0 3px;
}

/* ==========================================================================
   BADGE EXACT / ESTIMÉ
   ========================================================================== */
.couple-list-status {
    flex-shrink: 0;
    padding: 2px 6px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 9px;
    line-height: 1.2;
    font-weight: 600;
    border: 1px solid;
}

.status-exact {
    color: #38bdf8;
    background-color: #082f49;
    border-color: #075985;
}

.status-estimated {
    color: #fbbf24;
    background-color: #451a03;
    border-color: #92400e;
}
/* ==========================================================================
   LOCALISATION
   ========================================================================= */

.couple-list-place {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    color: #94a3b8;
    font-size: 11px;
    line-height: 1.3;
}

.couple-list-place i {
    flex-shrink: 0;
    width: 14px;
    color: #f59e0b;
    font-size: 10px;
    text-align: center;
}

.couple-list-place span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.legend-card {
    cursor: move;
    user-select: none;
    touch-action: none;
}
  /*Légende repliable sur mobile uniquement*/

            .mobile-legend-toggle,
            .legend-close-mobile {
                display: none;
            }

            @media (max-width: 640px) {
                .mobile-legend-toggle {
                    display: inline-flex;
                    position: absolute;
                    right: 12px;
                    bottom: 14px;
                    z-index: 1100;
                    align-items: center;
                    justify-content: center;
                    gap: 7px;
                    min-height: 40px;
                    padding: 9px 13px;
                    border: 1px solid #475569;
                    border-radius: 22px;
                    background: #0f172a;
                    color: #e2e8f0;
                    font: inherit;
                    font-size: 13px;
                    font-weight: 600;
                    box-shadow: 0 3px 12px rgba(0, 0, 0, .35);
                    cursor: pointer;
                    touch-action: manipulation;
                }

                .legend-card {
                    display: none !important;
                    position: absolute !important;
                    right: 10px !important;
                    bottom: 62px !important;
                    left: auto !important;
                    top: auto !important;
                    width: min(92vw, 360px);
                    max-width: 92vw;
                    max-height: 55vh !important;
                    overflow-y: auto;
                    overscroll-behavior: contain;
                    cursor: default !important;
                    touch-action: pan-y !important;
                    z-index: 1200 !important;
                    box-sizing: border-box;
                }

                .legend-card.is-open {
                    display: block !important;
                }

                .legend-close-mobile {
                    display: inline-flex;
                    align-items: center;
                    justify-content: center;
                    width: 30px;
                    height: 30px;
                    margin: -5px -4px -5px 8px;
                    border: 0;
                    border-radius: 50%;
                    background: transparent;
                    color: #e2e8f0;
                    font-size: 24px;
                    line-height: 1;
                    cursor: pointer;
                    flex: 0 0 auto;
                    touch-action: manipulation;
                }
            }
