/* ============================================================
   In God We Trust — Système de gestion de stock & facturation
   Design professionnel : sidebar, Inter, icônes Lucide
   Palette : navy professionnel (#0f2a47 / accent #1e5bb8)
   ============================================================ */

:root {
    --navy-900: #0b1f38;
    --navy-800: #0f2a47;
    --navy-700: #16395f;
    --accent:    #1e5bb8;
    --accent-600:#17519f;
    --accent-500:#2e6fd0;
    --accent-100:#e7f0fb;
    --bg:        #f3f6fb;
    --surface:   #ffffff;
    --line:      #e2e8f0;
    --text:      #10233d;
    --muted:     #64748b;
    --green:     #16a34a;
    --green-bg:  #e8f7ee;
    --red:       #dc2626;
    --red-bg:    #fdecec;
    --amber:     #d97706;
    --amber-bg:  #fdf3e0;
    --blue:      #2563eb;
    --blue-bg:   #e7f0fb;
    --slate:     #6b7280;
    --slate-bg:  #eef1f6;
    --radius:    10px;
    --shadow:    0 1px 2px rgba(16,35,61,.06), 0 4px 16px rgba(16,35,61,.06);
    --shadow-lg: 0 8px 30px rgba(16,35,61,.14);
}

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

html, body { height: 100%; }

body {
    font-family: 'Inter', 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14.5px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; }

/* ============================================================
   APP SHELL (sidebar + main)
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }
.app-main   { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: 262px;
    background: linear-gradient(180deg, var(--navy-800), var(--navy-900));
    color: #e6eefb;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: width .25s ease;
    z-index: 50;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-logo {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--accent);
    display: grid; place-items: center;
    color: #fff; font-size: 20px;
    flex-shrink: 0;
}
.brand-text strong { display: block; font-size: .95rem; letter-spacing: .3px; color: #fff; font-weight: 700; }
.brand-text span   { font-size: .72rem; color: #9db4d8; }

.sidebar-user {
    display: flex; align-items: center; gap: 11px;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.avatar, .topbar-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent-500);
    color: #fff; font-weight: 700; font-size: .85rem;
    display: grid; place-items: center; flex-shrink: 0;
}
.user-meta strong { display: block; font-size: .85rem; color: #fff; }
.user-meta span   { font-size: .72rem; color: #9db4d8; }

.sidebar-nav { flex: 1; padding: 8px 12px; }
.nav-section-label {
    font-size: .66rem; text-transform: uppercase; letter-spacing: 1px;
    color: #6f8cb8; font-weight: 700; margin: 16px 10px 7px;
}
.side-link {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 11px; margin-bottom: 2px;
    border-radius: 8px; color: #c6d5ec;
    font-size: .86rem; font-weight: 500;
    transition: background .15s, color .15s;
}
.side-link i { font-size: 17px; flex-shrink: 0; }
.side-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.side-link.active {
    background: var(--accent); color: #fff; font-weight: 600;
    box-shadow: 0 4px 12px rgba(30,91,184,.4);
}
.side-link.subtle { color: #9db4d8; }
.side-link.subtle.danger:hover { background: rgba(220,38,38,.15); color: #fca5a5; }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }

/* ---------- Topbar ---------- */
.topbar {
    height: 62px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 14px;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.role-chip {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .75rem; font-weight: 700; padding: 5px 11px; border-radius: 999px;
}
.role-chip i { width: 14px; height: 14px; }
.role-directeur { background: var(--amber-bg); color: var(--amber); }
.role-vendeur   { background: var(--accent-100); color: var(--accent); }
.icon-btn {
    background: transparent; border: none; cursor: pointer;
    color: var(--muted); display: grid; place-items: center;
    width: 38px; height: 38px; border-radius: 8px; font-size: 20px;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ============================================================
   CONTENT
   ============================================================ */
.main-content { flex: 1; padding: 26px 28px; width: 100%; max-width: 1320px; margin: 0 auto; }

/* ---------- Page header ---------- */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 22px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 {
    font-size: 1.35rem; font-weight: 800; color: var(--text);
    display: flex; align-items: center; gap: 10px;
}
.page-header h1 i { color: var(--accent); width: 24px; height: 24px; }
.page-subtitle { color: var(--muted); font-size: .85rem; margin-top: 2px; }

.section-title {
    font-size: 1rem; font-weight: 700; color: var(--text);
    margin: 26px 0 14px; display: flex; align-items: center; gap: 8px;
}

/* ============================================================
   BOUTONS
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 16px; border-radius: 8px;
    font-size: .85rem; font-weight: 600; border: none; cursor: pointer;
    transition: all .15s; letter-spacing: .1px; font-family: inherit;
}
.btn i { width: 15px; height: 15px; }
.btn:hover { transform: translateY(-1px); filter: brightness(1.03); }
.btn:active { transform: translateY(0); }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-600); }
.btn-success   { background: var(--green); color: #fff; }
.btn-warning   { background: var(--amber); color: #fff; }
.btn-danger    { background: var(--red); color: #fff; }
.btn-info      { background: var(--blue); color: #fff; }
.btn-secondary { background: var(--slate); color: #fff; }
.btn-outline   { background: transparent; color: var(--slate); border: 1.5px solid var(--line); }
.btn-outline:hover { background: var(--bg); color: var(--text); border-color: #cbd5e1; }
.btn-ghost     { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-100); }
.btn-sm { padding: 6px 11px; font-size: .76rem; border-radius: 7px; }
.btn-block { width: 100%; justify-content: center; }

/* ============================================================
   CARTES / SURFACES
   ============================================================ */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 22px 24px;
}
.card + .card, .card-margin { margin-top: 18px; }

/* ============================================================
   STATS (dashboard)
   ============================================================ */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 24px;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px;
    display: flex; flex-direction: column; gap: 4px;
    position: relative; overflow: hidden;
}
.stat-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: grid; place-items: center; margin-bottom: 8px;
    background: var(--accent-100); color: var(--accent);
}
.stat-icon i { width: 20px; height: 20px; }
.stat-value { font-size: 1.7rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.stat-value .unit { font-size: .9rem; color: var(--muted); font-weight: 600; }
.stat-label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.stat-card.stat-alert { border-left: 4px solid var(--red); }
.stat-card.stat-highlight {
    background: linear-gradient(135deg, var(--navy-800), var(--accent));
    color: #fff; border: none;
}
.stat-card.stat-highlight .stat-value, .stat-card.stat-highlight .stat-label { color: #fff; }
.stat-card.stat-highlight .stat-label { color: #c3d4ee; }
.stat-card.stat-highlight .stat-icon { background: rgba(255,255,255,.15); color: #fff; }

.dashboard-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.dashboard-block {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px 22px;
}
.dashboard-block h2 { font-size: .98rem; font-weight: 700; margin-bottom: 12px; }
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* CA de la semaine (compacte) */
.week-bar {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 24px;
}
.week-bar-title { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 700; }
.week-bar-title i { color: var(--accent); width: 18px; height: 18px; }
.week-bar-total { color: var(--accent); font-weight: 800; font-size: .95rem; }
.week-bar-days { display: flex; gap: 6px; flex-wrap: wrap; }
.week-day {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-width: 52px; padding: 6px 8px; border-radius: 8px; background: var(--bg);
    border: 1px solid var(--line); line-height: 1.2;
}
.week-day-val { font-size: .78rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.week-day-lab { font-size: .68rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }

/* Tableaux compacts du tableau de bord (pas de débordement horizontal) */
.dashboard-block .table-wrap { overflow-x: auto; }
.dashboard-block .data-table { min-width: 0; width: 100%; }
.dashboard-block .data-table th { padding: 8px 10px; white-space: nowrap; }
.dashboard-block .data-table td { padding: 8px 10px; }
.dashboard-block .data-table a { white-space: nowrap; }

/* ============================================================
   TABLEAUX
   ============================================================ */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.data-table th {
    background: var(--bg); color: var(--muted);
    text-align: left; padding: 12px 14px;
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
    border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: .85rem; vertical-align: middle; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tfoot td { font-weight: 700; background: var(--bg); }
.totals-final-row td { background: var(--navy-800) !important; color: #fff; font-size: 1rem; }

.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.actions-cell .btn { white-space: nowrap; }

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px;
    font-size: .72rem; font-weight: 700; white-space: nowrap;
}
.badge i { width: 11px; height: 11px; }
.badge-success   { background: var(--green-bg); color: var(--green); }
.badge-danger    { background: var(--red-bg); color: var(--red); }
.badge-warning   { background: var(--amber-bg); color: var(--amber); }
.badge-info      { background: var(--blue-bg); color: var(--blue); }
.badge-secondary { background: var(--slate-bg); color: var(--slate); }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.badge-statut-brouillon { background: var(--slate-bg); color: var(--slate); }
.badge-statut-validee   { background: var(--blue-bg); color: var(--blue); }
.badge-statut-payee     { background: var(--green-bg); color: var(--green); }
.badge-statut-annulee   { background: var(--red-bg); color: var(--red); }

/* ============================================================
   ALERTES
   ============================================================ */
.alert {
    padding: 13px 16px; border-radius: 8px; margin-bottom: 18px;
    font-size: .88rem; display: flex; align-items: flex-start; gap: 9px;
    border: 1px solid transparent;
}
.alert i { flex-shrink: 0; margin-top: 1px; width: 16px; height: 16px; }
.alert-success { background: var(--green-bg); color: #157a3a; border-color: #bfe5cd; }
.alert-error   { background: var(--red-bg);   color: #b91c1c; border-color: #f5c2c2; }
.alert-info    { background: var(--blue-bg);  color: #1d4ed8; border-color: #bfd6f5; }
.alert-warning { background: var(--amber-bg); color: #b45309; border-color: #f0d9a8; }

/* ============================================================
   FORMULAIRES
   ============================================================ */
.form-card {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--line); box-shadow: var(--shadow);
    padding: 28px 30px; max-width: 840px;
}
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; font-size: .86rem; color: var(--text); margin-bottom: 7px; }
.required { color: var(--red); }

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
    width: 100%; padding: 10px 13px;
    border: 1.6px solid var(--line); border-radius: 8px;
    font-size: .9rem; font-family: inherit; background: #fff;
    transition: border-color .15s, box-shadow .15s; color: var(--text);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(30,91,184,.12);
}
.form-group input:disabled, .form-group input[readonly] { background: var(--bg); color: var(--muted); }
.form-hint { display: block; margin-top: 6px; font-size: .76rem; color: var(--muted); }
.form-hint a { color: var(--accent); font-weight: 600; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); margin-top: 10px; }
.checkbox-inline { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--text); }
.checkbox-inline input { width: 17px; height: 17px; accent-color: var(--accent); }

/* ---------- Recherche / filtres ---------- */
.search-form {
    display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; align-items: flex-end;
    background: var(--surface); padding: 16px; border-radius: var(--radius);
    border: 1px solid var(--line); box-shadow: var(--shadow);
}
.search-input, .search-select {
    padding: 9px 13px; border: 1.6px solid var(--line); border-radius: 8px;
    font-size: .88rem; background: #fff;
}
.search-input { flex: 1; min-width: 200px; }
.search-input:focus, .search-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30,91,184,.12); }
.inline-form { display: flex; align-items: flex-end; gap: 15px; }
.inline-form .form-group { margin-bottom: 0; flex: 1; max-width: 320px; }

/* ---------- Onglets ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1.5px solid var(--line); margin-bottom: 18px; }
.tab {
    padding: 10px 16px; text-decoration: none; color: var(--muted);
    font-size: .85rem; font-weight: 600; border-bottom: 2.5px solid transparent; margin-bottom: -1.5px;
    transition: color .15s; display: inline-flex; align-items: center; gap: 7px;
}
.tab i { width: 15px; height: 15px; }
.tab:hover { color: var(--accent); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ============================================================
   DÉTAIL / FICHE
   ============================================================ */
.detail-card {
    background: var(--surface); border-radius: var(--radius);
    border: 1px solid var(--line); box-shadow: var(--shadow);
    padding: 24px 26px; margin-bottom: 18px;
}
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.detail-label {
    display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .5px;
    color: var(--muted); margin-bottom: 3px; font-weight: 700;
}
.detail-value { font-size: .95rem; color: var(--text); }
.detail-value a { color: var(--accent); font-weight: 600; }
.document-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }

/* ---------- Lignes de document ---------- */
.lines-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.lines-table th {
    background: var(--bg); padding: 8px 9px; font-size: .72rem;
    text-transform: uppercase; letter-spacing: .3px; color: var(--muted);
    text-align: left; border-bottom: 1.5px solid var(--line);
}
.lines-table td { padding: 7px 5px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.lines-table select, .lines-table input {
    width: 100%; padding: 7px 8px; border: 1.6px solid var(--line);
    border-radius: 6px; font-size: .84rem; background: #fff;
}
.lines-table select:focus, .lines-table input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30,91,184,.1); }
.lines-table .line-total { font-weight: 700; color: var(--text); white-space: nowrap; padding: 0 8px; }
.lines-table .remove-line-btn {
    background: var(--red); color: #fff; border: none; border-radius: 6px;
    width: 30px; height: 30px; cursor: pointer; font-size: .95rem; line-height: 1;
    display: grid; place-items: center;
}
.lines-table .remove-line-btn:hover { filter: brightness(1.1); }

.totals-block {
    max-width: 360px; margin-left: auto;
    background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
    padding: 16px 20px; margin-bottom: 18px;
}
.totals-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: .9rem; }
.totals-row input { width: 130px; padding: 6px 10px; border: 1.6px solid var(--line); border-radius: 6px; text-align: right; background: #fff; }
.totals-final { border-top: 2px solid var(--navy-800); margin-top: 6px; padding-top: 10px; font-weight: 800; font-size: 1.05rem; color: var(--accent); }

/* ============================================================
   ÉTATS VIDES
   ============================================================ */
.empty-state {
    text-align: center; padding: 55px 20px; color: var(--muted);
    background: var(--surface); border-radius: var(--radius);
    border: 1.5px dashed var(--line);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; color: #cbd5e1; }
.empty-state p { font-size: 1.02rem; margin-bottom: 18px; }
.empty-state-inline { color: var(--muted); padding: 16px 0; font-size: .88rem; }

/* ============================================================
   AUTH (login / reset)
   ============================================================ */
.auth-body, .auth-body * { font-family: 'Inter', sans-serif; }
.auth-body {
    background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px;
}
.auth-card {
    width: 100%; max-width: 420px;
    background: var(--surface); border-radius: 16px;
    box-shadow: var(--shadow-lg); overflow: hidden;
}
.auth-card-header { padding: 26px 30px 8px; text-align: center; }
.auth-brand-icon {
    width: 54px; height: 54px; border-radius: 14px; margin: 0 auto 14px;
    background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 27px;
}
.auth-card-header h1 { font-size: 1.25rem; font-weight: 800; color: var(--text); }
.auth-card-header p  { color: var(--muted); font-size: .84rem; margin-top: 4px; }
.auth-card-body { padding: 18px 30px 26px; }

/* ---------- Interrupteurs (activation) ---------- */
.switch { position: relative; display: inline-block; width: 42px; height: 23px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0;
    background: #cbd5e1; border-radius: 999px; transition: .25s;
}
.slider:before {
    content: ""; position: absolute; height: 17px; width: 17px; left: 3px; bottom: 3px;
    background: #fff; border-radius: 50%; transition: .25s;
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider:before { transform: translateX(19px); }

/* ---------- Pagination / lecteurs ---------- */
.meta-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .8rem; flex-wrap: wrap; }
.meta-row b { color: var(--text); }

/* ---------- Lignes inactives & actions en masse ---------- */
.row-inactive { opacity: .55; background: #f8fafc; }
.masse-bar {
    display: flex; align-items: center; gap: 12px; margin-top: 14px;
    background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
    padding: 12px 16px; box-shadow: var(--shadow);
}
.masse-count { font-size: .85rem; color: var(--muted); font-weight: 600; margin-right: auto; }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    background: var(--surface); border-top: 1px solid var(--line);
    color: var(--muted); text-align: center; padding: 15px; font-size: .78rem;
}

/* ============================================================
   LOGO IMAGE (remplace l'icône)
   ============================================================ */
.brand-logo { overflow: hidden; }
.brand-logo-img {
    width: 100%; height: 100%; object-fit: cover; display: block;
    border-radius: 10px;
}

/* ============================================================
   MENU COMPTE (avatar cliquable)
   ============================================================ */
.account-wrap { position: relative; }
.account-btn {
    display: flex; align-items: center; gap: 6px;
    background: transparent; border: none; cursor: pointer;
    padding: 3px 6px; border-radius: 8px; color: var(--muted);
    transition: background .15s;
}
.account-btn:hover { background: var(--bg); color: var(--text); }
.account-btn .topbar-avatar { width: 40px; height: 40px; }
.account-btn > i { width: 16px; height: 16px; transition: transform .2s; }
.account-wrap.open .account-btn > i { transform: rotate(180deg); }
.account-menu {
    position: absolute; top: calc(100% + 8px); right: 0;
    min-width: 210px; background: var(--surface);
    border: 1px solid var(--line); border-radius: 12px;
    box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: all .18s ease;
}
.account-menu.open { opacity: 1; visibility: visible; transform: translateY(0); }
.account-menu a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px; color: var(--text);
    font-size: .86rem; font-weight: 500; transition: background .12s;
}
.account-menu a i { width: 16px; height: 16px; color: var(--muted); }
.account-menu a:hover { background: var(--bg); }
.account-menu a.danger { color: var(--red); }
.account-menu a.danger i { color: var(--red); }

/* ============================================================
   OVERLAY SIDEBAR (mobile)
   ============================================================ */
.sidebar-overlay {
    position: fixed; inset: 0; background: rgba(11,31,56,.5);
    z-index: 45; opacity: 0; visibility: hidden; transition: opacity .25s;
}
.sidebar-overlay.show { opacity: 1; visibility: visible; }

/* ============================================================
   MODALE GENERIQUE
   ============================================================ */
.modal {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    padding: 20px; background: rgba(11,31,56,.55);
    opacity: 0; visibility: hidden; transition: opacity .18s;
}
.modal.open { opacity: 1; visibility: visible; }
.modal-content {
    width: 100%; max-width: 440px; background: var(--surface);
    border-radius: 14px; box-shadow: var(--shadow-lg);
    transform: translateY(8px); transition: transform .18s;
    overflow: hidden;
}
.modal.open .modal-content { transform: translateY(0); }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.modal-header h3 { display: flex; align-items: center; gap: 9px; font-size: 1rem; font-weight: 700; }
.modal-header h3 i { color: var(--accent); width: 19px; height: 19px; }
.modal-body { padding: 20px 22px 22px; }

/* Modale générique de confirmation */
.modal-narrow { max-width: 380px; }
.confirm-message { color: var(--text); line-height: 1.55; margin: 0 0 6px; }
.confirm-message strong { color: var(--text); }

/* Bouton "comme un lien" (ajout rapide d'un client) */
.link-like {
    background: none; border: none; padding: 0; cursor: pointer;
    color: var(--accent); font-size: .82rem; font-weight: 600;
    display: inline-flex; align-items: center; gap: 4px;
}
.link-like:hover { text-decoration: underline; }

/* Fermeture + messages de la modale client */
.modal-close {
    background: none; border: none; font-size: 1.3rem; line-height: 1;
    color: var(--text-muted); cursor: pointer; padding: 4px 6px; border-radius: 6px;
}
.modal-close:hover { color: var(--text); background: rgba(0,0,0,.05); }
.modal-msg {
    padding: 10px 12px; border-radius: 8px; margin-bottom: 14px;
    background: rgba(220,53,69,.08); color: #b02a37; font-size: .85rem; line-height: 1.4;
}
.modal-msg:empty { display: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1000px) {
    .dashboard-columns { grid-template-columns: 1fr; }
    .sidebar { width: 232px; }
}
@media (max-width: 820px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s; }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .app-main { margin-left: 0; }
    .form-row { grid-template-columns: 1fr; }
    .main-content { padding: 20px 16px; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}
@media (max-width: 560px) {
    .topbar-title { display: none; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .data-table { display: block; }
    .lines-table { display: block; }
    .totals-block { max-width: 100%; }
    .form-card { padding: 20px; }
    .page-header h1 { font-size: 1.15rem; }
}