/* ============================================================
   DOUIRA ARCHITECTURE — Admin Premium Design System v2.0
   Ultra-professional Back-Office UI
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;1,400&family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
    /* Core palette */
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-400: #60a5fa;
    --blue-500: #4A7DC0;
    --blue-600: #3366aa;
    --blue-700: #1d4ed8;
    --blue-900: #1e3a5f;

    /* Semantic */
    --admin-bg: #f1f5f9;
    --admin-sidebar: #ffffff;
    --admin-card: #ffffff;
    --admin-elevated: #f8fafc;
    --admin-border: rgba(74, 125, 192, .13);
    --admin-border-hover: rgba(74, 125, 192, .28);
    --admin-accent: #4A7DC0;
    --admin-accent-dark: #2a5a9a;
    --admin-accent-light: #6b9fd4;
    --admin-accent-bg: rgba(74, 125, 192, .07);
    --admin-accent-glow: rgba(74, 125, 192, .22);
    --admin-text: #0f172a;
    --admin-text-2: #334155;
    --admin-muted: #64748b;
    --admin-faint: #cbd5e1;
    --admin-success: #059669;
    --admin-warning: #d97706;
    --admin-danger: #dc2626;
    --admin-info: #0284c7;

    /* Typography */
    --font-serif: 'Cormorant Garamond', Georgia, serif;
    --font-sans: 'Inter', system-ui, sans-serif;

    /* Layout */
    --sidebar-w: 272px;
    --topbar-h: 64px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;

    /* Animation */
    --ease: cubic-bezier(.4, 0, .2, 1);
    --transition: all .22s var(--ease);
    --trans-slow: all .4s var(--ease);

    /* Shadows */
    --shadow-sm: 0 1px 4px rgba(15, 23, 42, .06);
    --shadow: 0 2px 12px rgba(15, 23, 42, .08);
    --shadow-md: 0 4px 24px rgba(15, 23, 42, .1);
    --shadow-lg: 0 8px 40px rgba(15, 23, 42, .12);
    --shadow-acc: 0 4px 20px rgba(74, 125, 192, .25);
}

/* ── Reset ─────────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body.admin-body {
    background: var(--admin-bg);
    color: var(--admin-text);
    font-family: var(--font-sans);
    font-weight: 400;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--admin-faint);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--admin-accent);
}

/* ── Bootstrap Overrides ───────────────────────────────────── */

/* Buttons */
.btn {
    border-radius: var(--radius);
    font-size: .82rem;
    letter-spacing: .025em;
    font-weight: 500;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .5rem 1.1rem;
    border: 1.5px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--admin-accent) 0%, var(--admin-accent-dark) 100%);
    border-color: transparent;
    color: #fff;
    box-shadow: var(--shadow-acc);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--admin-accent-dark) 0%, #1a4a8a 100%);
    color: #fff;
    box-shadow: 0 6px 28px rgba(74, 125, 192, .38);
    transform: translateY(-1px);
    border-color: transparent;
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #fff;
    border-color: var(--admin-border);
    color: var(--admin-text-2);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--admin-elevated);
    border-color: var(--admin-border-hover);
    color: var(--admin-text);
    box-shadow: var(--shadow);
}

.btn-outline-primary {
    background: transparent;
    border-color: var(--admin-accent);
    color: var(--admin-accent);
}

.btn-outline-primary:hover {
    background: var(--admin-accent-bg);
    border-color: var(--admin-accent-dark);
    color: var(--admin-accent-dark);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 8px rgba(220, 38, 38, .2);
}

.btn-danger:hover {
    box-shadow: 0 4px 16px rgba(220, 38, 38, .3);
    transform: translateY(-1px);
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: #fff;
    border-color: transparent;
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 2px 8px rgba(16, 185, 129, .22);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(16, 185, 129, .32);
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #fff;
    border-color: transparent;
}

.btn-sm {
    padding: .32rem .8rem;
    font-size: .75rem;
    border-radius: 6px;
}

.btn-lg {
    padding: .75rem 1.75rem;
    font-size: .9rem;
    border-radius: var(--radius-lg);
}

.btn-xs {
    padding: .2rem .55rem;
    font-size: .68rem;
    border-radius: 5px;
}

/* Form Controls */
.form-control,
.form-select {
    background: var(--admin-elevated);
    border: 1.5px solid var(--admin-border);
    color: var(--admin-text);
    border-radius: var(--radius);
    font-size: .875rem;
    font-family: var(--font-sans);
    transition: var(--transition);
    padding: .5rem .85rem;
}

.form-control:focus,
.form-select:focus {
    background: #fff;
    border-color: var(--admin-accent);
    color: var(--admin-text);
    box-shadow: 0 0 0 3px var(--admin-accent-glow);
    outline: none;
}

.form-control::placeholder {
    color: var(--admin-faint);
}

.form-label {
    font-size: .78rem;
    font-weight: 500;
    color: var(--admin-muted);
    margin-bottom: .38rem;
    letter-spacing: .02em;
}

/* Cards */
.card {
    background: var(--admin-card);
    border: 1.5px solid var(--admin-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    color: var(--admin-text);
}

.card:hover {
    border-color: var(--admin-border-hover);
    box-shadow: var(--shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1.5px solid var(--admin-border);
    padding: .9rem 1.4rem;
    font-size: .72rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--admin-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .6rem;
}

.card-header .card-header-icon {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    background: var(--admin-accent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--admin-accent);
    font-size: .7rem;
}

.card-body {
    padding: 1.4rem;
}

/* Tables */
.table {
    color: var(--admin-text);
    font-size: .875rem;
}

.table> :not(caption)>*>* {
    border-color: var(--admin-border);
    background: transparent;
    padding: .82rem 1rem;
}

.table thead {
    color: var(--admin-muted);
    font-size: .7rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    font-weight: 600;
}

.table thead th {
    border-bottom: 2px solid var(--admin-border);
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover>* {
    background: var(--admin-accent-bg) !important;
}

/* Modals */
.modal-content {
    background: #fff;
    border: 1.5px solid var(--admin-border);
    border-radius: var(--radius-2xl);
    box-shadow: 0 20px 60px rgba(15, 23, 42, .14);
    color: var(--admin-text);
}

.modal-header {
    border-bottom: 1.5px solid var(--admin-border);
    padding: 1.25rem 1.5rem;
}

.modal-footer {
    border-top: 1.5px solid var(--admin-border);
    padding: 1rem 1.5rem;
}

.modal-title {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    color: var(--admin-text);
    font-weight: 600;
}

.modal-backdrop.show {
    opacity: .45;
}

.btn-close {
    background: var(--admin-elevated) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2364748b'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e") center/10px auto no-repeat;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    opacity: 1;
    border: 1.5px solid var(--admin-border);
}

.btn-close:hover {
    background-color: #fee2e2;
    opacity: 1;
}

/* Dropdowns */
.dropdown-menu {
    background: #fff;
    border: 1.5px solid var(--admin-border);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-lg);
    padding: .35rem;
    min-width: 170px;
}

.dropdown-item {
    color: var(--admin-text-2);
    font-size: .84rem;
    transition: var(--transition);
    border-radius: var(--radius);
    padding: .55rem .85rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.dropdown-item:hover {
    background: var(--admin-accent-bg);
    color: var(--admin-accent-dark);
}

.dropdown-item i {
    width: 16px;
    text-align: center;
}

.dropdown-divider {
    border-color: var(--admin-border);
    margin: .3rem 0;
}

/* Badges */
.badge {
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .04em;
    padding: .3em .75em;
    border-radius: 20px;
}

.badge-accent {
    background: var(--admin-accent-bg);
    color: var(--admin-accent-dark);
    border: 1px solid rgba(74, 125, 192, .18);
}

.badge.bg-success {
    background: rgba(5, 150, 105, .1) !important;
    color: #059669 !important;
}

.badge.bg-warning {
    background: rgba(217, 119, 6, .1) !important;
    color: #d97706 !important;
}

.badge.bg-danger {
    background: rgba(220, 38, 38, .1) !important;
    color: #dc2626 !important;
}

.badge.bg-info {
    background: rgba(2, 132, 199, .1) !important;
    color: #0284c7 !important;
}

/* Tab Panes – ensure Bootstrap tab visibility even without CDN */
.tab-pane {
    display: none;
}
.tab-pane.show,
.tab-pane.active {
    display: block;
}

/* Nav Tabs */
.nav-tabs {
    border-bottom: 2px solid var(--admin-border);
    gap: .1rem;
}

.nav-tabs .nav-link {
    color: var(--admin-muted);
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    border-radius: 0;
    padding: .7rem 1.1rem;
    font-size: .82rem;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: .4rem;
}

.nav-tabs .nav-link:hover {
    color: var(--admin-text);
    border-color: transparent;
    background: var(--admin-accent-bg);
    border-radius: var(--radius) var(--radius) 0 0;
}

.nav-tabs .nav-link.active {
    color: var(--admin-accent-dark);
    border-bottom-color: var(--admin-accent);
    background: var(--admin-accent-bg);
    border-radius: var(--radius) var(--radius) 0 0;
    font-weight: 600;
}

/* Alert */
.alert {
    border-radius: var(--radius-lg);
    border: 1.5px solid;
    padding: .85rem 1.1rem;
    font-size: .875rem;
}

/* ── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: #fff;
    border-right: 1.5px solid var(--admin-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width .3s var(--ease);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 4px 0 24px rgba(74, 125, 192, .07);
}

/* ── Collapsed sidebar — icons only ── */
.sidebar.collapsed { width: 68px; }

.sidebar.collapsed .sidebar-brand-name,
.sidebar.collapsed .sidebar-brand-sub,
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .sidebar-user-name,
.sidebar.collapsed .sidebar-user-role,
.sidebar.collapsed .sidebar-collapse-label {
    opacity: 0; width: 0; overflow: hidden; white-space: nowrap;
}

.sidebar.collapsed .sidebar-brand { padding: 1.35rem .85rem 1.2rem; justify-content: center; }
.sidebar.collapsed .sidebar-brand > a { justify-content: center; gap: 0; }
.sidebar.collapsed .sidebar-brand > a > div:last-child { display: none; }

.sidebar.collapsed .sidebar-nav { padding: 0 .45rem; }
.sidebar.collapsed .sidebar-nav li a { justify-content: center !important; padding: .62rem .5rem; gap: 0; }
/* Hide text labels — direct spans that contain text */
.sidebar.collapsed .sidebar-nav li a > span > span,
.sidebar.collapsed .sidebar-nav li a > span:not(:has(i)),
.sidebar.collapsed .sidebar-nav li a > .sidebar-badge { display: none; }
.sidebar.collapsed .sidebar-nav li a > span:has(i) { gap: 0 !important; }
.sidebar.collapsed .sidebar-nav li a i { margin: 0; font-size: 1.1rem; }

.sidebar.collapsed .sidebar-section { padding-top: .8rem; }
.sidebar.collapsed .sidebar-section-label { height: 0; margin: 0; padding: 0; }

.sidebar.collapsed .sidebar-user { padding: .5rem; justify-content: center; }
.sidebar.collapsed .sidebar-user > div:not(.sidebar-user-avatar) { display: none; }
.sidebar.collapsed .sidebar-user > a { display: none; }

/* Collapse toggle button */
.sidebar-collapse-btn {
    padding: .55rem; margin: 0 .7rem; margin-top: -.4rem; margin-bottom: .5rem;
    border: 1.5px solid var(--admin-border); border-radius: var(--radius);
    background: var(--admin-elevated); color: var(--admin-muted);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    gap: .5rem; font-size: .75rem; font-weight: 500;
    transition: var(--transition); flex-shrink: 0;
}
.sidebar-collapse-btn:hover { background: var(--admin-accent-bg); border-color: var(--admin-accent); color: var(--admin-accent); }
.sidebar-collapse-btn i { font-size: .9rem; transition: transform .3s var(--ease); }
.sidebar.collapsed .sidebar-collapse-btn { margin: 0 .3rem .5rem; }
.sidebar.collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }

/* Floating tooltip for collapsed sidebar (positioned via JS) */
.sidebar-tooltip {
    position: fixed;
    background: var(--admin-text); color: #fff;
    font-size: .72rem; font-weight: 500; font-family: var(--font-sans);
    padding: .35rem .75rem; border-radius: 6px; white-space: nowrap;
    z-index: 9999; pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
    opacity: 0; transition: opacity .15s;
}
.sidebar-tooltip.visible { opacity: 1; }

/* Main adapts to collapsed sidebar */
.admin-main { transition: margin-left .3s var(--ease); }

.sidebar::-webkit-scrollbar {
    display: none;
}

/* Brand */
.sidebar-brand {
    padding: 1.35rem 1.4rem 1.2rem;
    border-bottom: 1.5px solid var(--admin-border);
    display: flex;
    align-items: center;
    gap: .9rem;
    flex-shrink: 0;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--admin-accent) 0%, var(--admin-accent-dark) 100%);
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(74, 125, 192, .33);
}

.sidebar-brand-name {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    color: var(--admin-text);
    line-height: 1.1;
    font-weight: 600;
}

.sidebar-brand-name span {
    color: var(--admin-accent);
}

.sidebar-brand-sub {
    font-size: .55rem;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--admin-muted);
    margin-top: .2rem;
}

/* Nav sections */
.sidebar-section {
    padding: 1.2rem 0 0;
}

.sidebar-section-label {
    font-size: .58rem;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--admin-faint);
    padding: 0 1.35rem;
    margin-bottom: .3rem;
    font-weight: 700;
}

.sidebar-nav {
    list-style: none;
    padding: 0 .7rem;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .62rem .9rem;
    color: var(--admin-muted);
    font-size: .84rem;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
    border-radius: var(--radius);
    margin-bottom: 2px;
    position: relative;
}

.sidebar-nav li a i {
    font-size: .95rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    transition: color .2s;
}

.sidebar-nav li a:hover {
    color: var(--admin-text);
    background: var(--admin-accent-bg);
}

.sidebar-nav li a:hover i {
    color: var(--admin-accent);
}

.sidebar-nav li a.active {
    color: #fff;
    background: linear-gradient(135deg, var(--admin-accent) 0%, var(--admin-accent-dark) 100%);
    box-shadow: 0 3px 14px rgba(74, 125, 192, .3);
    font-weight: 600;
}

.sidebar-nav li a.active i {
    color: rgba(255, 255, 255, .9);
}

.sidebar-nav li a.active::before {
    content: '';
    position: absolute;
    right: -1px;
    top: 25%;
    height: 50%;
    width: 3px;
    background: var(--admin-accent-dark);
    border-radius: 3px 0 0 3px;
}

.sidebar-badge {
    margin-left: auto;
    font-size: .6rem;
    background: var(--admin-accent);
    color: #fff;
    padding: .15em .55em;
    border-radius: 20px;
    font-weight: 700;
    line-height: 1.4;
}

.sidebar-nav li a.active .sidebar-badge {
    background: rgba(255, 255, 255, .25);
}

/* Sidebar user */
.sidebar-user {
    margin: .7rem;
    padding: .85rem 1rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: .75rem;
    background: var(--admin-accent-bg);
    border: 1.5px solid rgba(74, 125, 192, .12);
    margin-top: auto;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--admin-accent) 0%, var(--admin-accent-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .78rem;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(74, 125, 192, .25);
}

.sidebar-user-name {
    font-size: .82rem;
    font-weight: 600;
    color: var(--admin-text);
}

.sidebar-user-role {
    font-size: .62rem;
    color: var(--admin-accent);
    text-transform: capitalize;
    font-weight: 500;
}

/* ── TOPBAR ─────────────────────────────────────────────────── */
.admin-topbar {
    background: rgba(255, 255, 255, .9);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1.5px solid var(--admin-border);
    padding: 0 2rem;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 99;
    box-shadow: 0 1px 12px rgba(74, 125, 192, .06);
}

.admin-topbar-title {
    font-size: .95rem;
    font-weight: 600;
    color: var(--admin-text);
    flex: 1;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.admin-topbar-title .page-icon {
    width: 30px;
    height: 30px;
    border-radius: var(--radius);
    background: var(--admin-accent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--admin-accent);
    font-size: .85rem;
}

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

/* Breadcrumb in topbar */
.topbar-breadcrumb {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .75rem;
    color: var(--admin-muted);
}

.topbar-breadcrumb a {
    color: var(--admin-muted);
    text-decoration: none;
}

.topbar-breadcrumb a:hover {
    color: var(--admin-accent);
}

.topbar-breadcrumb .sep {
    opacity: .4;
}

/* ── MAIN CONTENT ───────────────────────────────────────────── */
.admin-main {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--admin-bg);
}

.admin-content {
    padding: 1.75rem 2rem;
    flex: 1;
}

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




.kpi-card {
    background: #fff;
    border: 1.5px solid var(--admin-border);
    border-radius: var(--radius-xl);
    padding: 1.5rem 1.4rem 1.25rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--kpi-color, var(--admin-accent));
    border-radius: 4px 4px 0 0;
}

.kpi-card::after {
    content: '';
    position: absolute;
    bottom: -20px;
    right: -20px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--kpi-color, var(--admin-accent));
    opacity: .04;
    transition: var(--trans-slow);
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--admin-border-hover);
}

.kpi-card:hover::after {
    opacity: .07;
    transform: scale(1.2);
}

.kpi-label {
    font-size: .65rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--admin-muted);
    margin-bottom: .7rem;
    font-weight: 600;
}

.kpi-value {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    color: var(--admin-text);
    line-height: 1;
    margin-bottom: .4rem;
    font-weight: 600;
}

.kpi-sub {
    font-size: .74rem;
    color: var(--admin-muted);
}

.kpi-icon {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--kpi-color, var(--admin-accent)) 12%, white);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--kpi-color, var(--admin-accent));
    font-size: 1.15rem;
}

.kpi-trend {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-size: .7rem;
    font-weight: 600;
    margin-top: .3rem;
    padding: .15em .5em;
    border-radius: 4px;
}

.kpi-trend.up {
    color: #059669;
    background: rgba(5, 150, 105, .1);
}

.kpi-trend.down {
    color: #dc2626;
    background: rgba(220, 38, 38, .1);
}

/* ── PAGE HEADER ────────────────────────────────────────────── */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1.5px solid var(--admin-border);
}

.page-header-left h1 {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--admin-text);
    margin: 0;
}

.page-header-left p {
    font-size: .8rem;
    color: var(--admin-muted);
    margin-top: .25rem;
}

.page-header-actions {
    display: flex;
    gap: .65rem;
    align-items: center;
}

/* ── SECTION HEADER ─────────────────────────────────────────── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-title {
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--admin-muted);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.section-title::before {
    content: '';
    width: 3px;
    height: 16px;
    background: var(--admin-accent);
    border-radius: 2px;
}

/* ── TOOLBAR ────────────────────────────────────────────────── */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.toolbar-filters {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
}

/* ── SEARCH BAR ─────────────────────────────────────────────── */
.search-wrap {
    position: relative;
}

.search-wrap svg {
    position: absolute;
    left: .85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--admin-muted);
    width: 15px;
    height: 15px;
    pointer-events: none;
}

.search-input {
    background: #fff;
    border: 1.5px solid var(--admin-border);
    color: var(--admin-text);
    border-radius: 999px;
    padding: .5rem 1rem .5rem 2.4rem;
    font-size: .84rem;
    font-family: var(--font-sans);
    width: 250px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.search-input:focus {
    border-color: var(--admin-accent);
    outline: none;
    width: 300px;
    box-shadow: 0 0 0 3px var(--admin-accent-glow);
}

/* ── STATUS BADGES ──────────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .28em .75em;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .03em;
    white-space: nowrap;
}

.status-badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.status-en-cours {
    background: rgba(74, 144, 217, .12);
    color: #3d7ecc;
}

.status-termine {
    background: rgba(5, 150, 105, .12);
    color: #059669;
}

.status-attente {
    background: rgba(100, 116, 139, .12);
    color: #64748b;
}

.status-suspendu {
    background: rgba(217, 119, 6, .12);
    color: #d97706;
}

.status-nouveau {
    background: rgba(74, 144, 217, .12);
    color: #3d7ecc;
}

.status-gagne {
    background: rgba(5, 150, 105, .12);
    color: #059669;
}

.status-perdu {
    background: rgba(220, 38, 38, .12);
    color: #dc2626;
}

.status-brouillon {
    background: rgba(100, 116, 139, .12);
    color: #64748b;
}

.status-emise {
    background: rgba(74, 125, 192, .12);
    color: var(--admin-accent-dark);
}

.status-payee {
    background: rgba(5, 150, 105, .12);
    color: #059669;
}

.status-retard {
    background: rgba(220, 38, 38, .12);
    color: #dc2626;
}

/* Priority */
.priority-faible {
    background: rgba(100, 116, 139, .1);
    color: #64748b;
}

.priority-normale {
    background: rgba(74, 125, 192, .1);
    color: var(--admin-accent-dark);
}

.priority-haute {
    background: rgba(217, 119, 6, .1);
    color: #d97706;
}

.priority-urgente {
    background: rgba(220, 38, 38, .1);
    color: #dc2626;
}

/* ── AVATAR ─────────────────────────────────────────────────── */
.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--admin-accent-bg);
    border: 2px solid rgba(74, 125, 192, .15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--admin-accent-dark);
    font-size: .78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.avatar-sm {
    width: 28px;
    height: 28px;
    font-size: .65rem;
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 1rem;
}

/* ── EMPTY STATE ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--admin-muted);
}

.empty-state-icon {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-xl);
    background: var(--admin-accent-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--admin-accent);
    font-size: 1.8rem;
    margin: 0 auto 1.25rem;
}

.empty-state h5 {
    color: var(--admin-text);
    margin-bottom: .5rem;
    font-family: var(--font-serif);
    font-size: 1.2rem;
}

.empty-state p {
    font-size: .85rem;
    max-width: 300px;
    margin: 0 auto;
}

/* ── KANBAN BOARD ───────────────────────────────────────────── */
.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    min-height: 400px;
}

.kanban-board::-webkit-scrollbar {
    height: 5px;
}

.kanban-col {
    flex: 0 0 268px;
    background: var(--admin-elevated);
    border: 1.5px solid var(--admin-border);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    max-height: 72vh;
    transition: var(--transition);
}

.kanban-col:hover {
    border-color: var(--admin-border-hover);
    box-shadow: var(--shadow);
}

.kanban-col-header {
    padding: 1rem 1.15rem .85rem;
    border-bottom: 1.5px solid var(--admin-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    border-radius: calc(var(--radius-xl) - 2px) calc(var(--radius-xl) - 2px) 0 0;
}

.kanban-col-title {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--admin-muted);
}

.kanban-col-count {
    background: #fff;
    border: 1px solid var(--admin-border);
    color: var(--admin-muted);
    font-size: .65rem;
    font-weight: 700;
    padding: .15em .6em;
    border-radius: 20px;
    box-shadow: var(--shadow-sm);
}

.kanban-cards {
    flex: 1;
    overflow-y: auto;
    padding: .7rem;
    display: flex;
    flex-direction: column;
    gap: .55rem;
}

.kanban-cards.drag-over {
    background: var(--admin-accent-bg);
    border-radius: var(--radius);
}

.kanban-card {
    background: #fff;
    border: 1.5px solid var(--admin-border);
    border-radius: var(--radius-lg);
    padding: .9rem 1rem;
    cursor: grab;
    transition: var(--transition);
    user-select: none;
    box-shadow: var(--shadow-sm);
}

.kanban-card:hover {
    border-color: var(--admin-border-hover);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.kanban-card.dragging {
    opacity: .45;
    cursor: grabbing;
}

.kanban-card-title {
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: .4rem;
    color: var(--admin-text);
}

.kanban-card-meta {
    font-size: .72rem;
    color: var(--admin-muted);
}

.kanban-card-footer {
    margin-top: .75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kanban-add-btn {
    margin: .65rem;
    width: calc(100% - 1.3rem);
    background: transparent;
    border: 1.5px dashed var(--admin-border);
    color: var(--admin-muted);
    font-size: .78rem;
    font-family: var(--font-sans);
    padding: .5rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.kanban-add-btn:hover {
    border-color: var(--admin-accent);
    color: var(--admin-accent);
    background: var(--admin-accent-bg);
}

/* Pipeline columns color-coded tops */
.pipeline-nouveau .kanban-col-header {
    border-top: 3px solid #4a90d9;
}

.pipeline-contacte .kanban-col-header {
    border-top: 3px solid #9c6ed9;
}

.pipeline-proposition .kanban-col-header {
    border-top: 3px solid var(--admin-accent);
}

.pipeline-negociation .kanban-col-header {
    border-top: 3px solid #d97706;
}

.pipeline-gagne .kanban-col-header {
    border-top: 3px solid #059669;
}

.pipeline-perdu .kanban-col-header {
    border-top: 3px solid #dc2626;
}

/* Kanban mobile: scrollable + compact */
@media (max-width: 768px) {
    .kanban-board {
        scroll-snap-type: x mandatory;
        padding-bottom: 1.5rem;
    }

    .kanban-col {
        flex: 0 0 240px;
        scroll-snap-align: start;
        max-height: 65vh;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── GANTT ──────────────────────────────────────────────────── */
.gantt-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .65rem 0;
    border-bottom: 1px solid var(--admin-border);
}

.gantt-label {
    width: 120px;
    font-size: .8rem;
    flex-shrink: 0;
    font-weight: 500;
}

.gantt-track {
    flex: 1;
    height: 8px;
    background: var(--admin-border);
    border-radius: 4px;
    overflow: hidden;
}

.gantt-bar {
    height: 100%;
    background: var(--admin-accent);
    border-radius: 4px;
    transition: width .6s var(--ease);
}

.gantt-dates {
    font-size: .7rem;
    color: var(--admin-muted);
    width: 200px;
    text-align: right;
    flex-shrink: 0;
}

/* ── STATS CHIPS ────────────────────────────────────────────── */
.stat-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    margin-bottom: 1.25rem;
}

.stat-chip {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .9rem;
    background: #fff;
    border: 1.5px solid var(--admin-border);
    border-radius: 999px;
    font-size: .78rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-chip:hover {
    border-color: var(--admin-border-hover);
    box-shadow: var(--shadow);
}

.stat-chip .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.stat-chip strong {
    font-weight: 700;
}

/* ── PAGE BUILDER ───────────────────────────────────────────── */
.pb-section-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1.5px solid var(--admin-border);
    cursor: grab;
    transition: var(--transition);
}

.pb-section-item:hover {
    background: var(--admin-accent-bg);
}

.pb-section-item.sortable-ghost {
    background: var(--admin-accent-bg);
}

.pb-drag-handle {
    color: var(--admin-faint);
    cursor: grab;
    flex-shrink: 0;
}

.pb-section-label {
    flex: 1;
    font-size: .875rem;
}

.pb-section-actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* ── FORM SWITCHES ──────────────────────────────────────────── */
.form-check-input {
    background-color: var(--admin-faint);
    border-color: var(--admin-faint);
    cursor: pointer;
    width: 1em;
    height: 1em;
}

.form-check-input:checked {
    background-color: var(--admin-accent);
    border-color: var(--admin-accent);
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px var(--admin-accent-glow);
}

.form-switch .form-check-input {
    width: 2.2em;
    height: 1.15em;
    background-color: var(--admin-faint);
    border: none;
}

.form-switch .form-check-input:checked {
    background-color: var(--admin-accent);
}

.form-check-label {
    cursor: pointer;
    font-size: .875rem;
}

/* ── RESPONSIVE SIDEBAR TOGGLE ──────────────────────────────── */
.sidebar-toggle {
    display: none;
    background: none;
    border: 1.5px solid var(--admin-border);
    color: var(--admin-text);
    padding: .4rem .55rem;
    cursor: pointer;
    border-radius: var(--radius);
    line-height: 1;
    flex-shrink: 0;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--admin-accent-bg);
    border-color: var(--admin-accent);
    color: var(--admin-accent);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    z-index: 99;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    cursor: pointer;
    touch-action: none;
}

.sidebar-overlay.show {
    display: block;
    animation: fadeIn .2s var(--ease) both;
}

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

@media (max-width: 950px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-w)));
        z-index: 200;
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 40px rgba(15, 23, 42, .18);
    }

    .admin-main {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .admin-topbar {
        padding: 0 1rem;
        gap: .6rem;
    }

    .admin-content {
        padding: 1.1rem 1rem;
    }

    .admin-topbar-actions .btn span {
        display: none;
    }

    .topbar-breadcrumb {
        display: none;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: .75rem;
    }

    .search-input {
        width: 100%;
        max-width: 100%;
    }

    .search-input:focus {
        width: 100%;
    }

    /* Hide secondary table columns on tablet */
    .table .col-hide-tablet {
        display: none;
    }
}

@media (max-width: 768px) {

    /* ── MOBILE TABLE → CARD TRANSFORMATION ────────────────────── */

    /* Wrapper becomes scrollable only if table is NOT in card-mode */
    .table-responsive {
        border: none;
        overflow-x: visible;
    }

    /* Transform table into stacked card rows */
    .table.table-mobile-cards,
    .table-responsive > .table {
        display: block;
        width: 100%;
    }

    .table.table-mobile-cards thead,
    .table-responsive > .table thead {
        display: none; /* Hide header row – labels shown via data-label */
    }

    .table.table-mobile-cards tbody,
    .table-responsive > .table tbody {
        display: flex;
        flex-direction: column;
        gap: .6rem;
        padding: .75rem;
    }

    .table.table-mobile-cards tbody tr,
    .table-responsive > .table tbody tr {
        display: flex;
        flex-direction: column;
        background: var(--admin-card);
        border: 1.5px solid var(--admin-border);
        border-radius: var(--radius-lg);
        padding: .85rem 1rem;
        box-shadow: var(--shadow-sm);
        gap: .4rem;
        transition: var(--transition);
    }

    .table.table-mobile-cards tbody tr:hover,
    .table-responsive > .table tbody tr:hover {
        border-color: var(--admin-border-hover);
        box-shadow: var(--shadow);
    }

    /* Override Bootstrap table hover background in card mode */
    .table.table-mobile-cards tbody tr:hover > *,
    .table-responsive > .table tbody tr:hover > * {
        background: transparent !important;
    }

    .table.table-mobile-cards tbody td,
    .table-responsive > .table tbody td {
        display: flex;
        align-items: flex-start;
        gap: .5rem;
        padding: .25rem 0 !important;
        border: none !important;
        font-size: .84rem;
        line-height: 1.4;
    }

    /* Label badge before each cell using data-label attribute */
    .table.table-mobile-cards tbody td[data-label]::before,
    .table-responsive > .table tbody td[data-label]::before {
        content: attr(data-label);
        font-size: .65rem;
        font-weight: 700;
        letter-spacing: .08em;
        text-transform: uppercase;
        color: var(--admin-muted);
        min-width: 90px;
        flex-shrink: 0;
        padding-top: .1rem;
    }

    /* Hide columns marked as mobile-hidden */
    .table.table-mobile-cards tbody td.mobile-hide,
    .table-responsive > .table tbody td.mobile-hide,
    .table.table-mobile-cards thead th.mobile-hide,
    .table-responsive > .table thead th.mobile-hide {
        display: none;
    }

    /* Action bar: always visible on mobile (no hover needed) */
    .action-bar {
        opacity: 1 !important;
    }

    /* First td (main info) gets styled as card title */
    .table.table-mobile-cards tbody td:first-child,
    .table-responsive > .table tbody td:first-child {
        font-weight: 600;
        font-size: .9rem;
        padding-bottom: .5rem !important;
        border-bottom: 1px solid var(--admin-border) !important;
        margin-bottom: .2rem;
    }

    .table.table-mobile-cards tbody td:first-child::before,
    .table-responsive > .table tbody td:first-child::before {
        display: none; /* No label for first (title) cell */
    }

    /* Last td (actions) – align to right */
    .table.table-mobile-cards tbody td:last-child,
    .table-responsive > .table tbody td:last-child {
        justify-content: flex-end;
        padding-top: .5rem !important;
        border-top: 1px solid var(--admin-border) !important;
        margin-top: .2rem;
    }

    .table.table-mobile-cards tbody td:last-child::before,
    .table-responsive > .table tbody td:last-child::before {
        display: none;
    }
}

@media (max-width: 576px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .admin-topbar {
        padding: 0 .75rem;
    }

    .admin-content {
        padding: 1rem .75rem;
    }

    .card-body {
        padding: 1rem;
    }

    .card-header {
        padding: .75rem 1rem;
    }

    .page-header-actions {
        width: 100%;
    }

    /* Toolbar stacks on small screens */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-filters .form-select,
    .toolbar-filters .search-input {
        width: 100% !important;
    }

    /* Full-width action buttons */
    .page-header-actions .btn {
        flex: 1;
        justify-content: center;
    }

    /* Stat chips wrap nicely */
    .stat-chips {
        gap: .4rem;
    }

    /* Mobile data-label width reduction for very small screens */
    .table-responsive > .table tbody td[data-label]::before {
        min-width: 75px;
    }

    /* Gantt hides date column */
    .gantt-dates {
        display: none;
    }
}

/* ── UTILITIES ──────────────────────────────────────────────── */
.text-accent {
    color: var(--admin-accent) !important;
}

.text-success {
    color: var(--admin-success) !important;
}

.text-danger {
    color: var(--admin-danger) !important;
}

.text-warning {
    color: var(--admin-warning) !important;
}

.text-info {
    color: var(--admin-info) !important;
}

.text-muted {
    color: var(--admin-muted) !important;
}

.bg-accent-soft {
    background: var(--admin-accent-bg) !important;
}

.border-accent {
    border-color: var(--admin-border) !important;
}

/* ── MICRO ANIMATIONS ───────────────────────────────────────── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

.animate-fade-up {
    animation: fadeInUp .3s var(--ease) both;
}

.animate-fade {
    animation: fadeIn .25s var(--ease) both;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

/* Stagger for KPI cards */
.kpi-card:nth-child(1) {
    animation: fadeInUp .3s .05s var(--ease) both;
}

.kpi-card:nth-child(2) {
    animation: fadeInUp .3s .10s var(--ease) both;
}

.kpi-card:nth-child(3) {
    animation: fadeInUp .3s .15s var(--ease) both;
}

.kpi-card:nth-child(4) {
    animation: fadeInUp .3s .20s var(--ease) both;
}

/* ── NOTIFICATION DOT ───────────────────────────────────────── */
.notif-dot {
    position: relative;
}

.notif-dot::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
}

/* ── INLINE LOADER ──────────────────────────────────────────── */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--admin-border);
    border-top-color: var(--admin-accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

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

/* ── ACTION ROW ─────────────────────────────────────────────── */
.action-bar {
    display: flex;
    gap: .4rem;
    opacity: 0;
    transition: opacity .2s;
}

tr:hover .action-bar {
    opacity: 1;
}

/* ── HOVER BORDER ACCENT ────────────────────────────────────── */
.hover-border-accent:hover {
    border-color: var(--admin-accent-dark) !important;
    transform: scale(1.15);
    transition: transform .2s;
}

/* ── PRINT ──────────────────────────────────────────────────── */
@media print {

    .sidebar,
    .admin-topbar,
    .btn,
    .no-print {
        display: none !important;
    }

    .admin-main {
        margin-left: 0 !important;
    }

    .admin-content {
        padding: 0 !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ── Prix Mode Toggle (HT/TTC) ─────────────────────────────── */
.prix-mode-btn {
    background: transparent;
    border: 1.5px solid transparent;
    color: var(--admin-muted);
    transition: var(--transition);
    cursor: pointer;
}

.prix-mode-btn:hover {
    color: var(--admin-text);
    background: rgba(74, 125, 192, .05);
}

.prix-mode-btn.active {
    background: linear-gradient(135deg, var(--admin-accent) 0%, var(--admin-accent-dark) 100%);
    color: #fff !important;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(74, 125, 192, .25);
}