/* =============================================
   CSS Custom Properties (Theme Variables)
   ============================================= */
:root {
    /* Neutral gray ramp (RGB triplets for rgb(var(--gray-X) / <alpha>) usage) */
    --gray-0: 255 255 255;
    --gray-50: 250 250 250;
    --gray-100: 243 244 246;
    --gray-200: 229 231 235;
    --gray-300: 212 216 222;
    --gray-400: 157 164 174;
    --gray-500: 107 114 128;
    --gray-600: 72 72 72;
    --gray-700: 55 65 81;
    --gray-800: 31 41 55;
    --gray-900: 17 17 17;
    --gray-1000: 0 0 0;

    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-sidebar-hover: rgb(var(--gray-100));
    --bg-sidebar-active: rgb(var(--gray-100));
    --text-primary: #111111;
    --text-secondary: #484848;
    --text-sidebar: #484848;
    --text-sidebar-active: #111111;
    --border-color: rgb(var(--gray-200));
    --accent: #111111;
    --accent-light: #333333;
    --secondary: #4e36f5;
    --secondary-light: #7a67ff;
    --success: #11a849;
    --warning: #f5a623;
    --danger: #ee0000;
    --info: #0070f3;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-card: 0px 1px 0 rgba(0,0,0,.02), 0px 2px 6px rgba(0,0,0,.05);
    --radius-card: 0.625rem;
    --radius-sm: 0.5rem;
    --sidebar-width: 270px;
    --sidebar-collapsed: 70px;
    --header-height: 68px;
    --transition-speed: 0.3s;

    --secondary-lighter: #dde3ff;
    --muted: #e3e3e3;
    --shadow-profile: 0px 2px 4px -2px rgba(0,0,0,.10), 0px 4px 6px -1px rgba(0,0,0,.10);
    --shadow-rounded-card: 0px 4px 6px -4px rgba(0,0,0,.1), 0px 10px 15px -3px rgba(0,0,0,.1);
    --radius-lg: 0.625rem;
    --radius-badge: 9999px;
}

@media (min-width: 1536px) {
    :root {
        --sidebar-width: 288px;
    }
}

/* Override Bootstrap's own theme variables so components using Bootstrap
   utility classes directly (.text-primary, .list-group-item.active,
   form-switches, .btn-check, spinners, etc.) inherit the new palette
   without needing per-page edits. */
:root {
    --bs-primary: var(--accent);
    --bs-primary-rgb: 17, 17, 17;
    --bs-secondary: rgb(var(--gray-500));
    --bs-secondary-rgb: 107, 114, 128;
    --bs-link-color: var(--secondary);
    --bs-link-color-rgb: 78, 54, 245;
    --bs-link-hover-color: var(--secondary-light);
    --bs-link-hover-color-rgb: 122, 103, 255;
    --bs-success: var(--success);
    --bs-success-rgb: 17, 168, 73;
    --bs-warning: var(--warning);
    --bs-warning-rgb: 245, 166, 35;
    --bs-danger: var(--danger);
    --bs-danger-rgb: 238, 0, 0;
    --bs-info: var(--info);
    --bs-info-rgb: 0, 112, 243;
}
[data-bs-theme="dark"] {
    --bs-primary-rgb: 237, 237, 237;
    --bs-secondary-rgb: 161, 161, 170;
    --bs-link-color-rgb: 122, 103, 255;
    --bs-link-hover-color-rgb: 154, 139, 255;
}
/* Components that pair --bs-primary as a background with hardcoded white
   text need the text flipped in dark mode, since --bs-primary inverts to
   near-white there (monochrome accent). */
.list-group-item.active,
.btn-check:checked + .btn-outline-primary,
.page-item.active .page-link {
    color: var(--bg-secondary) !important;
}
/* Several Bootstrap components scope their own color variable instead of
   referencing --bs-primary directly - override those explicitly. */
.list-group-item.active {
    background-color: var(--accent) !important;
    border-color: var(--accent) !important;
}
.form-check-input {
    width: 1.15em;
    height: 1.15em;
    border-color: var(--border-color);
    margin-top: 0.2em;
}
.form-check-input:checked {
    background-color: var(--accent) !important;
    border-color: var(--accent) !important;
}
.form-check-input:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 0.2rem rgba(var(--gray-900), 0.15) !important;
}
.form-check-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.form-switch .form-check-input {
    width: 2.25em;
    height: 1.15em;
}

[data-bs-theme="dark"] {
    --gray-50: 24 24 27;
    --gray-100: 39 39 42;
    --gray-200: 63 63 70;
    --gray-300: 82 82 91;
    --gray-400: 113 113 122;
    --gray-500: 161 161 170;
    --gray-900: 237 237 237;

    --bg-primary: #0b0b0d;
    --bg-secondary: #18181b;
    --bg-card: #18181b;
    --bg-sidebar: #111113;
    --bg-sidebar-hover: rgb(var(--gray-100));
    --bg-sidebar-active: rgb(var(--gray-100));
    --text-primary: #ededed;
    --text-secondary: #a1a1aa;
    --text-sidebar: #a1a1aa;
    --text-sidebar-active: #ffffff;
    --border-color: #27272a;
    --accent: #ededed;
    --accent-light: #d4d4d8;
    --secondary: #7a67ff;
    --secondary-light: #9a8bff;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-card: 0px 1px 0 rgba(0,0,0,.2), 0px 2px 8px rgba(0,0,0,.35);

    --secondary-lighter: #2a2550;
    --muted: #333333;
    --shadow-profile: 0px 2px 4px -2px rgba(0,0,0,.4), 0px 4px 6px -1px rgba(0,0,0,.4);
    --shadow-rounded-card: 0px 4px 6px -4px rgba(0,0,0,.35), 0px 10px 15px -3px rgba(0,0,0,.35);
}

/* =============================================
   Base Styles
   ============================================= */
html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}
@media (min-width: 768px) {
    html { font-size: 15px; }
}

* {
    transition: background-color var(--transition-speed), color var(--transition-speed), border-color var(--transition-speed);
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6,
.card-title, .stat-card-info h3, .stat-card-value {
    font-family: 'Lexend Deca', 'Inter', sans-serif;
    font-weight: 600;
    color: var(--text-primary);
}
h1, .h1 { font-size: 1.95rem; }
h2, .h2 { font-size: 1.5rem; }
h3, .h3 { font-size: 1.25rem; }
h4, .h4 { font-size: 1.125rem; }
h5, .h5 { font-size: 1rem; }
h6, .h6 { font-size: 0.875rem; }

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--accent);
}

/* =============================================
   Sidebar
   ============================================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-inline-end: 2px solid var(--border-color);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-speed) ease, transform var(--transition-speed) ease;
    overflow: hidden;
    box-shadow: none;
}

.sidebar-brand {
    height: auto;
    display: flex;
    align-items: center;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.sidebar-brand img {
    height: 32px;
    max-width: 155px;
    transition: opacity var(--transition-speed);
}
.sidebar-brand .brand-text {
    font-family: 'Lexend Deca', 'Inter', sans-serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-left: 12px;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition-speed);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 0;
    scrollbar-width: thin;
    scrollbar-color: rgb(var(--gray-300)) transparent;
}
.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgb(var(--gray-300));
    border-radius: 4px;
}

.sidebar-section {
    margin-bottom: 8px;
}
.sidebar-section-title {
    padding: 12px 20px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgb(var(--gray-400));
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    margin: 2px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
}
.sidebar-link i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    margin-right: 12px;
    color: rgb(var(--gray-500));
}
.sidebar-link:hover {
    color: var(--text-sidebar-active);
    background: var(--bg-sidebar-hover);
}
.sidebar-link:hover i {
    color: var(--text-sidebar-active);
}
.sidebar-link.active {
    color: var(--text-sidebar-active);
    background: var(--bg-sidebar-active);
    font-weight: 600;
}
.sidebar-link.active i {
    color: var(--accent);
}
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 4px 4px 0;
}

/* Sidebar collapsed state */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .sidebar-link span {
    opacity: 0;
    pointer-events: none;
}
.sidebar.collapsed .sidebar-link {
    padding: 10px 0;
    justify-content: normal;
    margin: 2px 8px;
}
.sidebar.collapsed .sidebar-link i {
    margin-right: 0;
    font-size: 1.3rem;
}
.sidebar.collapsed .sidebar-link.active::before {
    display: none;
}

/* =============================================
   Main Content Area
   ============================================= */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left var(--transition-speed) ease;
    display: flex;
    flex-direction: column;
}
.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* Top Header Bar */
.top-header {
    height: var(--header-height);
    background: rgba(255,255,255,0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: none;
    transition: box-shadow 0.2s, background 0.2s, border-color 0.2s;
}
@media (min-width: 992px) {
    .top-header { padding: 0 24px; }
}
.top-header.scrolled {
    border-bottom-color: var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
[data-bs-theme="dark"] .top-header {
    background: rgba(24,24,27,0.72);
}
[data-bs-theme="dark"] .top-header.scrolled {
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.top-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}
.top-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
@media (min-width: 1200px) {
    .top-header-right { gap: 14px; }
}

/* Sidebar toggle button */
.sidebar-toggle {
    background: rgb(var(--gray-50));
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.sidebar-toggle:hover {
    background: rgb(var(--gray-100));
    color: var(--text-primary);
}

/* Breadcrumbs */
.breadcrumb-nav {
    font-size: 0.85rem;
}
.breadcrumb-nav a {
    color: var(--text-secondary);
    text-decoration: none;
}
.breadcrumb-nav a:hover {
    color: var(--secondary);
}
.breadcrumb-nav .separator {
    color: var(--text-secondary);
    margin: 0 8px;
}
.breadcrumb-nav .current {
    color: var(--text-primary);
    font-weight: 600;
}

/* Header icon buttons */
.header-icon-btn {
    position: relative;
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow-sm);
    border: none;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
@media (min-width: 768px) {
    .header-icon-btn { width: 36px; height: 36px; }
}
[data-bs-theme="dark"] .header-icon-btn {
    background: rgba(39,39,42,0.6);
}
.header-icon-btn:hover {
    background: rgb(var(--gray-100));
    color: var(--text-primary);
}
.header-icon-btn i {
    line-height: 1;
}
.header-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-card);
}

.sidebar-noti-badge {
    position: static;
    width: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    border: none;
    font-size: 0.7rem;
}

.sidebar.collapsed .sidebar-noti-badge {
    position: absolute;
    top: 4px;
    right: 8px;
    padding: 0;
    width: 18px;
    min-width: 18px;
    height: 18px;
    font-size: 0.6rem;
    border: 2px solid var(--bg-sidebar);
}

/* User profile dropdown */
.user-profile-btn {
    display: flex;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    transition: box-shadow 0.2s;
}
.user-profile-btn:hover, .user-profile-btn:focus-visible {
    box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 3.5px rgb(var(--gray-400));
    outline: none;
}
.user-profile-btn img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: var(--shadow-profile);
}
@media (min-width: 576px) {
    .user-profile-btn img { width: 40px; height: 40px; }
}

/* Profile dropdown panel (avatar+name header / plain menu list / sign-out footer).
   Uses data-bs-display="static" on its toggle (see _Topbar.cshtml) so Bootstrap
   skips Popper entirely - Popper miscalculates offsets when its offsetParent is
   a "position: sticky" ancestor (.top-header here), which was rendering this
   menu off-screen. Plain CSS positioning via .dropdown-menu-end (right:0) is
   reliable and is all this simple top-right menu needs. margin-top restores
   the small gap Popper's spacer modifier used to add. */
.profile-menu {
    width: 16rem;
    padding: 0;
    overflow: hidden;
    margin-top: 0.5rem;
}
.profile-menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-color);
}
.profile-menu-header img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.profile-menu-id h6 {
    margin: 0;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}
.profile-menu-id span {
    font-size: 0.78rem;
    color: var(--text-secondary);
    word-break: break-all;
}
.profile-menu-list {
    display: grid;
    padding: 10px;
    gap: 2px;
}
.profile-menu-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s;
}
.profile-menu-item:hover {
    background: rgb(var(--gray-100));
    color: var(--text-primary);
}
.profile-menu-footer {
    border-top: 1px solid var(--border-color);
    padding: 8px 10px;
}
.profile-menu-footer .btn-flat {
    text-decoration: none;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.profile-menu-footer .btn-flat:hover {
    background: rgb(var(--gray-100));
    color: var(--text-primary);
}

/* Page content */
.page-content {
    padding: 24px;
    flex: 1;
}

/* =============================================
   Notification Dropdown
   ============================================= */
.notification-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    z-index: 1060;
    display: none;
    overflow: hidden;
}
.notification-dropdown.show { display: block; }
.notification-dropdown-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
}
.notification-dropdown-body {
    max-height: 320px;
    overflow-y: auto;
}
.notification-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}
.notification-item:hover { background: var(--bg-primary); }
.notification-item.unread { background: rgba(var(--gray-900), 0.03); }
[data-bs-theme="dark"] .notification-item.unread { background: rgba(255,255,255,0.05); }
.notification-item .noti-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 2px;
}
.notification-item .noti-text {
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.notification-item .noti-time {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 4px;
}
.notification-dropdown-footer {
    padding: 10px 16px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}
.notification-dropdown-footer a {
    font-size: 0.85rem;
    color: var(--secondary);
    text-decoration: none;
    font-weight: 500;
}

/* Global search */
.global-search {
    display: none;
    flex: 1;
    max-width: 420px;
    margin: 0 16px;
}
@media (min-width: 992px) {
    .global-search { display: block; }
}
.global-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 0.95rem;
    pointer-events: none;
}
.global-search-input {
    width: 100%;
    height: 38px;
    padding: 0 14px 0 38px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.15s;
}
.global-search-input:focus { border-color: var(--accent); }
.global-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    z-index: 1060;
    display: none;
    max-height: 400px;
    overflow-y: auto;
}
.global-search-dropdown.show { display: block; }
.global-search-group-title {
    padding: 8px 14px 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}
.global-search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.15s;
}
.global-search-item:hover { background: var(--bg-primary); }
.global-search-item i { color: var(--accent); font-size: 1rem; }
.global-search-item .gs-title { font-size: 0.85rem; font-weight: 600; }
.global-search-item .gs-sub { font-size: 0.75rem; color: var(--text-secondary); }
.global-search-empty {
    padding: 16px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* =============================================
   Cards
   ============================================= */
.card {
    background: var(--bg-card);
    border: 5px solid var(--border-color);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.2s;
}
.card:hover {
    box-shadow: var(--shadow-md);
}
.card-body {
    padding: 20px;
}
@media (min-width: 992px) {
    .card-body { padding: 28px; }
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
}
@media (min-width: 992px) {
    .card-header { padding: 20px 28px; }
}
.card-title {
    font-family: 'Lexend Deca', 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 600;
}

/* KPI Stat Cards */
.stat-card {
    background: var(--bg-card);
    border: 5px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.stat-card-icon.bg-accent { background: rgba(var(--gray-900), 0.08) !important; color: var(--accent); }
.stat-card-icon.bg-success { background: rgba(17,168,73,0.12) !important; color: var(--success); }
.stat-card-icon.bg-warning { background: rgba(245,166,35,0.12) !important; color: var(--warning); }
.stat-card-icon.bg-info { background: rgba(0,112,243,0.12) !important; color: var(--info); }
.stat-card-icon.bg-danger { background: rgba(238,0,0,0.12) !important; color: var(--danger); }
.stat-card-info h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}
.stat-card-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
}
.stat-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 8px;
}
.stat-badge.up { background: rgba(17,168,73,0.12); color: var(--success); }
.stat-badge.down { background: rgba(238,0,0,0.12); color: var(--danger); }

/* Flat/typographic KPI card (theme's minimal stat-card convention - no
   icon, no gradient, just label/value/caption hierarchy). */
.stat-card-flat {
    background: var(--bg-card);
    border: 5px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 24px;
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.2s;
}
.stat-card-flat:hover {
    box-shadow: var(--shadow-md);
}
.stat-card-flat-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}
.stat-card-flat-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.stat-card-flat-value {
    font-size: 1.85rem;
    font-weight: 500;
    color: var(--text-primary);
    font-family: 'Lexend Deca', 'Inter', sans-serif;
    line-height: 1.2;
}
.stat-card-flat-caption {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 6px;
}
.stat-card-flat-caption strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* =============================================
   Badges (flat / tinted style)
   ============================================= */
.badge {
    border-radius: var(--radius-badge);
    font-weight: 500;
    padding: 0.3rem 0.7rem;
    font-size: 0.72rem;
}
.badge.text-bg-primary, .badge.bg-primary {
    background: rgba(var(--gray-900), 0.1) !important;
    color: var(--text-primary) !important;
}
.badge.text-bg-success, .badge.bg-success {
    background: rgba(17,168,73,0.12) !important;
    color: var(--success) !important;
}
.badge.text-bg-warning, .badge.bg-warning {
    background: rgba(245,166,35,0.15) !important;
    color: var(--warning) !important;
}
.badge.text-bg-danger, .badge.bg-danger {
    background: rgba(238,0,0,0.12) !important;
    color: var(--danger) !important;
}
.badge.text-bg-info, .badge.bg-info {
    background: rgba(0,112,243,0.12) !important;
    color: var(--info) !important;
}
.badge.text-bg-secondary, .badge.bg-secondary {
    background: var(--secondary-lighter) !important;
    color: var(--secondary) !important;
}

/* =============================================
   Tables
   ============================================= */
.table {
    --bs-table-bg: var(--bg-card);
    --bs-table-border-color: var(--border-color);
    --bs-table-hover-bg: rgb(var(--gray-50));
    color: var(--text-secondary);
}
.table thead {
    background: rgb(var(--gray-50)) !important;
}
.table thead th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 12px 15px;
    border: none;
    border-bottom: 1px solid var(--border-color) !important;
    color: rgb(var(--gray-500)) !important;
    background: transparent !important;
}
.table thead th a,
.table thead th .DataTables_sort_wrapper {
    color: rgb(var(--gray-500)) !important;
}
.table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}
.table tbody tr:hover {
    background: rgb(var(--gray-50)) !important;
    cursor: pointer;
}
/* Status row color coding */
.status-row-enrolled { border-left: 3px solid var(--success); }
.status-row-applied { border-left: 3px solid var(--info); }
.status-row-potential { border-left: 3px solid var(--accent); }
.status-row-followup { border-left: 3px solid var(--warning); }
.status-row-notinterested { border-left: 3px solid var(--danger); }
.status-row-new { border-left: 3px solid var(--text-secondary); }

/* DataTables overrides */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: var(--text-primary);
    padding: 8px 0;
}
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 8px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--text-primary) !important;
    border-radius: 6px !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--accent) !important;
    color: var(--bg-secondary) !important;
    border-color: var(--accent) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}
/* DataTables sorting header fix */
table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc,
table.dataTable thead th.sorting::before,
table.dataTable thead th.sorting::after,
table.dataTable thead th.sorting_asc::before,
table.dataTable thead th.sorting_asc::after,
table.dataTable thead th.sorting_desc::before,
table.dataTable thead th.sorting_desc::after {
    color: rgb(var(--gray-500)) !important;
}
table.dataTable thead .sorting::before,
table.dataTable thead .sorting_asc::before,
table.dataTable thead .sorting_desc::before,
table.dataTable thead .sorting::after,
table.dataTable thead .sorting_asc::after,
table.dataTable thead .sorting_desc::after {
    opacity: 0.6;
}
table.dataTable thead .sorting_asc::before,
table.dataTable thead .sorting_desc::after {
    opacity: 1;
}
.table-info {
    --bs-table-bg: rgba(var(--gray-900), 0.06);
    color: var(--text-primary);
}
/* Safety net for stray Bootstrap-4-era classes left on markup that
   hasn't been swept yet - the header/row already themes correctly via
   the .table thead rule above, so these just neutralize hardcoded BS4
   colors that don't track dark mode. */
.table thead.thead-dark,
.table thead.thead-dark th {
    background: rgb(var(--gray-50)) !important;
    color: rgb(var(--gray-500)) !important;
    border: none !important;
}

/* =============================================
   Forms
   ============================================= */
.form-control, .form-select {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    min-height: 40px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
textarea.form-control {
    min-height: 0;
}
.form-control::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}
.form-control:focus, .form-select:focus {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(var(--gray-900), 0.12);
}
.form-control:hover:not(:focus):not(:disabled), .form-select:hover:not(:focus):not(:disabled) {
    border-color: rgb(var(--gray-400));
}
.form-control.is-invalid, .form-select.is-invalid {
    border-color: var(--danger);
}
.form-control.is-invalid:focus, .form-select.is-invalid:focus {
    box-shadow: 0 0 0 2px rgba(238,0,0,0.15);
}
.form-control-sm, .form-select-sm {
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    min-height: 32px;
    border-radius: 0.3rem;
}
.form-label {
    font-weight: 500;
    font-size: 0.82rem;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.input-group-text {
    background: rgb(var(--gray-50));
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.form-text, .invalid-feedback {
    font-size: 0.72rem;
    margin-top: 4px;
}
.invalid-feedback {
    color: var(--danger);
}
.btn {
    border-radius: var(--radius-sm);
}
.btn-primary {
    background-color: var(--accent);
    border-color: var(--accent);
    color: var(--bg-secondary);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--accent-light);
    border-color: var(--accent-light);
    color: var(--bg-secondary);
}
.btn-secondary {
    background-color: var(--secondary);
    border-color: var(--secondary);
    color: #fff;
}
.btn-secondary:hover, .btn-secondary:focus, .btn-secondary:active {
    background-color: var(--secondary-light);
    border-color: var(--secondary-light);
    color: #fff;
}
.btn-outline-primary {
    border-color: var(--border-color);
    color: var(--text-primary);
}
.btn-outline-primary:hover {
    background-color: var(--accent);
    border-color: var(--accent);
    color: var(--bg-secondary);
}
.btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}
.btn-outline-secondary:hover, .btn-outline-secondary:focus, .btn-outline-secondary:active {
    background-color: rgb(var(--gray-500));
    border-color: rgb(var(--gray-500));
    color: var(--bg-secondary);
}
.btn-success, .btn-outline-success:hover, .btn-outline-success:focus, .btn-outline-success:active {
    background-color: var(--success);
    border-color: var(--success);
    color: #fff;
}
.btn-warning, .btn-outline-warning:hover, .btn-outline-warning:focus, .btn-outline-warning:active {
    background-color: var(--warning);
    border-color: var(--warning);
    color: #fff;
}
.btn-danger, .btn-outline-danger:hover, .btn-outline-danger:focus, .btn-outline-danger:active {
    background-color: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.btn-info, .btn-outline-info:hover, .btn-outline-info:focus, .btn-outline-info:active {
    background-color: var(--info);
    border-color: var(--info);
    color: #fff;
}
.btn-outline-success {
    border-color: var(--success);
    color: var(--success);
}
.btn-outline-warning {
    border-color: var(--warning);
    color: var(--warning);
}
.btn-outline-danger {
    border-color: var(--danger);
    color: var(--danger);
}
.btn-outline-info {
    border-color: var(--info);
    color: var(--info);
}
.btn-light {
    background-color: rgb(var(--gray-100));
    border-color: rgb(var(--gray-100));
    color: var(--text-primary);
}
.btn-light:hover, .btn-light:focus, .btn-light:active {
    background-color: rgb(var(--gray-200));
    border-color: rgb(var(--gray-200));
    color: var(--text-primary);
}
.text-bg-secondary {
    color: var(--bg-secondary) !important;
    background-color: rgb(var(--gray-500)) !important;
}
.link-secondary {
    color: rgb(var(--gray-500)) !important;
}
.btn-sm {
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
}
.btn-flat, .btn-link {
    font-weight: 500;
    text-decoration: underline;
    color: var(--secondary);
    padding: 0;
}
.btn-flat:hover, .btn-link:hover {
    color: var(--secondary-light);
}

/* =============================================
   Modals
   ============================================= */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-rounded-card);
}
.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.1rem 1.25rem;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}
.modal-body:last-child,
.modal-footer:last-child {
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
}
@media (min-width: 992px) {
    .modal-header { padding: 1.25rem 1.75rem; }
}
.modal-header .modal-title {
    font-family: 'Lexend Deca', 'Inter', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary);
}
.modal-header .btn-close {
    box-shadow: none;
}
.modal-body {
    padding: 1.25rem;
}
@media (min-width: 992px) {
    .modal-body { padding: 1.75rem; }
}
.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    gap: 8px;
}
@media (min-width: 992px) {
    .modal-footer { padding: 1rem 1.75rem; }
}
.modal-backdrop.show { opacity: 0.5; }
[data-bs-theme="dark"] .modal-backdrop.show { opacity: 0.7; }
.modal.fade .modal-dialog {
    transform: translateY(-16px) scale(0.98);
}
.modal.show .modal-dialog {
    transform: none;
}
.btn-close { filter: none; }
[data-bs-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* =============================================
   Dropdowns
   ============================================= */
/* The bundled theme CSS overrides Bootstrap's default ".dropdown { position:
   relative }" down to "position: static". That forces any ".dropdown-menu"
   (position: absolute) to look further up the tree for its containing
   block/offsetParent, which lands on ".top-header" - a "position: sticky"
   ancestor. Popper.js miscalculates offsets against sticky offsetParents
   (sticky reports different "static" vs. "stuck" geometry to different
   position APIs), so menus like .profile-menu render in the wrong spot.
   Restoring position:relative here keeps the small, non-sticky .dropdown
   wrapper itself as the offsetParent. */
.dropdown {
    position: relative;
}
.dropdown-menu {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-md);
    padding: 6px;
}
.dropdown-item {
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.875rem;
}
.dropdown-item:hover {
    background: rgb(var(--gray-100));
    color: var(--text-primary);
}

/* =============================================
   Select2 Overrides
   ============================================= */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 0.375rem;
    min-height: 40px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 38px;
}
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(var(--gray-900), 0.12);
}
.select2-dropdown {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    box-shadow: var(--shadow-md);
}
.select2-search--dropdown .select2-search__field {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.3rem;
    color: var(--text-primary);
}
.select2-results__option--highlighted {
    background: rgb(var(--gray-100)) !important;
    color: var(--text-primary) !important;
}
.select2-results__option[aria-selected="true"] {
    background: rgba(var(--gray-900), 0.06) !important;
    font-weight: 500;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text-primary);
    line-height: 38px;
}

/* =============================================
   Timeline
   ============================================= */
.timeline {
    position: relative;
    padding-left: 30px;
}
.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}
.timeline-item {
    position: relative;
    padding-bottom: 20px;
    display: flex;
    gap: 15px;
}
.timeline-marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
    position: absolute;
    left: -25px;
}
.timeline-content {
    flex: 1;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

/* =============================================
   Activity Feed
   ============================================= */
.activity-feed-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    margin: 0 -12px;
    border-radius: var(--radius-sm);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}
.activity-feed-item:hover {
    background: rgb(var(--gray-50));
}
.activity-feed-item:last-child { border-bottom: none; }
.activity-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    margin-top: 2px;
}
.activity-feed-item .activity-text {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-primary);
}
.activity-feed-item .activity-text strong {
    font-weight: 600;
}
.activity-feed-item .activity-time {
    font-size: 0.72rem;
    color: var(--text-secondary);
}
.activity-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 3px;
}
.activity-detail {
    font-size: 0.72rem;
    color: var(--text-secondary);
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Scrollable feed wrapper with a bottom fade-out mask, so a long list
   hints at more content below instead of ending in a hard cut. */
.activity-feed-wrap {
    position: relative;
}
.activity-feed-scroll {
    max-height: 320px;
    overflow-y: auto;
}
.activity-feed-fade {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 32px;
    pointer-events: none;
    background: linear-gradient(to top, var(--bg-card), transparent);
}

/* =============================================
   Lead Score Badge
   ============================================= */
.lead-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
}
.lead-score.score-hot { background: rgba(238,0,0,0.12); color: var(--danger); }
.lead-score.score-warm { background: rgba(245,166,35,0.15); color: var(--warning); }
.lead-score.score-cold { background: rgb(var(--gray-100)); color: var(--text-secondary); }

/* =============================================
   Sticky Filter Bar
   ============================================= */
.filter-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-card);
}
.filter-panel.sticky {
    position: sticky;
    top: calc(var(--header-height) + 8px);
    z-index: 100;
}
.filter-toggle-btn {
    background: none;
    border: none;
    color: var(--secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
}
.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

/* =============================================
   Kanban Board
   ============================================= */
.kanban-board {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 20px;
    min-height: 70vh;
}
.kanban-column {
    min-width: 280px;
    max-width: 300px;
    background: rgb(var(--gray-50));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    display: flex;
    flex-direction: column;
}
.kanban-column-header {
    padding: 12px;
    font-weight: 600;
    text-align: center;
    border-radius: var(--radius-card) var(--radius-card) 0 0;
    color: white;
    position: sticky;
    top: 0;
    font-size: 0.9rem;
}
.kanban-column-header.wip-exceeded {
    animation: pulse-red 1.5s infinite;
}
@keyframes pulse-red {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: inset 0 0 0 2px rgba(238,0,0,0.5); }
}
.kanban-cards {
    padding: 8px;
    flex: 1;
    overflow-y: auto;
    max-height: 65vh;
}
.kanban-card {
    background: var(--bg-card);
    border: 5px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-bottom: 8px;
    cursor: grab;
    transition: box-shadow 0.2s, transform 0.2s;
    border-left: 3px solid transparent;
    box-shadow: var(--shadow-card);
}
.kanban-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.kanban-card .card-name { font-weight: 600; font-size: 0.88rem; }
.kanban-card .card-meta { font-size: 0.78rem; color: var(--text-secondary); margin-top: 4px; }
.kanban-card .card-score { float: right; }
.kanban-count { font-size: 0.8rem; opacity: 0.85; }

/* Card aging colors */
.kanban-card.age-fresh { border-left-color: var(--success); }
.kanban-card.age-warm { border-left-color: var(--warning); }
.kanban-card.age-stale { border-left-color: var(--danger); }

.stage-new { background: rgb(var(--gray-500)); }
.stage-potential { background: var(--secondary); }
.stage-followup { background: var(--warning); }
.stage-applied { background: var(--info); }
.stage-enrolled { background: var(--success); }
.stage-notinterested { background: var(--danger); }
.stage-locations { background: #8b5cf6; }
.sortable-ghost { opacity: 0.4; }

/* =============================================
   Lead Details modal (Kanban) and shared gradient
   modal-header pattern used by its sibling modals.
   ============================================= */
.modal-header-gradient {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    padding: 1.1rem 1.25rem;
    gap: 12px;
    border-bottom: none;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}
@media (min-width: 992px) {
    .modal-header-gradient { padding: 1.25rem 1.75rem; }
}
.modal-header-gradient .modal-title {
    color: #fff;
    font-family: 'Lexend Deca', 'Inter', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
}
.modal-header-gradient .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    opacity: 0.85;
}
.modal-header-gradient .btn-close:hover { opacity: 1; }
.modal-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255,255,255,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    flex-shrink: 0;
}

/* Client info grid (top of Lead Details modal) */
.client-info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
@media (max-width: 767.98px) {
    .client-info-grid { grid-template-columns: repeat(2, 1fr); }
}
.info-card {
    background: var(--bg-card);
    border: 5px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}
.info-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: rgb(var(--gray-500));
    margin-bottom: 4px;
}
.info-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
}

/* Status tabs inside the modal body (reuses the settings-tabs visual language) */
.status-modal-tabs .nav-link {
    color: var(--text-secondary);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 500;
}
.status-modal-tabs .nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: transparent;
}

/* Reminder box (Update tab) */
.reminder-box {
    background: rgb(var(--gray-50));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

/* Section header (Files tab) */
.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 0.9rem;
}
.section-header i { color: rgb(var(--gray-400)); font-size: 1.1rem; }
.section-header h6 { margin: 0; font-weight: 600; font-size: 0.85rem; }

/* Uploaded file rows */
.file-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 5px solid var(--border-color);
    border-radius: var(--radius-sm);
}
.file-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: rgba(var(--gray-900), 0.06);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.file-name {
    flex: 1;
    font-size: 0.85rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Timeline (Client Timeline modal, opened from Lead Details) */
.timeline-modern {
    position: relative;
    padding-left: 8px;
}
.timeline-entry {
    position: relative;
    padding-left: 22px;
    padding-bottom: 18px;
    border-left: 2px solid var(--border-color);
    margin-left: 6px;
}
.timeline-entry:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline-entry::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-secondary);
    border: 2px solid var(--bg-card);
}
.timeline-entry.te-success::before { background: var(--success); }
.timeline-entry.te-warning::before { background: var(--warning); }
.timeline-entry.te-danger::before { background: var(--danger); }
.timeline-entry.te-info::before { background: var(--info); }
.timeline-entry-card {
    background: var(--bg-card);
    border: 5px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
}
.te-title { font-weight: 600; font-size: 0.88rem; color: var(--text-primary); }
.te-desc { font-size: 0.82rem; color: var(--text-secondary); margin-top: 2px; }
.te-meta {
    display: flex;
    gap: 14px;
    margin-top: 6px;
    font-size: 0.75rem;
    color: rgb(var(--gray-400));
}

/* =============================================
   Bulk Action Toolbar
   ============================================= */
.bulk-toolbar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width);
    right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 12px 24px;
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 1020;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
    transition: left var(--transition-speed);
}
.bulk-toolbar.show { display: flex; }
.bulk-toolbar .selected-count {
    font-weight: 600;
    color: var(--secondary);
    font-size: 0.9rem;
}

/* =============================================
   Settings Tabs
   ============================================= */
.settings-tabs .nav-link {
    color: var(--text-secondary);
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 20px;
    font-weight: 500;
}
.settings-tabs .nav-link.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: transparent;
}

/* =============================================
   Alerts (flat/tinted, matches badge convention)
   ============================================= */
.alert {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    padding: 12px 16px;
}
.alert-success { background: rgba(17,168,73,0.1); border-color: rgba(17,168,73,0.25); color: var(--success); }
.alert-danger { background: rgba(238,0,0,0.08); border-color: rgba(238,0,0,0.2); color: var(--danger); }
.alert-warning { background: rgba(245,166,35,0.1); border-color: rgba(245,166,35,0.25); color: var(--warning); }
.alert-info { background: rgba(0,112,243,0.1); border-color: rgba(0,112,243,0.25); color: var(--info); }

/* =============================================
   Account Manage page (vertical nav + content card)
   ============================================= */
.manage-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.manage-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: background-color 0.15s, color 0.15s;
}
.manage-nav .nav-link i {
    font-size: 1.05rem;
    color: rgb(var(--gray-400));
    flex-shrink: 0;
}
.manage-nav .nav-link:hover {
    background: rgb(var(--gray-100));
    color: var(--text-primary);
}
.manage-nav .nav-link.active {
    background: var(--accent);
    color: var(--bg-secondary);
    font-weight: 600;
}
.manage-nav .nav-link.active i {
    color: var(--bg-secondary);
}
.recovery-code {
    display: inline-block;
    background: rgb(var(--gray-50));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    margin: 2px 4px 2px 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
}
.manage-content {
    border-inline-start: 1px solid var(--border-color);
    padding-inline-start: 28px;
}
@media (max-width: 767.98px) {
    .manage-content {
        border-inline-start: none;
        padding-inline-start: 0;
        margin-top: 20px;
        padding-top: 20px;
        border-top: 1px solid var(--border-color);
    }
}

/* =============================================
   Responsive Design
   ============================================= */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0 !important;
    }
    .bulk-toolbar {
        left: 0;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1035;
    }
    .sidebar-overlay.show { display: block; }
}

@media (max-width: 768px) {
    .page-content {
        padding: 16px;
    }
    .filter-row {
        grid-template-columns: 1fr 1fr;
    }
    .stat-card {
        padding: 14px;
    }
    .stat-card-info h3 {
        font-size: 1.2rem;
    }
}

/* =============================================
   Utility / Misc
   ============================================= */
.bg-light {
    background-color: var(--bg-primary) !important;
}
.border {
    border-color: var(--border-color) !important;
}
.shadow-sm {
    box-shadow: var(--shadow-sm) !important;
}
.text-muted {
    color: var(--text-secondary) !important;
}

/* Print styles */
@media print {
    .sidebar, .top-header, .bulk-toolbar { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
}

/* WhatsApp button */
.wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #25D366;
    font-size: 0.85rem;
    text-decoration: none;
}
.wa-btn:hover { color: #128C7E; }

/* =============================================
   ApexCharts tooltip (matches the theme's card-style
   tooltip: bordered/shadowed body + a shaded label header)
   ============================================= */
.apexcharts-tooltip {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    box-shadow: var(--shadow-md) !important;
    font-family: 'Inter', sans-serif !important;
    overflow: hidden;
}
.apexcharts-tooltip-title {
    background: rgb(var(--gray-50)) !important;
    border-bottom: 1px solid var(--border-color) !important;
    font-family: 'Lexend Deca', 'Inter', sans-serif !important;
    font-weight: 600 !important;
    font-size: 0.75rem !important;
    text-align: center;
    color: var(--text-primary) !important;
    padding: 6px 10px !important;
}
.apexcharts-tooltip-series-group {
    padding: 4px 10px !important;
    font-size: 0.75rem !important;
}
.apexcharts-tooltip-text-y-value, .apexcharts-tooltip-text-goals-value {
    font-weight: 600 !important;
    color: var(--text-primary) !important;
}
.apexcharts-tooltip-marker {
    width: 8px !important;
    height: 8px !important;
}
.apexcharts-xaxistooltip, .apexcharts-yaxistooltip {
    background: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}
.apexcharts-legend-text {
    color: var(--text-secondary) !important;
    font-size: 0.78rem !important;
}
.apexcharts-menu {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    box-shadow: var(--shadow-md) !important;
}
.apexcharts-menu-item:hover {
    background: rgb(var(--gray-100)) !important;
}

/* Saved filter chips */
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}
.filter-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.filter-chip .remove-chip {
    font-size: 0.7rem;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Calendar overrides */
.fc { background: var(--bg-card); border-radius: var(--radius-card); }
.fc .fc-toolbar-title { font-family: 'Lexend Deca', 'Inter', sans-serif; font-size: 1.2rem; font-weight: 600; color: var(--text-primary); }
.fc .fc-button {
    background: transparent !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
    box-shadow: none !important;
}
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: var(--bg-secondary) !important;
}
.fc .fc-today-button {
    text-transform: capitalize;
}
.fc-daygrid-day.fc-day-today,
.fc-timegrid-col.fc-day-today {
    background: rgba(var(--gray-900), 0.04) !important;
}
.fc-event { border-radius: 4px !important; }
.fc-theme-standard td, .fc-theme-standard th {
    border-color: var(--border-color);
}

/* Spinner icon animation (used for in-progress button states) */
@keyframes icon-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.icon-spin { display: inline-block; animation: icon-spin 0.9s linear infinite; }

/* Scrollbar global */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Modal extra-large */
.modal-xxl { max-width: 85%; }

/* Theme icon partial (_ThemeIcon.cshtml) */
.theme-icon { display: inline-flex; width: 1em; height: 1em; }
.theme-icon svg { width: 100%; height: 100%; }

/* Page-header icon chip, reused across page headers instead of being
   copy-pasted as an inline style per view. */
.page-icon-chip {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bg-secondary);
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* =============================================
   Auth Pages (Login / split-screen layout)
   ============================================= */
.auth-split {
    min-height: 100vh;
    display: flex;
    background: var(--bg-primary);
}
.auth-split-left {
    flex: 1 1 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
}
.auth-split-right {
    flex: 1 1 50%;
    background: var(--secondary-lighter);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    position: relative;
    overflow: hidden;
}
.auth-illustration {
    width: 100%;
    max-width: 420px;
}
@media (max-width: 991.98px) {
    .auth-split-right { display: none; }
}
.auth-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
}
.auth-logo { display: block; text-align: center; margin-bottom: 24px; }
.auth-logo img { max-width: 170px; }
.auth-title {
    font-family: 'Lexend Deca', 'Inter', sans-serif;
    font-weight: 600;
    font-size: 1.6rem;
    text-align: center;
    margin-bottom: 4px;
    color: var(--text-primary);
}
.auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 28px;
}
.auth-field { position: relative; margin-bottom: 18px; }
.auth-field label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-primary);
    margin-bottom: 6px;
    display: block;
}
.auth-field .auth-icon {
    position: absolute;
    left: 14px;
    top: 40px;
    color: rgb(var(--gray-400));
    font-size: 1.05rem;
    pointer-events: none;
}
.auth-field input.form-control { padding-left: 40px; height: 46px; }
.auth-remember { display: flex; align-items: center; margin-bottom: 24px; }
.auth-remember label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.auth-submit { width: 100%; height: 46px; font-weight: 600; font-size: 0.95rem; }
.auth-footer {
    text-align: center;
    margin-top: 28px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* =============================================
   Motion (kept subtle/short - entrance + feedback
   only, nothing that delays perceived load)
   ============================================= */
@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes badge-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(238,0,0,0.35); }
    50% { box-shadow: 0 0 0 4px rgba(238,0,0,0); }
}

@media (prefers-reduced-motion: no-preference) {
    /* Note: intentionally NOT animating .page-content itself - every
       Bootstrap modal in the app is a position:fixed descendant of it,
       and animating opacity/transform on an ancestor traps position:fixed
       children inside that ancestor's stacking context, making the
       body-level .modal-backdrop render in front of the modal instead
       of behind it. Animate only elements that never contain a modal. */
    .auth-split-left, .auth-split-right {
        animation: fade-in-up 0.4s ease both;
    }

    /* Stagger the first row of cards/stat cards so a dashboard doesn't
       just snap in as one flat block. Scoped to direct row/grid children
       so deeply nested cards (inside modals, kanban, etc.) aren't affected. */
    .row > div > .stat-card-flat,
    .row > div > .stat-card,
    .row > div > .card {
        animation: fade-in-up 0.4s ease both;
    }
    .row > div:nth-child(1) > .stat-card-flat, .row > div:nth-child(1) > .stat-card, .row > div:nth-child(1) > .card { animation-delay: 0.02s; }
    .row > div:nth-child(2) > .stat-card-flat, .row > div:nth-child(2) > .stat-card, .row > div:nth-child(2) > .card { animation-delay: 0.06s; }
    .row > div:nth-child(3) > .stat-card-flat, .row > div:nth-child(3) > .stat-card, .row > div:nth-child(3) > .card { animation-delay: 0.1s; }
    .row > div:nth-child(4) > .stat-card-flat, .row > div:nth-child(4) > .stat-card, .row > div:nth-child(4) > .card { animation-delay: 0.14s; }
    .row > div:nth-child(5) > .stat-card-flat, .row > div:nth-child(5) > .stat-card, .row > div:nth-child(5) > .card { animation-delay: 0.18s; }

    .activity-feed-item, .activity-item, .timeline-entry, .notification-item {
        animation: fade-in 0.3s ease both;
    }

    .modal.fade .modal-dialog {
        transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.25s ease;
    }
    .dropdown-menu {
        animation: fade-in-up 0.15s ease both;
    }
    .kanban-card {
        transition: box-shadow 0.2s, transform 0.2s;
    }
    .kanban-card:active {
        transform: scale(1.02) rotate(1deg);
        box-shadow: var(--shadow-md);
    }
}

/* Button/link press feedback - kept outside the reduced-motion guard
   since it's an instant feedback cue, not a decorative entrance. */
.btn, .header-icon-btn, .sidebar-toggle, .user-profile-btn {
    transition: transform 0.15s ease, background-color 0.2s, color 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.btn:active, .header-icon-btn:active, .sidebar-toggle:active {
    transform: scale(0.96);
}

/* Notification bell badge pulses while there are unread items */
.header-badge {
    animation: badge-pulse 1.8s ease-in-out infinite;
}
