/* ==========================================================================
   EMTOP Tunisie — Design system (Admin, Responsable, Commercial)
   Inspiré du thème de référence (sidebar sombre, header flottant, cartes blanches).
   Sommaire :
     1. Variables (clair / sombre)       5. Composants (cartes, boutons, formulaires…)
     2. Base & typographie               6. Pages (tableau de bord, connexion, 403)
     3. Utilitaires                      7. Responsive
     4. Layout (sidebar, header, footer) 8. Impression
   ========================================================================== */

/* 1. Variables ============================================================ */
:root {
    /* Identité EMTOP (rouge officiel du logo : #C11B1E) — voir aussi « Identité visuelle » (section 4) */
    --em-brand: #c11b1e;
    --em-brand-rgb: 193, 27, 30;
    --em-brand-light: #d52b2e;
    --em-brand-dark: #931316;
    --em-brand-gradient: linear-gradient(135deg, var(--em-brand-light) 0%, var(--em-brand) 55%, var(--em-brand-dark) 100%);
    --em-logo-sidebar: 130px;          /* logo complet, sidebar déployée */
    --em-logo-topbar: 112px;           /* logo complet, header tablette */
    --em-logo-auth: 210px;             /* logo complet, panneau identité de la connexion */
    --em-tile-radius: 22.5%;           /* arrondi des tuiles : identique aux icônes d'application */

    /* Palette du thème de référence (remplacer --em-primary par var(--em-brand) pour des boutons rouges) */
    --em-primary: #188ae2;
    --em-primary-rgb: 24, 138, 226;
    --em-primary-hover: #1479c7;
    --em-success: #10c469;
    --em-success-rgb: 16, 196, 105;
    --em-warning: #f9c851;
    --em-warning-rgb: 249, 200, 81;
    --em-danger: #ff5b5b;
    --em-danger-rgb: 255, 91, 91;
    --em-info: #35b8e0;
    --em-info-rgb: 53, 184, 224;
    --em-purple: #5b69bc;
    --em-purple-rgb: 91, 105, 188;
    --em-pink: #ff8acc;
    --em-pink-rgb: 255, 138, 204;

    /* Surfaces & textes */
    --em-body-bg: #f0f4f7;
    --em-card-bg: #ffffff;
    --em-body-color: #6c757d;
    --em-heading-color: #4c4c5c;
    --em-muted: #a1abc2;
    --em-border: #edf0f4;
    --em-border-strong: #dee2e6;
    --em-light: #eef2f7;
    --em-band: #f6f8fb;
    --em-input-bg: #ffffff;
    --em-search-bg: #eaeff3;
    --em-hover-bg: #f6f7fb;

    /* Sidebar */
    --em-sidebar-bg: #252630;
    --em-sidebar-color: #9097a7;
    --em-sidebar-hover: #e9ecf2;
    --em-sidebar-title: #6a7187;
    --em-sidebar-active-bg: rgba(255, 255, 255, .07);

    /* Dimensions */
    --em-sidebar-width: 245px;
    --em-sidebar-width-sm: 80px;
    --em-topbar-height: 64px;
    --em-gutter: 24px;
    --em-radius: 6px;
    --em-radius-lg: 8px;
    --em-radius-pill: 50rem;
    --em-shadow: 0 0 35px 0 rgba(154, 161, 171, .15);
    --em-shadow-lg: 0 5px 30px rgba(52, 58, 64, .12);
    --em-transition: .25s ease;

    /* Typographie */
    --em-font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --em-font-size: .9375rem;

    color-scheme: light;
}

html[data-theme="dark"] {
    --em-body-bg: #1a1b21;
    --em-card-bg: #23242d;
    --em-body-color: #a7b0be;
    --em-heading-color: #e3e6ec;
    --em-muted: #7d869a;
    --em-border: #30323d;
    --em-border-strong: #3a3d4a;
    --em-light: #2c2e39;
    --em-band: #282a34;
    --em-input-bg: #1f2028;
    --em-search-bg: #2c2e39;
    --em-hover-bg: #2a2c36;
    --em-sidebar-bg: #1f2028;
    --em-shadow: 0 0 35px 0 rgba(0, 0, 0, .25);
    --em-shadow-lg: 0 5px 30px rgba(0, 0, 0, .45);

    color-scheme: dark;
}

/* 2. Base & typographie =================================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--em-font);
    font-size: var(--em-font-size);
    font-weight: 400;
    line-height: 1.5;
    color: var(--em-body-color);
    background-color: var(--em-body-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    margin: 0 0 .5rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--em-heading-color);
}

h1 { font-size: 1.625rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.1875rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: .875rem; }

p { margin: 0 0 1rem; }

a {
    color: var(--em-primary);
    text-decoration: none;
}

a:hover { color: var(--em-primary-hover); }

img,
svg { vertical-align: middle; }

img {
    max-width: 100%;
    height: auto;
}

strong, b { font-weight: 600; }

small { font-size: .8125rem; }

hr {
    margin: 1rem 0;
    border: 0;
    border-top: 1px solid var(--em-border);
}

:focus-visible {
    outline: 2px solid rgba(var(--em-primary-rgb), .55);
    outline-offset: 2px;
}

.em-icon {
    width: 1.25em;
    height: 1.25em;
    flex-shrink: 0;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 12px;
    z-index: 2000;
    padding: .5rem 1rem;
    border-radius: var(--em-radius);
    background: var(--em-primary);
    color: #fff;
}

.skip-link:focus { top: 12px; color: #fff; }

/* Touches de marque discrètes : sélection de texte et barre de chargement Turbo aux couleurs EMTOP */
::selection { background-color: rgba(var(--em-brand-rgb), .16); }
.turbo-progress-bar { height: 3px; background: var(--em-brand-gradient); box-shadow: 0 0 8px rgba(var(--em-brand-rgb), .5); }

/* 3. Utilitaires ========================================================== */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.d-none { display: none !important; }
.d-flex { display: flex !important; }
.d-block { display: block !important; }
.d-inline-flex { display: inline-flex !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-center { justify-content: center !important; }
.align-items-center { align-items: center !important; }
.flex-wrap { flex-wrap: wrap !important; }
.gap-1 { gap: .25rem !important; }
.gap-2 { gap: .5rem !important; }
.gap-3 { gap: 1rem !important; }
.min-w-0 { min-width: 0; }
.w-100 { width: 100% !important; }
.ms-auto { margin-left: auto !important; }
.m-0 { margin: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: .25rem !important; }
.mb-2 { margin-bottom: .5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.text-center { text-align: center !important; }
.text-end { text-align: right !important; }
.text-muted { color: var(--em-muted) !important; }
.text-heading { color: var(--em-heading-color) !important; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-uppercase { text-transform: uppercase !important; }
.fw-medium { font-weight: 500 !important; }
.fw-semibold { font-weight: 600 !important; }
.text-primary { color: var(--em-primary) !important; }
.text-success { color: var(--em-success) !important; }
.text-warning { color: #d9a514 !important; }
.text-danger { color: var(--em-danger) !important; }
.text-info { color: var(--em-info) !important; }
.text-purple { color: var(--em-purple) !important; }
.text-pink { color: var(--em-pink) !important; }
.text-brand { color: var(--em-brand) !important; }
.bg-success { background-color: var(--em-success) !important; }
.bg-warning { background-color: var(--em-warning) !important; }
.bg-danger { background-color: var(--em-danger) !important; }
.bg-primary { background-color: var(--em-primary) !important; }
.bg-soft-primary { background-color: rgba(var(--em-primary-rgb), .12) !important; }
.bg-soft-success { background-color: rgba(var(--em-success-rgb), .12) !important; }
.bg-soft-warning { background-color: rgba(var(--em-warning-rgb), .18) !important; }
.bg-soft-danger { background-color: rgba(var(--em-danger-rgb), .12) !important; }
.bg-soft-info { background-color: rgba(var(--em-info-rgb), .12) !important; }
.bg-soft-purple { background-color: rgba(var(--em-purple-rgb), .12) !important; }
.bg-soft-pink { background-color: rgba(var(--em-pink-rgb), .15) !important; }
.bg-soft-brand { background-color: rgba(var(--em-brand-rgb), .1) !important; }

/* Grilles responsives (sans dépendance externe) */
.grid {
    display: grid;
    gap: var(--em-gutter);
    margin-bottom: var(--em-gutter);
}

.grid > .card { margin-bottom: 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); }
.grid-dashboard { grid-template-columns: minmax(0, 1fr); align-items: start; }

/* 4. Layout =============================================================== */

/* --- Identité visuelle EMTOP (templates/brand/_logo.html.twig) ------------
   Règles de la charte :
     - logo complet officiel (PNG 480 × 179) et symbole vectoriel : jamais déformés,
       la taille se règle uniquement par la largeur (height: auto, ratio verrouillé) ;
     - fond clair : logo rouge ; fond sombre / mode sombre : logo blanc ;
     - tuile = symbole blanc sur dégradé rouge, même dessin que favicon / icônes d'application ;
     - effets discrets (halo, reflet), désactivés si l'utilisateur limite les animations. */
.em-logo {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    line-height: 0;
    vertical-align: middle;
}

.em-logo-img {
    display: block;
    width: 100%;
    max-width: none;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.em-logo--logo .em-logo-img { aspect-ratio: 480 / 179; }
.em-logo--mark .em-logo-img,
.em-logo--tile .em-logo-img { aspect-ratio: 1; }

/* Variante automatique : rouge sur fond clair, blanche en mode sombre */
.em-logo-on-dark { display: none !important; }
html[data-theme="dark"] .em-logo--auto .em-logo-on-light { display: none !important; }
html[data-theme="dark"] .em-logo--auto .em-logo-on-dark { display: block !important; }

/* Tuile : format icône d'application (apple-touch-icon, PWA) */
.em-logo--tile {
    --em-tile-size: 40px;
    width: var(--em-tile-size);
    height: var(--em-tile-size);
    border-radius: var(--em-tile-radius);
    background:
        radial-gradient(circle at 22% 12%, rgba(255, 255, 255, .24), transparent 70%),
        var(--em-brand-gradient);
    box-shadow:
        0 5px 14px -6px rgba(var(--em-brand-rgb), .6),
        inset 0 1px 0 rgba(255, 255, 255, .2),
        inset 0 -1px 0 rgba(0, 0, 0, .12);
    transition: transform var(--em-transition), box-shadow var(--em-transition);
}

.em-logo--tile .em-logo-img {
    width: 60%;
    filter: drop-shadow(0 1px 1.5px rgba(90, 10, 12, .35));
}

/* Reflet lumineux : masqué par la forme exacte du logo, seuls ses pixels s'illuminent */
.em-logo-shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .85) 50%, transparent 62%) no-repeat;
    background-position: 100% 0;
    background-size: 260% 100%;
    -webkit-mask: url("../images/brand/emtop-logo-white-effsdIH.png") center / 100% 100% no-repeat;
    mask: url("../images/brand/emtop-logo-white-effsdIH.png") center / 100% 100% no-repeat;
    pointer-events: none;
}

@keyframes em-logo-shine {
    from { background-position: 100% 0; }
    to { background-position: 0 0; }
}

@keyframes em-logo-rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.app-wrapper {
    position: relative;
    min-height: 100vh;
    overflow-x: clip;
}

/* --- Sidebar ------------------------------------------------------------ */
.app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    width: var(--em-sidebar-width);
    background-color: var(--em-sidebar-bg);
    transition: width var(--em-transition), transform var(--em-transition);
}

.sidebar-brand {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    height: 88px;
    padding: 12px 20px;
}

/* Halo rouge très doux derrière le logo */
.sidebar-brand::before {
    position: absolute;
    inset: 8px 16px;
    z-index: -1;
    background: radial-gradient(ellipse 60% 55% at 50% 50%, rgba(var(--em-brand-rgb), .2), transparent 72%);
    content: "";
    opacity: .85;
    transition: opacity var(--em-transition);
    pointer-events: none;
}

/* Filet de séparation dégradé sous la marque */
.sidebar-brand::after {
    position: absolute;
    right: 20px;
    bottom: 0;
    left: 20px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(var(--em-brand-rgb), .55) 50%, transparent);
    content: "";
    pointer-events: none;
}

.sidebar-brand:hover::before { opacity: 1; }

.brand-link {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--em-radius);
}

.brand-link:focus-visible { outline-color: rgba(255, 255, 255, .45); outline-offset: 6px; }

.brand-logo-lg {
    width: var(--em-logo-sidebar);
    transition: filter var(--em-transition), transform var(--em-transition);
}

.brand-link:hover .brand-logo-lg,
.brand-link:focus-visible .brand-logo-lg {
    filter: drop-shadow(0 0 10px rgba(var(--em-brand-rgb), .45));
}

.brand-link:hover .brand-logo-lg .em-logo-shine,
.brand-link:focus-visible .brand-logo-lg .em-logo-shine { animation: em-logo-shine 1.1s ease-out; }

.brand-logo-sm { display: none; --em-tile-size: 44px; }
.brand-link:hover .brand-logo-sm { transform: translateY(-1px) scale(1.04); box-shadow: 0 10px 22px -8px rgba(var(--em-brand-rgb), .9), inset 0 1px 0 rgba(255, 255, 255, .2); }

.sidebar-close {
    position: absolute;
    top: 50%;
    right: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .06);
    color: var(--em-sidebar-color);
    cursor: pointer;
    transform: translateY(-50%);
}

.sidebar-close:hover { color: #fff; background: rgba(255, 255, 255, .12); }

/* Bouton rond à cheval sur le bord droit de la sidebar */
.sidebar-toggle-float {
    position: absolute;
    top: calc(12px + (var(--em-topbar-height) / 2) - 21px);
    right: -21px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 5px solid var(--em-body-bg);
    border-radius: 50%;
    background-color: var(--em-sidebar-bg);
    color: #8fa1bc;
    cursor: pointer;
    transition: color var(--em-transition), transform var(--em-transition);
}

.sidebar-toggle-float .em-icon { width: 18px; height: 18px; }
.sidebar-toggle-float:hover { color: #fff; }

.sidebar-search {
    position: relative;
    display: none;
    flex-shrink: 0;
    margin: 0 16px 8px;
}

.sidebar-search .em-icon {
    position: absolute;
    top: 50%;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--em-sidebar-color);
    transform: translateY(-50%);
    pointer-events: none;
}

.sidebar-search .form-control {
    height: 40px;
    padding-left: 40px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: var(--em-radius-pill);
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.sidebar-search .form-control::placeholder { color: var(--em-sidebar-color); }

.sidebar-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .15) transparent;
}

.side-nav {
    margin: 0;
    padding: 4px 0 24px;
    list-style: none;
}

.side-nav-title {
    padding: 18px 24px 8px;
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--em-sidebar-title);
    white-space: nowrap;
}

.side-nav-title:first-child { padding-top: 8px; }

.side-nav-item { position: relative; }

.side-nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 2px 14px;
    padding: 10px 12px;
    border-radius: var(--em-radius);
    font-size: .9375rem;
    font-weight: 500;
    color: var(--em-sidebar-color);
    white-space: nowrap;
    transition: color .15s ease, background-color .15s ease;
}

.side-nav-link .em-icon { width: 20px; height: 20px; }
.side-nav-link .menu-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

a.side-nav-link:hover,
a.side-nav-link:focus-visible {
    color: var(--em-sidebar-hover);
    background-color: rgba(255, 255, 255, .04);
}

.side-nav-link.active {
    color: #fff;
    background-color: var(--em-sidebar-active-bg);
}

.side-nav-link.active::before {
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: -14px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background-color: var(--em-brand);
    content: "";
}

.side-nav-link.active .em-icon { color: #fff; }

.side-nav-link.is-disabled {
    cursor: not-allowed;
    opacity: .55;
}

.side-nav-link-logout:hover { color: var(--em-danger) !important; }

.badge-soon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .07);
    color: var(--em-sidebar-color);
}

.side-nav-link .badge-soon .em-icon { width: 14px; height: 14px; }

.side-nav-item.is-filtered-out,
.side-nav-title.is-filtered-out { display: none; }

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1035;
    background: rgba(17, 18, 24, .5);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--em-transition), visibility var(--em-transition);
}

/* --- Contenu ------------------------------------------------------------ */
.app-content {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    margin-left: var(--em-sidebar-width);
    padding: 0 var(--em-gutter);
    transition: margin-left var(--em-transition);
}

.app-main {
    flex: 1 0 auto;
    min-width: 0;
    padding: 12px 0 0;
}

.app-main:focus { outline: none; }

/* --- Header (topbar) ---------------------------------------------------- */
.app-topbar-wrapper {
    position: sticky;
    top: 0;
    z-index: 1020;
    padding: 12px 0;
    background-color: var(--em-body-bg);
}

.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--em-topbar-height);
    padding: 0 24px;
    border-radius: var(--em-radius-lg);
    background-color: var(--em-card-bg);
    box-shadow: var(--em-shadow);
}

.topbar-copyright {
    margin-top: 6px;
    padding: 0 24px;
    color: var(--em-muted);
    font-size: .75rem;
    line-height: 1.4;
    text-align: right;
}

.topbar-start,
.topbar-end {
    display: flex;
    align-items: center;
    min-width: 0;
}

.topbar-start { flex: 1 1 auto; gap: 16px; }
.topbar-end { flex-shrink: 0; gap: 6px; }

.page-title {
    margin: 0;
    overflow: hidden;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--em-body-color);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--em-body-color);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

.topbar-btn .em-icon { width: 24px; height: 24px; }
button.topbar-btn:hover,
.dropdown.show > .topbar-btn { background-color: var(--em-hover-bg); color: var(--em-heading-color); }

.topbar-toggle { display: none; margin-left: -10px; }

/* Marque dans le header : visible uniquement quand la sidebar est masquée (tablette / mobile) */
.topbar-brand {
    display: none;
    flex-shrink: 0;
    align-items: center;
    align-self: stretch;
    padding-right: 16px;
    border-right: 1px solid var(--em-border);
    border-radius: 0;
}

.topbar-brand .em-logo { transition: transform var(--em-transition), box-shadow var(--em-transition); }
.topbar-brand:hover .em-logo { transform: translateY(-1px); }
.topbar-brand-logo { width: var(--em-logo-topbar); }
.topbar-brand-tile { display: none; --em-tile-size: 34px; }

.topbar-flag svg {
    width: 26px;
    height: 18px;
    border-radius: 4px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .06);
}

.theme-toggle .icon-dark { display: none; }
html[data-theme="dark"] .theme-toggle .icon-dark { display: block; }
html[data-theme="dark"] .theme-toggle .icon-light { display: none; }

/* Recherche */
.topbar-search {
    position: relative;
    width: 230px;
    margin-right: 14px;
}

.topbar-search .search-icon {
    position: absolute;
    top: 50%;
    left: 16px;
    width: 20px;
    height: 20px;
    color: var(--em-muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.topbar-search .form-control {
    height: 42px;
    padding-left: 46px;
    border: 0;
    border-radius: var(--em-radius-pill);
    background-color: var(--em-search-bg);
}

.topbar-search .form-control:focus { box-shadow: 0 0 0 3px rgba(var(--em-primary-rgb), .15); }

.search-results {
    left: 0;
    right: auto;
    width: 100%;
    min-width: 280px;
    max-height: 360px;
    overflow-y: auto;
}

.search-results .dropdown-item small {
    margin-left: auto;
    padding-left: 8px;
    font-size: .75rem;
    color: var(--em-muted);
}

.search-results .dropdown-item.is-current { background-color: var(--em-hover-bg); }

/* Profil */
.topbar-user { margin-left: 8px; }

.topbar-user-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: 260px;
    padding: 4px 6px 4px 4px;
    border: 0;
    border-radius: var(--em-radius-pill);
    background: transparent;
    font: inherit;
    font-weight: 500;
    color: var(--em-body-color);
    cursor: pointer;
}

.topbar-user-toggle:hover { background-color: var(--em-hover-bg); }
.topbar-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user-caret { width: 16px; height: 16px; transition: transform .2s ease; }
.dropdown.show .topbar-user-caret { transform: rotate(180deg); }

/* --- Footer ------------------------------------------------------------- */
.app-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 24px;
    margin-top: 12px;
    padding: 20px 0;
    border-top: 1px solid var(--em-border-strong);
    font-size: .875rem;
    color: #757682;
}

html[data-theme="dark"] .app-footer { color: var(--em-muted); }

.footer-start { display: inline-flex; align-items: center; gap: 10px; }
.footer-mark { width: 20px; opacity: .9; }

.footer-brand {
    font-weight: 600;
    text-decoration: underline;
    text-transform: uppercase;
    font-size: .8125rem;
}

.footer-links { display: flex; flex-wrap: wrap; gap: 6px 28px; }
.footer-links a { color: inherit; }
.footer-links a:hover { color: var(--em-primary); }

/* --- Sidebar compacte (ordinateur) -------------------------------------- */
@media (min-width: 992px) {
    html[data-sidebar="condensed"] .app-sidebar { width: var(--em-sidebar-width-sm); }
    html[data-sidebar="condensed"] .app-content { margin-left: var(--em-sidebar-width-sm); }
    html[data-sidebar="condensed"] .brand-logo-lg { display: none; }
    html[data-sidebar="condensed"] .brand-logo-sm { display: inline-flex; }
    html[data-sidebar="condensed"] .sidebar-brand { padding: 12px; }
    html[data-sidebar="condensed"] .sidebar-brand::after { right: 16px; left: 16px; }
    html[data-sidebar="condensed"] .sidebar-toggle-float { display: none; }
    html[data-sidebar="condensed"] .topbar-toggle { display: inline-flex; }
    html[data-sidebar="condensed"] .sidebar-scroll { overflow: visible; }

    html[data-sidebar="condensed"] .side-nav-title {
        height: 1px;
        margin: 14px 22px;
        padding: 0;
        overflow: hidden;
        background: rgba(255, 255, 255, .08);
        color: transparent;
    }

    html[data-sidebar="condensed"] .side-nav-title:first-child { margin-top: 4px; }

    html[data-sidebar="condensed"] .side-nav-link {
        justify-content: center;
        margin: 2px 12px;
        padding: 12px 0;
    }

    html[data-sidebar="condensed"] .side-nav-link .menu-text,
    html[data-sidebar="condensed"] .side-nav-link .badge-soon { display: none; }

    html[data-sidebar="condensed"] .side-nav-link.active::before { left: -12px; }

    /* Info-bulle au survol en mode compact */
    html[data-sidebar="condensed"] .side-nav-link::after {
        position: absolute;
        top: 50%;
        left: calc(100% + 14px);
        z-index: 10;
        padding: 6px 12px;
        border-radius: var(--em-radius);
        background: var(--em-sidebar-bg);
        box-shadow: var(--em-shadow-lg);
        font-size: .875rem;
        color: #fff;
        white-space: nowrap;
        content: attr(data-tooltip);
        opacity: 0;
        visibility: hidden;
        transform: translate(-6px, -50%);
        transition: opacity .15s ease, transform .15s ease, visibility .15s;
        pointer-events: none;
    }

    html[data-sidebar="condensed"] .side-nav-link:hover::after,
    html[data-sidebar="condensed"] .side-nav-link:focus-visible::after {
        opacity: 1;
        visibility: visible;
        transform: translate(0, -50%);
    }
}

/* 5. Composants =========================================================== */

/* --- Cartes ------------------------------------------------------------- */
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-bottom: var(--em-gutter);
    border: 0;
    border-radius: var(--em-radius);
    background-color: var(--em-card-bg);
    background-clip: border-box;
    box-shadow: var(--em-shadow);
    word-wrap: break-word;
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--em-border);
}

.card-title {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--em-heading-color);
}

.card-body { flex: 1 1 auto; padding: 24px; }

.card-band {
    padding: 10px 24px;
    background-color: var(--em-band);
    text-align: center;
    color: var(--em-heading-color);
}

.card-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--em-border);
}

/* --- Boutons ------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: .5rem 1rem;
    border: 1px solid transparent;
    border-radius: 4px;
    background-color: transparent;
    font-family: inherit;
    font-size: .9375rem;
    font-weight: 500;
    line-height: 1.5;
    color: var(--em-body-color);
    text-align: center;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color .15s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.btn .em-icon { width: 18px; height: 18px; }
.btn:focus-visible { box-shadow: 0 0 0 3px rgba(var(--em-primary-rgb), .25); outline: 0; }
.btn.disabled,
.btn:disabled { pointer-events: none; opacity: .65; }

.btn-sm { gap: 6px; padding: .3125rem .75rem; font-size: .875rem; }
.btn-sm .em-icon { width: 16px; height: 16px; }
.btn-lg { padding: .6875rem 1.25rem; font-size: 1rem; }

.btn-primary { background-color: var(--em-primary); border-color: var(--em-primary); color: #fff; }
.btn-primary:hover { background-color: var(--em-primary-hover); border-color: var(--em-primary-hover); color: #fff; }
.btn-brand { background-color: var(--em-brand); border-color: var(--em-brand); color: #fff; }
.btn-brand:hover { background-color: #a5171a; border-color: #a5171a; color: #fff; }
.btn-success { background-color: var(--em-success); border-color: var(--em-success); color: #fff; }
.btn-success:hover { background-color: #0ea95a; color: #fff; }
.btn-danger { background-color: var(--em-danger); border-color: var(--em-danger); color: #fff; }
.btn-danger:hover { background-color: #f14848; color: #fff; }
.btn-warning { background-color: var(--em-warning); border-color: var(--em-warning); color: #323a46; }
.btn-light { background-color: var(--em-light); border-color: var(--em-light); color: var(--em-heading-color); }
.btn-light:hover { background-color: var(--em-border-strong); color: var(--em-heading-color); }
.btn-outline-primary { border-color: var(--em-primary); color: var(--em-primary); }
.btn-outline-primary:hover { background-color: var(--em-primary); color: #fff; }
.btn-soft-primary { background-color: rgba(var(--em-primary-rgb), .1); color: var(--em-primary); }
.btn-soft-primary:hover { background-color: var(--em-primary); color: #fff; }
.btn-soft-danger { background-color: rgba(var(--em-danger-rgb), .1); color: var(--em-danger); }
.btn-soft-danger:hover { background-color: var(--em-danger); color: #fff; }
.btn-soft-success { background-color: rgba(var(--em-success-rgb), .1); color: var(--em-success); }
.btn-soft-success:hover { background-color: var(--em-success); color: #fff; }
.btn-icon { width: 38px; height: 38px; padding: 0; }
.btn-group-wrap { display: flex; flex-wrap: wrap; gap: 8px; }

/* --- Badges & statuts --------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: .3em .65em;
    border-radius: 4px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.badge .em-icon { width: 14px; height: 14px; }
.badge-soft-primary { background: rgba(var(--em-primary-rgb), .12); color: var(--em-primary); }
.badge-soft-success { background: rgba(var(--em-success-rgb), .12); color: var(--em-success); }
.badge-soft-warning { background: rgba(var(--em-warning-rgb), .18); color: #c99412; }
.badge-soft-danger { background: rgba(var(--em-danger-rgb), .12); color: var(--em-danger); }
.badge-soft-info { background: rgba(var(--em-info-rgb), .12); color: var(--em-info); }
.badge-soft-brand { background: rgba(var(--em-brand-rgb), .1); color: var(--em-brand); }
html[data-theme="dark"] .avatar { background: linear-gradient(135deg, #565a72, #3a3d50); }
html[data-theme="dark"] .badge-soft-brand { background: rgba(var(--em-brand-rgb), .22); color: #ff8a8c; }

.status-dot {
    display: inline-block;
    flex-shrink: 0;
    width: 9px;
    height: 9px;
    margin-right: 6px;
    border-radius: 50%;
    vertical-align: middle;
}

/* --- Alertes ------------------------------------------------------------ */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: var(--em-gutter);
    padding: 12px 16px;
    border: 1px solid transparent;
    border-radius: var(--em-radius);
    font-size: .9375rem;
}

.alert > .em-icon { width: 20px; height: 20px; margin-top: 1px; }
.alert-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.alert-success { background: rgba(var(--em-success-rgb), .1); border-color: rgba(var(--em-success-rgb), .25); color: #0b8a4b; }
.alert-danger { background: rgba(var(--em-danger-rgb), .1); border-color: rgba(var(--em-danger-rgb), .25); color: #d63c3c; }
.alert-warning { background: rgba(var(--em-warning-rgb), .15); border-color: rgba(var(--em-warning-rgb), .35); color: #9a7208; }
.alert-info { background: rgba(var(--em-info-rgb), .1); border-color: rgba(var(--em-info-rgb), .25); color: #1f8aab; }
html[data-theme="dark"] .alert-success { color: #4fe39a; }
html[data-theme="dark"] .alert-danger { color: #ff8c8c; }
html[data-theme="dark"] .alert-warning { color: #f9d47c; }
html[data-theme="dark"] .alert-info { color: #7fd3ee; }

.alert-close {
    display: inline-flex;
    flex-shrink: 0;
    padding: 2px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    opacity: .6;
    cursor: pointer;
}

.alert-close:hover { opacity: 1; }
.alert-close .em-icon { width: 18px; height: 18px; }

/* --- Avatars ------------------------------------------------------------ */
.avatar {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b3d4c, var(--em-sidebar-bg));
    font-weight: 600;
    font-size: .9375rem;
    color: #fff;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.avatar-sm { width: 36px; height: 36px; font-size: .8125rem; }
.avatar-xl { width: 76px; height: 76px; font-size: 1.5rem; }
.avatar-ring { box-shadow: 0 0 0 5px var(--em-card-bg), 0 0 0 7px var(--em-light); }

/* --- Dropdowns ---------------------------------------------------------- */
.dropdown { position: relative; }

.dropdown-menu {
    position: absolute;
    top: calc(100% + 14px);
    right: 0;
    z-index: 1050;
    display: none;
    min-width: 220px;
    padding: 8px 0;
    border: 1px solid var(--em-border);
    border-radius: var(--em-radius);
    background-color: var(--em-card-bg);
    box-shadow: var(--em-shadow-lg);
    text-align: left;
    animation: em-dropdown-in .15s ease-out;
}

.dropdown-menu.show { display: block; }
.dropdown-menu-end { right: 0; left: auto; }
.dropdown-menu-lg { width: 320px; }

@keyframes em-dropdown-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
    padding: 8px 18px 6px;
    font-size: .8125rem;
    font-weight: 600;
    color: var(--em-heading-color);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 18px;
    border: 0;
    background: transparent;
    font: inherit;
    font-size: .9375rem;
    color: var(--em-body-color);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}

.dropdown-item .em-icon { width: 20px; height: 20px; }
a.dropdown-item:hover,
button.dropdown-item:hover,
.dropdown-item:focus-visible { background-color: var(--em-hover-bg); color: var(--em-heading-color); }
.dropdown-item.is-static { cursor: default; }
.dropdown-item.is-static strong { color: var(--em-heading-color); }
.dropdown-item.is-disabled { cursor: not-allowed; opacity: .6; }
.dropdown-item-danger,
.dropdown-item-danger:hover { color: var(--em-danger) !important; }
.dropdown-item-danger:hover { background-color: rgba(var(--em-danger-rgb), .08) !important; }

.dropdown-divider {
    height: 0;
    margin: 6px 0;
    border-top: 1px solid var(--em-border);
}

.dropdown-empty {
    padding: 24px 18px;
    text-align: center;
    color: var(--em-muted);
}

.dropdown-empty p { margin: 8px 0 0; font-size: .875rem; }

.empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--em-light);
}

.empty-icon .em-icon { width: 24px; height: 24px; }

.quick-links {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 4px 10px 6px;
}

.quick-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 6px;
    border-radius: var(--em-radius);
    font-size: .8125rem;
    color: var(--em-body-color);
    text-align: center;
}

.quick-link:hover { background-color: var(--em-hover-bg); color: var(--em-heading-color); }

.quick-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(var(--em-primary-rgb), .1);
    color: var(--em-primary);
}

.quick-link-icon .em-icon { width: 20px; height: 20px; }

/* Interrupteur (paramètres d'affichage) */
.em-switch {
    position: relative;
    flex-shrink: 0;
    width: 34px;
    height: 18px;
    margin-left: auto;
    border-radius: var(--em-radius-pill);
    background: var(--em-border-strong);
    transition: background-color .2s ease;
}

.em-switch::after {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
    content: "";
    transition: transform .2s ease;
}

html[data-theme="dark"] .setting-theme .em-switch,
html[data-sidebar="condensed"] .setting-sidebar .em-switch { background: var(--em-primary); }
html[data-theme="dark"] .setting-theme .em-switch::after,
html[data-sidebar="condensed"] .setting-sidebar .em-switch::after { transform: translateX(16px); }

/* --- Formulaires (compatibles avec le thème bootstrap_5_layout de Symfony) */
.form-label,
form label:not(.form-check-label) {
    display: inline-block;
    margin-bottom: .4rem;
    font-size: .875rem;
    font-weight: 500;
    color: var(--em-heading-color);
}

.form-control,
.form-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="search"],
select,
textarea {
    display: block;
    width: 100%;
    max-width: 100%;
    min-height: 40px;
    padding: .5rem .875rem;
    border: 1px solid var(--em-border-strong);
    border-radius: 4px;
    background-color: var(--em-input-bg);
    font-family: inherit;
    font-size: .9375rem;
    line-height: 1.5;
    color: var(--em-heading-color);
    appearance: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

textarea { min-height: 96px; resize: vertical; }

input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

.form-select,
select {
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2398a6ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M6 9l6 6l6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    background-size: 16px 16px;
}

select[multiple] { padding-right: .875rem; background-image: none; }

select option {
    color: var(--em-heading-color);
    background-color: var(--em-input-bg);
}

select option:checked {
    background-color: var(--em-light);
    font-weight: 600;
}

.form-control::placeholder,
input::placeholder,
textarea::placeholder { color: var(--em-muted); opacity: 1; }

.form-control:focus,
.form-select:focus,
input:focus,
select:focus,
textarea:focus {
    border-color: rgba(var(--em-primary-rgb), .6);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(var(--em-primary-rgb), .12);
}

.form-control:disabled,
.form-select:disabled { background-color: var(--em-light); opacity: .8; }

.form-control.is-invalid,
.form-select.is-invalid { border-color: var(--em-danger); }

.invalid-feedback,
.form-error-message { display: block; margin-top: .3rem; font-size: .8125rem; color: var(--em-danger); }
.form-text,
.help-text { display: block; margin-top: .3rem; font-size: .8125rem; color: var(--em-muted); }

.form-check { display: flex; align-items: center; gap: 8px; min-height: 1.5rem; margin-bottom: .5rem; }

.form-check-input,
input[type="checkbox"],
input[type="radio"] {
    flex-shrink: 0;
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
    accent-color: var(--em-primary);
    cursor: pointer;
}

.form-check-label { font-size: .9375rem; color: var(--em-body-color); cursor: pointer; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: 0 var(--em-gutter);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
}

.input-group { display: flex; align-items: stretch; width: 100%; }
.input-group > .form-control { flex: 1 1 auto; width: 1%; min-width: 0; }
.input-group-text {
    display: flex;
    align-items: center;
    padding: .5rem .875rem;
    border: 1px solid var(--em-border-strong);
    background: var(--em-light);
    font-size: .9375rem;
    color: var(--em-body-color);
    white-space: nowrap;
}

.input-group > :first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group > :last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group > :not(:first-child) { margin-left: -1px; }

.input-icon { position: relative; }
.input-icon > .em-icon {
    position: absolute;
    top: 50%;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--em-muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.input-icon > .form-control { padding-left: 42px; }

/* --- Tableaux ----------------------------------------------------------- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    color: var(--em-body-color);
    vertical-align: middle;
}

.table > :not(caption) > * > * {
    padding: 14px 24px;
    border-bottom: 1px solid var(--em-border);
    background-color: transparent;
    text-align: left;
}

.table > thead > tr > th {
    padding-top: 12px;
    padding-bottom: 12px;
    background-color: var(--em-band);
    font-size: .8125rem;
    font-weight: 600;
    color: var(--em-heading-color);
    white-space: nowrap;
}

.table > tbody > tr:last-child > * { border-bottom: 0; }
.table-hover > tbody > tr:hover > * { background-color: var(--em-band); }
.table-sm > :not(caption) > * > * { padding: 8px 16px; }

/* Cellule « libellé au-dessus de la valeur » (style de la maquette) */
.cell-label {
    display: block;
    margin-bottom: 2px;
    font-size: .8125rem;
    color: var(--em-muted);
    white-space: nowrap;
}

.cell-value {
    display: flex;
    align-items: center;
    font-weight: 500;
    color: var(--em-heading-color);
}

.cell-action { text-align: right !important; white-space: nowrap; }

.table-entity {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.entity-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: rgba(var(--em-primary-rgb), .1);
    color: var(--em-primary);
}

.entity-icon .em-icon { width: 20px; height: 20px; }

/* --- Pagination --------------------------------------------------------- */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--em-border-strong);
    border-radius: 4px;
    background: var(--em-card-bg);
    font-size: .875rem;
    color: var(--em-heading-color);
}

.page-link:hover { background: var(--em-light); color: var(--em-heading-color); }
.page-item.active .page-link { background: var(--em-primary); border-color: var(--em-primary); color: #fff; }
.page-item.disabled .page-link { pointer-events: none; opacity: .5; }

/* 6. Pages ================================================================ */

/* --- Tableau de bord ---------------------------------------------------- */
.welcome-card { overflow: hidden; }

/* Filigrane du symbole EMTOP (décoratif, très léger) */
.welcome-card::after {
    position: absolute;
    top: 50%;
    right: -44px;
    width: 200px;
    aspect-ratio: 1;
    background: url("../images/brand/emtop-mark-fBa8pkU.svg") center / contain no-repeat;
    content: "";
    opacity: .045;
    transform: translateY(-50%);
    pointer-events: none;
}

html[data-theme="dark"] .welcome-card::after {
    background-image: url("../images/brand/emtop-mark-white-S5417uU.svg");
    opacity: .04;
}

.welcome-card .card-body {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 24px;
    background-image: radial-gradient(circle at 100% 0, rgba(var(--em-brand-rgb), .07), transparent 45%);
    border-radius: var(--em-radius);
}

.welcome-text { min-width: 0; }

.welcome-title {
    margin: 10px 0 4px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--em-heading-color);
}

.welcome-subtitle { margin: 0; font-size: 1rem; color: var(--em-body-color); }
.welcome-intro { margin: 4px 0 0; font-size: .9375rem; color: var(--em-muted); }

.welcome-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.welcome-date {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--em-radius-pill);
    background-color: var(--em-band);
    font-size: .875rem;
    font-weight: 500;
    color: var(--em-heading-color);
}

.welcome-date .em-icon { width: 18px; height: 18px; color: var(--em-muted); }

.kpi-card .card-body {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
}

.kpi-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
}

.kpi-icon .em-icon { width: 26px; height: 26px; }
.kpi-content { min-width: 0; }
.kpi-label { margin: 0 0 2px; font-size: .9375rem; color: var(--em-muted); }
.kpi-value { margin: 0; font-size: 1.625rem; font-weight: 700; line-height: 1.2; color: var(--em-heading-color); }

.profile-head {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 4px 0 4px 7px;
}

.profile-name { margin: 0; font-size: 1.0625rem; font-weight: 600; color: var(--em-heading-color); overflow-wrap: anywhere; }
.profile-role { margin: 2px 0 0; color: var(--em-muted); }

.info-list { margin: 0; padding: 0; list-style: none; }

.info-list li {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px 16px;
    padding: 12px 0;
    border-top: 1px solid var(--em-border);
}

.info-label { color: var(--em-muted); }
.info-value { min-width: 0; font-weight: 500; color: var(--em-heading-color); text-align: right; overflow-wrap: anywhere; }

/* --- Page d'erreur (403) ------------------------------------------------ */
.error-card { max-width: 640px; margin: 24px auto var(--em-gutter); text-align: center; }
.error-card .card-body { padding: 48px 32px; }

.error-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 88px;
    height: 88px;
    margin-bottom: 20px;
    border-radius: 50%;
    background: rgba(var(--em-danger-rgb), .1);
    color: var(--em-danger);
}

.error-icon .em-icon { width: 44px; height: 44px; }
.error-title { font-size: 1.5rem; }
.error-text { max-width: 460px; margin: 0 auto 24px; }

/* --- Connexion ---------------------------------------------------------- */
.auth-page { background-color: var(--em-body-bg); }

.auth-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px 16px;
    background-image:
        radial-gradient(circle at 0 0, rgba(var(--em-brand-rgb), .08), transparent 40%),
        radial-gradient(circle at 100% 100%, rgba(var(--em-primary-rgb), .08), transparent 40%);
}

.auth-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    max-width: 460px;
    overflow: hidden;
    border-radius: var(--em-radius-lg);
    background: var(--em-card-bg);
    box-shadow: var(--em-shadow-lg);
}

.auth-aside {
    position: relative;
    isolation: isolate;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    gap: 32px;
    padding: 40px;
    overflow: hidden;
    background:
        radial-gradient(circle at 100% 0, rgba(var(--em-brand-rgb), .35), transparent 55%),
        var(--em-sidebar-bg);
    color: var(--em-sidebar-color);
}

/* Filigrane du symbole EMTOP, partiellement hors cadre */
.auth-aside::before {
    position: absolute;
    right: -96px;
    bottom: -96px;
    z-index: -1;
    width: 360px;
    aspect-ratio: 1;
    background: url("../images/brand/emtop-mark-white-S5417uU.svg") center / contain no-repeat;
    content: "";
    opacity: .05;
    pointer-events: none;
}

.auth-aside-logo {
    align-self: flex-start;
    width: var(--em-logo-auth);
    filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .25));
    animation: em-logo-rise .7s cubic-bezier(.2, .7, .2, 1) both;
}

.auth-aside-logo .em-logo-shine { animation: em-logo-shine 1.6s ease-out 1s both; }
.auth-aside-title { margin: 0 0 8px; font-size: 1.375rem; font-weight: 600; color: #fff; }
.auth-aside-text p:last-child { margin: 0; }

.auth-aside-roles { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }

.auth-aside-roles li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--em-radius);
    background: rgba(255, 255, 255, .05);
    color: #dfe3ea;
}

.auth-aside-roles .em-icon { width: 20px; height: 20px; color: #ff8a8c; }

.auth-form-panel { padding: 40px 36px 32px; }
.auth-logo { display: flex; width: 170px; margin: 0 auto 28px; animation: em-logo-rise .6s cubic-bezier(.2, .7, .2, 1) both; }
.auth-tile { display: none; --em-tile-size: 52px; margin: 0 auto 20px; }
.auth-title { margin: 0 0 4px; font-size: 1.5rem; font-weight: 700; text-align: center; }
.auth-subtitle { margin: 0 0 24px; text-align: center; color: var(--em-muted); }
.auth-form .form-control { min-height: 46px; }

.auth-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 20px 0 0;
    font-size: .875rem;
    color: var(--em-muted);
}

.auth-note .em-icon { width: 18px; height: 18px; margin-top: 1px; }
.auth-footer { margin: 24px 0 0; font-size: .875rem; color: var(--em-muted); text-align: center; }

/* 7. Responsive =========================================================== */
@media (min-width: 576px) {
    .d-sm-none { display: none !important; }
    .d-sm-block { display: block !important; }
    .d-sm-flex { display: flex !important; }
    .d-sm-inline-flex { display: inline-flex !important; }
}

@media (min-width: 768px) {
    .d-md-none { display: none !important; }
    .d-md-block { display: block !important; }
    .d-md-flex { display: flex !important; }
}

@media (min-width: 992px) {
    .d-lg-none { display: none !important; }
    .d-lg-block { display: block !important; }
    .d-lg-flex { display: flex !important; }

    .auth-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); max-width: 920px; }
    .auth-aside { display: flex; }
    .auth-form-panel { padding: 48px 48px 40px; }

    /* Le logo complet est porté par le panneau identité : le formulaire affiche la tuile du symbole */
    .auth-logo { display: none; }
    .auth-tile { display: flex; }
}

@media (min-width: 1200px) {
    .grid-dashboard { grid-template-columns: minmax(300px, 1fr) minmax(0, 2fr); }
}

/* Tablette & mobile : sidebar hors-canevas ouverte par le bouton hamburger */
@media (max-width: 991.98px) {
    .app-sidebar {
        width: min(280px, 85vw);
        box-shadow: none;
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform var(--em-transition), visibility var(--em-transition);
    }

    .app-wrapper.sidebar-open .app-sidebar {
        box-shadow: var(--em-shadow-lg);
        transform: translateX(0);
        visibility: visible;
    }

    .app-wrapper.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }

    .sidebar-brand { justify-content: flex-start; padding-left: 24px; }
    .sidebar-brand::before { right: auto; left: 0; width: 210px; }
    .sidebar-close { display: inline-flex; }
    .sidebar-toggle-float { display: none; }
    .sidebar-search { display: block; }

    .app-content { margin-left: 0; }
    .topbar-toggle { display: inline-flex; }
    .topbar-brand { display: inline-flex; }

    html.sidebar-lock,
    html.sidebar-lock body { overflow: hidden; }
}

/* Ordinateur portable : header plus compact */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .topbar-search { width: 190px; margin-right: 4px; }
    .topbar-user-name,
    .topbar-user-caret { display: none; }
}

/* Tablette : la recherche passe dans la sidebar (bouton hamburger) */
@media (max-width: 991.98px) {
    .topbar-search { display: none; }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    /* Le logo EMTOP occupe le header : le nom reste accessible via l'avatar (comme sur ordinateur portable) */
    .topbar-user-name,
    .topbar-user-caret { display: none; }
}

@media (max-width: 767.98px) {
    :root { --em-gutter: 16px; --em-topbar-height: 60px; }

    .app-topbar-wrapper { padding: 10px 0; }
    .app-topbar { gap: 8px; padding: 0 12px 0 14px; }
    .topbar-start { gap: 8px; }
    .topbar-toggle { margin-left: -6px; }
    .topbar-brand { padding-right: 0; border-right: 0; }
    .topbar-brand-logo { display: none; }
    .topbar-brand-tile { display: inline-flex; --em-tile-size: 30px; }
    .page-title { font-size: 1.0625rem; }
    .topbar-end { gap: 2px; }
    .topbar-search { display: none; }
    .topbar-btn { width: 38px; height: 38px; }
    .topbar-btn .em-icon { width: 22px; height: 22px; }
    .topbar-user { margin-left: 2px; }
    .topbar-user-name,
    .topbar-user-caret { display: none; }
    .topbar-user-toggle { padding: 2px; }

    .card-header,
    .card-body,
    .card-footer { padding-left: 16px; padding-right: 16px; }
    .card-band { padding-left: 16px; padding-right: 16px; }

    .welcome-card .card-body { flex-direction: column; align-items: flex-start; }
    .welcome-card::after { top: 18px; right: -36px; width: 140px; transform: none; }
    .welcome-meta { align-items: flex-start; }
    .welcome-title { font-size: 1.3125rem; }

    .app-footer { flex-direction: column; justify-content: center; text-align: center; }
    .footer-start { justify-content: center; }
    .footer-links { justify-content: center; gap: 6px 20px; }

    .error-card .card-body { padding: 36px 20px; }

    /* Tableaux empilés : chaque ligne devient une carte, sans défilement horizontal */
    .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
    .table-stack,
    .table-stack tbody,
    .table-stack tr,
    .table-stack td { display: block; width: 100%; }

    .table-stack tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 10px 16px;
        padding: 14px 16px;
        border-bottom: 1px solid var(--em-border);
    }

    .table-stack tbody tr:last-child { border-bottom: 0; }
    .table.table-stack > :not(caption) > * > * { padding: 0; border: 0; }
    .table-stack td.cell-main { grid-column: 1 / -1; }
    .table-stack td.cell-action { grid-column: 1 / -1; text-align: left !important; }
    .table-stack td.cell-action .btn { width: 100%; }
    .table-stack td[data-label]::before {
        display: block;
        margin-bottom: 2px;
        font-size: .8125rem;
        color: var(--em-muted);
        content: attr(data-label);
    }

    .form-actions { justify-content: stretch; }
    .form-actions .btn { flex: 1 1 auto; }

    /* Menus déroulants pleine largeur : jamais hors écran */
    .topbar-end .dropdown-menu {
        position: fixed;
        top: calc(var(--em-topbar-height) + 20px);
        left: 12px;
        right: 12px;
        width: auto;
        min-width: 0;
        max-height: calc(100vh - var(--em-topbar-height) - 40px);
        overflow-y: auto;
    }
}

@media (max-width: 575.98px) {
    /* Indicateurs sur 2 colonnes, icône au-dessus de la valeur */
    .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .kpi-card .card-body { flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; }
    .kpi-icon { width: 42px; height: 42px; }
    .kpi-icon .em-icon { width: 22px; height: 22px; }
    .kpi-label { font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
    .kpi-content { width: 100%; }
    .kpi-value { font-size: 1.375rem; }

    .auth-form-panel { padding: 32px 22px 26px; }
    .auth-wrapper { padding: 20px 12px; }

    /* Header téléphone : tuile EMTOP + titre compactés pour garder le titre lisible */
    .topbar-start { gap: 6px; }
    .topbar-brand-tile { --em-tile-size: 28px; }
    .page-title { font-size: 1rem; }

    .quick-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .btn-group-wrap > .btn { flex: 1 1 auto; }
}

/* Très petits téléphones (< 390 px) : priorité au titre de la page, la marque reste dans le menu et le pied de page */
@media (max-width: 389.98px) {
    .topbar-brand { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }

    /* Identité : logo affiché immédiatement, sans reflet ni mouvement */
    .em-logo-shine { display: none; }
    .auth-logo,
    .auth-aside-logo { animation: none; }
}

/* 8. Impression =========================================================== */
@media print {
    .app-sidebar,
    .sidebar-backdrop,
    .app-topbar-wrapper,
    .app-footer,
    .skip-link { display: none !important; }

    .app-content { margin: 0 !important; padding: 0 !important; }
    body { background: #fff; }
    .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}
