:root {
    /* Brand */
    --mad-primary: #f05b07;
    --mad-primary-dark: #cf4d05;
    --mad-primary-light: #ffb27a;
    --mad-primary-soft: #fdeee3;
    --mad-primary-faint: #fef6f1;
    --mad-glow: rgba(240, 91, 7, .22);
    --mad-glow-soft: rgba(240, 91, 7, .10);

    /* Accent palette */
    --mad-blue: #2f6bff;
    --mad-blue-soft: #eaf0ff;
    --mad-turquoise: #12b5b5;
    --mad-turquoise-soft: #e3f6f6;
    --mad-green: #12b76a;
    --mad-green-soft: #e6f6ee;
    --mad-red: #e5484d;
    --mad-red-soft: #fdeced;
    --mad-amber: #b9862a;
    --mad-amber-soft: #fbeed0;
    --mad-violet: #7c5cf6;
    --mad-violet-soft: #efeafe;

    /* Neutrals */
    --mad-dark: #101828;
    --mad-text: #475467;
    --mad-muted: #98a2b3;
    --mad-border: #ebedf2;
    --mad-bg: #f7f8fa;
    --mad-card: #ffffff;
    --mad-sidebar: #f05b07;

    --sidebar-w: 240px;
    --mad-radius: 14px;
    --mad-radius-sm: 10px;
    --mad-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .03);
    --mad-shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--mad-bg);
    color: var(--mad-text);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em;
}

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

/* ============ Scrollbar ============ */
/* Fine & discreet SaaS scrollbar — WebKit/Blink + Firefox */
html { scrollbar-width: thin; scrollbar-color: rgba(140, 150, 165, .45) rgba(16, 24, 40, .05); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(140, 150, 165, .35); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(140, 150, 165, .58); }
::-webkit-scrollbar-thumb:active { background: rgba(140, 150, 165, .72); }
::-webkit-scrollbar-corner { background: transparent; }

/* ============ Layout ============ */
.admin-layout { min-height: 100vh; }

/* ============ Sidebar ============ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--mad-sidebar);
    color: #fff;
    border-right: none;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    transition: transform .3s ease;
    z-index: 1040;
    display: flex; flex-direction: column;
}
.sidebar { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .35) rgba(255, 255, 255, .08); }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .32); }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .55); }
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 18px;
    font-size: 16px; font-weight: 800; color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
    flex-shrink: 0;
}
.sidebar-brand img { height: 50px; width: auto; max-width: 200px; object-fit: contain; border-radius: 8px; background: #fff; padding: 4px; }
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.sidebar-brand .brand-text small { font-size: 11px; font-weight: 600; color: #fff; opacity: .85; }
.sidebar-nav { padding: 14px 12px 20px; flex: 1; }
.sidebar-nav .nav-section {
    text-transform: uppercase; font-size: 10px; letter-spacing: .12em;
    color: #fff; margin: 18px 12px 7px; font-weight: 700; opacity: .55;
}
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 13px; margin-bottom: 2px;
    color: #fff; border-radius: 10px; font-size: 13.5px; font-weight: 500;
    transition: background .2s, color .2s;
}
.sidebar-nav a i {
    width: 30px; height: 30px; text-align: center; font-size: 15px; color: #fff; opacity: .82;
    border: 1.4px solid rgba(255, 255, 255, .3); border-radius: 7px; padding: 5px 0;
    display: inline-flex; align-items: center; justify-content: center; transition: opacity .2s;
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.sidebar-nav a:hover i { opacity: 1; }
.sidebar-nav a.active {
    background: rgba(255, 255, 255, .2);
    color: #fff; font-weight: 700;
}
.sidebar-nav a.active i { opacity: 1; background: #fff; color: var(--mad-primary); border-color: #fff; }
.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid rgba(255, 255, 255, .12);
    flex-shrink: 0;
}
.sidebar-logout {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 10px 14px; border-radius: 10px;
    background: rgba(255, 255, 255, .14); color: #fff;
    font-size: 13.5px; font-weight: 600; transition: background .2s, transform .2s;
}
.sidebar-logout i { width: 20px; text-align: center; }
.sidebar-logout:hover { background: rgba(255, 255, 255, .26); color: #fff; }

/* ============ Main / Topbar ============ */
.admin-main { margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
    height: 60px; background: #fff;
    border-bottom: 1px solid var(--mad-border);
    display: flex; align-items: center; padding: 0 22px; gap: 14px;
    position: sticky; top: 0; z-index: 1030;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--mad-primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 15px; letter-spacing: -0.02em;
}
.topbar-title {
    font-weight: 700; font-size: 15px; color: var(--mad-dark);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-search {
    display: flex; align-items: center; gap: 8px; flex: 1; max-width: 360px; margin-left: 4px;
    background: #f4f6f8; border: 1px solid var(--mad-border); border-radius: 9px;
    padding: 7px 13px; transition: border-color .2s, background .2s;
}
.topbar-search:focus-within { border-color: var(--mad-primary-light); background: #fff; }
.topbar-search i { color: var(--mad-muted); font-size: 13px; }
.topbar-search input {
    border: none; background: none; outline: none; flex: 1; font-size: 13.5px; color: var(--mad-dark); font-family: inherit;
}
.topbar-search input::placeholder { color: var(--mad-muted); }
.sidebar-toggle { display: none; border: none; background: none; font-size: 20px; cursor: pointer; color: var(--mad-dark); }

.topbar-link {
    display: inline-flex; align-items: center; gap: 7px;
    color: var(--mad-text); font-size: 13.5px; font-weight: 600;
    padding: 8px 13px; border-radius: 9px; background: #f4f6f8;
    transition: background .2s, color .2s;
}
.topbar-link:hover { color: var(--mad-dark); background: #eceef2; }
.topbar-link.topbar-install { border: none; cursor: pointer; font-family: inherit; }
.topbar-install[hidden] { display: none; }

/* ============ Notifications ============ */
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-bell { position: relative; }
.bell-btn {
    position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--mad-border);
    background: #fff; color: var(--mad-text); font-size: 15px; cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: color .2s, border-color .2s, background .2s;
}
.bell-btn:hover { color: var(--mad-primary); border-color: var(--mad-primary-soft); background: var(--mad-primary-faint); }
.bell-btn:focus { outline: none; box-shadow: 0 0 0 3px var(--mad-glow-soft); }
.bell-badge {
    position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 20px; background: var(--mad-primary); color: #fff; font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; line-height: 1;
}
.notif-menu { width: 340px; max-width: calc(100vw - 24px); padding: 0; overflow: hidden; border-radius: 14px; box-shadow: 0 12px 32px rgba(16, 24, 40, .12); border: 1px solid var(--mad-border); background: #fff; z-index: 1050; }
.notif-menu-head {
    display: flex; align-items: center; justify-content: space-between; padding: 13px 16px;
    border-bottom: 1px solid var(--mad-border); background: #fbfcfd;
}
.notif-menu-head strong { font-size: 14px; color: var(--mad-dark); }
.notif-mark-all { border: none; background: none; color: var(--mad-primary); font-size: 12px; font-weight: 600; cursor: pointer; padding: 0; }
.notif-mark-all:hover { text-decoration: underline; }
.notif-head-actions { display: flex; align-items: center; gap: 12px; }
.notif-icon-btn {
    width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--mad-border);
    background: #fff; color: var(--mad-muted); cursor: pointer; font-size: 11.5px;
    display: inline-flex; align-items: center; justify-content: center; padding: 0;
    transition: color .2s, background .2s, border-color .2s;
}
.notif-icon-btn:hover { color: #e23b3b; border-color: #f3c9c9; background: #fdeced; }
.notif-icon-btn[disabled] { opacity: .5; cursor: default; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #f0f2f5; text-decoration: none; position: relative; }
.notif-item:hover { background: #fbfcfd; }
.notif-item:last-child { border-bottom: none; }
.notif-item .notif-ico {
    width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: #fff; background: var(--mad-primary);
}
.notif-item .notif-txt { flex: 1; min-width: 0; }
.notif-item .notif-txt strong { display: block; font-size: 13.5px; color: var(--mad-dark); }
.notif-item .notif-txt span { display: block; font-size: 12.5px; color: var(--mad-muted); margin-top: 2px; line-height: 1.4; }
.notif-item .notif-txt small { display: block; font-size: 11px; color: #c0a08c; margin-top: 4px; }
.notif-item .notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mad-primary); flex-shrink: 0; margin-top: 5px; }
.notif-item.read .notif-dot { display: none; }
.notif-empty { padding: 30px 16px; text-align: center; color: var(--mad-muted); font-size: 13px; }
.notif-item.notif-p-success { border-left: 3px solid #1a9d56; }
/* Ligne de notification + bouton de retrait individuel */
.notif-item-wrap { position: relative; display: flex; border-bottom: 1px solid #f0f2f5; }
.notif-item-wrap:last-child { border-bottom: none; }
.notif-item-wrap .notif-item { flex: 1; min-width: 0; border-bottom: none; padding-right: 38px; }
.notif-del {
    position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
    width: 24px; height: 24px; border-radius: 7px; border: none; background: none;
    color: var(--mad-muted); cursor: pointer; font-size: 11px; padding: 0;
    display: flex; align-items: center; justify-content: center; opacity: 0;
    transition: opacity .2s, color .2s, background .2s;
}
.notif-item-wrap:hover .notif-del, .notif-del:focus { opacity: 1; }
.notif-del:hover { color: #e23b3b; background: #fdeced; }
@media (hover: none) { .notif-del { opacity: 1; } }
.notif-item.notif-p-warning { border-left: 3px solid #b9862a; }
.notif-item.notif-p-urgent { border-left: 3px solid #e23b3b; }
.notif-item.notif-p-urgent .notif-ico { background: #fdeced; color: #e23b3b; }
.notif-item.notif-p-warning .notif-ico { background: #fbeed0; color: #b9862a; }
.notif-item.notif-p-success .notif-ico { background: #e8f7ee; color: #1a9d56; }
.notif-page { max-height: none; }
.notif-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.notif-day-head {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px 6px;
    font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
    color: var(--mad-muted);
}
.notif-page .notif-item .notif-txt small { color: #8b91a7; }
.notif-page .notif-txt small .badge { vertical-align: middle; margin-right: 2px; }
.notif-page .notif-time { margin-left: 6px; font-weight: 600; white-space: nowrap; }
.mad-notif-toasts { position: fixed; top: 16px; right: 16px; z-index: 1080; display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 32px); }
.mad-notif-toast {
    display: flex; align-items: center; gap: 12px; width: 340px; max-width: 100%; padding: 12px 14px;
    border-radius: 12px; background: #fff; border: 1px solid var(--mad-border); box-shadow: 0 10px 30px rgba(16, 24, 40, .16);
    cursor: pointer; animation: madToastIn .25s ease;
}
.mad-notif-toast.hide { opacity: 0; transform: translateX(20px); transition: all .35s ease; }
.mad-notif-toast .toast-ico {
    width: 36px; height: 36px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    font-size: 15px; color: #fff; background: var(--mad-primary);
}
.mad-notif-toast.notif-p-success .toast-ico { background: #1a9d56; }
.mad-notif-toast.notif-p-warning .toast-ico { background: #b9862a; }
.mad-notif-toast.notif-p-urgent .toast-ico { background: #e23b3b; }
.mad-notif-toast .toast-body { flex: 1; min-width: 0; }
.mad-notif-toast .toast-body strong { display: block; font-size: 13.5px; color: var(--mad-dark); }
.mad-notif-toast .toast-body span { display: block; font-size: 12.5px; color: var(--mad-muted); margin-top: 2px; line-height: 1.4; }
@keyframes madToastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.topbar-user .user-btn { display: flex; align-items: center; gap: 9px; background: none; border: none; cursor: pointer; padding: 0; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--mad-primary);
    color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.user-meta { display: flex; flex-direction: column; text-align: left; line-height: 1.15; }
.user-meta strong { color: var(--mad-dark); font-size: 13.5px; }
.user-meta small { color: var(--mad-muted); font-size: 12px; }

/* ============ Content ============ */
.content { padding: 26px 24px 48px; flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 14px; }
.page-head h1 { font-size: 22px; margin: 0; color: var(--mad-dark); font-weight: 700; letter-spacing: -0.02em; display: inline-flex; align-items: center; gap: 10px; padding: 5px 14px 5px 9px; border-radius: 12px; background: linear-gradient(120deg, var(--mad-primary-faint), var(--mad-primary-soft)); border: 1px solid var(--mad-primary-soft); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 1px 2px rgba(16, 24, 40, .04); }
.page-head h1 i { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; background: var(--mad-primary); color: #fff !important; font-size: 15px; flex-shrink: 0; }
.page-head p { margin: 5px 0 0; color: var(--mad-muted); font-size: 14px; }

/* ============ Cards ============ */
.card-box {
    background: var(--mad-card);
    border: 1px solid var(--mad-border);
    border-radius: var(--mad-radius);
    padding: 20px;
    box-shadow: var(--mad-shadow);
}
.card-title { margin: 0 0 14px; color: var(--mad-dark); font-size: 15px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; }
.card-title i { color: var(--mad-primary); margin-right: 9px; font-size: 14px; width: auto; height: auto; background: none; border-radius: 0; }

/* ============ KPI (stat) cards ============ */
.stat-card { display: flex; align-items: center; gap: 14px; position: relative; transition: border-color .2s, box-shadow .2s, transform .2s; }
.stat-card::before { display: none; }
.stat-card:hover { border-color: #dfe2ea; box-shadow: 0 2px 8px rgba(16, 24, 40, .06); transform: translateY(-2px); }
.stat-icon {
    width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: #fff; background: var(--accent-soft, var(--mad-primary-soft)); flex-shrink: 0;
}
.stat-icon i { color: #fff; }
.stat-card .value { font-size: 27px; font-weight: 700; color: var(--mad-dark); line-height: 1.1; letter-spacing: -0.02em; }
.stat-card .label { font-size: 12.5px; color: var(--mad-muted); margin-top: 3px; }

/* ============ Dropzone (partage de fichiers) ============ */
.dropzone { border: 2px dashed var(--mad-border, #e3e6ee); border-radius: 14px; padding: 34px 20px; text-align: center; cursor: pointer; background: #fafbfc; transition: border-color .2s, background .2s; }
.dropzone.dragover { border-color: var(--mad-primary, #ff5e00); background: var(--mad-primary-faint, #fff5f0); }
.dropzone.has-file { border-color: #1a9d56; background: #f1faf4; }
.dropzone .dz-icon { font-size: 34px; color: var(--mad-primary, #ff5e00); }
.dropzone p { margin: 12px 0 6px; font-weight: 600; color: var(--mad-dark, #1d2333); }
.dropzone .dz-or { display: block; font-size: 12px; color: var(--mad-muted, #8a93a6); margin-bottom: 10px; }
.dropzone .dz-filename { margin-top: 12px; font-size: 13px; font-weight: 600; color: #1a9d56; word-break: break-all; }

/* ============ Boîte de téléversement (partage de fichiers) ============ */
/* Variante en ligne dans une page (le conteneur n'est plus une modale). */
.upload-modal.upload-panel { width: auto; height: auto; margin: 0; padding: 0; overflow: visible; }
.upload-modal { background: transparent; width: 600px; max-width: 100%; height: 300px; border: none; border-radius: 16px; padding: 16px 20px; overflow: hidden; margin: 0 auto 96px; }
.upload-modal-head { display: flex; align-items: center; justify-content: space-between; }
.upload-modal-title { font-size: 17px; font-weight: 700; color: #1d2333; margin: 0; }
.upload-modal-close { border: none; background: transparent; font-size: 18px; color: #98a2b3; cursor: pointer; line-height: 1; }
.upload-modal-close:hover { color: #5b6577; }
.upload-dropzone { margin-top: 12px; border: 2px dashed #9fb6d4; border-radius: 12px; background: #f7f9fc; padding: 24px 20px; text-align: center; cursor: pointer; transition: border-color .2s, background .2s; }
.upload-dropzone.dragover { border-color: #3b82f6; background: #eef4ff; }
.upload-dropzone-text { margin: 0 0 14px; color: #5b6577; font-size: 14px; font-weight: 500; }
.upload-preview { margin-top: 16px; display: flex; align-items: center; gap: 14px; border: 1px solid #eef1f6; border-radius: 12px; padding: 12px 14px; background: #fcfdff; }
.upload-thumb { width: 46px; height: 46px; border-radius: 10px; background: #eef3fb; color: #6b9bd1; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.upload-meta { flex: 1; min-width: 0; }
.upload-name { font-size: 13.5px; font-weight: 600; color: #1d2333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-bar { height: 4px; border-radius: 4px; background: #e9edf3; margin: 8px 0 6px; overflow: hidden; }
.upload-bar-fill { display: block; height: 100%; width: 0; background: #6b9bd1; border-radius: 4px; transition: width .25s; }
.upload-size { font-size: 11.5px; color: #98a2b3; }
.upload-badge { flex-shrink: 0; background: #1a9d56; color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; border-radius: 999px; padding: 6px 12px; text-transform: uppercase; }
.upload-modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }

/* ============ Partage de fichiers — cartes postes & historique ============ */
.poste-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.poste-card { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 7px; border: 1px solid var(--mad-border, #e3e6ee); border-radius: 999px; cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s; }
.poste-card:hover { border-color: #c9d3e3; background: #fafbfd; }
.poste-card:has(input:checked) { border-color: var(--mad-primary, #ff5e00); background: #fff5f0; box-shadow: 0 0 0 3px rgba(255,94,0,.08); }
.poste-card input { position: absolute; opacity: 0; width: 0; height: 0; }
.poste-card .pc-icon { width: 30px; height: 30px; border-radius: 50%; background: #eef3fb; color: #6b9bd1; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; transition: background .15s, color .15s; }
.poste-card:has(input:checked) .pc-icon { background: var(--mad-primary, #ff5e00); color: #fff; }
.poste-card .pc-label { font-size: 14px; font-weight: 600; color: var(--mad-dark, #1d2333); white-space: nowrap; }
.poste-card .pc-check { display: none; width: 16px; height: 16px; border-radius: 50%; background: var(--mad-primary, #ff5e00); color: #fff; align-items: center; justify-content: center; font-size: 9px; }
.poste-card:has(input:checked) .pc-check { display: inline-flex; }
@media (max-width: 600px) {
    .poste-card { padding: 7px; }
    .poste-card .pc-label { display: none; }
    .poste-card .pc-check { display: none; }
}
.result-panel { border: 1px solid #c8e6d2; background: #f1faf4; }
.result-panel .card-title-heading, .result-panel .card-title-heading i { color: #1a9d56; }
.file-cell { display: flex; align-items: center; gap: 8px; }
.file-cell i { color: #6b9bd1; }
.user-cell { display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--mad-primary, #ff5e00); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.poste-badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eef3fb; color: #3b6fb0; margin: 2px 4px 0 0; }
.table tbody tr:hover { background: #f7f9fc; }

/* ============ Tables ============ */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--mad-border); font-size: 14px; vertical-align: middle; }
.table th { color: var(--mad-muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }
.recap-table td { padding: 7px 10px; font-size: 13px; vertical-align: top; }
.recap-table td:first-child { font-weight: 500; }
.recap-table .user-avatar { width: 22px; height: 22px; font-size: 10px; }
.thumb-sm { width: 56px; height: 42px; object-fit: cover; border-radius: 10px; border: 1px solid var(--mad-border); }

/* ============ Badges ============ */
.badge { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; display: inline-block; }
.badge-publie { background: var(--mad-green-soft); color: var(--mad-green); }
.badge-brouillon { background: var(--mad-amber-soft); color: var(--mad-amber); }
.badge-active { background: var(--mad-primary-soft); color: var(--mad-primary-dark); }
.badge-role { background: #ffece0; color: #e06a15; }
.badge-client { background: #e6edfa; color: #3a6db5; }
.badge-secretary { background: var(--mad-green-soft); color: var(--mad-green); }
.badge-admin { background: #fbeed0; color: #b9862a; }
.badge-superadmin { background: #fdeced; color: var(--mad-red); }
.badge-agent { background: #ffece0; color: #e06a15; }
.badge-commercial_manager { background: var(--mad-amber-soft); color: var(--mad-amber); }
.badge-telemarketer { background: #e3f2fb; color: #2a7faf; }
.badge-commercial_field { background: #e8f7ee; color: #1a9d56; }
.badge-commercial_comptoir { background: #f3eafd; color: #7a4fc9; }
.badge-key_account { background: #e6edfa; color: #3a6db5; }
.badge-apporteur { background: #fdf3e0; color: #b9862a; }
.badge-stagiaire { background: #f1f2f6; color: #6b7280; }
.badge-studio { background: #efeafd; color: #7c5cf6; }
.badge-atelier_papier { background: #e9effe; color: #2f6bff; }
.badge-atelier_bache { background: #fff0eb; color: #f05b07; }
.badge-atelier_offset { background: #e3f5f5; color: #0e9494; }
.badge-logistique { background: #e8f7ee; color: #1a9d56; }
.badge-danger { background: #fdeced; color: var(--mad-red); }

/* ============ Buttons ============ */
.btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px;
    border-radius: 10px; border: none; font-size: 14px; font-weight: 600; cursor: pointer;
    background: var(--mad-primary); color: #fff;
    box-shadow: 0 1px 2px var(--mad-glow);
    transition: background .2s, transform .05s, box-shadow .2s;
}
.btn:hover { background: var(--mad-primary-dark); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-secondary { background: #98a0b3; box-shadow: none; }
.btn-secondary:hover { background: #828ba1; }
.btn-sm { padding: 6px 13px; font-size: 13px; }
.btn-outline { background: #fff; color: var(--mad-primary); border: 1px solid var(--mad-primary-soft); box-shadow: none; }
.btn-outline:hover { background: var(--mad-primary-faint); color: var(--mad-primary-dark); border-color: var(--mad-primary-light); }
.btn-danger { background: var(--mad-red); box-shadow: none; }
.btn-danger:hover { background: #cf3d42; }
.icon-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; border: 1px solid var(--mad-border); color: var(--mad-text); background: #fff; }
.icon-btn:hover { background: var(--mad-primary-faint); color: var(--mad-primary); border-color: var(--mad-primary-soft); }
.action-cell { display: flex; gap: 7px; }

/* ============ Forms ============ */
.form-label { font-size: 13.5px; font-weight: 600; color: var(--mad-dark); margin-bottom: 7px; display: block; }
.form-control, .form-select {
    width: 100%; padding: 10px 13px; border: 1px solid var(--mad-border); border-radius: 10px;
    font-size: 14px; color: var(--mad-text); background: #fff; transition: border-color .2s, box-shadow .2s; font-family: inherit;
}
.form-control:focus, .form-select:focus { outline: none; border-color: var(--mad-primary-light); box-shadow: 0 0 0 3px var(--mad-glow-soft); }

/* ============ Misc ============ */
.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 20px; font-size: 14px; border: 1px solid var(--mad-border); }
.alert-success { background: var(--mad-green-soft); color: var(--mad-green); border-color: #cdeede; }
.alert-danger { background: #fdeced; color: var(--mad-red); border-color: #f6d4d6; }
.alert-warning { background: #fff8e6; color: #8a6116; border-color: #f0dcae; }
.alert-info { background: #edf4fd; color: #24548f; border-color: #c9dcf0; }
.secr-card { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border: 1px solid #c9dcf0; background: #edf4fd; border-radius: 12px; max-width: 100%; flex-wrap: wrap; }
.secr-card .secr-icon { width: 34px; height: 34px; border-radius: 50%; background: #2f6bff; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.secr-card .secr-label { font-size: 14px; font-weight: 600; color: #1d2333; }
.row {
    display: flex; flex-wrap: wrap; gap: 24px;
    --bs-gutter-x: 0; --bs-gutter-y: 0; margin-right: 0; margin-left: 0; margin-top: 0;
}
.row > * { padding-right: 0; padding-left: 0; }
.col { flex: 1; min-width: 230px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 24px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; }
.mt-3 { margin-top: 16px !important; }
.mb-3 { margin-bottom: 16px !important; }
.text-muted { color: var(--mad-muted) !important; }
.empty { text-align: center; padding: 40px; color: var(--mad-muted); }

/* ============ Evolution badge ============ */
.evol {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: 6px;
    background: var(--mad-green-soft); color: var(--mad-green);
}
.evol-down { background: #fdeced; color: var(--mad-red); }

/* ============ Secondary info (alerts) ============ */
.alert-box { display: flex; align-items: center; gap: 13px; position: relative; transition: border-color .2s, box-shadow .2s; }
.alert-box:hover { border-color: #dfe2ea; box-shadow: 0 2px 8px rgba(16, 24, 40, .05); }
.alert-box-icon {
    width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0;
}
.alert-box-value { font-size: 19px; font-weight: 700; color: var(--mad-dark); line-height: 1.1; }
.alert-box-label { font-size: 12px; color: var(--mad-muted); margin-top: 2px; }
.alert-box-link { position: absolute; top: 14px; right: 16px; font-size: 12px; color: var(--mad-muted); text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.alert-box-link:hover { color: var(--mad-primary); }
.alert-box.ok .alert-box-icon { background: var(--mad-green-soft); color: var(--mad-green); }
.alert-box.danger .alert-box-icon { background: var(--mad-red-soft); color: var(--mad-red); }
.alert-box.warn .alert-box-icon { background: var(--mad-amber-soft); color: var(--mad-amber); }
.alert-box.info .alert-box-icon { background: var(--mad-blue-soft); color: var(--mad-blue); }
.alert-box.tech .alert-box-value { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 16px; letter-spacing: .02em; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mad-green); box-shadow: 0 0 0 3px var(--mad-green-soft); flex-shrink: 0; }

/* ============ Section heads + period selector ============ */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin: 34px 0 14px; flex-wrap: wrap; }
.section-head .eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--mad-muted); }
.section-head h2 { margin: 3px 0 0; font-size: 18px; font-weight: 700; color: var(--mad-dark); letter-spacing: -0.02em; }
.period { display: inline-flex; background: #f1f3f6; border: 1px solid var(--mad-border); border-radius: 9px; padding: 3px; gap: 2px; }
.period a { font-size: 12.5px; font-weight: 600; color: var(--mad-muted); padding: 5px 12px; border-radius: 7px; text-decoration: none; transition: color .2s, background .2s; }
.period a:hover { color: var(--mad-dark); }
.period a.active { background: #fff; color: var(--mad-dark); box-shadow: 0 1px 2px rgba(16, 24, 40, .06); }

/* ============ Charts ============ */
.card-head-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.card-head-row .card-title { margin: 0; }
.chart-title { font-size: 14px; font-weight: 600; color: var(--mad-dark); }
.chart-sub { font-size: 11.5px; color: var(--mad-muted); margin-top: 2px; }
.chart-sum { font-size: 14px; font-weight: 700; color: var(--mad-dark); text-align: right; }
.chart-sum small { display: block; font-weight: 500; color: var(--mad-muted); font-size: 11.5px; }
.chart-card .card-head-row { padding: 0; }
.chart-card .bar-chart { padding-left: 0; padding-right: 0; }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 8px 16px 0; border-bottom: 1px solid var(--mad-border); overflow-x: auto; }
.bar-chart-sm { height: 160px; }
.bar-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar { width: 60%; max-width: 22px; margin: 0 auto; background: var(--c, var(--mad-blue)); border-radius: 5px 5px 0 0; min-height: 4px; transition: height .3s; flex-shrink: 0; }
.bar-label { font-size: 10px; color: var(--mad-muted); margin-top: 7px; white-space: nowrap; }
.bar-col.today .bar { background: var(--mad-primary); }
.bar-col.today .bar-label { color: var(--mad-dark); font-weight: 700; }

/* ============ Donut ============ */
.donut-wrap { display: flex; align-items: center; justify-content: center; gap: 34px; flex-wrap: wrap; padding: 6px 0 2px; }
.donut-box { position: relative; width: 210px; height: 210px; flex-shrink: 0; }
.donut-svg { width: 100%; height: 100%; display: block; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.donut-center .d-value { font-size: 27px; font-weight: 700; color: var(--mad-dark); line-height: 1.1; letter-spacing: -0.02em; }
.donut-center .d-label { font-size: 12px; color: var(--mad-muted); margin-top: 4px; font-weight: 600; }
.donut-legend { display: flex; flex-direction: column; gap: 10px; min-width: 220px; }
.donut-legend .dl-row { display: flex; align-items: center; gap: 11px; font-size: 13.5px; }
.donut-legend .dl-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.donut-legend .dl-name { color: var(--mad-text); flex: 1; }
.donut-legend .dl-val { color: var(--mad-dark); font-weight: 700; }
.donut-legend .dl-pct { color: var(--mad-muted); font-size: 12px; width: 46px; text-align: right; }
.donut-legend .dl-track { height: 7px; background: #f0f2f5; border-radius: 999px; overflow: hidden; width: 100%; margin-top: 2px; }
.donut-legend .dl-track span { display: block; height: 100%; border-radius: 999px; background: var(--mad-blue); }

/* ============ Hero (welcome) ============ */
.dash-hero {
    position: relative; display: flex; align-items: center; justify-content: space-between;
    gap: 16px; flex-wrap: wrap; padding: 20px 22px; margin-bottom: 22px;
    background: #fbfcfd; border: 1px solid var(--mad-border); border-radius: var(--mad-radius);
}
.dash-hero h1 { margin: 2px 0 4px; font-size: 21px; font-weight: 700; color: var(--mad-dark); letter-spacing: -0.02em; }
.dash-hero p { margin: 0; color: var(--mad-muted); font-size: 13px; display: flex; align-items: center; gap: 7px; }
.hero-greeting { display: inline-block; font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--mad-muted); }
.hero-left { position: relative; z-index: 1; }
.hero-right { position: relative; z-index: 1; }
.hero-right .btn { background: #fff; color: var(--mad-primary); border: 1px solid var(--mad-border); box-shadow: none; padding: 8px 16px; font-size: 13px; }
.hero-right .btn:hover { background: var(--mad-primary-faint); border-color: var(--mad-primary-soft); color: var(--mad-primary-dark); }

/* ============ Top products ============ */
.top-prod { margin-bottom: 14px; }
.top-prod:last-child { margin-bottom: 0; }
.top-prod-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.top-prod-head span { color: var(--mad-text); }
.top-prod-head strong { color: var(--mad-dark); }
.top-prod-bar { height: 7px; background: #f0f2f5; border-radius: 999px; overflow: hidden; }
.top-prod-bar span { display: block; height: 100%; border-radius: 999px; background: var(--mad-blue); }

/* ============ Quick access ============ */
.qa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 16px; }
.qa-tile {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding: 16px 10px 13px; border: 1px solid var(--mad-border); border-radius: 12px;
    background: #fff; color: var(--mad-text); box-shadow: var(--mad-shadow);
    transition: transform .2s, box-shadow .2s, border-color .2s, color .2s;
}
.qa-tile:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(16, 24, 40, .07); border-color: var(--tile); color: var(--mad-dark); }
.qa-icon {
    width: 40px; height: 40px; border-radius: 11px; background: #f4f6f8; color: var(--tile);
    display: flex; align-items: center; justify-content: center; font-size: 16px; transition: background .2s, color .2s;
}
.qa-tile:hover .qa-icon { background: var(--tile); color: #fff; }
.qa-tile > span:last-child { font-size: 12.5px; font-weight: 600; text-align: center; }

/* ============ Mini rows & visits ============ */
.mini-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--mad-border); font-size: 14px; }
.mini-row:last-child { border-bottom: none; }
.mini-label { color: var(--mad-text); display: flex; align-items: center; gap: 10px; }
.mini-label i { width: 18px; text-align: center; color: var(--mad-muted); }
.mini-count {
    background: #f1f3f6; color: var(--mad-dark); font-weight: 700; font-size: 13px;
    padding: 3px 12px; border-radius: 999px;
}
.visit-big { font-size: 30px; font-weight: 700; color: var(--mad-dark); line-height: 1.1; letter-spacing: -0.02em; }
.visit-sub { color: var(--mad-muted); font-size: 13px; margin: 2px 0 16px; }

/* ============ Modal ============ */
.mad-modal { position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center; }
.mad-modal.show { display: flex; }
.mad-modal-overlay { position: absolute; inset: 0; background: rgba(16, 24, 40, .35); }
.mad-modal-box {
    position: relative; width: min(420px, 92vw); background: #fff; border-radius: 16px;
    box-shadow: 0 20px 50px rgba(16, 24, 40, .2); padding: 30px 28px 24px; text-align: center;
    transform: translateY(-14px) scale(.97); opacity: 0; transition: transform .22s ease, opacity .22s ease;
}
.mad-modal.show .mad-modal-box { transform: none; opacity: 1; }
.mad-modal-icon {
    width: 60px; height: 60px; margin: 0 auto 16px; border-radius: 50%;
    background: #f1f3f6; color: var(--mad-primary); display: flex; align-items: center; justify-content: center; font-size: 26px;
}
.mad-modal.success .mad-modal-icon { background: var(--mad-green-soft); color: var(--mad-green); }
.mad-modal.error .mad-modal-icon { background: #fdeced; color: var(--mad-red); }
.mad-modal.info .mad-modal-icon { background: #e6edfa; color: #3a6db5; }
.mad-modal.confirm .mad-modal-icon { background: var(--mad-amber-soft); color: var(--mad-amber); }
.mad-modal-title { margin: 0 0 8px; font-size: 18px; color: var(--mad-dark); font-weight: 700; }
.mad-modal-message { margin: 0 0 22px; color: var(--mad-muted); font-size: 14px; line-height: 1.55; white-space: pre-line; }
.mad-modal-actions { display: flex; gap: 10px; justify-content: center; }
.mad-modal-actions .btn { min-width: 112px; justify-content: center; }

/* ============ Dropdown ============ */
.dropdown-menu { border-radius: 12px; border: 1px solid var(--mad-border); box-shadow: 0 12px 32px rgba(16, 24, 40, .12); padding: 8px; }
.dropdown-item { border-radius: 8px; font-size: 14px; padding: 8px 12px; }
.dropdown-item i { width: 18px; }
button.dropdown-item { display: flex; align-items: center; gap: 6px; width: 100%; border: none; background: none; text-align: left; cursor: pointer; color: inherit; font-family: inherit; }
button.dropdown-item:hover { background: var(--mad-primary-faint); }
button.dropdown-item[disabled] { opacity: .55; cursor: default; }

/* ============ Card title heading (tresorerie pattern) ============ */
.card-title-heading { margin: 0 0 14px; font-size: 15px; font-weight: 600; color: #1d2333; display: flex; align-items: center; gap: 8px; }
.card-title-heading i { width: auto; height: auto; background: none; border-radius: 0; padding: 0; font-size: 14px; }
.card-title-heading-sm { margin: 0 0 14px; font-size: 14px; font-weight: 600; color: #1d2333; display: flex; align-items: center; gap: 8px; }

/* ============ Icon color utilities ============ */
.ico-primary { color: var(--mad-primary); }
.ico-blue { color: var(--mad-blue); }
.ico-turquoise { color: var(--mad-turquoise); }
.ico-green { color: var(--mad-green); }
.ico-red { color: var(--mad-red); }
.ico-violet { color: var(--mad-violet); }
.ico-amber { color: var(--mad-amber); }
.ico-success { color: #1a9d56; }
.ico-success i { color: #1a9d56; }
.ico-dark { color: #1d2333; }
.ico-whatsapp { color: #25d366; }
.ico-muted { color: var(--mad-muted); }

/* ============ Text color utilities ============ */
.text-primary { color: var(--mad-primary) !important; }
.text-green { color: #1a9d56 !important; }
.text-red { color: #e23b3b !important; }
.text-amber { color: #d98800 !important; }
.text-dark { color: #1d2333 !important; }

/* ============ KPI sub-label ============ */
.stat-card .sub { font-size: 12px; color: var(--mad-muted); margin-top: 4px; }

/* ============ Bootstrap neutralization ============ */
body { --bs-body-font-family: inherit; --bs-body-font-size: inherit; --bs-body-bg: transparent; }
h1, h2, h3, h4, h5, h6 { margin-top: 0; }
.btn { --bs-btn-padding-x: 0; --bs-btn-padding-y: 0; line-height: inherit; }
.btn, .btn:hover, .btn:focus, .btn:active, .btn:disabled { border: none; }
.form-control, .form-select { height: auto; min-height: 0; }
.form-control::placeholder { color: var(--mad-muted); opacity: 1; }
.form-control:disabled, .form-select:disabled { background: #f4f6fa; color: var(--mad-muted); cursor: not-allowed; }
.dropdown-menu { --bs-dropdown-border-radius: 12px; --bs-dropdown-inner-border-radius: 0; --bs-dropdown-bg: #fff; }
.table { --bs-table-bg: transparent; --bs-table-border-color: transparent; margin-bottom: 0; color: inherit; }
.table > :not(caption) > * > * { background: transparent; border-bottom-color: var(--mad-border); }
.table-hover tbody tr:hover { --bs-table-accent-bg: transparent; }
.badge { vertical-align: middle; line-height: 1.2; }
.modal { --bs-modal-border-radius: 0; }
.text-muted { color: var(--mad-muted) !important; }

/* ============ Responsive ============ */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(16, 24, 40, .25); }
    .admin-main { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 1035; display: none; }
    .backdrop.show { display: block; }
    .content { padding: 20px 16px 40px; }
    .topbar { padding: 0 16px; }
    .topbar-search { display: none; }
}
@media (max-width: 768px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .row .col { min-width: 100%; }
}
@media (max-width: 575px) {
    .user-meta { display: none; }
    .topbar-link span { display: none; }
    .grid-4 { grid-template-columns: 1fr; }
    .notif-menu { width: calc(100vw - 24px); }
}
