/* === Base === */
:root {
    --primary: #1a56db;
    --primary-dark: #1240a4;
    --primary-light: #e1effe;
    --accent: #e74c3c;
    --accent-green: #27ae60;
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --radius: 12px;
    --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* === Header === */
header {
    background: linear-gradient(135deg, var(--primary) 0%, #2563eb 50%, #3b82f6 100%);
    color: white;
    padding: 2rem 1.5rem;
    text-align: center;
}

.header-content h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 0.95rem;
    opacity: 0.85;
    font-weight: 300;
}

/* === Main === */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

section {
    margin-bottom: 2rem;
}

section h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text);
}

/* === KPI Loader === */
.kpi-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--text-light);
    font-size: 0.95rem;
}
.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === KPI Cards === */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.kpi-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.15s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.kpi-card.highlight {
    background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
    color: white;
    border: none;
}

.kpi-card.highlight .kpi-label,
.kpi-card.highlight .kpi-detail {
    color: rgba(255,255,255,0.85);
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.kpi-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-detail {
    font-size: 0.78rem;
    color: var(--text-light);
    margin-top: 0.5rem;
    line-height: 1.45;
}

/* === Filters === */
.filters-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.filters-section h2 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.filters-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 160px;
}

.filter-group label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.filter-group select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text);
    background: white;
    cursor: pointer;
    appearance: auto;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.filter-actions {
    flex-direction: row !important;
    gap: 0.5rem !important;
    align-items: flex-end;
    min-width: auto;
}

.btn {
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text-light);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

/* === Content Grid (Map + Charts) === */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1.5rem;
}

@media (max-width: 1100px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* === Map === */
.map-container {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
}

/* === Building Side Panel === */
.building-panel {
    position: absolute;
    right: 0;
    top: 0;
    width: 380px;
    height: 100%;
    z-index: 1000;
    background: var(--card-bg);
    border-left: 1px solid var(--border);
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
    overflow-y: auto;
    display: none;
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 1rem 1.25rem;
}

.building-panel.open {
    display: block;
}

.building-panel-close {
    position: sticky;
    top: 0;
    float: right;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: all 0.15s;
}

.building-panel-close:hover {
    background: var(--border);
    color: var(--text);
}

#building-panel-content {
    clear: both;
    padding-top: 0.25rem;
}

#building-panel-content .popup-title {
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

#building-panel-content .popup-row {
    padding: 0.25rem 0;
}

@media (max-width: 800px) {
    .building-panel {
        width: 300px;
    }
}

.map-container h2 {
    margin-bottom: 0.5rem;
}

.map-legend {
    display: flex;
    gap: 1.25rem;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-light);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot-collectif {
    background: var(--accent);
}

.dot-elevated {
    background: #e67e22;
}

.dot-moyenne {
    background: #f39c12;
}

.dot-individuel {
    background: #95a5a6;
}

.dot-connected {
    background: #27ae60;
}

.line {
    width: 24px;
    height: 5px;
    display: inline-block;
    border-radius: 3px;
}

.line-network {
    background: #0d47a1;
    box-shadow: 0 0 4px rgba(13, 71, 161, 0.5);
}

.btn-toggle-networks {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.15s;
    margin-left: auto;
}

.btn-toggle-networks:hover {
    background: var(--primary-light);
}

.btn-toggle-networks.active {
    background: var(--primary);
    color: white;
}

.btn-toggle-connected {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--accent-green);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--accent-green);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-toggle-connected:hover {
    background: #d4edda;
}

.btn-toggle-connected.active {
    background: var(--accent-green);
    color: white;
}

.connected-count-label {
    font-size: 0.75rem;
    color: var(--accent-green);
    font-weight: 500;
}

.marker-cluster-connected {
    background-color: rgba(39, 174, 96, 0.3);
}
.marker-cluster-connected div {
    background-color: rgba(39, 174, 96, 0.6);
    color: white;
    border-radius: 50%;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

#map {
    width: 100%;
    height: 550px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.map-info {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-light);
    text-align: center;
}

/* === Charts === */
.charts-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chart-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.chart-card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.chart-card canvas {
    max-height: 200px;
}

.chart-card-tall canvas {
    max-height: 350px;
}

.chart-card-tall {
    min-height: 380px;
}

/* === Department Chart === */
.dept-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.dept-chart-wrapper {
    max-height: 350px;
    position: relative;
}

/* === Table === */
.table-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: var(--bg);
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

tr:hover td {
    background: var(--primary-light);
}

td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* === Insights === */
.insights-section h2 {
    font-size: 1.15rem;
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.insight-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    transition: transform 0.15s;
}

.insight-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.insight-highlight {
    border-left: 4px solid var(--primary);
}

.insight-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
    width: 40px;
    text-align: center;
}

.insight-number {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
    margin-bottom: 0.15rem;
}

.insight-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.insight-desc {
    font-size: 0.8rem;
    color: var(--text-light);
    line-height: 1.5;
}

/* === Methodology === */
.methodology-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.method-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.method-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

.method-card ul {
    list-style: none;
    padding: 0;
}

.method-card li {
    font-size: 0.83rem;
    padding: 0.3rem 0;
    padding-left: 1rem;
    position: relative;
    color: var(--text);
}

.method-card li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--primary);
}

/* === Header button === */
.btn-header {
    display: inline-block;
    margin-top: 0.75rem;
    padding: 0.5rem 1.5rem;
    background: rgba(255,255,255,0.15);
    color: white;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s;
}

.btn-header:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.6);
}

/* === Valeur ENGIE Section === */
.engie-section {
    background: linear-gradient(135deg, #f8fafc 0%, #f0f4f8 100%);
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    border: 1px solid var(--border);
    scroll-margin-top: 1rem;
}

.engie-section h2 {
    font-size: 1.3rem;
    margin-bottom: 1.25rem;
}

.engie-kpi {
    text-align: center;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #1a56db 0%, #2563eb 100%);
    border-radius: var(--radius);
    color: white;
}

.engie-kpi-value {
    font-size: 2.8rem;
    font-weight: 700;
    line-height: 1.2;
}

.engie-kpi-label {
    font-size: 1rem;
    font-weight: 500;
    opacity: 0.9;
    margin-top: 0.25rem;
}

.engie-kpi-detail {
    font-size: 0.82rem;
    opacity: 0.7;
    margin-top: 0.5rem;
}

.engie-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.engie-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.engie-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.engie-card p {
    font-size: 0.85rem;
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.engie-card-highlight {
    border-left: 4px solid var(--primary);
    background: #f0f5ff;
}

.engie-sources {
    font-size: 0.78rem !important;
    color: var(--text-light);
    font-style: italic;
}

.engie-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
}

.engie-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.engie-table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.engie-table tr:hover td {
    background: var(--primary-light);
}

.engie-range {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 700px) {
    .engie-range { grid-template-columns: 1fr; }
}

.engie-range h4 {
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.engie-range-low h4 { color: var(--text-light); }
.engie-range-high h4 { color: var(--primary); }

.engie-range ul {
    list-style: none;
    padding: 0;
}

.engie-range li {
    font-size: 0.83rem;
    padding: 0.25rem 0 0.25rem 1rem;
    position: relative;
}

.engie-range li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--text-light);
}

.engie-range-high li::before {
    color: var(--primary);
}

/* === Footer === */
footer {
    text-align: center;
    padding: 2rem 1.5rem;
    color: var(--text-light);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* === Loading indicator === */
.loading {
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-sm) !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 0.82rem !important;
}

.leaflet-popup-content {
    margin: 10px 14px !important;
    line-height: 1.5 !important;
}

.popup-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.popup-row {
    display: flex;
    justify-content: space-between;
    padding: 0.15rem 0;
}

.popup-label {
    color: var(--text-light);
    margin-right: 0.75rem;
}

.popup-value {
    font-weight: 500;
}

.badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-collectif {
    background: #fde8e8;
    color: var(--accent);
}

.badge-individuel {
    background: #fef3cd;
    color: #856404;
}

.badge-priority-high { background: #fde8e8; color: #c0392b; }
.badge-priority-medium { background: #ffe0b2; color: #e65100; }
.badge-priority-mid { background: #fff3cd; color: #856404; }
.badge-priority-low { background: #e3f2fd; color: #1565c0; }

.badge-dpe-a, .badge-dpe-b { background: #d4edda; color: #155724; }
.badge-dpe-c { background: #d4edda; color: #155724; }
.badge-dpe-d { background: #fff3cd; color: #856404; }
.badge-dpe-e { background: #ffe0b2; color: #e65100; }
.badge-dpe-f { background: #fde8e8; color: #c0392b; }
.badge-dpe-g { background: #f5c6cb; color: #721c24; }

.badge-connected { background: #d4edda; color: #155724; }
.badge-conflict { background: #fff3cd; color: #856404; font-size: 0.68rem; }
.badge-dpe-immeuble { background: #d4edda; color: #155724; }
.badge-dpe-appart { background: #e3f2fd; color: #1565c0; }

/* Network trace hover cursor */
.leaflet-interactive.network-trace:hover {
    cursor: pointer;
}

/* Network popup title */
.popup-title-network {
    color: #0d47a1 !important;
    border-bottom: 2px solid #0d47a1;
    padding-bottom: 0.35rem;
}

/* Popup divider between sections */
.popup-divider {
    border-top: 1px solid var(--border);
    margin: 0.35rem 0;
}

/* Limit long commune lists in popup */
.popup-communes {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

/* === Popup BDNB Identifiers === */
.popup-ids {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    margin-bottom: 0.5rem;
    border: 1px solid #e9ecef;
}

.popup-ids-title {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 0.25rem;
}

.popup-id-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.1rem 0;
}

.popup-id-label {
    font-size: 0.72rem;
    color: var(--text-light);
}

.popup-copyable {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
    transition: background 0.15s;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

.popup-copyable:hover {
    background: #dee2e6;
}

.popup-copyable.copied {
    background: #d4edda;
    color: #155724;
}

/* === Funnel Section === */
.funnel-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.funnel-section h2 {
    text-align: center;
    margin-bottom: 1.25rem;
}

.funnel-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 700px;
    margin: 0 auto;
    gap: 0;
}

.funnel-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: transform 0.15s;
}

.funnel-step:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow);
}

.funnel-step-final {
    background: linear-gradient(135deg, var(--primary) 0%, #2563eb 100%);
    color: white;
    border: none;
    padding: 1rem 1.25rem;
}

.funnel-step-final .funnel-step-label {
    color: rgba(255,255,255,0.9);
}

.funnel-step-final .funnel-step-count {
    color: white;
}

.funnel-step-final .funnel-step-note {
    color: rgba(255,255,255,0.75);
}

.funnel-step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.funnel-step-final .funnel-step-number {
    background: rgba(255,255,255,0.25);
}

.funnel-step-body {
    flex: 1;
    min-width: 0;
}

.funnel-step-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
}

.funnel-step-note {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.15rem;
}

.funnel-step-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.funnel-step-count {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.funnel-badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.funnel-badge-exact {
    background: #d4edda;
    color: #155724;
}

.funnel-badge-estimate {
    background: #fff3cd;
    color: #856404;
}

.funnel-badge-nd {
    background: #e9ecef;
    color: #6b7280;
}

.funnel-arrow {
    display: flex;
    justify-content: center;
    padding: 0.15rem 0;
    color: var(--text-light);
    font-size: 0.9rem;
    line-height: 1;
}

.funnel-breakdown {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.35rem;
    flex-wrap: wrap;
}

.funnel-chip {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
}

.funnel-loader {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* === Header Badge === */
.header-badge {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 500;
    color: rgba(255,255,255,0.85);
}

/* === Orphan Network Legend === */
.line-orphan {
    background: #7c3aed;
    box-shadow: 0 0 4px rgba(124, 58, 237, 0.5);
}

/* === Data Quality Section === */
.data-quality-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.dq-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.dq-card {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    border: 1px solid var(--border);
}

.dq-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

.dq-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.dq-table th {
    text-align: left;
    padding: 0.5rem 0.6rem;
    background: var(--card-bg);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    font-size: 0.78rem;
}

.dq-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border);
}

.dq-table .dq-total td {
    font-weight: 700;
    border-top: 2px solid var(--border);
    background: var(--card-bg);
}

.dq-explanation {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--card-bg);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.dq-explanation h4 {
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text);
}

.dq-explanation p,
.dq-explanation li {
    font-size: 0.78rem;
    color: var(--text-light);
    line-height: 1.5;
}

.dq-explanation ul {
    list-style: none;
    padding: 0;
    margin: 0.25rem 0;
}

.dq-explanation li {
    padding: 0.15rem 0 0.15rem 0.75rem;
    position: relative;
}

.dq-explanation li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--primary);
}

/* === Match Method Badges === */
.badge-match-id { background: #d4edda; color: #155724; }
.badge-match-geo { background: #e3f2fd; color: #1565c0; }
.badge-match-orphan { background: #ede9fe; color: #5b21b6; }

/* === Warning DPE Badge === */
.badge-warning-dpe { background: #fde8e8; color: #c0392b; font-size: 0.68rem; }

/* === DPE Links in popup === */
.popup-dpe-links {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.dpe-link {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.7rem;
    color: var(--primary);
    text-decoration: none;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    transition: background 0.15s;
}

.dpe-link:hover {
    background: var(--primary-light);
    text-decoration: underline;
}

.popup-row-block {
    flex-direction: column;
    align-items: flex-start;
}

.popup-combis {
    width: 100%;
    margin-top: 0.2rem;
}

.popup-combi {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0;
    font-size: 0.8rem;
    border-bottom: 1px solid #f0f0f0;
}

.popup-combi:last-child {
    border-bottom: none;
}
