:root {
    /* Eldyne Custom Palette - Hard Refresh Required Version */
    --primary-color: #6B1E22;
    /* Deep Burgundy/Red */
    --secondary-color: #A9384E;
    /* Muted Red/Rose */
    --accent-color: #4A5D6E;
    /* Slate Blue */
    --success-color: #10b981;
    /* Keeping standard green for success */
    --danger-color: #D32F2F;
    /* Standard red */
    --warning-color: #f59e0b;
    /* Standard orange */
    --info-color: #4A5D6E;
    /* Slate Blue for info */

    --light-bg: #f5f5f5;
    /* Off-white from palette */
    --dark-text: #2C2C2C;
    /* Dark Grey from palette */
    --muted-text: #555555;
    /* Medium Grey from palette */

    --sidebar-width: 280px;
    --header-height: 70px;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --hover-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: 1px solid rgba(255, 255, 255, 0.18);
    --transition-speed: 0.3s;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: #f0f2f5;
    color: var(--dark-text);
    overflow-x: hidden;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Sidebar Styling */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: #ffffff;
    color: #4a5568;
    overflow-y: auto;
    transition: transform var(--transition-speed) ease;
    z-index: 1050;
    /* Higher than top-navbar and overlay */
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.02);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
}

.sidebar-header {
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
}

/* Segmented Tiles Logo */
.logo-wrapper {
    display: flex;
    justify-content: center;
    gap: 3px;
    margin-bottom: 20px;
    padding: 5px;
}

/* Logo Tiles Animation */
@keyframes tilePopIn {
    0% {
        opacity: 0;
        transform: translateY(-20px) skewX(-12deg);
    }

    100% {
        opacity: 1;
        transform: translateY(0) skewX(-12deg);
    }
}

.hover-scale {
    transition: transform 0.2s ease;
    display: inline-block;
}

.hover-scale:hover {
    transform: scale(1.15);
}

.logo-char {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 52px;
    background: linear-gradient(135deg, #6B1E22, #800000);
    color: white;
    font-size: 28px;
    font-weight: 800;
    font-style: italic;
    transform: skewX(-12deg);
    border: 2px solid white;
    box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.25);
    line-height: 1;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: tilePopIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
    cursor: default;
}

/* Staggered Entrance */
.logo-char:nth-child(1) {
    animation-delay: 0.1s;
}

.logo-char:nth-child(2) {
    animation-delay: 0.2s;
}

.logo-char:nth-child(3) {
    animation-delay: 0.3s;
}

.logo-char:nth-child(4) {
    animation-delay: 0.4s;
}

.logo-char:nth-child(5) {
    animation-delay: 0.5s;
}

.logo-char:nth-child(6) {
    animation-delay: 0.6s;
}

/* Interactive Hover */
.logo-char:hover {
    transform: translateY(-5px) skewX(-12deg) scale(1.1);
    box-shadow: 0 10px 20px rgba(107, 30, 34, 0.4);
    background: linear-gradient(135deg, #8A252C, #A9384E);
    z-index: 10;
}

/* Shine Effect on Tiles */
.logo-char::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.4) 50%, rgba(255, 255, 255, 0) 100%);
    transform: skewX(-15deg);
    animation: shine 4s infinite;
    animation-delay: inherit;
}

/* Remove old class if unused or keep for compatibility if referenced elsewhere */
.logo-icon {
    display: none;
}

.sidebar-header h4 {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark-text);
    margin: 0;
    letter-spacing: -0.5px;
}

.sidebar-header p {
    font-size: 12px;
    color: #a0aec0;
    margin-top: 4px;
    font-weight: 500;
}

.nav-category {
    padding: 24px 24px 8px;
    font-size: 11px;
    font-weight: 800;
    color: #cbd5e0;
    text-transform: uppercase;
    letter-spacing: 1.2px;
}


.nav-item {
    padding: 12px 24px;
    color: #718096;
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 14px;
    margin: 4px 12px;
    border-radius: 8px;
}

.nav-item:hover {
    color: var(--primary-color);
    background-color: rgba(107, 30, 34, 0.05);
    transform: translateX(4px);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 12px rgba(107, 30, 34, 0.25);
}

.nav-item i {
    width: 24px;
    margin-right: 12px;
    font-size: 16px;
    text-align: center;
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 24px;
    transition: margin-left var(--transition-speed) ease;
}

/* Top Navbar */
.top-navbar {
    background: var(--glass-bg);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 16px 24px;
    margin-bottom: 32px;
    box-shadow: var(--card-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.5);
    position: sticky;
    top: 24px;
    z-index: 1040;
    /* Sticky but below sidebar */
}

/* ... skipping middle lines ... */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1045;
    /* Just below sidebar (1050) */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}


.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--dark-text);
    margin: 0;
    letter-spacing: -0.5px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 6px;
    border-radius: 50px;
    background: white;
    border: 1px solid #edf2f7;
    padding-right: 20px;
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), var(--success-color));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--dark-text);
    line-height: 1.2;
}

.user-role {
    font-size: 11px;
    color: #718096;
    font-weight: 600;
    text-transform: uppercase;
}

/* Cards & Glassmorphism */

/* Buttons */

/* Form Elements */

/* Stat Cards */
.stat-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.02);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4));
    transform: skewX(-20deg) translateX(150%);
    transition: 0.5s;
}

.stat-card:hover::after {
    transform: skewX(-20deg) translateX(-150%);
}

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

.stat-card i {
    font-size: 32px;
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 16px;
    display: inline-block;
}

.stat-card.primary i {
    background: rgba(67, 97, 238, 0.1);
    color: var(--primary-color);
}

.stat-card.success i {
    background: rgba(76, 201, 240, 0.1);
    color: var(--success-color);
}

.stat-card.warning i {
    background: rgba(252, 163, 17, 0.1);
    color: var(--warning-color);
}

.stat-card.danger i {
    background: rgba(247, 37, 133, 0.1);
    color: var(--danger-color);
}

.stat-card h3 {
    font-size: 28px;
    font-weight: 800;
    margin: 0;
    color: var(--dark-text);
}

.stat-card p {
    color: #718096;
    font-size: 13px;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        display: flex;
        flex-direction: column;
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
    }

    /* Make nav-menu scrollable with bottom padding */
    .sidebar .nav-menu {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding-bottom: 100px;
        /* Extra space for last menu items */
    }

    /* Reduce sidebar header on mobile */
    .sidebar .sidebar-header {
        padding: 16px;
    }

    .sidebar .sidebar-header .logo-icon {
        width: 40px;
        height: 40px;
        font-size: 8px;
        margin-bottom: 8px;
    }

    .sidebar .sidebar-header h4 {
        font-size: 16px;
    }

    .sidebar .sidebar-header p {
        font-size: 11px;
        margin-top: 2px;
    }

    /* Smaller nav items on mobile */
    .nav-category {
        padding: 16px 16px 6px;
        font-size: 10px;
    }

    .nav-item {
        padding: 10px 16px;
        margin: 3px 8px;
        font-size: 13px;
    }

    .nav-item i {
        width: 20px;
        margin-right: 10px;
        font-size: 14px;
    }

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

    .overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1045;
        /* Just below sidebar (1050) */
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s;
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
    }

    .overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .sidebar-toggle {
        display: block !important;
        cursor: pointer;
        padding: 8px;
        margin-right: 16px;
        font-size: 20px;
        color: var(--dark-text);
    }
}

/* Extra small screen sidebar fixes */
@media (max-width: 480px) {
    .sidebar {
        width: 85vw;
        max-width: 280px;
    }

    .sidebar .nav-menu {
        padding-bottom: 120px;
        /* Even more space for safe area */
    }

    /* Support for phones with home indicator */
    @supports (padding-bottom: env(safe-area-inset-bottom)) {
        .sidebar .nav-menu {
            padding-bottom: calc(100px + env(safe-area-inset-bottom));
        }
    }
}

@media (min-width: 992px) {
    .sidebar-toggle {
        display: none !important;
    }
}

/* Custom Logo Styling */
.logo-maroon {
    background: linear-gradient(135deg, #800000 0%, #A52A2A 100%) !important;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    letter-spacing: 1px;
    box-shadow: 0 4px 12px rgba(128, 0, 0, 0.3) !important;
}

/* Global Bootstrap Overrides for Eldyne Maroon Theme */

/* Buttons */
.btn-primary,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color)) !important;
    border-color: transparent !important;
    box-shadow: 0 4px 12px rgba(107, 30, 34, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 16px rgba(107, 30, 34, 0.4);
    transform: translateY(-1px);
}

.btn-danger,
.btn-danger:focus {
    background: linear-gradient(135deg, #D32F2F, #B71C1C) !important;
    /* Standard Red for Danger actions */
    border-color: transparent !important;
    box-shadow: 0 4px 12px rgba(211, 47, 47, 0.3);
}

.btn-danger:hover {
    box-shadow: 0 6px 16px rgba(211, 47, 47, 0.4);
    transform: translateY(-1px);
}

/* Utilities */
.text-primary {
    color: var(--primary-color) !important;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

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

/* Custom Gradients */
.bg-gradient-maroon {
    background: linear-gradient(135deg, #6B1E22 0%, #8A252C 100%);
}

.text-gradient-maroon {
    background: -webkit-linear-gradient(135deg, #6B1E22 0%, #8A252C 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* -------------------------------------------------------------------------- */
/*                                 Animations                                 */
/* -------------------------------------------------------------------------- */

/* 1. Shine Effect for Logo */
@keyframes shine {
    0% {
        left: -100%;
        opacity: 0;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        left: 100%;
        opacity: 0;
    }
}

.logo-maroon,
.logo-icon {
    position: relative;
    overflow: hidden;
}

.logo-maroon::after,
.logo-icon::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.3) 50%, rgba(255, 255, 255, 0) 100%);
    transform: skewX(-25deg);
    animation: shine 6s infinite;
}

/* 2. Global Entrance Animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
    }

    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

.page-animate {
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.dashboard-card,
.stat-card {
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

/* Stagger Animations */
.col-md-3:nth-child(1) .dashboard-card {
    animation-delay: 0.1s;
}

.col-md-3:nth-child(2) .dashboard-card {
    animation-delay: 0.2s;
}

.col-md-3:nth-child(3) .dashboard-card {
    animation-delay: 0.3s;
}

.col-md-3:nth-child(4) .dashboard-card {
    animation-delay: 0.4s;
}

/* 3. Enhanced Card Hover */
.stat-card {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.stat-card:hover .icon-bg i {
    transform: scale(1.2) rotate(5deg);
    transition: transform 0.3s ease;
}

/* Icon bg transition */
.icon-bg i {
    transition: transform 0.3s ease;
}

/* -------------------------------------------------------------------------- */
/*                            QR Scanner UI Styles                            */
/* -------------------------------------------------------------------------- */

/* Custom Scan Region Overlay */
/* Note: Html5Qrcode creates a shaded region automatically using 'qrbox' */

/* Scanner Container in Modal */
#reader {
    width: 100%;
    min-height: 300px;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    position: relative;
}

#reader video {
    object-fit: cover;
    border-radius: 8px;
}

/* Loading Indicator */
.qr-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 1.2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 10;
}

/* Zoom Slider Container */
.zoom-container {
    display: none;
    /* Hidden by default until zoom detected */
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
}

.zoom-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 200px;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

.zoom-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

/* ISO Standard Scanner Overlay */
.iso-scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.iso-scanner-frame {
    position: relative;
    /* Box shadow for darkened margin, but no continuous border */
    box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.7);
}

/* Yellow Corner borders simulating the screenshot scanner */
.iso-scanner-frame::before,
.iso-scanner-frame::after,
.iso-scanner-frame>.iso-corners::before,
.iso-scanner-frame>.iso-corners::after {
    content: '';
    position: absolute;
    width: 50px;
    /* Longer brackets */
    height: 50px;
    border-color: #fbbc04;
    /* Google Yellow */
    border-style: solid;
    border-width: 0;
    opacity: 0.9;
    border-radius: 12px;
    /* Slightly rounded edges */
}

/* Top Left */
.iso-scanner-frame::before {
    top: -2px;
    left: -2px;
    border-top-width: 5px;
    border-left-width: 5px;
    border-top-left-radius: 16px;
    border-bottom-right-radius: 0px;
}

/* Top Right */
.iso-scanner-frame::after {
    top: -2px;
    right: -2px;
    border-top-width: 5px;
    border-right-width: 5px;
    border-top-right-radius: 16px;
    border-bottom-left-radius: 0px;
}

/* Bottom Left */
.iso-scanner-frame>.iso-corners::before {
    bottom: -2px;
    left: -2px;
    border-bottom-width: 5px;
    border-left-width: 5px;
    border-bottom-left-radius: 16px;
    border-top-right-radius: 0px;
}

/* Bottom Right */
.iso-scanner-frame>.iso-corners::after {
    bottom: -2px;
    right: -2px;
    border-bottom-width: 5px;
    border-right-width: 5px;
    border-bottom-right-radius: 16px;
    border-top-left-radius: 0px;
}

/* Ensure the shaded region SVG from html5-qrcode is hidden because we use the box-shadow hack above for better performance and look */
#qr-shaded-region {
    display: none !important;
}

/* Torch Button Active State - Deep Yellow like Native Android/iOS */
#torch-btn.active-yellow {
    background-color: #fbbc04 !important;
    /* Google Yellow */
    color: #000 !important;
    border-color: #fbbc04 !important;
}

/* Error Message */
.qr-error-msg {
    color: #dc3545;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 4px;
    margin-top: 10px;
    font-size: 0.9rem;
}

/* Fix modal z-index issues - FORCED */
body .modal-backdrop,
body .modal-backdrop.show,
body .modal-backdrop.fade {
    z-index: 9998 !important;
}

body .modal,
body .modal.show,
body .modal.fade {
    z-index: 9999 !important;
}

body .modal-dialog,
body .modal-content {
    z-index: 10000 !important;
    position: relative;
}

/* Dashboard Page Light Blue Theme Aesthetic */
body.dashboard-page {
    background-color: #f0f9ff;
    color: #1e293b;
}

body.dashboard-page .sidebar {
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.02);
    color: #475569;
}

body.dashboard-page .sidebar-header {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    color: #1e293b;
}

body.dashboard-page .nav-category {
    color: #94a3b8;
    background: transparent;
}

body.dashboard-page .nav-item {
    color: #64748b;
}

body.dashboard-page .nav-item:hover,
body.dashboard-page .nav-item.active {
    background: #eff6ff;
    color: #2563eb;
}

body.dashboard-page .main-content {
    background-color: #f0f9ff;
}

body.dashboard-page .top-navbar {
    display: none;
}

body.dashboard-page .main-content {
    padding-top: 0;
}

body.dashboard-page .page-title {
    color: #1e293b;
}

body.dashboard-page .user-name {
    color: #1e293b;
}

body.dashboard-page .sidebar-toggle {
    color: #1e293b;
}

body.dashboard-page .user-avatar {
    background: linear-gradient(135deg, #2563eb, #0891b2);
    color: #ffffff;
}

body.dashboard-page .logo-char {
    border-color: #ffffff;
    box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
}

body.dashboard-page .sidebar-header h4 {
    color: #1e293b;
}

body.dashboard-page .sidebar-header p {
    color: #64748b;
}

body.dashboard-page .nav-item i {
    color: inherit;
}

/* -------------------------------------------------------------------------- */
/*                        Action Button Group Design                          */
/* -------------------------------------------------------------------------- */

.btn-action-group {
    display: inline-flex;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    /* Deeper shadow for depth */
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.btn-action-group .btn {
    border-radius: 0;
    margin: 0;
    border: none;
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    /* Separator line */
    background: #ffffff;
    padding: 6px 12px;
    /* Slightly wider */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    font-size: 14px;
}

.btn-action-group .btn:last-child {
    border-right: none;
}

.btn-action-group .btn:hover {
    z-index: 1;
    transform: translateY(-2px);
    /* Lift effect */
}

/* Specific Colors - Outline style becoming filled/vibrant on hover */

/* VIEW - Blue/Primary */
.btn-action-group .btn-view {
    color: #4361ee;
    background-color: #f8f9fa;
}

.btn-action-group .btn-view:hover {
    background-color: #4361ee;
    color: #fff;
    box-shadow: 0 4px 10px rgba(67, 97, 238, 0.3);
}

/* PDF/EXPORT - Red/Rose - Fits typical PDF color */
.btn-action-group .btn-pdf {
    color: #e91e63;
    background-color: #f8f9fa;
}

.btn-action-group .btn-pdf:hover {
    background-color: #e91e63;
    color: #fff;
    box-shadow: 0 4px 10px rgba(233, 30, 99, 0.3);
}

/* EDIT - Orange/Warning */
.btn-action-group .btn-edit {
    color: #fb8500;
    background-color: #f8f9fa;
}

.btn-action-group .btn-edit:hover {
    background-color: #fb8500;
    color: #fff;
    box-shadow: 0 4px 10px rgba(251, 133, 0, 0.3);
}

/* DELETE - Red/Danger */
.btn-action-group .btn-delete {
    color: #ef233c;
    background-color: #f8f9fa;
}

.btn-action-group .btn-delete:hover {
    background-color: #ef233c;
    color: #fff;
    box-shadow: 0 4px 10px rgba(239, 35, 60, 0.3);
}

/* -------------------------------------------------------------------------- */
/*                        Mobile Responsive Enhancements                      */
/* -------------------------------------------------------------------------- */

/* General Mobile Improvements */
@media (max-width: 991px) {

    /* Improve touch targets */
    button,
    .btn,
    .nav-link,
    input[type="checkbox"],
    input[type="radio"],
    .page-link {
        min-height: 44px;
        min-width: 44px;
        touch-action: manipulation;
    }

    /* Prevent horizontal scrolling on body */
    body,
    html {
        overflow-x: hidden;
        width: 100%;
        position: relative;
    }

    /* Container padding adjustment */
    .container-fluid {
        padding-left: 16px;
        padding-right: 16px;
    }

    /* Fix table overflow */
    .table-responsive {
        overflow-x: auto;
        margin-bottom: 1rem;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

    /* Ensure tables don't force width */
    table {
        width: 100% !important;
        white-space: nowrap;
    }

    /* Stack form groups properly */
    .form-group,
    .mb-3 {
        margin-bottom: 20px !important;
    }

    /* Map height adjustment */
    #map {
        height: 60vh !important;
        min-height: 400px;
    }

    /* Navbar items stacking */
    .top-navbar {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 16px;
        height: auto;
        min-height: 70px;
    }

    .top-navbar .page-title {
        font-size: 18px;
        width: 100%;
        text-align: center;
        order: 1;
        /* Title first */
        margin-bottom: 10px;
    }

    .sidebar-toggle {
        position: absolute;
        left: 16px;
        top: 18px;
        z-index: 1050;
    }

    .top-navbar .user-profile {
        margin-left: auto;
        order: 2;
        /* User profile last */
    }

    /* Adjust modal sizing */
    .modal-dialog {
        margin: 10px;
    }

    .modal-content {
        border-radius: 12px;
    }
}

/* Small Screens (Phones) */
@media (max-width: 576px) {

    /* Dashboard Cards Stack */
    .col-md-3 .dashboard-card,
    .col-md-3 .stat-card {
        margin-bottom: 16px;
    }

    /* Login Page Optimization */
    .login-box,
    .auth-box {
        width: 90% !important;
        padding: 20px !important;
    }

    /* QR Scanner Modal Fullscreen */
    #qrModal .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }

    #qrModal .modal-content {
        min-height: 100vh;
        border-radius: 0;
        border: none;
    }

    /* Hide less critical columns in tables if needed 
       (Generic approach, specific tables might need targeted classes) */
    .table td,
    .table th {
        padding: 12px 8px;
        font-size: 14px;
    }

    /* User profile compact */
    .user-profile {
        padding: 4px;
        padding-right: 12px;
        background: transparent;
        border: none;
    }

    .user-details {
        display: none;
        /* Hide name/role on very small screens to save space */
    }

    .user-avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
}

/* Fix for Select2 dropdowns on mobile */
.select2-container--bootstrap-5 .select2-selection {
    min-height: 44px;
    /* Touch target */
    padding: 8px 12px;
}

.select2-container--bootstrap-5 .select2-dropdown {
    z-index: 1060;
    /* Above sidebar/navbar */
}

/* Safe Area Insets for iOS Notch */
@supports (padding-top: env(safe-area-inset-top)) {
    .sidebar {
        padding-top: env(safe-area-inset-top);
    }

    .top-navbar {
        margin-top: env(safe-area-inset-top);
    }

    body {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* -------------------------------------------------------------------------- */
/*                     Final Mobile Polish (Post-Verification)                */
/* -------------------------------------------------------------------------- */

@media (max-width: 576px) {

    /* 1. Fix Header Title Spacing */
    .top-navbar .page-title {
        font-size: 16px !important;
        margin-top: 5px;
        margin-bottom: 5px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
        margin-left: auto;
        margin-right: auto;
    }

    /* 2. Optimize User Profile Section */
    .user-profile {
        padding: 2px !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }

    .user-details {
        display: none !important;
        /* Hide name/role completely on phone to save space */
    }

    .user-avatar {
        width: 32px;
        height: 32px;
        font-size: 12px;
        margin: 0 !important;
    }

    /* 3. DataTable Controls Stacking */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        float: none !important;
        text-align: left !important;
        margin-bottom: 10px;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
    }

    /* 4. Action Button Spacing in Cards */
    .card-header .btn {
        margin-bottom: 5px;
    }

    .d-flex.gap-2 {
        gap: 8px !important;
        flex-wrap: wrap;
    }

    /* 5. Dashboard Card Header Stack */
    .db-card-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px;
    }

    .db-card-header .d-flex.gap-2 {
        width: 100%;
        display: flex !important;
        justify-content: space-between;
    }

    .db-card-header select.form-select {
        flex: 1;
        min-width: 80px;
    }

    .db-card-header #exportPdfBtn {
        width: auto;
    }
}

/* -------------------------------------------------------------------------- */
/*                          DataTables UI Alignment                           */
/* -------------------------------------------------------------------------- */

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    padding: 1.5rem 1rem 1rem;
}

.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    display: inline-flex !important;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--dark-text);
    white-space: nowrap;
}

.dataTables_wrapper .dataTables_length select.form-select {
    width: auto !important;
    padding: 0.375rem 2.25rem 0.375rem 0.75rem;
    font-size: 0.875rem;
    display: inline-block;
    border-radius: 8px;
    margin: 0 4px;
}

.dataTables_wrapper .dataTables_filter input.form-control {
    width: auto !important;
    display: inline-block;
    margin-left: 0.5rem;
    border-radius: 8px;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* Ensure controls are on the same row on desktop */
@media (min-width: 768px) {
    .dataTables_wrapper .row:first-child .col-md-6:first-child {
        display: flex;
        justify-content: flex-start;
    }

    .dataTables_wrapper .row:first-child .col-md-6:last-child {
        display: flex;
        justify-content: flex-end;
    }
}

/* -------------------------------------------------------------------------- */
/*                     DataTables Pagination & Info Polish                     */
/* -------------------------------------------------------------------------- */

.dataTables_wrapper .dataTables_info {
    padding: 1rem;
    font-size: 0.85rem;
    color: var(--light-text, #6c757d);
}

.dataTables_wrapper .dataTables_paginate {
    padding: 0.75rem 1rem;
    text-align: right;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 6px 14px;
    margin: 0 2px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: var(--dark-text, #1e293b) !important;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary-color, #6B1E22) !important;
    color: #fff !important;
    border-color: var(--primary-color, #6B1E22) !important;
    box-shadow: 0 2px 6px rgba(107, 30, 34, 0.25);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary-color, #6B1E22) !important;
    color: #fff !important;
    border-color: var(--primary-color, #6B1E22) !important;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(107, 30, 34, 0.3);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

/* -------------------------------------------------------------------------- */
/*                       Table-Modern Visual Enhancements                     */
/* -------------------------------------------------------------------------- */

/* Zebra striping */
.table-modern tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

/* Smooth hover transitions */
.table-modern tbody tr {
    transition: background-color 0.2s ease, box-shadow 0.15s ease;
}

.table-modern tbody tr:hover {
    background-color: #eef2ff;
    box-shadow: inset 3px 0 0 var(--primary-color, #6B1E22);
}

/* Empty state */
.table-modern tbody tr td[colspan] {
    text-align: center;
    padding: 40px 20px;
    color: var(--light-text, #6c757d);
    font-style: italic;
}

/* Card header with primary bg gradient */
.card-header.bg-primary {
    background: linear-gradient(135deg, var(--primary-color, #6B1E22), var(--secondary-color, #A9384E)) !important;
    border: none;
}

.card-header.bg-primary .btn-light {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.card-header.bg-primary .btn-light:hover {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* -------------------------------------------------------------------------- */
/*                        Collapsible Filter Sections                         */
/* -------------------------------------------------------------------------- */

.filter-collapse-header {
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: background-color 0.2s ease;
}

.filter-collapse-header:hover {
    background-color: #e9ecef !important;
}

.filter-collapse-header .fa-chevron-down {
    transition: transform 0.3s ease;
}

.filter-collapse-header.collapsed .fa-chevron-down {
    transform: rotate(-90deg);
}