/*
 * Attendex Payroll — Design System v2
 * White / Violet / Purple, light + dark, desktop · tablet · mobile.
 * Loaded after Bootstrap 5.3 (grid + utilities) and Bootstrap Icons.
 */

/* ==========================================================================
   1. Tokens
   ========================================================================== */
:root,
[data-theme="light"] {
    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;

    --violet-50:  #F5F3FF;
    --violet-100: #EDE9FE;
    --violet-200: #DDD6FE;
    --violet-300: #C4B5FD;
    --violet-400: #A78BFA;
    --violet-500: #8B5CF6;
    --violet-600: #7C3AED;
    --violet-700: #6D28D9;
    --violet-800: #5B21B6;
    --violet-900: #4C1D95;
    --purple-500: #A855F7;
    --purple-600: #9333EA;

    --primary: var(--violet-600);
    --primary-hover: var(--violet-700);
    --primary-dark: var(--violet-800);
    --primary-light: var(--violet-50);
    --primary-soft: var(--violet-100);
    --primary-ring: rgba(124, 58, 237, 0.22);
    --primary-gradient: linear-gradient(135deg, #7C3AED 0%, #9333EA 55%, #A855F7 100%);

    --success: #059669;  --success-light: #ECFDF5;  --success-border: #A7F3D0;
    --danger:  #DC2626;  --danger-light:  #FEF2F2;  --danger-border:  #FECACA;
    --warning: #D97706;  --warning-light: #FFFBEB;  --warning-border: #FDE68A;
    --info:    #2563EB;  --info-light:    #EFF6FF;  --info-border:    #BFDBFE;

    --bg-body: #F7F6FB;
    --bg-surface: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-surface-header: #FAF9FD;
    --bg-subtle: #F3F1F9;
    --bg-hover: #F5F3FF;
    --bg-input: #FFFFFF;

    --text-heading: #17132B;
    --text-main: #2E2A42;
    --text-body: #2E2A42;
    --text-muted: #6B6785;
    --text-faint: #9A97AF;

    --border-color: #E7E4F0;
    --border-strong: #D6D2E4;

    --white: #FFFFFF;
    --gray-50:  #FAF9FD;
    --gray-100: #F3F1F9;
    --gray-200: #E7E4F0;
    --gray-300: #D6D2E4;
    --gray-400: #A9A5BE;
    --gray-500: #6B6785;
    --gray-700: #3E3A55;
    --gray-900: #17132B;

    --sidebar-bg: #FFFFFF;
    --sidebar-border: #EEEBF5;
    --sidebar-text: #4A4663;
    --sidebar-muted: #9A97AF;
    --sidebar-hover-bg: #F5F3FF;
    --sidebar-active-bg: var(--primary-gradient);
    --sidebar-active-text: #FFFFFF;

    --header-bg: rgba(255, 255, 255, 0.82);

    --radius-sm: 8px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    --shadow-xs: 0 1px 2px rgba(23, 19, 43, 0.05);
    --shadow-sm: 0 1px 3px rgba(23, 19, 43, 0.06), 0 1px 2px rgba(23, 19, 43, 0.04);
    --shadow-md: 0 6px 16px -4px rgba(23, 19, 43, 0.08), 0 2px 4px rgba(23, 19, 43, 0.04);
    --shadow-lg: 0 20px 40px -12px rgba(46, 16, 101, 0.22);
    --shadow-primary: 0 6px 16px -4px rgba(124, 58, 237, 0.45);
    --card-shadow: var(--shadow-sm);
    --shadow-color: rgba(23, 19, 43, 0.08);

    --sidebar-w: 264px;
    --sidebar-rail-w: 76px;
    --header-h: 64px;
    --bottomnav-h: 64px;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);

    color-scheme: light;
}

[data-theme="dark"] {
    --primary: #A78BFA;
    --primary-hover: #C4B5FD;
    --primary-dark: #8B5CF6;
    --primary-light: rgba(167, 139, 250, 0.12);
    --primary-soft: rgba(167, 139, 250, 0.2);
    --primary-ring: rgba(167, 139, 250, 0.3);
    --primary-gradient: linear-gradient(135deg, #7C3AED 0%, #9333EA 55%, #A855F7 100%);

    --success: #34D399;  --success-light: rgba(52, 211, 153, 0.12);  --success-border: rgba(52, 211, 153, 0.3);
    --danger:  #F87171;  --danger-light:  rgba(248, 113, 113, 0.12); --danger-border:  rgba(248, 113, 113, 0.3);
    --warning: #FBBF24;  --warning-light: rgba(251, 191, 36, 0.12);  --warning-border: rgba(251, 191, 36, 0.3);
    --info:    #60A5FA;  --info-light:    rgba(96, 165, 250, 0.12);  --info-border:    rgba(96, 165, 250, 0.3);

    --bg-body: #0D0A16;
    --bg-surface: #16121F;
    --bg-card: #16121F;
    --bg-surface-header: #1B1626;
    --bg-subtle: #1E1929;
    --bg-hover: rgba(167, 139, 250, 0.08);
    --bg-input: #120F1B;

    --text-heading: #F4F2FA;
    --text-main: #D6D2E4;
    --text-body: #D6D2E4;
    --text-muted: #9A95B0;
    --text-faint: #6E6984;

    --border-color: #2A2438;
    --border-strong: #3A3349;

    --white: #16121F;
    --gray-50:  #1B1626;
    --gray-100: #1E1929;
    --gray-200: #2A2438;
    --gray-300: #3A3349;
    --gray-400: #6E6984;
    --gray-500: #9A95B0;
    --gray-700: #D6D2E4;
    --gray-900: #F4F2FA;

    --sidebar-bg: #120F1B;
    --sidebar-border: #221D2F;
    --sidebar-text: #B8B3CB;
    --sidebar-muted: #6E6984;
    --sidebar-hover-bg: rgba(167, 139, 250, 0.08);

    --header-bg: rgba(18, 15, 27, 0.8);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 8px 20px -6px rgba(0, 0, 0, 0.55);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.7);
    --shadow-primary: 0 6px 18px -4px rgba(124, 58, 237, 0.55);
    --card-shadow: var(--shadow-sm);
    --shadow-color: rgba(0, 0, 0, 0.5);

    color-scheme: dark;
}

/* Bootstrap bridge — keep utilities (text-primary, bg-light, borders) on-palette */
:root, [data-theme="light"], [data-theme="dark"] {
    --bs-primary: var(--violet-600);
    --bs-primary-rgb: 124, 58, 237;
    --bs-secondary-rgb: 107, 103, 133;
    --bs-success-rgb: 5, 150, 105;
    --bs-danger-rgb: 220, 38, 38;
    --bs-warning-rgb: 217, 119, 6;
    --bs-info-rgb: 37, 99, 235;
    --bs-body-font-family: var(--font-sans);
    --bs-body-bg: var(--bg-body);
    --bs-body-color: var(--text-main);
    --bs-emphasis-color: var(--text-heading);
    --bs-secondary-color: var(--text-muted);
    --bs-tertiary-bg: var(--bg-subtle);
    --bs-border-color: var(--border-color);
    --bs-link-color: var(--primary);
    --bs-link-color-rgb: 124, 58, 237;
    --bs-link-hover-color: var(--primary-hover);
    --bs-heading-color: var(--text-heading);
    --bs-border-radius: var(--radius);
}
[data-theme="dark"] {
    --bs-primary-rgb: 167, 139, 250;
    --bs-link-color-rgb: 167, 139, 250;
    --bs-success-rgb: 52, 211, 153;
    --bs-danger-rgb: 248, 113, 113;
    --bs-warning-rgb: 251, 191, 36;
    --bs-info-rgb: 96, 165, 250;
}

/* ==========================================================================
   2. Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--text-main);
    background: var(--bg-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01';
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--text-heading);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
}
h1 { font-size: 1.6rem; } h2 { font-size: 1.35rem; } h3 { font-size: 1.15rem; }
h4 { font-size: 1.02rem; } h5 { font-size: 0.95rem; } h6 { font-size: 0.85rem; }

a { color: var(--primary); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--primary-hover); }

::selection { background: var(--violet-200); color: var(--violet-900); }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); background-clip: padding-box; border: 3px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

.text-muted { color: var(--text-muted) !important; }
.text-heading { color: var(--text-heading) !important; }
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.bg-primary { background: var(--primary) !important; }
.bg-primary-light { background-color: var(--primary-light) !important; }
.bg-light { background-color: var(--bg-subtle) !important; }
.bg-white { background-color: var(--bg-surface) !important; }
.border, .border-top, .border-bottom, .border-start, .border-end { border-color: var(--border-color) !important; }

/* Legacy helpers used across pages */
.align-center { align-items: center !important; }
.justify-center { justify-content: center !important; }
.justify-between { justify-content: space-between !important; }
.font-bold { font-weight: 700 !important; }
.font-medium { font-weight: 500 !important; }
.text-right { text-align: right !important; }
.text-left { text-align: left !important; }

/* ==========================================================================
   3. App shell
   ========================================================================== */
.app-wrapper { min-height: 100vh; min-height: 100dvh; }

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    transition: width .25s var(--ease), transform .3s var(--ease);
}

.sidebar-header {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem 0 1.25rem;
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: .7rem;
    color: var(--text-heading);
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
}
.sidebar-logo:hover { color: var(--text-heading); }
.brand-mark {
    width: 36px; height: 36px;
    flex-shrink: 0;
    border-radius: 11px;
    display: grid; place-items: center;
    background: var(--primary-gradient);
    color: #fff;
    font-size: 1.15rem;
    box-shadow: var(--shadow-primary);
}
.brand-text small {
    display: block;
    font-family: var(--font-sans);
    font-size: .68rem;
    font-weight: 600;
    color: var(--sidebar-muted);
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-top: -2px;
}

.sidebar-close {
    display: none;
    border: 0; background: transparent;
    color: var(--text-muted);
    width: 34px; height: 34px; border-radius: 8px;
    font-size: 1.2rem;
}
.sidebar-close:hover { background: var(--bg-hover); color: var(--primary); }

.sidebar-org {
    margin: .25rem 1rem .75rem;
    padding: .6rem .75rem;
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius);
    background: var(--bg-surface-header);
    display: flex; align-items: center; gap: .6rem;
    font-size: .8rem;
    overflow: hidden;
}
.sidebar-org .org-dot {
    width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
    display: grid; place-items: center;
    background: var(--primary-soft); color: var(--primary);
    font-weight: 700; font-size: .75rem;
}
.sidebar-org .org-name { font-weight: 600; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-org .org-sub { color: var(--text-faint); font-size: .7rem; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: .25rem .75rem 1rem;
    scrollbar-width: thin;
}

.nav-section { margin-bottom: .5rem; }
.nav-section-title {
    padding: .9rem .75rem .4rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--sidebar-muted);
    white-space: nowrap;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .75rem;
    margin: 2px 0;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    font-size: .875rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav-item i { font-size: 1.1rem; width: 20px; text-align: center; flex-shrink: 0; color: var(--sidebar-muted); transition: color .15s; }
.nav-item:hover { background: var(--sidebar-hover-bg); color: var(--primary); }
.nav-item:hover i { color: var(--primary); }
.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
    box-shadow: var(--shadow-primary);
}
.nav-item.active i { color: #fff; }
.nav-item .nav-badge {
    margin-left: auto;
    font-size: .68rem; font-weight: 700;
    padding: .1rem .45rem; border-radius: 999px;
    background: var(--primary-soft); color: var(--primary);
}
.nav-item.active .nav-badge { background: rgba(255,255,255,.25); color: #fff; }

.sidebar-footer {
    padding: .75rem;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}
.sidebar-user {
    display: flex; align-items: center; gap: .7rem;
    padding: .5rem; border-radius: var(--radius);
    overflow: hidden;
}
.sidebar-user .user-meta { min-width: 0; }
.sidebar-user .user-name { font-weight: 600; font-size: .85rem; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: .72rem; color: var(--text-muted); white-space: nowrap; }

.sidebar-collapse-btn {
    border: 1px solid var(--sidebar-border);
    background: var(--bg-surface);
    color: var(--text-muted);
    width: 30px; height: 30px; border-radius: 8px;
    display: grid; place-items: center;
    transition: all .15s;
}
.sidebar-collapse-btn:hover { color: var(--primary); border-color: var(--violet-300); }

.sidebar-backdrop {
    position: fixed; inset: 0; z-index: 1035;
    background: rgba(13, 10, 22, .45);
    backdrop-filter: blur(3px);
    opacity: 0; visibility: hidden;
    transition: opacity .25s var(--ease), visibility .25s;
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }

/* ── Main ── */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    transition: margin-left .25s var(--ease);
    min-width: 0;
}

.header {
    position: sticky; top: 0; z-index: 1030;
    height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem;
    padding: 0 1.75rem;
    background: var(--header-bg);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border-color);
}
.header-left, .header-right { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.header-left { flex: 1; }

.page-heading { min-width: 0; }
.page-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.breadcrumb-mini { font-size: .72rem; color: var(--text-faint); font-weight: 500; white-space: nowrap; }

.icon-btn, .menu-toggle {
    width: 38px; height: 38px;
    display: inline-grid; place-items: center;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all .15s var(--ease);
    position: relative;
    flex-shrink: 0;
}
.icon-btn:hover, .menu-toggle:hover { background: var(--bg-hover); color: var(--primary); }
.menu-toggle { display: none; }

.header-search {
    display: flex; align-items: center; gap: .5rem;
    height: 38px; width: 280px;
    padding: 0 .75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-faint);
    font-size: .85rem;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
}
.header-search:hover { border-color: var(--violet-300); box-shadow: 0 0 0 3px var(--primary-ring); }
.header-search span { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kbd {
    font-family: var(--font-sans);
    font-size: .68rem; font-weight: 600;
    padding: .1rem .4rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-subtle);
    color: var(--text-muted);
}

.user-avatar {
    width: 36px; height: 36px; border-radius: 10px;
    flex-shrink: 0;
    display: grid; place-items: center;
    background: var(--primary-gradient);
    color: #fff; font-weight: 700; font-size: .8rem;
    overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-dropdown { position: relative; }
.user-dropdown-toggle {
    display: flex; align-items: center; gap: .6rem;
    padding: .25rem .5rem .25rem .25rem;
    border: 1px solid transparent; border-radius: 12px;
    background: transparent; cursor: pointer;
    color: var(--text-main);
    transition: all .15s;
}
.user-dropdown-toggle:hover { background: var(--bg-hover); }
.user-dropdown-toggle .user-name { font-size: .82rem; font-weight: 600; color: var(--text-heading); line-height: 1.2; text-align: left; }
.user-dropdown-toggle .user-role { font-size: .7rem; color: var(--text-muted); text-align: left; }

/* Popover menus (user menu + any .dropdown-menu used by pages) */
.dropdown-menu, .popover-menu {
    position: absolute; top: calc(100% + 8px); right: 0;
    min-width: 230px;
    padding: .4rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1060;
    opacity: 0; visibility: hidden;
    transform: translateY(-6px) scale(.98);
    transform-origin: top right;
    transition: opacity .15s var(--ease), transform .15s var(--ease), visibility .15s;
    display: block;
}
.dropdown-menu.show, .popover-menu.show { opacity: 1; visibility: visible; transform: none; }
.dropdown-menu a, .dropdown-menu button.menu-link, .popover-menu a {
    display: flex; align-items: center; gap: .65rem;
    width: 100%;
    padding: .55rem .7rem;
    border: 0; background: none;
    border-radius: 8px;
    color: var(--text-main);
    font-size: .85rem; font-weight: 500;
    text-align: left;
}
.dropdown-menu a i, .popover-menu a i { color: var(--text-muted); font-size: 1rem; }
.dropdown-menu a:hover, .popover-menu a:hover { background: var(--bg-hover); color: var(--primary); }
.dropdown-menu a:hover i, .popover-menu a:hover i { color: var(--primary); }
.dropdown-menu .menu-danger, .dropdown-menu .menu-danger i { color: var(--danger) !important; }
.dropdown-menu .menu-danger:hover { background: var(--danger-light); }
.dropdown-divider { height: 1px; margin: .35rem 0; background: var(--border-color); border: 0; }
.menu-header { padding: .6rem .7rem .5rem; border-bottom: 1px solid var(--border-color); margin-bottom: .35rem; }
.menu-header .name { font-weight: 600; color: var(--text-heading); font-size: .88rem; }
.menu-header .email { font-size: .75rem; color: var(--text-muted); word-break: break-all; }

.theme-switch {
    display: flex; gap: 2px;
    padding: 3px; margin: .25rem .2rem;
    background: var(--bg-subtle);
    border-radius: 9px;
}
.theme-switch button {
    flex: 1; border: 0; background: transparent;
    padding: .35rem .25rem;
    border-radius: 7px;
    font-size: .75rem; font-weight: 600;
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center; gap: .3rem;
}
.theme-switch button.active { background: var(--bg-surface); color: var(--primary); box-shadow: var(--shadow-xs); }

.page-content {
    flex: 1;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.75rem;
    animation: pageIn .28s var(--ease);
}
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.app-footer {
    padding: 1rem 1.75rem;
    font-size: .75rem;
    color: var(--text-faint);
    display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}

/* ── Top progress bar (dynamic navigation) ── */
.nav-progress {
    position: fixed; top: 0; left: 0; z-index: 2000;
    height: 3px; width: 0;
    background: var(--primary-gradient);
    box-shadow: 0 0 10px rgba(124, 58, 237, .6);
    opacity: 0;
    transition: width .3s var(--ease), opacity .3s;
    pointer-events: none;
}
.nav-progress.active { opacity: 1; }

.app-loading .page-content { opacity: .55; pointer-events: none; transition: opacity .15s; }

/* ── Bottom tab bar (phones) ── */
.bottom-nav {
    display: none;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--header-bg);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--border-color);
}
.bottom-nav a, .bottom-nav button {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border: 0; background: none;
    color: var(--text-faint);
    font-size: .66rem; font-weight: 600;
    position: relative;
}
.bottom-nav i { font-size: 1.25rem; }
.bottom-nav .active { color: var(--primary); }
.bottom-nav .active::before {
    content: ''; position: absolute; top: 0; left: 30%; right: 30%;
    height: 3px; border-radius: 0 0 3px 3px;
    background: var(--primary-gradient);
}

/* ── Collapsed rail (desktop toggle + tablet default) ── */
@media (min-width: 1200px) {
    .app-wrapper.sidebar-collapsed .sidebar { width: var(--sidebar-rail-w); }
    .app-wrapper.sidebar-collapsed .main-content { margin-left: var(--sidebar-rail-w); }
}
@media (min-width: 768px) and (max-width: 1199.98px) {
    .app-wrapper:not(.sidebar-expanded) .sidebar { width: var(--sidebar-rail-w); }
    .app-wrapper .main-content { margin-left: var(--sidebar-rail-w); }
    .app-wrapper.sidebar-expanded .sidebar { box-shadow: var(--shadow-lg); }
}
.sidebar.is-rail .sidebar-header { justify-content: center; padding: 0; }
.sidebar.is-rail .brand-text,
.sidebar.is-rail .nav-section-title,
.sidebar.is-rail .nav-label,
.sidebar.is-rail .nav-badge,
.sidebar.is-rail .sidebar-org .org-meta,
.sidebar.is-rail .sidebar-user .user-meta,
.sidebar.is-rail .sidebar-collapse-btn.in-header { display: none; }
.sidebar.is-rail .sidebar-org { justify-content: center; margin: .25rem .75rem .5rem; padding: .5rem; }
.sidebar.is-rail .nav-section { margin-bottom: 0; padding-top: .35rem; border-top: 1px solid var(--sidebar-border); }
.sidebar.is-rail .nav-section:first-child { border-top: 0; }
.sidebar.is-rail .nav-item { justify-content: center; padding: .65rem 0; }
.sidebar.is-rail .nav-item i { font-size: 1.2rem; }
.sidebar.is-rail .sidebar-user { justify-content: center; flex-direction: column; gap: .5rem; padding: .25rem 0; }
.sidebar.is-rail .sidebar-collapse-btn { margin: 0 !important; }
.sidebar.is-rail .sidebar-footer { display: flex; flex-direction: column; align-items: center; gap: .5rem; }

/* Rail tooltip */
.rail-tip {
    position: fixed; z-index: 2100;
    padding: .35rem .6rem;
    border-radius: 7px;
    background: var(--gray-900); color: var(--bg-surface);
    font-size: .75rem; font-weight: 600;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
}
[data-theme="dark"] .rail-tip { background: #F4F2FA; color: #16121F; }

/* ── Tablet ── */
@media (max-width: 1199.98px) {
    .header { padding: 0 1.25rem; }
    .page-content { padding: 1.25rem; }
    .header-search { width: 220px; }
}

/* ── Phone ── */
@media (max-width: 767.98px) {
    .sidebar {
        width: min(86vw, 300px);
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: none; }
    .sidebar-close { display: grid; place-items: center; }
    .sidebar .sidebar-collapse-btn { display: none; }
    .main-content { margin-left: 0; padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); }
    .menu-toggle { display: inline-grid; }
    .header { padding: 0 .75rem; gap: .5rem; height: 58px; }
    .header-search { width: 38px; padding: 0; justify-content: center; border-color: transparent; background: transparent; }
    .header-search span, .header-search .kbd { display: none; }
    .user-dropdown-toggle .user-info { display: none !important; }
    .breadcrumb-mini { display: none; }
    .page-title { font-size: 1rem; }
    .page-content { padding: 1rem .85rem; }
    .bottom-nav { display: flex; }
    .app-footer { display: none; }
}

/* ==========================================================================
   4. Cards & stat tiles
   ========================================================================== */
.card {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.25rem;
    color: var(--text-main);
    overflow: visible;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem;
    padding: 1rem 1.25rem !important;
    background: transparent !important;
    border-bottom: 1px solid var(--border-color) !important;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
}
.card-header h2, .card-header h3, .card-header h4, .card-header h5, .card-title {
    margin: 0; font-size: .98rem; font-weight: 700; color: var(--text-heading);
    display: flex; align-items: center; gap: .5rem;
}
.card-header h2 i, .card-header h3 i, .card-header h4 i, .card-header h5 i { color: var(--primary); }
.card-body { padding: 1.25rem; }
.card-footer {
    padding: .9rem 1.25rem !important;
    background: var(--bg-surface-header) !important;
    border-top: 1px solid var(--border-color) !important;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg) !important;
}
.card > .table-responsive:last-child,
.card > .card-body.p-0 > .table-responsive:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    position: relative;
    display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem;
    padding: 1.15rem 1.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--violet-200); }
[data-theme="dark"] .stat-card:hover { border-color: var(--border-strong); }
.stat-content { min-width: 0; }
.stat-content h3, .stat-title, .stat-label {
    font-family: var(--font-sans);
    font-size: .75rem; font-weight: 600;
    color: var(--text-muted) !important;
    margin: 0 0 .45rem;
    letter-spacing: .01em;
}
.stat-value {
    font-family: var(--font-display);
    font-size: 1.65rem; font-weight: 800;
    color: var(--text-heading);
    line-height: 1.15;
    letter-spacing: -0.02em;
    word-break: break-word;
}
.stat-change { display: flex; align-items: center; gap: .3rem; margin-top: .5rem; font-size: .74rem; font-weight: 600; color: var(--text-muted); }
.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }
.stat-icon {
    width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
    display: grid; place-items: center;
    font-size: 1.2rem;
    background: var(--primary-soft); color: var(--primary);
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.primary { background: var(--primary-soft); color: var(--primary); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.danger  { background: var(--danger-light);  color: var(--danger); }
.stat-icon.info    { background: var(--info-light);    color: var(--info); }
.stat-card::after {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: var(--primary-gradient); opacity: 0; transition: opacity .2s;
}
.stat-card:hover::after { opacity: 1; }

@media (max-width: 1199.98px) {
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .stat-card { flex-direction: column-reverse; gap: .6rem; }
    .stat-value { font-size: 1.45rem; }
}

/* Page hero / toolbars */
.page-header, .page-toolbar {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem;
    margin-bottom: 1.25rem;
}
.page-header h2, .page-toolbar h2 { margin: 0; font-size: 1.25rem; }
.welcome-hero {
    position: relative; overflow: hidden;
    border-radius: var(--radius-xl);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.5rem;
    color: #fff;
    background: radial-gradient(1200px 300px at 100% 0%, rgba(255,255,255,.18), transparent 60%), var(--primary-gradient);
    box-shadow: var(--shadow-primary);
}
.welcome-hero h2 { color: #fff; margin: 0 0 .25rem; }
.welcome-hero p { margin: 0; opacity: .85; }

/* ==========================================================================
   5. Buttons
   ========================================================================== */
.btn {
    --btn-h: 38px;
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    min-height: var(--btn-h);
    padding: 0 1rem;
    font-family: var(--font-sans);
    font-size: .85rem; font-weight: 600;
    line-height: 1.2;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .15s var(--ease), border-color .15s, color .15s, box-shadow .15s, transform .1s;
    user-select: none;
    text-decoration: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
.btn i { font-size: 1em; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-sm { --btn-h: 32px; padding: 0 .7rem; font-size: .78rem; border-radius: 8px; }
.btn-lg { --btn-h: 46px; padding: 0 1.4rem; font-size: .95rem; }
.btn-icon { width: var(--btn-h); padding: 0; }

.btn-primary {
    background: var(--primary-gradient) !important;
    border-color: transparent !important;
    color: #fff !important;
    box-shadow: 0 1px 2px rgba(76, 29, 149, .2), inset 0 1px 0 rgba(255,255,255,.12);
}
.btn-primary:hover { filter: brightness(1.07); box-shadow: var(--shadow-primary); color: #fff !important; }

.btn-secondary {
    background: var(--bg-subtle) !important;
    border-color: var(--border-color) !important;
    color: var(--text-main) !important;
}
.btn-secondary:hover { background: var(--gray-200) !important; color: var(--text-heading) !important; }

.btn-outline, .btn-outline-secondary, .btn-light {
    background: var(--bg-surface) !important;
    border-color: var(--border-strong) !important;
    color: var(--text-main) !important;
    box-shadow: var(--shadow-xs);
}
.btn-outline:hover, .btn-outline-secondary:hover, .btn-light:hover {
    border-color: var(--violet-300) !important;
    color: var(--primary) !important;
    background: var(--primary-light) !important;
}
.btn-outline-primary {
    background: transparent !important;
    border-color: var(--violet-300) !important;
    color: var(--primary) !important;
}
.btn-outline-primary:hover { background: var(--primary-light) !important; }
[data-theme="dark"] .btn-outline-primary { border-color: rgba(167,139,250,.4) !important; }

.btn-success { background: var(--success) !important; border-color: var(--success) !important; color: #fff !important; }
.btn-danger  { background: var(--danger) !important;  border-color: var(--danger) !important;  color: #fff !important; }
.btn-warning { background: var(--warning) !important; border-color: var(--warning) !important; color: #fff !important; }
.btn-info    { background: var(--info) !important;    border-color: var(--info) !important;    color: #fff !important; }
[data-theme="dark"] .btn-success, [data-theme="dark"] .btn-danger,
[data-theme="dark"] .btn-warning, [data-theme="dark"] .btn-info { color: #0D0A16 !important; }
.btn-success:hover, .btn-danger:hover, .btn-warning:hover, .btn-info:hover { filter: brightness(1.08); }

.btn-outline-danger  { background: transparent !important; border-color: var(--danger-border) !important;  color: var(--danger) !important; }
.btn-outline-danger:hover  { background: var(--danger-light) !important; }
.btn-outline-success { background: transparent !important; border-color: var(--success-border) !important; color: var(--success) !important; }
.btn-outline-success:hover { background: var(--success-light) !important; }
.btn-outline-warning { background: transparent !important; border-color: var(--warning-border) !important; color: var(--warning) !important; }
.btn-outline-warning:hover { background: var(--warning-light) !important; }

.btn-link { background: none !important; border: 0 !important; color: var(--primary) !important; padding: 0 .25rem; min-height: auto; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--primary); }

.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
    content: ''; position: absolute; width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%;
    animation: spin .7s linear infinite;
}
.btn-outline.is-loading::after, .btn-secondary.is-loading::after, .btn-light.is-loading::after { border-color: var(--violet-200); border-top-color: var(--primary); }

/* ==========================================================================
   6. Forms
   ========================================================================== */
.form-group { margin-bottom: 1rem; }
.form-label, .form-group > label, .modal-body label:not(.form-check-label) {
    display: block;
    margin-bottom: .4rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-heading);
}
.form-text, small.form-text { font-size: .75rem; color: var(--text-muted); }

.form-control, .form-select,
input[type="text"]:not(.no-style), input[type="email"]:not(.no-style), input[type="password"]:not(.no-style),
input[type="number"]:not(.no-style), input[type="date"]:not(.no-style), input[type="time"]:not(.no-style),
input[type="tel"]:not(.no-style), input[type="month"]:not(.no-style), input[type="search"]:not(.no-style),
input[type="datetime-local"]:not(.no-style), select:not(.no-style), textarea:not(.no-style) {
    width: 100%;
    min-height: 40px;
    padding: .5rem .8rem;
    font-family: var(--font-sans);
    font-size: .875rem;
    color: var(--text-heading);
    background-color: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
    appearance: none;
    -webkit-appearance: none;
}
textarea:not(.no-style), textarea.form-control { min-height: 88px; resize: vertical; }
.form-control-sm, .form-select-sm { min-height: 32px !important; padding: .3rem .6rem !important; font-size: .8rem !important; }
input[type="checkbox"]:not(.form-check-input), input[type="radio"]:not(.form-check-input) { width: auto; min-height: 0; accent-color: var(--violet-600); }

.form-select, select:not(.no-style):not([multiple]) {
    padding-right: 2.2rem;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%237C6F9A' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    background-size: 12px 10px;
}
select[multiple] { min-height: 110px; }

.form-control::placeholder, input::placeholder, textarea::placeholder { color: var(--text-faint); }
.form-control:hover, .form-select:hover, input:not([type="checkbox"]):not([type="radio"]):not(.no-style):hover, select:not(.no-style):hover, textarea:not(.no-style):hover { border-color: var(--gray-400); }
.form-control:focus, .form-select:focus, input:not(.no-style):focus, select:not(.no-style):focus, textarea:not(.no-style):focus {
    outline: none;
    border-color: var(--violet-500);
    box-shadow: 0 0 0 3px var(--primary-ring);
    background-color: var(--bg-input);
    color: var(--text-heading);
}
.form-control:disabled, .form-control[readonly], select:disabled, input:disabled { background-color: var(--bg-subtle); color: var(--text-muted); cursor: not-allowed; }
[data-theme="dark"] input[type="date"], [data-theme="dark"] input[type="time"], [data-theme="dark"] input[type="month"], [data-theme="dark"] input[type="datetime-local"] { color-scheme: dark; }

.form-check { display: flex; align-items: center; gap: .55rem; min-height: 1.5rem; padding-left: 0; margin-bottom: .35rem; }
.form-check .form-check-input { float: none; margin: 0; flex-shrink: 0; }
.form-check-input {
    width: 1.1rem; height: 1.1rem;
    border: 1.5px solid var(--border-strong);
    background-color: var(--bg-input);
    cursor: pointer;
}
.form-check-input:checked { background-color: var(--violet-600); border-color: var(--violet-600); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--primary-ring); border-color: var(--violet-500); }
.form-switch .form-check-input { width: 2.2rem; height: 1.2rem; border-radius: 1rem; }
.form-check-label { font-size: .85rem; color: var(--text-main); cursor: pointer; }

.input-group { display: flex; align-items: stretch; flex-wrap: nowrap; }
.input-group > .form-control, .input-group > .form-select { border-radius: 0; flex: 1 1 auto; width: 1%; min-width: 0; }
.input-group > .btn { border-radius: 0; }
.input-group > :first-child { border-top-left-radius: var(--radius) !important; border-bottom-left-radius: var(--radius) !important; }
.input-group > :last-child { border-top-right-radius: var(--radius) !important; border-bottom-right-radius: var(--radius) !important; }
.input-group-text {
    display: flex; align-items: center; padding: 0 .75rem;
    font-size: .85rem; color: var(--text-muted);
    background: var(--bg-subtle); border: 1px solid var(--border-strong);
}

.form-row { display: flex; flex-wrap: wrap; margin: 0 -.5rem; }
.form-row > * { padding: 0 .5rem; width: 100%; }
@media (min-width: 768px) {
    .form-row > :not([class*="col"]) { flex: 1 1 0; width: auto; }
}

.is-invalid { border-color: var(--danger) !important; }
.invalid-feedback { color: var(--danger); font-size: .75rem; }

/* ==========================================================================
   7. Tables
   ========================================================================== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
}
.card .table-responsive { border-radius: 0; }

.table {
    width: 100%;
    margin-bottom: 0 !important;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--text-main) !important;
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-main);
    --bs-table-striped-bg: transparent;
    --bs-table-hover-bg: var(--bg-hover);
}
.table > :not(caption) > * > * { background-color: transparent; box-shadow: none; color: inherit; }
.table th, .table thead td {
    padding: .7rem 1rem !important;
    background: var(--bg-surface-header) !important;
    color: var(--text-muted) !important;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color) !important;
    border-top: 0 !important;
    vertical-align: middle;
}
.table td {
    padding: .8rem 1rem !important;
    border-bottom: 1px solid var(--border-color) !important;
    border-top: 0 !important;
    font-size: .855rem;
    vertical-align: middle;
}
.table tbody tr { transition: background-color .12s; }
.table tbody tr:hover > * { background-color: var(--bg-hover) !important; }
.table tbody tr:last-child td { border-bottom: 0 !important; }
.table-sm th, .table-sm td { padding: .45rem .7rem !important; }
.table-bordered td, .table-bordered th { border: 1px solid var(--border-color) !important; }
.table tfoot td, .table tfoot th { background: var(--bg-surface-header) !important; font-weight: 700; color: var(--text-heading) !important; border-top: 1px solid var(--border-color) !important; }

.cell-user { display: flex; align-items: center; gap: .65rem; }
.cell-user .avatar-sm {
    width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; overflow: hidden;
    display: grid; place-items: center;
    background: var(--primary-soft); color: var(--primary); font-size: .72rem; font-weight: 700;
}

/* Mobile: tables become stacked cards (app.js adds data-label + .table-stack) */
@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr {
        margin: .65rem .65rem 0;
        width: auto;
        padding: .35rem .25rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        background: var(--bg-surface);
        box-shadow: var(--shadow-xs);
    }
    .table-stack tr:last-child { margin-bottom: .65rem; }
    .table-stack td {
        display: flex; justify-content: space-between; align-items: center; gap: 1rem;
        padding: .45rem .75rem !important;
        border-bottom: 1px dashed var(--border-color) !important;
        text-align: right !important;
    }
    .table-stack td:last-child { border-bottom: 0 !important; }
    .table-stack td::before {
        content: attr(data-label);
        flex-shrink: 0;
        font-size: .7rem; font-weight: 700;
        text-transform: uppercase; letter-spacing: .04em;
        color: var(--text-muted);
        text-align: left;
    }
    .table-stack td[data-label=""]::before { content: none; }
    .table-stack td[data-label=""] { justify-content: flex-end; }
    .table-stack td[colspan] { justify-content: center; text-align: center !important; }
    .table-stack td[colspan]::before { content: none; }
    .table-stack tbody tr:hover > * { background: transparent !important; }
    .table-stack tfoot { display: none; }
    .card .table-responsive:has(.table-stack) { overflow: visible; }
}

/* Employees page has a dedicated phone list */
.mobile-employee-list { display: none; }
@media (max-width: 767.98px) {
    .card:has(.mobile-employee-list) .table-responsive { display: none; }
    .mobile-employee-list { display: block; padding: .5rem; }
    .mobile-employee-card {
        background: var(--bg-surface);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        padding: 1rem;
        margin-bottom: .5rem;
        cursor: pointer;
        transition: border-color .2s, box-shadow .2s;
    }
    .mobile-employee-card:hover, .mobile-employee-card.expanded { border-color: var(--violet-300); box-shadow: var(--shadow-md); }
    .mobile-employee-card .mobile-card-chevron { transition: transform .2s var(--ease); }
    .mobile-employee-card.expanded .mobile-card-chevron { transform: rotate(90deg); color: var(--primary) !important; }
}

/* ==========================================================================
   8. Badges, alerts, tabs, pagination
   ========================================================================== */
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .22rem .6rem;
    font-size: .7rem; font-weight: 600;
    line-height: 1.4;
    border-radius: 999px;
    letter-spacing: .01em;
    white-space: nowrap;
    background: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid transparent;
}
.badge-primary, .badge.bg-primary, .badge-info, .badge.bg-info { background: var(--primary-light) !important; color: var(--primary) !important; border-color: var(--violet-200); }
.badge-success, .badge.bg-success { background: var(--success-light) !important; color: var(--success) !important; border-color: var(--success-border); }
.badge-danger,  .badge.bg-danger  { background: var(--danger-light)  !important; color: var(--danger)  !important; border-color: var(--danger-border); }
.badge-warning, .badge.bg-warning { background: var(--warning-light) !important; color: var(--warning) !important; border-color: var(--warning-border); }
.badge-secondary, .badge.bg-secondary, .badge.bg-light { background: var(--bg-subtle) !important; color: var(--text-muted) !important; border-color: var(--border-color); }
.badge.bg-dark { background: var(--gray-900) !important; color: var(--bg-surface) !important; }
[data-theme="dark"] .badge-primary, [data-theme="dark"] .badge-info { border-color: rgba(167,139,250,.3); }

.alert {
    display: flex; align-items: flex-start; gap: .6rem;
    position: relative;
    padding: .85rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius);
    border: 1px solid;
    font-size: .85rem;
}
.alert-success { background: var(--success-light); border-color: var(--success-border); color: var(--success); }
.alert-danger  { background: var(--danger-light);  border-color: var(--danger-border);  color: var(--danger); }
.alert-warning { background: var(--warning-light); border-color: var(--warning-border); color: var(--warning); }
.alert-info    { background: var(--primary-light); border-color: var(--violet-200);     color: var(--primary-dark); }
[data-theme="dark"] .alert-info { color: var(--primary); border-color: rgba(167,139,250,.3); }
.alert-dismissible { padding-right: 2.5rem; }
.alert .btn-close { position: absolute; top: .7rem; right: .7rem; padding: .4rem; }

.tabs, .nav-tabs {
    display: flex; gap: .25rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-item, .tab-btn, .nav-tabs .nav-link {
    padding: .65rem 1rem;
    border: 0; background: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    color: var(--text-muted);
    font-size: .85rem; font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.tab-item:hover, .tab-btn:hover, .nav-tabs .nav-link:hover { color: var(--text-heading); }
.tab-item.active, .tab-btn.active, .nav-tabs .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); background: none; }
.tab-content, .tab-panel { display: none; }
.tab-content.active, .tab-panel.active { display: block; animation: pageIn .2s var(--ease); }

.pagination { display: flex; justify-content: center; flex-wrap: wrap; gap: .3rem; margin: 1.25rem 0 .5rem; padding: 0; list-style: none; }
.pagination ul { display: flex; flex-wrap: wrap; list-style: none; gap: .3rem; padding: 0; margin: 0; }
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 .7rem;
    font-size: .82rem; font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    background: var(--bg-surface);
}
.pagination a:hover { border-color: var(--violet-300); color: var(--primary); background: var(--primary-light); }
.pagination li.active span, .pagination .active > span, .pagination .active > a { background: var(--primary-gradient); border-color: transparent; color: #fff; }

.spinner {
    width: 22px; height: 22px;
    border: 2.5px solid var(--violet-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; color: var(--violet-300); display: block; margin-bottom: .75rem; }

/* Skeleton */
.skeleton { position: relative; overflow: hidden; background: var(--bg-subtle); border-radius: 8px; }
.skeleton::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent);
    animation: shimmer 1.2s infinite;
    transform: translateX(-100%);
}
[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.05), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }

/* Info rows used by profile/detail pages */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.info-item-label, .info-item .label { font-size: .72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.info-item-value, .info-item .value { font-size: .9rem; font-weight: 600; color: var(--text-heading); word-break: break-word; }

/* ==========================================================================
   9. Modals — supports both legacy structures
   A) .modal-overlay(.active) > .modal
   B) div.modal(style display flex / .active) > .modal-content
   ========================================================================== */
.modal-overlay, div.modal {
    position: fixed !important;
    inset: 0 !important;
    z-index: 1070 !important;
    display: none !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 1rem !important;
    margin: 0 !important;
    width: auto !important; height: auto !important;
    background: rgba(13, 10, 22, .5) !important;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    overflow-y: auto;
}
.modal-overlay.active, .modal-overlay.show,
.modal-overlay[style*="display: flex"], .modal-overlay[style*="display:flex"], .modal-overlay[style*="display: block"], .modal-overlay[style*="display:block"],
div.modal.active, div.modal.show,
div.modal[style*="display: flex"], div.modal[style*="display:flex"], div.modal[style*="display: block"], div.modal[style*="display:block"] {
    display: flex !important;
    animation: fadeIn .15s var(--ease);
}
.modal-overlay[style*="display: none"], .modal-overlay[style*="display:none"],
div.modal[style*="display: none"], div.modal[style*="display:none"] { display: none !important; }

.modal-overlay > .modal, div.modal > .modal-content, div.modal > .modal-dialog > .modal-content {
    position: relative !important;
    inset: auto !important;
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 620px;
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
    height: auto !important;
    margin: auto !important;
    padding: 0;
    background: var(--bg-surface) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--shadow-lg) !important;
    overflow: hidden !important;
    animation: modalIn .22s var(--ease);
    color: var(--text-main);
}
/* The inner .modal of pattern A is also a div.modal: undo the backdrop rules it inherits */
.modal-overlay > .modal {
    align-items: stretch !important;
    justify-content: flex-start !important;
    padding: 0 !important;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    z-index: auto !important;
}
div.modal > .modal-dialog { max-width: 620px; width: 100%; margin: auto; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.modal-overlay > .modal > form, div.modal .modal-content > form {
    display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; overflow: hidden;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1rem 1.25rem !important;
    border-bottom: 1px solid var(--border-color) !important;
    background: var(--bg-surface) !important;
    flex-shrink: 0;
}
.modal-header h2, .modal-header h3, .modal-header h4, .modal-header h5, .modal-title {
    margin: 0 !important;
    font-size: 1.02rem !important;
    font-weight: 700;
    color: var(--text-heading) !important;
    display: flex; align-items: center; gap: .5rem;
}
.modal-body { padding: 1.25rem !important; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-footer {
    display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: .5rem;
    padding: .85rem 1.25rem !important;
    border-top: 1px solid var(--border-color) !important;
    background: var(--bg-surface-header) !important;
    flex-shrink: 0;
}
.modal-footer > * { margin: 0; }
.modal-close, .btn-close {
    width: 32px; height: 32px;
    display: inline-grid; place-items: center;
    padding: 0;
    border: 0; border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.35rem; line-height: 1;
    cursor: pointer;
    opacity: 1;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.modal-close:hover, .btn-close:hover { background: var(--bg-hover); color: var(--text-heading); }
.btn-close { background-image: none; }
.btn-close::before { content: '\00d7'; font-size: 1.4rem; }

/* Phone: modals become bottom sheets */
@media (max-width: 575.98px) {
    .modal-overlay, div.modal { padding: 0 !important; align-items: flex-end !important; }
    .modal-overlay > .modal, div.modal > .modal-content, div.modal > .modal-dialog > .modal-content {
        max-width: 100% !important;
        max-height: 92dvh;
        border-radius: 20px 20px 0 0 !important;
        border-bottom: 0 !important;
        margin: 0 !important;
        animation: sheetIn .25s var(--ease);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .modal-footer { position: sticky; bottom: 0; }
    .modal-footer .btn { flex: 1; }
}
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }

/* ==========================================================================
   10. Toasts, confirm dialog, command palette
   ========================================================================== */
.toast-stack {
    position: fixed; z-index: 2200;
    top: calc(var(--header-h) + 12px); right: 16px;
    display: flex; flex-direction: column; gap: .5rem;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}
.toast-item {
    pointer-events: auto;
    display: flex; align-items: flex-start; gap: .7rem;
    padding: .85rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    font-size: .85rem;
    color: var(--text-main);
    animation: toastIn .25s var(--ease);
    position: relative; overflow: hidden;
}
.toast-item.leaving { animation: toastOut .2s var(--ease) forwards; }
.toast-item .toast-icon {
    width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
    display: grid; place-items: center; font-size: 1rem;
    background: var(--primary-light); color: var(--primary);
}
.toast-item.success .toast-icon { background: var(--success-light); color: var(--success); }
.toast-item.danger .toast-icon, .toast-item.error .toast-icon { background: var(--danger-light); color: var(--danger); }
.toast-item.warning .toast-icon { background: var(--warning-light); color: var(--warning); }
.toast-item .toast-body { flex: 1; padding-top: 3px; word-break: break-word; }
.toast-item .toast-close { border: 0; background: none; color: var(--text-faint); font-size: 1.1rem; line-height: 1; padding: 2px; cursor: pointer; }
.toast-item .toast-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--primary-gradient); animation: toastBar linear forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(16px); } }
@keyframes toastBar { from { width: 100%; } to { width: 0; } }
@media (max-width: 767.98px) {
    .toast-stack { top: auto; bottom: calc(var(--bottomnav-h) + 12px + env(safe-area-inset-bottom)); right: 12px; left: 12px; width: auto; }
}

.dialog-backdrop {
    position: fixed; inset: 0; z-index: 2150;
    display: none; align-items: center; justify-content: center; padding: 1rem;
    background: rgba(13, 10, 22, .5);
    backdrop-filter: blur(4px);
}
.dialog-backdrop.show { display: flex; animation: fadeIn .15s; }
.dialog {
    width: 100%; max-width: 420px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    text-align: center;
    animation: modalIn .2s var(--ease);
}
.dialog .dialog-icon {
    width: 52px; height: 52px; margin: 0 auto 1rem; border-radius: 16px;
    display: grid; place-items: center; font-size: 1.5rem;
    background: var(--danger-light); color: var(--danger);
}
.dialog.info .dialog-icon { background: var(--primary-light); color: var(--primary); }
.dialog h3 { font-size: 1.05rem; margin: 0 0 .4rem; }
.dialog p { color: var(--text-muted); margin: 0 0 1.25rem; font-size: .88rem; }
.dialog .dialog-actions { display: flex; gap: .5rem; }
.dialog .dialog-actions .btn { flex: 1; }

.cmdk-backdrop {
    position: fixed; inset: 0; z-index: 2180;
    display: none; justify-content: center; align-items: flex-start;
    padding: 12vh 1rem 1rem;
    background: rgba(13, 10, 22, .45);
    backdrop-filter: blur(4px);
}
.cmdk-backdrop.show { display: flex; animation: fadeIn .12s; }
.cmdk {
    width: 100%; max-width: 580px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalIn .18s var(--ease);
}
.cmdk-input { display: flex; align-items: center; gap: .6rem; padding: 0 1rem; border-bottom: 1px solid var(--border-color); }
.cmdk-input i { color: var(--primary); font-size: 1.1rem; }
.cmdk-input input {
    flex: 1; height: 54px; border: 0 !important; box-shadow: none !important; background: transparent !important;
    font-size: .98rem; color: var(--text-heading); padding: 0 !important; min-height: 0 !important;
}
.cmdk-input input:focus-visible { outline: none; }
.cmdk-list { max-height: 50vh; overflow-y: auto; padding: .4rem; }
.cmdk-group { padding: .5rem .7rem .3rem; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
.cmdk-item {
    display: flex; align-items: center; gap: .7rem;
    padding: .6rem .7rem;
    border-radius: 9px;
    color: var(--text-main);
    font-size: .88rem; font-weight: 500;
    cursor: pointer;
}
.cmdk-item i { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--bg-subtle); color: var(--text-muted); font-size: .95rem; }
.cmdk-item.selected { background: var(--primary-light); color: var(--primary); }
.cmdk-item.selected i { background: var(--primary-gradient); color: #fff; }
.cmdk-item .cmdk-hint { margin-left: auto; font-size: .72rem; color: var(--text-faint); }
.cmdk-empty { padding: 2rem; text-align: center; color: var(--text-muted); font-size: .85rem; }
.cmdk-foot { display: flex; gap: 1rem; padding: .55rem 1rem; border-top: 1px solid var(--border-color); font-size: .72rem; color: var(--text-faint); background: var(--bg-surface-header); }

/* ==========================================================================
   11. Auth pages (login / register / forgot / reset)
   ========================================================================== */
.auth-body {
    min-height: 100vh; min-height: 100dvh;
    background: var(--bg-body);
    margin: 0;
}
.auth-wrapper {
    min-height: 100vh; min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(380px, 1.05fr) 1fr;
}
.auth-brand {
    position: relative; overflow: hidden;
    padding: 3rem;
    display: flex; flex-direction: column; justify-content: space-between;
    color: #fff;
    background:
        radial-gradient(700px 400px at 0% 0%, rgba(255,255,255,.14), transparent 60%),
        radial-gradient(600px 500px at 100% 100%, rgba(168,85,247,.55), transparent 60%),
        linear-gradient(150deg, #2E1065 0%, #4C1D95 45%, #6D28D9 100%);
}
.auth-brand::before {
    content: ''; position: absolute; inset: 0;
    background-image: linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(circle at 30% 40%, #000 0%, transparent 75%);
    -webkit-mask-image: radial-gradient(circle at 30% 40%, #000 0%, transparent 75%);
}
.auth-brand > * { position: relative; }
.auth-brand .brand-row { display: flex; align-items: center; gap: .75rem; font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; }
.auth-brand .brand-mark { background: rgba(255,255,255,.16); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.auth-brand h2 { color: #fff; font-size: clamp(1.6rem, 2.6vw, 2.3rem); line-height: 1.15; letter-spacing: -0.03em; margin: 0 0 1rem; max-width: 460px; }
.auth-brand p.lead { color: rgba(255,255,255,.78); font-size: 1rem; max-width: 440px; margin: 0; }
.auth-features { list-style: none; padding: 0; margin: 2rem 0 0; display: grid; gap: .85rem; }
.auth-features li { display: flex; align-items: center; gap: .75rem; color: rgba(255,255,255,.9); font-size: .9rem; }
.auth-features li i { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.14); }
.auth-brand .auth-foot { color: rgba(255,255,255,.55); font-size: .78rem; }

.auth-card {
    width: 100%; max-width: 440px;
    margin: auto;
    padding: 2.5rem 2rem;
    background: transparent;
    border: 0;
    box-shadow: none;
    align-self: center; justify-self: center;
}
.auth-logo h1 { font-size: 1.3rem; display: flex; align-items: center; justify-content: center; gap: .5rem; margin: 0; }
.auth-logo p { color: var(--text-muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin: .35rem 0 0; }
.auth-title h2 { font-size: 1.6rem; margin: 0 0 .35rem; letter-spacing: -0.02em; }
.auth-title p { color: var(--text-muted); margin: 0; }
.auth-card .form-control { min-height: 46px; font-size: .92rem; }
.auth-card .btn-primary { min-height: 46px; width: 100%; font-size: .95rem; }
.auth-card .auth-links, .auth-card .auth-footer { text-align: center; font-size: .85rem; color: var(--text-muted); margin-top: 1.25rem; }
.password-field { position: relative; }
.password-field .form-control { padding-right: 2.75rem; }
.password-toggle {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    width: 32px; height: 32px; border: 0; background: none; border-radius: 8px;
    color: var(--text-muted); display: grid; place-items: center; cursor: pointer;
}
.password-toggle:hover { color: var(--primary); background: var(--bg-hover); }

.auth-theme-toggle {
    position: fixed; top: 1rem; right: 1rem; z-index: 50;
    width: 40px; height: 40px; border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-muted);
    display: grid; place-items: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}
.auth-theme-toggle:hover { color: var(--primary); }
.auth-theme-toggle i { font-size: 1.05rem !important; color: inherit !important; }

@media (max-width: 991.98px) {
    .auth-wrapper { grid-template-columns: 1fr; }
    .auth-brand { padding: 1.5rem 1.5rem 1.75rem; min-height: auto; }
    .auth-brand h2 { font-size: 1.35rem; margin-bottom: .35rem; }
    .auth-brand p.lead { font-size: .88rem; }
    .auth-features, .auth-brand .auth-foot { display: none; }
    .auth-brand .brand-row { margin-bottom: 1.25rem; }
    .auth-card { padding: 1.75rem 1.25rem 2.5rem; }
    .auth-theme-toggle { background: rgba(255,255,255,.15); border-color: rgba(255,255,255,.25); color: #fff; }
}

/* ==========================================================================
   12. Misc legacy components
   ========================================================================== */
.employee-item { border-left: 3px solid transparent !important; transition: background-color .15s, border-color .15s; }
.employee-item:hover, .employee-item.bg-primary-light { background: var(--primary-light) !important; color: var(--primary) !important; border-left-color: var(--primary) !important; }

.salary-employee-grid, .salary-components-grid { gap: 1.25rem; }
@media (max-width: 991.98px) {
    .salary-employee-grid, .salary-components-grid { grid-template-columns: 1fr !important; }
}

.timeline-item { position: relative; padding-left: 1.25rem; border-left: 2px solid var(--border-color); padding-bottom: 1rem; }
.timeline-item::before { content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }

/* Responsive helpers for header-action rows */
@media (max-width: 575.98px) {
    .card-header { padding: .85rem 1rem !important; }
    .card-body { padding: 1rem; }
    .card-header .btn, .page-header .btn, .page-toolbar .btn { min-height: 36px; }
    .card-body form.d-flex, .card form.d-flex { flex-direction: column; align-items: stretch !important; gap: .6rem !important; }
    .card-body form.d-flex > *, .card form.d-flex > * { width: 100% !important; max-width: none !important; flex: none !important; margin-bottom: 0 !important; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
    .stat-card { padding: .9rem; flex-direction: column-reverse; gap: .5rem; }
    .stat-value { font-size: 1.3rem; }
    .stat-icon { width: 36px; height: 36px; font-size: 1rem; border-radius: 10px; }
}

/* ==========================================================================
   13. Print
   ========================================================================== */
@media print {
    .sidebar, .header, .bottom-nav, .app-footer, .toast-stack, .nav-progress, .no-print { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
    .page-content { padding: 0 !important; max-width: none; }
    body { background: #fff !important; color: #000 !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ==========================================================================
   Accent colours (user preference: html[data-accent]) — violet is the default.
   Each accent re-points the violet scale, so every component follows.
   ========================================================================== */
html[data-accent="blue"] {
    --violet-50: #EFF6FF;
    --violet-100: #DBEAFE;
    --violet-200: #BFDBFE;
    --violet-300: #93C5FD;
    --violet-400: #60A5FA;
    --violet-500: #3B82F6;
    --violet-600: #2563EB;
    --violet-700: #1D4ED8;
    --violet-800: #1E40AF;
    --violet-900: #1E3A8A;
    --purple-500: #0EA5E9;
    --purple-600: #2563EB;
    --primary-ring: rgba(37, 99, 235, 0.22);
    --primary-gradient: linear-gradient(135deg, #2563EB 0%, #3B82F6 55%, #0EA5E9 100%);
    --shadow-primary: 0 6px 18px -4px rgba(37, 99, 235, 0.55);
    --bs-primary: #2563EB;
    --bs-primary-rgb: 37, 99, 235;
}
html[data-accent="blue"][data-theme="dark"] {
    --primary: #60A5FA;
    --primary-hover: #93C5FD;
    --primary-dark: #3B82F6;
    --primary-light: rgba(96, 165, 250, 0.12);
    --primary-soft: rgba(96, 165, 250, 0.2);
    --primary-ring: rgba(96, 165, 250, 0.3);
    --bs-primary-rgb: 96, 165, 250;
}
html[data-accent="pink"] {
    --violet-50: #FDF2F8;
    --violet-100: #FCE7F3;
    --violet-200: #FBCFE8;
    --violet-300: #F9A8D4;
    --violet-400: #F472B6;
    --violet-500: #EC4899;
    --violet-600: #DB2777;
    --violet-700: #BE185D;
    --violet-800: #9D174D;
    --violet-900: #831843;
    --purple-500: #F43F5E;
    --purple-600: #DB2777;
    --primary-ring: rgba(219, 39, 119, 0.22);
    --primary-gradient: linear-gradient(135deg, #DB2777 0%, #EC4899 55%, #F43F5E 100%);
    --shadow-primary: 0 6px 18px -4px rgba(219, 39, 119, 0.55);
    --bs-primary: #DB2777;
    --bs-primary-rgb: 219, 39, 119;
}
html[data-accent="pink"][data-theme="dark"] {
    --primary: #F472B6;
    --primary-hover: #F9A8D4;
    --primary-dark: #EC4899;
    --primary-light: rgba(244, 114, 182, 0.12);
    --primary-soft: rgba(244, 114, 182, 0.2);
    --primary-ring: rgba(244, 114, 182, 0.3);
    --bs-primary-rgb: 244, 114, 182;
}
html[data-accent="green"] {
    --violet-50: #ECFDF5;
    --violet-100: #D1FAE5;
    --violet-200: #A7F3D0;
    --violet-300: #6EE7B7;
    --violet-400: #34D399;
    --violet-500: #10B981;
    --violet-600: #059669;
    --violet-700: #047857;
    --violet-800: #065F46;
    --violet-900: #064E3B;
    --purple-500: #14B8A6;
    --purple-600: #059669;
    --primary-ring: rgba(5, 150, 105, 0.22);
    --primary-gradient: linear-gradient(135deg, #059669 0%, #10B981 55%, #14B8A6 100%);
    --shadow-primary: 0 6px 18px -4px rgba(5, 150, 105, 0.55);
    --bs-primary: #059669;
    --bs-primary-rgb: 5, 150, 105;
}
html[data-accent="green"][data-theme="dark"] {
    --primary: #34D399;
    --primary-hover: #6EE7B7;
    --primary-dark: #10B981;
    --primary-light: rgba(52, 211, 153, 0.12);
    --primary-soft: rgba(52, 211, 153, 0.2);
    --primary-ring: rgba(52, 211, 153, 0.3);
    --bs-primary-rgb: 52, 211, 153;
}
html[data-accent="orange"] {
    --violet-50: #FFF7ED;
    --violet-100: #FFEDD5;
    --violet-200: #FED7AA;
    --violet-300: #FDBA74;
    --violet-400: #FB923C;
    --violet-500: #F97316;
    --violet-600: #EA580C;
    --violet-700: #C2410C;
    --violet-800: #9A3412;
    --violet-900: #7C2D12;
    --purple-500: #F59E0B;
    --purple-600: #EA580C;
    --primary-ring: rgba(234, 88, 12, 0.22);
    --primary-gradient: linear-gradient(135deg, #EA580C 0%, #F97316 55%, #F59E0B 100%);
    --shadow-primary: 0 6px 18px -4px rgba(234, 88, 12, 0.55);
    --bs-primary: #EA580C;
    --bs-primary-rgb: 234, 88, 12;
}
html[data-accent="orange"][data-theme="dark"] {
    --primary: #FB923C;
    --primary-hover: #FDBA74;
    --primary-dark: #F97316;
    --primary-light: rgba(251, 146, 60, 0.12);
    --primary-soft: rgba(251, 146, 60, 0.2);
    --primary-ring: rgba(251, 146, 60, 0.3);
    --bs-primary-rgb: 251, 146, 60;
}
/* Accent picker (avatar menu + preferences) */
.accent-swatches { display: flex; gap: .45rem; flex-wrap: wrap; }
.accent-swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--bg-surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; }
.accent-swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--text-heading); }
.accent-swatch[data-accent-set="violet"] { background: #7C3AED; }
.accent-swatch[data-accent-set="blue"] { background: #2563EB; }
.accent-swatch[data-accent-set="pink"] { background: #DB2777; }
.accent-swatch[data-accent-set="green"] { background: #059669; }
.accent-swatch[data-accent-set="orange"] { background: #EA580C; }

/* Notification bell */
.notif-btn { position: relative; }
.notif-badge { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .62rem; font-weight: 700; line-height: 17px; text-align: center; border: 2px solid var(--bg-surface); box-sizing: content-box; }
.notif-menu { width: min(380px, calc(100vw - 24px)); padding: 0 !important; right: 0; left: auto; }
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .7rem .9rem; border-bottom: 1px solid var(--border-color); }
.notif-list { max-height: min(420px, 70vh); overflow-y: auto; }
.notif-item { display: grid !important; grid-template-columns: 22px 1fr auto; gap: .6rem; align-items: start; padding: .7rem .9rem !important; border-bottom: 1px solid var(--border-color); color: var(--text-body) !important; text-decoration: none; white-space: normal !important; }
.notif-item:last-child { border-bottom: 0; }
.notif-item i { color: var(--primary); margin-top: 2px; }
.notif-item.unread { background: var(--primary-light); }
.notif-item.unread .notif-time::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-left: .35rem; vertical-align: middle; }
.notif-text { display: flex; flex-direction: column; gap: .15rem; font-size: .82rem; min-width: 0; }
.notif-text b { font-weight: 600; color: var(--text-heading); }
.notif-text span { color: var(--text-muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif-time { font-size: .72rem; color: var(--text-faint); white-space: nowrap; }
.notif-empty { padding: 2rem 1rem; text-align: center; color: var(--text-muted); display: flex; flex-direction: column; gap: .4rem; align-items: center; }
.notif-empty i { font-size: 1.6rem; color: var(--violet-300); }


/* ==========================================================================
   Attendex HR — visual refresh (v2): deeper contrast, ink sidebar with
   collapsible groups, elevated cards, stronger typography, slim scrollbars.
   Accent-aware (follows html[data-accent]); dark mode keeps its own tokens.
   ========================================================================== */
html:not([data-theme="dark"]) {
    --bg-body: #F1F2F7;
    --bg-surface: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-surface-header: #FAFAFD;
    --bg-subtle: #F5F6FA;
    --bg-hover: color-mix(in srgb, var(--violet-500) 7%, #FFFFFF);
    --text-heading: #0D0F22;
    --text-main: #262A40;
    --text-body: #262A40;
    --text-muted: #5E6480;
    --text-faint: #8D93AD;
    --border-color: #E2E4EE;
    --border-strong: #CED2E0;
    --shadow-xs: 0 1px 2px rgba(15, 17, 40, 0.06);
    --shadow-sm: 0 1px 2px rgba(15, 17, 40, 0.05), 0 4px 14px -6px rgba(15, 17, 40, 0.10);
    --shadow-md: 0 10px 28px -10px rgba(15, 17, 40, 0.18), 0 2px 6px rgba(15, 17, 40, 0.05);
    --card-shadow: var(--shadow-sm);
    --radius-lg: 16px;
    --header-bg: rgba(255, 255, 255, 0.86);
}

/* ---- slim, quiet scrollbars everywhere ---- */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--text-muted) 40%, transparent) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text-muted) 32%, transparent); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--text-muted) 55%, transparent); background-clip: padding-box; }
body { overscroll-behavior-y: none; }

/* ---- page background with a soft accent wash at the top ---- */
html:not([data-theme="dark"]) body {
    background:
        radial-gradient(900px 260px at 75% -120px, color-mix(in srgb, var(--violet-400) 14%, transparent), transparent 70%),
        var(--bg-body);
    background-attachment: fixed;
}

/* ---- ink sidebar (light mode) ---- */
html:not([data-theme="dark"]) .sidebar {
    --sidebar-bg: #0E0D1C;
    --sidebar-border: rgba(255, 255, 255, 0.07);
    --sidebar-text: rgba(236, 234, 248, 0.74);
    --sidebar-muted: rgba(236, 234, 248, 0.42);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.06);
    --text-heading: #FFFFFF;
    --text-muted: rgba(236, 234, 248, 0.6);
    --text-faint: rgba(236, 234, 248, 0.45);
    --bg-hover: rgba(255, 255, 255, 0.08);
    background:
        radial-gradient(420px 260px at -40px -60px, color-mix(in srgb, var(--violet-500) 42%, transparent), transparent 70%),
        radial-gradient(300px 300px at 120% 110%, color-mix(in srgb, var(--violet-700) 30%, transparent), transparent 70%),
        #0E0D1C;
    border-right: 0;
    box-shadow: 1px 0 0 rgba(15, 17, 40, 0.08);
}
html:not([data-theme="dark"]) .sidebar .sidebar-org { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.08); }
html:not([data-theme="dark"]) .sidebar .sidebar-collapse-btn { color: var(--sidebar-muted); background: transparent; border-color: rgba(255, 255, 255, 0.1); }
html:not([data-theme="dark"]) .sidebar .sidebar-collapse-btn:hover,
html:not([data-theme="dark"]) .sidebar .sidebar-close:hover { color: #FFFFFF; border-color: rgba(255, 255, 255, 0.28); }

/* nav items: soft tinted active pill with an accent bar, not a loud gradient block */
.sidebar .nav-item { padding: .5rem .75rem; margin: 1px 0; border-radius: 10px; }
.sidebar .nav-item:hover { background: var(--sidebar-hover-bg); color: var(--text-heading); }
.sidebar .nav-item:hover i { color: var(--text-heading); }
html:not([data-theme="dark"]) .sidebar .nav-item.active {
    background: linear-gradient(90deg, color-mix(in srgb, var(--violet-500) 34%, transparent), color-mix(in srgb, var(--violet-500) 12%, transparent));
    color: #FFFFFF; box-shadow: none;
}
.sidebar .nav-item.active::before {
    content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0;
    background: var(--violet-400); box-shadow: 0 0 12px color-mix(in srgb, var(--violet-400) 70%, transparent);
}
html:not([data-theme="dark"]) .sidebar .nav-item.active i { color: var(--violet-300); }

/* collapsible groups */
.nav-section { margin-bottom: .15rem; }
.nav-section-title {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    background: none; border: 0; cursor: pointer; text-align: left;
    padding: .75rem .75rem .35rem; border-radius: 8px;
}
.nav-section-title:hover { color: var(--sidebar-text); }
.nav-section-title:focus-visible { outline: 2px solid var(--violet-400); outline-offset: -2px; }
.nav-group-chev { font-size: .7rem; transition: transform .18s var(--ease); opacity: .7; }
.nav-section.collapsed .nav-group-chev { transform: rotate(-90deg); }
.nav-group-items { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .2s var(--ease); }
.nav-group-items > * { min-height: 0; }
.nav-group-items { overflow: hidden; }
.nav-section.collapsed .nav-group-items { grid-template-rows: 0fr; }
.nav-section.collapsed .nav-group-items > .nav-item { margin: 0; padding-top: 0; padding-bottom: 0; height: 0; opacity: 0; pointer-events: none; }
.nav-section.collapsed.has-active .nav-section-title { color: var(--sidebar-text); }
/* rail mode (collapsed sidebar): every item visible, no group headers */
.sidebar.is-rail .nav-section-title { display: none; }
.sidebar.is-rail .nav-section.collapsed .nav-group-items { grid-template-rows: 1fr; }
.sidebar.is-rail .nav-section.collapsed .nav-group-items > .nav-item { height: auto; opacity: 1; pointer-events: auto; padding: .5rem .75rem; margin: 1px 0; }
.sidebar.is-rail .nav-item.active::before { left: -10px; }

/* ---- header ---- */
html:not([data-theme="dark"]) .header { border-bottom: 1px solid var(--border-color); box-shadow: 0 1px 0 rgba(15, 17, 40, 0.02); }
.page-title { font-weight: 800; letter-spacing: -.01em; }
.breadcrumb-mini { font-weight: 600; letter-spacing: .02em; }

/* ---- page toolbar / headings ---- */
.page-toolbar h2, .page-header h2 { font-size: 1.4rem; font-weight: 800; letter-spacing: -.015em; color: var(--text-heading); }
.page-toolbar p, .page-header p { color: var(--text-muted); }

/* ---- cards ---- */
.card { border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--card-shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--border-color); }
.card-header h3, .card-header h4, .card-header h5 { font-weight: 700; color: var(--text-heading); }

/* ---- stat tiles: one row on desktop, bold numbers, accent edge ---- */
.stats-grid { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: .9rem; }
.stat-card {
    position: relative; overflow: hidden;
    border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--card-shadow);
}
html:not([data-theme="dark"]) .stat-card { background: linear-gradient(180deg, #FFFFFF, color-mix(in srgb, var(--violet-50) 35%, #FFFFFF)); }
.stat-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--primary-gradient); opacity: .85; }
.stat-value { font-size: 1.85rem; font-weight: 800; letter-spacing: -.02em; color: var(--text-heading); }
.stat-content h3, .stat-title, .stat-label { text-transform: uppercase; letter-spacing: .06em; font-size: .7rem; font-weight: 700; color: var(--text-muted); }
.stat-icon { border-radius: 12px; }
html:not([data-theme="dark"]) .stat-icon.primary { background: color-mix(in srgb, var(--violet-500) 14%, #FFFFFF); }
html:not([data-theme="dark"]) .stat-icon.success { background: #DDF6EA; }
html:not([data-theme="dark"]) .stat-icon.warning { background: #FCEFD6; }
html:not([data-theme="dark"]) .stat-icon.danger  { background: #FCE1E1; }
html:not([data-theme="dark"]) .stat-icon.info    { background: #DCEBFD; }

/* ---- buttons ---- */
.btn-primary {
    background: var(--primary-gradient) !important; border: 0 !important; color: #fff !important;
    box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--violet-600) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
html:not([data-theme="dark"]) .btn-outline, html:not([data-theme="dark"]) .btn-secondary { border-color: var(--border-strong) !important; color: var(--text-heading) !important; background: var(--bg-surface) !important; }
.btn-outline:hover, .btn-secondary:hover { border-color: var(--violet-400) !important; color: var(--primary) !important; }

/* ---- tables ---- */
.table thead th {
    background: var(--bg-subtle); color: var(--text-muted);
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
    border-bottom: 1px solid var(--border-color);
}
.table tbody tr:hover > td { background: color-mix(in srgb, var(--violet-500) 4%, transparent); }
.table td { border-color: var(--border-color); }

/* ---- tabs ---- */
.tabs { border-bottom: 1px solid var(--border-strong); }
.tab-item.active { color: var(--primary); font-weight: 700; }

/* ---- form controls: crisper borders & focus ---- */
.form-control, .form-select { border-color: var(--border-strong); }
.form-control:focus, .form-select:focus { border-color: var(--violet-500); box-shadow: 0 0 0 4px color-mix(in srgb, var(--violet-500) 16%, transparent); }

/* ---- Top bar in the theme colour (light mode); follows html[data-accent] ----
   Only the bar's own elements are restyled, so dropdowns that open from it keep
   their normal (dark-on-white) colours. */
html:not([data-theme="dark"]) .header {
    background:
        radial-gradient(600px 120px at 85% -40px, rgba(255, 255, 255, 0.18), transparent 70%),
        linear-gradient(100deg, var(--violet-800) 0%, var(--violet-600) 55%, var(--purple-500) 100%);
    border-bottom: 0;
    box-shadow: 0 6px 18px -10px color-mix(in srgb, var(--violet-700) 70%, transparent);
    backdrop-filter: none; -webkit-backdrop-filter: none;
}
html:not([data-theme="dark"]) .header .page-title { color: #FFFFFF; }
html:not([data-theme="dark"]) .header .breadcrumb-mini { color: rgba(255, 255, 255, 0.72); }
html:not([data-theme="dark"]) .header .icon-btn,
html:not([data-theme="dark"]) .header .menu-toggle { color: rgba(255, 255, 255, 0.9); background: transparent; border-color: transparent; }
html:not([data-theme="dark"]) .header .icon-btn:hover,
html:not([data-theme="dark"]) .header .menu-toggle:hover { background: rgba(255, 255, 255, 0.14); color: #FFFFFF; }
html:not([data-theme="dark"]) .header .header-search {
    background: rgba(255, 255, 255, 0.14); border-color: rgba(255, 255, 255, 0.22); color: rgba(255, 255, 255, 0.85);
}
html:not([data-theme="dark"]) .header .header-search:hover { background: rgba(255, 255, 255, 0.2); border-color: rgba(255, 255, 255, 0.4); box-shadow: none; }
html:not([data-theme="dark"]) .header .header-search i { color: rgba(255, 255, 255, 0.85); }
html:not([data-theme="dark"]) .header .header-search .kbd { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.25); color: #FFFFFF; }
html:not([data-theme="dark"]) .header .user-dropdown-toggle:hover { background: rgba(255, 255, 255, 0.12); }
html:not([data-theme="dark"]) .header .user-dropdown-toggle .user-name { color: #FFFFFF; }
html:not([data-theme="dark"]) .header .user-dropdown-toggle .user-role,
html:not([data-theme="dark"]) .header .user-dropdown-toggle > .bi { color: rgba(255, 255, 255, 0.7) !important; }
html:not([data-theme="dark"]) .header .user-dropdown-toggle .user-avatar { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5); }
html:not([data-theme="dark"]) .header .notif-badge { border-color: var(--violet-700); }

/* ===================================================================== Attendex logo (assets/brand) */
.brand-logo { display: block; height: 28px; width: auto; max-width: 100%; }
.brand-logo-on-dark { display: none; }
html[data-theme="dark"] .brand-logo-on-light { display: none; }
html[data-theme="dark"] .brand-logo-on-dark { display: block; }
/* Sidebar: wordmark + portal label; the square mark only in the collapsed rail */
.sidebar-logo .brand-text { display: flex; flex-direction: column; gap: 4px; }
.sidebar-logo .brand-text .brand-logo { height: 24px; }
.sidebar-logo .brand-text small { margin-top: 0; padding-left: 1px; }
.sidebar-logo .brand-mark { display: none; }
.sidebar.is-rail .sidebar-logo .brand-mark { display: grid; }
.brand-mark img { width: 22px; height: 22px; object-fit: contain; }
/* Sign-in pages */
.auth-logo h1 { justify-content: center; }
.auth-logo .brand-logo { height: 40px; margin: 0 auto; }
.auth-brand .brand-row .brand-logo { height: 34px; }
@media (max-width: 991.98px) { .auth-brand .brand-row .brand-logo { height: 28px; } }
