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

body {
    font-family: 'Inter', sans-serif;
    background: #f8fafc;
    color: #0f172a;
    min-height: 100vh;
    display: flex;
}



/* SIDEBAR */
.sidebar {
    width: 240px;
    background: #0f172a;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    padding: 1.5rem;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    gap: .75rem;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: #2563eb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.logo-icon-img {
    background: white;
    padding: 4px;
    overflow: hidden;
}

.logo-icon-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.logo-text {
    font-size: .95rem;
    font-weight: 700;
    color: white;
}

.logo-sub {
    font-size: .7rem;
    color: #64748b;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-section {
    padding: .5rem 1rem .25rem;
    font-size: .65rem;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1rem;
    margin: .1rem .75rem;
    border-radius: 8px;
    color: #94a3b8;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    border: none;
    background: none;
    width: calc(100% - 1.5rem);
    text-align: left;
}

.nav-item:hover {
    background: #1e293b;
    color: white;
}

.nav-item.active {
    background: #2563eb;
    color: white;
}

.nav-item .icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.nav-badge {
    margin-left: auto;
    background: #ef4444;
    color: white;
    font-size: .65rem;
    font-weight: 700;
    padding: .15rem .4rem;
    border-radius: 10px;
}

.sidebar-user {
    padding: 1rem;
    border-top: 1px solid #1e293b;
    display: flex;
    align-items: center;
    gap: .75rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: #2563eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: .8rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: .7rem;
    color: #64748b;
}

.logout-btn {
    color: #64748b;
    cursor: pointer;
    font-size: 1rem;
    background: none;
    border: none;
    padding: .25rem;
}

.logout-btn:hover {
    color: #ef4444;
}

/* MAIN */
.main {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* TOPBAR */
.topbar {
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* CONTENT */
.content {
    padding: 2rem;
    flex: 1;
}

/* BUTTONS */
.btn-primary {
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    padding: .5rem 1.25rem;
    font-size: .875rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background .2s;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

.btn-secondary {
    background: white;
    color: #374151;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: .5rem 1.25rem;
    font-size: .875rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: border-color .2s;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}

.btn-secondary:hover {
    border-color: #2563eb;
    color: #2563eb;
}

.btn-danger {
    background: #fef2f2;
    color: #dc2626;
    border: 1.5px solid #fecaca;
    border-radius: 8px;
    padding: .5rem 1.25rem;
    font-size: .875rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
}

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

/* CARDS */
.card {
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: .95rem;
    font-weight: 600;
    color: #0f172a;
}

.card-link {
    font-size: .8rem;
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}

/* TABLES */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    padding: .75rem 1.5rem;
    text-align: left;
    font-size: .75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

td {
    padding: .875rem 1.5rem;
    font-size: .875rem;
    border-bottom: 1px solid #f1f5f9;
}

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

tr:hover td {
    background: #f8fafc;
}

/* BADGES */
.badge {
    display: inline-block;
    padding: .25rem .75rem;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 500;
}

.badge-success {
    background: #f0fdf4;
    color: #16a34a;
}

.badge-warning {
    background: #fffbeb;
    color: #d97706;
}

.badge-danger {
    background: #fef2f2;
    color: #dc2626;
}

.badge-info {
    background: #eff6ff;
    color: #2563eb;
}

.badge-gray {
    background: #f1f5f9;
    color: #64748b;
}

/* FORMS */
.form-field {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.form-field label {
    font-size: .8rem;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.form-field input,
.form-field textarea,
.form-field select {
    padding: .625rem .875rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: .9rem;
    font-family: 'Inter', sans-serif;
    color: #0f172a;
    transition: border-color .2s;
    background: white;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.form-field input:disabled {
    background: #f8fafc;
    color: #64748b;
}

.form-field textarea {
    resize: vertical;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    padding: 1.5rem;
}

.form-grid .full {
    grid-column: 1 / -1;
}

/* LOADING */
.loading {
    text-align: center;
    padding: 3rem;
    color: #64748b;
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ALERTS */
.alert {
    padding: .75rem 1rem;
    border-radius: 8px;
    font-size: .875rem;
    margin-bottom: 1rem;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #16a34a;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
}

.alert-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #2563eb;
}

/* KPI */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.kpi-label {
    font-size: .8rem;
    font-weight: 500;
    color: #64748b;
}

.kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0f172a;
}

.kpi-sub {
    font-size: .75rem;
    color: #64748b;
}

.icon-blue {
    background: #eff6ff;
}

.icon-green {
    background: #f0fdf4;
}

.icon-purple {
    background: #ede9fe;
    color: #7c3aed;
}


.icon-orange {
    background: #fff7ed;
}

.icon-red {
    background: #fef2f2;
}

/* ============ SÉLECTEUR DE PÉRIODE ============ */
.periode-switcher {
    display: inline-flex;
    gap: 0.25rem;
    background: #f1f5f9;
    padding: 0.3rem;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.periode-btn {
    border: none;
    background: transparent;
    color: #64748b;
    padding: 0.5rem 1rem;
    border-radius: 7px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}

.periode-btn:hover {
    background: #fff;
    color: #0f172a;
}

.periode-btn.active {
    background: #2563eb;
    color: #fff;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}

.periode-btn.active:hover {
    background: #1d4ed8;
    color: #fff;
}

.periode-btn-custom {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border-left: 1px solid #e2e8f0;
    padding-left: 0.75rem;
    margin-left: 0.25rem;
}

.periode-btn-custom.active {
    border-left-color: transparent;
}

.raccourci-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #475569;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.raccourci-btn:hover {
    background: #eff6ff;
    border-color: #2563eb;
    color: #2563eb;
}

/* ===== Modales unifiées (envoi document + message client) ===== */
.modal-content .modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-content .modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: #0f172a;
}

.modal-content .modal-body {
    padding: 1.5rem;
}

.modal-content .modal-body .form-field {
    margin-bottom: 1rem;
}

.modal-content .modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
}




/* === Bandeau d'alerte cliquable === */
.alerte-clickable {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.85rem;
    padding: 0.9rem 1.15rem;
    border-radius: 10px;
    margin-bottom: 0.6rem;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    border-left-width: 4px;
    border-left-style: solid;
    cursor: pointer !important;
    text-decoration: none;
}

.alerte-clickable * {
    cursor: pointer !important;
}

.alerte-clickable:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.alerte-clickable.alerte-warning {
    background: #fffbeb;
    border-color: #fde68a;
    border-left-color: #f59e0b;
    color: #78350f;
}

.alerte-clickable.alerte-danger {
    background: #fef2f2;
    border-color: #fecaca;
    border-left-color: #ef4444;
    color: #991b1b;
}

.alerte-clickable .alerte-icon {
    font-size: 1.4rem;
}

.alerte-clickable .alerte-content {
    flex: 1;
}

.alerte-clickable .alerte-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.alerte-clickable .alerte-subtitle {
    font-size: 0.78rem;
    opacity: 0.75;
    margin-top: 0.1rem;
}

.alerte-clickable .alerte-cta {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}

/* RESPONSIVE */
@media (max-width: 1024px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main {
        margin-left: 0;
    }
}