:root {
    --primary: #0B3C5D;
    --primary-light: #145a8a;
    --secondary: #E0A11B;
    --hover: #F2C94C;
    --bg: #F7F9FC;
    --card: #FFFFFF;
    --heading: #1F2937;
    --text: #6B7280;
    --border: #E5E7EB;
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.25s ease;
}

[data-theme="dark"] {
    --primary: #3d8fd1;
    --primary-light: #5aa3db;
    --secondary: #E0A11B;
    --hover: #F2C94C;
    --bg: #111827;
    --card: #1F2937;
    --heading: #F9FAFB;
    --text: #9CA3AF;
    --border: #374151;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    max-width: 100vw;
    transition: background-color var(--transition), color var(--transition);
}

h1, h2, h3, h4, h5, h6,
.text-heading {
    color: var(--heading);
    font-weight: 600;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary-light);
}

/* ===== Layout ===== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed);
}

.page-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 100%;
    overflow-x: hidden;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--primary);
    color: #fff;
    z-index: 1040;
    transition: width var(--transition);
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 68px;
}

.sidebar-brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.65rem;
    background: #fff;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    text-decoration: none;
    flex-shrink: 0;
    transition: box-shadow var(--transition);
}

.sidebar-brand-logo:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.sidebar-brand-logo img {
    height: 38px;
    width: auto;
    max-width: 150px;
    object-fit: contain;
    display: block;
}

.sidebar-collapsed .sidebar-brand-logo {
    padding: 0.35rem;
}

.sidebar-collapsed .sidebar-brand-logo img {
    max-width: 36px;
}

.sidebar-brand span {
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--transition);
}

.sidebar-collapsed .sidebar-brand span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
}

.sidebar-nav .nav-section {
    padding: 0.5rem 1.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.5;
    white-space: nowrap;
}

.sidebar-collapsed .nav-section {
    opacity: 0;
    height: 0;
    padding: 0;
    overflow: hidden;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    color: rgba(255, 255, 255, 0.75);
    transition: all var(--transition);
    white-space: nowrap;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link i {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-left-color: var(--secondary);
}

.sidebar-nav .nav-link.active {
    background: rgba(255, 255, 255, 0.15);
}

.sidebar-collapsed .sidebar-nav .nav-link span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* ===== Navbar ===== */
.top-navbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1050;
    box-shadow: var(--shadow-sm);
    max-width: 100%;
    overflow: visible;
    flex-shrink: 0;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 0;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.top-navbar .dropdown-menu {
    z-index: 1060;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--heading);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--bg);
    border-color: var(--primary);
    color: var(--primary);
}

/* ===== Cards ===== */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
}

.card-hover:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--heading);
}

.card-body {
    padding: 1.25rem;
}

/* ===== Stat Cards ===== */
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-card .stat-icon.primary { background: rgba(11, 60, 93, 0.1); color: var(--primary); }
.stat-card .stat-icon.secondary { background: rgba(224, 161, 27, 0.15); color: var(--secondary); }
.stat-card .stat-icon.success { background: rgba(34, 197, 94, 0.12); color: #22c55e; }
.stat-card .stat-icon.warning { background: rgba(234, 179, 8, 0.12); color: #eab308; }
.stat-card .stat-icon.danger { background: rgba(239, 68, 68, 0.12); color: #ef4444; }

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--heading);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text);
}

/* ===== Product Cards ===== */
.product-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
    border-color: var(--secondary);
}

.product-card .product-img {
    width: 100%;
    height: 200px;
    object-fit: contain;
    background: var(--bg);
    padding: 1rem;
}

.product-img-btn {
    display: block;
    width: 100%;
    border: none;
    padding: 0;
    background: var(--bg);
    cursor: zoom-in;
}

.product-img-btn:hover .product-img {
    opacity: 0.92;
}

.product-image-preview {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.product-card .product-body {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-card .product-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--heading);
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card .product-code {
    font-size: 0.8rem;
    color: var(--text);
}

.product-card .product-price {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: auto;
    padding-top: 0.75rem;
}

.product-card .product-stock {
    font-size: 0.8rem;
}

.product-card .product-stock.in-stock { color: #22c55e; }
.product-card .product-stock.low-stock { color: #eab308; }
.product-card .product-stock.out-of-stock { color: #ef4444; }

/* ===== Buttons ===== */
.btn-primary {
    background-color: var(--primary) !important;
    border-color: var(--primary) !important;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-light) !important;
    border-color: var(--primary-light) !important;
}

.btn-secondary-custom {
    background-color: var(--secondary);
    border-color: var(--secondary);
    color: #fff;
}

.btn-secondary-custom:hover {
    background-color: var(--hover);
    border-color: var(--hover);
    color: var(--heading);
}

/* ===== Forms ===== */
.form-control,
.form-select {
    border-color: var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--heading);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(11, 60, 93, 0.15);
}

.form-label {
    color: var(--heading);
    font-weight: 500;
    font-size: 0.875rem;
}

/* ===== Tables ===== */
.table {
    color: var(--text);
}

.table thead th {
    background: var(--bg);
    color: var(--heading);
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.table tbody td {
    vertical-align: middle;
    border-color: var(--border);
}

.table-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
}

.table-actions form {
    display: inline-flex;
    margin: 0;
}

.table-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
}

.table td.actions-cell {
    width: 1%;
    white-space: nowrap;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* DataTables controls */
.dataTables_wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.dataTables_wrapper .dataTables_scroll {
    max-width: 100%;
}

.dataTables_wrapper .row {
    margin-left: 0;
    margin-right: 0;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 0.75rem;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin-top: 0.75rem;
}

table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
    background-color: var(--primary);
    border-color: var(--primary);
}

.container-fluid {
    width: 100%;
    max-width: 100%;
}

.select2-container {
    max-width: 100%;
}

/* ===== User Shop Header ===== */
.user-header {
    background: linear-gradient(135deg, #0B3C5D 0%, #0e4a72 50%, #145a8a 100%);
    border-bottom: 3px solid var(--secondary);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: 0 4px 20px rgba(11, 60, 93, 0.28);
}

.user-header-inner {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
}

.user-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    min-width: 0;
}

.user-brand {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 0.35rem 0.65rem;
    background: #fff;
    border-radius: var(--radius-sm);
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.user-brand img {
    height: 38px;
    width: auto;
    max-width: 150px;
    object-fit: contain;
    display: block;
}

.user-topnav {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 0.25rem;
    min-width: 0;
}

.user-topnav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.9rem;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.925rem;
    font-weight: 500;
    line-height: 1.2;
    border-radius: var(--radius-sm);
    text-decoration: none;
    white-space: nowrap;
    transition: background-color var(--transition), color var(--transition), box-shadow var(--transition);
    cursor: pointer;
}

.user-topnav-link:hover,
.user-topnav-link:focus {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.user-topnav-link.active {
    background: rgba(224, 161, 27, 0.22);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 0 -2px 0 var(--secondary);
}

.user-topnav-cart {
    position: relative;
}

.user-topnav-badge,
.user-mobile-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.35rem;
    height: 1.35rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--secondary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.user-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.user-topnav-icon {
    padding: 0.55rem 0.7rem;
    color: rgba(255, 255, 255, 0.9);
}

.user-topnav-icon:hover,
.user-topnav-icon:focus {
    color: #fff;
}

.user-topnav-logout {
    color: rgba(255, 255, 255, 0.9);
}

.user-topnav-logout:hover,
.user-topnav-logout:focus {
    background: rgba(220, 53, 69, 0.28);
    color: #ffc9ce;
}

.user-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1.35rem;
    cursor: pointer;
    transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

.user-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: var(--secondary);
    color: #fff;
}

.user-header-search {
    width: 100%;
}

.user-header-search .form-control {
    border-radius: 50px 0 0 50px;
    border: 1px solid var(--border);
    border-right: none;
    padding-left: 1rem;
    min-width: 0;
    background: var(--bg);
}

.user-header-search .btn-search {
    border-radius: 0 50px 50px 0;
    background: var(--secondary);
    border: 1px solid var(--secondary);
    color: #fff;
    padding: 0 1.15rem;
    flex-shrink: 0;
}

.user-header-search .btn-search:hover {
    background: var(--hover);
    border-color: var(--hover);
    color: var(--heading);
}

.shop-search {
    display: flex;
    width: 100%;
}

.shop-search .form-control {
    border-radius: 50px 0 0 50px;
    border: 1px solid var(--border);
    border-right: none;
    padding-left: 1rem;
    min-width: 0;
    background: var(--card);
}

.shop-search .btn-search {
    border-radius: 0 50px 50px 0;
    background: var(--secondary);
    border: 1px solid var(--secondary);
    color: #fff;
    padding: 0 1.15rem;
    flex-shrink: 0;
}

.shop-search .btn-search:hover {
    background: var(--hover);
    border-color: var(--hover);
    color: var(--heading);
}

.user-page-content {
    padding: 1rem;
}

body.user-layout {
    background: linear-gradient(180deg, #e8eef5 0%, var(--bg) 140px);
}

[data-theme="dark"] body.user-layout {
    background: var(--bg);
}

.user-mobile-nav .offcanvas-header {
    background: linear-gradient(135deg, #0B3C5D 0%, #145a8a 100%);
    border-bottom: 3px solid var(--secondary);
    color: #fff;
}

.user-mobile-nav .offcanvas-title {
    color: #fff;
    font-weight: 600;
}

.user-mobile-nav .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.85;
}

.user-mobile-nav .offcanvas-body {
    display: flex;
    flex-direction: column;
}

.user-mobile-links {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.user-mobile-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--heading);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color var(--transition), color var(--transition);
}

.user-mobile-link i {
    font-size: 1.15rem;
    width: 1.35rem;
    text-align: center;
}

.user-mobile-link:hover,
.user-mobile-link:focus {
    background: rgba(11, 60, 93, 0.08);
    color: var(--primary);
}

.user-mobile-link.active {
    background: rgba(11, 60, 93, 0.1);
    color: var(--primary);
    font-weight: 600;
    border-left: 3px solid var(--secondary);
    padding-left: calc(1rem - 3px);
}

.user-mobile-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.user-mobile-logout:hover,
.user-mobile-logout:focus {
    background: rgba(220, 53, 69, 0.1) !important;
    color: #dc3545 !important;
}

/* Branded header stays consistent in dark mode */
[data-theme="dark"] .user-brand,
[data-theme="dark"] .sidebar-brand-logo {
    background: #fff;
}

.user-header .search-form {
    max-width: 500px;
    flex: 1;
}

.user-header .search-form .form-control {
    border-radius: 50px 0 0 50px;
    border: none;
    padding-left: 1.25rem;
}

.user-header .search-form .btn-search {
    border-radius: 0 50px 50px 0;
    background: var(--secondary);
    border: none;
    color: #fff;
    padding: 0 1.25rem;
}

.user-header .search-form .btn-search:hover {
    background: var(--hover);
    color: var(--heading);
}

.cart-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--secondary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Auth Layout ===== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, #145a8a 50%, var(--secondary) 100%);
    padding: 2rem;
}

.auth-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    padding: 2.5rem;
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo img {
    height: 60px;
    margin-bottom: 0.75rem;
}

.auth-logo h4 {
    color: var(--heading);
    margin: 0;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--secondary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header-title {
    flex: 1 1 auto;
    min-width: 0;
}

.page-header h1,
.page-header-title h1 {
    font-size: 1.5rem;
    margin: 0;
}

.page-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
    flex: 0 1 auto;
}

@media (max-width: 991.98px) {
    .page-header-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .page-header-actions .btn,
    .page-header-actions .d-flex {
        width: 100%;
    }

    .page-header-actions .d-flex {
        flex-direction: column;
        gap: 0.5rem;
    }

    .page-header-actions .d-flex .btn {
        width: 100%;
    }

    .page-header-actions form {
        width: 100%;
    }

    .page-header-actions form .btn {
        width: 100%;
    }
}

@media (min-width: 992px) {
    .page-header-actions {
        flex-wrap: nowrap;
    }
}

.page-header .breadcrumb {
    margin: 0;
    font-size: 0.85rem;
}

.navbar-title-wrap {
    min-width: 0;
    max-width: calc(100vw - 180px);
}

/* ===== Badge Status ===== */
.badge-status {
    padding: 0.35em 0.75em;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 500;
}

/* ===== Filter Bar ===== */
.filter-bar {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 992px) {
    .filter-bar .row.align-items-end {
        flex-wrap: nowrap;
    }

    .filter-bar .row.align-items-end > [class*="col-"] {
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
    }

    .filter-bar .form-control,
    .filter-bar .form-select,
    .filter-bar .btn {
        min-height: calc(1.5em + 0.75rem + 2px);
    }

    .filter-bar .select2-container--bootstrap-5 .select2-selection--single {
        min-height: calc(1.5em + 0.75rem + 2px);
        display: flex;
        align-items: center;
    }

    .filter-bar .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
        line-height: calc(1.5em + 0.75rem);
        padding-top: 0;
        padding-bottom: 0;
    }

    .filter-bar .select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
        height: calc(1.5em + 0.75rem + 2px);
    }
}

@media (max-width: 991.98px) {
    .filter-bar .col-lg-auto.ms-lg-auto {
        margin-left: 0;
    }
}

.shop-filter-bar .shop-filter-row {
    flex-wrap: wrap;
}

@media (min-width: 992px) {
    .shop-filter-bar .shop-filter-row {
        flex-wrap: nowrap;
    }
}

@media (max-width: 575.98px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar {
        padding: 0.75rem;
    }

    .filter-bar .form-label {
        margin-bottom: 0.35rem;
    }
}

/* ===== Dark mode overrides ===== */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: #374151;
    color: #F9FAFB;
    border-color: #4B5563;
}

[data-theme="dark"] .table thead th {
    background: #374151;
}

[data-theme="dark"] .sidebar {
    background: #0f172a;
}

[data-theme="dark"] .btn-icon {
    background: #374151;
    border-color: #4B5563;
    color: #F9FAFB;
}

[data-theme="dark"] .modal-content {
    background: var(--card);
    color: var(--text);
}

[data-theme="dark"] .dropdown-menu {
    background: var(--card);
    border-color: var(--border);
}

[data-theme="dark"] .dropdown-item {
    color: var(--text);
}

[data-theme="dark"] .dropdown-item:hover {
    background: var(--bg);
    color: var(--heading);
}

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
    }

    .sidebar-collapsed .main-content {
        margin-left: 0 !important;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1035;
        display: none;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .top-navbar {
        padding: 0.65rem 1rem;
    }

    .navbar-right .dropdown .btn span,
    .navbar-right .dropdown-toggle .user-name {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .page-content {
        padding: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .card-header {
        padding: 0.75rem 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.25rem;
    }

    .product-card .product-img {
        height: 160px;
    }

    .auth-wrapper {
        padding: 1rem;
        align-items: flex-start;
        padding-top: 2rem;
    }

    .auth-card {
        padding: 1.5rem;
    }

    .toast-container {
        left: 0.75rem;
        right: 0.75rem;
        top: auto;
        bottom: 1rem;
    }

    .toast-container .toast {
        width: 100%;
        max-width: 100%;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        text-align: left;
        float: none;
        width: 100%;
    }

    .dataTables_wrapper .dataTables_length select,
    .dataTables_wrapper .dataTables_filter input {
        width: 100%;
        max-width: 100%;
        margin-left: 0;
    }

    .dataTables_wrapper table.dataTable thead th {
        white-space: normal;
        font-size: 0.78rem;
        padding: 0.5rem 0.35rem;
    }

    .dataTables_wrapper table.dataTable tbody td {
        font-size: 0.85rem;
        padding: 0.5rem 0.35rem;
    }

    table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control,
    table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control {
        padding-left: 1.75rem;
    }

    table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control::before,
    table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control::before {
        top: 50%;
        transform: translateY(-50%);
    }

    table.dataTable > tbody > tr.child ul.dtr-details {
        width: 100%;
    }

    table.dataTable > tbody > tr.child ul.dtr-details > li {
        display: flex;
        justify-content: space-between;
        gap: 0.5rem;
        padding: 0.35rem 0;
        border-bottom: 1px solid var(--border);
    }

    .dataTables_wrapper .dataTables_info {
        text-align: center;
        float: none;
        width: 100%;
        padding-top: 0.5rem;
    }

    .dataTables_wrapper .dataTables_paginate {
        text-align: center;
        float: none;
        width: 100%;
        margin-top: 0.5rem;
    }

    .dataTables_wrapper .dataTables_paginate .pagination {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-fullscreen-sm-down {
        width: 100%;
        max-width: none;
        margin: 0;
    }

    .table-actions {
        flex-wrap: wrap;
    }

    .product-card form.d-flex {
        flex-wrap: wrap;
    }

    .product-card form.d-flex .form-control {
        width: 100% !important;
        max-width: 100%;
    }
}

@media (min-width: 768px) {
    .user-header-inner {
        padding: 0.85rem 1.5rem;
    }

    .user-header-search {
        max-width: 640px;
        margin: 0 auto;
    }

    .user-page-content {
        padding: 1.5rem;
    }
}

@media (min-width: 992px) {
    .user-header-inner {
        gap: 0.85rem;
    }

    .user-topnav {
        gap: 0.35rem;
    }
}

/* ===== Select2 / DataTables dark ===== */
[data-theme="dark"] .select2-container--default .select2-selection--single {
    background: #374151;
    border-color: #4B5563;
    color: #F9FAFB;
}

[data-theme="dark"] .select2-dropdown {
    background: #1F2937;
    border-color: #4B5563;
}

[data-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--primary);
}

[data-theme="dark"] table.dataTable tbody tr {
    background: var(--card);
    color: var(--text);
}

[data-theme="dark"] .dataTables_wrapper .dataTables_filter input,
[data-theme="dark"] .dataTables_wrapper .dataTables_length select {
    background: #374151;
    color: #F9FAFB;
    border-color: #4B5563;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text);
}

.empty-state i {
    font-size: 3rem;
    opacity: 0.4;
    margin-bottom: 1rem;
}

/* ===== User content & orders ===== */
.user-content-wrap {
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
    min-width: 0;
}

.order-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.order-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow var(--transition), border-color var(--transition);
}

.order-card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(224, 161, 27, 0.45);
}

.order-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.order-card-meta {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.order-card-number {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    word-break: break-word;
}

.order-card-date {
    font-size: 0.85rem;
    color: var(--text);
}

.order-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem 1rem;
    padding: 1rem 1.15rem;
    align-items: center;
}

.order-card-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.order-card-stat-label {
    font-size: 0.78rem;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.order-card-stat-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--heading);
    word-break: break-word;
}

.order-card-stat-total .order-card-stat-value {
    font-size: 1.15rem;
    color: var(--primary);
}

.order-card-action {
    grid-column: 1 / -1;
}

.order-card-action .btn {
    width: 100%;
}

.user-pagination .pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
    margin-bottom: 0;
}

.order-summary-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.order-summary-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.order-summary-list li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.order-summary-list span:first-child {
    color: var(--text);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.order-summary-list strong,
.order-summary-list .badge {
    text-align: right;
}

.order-notes {
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
}

.order-notes p {
    margin-top: 0.35rem;
    color: var(--text);
    font-size: 0.92rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.order-item-list {
    display: flex;
    flex-direction: column;
}

.order-item-row {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    grid-template-areas:
        "thumb info"
        "thumb qty"
        "thumb unit"
        "thumb total";
    gap: 0.35rem 0.75rem;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--border);
    align-items: start;
}

.order-item-row:last-child {
    border-bottom: none;
}

.order-item-thumb {
    grid-area: thumb;
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 0.25rem;
}

.order-item-info {
    grid-area: info;
    min-width: 0;
}

.order-item-info strong {
    display: block;
    color: var(--heading);
    word-break: break-word;
}

.order-item-qty,
.order-item-unit,
.order-item-line-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.9rem;
    padding-left: 0;
}

.order-item-qty { grid-area: qty; }
.order-item-unit { grid-area: unit; }
.order-item-line-total { grid-area: total; }

.order-item-qty-form {
    grid-area: qty;
    min-width: 0;
}

.order-item-qty-form .order-item-qty-label {
    display: block;
    margin-bottom: 0.25rem;
}

.order-item-remove {
    grid-area: remove;
    align-self: center;
    justify-self: end;
}

.order-item-editable {
    grid-template-areas:
        "thumb info remove"
        "thumb qty remove"
        "thumb unit remove"
        "thumb total remove";
}

.order-item-qty-label {
    font-size: 0.78rem;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.order-item-line-total strong {
    color: var(--heading);
}

.order-grand-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem;
    background: var(--bg);
    border-top: 1px solid var(--border);
    font-size: 1rem;
}

.order-grand-total strong {
    font-size: 1.2rem;
}

.order-item-removed {
    opacity: 0.72;
    background: rgba(107, 114, 128, 0.08);
}

.order-item-removed td,
.order-item-removed strong,
.order-item-removed .order-item-info strong {
    color: var(--text) !important;
}

@media (min-width: 576px) {
    .order-card-body {
        grid-template-columns: 1fr 1fr auto;
    }

    .order-card-action {
        grid-column: auto;
        justify-self: end;
    }

    .order-card-action .btn {
        width: auto;
        white-space: nowrap;
    }
}

@media (min-width: 768px) {
    .order-item-row {
        grid-template-columns: 52px minmax(0, 2fr) repeat(3, minmax(72px, 1fr));
        grid-template-areas: "thumb info qty unit total";
        align-items: center;
        gap: 1rem;
    }

    .order-item-editable {
        grid-template-columns: 52px minmax(0, 2fr) minmax(120px, 1fr) repeat(2, minmax(72px, 1fr)) auto;
        grid-template-areas: "thumb info qty unit total remove";
    }

    .order-item-qty,
    .order-item-qty-form,
    .order-item-unit,
    .order-item-line-total {
        flex-direction: column;
        align-items: flex-end;
        justify-content: center;
        text-align: right;
    }
}

/* ===== Cart ===== */
.cart-card .card-footer {
    background: var(--bg);
}

.cart-item-list {
    display: flex;
    flex-direction: column;
}

.cart-item-row {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    grid-template-areas:
        "thumb info remove"
        "thumb qty remove"
        "thumb total remove";
    gap: 0.5rem 0.75rem;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--border);
    align-items: start;
}

.cart-item-row:last-child {
    border-bottom: none;
}

.cart-item-thumb {
    grid-area: thumb;
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 0.25rem;
}

.cart-item-info {
    grid-area: info;
    min-width: 0;
}

.cart-item-info strong {
    display: block;
    color: var(--heading);
    word-break: break-word;
}

.cart-item-unit-price {
    display: inline-block;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--text);
}

.cart-item-qty-form {
    grid-area: qty;
    min-width: 0;
}

.cart-item-qty-label {
    display: block;
    font-size: 0.78rem;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
}

.cart-item-qty-controls {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    max-width: 160px;
}

.cart-item-qty-controls .form-control {
    min-width: 0;
}

.cart-item-line-total {
    grid-area: total;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.cart-item-line-total strong {
    color: var(--heading);
    font-size: 1rem;
}

.cart-item-remove {
    grid-area: remove;
    align-self: start;
}

.cart-footer {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.15rem;
}

.cart-footer-summary {
    text-align: center;
}

.cart-checkout-form {
    width: 100%;
}

@media (min-width: 768px) {
    .cart-item-row {
        grid-template-columns: 56px minmax(0, 2fr) minmax(140px, 1fr) minmax(100px, 1fr) auto;
        grid-template-areas: "thumb info qty total remove";
        align-items: center;
        gap: 1rem;
    }

    .cart-item-qty-controls {
        max-width: none;
    }

    .cart-item-line-total {
        align-items: flex-end;
        text-align: right;
    }

    .cart-footer {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
    }

    .cart-footer-summary {
        text-align: right;
        flex-shrink: 0;
    }

    .cart-checkout-form {
        flex: 1;
        max-width: 420px;
    }
}
