:root {
    /* Couleurs Premium */
    --bg-body: #F0F4FA;
    --bg-sidebar: #0B1437;
    --text-main: #1B2559;
    --text-muted: #8F9BBA;
    --white: #ffffff;
    --primary: #4318FF;
    --primary-hover: #3311DB;
    --success: #01B574;
    --danger: #EE5D50;
    --warning: #FFCE20;
    --border: #E0E5F2;
    --shadow-soft: 0px 10px 30px rgba(112, 144, 176, 0.1);
    --radius: 20px;
}

/* --- BASE --- */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Plus Jakarta Sans', sans-serif; }

body { 
    display: flex; 
    background-color: var(--bg-body); 
    color: var(--text-main); 
    height: 100vh; 
    width: 100vw;
    overflow: hidden; 
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }

/* --- SIDEBAR (Fixe) --- */
aside { 
    width: 260px; 
    min-width: 260px;
    background: var(--bg-sidebar); 
    color: #fff; 
    padding: 30px 20px; 
    display: flex; 
    flex-direction: column; 
    z-index: 100; 
}

.logo { font-size: 1.4rem; font-weight: 800; margin-bottom: 40px; text-align: center; }
.logo span { color: #8C6DFD; }

nav ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
nav ul li a { display: flex; align-items: center; gap: 12px; color: var(--text-muted); padding: 14px 20px; border-radius: 12px; cursor: pointer; transition: 0.3s; text-decoration: none; font-weight: 600;}
nav ul li a:hover, nav ul li a.active { background: rgba(255,255,255,0.1); color: #fff; transform: translateX(5px); }
nav ul li a.active { border-left: 3px solid #8C6DFD; background: linear-gradient(90deg, rgba(67, 24, 255, 0.2) 0%, rgba(0,0,0,0) 100%); }

.aside-footer { margin-top: auto; }
.premium-badge { background: linear-gradient(135deg, #FFB547, #FFCE20); color: #4A3000; padding: 10px; border-radius: 10px; font-weight: 800; font-size: 0.8rem; text-align: center; }

/* --- MAIN CONTENT (Flexible) --- */
main { 
    flex: 1; 
    padding: 30px; 
    overflow-y: auto; 
    overflow-x: hidden;
    position: relative;
}

.content-section { display: none; animation: fadeIn 0.4s ease-out; max-width: 1600px; margin: 0 auto; padding-bottom: 50px; }
.content-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Headers */
header { margin-bottom: 30px; }
h1 { font-size: 1.8rem; font-weight: 800; }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 5px; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 25px; display: flex; align-items: center; gap: 15px; box-shadow: var(--shadow-soft); }
.icon-box { width: 50px; height: 50px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.icon-box.blue { background: #E9E3FF; color: var(--primary); }
.icon-box.green { background: #E6FBF3; color: var(--success); }
.icon-box.red { background: #FEECEB; color: var(--danger); }
.premium-card { background: linear-gradient(135deg, #111C44 0%, #0B1437 100%); color: white; }
.premium-card h3, .premium-card p { color: white !important; }

/* --- OPERATIONS --- */
.operations-layout { display: flex; flex-wrap: wrap; gap: 25px; align-items: flex-start; }
.premium-form-container { flex: 2; min-width: 350px; background: #fff; padding: 30px; border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.recent-ops-container { flex: 1; min-width: 300px; background: #fff; padding: 30px; border-radius: var(--radius); box-shadow: var(--shadow-soft); max-height: 800px; overflow-y: auto; }

/* Formulaires */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.input-group { margin-bottom: 15px; }
.input-group label { display: block; font-weight: 700; margin-bottom: 8px; font-size: 0.9rem; }
.form-control { width: 100%; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: #F8F9FA; font-size: 0.95rem; outline: none; }
.form-control:focus { border-color: var(--primary); background: #fff; }

.btn-primary { background: var(--primary); color: white; border: none; padding: 15px; width: 100%; border-radius: 12px; font-weight: 700; cursor: pointer; font-size: 1rem; margin-top: 10px; transition: 0.2s; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-2px); }

/* Listes Récentes */
.recent-op-item { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--border); }
.recent-op-info h4 { font-size: 0.95rem; margin-bottom: 3px; }
.recent-op-info p { font-size: 0.8rem; color: var(--text-muted); }

/* --- TABLEAUX --- */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.invoice-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.invoice-table th { text-align: left; padding: 15px; background: #F7F9FC; color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; }
.invoice-table td { padding: 15px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.9rem; }

/* Tags */
.op-tag { padding: 5px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; color: white; display: inline-block; }
.op-tag.recette { background: var(--success); }
.op-tag.depense { background: var(--danger); }

/* Utilitaires Couleur */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }

/* Responsive Mobile */
@media (max-width: 900px) {
    aside { display: none; }
    main { padding: 15px; }
    .form-grid { grid-template-columns: 1fr; }
    .operations-layout { flex-direction: column; }
    .premium-form-container, .recent-ops-container { width: 100%; }
}

/* =========================================
   AJOUTS POUR CORRIGER LES BUGS VISUELS (MODALE, GRAPHIQUE, CALENDRIER)
   ========================================= */

/* 1. GRAPHIQUE (Dimensionnement obligatoire pour Chart.js) */
.chart-container {
    position: relative;
    height: 380px; 
    padding: 20px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

/* 2. MODALE "Ajouter un Véhicule" */
.modal {
    display: none; /* Masqué par défaut */
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(11, 20, 55, 0.6);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal.active {
    display: flex;
    animation: modalFadeIn 0.3s ease-out;
}
.modal-content {
    background: var(--white);
    padding: 30px;
    border-radius: var(--radius);
    width: 100%; max-width: 500px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.close-btn { background: transparent; border: none; font-size: 1.8rem; cursor: pointer; color: var(--text-muted); transition: 0.2s;}
.close-btn:hover { color: var(--danger); transform: scale(1.1); }

@keyframes modalFadeIn { 
    from { opacity: 0; transform: translateY(-20px); } 
    to { opacity: 1; transform: translateY(0); } 
}

/* 3 & 4. GRILLES VÉHICULES, CALENDRIER ET JOURNAL */
.vehicules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.vehicule-card { background: var(--white); padding: 25px; border-radius: var(--radius); box-shadow: var(--shadow-soft); cursor: pointer; border: 2px solid transparent; transition: 0.3s; }
.vehicule-card:hover { border-color: var(--primary); transform: translateY(-5px); box-shadow: 0 15px 35px rgba(67, 24, 255, 0.15); }

/* Utilitaires de positionnement */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.gap-3 { gap: 15px; } .mt-3 { margin-top: 15px; } .mt-4 { margin-top: 25px; } .mb-3 { margin-bottom: 15px; } .mb-4 { margin-bottom: 25px; }
.btn-outline, .btn-outline-sm { background: transparent; border: 1px solid var(--border); padding: 10px 20px; border-radius: 10px; cursor: pointer; color: var(--text-main); font-weight: 600; transition: 0.2s; }
.btn-outline:hover, .btn-outline-sm:hover { border-color: var(--primary); color: var(--primary); background: #F0F4FA; }

/* Calendrier Sophistiqué */
.calendar-card { padding: 30px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.calendar-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.btn-icon { background: var(--bg-body); border: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; color: var(--primary); font-weight: bold; transition: 0.2s; }
.btn-icon:hover { background: var(--primary); color: white; }
.calendar-header { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-weight: 700; color: var(--text-muted); margin-bottom: 15px; }
.calendar-body { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.calendar-day { background: #F8F9FA; min-height: 90px; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 5px; border: 1px solid var(--border); transition: 0.2s; }
.calendar-day:hover { border-color: var(--primary); box-shadow: var(--shadow-soft); }
.calendar-day.empty { background: transparent; border: none; }
.calendar-day.today { background: #E9E3FF; border-color: var(--primary); }
.day-num { font-weight: 800; font-size: 0.95rem; margin-bottom: 5px; color: var(--text-main); }

/* En-têtes du Journal */
.journal-stats { display: flex; gap: 20px; flex-wrap: wrap; }
.j-stat { flex: 1; min-width: 200px; background: #F8F9FA; padding: 20px; border-radius: 15px; border: 1px solid var(--border); }
.j-stat span { font-size: 0.85rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }
.j-stat h3 { font-size: 1.5rem; margin-top: 5px; }
.alerts-container {
    background: #fff;
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    border-left: 5px solid var(--danger);
    margin-top: 20px;
    margin-bottom: 20px;
}
.alert-item {
    padding: 15px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 600;
    font-size: 0.95rem;
}
.alert-warning { background: #FFFBEA; color: #9D7C00; border: 1px solid #FFE485; }
.alert-danger { background: #FEECEB; color: var(--danger); border: 1px solid #FCCAC7; }
@media print {
    /* Cache tout sauf la zone de facture */
    aside, nav, header, .billing-controls, .btn-primary, .btn-outline, .ambient-light {
        display: none !important;
    }
    main { padding: 0; margin: 0; }
    .content-section { display: block !important; }
    #invoice-zone {
        display: block !important;
        box-shadow: none !important;
        border: none !important;
        width: 100%;
    }
    body { background: white; }
}
:root {
    /* Couleurs Premium */
    --bg-body: #F0F4FA;
    --bg-sidebar: #0B1437;
    --text-main: #1B2559;
    --text-muted: #8F9BBA;
    --white: #ffffff;
    --primary: #4318FF;
    --primary-hover: #3311DB;
    --success: #01B574;
    --danger: #EE5D50;
    --warning: #FFCE20;
    --border: #E0E5F2;
    --shadow-soft: 0px 10px 30px rgba(112, 144, 176, 0.1);
    --radius: 20px;
}

/* --- BASE --- */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Plus Jakarta Sans', sans-serif; }

body { 
    display: flex; 
    background-color: var(--bg-body); 
    color: var(--text-main); 
    height: 100vh; 
    width: 100vw;
    overflow: hidden; 
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }

/* --- SIDEBAR (Fixe) --- */
aside { 
    width: 260px; 
    min-width: 260px;
    background: var(--bg-sidebar); 
    color: #fff; 
    padding: 30px 20px; 
    display: flex; 
    flex-direction: column; 
    z-index: 100; 
}

.logo { font-size: 1.4rem; font-weight: 800; margin-bottom: 40px; text-align: center; }
.logo span { color: #8C6DFD; }

nav ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
nav ul li a { display: flex; align-items: center; gap: 12px; color: var(--text-muted); padding: 14px 20px; border-radius: 12px; cursor: pointer; transition: 0.3s; text-decoration: none; font-weight: 600;}
nav ul li a:hover, nav ul li a.active { background: rgba(255,255,255,0.1); color: #fff; transform: translateX(5px); }
nav ul li a.active { border-left: 3px solid #8C6DFD; background: linear-gradient(90deg, rgba(67, 24, 255, 0.2) 0%, rgba(0,0,0,0) 100%); }

.aside-footer { margin-top: auto; }
.premium-badge { background: linear-gradient(135deg, #FFB547, #FFCE20); color: #4A3000; padding: 10px; border-radius: 10px; font-weight: 800; font-size: 0.8rem; text-align: center; }

/* --- MAIN CONTENT (Flexible) --- */
main { 
    flex: 1; 
    padding: 30px; 
    overflow-y: auto; 
    overflow-x: hidden;
    position: relative;
}

.content-section { display: none; animation: fadeIn 0.4s ease-out; max-width: 1600px; margin: 0 auto; padding-bottom: 50px; }
.content-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Headers */
header { margin-bottom: 30px; }
h1 { font-size: 1.8rem; font-weight: 800; }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 5px; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 25px; display: flex; align-items: center; gap: 15px; box-shadow: var(--shadow-soft); }
.icon-box { width: 50px; height: 50px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.icon-box.blue { background: #E9E3FF; color: var(--primary); }
.icon-box.green { background: #E6FBF3; color: var(--success); }
.icon-box.red { background: #FEECEB; color: var(--danger); }
.premium-card { background: linear-gradient(135deg, #111C44 0%, #0B1437 100%); color: white; }
.premium-card h3, .premium-card p { color: white !important; }

/* --- OPERATIONS --- */
.operations-layout { display: flex; flex-wrap: wrap; gap: 25px; align-items: flex-start; }
.premium-form-container { flex: 2; min-width: 350px; background: #fff; padding: 30px; border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.recent-ops-container { flex: 1; min-width: 300px; background: #fff; padding: 30px; border-radius: var(--radius); box-shadow: var(--shadow-soft); max-height: 800px; overflow-y: auto; }

/* Formulaires */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.input-group { margin-bottom: 15px; }
.input-group label { display: block; font-weight: 700; margin-bottom: 8px; font-size: 0.9rem; }
.form-control { width: 100%; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: #F8F9FA; font-size: 0.95rem; outline: none; }
.form-control:focus { border-color: var(--primary); background: #fff; }

.btn-primary { background: var(--primary); color: white; border: none; padding: 15px; width: 100%; border-radius: 12px; font-weight: 700; cursor: pointer; font-size: 1rem; margin-top: 10px; transition: 0.2s; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-2px); }

/* Listes Récentes */
.recent-op-item { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--border); }
.recent-op-info h4 { font-size: 0.95rem; margin-bottom: 3px; }
.recent-op-info p { font-size: 0.8rem; color: var(--text-muted); }

/* --- TABLEAUX --- */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.invoice-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.invoice-table th { text-align: left; padding: 15px; background: #F7F9FC; color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; }
.invoice-table td { padding: 15px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.9rem; }

/* Tags */
.op-tag { padding: 5px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; color: white; display: inline-block; }
.op-tag.recette { background: var(--success); }
.op-tag.depense { background: var(--danger); }

/* Utilitaires Couleur */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }

/* Responsive Mobile */
@media (max-width: 900px) {
    aside { display: none; }
    main { padding: 15px; }
    .form-grid { grid-template-columns: 1fr; }
    .operations-layout { flex-direction: column; }
    .premium-form-container, .recent-ops-container { width: 100%; }
}

/* =========================================
   AJOUTS POUR CORRIGER LES BUGS VISUELS (MODALE, GRAPHIQUE, CALENDRIER)
   ========================================= */

/* 1. GRAPHIQUE (Dimensionnement obligatoire pour Chart.js) */
.chart-container {
    position: relative;
    height: 380px; 
    padding: 20px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

/* 2. MODALE "Ajouter un Véhicule" */
.modal {
    display: none; /* Masqué par défaut */
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(11, 20, 55, 0.6);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal.active {
    display: flex;
    animation: modalFadeIn 0.3s ease-out;
}
.modal-content {
    background: var(--white);
    padding: 30px;
    border-radius: var(--radius);
    width: 100%; max-width: 500px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.close-btn { background: transparent; border: none; font-size: 1.8rem; cursor: pointer; color: var(--text-muted); transition: 0.2s;}
.close-btn:hover { color: var(--danger); transform: scale(1.1); }

@keyframes modalFadeIn { 
    from { opacity: 0; transform: translateY(-20px); } 
    to { opacity: 1; transform: translateY(0); } 
}

/* 3 & 4. GRILLES VÉHICULES, CALENDRIER ET JOURNAL */
.vehicules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.vehicule-card { background: var(--white); padding: 25px; border-radius: var(--radius); box-shadow: var(--shadow-soft); cursor: pointer; border: 2px solid transparent; transition: 0.3s; }
.vehicule-card:hover { border-color: var(--primary); transform: translateY(-5px); box-shadow: 0 15px 35px rgba(67, 24, 255, 0.15); }

/* Utilitaires de positionnement */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.gap-3 { gap: 15px; } .mt-3 { margin-top: 15px; } .mt-4 { margin-top: 25px; } .mb-3 { margin-bottom: 15px; } .mb-4 { margin-bottom: 25px; }
.btn-outline, .btn-outline-sm { background: transparent; border: 1px solid var(--border); padding: 10px 20px; border-radius: 10px; cursor: pointer; color: var(--text-main); font-weight: 600; transition: 0.2s; }
.btn-outline:hover, .btn-outline-sm:hover { border-color: var(--primary); color: var(--primary); background: #F0F4FA; }

/* Calendrier Sophistiqué */
.calendar-card { padding: 30px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.calendar-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.btn-icon { background: var(--bg-body); border: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; color: var(--primary); font-weight: bold; transition: 0.2s; }
.btn-icon:hover { background: var(--primary); color: white; }
.calendar-header { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-weight: 700; color: var(--text-muted); margin-bottom: 15px; }
.calendar-body { display: grid; grid-template-columns: repeat(7, 1fr); gap: 10px; }
.calendar-day { background: #F8F9FA; min-height: 90px; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 5px; border: 1px solid var(--border); transition: 0.2s; }
.calendar-day:hover { border-color: var(--primary); box-shadow: var(--shadow-soft); }
.calendar-day.empty { background: transparent; border: none; }
.calendar-day.today { background: #E9E3FF; border-color: var(--primary); }
.day-num { font-weight: 800; font-size: 0.95rem; margin-bottom: 5px; color: var(--text-main); }

/* En-têtes du Journal */
.journal-stats { display: flex; gap: 20px; flex-wrap: wrap; }
.j-stat { flex: 1; min-width: 200px; background: #F8F9FA; padding: 20px; border-radius: 15px; border: 1px solid var(--border); }
.j-stat span { font-size: 0.85rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }
.j-stat h3 { font-size: 1.5rem; margin-top: 5px; }
.alerts-container {
    background: #fff;
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
    border-left: 5px solid var(--danger);
    margin-top: 20px;
    margin-bottom: 20px;
}
.alert-item {
    padding: 15px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 600;
    font-size: 0.95rem;
}
.alert-warning { background: #FFFBEA; color: #9D7C00; border: 1px solid #FFE485; }
.alert-danger { background: #FEECEB; color: var(--danger); border: 1px solid #FCCAC7; }
@media print {
    /* Cache tout sauf la zone de facture */
    aside, nav, header, .billing-controls, .btn-primary, .btn-outline, .ambient-light {
        display: none !important;
    }
    main { padding: 0; margin: 0; }
    .content-section { display: block !important; }
    #invoice-zone {
        display: block !important;
        box-shadow: none !important;
        border: none !important;
        width: 100%;
    }
    body { background: white; }
}

/* Style spécifique pour le PDF généré */
.pdf-template {
    padding: 40px;
    background: white;
    color: #000;
}
