/* ==========================================================
   MODERN.CSS — Surcouche design "SaaS moderne" (Tailwind)
   Chargée APRÈS style.css. Utilise des variables CSS pour
   rester compatible avec les thèmes clair / sombre / daltonien.
   ========================================================== */

/* ==========================================
   PAGE ANOMALIES / DYSFONCTIONNEMENT / AIDE / LIENS
   Mise en page « bibliothèque » : colonne de
   navigation par section à gauche (sticky),
   grille de cards organisée par section à droite.
   ========================================== */

.anomalies-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.anomalies-settings {
    position: relative;
    flex-shrink: 0;
}

.anomalies-settings > summary {
    list-style: none;
    cursor: pointer;
}

.anomalies-settings > summary::-webkit-details-marker {
    display: none;
}

.anomalies-settings-panel {
    position: absolute;
    z-index: 30;
    top: calc(100% + 8px);
    right: 0;
    width: min(390px, calc(100vw - 32px));
    max-height: min(70vh, 620px);
    overflow-y: auto;
    padding: 16px;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    background: var(--gray-50);
    box-shadow: 0 12px 30px rgba(15, 23, 42, .18);
}

/* --- Accent par section (nav, en-têtes et icons de cards) ---
   Les variables sont posées sur l'élément porteur de data-accent
   (section ou item de nav) et héritées par sa descendance. --- */

.anomaly-nav-item,
.anomaly-card-section {
    --anomaly-accent: var(--m-primary);
    --anomaly-accent-soft: var(--m-primary-soft);
    --anomaly-accent-border: rgba(79, 70, 229, .18);
}

[data-accent="danger"] {
    --anomaly-accent: var(--m-danger);
    --anomaly-accent-soft: var(--m-danger-soft);
    --anomaly-accent-border: rgba(220, 38, 38, .18);
}

[data-accent="warning"] {
    --anomaly-accent: var(--m-warning);
    --anomaly-accent-soft: var(--m-warning-soft);
    --anomaly-accent-border: rgba(217, 119, 6, .18);
}

[data-accent="info"] {
    --anomaly-accent: var(--m-info);
    --anomaly-accent-soft: var(--m-info-soft);
    --anomaly-accent-border: rgba(2, 132, 199, .18);
}

[data-accent="primary"] {
    --anomaly-accent: var(--m-primary);
    --anomaly-accent-soft: var(--m-primary-soft);
    --anomaly-accent-border: rgba(79, 70, 229, .18);
}

[data-accent="success"] {
    --anomaly-accent: var(--m-success);
    --anomaly-accent-soft: var(--m-success-soft);
    --anomaly-accent-border: rgba(5, 150, 105, .18);
}

/* --- Structure générale : [nav] [cards] --- */

.anomalies-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 22px;
    /* stretch (par défaut) : la colonne de nav s'étire sur toute la hauteur
       de la ligne pour que la carte sticky puisse « coller » au défilement. */
}

/* Colonne de navigation des sections */

.anomaly-nav-col {
    min-width: 0;
}

.anomaly-nav-card {
    position: sticky;
    top: calc(var(--topbar-height) + 24px);
    display: grid;
    gap: 3px;
    padding: 12px;
    border: 1px solid var(--gray-200);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: var(--m-shadow-card);
}

[data-theme="dark"] .anomaly-nav-card {
    background: var(--gray-50);
}

.anomaly-nav-label {
    margin: 0 0 6px;
    padding-left: 10px;
    color: var(--gray-400);
    font-size: .64rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.anomaly-section-nav {
    display: grid;
    gap: 3px;
}

.anomaly-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    color: var(--gray-600);
    font-size: .84rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}

.anomaly-nav-item:hover {
    background: var(--gray-50);
    color: var(--gray-900);
}

.anomaly-nav-item:focus-visible {
    outline: 2px solid var(--m-primary);
    outline-offset: 2px;
}

.anomaly-nav-item.is-active {
    background: var(--anomaly-accent-soft);
    color: var(--anomaly-accent);
}

.anomaly-nav-icon {
    display: grid;
    flex: 0 0 30px;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--anomaly-accent-border);
    border-radius: 9px;
    background: var(--anomaly-accent-soft);
    font-size: .95rem;
}

.anomaly-nav-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.anomaly-nav-count {
    flex-shrink: 0;
    min-width: 22px;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--gray-100);
    color: var(--gray-500);
    font-size: .7rem;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
    transition: background .15s ease, color .15s ease;
}

.anomaly-nav-item.is-active .anomaly-nav-count {
    background: var(--anomaly-accent);
    color: #fff;
}

/* Grille de cards (colonne de droite) */

.anomaly-cards-grid {
    display: grid;
    gap: 28px;
    min-width: 0;
}

.anomaly-card-section {
    display: grid;
    gap: 14px;
    min-width: 0;
    scroll-margin-top: calc(var(--topbar-height) + 20px);
}

.anomaly-card-section h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-800);
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: -.01em;
}

[data-theme="dark"] .anomaly-card-section h3 {
    color: #f1f5f9;
}

.anomaly-section-icon {
    display: grid;
    flex: 0 0 32px;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--anomaly-accent-border);
    border-radius: 10px;
    background: var(--anomaly-accent-soft);
    font-size: 1rem;
}

.anomaly-section-title {
    min-width: 0;
    overflow-wrap: anywhere;
}

.anomaly-section-count {
    margin-left: auto;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--anomaly-accent-soft);
    color: var(--anomaly-accent);
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.anomaly-card-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr));
    align-items: stretch;
    gap: 18px;
}

.anomalies-settings-panel form {
    display: grid;
    gap: 8px;
}

.anomaly-card-form-actions,
.anomaly-settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.anomaly-settings-actions {
    flex-shrink: 0;
}

.anomalies-settings-panel label {
    color: var(--gray-700);
    font-size: .82rem;
    font-weight: 600;
}

.anomalies-settings-panel input,
.anomalies-settings-panel select {
    width: 100%;
    min-width: 0;
    margin-bottom: 6px;
    padding: 9px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    background: var(--gray-50);
    color: var(--gray-800);
}

.anomalies-settings-panel textarea {
    width: 100%;
    min-width: 0;
    margin-bottom: 6px;
    padding: 9px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    background: var(--gray-50);
    color: var(--gray-800);
    font: inherit;
    resize: vertical;
}

.anomaly-card-sites-fieldset {
    display: grid;
    gap: 8px;
    margin: 0 0 6px;
    padding: 10px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
}

.anomaly-card-sites-fieldset legend {
    padding: 0 4px;
    color: var(--gray-700);
    font-size: .82rem;
    font-weight: 600;
}

.anomaly-card-sites {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
}

.anomaly-card-sites label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.anomaly-card-sites input {
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.anomaly-card-sites-fieldset small,
.anomaly-settings-sites {
    color: var(--gray-500);
    font-size: .76rem;
}

.anomalies-settings-list {
    display: grid;
    gap: 8px;
    margin-top: 18px;
    color: var(--gray-700);
    font-size: .84rem;
}

.anomaly-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--gray-200);
}

.anomaly-settings-row span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.anomaly-settings-row > div:first-child {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.anomalies-settings-empty,
.anomalies-empty {
    margin: 0;
    padding: 24px;
    color: var(--gray-500);
    text-align: center;
}

.anomaly-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    background: linear-gradient(145deg, var(--gray-50), var(--gray-100));
    box-shadow: var(--m-shadow-card);
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.anomaly-card:hover {
    transform: translateY(-3px);
    border-color: var(--m-primary);
    box-shadow: var(--m-shadow-card-hover);
}

.anomaly-card-open {
    display: flex;
    width: 100%;
    min-height: 204px;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 22px;
    border: 0;
    background: transparent;
    color: var(--gray-800);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.anomaly-card-open:focus-visible {
    outline: 3px solid var(--m-primary);
    outline-offset: -4px;
    border-radius: inherit;
}

.anomaly-card-top {
    display: flex;
    align-items: center;
    gap: 13px;
    width: 100%;
}

.anomaly-card-icon {
    display: grid;
    flex: 0 0 44px;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--anomaly-accent-border);
    border-radius: 13px;
    background: var(--anomaly-accent-soft);
    color: var(--anomaly-accent);
    font-size: 1.2rem;
    font-weight: 800;
}

.anomaly-card-heading {
    min-width: 0;
}

.anomaly-card-open h3 {
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--gray-900);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
}

.anomaly-viewer-description {
    margin: 0;
    color: var(--gray-600);
    font-size: .86rem;
    font-weight: 400;
    line-height: 1.5;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.anomaly-card-description {
    display: -webkit-box;
    width: 100%;
    margin: 0;
    overflow: hidden;
    color: var(--gray-600);
    font-size: .84rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.anomaly-card-password {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--gray-700);
    font-size: .84rem;
    font-weight: 600;
    font-family: inherit;
    text-align: left;
    overflow-wrap: anywhere;
    cursor: pointer;
}

.anomaly-card-password:hover,
.anomaly-card-password:focus-visible {
    color: var(--m-primary);
    text-decoration: underline;
}

.anomaly-card-password:focus-visible {
    outline: 2px solid var(--m-primary);
    outline-offset: 3px;
}

.anomaly-viewer-description {
    margin-top: 5px;
}

.anomaly-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
    margin-top: auto;
    padding-top: 13px;
    border-top: 1px solid var(--gray-200);
}

.anomaly-card-action {
    color: var(--m-primary);
    font-size: .8rem;
    font-weight: 600;
    transition: color .18s ease;
}

.anomaly-card-arrow {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--m-primary-soft);
    color: var(--m-primary);
    font-size: 1rem;
    transition: transform .18s ease, background .18s ease, color .18s ease;
}

.anomaly-card:hover .anomaly-card-arrow {
    transform: translateX(3px);
    background: var(--m-primary);
    color: #fff;
}

[data-theme="dark"] .anomaly-card {
    background: linear-gradient(145deg, var(--gray-50), var(--gray-100));
}

[data-theme="dark"] .anomaly-card-open h3 {
    color: var(--gray-900);
}

.anomaly-viewer-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.anomaly-viewer-toolbar h2 {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--gray-800);
    font-size: 1.2rem;
}

.anomaly-viewer-content {
    overflow: hidden;
    border: 1px solid var(--gray-200);
    border-radius: 14px;
    background: var(--gray-50);
    box-shadow: var(--m-shadow-card);
}

.anomaly-viewer-frame {
    display: block;
    width: 100%;
    height: calc(100vh - var(--topbar-height) - 128px);
    min-height: 480px;
    border: 0;
    background: var(--gray-50);
}

.anomalies-error {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid #fecaca;
    border-radius: 10px;
    background: #fef2f2;
    color: #991b1b;
}

[data-theme="dark"] .anomalies-error {
    border-color: #7f1d1d;
    background: #450a0a;
    color: #fecaca;
}

/* Tablette / mobile : la nav passe au-dessus de la grille,
   en bandeau horizontal défilable. */
@media (max-width: 960px) {
    .anomalies-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .anomaly-nav-card {
        position: static;
        padding: 10px;
    }

    .anomaly-nav-label {
        margin-bottom: 4px;
    }

    .anomaly-section-nav {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: max-content;
        gap: 4px;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .anomaly-nav-item {
        padding: 7px 10px;
        white-space: nowrap;
    }

    .anomaly-cards-grid {
        gap: 22px;
    }

    .anomaly-card-section-grid {
        gap: 14px;
    }
}

@media (max-width: 640px) {
    .anomaly-card-section-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .anomaly-card-open {
        min-height: 180px;
        padding: 18px;
    }

    .anomalies-page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .anomalies-settings {
        align-self: flex-end;
    }

    .anomaly-viewer-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .anomaly-viewer-frame {
        height: calc(100vh - var(--topbar-height) - 160px);
        min-height: 360px;
    }
}

:root {
    --m-primary: #4f46e5;
    --m-primary-soft: #eef2ff;
    --m-success: #059669;
    --m-success-soft: #ecfdf5;
    --m-warning: #d97706;
    --m-warning-soft: #fffbeb;
    --m-info: #0284c7;
    --m-info-soft: #f0f9ff;
    --m-danger: #dc2626;
    --m-danger-soft: #fef2f2;
    --m-sidebar-bg: #0f172a;
    --m-sidebar-surface: rgba(255, 255, 255, 0.04);
    --m-sidebar-border: rgba(148, 163, 184, 0.12);
    --m-shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px -4px rgba(15, 23, 42, 0.08);
    --m-shadow-card-hover: 0 2px 4px rgba(15, 23, 42, 0.06), 0 12px 28px -8px rgba(15, 23, 42, 0.18);
}

[data-theme="dark"] {
    --m-primary-soft: rgba(79, 70, 229, 0.18);
    --m-success-soft: rgba(5, 150, 105, 0.16);
    --m-warning-soft: rgba(217, 119, 6, 0.16);
    --m-info-soft: rgba(2, 132, 199, 0.16);
    --m-danger-soft: rgba(220, 38, 38, 0.16);
}

/* ==========================================
   FOND DE PAGE & TOPBAR
   ========================================== */

body {
    background:
        radial-gradient(1200px 400px at 80% -10%, rgba(79, 70, 229, 0.06), transparent 60%),
        var(--gray-100);
}

body .topbar {
    background: #082e79 url("../uploads/1756881298.jpeg") right 42% / auto 150px no-repeat;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--gray-200);
}

[data-theme="dark"] body .topbar {
    background: #082e79 url("../uploads/1756881298.jpeg") right 42% / auto 150px no-repeat;
}

body .topbar .topbar-title span {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

body .topbar .menu-toggle {
    color: #fff;
}

/* ==========================================
   SIDEBAR — sombre, épurée, accents indigo
   ========================================== */

body .sidebar {
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #0f172a 0%, #111c33 100%);
    border-right: 1px solid var(--m-sidebar-border);
}

body .sidebar .sidebar-header {
    padding: 20px 18px 18px;
    border-bottom: 1px solid var(--m-sidebar-border);
    flex-shrink: 0;
}

body .sidebar .logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

body .sidebar .tw-logo-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--m-primary) 0%, #7c3aed 100%);
    box-shadow: 0 4px 14px -2px rgba(79, 70, 229, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    overflow: hidden;
    flex-shrink: 0;
}

body .sidebar .tw-logo-link img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
}

body .sidebar .logo-text {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #f8fafc;
    line-height: 1.1;
}

body .sidebar .tw-logo-highlight {
    display: block;
    font-size: 0.66rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    color: #7c8aa5;
    margin-top: 3px;
    white-space: nowrap;
    text-transform: none;
}

/* Indicateur de site */
body .sidebar .sidebar-site-info {
    padding: 14px 14px 4px;
    background: transparent;
    border-bottom: none;
    flex-shrink: 0;
}

body .sidebar .site-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.16) 0%, rgba(79, 70, 229, 0.05) 100%);
    border: 1px solid rgba(129, 140, 248, 0.25);
    border-radius: 12px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

body .sidebar .site-indicator:hover {
    border-color: rgba(129, 140, 248, 0.5);
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.24) 0%, rgba(79, 70, 229, 0.08) 100%);
}

body .sidebar .tw-site-dot::before {
    content: '';
    display: block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #818cf8;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

body .sidebar .site-icon-small {
    font-size: 0;
}

body .sidebar .site-name {
    color: #e2e8f0;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

body .sidebar .site-name::before {
    content: 'Site actif';
    display: block;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #818cf8;
    margin-bottom: 1px;
}

/* Caret (flèche du menu déroulant) */
body .sidebar .site-caret {
    margin-left: auto;
    font-size: 0.7rem;
    color: #94a3b8;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

body .sidebar .site-caret.open {
    transform: rotate(180deg);
}

/* Conteneur + menu déroulant */
body .sidebar .site-switcher {
    position: relative;
}

body .sidebar .site-dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    z-index: 60;
    background: #1e293b;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 12px;
    box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.55);
    padding: 8px;
    animation: twDropdownIn 0.15s ease;
}

@keyframes twDropdownIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

body .sidebar .site-dropdown-label {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #64748b;
    padding: 4px 10px 8px;
}

body .sidebar .site-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #cbd5e1;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

body .sidebar .site-dropdown-item:hover {
    background: rgba(79, 70, 229, 0.2);
    color: #ffffff;
}

body .sidebar .site-dropdown-item.current {
    background: rgba(79, 70, 229, 0.16);
    color: #ffffff;
    font-weight: 600;
}

body .sidebar .site-dropdown-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #64748b;
    flex-shrink: 0;
}

body .sidebar .site-dropdown-item.current .site-dropdown-dot,
body .sidebar .site-dropdown-item:hover .site-dropdown-dot {
    background: #818cf8;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

body .sidebar .site-dropdown-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body .sidebar .site-dropdown-check {
    font-size: 0.75rem;
    color: #818cf8;
    font-weight: 700;
}

body .sidebar .site-dropdown-empty {
    padding: 12px 10px;
    font-size: 0.8rem;
    color: #64748b;
    text-align: center;
    font-style: italic;
}

/* Le dropdown reste masqué quand la sidebar est réduite
   (mais affichable quand elle est étendue au survol : .hover-open) */
body .sidebar.collapsed:not(.hover-open) .site-dropdown {
    display: none !important;
}


/* Navigation */
body .sidebar .sidebar-nav {
    flex: 1;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Fine barre de défilement si la liste dépasse */
body .sidebar .sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

body .sidebar .sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.2);
    border-radius: 4px;
}

body .sidebar .nav-section-label {
    font-size: 0.63rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: #94a3b8;
    padding: 2px 12px 12px;
    flex-shrink: 0;
}

body .sidebar .nav-section-label::after {
    content: '';
    display: block;
    height: 1px;
    margin-top: 10px;
    background: linear-gradient(90deg, rgba(129, 140, 248, 0.35), transparent);
}

body .sidebar .nav-btn {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 11px;
    background: transparent;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

/* Tuile d'icône : encadre chaque emoji pour un rendu homogène */
body .sidebar .nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    font-size: 1rem;
    border-radius: 9px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.1);
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

body .sidebar .nav-btn:hover {
    background: var(--m-sidebar-surface);
    color: #f1f5f9;
}

body .sidebar .nav-btn:hover .nav-icon {
    background: rgba(148, 163, 184, 0.14);
    border-color: rgba(148, 163, 184, 0.2);
    transform: translateY(-1px);
}

body .sidebar .nav-btn:focus-visible {
    outline: 2px solid #818cf8;
    outline-offset: 2px;
}

body .sidebar .nav-btn.active {
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.32) 0%, rgba(79, 70, 229, 0.08) 100%);
    color: #ffffff;
    font-weight: 600;
}

body .sidebar .nav-btn.active .nav-icon {
    background: linear-gradient(135deg, var(--m-primary) 0%, #7c3aed 100%);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 12px -2px rgba(79, 70, 229, 0.6);
}

body .sidebar .nav-btn.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 26px;
    background: linear-gradient(180deg, #818cf8, #6366f1);
    border-radius: 0 4px 4px 0;
}

/* Pied de sidebar : ancré en bas de la colonne */
body .sidebar .sidebar-footer {
    margin-top: auto;
    padding: 16px 18px;
    border-top: 1px solid var(--m-sidebar-border);
    flex-shrink: 0;
}

body .sidebar .sidebar-footer-info {
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

body .sidebar .sidebar-presence {
    margin-top: 10px;
    padding: 11px 12px;
    color: #e2e8f0;
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.16) 0%, rgba(79, 70, 229, 0.05) 100%);
    border: 1px solid rgba(129, 140, 248, 0.25);
    border-radius: 12px;
    font-size: 0.72rem;
    line-height: 1.4;
    white-space: normal;
}

body .sidebar .sidebar-presence-description {
    margin: 0 0 7px;
    color: #a5b4fc;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

body .sidebar .sidebar-presence-users {
    gap: 5px;
    margin-top: 0;
    font-size: 0.88rem;
    line-height: 1.3;
}

body .sidebar .sidebar-presence-users li {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 6px 8px;
    color: #f8fafc;
    background: rgba(15, 23, 42, 0.28);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 8px;
    font-weight: 600;
}

body .sidebar .sidebar-presence-users li::before {
    content: '';
    width: 7px;
    height: 7px;
    margin-right: 8px;
    flex-shrink: 0;
    background: #34d399;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.15);
}


/* ==========================================
   CARTES DE STATISTIQUES (Dashboard)
   ========================================== */

body .dashboard-grid {
    gap: 20px;
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

body #page-dashboard .dashboard-grid.has-controller-card {
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

@media (max-width: 1200px) and (min-width: 769px) {
    body #page-dashboard .dashboard-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1200px) {
    body #page-dashboard .dashboard-grid.has-controller-card {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    body #page-dashboard .dashboard-grid.has-controller-card {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    body #page-dashboard .dashboard-grid.has-controller-card {
        grid-template-columns: 1fr;
    }
}

body .dashboard-card {
    position: relative;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--m-shadow-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

body .dashboard-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--m-shadow-card-hover);
    border-color: var(--gray-300);
}

[data-theme="dark"] body .dashboard-card {
    background: var(--gray-50);
}

/* Liseré coloré à gauche de chaque carte */
body .dashboard-card .card-accent {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 4px 0 0 4px;
}

body .tw-accent-success { background: linear-gradient(180deg, #10b981, #059669); }
body .tw-accent-warning { background: linear-gradient(180deg, #fbbf24, #d97706); }
body .tw-accent-info    { background: linear-gradient(180deg, #38bdf8, #0284c7); }
body .tw-accent-primary { background: linear-gradient(180deg, #818cf8, #4f46e5); }
body .tw-accent-danger  { background: linear-gradient(180deg, #f87171, #dc2626); }

/* Tuile d'icône arrondie, fond teinté */
body .dashboard-card .card-icon.tw-icon-tile {
    width: 48px;
    height: 48px;
    font-size: 1.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    margin: 0;
    flex-shrink: 0;
}

body .tw-icon-success { background: var(--m-success-soft); }
body .tw-icon-warning { background: var(--m-warning-soft); }
body .tw-icon-info    { background: var(--m-info-soft); }
body .tw-icon-primary { background: var(--m-primary-soft); }
body .tw-icon-danger  { background: var(--m-danger-soft); }

body .dashboard-card:hover .card-icon.tw-icon-tile {
    background: var(--m-primary-soft);
}

body .dashboard-card:hover .tw-icon-success { background: var(--m-success-soft); }
body .dashboard-card:hover .tw-icon-warning { background: var(--m-warning-soft); }
body .dashboard-card:hover .tw-icon-info    { background: var(--m-info-soft); }
body .dashboard-card:hover .tw-icon-primary { background: var(--m-primary-soft); }
body .dashboard-card:hover .tw-icon-danger  { background: var(--m-danger-soft); }

#page-dashboard .dashboard-card.card-services .card-accent,
#page-dashboard .dashboard-card.card-planning .card-accent {
    background: #26A44B;
}

#page-dashboard .dashboard-card.card-warning .card-accent {
    background: #BF8101;
}

#page-dashboard .dashboard-card.card-agents .card-accent {
    background: #069F9C;
}

#page-dashboard .dashboard-card.card-absent .card-accent {
    background: #666666;
}

#page-dashboard .dashboard-card.card-services .card-icon,
#page-dashboard .dashboard-card.card-planning .card-icon {
    background: #DAF7E2;
    color: #1C863D;
}

#page-dashboard .dashboard-card.card-warning .card-icon {
    background: #FDF0C9;
    color: #A46804;
}

#page-dashboard .dashboard-card.card-agents .card-icon {
    background: #D6F8F8;
    color: #008280;
}

#page-dashboard .dashboard-card.card-absent .card-icon {
    background: #F2F2F2;
    color: #666666;
}

#page-dashboard .dashboard-card.card-controleur .card-accent {
    background: #0E7490;
}

#page-dashboard .dashboard-card.card-controleur .card-icon {
    background: #CFFAFE;
    color: #155E75;
}

body #page-dashboard .dashboard-card .card-icon.tw-icon-tile svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Hiérarchie : valeur dominante, label discret */
body .dashboard-card .card-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

body .dashboard-card .card-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--gray-900);
    font-variant-numeric: tabular-nums;
}

body .dashboard-card .card-value-name {
    font-size: 1.05rem;
    line-height: 1.2;
    letter-spacing: 0;
    overflow-wrap: anywhere;
    font-variant-numeric: normal;
}

[data-theme="dark"] body .dashboard-card .card-value {
    color: #f1f5f9;
}

body .dashboard-card .card-label {
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    line-height: 1.35;
}

/* ==========================================
   SIDEBAR — expansion au survol (mode overlay)
   ========================================== */

/* Quand la barre réduite est survolée : pleine largeur, sans déplacer le contenu */
body .sidebar.hover-open {
    width: var(--sidebar-width);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.45);
    z-index: 200;
}

/* Ré-afficher les libellés masqués par le mode réduit
   (!important nécessaire : les règles .collapsed sont déclarées plus bas
   dans la feuille et l'emporteraient sinon) */
body .sidebar.hover-open .logo-text,
body .sidebar.hover-open .nav-label,
body .sidebar.hover-open .nav-section-label,
body .sidebar.hover-open .sidebar-footer-info {
    display: block !important;
    white-space: nowrap;
}

body .sidebar.hover-open .logo-text {
    display: inline-block !important;
}

body .sidebar.hover-open .sidebar-site-info {
    display: block !important;
}

body .sidebar.hover-open .sidebar-presence {
    display: block !important;
}

body .sidebar.hover-open .tw-logo-highlight {
    white-space: nowrap;
}

/* Transitions douces d'ouverture/fermeture */
body .sidebar {
    transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s ease;
}

body .sidebar .nav-label,
body .sidebar .logo-text,
body .sidebar .nav-section-label,
body .sidebar .sidebar-footer-info {
    transition: opacity 0.15s ease;
}

/* Pas d'expansion au survol sur les petits écrans (tactile) */
@media (max-width: 768px) {
    body .sidebar.hover-open {
        width: var(--sidebar-collapsed);
        box-shadow: none;
    }

    body .sidebar.hover-open .logo-text,
    body .sidebar.hover-open .nav-label,
    body .sidebar.hover-open .nav-section-label,
    body .sidebar.hover-open .sidebar-footer-info,
    body .sidebar.hover-open .sidebar-presence,
    body .sidebar.hover-open .sidebar-site-info {
        display: none !important;
    }
}

/* ==========================================
   EN-TÊTE DU TABLEAU DE BORD
   ========================================== */

body .dash-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

body .dash-header-text h2 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--gray-900);
    line-height: 1.2;
}

[data-theme="dark"] body .dash-header-text h2 {
    color: #f1f5f9;
}

body .dash-header-text p {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-500);
    margin-top: 2px;
}

/* Identifiant de session cliquable : ouvre la modal « Changer le mot de passe » */
body .dash-greeting-user {
    color: var(--primary);
    cursor: pointer;
    border-bottom: 1px dashed var(--primary);
    transition: opacity 0.15s ease;
}

body .dash-greeting-user:hover,
body .dash-greeting-user:focus {
    opacity: 0.75;
    text-decoration: underline;
    outline: none;
}

/* ==========================================
   PANNEAUX DU BAS DE DASHBOARD
   ========================================== */

body .dashboard-bottom {
    align-items: stretch;
    flex: 1;
    grid-template-columns: 1fr 1fr 1fr 1.15fr;
}

/* Page « Mes appels » : grille de 2 colonnes (saisie + tableau personnel) */
body #page-appels .dashboard-bottom {
    grid-template-columns: 340px 1fr 1fr;
}

body #page-retours .dashboard-bottom {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Panneau « Appels de tous les agents » : sur toute la largeur */
body #page-appels .dash-panel-all {
    grid-column: 1 / -1;
}


body .dash-panel {
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    box-shadow: var(--m-shadow-card);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    min-height: 280px;
}

body .dash-panel:hover {
    transform: none;
    border-color: var(--gray-300);
    box-shadow: var(--m-shadow-card-hover);
}

[data-theme="dark"] body .dash-panel {
    background: var(--gray-50);
}

body .dash-panel > h3 {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gray-600);
    border-bottom: 1px solid var(--gray-100);
    padding-bottom: 12px;
    margin-bottom: 14px;
}

body .dash-panel-online > h3 {
    color: #4C4C4C;
}

body .dash-online-header-dot,
body .dash-online-agent-dot {
    display: inline-block;
    flex: 0 0 auto;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #26A44B;
}

body .dash-online-agent-dot {
    width: 7px;
    height: 7px;
}

body .dash-online-time,
body .dash-online-remaining {
    color: #1C863D;
}

body .dash-online-time {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 700;
}

body .dash-online-name {
    color: #4C4C4C;
    font-size: 0.85rem;
    font-weight: 600;
}

body .dash-online-remaining {
    font-size: 0.75rem;
}

body .dash-online-progress-track {
    height: 4px;
    margin-top: 2px;
    overflow: hidden;
    border-radius: 2px;
    background: #DAF7E2;
}

body .dash-online-progress-fill {
    height: 100%;
    border-radius: 2px;
    background: #1C863D;
}

body .dash-panel-upcoming > h3,
body .dash-upcoming-names {
    color: #4C4C4C;
}

body .dash-upcoming-time,
body .dash-upcoming-pagination {
    color: #666666;
}

body .dash-upcoming-date {
    padding: 2px 8px;
    border-radius: 10px;
    background: #F2F2F2;
    color: #666666;
    font-size: 0.7rem;
    font-weight: 600;
}

body .dash-upcoming-time {
    font-size: 0.85rem;
    font-weight: 700;
}

body .dash-upcoming-names {
    font-size: 0.85rem;
    font-weight: 500;
}

body .dash-upcoming-pagination {
    align-self: center;
    padding: 4px 12px;
    font-size: 0.85rem;
}

body .dash-upcoming-item--turquoise {
    --upcoming-time-color: #008280;
    --upcoming-accent-color: #069F9C;
}

body .dash-upcoming-item--ambre {
    --upcoming-time-color: #A46804;
    --upcoming-accent-color: #BF8101;
}

body .dash-upcoming-time {
    color: var(--upcoming-time-color, #008280);
}

body .dash-upcoming-accent,
body .dash-upcoming-avatar {
    border: 2px solid var(--upcoming-accent-color, #069F9C);
}

body .dash-upcoming-accent {
    border-width: 0;
    background: var(--upcoming-accent-color, #069F9C);
}

body .dash-upcoming-avatar-initial {
    border: 2px solid var(--upcoming-accent-color, #069F9C);
    background: var(--upcoming-time-color, #008280);
}

body .dash-panel-today > h3,
body .dash-today-names {
    color: #4C4C4C;
}

body .dash-today-time {
    color: #008280;
    font-size: 0.85rem;
    font-weight: 700;
}

body .dash-today-countdown {
    color: #006666;
    font-size: 0.75rem;
    font-weight: 600;
}

body .dash-today-names {
    font-size: 0.85rem;
    font-weight: 500;
}

body .dash-today-accent {
    background: #069F9C;
}

body .dash-today-avatar,
body .dash-today-avatar-initial {
    border: 2px solid #069F9C;
}

body .dash-today-avatar-initial {
    background: #008280;
    color: #FFFFFF;
}

/* Corps de panneau : occupe l'espace disponible */
body .dash-panel-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 0;
}

body #page-retours .retour-status {
    max-width: 120px;
    min-width: 0;
    padding: 4px 8px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    color: var(--gray-700);
    background: var(--gray-50);
    font-size: 0.75rem;
}

body #page-retours .retour-entry {
    display: block;
}

body #page-retours .retour-entry-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    cursor: pointer;
    list-style: none;
}

body #page-retours .retour-entry-summary::-webkit-details-marker {
    display: none;
}

body #page-retours .retour-entry-summary::after {
    content: "▸";
    color: var(--gray-400);
    transition: transform 0.15s ease;
}

body #page-retours .retour-entry[open] .retour-entry-summary::after {
    transform: rotate(90deg);
}

body #page-retours .retour-entry-summary strong {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

body #page-retours .retour-status-label {
    flex-shrink: 0;
    padding: 3px 8px;
    border-radius: 999px;
    color: var(--gray-600);
    background: var(--gray-100);
    font-size: 0.7rem;
    font-weight: 700;
}

body #page-retours .retour-entry-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    min-width: 0;
    padding: 10px 0 2px 36px;
}

body #page-retours .retour-entry-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

body #page-retours .retour-comments {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    min-width: 0;
}

body #page-retours .retour-comments h4 {
    margin: 0;
    color: var(--gray-600);
    font-size: 0.75rem;
}

body #page-retours .retour-comment {
    min-width: 0;
    padding: 8px 10px;
    background: var(--gray-50);
    border-radius: 8px;
}

body #page-retours .retour-comment-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 10px;
    color: var(--gray-500);
    font-size: 0.7rem;
}

body #page-retours .retour-comment p {
    margin: 4px 0 0;
    color: var(--gray-700);
    font-size: 0.8rem;
    overflow-wrap: anywhere;
}

body #page-retours .retour-comment-form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

body #page-retours .retour-comment-form textarea {
    width: 100%;
    min-width: 0;
    resize: vertical;
    padding: 8px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    color: var(--gray-700);
    background: #ffffff;
    font: inherit;
    font-size: 0.8rem;
}

body #page-retours .retour-comment-form .btn {
    align-self: flex-end;
}

[data-theme="dark"] body #page-retours .retour-comment-form textarea {
    background: var(--gray-100);
}

/* État vide soigné */
body .empty-message {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 28px 16px;
    text-align: center;
    color: var(--gray-400);
    background:
        radial-gradient(circle at 50% 0%, var(--m-primary-soft), transparent 70%);
    border-radius: 12px;
}

body .empty-message-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: 14px;
    box-shadow: var(--m-shadow-card);
}

[data-theme="dark"] body .empty-message-icon {
    background: var(--gray-100);
}

body .empty-message p {
    font-size: 0.85rem;
    font-style: normal;
    font-weight: 500;
    max-width: 240px;
}

/* Items de liste dans les panneaux */
body .dash-list-item {
    border-bottom: 1px solid var(--gray-100);
    border-radius: 8px;
}

body .dash-list-item:last-child {
    border-bottom: none;
}

body .dash-list-item:hover {
    background: var(--gray-50);
    margin: 0 -8px;
    padding-left: 8px;
    padding-right: 8px;
}

/* Journal des mouvements */
body .activity-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

body .activity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.8rem;
    border-radius: 8px;
}

body .activity-item:last-child {
    border-bottom: none;
}

body .dash-panel-activity > h3 {
    color: #4C4C4C;
}

body .activity-item:hover {
    background: var(--gray-50);
}

body .activity-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    background: var(--gray-100);
    border-radius: 8px;
}

body .dash-panel-activity .activity-icon svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

body .activity-message {
    flex: 1;
    min-width: 0;
    color: var(--gray-700);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

body .activity-message-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

body .activity-old {
    color: var(--gray-400);
    text-decoration: line-through;
    text-decoration-thickness: 1px;
    flex-shrink: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
}

body .activity-arrow {
    color: var(--m-primary);
    font-weight: 800;
    flex-shrink: 0;
}

body .activity-new {
    color: var(--gray-900);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

body .activity-details {
    flex-shrink: 0;
    font-size: 0.68rem;
    color: var(--gray-400);
    font-weight: 500;
}

body .activity-date {
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-400);
    font-variant-numeric: tabular-nums;
}

body .activity-time {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--m-primary);
    font-variant-numeric: tabular-nums;
}

[data-theme="dark"] body .activity-message {
    color: var(--gray-300);
}

[data-theme="dark"] body .activity-new {
    color: #f1f5f9;
}

[data-theme="dark"] body .activity-old {
    color: var(--gray-500);
}

[data-theme="dark"] body .activity-icon {
    background: var(--gray-100);
}

body .dash-panel-activity .activity-icon {
    background: #F2F2F2;
    color: #4C4C4C;
}

body .dash-panel-activity .activity-message,
body .dash-panel-activity .activity-new,
body .dash-panel-activity .activity-arrow {
    color: #4C4C4C;
}

body .dash-panel-activity .activity-old,
body .dash-panel-activity .activity-details,
body .dash-panel-activity .activity-date {
    color: #666666;
}

body .dash-panel-activity .activity-time {
    color: #006666;
}

@media (max-width: 1280px) {
    body .dashboard-bottom {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    body .dashboard-bottom {
        grid-template-columns: 1fr;
    }
}


/* ==========================================
   PAGE STATISTIQUES
   ========================================== */

body #page-statistiques.active {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

/* Barre de filtres en carte */
body .stats-toolbar {
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    box-shadow: var(--m-shadow-card);
    padding: 16px 20px;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

[data-theme="dark"] body .stats-toolbar {
    background: var(--gray-50);
}

body .stats-filters {
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
}

body .stats-filters label {
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

body .stats-filters select {
    padding: 9px 14px;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font);
    background: var(--gray-50);
    color: var(--gray-700);
    min-width: 170px;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

body .stats-filters select:hover {
    border-color: var(--gray-300);
}

body .stats-filters select:focus {
    outline: none;
    border-color: var(--m-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* KPI de synthèse */
body .stats-summary {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 10px;
    margin-left: auto;
    flex-wrap: nowrap;
    overflow-x: auto;
}

body .stats-summary-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 10px 16px;
    text-align: left;
    min-width: 96px;
    transition: border-color 0.15s ease, background 0.15s ease;
}

body .stats-summary-card:hover {
    border-color: rgba(79, 70, 229, 0.35);
    background: var(--m-primary-soft);
}

body .stats-summary-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

body .stats-summary-value {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-top: 2px;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

[data-theme="dark"] body .stats-summary-value {
    color: #f1f5f9;
}

/* Grille : tableau large + carte héro */
body .stats-content {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
    align-items: stretch;
}

/* Cartes */
body .stats-card {
    background: #ffffff;
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    box-shadow: var(--m-shadow-card);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

[data-theme="dark"] body .stats-card {
    background: var(--gray-50);
}

body .stats-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-100);
}

body .stats-card h3 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-600);
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

body .stats-card-actions {
    display: flex;
    gap: 8px;
}

body .stats-card-actions .btn {
    font-size: 0.75rem;
    padding: 7px 14px;
    border-radius: 999px;
}

/* Carte héro « Total heures » */
body .stats-hero-card .stats-total-heures {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0;
}

body .stats-total-heures {
    padding: 32px 24px;
    text-align: center;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border-radius: 14px;
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 24px -8px rgba(79, 70, 229, 0.5);
}

body .stats-total-heures::before {
    content: '⏱️';
    position: absolute;
    top: -14px;
    right: -14px;
    font-size: 5.5rem;
    opacity: 0.14;
}

body .stats-heures-value {
    font-size: 3.2rem;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

body .stats-heures-label {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.85;
    margin-top: 8px;
}

/* Tableaux */
body .stats-table-container {
    border-radius: 12px;
    overflow: auto;
    border: 1px solid var(--gray-100);
    flex: 1;
}

body .stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

body .stats-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--gray-200);
    background: var(--gray-50);
    position: sticky;
    top: 0;
    z-index: 1;
    white-space: nowrap;
}

body .stats-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-100);
}

body .stats-table tbody tr:last-child td {
    border-bottom: none;
}

body .stats-table tr:hover td {
    background: var(--gray-50);
}

body .stats-table .text-right {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

body .stats-agents-card {
    margin-top: 0;
}

@media (max-width: 1024px) {
    body .stats-content {
        grid-template-columns: 1fr;
    }

    body .stats-summary {
        grid-auto-flow: row;
        grid-template-columns: repeat(2, 1fr);
        margin-left: 0;
        width: 100%;
    }
}


/* ==========================================
   CARTES GÉNÉRIQUES & ACCUEIL
   ========================================== */

body .content-card {
    border-radius: 16px;
    border: 1px solid var(--gray-200);
    box-shadow: var(--m-shadow-card);
}

body .home-page {
    background: #ffffff url("../uploads/bg_sel_site.png") center / cover no-repeat;
}

/* ==========================================
   THÈME DALTONIEN — contrastes conservés
   ========================================== */

[data-theme="daltonien"] body .dashboard-card .card-value {
    color: #000000;
}

[data-theme="daltonien"] body .sidebar {
    background: #0066CC;
}

[data-theme="daltonien"] body .sidebar .nav-btn.active {
    background: #ffffff;
    color: #0066CC;
}

[data-theme="daltonien"] body .sidebar .tw-logo-link {
    background: #ffffff;
    box-shadow: none;
}

/* ==========================================
   COLLAPSE & RESPONSIVE
   ========================================== */

body .sidebar.collapsed .tw-logo-highlight,
body .sidebar.collapsed .sidebar-site-info,
body .sidebar.collapsed .nav-label,
body .sidebar.collapsed .nav-section-label,
body .sidebar.collapsed .sidebar-footer-info {
    display: none;
}

@media (max-width: 768px) {
    body .dashboard-card .card-value {
        font-size: 1.6rem;
    }

    body .dashboard-card .card-icon.tw-icon-tile {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
}

/* ==========================================
   MISE EN PAGE PLEINE HAUTEUR DU DASHBOARD
   ========================================== */

body #page-dashboard.active {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

/* Accent au survol, cohérent avec la sémantique de la carte */
body .dashboard-card.card-services:hover { border-color: var(--m-success); }
body .dashboard-card.card-warning:hover  { border-color: var(--m-warning); }
body .dashboard-card.card-agents:hover   { border-color: var(--m-info); }
body .dashboard-card.card-planning:hover { border-color: var(--m-primary); }
body .dashboard-card.card-absent:hover   { border-color: var(--m-danger); }

/* ==========================================
   TOPBAR — horloge en « chip » discrète
   ========================================== */

body .topbar-clock {
    padding: 6px 14px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-700);
}

body .topbar-clock .clock-icon {
    font-size: 0.9rem;
    margin-right: 6px;
}

[data-theme="dark"] body .topbar-clock {
    background: var(--gray-100);
    border-color: var(--gray-200);
    color: var(--gray-300);
}

body .menu-toggle {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

body .menu-toggle:hover {
    background: var(--gray-100);
}

/* ==========================================
   PLANNING HEBDOMADAIRE — refonte graphique
   ========================================== */

body .planning-table-wrapper {
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--m-shadow-card);
    background: #ffffff;
}

[data-theme="dark"] body .planning-table-wrapper {
    background: var(--gray-50);
}

/* En-tête des créneaux */
body .planning-table thead th {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--gray-400);
    background: var(--gray-50);
    border: none;
    border-right: 1px solid var(--gray-100);
    padding: 10px 4px;
    position: sticky;
    top: 0;
    z-index: 2;
}

body .planning-table thead th:last-child {
    border-right: none;
}

body .planning-table thead th.h-early {
    background: #eff6ff;
    color: #3b82f6;
}

body .planning-table thead th.h-late {
    background: #fffbeb;
    color: #d97706;
}

body .planning-table thead th.planning-th-end,
body .planning-table td.planning-td-end {
    border-left: 2px solid var(--gray-300);
}

body .planning-table td.planning-td-end {
    background: var(--gray-50);
}

body .planning-table td.planning-td-ferie {
    height: 40px;
    padding: 8px;
    background: var(--gray-100);
    color: var(--gray-600);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-align: center;
    vertical-align: middle;
}

body .planning-sticky-header {
    display: none;
    position: fixed;
    z-index: 40;
    overflow: hidden;
    pointer-events: none;
    background: var(--gray-50);
    box-shadow: 0 2px 5px rgba(15, 23, 42, 0.12);
}

body .planning-sticky-header .planning-sticky-table {
    min-width: 0;
    margin: 0;
    border-spacing: 0;
    table-layout: fixed;
    transform-origin: top left;
}

body .planning-sticky-header .planning-sticky-table thead th {
    position: static;
    top: auto;
    z-index: auto;
}

body .planning-sticky-header .planning-sticky-table thead th:last-child {
    text-align: right;
    padding-right: 3px;
}

body .effectifs-sticky-header {
    display: none;
    position: fixed;
    z-index: 40;
    overflow: hidden;
    pointer-events: none;
    background: var(--gray-50);
    box-shadow: 0 2px 5px rgba(15, 23, 42, 0.12);
}

body .effectifs-sticky-header .effectifs-sticky-table {
    min-width: 0;
    margin: 0;
    border-spacing: 0;
    table-layout: fixed;
    transform-origin: top left;
}

body .effectifs-sticky-header .effectifs-sticky-table thead th {
    position: static;
    top: auto;
    z-index: auto;
}

body .effectifs-sticky-header .effectifs-sticky-table thead th.effectifs-th-agent {
    position: sticky;
    left: 0;
    z-index: 3;
}

/* Cellule jour */
body .planning-td-day {
    font-size: 0.8rem;
    font-weight: 700;
    vertical-align: middle;
    cursor: pointer;
    position: relative;
    transition: filter 0.15s ease;
}

body .planning-td-day:hover {
    filter: brightness(0.96);
}

body .jour-date-small {
    color: var(--gray-500);
    font-weight: 500;
}

body .jour-today-badge {
    display: inline-block;
    margin-top: 5px;
    padding: 2px 8px;
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #ffffff;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    border-radius: 999px;
    box-shadow: 0 2px 6px -1px rgba(79, 70, 229, 0.5);
}

/* Séparateurs aérés entre les jours */
body .planning-separateur td {
    background: transparent !important;
    height: 10px !important;
    border: none !important;
}

/* Cellules vides : cliquables, avec repère « + » au survol */
body .planning-td-empty {
    cursor: pointer;
    border-right: 1px solid rgba(148, 163, 184, 0.15);
    transition: background 0.12s ease;
    position: relative;
}

body .planning-td-empty:last-child {
    border-right: none;
}

body .planning-td-empty:hover {
    background: rgba(79, 70, 229, 0.10) !important;
    box-shadow: inset 0 0 0 2px rgba(79, 70, 229, 0.35);
}

body .planning-td-empty:hover::after {
    content: '+';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--m-primary);
    pointer-events: none;
}

/* Journée entièrement libre : invite permanente sur la première cellule vide */
body .planning-day-empty .planning-td-empty:nth-of-type(2)::after {
    content: '＋ Ajouter un créneau';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--gray-400);
    pointer-events: none;
    opacity: 0.7;
    white-space: nowrap;
}

body .planning-day-empty .planning-td-empty:nth-of-type(2):hover::after {
    content: '+';
    left: auto;
    top: auto;
    transform: none;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--m-primary);
    opacity: 1;
}

@media print {
    body .planning-day-empty .planning-td-empty:nth-of-type(2)::after {
        content: none;
    }

    body .planning-empty-banner {
        display: none;
    }
}

/* Ligne du jour courant : liseré + légère surbrillance */
body .planning-row-today td {
    box-shadow: inset 3px 0 0 0 var(--m-primary);
}

/* Barres de créneau */
body .planning-bar {
    border-radius: 8px;
    box-shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.25);
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 55%) !important;
    cursor: grab;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease, opacity 0.15s ease;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

body .planning-bar:active {
    cursor: grabbing;
}

/* Barre en cours de glisser-déposer */
body .planning-bar.dragging {
    opacity: 0.35;
    transform: scale(0.98);
}

/* Cible de dépôt survolée */
body td.planning-drop-hover {
    background: rgba(79, 70, 229, 0.18) !important;
    box-shadow: inset 0 0 0 2px var(--m-primary);
}

body td.planning-drop-hover.planning-td-empty::after {
    content: '+' !important;
    opacity: 1;
    left: auto;
    top: auto;
    transform: none;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--m-primary);
}

/* Ligne d'ajout sous les pistes d'un jour */
body .planning-row-add td {
    height: 26px;
    border: none !important;
    background: transparent !important;
}

body .planning-td-add-day {
    text-align: center;
    color: var(--gray-400);
    font-weight: 800;
    font-size: 0.9rem;
}

body .planning-td-add-cell {
    cursor: pointer;
    color: var(--gray-400);
    font-size: 0.74rem;
    font-weight: 600;
    padding-left: 14px !important;
    border-top: 1px dashed var(--gray-300) !important;
    transition: color 0.15s ease, background 0.15s ease;
}

body .planning-td-add-cell:hover {
    color: var(--m-primary);
    background: rgba(79, 70, 229, 0.06) !important;
}

body .planning-td-add-cell:hover::before {
    content: none;
}

@media print {
    body .planning-row-add {
        display: none;
    }
}

/* Sélection de plusieurs créneaux vides au clic-glissé */
body td.planning-select-range {
    background: rgba(79, 70, 229, 0.18) !important;
    box-shadow: inset 0 0 0 2px var(--m-primary);
}

body td.planning-select-range:first-of-type::before,
body td.planning-select-range::before {
    content: none;
}

/* Évite la sélection de texte pendant les glissés sur le planning */
body .planning-table {
    user-select: none;
    -webkit-user-select: none;
}

body .planning-bar:hover {
    transform: translateY(-2px) scale(1.005);
    box-shadow: 0 6px 16px -4px rgba(15, 23, 42, 0.35);
    filter: saturate(1.15);
    z-index: 3;
}

body .planning-bar-name {
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body .planning-bar-time {
    display: inline-block;
    padding: 1px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    white-space: nowrap;
}

/* Bannière semaine vide */
body .planning-empty-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    background: var(--m-primary-soft);
    border: 1px solid rgba(79, 70, 229, 0.25);
    border-radius: 14px;
    padding: 14px 20px;
    margin-bottom: 16px;
}

body .planning-empty-banner-icon {
    font-size: 1.6rem;
}

body .planning-empty-banner-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 200px;
    color: var(--gray-700);
    font-size: 0.9rem;
}

body .planning-empty-banner-text span {
    color: var(--gray-500);
    font-size: 0.82rem;
}

/* ==========================================
   SÉLECTEUR D'AGENTS EN PUCES (anti-glissement)
   ========================================== */

/* Le multi-select natif est masqué : les puces sont l'interface */
body #plageAgentsSelect,
body #planningPlageAgentsSelect {
    display: none !important;
}

body .agent-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
    padding: 10px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
}

body .agent-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 999px;
    background: #ffffff;
    color: var(--gray-600);
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

body .agent-chip::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gray-300);
    transition: background 0.12s ease, box-shadow 0.12s ease;
}

body .agent-chip:hover {
    border-color: var(--m-primary);
    color: var(--m-primary);
    transform: translateY(-1px);
}

body .agent-chip.selected {
    background: var(--m-primary);
    border-color: var(--m-primary);
    color: #ffffff;
    font-weight: 600;
}

body .agent-chip.selected::before {
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}

body .agent-chips-empty {
    font-size: 0.78rem;
    color: var(--gray-400);
    font-style: italic;
    text-align: center;
    width: 100%;
    padding: 4px;
}

[data-theme="dark"] body .agent-chips {
    background: var(--gray-100);
    border-color: var(--gray-200);
}

[data-theme="dark"] body .agent-chip {
    background: var(--gray-100);
    border-color: var(--gray-300);
    color: var(--gray-300);
}

[data-theme="dark"] body .agent-chip.selected {
    background: var(--m-primary);
    border-color: var(--m-primary);
    color: #ffffff;
}

/* ==========================================
   SEMAINES D'ENQUÊTE DE SATISFACTION
   ========================================== */

body .enquete-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    background: linear-gradient(90deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #f59e0b;
    border-left: 5px solid #f59e0b;
    border-radius: 12px;
    padding: 12px 18px;
    margin-bottom: 16px;
}

body .enquete-banner-icon {
    font-size: 1.5rem;
}

body .enquete-banner-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: #92400e;
    font-size: 0.9rem;
}

body .enquete-banner-text strong {
    font-weight: 700;
}

body .enquete-banner-text span {
    font-size: 0.8rem;
    color: #b45309;
}

/* Bouton « Enquêtes » quand la semaine affichée est marquée */
body #enqueteBtn.enquete-active {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #ffffff;
    font-weight: 700;
}

body #enqueteBtn.enquete-active:hover {
    background: #d97706;
}

/* Liste dans la modal */
body .enquete-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
}

body .enquete-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-700);
}

body .enquete-list-item .btn {
    padding: 3px 10px;
}

[data-theme="dark"] body .enquete-banner {
    background: rgba(245, 158, 11, 0.12);
    border-color: #f59e0b;
}

[data-theme="dark"] body .enquete-banner-text {
    color: #fcd34d;
}

[data-theme="dark"] body .enquete-banner-text span {
    color: #fbbf24;
}

[data-theme="dark"] body .enquete-list-item {
    background: var(--gray-100);
    border-color: var(--gray-200);
    color: var(--gray-300);
}

/* ==========================================
   FORMULAIRE PLAGES — helpers & date calculée
   ========================================== */

body .date-display {
    padding: 9px 14px;
    background: var(--m-primary-soft);
    border: 1px solid rgba(79, 70, 229, 0.2);
    border-radius: 10px;
    font-weight: 700;
    color: var(--m-primary);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    min-height: 38px;
    display: flex;
    align-items: center;
}

[data-theme="dark"] body .date-display {
    color: #c7d2fe;
}

body .agents-select-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

body .agents-select-actions .btn {
    font-size: 0.72rem;
    padding: 5px 12px;
    border-radius: 999px;
}

body #plageAgentsSelect {
    border-radius: 10px;
    border: 1px solid var(--gray-200);
    background: var(--gray-50);
    padding: 8px;
}

body #plageAgentsSelect:focus {
    outline: none;
    border-color: var(--m-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Liste temporaire de plages */
body .plages-temp-list {
    background: var(--gray-50) !important;
    border: 1px solid var(--gray-100);
    border-radius: 12px !important;
    padding: 12px !important;
}

body .plage-temp-item {
    border-radius: 8px !important;
    border-left-width: 4px !important;
}

/* ==========================================
   PLANNING CONTRÔLEUR
   ========================================== */

body .controleur-planning-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 14px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
}

body .controleur-planning-toolbar strong {
    min-width: 220px;
    color: var(--gray-800);
    text-align: center;
}

body .controleur-planning-calendar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

body .controleur-week {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 12px;
    min-height: 280px;
    padding: 16px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-top: 3px solid var(--m-primary);
    border-radius: 8px;
}

body .controleur-week-current {
    background: #d1fae5;
    border: 2px solid #15803d;
    border-top-width: 5px;
    box-shadow: 0 6px 18px rgba(21, 128, 61, 0.22);
}

[data-theme="dark"] body .controleur-week-current {
    background: #1f5134;
    border-color: #4ade80;
    border-top-color: #4ade80;
}

body .controleur-current-badge {
    align-self: flex-start;
    padding: 4px 8px;
    border-radius: 4px;
    background: #15803d;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.2;
}

[data-theme="dark"] body .controleur-current-badge {
    background: #4ade80;
    color: #052e16;
}

body .controleur-week-current h3,
body .controleur-week-current time {
    color: #14532d;
}

[data-theme="dark"] body .controleur-week-current h3,
[data-theme="dark"] body .controleur-week-current time {
    color: #dcfce7;
}

body .controleur-week h3 {
    margin: 0;
    color: var(--gray-800);
    font-size: 0.9rem;
}

body .controleur-week time {
    display: block;
    margin-top: 5px;
    color: var(--gray-500);
    font-size: 0.78rem;
}

body .controleur-week-assignments {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
}

body .controleur-week-assignment {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

body .controleur-week label {
    color: var(--gray-600);
    font-size: 0.72rem;
    font-weight: 600;
}

body .controleur-week select {
    width: 100%;
    min-height: 40px;
    padding: 8px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    background: #fff;
    color: var(--gray-800);
    font: inherit;
}

[data-theme="dark"] body .controleur-week {
    background: var(--gray-50);
}

[data-theme="dark"] body .controleur-week select {
    background: var(--gray-100);
    color: var(--gray-800);
}

@media (max-width: 900px) {
    body .controleur-planning-calendar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    body .controleur-planning-calendar {
        grid-template-columns: 1fr;
    }

    body .controleur-planning-toolbar strong {
        order: -1;
        width: 100%;
    }
}

/* ==========================================
   PIED DE PAGE (app-footer)
   ========================================== */

body .app-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 24px;
    background: #ffffff;
    border-top: 1px solid var(--gray-200);
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* app.js pose un style inline `display:block` sur .main-content (selectSite),
   ce qui casse le flex-column : on le neutralise pour que .pages (flex:1)
   remplisse l'écran et que le footer reste collé en bas. */
body .main-content {
    display: flex !important;
    flex-direction: column !important;
    min-height: 100vh !important;
}

/* .pages doit pouvoir grandir à l'intérieur */
body .pages {
    flex: 1 0 auto;
}

[data-theme="dark"] body .app-footer {
    background: var(--gray-50);
    border-top-color: var(--gray-200);
}

body .app-footer-left,
body .app-footer-right {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

body .app-footer-logo {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    object-fit: cover;
}

body .app-footer-brand {
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--gray-800);
    font-size: 0.8rem;
}

[data-theme="dark"] body .app-footer-brand {
    color: #f1f5f9;
}

body .app-footer-sep {
    width: 1px;
    height: 14px;
    background: var(--gray-200);
    flex-shrink: 0;
}

body .app-footer-muted {
    color: var(--gray-400);
    white-space: nowrap;
}

body .app-footer-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Pastille verte du footer (réutilise l'animation de la sidebar) */
body .app-footer .sidebar-footer-dot {
    width: 7px;
    height: 7px;
}

body .app-footer-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 999px;
    background: transparent;
    color: var(--gray-600);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

body .app-footer-link:hover {
    background: var(--m-primary-soft);
    border-color: rgba(79, 70, 229, 0.3);
    color: var(--m-primary);
}

[data-theme="dark"] body .app-footer-link {
    color: var(--gray-300);
    border-color: var(--gray-200);
}

@media (max-width: 640px) {
    body .app-footer {
        justify-content: center;
        text-align: center;
        padding: 12px 16px;
    }

    body .app-footer-left,
    body .app-footer-right {
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ==========================================
   PAGE RGPD — Mentions légales & Politique
   de confidentialité (texte statique)
   ========================================== */

/* Une seule colonne de panneaux (contenu long à défilement vertical) */
body #page-rgpd .dashboard-bottom {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

body #page-rgpd .dash-panel {
    min-height: 0;
}

body .rgpd-h4 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-600);
    margin: 18px 0 6px;
}

body .rgpd-h4:first-child {
    margin-top: 0;
}

body .rgpd-p {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--gray-700);
    margin: 0 0 10px;
}

body .rgpd-list {
    margin: 0 0 10px;
    padding-left: 20px;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--gray-700);
}

body .rgpd-list li {
    margin-bottom: 4px;
}

body .rgpd-list li::marker {
    color: var(--gray-400);
}

body .rgpd-link {
    color: var(--m-primary);
    font-weight: 600;
    text-decoration: none;
}

body .rgpd-link:hover {
    text-decoration: underline;
}

body .rgpd-updated {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--gray-200);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gray-500);
}

/* ==========================================
   RESPONSIVE TOTAL — ordinateur / tablette / mobile
   (couche finale : prime sur style.css, chargée avant)
   ========================================== */

/* --- Ajustements généraux (tous formats) --- */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
}

img {
    max-width: 100%;
}

/* L'écran de sélection doit rester accessible quand son contenu dépasse la fenêtre. */
body .home-page {
    overflow-y: auto;
    align-items: flex-start;
}

body .home-container {
    margin: auto;
}

/* Cibles tactiles confortables sur écrans tactiles */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .nav-btn,
    .menu-toggle,
    .toolbar-search input,
    .toolbar-search select {
        min-height: 40px;
    }

    .nav-btn {
        padding: 12px 14px;
    }

    /* Pas d'effet « survol » piégeant sur tactile */
    .site-card:hover,
    .dashboard-card:hover {
        transform: none;
    }
}

/* Fond assombri sous le tiroir latéral (mobile / tablette) */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    opacity: 0;
    pointer-events: none;
    z-index: 150;
    transition: opacity 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
}

/* ==========================================
   TIROIR LATÉRAL — tablette & mobile (≤ 1024px)
   ========================================== */

@media (max-width: 1024px) {
    /* La sidebar devient un tiroir superposé */
    body .sidebar {
        width: 264px;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
        z-index: 200;
        display: block;
    }

    /* Le mode « réduit » desktop n'a plus d'effet ici */
    body .sidebar.collapsed {
        width: 264px;
    }

    body .sidebar.collapsed .logo-text,
    body .sidebar.collapsed .nav-label,
    body .sidebar.collapsed .nav-section-label,
    body .sidebar.collapsed .sidebar-footer-info {
        display: block;
    }

    body .sidebar .nav-btn {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    body .sidebar .nav-badge {
        display: inline-flex;
    }

    body .sidebar.collapsed .sidebar-site-info {
        display: block;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    /* Le contenu n'est plus décalé */
    body .main-content,
    body .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }

    /* Accueil : grille de sites fluide */
    body .sites-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }

    /* En-tête d'accueil lisible partout */
    body .home-header h1 {
        font-size: clamp(1.25rem, 4.5vw, 1.75rem);
    }

    /* Tableaux : largeur réduite avant défilement */
    body .planning-table,
    body .effectifs-table {
        min-width: 720px;
    }
}


/* ==========================================
   TABLETTE ÉTROITE & GRAND MOBILE (≤ 768px)
   ========================================== */

@media (max-width: 768px) {
    /* Topbar compacte */
    body .topbar {
        padding: 8px 12px;
        gap: 10px;
        min-height: var(--topbar-height);
        flex-wrap: wrap;
    }

    body .topbar-clock {
        display: none;
    }

    /* La puce de session reste visible (durée de vie restante) */
    body .topbar-session.topbar-clock {
        display: flex !important;
    }

    body .topbar-title {
        min-width: 0;
    }

    body .topbar-title span {
        font-size: 0.95rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
        display: inline-block;
    }

    /* Pages : marges réduites */
    body .pages {
        padding: 16px;
    }

    /* Barres d'outils : empilement vertical */
    body .page-toolbar,
    body .stats-toolbar,
    body .stats-filters,
    body .effectifs-nav {
        flex-direction: column;
        align-items: stretch;
    }

    body .toolbar-search {
        width: 100%;
    }

    body .toolbar-search input {
        min-width: 0;
        width: 100%;
    }

    body .toolbar-search select {
        flex: 1;
        min-width: 0;
    }

    /* Les boutons prennent au moins 2 par rangée, sans débordement */
    body .page-toolbar .btn,
    body .stats-toolbar .btn {
        flex: 1 1 40%;
        text-align: center;
    }

    /* Contrôles planning hebdo */
    body .planning-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    body .planning-week-label {
        order: -1;
        font-size: 1rem;
    }

    body #effectifsSemaineLabel {
        min-width: 0 !important;
    }

    /* Tableaux : défilement horizontal maîtrisé */
    body .planning-table,
    body .effectifs-table {
        min-width: 640px;
    }

    body .stats-table-container {
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    /* Modales : pleine largeur, ancrées en bas */
    body .modal-overlay {
        padding: 12px;
        align-items: flex-end;
    }

    body .modal-content,
    body .agent-modal-content {
        max-width: none;
        width: 100%;
        max-height: calc(100dvh - 24px);
        border-radius: 16px 16px 0 0;
    }

    body .modal-body {
        padding: 16px;
        max-height: calc(100dvh - 200px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    body .modal-footer {
        flex-wrap: wrap;
        justify-content: stretch;
    }

    body .modal-footer .btn {
        flex: 1 1 auto;
    }

    /* Formulaires : une colonne */
    body .form-row {
        grid-template-columns: 1fr;
    }

    body .form-group input,
    body .form-group select,
    body .form-group textarea {
        font-size: 16px; /* évite le zoom auto iOS */
    }

    /* Grille agents fluide */
    body .agent-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }

    /* Tableau de bord : 2 colonnes */
    body .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    /* Panneaux internes sans débordement */
    body .dash-panel,
    body .content-card,
    body .planning-section,
    body .form-panel {
        min-width: 0;
        overflow-x: hidden;
    }

    /* Accueil */
    body .home-container {
        padding: 24px 16px;
    }

    body .site-card {
        padding: 24px 18px;
    }
}

/* ==========================================
   MOBILE (≤ 480px)
   ========================================== */

@media (max-width: 480px) {
    body .pages {
        padding: 12px;
    }

    body .topbar {
        padding-left: 8px;
        padding-right: 8px;
    }

    /* Tableau de bord : une seule colonne */
    body .dashboard-grid {
        grid-template-columns: 1fr;
    }

    body .dashboard-card {
        padding: 16px;
        gap: 12px;
    }

    /* Boutons pleine largeur, empilés */
    body .page-toolbar .btn,
    body .stats-toolbar .btn,
    body .planning-controls .btn {
        flex: 1 1 100%;
    }

    /* Modales : quasi plein écran */
    body .modal-body {
        padding: 14px 12px;
    }

    body .modal-footer {
        flex-direction: column;
        padding: 12px 14px;
    }

    body .modal-footer .btn {
        width: 100%;
    }

    body .modal-header {
        padding: 14px;
    }

    /* Accueil */
    body .home-container {
        padding: 20px 12px;
    }

    body .home-header {
        margin-bottom: 24px;
    }

    body .sites-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
        margin-bottom: 24px;
    }

    body .site-card {
        padding: 20px 16px;
    }

    body .site-icon img {
        max-height: 128px;
    }

    body .home-header h1 {
        font-size: 1.2rem;
    }

    body .logo-img-large {
        width: 44px;
        height: 44px;
    }

    body .plages-day-filters {
        gap: 4px;
    }

    /* Tables : min-width réduite pour limiter le défilement */
    body .planning-table,
    body .effectifs-table {
        min-width: 560px;
        font-size: 0.72rem;
    }

    /* Agents : une colonne */
    body .agent-grid {
        grid-template-columns: 1fr;
    }

    /* Tiroir : jamais plus large que l'écran */
    body .sidebar {
        width: min(300px, calc(100vw - 64px));
    }
}

/* ==========================================
   TRÈS PETITS ÉCRANS (≤ 360px)
   ========================================== */

@media (max-width: 360px) {
    body .pages {
        padding: 10px;
    }

    body .topbar-title span {
        font-size: 0.85rem;
    }

    body .planning-table,
    body .effectifs-table {
        min-width: 480px;
    }
}

/* ==========================================
   LANDSCAPE MOBILE : hauteur réduite utile
   ========================================== */

@media (max-height: 480px) and (orientation: landscape) {
    body .sidebar {
        overflow-y: auto;
    }

    body .topbar {
        position: static;
    }

    body .modal-content {
        max-height: calc(100vh - 24px);
    }
}

/* ==========================================
   IMPRESSION
   ========================================== */

@media print {
    .sidebar,
    .sidebar-backdrop,
    .topbar,
    .app-footer {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
    }
}

/* ==========================================
   CONNEXION & GESTION DES UTILISATEURS
   ========================================== */

body .login-overlay {
    /* Au-dessus de la page de sélection de site (.home-page, z-index 9999) :
       l'écran de connexion doit rester cliquable quand l'utilisateur n'est pas
       encore authentifié (chemin rare en prod derrière le proxy, qui
       authentifie toujours avant, mais réel en accès direct / tests E2E).
       Reste sous le splash (100000) et le loading overlay (99999). */
    z-index: 20000;
}

body .login-box {
    max-width: 360px;
}

body .users-manager-entry {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    max-width: 720px;
    margin: 0 auto 20px;
    padding: 16px 22px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

body .users-manager-entry:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

body .users-manager-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

body .users-manager-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

body .users-manager-text {
    flex: 1;
    min-width: 0;
    text-align: left;
}

body .users-manager-text strong {
    display: block;
    color: var(--gray-800);
    font-size: 0.98rem;
}

body .users-manager-text small {
    color: var(--gray-400);
    font-size: 0.8rem;
}

body .users-manager-entry .site-arrow {
    color: var(--primary);
    font-weight: 700;
}

body .topbar-session {
    gap: 6px;
}

body .session-logout {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--gray-500);
    padding: 2px 4px;
    border-radius: 6px;
}

body .session-logout:hover {
    background: var(--gray-100);
    color: var(--danger);
}

/* Bouton Déconnexion du menu latéral : repère rouge au survol */
body .nav-btn.nav-logout:hover {
    background: rgba(220, 38, 38, 0.15);
    color: #fca5a5;
}

body .nav-btn.nav-logout:hover .nav-icon {
    transform: translateX(2px);
}

/* Les pages doivent pouvoir rétrécir sous la largeur intrinsèque de leur contenu. */
body .main-content,
body .pages,
body .page {
    min-width: 0;
}

body .pages {
    flex: 1 1 auto;
}

body .page {
    width: 100%;
}

/* Conserver le défilement tactile des tableaux larges sans élargir la page. */
body .planning-table-wrapper,
body .effectifs-grid,
body .stats-table-container {
    max-width: 100%;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
}

body .planning-table-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
}

@media (max-width: 768px) {
    body #page-appels .dashboard-bottom {
        grid-template-columns: minmax(0, 1fr);
    }

    body #page-retours .dashboard-bottom {
        grid-template-columns: minmax(0, 1fr);
    }

    body #page-retours .dash-panel-activity,
    body #page-retours #retList,
    body #page-retours #retList .activity-item,
    body #page-retours #retList .activity-item > div:first-child {
        min-width: 0;
        max-width: 100%;
    }

    body #page-retours .retour-entry-content {
        padding-left: 0;
    }

    body #page-retours .retour-entry-summary {
        flex-wrap: wrap;
    }

    body #page-retours #retList .activity-item strong {
        flex: 1 1 calc(100% - 36px) !important;
        min-width: 0;
        overflow-wrap: anywhere;
    }

    body #page-retours #retList .activity-message {
        display: block;
        overflow: visible;
        overflow-wrap: anywhere;
        text-overflow: clip;
        white-space: normal;
    }

    body #page-retours #retList .activity-item > div:last-child {
        overflow-wrap: anywhere;
    }

    body .plages-pagination > div:first-child {
        width: 100%;
        min-width: 0;
        flex-wrap: wrap;
        justify-content: center;
    }

    body #plagesSemaineLabel {
        min-width: 0 !important;
    }

    body .stats-card,
    body .stats-content > *,
    body .stats-filters > * {
        min-width: 0;
    }
}

.usage-header {
    align-items: center;
    justify-content: space-between;
}

.usage-live {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--gray-600);
    font-size: .84rem;
}

.usage-live span {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, .14);
}

.usage-toolbar {
    display: flex;
    align-items: end;
    gap: 14px;
    flex-wrap: wrap;
    margin: 0 0 18px;
    padding: 14px 16px;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    background: var(--gray-50);
}

.usage-toolbar label {
    display: grid;
    gap: 5px;
    color: var(--gray-600);
    font-size: .8rem;
    font-weight: 600;
}

.usage-toolbar select {
    min-width: 170px;
    padding: 8px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    background: var(--gray-50);
    color: var(--gray-800);
}

.usage-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.usage-metric {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 12px;
    row-gap: 4px;
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--gray-200);
    border-radius: 14px;
    background: var(--gray-50);
    box-shadow: var(--m-shadow-card);
}

.usage-metric-icon {
    grid-row: span 3;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--m-primary-soft);
    font-size: 1.2rem;
}

.usage-metric-label,
.usage-metric small {
    color: var(--gray-500);
    font-size: .78rem;
}

.usage-metric strong {
    overflow-wrap: anywhere;
    color: var(--gray-900);
    font-size: 1.35rem;
}

.usage-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.usage-panel {
    min-width: 0;
    padding: 18px;
}

.usage-panel .stats-card-header {
    padding: 0 0 14px;
}

.usage-chart-legend {
    display: flex;
    gap: 18px;
    margin: 0 0 12px;
    color: var(--gray-500);
    font-size: .76rem;
}

.usage-chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.usage-chart-legend i {
    width: 9px;
    height: 9px;
    border-radius: 3px;
}

.usage-legend-sessions,
.usage-chart-session {
    background: #6366f1;
}

.usage-legend-users,
.usage-chart-users {
    background: #10b981;
}

.usage-legend-active,
.usage-chart-active {
    background: #f59e0b;
}

.usage-active-legend {
    margin-top: 18px;
}

.usage-chart-bars {
    display: flex;
    align-items: end;
    gap: 4px;
    min-height: 176px;
    overflow-x: auto;
    padding: 4px 2px 0;
}

.usage-active-bars {
    min-height: 150px;
}

.usage-chart-column {
    display: flex;
    flex: 1 0 18px;
    flex-direction: column;
    align-items: center;
    justify-content: end;
    min-width: 18px;
    height: 170px;
}

.usage-chart-value {
    min-height: 15px;
    color: var(--gray-500);
    font-size: .64rem;
    white-space: nowrap;
}

.usage-chart-track {
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 2px;
    width: 100%;
    height: 130px;
    border-bottom: 1px solid var(--gray-200);
}

.usage-chart-track span {
    width: min(42%, 12px);
    min-height: 0;
    border-radius: 4px 4px 0 0;
}

.usage-chart-active {
    width: min(55%, 16px) !important;
}

.usage-chart-date {
    min-height: 16px;
    margin-top: 5px;
    color: var(--gray-500);
    font-size: .58rem;
    white-space: nowrap;
}

.usage-pages {
    display: grid;
    gap: 15px;
}

.usage-page-row > div:first-child {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--gray-700);
    font-size: .84rem;
}

.usage-page-row strong {
    color: var(--gray-900);
}

.usage-page-track {
    height: 7px;
    margin-top: 6px;
    overflow: hidden;
    border-radius: 99px;
    background: var(--gray-100);
}

.usage-page-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary-gradient);
}

.usage-table-wrap {
    overflow-x: auto;
}

.usage-table-wrap .stats-table {
    min-width: 500px;
}

.usage-status {
    color: var(--gray-500);
    font-size: .76rem;
}

.usage-status.is-online {
    color: #059669;
    font-weight: 700;
}

.usage-empty {
    margin: 0;
    padding: 24px 12px;
    color: var(--gray-500);
    font-size: .86rem;
    text-align: center;
}

.usage-error {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid #fecaca;
    border-radius: 10px;
    background: #fef2f2;
    color: #991b1b;
}

.usage-disclaimer {
    margin: 14px 0 0;
    color: var(--gray-500);
    font-size: .76rem;
}

[data-theme="dark"] .usage-toolbar {
    background: var(--gray-50);
}

[data-theme="dark"] .usage-error {
    border-color: #7f1d1d;
    background: #450a0a;
    color: #fecaca;
}

@media (max-width: 900px) {
    .usage-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .usage-grid {
        grid-template-columns: 1fr;
    }

    .usage-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .usage-metric {
        padding: 13px;
    }

    .usage-toolbar label,
    .usage-toolbar select {
        width: 100%;
    }
}

@media (max-width: 380px) {
    .usage-metrics {
        grid-template-columns: 1fr;
    }
}

.moa-calls-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 14px 16px;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    background: var(--gray-50);
}

.moa-calls-week-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.moa-calls-date-filters,
.moa-calls-export-actions {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.moa-calls-date-filters label {
    display: grid;
    gap: 5px;
    color: var(--gray-600);
    font-size: .84rem;
    font-weight: 600;
}

.moa-calls-date-filters input {
    min-height: 38px;
    padding: 7px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    background: var(--gray-50);
    color: var(--gray-800);
}

.moa-calls-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.moa-calls-card {
    min-width: 0;
    overflow: hidden;
}

.moa-calls-card-summary {
    color: var(--gray-600);
    font-size: .84rem;
    text-align: right;
}

.moa-calls-card .stats-card-header {
    display: block;
}

.moa-calls-card .stats-card-header h3 {
    margin-bottom: 5px;
}

.moa-calls-chart-scroll,
.moa-calls-table-scroll {
    overflow-x: auto;
}

.moa-calls-chart {
    display: block;
    width: 100%;
    height: auto;
}

.moa-chart-grid-line {
    stroke: var(--gray-200);
    stroke-width: 1;
}

.moa-chart-axis-title,
.moa-chart-tick,
.moa-chart-week-label {
    fill: var(--gray-600);
    font-family: inherit;
}

.moa-chart-axis-title { font-size: 11px; }
.moa-chart-tick { font-size: 10px; }
.moa-chart-week-label { font-size: 10px; }

.moa-chart-target-line {
    stroke: #d97706;
    stroke-width: 1.5;
    stroke-dasharray: 6 4;
}

.moa-chart-bar {
    fill: #4f46e5;
}

.moa-chart-excess {
    fill: #059669;
}

.moa-chart-deficit {
    fill: #e11d48;
}

.moa-calls-legend {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 12px 12px;
    color: var(--gray-600);
    font-size: .7rem;
    flex-wrap: wrap;
}

.moa-calls-legend-bar {
    width: 11px;
    height: 11px;
    border-radius: 3px;
    background: #4f46e5;
}

.moa-calls-legend-excess,
.moa-calls-legend-deficit,
.moa-calls-legend-target {
    width: 11px;
    height: 11px;
    margin-left: 4px;
}

.moa-calls-legend-target {
    width: 20px;
    height: 0;
    border-top: 2px dashed #d97706;
    border-radius: 0;
}

.moa-calls-legend-excess {
    background: #059669;
}

.moa-calls-legend-deficit {
    background: #e11d48;
}

.moa-calls-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    font-size: .78rem;
}

.moa-calls-table th,
.moa-calls-table td {
    padding: 6px 5px;
}

.moa-calls-forecast-input {
    width: 58px;
    min-height: 30px;
    padding: 3px 5px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    background: var(--gray-50);
    color: var(--gray-800);
    text-align: right;
}

.moa-calls-save-forecast {
    margin-left: 3px;
    padding: 4px 6px;
    border: 0;
    border-radius: 5px;
    background: var(--m-primary-soft);
    color: var(--m-primary);
    cursor: pointer;
    font-weight: 700;
}

.moa-calls-table tfoot tr {
    background: var(--primary-bg);
    font-weight: 700;
}

.moa-calls-error {
    padding: 16px;
    border: 1px solid #fecaca;
    border-radius: 10px;
    background: #fef2f2;
    color: #991b1b;
}

.moa-calls-empty {
    padding: 16px;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    background: var(--gray-50);
    color: var(--gray-600);
}

[data-theme="dark"] .moa-calls-toolbar {
    background: var(--gray-50);
}

[data-theme="dark"] .moa-chart-target-line {
    stroke: #f59e0b;
}

@media (max-width: 900px) {
    .moa-calls-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 600px) {
    .moa-calls-toolbar,
    .moa-calls-week-navigation,
    .moa-calls-date-filters,
    .moa-calls-export-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .moa-calls-date-filters input,
    .moa-calls-export-actions .btn {
        width: 100%;
    }

    .moa-calls-card-summary {
        text-align: left;
    }

    .moa-calls-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}
