/* ============================================================
   STYLES - Application Principale (Style ERP/SAP)
   ============================================================ */

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

:root {
    --sidebar-w: 260px;
    --sidebar-w-collapsed: 68px;
    --topbar-h: 60px;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --bg: #eef1f5;
    --surface: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-hover: #1e293b;
    --sidebar-active: #1e3a5f;
    --sidebar-width: 260px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== MODE SOMBRE ===== */
body.mode-sombre {
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f1f5f9;
    --text-secondary: #64748b;
    --text-muted: #64748b;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
    --primary-light: #1e3a5f;
}

/* ============================================================
   SIDEBAR
   Modes d'affichage (attribut data-mode pose par script.js) :
     overlay-unpinned    : flotte au-dessus du contenu (overlay, non ancree)
     collapsed-pinned    : reduite aux icones, ancree (pousse le contenu)
     expanded-pinned     : ouverte, ancree (pousse le contenu)
     expanded-unpinned   : ouverte mais flottante (overlay)
     floating-unpinned   : pastille flottante, se deplie au survol
   Options personnalisables : largeur, flou overlay, couleur, icones,
   libelles, compteurs, titres de section, bloc utilisateur, ordre des
   sections, etat reduit a l'ouverture (classe .sidebar-redux cote JS).
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    will-change: width, transform;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.25s ease;
    overflow: hidden;
}

/* --- ANCRAGE (pinned) : la barre pousse le contenu --- */
.sidebar[data-mode="expanded-pinned"] ~ .contenu-principal,
.sidebar[data-mode="collapsed-pinned"] ~ .contenu-principal {
    margin-left: var(--sidebar-w);
}
.sidebar[data-mode="collapsed-pinned"] {
    width: var(--sidebar-w-collapsed);
}
.sidebar[data-mode="collapsed-pinned"] ~ .contenu-principal {
    margin-left: var(--sidebar-w-collapsed);
}

/* --- OVERLAY (non ancree) : flotte au-dessus du contenu --- */
.sidebar[data-mode="overlay-unpinned"],
.sidebar[data-mode="expanded-unpinned"],
.sidebar[data-mode="floating-unpinned"] {
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.28);
}
.sidebar[data-mode="overlay-unpinned"] ~ .contenu-principal,
.sidebar[data-mode="expanded-unpinned"] ~ .contenu-principal,
.sidebar[data-mode="floating-unpinned"] ~ .contenu-principal {
    margin-left: 0;
}

/* Overlay : repliee = sort de l'ecran (reste une languette cliquable) */
.sidebar[data-mode="overlay-unpinned"].sidebar-dessus {
    transform: translateX(0);
}
.sidebar.sidebar-repliee {
    transform: translateX(-100%);
}

/* Floating : pastille repliee puis depliement au survol */
.sidebar[data-mode="floating-unpinned"] {
    transform: translateX(calc(-100% + 14px));
}
.sidebar[data-mode="floating-unpinned"]:hover,
.sidebar[data-mode="floating-unpinned"].sidebar-epingle {
    transform: translateX(0);
}

/* --- ETAT REDUIT (icones seulement) --- */
.sidebar.sidebar-redux {
    width: var(--sidebar-w-collapsed);
}
.sidebar.sidebar-redux .logo-texte,
.sidebar.sidebar-redux .nav-label,
.sidebar.sidebar-redux .sous-fleche,
.sidebar.sidebar-redux .user-infos { display: none !important; }
.sidebar.sidebar-redux .nav-titre { opacity: 0; height: 0; padding: 0; margin: 0; }
.sidebar.sidebar-redux[data-mode="expanded-pinned"] ~ .contenu-principal,
.sidebar.sidebar-redux[data-mode="overlay-unpinned"]:not(.sidebar-repliee) ~ .contenu-principal {
    margin-left: var(--sidebar-w-collapsed);
}
/* En mode reduit, les sous-menus se deplient en volant a droite du rail */
.sidebar.sidebar-redux .sous-menu.ouvert {
    position: absolute;
    left: var(--sidebar-w-collapsed);
    min-width: 210px;
    background: var(--sidebar-bg);
    border-radius: 0 10px 10px 0;
    box-shadow: 8px 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 1200;
    max-height: 70vh;
    overflow-y: auto;
}
.sidebar.sidebar-redux .sous-menu.ouvert .nav-label { display: inline !important; }
.sidebar.sidebar-redux .sous-menu .nav-item { padding-left: 18px; }

/* Options d'affichage (icones / libelles / compteurs / sections / user) */
.sidebar.sb-sans-icones .nav-item > i:first-child { display: none; }
.sidebar.sb-sans-libelles .nav-label { display: none !important; }
.sidebar.sb-sans-compteurs .nav-compteur { display: none !important; }
.sidebar.sb-sans-sections .nav-titre { display: none !important; }
body:has(.sidebar.sb-sans-user) .topbar-user { display: none !important; }

/* Donner du relief aux differents modes */
.sidebar[data-mode="collapsed-pinned"],
.sidebar[data-mode="expanded-pinned"] { box-shadow: 1px 0 0 rgba(255,255,255,0.04); }

/* Halo/indicateur quand le curseur est sur le bord droit (poignee de resize) */
.sidebar-resize {
    position: absolute;
    top: 0; right: 0;
    width: 6px; height: 100%;
    cursor: col-resize;
    z-index: 3;
}
.sidebar[data-mode="expanded-pinned"] .sidebar-resize:hover,
.sidebar[data-mode="expanded-unpinned"] .sidebar-resize:hover { background: rgba(96,165,250,0.35); }

/* Bouton personnalisation (engrenage dans le logo) */
.btn-sidebar-cfg {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    font-size: 14px;
    padding: 6px;
    border-radius: 6px;
    opacity: 0.6;
    transition: var(--transition);
}
.btn-sidebar-cfg:hover { opacity: 1; background: var(--sidebar-hover); color: #60a5fa; }
.sidebar.sidebar-redux .btn-sidebar-cfg { display: none; }

/* Languette laterale visible quand la barre est sortie de l'ecran */
.sidebar-poignee {
    position: absolute;
    top: 50%;
    right: -22px;
    width: 22px; height: 56px;
    transform: translateY(-50%);
    background: var(--sidebar-bg);
    color: #60a5fa;
    border: 1px solid rgba(255,255,255,0.08);
    border-left: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    z-index: 5;
    box-shadow: 2px 0 8px rgba(0,0,0,0.25);
}
.sidebar.sidebar-repliee .sidebar-poignee,
.sidebar[data-mode="floating-unpinned"] .sidebar-poignee { display: flex; }

/* Fond assombri quand l'overlay est ouvert */
.sidebar-overlay-fond {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(var(--sidebar-blur, 2px));
    -webkit-backdrop-filter: blur(var(--sidebar-blur, 2px));
    z-index: 990;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.sidebar-overlay-fond.visible { opacity: 1; pointer-events: auto; }

/* --- PANEL DE PERSONNALISATION (MODAL) --- */
.sidebar-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 560px;
    max-width: 94vw;
    max-height: 88vh;
    transform: translate(-50%, -46%) scale(0.96);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 24px 64px rgba(0,0,0,0.35);
    z-index: 1500;
    display: flex;
    flex-direction: column;
    transition: transform 0.26s cubic-bezier(0.4,0,0.2,1), opacity 0.2s ease, visibility 0.26s;
}
.sidebar-panel.visible {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}
/* Fond assombri derriere le modal de personnalisation */
.sidebar-panel::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.26s ease;
}
.sidebar-panel.visible::before { opacity: 1; }
.sidebar-panel-entete {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.sidebar-panel-entete i { color: var(--primary); font-size: 18px; }
.sidebar-panel-entete h3 { font-size: 15px; font-weight: 700; flex: 1; }
.sidebar-panel-fermer {
    width: 30px; height: 30px; border-radius: 6px; border: none;
    background: transparent; color: var(--text-muted); cursor: pointer;
}
.sidebar-panel-fermer:hover { background: var(--border); color: var(--text); }
.sidebar-panel-corps { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 20px 20px; }
.sidebar-panel-pied {
    display: flex; gap: 10px; justify-content: flex-end;
    padding: 14px 20px; border-top: 1px solid var(--border);
}
.sidebar-panel-pied .btn-principal,
.sidebar-panel-pied .btn-secondaire { padding: 9px 16px; font-size: 13px; }

.sp-section { padding: 14px 0; border-bottom: 1px solid var(--border); }
.sp-section:last-child { border-bottom: none; }
.sp-titre {
    display: block; font-size: 11px; font-weight: 800; text-transform: uppercase;
    letter-spacing: 0.8px; color: var(--text-muted); margin-bottom: 10px;
}
.sp-option {
    display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px;
    border-radius: 8px; cursor: pointer; transition: background 0.15s ease;
}
.sp-option:hover { background: var(--bg); }
.sp-option input { position: absolute; opacity: 0; pointer-events: none; }
.sp-radio {
    width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; margin-top: 2px;
    border: 2px solid var(--border); position: relative; transition: var(--transition);
}
.sp-option input:checked + .sp-radio { border-color: var(--primary); }
.sp-option input:checked + .sp-radio::after {
    content: ''; position: absolute; inset: 3px; border-radius: 50%; background: var(--primary);
}
.sp-option.selectionnee { background: var(--primary-light); }
.sp-texte { display: flex; flex-direction: column; gap: 2px; }
.sp-texte strong { font-size: 13px; font-weight: 600; }
.sp-texte small { font-size: 11px; color: var(--text-muted); line-height: 1.35; }

.sp-ligne {
    display: flex; align-items: center; gap: 10px; padding: 6px 2px;
    font-size: 13px; cursor: pointer;
}
.sp-ligne input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.sp-ligne-range { flex-wrap: wrap; }
.sp-ligne-range span { flex: 1; }
.sp-ligne-range input[type="range"] { width: 100%; accent-color: var(--primary); }
.sp-ligne-range output { font-size: 12px; font-weight: 700; color: var(--primary); min-width: 50px; text-align: right; }

.sp-couleurs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sp-couleur {
    width: 32px; height: 32px; border-radius: 8px; border: 2px solid transparent;
    cursor: pointer; transition: var(--transition);
}
.sp-couleur:hover { transform: scale(1.08); }
.sp-couleur.active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.2); }
.sp-couleur-libre {
    width: 32px; height: 32px; border-radius: 8px; overflow: hidden; position: relative;
    border: 2px dashed var(--border); cursor: pointer; display: flex;
    align-items: center; justify-content: center; color: var(--text-muted);
}
.sp-couleur-libre input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.sp-ordre { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.sp-ordre li {
    display: flex; align-items: center; gap: 8px; padding: 7px 10px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
    font-size: 12px; cursor: grab; user-select: none;
}
.sp-ordre li:active { cursor: grabbing; }
.sp-ordre li.drag-sur { border-color: var(--primary); background: var(--primary-light); }
.sp-ordre li i { color: var(--text-muted); font-size: 11px; }

body.mode-sombre .sidebar-panel { background: #1e293b; }
body.mode-sombre .sp-option.selectionnee { background: #1e3a5f; }
body.mode-sombre .sp-ordre li { background: #0f172a; }

/* Logo */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    min-height: 72px;
    flex-shrink: 0;
}

.sidebar-logo i {
    font-size: 28px;
    color: var(--primary);
    min-width: 32px;
    text-align: center;
}

.logo-texte {
    font-size: 16px;
    font-weight: 800;
    color: #3c78b4;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
}

.logo-texte small {
    font-weight: 400;
    font-size: 11px;
    color: var(--sidebar-text);
}

.logo-texte {
    flex: 1;
    min-width: 0;
}

/* Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--sidebar-hover); border-radius: 4px; }

.nav-section {
    margin-bottom: 4px;
}

.nav-titre {
    padding: 12px 20px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.sidebar-redux .nav-titre,
.sidebar.sidebar-redux .sidebar-footer {
    overflow: hidden;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: 0;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
}

.nav-item.actif {
    background: var(--sidebar-active);
    color: #60a5fa;
    border-left-color: var(--primary);
}

.nav-item i:first-child {
    font-size: 18px;
    min-width: 22px;
    text-align: center;
}

.nav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =====
   Remplace l'ancien masquage ".collapsed" : la reduction est desormais
   geree par la classe .sidebar-redux (voir bloc SIDEBAR en haut du fichier).
   ===== */

.nav-compteur {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 50px;
    background: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
    min-width: 20px;
    text-align: center;
    transition: var(--transition);
}

.sous-fleche {
    font-size: 11px;
    transition: transform 0.3s ease;
    color: var(--text-muted);
}

.nav-item.ouvert .sous-fleche {
    transform: rotate(90deg);
}

/* Sous-menus */
.sous-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: rgba(0,0,0,0.15);
}

.sous-menu.ouvert {
    max-height: 620px;
}

.sous-menu .nav-item {
    padding-left: 52px;
    font-size: 12px;
}

.sous-menu .nav-item i:first-child {
    font-size: 14px;
    min-width: 18px;
}

/* Footer sidebar */
.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding: 12px 12px;
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    cursor: pointer;
}

.sidebar-user:hover {
    background: var(--sidebar-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--sidebar-active);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #60a5fa;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.user-infos {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.sidebar.sidebar-redux .user-infos { display: none; }

.user-nom {
    font-size: 12px;
    font-weight: 700;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 10px;
    color: var(--sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-sidebar-deconnexion {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-sidebar-deconnexion:hover {
    color: #ef4444;
    background: rgba(239,68,68,0.1);
}

/* ============================================================
   CONTENU PRINCIPAL
   ============================================================ */
.contenu-principal {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
}

/* ===== TOPBAR ===== */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.btn-toggle-sidebar {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-toggle-sidebar:hover {
    background: var(--border);
    color: var(--text);
}

.topbar-recherche {
    position: relative;
    flex: 1;
    max-width: 480px;
    display: flex;
    align-items: center;
}

.topbar-recherche i {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 16px;
    pointer-events: none;
}

.topbar-recherche input {
    width: 100%;
    padding: 9px 12px 9px 40px;
    border: 2px solid var(--border);
    border-radius: 50px;
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: var(--transition);
    font-family: inherit;
}

.topbar-recherche input:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(37,99,235,0.1);
}

.topbar-recherche input::placeholder {
    color: var(--text-muted);
}

.topbar-droite {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.topbar-btn {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.topbar-btn:hover {
    background: var(--border);
    color: var(--text);
}

.badge-notif {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 9px;
    font-weight: 700;
    background: #ef4444;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.topbar-separateur {
    width: 1px;
    height: 28px;
    background: var(--border);
    margin: 0 4px;
}

.topbar-date,
.topbar-heure {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.topbar-heure {
    font-weight: 700;
    color: var(--text-secondary);
}

/* Site dans la topbar */
.topbar-site {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    background: var(--primary-light);
    border-radius: 50px;
    font-size: 12px;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    border: 1px solid var(--primary);
    margin-right: 4px;
}

.topbar-site i {
    font-size: 14px;
}

body.mode-sombre .topbar-site {
    background: #1e3a5f;
    border-color: #2563eb;
    color: #60a5fa;
}

/* Recherche - résultats en boutons arrondis */
.raccourcis-recherche {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 2000;
    max-height: 320px;
    overflow-y: auto;
    display: none;
    margin-top: 4px;
    padding: 6px;
}

.raccourcis-recherche.visible {
    display: block;
}

.raccourci-vide {
    padding: 10px 14px;
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

.raccourci-item {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 8px 18px 8px 6px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    border-radius: 50px;
    transition: all 0.15s ease;
    margin: 2px 0;
}

.raccourci-item:hover {
    background: var(--bg);
    color: var(--primary);
}

.raccourci-item i {
    width: 32px;
    flex-shrink: 0;
    text-align: center;
    font-size: 16px;
    color: var(--primary);
}

.raccourci-item span {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 140px;
}

body.mode-sombre .raccourci-item i {
    color: #60a5fa;
}

body.mode-sombre .raccourci-item:hover i {
    color: #93c5fd;
}

/* ===== MAIN CONTENU ===== */
.main-contenu {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

/* ============================================================
   PAGE DASHBOARD
   ============================================================ */
.dashboard-page h1 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 4px;
}

.dashboard-page .sous-titre {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* Widgets Cards */
.widgets-grille {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.widget-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    cursor: default;
    border: 1px solid var(--border);
}

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

.widget-icone {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.widget-icone.bleu { background: var(--primary-light); color: var(--primary); }
.widget-icone.rouge { background: #fee2e2; color: #ef4444; }
.widget-icone.vert { background: #dcfce7; color: #16a34a; }
.widget-icone.jaune { background: #fef3c7; color: #d97706; }
.widget-icone.violet { background: #ede9fe; color: #7c3aed; }
.widget-icone.rose { background: #fce7f3; color: #ec4899; }

.widget-infos { flex: 1; min-width: 0; }
.widget-infos .widget-valeur {
    font-size: 26px;
    font-weight: 800;
    line-height: 1.1;
}
.widget-infos .widget-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 2px;
}
.widget-infos .widget-tendance {
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
}
.widget-infos .widget-tendance.haute { color: #16a34a; }
.widget-infos .widget-tendance.basse { color: #ef4444; }

/* Grille dashboard */
.dashboard-grille {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.dashboard-grille-large {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

/* Cartes génériques */
.carte {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.carte-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.carte-header i {
    font-size: 18px;
    color: var(--primary);
}

.carte-header h3 {
    font-size: 14px;
    font-weight: 700;
    flex: 1;
}

.carte-header .badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 50px;
    background: var(--primary-light);
    color: var(--primary);
    white-space: nowrap;
}

.carte-body {
    padding: 16px 20px;
}

/* Tableaux */
.table-mini {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.table-mini th {
    text-align: left;
    padding: 8px 4px 8px 0;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-mini td {
    padding: 8px 4px 8px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

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

.table-mini .statut-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 50px;
    display: inline-block;
}

/* Badges de statut en style bouton arrondi */
.statut-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 14px;
    border-radius: 50px;
    border: none;
    letter-spacing: 0.3px;
    cursor: default;
    user-select: none;
    transition: all 0.2s ease;
}

.statut-badge.ok {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.statut-badge.en-attente {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.statut-badge.impaye {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Mode sombre : adaptations */
body.mode-sombre .statut-badge.ok {
    background: #064e3b;
    color: #6ee7b7;
    border-color: #065f46;
}

body.mode-sombre .statut-badge.en-attente {
    background: #451a03;
    color: #fbbf24;
    border-color: #78350f;
}

body.mode-sombre .statut-badge.impaye {
    background: #450a0a;
    color: #fca5a5;
    border-color: #7f1d1d;
}

/* Message de statut de la page "Ouvrir journée" */
.message-statut-journee {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 20px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid;
    font-size: 14px;
    line-height: 1.5;
}

.message-statut-journee i {
    margin-top: 2px;
    flex-shrink: 0;
}

.message-statut-journee.ouverte {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.message-statut-journee.ouverte i {
    color: #16a34a;
}

.message-statut-journee.fermee {
    background: #fffbeb;
    border-color: #fde68a;
    color: #854d0e;
}

.message-statut-journee.fermee i {
    color: #d97706;
}

body.mode-sombre .message-statut-journee.ouverte {
    background: #052e16;
    border-color: #065f46;
    color: #bbf7d0;
}

body.mode-sombre .message-statut-journee.fermee {
    background: #451a03;
    border-color: #78350f;
    color: #fef3c7;
}

/* Liste activités */
.liste-activite {
    display: flex;
    flex-direction: column;
}

.item-activite {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.item-activite:last-child { border-bottom: none; }

.item-activite .act-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.item-activite .act-infos {
    flex: 1;
    min-width: 0;
}

.item-activite .act-texte {
    font-size: 12px;
    font-weight: 600;
}

.item-activite .act-texte small {
    font-weight: 400;
    color: var(--text-secondary);
}

.item-activite .act-date {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

.item-activite .act-montant {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    text-align: right;
    white-space: nowrap;
}

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
    min-width: 280px;
    max-width: 420px;
}

.toast.succes { background: #16a34a; color: white; }
.toast.erreur { background: #ef4444; color: white; }
.toast.info { background: var(--primary); color: white; }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   PAGE GÉNÉRIQUE
   ============================================================ */
.page-generique {
    padding: 20px 0;
}

.page-generique h1 {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-generique h1 i {
    color: var(--primary);
}

.page-generique p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 24px;
}

.placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 2px dashed var(--border);
    text-align: center;
}

.placeholder-content i {
    font-size: 48px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.placeholder-content h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 8px;
}

.placeholder-content p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* ============================================================
   PAGE EMBALLAGE
   ============================================================ */
.page-emballage h1 {
    font-size: 22px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
}
.page-emballage h1 i { color: var(--primary); }
.page-emballage .sous-titre {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.page-header-actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

/* Bouton principal */
.btn-principal {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Bouton principal désactivé (ex : Enregistrer achat tant que le N° Bon Livraison est vide) */
.btn-principal:disabled,
.btn-principal[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(0.35);
}
.btn-principal:disabled:hover,
.btn-principal[disabled]:hover {
    transform: none;
    box-shadow: none;
}

/* Bouton principal desactive (ex : Enregistrer achat tant que le N° Bon Livraison est vide) */
.btn-principal:disabled,
.btn-principal[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(0.35);
}
.btn-principal:disabled:hover,
.btn-principal[disabled]:hover {
    transform: none;
    box-shadow: none;
}
.btn-principal:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.btn-secondaire {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}
.btn-secondaire:hover {
    border-color: var(--text-muted);
    background: var(--border);
    color: var(--text);
}
/* Bouton secondaire desactive (ex : Fermer journee quand la date n'est pas ouverte) */
.btn-secondaire:disabled,
.btn-secondaire[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.4);
}
.btn-secondaire:disabled:hover,
.btn-secondaire[disabled]:hover {
    border-color: var(--border);
    background: transparent;
    color: var(--text-secondary);
}

/* Tableau emballage */
.table-wrapper {
    overflow-x: auto;
}

.table-emballage {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table-emballage thead th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 700;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--surface);
    position: sticky;
    top: 0;
}

.table-emballage tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.table-emballage tbody tr:hover {
    background: var(--bg);
}

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

/* Colonne "Action" (derniere colonne) alignee a droite de la table.
   On cible uniquement les tables qui possedent reellement une colonne
   d'actions (boutons modifier/supprimer/details...), afin de ne pas
   deranger les tableaux sans colonne Action (dashboard, etc.).
   On aligne AUSSI l'en-tete <th> "Action" a droite pour qu'il soit
   centre au-dessus des boutons (sinon titre a gauche, boutons a droite). */
.table-emballage:has(.btn-table-action) thead th:last-child,
.table-emballage:has(.btn-boule) thead th:last-child,
.table-emballage:has(.btn-edit) thead th:last-child,
.table-emballage:has(.btn-suppr) thead th:last-child,
.table-emballage:has(.btn-table-action) tbody td:last-child,
.table-emballage:has(.btn-boule) tbody td:last-child,
.table-emballage:has(.btn-edit) tbody td:last-child,
.table-emballage:has(.btn-suppr) tbody td:last-child {
    text-align: right;
    white-space: nowrap;
}
.table-emballage tbody td:last-child > * {
    vertical-align: middle;
}

/* Boutons d'action dans le tableau */
.btn-table-action {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    background: transparent;
}
.btn-edit { color: var(--primary); }
.btn-edit:hover { background: var(--primary-light); }
.btn-suppr { color: #ef4444; }
.btn-suppr:hover { background: #fee2e2; }

/* Boutons boule pour actions */
.btn-boule {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    background: var(--surface);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    margin: 0 2px;
}
.btn-boule.btn-edit { color: var(--primary); border: 1px solid var(--primary); }
.btn-boule.btn-edit:hover { background: var(--primary); color: white; }
.btn-boule.btn-taux { color: #d97706; border: 1px solid #d97706; }
.btn-boule.btn-taux:hover { background: #d97706; color: white; }
.btn-boule.btn-detail { color: #7c3aed; border: 1px solid #7c3aed; }
.btn-boule.btn-detail:hover { background: #7c3aed; color: white; }

/* Select dans la modale */
.modale-body .input-icone select {
    width: 100%;
    padding: 12px 14px 12px 44px;   
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: var(--transition);
    outline: none;
    font-family: inherit;
    appearance: auto;
    cursor: pointer;
}
.modale-body .input-icone select:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(37,99,235,0.1);
}

body.mode-sombre .modale-body .input-icone select {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
}
body.mode-sombre .modale-body .input-icone select:focus {
    border-color: var(--primary);
    background: #1e293b;
}

/* ============================================================
   MODALE EMBALLAGE
   ============================================================ */
.overlay-modale {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}
.overlay-modale.visible { display: flex; }

.modale-emballage {
    background: var(--surface);
    border-radius: var(--radius);
    max-width: 480px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    animation: modaleEntree 0.25s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modale-emballage .modale-header { flex-shrink: 0; }
.modale-emballage .modale-footer { flex-shrink: 0; }

@keyframes modaleEntree {
    from { transform: scale(0.95) translateY(10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modale-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modale-header i { font-size: 20px; color: var(--primary); }
.modale-header h2 { font-size: 16px; font-weight: 700; flex: 1; }

.btn-fermer-modale {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.btn-fermer-modale:hover {
    background: var(--border);
    color: var(--text);
}

.modale-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modale-body .groupe-champ {
    margin-bottom: 18px;
}

.modale-body .groupe-champ label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* === INPUT ICONE (hors modale) === */
.input-icone {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icone > i {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 14px;
    pointer-events: none;
    z-index: 1;
}

.input-icone input,
.input-icone select {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-card);
    color: var(--text);
    outline: none;
}

/* Champs dans la page Achat */
#pageAchat .groupe-champ input,
#pageAchat .groupe-champ select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-card);
    color: var(--text);
    outline: none;
    box-sizing: border-box;
}

#pageAchat .groupe-champ input:focus,
#pageAchat .groupe-champ select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74,144,217,0.1);
}

#pageAchat .groupe-champ input[readonly] {
    cursor: not-allowed;
    opacity: 0.7;
}

body.mode-sombre #pageAchat .groupe-champ input,
body.mode-sombre #pageAchat .groupe-champ select {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
}

body.mode-sombre #pageAchat .groupe-champ input:focus,
body.mode-sombre #pageAchat .groupe-champ select:focus {
    border-color: var(--primary);
    background: #1e293b;
}

body.mode-sombre #pageAchat .groupe-champ input[readonly] {
    background: #1e293b;
    opacity: 0.6;
}

/* Input avec icone dans Achat - padding different pour l'icone */
#pageAchat .input-icone input,
#pageAchat .input-icone select {
    padding: 8px 12px 8px 36px;
}

#pageAchat .input-icone input:focus,
#pageAchat .input-icone select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74,144,217,0.1);
}

body.mode-sombre #pageAchat .input-icone input,
body.mode-sombre #pageAchat .input-icone select {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
}

body.mode-sombre #pageAchat .input-icone input:focus,
body.mode-sombre #pageAchat .input-icone select:focus {
    border-color: var(--primary);
    background: #1e293b;
}

.champ-styler input,
.champ-styler select,
.champ-styler input[type="date"] {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-card);
    color: var(--text);
    outline: none;
}

.input-icone input:focus,
.input-icone select:focus,
.champ-styler input:focus,
.champ-styler select:focus,
.champ-styler input[type="date"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74,144,217,0.1);
}

body.mode-sombre .input-icone input,
body.mode-sombre .input-icone select,
body.mode-sombre .champ-styler input,
body.mode-sombre .champ-styler select,
body.mode-sombre .champ-styler input[type="date"] {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
}

body.mode-sombre .input-icone input:focus,
body.mode-sombre .input-icone select:focus,
body.mode-sombre .champ-styler input:focus,
body.mode-sombre .champ-styler select:focus,
body.mode-sombre .champ-styler input[type="date"]:focus {
    border-color: var(--primary);
    background: #1e293b;
}

body.mode-sombre .input-icone > i {
    color: #64748b;
}

.modale-body .input-icone i:first-child {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 16px;
    pointer-events: none;
}

.modale-body .input-icone input {
    width: 100%;
    padding: 12px 14px 12px 44px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: var(--transition);
    outline: none;
    font-family: inherit;
}

.modale-body .input-icone input:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(37,99,235,0.1);
}

.modale-body .input-icone input:read-only {
    background: var(--border);
    cursor: not-allowed;
    opacity: 0.7;
}

/* Select dans les modales (prix particulier, etc.) */
.modale-body .input-icone.select-icone select {
    width: 100%;
    padding: 12px 14px 12px 44px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: var(--transition);
    outline: none;
    font-family: inherit;
    cursor: pointer;
    appearance: auto;
    -webkit-appearance: auto;
}

.modale-body .input-icone.select-icone select:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 4px rgba(37,99,235,0.1);
}

.modale-body .input-icone.select-icone .select-styler {
    background-color: var(--surface);
}

.modale-body .message-erreur {
    font-size: 12px;
    color: #ef4444;
    font-weight: 600;
    margin-top: 4px;
    display: none;
}
.modale-body .message-erreur.visible { display: block; }

.modale-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.modale-footer .btn-principal,
.modale-footer .btn-secondaire {
    padding: 10px 20px;
    font-size: 13px;
}

/* Mode sombre pour la modale */
body.mode-sombre .modale-emballage {
    background: #1e293b;
}
body.mode-sombre .modale-body .input-icone input {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
}
body.mode-sombre .modale-body .input-icone input:focus {
    border-color: var(--primary);
    background: #1e293b;
}
body.mode-sombre .modale-body .input-icone input:read-only {
    background: #0f172a;
    opacity: 0.6;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .dashboard-grille {
        grid-template-columns: 1fr;
    }
    .dashboard-grille-large {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Sur petit ecran, la barre est TOUJOURS en overlay non ancree */
    .sidebar {
        width: var(--sidebar-w);
        transform: translateX(-100%);
        box-shadow: 8px 0 32px rgba(0,0,0,0.3);
    }
    .sidebar.sidebar-dessus,
    .sidebar.ouverte {
        transform: translateX(0);
    }
    .contenu-principal {
        margin-left: 0 !important;
    }
    .topbar {
        padding: 0 12px;
    }
    .topbar-date { display: none; }
    .main-contenu {
        padding: 16px;
    }
    .widgets-grille {
        grid-template-columns: 1fr 1fr;
    }
}


/* ============================================================
   PAGE ACHAT - Barre "Application de la valeur d'entree" (HT/TVA)
   Barre compacte : toggle + champs Frais acc. / Prix de revient /
   Prix de vente sur la meme ligne. Compatible mode sombre.
   ============================================================ */
.barre-valeur-entree {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-bottom: 16px;
    padding: 8px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: background 0.3s ease, border-color 0.3s ease;
}
.barre-valeur-entree .bve-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}
.barre-valeur-entree .toggle-ht-tva {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}
.barre-valeur-entree .btn-toggle-ht,
.barre-valeur-entree .btn-toggle-tva {
    border: none;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    background: var(--surface);
    color: var(--text-secondary);
    transition: var(--transition);
    white-space: nowrap;
}
.barre-valeur-entree .btn-toggle-ht.actif,
.barre-valeur-entree .btn-toggle-tva.actif {
    background: #4A90D9;
    color: #fff;
}
.barre-valeur-entree .bve-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    cursor: pointer;
}
.barre-valeur-entree .bve-check input { cursor: pointer; }
.barre-valeur-entree .bve-champs {
    display: flex;
    align-items: flex-end;
    flex-wrap: nowrap;
    gap: 8px;
    margin-left: auto;
}
.barre-valeur-entree .bve-champ {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 0 0 auto;
}
.barre-valeur-entree .bve-champ label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
}
.barre-valeur-entree .bve-champ input {
    width: 115px;
    min-width: 115px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
    outline: none;
    box-sizing: border-box;
}
.barre-valeur-entree .bve-champ input[readonly] {
    cursor: not-allowed;
    opacity: 0.75;
}
body.mode-sombre .barre-valeur-entree {
    background: #1e293b;
    border-color: #334155;
}
body.mode-sombre .barre-valeur-entree .btn-toggle-ht,
body.mode-sombre .barre-valeur-entree .btn-toggle-tva {
    background: #334155;
    color: #cbd5e1;
}
body.mode-sombre .barre-valeur-entree .btn-toggle-ht.actif,
body.mode-sombre .barre-valeur-entree .btn-toggle-tva.actif {
    background: #4A90D9;
    color: #fff;
}
body.mode-sombre .barre-valeur-entree .bve-champ input {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
}
/* ===== FENETRE FACTURATION : alignement vertical des champs ===== */
.fact-grille {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
    margin-bottom: 20px;
}
.fact-champ {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-width: 0;
}
.fact-champ label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
/* Champ (input/select) a HAUTEUR FIXE et alignee verticalement */
.fact-champ input,
.fact-champ select,
.fact-input {
    height: 46px;
    width: 100%;
    box-sizing: border-box;
    padding: 0 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: var(--transition);
}
.fact-champ input:focus,
.fact-champ select:focus,
.fact-input:focus {
    border-color: #2563eb;
}
.fact-champ input[readonly],
.fact-input[readonly] {
    background: var(--bg);
}
.fact-champ input.fact-important {
    font-weight: 700;
    color: var(--primary);
}

/* Bloc icone (input + icone + bouton) a hauteur fixe */
.fact-champ .fact-icone {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 46px;
}
.fact-champ .fact-icone > i.fact-ic {
    position: absolute;
    left: 14px;
    color: var(--text-secondary);
    pointer-events: none;
}
.fact-champ .fact-icone input {
    padding-left: 40px;
}

/* Bouton pleine hauteur aligne */
.fact-btn-h {
    height: 46px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

/* Partie calculs alignee verticalement a droite */
.fact-calculs {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 18px;
}
.fact-calculs-bloc {
    min-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.fact-calculs-ligne {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}
.fact-calculs-ligne.net {
    background: #eff6ff;
    border-color: #bfdbfe;
    font-weight: 700;
    color: #1e3a5f;
}
.fact-calculs-ligne.net span {
    color: #1e3a5f;
}
.fact-calculs-ligne.net strong {
    color: #2563eb;
    font-size: 16px;
}
body.mode-sombre .fact-calculs-ligne.net {
    background: #1e3a5f;
    border-color: #2563eb;
    color: #ffffff;
}
body.mode-sombre .fact-calculs-ligne.net span {
    color: #ffffff;
}
body.mode-sombre .fact-calculs-ligne.net strong {
    color: #93c5fd;
}

/* Boutons d'action alignes verticalement a droite */
.fact-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    align-items: stretch;
}
.fact-actions .btn-principal,
.fact-actions .btn-secondaire {
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

body.mode-sombre .fact-champ input,
body.mode-sombre .fact-champ select {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}
body.mode-sombre .fact-champ input[readonly] {
    background: #0f172a;
}
/* ===== FENETRE FACTURATION : alignement vertical des champs ===== */
.fact-grille {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
    margin-bottom: 20px;
}
.fact-champ {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-width: 0;
}
.fact-champ label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
/* Champ (input/select) a HAUTEUR FIXE et alignee verticalement */
.fact-champ input,
.fact-champ select,
.fact-input {
    height: 46px;
    width: 100%;
    box-sizing: border-box;
    padding: 0 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: var(--transition);
}
.fact-champ input:focus,
.fact-champ select:focus,
.fact-input:focus {
    border-color: #2563eb;
}
.fact-champ input[readonly],
.fact-input[readonly] {
    background: var(--bg);
}
.fact-champ input.fact-important {
    font-weight: 700;
    color: var(--primary);
}

/* Bloc icone (input + icone + bouton) a hauteur fixe */
.fact-champ .fact-icone {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 46px;
}
.fact-champ .fact-icone > i.fact-ic {
    position: absolute;
    left: 14px;
    color: var(--text-secondary);
    pointer-events: none;
}
.fact-champ .fact-icone input {
    padding-left: 40px;
}

/* Bouton pleine hauteur aligne */
.fact-btn-h {
    height: 46px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

/* Partie calculs alignee verticalement a droite */
.fact-calculs {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 18px;
}
.fact-calculs-bloc {
    min-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.fact-calculs-ligne {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
}


/* Boutons d'action alignes verticalement a droite */
.fact-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    align-items: stretch;
}
.fact-actions .btn-principal,
.fact-actions .btn-secondaire {
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

body.mode-sombre .fact-champ input,
body.mode-sombre .fact-champ select {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}
body.mode-sombre .fact-champ input[readonly] {
    background: #0f172a;
}
/* ============================================================
   BLOC UTILISATEUR DANS LA TOPBAR (deplace depuis le sidebar)
   ============================================================ */
.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 4px 4px;
    border-radius: 50px;
    transition: var(--transition);
}
.topbar-user:hover { background: var(--border); }

.topbar-user .user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    overflow: hidden;
}
.topbar-user .user-avatar img {
    width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;
}
.topbar-user .user-infos {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 160px;
}
.topbar-user .user-nom {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}
.topbar-user .user-role {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}
.topbar-user .btn-sidebar-deconnexion {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: var(--transition);
    flex-shrink: 0;
}
.topbar-user .btn-sidebar-deconnexion:hover {
    color: #ef4444;
    background: rgba(239,68,68,0.1);
}

body.mode-sombre .topbar-user .user-avatar {
    background: #1e3a5f;
    color: #60a5fa;
}
body.mode-sombre .topbar-user .user-nom { color: #f1f5f9; }
body.mode-sombre .topbar-user .btn-sidebar-deconnexion { color: #94a3b8; }

@media (max-width: 768px) {
    .topbar-user .user-infos { display: none; }
}
/* ============================================================
   MODALS TAUX : backdrop partage SOUS la sidebar (z-index 990)
   pour que le menu lateral reste cliquable pendant qu'un modal
   Taux est ouvert. Le ::before propre au .sidebar-panel est
   neutralise pour ces modals uniquement.
   ============================================================ */
#modalTauxJour::before,
#modalTVA::before,
#modalTauxParticuliers::before { display: none; }

#tauxBackdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(var(--sidebar-blur, 2px));
    -webkit-backdrop-filter: blur(var(--sidebar-blur, 2px));
    z-index: 990;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.26s ease;
}
#tauxBackdrop.visible { opacity: 1; pointer-events: auto; }

/* ========================================
   BARRE DE FILTRE "PILLS" (Locations / Clients / Articles)
   Composant partage : .filtre-bar + .filtre-pill
   ======================================== */
.filtre-bar{display:flex;flex-wrap:wrap;align-items:center;gap:14px;padding:14px 18px;
    background:linear-gradient(135deg,#f8fafc 0%,#eef2ff 100%);border-bottom:1px solid var(--border,#e2e8f0);}
.filtre-titre{display:inline-flex;align-items:center;gap:8px;font-weight:700;font-size:12px;
    letter-spacing:.6px;text-transform:uppercase;color:#475569;}
.filtre-titre .ico{width:26px;height:26px;border-radius:8px;display:inline-flex;align-items:center;
    justify-content:center;background:var(--primary-light,#dbeafe);color:var(--primary,#2563eb);font-size:12px;}
.filtre-pills{display:inline-flex;flex-wrap:wrap;gap:6px;background:#ffffffee;border:1px solid var(--border,#e2e8f0);
    border-radius:12px;padding:4px;box-shadow:0 1px 2px rgba(15,23,42,.06);}
.filtre-pill{border:0;background:transparent;cursor:pointer;font-size:13px;font-weight:600;color:#64748b;
    padding:8px 14px;border-radius:9px;display:inline-flex;align-items:center;gap:7px;transition:all .18s ease;white-space:nowrap;}
.filtre-pill i{font-size:12px;opacity:.9;}
.filtre-pill .filtre-pill-nb{min-width:20px;text-align:center;font-size:11px;font-weight:700;padding:1px 7px;
    border-radius:20px;background:#e2e8f0;color:#475569;transition:all .18s ease;}
.filtre-pill:hover{background:#eef2ff;color:#3730a3;}
.filtre-pill.actif{background:linear-gradient(135deg,var(--primary,#2563eb),#3b82f6);color:#fff;
    box-shadow:0 3px 10px rgba(37,99,235,.35);}
.filtre-pill.actif .filtre-pill-nb{background:rgba(255,255,255,.25);color:#fff;}
.filtre-pill.actif i{opacity:1;}
.filtre-compteur{margin-left:auto;font-size:12px;font-weight:600;color:#475569;
    background:#fff;border:1px solid var(--border,#e2e8f0);border-radius:20px;padding:6px 12px;
    display:inline-flex;align-items:center;gap:6px;}
.filtre-compteur i{color:var(--primary,#2563eb);}
.filtre-compteur b{color:var(--primary,#2563eb);font-weight:800;}
body.mode-sombre .filtre-bar{background:linear-gradient(135deg,#1e293b 0%,#1e1b4b 100%);border-bottom-color:#334155;}
body.mode-sombre .filtre-titre{color:#94a3b8;}
body.mode-sombre .filtre-pills{background:#0f172a;border-color:#334155;}
body.mode-sombre .filtre-pill{color:#94a3b8;}
body.mode-sombre .filtre-pill:hover{background:#1e293b;color:#c7d2fe;}
body.mode-sombre .filtre-pill .filtre-pill-nb{background:#334155;color:#cbd5e1;}
body.mode-sombre .filtre-compteur{background:#0f172a;border-color:#334155;color:#cbd5e1;}
body.mode-sombre .filtre-compteur b{color:#60a5fa;}
