:root {
    --primary: #FFBE0B;
    --primary-hover: #e0a800;
    --dark-bg: #09090b;
    --dark: #121214;
    --text-main: #fcfcfc;
    --text-muted: #a1a1aa;
    
    --success: #34d399;
    --danger: #ef4444;
    --warning: #fbbf24;

    --panel-bg: rgba(18, 18, 20, 0.82);
    --border: rgba(255, 190, 11, 0.16);
    
    --font-family: 'Inter', sans-serif;
}

[hidden] { display: none !important; }

.setup-panel h1 { font-size: 1.8rem; margin-bottom: 12px; }
.setup-panel p { color: var(--text-muted); line-height: 1.6; font-size: 0.95rem; margin-bottom: 22px; }
.setup-panel form, #stockActionForm { display: grid; gap: 16px; }
.setup-panel label, #stockActionForm label { display: grid; gap: 7px; color: var(--text-muted); font-size: 0.9rem; }
.setup-panel input { width: 100%; padding: 11px 12px; }
.setup-panel a { color: var(--primary); display: inline-block; margin-top: 16px; font-size: 0.9rem; }
.setup-panel #setupMessage { margin: 16px 0 0; }

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-size: 11.5px; /* Scaled down base font size to fit more content */
    font-family: var(--font-family);
    background: linear-gradient(135deg, #070708 0%, #111113 100%);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* Custom Premium Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 190, 11, 0.5); /* Primary color with transparency */
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Glassmorphism Panel */
.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px; /* Reduced from 16px */
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--text-main);
}
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-main);
}
.btn-primary {
    background: var(--primary);
    color: #0d0d0f;
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}
.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-outline:hover {
    background: rgba(255, 190, 11, 0.1);
}
.icon-btn {
    background: transparent;
    border: none;
    color: var(--primary);
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.icon-btn:hover {
    background: rgba(255, 190, 11, 0.1);
}

/* Inputs */
input:not([type="checkbox"]), select {
    width: 100%;
    padding: 8px 12px;
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    transition: border 0.2s;
}
input:not([type="checkbox"]):focus, select:focus {
    outline: none;
    border-color: var(--primary);
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

input[type="date"] {
    color-scheme: dark;
    cursor: pointer;
}

select option {
    background: var(--dark);
    color: var(--text-main);
}

/* Custom Date Picker (Centered on Screen) */
.datepicker-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    z-index: 99999;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.9), 0 0 25px rgba(255, 190, 11, 0.2);
    padding: 20px;
    border-radius: 16px;
    background: #181818;
    border: 1px solid rgba(255, 190, 11, 0.35);
}
.dp-days-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.7rem;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 8px;
}
.dp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.dp-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-main);
}
.dp-cell:hover:not(.dp-empty) {
    background: rgba(255, 179, 71, 0.2);
}
.dp-cell.dp-selected {
    background: var(--primary);
    color: var(--dark);
    font-weight: bold;
}
.dp-empty {
    cursor: default;
}

/* Fix native password eye color for dark mode (Edge/Windows) */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    filter: invert(1) brightness(2);
}

label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Loader */
.loader-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dark-bg);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease, visibility 0.8s ease, transform 0.8s cubic-bezier(0.5, 0, 0.2, 1);
    transform: scale(1);
}
.loader-container.hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(5);
}
.loader-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.loader-icon {
    width: 140px;
    height: 140px;
    color: var(--primary);
    filter: drop-shadow(0 0 20px rgba(255, 190, 11, 0.6));
    animation: pulseGlow 1.5s infinite alternate ease-in-out;
}
@keyframes pulseGlow {
    0% { transform: scale(0.95); filter: drop-shadow(0 0 10px rgba(255, 190, 11, 0.4)); }
    100% { transform: scale(1.05); filter: drop-shadow(0 0 40px rgba(255, 190, 11, 0.9)); }
}

/* Background Particles */
#particles-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* Login Page */
#page-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}
.login-box {
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-box h2 {
    margin-bottom: 24px;
    font-size: 2rem;
}
.login-box .input-group {
    text-align: left;
    margin-bottom: 16px;
}
.login-box .btn {
    width: 100%;
    margin-top: 16px;
}
#loginError {
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 16px;
    display: none;
}
#loginError.active {
    display: block;
}

/* Dashboard Layout */
.dashboard-layout {
    display: none; /* hidden by default */
    grid-template-columns: 200px 1fr;
    height: 100vh;
    overflow: hidden;
    transition: grid-template-columns 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.dashboard-layout.active {
    display: grid;
}
.dashboard-layout.sidebar-collapsed {
    grid-template-columns: 64px 1fr;
}
.dashboard-layout.sidebar-collapsed .sidebar {
    padding: 12px 6px;
    align-items: center;
}
.dashboard-layout.sidebar-collapsed .sidebar-logo {
    justify-content: center;
    gap: 0;
    margin-bottom: 16px;
}
.dashboard-layout.sidebar-collapsed .sidebar-logo .logo-text {
    display: none;
}
.dashboard-layout.sidebar-collapsed .sidebar-collapse-toggle {
    margin-left: 0;
    transform: rotate(180deg);
}
.dashboard-layout.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 9px;
    position: relative;
}
.dashboard-layout.sidebar-collapsed .nav-item span,
.dashboard-layout.sidebar-collapsed .nav-item i[data-lucide="chevron-down"],
.dashboard-layout.sidebar-collapsed .nav-group > a > span,
.dashboard-layout.sidebar-collapsed .nav-group > a > i[data-lucide="chevron-down"] {
    display: none;
}
.dashboard-layout.sidebar-collapsed .nav-submenu {
    display: none !important;
}
.dashboard-layout.sidebar-collapsed .user-info {
    display: none;
}
.dashboard-layout.sidebar-collapsed .user-profile {
    justify-content: center;
    padding: 8px 0;
    flex-direction: column;
    gap: 8px;
}
.dashboard-layout.sidebar-collapsed .user-profile #logoutBtn {
    margin-left: 0;
}

/* Visibility Utilities */
.mobile-only { display: none !important; }
.desktop-only { display: flex !important; }

/* Sidebar */
.sidebar {
    background: #0d0d0f;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 12px;
    height: 100vh;
    transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1), padding 0.25s ease;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
}
.sidebar-logo .logo-mark {
    display: inline-flex;
    align-items: center;
    user-select: none;
}
.sidebar-collapse-toggle {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}
.sidebar-collapse-toggle:hover {
    color: var(--primary);
    background: rgba(255, 190, 11, 0.12);
    border-color: var(--primary);
}
.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 500;
}
.nav-item:hover {
    color: var(--primary);
    background: rgba(255, 190, 11, 0.05);
}
.nav-item.active {
    color: #0d0d0f;
    background: var(--primary);
    font-weight: 700;
}
.nav-submenu {
    display: none;
    flex-direction: column;
    gap: 3px;
    padding-left: 14px;
    margin-top: 3px;
    margin-bottom: 4px;
    border-left: 2px solid rgba(255, 190, 11, 0.2);
    margin-left: 12px;
}
.nav-submenu.open {
    display: flex;
}
.nav-subitem {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    transition: all 0.2s;
}
.nav-subitem:hover {
    color: var(--primary);
    background: rgba(255, 190, 11, 0.08);
}
.nav-subitem.active {
    color: var(--primary);
    background: rgba(255, 190, 11, 0.16);
    font-weight: 600;
}
.user-sub-tab {
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    background: rgba(255, 255, 255, 0.04) !important;
    color: var(--text-muted) !important;
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    outline: none;
}
.user-sub-tab:hover {
    background: rgba(255, 190, 11, 0.12) !important;
    color: var(--primary) !important;
    border-color: rgba(255, 190, 11, 0.35) !important;
}
.user-sub-tab.active {
    background: var(--primary) !important;
    color: var(--dark) !important;
    font-weight: 700 !important;
    border-color: var(--primary) !important;
    box-shadow: 0 4px 14px rgba(255, 190, 11, 0.25);
}
.user-sub-tab span {
    background: rgba(255, 190, 11, 0.16) !important;
    color: var(--primary) !important;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.72rem;
    margin-left: 4px;
}
.user-sub-tab.active span {
    background: rgba(0, 0, 0, 0.25) !important;
    color: var(--dark) !important;
}
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}
.user-info h4 {
    font-size: 0.9rem;
    margin-bottom: 2px;
}
.user-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    margin: 12px 14px;
    padding: 14px 16px;
    border-radius: 18px;
    height: calc(100vh - 24px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background: rgba(14, 14, 16, 0.94);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
    transition: margin 0.2s ease, padding 0.2s ease;
}

#viewMasterOrders, #viewUsers {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

#viewLocations, #viewVendors {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    padding-right: 4px;
    padding-bottom: 30px;
}

/* Top Header */
.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-shrink: 0;
    gap: 10px;
    flex-wrap: wrap;
}
.header-title h1 {
    font-size: 1.25rem;
    margin-bottom: 2px;
}
.header-title p {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Metrics Row */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
    flex-shrink: 0;
}
.metric-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 14px;
}
.metric-card h3 {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.metric-card .value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
}

/* Quick Stock Actions Toolbar */
#stockActionsToolbar, .stock-actions-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin: 8px 0 12px 0;
}
.stock-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 13px;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}
.stock-action-btn:hover {
    background: rgba(255, 190, 11, 0.12);
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* Outlet Filter Pills Bar */
#outletFilterPills {
    display: flex;
    gap: 6px;
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
#outletFilterPills::-webkit-scrollbar {
    display: none;
}

/* Dashboard Grid (Table + Sidebar) */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 240px;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

.dash-grid:has(.sidebar-right.hidden),
.dash-grid:has(.sidebar-right[style*="display: none"]),
.dash-grid:not(:has(.sidebar-right)) {
    grid-template-columns: 1fr;
}

/* Data Table */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
    height: 100%;
    flex: 1;
    min-height: 280px;
    border-radius: 10px;
    scrollbar-width: thin;
}
.table-container-compact {
    overflow-y: auto;
    height: auto !important;
    max-height: 280px;
}
table {
    width: 100%;
    min-width: 580px;
    border-collapse: collapse;
    font-size: 0.8rem;
}
th, td {
    padding: 7px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    background: #141417;
    backdrop-filter: blur(16px);
    z-index: 10;
}
tbody tr:hover {
    background: rgba(255, 190, 11, 0.03);
}

/* Status Badges */
.status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}
.status.low { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.status.ok { background: rgba(52, 211, 153, 0.2); color: var(--success); }
.status.pending { background: rgba(251, 191, 36, 0.2); color: var(--warning); }

/* Right Sidebar Forms */
.sidebar-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    overflow-y: auto;
}
.form-section {
    margin-bottom: 0;
}
.form-section h3 {
    margin-bottom: 12px;
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
}
.form-section .input-group {
    margin-bottom: 8px;
}

/* Heatmap */
.heatmap-section {
    margin-top: 32px;
}
.heatmap-table th, .heatmap-table td {
    text-align: center;
}
.heatmap-cell {
    transition: background 0.3s;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal > .panel, .stock-modal-panel {
    width: min(94vw, 500px);
    max-height: 90vh;
    overflow-y: auto;
    padding: 22px;
}

/* Utility */
.hidden { display: none !important; }
.page:not(.active) { display: none !important; }

/* Responsive Media Queries */
@media (max-width: 1024px) {
    /* Tablet */
    .dashboard-layout {
        grid-template-columns: 175px 1fr;
    }
    .main-content {
        margin: 10px;
        padding: 12px;
        height: calc(100vh - 20px);
        border-radius: 14px;
    }
    .dash-grid {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
    .table-container {
        height: auto;
        flex: 1;
        min-height: 320px;
        max-height: none;
    }
    .sidebar-right {
        height: auto;
        overflow-y: visible;
        flex-direction: row;
        flex-wrap: wrap;
    }
    .form-section {
        flex: 1;
        min-width: 240px;
    }
    .metrics-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
}

@media (max-width: 768px) {
    /* Mobile */
    .mobile-only { display: flex !important; }
    .desktop-only { display: none !important; }

    /* Mobile Topbar */
    .mobile-topbar {
        height: 52px;
        background: #0d0d0f;
        border-bottom: 1px solid var(--border);
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 12px;
        position: sticky;
        top: 0;
        z-index: 1000;
        flex-shrink: 0;
    }
    .mobile-menu-btn {
        width: 36px;
        height: 36px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--border);
        color: var(--primary);
    }
    .mobile-logo {
        font-size: 1.15rem;
        font-weight: 800;
        letter-spacing: -0.5px;
    }
    .mobile-active-page {
        font-size: 0.72rem;
        font-weight: 600;
        color: var(--text-muted);
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid var(--border);
        padding: 3px 8px;
        border-radius: 12px;
        max-width: 120px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .mobile-topbar-actions {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    /* Dashboard Layout as Vertical Flex Stack */
    .dashboard-layout.active {
        display: flex;
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

    /* Slide-in Mobile Navigation Drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 275px;
        max-width: 82vw;
        background: #0f0f12;
        border-right: 1px solid rgba(255, 190, 11, 0.25);
        box-shadow: 10px 0 35px rgba(0, 0, 0, 0.85);
        z-index: 10001;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
        display: flex;
        flex-direction: column;
        padding: 16px;
        height: 100vh;
        overflow-y: auto;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .sidebar-logo {
        margin-bottom: 20px;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--border);
    }
    .mobile-drawer-close {
        width: 32px;
        height: 32px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.06);
        color: var(--text-muted);
    }
    .nav-menu {
        flex-direction: column;
        gap: 6px;
        margin-right: 0;
    }
    .nav-item {
        padding: 10px 12px;
        font-size: 0.9rem;
        border-radius: 8px;
    }
    .nav-submenu {
        margin-left: 14px;
        padding-left: 12px;
        border-left: 2px solid rgba(255, 190, 11, 0.3);
    }
    .nav-subitem {
        padding: 9px 12px;
        font-size: 0.86rem;
    }
    .user-profile {
        margin-top: auto;
        padding-top: 14px;
        border-top: 1px solid var(--border);
    }

    /* Drawer Backdrop */
    .mobile-drawer-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.7);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 10000;
        transition: opacity 0.25s ease;
    }
    .mobile-drawer-backdrop.hidden {
        display: none !important;
    }

    /* Main Content on Mobile */
    .main-content {
        margin: 6px;
        padding: 10px;
        border-radius: 12px;
        height: calc(100vh - 64px);
        overflow-y: auto;
        flex: 1;
    }

    /* Top Header */
    .dash-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 10px;
    }
    .header-title h1 {
        font-size: 1.15rem;
    }
    .header-title p {
        font-size: 0.74rem;
    }
    .header-filters {
        width: 100%;
        justify-content: space-between;
    }

    /* Metrics Row on Mobile */
    .metrics-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        margin-bottom: 10px;
    }
    .metric-card {
        padding: 8px 6px;
        border-radius: 8px;
        text-align: center;
        align-items: center;
    }
    .metric-card h3 {
        font-size: 0.6rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .metric-card .value {
        font-size: 1.2rem;
        line-height: 1.2;
    }

    /* Quick Stock Actions Toolbar on Mobile */
    #stockActionsToolbar, .stock-actions-toolbar {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
        margin: 8px 0 10px 0;
    }
    #stockActionsToolbar::-webkit-scrollbar,
    .stock-actions-toolbar::-webkit-scrollbar {
        display: none;
    }
    .stock-action-btn {
        padding: 5px 11px;
        font-size: 0.74rem;
        flex-shrink: 0;
    }

    /* Table Container on Mobile */
    .table-container {
        max-height: none;
        flex: 1;
        min-height: 260px;
        margin-bottom: 10px;
    }
    table th:first-child, table td:first-child {
        position: sticky;
        left: 0;
        background: #131316;
        z-index: 2;
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.4);
    }
    table th:first-child {
        z-index: 12;
    }

    /* Right Sidebar (Forms) on Mobile */
    .sidebar-right {
        flex-direction: column;
        height: auto;
    }

    /* Modals on Mobile */
    .modal {
        padding: 10px !important;
    }
    .modal > .panel, .stock-modal-panel {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92vh !important;
        padding: 18px 14px !important;
        border-radius: 12px !important;
    }
}

/* Fade In Page */
.fade-in-page {
    opacity: 0;
    transition: opacity 0.8s ease 0.3s;
}
.fade-in-page.show {
    opacity: 1;
}

/* Centered Custom UI Alert / Confirm / Prompt Modal */
#uiAlertModal {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.8) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    z-index: 9999999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    animation: fadeInModalBg 0.2s ease-out;
}

#uiAlertModal.hidden {
    display: none !important;
}

#uiAlertModal .panel {
    animation: centerModalScale 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInModalBg {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes centerModalScale {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Master Orders Outlet Filter Pills & Controls */
.outlet-pill {
    padding: 3px 10px;
    font-size: 0.74rem;
    font-weight: 500;
    border-radius: 16px;
    cursor: pointer;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.outlet-pill:hover {
    background: rgba(255, 190, 11, 0.12);
    color: var(--text-main);
    border-color: rgba(255, 190, 11, 0.35);
    transform: translateY(-1px);
}
.outlet-pill.active {
    background: var(--primary);
    color: #0d0d0f !important;
    font-weight: 700;
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(255, 190, 11, 0.35);
}
#storeViewTrigger:hover {
    border-color: var(--primary);
    background: rgba(28, 28, 30, 1);
}
#btnResetOutletFilter:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

body.database-saving::after {
    content: 'Saving…';
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    background: rgba(0, 0, 0, 0.2);
    display: grid;
    place-items: center;
    color: #ffbe0b;
    font-weight: 700;
    cursor: wait;
}

/* Item Name Suggestions Dropdown */
#newItemSuggestions {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 190, 11, 0.3) transparent;
}
#newItemSuggestions::-webkit-scrollbar {
    width: 6px;
}
#newItemSuggestions::-webkit-scrollbar-thumb {
    background: rgba(255, 190, 11, 0.3);
    border-radius: 4px;
}
.suggestion-item {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    transition: all 0.15s ease;
    font-size: 0.85rem;
}
.suggestion-item:hover, .suggestion-item.active {
    background: rgba(255, 190, 11, 0.16) !important;
}

/* Inline Cuisine Filter Select */
.cuisine-select {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 3px 10px;
    font-size: 0.74rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.cuisine-select:hover {
    border-color: rgba(255, 190, 11, 0.4);
    background: rgba(255, 190, 11, 0.08);
}
.cuisine-select.active {
    background: rgba(255, 190, 11, 0.15);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 10px rgba(255, 190, 11, 0.2);
}
.cuisine-select option {
    background: #18181b;
    color: #ffffff;
}



.nav-section-label { padding: 16px 10px 4px; color: var(--text-muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
.inventory-form { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; margin-bottom: 28px; max-width: 850px; }
.inventory-form h3, .inventory-form > p, .inventory-form > div { grid-column: 1 / -1; }
.inventory-workspace label { display: flex; flex-direction: column; gap: 7px; font-size: .85rem; }
.inventory-workspace input, .inventory-workspace select { width: 100%; padding: 10px; background: var(--dark); color: var(--text-main); border: 1px solid var(--border); border-radius: 8px; }
.inventory-search { max-width: 420px; margin-bottom: 18px; }
.inventory-workspace .table-container { overflow-x: auto; }
.dashboard-layout.sidebar-collapsed .nav-section-label { display: none; }
@media(max-width: 640px) { .inventory-form { grid-template-columns: 1fr; } .inventory-workspace { padding: 14px; } }

.inventory-filters { display:flex; align-items:flex-start; flex-wrap:wrap; gap:14px; width:100%; margin-bottom:14px; }
.inventory-filters label { display:flex; flex-direction:column; gap:6px; min-width:145px; font-size:.8rem; }
.inventory-filters input, .inventory-filters select, .item-picker input[type=text] { width:100%; padding:10px; background:var(--dark); color:var(--text-main); border:1px solid var(--border); border-radius:8px; }
.item-picker { position:relative; min-width:220px; }
.item-picker-options { position:absolute; top:calc(100% + 4px); left:0; right:0; max-height:260px; overflow-y:auto; background:#151517; border:1px solid var(--border-gold); border-radius:8px; padding:5px; z-index:100; box-shadow:0 12px 30px #0009; }
.item-picker-option, .outlet-menu-option { display:block; width:100%; text-align:left; border:0; padding:9px 10px; border-radius:5px; background:transparent; color:var(--text-main); cursor:pointer; }
.item-picker-option:hover, .item-picker-option[aria-selected=true], .outlet-menu-option:hover { background:rgba(255,190,11,.16); color:var(--primary); }
.item-picker-options small { display:block; padding:6px; color:var(--text-muted); }
.fixed-outlet { display:block; padding:10px; border:1px solid var(--border-gold); border-radius:8px; color:var(--primary); }
#storeViewTrigger:disabled { cursor:default; opacity:1; }
#reportError { color:var(--danger); width:100%; }
.master-stock-panel { min-width:0; overflow:visible; }
@media(max-width:640px) { .inventory-filters label, .inventory-filters .item-picker { min-width:0; width:100%; } .inventory-filters { flex-direction:column; } }

.master-stock-panel > div:first-child > div { width:100%; }

/* Ingredient cards must fit their grid cells rather than inherit modal sizing. */
#wizardItemsGrid { grid-template-columns:repeat(auto-fill,minmax(min(200px,100%),1fr)) !important; }
#wizardItemsGrid > .panel { min-width:0; width:auto; max-width:100%; overflow-wrap:anywhere; }
