:root {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #93c5fd;
    --secondary-color: #64748b;
    --success-color: #059669;
    --danger-color: #dc2626;
    --warning-color: #d97706;
    --info-color: #0891b2;
    --dark-color: #1e293b;
    --light-color: #f8fafc;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --bg-gradient: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
    --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --card-shadow-hover: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --transition: all 0.2s ease-in-out;
    --section-spacing: 2rem;
    --card-spacing: 1.5rem;
    --mobile-section-spacing: 1.5rem;
    --mobile-card-spacing: 1rem;
    /* Bootstrap interop (light theme fallback) */
    --bs-body-bg: #ffffff;
}

/* Dark theme variables */
[data-theme="dark"] {
    --primary-color: #60a5fa;
    --primary-dark: #3b82f6;
    --primary-light: #93c5fd;
    --secondary-color: #94a3b8;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #38bdf8;
    --dark-color: #0b1220;
    --light-color: #0f172a;
    --border-color: #1f2a44;
    --text-primary: #e5e7eb;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --bg-gradient: linear-gradient(135deg, #0b1220 0%, #0f172a 100%);
    --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.6), 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --card-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.6);
    /* Bootstrap variable overrides for dark theme */
    --bs-body-bg: #0b1220;
    --bs-body-color: #e5e7eb;
    --bs-dropdown-bg: #0f172a;
    --bs-dropdown-link-color: #cbd5e1;
    --bs-dropdown-link-hover-bg: #111827;
    --bs-card-bg: #0f172a;
    --bs-card-border-color: #1f2a44;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8fafc;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 0.95rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Base backgrounds in dark theme */
[data-theme="dark"] body {
    background: #0b1220;
}

main {
    flex: 1 0 auto;
    display: block;
    padding-bottom: var(--section-spacing);
}

/* Enhanced Container Layout */
.container {
    max-width: 1400px;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

/* Improved Section Spacing */
.section-spacing {
    margin-bottom: var(--section-spacing);
}

.section-spacing:last-child {
    margin-bottom: 0;
}

/* Enhanced Card Layout */
.card {
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    border-radius: var(--border-radius);
    transition: var(--transition);
    background: white;
    /* Allow dropdown menus within cards to overflow properly */
    overflow: visible;
    margin-bottom: var(--card-spacing);
}

[data-theme="dark"] .card,
[data-theme="dark"] .modal-content,
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .mobile-table-row,
[data-theme="dark"] .table tr {
    background: #0f172a !important;
    color: var(--text-secondary);
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .card-header,
[data-theme="dark"] .alert,
[data-theme="dark"] .table td,
[data-theme="dark"] .table th {
    background: #0f172a;
    color: var(--text-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .card a:hover .card-body { background-color: #111827; }
[data-theme="dark"] .dropdown-item { background-color: #0f172a !important; color: var(--text-secondary) !important; }
[data-theme="dark"] .dropdown-item:hover { background-color: #111827 !important; }
[data-theme="dark"] .navbar .dropdown-menu { --bs-dropdown-bg: #0f172a; }

.card:last-child {
    margin-bottom: 0;
}

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

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

.card a:hover {
    text-decoration: none;
}

/* Quick action card hover effects */
.card a:hover .card-body {
    background-color: var(--light-color);
}

.card a:hover .bg-primary.bg-opacity-10 {
    background-color: rgba(59, 130, 246, 0.2) !important;
}

.card a:hover .bg-secondary.bg-opacity-10 {
    background-color: rgba(100, 116, 139, 0.2) !important;
}

.card a:hover .bg-info.bg-opacity-10 {
    background-color: rgba(8, 145, 178, 0.2) !important;
}

.card a:hover .bg-warning.bg-opacity-10 {
    background-color: rgba(217, 119, 6, 0.2) !important;
}

.card-header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.card-body {
    padding: 1.75rem;
}

/* Enhanced Button Layout */
.btn {
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    padding: 0.75rem 1.25rem;
    transition: var(--transition);
    border: none;
    position: relative;
    font-size: 0.95rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    gap: 0.5rem;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
}

/* Soft button variants */
.btn-soft-primary {
    color: var(--primary-color);
    background: rgba(59,130,246,0.1);
    border: 1px solid rgba(59,130,246,0.2);
}
.btn-soft-primary:hover { background: rgba(59,130,246,0.15); }

.btn-soft-secondary {
    color: var(--text-secondary);
    background: rgba(148,163,184,0.12);
    border: 1px solid rgba(148,163,184,0.25);
}
.btn-soft-secondary:hover { background: rgba(148,163,184,0.18); }

.btn-soft-success {
    color: #166534;
    background: rgba(34,197,94,0.12);
    border: 1px solid rgba(34,197,94,0.25);
}
.btn-soft-success:hover { background: rgba(34,197,94,0.18); }

.btn-soft-danger {
    color: #991b1b;
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.25);
}
.btn-soft-danger:hover { background: rgba(239,68,68,0.18); }

/* Icon-only buttons */
.btn-icon {
    padding: 0.5rem;
    width: 36px;
    height: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon.btn-sm { width: 32px; height: 32px; min-height: 32px; }
.btn-icon i { font-size: 0.95rem; }

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #047857;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.3);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.3);
}

.btn-outline-primary {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.btn-outline-secondary {
    border: 2px solid var(--border-color);
    color: var(--text-secondary);
    background: transparent;
}

.btn-outline-secondary:hover {
    background: var(--light-color);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

[data-theme="dark"] .btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}
[data-theme="dark"] .btn-outline-secondary:hover {
    background: #111827;
    border-color: var(--text-secondary);
    color: var(--text-primary);
}
/* Outline light buttons on dark backgrounds */
[data-theme="dark"] .btn-outline-light {
    border: 2px solid #e5e7eb;
    color: #e5e7eb;
    background: transparent;
}
[data-theme="dark"] .btn-outline-light:hover {
    background: #e5e7eb;
    color: #0b1220;
    border-color: #e5e7eb;
}

/* Keep outline secondary buttons light when opened/active */
.btn-outline-secondary:focus,
.btn-outline-secondary:active,
.btn-outline-secondary.dropdown-toggle.show,
.show > .btn-outline-secondary.dropdown-toggle {
    background: var(--light-color);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

/* Unify small/large sizes */
.btn-sm {
    padding: 0.4rem 0.65rem;
    font-size: 0.85rem;
    min-height: 36px;
}
.btn-lg {
    padding: 0.9rem 1.25rem;
    font-size: 1.05rem;
    min-height: 50px;
}

/* Enhanced Form Layout */
.form-control, .form-select {
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 1rem 1.25rem;
    font-size: 1rem;
    transition: var(--transition);
    background: white;
    min-height: 52px;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: #0f172a;
    color: var(--text-primary);
}
[data-theme="dark"] .form-text { color: var(--text-muted); }
[data-theme="dark"] .form-control::placeholder { color: #64748b; }
[data-theme="dark"] .form-select option { background: #0f172a; color: var(--text-primary); }

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    outline: none;
}

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

/* Enhanced Table Layout */
.table {
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    margin-bottom: 0;
}

.table th {
    background: var(--light-color);
    border: none;
    font-weight: 600;
    color: var(--text-primary);
    padding: 1.25rem 1rem;
    text-transform: none;
    font-size: 0.9rem;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    color: var(--text-secondary);
}

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

.table tbody tr:hover {
    background: var(--light-color);
    transform: scale(1.01);
}

[data-theme="dark"] .table tbody tr:hover {
    background: #111827;
}

/* Consistent table action groups */
.table td,
.table th {
    vertical-align: middle;
}

.actions-cell {
    white-space: nowrap;
}

.table td .btn-group {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
}

/* Ensure grouped action buttons sit flush with no gaps */
.btn-group > .btn,
.btn-group .btn-action {
    margin: 0;
}
.btn-group > .btn + .btn,
.btn-group > .btn + .btn-group,
.btn-group > .btn-group + .btn,
.btn-group > .btn-group + .btn-group {
    margin-left: -1px; /* collapse borders */
}
.btn-group .btn-action {
    border-radius: 0;
}
.btn-group .btn-action:first-child {
    border-top-left-radius: var(--border-radius-sm);
    border-bottom-left-radius: var(--border-radius-sm);
}
.btn-group .btn-action:last-child {
    border-top-right-radius: var(--border-radius-sm);
    border-bottom-right-radius: var(--border-radius-sm);
}

.table td .btn-group .btn {
    padding: 0.45rem 0.6rem;
    font-size: 0.85rem;
}

.table td .btn-group .btn i {
    pointer-events: none;
}

/* Restore contiguous button-group corners when custom .btn radius is applied */
.btn-group > .btn:not(:last-child):not(.dropdown-toggle),
.btn-group > .btn-group:not(:last-child) > .btn {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* Unified action button styles for tables */
.btn-action {
    padding: 0.45rem 0.6rem;
    font-size: 0.85rem;
    line-height: 1;
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}
/* Action buttons in dark theme */
[data-theme="dark"] .btn-action {
    background: #0f172a;
    border-color: var(--border-color);
    color: var(--text-secondary);
}
[data-theme="dark"] .btn-action:hover { background: #111827; }
[data-theme="dark"] .btn-action--view {
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.35);
}
[data-theme="dark"] .btn-action--view:hover { background: rgba(59, 130, 246, 0.08); }
[data-theme="dark"] .btn-action--edit {
    color: var(--text-secondary);
    border-color: var(--border-color);
}
[data-theme="dark"] .btn-action--edit:hover { background: #111827; }
[data-theme="dark"] .btn-action--danger {
    color: #fca5a5;
    border-color: rgba(220, 38, 38, 0.45);
}
[data-theme="dark"] .btn-action--danger:hover { background: rgba(220, 38, 38, 0.12); }
[data-theme="dark"] .btn-action--success {
    color: #86efac;
    border-color: rgba(16, 185, 129, 0.45);
}
[data-theme="dark"] .btn-action--success:hover { background: rgba(16, 185, 129, 0.12); }
[data-theme="dark"] .btn-action--warning {
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.55);
}
[data-theme="dark"] .btn-action--warning:hover { background: rgba(245, 158, 11, 0.12); }
[data-theme="dark"] .btn-action--more {
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.45);
}
[data-theme="dark"] .btn-action--more:hover { background: rgba(59, 130, 246, 0.12); }

.btn-action i { font-size: 0.95rem; }

.btn-action--view {
    color: var(--primary-color);
    border-color: var(--primary-light);
}
.btn-action--view:hover { background: rgba(59, 130, 246, 0.08); }

.btn-action--edit {
    color: var(--text-secondary);
    border-color: var(--border-color);
}
.btn-action--edit:hover { background: var(--light-color); }

.btn-action--danger {
    color: var(--danger-color);
    border-color: rgba(220, 38, 38, 0.25);
}
.btn-action--danger:hover { background: rgba(220, 38, 38, 0.08); }

.btn-action--success {
    color: #0f766e; /* teal-700 */
    border-color: rgba(16, 185, 129, 0.25);
}
.btn-action--success:hover { background: rgba(16, 185, 129, 0.08); }

.btn-action--warning {
    color: #92400e; /* amber-800 */
    border-color: rgba(245, 158, 11, 0.35);
}
.btn-action--warning:hover { background: rgba(245, 158, 11, 0.08); }

.btn-action--more {
    color: #075985; /* sky-800/info-ish */
    border-color: rgba(59, 130, 246, 0.25);
}
.btn-action--more:hover { background: rgba(59, 130, 246, 0.08); }

.btn-group > .btn:nth-child(n+2),
.btn-group > .btn-group:nth-child(n+2) > .btn {
    margin-left: -1px;
}

.btn-group > .btn:not(:first-child),
.btn-group > .btn-group:not(:first-child) > .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Badges and progress helpers */
.badge-soft-primary { background: rgba(59,130,246,0.12); color: var(--primary-color); border: 1px solid rgba(59,130,246,0.25); }
.badge-soft-secondary { background: rgba(148,163,184,0.12); color: var(--text-secondary); border: 1px solid rgba(148,163,184,0.25); }
.badge-soft-success { background: rgba(34,197,94,0.12); color: #166534; border: 1px solid rgba(34,197,94,0.25); }
.badge-soft-danger { background: rgba(239,68,68,0.12); color: #991b1b; border: 1px solid rgba(239,68,68,0.25); }
.badge-pill { border-radius: 9999px; }

.progress-thin { height: 6px; border-radius: 9999px; overflow: hidden; }
.progress-thin .progress-bar { border-radius: 9999px; }

/* Enhanced Navigation Layout */
.navbar {
    background: #ffffff !important;
    background-color: #ffffff !important; /* ensure solid fill */
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important; /* avoid translucency */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    z-index: 1030;
    position: relative;
    min-height: 70px;
}

[data-theme="dark"] .navbar {
    background: #0b1220 !important;
    border-bottom-color: var(--border-color);
}
[data-theme="light"] .navbar,
html[data-theme="light"] .navbar {
    background: #ffffff !important;
    background-color: #ffffff !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}
[data-theme="dark"] .navbar-collapse {
    background: #0b1220 !important;
}
[data-theme="dark"] .navbar .navbar-toggler {
    border-color: var(--border-color);
}
[data-theme="dark"] .navbar .navbar-toggler-icon {
    filter: invert(1) brightness(0.9);
}
[data-theme="dark"] .navbar .nav-link { color: var(--text-secondary) !important; }
[data-theme="dark"] .navbar .nav-link.active { color: #fff !important; }
[data-theme="dark"] .navbar .navbar-brand .text-dark { color: var(--text-primary) !important; }
[data-theme="dark"] .mobile-tabbar { background: #0b1220; border-top: 1px solid var(--border-color); }

/* Navbar shadow on scroll */
.navbar.scrolled {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    border-bottom-color: rgba(226, 232, 240, 0.8);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--primary-color) !important;
    text-decoration: none;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.navbar-brand img {
    transition: var(--transition);
}

.navbar-brand:hover img {
    transform: scale(1.1);
}

.navbar-brand:hover {
    color: var(--primary-dark) !important;
}

.navbar-nav .nav-link {
    color: var(--text-secondary) !important;
    font-weight: 500;
    padding: 0.875rem 1.25rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    position: relative;
    margin: 0 0.25rem;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-nav .nav-link:hover {
    color: var(--primary-color) !important;
    background: var(--light-color);
    transform: translateY(-1px);
}

[data-theme="dark"] .navbar-nav .nav-link:hover {
    background: #111827;
}

.navbar-nav .nav-link.active {
    background: var(--primary-color);
    color: white !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Enhanced Mobile Layout */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .section-spacing {
        margin-bottom: var(--mobile-section-spacing);
    }
    
    .card {
        margin-bottom: var(--mobile-card-spacing);
    }
    
    .card-body {
        padding: 1.25rem;
    }
    
    .card-header {
        padding: 1.25rem 1.25rem;
    }
    
    .btn {
        padding: 1rem 1.5rem;
        font-size: 1rem;
        min-height: 52px;
        width: 100%;
        margin-bottom: 0.75rem;
    }
    
    .btn:last-child {
        margin-bottom: 0;
    }
    
    .form-control, .form-select {
        padding: 1rem 1.25rem;
        font-size: 16px;
        min-height: 56px;
    }
    
    .table th, .table td {
        padding: 1rem 0.75rem;
    }
    
    .navbar {
        padding: 0.75rem 0;
        min-height: 60px;
    }
    
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    .navbar-nav .nav-link {
        padding: 1rem 1.5rem;
        margin: 0.25rem 0;
        font-size: 1.1rem;
        min-height: 52px;
    }
}

/* Enhanced Small Mobile Layout */
@media (max-width: 480px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-header {
        padding: 1rem 1rem;
    }
    
    .btn {
        padding: 1rem 1.25rem;
        font-size: 0.95rem;
        min-height: 56px;
    }
    
    .form-control, .form-select {
        padding: 0.875rem 1rem;
        min-height: 56px;
    }
    
    .navbar-brand {
        font-size: 1.1rem;
    }
}

/* Enhanced Grid Layout */
.row {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
}

.col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

@media (max-width: 768px) {
    .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .col, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Enhanced Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 1rem;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

@media (max-width: 768px) {
    h1 { font-size: 1.875rem; }
    h2 { font-size: 1.625rem; }
    h3 { font-size: 1.375rem; }
    h4 { font-size: 1.125rem; }
    h5 { font-size: 1rem; }
    h6 { font-size: 0.95rem; }
}

/* Enhanced Spacing Utilities */
.section-gap {
    margin-bottom: var(--section-spacing);
}

.card-gap {
    margin-bottom: var(--card-spacing);
}

@media (max-width: 768px) {
    .section-gap {
        margin-bottom: var(--mobile-section-spacing);
    }
    
    .card-gap {
        margin-bottom: var(--mobile-card-spacing);
    }
}

/* Enhanced Animation Classes */
.fade-in {
    animation: fadeIn 0.4s ease-out;
}

.slide-up {
    animation: slideUp 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Enhanced Utility Classes */
.text-gradient {
    background: var(--bg-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glass-effect {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.hover-lift {
    transition: var(--transition);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
}

/* Ensure dropdown menus are fully opaque and above other elements */
.dropdown-menu {
    background: #ffffff !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    z-index: 1060; /* above navbar (1030) and our backdrop */
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--card-shadow-hover);
    margin-top: 0.5rem;
    overflow: visible; /* allow soft shadow rounding */
    position: absolute !important; /* ensure above backdrop and positioned by Bootstrap */
    pointer-events: auto; /* capture interactions */
    background-clip: padding-box; /* ensure solid fill to rounded corners */
}

/* Dark mode dropdown menu container */
[data-theme="dark"] .dropdown-menu {
    background: #0f172a !important;
    border-color: var(--border-color);
    box-shadow: var(--card-shadow-hover);
}
[data-theme="dark"] .dropdown-menu .dropdown-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
[data-theme="dark"] .dropdown-menu .dropdown-item:last-child {
    border-bottom: none;
}
[data-theme="dark"] .dropdown-divider {
    background-color: var(--border-color) !important;
    opacity: 1;
}
[data-theme="dark"] .dropdown-item { color: var(--text-secondary) !important; }
[data-theme="dark"] .dropdown-item:hover { background-color: #111827 !important; color: var(--text-primary) !important; }

/* Light mode dropdown fixes (ensure solid background and proper contrast) */
[data-theme="light"] .dropdown-menu,
.navbar .dropdown-menu {
    --bs-dropdown-bg: #ffffff;
    --bs-dropdown-link-color: var(--text-primary);
    --bs-dropdown-link-hover-bg: var(--light-color);
    --bs-dropdown-link-hover-color: var(--text-primary);
    --bs-dropdown-border-color: var(--border-color);
    background-color: #ffffff !important;
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow-hover);
}

[data-theme="light"] .dropdown-item,
.navbar .dropdown-item {
    color: var(--text-primary) !important;
}

[data-theme="light"] .dropdown-item:hover,
.navbar .dropdown-item:hover {
    background-color: var(--light-color) !important;
    color: var(--text-primary) !important;
}

[data-theme="light"] .dropdown-divider,
.navbar .dropdown-divider {
    background-color: var(--border-color) !important;
    opacity: 1;
}

/* Ensure dropdowns inside cards stack above adjacent content */
.card .dropdown,
.mobile-card .dropdown {
    position: relative;
    z-index: 2000;
}
.dropdown-item {
    background-color: #ffffff !important; /* make items opaque */
}
.dropdown-menu::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffffff; /* solid background to avoid transparency */
    border-radius: inherit;
    z-index: -1; /* sit behind menu content but within menu stacking */
}

/* Fix white overlay in dark mode dropdown */
[data-theme="dark"] .dropdown-menu::before {
    background: #0f172a;
}

/* Solid hover state for items to further avoid transparency feel */
.dropdown-item:hover, .dropdown-item:focus {
    background-color: var(--light-color) !important;
}

/* Backdrop to block interactions behind open dropdowns */
/* Removed custom dropdown backdrop; rely on Bootstrap defaults */

/* Increase dropdown item touch targets and spacing */
.dropdown-item {
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-item i { width: 1rem; text-align: center; }

/* Enhanced Mobile Components */
.mobile-stack {
    display: flex;
    flex-direction: column;
}

.mobile-stack .btn {
    margin-bottom: 0.75rem;
}

.mobile-stack .btn:last-child {
    margin-bottom: 0;
}

.touch-target {
    min-height: 48px;
    min-width: 48px;
}

@media (max-width: 768px) {
    .touch-target {
        min-height: 52px;
        min-width: 52px;
    }
}

/* Enhanced Footer Layout */
.footer {
    background: white;
    color: var(--text-secondary);
    padding: 2.5rem 0;
    margin-top: 4rem;
    border-top: 1px solid var(--border-color);
}

[data-theme="dark"] .footer {
    background: #0b1220;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary-dark);
}

/* Enhanced Toast Container */
.toast-container {
    z-index: 9999;
}

.toast {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--card-shadow-hover);
}

/* Enhanced Loading Animation */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* Enhanced Modal Layout */
.modal-content {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.75rem;
}

.modal-body {
    padding: 1.75rem;
}

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

@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.75rem;
        max-width: calc(100% - 1.5rem);
    }
    
    .modal-header, .modal-body, .modal-footer {
        padding: 1.25rem;
    }
}

/* Enhanced Badge Layout */
.badge {
    font-size: 0.8rem;
    font-weight: 500;
    padding: 0.5rem 0.875rem;
    border-radius: var(--border-radius-sm);
}

/* Enhanced Alert Layout */
.alert {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 1.25rem 1.5rem;
    font-weight: 500;
    position: relative;
    background: white;
}

[data-theme="dark"] .alert { background: #0f172a; }
[data-theme="dark"] .alert-success { background: #052e1f; color: #a7f3d0; }
[data-theme="dark"] .alert-danger { background: #3f1d1d; color: #fecaca; }
[data-theme="dark"] .alert-info { background: #082f49; color: #bae6fd; }
[data-theme="dark"] .alert-warning { background: #422006; color: #fed7aa; }

/* ==========================================
   Dark theme utility & component overrides
   ========================================== */

/* Text utilities */
[data-theme="dark"] .text-dark { color: var(--text-primary) !important; }
[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
[data-theme="dark"] .text-secondary { color: var(--text-secondary) !important; }

/* Background utilities */
[data-theme="dark"] .bg-white { background-color: #0f172a !important; }
[data-theme="dark"] .bg-light { background-color: #111827 !important; }
[data-theme="dark"] .bg-body { background-color: #0b1220 !important; }

/* Borders and dividers */
[data-theme="dark"] .border,
[data-theme="dark"] .border-top,
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-start,
[data-theme="dark"] .border-end,
[data-theme="dark"] hr,
[data-theme="dark"] .dropdown-divider { border-color: var(--border-color) !important; }

/* List groups */
[data-theme="dark"] .list-group-item {
    background-color: #0f172a;
    color: var(--text-secondary);
    border-color: var(--border-color);
}
[data-theme="dark"] .list-group-item.active {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-dark);
}

/* Badges */
[data-theme="dark"] .badge.bg-light {
    background-color: #1f2937 !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border-color);
}

/* Pagination */
[data-theme="dark"] .pagination .page-link {
    background-color: #0f172a;
    color: var(--text-secondary);
    border-color: var(--border-color);
}
[data-theme="dark"] .pagination .page-item.active .page-link {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-dark);
}
[data-theme="dark"] .pagination .page-link:hover {
    background-color: #111827;
}

/* Tables: ensure caption and muted text are readable */
[data-theme="dark"] table caption { color: var(--text-muted); }

/* Inputs toggles and checks */
[data-theme="dark"] .form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* In-page status badges (tasks) */
[data-theme="dark"] .status-todo { background-color: #334155 !important; color: #cbd5e1 !important; }
[data-theme="dark"] .status-in_progress { background-color: #3f2d0c !important; color: #fbbf24 !important; }
[data-theme="dark"] .status-review { background-color: #1e3a8a !important; color: #dbeafe !important; }
[data-theme="dark"] .status-done { background-color: #064e3b !important; color: #d1fae5 !important; }
[data-theme="dark"] .status-cancelled { background-color: #7f1d1d !important; color: #fee2e2 !important; }

.alert-success {
    border-color: #10b981;
    background: #f0fdf4;
    color: #065f46;
}

.alert-danger {
    border-color: #ef4444;
    background: #fef2f2;
    color: #991b1b;
}

.alert-info {
    border-color: #06b6d4;
    background: #f0f9ff;
    color: #0c4a6e;
}

.alert-warning {
    border-color: #f59e0b;
    background: #fffbeb;
    color: #92400e;
}

/* Enhanced Timer Display */
.timer-display {
    font-family: 'Inter', monospace;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 2px;
}

@media (max-width: 768px) {
    .timer-display {
        font-size: 1.75rem;
        letter-spacing: 1px;
    }
}

/* Enhanced Stats Cards */
.stats-card {
    background: var(--bg-gradient);
    color: white;
    position: relative;
    overflow: hidden;
}

.stats-card .card-body {
    position: relative;
    z-index: 1;
}

.stats-card i {
    font-size: 2.5rem;
    opacity: 0.9;
    margin-bottom: 1rem;
}

.stats-card h4 {
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

@media (max-width: 768px) {
    .stats-card h4 {
        font-size: 2rem;
    }
    
    .stats-card i {
        font-size: 2rem;
        margin-bottom: 0.75rem;
    }
}

/* Enhanced Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--light-color);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}


/* Shared summary cards used across pages (invoices, reports) */
.summary-card {
    transition: all 0.3s ease;
    border-radius: 12px;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.summary-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.summary-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.summary-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.empty-state {
    padding: 2rem;
}

.empty-state i {
    opacity: 0.5;
}

@media (max-width: 768px) {
    .summary-card { margin-bottom: 1rem; }
    .summary-value { font-size: 18px; }
}

/* Shared page header utilities to align with admin dashboard */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header .h3 { margin: 0; }

/* Consistent badge sizing used next to page titles */
.badge.fs-6 {
    line-height: 1;
    padding: 0.5rem 0.75rem;
    border-radius: 9999px;
}

