/* Styles personnalisés pour l'application Suivi-Stock */

:root {
    --app-navy: #173d63;
    --app-navy-2: #123455;
    --app-navy-3: #0f2d49;
    --app-gold: #d3a12a;
    --app-bg: #f4f7fb;
    --app-panel: #ffffff;
    --app-border: #dfe7f1;
    --app-text: #0f172a;
    --app-muted: #64748b;
    --app-green: #16a34a;
    --app-red: #ef4444;
}

* {
    letter-spacing: 0;
}

html {
    background: var(--app-bg);
    /* Évite le scroll horizontal accidentel sur mobile */
    overflow-x: hidden;
}

@media (max-width: 767px) {
    body {
        overflow-x: hidden;
    }
}

body {
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(244, 247, 251, 0.98), rgba(239, 244, 250, 0.98)),
        var(--app-bg) !important;
    color: var(--app-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#login-screen {
    background:
        radial-gradient(circle at top left, rgba(23, 61, 99, 0.14), transparent 34rem),
        linear-gradient(135deg, #f8fafc 0%, #edf3fa 100%);
}

.login-card {
    border-radius: 18px !important;
    box-shadow: 0 24px 80px rgba(15, 45, 73, 0.18) !important;
}

#main-interface:not(.hidden) {
    display: flex;
    min-height: 100vh;
    background: var(--app-bg);
}

#app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    flex-direction: column;
    gap: 18px;
    padding: 18px 14px;
    color: #dbeafe;
    background: linear-gradient(180deg, var(--app-navy) 0%, var(--app-navy-2) 54%, var(--app-navy-3) 100%);
    box-shadow: 12px 0 36px rgba(15, 45, 73, 0.18);
    z-index: 45;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 54px;
    padding: 0 2px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.sidebar-logo {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: inset 0 0 0 1px rgba(15, 45, 73, 0.08);
}

.sidebar-brand h1 {
    margin: 0;
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.2;
}

.sidebar-brand p,
.sidebar-section-label {
    margin: 0;
    color: rgba(219, 234, 254, 0.66);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.sidebar-section-label {
    padding: 0 8px;
}

.sidebar-spacer {
    display: none;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 58px;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 999px;
    color: #fff;
    background: #1e88e5;
    flex: 0 0 auto;
}

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

.sidebar-user-meta p {
    margin: 0;
    overflow: hidden;
    color: #fff;
    font-size: 13px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-meta span {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    color: rgba(191, 219, 254, 0.78);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    color: rgba(191, 219, 254, 0.82);
    background: transparent;
    /* Propriété manquante corrigée — "transition: 0.2s" est invalide sans nom de propriété */
    transition: color 0.2s ease, background-color 0.2s ease;
}

.sidebar-logout:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.app-shell {
    flex: 1;
    min-width: 0;
}

#app-header {
    margin-left: 280px;
    padding: 12px 24px !important;
    color: var(--app-text) !important;
    background: rgba(255, 255, 255, 0.86) !important;
    border-bottom: 1px solid var(--app-border);
    box-shadow: 0 10px 28px rgba(15, 45, 73, 0.06) !important;
    backdrop-filter: blur(16px);
}

#app-header.bg-purple-900 {
    background: rgba(255, 255, 255, 0.86) !important;
}

#app-header .max-w-7xl {
    max-width: none;
    padding: 0;
}

#app-header .max-w-7xl > .flex.items-center.space-x-3 {
    display: none;
}

#app-header .max-w-7xl > .flex.items-center.gap-4 {
    width: 100%;
    justify-content: flex-end;
}

#desktop-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 0 8px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}

#desktop-nav::-webkit-scrollbar { width: 4px; }
#desktop-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
#desktop-nav::-webkit-scrollbar-track { background: transparent; }

#desktop-nav .nav-btn {
    width: 100%;
    min-height: 44px;
    justify-content: flex-start;
    gap: 10px;
    margin: 0 !important;
    padding: 11px 13px !important;
    border: 1px solid transparent;
    border-radius: 10px !important;
    color: rgba(232, 242, 255, 0.78) !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 14px;
    font-weight: 650;
}

#desktop-nav .nav-btn i {
    width: 18px;
    margin: 0 !important;
    color: rgba(232, 242, 255, 0.62);
    text-align: center;
}

#desktop-nav .nav-btn:hover,
#desktop-nav .nav-btn.active {
    color: #fff !important;
    background: rgba(255, 255, 255, 0.12) !important;
    border-color: rgba(255, 255, 255, 0.08);
}

#desktop-nav .nav-btn.active i {
    color: #fff;
}

#desktop-nav .nav-btn[data-tab="new"] {
    margin-top: 10px !important;
    color: #102a43 !important;
    background: var(--app-gold) !important;
}

#desktop-nav .nav-btn[data-tab="new"] i {
    color: #102a43;
}

#app-header .border-l {
    border-left: 0 !important;
}

#app-header #notif-btn,
#app-header #logout-btn,
.topbar-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--app-border);
    border-radius: 12px;
    color: var(--app-navy) !important;
    background: #fff !important;
    box-shadow: 0 8px 18px rgba(15, 45, 73, 0.06);
}

#export-btn,
.topbar-action {
    min-height: 40px;
    padding: 0 14px !important;
    border: 0;
    border-radius: 12px !important;
    color: #fff !important;
    background: var(--app-navy) !important;
    box-shadow: 0 10px 20px rgba(23, 61, 99, 0.18) !important;
}

#main-interface main {
    margin-left: 280px;
    max-width: none !important;
    width: calc(100% - 280px);
    padding: 28px 32px 36px !important;
}

#main-interface main::before {
    content: "Tableau de bord";
    display: block;
    margin-bottom: 4px;
    color: var(--app-text);
    font-size: 24px;
    font-weight: 850;
}

#main-interface main::after {
    content: "Suivi clair des stocks, mouvements et validations";
    display: block;
    margin: -4px 0 22px;
    color: var(--app-muted);
    font-size: 14px;
}

body[data-active-tab="stock"] #main-interface main::before { content: "Stocks"; }
body[data-active-tab="stock"] #main-interface main::after { content: "Inventaire, seuils et disponibilité des articles"; }
body[data-active-tab="journal"] #main-interface main::before { content: "Journal"; }
body[data-active-tab="journal"] #main-interface main::after { content: "Historique filtrable des mouvements"; }
body[data-active-tab="new"] #main-interface main::before { content: "Nouveau mouvement"; }
body[data-active-tab="new"] #main-interface main::after { content: "Entrée, sortie, transfert ou ravitaillement"; }
body[data-active-tab="users"] #main-interface main::before { content: "Utilisateurs"; }
body[data-active-tab="users"] #main-interface main::after { content: "Gestion des accès et rôles"; }
body[data-active-tab="agencies"] #main-interface main::before { content: "Agences"; }
body[data-active-tab="agencies"] #main-interface main::after { content: "Organisation des agences et sous-agences"; }
body[data-active-tab="multi_stock"] #main-interface main::before { content: "Multi-Stock"; }
body[data-active-tab="multi_stock"] #main-interface main::after { content: "Comparaison des stocks par localisation"; }
body[data-active-tab="validations"] #main-interface main::before { content: "Validations"; }
body[data-active-tab="validations"] #main-interface main::after { content: "Mouvements en attente et décisions"; }

body[data-active-tab="dashboard"] #main-interface main::before,
body[data-active-tab="dashboard"] #main-interface main::after {
    display: none;
}

.dashboard-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 6px;
}

.dashboard-toolbar h2 {
    margin: 0;
    color: #0f2b3d;
    font-size: 28px;
    font-weight: 850;
    line-height: 1.1;
}

.dashboard-toolbar p {
    margin-top: 5px;
    color: #64748b;
    font-size: 14px;
}

.dashboard-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dashboard-period {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    color: #64748b;
    background: #fff;
    box-shadow: 0 8px 18px rgba(15, 43, 61, 0.05);
}

.dashboard-period select {
    min-width: 150px;
    border: 0 !important;
    color: #334155;
    background: transparent;
    font-size: 14px;
    font-weight: 700;
    outline: none;
    box-shadow: none !important;
}

.dashboard-chart-card {
    min-width: 0;
    padding: 20px;
    border: 1px solid #eef2f6;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 12px 34px rgba(15, 45, 73, 0.07);
}

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

.dashboard-card-header h3 {
    margin: 0;
    color: #1e293b !important;
    font-size: 16px !important;
    font-weight: 850;
}

.dashboard-card-header p {
    margin-top: 4px;
    color: #64748b;
    font-size: 12px;
}

.dashboard-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
    color: #64748b;
    font-size: 12px;
    white-space: nowrap;
}

.dashboard-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.legend-blue { background: #1e88e5; }
.legend-red { background: #ef4444; }

#edit-transaction-modal {
    overscroll-behavior: contain;
}

.edit-transaction-dialog {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 1.5rem);
    margin: auto 0;
    overflow-y: auto;
    border: 1px solid rgba(226, 232, 240, 0.9);
}

.edit-transaction-header {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #eef2f6;
    background: #ffffff;
}

.edit-transaction-dialog > .text-xs {
    margin: 1rem 1.5rem 0;
}

.edit-transaction-form {
    padding: 1rem 1.5rem 0;
}

.edit-transaction-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: 0 -1.5rem;
    padding: 0.9rem 1.5rem;
    border-top: 1px solid #eef2f6;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
}

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

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

@keyframes slideInBottom {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Classes utilitaires */
.animate-in {
    animation: fadeIn 0.3s ease-out;
}

.slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

.slide-in-bottom {
    animation: slideInBottom 0.3s ease-out;
}

.zoom-in {
    animation: zoomIn 0.3s ease-out;
}

/* Styles des boutons de navigation */
.nav-btn.active {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.mobile-nav-btn.active {
    color: #1e40af;
    background-color: #eff6ff;
}

/* Styles des cartes de statistiques */
.stat-card {
    /* Ciblage explicite des propriétés GPU-accelerated uniquement (pas de reflow) */
    transition: transform 0.2s ease, opacity 0.2s ease;
    will-change: transform;
}

.stat-card:hover {
    transform: translateY(-2px);
    /* filter:drop-shadow évite le repaint que box-shadow déclenche sur certains moteurs */
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.1));
}

#dashboard-content .bg-white,
#stock-content .bg-white,
#journal-content .bg-white,
#users-content .bg-white,
#new-content .bg-white,
#multi_stock-content .bg-white,
#agencies-content .bg-white,
#validations-content .bg-white,
#stat-card-template .bg-white {
    border-color: var(--app-border) !important;
    border-radius: 14px !important;
    box-shadow: 0 12px 34px rgba(15, 45, 73, 0.07) !important;
}

#dashboard-content .rounded-2xl,
#stock-content .rounded-xl,
#journal-content .rounded-xl,
#users-content .rounded-xl,
#new-content .rounded-xl,
#multi_stock-content .rounded-xl,
#agencies-content .rounded-xl,
#validations-content .rounded-xl {
    border-radius: 14px !important;
}

#dashboard-content h3,
#stock-content h2,
#journal-content h2,
#users-content h2,
#new-content h2,
#agencies-content h2,
#validations-content h2 {
    color: var(--app-text) !important;
    font-size: 17px !important;
    line-height: 1.25;
}

#dashboard-content p.text-5xl {
    color: var(--app-text) !important;
    font-size: clamp(2rem, 4vw, 2.75rem) !important;
    line-height: 1;
}

#dashboard-content p.text-2xl {
    color: var(--app-muted) !important;
    font-size: 14px !important;
}

#dashboard-content .grid > .bg-white i {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #eef4fb;
}

button.bg-blue-600,
button.bg-indigo-600,
button.bg-green-600,
button.bg-emerald-600 {
    background: var(--app-navy) !important;
    box-shadow: 0 10px 20px rgba(23, 61, 99, 0.14);
}

button.bg-yellow-500 {
    background: var(--app-gold) !important;
}

input,
select,
textarea {
    border-color: var(--app-border) !important;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(23, 61, 99, 0.45) !important;
    box-shadow: 0 0 0 4px rgba(23, 61, 99, 0.09) !important;
}

/* Badges d'état */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    border-width: 1px;
}

.status-critical {
    background-color: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.status-warning {
    background-color: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}

.status-ok {
    background-color: #d1fae5;
    color: #065f46;
    border-color: #a7f3d0;
}

/* Styles des tables */
.stock-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.stock-table th {
    position: sticky;
    top: 0;
    background-color: #f8fafc;
    z-index: 10;
}

.stock-table tbody tr {
    transition: background-color 0.2s ease;
}

.stock-table tbody tr:hover {
    background-color: #f3f7fb;
}

table thead {
    background: #f8fafc !important;
    color: #475569 !important;
}

table th {
    font-size: 12px;
    font-weight: 800 !important;
    text-transform: uppercase;
}

table tbody tr {
    transition: background-color 0.18s ease;
}

table tbody tr:hover {
    background: #f8fbff;
}

/* Scrollbar personnalisée */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Styles pour les formulaires */
.form-input {
    /* Ciblage des seules propriétés qui changent au focus — pas de reflow */
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Styles pour les notifications */
.notification {
    animation: fadeIn 0.3s ease-out;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.notification-success {
    background-color: #10b981;
    color: white;
}

.notification-error {
    background-color: #ef4444;
    color: white;
}

.notification-warning {
    background-color: #f59e0b;
    color: white;
}

.notification-info {
    background-color: #3b82f6;
    color: white;
}

/* Styles pour les onglets */
.tab-content {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    /* Promotion GPU avant l'animation pour éviter le jank au premier affichage */
    will-change: opacity, transform;
}

.tab-content.active {
    opacity: 1;
    transform: translateY(0);
    /* Libère la couche GPU une fois l'animation terminée */
    will-change: auto;
}

/* Styles pour les badges de rôle */
.role-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.role-admin {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.role-super-admin {
    background-color: #ede9fe;
    color: #5b21b6;
    border: 1px solid #ddd6fe;
}

/* Styles pour les indicateurs de stock */
.stock-indicator {
    height: 4px;
    border-radius: 2px;
    margin-top: 4px;
}

.stock-high {
    background-color: #10b981;
}

.stock-medium {
    background-color: #f59e0b;
}

.stock-low {
    background-color: #ef4444;
}

/* Styles responsives */
@media (max-width: 768px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .mobile-hidden {
        display: none !important;
    }
}

/* Styles d'impression */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background-color: white !important;
    }
    
    .tab-content {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Specific styling for chart containers to ensure responsiveness */
.chart-panel {
    position: relative;
    width: 100%;
    min-height: 340px;
}

#dashboard-operations-chart-container,
#dashboard-trend-chart-container,
#dashboard-distribution-chart-container {
    height: 340px;
}

#operation-counts-chart-container {
    max-width: 100%;
    min-width: 720px;
    height: 400px;
    margin-top: 24px;
    margin-bottom: 18px;
}

/* Wrapper scrollable pour les graphiques larges */
.chart-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#operation-counts-chart,
#dashboard-operations-chart,
#dashboard-trend-chart,
#dashboard-distribution-chart {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* =============================================
   RESPONSIVE — Mobile (≤ 767px)
   ============================================= */
@media (max-width: 767px) {
    #main-interface:not(.hidden) {
        display: block;
    }

    #app-sidebar,
    #desktop-nav {
        display: none !important;
    }

    #app-header {
        margin-left: 0;
        padding: 10px 14px !important;
        backdrop-filter: blur(12px);
    }

    #app-header .max-w-7xl > .flex.items-center.space-x-3 {
        display: flex;
    }

    #app-header .max-w-7xl {
        gap: 8px;
    }

    #app-header .max-w-7xl > .flex.items-center.gap-4 {
        width: auto;
        gap: 8px !important;
    }

    #app-header nav {
        display: none !important;
    }

    /* Header boutons : taille confortable pour les doigts */
    #app-header #notif-btn,
    #app-header #logout-btn,
    #export-btn {
        width: 44px !important;
        height: 44px !important;
        min-height: 44px !important;
    }

    /* Notification dropdown : ne dépasse pas l'écran */
    #notif-dropdown {
        width: min(320px, calc(100vw - 24px));
        right: -4px;
    }

    /* Contenu principal */
    #main-interface main {
        width: 100%;
        margin-left: 0;
        padding: 16px 12px 96px !important;
    }

    #main-interface main::before {
        font-size: 20px;
    }

    #main-interface main::after {
        font-size: 13px;
        margin-bottom: 14px;
    }

    /* Navigation mobile */
    #mobile-nav {
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -12px 30px rgba(15, 45, 73, 0.12);
        padding: 6px 4px 8px;
        /* Safe area pour iPhone X+ */
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }

    .mobile-nav-btn {
        min-height: 48px;
        padding: 6px 4px !important;
    }

    .mobile-nav-btn.active {
        color: var(--app-navy) !important;
        background-color: #eaf1f8 !important;
    }

    /* Graphiques : scrollable horizontalement, pas la page entière */
    #operation-counts-chart-container {
        min-width: 580px;
        height: 300px;
    }

    .chart-scroll-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -12px;
        padding: 0 12px 6px;
    }

    #dashboard-operations-chart-container,
    #dashboard-trend-chart-container,
    #dashboard-distribution-chart-container {
        min-height: 240px;
        height: 240px;
    }

    /* Dashboard toolbar : empilé sur mobile */
    .dashboard-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .dashboard-toolbar h2 {
        font-size: 22px;
    }

    .dashboard-toolbar p {
        font-size: 13px;
    }

    .dashboard-card-header {
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
    }

    .dashboard-toolbar-actions,
    .dashboard-period {
        width: 100%;
    }

    .dashboard-period {
        justify-content: space-between;
    }

    .dashboard-period select {
        width: 100%;
        min-width: 0;
    }

    /* Cartes dashboard : padding compact */
    #dashboard-content .bg-white.p-5,
    #dashboard-content .bg-white.p-6 {
        padding: 14px !important;
    }

    /* Chiffres KPI : taille adaptée */
    #dashboard-content p.text-5xl {
        font-size: clamp(1.6rem, 6vw, 2.2rem) !important;
    }

    /* Icônes des cartes : compactes */
    #dashboard-content .grid > .bg-white i {
        width: 30px !important;
        height: 30px !important;
    }

    /* Tables : scrollables horizontalement */
    .table-responsive,
    #journal-content .overflow-x-auto,
    #stock-content .overflow-x-auto,
    #validations-content .overflow-x-auto {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        display: block;
        width: 100%;
    }

    /* Inputs / selects : touch-friendly */
    input, select, textarea {
        min-height: 44px;
        font-size: 16px !important; /* Évite le zoom auto iOS */
    }

    button {
        min-height: 44px;
    }

    /* Formulaires : un champ par ligne */
    .grid.grid-cols-2.gap-2,
    .grid.grid-cols-2.gap-3 {
        grid-template-columns: 1fr !important;
    }

    /* Panneau détail journal (split-view) : empilé */
    .grid.grid-cols-2.divide-x {
        grid-template-columns: 1fr !important;
    }

    /* Modale modification transaction */
    .edit-transaction-dialog {
        max-height: calc(100dvh - 1rem);
        border-radius: 14px 14px 0 0;
        width: 100% !important;
        max-width: 100% !important;
        margin: auto 0 0 !important;
    }

    .edit-transaction-header,
    .edit-transaction-form {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .edit-transaction-dialog > .text-xs {
        margin-left: 1rem;
        margin-right: 1rem;
    }

    .edit-transaction-actions {
        flex-direction: column-reverse;
        margin-left: -1rem;
        margin-right: -1rem;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .edit-transaction-actions button {
        width: 100%;
        justify-content: center;
    }

    /* Notifications toast : pleine largeur */
    #notification {
        top: auto !important;
        bottom: 84px;
        right: 12px !important;
        left: 12px !important;
        max-width: none !important;
    }

    /* Légendes graphiques : compactes */
    .dashboard-legend {
        font-size: 11px;
        gap: 8px;
    }

    /* Sections avec trop de colonnes : réduction */
    .grid.grid-cols-2.lg\:grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Texte tronqué dans les tables : wrap */
    td, th {
        white-space: nowrap;
    }
}

/* =============================================
   RESPONSIVE — Petit téléphone (≤ 400px)
   ============================================= */
@media (max-width: 400px) {
    #mobile-nav {
        justify-content: space-around;
    }

    .mobile-nav-btn {
        width: auto !important;
        min-width: 50px;
        flex: 1;
    }

    #main-interface main {
        padding: 12px 10px 92px !important;
    }

    #dashboard-content p.text-5xl {
        font-size: 1.5rem !important;
    }

    .dashboard-toolbar h2 {
        font-size: 19px;
    }
}

/* =============================================
   RESPONSIVE — Tablette portrait (640–767px)
   ============================================= */
@media (min-width: 640px) and (max-width: 767px) {
    #main-interface main {
        padding: 20px 18px 96px !important;
    }

    #dashboard-content p.text-5xl {
        font-size: 2rem !important;
    }

    .grid.grid-cols-2.gap-2,
    .grid.grid-cols-2.gap-3 {
        grid-template-columns: repeat(2, 1fr) !important; /* 2 colonnes OK à 640px */
    }
}

/* =============================================
   RESPONSIVE — Tablette (768px–1120px)
   ============================================= */
@media (min-width: 768px) and (max-width: 1120px) {
    #app-sidebar {
        width: 238px;
    }

    #desktop-nav {
        width: 214px;
    }

    #app-header,
    #main-interface main {
        margin-left: 238px;
    }

    #main-interface main {
        width: calc(100% - 238px);
        padding: 22px 24px !important;
    }
}
