/* =============================================================================
   HADOTECH BOUTIQUE - Design System v2
   Palette HadoTech officielle (bleu #1E4CA1 / rouge #E31E24)
   Design moderne, responsive mobile-first, animations subtiles
   ============================================================================= */

:root {
    /* Brand - couleurs officielles HadoTech */
    --brand-blue: #1E4CA1;
    --brand-blue-dark: #163A7F;
    --brand-blue-light: #EEF3FB;
    --brand-blue-hover: #2559BE;
    --brand-red: #E31E24;
    --brand-red-dark: #B8181D;
    --brand-red-light: #FEF2F2;
    --brand-gradient: linear-gradient(135deg, #1E4CA1 0%, #2559BE 100%);
    --brand-gradient-red: linear-gradient(135deg, #E31E24 0%, #FF3A3F 100%);

    /* Neutrals - palette plus riche */
    --gray-0: #ffffff;
    --gray-25: #fcfcfd;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-150: #e9edf3;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Semantic */
    --brand-green: #10b981;
    --success: #10b981;
    --success-bg: #d1fae5;
    --success-dark: #059669;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --warning-dark: #d97706;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --danger-dark: #dc2626;
    --info: #0ea5e9;
    --info-bg: #e0f2fe;

    /* Layout */
    --sidebar-w: 272px;
    --topbar-h: 60px;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --shadow-xs: 0 1px 2px rgba(15,23,42,0.04);
    --shadow-sm: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
    --shadow: 0 4px 8px -2px rgba(15,23,42,0.08), 0 2px 4px -2px rgba(15,23,42,0.04);
    --shadow-md: 0 8px 16px -4px rgba(15,23,42,0.10), 0 4px 6px -4px rgba(15,23,42,0.05);
    --shadow-lg: 0 20px 25px -5px rgba(15,23,42,0.10), 0 10px 10px -5px rgba(15,23,42,0.04);
    --shadow-xl: 0 25px 50px -12px rgba(15,23,42,0.25);
    --ring: 0 0 0 3px rgba(30,76,161,0.15);

    /* Motion */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --transition: 180ms var(--ease-out);

    /* Type */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Space Grotesk', var(--font-sans);
    --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.55;
    color: var(--gray-800);
    background: var(--gray-50);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.025em;
    margin: 0 0 0.5em;
    color: var(--gray-900);
    line-height: 1.25;
}
h1 { font-size: 1.875rem; letter-spacing: -0.03em; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }

a { color: var(--brand-blue); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand-blue-hover); }

.mono { font-family: var(--font-mono); font-size: 0.92em; }

img { max-width: 100%; height: auto; display: block; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); background-clip: padding-box; border: 2px solid transparent; }

/* =============================================================================
   AUTH (login screens)
   ============================================================================= */

.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(ellipse at top left, rgba(30,76,161,0.10) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(227,30,36,0.08) 0%, transparent 50%),
        linear-gradient(135deg, #f8fafc 0%, #eef3fb 100%);
}

.auth-card {
    width: 100% !important;
    max-width: 440px !important;
    background: var(--gray-0);
    border-radius: var(--radius-xl);
    padding: 40px 36px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-150);
    margin: 0 auto !important;
    overflow: hidden;
    box-sizing: border-box;
}

.auth-logo {
    display: block !important;
    max-width: 200px !important;
    width: auto !important;
    height: auto !important;
    max-height: 60px !important;
    margin: 0 auto 8px !important;
    object-fit: contain;
}
.auth-logo-sub {
    text-align: center;
    color: var(--gray-500);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 600;
    margin-bottom: 32px;
}
.auth-card h1 { font-size: 1.5rem; text-align: center; margin-bottom: 6px; }
.auth-sub { text-align: center; color: var(--gray-500); margin: 0 0 28px; font-size: 14px; }
.auth-card .form-group { margin-bottom: 18px; }
.auth-card .btn { width: 100%; padding: 12px; font-size: 15px; margin-top: 8px; }
.auth-footer { text-align: center; margin-top: 24px; font-size: 13px; color: var(--gray-500); }
.auth-footer a { color: var(--brand-blue); font-weight: 500; }

/* Legacy brand mark (fallback) */
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; justify-content: center; }
.brand-mark, .brand-mark-red {
    width: 44px; height: 44px; border-radius: var(--radius); display: flex;
    align-items: center; justify-content: center; color: white; font-weight: 700;
    font-size: 20px; font-family: var(--font-display);
}
.brand-mark { background: var(--brand-gradient); }
.brand-mark-red { background: var(--brand-gradient-red); }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; text-transform: uppercase; letter-spacing: 0.15em; color: var(--gray-500); font-weight: 600; }

/* =============================================================================
   APP LAYOUT - sidebar + main
   ============================================================================= */

.app-body {
    min-height: 100vh;
    background: var(--gray-50);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #0f2547 0%, #163a7f 50%, #1E4CA1 100%);
    border-right: none;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 30;
    transition: transform var(--transition);
    box-shadow: 4px 0 20px -8px rgba(15, 37, 71, 0.4);
    color: #cfdcf0;
}

.sidebar-brand {
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.98);
    min-height: 78px;
    max-height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    overflow: hidden;
    box-sizing: border-box;
}
.sidebar-brand img {
    max-height: 42px !important;
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
    display: block;
}
.sidebar-brand-fallback {
    display: flex; align-items: center; gap: 12px; width: 100%;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px 20px;
}
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }

.nav-section {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255,255,255,0.5);
    font-weight: 700;
    margin: 18px 12px 6px;
}
.nav-section:first-child { margin-top: 8px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    color: #cfdcf0;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition);
    position: relative;
    margin-bottom: 1px;
}
.nav-link:hover {
    background: rgba(255,255,255,0.08);
    color: white;
    text-decoration: none;
    transform: translateX(2px);
}
.nav-link.active {
    background: linear-gradient(135deg, #ffffff 0%, #f0f4fa 100%);
    color: var(--brand-blue);
    box-shadow: 0 4px 12px -2px rgba(0,0,0,0.25);
    font-weight: 600;
}
.nav-link.active:hover { color: var(--brand-blue); transform: translateX(0); background: white; }
.nav-link.muted { opacity: 0.5; pointer-events: none; }

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 14px 16px;
    background: rgba(0,0,0,0.15);
}
.user-chip {
    display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.user-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, #E31E24, #ff5060);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 15px; font-family: var(--font-display);
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(227,30,36,0.4);
}
.user-info { min-width: 0; flex: 1; }
.user-name { font-weight: 600; font-size: 13px; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.55); text-transform: uppercase; letter-spacing: 0.05em; }

.btn-logout {
    width: 100%; padding: 8px 12px;
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
    color: white; font-weight: 500; font-size: 12.5px;
    border-radius: var(--radius-sm); cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}
.btn-logout:hover { background: var(--brand-red); border-color: var(--brand-red); color: white; }

/* Mobile topbar */
.mobile-topbar {
    display: none;
    height: var(--topbar-h);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 16px;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: var(--shadow-xs);
}
.mobile-topbar img { max-height: 32px !important; max-width: 180px !important; width: auto !important; height: auto !important; object-fit: contain; }
.hamburger {
    background: none; border: none; padding: 8px;
    cursor: pointer; color: var(--gray-700);
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.hamburger:hover { background: var(--gray-100); }
.hamburger svg { width: 24px; height: 24px; }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.5);
    z-index: 25;
    animation: fadeIn 180ms var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Main content */
.main {
    margin-left: var(--sidebar-w);
    padding: 28px 32px;
    min-height: 100vh;
    box-sizing: border-box;
}

/* =============================================================================
   PAGE HEADER
   ============================================================================= */

.page-header {
    display: flex; align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.page-header h1 { margin: 0; }
.page-sub { color: var(--gray-500); font-size: 13.5px; margin-top: 4px; }

/* =============================================================================
   CARDS
   ============================================================================= */

.card {
    background: var(--gray-0);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-150);
    box-shadow: var(--shadow-xs);
    padding: 22px;
    margin-bottom: 20px;
    transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-sm); }
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 14px; margin-bottom: 18px;
    border-bottom: 1px solid var(--gray-150);
}
.card-title { font-size: 1.05rem; font-weight: 600; margin: 0; color: var(--gray-900); }

/* =============================================================================
   STAT CARDS (dashboard)
   ============================================================================= */

.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--gray-0);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-150);
    padding: 20px 22px;
    box-shadow: var(--shadow-xs);
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
    cursor: default;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; bottom: 0;
    width: 4px; background: var(--brand-gradient);
    border-radius: 4px 0 0 4px;
    opacity: 0.9;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--gray-200);
}
.stat-label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--gray-500);
    font-weight: 600;
    margin-bottom: 8px;
}
.stat-value {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.03em;
    line-height: 1.1;
}
.stat-value.blue { color: var(--brand-blue); }
.stat-value.red { color: var(--brand-red); }
.stat-value.green { color: var(--brand-green); }
.stat-sub { font-size: 12px; color: var(--gray-500); margin-top: 6px; }

/* =============================================================================
   KPI CARDS v2 - dashboard richly designed
   ============================================================================= */
.kpi-hero {
    background: linear-gradient(135deg, #1E4CA1 0%, #2559BE 60%, #E31E24 140%);
    color: white;
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 12px 40px -12px rgba(30,76,161,0.5);
}
.kpi-hero::before {
    content:''; position:absolute; top:-40%; right:-10%; width:400px; height:400px;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
    pointer-events:none;
}
.kpi-hero::after {
    content:''; position:absolute; bottom:-60%; left:20%; width:300px; height:300px;
    background: radial-gradient(circle, rgba(227,30,36,0.25) 0%, transparent 70%);
    pointer-events:none;
}
.kpi-hero-content { position:relative; z-index:1; display:grid; grid-template-columns: 1fr auto; gap:20px; align-items:center; }
.kpi-hero-label { font-size:12px; text-transform:uppercase; letter-spacing:0.15em; opacity:0.85; margin-bottom:8px; font-weight:600; }
.kpi-hero-value { font-family: var(--font-display); font-size: 2.75rem; font-weight:700; line-height:1; letter-spacing:-0.03em; }
.kpi-hero-sub { font-size:13px; opacity:0.9; margin-top:8px; }
.kpi-hero-side { text-align:right; font-size:13px; }
.kpi-hero-side strong { font-size:18px; display:block; font-family: var(--font-display); }

.kpi-grid {
    display:grid; grid-template-columns:repeat(auto-fit, minmax(240px, 1fr)); gap:16px; margin-bottom:24px;
}
.kpi {
    background: white; border-radius: var(--radius-lg);
    padding: 18px 20px; border:1px solid var(--gray-150);
    display:flex; gap:14px; align-items:center;
    transition: all var(--transition); position:relative; overflow:hidden;
    box-shadow: var(--shadow-xs);
}
.kpi:hover { transform:translateY(-3px); box-shadow: var(--shadow-md); }
.kpi-icon {
    width:52px; height:52px; border-radius:14px; flex-shrink:0;
    display:flex; align-items:center; justify-content:center;
    font-size:24px;
}
.kpi-body { flex:1; min-width:0; }
.kpi-label { font-size:11.5px; text-transform:uppercase; letter-spacing:0.1em; color:var(--gray-500); font-weight:600; margin-bottom:4px; }
.kpi-value { font-family: var(--font-display); font-size:1.5rem; font-weight:700; color:var(--gray-900); letter-spacing:-0.02em; line-height:1.15; }
.kpi-sub { font-size:11.5px; color:var(--gray-500); margin-top:3px; }
.kpi-trend { display:inline-flex; align-items:center; gap:3px; font-size:11px; font-weight:600; padding:2px 8px; border-radius:99px; }
.kpi-trend.up { background:#dcfce7; color:#166534; }
.kpi-trend.down { background:#fee2e2; color:#991b1b; }

.kpi.k-blue    .kpi-icon { background:#eff6ff; color:#1E4CA1; }
.kpi.k-green   .kpi-icon { background:#dcfce7; color:#15803d; }
.kpi.k-red     .kpi-icon { background:#fee2e2; color:#dc2626; }
.kpi.k-orange  .kpi-icon { background:#ffedd5; color:#c2410c; }
.kpi.k-purple  .kpi-icon { background:#f3e8ff; color:#7c3aed; }
.kpi.k-cyan    .kpi-icon { background:#cffafe; color:#0891b2; }
.kpi.k-pink    .kpi-icon { background:#fce7f3; color:#be185d; }
.kpi.k-gray    .kpi-icon { background:var(--gray-100); color:var(--gray-600); }
.kpi.k-blue .kpi-value    { color:#1E4CA1; }
.kpi.k-green .kpi-value   { color:#15803d; }
.kpi.k-red .kpi-value     { color:#dc2626; }
.kpi.k-orange .kpi-value  { color:#c2410c; }
.kpi.k-purple .kpi-value  { color:#7c3aed; }
.kpi.k-cyan .kpi-value    { color:#0891b2; }

.dash-section-title {
    font-size:13px; text-transform:uppercase; letter-spacing:0.12em;
    color:var(--gray-500); font-weight:700; margin: 24px 0 12px;
    display:flex; align-items:center; gap:10px;
}
.dash-section-title::before {
    content:''; width:4px; height:18px; background: var(--brand-gradient); border-radius:2px;
}

/* =============================================================================
   FORMS
   ============================================================================= */

.form-group { margin-bottom: 16px; }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}
.form-row .form-group { margin-bottom: 0; }

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

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: var(--gray-0);
    font-family: inherit;
    font-size: 14px;
    color: var(--gray-900);
    transition: all var(--transition);
    outline: none;
}
.form-input:hover, .form-select:hover, .form-textarea:hover {
    border-color: var(--gray-300);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--brand-blue);
    box-shadow: var(--ring);
}
.form-select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    appearance: none;
}
.form-textarea { resize: vertical; min-height: 72px; }

/* =============================================================================
   BUTTONS
   ============================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    outline: none;
    white-space: nowrap;
    line-height: 1.2;
}
.btn:focus-visible { box-shadow: var(--ring); }
.btn:disabled, .btn.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary { background: var(--brand-gradient); color: white; box-shadow: 0 2px 4px rgba(30,76,161,0.25); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(30,76,161,0.35); color: white; text-decoration: none; }

.btn-secondary { background: var(--gray-0); color: var(--gray-700); border: 1.5px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); color: var(--gray-900); text-decoration: none; }

.btn-danger { background: var(--brand-gradient-red); color: white; box-shadow: 0 2px 4px rgba(227,30,36,0.25); }
.btn-danger:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(227,30,36,0.35); color: white; text-decoration: none; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: var(--success-dark); color: white; text-decoration: none; }

.btn-ghost { background: transparent; color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-900); text-decoration: none; }

.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* =============================================================================
   TABLES
   ============================================================================= */

.table-wrapper { overflow-x: auto; margin: 0 -8px; padding: 0 8px; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
.table thead th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}
.table tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-800);
    vertical-align: middle;
}
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--gray-25); }
.table tbody tr:last-child td { border-bottom: none; }
.table .amount { text-align: right; font-family: var(--font-mono); font-size: 13px; white-space: nowrap; }
.table th.amount { text-align: right; }

/* =============================================================================
   BADGES
   ============================================================================= */

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.4;
    white-space: nowrap;
}
.badge-neutral  { background: var(--gray-100); color: var(--gray-700); }
.badge-success  { background: var(--success-bg); color: var(--success-dark); }
.badge-warning  { background: var(--warning-bg); color: var(--warning-dark); }
.badge-danger   { background: var(--danger-bg); color: var(--danger-dark); }
.badge-info     { background: var(--info-bg); color: var(--info); }

/* =============================================================================
   ALERTS
   ============================================================================= */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 13.5px;
    display: flex; align-items: flex-start; gap: 10px;
    border-left: 4px solid;
    animation: slideDown 300ms var(--ease-out);
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
.alert-success { background: var(--success-bg); color: var(--success-dark); border-color: var(--success); }
.alert-warning { background: var(--warning-bg); color: var(--warning-dark); border-color: var(--warning); }
.alert-danger  { background: var(--danger-bg); color: var(--danger-dark); border-color: var(--danger); }
.alert-info    { background: var(--info-bg); color: var(--info); border-color: var(--info); }

/* =============================================================================
   EMPTY STATE
   ============================================================================= */

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--gray-500);
}
.empty-state h3 { color: var(--gray-700); margin-bottom: 8px; }

/* =============================================================================
   RESPONSIVE
   ============================================================================= */

@media (max-width: 1024px) {
    .main { padding: 24px; }
}

@media (max-width: 768px) {
    :root { --sidebar-w: 260px; }
    .mobile-topbar { display: flex; }
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-xl);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main {
        margin-left: 0;
        padding: 20px 16px;
    }
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header .btn { align-self: stretch; text-align: center; }
    h1 { font-size: 1.5rem; }
    .card { padding: 18px; }
    .stat-value { font-size: 1.5rem; }
    .grid-cards { grid-template-columns: 1fr 1fr; gap: 12px; }
    .table { font-size: 12.5px; }
    .table thead th, .table tbody td { padding: 8px 10px; }
    .auth-card { padding: 28px 22px; }
}

@media (max-width: 480px) {
    .main { padding: 16px 12px; }
    .grid-cards { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .auth-card { padding: 24px 18px; }
    .auth-logo { max-width: 180px; }
}

@media print {
    /* Masquer tout le chrome de l'app */
    .sidebar, .sidebar-overlay, .mobile-topbar,
    .btn, .page-header a, form.card,
    .alert:not(.print-keep),
    .no-print { display: none !important; }

    /* Layout plein page pour impression */
    body, .app-body { background: white !important; margin: 0 !important; padding: 0 !important; }
    .main { margin-left: 0 !important; padding: 0 !important; max-width: 100% !important; }

    /* Cards sans ombre pour impression */
    .card {
        box-shadow: none !important;
        border: 1px solid #999 !important;
        break-inside: avoid;
        margin-bottom: 12px !important;
        page-break-inside: avoid;
    }

    /* Tableaux */
    table { break-inside: auto; }
    tr    { break-inside: avoid; break-after: auto; }
    thead { display: table-header-group; }
    tfoot { display: table-footer-group; }

    /* Couleurs conservées */
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; }

    /* En-tête d'impression (visible uniquement à l'impression) */
    .print-only { display: block !important; }
    .print-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 12px 0 16px;
        border-bottom: 2px solid #000;
        margin-bottom: 20px;
        page-break-after: avoid;
    }
    .print-header .co-info h2 { font-size: 18px; margin: 0 0 4px; }
    .print-header .co-info .meta { font-size: 11px; color: #555; line-height: 1.5; }
    .print-header img { max-height: 60px; max-width: 130px; }
    .print-footer {
        display: block !important;
        margin-top: 24px; padding-top: 8px;
        border-top: 1px solid #999;
        font-size: 10px; text-align: center; color: #666;
    }

    /* Contenu à impression : marge intérieure */
    .page-header h1 { font-size: 18px; margin-bottom: 4px; }
    .page-header .page-sub { font-size: 12px; color: #555; }
    .page-header { padding-bottom: 8px; border-bottom: 1px solid #ccc; margin-bottom: 12px; }

    @page {
        margin: 15mm 10mm 15mm 10mm;
        size: A4;
    }
    @page :first {
        margin-top: 10mm;
    }
}

/* Éléments visibles uniquement à l'impression : cachés à l'écran */
.print-only { display: none; }

/* =============================================================================
   BARRE LATÉRALE - Menus déroulants (modules / sous-modules)
   ============================================================================= */
.sb-nav, .sb-sub { list-style: none; margin: 0; padding: 0; }
.sb-item { margin-bottom: 2px; position: relative; }

/* Module principal (lien direct ou bouton d'ouverture) */
.sb-link, .sb-toggle {
    display: flex; align-items: center; gap: 12px;
    width: 100%; min-height: 42px; padding: 9px 12px;
    border: 0; border-radius: var(--radius-sm);
    background: transparent; color: #cfdcf0;
    font: inherit; font-size: 13.5px; font-weight: 500; line-height: 1.3;
    text-align: left; text-decoration: none; cursor: pointer;
    position: relative;
    transition: background-color .15s ease, color .15s ease;
    -webkit-tap-highlight-color: transparent;
}
.sb-link:hover, .sb-toggle:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.sb-ico { width: 18px; height: 18px; flex-shrink: 0; opacity: .8; transition: opacity .15s ease; }
.sb-link:hover .sb-ico, .sb-toggle:hover .sb-ico { opacity: 1; }
.sb-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Flèche : → fermé, ↓ ouvert */
.sb-chev { width: 16px; height: 16px; flex-shrink: 0; opacity: .65; transition: transform .22s cubic-bezier(.2,.8,.2,1), opacity .15s ease; }
.sb-toggle[aria-expanded="true"] .sb-chev { transform: rotate(90deg); opacity: 1; }
.sb-toggle[aria-expanded="true"] { color: #fff; }

/* Page active : lien direct ou sous-module */
.sb-link.active, .sb-sublink.active {
    background: linear-gradient(135deg, #ffffff 0%, #f0f4fa 100%);
    color: var(--brand-blue); font-weight: 600;
    box-shadow: 0 4px 12px -2px rgba(0,0,0,0.25);
}
.sb-link.active .sb-ico { opacity: 1; }
.sb-link.active:hover, .sb-sublink.active:hover { background: #fff; color: var(--brand-blue); }

/* Module parent de la page active */
.sb-item.is-current > .sb-toggle { color: #fff; font-weight: 600; background: rgba(255,255,255,0.10); }
.sb-item.is-current > .sb-toggle .sb-ico { opacity: 1; }
.sb-item.is-current > .sb-toggle::before {
    content: ''; position: absolute; left: -12px; top: 9px; bottom: 9px;
    width: 4px; border-radius: 0 4px 4px 0; background: var(--brand-red);
}

/* Panneau des sous-modules (animation de hauteur fluide) */
.sb-panel {
    display: grid; grid-template-rows: 0fr; visibility: hidden;
    transition: grid-template-rows .22s cubic-bezier(.2,.8,.2,1), visibility 0s linear .22s;
}
.sb-item.open > .sb-panel {
    grid-template-rows: 1fr; visibility: visible;
    transition: grid-template-rows .22s cubic-bezier(.2,.8,.2,1), visibility 0s;
}
.sb-panel-inner { min-height: 0; overflow: hidden; }
.sb-sub {
    margin: 2px 0 6px 20px;              /* décalage vers la droite = hiérarchie */
    padding-left: 12px;
    border-left: 1px solid rgba(255,255,255,0.15);
}
.sb-sublink {
    display: flex; align-items: center; min-height: 36px;
    padding: 7px 12px; margin: 1px 0;
    border-radius: var(--radius-sm);
    color: rgba(207,220,240,0.85); font-size: 13px; font-weight: 500;
    text-decoration: none; position: relative;
    transition: background-color .15s ease, color .15s ease;
}
.sb-sublink:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.sb-sublink.active::before {   /* repère sur la ligne de hiérarchie */
    content: ''; position: absolute; left: -16.5px; top: 50%;
    width: 8px; height: 8px; margin-top: -4px; border-radius: 50%;
    background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,0.18);
}

/* Compteur (Alertes) */
.sb-badge {
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
    background: var(--brand-red); color: #fff;
    font-size: 11px; font-weight: 700; line-height: 20px; text-align: center;
    flex-shrink: 0;
}
.sb-badge[hidden] { display: none; }

/* Focus clavier visible */
.sb-link:focus-visible, .sb-toggle:focus-visible, .sb-sublink:focus-visible {
    outline: 2px solid #93c5fd; outline-offset: 2px;
}

/* Pas d'animation au chargement / mouvement réduit */
.sb-nav.no-anim .sb-panel, .sb-nav.no-anim .sb-chev { transition: none !important; }
@media (prefers-reduced-motion: reduce) {
    .sb-panel, .sb-chev, .sb-link, .sb-toggle, .sb-sublink { transition: none !important; }
}

/* Tactile : cibles plus grandes */
@media (max-width: 1024px), (pointer: coarse) {
    .sb-link, .sb-toggle { min-height: 46px; font-size: 14px; }
    .sb-sublink { min-height: 42px; font-size: 13.5px; }
}
.sidebar-nav { overscroll-behavior: contain; }
