/* ============================================
   Dashboard Admin - Styles Principaux
   Thème: #f9d406 (jaune) & #06621f (vert foncé)
   ============================================ */

:root {
    --primary-yellow: #f9d406;
    --primary-green: #06621f;
    --dark-green: #044a17;
    --light-yellow: #fff9d6;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --sidebar-width: 260px;
    --header-height: 70px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
}

/* ============================================
   Layout Principal
   ============================================ */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary-green) 0%, var(--dark-green) 100%);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-close { display: none; }

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
}

.sidebar-logo h2 {
    color: var(--white);
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-logo span {
    color: var(--primary-yellow);
}

.sidebar-nav {
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 5px 24px !important;
    color: rgba(255, 255, 255, 0.7);
    transition: var(--transition);
    cursor: pointer;
    border-left: 3px solid transparent;
    margin: 4px 0;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.nav-item.active {
    background: rgba(249, 212, 6, 0.15);
    color: var(--primary-yellow);
    border-left-color: var(--primary-yellow);
}

.nav-item i {
    width: 24px;
    font-size: 1.1rem;
    margin-right: 12px;
}

.nav-item span {
    font-size: 0.95rem;
    font-weight: 500;
}

.sidebar-footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px;
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.95rem;
    font-weight: 500;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}

.logout-btn i {
    margin-right: 8px;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* ============================================
   Header
   ============================================ */
.header {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-800);
}

.header-search {
    position: relative;
}

.header-search input {
    width: 300px;
    padding: 10px 16px 10px 42px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: var(--transition);
    background: var(--gray-50);
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary-green);
    background: var(--white);
    box-shadow: 0 0 0 3px rgba(6, 98, 31, 0.1);
}

.header-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.notification-btn {
    position: relative;
    width: 42px;
    height: 42px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-btn:hover {
    background: var(--gray-200);
}

.notification-btn i {
    font-size: 1.2rem;
    color: var(--gray-600);
}

.notification-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px 6px 6px;
    background: var(--gray-50);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
}

.user-menu:hover {
    background: var(--gray-100);
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary-yellow), var(--primary-green));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
}

.user-info {
    text-align: left;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-800);
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* --------------------------------------------------------------
   Listes déroulantes avec recherche (js/select-recherche.js)
   Le <select> d'origine reste dans le DOM, simplement masqué :
   la sérialisation des formulaires et le code existant continuent
   de fonctionner sans retouche.
   -------------------------------------------------------------- */
.sr-boite {
    position: relative;
}

.sr-natif {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
}

.sr-bouton {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    text-align: left;
    cursor: pointer;
    background: var(--white);
}

.sr-bouton::after {
    content: '';
    flex: none;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--gray-500);
    border-bottom: 1.5px solid var(--gray-500);
    transform: rotate(45deg) translate(-2px, -2px);
    transition: transform .18s ease;
}

.sr-ouverte .sr-bouton::after {
    transform: rotate(-135deg) translate(-2px, -2px);
}

.sr-bouton.sr-vide {
    color: var(--gray-500);
}

.sr-panneau {
    display: none;
    position: absolute;
    z-index: 1400;   /* au-dessus des modales, sinon la liste est tronquée */
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .14);
    overflow: hidden;
}

.sr-ouverte .sr-panneau {
    display: block;
}

.sr-champ {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--gray-200);
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
}

.sr-liste {
    list-style: none;
    margin: 0;
    padding: 4px;
    max-height: 240px;
    overflow-y: auto;
}

.sr-option {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

.sr-option:hover {
    background: var(--gray-100);
}

.sr-option.sr-choisie {
    background: #ecfdf5;
    color: #047857;
    font-weight: 600;
}

.sr-option.sr-desactivee {
    color: var(--gray-500);
    cursor: not-allowed;
}

.sr-aucun {
    padding: 12px;
    text-align: center;
    font-size: 13px;
    color: var(--gray-500);
}

/* --------------------------------------------------------------
   Badge de rôle (DG, DGA, comptable, secrétaire)
   Les couleurs viennent de function/roles.php, injectées en
   variables --role-c / --role-bg sur .user-menu : la feuille de
   style n'a pas à connaître la liste des rôles, ajouter un rôle
   ne demande donc aucune retouche ici.
   -------------------------------------------------------------- */
.user-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    padding: 2px 10px 2px 8px;
    border-radius: 999px;
    background: var(--role-bg, #f3f4f6);
    color: var(--role-c, #6b7280);
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.7;
    white-space: nowrap;
    cursor: default;
    animation: roleApparition .5s cubic-bezier(.2, .7, .3, 1) both;
}

.user-role-dot {
    position: relative;
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

/* Anneau qui se diffuse depuis la pastille — signale un état vivant
   sans attirer l'oeil en permanence comme le ferait un clignotement. */
.user-role-dot::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: currentColor;
    animation: rolePouls 2.6s ease-out infinite;
}

@keyframes roleApparition {
    from { opacity: 0; transform: translateY(-5px) scale(.92); }
    to   { opacity: 1; transform: none; }
}

@keyframes rolePouls {
    0%        { transform: scale(1);   opacity: .5; }
    70%, 100% { transform: scale(2.8); opacity: 0; }
}

/* Une animation perpétuelle peut gêner, voire déclencher des troubles
   vestibulaires : on respecte le réglage système. */
@media (prefers-reduced-motion: reduce) {
    .user-role-badge,
    .user-role-dot::after {
        animation: none;
    }
}

/* ============================================
   Page Content
   ============================================ */
.page-content {
    padding: 30px;
}

/* ============================================
   Cards
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

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

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.stat-card.expenses::before {
    background: var(--danger);
}

.stat-card.balance::before {
    background: var(--primary-green);
}

.stat-card.savings::before {
    background: var(--primary-yellow);
}

.stat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.expenses {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.stat-icon.balance {
    background: rgba(6, 98, 31, 0.1);
    color: var(--primary-green);
}

.stat-icon.savings {
    background: rgba(249, 212, 6, 0.2);
    color: #b8960c;
}

.stat-icon i {
    font-size: 1.5rem;
}

.stat-trend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.stat-trend.up {
    color: var(--success);
}

.stat-trend.down {
    color: var(--danger);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--gray-500);
}

/* ============================================
   Content Card
   ============================================ */
.content-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.card-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--gray-800);
}

.card-body {
    padding: 24px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary-green);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--dark-green);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-warning {
    background: var(--primary-yellow);
    color: var(--gray-800);
}

.btn-warning:hover {
    background: #e0c005;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--gray-300);
    color: var(--gray-600);
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.95rem;
    transition: var(--transition);
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-green);
    box-shadow: 0 0 0 3px rgba(6, 98, 31, 0.1);
}

.form-control::placeholder {
    color: var(--gray-400);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

select.form-control {
    cursor: pointer;
}

/* Radio & Checkbox */
.radio-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.radio-item, .checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.radio-item input, .checkbox-item input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-green);
    cursor: pointer;
}

/* ============================================
   Tables / DataTables
   ============================================ */
.table-container {
    overflow-x: auto;
}

/* Fix : dropdown visible dans le tableau */
.table-container .dropdown-menu.show {
    position: fixed !important;
    z-index: 1060;
    will-change: transform;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.data-table td {
    color: var(--gray-700);
    font-size: 0.9rem;
}

/* DataTables Override */
.dataTables_wrapper {
    padding: 0;
}

.dataTables_filter input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    margin-left: 8px;
}

.dataTables_length select {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    margin: 0 8px;
}

.dataTables_paginate .paginate_button {
    padding: 6px 12px !important;
    border-radius: var(--radius) !important;
    margin: 0 2px !important;
}

.dataTables_paginate .paginate_button.current {
    background: var(--primary-green) !important;
    color: var(--white) !important;
    border: none !important;
}

.dataTables_info {
    color: var(--gray-500);
    font-size: 0.9rem;
}

/* ============================================
   Status Badges
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.badge-secondary {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal.modal-lg {
    max-width: 900px;
}

.modal.modal-xl {
    max-width: 1200px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
}

.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--gray-200);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* ============================================
   Dropdown
   ============================================ */
.dropdown {
    position: relative;
}

.dropdown-toggle {
    cursor: pointer;
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 180px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition);
    z-index: 100;
}

.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(5px);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--gray-700);
    transition: var(--transition);
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--gray-50);
}

.dropdown-item i {
    width: 18px;
    color: var(--gray-500);
}

.dropdown-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 4px 0;
}

/* ============================================
   Quick Actions
   ============================================ */
.quick-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--white);
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    color: var(--gray-600);
    cursor: pointer;
    transition: var(--transition);
}

.quick-action-btn:hover {
    border-color: var(--primary-green);
    color: var(--primary-green);
    background: rgba(6, 98, 31, 0.02);
}

/* ============================================
   Filter Bar
   ============================================ */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.month-filter {
    padding: 10px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    cursor: pointer;
}

/* ============================================
   Invoice Preview
   ============================================ */
.invoice-preview {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 40px;
    margin-top: 20px;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--primary-green);
}

.invoice-logo img {
    max-height: 60px;
}

.invoice-title {
    text-align: right;
}

.invoice-title h1 {
    font-size: 2rem;
    color: var(--primary-green);
    margin-bottom: 8px;
}

.invoice-title .invoice-number {
    font-size: 1rem;
    color: var(--gray-600);
}

.invoice-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 40px;
}

.invoice-party h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.invoice-party p {
    margin-bottom: 4px;
    color: var(--gray-700);
}

.invoice-party strong {
    color: var(--gray-800);
}

.invoice-dates {
    display: flex;
    gap: 40px;
    margin-bottom: 30px;
}

.invoice-date {
    font-size: 0.9rem;
}

.invoice-date span {
    color: var(--gray-500);
}

.invoice-table {
    width: 100%;
    margin-bottom: 30px;
    border-collapse: collapse;
}

.invoice-table th {
    background: var(--gray-100);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
}

.invoice-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-200);
}

.invoice-table .text-right {
    text-align: right;
}

.invoice-totals {
    display: flex;
    justify-content: flex-end;
}

.invoice-totals-table {
    width: 300px;
}

.invoice-totals-table tr td {
    padding: 8px 16px;
}

.invoice-totals-table tr td:first-child {
    text-align: right;
    color: var(--gray-600);
}

.invoice-totals-table tr td:last-child {
    text-align: right;
    font-weight: 500;
}

.invoice-totals-table .total-row {
    background: var(--primary-green);
    color: var(--white);
    font-weight: 700;
    font-size: 1.1rem;
}

.invoice-totals-table .total-row td {
    border-radius: var(--radius);
}

.invoice-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

.invoice-notes {
    margin-bottom: 20px;
}

.invoice-notes h4 {
    font-size: 0.9rem;
    color: var(--gray-600);
    margin-bottom: 8px;
}

.invoice-notes p {
    color: var(--gray-500);
    font-size: 0.9rem;
}

.invoice-qr {
    text-align: center;
}

.invoice-qr canvas {
    max-width: 100px;
}

/* ============================================
   Login Page
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gray-100) 0%, var(--light-yellow) 100%);
    padding: 20px;
}

.login-container {
    display: flex;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    max-width: 900px;
    width: 100%;
}

.login-image {
    flex: 1;
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--dark-green) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--white);
}

.login-image h1 {
    font-size: 2rem;
    margin-bottom: 16px;
}

.login-image p {
    opacity: 0.9;
    text-align: center;
}

.login-form-container {
    flex: 1;
    padding: 60px 40px;
}

.login-form-header {
    margin-bottom: 32px;
}

.login-form-header h2 {
    font-size: 1.75rem;
    color: var(--gray-800);
    margin-bottom: 8px;
}

.login-form-header p {
    color: var(--gray-500);
}

.login-form .form-group {
    margin-bottom: 24px;
}

.login-form .btn {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
}

.login-footer {
    margin-top: 24px;
    text-align: center;
    color: var(--gray-500);
    font-size: 0.9rem;
}

/* ============================================
   Settings Page
   ============================================ */
.settings-section {
    margin-bottom: 30px;
}

.settings-section h3 {
    font-size: 1.1rem;
    color: var(--gray-800);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--gray-200);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.logo-upload {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo-preview {
    width: 80px;
    height: 80px;
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    overflow: hidden;
}

.logo-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .header {
        padding: 0 20px;
    }
    
    .header-search input {
        width: 200px;
    }
    
    .invoice-parties {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .login-image {
        display: none;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .header-search {
        display: none;
    }
    
    .quick-actions {
        flex-direction: column;
    }
    
    .modal {
        width: 95%;
        margin: 10px;
    }
    
    .page-content {
        padding: 20px;
    }
}

@media (max-width: 576px) {
    /* Le bloc nom + rôle disparaît faute de place. Pour que le rôle reste
       lisible, sa couleur passe en anneau autour de l'avatar. */
    .user-info {
        display: none;
    }

    .user-menu .user-avatar {
        box-shadow: 0 0 0 2px var(--white), 0 0 0 4px var(--role-c, transparent);
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .card-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease forwards;
}

/* ============================================
   Utilities
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--gray-500); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.gap-2 { gap: 16px; }
.hidden { display: none !important; }

/* ============================================
   Phone Input Customization
   ============================================ */
.iti {
    width: 100%;
}

.iti__flag-container {
    padding: 0;
}

.iti__selected-flag {
    padding: 0 12px;
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .no-print {
        display: none !important;
    }
    
    .invoice-preview {
        padding: 0;
        border: none;
        box-shadow: none;
    }
}

/* ============================================
   Font Awesome Icon Sizing (remplacement Feather)
   ============================================ */

/* Taille par défaut des icônes FA dans la sidebar et le layout */
.sidebar-nav .nav-item i,
.sidebar-footer i,
.header i,
.quick-action-btn i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

/* Icônes dans les stat-cards */
.stat-icon i {
    font-size: 20px;
}

/* Icônes dans les boutons */
.btn i.fa-solid,
.btn i.fa-regular {
    font-size: 14px;
}

/* Icônes dans les card-title */
.card-title i {
    font-size: 16px;
    vertical-align: middle;
    margin-right: 6px;
}

/* Dropdown action bouton - trois points */
.dropdown .btn-sm i.fa-solid,
.dropdown .btn-sm i.fa-regular,
table .dropdown .btn i,
.data-table .dropdown .btn i {
    font-size: 16px;
    line-height: 1;
}

/* Dropdown menu items */
.dropdown-menu .dropdown-item i,
.dropdown-menu .dropdown-item i.fa-solid {
    font-size: 14px;
    width: 20px;
    text-align: center;
    margin-right: 6px;
    display: inline-block;
    vertical-align: middle;
}

/* Forcer l'affichage des icônes FA dans les cellules de tableau */
td i.fa-solid,
td i.fa-regular,
td .dropdown i {
    font-size: 16px;
    display: inline-block;
    vertical-align: middle;
}

/* Stat trend arrows */
.stat-trend i {
    font-size: 12px;
}

/* Notification badge bell */
.notification-btn i {
    font-size: 18px;
}

/* Modal close button */
.modal-close i {
    font-size: 16px;
}

/* Badge dans les filtres */
.filter-bar .btn i {
    font-size: 12px;
}

/* ============================================
   Btn Loading Spinner
   ============================================ */
.loader-btn {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: loader-btn-spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}
@keyframes loader-btn-spin {
    to { transform: rotate(360deg); }
}
.btn[disabled] {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

/* =====================================================================
   Bannière de mise à jour PWA
   ---------------------------------------------------------------------
   Couleurs Téra : vert #06621e, jaune #F9D406.
   Cachée par défaut ; .show la fait glisser depuis le bas.
   ===================================================================== */
.pwa-update-banner {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%) translateY(160%);
    width: calc(100% - 32px);
    max-width: 440px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #06621e;
    color: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
    z-index: 99998;
    opacity: 0;
    visibility: hidden;
    transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease, visibility 0.35s;
    border: 1px solid rgba(249, 212, 6, 0.35);
}

.pwa-update-banner.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.pwa-update-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(249, 212, 6, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
}
.pwa-update-icon i {
    color: #F9D406;
    font-size: 18px;
    animation: pwa-spin 2.5s linear infinite;
}
@keyframes pwa-spin { to { transform: rotate(360deg); } }

.pwa-update-text {
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}
.pwa-update-text strong {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
}
.pwa-update-text span {
    display: block;
    font-size: 0.78rem;
    opacity: 0.85;
    margin-top: 1px;
}

.pwa-update-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #F9D406;
    color: #06621e;
    border: none;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: filter 0.2s, transform 0.1s;
    white-space: nowrap;
}
.pwa-update-btn:hover { filter: brightness(1.06); }
.pwa-update-btn:active { transform: scale(0.97); }
.pwa-update-btn:disabled { opacity: 0.75; cursor: default; }

/* Loader dans le bouton (caché tant que pas en .loading) */
.pwa-update-btn .loader-dot { display: none; }
.pwa-update-btn.loading .loader-dot {
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid #06621e;
    border-right-color: transparent;
    border-radius: 50%;
    animation: pwa-spin 0.7s linear infinite;
}
.pwa-update-btn.loading .pwa-update-btn-label { opacity: 0.7; }

.pwa-update-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.75);
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.pwa-update-close:hover { color: #fff; }

/* Sur très petit écran : passer en colonne pour ne rien rogner */
@media (max-width: 380px) {
    .pwa-update-banner { flex-wrap: wrap; }
    .pwa-update-text { flex-basis: calc(100% - 52px); }
    .pwa-update-btn { flex: 1; justify-content: center; margin-top: 4px; }
    .pwa-update-close { position: absolute; top: 8px; right: 8px; }
}

/* =====================================================================
   MENU LATERAL GROUPE
   ---------------------------------------------------------------------
   Deux niveaux seulement : section repliable > entree.
   Le marqueur natif du <details> est neutralise en gardant summary en
   display:block (un wrapper interne porte le flex) : c'est la seule
   methode fiable sur Chrome recent, ou display:flex sur summary ne
   supprime plus le triangle.
   ===================================================================== */

.nav-group { border: 0; margin: 0; }

.nav-group > summary {
    display: block;              /* indispensable : voir commentaire */
    list-style: none;
    cursor: pointer;
    user-select: none;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary::marker { content: ""; }

/* Wrapper interne : porte la mise en page */
.nav-group-head {
    display: flex;
    align-items: center;
    padding: 11px 24px;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.9rem;
    font-weight: 600;
    border-left: 3px solid transparent;
    transition: var(--transition);
}

.nav-group > summary:hover .nav-group-head {
    background: rgba(255, 255, 255, 0.08);
}

/* Section ouverte : fond legerement creuse pour la detacher */
.nav-group[open] > summary .nav-group-head {
    background: rgba(0, 0, 0, 0.16);
}

/* Section contenant la page courante */
.nav-group.nav-group-active > summary .nav-group-head {
    color: var(--primary-yellow);
    border-left-color: var(--primary-yellow);
}

.nav-group-head i:first-child {
    width: 24px;
    font-size: 1rem;
    margin-right: 12px;
    text-align: center;
}

.nav-chevron {
    margin-left: auto;
    font-size: 0.7rem;
    opacity: 0.65;
    transition: transform .2s ease;
}
.nav-group[open] > summary .nav-chevron { transform: rotate(90deg); }

/* Corps de la section */
.nav-group-body {
    background: rgba(0, 0, 0, 0.16);
    padding: 4px 0 8px;
}

.nav-group-body .nav-item {
    padding: 7px 24px 7px 50px !important;
    font-size: 0.875rem;
    margin: 0;
}

/* Filet de separation entre familles d'entrees */
.nav-group-body hr {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
    margin: 6px 24px 6px 50px;
}

/* Pastille de comptage */
.nav-badge {
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    line-height: 1.4;
    margin-left: auto;
}
.nav-group-head .nav-badge { margin-left: auto; margin-right: 10px; }

.nav-separator {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 20px;
}
