:root {
    --primary: #dc2626;
    --primary-hover: #b91c1c;
    --primary-glow: rgba(220, 38, 38, 0.15);
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --card-hover: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --sidebar-width: 280px;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: 
        /* Technical Grid Lines */
        linear-gradient(rgba(0, 0, 0, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.025) 1px, transparent 1px),
        /* Ambient Brand Red Glow (Top Right) */
        radial-gradient(circle at 85% 0%, rgba(229, 9, 20, 0.08) 0%, rgba(229, 9, 20, 0) 50%),
        /* Ambient Warm Amber Glow (Bottom Left) */
        radial-gradient(circle at 15% 85%, rgba(255, 165, 0, 0.04) 0%, rgba(255, 165, 0, 0) 60%),
        /* Base Warm Radial Canvas */
        radial-gradient(circle at 50% 0%, #ffffff 0%, #f4f4f7 100%);
    background-size: 40px 40px, 40px 40px, 100% 100%, 100% 100%, 100% 100%;
    background-attachment: fixed;
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Scrollbar customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
    background: #d1d1d6;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

h1, h2, h3 { 
    font-family: 'Montserrat', sans-serif;
    font-weight: 800; 
    color: var(--text-main); 
    letter-spacing: -0.5px;
}

.text-danger { 
    color: #ef4444 !important; 
}

/* Premium Typography & Dividers */
.section-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 24px; 
    flex-wrap: wrap;
    gap: 16px;
}
.section-header h2 {
    font-size: 1.5rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-header h2::before {
    content: '';
    display: block;
    width: 4px;
    height: 24px;
    background: var(--primary);
    border-radius: 2px;
    flex-shrink: 0;
}

/* Buttons with tactile feedback */
.btn {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    outline: none;
}
.btn-primary { 
    background: var(--primary); 
    color: white; 
    box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover { 
    background: var(--primary-hover); 
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(229, 9, 20, 0.25); 
}
.btn-primary:active {
    transform: translateY(1px);
}
.btn-outline { 
    background: transparent; 
    border: 1px solid var(--border-color); 
    color: var(--text-main); 
}
.btn-outline:hover { 
    background: #f1f1f5; 
    border-color: #d1d1d6; 
}
.btn-danger { 
    background: rgba(239, 68, 68, 0.1); 
    color: #ef4444; 
    border: 1px solid rgba(239, 68, 68, 0.2); 
}
.btn-danger:hover { 
    background: rgba(239, 68, 68, 0.2); 
    border-color: rgba(239, 68, 68, 0.3);
}
.btn-sm { 
    padding: 6px 12px; 
    font-size: 0.75rem; 
    border-radius: 4px;
}

/* Login Panel (Redesigned & Responsive) */
.login-body { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    height: 100vh; 
    background: 
        linear-gradient(rgba(0, 0, 0, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.025) 1px, transparent 1px),
        radial-gradient(circle at 85% 0%, rgba(229, 9, 20, 0.08) 0%, rgba(229, 9, 20, 0) 50%),
        radial-gradient(circle at 15% 85%, rgba(255, 165, 0, 0.04) 0%, rgba(255, 165, 0, 0) 60%),
        radial-gradient(circle at 50% 0%, #ffffff 0%, #f4f4f7 100%);
    background-size: 40px 40px, 40px 40px, 100% 100%, 100% 100%, 100% 100%;
    padding: 20px;
}
.login-card { 
    background: var(--card-bg); 
    padding: 40px 30px; 
    border-radius: 12px; 
    border: 1px solid var(--border-color); 
    width: 100%; 
    max-width: 400px; 
    text-align: center;
    box-shadow: var(--shadow-md);
}
.login-logo { 
    margin-bottom: 24px; 
    color: var(--primary); 
    display: inline-flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    background: rgba(229, 9, 20, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(229, 9, 20, 0.15);
}
.login-card h2 { 
    margin-bottom: 8px; 
    font-size: 1.6rem;
}
.login-card p { 
    color: var(--text-muted); 
    margin-bottom: 28px; 
    font-size: 0.9rem; 
}
.alert { 
    padding: 12px; 
    border-radius: 6px; 
    margin-bottom: 20px; 
    font-size: 0.85rem; 
    text-align: left;
}
.alert.error { 
    background: rgba(239, 68, 68, 0.1); 
    color: #ef4444; 
    border: 1px solid rgba(239, 68, 68, 0.2); 
}

/* Forms controls */
.form-group { 
    margin-bottom: 20px; 
    text-align: left; 
}
.form-group label { 
    display: block; 
    margin-bottom: 8px; 
    font-size: 0.75rem; 
    font-weight: 700; 
    color: var(--text-muted); 
    text-transform: uppercase; 
    letter-spacing: 0.5px;
}
.form-group input[type="text"], 
.form-group input[type="password"], 
.form-group input[type="number"], 
.form-group select, 
.form-group textarea {
    width: 100%; 
    padding: 12px 16px; 
    border: 1px solid var(--border-color); 
    border-radius: 6px; 
    font-family: inherit; 
    font-size: 0.9rem; 
    outline: none; 
    transition: all 0.2s;
    background: #ffffff; 
    color: var(--text-main);
}
.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus { 
    border-color: var(--primary); 
    background: #ffffff;
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.login-card .btn { 
    width: 100%; 
    padding: 14px; 
    font-size: 0.95rem; 
    margin-top: 10px;
}
.form-row { 
    display: flex; 
    gap: 16px; 
    margin-bottom: 16px;
}
.checkbox-label { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    font-size: 0.85rem; 
    cursor: pointer; 
    color: var(--text-muted); 
    user-select: none;
}
.checkbox-label input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Layout */
.admin-layout { 
    display: flex; 
    height: 100vh; 
    overflow: hidden; 
}

/* Sidebar Navigation */
.sidebar { 
    width: var(--sidebar-width); 
    background: var(--card-bg); 
    border-right: 1px solid var(--border-color); 
    display: flex; 
    flex-direction: column; 
    flex-shrink: 0;
}
.sidebar-header { 
    padding: 24px; 
    border-bottom: 1px solid var(--border-color); 
}
.sidebar-header h3 { 
    color: var(--text-main); 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    font-size: 1rem; 
    border-left: 3px solid var(--primary);
    padding-left: 10px;
}
.sidebar-nav { 
    flex: 1; 
    padding: 20px 0; 
    overflow-y: auto; 
}
.nav-link { 
    display: block; 
    padding: 14px 24px; 
    color: var(--text-muted); 
    text-decoration: none; 
    font-weight: 600; 
    font-size: 0.9rem;
    transition: all 0.2s; 
    border-left: 3px solid transparent; 
}
.nav-link:hover { 
    background: #f1f1f5; 
    color: var(--text-main); 
}
.nav-link.active {
    background: rgba(229, 9, 20, 0.05); 
    color: var(--primary); 
    border-left-color: var(--primary); 
}
.mobile-only-nav {
    display: none !important;
}
.sidebar-footer { 
    padding: 20px; 
    border-top: 1px solid var(--border-color); 
}

/* Main Content Workspace */
.main-content { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
}
.topbar { 
    background: var(--card-bg); 
    padding: 16px 30px; 
    border-bottom: 1px solid var(--border-color); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-shrink: 0;
}
.topbar h2 { 
    font-size: 1.1rem; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.user-profile { 
    font-size: 0.8rem;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.03);
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}
.content-wrapper { 
    flex: 1; 
    padding: 30px; 
    overflow-y: auto; 
}

/* Dashboard Metrics */
.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); 
    gap: 24px; 
    margin-bottom: 30px; 
}
.stat-card { 
    background: var(--card-bg); 
    padding: 24px; 
    border-radius: 12px; 
    border: 1px solid var(--border-color); 
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
    z-index: 1;
}
.stat-card:hover {
    transform: translateY(-4px) scale(1.02);
    border-color: var(--card-accent, var(--border-color));
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}
.stat-card:hover::after {
    opacity: 1;
}

/* Specific accent glows for each card on hover */
.stat-card:has(.orders):hover {
    --card-accent: rgba(229, 9, 20, 0.2);
    box-shadow: 0 12px 30px rgba(229, 9, 20, 0.06), 0 0 20px rgba(229, 9, 20, 0.02);
}
.stat-card:has(.orders)::after {
    background: radial-gradient(circle at 80% 20%, rgba(229, 9, 20, 0.03) 0%, rgba(229, 9, 20, 0) 50%);
}

.stat-card:has(.products):hover {
    --card-accent: rgba(34, 197, 94, 0.2);
    box-shadow: 0 12px 30px rgba(34, 197, 94, 0.06), 0 0 20px rgba(34, 197, 94, 0.02);
}
.stat-card:has(.products)::after {
    background: radial-gradient(circle at 80% 20%, rgba(34, 197, 94, 0.03) 0%, rgba(34, 197, 94, 0) 50%);
}

.stat-card:has(.categories):hover {
    --card-accent: rgba(245, 158, 11, 0.2);
    box-shadow: 0 12px 30px rgba(245, 158, 11, 0.06), 0 0 20px rgba(245, 158, 11, 0.02);
}
.stat-card:has(.categories)::after {
    background: radial-gradient(circle at 80% 20%, rgba(245, 158, 11, 0.03) 0%, rgba(245, 158, 11, 0) 50%);
}

.stat-card-content {
    position: relative;
    z-index: 2;
}
.stat-card h3 { 
    color: var(--text-muted); 
    font-size: 0.75rem; 
    margin-bottom: 8px; 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
}
.stat-card .value { 
    font-size: 2.2rem; 
    font-weight: 800; 
    color: var(--text-main); 
    font-family: 'Inter', sans-serif;
    line-height: 1.1;
}

/* SVG Wrapper with micro-degradados */
.stat-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    z-index: 2;
}
.stat-icon-wrapper svg {
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.stat-card:hover .stat-icon-wrapper svg {
    transform: scale(1.15) rotate(5deg);
}

/* SVG Wrapper specifics */
.stat-icon-wrapper.orders {
    background: rgba(229, 9, 20, 0.08);
    color: #e50914;
    border: 1px solid rgba(229, 9, 20, 0.12);
}
.stat-card:hover .stat-icon-wrapper.orders {
    background: #e50914;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(229, 9, 20, 0.25);
}

.stat-icon-wrapper.products {
    background: rgba(34, 197, 94, 0.08);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.12);
}
.stat-card:hover .stat-icon-wrapper.products {
    background: #22c55e;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.25);
}

.stat-icon-wrapper.categories {
    background: rgba(245, 158, 11, 0.08);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.12);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 30px;
}
.chart-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
}
.dashboard-side .card {
    height: 100%;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}
.card-header h3 {
    font-size: 0.95rem;
    color: var(--text-main);
    text-transform: uppercase;
}
.btn-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
}
.btn-link:hover {
    text-decoration: underline;
}

/* Recent Orders List */
.recent-orders-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.recent-order-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    transition: transform 0.2s;
}
.recent-order-item:hover {
    transform: translateX(4px);
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.ro-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(229, 9, 20, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}
.ro-details {
    flex: 1;
}
.ro-details h4 {
    font-size: 0.85rem;
    margin-bottom: 2px;
}
.ro-details span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-card:hover .stat-icon-wrapper.categories {
    background: #f59e0b;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

/* Table Design (Premium Glassmorphic Table) */
.card { 
    background: var(--card-bg); 
    border-radius: 8px; 
    border: 1px solid var(--border-color); 
    overflow: hidden; 
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}
.table { 
    width: 100%; 
    border-collapse: collapse; 
}
.table th, .table td { 
    padding: 14px 16px; 
    text-align: left; 
    border-bottom: 1px solid var(--border-color); 
    font-size: 0.88rem; 
}
.table th { 
    color: var(--text-muted); 
    font-weight: 700; 
    text-transform: uppercase; 
    font-size: 0.75rem; 
    letter-spacing: 0.5px; 
    background: #f8f9fa;
}
.table tr:hover td {
    background: rgba(0, 0, 0, 0.01);
}
.table tr:last-child td { 
    border-bottom: none; 
}
.thumb, .thumb-placeholder { 
    width: 48px; 
    height: 48px; 
    object-fit: contain; 
    padding: 2px; /* Frame thumbnail images elegantly without cropping */
    border-radius: 6px; 
    border: 1px solid var(--border-color); 
    background: #ffffff; 
}
.thumb-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}
.badge { 
    padding: 6px 12px 6px 22px; 
    border-radius: 50px; 
    font-size: 0.72rem; 
    font-weight: 600; 
    text-transform: uppercase; 
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    position: relative;
    line-height: 1;
}
.badge::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.badge.success { 
    background: rgba(34, 197, 94, 0.08); 
    color: #16a34a; 
    border: 1px solid rgba(34, 197, 94, 0.15); 
}
.badge.success::before {
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e, 0 0 3px #22c55e;
    animation: ledPulseGreen 2s infinite alternate;
}
.badge.neutral { 
    background: rgba(142, 146, 155, 0.08); 
    color: #4b5563; 
    border: 1px solid rgba(142, 146, 155, 0.15); 
}
.badge.neutral::before {
    background: #9ca3af;
    box-shadow: none;
}

@keyframes ledPulseGreen {
    0% {
        opacity: 0.6;
        box-shadow: 0 0 4px #22c55e;
    }
    100% {
        opacity: 1;
        box-shadow: 0 0 10px #22c55e, 0 0 4px #22c55e;
    }
}

/* Modals Overlay & Content */
.modal { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0,0,0,0.6); 
    backdrop-filter: blur(8px); 
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000; 
    justify-content: center; 
    align-items: center; 
    padding: 20px;
}
.modal.active { 
    display: flex; 
}
.modal-content { 
    background: var(--card-bg); 
    width: 100%; 
    max-width: 500px; 
    border-radius: 12px; 
    border: 1px solid var(--border-color); 
    padding: 30px; 
    box-shadow: var(--shadow-md);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 24px; 
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
}
.close-btn { 
    background: none; 
    border: none; 
    font-size: 1.8rem; 
    cursor: pointer; 
    color: var(--text-muted); 
    transition: color 0.2s; 
    display: flex;
    align-items: center;
    justify-content: center;
}
.close-btn:hover { 
    color: var(--text-main); 
}
.modal-footer { 
    margin-top: 30px; 
    display: flex; 
    justify-content: flex-end; 
    gap: 12px; 
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

/* ========================================================== */
/* RESPONSIVE DESIGN FOR SMARTPHONES & TABLETS                */
/* ========================================================== */
@media (max-width: 768px) {
    /* Redesign layout for vertical flow */
    .admin-layout {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }
    
    /* Convert Sidebar to an elegant Top Header with scrolling navigation tab bar */
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        position: sticky;
        top: 0;
        z-index: 100;
        background: var(--card-bg);
        padding: 0;
    }
    
    .sidebar-header {
        padding: 16px 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid var(--border-color);
    }
    
    .sidebar-header h3 {
        font-size: 0.95rem;
        padding-left: 8px;
    }
    
    .sidebar-nav {
        display: flex;
        flex-direction: row;
        padding: 0;
        overflow-x: auto;
        white-space: nowrap;
        scrollbar-width: none; /* Firefox */
    }
    
    .sidebar-nav::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }
    
    .nav-link {
        padding: 14px 18px;
        border-left: none;
        border-bottom: 3px solid transparent;
        display: inline-block;
        font-size: 0.85rem;
    }
    .mobile-only-nav {
        display: inline-block !important;
    }
    
    .nav-link.active {
        background: transparent;
        color: var(--primary);
        border-bottom-color: var(--primary);
    }
    
    .sidebar-footer {
        display: none !important;
    }
    
    /* Topbar adjustments - hidden on mobile to maximize workspace */
    .topbar {
        display: none !important;
    }
    
    /* Work area spacing */
    .content-wrapper {
        padding: 15px 10px;
        overflow-y: visible;
    }
    
    /* Grid system updates */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-card .value {
        font-size: 1.6rem;
    }
    
    .card {
        padding: 16px;
    }
    
    /* MODAL ERGONOMICS FOR TOUCH */
    .modal-content {
        padding: 20px 15px;
        width: 100%;
        max-height: 85vh;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    /* TABLE TO CARDS RADICAL TRANSFORM FOR CELLPHONE */
    .table, 
    .table thead, 
    .table tbody, 
    .table th, 
    .table td, 
    .table tr {
        display: block;
    }
    
    .table thead {
        display: none; /* Hide header rows completely */
    }
    
    .table tr {
        margin-bottom: 16px;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        background: var(--card-bg);
        padding: 8px 12px;
        box-shadow: var(--shadow-sm);
    }
    
    .table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 4px;
        border-bottom: 1px solid var(--border-color);
        font-size: 0.85rem;
        text-align: right;
    }
    
    .table td:last-child {
        border-bottom: none;
        justify-content: flex-end;
        padding-top: 14px;
        gap: 10px;
    }
    
    /* Mobilized label injector */
    .table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
        text-transform: uppercase;
        font-size: 0.72rem;
        text-align: left;
        margin-right: 15px;
        letter-spacing: 0.5px;
    }
    
    .table td .thumb {
        width: 40px;
        height: 40px;
    }
    
    .table td .btn {
        margin-left: 4px;
    }
}

/* ========================================================== */
/* PREMIUM TOAST NOTIFICATIONS SYSTEM                        */
/* ========================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    max-width: 380px;
    width: calc(100% - 48px);
}

.toast {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    padding: 14px 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateY(20px);
    opacity: 0;
    animation: toastSlideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards,
               toastFadeOut 0.3s cubic-bezier(0.16, 1, 0.3, 1) var(--toast-delay, 4s) forwards;
    position: relative;
    overflow: hidden;
}

/* Color accents left border */
.toast::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--toast-accent, var(--primary));
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--toast-bg, rgba(229, 9, 20, 0.08));
    color: var(--toast-accent, var(--primary));
}

.toast-message {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-main);
    line-height: 1.4;
    flex-grow: 1;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.toast-close:hover {
    color: var(--text-main);
}

/* Toast States */
.toast.success {
    --toast-accent: #22c55e;
    --toast-bg: rgba(34, 197, 94, 0.08);
}
.toast.error {
    --toast-accent: #ef4444;
    --toast-bg: rgba(239, 68, 68, 0.08);
}
.toast.info {
    --toast-accent: #3b82f6;
    --toast-bg: rgba(59, 130, 246, 0.08);
}

@keyframes toastSlideIn {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes toastFadeOut {
    to {
        transform: translateY(-10px) scale(0.95);
        opacity: 0;
        pointer-events: none;
    }
}

/* Responsiveness for Toast Container */
@media (max-width: 480px) {
    .toast-container {
        bottom: 16px;
        right: 16px;
        width: calc(100% - 32px);
    }
    .toast {
        padding: 12px 14px;
        gap: 10px;
    }
}

/* ============================================================
   PUNTO DE VENTA (POS) STYLES
   ============================================================ */
.pos-container {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 25px;
    margin-top: 10px;
    align-items: start;
    width: 100%;
}
.pos-products-col {
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.pos-filter-bar {
    display: flex;
    gap: 12px;
}
.pos-search-input {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    font-size: 0.9rem;
    transition: 0.2s;
    background: #fff;
    height: 40px;
}
.pos-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.pos-select-filter {
    padding: 0 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    background: #fff;
    height: 40px;
}

/* Products Grid */
.pos-products-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: calc(100vh - 240px);
    max-height: none;
    overflow-y: auto;
    padding-right: 5px;
}
.pos-product-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}
.pos-product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--primary);
}
.pos-product-card:active {
    transform: scale(0.97);
}
.pos-prod-img-wrapper {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
    border: 1px solid #f1f1f5;
}
.pos-prod-img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}
.pos-prod-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #cbd5e1;
}
.pos-prod-title {
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1.35;
    min-height: 2.7em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text-main);
}
.pos-prod-price {
    font-size: 0.85rem;
    font-weight: 900;
    color: var(--primary);
}
.pos-prod-stock {
    font-size: 0.72rem;
    font-weight: 700;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
}
.pos-prod-stock.out-of-stock {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

/* Cart Column */
.pos-cart-col {
    position: sticky;
    top: 95px;
}
.pos-cart-items {
    flex-grow: 1;
    overflow-y: auto;
    height: calc(100vh - 430px);
    max-height: none;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 5px;
}
.pos-empty-cart {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: #94a3b8;
    gap: 12px;
}
.pos-empty-cart p {
    font-size: 0.85rem;
    font-weight: 600;
}

/* Cart Item */
.pos-cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fafafc;
    gap: 10px;
}
.pos-item-details {
    flex-grow: 1;
}
.pos-item-name {
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.3;
}
.pos-item-price {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-top: 3px;
}
.pos-item-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pos-qty-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    color: #444;
}
.pos-qty-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.pos-qty-val {
    font-size: 0.85rem;
    font-weight: 800;
    min-width: 15px;
    text-align: center;
}
.pos-item-total {
    font-size: 0.85rem;
    font-weight: 900;
    color: var(--text-main);
    min-width: 65px;
    text-align: right;
}

/* Summary Box */
.pos-cart-summary {
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
    background: #fff;
}
.pos-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.pos-summary-row.total {
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--text-main);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 6px;
}
.pos-summary-row.total span:last-child {
    color: var(--primary);
}

.pos-mobile-tabs {
    display: none;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    gap: 5px;
}
.pos-mob-tab {
    flex: 1;
    border: none;
    background: none;
    padding: 12px;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    font-family: 'Montserrat', sans-serif;
}
.pos-mob-tab.active {
    background: var(--primary);
    color: #ffffff;
}

@media (max-width: 991px) {
    .pos-container {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 768px) {
    /* Ocupar el 100% del ancho real en celulares eliminando paddings innecesarios */
    #section-pos {
        margin: -10px -5px;
        padding: 0;
    }
    .pos-mobile-tabs {
        display: flex;
        margin-bottom: 15px;
    }
    .pos-cart-col {
        display: none; /* Controlado dinámicamente mediante JS */
        position: static;
    }
    .pos-products-grid {
        height: calc(100vh - 280px) !important;
        max-height: none !important;
    }
    .pos-cart-items {
        height: calc(100vh - 460px) !important;
        max-height: none !important;
    }
    .pos-product-card {
        padding: 14px 12px;
        border-radius: 8px;
        background: #ffffff;
        box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    }
    .pos-prod-title {
        font-size: 0.88rem !important;
        font-weight: 800;
        line-height: 1.4;
    }
    .pos-prod-price {
        font-size: 0.95rem !important;
        font-weight: 900;
    }
}

/* PREMIUM CARD-BASED CATEGORIES SYSTEM */
.category-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 800px;
    width: 100%;
}
.cat-parent-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.cat-parent-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04), 0 0 15px rgba(229, 9, 20, 0.01);
    border-color: rgba(229, 9, 20, 0.15);
}
.cat-parent-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #ffffff;
    border-bottom: 1px dashed var(--border-color);
}
.cat-parent-info {
    display: flex;
    align-items: center;
    gap: 15px;
}
.cat-parent-icon-wrapper {
    width: 44px;
    height: 44px;
    background: #f8f9fa;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    transition: all 0.3s;
}
.cat-parent-card:hover .cat-parent-icon-wrapper {
    background: rgba(229, 9, 20, 0.05);
    border-color: rgba(229, 9, 20, 0.15);
    color: var(--primary);
}
.cat-parent-icon-wrapper img {
    width: 26px;
    height: 26px;
    object-fit: contain;
}
.cat-parent-icon-wrapper svg {
    color: #4b5563;
}
.cat-parent-card:hover .cat-parent-icon-wrapper svg {
    color: var(--primary);
}
.cat-parent-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.cat-parent-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary);
    background: rgba(229, 9, 20, 0.08);
    padding: 2px 8px;
    border-radius: 50px;
    width: fit-content;
    letter-spacing: 0.5px;
}
.cat-parent-name {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.3px;
    margin: 0;
}
.cat-actions {
    display: flex;
    gap: 8px;
}
.btn-cat-action {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-muted);
}
.btn-cat-action.edit:hover {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #16a34a;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.15);
}
.btn-cat-action.delete:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.15);
}

/* Subcategories Container */
.cat-subs-container {
    background: #fafafc;
    padding: 10px 20px;
    display: flex;
    flex-direction: column;
}
.cat-sub-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f1f1f5;
}
.cat-sub-row:last-child {
    border-bottom: none;
}
.cat-sub-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.cat-tree-node-icon {
    color: #cbd5e1;
    display: flex;
    align-items: center;
}
.cat-sub-badge {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #475569;
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.cat-sub-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-main);
}
.cat-actions.mini .btn-cat-action {
    width: 28px;
    height: 28px;
    border-radius: 6px;
}


@media (max-width: 768px) {
    #section-pos {
        margin: -15px -10px;
        padding: 5px;
        background: #f8fafc;
    }
    .pos-container {
        gap: 10px !important;
    }
    .pos-products-grid {
        height: auto !important;
        max-height: 50vh !important;
        grid-template-columns: repeat(2, 1fr) !important;
        display: grid !important;
        gap: 10px !important;
        overflow-y: auto !important;
        padding-bottom: 20px;
    }
    .pos-cart-col {
        display: none; /* Oculto por defecto hasta que se seleccione algo */
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        z-index: 1000;
        box-shadow: 0 -10px 30px rgba(0,0,0,0.1);
        padding: 15px;
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
        height: 45vh;
        transform: translateY(calc(100% - 60px));
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    .pos-cart-col.open {
        transform: translateY(0);
    }
    .pos-cart-items {
        height: calc(45vh - 120px) !important;
    }
    .mobile-cart-toggle {
        position: absolute;
        top: -20px;
        left: 50%;
        transform: translateX(-50%);
        background: #fff;
        padding: 5px 20px;
        border-radius: 20px;
        box-shadow: 0 -5px 15px rgba(0,0,0,0.05);
        font-weight: 800;
        color: var(--primary);
        cursor: pointer;
        border: 1px solid var(--border-color);
        display: flex;
        align-items: center;
        gap: 8px;
    }
}


/* ========================================================== */
/* ULTRA MOBILE FIRST OVERHAUL                                */
/* ========================================================== */
.bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .admin-layout {
        display: block !important;
        padding-bottom: 70px !important;
    }
    
    .sidebar {
        display: none !important; /* TOTAL HIDE SIDEBAR ON MOBILE */
    }
    
    .main-content {
        width: 100% !important;
        padding: 0 !important;
    }
    
    .content-wrapper {
        padding: 15px 12px 30px !important; /* Quitar margenes gigantes */
    }
    
    .topbar {
        display: flex !important;
        position: sticky;
        top: 0;
        z-index: 50;
        background: #fff;
        border-bottom: 1px solid var(--border-color);
        padding: 12px 15px !important;
        justify-content: space-between;
        align-items: center;
        box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    }
    
    .topbar h2 {
        font-size: 1.1rem;
        margin: 0;
    }
    
    /* Full width cards on mobile */
    .card {
        margin-left: -5px;
        margin-right: -5px;
        border-radius: 12px;
        width: calc(100% + 10px);
    }
    
    /* Bottom Navigation Bar */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 65px;
        background: #ffffff;
        box-shadow: 0 -5px 20px rgba(0,0,0,0.05);
        border-top: 1px solid var(--border-color);
        z-index: 9999;
        justify-content: space-around;
        align-items: center;
        padding: 0 5px;
    }
    
    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: var(--text-muted);
        gap: 4px;
        flex: 1;
        height: 100%;
        transition: 0.2s;
        border: none !important; /* overwrite nav-link border */
        padding: 0 !important;
    }
    
    .bottom-nav-item span {
        font-size: 0.65rem;
        font-weight: 700;
        font-family: var(--font-body);
    }
    
    .bottom-nav-item svg {
        width: 22px;
        height: 22px;
    }
    
    .bottom-nav-item.active {
        color: var(--primary) !important;
        background: transparent !important;
    }
    
    .bottom-nav-item.active svg {
        stroke-width: 2.5;
    }
    
    .bottom-nav-item.pos-btn {
        position: relative;
    }
    
    .pos-icon-wrapper {
        width: 48px;
        height: 48px;
        background: var(--primary);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        margin-top: -24px;
        box-shadow: 0 5px 15px var(--primary-glow);
        border: 4px solid #fff;
    }
    
    .bottom-nav-item.pos-btn span {
        margin-top: 2px;
        color: var(--text-main);
    }
}


/* DASHBOARD FIXES */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    /* Let the 3rd stat card span full width to not look awkward */
    .stat-card:nth-child(3) {
        grid-column: span 2;
    }
}


.dashboard-grid > .card {
    min-width: 0;
    overflow: hidden;
}


/* FIX MOBILE TABLE CELLS FOR ORDERS */
@media (max-width: 768px) {
    .table td {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: left !important;
        gap: 5px;
    }
    .table td::before {
        margin-right: 0 !important;
        margin-bottom: 2px;
        color: var(--primary) !important;
    }
    .table td ul {
        padding-left: 20px !important;
        width: 100%;
    }
    .table td:last-child {
        justify-content: flex-start !important;
        flex-direction: row !important;
    }
}


/* POS MOBILE COMPACT OPTIMIZATION */
@media (max-width: 768px) {
    /* Hide redundant elements to save space */
    #section-pos .section-header {
        display: none !important;
    }
    
    .pos-mobile-tabs {
        display: none !important;
    }
    
    /* Make the filter bar ultra compact */
    .pos-filter-bar {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        padding: 5px 0 10px 0 !important;
        margin-bottom: 0 !important;
    }
    
    .pos-search-input, .pos-select-filter {
        flex: 1;
        width: 50% !important;
        padding: 8px !important;
        font-size: 0.8rem !important;
        height: 36px !important;
        border-radius: 8px !important;
        margin: 0 !important;
    }
    
    /* Make product cards smaller to fit more */
    .pos-products-grid {
        gap: 8px !important;
        grid-template-columns: repeat(2, 1fr) !important;
        padding-bottom: 70px !important; /* Leave space for bottom nav */
    }
    
    .pos-product-card {
        padding: 8px !important;
        border-radius: 10px !important;
    }
    
    .pos-prod-title {
        font-size: 0.75rem !important;
        line-height: 1.2 !important;
        margin-bottom: 4px !important;
    }
    
    .pos-prod-price {
        font-size: 0.85rem !important;
    }
    
    .pos-product-card > div > div:nth-child(2) {
        font-size: 0.65rem !important;
        margin-top: 4px !important;
        gap: 2px !important;
    }
    
    /* Ensure the mobile cart toggle looks sleek */
    .mobile-cart-toggle {
        top: -24px !important;
        padding: 6px 16px !important;
        font-size: 0.8rem !important;
        border-radius: 16px 16px 0 0 !important;
        border-bottom: none !important;
    }
}


/* GLOBAL BOX SIZING FIX */
* {
    box-sizing: border-box;
}

/* POS OVERFLOW FIXES */
@media (max-width: 768px) {
    #section-pos {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }
    
    .pos-products-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        padding-right: 0 !important;
    }
    
    .pos-product-card {
        width: 100% !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        overflow: hidden !important;
    }
    
    .pos-filter-bar {
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Ensure Orders Section shows up */
    #section-orders {
        width: 100% !important;
        overflow-x: hidden !important;
    }
    
    #section-orders .card {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    #section-orders .table tr {
        display: flex !important;
        flex-direction: column !important;
    }
}


/* REDESIGN CART TOGGLE TO BE A SMALL FLOATING ICON */
@media (max-width: 768px) {
    .pos-cart-col {
        transform: translateY(100%) !important; /* Totalmente oculto hacia abajo */
        height: 60vh !important; /* Un poco mas alto al abrir */
        padding-top: 30px !important;
        bottom: 0 !important;
        z-index: 10000 !important;
        display: flex !important; /* Always flex on mobile, JS toggles visibility if needed, but we rely on transform */
    }
    
    .pos-cart-col.open {
        transform: translateY(0) !important;
    }
    
    /* Boton para cerrar el panel (la barrita gris) */
    .pos-cart-col::after {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 5px;
        background: #cbd5e1;
        border-radius: 5px;
    }
    
    .mobile-cart-toggle {
        display: none; /* Oculto por defecto hasta agregar items */
        position: fixed !important;
        bottom: 80px !important; /* Arriba de la barra de navegacion inferior */
        right: 20px !important;
        top: auto !important;
        left: auto !important;
        transform: none !important;
        width: 60px !important;
        height: 60px !important;
        border-radius: 50% !important;
        background: var(--primary) !important;
        color: white !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4) !important;
        padding: 0 !important;
        z-index: 9990 !important;
        cursor: pointer;
    }
    
    .mobile-cart-toggle span {
        display: none !important; /* Ocultar texto */
    }
    
    /* Mostrar solo el contador en una burbuja roja usando attr(data-count) */
    .mobile-cart-toggle::after {
        content: attr(data-count);
        position: absolute;
        top: -5px;
        right: -5px;
        background: #ef4444;
        color: white;
        font-size: 0.75rem;
        font-weight: 900;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 2px solid white;
    }
}
