@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* ==========================================================================
   THEME DESIGN TOKENS (DARK & LIGHT)
   ========================================================================== */

:root, [data-theme="dark"] {
    --bg-main: #0b0f19;
    --bg-card: #131b2e;
    --bg-surface: #1c2742;
    --bg-hover: #263554;
    
    --primary: #f59e0b; /* Golden Amber */
    --primary-hover: #d97706;
    --primary-glow: rgba(245, 158, 11, 0.25);
    
    --accent-red: #ef4444; /* Flame Red */
    --accent-red-hover: #dc2626;
    --accent-green: #10b981; /* Fresh Emerald */
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border-color: #1e293b;
    --border-light: #334155;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px rgba(245, 158, 11, 0.35);

    --sidebar-bg: #0b0f19;
    --topbar-bg: rgba(19, 27, 46, 0.95);
    --card-header-bg: rgba(19, 27, 46, 0.7);
    --table-header-bg: #1c2742;
    --table-hover: rgba(255, 255, 255, 0.025);
}

[data-theme="light"] {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-surface: #f1f5f9;
    --bg-hover: #e2e8f0;
    
    --primary: #d97706; /* High-contrast Amber */
    --primary-hover: #b45309;
    --primary-glow: rgba(217, 119, 6, 0.2);
    
    --accent-red: #dc2626;
    --accent-red-hover: #b91c1c;
    --accent-green: #059669;
    --accent-blue: #2563eb;
    --accent-purple: #7c3aed;

    --text-primary: #0f172a; /* Deep Slate */
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --border-color: #e2e8f0;
    --border-light: #cbd5e1;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 14px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --shadow-glow: 0 0 18px rgba(217, 119, 6, 0.25);

    --sidebar-bg: #ffffff;
    --topbar-bg: rgba(255, 255, 255, 0.95);
    --card-header-bg: #f8fafc;
    --table-header-bg: #f1f5f9;
    --table-hover: #f8fafc;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

html, body {
    max-width: 100vw;
    overflow-x: hidden;
    width: 100%;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-size: 13.5px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    transition: background-color 0.25s ease, color 0.25s ease;
}

h1, h2, h3, h4, h5, h6, .brand-font {
    font-family: 'Outfit', sans-serif;
}

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Layout Container with Left Sidebar */
.app-layout {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-main);
    position: relative;
    width: 100%;
}

/* ==========================================================================
   LEFT NAVIGATION SIDEBAR (DEFAULT EXPANDED: 230px)
   ========================================================================== */
.app-sidebar {
    width: 230px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    flex-shrink: 0;
    padding: 0.85rem 0.9rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-header-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 2;
    transition: all 0.25s ease;
}

.sidebar-brand-title {
    font-size: 0.98rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.3px;
    line-height: 1.1;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}

.sidebar-nav {
    flex: 1 1 0px;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(245, 158, 11, 0.4) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(245, 158, 11, 0.35);
    border-radius: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

.sidebar-section-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 800;
    letter-spacing: 0.6px;
    padding: 0.5rem 0.6rem 0.15rem;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.42rem 0.65rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    flex-shrink: 0;
    position: relative;
    white-space: nowrap;
}

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

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

.sidebar-link.active {
    color: var(--primary);
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.15) 0%, rgba(245, 158, 11, 0.02) 100%);
    border-left: 3px solid var(--primary);
    font-weight: 700;
}

.sidebar-link.pos-highlight {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(239, 68, 68, 0.1));
    border: 1px solid rgba(245, 158, 11, 0.35);
    color: var(--primary);
    font-weight: 700;
    margin: 0.2rem 0;
}
.sidebar-link.pos-highlight:hover {
    background: var(--primary);
    color: #ffffff;
}

.sidebar-footer {
    flex-shrink: 0;
    margin-top: auto;
    padding: 0.65rem 0.85rem;
    border-top: 1px solid var(--border-color);
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 2;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.03);
    transition: all 0.25s ease;
}

/* ==========================================================================
   MINI DRAWER SIDEBAR (COLLAPSED DESKTOP: 68px)
   ========================================================================== */
@media (min-width: 1025px) {
    .sidebar-collapsed .app-sidebar,
    body.sidebar-collapsed .app-sidebar,
    .app-layout.sidebar-collapsed .app-sidebar {
        width: 68px !important;
    }

    .sidebar-collapsed .app-main,
    body.sidebar-collapsed .app-main,
    .app-layout.sidebar-collapsed .app-main {
        margin-left: 68px !important;
        width: calc(100% - 68px) !important;
        max-width: calc(100% - 68px) !important;
    }

    .sidebar-collapsed .sidebar-brand,
    body.sidebar-collapsed .sidebar-brand {
        padding: 0.85rem 0 !important;
        justify-content: center !important;
    }

    .sidebar-collapsed .sidebar-brand-text,
    .sidebar-collapsed .sidebar-brand-title,
    .sidebar-collapsed .brand-badge,
    .sidebar-collapsed .sidebar-link span,
    .sidebar-collapsed .sidebar-footer .user-details,
    .sidebar-collapsed .logout-btn-label,
    body.sidebar-collapsed .sidebar-brand-text,
    body.sidebar-collapsed .sidebar-brand-title,
    body.sidebar-collapsed .brand-badge,
    body.sidebar-collapsed .sidebar-link span,
    body.sidebar-collapsed .sidebar-footer .user-details,
    body.sidebar-collapsed .logout-btn-label {
        display: none !important;
    }

    .sidebar-collapsed .sidebar-brand a,
    body.sidebar-collapsed .sidebar-brand a {
        justify-content: center !important;
    }

    .sidebar-collapsed .sidebar-section-label,
    body.sidebar-collapsed .sidebar-section-label {
        height: 1px !important;
        padding: 0 !important;
        margin: 0.4rem 0.5rem !important;
        background: var(--border-color) !important;
        color: transparent !important;
        font-size: 0 !important;
        overflow: hidden !important;
    }

    .sidebar-collapsed .sidebar-nav,
    body.sidebar-collapsed .sidebar-nav {
        padding: 0.5rem 0.25rem !important;
        align-items: center !important;
    }

    .sidebar-collapsed .sidebar-link,
    body.sidebar-collapsed .sidebar-link {
        justify-content: center !important;
        padding: 0.5rem 0 !important;
        width: 44px !important;
        height: 38px !important;
        border-radius: var(--radius-sm) !important;
        margin: 2px auto !important;
        border-left: none !important;
    }

    .sidebar-collapsed .sidebar-link.active,
    body.sidebar-collapsed .sidebar-link.active {
        background: var(--bg-hover) !important;
        border: 1px solid var(--primary) !important;
    }

    .sidebar-collapsed .sidebar-link i,
    body.sidebar-collapsed .sidebar-link i {
        font-size: 1.05rem !important;
        margin: 0 !important;
        width: auto !important;
    }

    .sidebar-collapsed .sidebar-footer,
    body.sidebar-collapsed .sidebar-footer {
        padding: 0.65rem 0.25rem !important;
        justify-content: center !important;
        flex-direction: column !important;
        gap: 0.4rem !important;
    }

    .sidebar-collapsed .sidebar-footer .btn-logout,
    body.sidebar-collapsed .sidebar-footer .btn-logout {
        padding: 0.35rem !important;
        border-radius: var(--radius-sm) !important;
        width: 32px !important;
        height: 32px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Hover Tooltip for Collapsed Sidebar */
    .sidebar-collapsed .sidebar-link[data-tooltip]:hover::after,
    body.sidebar-collapsed .sidebar-link[data-tooltip]:hover::after {
        content: attr(data-tooltip);
        position: absolute;
        left: 62px;
        top: 50%;
        transform: translateY(-50%);
        background: var(--bg-card);
        color: var(--text-primary);
        padding: 0.35rem 0.75rem;
        border-radius: var(--radius-sm);
        font-size: 0.75rem;
        font-weight: 600;
        white-space: nowrap;
        box-shadow: var(--shadow-md);
        border: 1px solid var(--border-light);
        z-index: 9999;
        pointer-events: none;
        animation: fadeInTooltip 0.15s ease-out;
    }
}

@keyframes fadeInTooltip {
    from { opacity: 0; transform: translateY(-50%) translateX(-5px); }
    to { opacity: 1; transform: translateY(-50%) translateX(0); }
}

/* ==========================================================================
   WORKSPACE & TOPBAR
   ========================================================================== */
.app-main {
    margin-left: 230px;
    width: calc(100% - 230px);
    max-width: calc(100% - 230px);
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    box-sizing: border-box;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.dashboard-main-grid {
    display: grid;
    grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr);
    gap: 1.5rem;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 1150px) {
    .dashboard-main-grid {
        grid-template-columns: 1fr;
    }
}

.topbar {
    background-color: var(--topbar-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 900;
    padding: 0.45rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

/* Topbar Buttons */
.topbar-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.topbar-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-hover);
}

.brand-badge {
    background: linear-gradient(135deg, var(--accent-red), var(--primary));
    color: white;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    font-weight: 700;
    text-transform: uppercase;
}

.role-badge {
    background: rgba(245, 158, 11, 0.15);
    color: var(--primary);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
}

/* App Container */
.app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.9rem 1.2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Mobile Sidebar Backdrop Overlay */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

/* ==========================================================================
   CARDS & WIDGETS
   ========================================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.65rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.45rem;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.card-title {
    font-size: 0.925rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Stat Widgets */
.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-surface) 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    margin: 0.15rem 0;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
}

.stat-icon.primary { background: rgba(245, 158, 11, 0.15); color: var(--primary); }
.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.stat-icon.red { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); }
.stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.stat-icon.purple { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }

/* ==========================================================================
   BUTTONS & CONTROLS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
    color: #ffffff;
    box-shadow: 0 2px 6px var(--primary-glow);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}
.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}
.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}
.btn-danger:hover {
    background: #dc2626;
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
}

.btn-sm {
    padding: 0.22rem 0.5rem;
    font-size: 0.72rem;
    border-radius: 4px;
}

.btn-lg {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

/* Forms */
.form-group {
    margin-bottom: 0.75rem;
}

.form-label {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 0.45rem 0.65rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.825rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ==========================================================================
   DATA TABLES (RESPONSIVE TOUCH-SCROLL)
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table, .data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    text-align: left;
    white-space: nowrap;
}

.table th, .data-table th {
    background: var(--table-header-bg);
    color: var(--text-secondary);
    font-weight: 700;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.4px;
}

.table td, .data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
    font-size: 0.8rem;
}

.table tbody tr:hover, .data-table tbody tr:hover {
    background: var(--table-hover);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-info { background: rgba(59, 130, 246, 0.15); color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.3); }

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.modal-backdrop.show {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 90vw;
}

.toast {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.25rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideUp 0.3s ease-out;
}

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

.toast.success { border-left: 4px solid var(--accent-green); }
.toast.error { border-left: 4px solid var(--accent-red); }
.toast.info { border-left: 4px solid var(--accent-blue); }

/* ==========================================================================
   MOBILE & TABLET RESPONSIVE STYLES
   ========================================================================== */
@media (max-width: 1024px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: 270px !important;
        box-shadow: 0 0 35px rgba(0,0,0,0.6);
        z-index: 9999;
        top: 0 !important;
        bottom: 0 !important;
        height: 100% !important;
        height: 100dvh !important;
        max-height: 100% !important;
        max-height: 100dvh !important;
    }

    .mobile-sidebar-open .app-sidebar,
    body.mobile-sidebar-open .app-sidebar,
    .app-layout.mobile-sidebar-open .app-sidebar {
        transform: translateX(0) !important;
    }

    .mobile-sidebar-open .sidebar-backdrop,
    body.mobile-sidebar-open .sidebar-backdrop,
    .app-layout.mobile-sidebar-open .sidebar-backdrop {
        display: block !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .app-main {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Guaranteed visible sidebar footer & logout button on mobile drawer */
    .sidebar-footer,
    .sidebar-collapsed .sidebar-footer,
    body.sidebar-collapsed .sidebar-footer {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 0.75rem 0.9rem !important;
        padding-bottom: max(0.85rem, env(safe-area-inset-bottom, 15px)) !important;
        background: var(--bg-card) !important;
        border-top: 1px solid var(--border-light) !important;
        flex-shrink: 0 !important;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08) !important;
    }

    .sidebar-footer .btn-logout,
    .sidebar-collapsed .sidebar-footer .btn-logout,
    body.sidebar-collapsed .sidebar-footer .btn-logout {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.35rem !important;
        padding: 0.35rem 0.75rem !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .sidebar-footer .btn-logout .logout-btn-label,
    .sidebar-collapsed .sidebar-footer .btn-logout .logout-btn-label,
    body.sidebar-collapsed .sidebar-footer .btn-logout .logout-btn-label {
        display: inline !important;
    }

    .sidebar-footer .user-details,
    .sidebar-collapsed .sidebar-footer .user-details,
    body.sidebar-collapsed .sidebar-footer .user-details {
        display: block !important;
    }

    /* Keep labels visible on mobile drawer even if desktop was collapsed */
    .sidebar-collapsed .app-sidebar,
    body.sidebar-collapsed .app-sidebar {
        width: 270px !important;
    }
    .sidebar-collapsed .sidebar-brand-title,
    body.sidebar-collapsed .sidebar-brand-title,
    .sidebar-collapsed .brand-badge,
    body.sidebar-collapsed .brand-badge,
    .sidebar-collapsed .sidebar-link span,
    body.sidebar-collapsed .sidebar-link span {
        display: block !important;
    }
    .sidebar-collapsed .sidebar-link,
    body.sidebar-collapsed .sidebar-link {
        justify-content: flex-start !important;
        width: auto !important;
        padding: 0.55rem 0.75rem !important;
    }
    .sidebar-collapsed .sidebar-brand,
    body.sidebar-collapsed .sidebar-brand {
        padding: 1.15rem 1rem !important;
        justify-content: space-between !important;
    }
    .sidebar-collapsed .sidebar-section-label,
    body.sidebar-collapsed .sidebar-section-label {
        height: auto !important;
        padding: 0.75rem 0.75rem 0.25rem !important;
        margin: 0 !important;
        background: transparent !important;
        color: var(--text-muted) !important;
        font-size: 0.65rem !important;
    }

    .topbar {
        padding: 0.5rem 0.85rem;
    }

    .app-container {
        padding: 0.85rem 0.65rem;
    }
}

@media (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
    }

    .app-layout, .app-main {
        overflow-x: hidden !important;
        max-width: 100% !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    .app-container {
        padding: 0.65rem 0.5rem !important;
        overflow-x: hidden !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    /* Topbar compact fit for small screens */
    .topbar {
        padding: 0.35rem 0.5rem !important;
        gap: 0.35rem !important;
    }

    .topbar-btn {
        width: 30px !important;
        height: 30px !important;
        font-size: 0.8rem !important;
        flex-shrink: 0 !important;
    }

    .topbar-brand-label,
    .topbar-sep {
        display: none !important;
    }

    .topbar-breadcrumb {
        max-width: 135px !important;
        font-size: 0.78rem !important;
    }

    .topbar-title-text {
        font-size: 0.78rem !important;
    }

    .topbar-shift-badge {
        padding: 2px 6px !important;
        font-size: 0.68rem !important;
    }

    .shift-label-desktop {
        display: none !important;
    }

    .shift-label-mobile {
        display: inline !important;
    }

    .shift-open-text {
        display: none !important;
    }

    /* Page headers & headings */
    .page-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
        margin-bottom: 0.85rem !important;
    }

    h1, .page-header h1 {
        font-size: 1.2rem !important;
        word-break: break-word;
        gap: 0.35rem !important;
    }

    .page-header p {
        font-size: 0.75rem !important;
    }

    /* Action button groups wrap nicely */
    .action-btn-group,
    div[style*="display:flex"][style*="gap:0.75rem"],
    div[style*="display:flex"][style*="gap: 0.75rem"],
    div[style*="display:flex"][style*="gap:1rem"] {
        flex-wrap: wrap !important;
        width: 100% !important;
        gap: 0.35rem !important;
    }

    .btn {
        font-size: 0.74rem !important;
        padding: 0.32rem 0.6rem !important;
    }

    .grid-stats {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 0.75rem 0.65rem !important;
        max-width: 100% !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }

    .table-responsive {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        display: block !important;
    }

    .modal-content {
        max-width: 96%;
        margin: 0.5rem auto;
        padding: 1rem;
    }
}
