:root {
    --primary: #112B48;
    --secondary: #B2461A;
    --accent: #CB8A6D;
    --neutral: #7A8898;
    --soft: #D8C9C5;
    --white: #FFFFFF;
    --shadow-sm: 0 2px 4px rgba(17, 43, 72, 0.08);
    --shadow-md: 0 4px 6px rgba(17, 43, 72, 0.12);
    --shadow-lg: 0 10px 20px rgba(17, 43, 72, 0.15);
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Z-index scale - gouvernance (standard entreprise)
       Contenu: 1
       Header global: 100
       Sidebar: 200
       Overlay mobile: 300
       Modals: 1000
    */
    --z-base: 1;
    --z-content: 1;
    --z-header: 100;
    --z-sidebar: 200;
    --z-overlay: 300;
    --z-modal: 1000;
}

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

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: var(--primary);
    line-height: 1.7;
    min-height: 100vh;
}

/* ---------------------------
   Avatar profil (Mon profil)
   --------------------------- */
.profile-avatar-wrapper {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(17, 43, 72, 0.06);
    border: 1px solid rgba(17, 43, 72, 0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: 0.2s ease;
    flex: 0 0 auto;
    user-select: none;
}
.profile-avatar-wrapper:hover {
    filter: brightness(1.06);
    border-color: rgba(17, 43, 72, 0.18);
}
.profile-avatar-img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.profile-avatar-icon {
    font-size: 60px;
    line-height: 1;
    color: rgba(17, 43, 72, 0.55);
}
.profile-avatar-delete {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid rgba(17, 43, 72, 0.22);
    background: #fff;
    color: rgba(17, 43, 72, 0.85);
    font-size: 16px;
    line-height: 18px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    padding: 0;
}
.profile-avatar-delete:hover {
    background: rgba(178, 70, 26, 0.08);
    border-color: rgba(178, 70, 26, 0.35);
    color: var(--secondary);
}

/* ---------------------------
   Signature électronique (Profil)
   --------------------------- */
/* iPad/Safari hardening:
   `#sigHint` est un bloc purement informatif (messages UX/diagnostic).
   Il ne doit JAMAIS intercepter les taps/clics des boutons situés en dessous,
   même si Safari calcule une bounding-box trop grande. */
#sigHint {
    display: block;
    min-height: 24px;
    max-width: 100%;
    word-break: break-word;
    pointer-events: none;
}

/* Garantir que les contrôles interactifs restent toujours hit-testables. */
#sigUploadBtn,
#sigDeleteBtn,
#sigClearBtn,
#sigSaveBtn,
#sigCanvas {
    position: relative;
    z-index: 2;
}
.profile-avatar-hint {
    margin-top: .15rem;
    font-size: .85rem;
    color: var(--neutral);
}
.profile-avatar-hint.is-error {
    color: #b91c1c;
}

.header {
    background: linear-gradient(135deg, var(--primary) 0%, #0a1f35 100%);
    color: var(--white);
    padding: 1.25rem 2rem;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: var(--z-header); /* Inférieur au menu mobile (9999) */
    /* backdrop-filter avec fallback pour Safari iOS */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Fallback Safari iOS : désactiver backdrop-filter sur mobile si problème */
@supports not (backdrop-filter: blur(10px)) {
    .header {
        background: linear-gradient(135deg, var(--primary) 0%, #0a1f35 100%);
    }
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--white);
}

.logo img {
    height: 65px;
    width: auto;
    object-fit: contain;
    border-radius: 8px;
    background: var(--white);
    padding: 8px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.logo a {
    transition: var(--transition);
    display: flex;
    align-items: center;
}

.logo a:hover {
    transform: translateY(-2px);
}

.logo a:hover img {
    box-shadow: var(--shadow-lg);
}

.nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.nav a {
    color: var(--white);
    text-decoration: none;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    transition: var(--transition);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px;
}

.nav a::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    transition: left 0.3s;
}

.nav a:hover::before {
    left: 0;
}

.nav a:hover {
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.nav a i {
    font-size: 0.9rem;
}

/* Menu hamburger pour mobile */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.75rem;
    min-width: 44px;
    min-height: 44px;
    opacity: 0.9;
    transition: opacity 0.3s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    position: relative;
    /* Gouvernance: au-dessus du header, jamais au-dessus overlay/modal */
    z-index: calc(var(--z-header) + 1);
}

.menu-toggle .menu-toggle-icon {
    display: block;
    width: 24px;
    height: 24px;
}

.authenticated-menu-toggle {
    display: none; /* Caché par défaut sur desktop */
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.75rem;
    min-width: 44px;
    min-height: 44px;
    opacity: 0.9;
    transition: opacity 0.3s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    position: relative;
    z-index: calc(var(--z-header) + 1);
    flex-shrink: 0;
}

.authenticated-menu-toggle:hover,
.authenticated-menu-toggle:active {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

/* Afficher le bouton sur petits écrans (mobile ET fenêtre réduite) */
@media (max-width: 767px) {
    .authenticated-menu-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.1) !important;
        border-radius: 8px;
        margin-left: auto;
        pointer-events: auto !important;
    }
}

.menu-toggle:hover,
.menu-toggle:active {
    opacity: 1;
}

.nav a.secure-access {
    font-weight: 500;
    opacity: 1;
}

.nav-separator {
    color: var(--white);
    opacity: 0.5;
    padding: 0 0.25rem;
    font-weight: 300;
    display: none; /* Caché sur mobile */
}

/* Menu mobile (overlay) */
.mobile-menu {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, #0a1f35 100%);
    /* Gouvernance: drawer mobile au-dessus contenu/header/sidebar */
    z-index: calc(var(--z-overlay) + 2);
    padding: 2rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.mobile-menu.active {
    display: block;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.mobile-menu-close {
    background: none;
    border: none;
    color: var(--white);
    font-size: 2rem;
    cursor: pointer;
    padding: 0.75rem;
    min-width: 44px;
    min-height: 44px;
    opacity: 0.9;
    transition: opacity 0.3s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mobile-menu-close:hover,
.mobile-menu-close:active {
    opacity: 1;
}

.mobile-menu-nav {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mobile-menu-nav a {
    color: var(--white);
    text-decoration: none;
    padding: 1.25rem 0;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0.9;
    transition: opacity 0.3s;
    display: block;
    min-height: 48px;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
    touch-action: manipulation;
}

.mobile-menu-nav a:hover,
.mobile-menu-nav a:active {
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.05);
}

.mobile-menu-nav a.secure-access {
    font-weight: 600;
    opacity: 1;
    margin-top: 1rem;
    padding-top: 1.5rem;
    border-top: 2px solid rgba(255, 255, 255, 0.2);
}

.container {
    max-width: 1400px;
    margin: 2.5rem auto;
    padding: 0 2rem;
}

/* Menu mobile sidebar - CACHÉ PAR DÉFAUT (desktop) */
.mobile-sidebar-overlay {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-overlay);
    opacity: 0;
    transition: opacity 0.3s ease;
    /* Sécurité: un overlay inactif ne doit jamais bloquer les taps */
    pointer-events: none;
}

.mobile-sidebar {
    display: none !important;
    visibility: hidden !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
    box-shadow: 4px 0 24px rgba(17, 43, 72, 0.15);
    z-index: calc(var(--z-overlay) + 1);
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    overflow-x: hidden;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Layout avec sidebar */
.main-layout {
    display: flex;
    min-height: calc(100vh - 200px);
    gap: 0;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
    box-shadow: 4px 0 12px rgba(17, 43, 72, 0.08);
    position: sticky;
    top: 80px;
    height: calc(100vh - 80px);
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid rgba(17, 43, 72, 0.08);
    z-index: var(--z-sidebar);
    scrollbar-width: thin;
    scrollbar-color: rgba(17, 43, 72, 0.2) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(17, 43, 72, 0.2);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(17, 43, 72, 0.3);
}

.sidebar-nav {
    padding: 1.5rem 0;
}

/* Premier élément du menu (Tableau de bord) - Style spécial */
.sidebar-nav > .menu-item:first-child .menu-link {
    background: linear-gradient(90deg, rgba(17, 43, 72, 0.05) 0%, rgba(17, 43, 72, 0.02) 100%);
    border-left-color: var(--primary);
    font-weight: 700;
}

.sidebar-nav > .menu-item:first-child .menu-link i:first-child {
    color: var(--primary);
}

.sidebar-nav > .menu-item:first-child .menu-link:hover {
    background: linear-gradient(90deg, rgba(17, 43, 72, 0.08) 0%, rgba(17, 43, 72, 0.04) 100%);
}

.menu-item {
    margin-bottom: 0.25rem;
    position: relative;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    color: var(--primary);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    position: relative;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    border-left: 3px solid transparent;
    margin-left: 0.5rem;
    border-radius: 0 12px 12px 0;
}

.menu-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--secondary) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.menu-link:hover {
    background: linear-gradient(90deg, rgba(17, 43, 72, 0.05) 0%, rgba(17, 43, 72, 0.02) 100%);
    color: var(--secondary);
    transform: translateX(4px);
    border-left-color: var(--secondary);
}

.menu-link:hover::before {
    opacity: 1;
}

.menu-link.logout {
    color: #ef4444;
    margin-top: 1rem;
    border-top: 1px solid rgba(17, 43, 72, 0.08);
    padding-top: 1.25rem;
}

.menu-link.logout:hover {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%);
    color: #dc2626;
    border-left-color: #ef4444;
}

.menu-link.logout::before {
    background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
}

.menu-link i:first-child {
    width: 24px;
    text-align: center;
    font-size: 1.25rem;
    color: var(--neutral);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-link:hover i:first-child {
    color: var(--secondary);
    transform: scale(1.1);
}

.menu-link.logout:hover i:first-child {
    color: #ef4444;
}

.menu-link span {
    flex: 1;
    font-size: 0.9375rem;
    letter-spacing: -0.2px;
}

.dropdown-toggle {
    cursor: pointer;
}

.dropdown-icon {
    font-size: 0.75rem;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: auto;
    color: var(--neutral);
}

.menu-item.dropdown.active .dropdown-icon {
    transform: rotate(180deg);
    color: var(--secondary);
}

/* Indicateur visuel pour dropdown ouvert (accessibilité clavier) */
.menu-item.dropdown.active > .menu-link {
    background: linear-gradient(90deg, rgba(17, 43, 72, 0.08) 0%, rgba(17, 43, 72, 0.04) 100%);
    color: var(--secondary);
    border-left-color: var(--secondary);
    font-weight: 700;
}

.menu-item.dropdown.active > .menu-link::before {
    opacity: 1;
}

.menu-item.dropdown.active > .menu-link i:first-child {
    color: var(--secondary);
}

.menu-item.dropdown.active > .menu-link:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.submenu {
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
    background: linear-gradient(180deg, rgba(248, 249, 250, 0.5) 0%, rgba(241, 243, 245, 0.3) 100%);
    border-left: 2px solid rgba(17, 43, 72, 0.08);
    margin-left: 1.5rem;
    border-radius: 0 0 8px 0;
}

.menu-item.dropdown.active .submenu {
    max-height: 500px;
    padding: 0.75rem 0;
}

.submenu li {
    margin: 0;
    position: relative;
}

.submenu li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 4px;
    background: var(--neutral);
    border-radius: 50%;
    opacity: 0.4;
    transition: all 0.3s ease;
}

.submenu a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem 0.75rem 3.5rem;
    color: var(--neutral);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.875rem;
    font-weight: 500;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    position: relative;
    border-radius: 0 8px 8px 0;
    margin-right: 0.5rem;
}

.submenu a:hover {
    background: linear-gradient(90deg, rgba(17, 43, 72, 0.06) 0%, rgba(17, 43, 72, 0.03) 100%);
    color: var(--primary);
    padding-left: 4rem;
    transform: translateX(4px);
    font-weight: 600;
}

.submenu a:hover ~ li::before,
.submenu li:hover::before {
    background: var(--secondary);
    opacity: 1;
    transform: translateY(-50%) scale(1.2);
}

.submenu a i {
    width: 18px;
    text-align: center;
    font-size: 0.875rem;
    color: var(--neutral);
    transition: all 0.3s ease;
}

.submenu a:hover i {
    color: var(--secondary);
    transform: scale(1.1);
}

/* Contenu principal */
.main-content {
    flex: 1;
    padding: 2.5rem;
    max-width: calc(100% - 280px);
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    min-height: calc(100vh - 80px);
}

.page-header {
    margin-bottom: 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid rgba(17, 43, 72, 0.08);
}

.page-header h1 {
    color: var(--primary);
    font-size: 2.25rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.8px;
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.page-header h1 i {
    color: var(--secondary);
    font-size: 2rem;
}

.card {
    background: var(--white);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(17, 43, 72, 0.08), 0 1px 3px rgba(17, 43, 72, 0.04);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(17, 43, 72, 0.06);
    position: relative;
    z-index: var(--z-content);
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.card:hover {
    box-shadow: 0 8px 24px rgba(17, 43, 72, 0.12), 0 4px 8px rgba(17, 43, 72, 0.08);
    transform: translateY(-4px);
    border-color: rgba(17, 43, 72, 0.12);
}

.card:hover::before {
    opacity: 1;
}

.card-header {
    border-bottom: 1px solid rgba(17, 43, 72, 0.08);
    padding-bottom: 1.5rem;
    margin-bottom: 1.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    /* iPad/Safari hardening: le header ne doit jamais recouvrir le body */
    position: relative;
    z-index: 1;
}

/* iPad/Safari hardening: si un overlap se produit, le contenu reste au-dessus */
.card > :not(.card-header) {
    position: relative;
    z-index: 2;
}

.card-header h2 {
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.3px;
}

.card-header h2 i {
    color: var(--secondary);
    font-size: 1.375rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem;
    background-color: var(--primary);
    color: var(--white);
    text-decoration: none;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn:hover {
    background-color: #0a1f35;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary {
    background-color: var(--neutral);
}

.btn-secondary:hover {
    background-color: #5a6675;
}

.btn-success {
    background-color: var(--secondary);
}

.btn-success:hover {
    background-color: #8d3615;
}

.btn-danger {
    background-color: #dc2626;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 36px;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.action-buttons .btn {
    white-space: nowrap;
}

.btn-text {
    margin-left: 0.25rem;
}

@media (max-width: 768px) {
    .btn-text {
        display: none;
    }

    .action-buttons .btn {
        padding: 0.5rem;
        min-width: 40px;
        justify-content: center;
    }
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 1rem;
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(17, 43, 72, 0.04);
}

table thead {
    background: linear-gradient(135deg, #f8f9fa 0%, #f1f3f5 100%);
    border-bottom: 2px solid rgba(17, 43, 72, 0.1);
}

table th {
    padding: 1.125rem 1.5rem;
    text-align: left;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    border-bottom: none;
    white-space: nowrap;
}

table td {
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid rgba(17, 43, 72, 0.06);
    color: var(--primary);
    font-size: 0.9375rem;
    vertical-align: middle;
}

table tbody tr {
    transition: all 0.2s ease;
    background: var(--white);
}

table tbody tr:hover {
    background: linear-gradient(90deg, rgba(17, 43, 72, 0.02) 0%, rgba(17, 43, 72, 0.04) 100%);
    transform: scale(1.001);
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* Tables dans les cards de détail */
.card table {
    margin-top: 0;
    box-shadow: none;
    border-radius: 0;
}

.card table th {
    background: transparent;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.875rem;
    padding: 1rem 1.5rem 1rem 0;
    width: 200px;
    vertical-align: top;
    border-bottom: 1px solid rgba(17, 43, 72, 0.08);
}

.card table td {
    padding: 1rem 0;
    border-bottom: 1px solid rgba(17, 43, 72, 0.08);
    color: var(--primary);
    font-size: 0.9375rem;
}

.card table tbody tr:last-child th,
.card table tbody tr:last-child td {
    border-bottom: none;
}

.card table tbody tr:hover {
    background: transparent;
    transform: none;
}

table a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

table a:hover {
    color: var(--secondary);
    text-decoration: none;
    transform: translateX(2px);
}

table a i {
    font-size: 0.875rem;
}

/* Scroll container for large tables */
.table-scroll {
    max-height: 480px;
    overflow: auto;
    border: 1px solid rgba(17, 43, 72, 0.08);
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
}

.table-scroll table {
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    min-width: 100%;
}

.table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: linear-gradient(135deg, #f8f9fa 0%, #f1f3f5 100%);
    border-bottom: 2px solid rgba(17, 43, 72, 0.1);
}

.form-group {
    margin-bottom: 1.75rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9375rem;
}

.form-control {
    width: 100%;
    padding: 0.875rem 1.25rem;
    border: 2px solid var(--neutral);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
    background: var(--white);
    color: var(--primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(17, 43, 72, 0.1);
    transform: translateY(-1px);
}

/* Notification groupée par voyage (scopé) */
#bulk-voyage-notify {
    display: block;
    visibility: visible;
    height: auto;
    overflow: visible;
    margin: 0 0 0.75rem 0;
    padding: 0.75rem 1rem;
    border-left: 4px solid var(--primary, #0d6efd);
    background: rgba(13, 110, 253, 0.06);
    border-radius: 0.25rem;
    position: relative;
    z-index: 1;
}

#bulk-voyage-notify form {
    display: block;
    margin: 0;
    visibility: visible;
    height: auto;
    overflow: visible;
}

#bulk-voyage-notify .bulk-voyage-notify-title {
    font-weight: 600;
    margin-bottom: 0.35rem;
}

/* Radio buttons pour mode de sélection */
input[type="radio"].dossier-mode-selector,
input[type="radio"].recipient-mode-selector {
    margin-right: 0.5rem;
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

input[type="radio"].dossier-mode-selector + span,
input[type="radio"].recipient-mode-selector + span {
    user-select: none;
}

.alert {
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    animation: slideIn 0.3s ease-out;
    position: relative;
}

.alert .alert-content strong {
    display: block;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.alert .alert-content div {
    color: inherit;
    opacity: 0.95;
}

.alert .alert-close {
    position: absolute;
    top: 0.35rem;
    right: 0.5rem;
    border: none;
    background: transparent;
    color: currentColor;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.25rem 0.35rem;
    cursor: pointer;
    opacity: 0.75;
}

.alert .alert-close:hover,
.alert .alert-close:focus {
    opacity: 1;
}

.alert.alert-closing {
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 180ms ease, transform 180ms ease;
}

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

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.alert-warning {
    background-color: #fffbeb;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.alert-info {
    background-color: var(--soft);
    color: var(--primary);
    border-left: 4px solid var(--accent);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    grid-auto-rows: min-content;
    grid-auto-flow: dense;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    align-items: stretch;
}

/* Grille automatique pour les statistiques - Calcul intelligent de l'espace */
.auto-grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    grid-auto-rows: min-content;
    grid-auto-flow: row;
    gap: 1.5rem;
    align-items: stretch;
    width: 100%;
    justify-items: stretch;
}

/* Limiter à 3 colonnes maximum sur grands écrans (MacBook et plus) pour mieux distribuer 6 boîtes */
@media (min-width: 1024px) {
    .auto-grid-stats {
        grid-template-columns: repeat(3, 1fr) !important;
        max-width: 100%;
    }

    /* Forcer les stat-cards à remplir les colonnes */
    .auto-grid-stats > .stat-card {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* Assurer que les stat-cards remplissent tout l'espace disponible */
.auto-grid-stats > .stat-card {
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

/* Grille automatique pour les grandes cartes - 2 colonnes max */
.auto-grid-large {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    grid-auto-rows: min-content;
    grid-auto-flow: dense;
    gap: 1.5rem;
    align-items: stretch;
    width: 100%;
}

.stat-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(17, 43, 72, 0.08);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

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

.stat-card h3 {
    color: var(--neutral);
    font-size: 0.875rem;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.stat-card .value {
    color: var(--primary);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .change {
    color: var(--secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

.footer {
    background: linear-gradient(135deg, var(--primary) 0%, #0a1f35 100%);
    color: var(--white);
    text-align: center;
    padding: 3rem 2rem;
    margin-top: 4rem;
}

.footer p {
    margin: 0.5rem 0;
    opacity: 0.9;
}

.footer-container {
    max-width: 1000px;
    margin: 0 auto;
}

.footer-header {
    text-align: center;
    margin-bottom: 2rem;
}

.footer-title {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.footer-subtitle {
    opacity: 0.9;
    margin-bottom: 1.5rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    grid-auto-rows: min-content;
    grid-auto-flow: dense;
    gap: 2rem;
    margin-bottom: 2rem;
    text-align: center;
    align-items: stretch;
}

.footer-grid > div {
    /* Centrer le contenu AU MILIEU de chaque "boîte" */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.35rem; /* espace régulier (évite les lignes trop espacées) */
    min-width: 0;
}

.footer-section-title {
    opacity: 0.95;
    font-weight: 600;
    margin: 0 0 0.35rem 0;
    font-size: 0.95rem;
}

.footer-text {
    opacity: 0.85;
    margin: 0;
    line-height: 1.5;
}

.footer-text:last-child {
    margin-bottom: 0;
}

.footer-copyright {
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding-top: 1.5rem;
}

.footer-copyright-text {
    opacity: 0.8;
    font-size: 0.9rem;
    margin: 0;
}

.messages {
    margin-bottom: 1.5rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
}

.badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.badge-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: var(--white);
}

.badge-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: var(--white);
}

.badge-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: var(--white);
}

.badge-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: var(--white);
}

.badge-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #0a1f35 100%);
    color: var(--white);
}

.badge-secondary {
    background: linear-gradient(135deg, var(--secondary) 0%, #8d3615 100%);
    color: var(--white);
}

.badge-accent {
    background: linear-gradient(135deg, var(--accent) 0%, #b8755a 100%);
    color: var(--white);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        padding: 0 1.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
        grid-auto-flow: dense;
    }

    /* Grille automatique pour les statistiques - Tablette */
    .auto-grid-stats {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
        gap: 1.25rem;
    }

    /* Grille automatique pour les grandes cartes - Tablette */
    .auto-grid-large {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
        gap: 1.25rem;
    }
}

        /* Desktop-first approach - Styles de base pour desktop, puis adaptation mobile */

        /* Mobile uniquement (< 768px) */
@media (max-width: 767px) {
    /* Grille automatique pour les statistiques - Mobile */
    .auto-grid-stats {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
    }

    /* Grille automatique pour les grandes cartes - Mobile */
    .auto-grid-large {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .header {
        padding: 0.75rem 1rem;
    }

    .header-content {
        gap: 1rem;
    }

    .menu-toggle {
        display: block;
    }

    .nav {
        display: none;
    }

    .logo-text {
        display: none;
    }

    .logo img {
        height: 45px;
        padding: 5px;
    }

    .nav-separator {
        display: none;
    }

            /* Sidebar complètement cachée sur mobile pour utilisateurs authentifiés */
            .sidebar {
                display: none;
                visibility: hidden;
            }

            /* Afficher le bouton menu pour utilisateurs authentifiés */
            .authenticated-menu-toggle {
                display: flex !important;
                visibility: visible !important;
                opacity: 1 !important;
                align-items: center;
                justify-content: center;
                background: rgba(255, 255, 255, 0.1) !important;
                border-radius: 8px;
                margin-left: auto;
            }

            /* S'assurer que le header content a assez d'espace */
            .header-content.authenticated {
                justify-content: space-between !important;
                position: relative;
                width: 100%;
            }

            /* Logo dans header authentifié */
            .header-content.authenticated .logo {
                flex-shrink: 0;
            }

            /* Forcer l'affichage du bouton */
            .header-content.authenticated .authenticated-menu-toggle {
                display: flex !important;
                visibility: visible !important;
                opacity: 1 !important;
                pointer-events: auto !important;
            }

            /* Menu mobile sidebar pour utilisateurs authentifiés - CACHÉ PAR DÉFAUT */
            .mobile-sidebar-overlay {
                display: none !important;
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                background: rgba(0, 0, 0, 0.5);
                z-index: var(--z-overlay);
                opacity: 0;
                transition: opacity 0.3s ease;
                pointer-events: none !important; /* Non cliquable par défaut */
            }

            .mobile-sidebar-overlay.active {
                display: block !important;
                opacity: 1 !important;
                pointer-events: auto !important; /* Cliquable quand actif */
            }

            /* Sur mobile ET fenêtre réduite, le menu existe mais reste TOUJOURS caché hors écran par défaut */
            .mobile-sidebar {
                display: block !important;
                visibility: visible !important;
                position: fixed !important;
                top: 0 !important;
                left: 0 !important;
                width: 280px !important;
                max-width: 85vw !important;
                height: 100vh !important;
                background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%) !important;
                box-shadow: 4px 0 24px rgba(17, 43, 72, 0.15) !important;
                z-index: calc(var(--z-overlay) + 1) !important;
                transform: translateX(-100%) !important; /* TOUJOURS caché hors écran par défaut - CRITIQUE */
                transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
                overflow-y: auto !important;
                overflow-x: hidden !important;
                opacity: 1 !important;
                pointer-events: none !important; /* Non cliquable par défaut */
            }

            /* IMPORTANT : Le menu ne doit JAMAIS être visible sans la classe active */
            .mobile-sidebar:not(.active) {
                transform: translateX(-100%) !important;
                pointer-events: none !important;
            }

            /* Le menu devient visible ET cliquable uniquement avec la classe active */
            .mobile-sidebar.active {
                transform: translateX(0) !important; /* Visible quand actif */
                pointer-events: auto !important; /* Cliquable quand actif */
            }

            /* Overlay visible sur mobile ET fenêtre réduite */
            .mobile-sidebar-overlay {
                display: none !important; /* Caché par défaut */
                pointer-events: none !important;
            }

            .mobile-sidebar-overlay.active {
                display: block !important; /* Visible quand actif */
                pointer-events: auto !important; /* Cliquable quand actif */
            }

            .mobile-sidebar-header {
                display: flex;
                justify-content: space-between;
                align-items: center;
                padding: 1.25rem 1.5rem;
                border-bottom: 1px solid rgba(17, 43, 72, 0.08);
                background: var(--white);
                position: sticky;
                top: 0;
                z-index: 10;
            }

            .mobile-sidebar-header .logo {
                display: flex;
                align-items: center;
                gap: 0.75rem;
            }

            .mobile-sidebar-header .logo img {
                height: 40px;
            }

            .mobile-sidebar-header .logo-text {
                font-weight: 700;
                color: var(--primary);
                font-size: 1rem;
            }

            .mobile-sidebar-close {
                background: none;
                border: none;
                color: var(--primary);
                font-size: 1.5rem;
                cursor: pointer;
                padding: 0.5rem;
                min-width: 44px;
                min-height: 44px;
                opacity: 0.7;
                transition: opacity 0.3s;
                -webkit-tap-highlight-color: transparent;
                touch-action: manipulation;
                display: flex;
                align-items: center;
                justify-content: center;
            }

            .mobile-sidebar-close:hover {
                opacity: 1;
            }

            .mobile-sidebar-nav {
                padding: 1rem 0;
            }

            .mobile-sidebar-nav .menu-item {
                margin-bottom: 0;
            }

            .mobile-sidebar-nav .menu-link {
                margin-left: 0;
                border-radius: 0;
                border-left: none;
            }

            .mobile-sidebar-nav .menu-link::before {
                display: none;
            }

            .mobile-sidebar-nav .submenu {
                margin-left: 0;
                border-left: none;
                border-top: 1px solid rgba(17, 43, 72, 0.08);
            }

            .mobile-sidebar-nav .submenu a {
                margin-right: 0;
                border-radius: 0;
            }

            /* Menu mobile : z-index très élevé pour être au-dessus de tout */
            .mobile-menu.active {
                z-index: calc(var(--z-overlay) + 2);
                display: block;
            }

            /* Footer simplifié sur mobile */
            .footer-grid {
                grid-template-columns: 1fr;
                gap: 1.5rem;
                text-align: center;
            }

            .footer-text {
                line-height: 1.6;
            }

            /* Réduire padding menu mobile sur très petits écrans (iPhone SE) */
            .mobile-menu-nav a {
                padding: 1rem 0;
            }

            /* Désactiver backdrop-filter sur mobile Safari si problème */
            @supports not (backdrop-filter: blur(10px)) {
                .header {
                    backdrop-filter: none;
                    -webkit-backdrop-filter: none;
                }
            }

    /* Menu mobile toujours au-dessus de tout sur mobile */
    .mobile-menu {
        z-index: calc(var(--z-overlay) + 2) !important; /* Gouvernance: au-dessus contenu/header/sidebar */
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100vh !important;
    }

    /* S'assurer que le contenu ne passe pas au-dessus du menu */
    .main-content,
    .container,
    .card,
    .main-layout,
    .header {
        position: relative;
        z-index: 1;
    }

    /* Header avec z-index inférieur au menu mobile */
    .header {
        z-index: var(--z-header);
    }

    /* Amélioration des zones de clic sur mobile */
    .btn {
        min-height: 48px;
        padding: 0.875rem 1.5rem;
    }

    .menu-link {
        min-height: 48px;
        padding: 1.25rem 1.5rem;
        margin-left: 0;
        border-radius: 0;
    }

    .menu-link::before {
        display: none;
    }

    .submenu {
        margin-left: 0;
        border-left: none;
        border-top: 1px solid rgba(17, 43, 72, 0.08);
    }

    .submenu a {
        min-height: 44px;
        padding: 1rem 1.5rem;
        margin-right: 0;
        border-radius: 0;
    }

    .submenu li::before {
        display: none;
    }

    .main-layout {
        flex-direction: column;
    }

    .main-content {
        max-width: 100%;
        padding: 1rem;
    }

    .container {
        margin: 1.5rem auto;
        padding: 0 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header h1 {
        font-size: 1.75rem;
    }

    .card {
        padding: 1.5rem;
        margin-bottom: 1.5rem;
        border-radius: 12px;
    }

    .card-header {
        padding-bottom: 1.25rem;
        margin-bottom: 1.5rem;
    }

    .card-header h2 {
        font-size: 1.25rem;
    }

    .empty-state {
        padding: 0 !important;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        grid-auto-flow: row;
        gap: 1rem;
    }

    /* Grille automatique pour les statistiques - Très petits écrans */
    .auto-grid-stats {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    table {
        font-size: 0.875rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table th,
    table td {
        padding: 0.75rem 0.5rem;
    }

    .card table th {
        width: auto;
        padding: 0.75rem 0.5rem 0.75rem 0;
    }

    .card table td {
        padding: 0.75rem 0;
    }

    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.9375rem;
    }
}

/* Tablette et petits écrans (≥ 768px) */
@media (min-width: 768px) {
    .header {
        padding: 0.75rem 2rem;
    }

    .logo-text {
        display: block;
    }

    .logo img {
        height: 60px;
        padding: 8px;
    }

    .menu-toggle {
        display: none;
    }

    .nav {
        display: flex;
    }

    .nav-separator {
        display: inline;
    }

    .mobile-menu {
        display: none;
    }

    /* Cacher le menu mobile sidebar sur desktop (≥ 768px) */
    .mobile-sidebar {
        display: none !important;
        visibility: hidden !important;
    }

    .mobile-sidebar-overlay {
        display: none !important;
        visibility: hidden !important;
    }

    .authenticated-menu-toggle {
        display: none !important;
        visibility: hidden !important;
    }

    /* Sidebar visible sur tablette et plus */
    .sidebar {
        display: block;
    }
}

/* Desktop standard (≥ 1024px) */
@media (min-width: 1024px) {
    .logo img {
        height: 65px;
    }

    .logo-text {
        font-size: 1.25rem;
    }

    .nav a {
        font-size: 0.95rem;
    }

    .container {
        max-width: 1200px;
    }
}

/* Écrans larges (≥ 1400px) */
@media (min-width: 1400px) {
    .header-content {
        max-width: 1400px;
    }

    .container {
        max-width: 1400px;
    }
}

/* Très grands écrans (≥ 1920px) */
@media (min-width: 1920px) {
    .header-content {
        max-width: 1600px;
    }

    .container {
        max-width: 1600px;
    }
}

@media (max-width: 480px) {
    .page-header h1 {
        font-size: 1.5rem;
    }

    .card-header h2 {
        font-size: 1.25rem;
    }

    .stat-card .value {
        font-size: 2rem;
    }
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* Selection color */
::selection {
    background-color: var(--accent);
    color: var(--white);
}

/* Focus visible pour navigation clavier (WCAG AA) */
a:focus-visible,
button:focus-visible,
.menu-link:focus-visible,
.dropdown-toggle:focus-visible,
.mobile-menu-nav a:focus-visible,
.mobile-menu-close:focus-visible,
.menu-toggle:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Focus visible pour inputs */
.form-control:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* Supprimer outline par défaut, garder uniquement focus-visible */
a:focus,
button:focus {
    outline: none;
}
