* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #3d5a80; --secondary: #98c1d9; --light: #e0fbfc;
    --accent: #ee6c4d; --dark: #293241; --white: #ffffff; --gray: #6c757d;
    --success: #28a745; --danger: #dc3545;
    --sidebar-width: 220px; --sidebar-collapsed: 60px;
    --bs-primary: #3d5a80; --bs-secondary: #6c757d; --bs-success: #28a745;
    --bs-danger: #dc3545; --bs-warning: #ee6c4d; --bs-info: #98c1d9;
    --bs-light: #e0fbfc; --bs-dark: #293241;
}
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; min-height: 100vh; overflow-x: hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed; top: 0; left: 0; width: var(--sidebar-width); height: 100vh;
    background: var(--dark); z-index: 200; display: flex; flex-direction: column;
    transition: width 0.15s ease; overflow: hidden;
}
.sidebar-header {
    display: flex; align-items: center; height: 60px; padding: 0 12px;
    gap: 12px; border-bottom: 1px solid rgba(255,255,255,0.08); flex-shrink: 0;
}
.sidebar-toggle {
    background: none; border: none; color: var(--white); font-size: 1.4rem; cursor: pointer;
    padding: 8px; border-radius: 8px; transition: background 0.2s; flex-shrink: 0;
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.1); }
.sidebar-brand { color: #fff; font-size: 1rem; font-weight: 600; white-space: nowrap; transition: opacity 0.2s; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
    display: flex; align-items: center; gap: 14px; padding: 10px 16px;
    color: rgba(255,255,255,0.75); text-decoration: none; font-size: 0.9rem;
    white-space: nowrap; transition: background 0.1s; margin: 0 8px; border-radius: 8px;
}
.sidebar-link:hover { background: rgba(255,255,255,0.1); color: var(--white); }
.sidebar-link .si { font-size: 1.2rem; flex-shrink: 0; width: 24px; text-align: center; }
.sidebar-link .st { transition: opacity 0.2s; }
.sidebar-divider { border: none; border-top: 1px solid rgba(255,255,255,0.1); margin: 6px 16px; flex-shrink: 0; }
.sidebar-footer {
    display: flex; align-items: center; gap: 8px; padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.08); flex-shrink: 0; white-space: nowrap;
}
.sidebar-dark-btn {
    background: none; border: none; font-size: 1.1rem; cursor: pointer; padding: 6px;
    border-radius: 6px; line-height: 1; flex-shrink: 0;
}
.sidebar-dark-btn:hover { background: rgba(255,255,255,0.1); }
.sidebar-user { color: rgba(255,255,255,0.7); font-size: 0.8rem; font-weight: 500; }
.sidebar-role { background: var(--accent); color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; }
.sidebar-logout { color: rgba(255,255,255,0.5); text-decoration: none; font-size: 1.1rem; margin-left: auto; padding: 4px 8px; border-radius: 6px; transition: all 0.2s; }
.sidebar-logout:hover { color: var(--accent); background: rgba(238,108,77,0.15); }
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-brand { opacity: 0; width: 0; }
.sidebar.collapsed .st { opacity: 0; width: 0; overflow: hidden; }
.sidebar.collapsed .sidebar-user, .sidebar.collapsed .sidebar-role { display: none; }
.sidebar.collapsed .sidebar-footer { justify-content: center; padding: 12px 4px; }
.sidebar.collapsed .sidebar-link { justify-content: center; padding: 10px 8px; margin: 0 4px; }
.sidebar.collapsed .sidebar-link .si { width: auto; }

/* ===== MAIN ===== */
.main-area { margin-left: var(--sidebar-width); transition: margin-left 0.15s ease; min-height: 100vh; display: flex; flex-direction: column; }
.sidebar.collapsed ~ .main-area { margin-left: var(--sidebar-collapsed); }

/* ===== TOPBAR ===== */
.topbar { background: var(--primary); color: #fff; padding: 0 1.5rem; display: flex; align-items: center; justify-content: space-between; height: 60px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); position: sticky; top: 0; z-index: 100; }
.topbar h1 { font-size: 1.3rem; font-weight: 600; }
.mobile-menu-btn { display: none; background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }
.mobile-nav { display: none; }

/* ===== CUSTOM COMPONENTS ===== */
.stat-card { background: #fff; border-radius: 12px; padding: 1.5rem; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,0.06); border-left: 4px solid var(--primary); transition: transform 0.2s; }
.stat-card:hover { transform: translateY(-2px); }
.stat-card .number { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 0.85rem; color: var(--gray); margin-top: 0.3rem; }
.stat-card.border-warning { border-left-color: var(--accent); }
.stat-card.border-warning .number { color: var(--accent); }
.stat-card.border-success { border-left-color: var(--success); }
.stat-card.border-success .number { color: var(--success); }
.cart-item { display: flex; justify-content: space-between; align-items: center; padding: 0.7rem 0; border-bottom: 1px solid var(--secondary); }
.cart-item .info .name { font-weight: 500; }
.cart-item .info .price { font-size: 0.85rem; color: var(--gray); }
.cart-total { font-size: 1.5rem; font-weight: 700; color: var(--primary); text-align: right; margin: 1rem 0; }
.change-display { font-size: 1.2rem; font-weight: 600; color: var(--success); text-align: center; padding: 0.5rem; }
.table-responsive { overflow-x: auto; }
.text-muted-small { font-size: 0.75rem; color: var(--gray); }
pre { white-space: pre-wrap; }
.thead-primary th { background: var(--dark) !important; color: #fff !important; font-weight: 600; border-color: rgba(255,255,255,0.1) !important; }
body.dark-mode .thead-primary th { background: #1e2335 !important; color: #8ab8d9 !important; }

.card-header-primary { background: var(--dark) !important; color: #fff !important; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,0.1) !important; }
body.dark-mode .card-header-primary { background: #1e2335 !important; color: #8ab8d9 !important; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-area { margin-left: 0 !important; }
    .mobile-menu-btn { display: block; }
    .desktop-only { display: none !important; }
    .mobile-nav {
        position: absolute; top: 60px; left: 0; right: 0; background: var(--primary);
        flex-direction: column; padding: 0 1rem; box-shadow: 0 4px 8px rgba(0,0,0,0.2);
        max-height: 0; overflow: hidden; transition: max-height 0.15s ease, padding 0.15s ease;
        display: flex;
    }
    .mobile-nav.open { max-height: 500px; padding: 1rem; }
    .mobile-nav a { color: #fff; text-decoration: none; padding: 0.7rem 1rem; border-radius: 6px; font-size: 0.9rem; opacity: 0; transform: translateX(-10px); transition: opacity 0.15s ease, transform 0.15s ease; }
    .mobile-nav a:hover { background: rgba(255,255,255,0.15); }
    .mobile-nav.open a { opacity: 1; transform: translateX(0); }
}

/* ===== DARK MODE ===== */
body.dark-mode { --primary: #5a8dc9; --secondary: #6a9ab8; --light: #1e2335; --accent: #ee6c4d; --dark: #e0e0e0; --white: #2a3045; --gray: #b0b8c8; --success: #2dce89; --danger: #f55d6e; }
body.dark-mode .sidebar { background: #161a2a; }
body.dark-mode .sidebar-link { color: rgba(255,255,255,0.65); }
body.dark-mode .sidebar-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
body.dark-mode .topbar, body.dark-mode .topbar nav a, body.dark-mode .mobile-nav a, body.dark-mode .topbar .user-info { color: #ffffff; }
body.dark-mode .stat-card { background: var(--white); }
body.dark-mode .stat-card .number { color: #8ab8d9; }
body.dark-mode .card { background: var(--white); border-color: #3a4055; }
body.dark-mode .card-header { background: #1e2335; color: #8ab8d9; border-bottom-color: #3a4055; }
body.dark-mode .card-body { color: #d0d4e0; }
body.dark-mode .cart-total { color: #8ab8d9; }
body.dark-mode .table { color: #d0d4e0; }
body.dark-mode .table th { background: #1e2335; color: #8ab8d9; border-color: #3a4055; }
body.dark-mode .table td { border-color: #3a4055; }
body.dark-mode .table tr:hover td { background: rgba(74,122,181,0.12); }
body.dark-mode .form-control, body.dark-mode .form-select { background: #1e2335; color: #e0e0e0; border-color: #3a4055; }
body.dark-mode .form-control:focus, body.dark-mode .form-select:focus { background: #252a3a; color: #fff; }
body.dark-mode .form-label, body.dark-mode label { color: #c0c8d8; }
body.dark-mode .list-group-item { background: var(--white); color: #d0d4e0; border-color: #3a4055; }
body.dark-mode .modal-content { background: var(--white); }
body.dark-mode .modal-header { background: #1e2335; border-bottom-color: #3a4055; }
body.dark-mode .modal-header .modal-title { color: #8ab8d9; }
body.dark-mode .modal-footer { border-top-color: #3a4055; }
body.dark-mode .btn-close { filter: invert(0.8); }
body.dark-mode .bg-light { background-color: #1e2335 !important; }
body.dark-mode pre, body.dark-mode code { color: #e0e0e0; }
