/* ==========================================================================
   Dashboard CSS - Combined from inline styles and external dashboard.css
   ========================================================================== */

/* --- CSS Variables --- */
:root {
    --primary-color: #059669;
    --primary-color-rgb: 5, 150, 105;
    --secondary-color: #0f172a;
    --background-color: #f1f5f9;
    --dash-surface: #ffffff;
    --dash-border: rgba(15, 23, 42, 0.08);
    --dash-muted: #64748b;
    --card-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
    --card-shadow-hover: 0 4px 12px rgba(15, 23, 42, 0.08), 0 16px 40px rgba(15, 23, 42, 0.08);
    --warning-color: #d97706;
    --danger-color: #dc2626;
    --info-color: #0891b2;
    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-sm: 8px;
}

/* Échelle globale un peu plus compacte (moins « zoomé ») */
html {
    font-size: 87.5%;
}

/* --- Base --- */
body {
    background-color: var(--background-color);
    font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    padding: 12px;
    color: var(--secondary-color);
    -webkit-font-smoothing: antialiased;
}

.container-fluid {
    padding: 0.75rem;
    max-width: none;
}

.dashboard-main.container-fluid {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

/* --- En-tête dashboard (refonte) --- */
.dashboard-header {
    background: linear-gradient(135deg, var(--dash-surface) 0%, #f8fafc 72%, rgba(var(--primary-color-rgb), 0.04) 100%);
    padding: 16px 20px 16px 18px;
    border-radius: var(--radius-lg);
    margin-bottom: 18px;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--dash-border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 20px;
}

.dashboard-header__lead {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: min(100%, 220px);
    flex: 1 1 auto;
}

.dashboard-header__mark {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(145deg, rgba(var(--primary-color-rgb), 0.18) 0%, rgba(var(--primary-color-rgb), 0.06) 100%);
    color: var(--primary-color);
    font-size: 1.2rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.dashboard-header__titles {
    min-width: 0;
}

.dashboard-header__title {
    margin: 0;
    font-size: clamp(1.05rem, 2.5vw, 1.28rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--secondary-color);
    line-height: 1.2;
}

.dashboard-header__tagline {
    margin: 4px 0 0;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--dash-muted);
    line-height: 1.35;
    max-width: 28rem;
}

.dashboard-header__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px 12px;
    flex: 0 1 auto;
}

.dashboard-header__sync {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 8px 10px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid var(--dash-border);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    max-width: 100%;
}

.dashboard-header__sync-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(var(--primary-color-rgb), 0.1);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.dashboard-header__sync-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    text-align: left;
}

.dashboard-header__sync-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--dash-muted);
    line-height: 1.2;
}

.dashboard-header__sync-value {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--secondary-color);
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
    white-space: nowrap;
}

/* Loader HTMX (hx-indicator) */
.dashboard-header-loader.htmx-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    width: 0;
    min-width: 0;
    overflow: hidden;
    transition: opacity 0.2s ease, visibility 0.2s, width 0.2s ease, min-width 0.2s ease;
}

.dashboard-header-loader.htmx-indicator.htmx-request {
    opacity: 1;
    visibility: visible;
    width: 36px;
    min-width: 36px;
}

.dashboard-header-loader__ring {
    width: 22px;
    height: 22px;
    border: 2.5px solid rgba(var(--primary-color-rgb), 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: dash-header-spin 0.65s linear infinite;
}

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

.dashboard-header__actions {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.dash-header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    font-size: 0.8125rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.2;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease,
        box-shadow 0.18s ease, transform 0.15s ease;
    white-space: nowrap;
}

.dash-header-btn i {
    font-size: 0.88rem;
    opacity: 0.95;
}

.dash-header-btn--primary {
    background: var(--primary-color);
    color: #fff;
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 8px rgba(var(--primary-color-rgb), 0.28);
}

.dash-header-btn--primary:hover:not(:disabled) {
    background: #047857;
    color: #fff;
    box-shadow: 0 4px 14px rgba(var(--primary-color-rgb), 0.35);
    transform: translateY(-1px);
}

.dash-header-btn--primary:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(var(--primary-color-rgb), 0.25);
}

.dash-header-btn--primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.dash-header-btn--ghost {
    background: rgba(255, 255, 255, 0.85);
    color: var(--secondary-color);
    border-color: var(--dash-border);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.dash-header-btn--ghost:hover {
    background: #fff;
    border-color: rgba(var(--primary-color-rgb), 0.35);
    color: var(--primary-color);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
    transform: translateY(-1px);
}

.dash-header-btn--ghost:active {
    transform: translateY(0);
}

.dash-header-btn:focus-visible {
    outline: 2px solid rgba(var(--primary-color-rgb), 0.45);
    outline-offset: 2px;
}

@media (max-width: 767.98px) {
    .dashboard-header {
        padding: 14px 14px 16px;
    }

    .dashboard-header__toolbar {
        width: 100%;
        justify-content: stretch;
    }

    .dashboard-header__sync {
        flex: 1 1 100%;
        order: -1;
    }

    .dashboard-header__actions {
        flex: 1 1 auto;
        justify-content: stretch;
    }

    .dash-header-btn {
        flex: 1 1 auto;
        min-width: 0;
    }

    .dashboard-header__sync-value {
        white-space: normal;
    }
}

/* Chargement filtres / onglets (reste visible jusqu’à fin init DataTable) */
.tab-content-host {
    min-height: 14rem;
}

.tab-content-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-direction: column;
    padding: 16px 12px;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s;
}

.tab-content-loading-overlay.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.tab-content-loading-inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    text-align: left;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
}

.tab-content-loading-label {
    font-weight: 600;
    color: var(--secondary-color);
    font-size: 0.95rem;
}

.tab-content-loading-hint {
    font-size: 0.8rem;
    margin-top: 0;
}


.last-update-text {
    color: var(--secondary-color);
    font-size: 0.85rem;
}

/* --- Stats Cards (base + KPI + visuels) --- */
.stats-card {
    background: var(--dash-surface);
    border-radius: var(--radius-lg);
    padding: 0;
    height: 100%;
    transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.2s ease;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--dash-border);
    position: relative;
    overflow: hidden;
}

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

/* ——— KPI strip ——— */
.stats-kpi {
    display: flex;
    align-items: stretch;
    gap: 0;
    min-height: 118px;
    padding: 14px 14px 14px 0;
}

.stats-kpi__accent {
    width: 4px;
    flex-shrink: 0;
    border-radius: 0 4px 4px 0;
    margin-right: 12px;
    align-self: stretch;
    background: var(--kpi-accent, var(--primary-color));
}

.stats-kpi--accent-emerald { --kpi-accent: #059669; --kpi-icon-bg: rgba(5, 150, 105, 0.12); --kpi-icon-fg: #047857; }
.stats-kpi--accent-teal { --kpi-accent: #0d9488; --kpi-icon-bg: rgba(13, 148, 136, 0.12); --kpi-icon-fg: #0f766e; }
.stats-kpi--accent-amber { --kpi-accent: #d97706; --kpi-icon-bg: rgba(217, 119, 6, 0.12); --kpi-icon-fg: #b45309; }
.stats-kpi--accent-rose { --kpi-accent: #e11d48; --kpi-icon-bg: rgba(225, 29, 72, 0.1); --kpi-icon-fg: #be123c; }
.stats-kpi--accent-slate { --kpi-accent: #475569; --kpi-icon-bg: rgba(71, 85, 105, 0.1); --kpi-icon-fg: #334155; }
.stats-kpi--accent-violet { --kpi-accent: #7c3aed; --kpi-icon-bg: rgba(124, 58, 237, 0.1); --kpi-icon-fg: #6d28d9; }

.stats-kpi__icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--kpi-icon-bg, rgba(5, 150, 105, 0.12));
    color: var(--kpi-icon-fg, var(--primary-color));
    font-size: 1.1rem;
    margin-right: 12px;
    align-self: flex-start;
}

.stats-kpi__icon--warn {
    background: rgba(217, 119, 6, 0.14);
    color: #b45309;
}

.stats-kpi__icon--alert {
    background: rgba(225, 29, 72, 0.12);
    color: #be123c;
}

.stats-kpi__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding-right: 4px;
}

.stats-kpi__label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--dash-muted);
    line-height: 1.3;
}

.stats-kpi__value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--secondary-color);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0;
}

.stats-kpi__value--stack {
    font-size: 1.05rem;
}

.stats-kpi__value--compact {
    font-size: 1.05rem;
}

.stats-kpi__value-secondary {
    font-weight: 600;
    color: var(--dash-muted);
    font-size: 0.95em;
}

.stats-kpi__sep {
    color: var(--dash-muted);
    font-weight: 500;
    margin: 0 0.15em;
    opacity: 0.7;
}

.stats-kpi__detail {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dash-muted);
    margin-left: 0.35rem;
    font-variant-numeric: tabular-nums;
}

.stats-kpi__subline {
    font-size: 0.72rem;
    color: var(--dash-muted);
    margin: 4px 0 0;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.stats-kpi__dot {
    margin: 0 0.35rem;
    opacity: 0.5;
}

.stats-kpi__hint {
    font-size: 0.68rem;
    color: var(--dash-muted);
    font-weight: 500;
    margin-top: 2px;
}

/* Cartes graphiques / carte (en-tête cliquable, corps repliable) */
.stats-visual-card {
    padding: 0;
    display: flex;
    flex-direction: column;
}

.stats-visual-card__toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 16px;
    margin: 0;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: inherit;
    font: inherit;
    border-radius: var(--radius-lg);
    transition: background 0.15s ease;
}

.stats-visual-card__toggle:hover {
    background: rgba(var(--primary-color-rgb), 0.05);
}

.stats-visual-card__toggle:focus-visible {
    outline: 2px solid rgba(var(--primary-color-rgb), 0.4);
    outline-offset: -2px;
}

.stats-visual-card__chevron {
    margin-left: auto;
    color: var(--dash-muted);
    font-size: 0.7rem;
    transition: transform 0.22s ease;
    flex-shrink: 0;
    opacity: 0.85;
}

.stats-visual-card__toggle.collapsed .stats-visual-card__chevron {
    transform: rotate(-90deg);
}

.stats-visual-card__collapse {
    padding: 0 14px 16px;
}

.stats-visual-card__head--split {
    display: flex;
    align-items: stretch;
    gap: 6px;
    padding-right: 10px;
    flex-wrap: nowrap;
}

.stats-visual-card__toggle--in-split {
    flex: 1;
    min-width: 0;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    padding-right: 8px;
}

.stats-visual-card__head--split .btn-expand-map {
    align-self: center;
    flex-shrink: 0;
    margin: 0 4px 0 0;
}

.stats-visual-card__icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(var(--primary-color-rgb), 0.1);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.stats-visual-card__title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--secondary-color);
    letter-spacing: -0.01em;
    flex: 1;
    min-width: 0;
}

.btn-expand-map {
    border: 1px solid rgba(var(--primary-color-rgb), 0.35);
    background: rgba(var(--primary-color-rgb), 0.06);
    color: var(--primary-color);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-size: 0.8rem;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.btn-expand-map:hover {
    background: var(--primary-color);
    color: #fff;
    transform: translateY(-1px);
}

/* Anciennes classes (rétrocompat éventuelle) */
.stats-card .card-title {
    color: var(--secondary-color);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.stats-card .card-text {
    color: var(--primary-color);
    font-size: 1.35rem;
    font-weight: bold;
}

.stats-card i {
    font-size: 1.25rem;
    color: var(--primary-color);
}

/* --- Card & Card Header --- */
.card {
    border: none;
    box-shadow: var(--card-shadow);
    border-radius: 10px;
    overflow: hidden;
    width: auto;
    max-width: none;
}

.dashboard-main .btn {
    font-size: 0.8125rem;
    padding: 0.3rem 0.65rem;
}

.card-header {
    border-bottom: 1px solid #e9ecef;
    padding: 0;
}

/* --- Table Styles --- */
.sensor-table {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--card-shadow);
}

.table-responsive {
    background: white;
    border-radius: 10px;
    padding: 12px;
    box-shadow: var(--card-shadow);
    margin-top: 12px;
}

.modern-table {
    background: white;
    contain: layout style;
}

/* Barre DataTables : afficher N entrées, info, recherche globale, bouton Colonnes */
.dataTables_wrapper {
    width: 100%;
}

.dataTables_wrapper .dataTables_top_controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    padding: 12px 14px;
    margin-bottom: 12px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
}

.dataTables_wrapper .dataTables_top_controls_left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.25rem;
    flex: 1 1 auto;
    min-width: min(100%, 260px);
}

.dataTables_wrapper .dataTables_top_controls_right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    flex: 0 1 auto;
    min-width: 0;
}

.dataTables_wrapper .dataTables_length_label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--secondary-color);
    white-space: nowrap;
}

.dataTables_wrapper .dataTables_length select.form-select {
    width: auto;
    min-width: 4.25rem;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
}

.dataTables_wrapper .dataTables_info_top {
    font-size: 0.8125rem;
    color: #5a6c7d;
    line-height: 1.4;
    flex: 1 1 12rem;
    min-width: 0;
}

.dataTables_wrapper .dataTables_filter_label {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    flex-wrap: wrap;
}

.dataTables_wrapper .dataTables_filter_text {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--secondary-color);
    white-space: nowrap;
}

.dataTables_wrapper .dataTables_filter input[type="search"] {
    min-width: 10rem;
    width: 14rem;
    max-width: 100%;
}

.dataTables_wrapper .dataTables_columns_btn {
    border-color: #ced4da;
    color: var(--secondary-color);
    font-weight: 500;
    white-space: nowrap;
}

.dataTables_wrapper .dataTables_columns_btn:hover {
    background: #f1f3f5;
    border-color: #adb5bd;
    color: var(--secondary-color);
}

/* Pagination (Précédent / numéros / Suivant) */
.dataTables_wrapper .dataTables_bottom_controls {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 14px 12px;
    margin-top: 12px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
}

.dataTables_wrapper .dataTables_paginate {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.dataTables_wrapper .dataTables_paginate .pagination-numbers {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: 0 2px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--secondary-color);
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    line-height: 1;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.disabled) {
    background: #f1f3f5;
    border-color: #ced4da;
    color: var(--secondary-color);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.page-number.current {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
    font-weight: 600;
    cursor: default;
    box-shadow: 0 1px 2px rgba(40, 167, 69, 0.35);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.previous,
.dataTables_wrapper .dataTables_paginate .paginate_button.next {
    min-width: auto;
    padding: 0 12px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    opacity: 0.42;
    cursor: not-allowed;
    pointer-events: none;
}

/* Points de suspension « … » entre les blocs de pages */
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:not(.previous):not(.next):not(.page-number) {
    opacity: 1;
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 0 2px;
    min-width: auto;
    width: auto;
    height: auto;
    color: #adb5bd;
    font-weight: 600;
    letter-spacing: 0.06em;
}

@media (max-width: 767.98px) {
    .dataTables_wrapper .dataTables_top_controls {
        flex-direction: column;
        align-items: stretch;
    }

    .dataTables_wrapper .dataTables_top_controls_right {
        flex-direction: column;
        align-items: stretch;
    }

    .dataTables_wrapper .dataTables_filter input[type="search"] {
        width: 100%;
    }

    .dataTables_wrapper .dataTables_filter_label {
        flex-direction: column;
        align-items: stretch;
    }

    .dataTables_wrapper .dataTables_columns_btn {
        width: 100%;
    }
}

.table {
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
}

/* --- En-têtes de tableaux : nouvelle DA (plus moderne) --- */
.table thead {
    background: transparent;
}

.table thead th {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(248, 249, 250, 0.92));
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #22313f;
    font-weight: 700;
    border: none;
    padding: 10px 12px;
    height: 46px;
    text-transform: uppercase;
    font-size: 0.76rem;
    letter-spacing: 0.06em;
    position: sticky;
    top: 0;
    z-index: 120;
    white-space: nowrap;
    box-shadow: inset 0 -1px 0 rgba(44, 62, 80, 0.10);
}

/* Séparateurs verticaux subtils (lisibilité) */
.table thead th + th {
    box-shadow:
        inset 1px 0 0 rgba(44, 62, 80, 0.06),
        inset 0 -1px 0 rgba(44, 62, 80, 0.10);
}

.table thead th:first-child,
.table tbody td:first-child {
    min-width: 220px;
    width: 220px;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 12px;
}

.table thead th:last-child,
.table tbody td:last-child {
    padding-right: 12px;
}

.table-header {
    border-bottom: 2px solid rgba(40, 167, 69, 0.35);
}

.table-header th {
    /* hérite de .table thead th */
    border-bottom: none;
}

.table-header th i {
    color: var(--primary-color);
    opacity: 0.9;
    filter: saturate(1.05);
}

/* Indicateur de tri (compatible classes DataTables simples) */
/* Flèches haut/bas empilées, alignées sur la même “ligne” que l’en-tête */
.table thead th.sorting,
.table thead th.sorting_asc,
.table thead th.sorting_desc {
    position: sticky; /* déjà présent mais on réaffirme pour le ::after */
    padding-right: 34px; /* réserve la place des flèches */
}

.table thead th.sorting::after,
.table thead th.sorting_asc::after,
.table thead th.sorting_desc::after {
    content: "";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 16px;
    opacity: 0.26;
    background-image: linear-gradient(#22313f, #22313f);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='16' viewBox='0 0 10 16'%3E%3Cpath fill='black' d='M5 0l4 4H1l4-4zM5 16l-4-4h8l-4 4z'/%3E%3C/svg%3E") center/10px 16px no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='16' viewBox='0 0 10 16'%3E%3Cpath fill='black' d='M5 0l4 4H1l4-4zM5 16l-4-4h8l-4 4z'/%3E%3C/svg%3E") center/10px 16px no-repeat;
    pointer-events: none;
}

.table thead th.sorting_asc::after,
.table thead th.sorting_desc::after {
    opacity: 0.72;
    background-image: linear-gradient(#0d6efd, #0d6efd);
}

/* En-têtes tableaux dashboard : tri DataTables + curseur pointeur */
.modern-table .table thead th {
    cursor: pointer;
}

/* Première colonne (nom du site) : vert charte */
.modern-table tbody tr:not(.details-row) td:first-child {
    color: var(--primary-color);
    font-weight: 600;
}

/* Gras uniquement : évite conflits avec DataTables / filtres qui réappliquent les styles des cellules */
.table tbody td.site-name-cell {
    font-weight: 700;
    color: var(--primary-color);
}

/* Libellé colonne « site » (en-têtes multi-lignes) */
.table thead th.th-col-site .th-head-line2,
.table-header th.th-col-site .th-head-line2 {
    color: var(--primary-color);
}

/* Première colonne d’en-tête (ex. onglets sans th-col-site) */
.modern-table thead tr th:first-child {
    color: var(--primary-color);
}

.modern-table .consumption-pending {
    font-size: 1.1rem;
    font-weight: 500;
}

.modern-table .td-conso-15j {
    max-width: 9.5rem;
    width: 1%;
    padding-left: 6px;
    padding-right: 6px;
    font-size: 0.8125rem;
    font-variant-numeric: tabular-nums;
}

/* Conso 15j + badge d'analyse (dans la même cellule) */
.conso-cell {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    width: 100%;
}

.conso-cell__value {
    flex: 0 0 auto;
    min-width: 0;
    font-variant-numeric: tabular-nums;
}

.conso-cell__badge {
    flex: 0 1 auto;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    color: var(--dash-muted);
}

.tendance-cell {
    min-width: 0;
}

.tendance-main {
    font-size: 0.875rem;
    font-weight: 500;
}

.tendance-supabase {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.45rem;
    margin-top: 0.28rem;
    line-height: 1.25;
    font-size: 0.7rem;
    font-variant-numeric: tabular-nums;
}

.tendance-metric {
    white-space: nowrap;
}

.tendance-metric + .tendance-metric::before {
    content: "·";
    margin-right: 0.35rem;
    opacity: 0.55;
}

.table thead th.th-multi-line,
.table-header th.th-multi-line,
.table thead th.th-col-site,
.table-header th.th-col-site {
    white-space: normal;
    height: auto;
    min-height: 48px;
    line-height: 1.25;
    padding: 8px 6px;
    vertical-align: middle;
    text-align: center;
}

.table thead th.th-col-site,
.table-header th.th-col-site {
    text-align: left;
}

.th-head-line1 {
    display: block;
    font-size: 0.72rem;
    opacity: 0.95;
}

.th-head-line2 {
    display: block;
    font-size: 0.68rem;
    margin-top: 3px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.35px;
    line-height: 1.15;
    max-width: 5.5rem;
    margin-left: auto;
    margin-right: auto;
}

.table thead th.th-col-site .th-head-line2,
.table-header th.th-col-site .th-head-line2 {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}

/* Colonnes à contenu court : largeur réduite */
.modern-table thead th.th-w-cp { width: 4.25rem; max-width: 4.5rem; }
.modern-table thead th.th-w-num { width: 4.75rem; max-width: 5.25rem; }
.modern-table thead th.th-w-conso {
    width: 4.85rem;
    max-width: 5.35rem;
}
.modern-table thead th.th-w-auto,
.modern-table thead th.th-w-jsc { width: 4.5rem; max-width: 5.25rem; }
.modern-table thead th.th-w-tend {
    min-width: 9.75rem;
    width: 10.5rem;
    max-width: 14rem;
}
.modern-table thead th.th-w-tend .th-head-line2 {
    max-width: none;
}
.modern-table thead th.th-w-cmd,
.modern-table thead th.th-w-robot,
.modern-table thead th.th-w-prepay { width: 3.75rem; max-width: 4.25rem; }
.modern-table thead th.th-w-rupt { width: 5.5rem; max-width: 6.5rem; }
.modern-table thead th.th-w-act {
    width: 5.5rem;
    min-width: 5.75rem;
    max-width: none;
}

.table-actions-external {
    flex-wrap: nowrap;
    white-space: nowrap;
}

.table-actions-external .btn {
    padding: 0.28rem 0.5rem;
    flex-shrink: 0;
}

.table tbody tr {
    transition: none;
    border-left: 3px solid transparent;
}

.table tbody tr:hover {
    background-color: rgba(40, 167, 69, 0.03);
    border-left: 3px solid var(--primary-color);
}

.table tbody td {
    padding: 10px 12px;
    vertical-align: middle;
    border-color: #e9ecef;
    font-size: 0.875rem;
}

.table tbody tr:not(.details-row) {
    cursor: pointer;
    transition: all 0.2s ease;
}

.table tbody tr:not(.details-row):hover {
    background-color: rgba(var(--primary-color-rgb), 0.05) !important;
}

.table tbody tr:not(.details-row).row-expanded {
    background-color: rgba(var(--primary-color-rgb), 0.09) !important;
    border-left: 3px solid var(--primary-color);
}

.table .table-danger {
    background-color: rgba(220, 53, 69, 0.15) !important;
}

.table .table-warning {
    background-color: rgba(255, 193, 7, 0.15) !important;
}

.table .table-danger:hover {
    background-color: rgba(220, 53, 69, 0.25) !important;
}

.table .table-warning:hover {
    background-color: rgba(255, 193, 7, 0.25) !important;
}

/* --- Sensor Row --- */
.sensor-row {
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.sensor-row:hover {
    background-color: rgba(var(--primary-color-rgb), 0.05);
}

.sensor-details {
    background-color: var(--background-color);
    transition: all 0.3s ease;
}

.sensor-details:not(.d-none) {
    animation: slideDown 0.3s ease forwards;
}

/* --- Nav Tabs --- */
.nav-tabs {
    border-bottom: none;
    margin: 0;
}

.nav-tabs .nav-link {
    border: none;
    color: var(--secondary-color);
    padding: 10px 14px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border-radius: 0;
    position: relative;
}

.nav-tabs .nav-link:hover {
    background-color: rgba(var(--primary-color-rgb), 0.06);
    color: var(--primary-color);
}

.nav-tabs .nav-link.active {
    background-color: transparent;
    color: var(--primary-color);
    font-weight: 600;
    border-bottom: 3px solid var(--primary-color);
}

.nav-tabs .nav-link.active::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), #14b8a6);
}

.nav-tabs .nav-item.ms-auto {
    margin-left: auto !important;
}

.tab-pane {
    animation: none;
}

/* --- Anomalies Tab --- */
#anomalies-tab {
    position: relative;
}

.anomalies-tab {
    color: #dc6868 !important;
    border-left: 2px solid #e9ecef !important;
    margin-left: 20px;
}

.anomalies-tab:hover {
    background: rgba(220, 104, 104, 0.1) !important;
    border-color: #dc6868 !important;
    color: #c55555 !important;
}

.anomalies-tab.active {
    background: #dc6868 !important;
    border-color: #dc6868 !important;
    color: white !important;
    border-bottom: 3px solid #dc6868 !important;
}

.anomalies-tab.active::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #dc6868, #c55555);
}

/* --- Badge --- */
.badge {
    padding: 6px 10px;
    font-weight: 500;
    border-radius: 12px;
    font-size: 0.75rem;
    margin: 2px;
}

/* --- Button Primary --- */
.btn-primary {
    background: var(--primary-color);
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.btn-primary:hover {
    background-color: #218838;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
}

/* --- Alert --- */
.alert {
    border-radius: 12px;
    margin-bottom: 20px;
}

/* --- Loader --- */
.loader {
    display: none;
    text-align: center;
    padding: 20px;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-border {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 0.2em;
}

/* --- Ligne détail (clic sur ligne tableau) — refonte DA --- */
.details-row {
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
    border-top: none;
    animation: slideDown 0.28s ease forwards;
}

.details-row:hover {
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%) !important;
}

.details-row > td {
    border-bottom: 1px solid var(--dash-border) !important;
}

.details-cell {
    padding: 0 !important;
    border: none !important;
    vertical-align: top;
}

.details-panel {
    margin: 12px 14px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--dash-border);
    background: var(--dash-surface);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

/* Grille cartes (sans bandeau récap) */
.details-panel__body {
    padding: 16px 16px 18px;
    background: #f8fafc;
}

.details-panel__body--solo {
    padding-top: 18px;
}

.details-card {
    height: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--dash-border);
    background: var(--dash-surface);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.details-card__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(180deg, rgba(var(--primary-color-rgb), 0.08) 0%, transparent 100%);
    border-bottom: 1px solid var(--dash-border);
}

.details-card__icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--primary-color-rgb), 0.12);
    color: var(--primary-color);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.details-card__title {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--secondary-color);
}

.details-card__body {
    padding: 12px 14px 14px;
    flex: 1;
}

.details-kv {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.details-kv__row {
    display: grid;
    grid-template-columns: minmax(0, 38%) minmax(0, 62%);
    gap: 8px 12px;
    align-items: start;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
}

.details-kv__row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.details-kv__dt {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--dash-muted);
    line-height: 1.35;
    padding-top: 2px;
}

.details-kv__dd {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--secondary-color);
    text-align: right;
    line-height: 1.4;
    word-break: break-word;
}

.details-kv__dd--copy {
    cursor: pointer;
    border-radius: 6px;
    padding: 4px 8px;
    margin: -4px -8px;
    transition: background 0.15s ease, color 0.15s ease;
    position: relative;
}

.details-kv__dd--copy:hover {
    background: rgba(var(--primary-color-rgb), 0.08);
    color: var(--primary-color);
}

.copyable-value.copied {
    background: rgba(var(--primary-color-rgb), 0.12) !important;
}

.copyable-value::after {
    content: "Copié";
    position: absolute;
    top: -26px;
    right: 0;
    background: var(--secondary-color);
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    white-space: nowrap;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.copyable-value.copied::after {
    opacity: 1;
}

.details-location-map.location-map {
    height: 180px;
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--dash-border);
    margin: 0 0 12px;
    overflow: hidden;
    z-index: 0;
}

.details-kv--location .details-kv__row:first-child .details-kv__dd {
    text-align: left;
}

.toggle-details {
    padding: 6px 10px;
    transition: all 0.3s ease;
}

.toggle-details i {
    transition: transform 0.3s ease;
}

/* Compat : anciennes classes si HTML legacy */
.details-content {
    margin: 12px 14px 16px;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    padding: 8px 10px;
    background: var(--dash-surface);
    border-radius: 8px;
    border: 1px solid var(--dash-border);
}

.detail-label {
    font-weight: 600;
    color: var(--secondary-color);
    font-size: 0.75rem;
}

.detail-value {
    color: #475569;
    text-align: right;
    flex: 1;
    font-size: 0.8125rem;
}

.location-map {
    height: 200px;
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--dash-border);
}

.location-info {
    background: #f8fafc;
    padding: 10px;
    border-radius: var(--radius-sm);
    margin-top: 10px;
    border: 1px solid var(--dash-border);
}

.location-info .location-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.location-info .location-item:last-child {
    margin-bottom: 0;
}

.location-label {
    font-weight: 600;
    color: var(--secondary-color);
}

.location-value {
    color: #475569;
}

/* --- Carte onglets --- */
.dashboard-tabs-card {
    border: 1px solid var(--dash-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--card-shadow);
}

.dashboard-tabs-card > .card-header {
    background: transparent;
}

.dashboard-tabs-card > .card-header.bg-white {
    border-top: 1px solid var(--dash-border);
    padding-left: 6px;
    padding-right: 6px;
}

/* --- Filtres avancés --- */
.filters-section {
    background: linear-gradient(180deg, #f8fafc 0%, #fff 48%);
    padding: 0;
    border-bottom: 1px solid var(--dash-border) !important;
}

.advanced-filters {
    padding: 18px 20px 20px;
}

.advanced-filters__intro {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.advanced-filters__title-wrap {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.advanced-filters__badge {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(var(--primary-color-rgb), 0.15) 0%, rgba(var(--primary-color-rgb), 0.06) 100%);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.advanced-filters__title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--secondary-color);
    letter-spacing: -0.02em;
}

.advanced-filters__subtitle {
    margin: 0;
    font-size: 0.8rem;
    color: var(--dash-muted);
    line-height: 1.45;
    max-width: 42rem;
}

.advanced-filters__collapse-toggle[aria-expanded="false"] .fa-chevron-down {
    transform: rotate(-90deg);
}

.advanced-filters__collapse-toggle .fa-chevron-down {
    transition: transform 0.2s ease;
    display: inline-block;
}

.advanced-filters__divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--dash-border), transparent);
    margin: 4px 0 18px;
}

.advanced-filters__grid {
    display: grid;
    gap: 14px 16px;
    align-items: end;
}

.advanced-filters__grid--primary {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

@media (min-width: 992px) {
    .advanced-filters__grid--primary {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

.advanced-filters__grid--secondary {
    grid-template-columns: 1fr;
    align-items: stretch;
}

@media (min-width: 768px) {
    .advanced-filters__grid--secondary {
        grid-template-columns: minmax(200px, 1fr) minmax(280px, 2.2fr) auto;
        align-items: end;
    }
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.filter-field--reset {
    justify-content: flex-end;
}

.filter-label {
    color: var(--secondary-color);
    font-weight: 600;
    font-size: 0.72rem;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.filter-label__icon {
    color: var(--primary-color);
    font-size: 0.85rem;
    opacity: 0.9;
}

.filter-label__hint {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    color: var(--dash-muted);
    font-size: 0.68rem;
}

.filter-label--transparent {
    visibility: hidden;
    min-height: 1em;
}

.filter-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--dash-border);
    border-radius: var(--radius-sm);
    background-color: var(--dash-surface);
    color: var(--secondary-color);
    font-size: 0.875rem;
    font-weight: 500;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M3 4.5L6 8l3-3.5H3z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.filter-select:focus {
    outline: none;
    border-color: rgba(var(--primary-color-rgb), 0.55);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb), 0.15);
}

.filter-select:hover {
    border-color: rgba(var(--primary-color-rgb), 0.35);
}

.filter-reset-btn {
    background: var(--secondary-color);
    color: #fff;
    border: none;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.8rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    white-space: nowrap;
}

.filter-reset-btn:hover {
    background: #1e293b;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18);
}

.filter-reset-btn:active {
    transform: translateY(0);
}

.filter-reset-btn i {
    font-size: 0.8rem;
}

/* --- Groupes radio --- */
.filter-radio-group {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

.filter-radio-group--wrap {
    flex-wrap: wrap;
}

.filter-radio-group--segmented {
    background: #f1f5f9;
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--dash-border);
    gap: 4px;
}

.filter-radio-group--chips {
    gap: 8px;
    flex-wrap: wrap;
}

.filter-radio-item {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.filter-radio-group--chips .filter-radio-item {
    flex: 0 1 auto;
}

.filter-radio-item input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.filter-radio-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    background: var(--dash-surface);
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--secondary-color);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    white-space: nowrap;
    width: 100%;
    min-height: 38px;
}

.filter-radio-group--segmented .filter-radio-label {
    border-radius: 6px;
    box-shadow: none;
}

.filter-radio-group--chips .filter-radio-label {
    border: 1px solid var(--dash-border);
    border-radius: 999px;
    padding: 8px 14px;
    width: auto;
    font-size: 0.8rem;
    font-weight: 600;
}

.filter-radio-label:hover {
    background: rgba(var(--primary-color-rgb), 0.08);
    color: var(--secondary-color);
}

.filter-radio-item input[type="radio"]:checked + .filter-radio-label {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 2px 8px rgba(var(--primary-color-rgb), 0.25);
}

.filter-radio-group--segmented .filter-radio-item input[type="radio"]:checked + .filter-radio-label {
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.filter-radio-group--chips .filter-radio-item input[type="radio"]:checked + .filter-radio-label {
    border-color: var(--primary-color);
}

.filter-radio-compact {
    padding: 8px 6px;
    min-width: 0;
}

.filter-radio-compact i {
    font-size: 0.95rem;
}

/* --- Chart Styles --- */
.chart-with-legend {
    display: flex;
    align-items: center;
    gap: 20px;
    justify-content: center;
}

.chart-container {
    position: relative;
    height: 200px;
    width: 200px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-legend-side {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.8rem;
    max-width: 200px;
    flex-grow: 1;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    font-size: 0.8rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.legend-item:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: translateX(2px);
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.legend-text {
    font-size: 0.8rem;
    color: var(--secondary-color);
    font-weight: 500;
    line-height: 1.2;
}

.chart-container canvas {
    transition: opacity 0.3s ease;
}

/* Histogramme « Répartition par consommation » : occupe toute la largeur de la carte */
.chart-container.chart-container-wide {
    width: 100%;
    max-width: 100%;
    height: 280px;
    min-height: 260px;
    display: block;
    position: relative;
}

.chart-container.chart-container-wide canvas {
    max-width: 100%;
}

.chart-updating {
    opacity: 0.6;
}

/* --- France Map --- */
.map-container {
    position: relative;
    height: 280px;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.france-map {
    flex: 1;
    min-height: 200px;
    border-radius: var(--radius-md);
    border: 1px solid var(--dash-border);
    background: #f8fafc;
}

/* Rangée 4 colonnes (XL) : hauteurs homogènes histogramme + carte */
@media (min-width: 1200px) {
    .stats-row-visuals .col-xl-3 .chart-container.chart-container-wide {
        height: 230px;
        min-height: 210px;
    }

    .stats-row-visuals .col-xl-3 .map-container.map-container-inline {
        height: 230px;
    }

    .stats-row-visuals .col-xl-3 .france-map {
        min-height: 180px;
    }

    .stats-row-visuals .map-card-title {
        font-size: 0.8rem;
        line-height: 1.25;
    }
}

.map-legend {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.85rem;
}

.map-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.map-legend .legend-item:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: translateX(2px);
}

.map-legend .legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.map-legend .legend-text {
    font-size: 0.8rem;
    color: var(--secondary-color);
    font-weight: 500;
    line-height: 1.2;
}

/* --- Client Marker --- */
.client-marker {
    background: var(--primary-color);
    border: 2px solid white;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

#franceMapModal .client-marker {
    background: #007bff;
}

.client-marker:hover {
    transform: scale(1.3);
    z-index: 1000;
}

/* --- Main Map Marker (from external CSS) --- */
.main-map-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #007bff;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.main-map-marker.modal-marker {
    width: 16px;
    height: 16px;
}

.main-map-marker i {
    font-size: 8px;
    color: white;
    margin: 0;
    padding: 0;
}

.main-map-marker.modal-marker i {
    font-size: 10px;
}

.main-map-marker:hover {
    transform: scale(1.2);
    background-color: #0056b3;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.main-map-client .custom-tooltip {
    bottom: 100%;
    margin-bottom: 8px;
}

.modal-map-client .custom-tooltip {
    bottom: 100%;
    margin-bottom: 10px;
}

/* --- Custom Tooltip (from external CSS) --- */
.custom-tooltip-container {
    position: relative;
    display: inline-block;
}

.custom-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
    pointer-events: none;
}

.tooltip-content {
    background: white;
    color: #333;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.4;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e0e0e0;
    text-align: center;
}

.tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: white;
}

.custom-tooltip-container:hover .custom-tooltip {
    opacity: 1;
    visibility: visible;
}

.client-tooltip .tooltip-content {
    border-left: 4px solid #28a745;
}

.prestataire-tooltip .tooltip-content {
    border-left: 4px solid #007bff;
}

/* --- Leaflet Popup Custom (from external CSS) --- */
.custom-leaflet-popup .leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    border: none;
    padding: 0;
    overflow: hidden;
}

.custom-leaflet-popup .leaflet-popup-content {
    margin: 0;
    padding: 15px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
}

.client-popup .leaflet-popup-content-wrapper {
    background: white;
    color: #333;
    border-left: 4px solid #28a745;
}

.prestataire-popup .leaflet-popup-content-wrapper {
    background: white;
    color: #333;
    border-left: 4px solid #007bff;
}

.custom-leaflet-popup .leaflet-popup-tip {
    background: white;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.custom-leaflet-popup .leaflet-popup-close-button {
    color: #666;
    font-size: 18px;
    font-weight: bold;
    right: 8px;
    top: 8px;
    width: 20px;
    height: 20px;
    text-align: center;
    line-height: 20px;
    opacity: 0.7;
    transition: all 0.2s;
    text-decoration: none;
}

.custom-leaflet-popup .leaflet-popup-close-button:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    color: #333;
}

/* --- Department Tooltip --- */
.dept-tooltip {
    background: rgba(0, 0, 0, 0.8) !important;
    color: white !important;
    border: none !important;
    border-radius: 4px !important;
    font-size: 11px !important;
    padding: 4px 8px !important;
    font-weight: 500 !important;
}

.dept-tooltip::before {
    border-top-color: rgba(0, 0, 0, 0.8) !important;
}

/* --- Anomaly Styles --- */
.anomaly-badge {
    display: inline-block;
    margin: 2px;
    font-size: 0.75rem;
    border-radius: 4px;
    padding: 4px 8px;
    font-weight: 500;
}

.anomaly-badge.contract {
    background: var(--warning-color);
    color: #000;
}

.anomaly-badge.location {
    background: var(--info-color);
    color: white;
}

.anomaly-badge.siret {
    background: #6c757d;
    color: white;
}

.anomaly-badge.duplicate {
    background: var(--danger-color);
    color: white;
}

.anomaly-row {
    animation: anomalyPulse 2s ease-in-out infinite;
}

.anomaly-tooltip {
    position: relative;
    cursor: help;
}

.anomaly-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
}

.anomaly-tooltip:hover::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
}

/* --- Stats Filtered Indicator --- */
.stats-filtered {
    border: 2px solid rgba(var(--primary-color-rgb), 0.45) !important;
    box-shadow: 0 4px 20px rgba(var(--primary-color-rgb), 0.12) !important;
    transform: translateY(-2px);
    transition: all 0.3s ease;
}

.filter-badge {
    background: rgba(var(--primary-color-rgb), 0.12);
    color: var(--primary-color);
    border: 1px solid rgba(var(--primary-color-rgb), 0.25);
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 8px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    animation: none;
    vertical-align: middle;
}

.filter-badge i {
    font-size: 0.6rem;
    margin-right: 4px;
}

/* --- Volume Display (from external CSS) --- */
.volume-display {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.volume-numbers {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.volume-numbers .current-volume {
    color: var(--primary-color);
    font-size: 1.1em;
}

.volume-numbers .total-volume {
    font-size: 0.9em;
}

.volume-gauge {
    width: 100%;
    padding: 2px 0;
}

.volume-gauge .progress {
    border-radius: 4px;
    background-color: rgba(0, 0, 0, 0.05);
}

.volume-gauge .progress-bar {
    transition: none;
    border-radius: 4px;
}

.volume-text {
    font-size: 0.85em;
    font-style: italic;
    text-align: right;
}

.progress-bar.bg-success {
    background-color: rgba(40, 167, 69, 0.7) !important;
}

.progress-bar.bg-warning {
    background-color: rgba(255, 193, 7, 0.7) !important;
}

.progress-bar.bg-danger {
    background-color: rgba(220, 53, 69, 0.7) !important;
}

/* --- Tank Size Dropdown --- */
.main-tank-size {
    background-color: rgba(40, 167, 69, 0.1) !important;
    font-weight: 600 !important;
    color: var(--primary-color) !important;
}

.main-tank-size:hover {
    background-color: rgba(40, 167, 69, 0.2) !important;
}

/* --- Very Critical Rows --- */
.very-critical {
    background-color: rgba(220, 53, 69, 0.1) !important;
    border-left: 3px solid #dc3545 !important;
}

.very-critical:hover {
    background-color: rgba(220, 53, 69, 0.2) !important;
}

/* --- Cuve inactive: mise en évidence douce (ligne) --- */
.table tbody tr.row-cuve-inactive {
    background-color: rgba(220, 53, 69, 0.07) !important;
    border-left: 3px solid rgba(220, 53, 69, 0.65) !important;
}

.table tbody tr.row-cuve-inactive:hover {
    background-color: rgba(220, 53, 69, 0.11) !important;
    border-left-color: rgba(220, 53, 69, 0.85) !important;
}

/* --- Badges "soft" (moins agressifs que les bg-*) --- */
.badge.badge-soft-danger {
    background-color: rgba(220, 53, 69, 0.14);
    color: #b02a37;
    border: 1px solid rgba(220, 53, 69, 0.25);
}

.badge.badge-soft-warning {
    background-color: rgba(255, 193, 7, 0.22);
    color: #7a5a00;
    border: 1px solid rgba(255, 193, 7, 0.30);
}

.badge.badge-soft-primary {
    background-color: rgba(13, 110, 253, 0.16);
    color: #0a58ca;
    border: 1px solid rgba(13, 110, 253, 0.28);
}

.badge.badge-soft-success {
    background-color: rgba(25, 135, 84, 0.16);
    color: #146c43;
    border: 1px solid rgba(25, 135, 84, 0.28);
}

.badge.badge-soft-info {
    background-color: rgba(13, 202, 240, 0.18);
    color: #055160;
    border: 1px solid rgba(13, 202, 240, 0.30);
}

.badge.badge-soft-secondary {
    background-color: rgba(108, 117, 125, 0.16);
    color: #495057;
    border: 1px solid rgba(108, 117, 125, 0.26);
}

.badge.badge-soft-purple {
    background-color: rgba(111, 66, 193, 0.16);
    color: #5a2ea6;
    border: 1px solid rgba(111, 66, 193, 0.28);
}

.badge.badge-soft-gold {
    background-color: rgba(255, 193, 7, 0.18);
    color: #7a5a00;
    border: 1px solid rgba(255, 193, 7, 0.35);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

td[data-remaining-days="0"],
td[data-remaining-days="1"] {
    color: #dc3545;
    font-weight: bold;
}

td[data-remaining-days="2"],
td[data-remaining-days="3"] {
    color: #ffc107;
    font-weight: bold;
}

.stats-row {
    transition: all 0.3s ease;
}

/* --- Expand Map Button (id + classe) --- */
#expandMapBtn,
.btn-expand-map {
    border-color: rgba(var(--primary-color-rgb), 0.35);
    color: var(--primary-color);
}

#expandMapBtn:hover {
    background-color: var(--primary-color);
    color: white;
}

/* --- Modal Fullscreen Map --- */
.modal-fullscreen .modal-content {
    border: none;
    border-radius: 0;
}

.modal-header {
    background: linear-gradient(135deg, #047857 0%, var(--primary-color) 55%, #0d9488 100%);
    color: white;
    border-bottom: none;
    padding: 15px 20px;
}

.modal-header .modal-title {
    font-weight: 600;
    font-size: 1.2rem;
}

.modal-header .btn-close {
    filter: invert(1);
    opacity: 0.8;
}

.modal-header .btn-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

.modal-header .filter-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.modal-body .legend-item {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    font-size: 0.85rem;
}

.modal-body .legend-item:hover {
    background: white;
    transform: translateX(-2px);
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(40, 167, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}

@keyframes anomalyPulse {
    0%, 100% { background-color: transparent; }
    50% { background-color: rgba(220, 53, 69, 0.05); }
}

/* --- Stats Row Animation --- */
.stats-row > div {
    animation: fadeIn 0.5s ease forwards;
}

.stats-row > div:nth-child(1) { animation-delay: 0.1s; }
.stats-row > div:nth-child(2) { animation-delay: 0.2s; }
.stats-row > div:nth-child(3) { animation-delay: 0.3s; }
.stats-row > div:nth-child(4) { animation-delay: 0.4s; }
.stats-row > div:nth-child(5) { animation-delay: 0.5s; }

.stats-row:nth-child(2) > div:nth-child(1) { animation-delay: 0.6s; }
.stats-row:nth-child(2) > div:nth-child(2) { animation-delay: 0.7s; }
.stats-row:nth-child(2) > div:nth-child(3) { animation-delay: 0.8s; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
    .nav-tabs .nav-link {
        padding: 12px 8px;
        font-size: 0.85rem;
    }

    .nav-tabs .nav-link i {
        display: none;
    }

    .details-panel__body .col-xl-3,
    .details-panel__body .col-md-6 {
        margin-bottom: 12px;
    }

    .details-panel__body .row > div:last-child {
        margin-bottom: 0;
    }

    .details-kv__row {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .details-kv__dd {
        text-align: left;
    }

    .detail-item {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }

    .detail-label {
        min-width: auto;
        margin-bottom: 4px;
        font-size: 0.9rem;
    }

    .detail-value {
        text-align: left;
        font-size: 0.95rem;
    }

    .location-map {
        height: 150px;
    }

    .chart-with-legend {
        flex-direction: column;
        gap: 15px;
    }

    .chart-legend-side {
        max-width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .legend-item {
        padding: 4px 8px;
    }

    .legend-text {
        font-size: 0.75rem;
    }

    .map-container {
        height: 200px;
    }

    .france-map {
        min-height: 150px;
    }

    .map-legend {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .map-legend .legend-item {
        padding: 3px 6px;
    }

    .map-legend .legend-text {
        font-size: 0.75rem;
    }

    .modal-body .position-absolute {
        position: fixed !important;
        bottom: 20px !important;
        top: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        right: auto !important;
        margin: 0 !important;
    }

    .modal-body .d-flex {
        flex-direction: row !important;
        justify-content: center;
    }
}

/* --- Colonne Volume actuel (résumé + jauge) --- */
.volume-actuel-cell {
    min-width: 11rem;
    vertical-align: middle;
}

.volume-cell {
    min-width: 10.5rem;
}

.volume-cell-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    line-height: 1.25;
}

.volume-cell-left {
    flex: 1;
    min-width: 0;
}

.volume-cell-right {
    flex-shrink: 0;
    text-align: right;
}

.volume-current {
    font-weight: 700;
    color: #212529;
}

.volume-percent {
    color: #868e96;
    font-weight: 400;
}

.volume-total {
    color: #868e96;
    font-weight: 400;
    white-space: nowrap;
}

.volume-progress-pill {
    width: 100%;
    height: 9px;
    border-radius: 999px;
    background-color: #e9ecef;
    overflow: hidden;
}

.volume-progress-pill .progress-bar {
    border-radius: 999px;
    min-width: 0;
    max-width: 100%;
    transition: width 0.35s ease;
    box-sizing: border-box;
}
