/* ============================================
   QWaste Design System — Modern SaaS Dashboard
   ============================================ */

:root {
    --sidebar-desktop-width: 16.666667%;
    --sidebar-collapsed-width: 62px;
    /* ── Brand palette — change colors here, everything else uses these ── */
    --primary: #0E9CA8;        /* основной фирменный */
    --primary-2: #0FA38A;      /* конец градиента */
    --primary-dark: #0C8A95;   /* hover/нажатие */
    --primary-darker: #0B7E74; /* конец градиента hover */
    --primary-light: #8AD8DF;
    --accent: #14B8C4;         /* насыщенный акцент */
    --accent-2: #2BBAC6;
    --primary-rgb: 14, 156, 168;  /* #0E9CA8 для rgba(...) */
    --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
    --gradient-primary-hover: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
    --gradient-sidebar: linear-gradient(180deg, #1a1d29 0%, #16192b 100%);

    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1d29;
    --bg-sidebar-hover: rgba(255, 255, 255, 0.08);
    --bg-sidebar-active: rgba(var(--primary-rgb), 0.2);
    --bg-navbar: #1a1d29;

    --text-primary: #1a202c;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-sidebar: #8b95a5;
    --text-sidebar-hover: #ffffff;
    --text-sidebar-active: var(--primary);

    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);

    --border-color: #e2e8f0;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.06), 0 4px 10px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.08);

    --transition: all 0.2s ease;
    --transition-slow: all 0.3s ease;
}

/* ---- Base ---- */
body {
    background: var(--bg-body);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-primary);
}

/* Brand accent for native controls (date picker, checkboxes, radios, range) */
html { accent-color: var(--primary); }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- Navbar ---- */
.navbar-main {
    background: var(--bg-navbar);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 0.65rem 1.5rem;
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 1050;
}

.navbar-main .navbar-brand {
    font-weight: 800;
    letter-spacing: 0.5px;
    font-size: 1.3rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.navbar-main .badge-role {
    background: rgba(var(--primary-rgb), 0.2);
    color: var(--primary-light);
    font-weight: 500;
    font-size: 0.72rem;
    padding: 0.3em 0.65em;
    border-radius: 6px;
}

.navbar-main .user-info {
    color: #c1c8d4;
    font-size: 0.875rem;
}

.navbar-main .btn-logout {
    color: #8b95a5;
    border-color: rgba(255, 255, 255, 0.1);
    transition: var(--transition);
}
.navbar-main .btn-logout:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.06);
}

/* ---- Sidebar ---- */
.sidebar {
    background: var(--gradient-sidebar);
    min-height: 100vh;
    height: 100vh;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-desktop-width);
    overflow: visible;
    z-index: 1500;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 0.35rem 1rem 0.3rem;
    flex-shrink: 0;
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    color: #ffffff;
    font-weight: 800;
    font-size: 1.18rem;
    letter-spacing: 0.02em;
}

.sidebar-brand-link i {
    color: var(--primary-light);
    font-size: 1.15rem;
}

.sidebar-brand-subtitle {
    margin-top: 0.35rem;
    font-size: 0.74rem;
    line-height: 1.35;
    color: #7f8a9b;
}

.sidebar-menu {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: clip;
    padding: 0.85rem 0 13.5rem;
}

.nav-item-divider {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 0.4rem;
    padding-bottom: 0.4rem;
}
body.sidebar-collapsed .sidebar-menu {
    overflow-x: visible;
}

.sidebar-footer {
    position: fixed;
    left: 0;
    bottom: 0;
    width: var(--sidebar-desktop-width);
    flex-shrink: 0;
    padding: 0.85rem 0.9rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: #0d101c;
    z-index: 1510;
}

.sidebar-user-meta {
    margin-bottom: 0.75rem;
    padding: 0.62rem 0.68rem;
    border-radius: var(--border-radius-sm);
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.065);
}

.sidebar-user-name {
    color: #f8fafc;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-role {
    margin-top: 0.15rem;
    color: #a8b3c4;
    font-size: 0.76rem;
    line-height: 1.3;
}

.sidebar-footer-link {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.7rem;
    margin-bottom: 0.7rem;
    border-radius: var(--border-radius-sm);
    background: rgba(255, 255, 255, 0.04);
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.83rem;
    font-weight: 500;
}

.sidebar-footer-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.sidebar-monitor-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    margin: 2px 10px 0.65rem;
    border-radius: var(--border-radius-sm);
    background: rgba(var(--primary-rgb), 0.14);
    border: 1px solid rgba(var(--primary-rgb), 0.22);
    color: var(--primary-light);
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sidebar-monitor-link:hover {
    background: rgba(var(--primary-rgb), 0.24);
    border-color: rgba(var(--primary-rgb), 0.38);
    color: var(--primary-light);
}
.sidebar-monitor-link.active {
    background: rgba(var(--primary-rgb), 0.28);
    border-color: rgba(var(--primary-rgb), 0.45);
    color: var(--primary-light);
}

.sidebar-footer-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.sidebar-footer-button {
    width: 100%;
    justify-content: center;
}

.sidebar-footer .btn-logout.sidebar-footer-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.2rem;
    color: #f1f5f9;
    border: 1px solid rgba(226, 232, 240, 0.18);
    background: rgba(255, 255, 255, 0.075);
    font-weight: 600;
}

.sidebar-footer .btn-logout.sidebar-footer-button:hover {
    color: #ffffff;
    border-color: rgba(226, 232, 240, 0.28);
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-footer .btn-impersonate.sidebar-footer-button,
.sidebar-footer .btn-impersonate-stop {
    min-height: 2.2rem;
    color: #cbd5e1;
    border: 1px solid rgba(226, 232, 240, 0.13);
    background: rgba(255, 255, 255, 0.035);
    font-weight: 600;
}

.sidebar-footer .btn-impersonate.sidebar-footer-button:hover,
.sidebar-footer .btn-impersonate-stop:hover {
    color: #ffffff;
    border-color: rgba(226, 232, 240, 0.24);
    background: rgba(255, 255, 255, 0.085);
}

/* ── Sidebar footer v2 (карточки) ─────────────────────────────────────────── */
.sf-cabinet {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.65rem;
    margin-bottom: 0.5rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.07);
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}
.sf-cabinet:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.13); }
.sf-cabinet-ic {
    flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255, 255, 255, 0.06); color: #aebbcf; font-size: 0.95rem;
}
.sf-cabinet-name {
    flex: 1 1 auto; min-width: 0; font-size: 0.86rem; font-weight: 600; color: #e6ebf3;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sf-cabinet-chevron { flex: 0 0 auto; color: #7c8aa3; font-size: 0.95rem; }

.sf-user {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.5rem 0.55rem; margin-bottom: 0.5rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.045);
    border: 1px solid rgba(255, 255, 255, 0.07);
}
.sf-user--impersonating { border-color: rgba(245, 164, 23, 0.4); background: rgba(245, 164, 23, 0.08); }
.sf-avatar {
    flex: 0 0 auto; width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(var(--primary-rgb), 0.18); color: var(--primary-light);
    font-weight: 700; font-size: 1rem;
}
.sf-user-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.sf-user-name {
    font-size: 0.88rem; font-weight: 700; color: #f1f5f9;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sf-user-role { font-size: 0.76rem; color: #9aa6b8; line-height: 1.2; margin-top: 1px; }
.sf-user-menu { flex: 0 0 auto; }
.sf-user-menu-btn {
    width: 30px; height: 30px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: transparent; color: #8593a8; font-size: 1.05rem; cursor: pointer;
}
.sf-user-menu-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.sf-user-dropdown { max-height: 60vh; overflow-y: auto; }

.sf-actions { display: flex; align-items: stretch; gap: 0.5rem; }
.sf-action-form { flex: 1 1 auto; display: flex; }
.sf-logout {
    flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 0.3rem;
    min-height: 2.5rem; border-radius: 12px;
    color: #f1f5f9; border: 1px solid rgba(226, 232, 240, 0.16); background: rgba(255, 255, 255, 0.07);
    font-size: 0.85rem; font-weight: 600; cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.sf-logout:hover { color: #fff; border-color: rgba(226, 232, 240, 0.28); background: rgba(255, 255, 255, 0.12); }

/* Колокол как квадратная кнопка в ряду действий */
.sf-actions .notif-bell { flex: 0 0 auto; }
.sf-actions .notif-bell .btn-notif {
    width: 2.6rem; height: 2.5rem; border-radius: 12px;
    background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.08);
    color: #aebbcf; display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.sf-actions .notif-bell .btn-notif:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.sf-actions .notif-bell .notif-badge { top: 5px; right: 5px; }

/* Свёрнутый сайдбар — только иконки */
body.sidebar-collapsed .sf-cabinet-name,
body.sidebar-collapsed .sf-cabinet-chevron,
body.sidebar-collapsed .sf-user-info,
body.sidebar-collapsed .sf-user-menu { display: none; }
body.sidebar-collapsed .sf-cabinet,
body.sidebar-collapsed .sf-user { justify-content: center; padding: 0.45rem; gap: 0; }
body.sidebar-collapsed .sf-actions { flex-direction: column; }
body.sidebar-collapsed .sf-logout { font-size: 0; gap: 0; min-height: 2.4rem; }
body.sidebar-collapsed .sf-logout i { font-size: 1.1rem; margin: 0 !important; }
body.sidebar-collapsed .sf-actions .notif-bell .btn-notif { width: 100%; }

.sidebar .nav-link {
    color: var(--text-sidebar);
    padding: 0.55rem 1.1rem;
    border-radius: var(--border-radius-sm);
    margin: 1px 10px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar .nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-sidebar-hover);
}

.sidebar .nav-link.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    font-weight: 600;
}

.sidebar .nav-link i {
    width: 20px;
    font-size: 1rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar .nav-section {
    color: #505a6b;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    padding: 1rem 1.2rem 0.35rem;
    margin-top: 0.25rem;
}

/* ---- Sidebar Collapsible Groups ---- */
.sidebar .sidebar-group {
    margin: 2px 0;
}

.sidebar .sidebar-group-toggle {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.84rem;
    color: #a0aab8;
    padding: 0.6rem 1.1rem;
    border-radius: var(--border-radius-sm);
    margin: 1px 10px;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: var(--transition);
    text-decoration: none;
}

.sidebar .sidebar-group-toggle:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-sidebar-hover);
}

.sidebar .sidebar-group-toggle.open {
    color: #c8d0dc;
}

.sidebar .sidebar-group-toggle .chevron {
    font-size: 0.65rem;
    transition: none;
    width: auto;
}

.sidebar .sidebar-group-toggle[aria-expanded="true"] .chevron,
.sidebar .sidebar-group-toggle.open:not(.collapsed) .chevron {
    transform: rotate(90deg);
}

.sidebar .sidebar-group-toggle.collapsed .chevron {
    transform: rotate(0deg);
}

.sidebar .sidebar-sub-items {
    padding-left: 0;
    margin-left: 1.65rem;
    border-left: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar .sidebar-sub-items .nav-link {
    font-size: 0.82rem;
    padding: 0.4rem 1rem 0.4rem 1rem;
    margin: 0 10px;
    color: var(--text-sidebar);
}

.sidebar .sidebar-sub-items .nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-sidebar-hover);
}

.sidebar .sidebar-sub-items .nav-link.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    font-weight: 600;
}

.sidebar .sidebar-sub-items .nav-link i {
    width: 18px;
    font-size: 0.88rem;
}

/* ── Level-3 nested sub-group toggle ── */
.sidebar .sidebar-sub-items .sidebar-sub-group-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    cursor: pointer;
    text-align: left;
    padding: 0;
    outline: none;
}
.sidebar .sidebar-sub-items .sidebar-sub-group-toggle .chevron {
    font-size: 0.6rem;
    transition: transform 0.2s;
}
.sidebar .sidebar-sub-items .sidebar-sub-group-toggle.open .chevron {
    transform: rotate(90deg);
}

/* ── Level-3 panel (mobile: inline, desktop: floating) ── */
.sidebar .sidebar-sub-submenu {
    display: none;
    padding-left: 0;
    margin-left: 1.4rem;
    border-left: 1px solid rgba(255,255,255,0.05);
}
.sidebar .sidebar-sub-submenu.show {
    display: block;
}

.sidebar .sidebar-sub-sub-items {
    padding-left: 0;
}
.sidebar .sidebar-sub-sub-items .nav-link {
    font-size: 0.78rem;
    padding: 0.28rem 0.8rem;
    margin: 0 8px;
    color: var(--text-sidebar);
    opacity: 0.8;
}
.sidebar .sidebar-sub-sub-items .nav-link:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-sidebar-hover);
    opacity: 1;
}
.sidebar .sidebar-sub-sub-items .nav-link.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    font-weight: 600;
    opacity: 1;
}

@media (min-width: 768px) {
    .sidebar .sidebar-sub-submenu {
        position: fixed;
        top: -9999px;
        left: -9999px;
        margin-left: 0;
        border-left: none;
        min-width: 210px;
        max-width: 300px;
        padding: 0.45rem 0;
        background: #16192b;
        border: 1px solid rgba(255,255,255,0.08);
        border-radius: var(--border-radius-sm);
        box-shadow: var(--shadow-xl);
        z-index: 3100;
        overflow-y: auto;
    }
    .sidebar .sidebar-sub-sub-items .nav-link {
        white-space: nowrap;
        opacity: 1;
        padding: 0.5rem 0.9rem;
    }
}

@media (min-width: 768px) {
    .sidebar .sidebar-group {
        position: relative;
    }

    .sidebar .sidebar-submenu {
        position: fixed;
        top: var(--sidebar-submenu-top, 0px);
        left: var(--sidebar-submenu-left, var(--sidebar-desktop-width));
        min-width: 220px;
        max-width: min(360px, calc(100vw - var(--sidebar-submenu-left, var(--sidebar-desktop-width)) - 24px));
        max-height: calc(100vh - 24px);
        overflow-y: auto;
        padding: 0.45rem 0;
        background: #16192b;
        border: 1px solid rgba(255, 255, 255, 0.08);
        border-radius: var(--border-radius-sm);
        box-shadow: var(--shadow-xl);
        z-index: 3000;
    }

    .sidebar .sidebar-submenu:not(.show) {
        display: none;
    }

    .sidebar .sidebar-submenu.show {
        display: block;
    }

    .sidebar .sidebar-submenu.collapsing {
        display: block;
        height: auto !important;
        overflow: hidden;
        transition: none;
    }

    .sidebar .sidebar-sub-items {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
    }

    .sidebar .sidebar-sub-items .nav-link {
        margin: 0 8px;
        padding: 0.55rem 0.9rem;
        white-space: nowrap;
    }
}

/* ══════════════════════════════════════════════
   Sidebar collapsed state
   ══════════════════════════════════════════════ */

/* Toggle button — floats on the right edge of the sidebar */
.sidebar-toggle-btn {
    position: absolute;
    top: 50%;
    right: -11px;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    background: var(--primary);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    z-index: 1600;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
    transition: background 0.15s, opacity 0.15s;
    opacity: 0;
    pointer-events: none;
}
.sidebar:hover .sidebar-toggle-btn {
    opacity: 1;
    pointer-events: auto;
}
body.sidebar-collapsed .sidebar .sidebar-toggle-btn {
    opacity: 1;
    pointer-events: auto;
}
.sidebar-toggle-btn:hover { background: var(--primary-dark); }

/* Mini logo (hidden by default) */
.sidebar-logo-mini { display: none; }
.sidebar-logo-full { display: block; }

/* ── Collapsed layout ── */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
}
body.sidebar-collapsed .sidebar-footer {
    width: var(--sidebar-collapsed-width);
    padding: 0.75rem 0.25rem;
}
@media (min-width: 768px) {
    body.sidebar-collapsed .main-content {
        margin-left: var(--sidebar-collapsed-width);
        width: calc(100% - var(--sidebar-collapsed-width));
    }
}

/* Brand */
body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: 0.75rem 0.5rem;
}
body.sidebar-collapsed .sidebar-logo-full { display: none; }
body.sidebar-collapsed .sidebar-logo-mini { display: block; }

/* Nav links: icon-only */
body.sidebar-collapsed .sidebar .nav-link {
    justify-content: center;
    padding: 0.6rem 0;
    margin: 1px 4px;
    font-size: 0;
    gap: 0;
}
body.sidebar-collapsed .sidebar .nav-link i {
    font-size: 1.15rem;
    width: auto;
}

/* Group toggles: icon-only */
body.sidebar-collapsed .sidebar .sidebar-group-toggle {
    justify-content: center;
    padding: 0.6rem 0;
    margin: 1px 4px;
    font-size: 0;
    gap: 0;
}
body.sidebar-collapsed .sidebar .sidebar-group-toggle i:not(.chevron) {
    font-size: 1.15rem;
    width: auto;
}
body.sidebar-collapsed .sidebar .sidebar-group-toggle .chevron {
    display: none;
}

/* Submenu links stay full (icon + text) even in collapsed mode */
body.sidebar-collapsed .sidebar .sidebar-submenu .nav-link {
    justify-content: flex-start;
    padding: 0.55rem 0.9rem;
    margin: 0 8px;
    font-size: 0.82rem;
    gap: 0.6rem;
}
body.sidebar-collapsed .sidebar .sidebar-submenu .nav-link i {
    font-size: 0.88rem;
    width: 18px;
}

/* Tooltip on hover (collapsed mode) */
body.sidebar-collapsed .sidebar [data-nav-title] {
    position: relative;
    overflow: visible;
}
body.sidebar-collapsed .sidebar [data-nav-title]:hover::after {
    content: attr(data-nav-title);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e2130;
    color: #f1f5f9;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    white-space: nowrap;
    font-size: 0.82rem;
    font-weight: 500;
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
    z-index: 9999;
    border: 1px solid rgba(255,255,255,0.1);
    pointer-events: none;
}

/* Footer collapsed */
body.sidebar-collapsed .sidebar-user-meta { display: none; }
body.sidebar-collapsed .sidebar-footer-link span { display: none; }
body.sidebar-collapsed .sidebar-footer-link {
    justify-content: center;
    padding: 0.5rem;
    margin-bottom: 0.4rem;
}
body.sidebar-collapsed .sidebar-footer-actions {
    flex-direction: column;
    gap: 4px;
}
body.sidebar-collapsed .sidebar-footer-button {
    padding: 0.45rem 0;
    font-size: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
body.sidebar-collapsed .sidebar-footer-button i {
    font-size: 1rem;
    margin: 0 !important;
}

/* ── End collapsed state ── */

/* ---- Main Content ---- */
.main-content {
    min-height: 100vh;
    padding: 1.75rem 2rem;
}

@media (min-width: 768px) {
    .main-content {
        margin-left: var(--sidebar-desktop-width);
    }
}

@media (max-width: 991px) {
    .main-content { padding: 1rem; }
}

/* ---- Cards ---- */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    background: var(--bg-card);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.card-body { padding: 1.25rem; }

/* ---- Stat Cards ---- */
.stat-card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
    position: relative;
}

.stat-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ---- Page Header ---- */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h4 {
    font-weight: 700;
    font-size: 1.35rem;
    color: var(--text-primary);
    margin: 0;
}

.page-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* ---- Buttons ---- */
.btn-gradient {
    background: var(--gradient-primary);
    border: none;
    color: white;
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.35);
}

.btn-gradient:hover {
    background: var(--gradient-primary-hover);
    color: white;
    box-shadow: 0 4px 14px rgba(var(--primary-rgb), 0.45);
    transform: translateY(-1px);
}

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

.btn-gradient-sm {
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
}

.btn-soft-primary {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
    border: none;
    font-weight: 500;
}
.btn-soft-primary:hover {
    background: rgba(var(--primary-rgb), 0.2);
    color: var(--primary-dark);
}

.btn-soft-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: none;
}
.btn-soft-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #dc2626;
}

.btn-soft-success {
    background: var(--success-bg);
    color: var(--success);
    border: none;
}
.btn-soft-success:hover {
    background: rgba(34, 197, 94, 0.2);
    color: #16a34a;
}

.btn-soft-warning {
    background: var(--warning-bg);
    color: #d97706;
    border: none;
}
.btn-soft-warning:hover {
    background: rgba(245, 158, 11, 0.2);
    color: #b45309;
}

/* ---- Tables ---- */
.table {
    font-size: 0.875rem;
}

.table thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.85rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background: #f8fafc;
}

/* ---- Badges ---- */
.badge {
    font-weight: 600;
    font-size: 0.73rem;
    padding: 0.35em 0.7em;
    border-radius: 6px;
}

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

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

.badge-success-soft {
    background: var(--success-bg);
    color: #16a34a;
}
.badge-success-soft::before { background: var(--success); }

.badge-warning-soft {
    background: var(--warning-bg);
    color: #d97706;
}
.badge-warning-soft::before { background: var(--warning); }

.badge-danger-soft {
    background: var(--danger-bg);
    color: #dc2626;
}
.badge-danger-soft::before { background: var(--danger); }

.badge-info-soft {
    background: var(--info-bg);
    color: #2563eb;
}
.badge-info-soft::before { background: var(--info); }

.badge-secondary-soft {
    background: #f1f5f9;
    color: #64748b;
}
.badge-secondary-soft::before { background: #94a3b8; }

.badge-dark-soft {
    background: rgba(30, 41, 59, 0.1);
    color: #1e293b;
}

/* ---- Document Status Pill ---- */
/* Compact attribute-style indicator: soft bg + dot, no border, no shadow */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    padding: 0.18rem 0.52rem;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: 0.01em;
    white-space: nowrap;
    border: none;
    box-shadow: none;
}
.status-pill::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-pill--success  { background: rgba(34,197,94,.11);   color: #15803d; }
.status-pill--success::before  { background: #22c55e; }

.status-pill--warning  { background: rgba(245,158,11,.11);  color: #92400e; }
.status-pill--warning::before  { background: #f59e0b; }

.status-pill--danger   { background: rgba(239,68,68,.11);   color: #b91c1c; }
.status-pill--danger::before   { background: #ef4444; }

.status-pill--info     { background: rgba(59,130,246,.11);  color: #1d4ed8; }
.status-pill--info::before     { background: #3b82f6; }

.status-pill--secondary { background: rgba(148,163,184,.13); color: #475569; }
.status-pill--secondary::before { background: #94a3b8; }

.status-pill--primary  { background: rgba(var(--primary-rgb),.11);  color: var(--primary-dark); }
.status-pill--primary::before  { background: var(--accent); }

/* ---- Progress Bars ---- */
.progress {
    border-radius: 20px;
    background: #e2e8f0;
    overflow: hidden;
}

.progress-bar {
    border-radius: 20px;
    transition: width 0.6s ease;
}

.progress-bar-gradient {
    background: var(--gradient-primary);
}

/* ---- Forms ---- */
.form-control, .form-select {
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    transition: var(--transition);
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.input-group-text {
    background: #f8fafc;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
}

/* ---- Alerts ---- */
.alert {
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-info {
    background: var(--info-bg);
    color: #1e40af;
}

.alert-success {
    background: var(--success-bg);
    color: #166534;
}

.alert-warning {
    background: var(--warning-bg);
    color: #92400e;
}

.alert-danger {
    background: var(--danger-bg);
    color: #991b1b;
}

/* ---- Toast notifications (fixed overlay, doesn't push content) ---- */
.toast-stack {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 340px;
    width: max-content;
}
.toast-msg {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: .82rem;
    line-height: 1.4;
    box-shadow: 0 4px 16px rgba(0,0,0,.10);
    border: 1px solid transparent;
}
.toast-body { flex: 1; }
.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    opacity: .55;
    flex-shrink: 0;
    margin-top: 1px;
}
.toast-close:hover { opacity: 1; }
.toast-info    { background: var(--info-bg);    color: #1e40af; border-color: #bfdbfe; }
.toast-success { background: var(--success-bg); color: #166534; border-color: #bbf7d0; }
.toast-warning { background: var(--warning-bg); color: #92400e; border-color: #fde68a; }
.toast-danger,
.toast-error   { background: var(--danger-bg);  color: #991b1b; border-color: #fecaca; }

/* ---- List Groups (inside cards) ---- */
.list-group-item {
    border-color: #f1f5f9;
    transition: var(--transition);
    padding: 0.85rem 1.25rem;
}

.list-group-item-action:hover {
    background: #f8fafc;
}

/* ---- Delete confirmation ---- */
.delete-card {
    border: 2px solid var(--danger-bg);
}

.delete-card .delete-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--danger-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

/* ---- Map containers ---- */
.map-container {
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

/* ---- Mobile bottom nav ---- */
.mobile-nav {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
    padding: 0.5rem 0;
}

.mobile-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.mobile-nav a:hover,
.mobile-nav a.active {
    color: var(--primary);
}

/* ---- Filters bar ---- */
.filter-bar {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 0.75rem 1.25rem;
}

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

.fade-in-up {
    animation: fadeInUp 0.3s ease both;
}

/* ---- Login Page ---- */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1d29 0%, #2d1b69 50%, #1a1d29 100%);
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(var(--primary-rgb), 0.15) 0%, transparent 70%);
    top: -200px;
    right: -200px;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(118, 75, 162, 0.12) 0%, transparent 70%);
    bottom: -150px;
    left: -100px;
}

.login-card {
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    position: relative;
    z-index: 1;
}

.login-brand-icon {
    width: 72px;
    height: 72px;
    background: var(--gradient-primary);
    border-radius: var(--border-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    box-shadow: 0 8px 20px rgba(var(--primary-rgb), 0.3);
}

/* ---- Empty State ---- */
.empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

/* ---- Pagination ---- */
.pagination .page-link {
    border: none;
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    margin: 0 2px;
    padding: .4rem .7rem;
}
.pagination .page-item.active .page-link {
    background: var(--gradient-primary);
    color: #fff;
}
.pagination .page-link:hover {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

/* ---- Badge: light (for draft status) ---- */
.badge-light-soft {
    background: #f1f5f9;
    color: #475569;
}
.badge-light-soft::before { background: #94a3b8; }

/* ---- Responsive ---- */
@media (max-width: 767px) {
    .sidebar {
        position: relative;
        width: auto;
        min-height: auto;
        height: auto;
    }
    .sidebar-footer {
        position: static;
        width: auto;
    }
    .main-content { padding: 1rem; padding-bottom: 5rem; }
    .stat-card .stat-value { font-size: 1.4rem; }
    .page-header h4 { font-size: 1.15rem; }
}

/* ---- Utility ---- */
.rounded-xl { border-radius: var(--border-radius-lg) !important; }
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ---- Impersonation ---- */
.btn-impersonate {
    color: #8b95a5;
    border-color: rgba(255, 255, 255, 0.1);
    transition: var(--transition);
}
.btn-impersonate:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.06);
}
.btn-impersonate-stop {
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.3);
    transition: var(--transition);
}
.btn-impersonate-stop:hover {
    color: #fff;
    background: rgba(251, 191, 36, 0.2);
    border-color: rgba(251, 191, 36, 0.5);
}
.impersonate-indicator {
    color: #fbbf24;
    font-size: 0.78rem;
    font-weight: 600;
    animation: impersonatePulse 2s ease-in-out infinite;
}
@keyframes impersonatePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
.impersonate-banner {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    text-align: center;
    padding: 0.4rem 1rem;
    font-size: 0.82rem;
    font-weight: 500;
}
.impersonate-banner .btn-light {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════
   DatePicker component
   ═══════════════════════════════════════════════════════════════ */

.dp-wrapper {
    position: relative;
    display: block;
    width: 100%;
}

.dp-input-row {
    position: relative;
    display: flex;
    align-items: center;
}

.dp-display {
    padding-right: 2.4rem !important;
    cursor: pointer !important;
    background-color: #fff !important;
    caret-color: transparent;
}
.dp-display:focus { outline: none; box-shadow: 0 0 0 3px rgba(var(--primary-rgb),0.15); border-color: var(--primary); }

.dp-icon {
    position: absolute;
    right: 0.65rem;
    color: #94A3B8;
    font-size: 0.88rem;
    pointer-events: none;
    line-height: 1;
}

.dp-clear-btn {
    position: absolute;
    right: 1.9rem;
    background: none;
    border: none;
    color: #94A3B8;
    font-size: 1rem;
    line-height: 1;
    padding: 0 3px;
    cursor: pointer;
    z-index: 1;
}
.dp-clear-btn:hover { color: #475569; }

/* ── Popup ── */
.dp-popup {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1060;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(226, 232, 240, 0.9);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.06);
    padding: 14px;
    min-width: 248px;
    user-select: none;
}
.dp-popup--range {
    min-width: 520px;
}

/* ── Two-calendar layout ── */
.dp-calendars {
    display: flex;
    gap: 16px;
}
.dp-calendar { flex: 1; min-width: 0; }

/* ── Navigation ── */
.dp-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 4px;
}
.dp-nav-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 6px;
    color: #475569;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.1s, border-color 0.1s;
}
.dp-nav-btn:hover { background: #F1F5F9; border-color: #CBD5E1; }
.dp-month-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: #0F172A;
    text-align: center;
    flex: 1;
}

/* ── Weekday headers ── */
.dp-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 3px;
}
.dp-weekdays span {
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 0;
}

/* ── Day grid ── */
.dp-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}

.dp-day {
    aspect-ratio: 1;
    width: 100%;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #0F172A;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s, color 0.1s;
    padding: 0;
}
.dp-day:hover:not(:disabled) { background: #F1F5F9; }

.dp-day--other   { color: #CBD5E1; }
.dp-day--today   { color: var(--primary); font-weight: 800; }
.dp-day--disabled { color: #E2E8F0; cursor: not-allowed; }

/* selected single / range endpoints */
.dp-day--selected {
    background: var(--primary) !important;
    color: #fff !important;
    font-weight: 700;
}
.dp-day--selected:hover { background: var(--primary-dark) !important; }

/* range start/end rounding */
.dp-day--range-start { border-radius: 6px 2px 2px 6px; }
.dp-day--range-end   { border-radius: 2px 6px 6px 2px; }
.dp-day--range-start.dp-day--range-end { border-radius: 6px; }

/* in-range fill */
.dp-day--in-range {
    background: rgba(var(--primary-rgb), 0.1) !important;
    border-radius: 0;
    color: #0F172A;
}

/* hover preview (before end is picked) */
.dp-day--in-preview {
    background: rgba(var(--primary-rgb), 0.06) !important;
    border-radius: 0;
}
.dp-day--hover-end {
    background: rgba(var(--primary-rgb), 0.2) !important;
    border-radius: 2px 6px 6px 2px;
    color: #fff;
}

/* ── Month mode ── */
.dp-popup--month { min-width: 240px; }
.dp-months {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 8px;
}
.dp-month-cell {
    border: none;
    background: transparent;
    border-radius: 6px;
    padding: 10px 0;
    font-size: 0.82rem;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    transition: background 0.12s;
}
.dp-month-cell:hover:not(:disabled) { background: #F1F5F9; }
.dp-month-cell--today { color: var(--primary); font-weight: 800; }
.dp-month-cell--selected {
    background: var(--primary) !important;
    color: #fff !important;
    font-weight: 700;
}
.dp-month-cell--selected:hover { background: var(--primary-dark) !important; }
.dp-month-cell--disabled { color: #E2E8F0; cursor: not-allowed; }
