:root {
            --bg: #F4F6F9;
            --card: #FFFFFF;
            --text: #1E293B;
            --text-light: #64748B;
            --green: #10B981;
            --orange: #F59E0B;
            --red: #EF4444;
            --blue: #3B82F6;
            --border: rgba(226, 232, 240, 0.8);
            --shadow: 0 4px 20px rgba(15, 23, 42, 0.03);
            --shadow-hover: 0 10px 30px rgba(15, 23, 42, 0.08);
            --font: 'Outfit', sans-serif;
            --sidebar-width: 80px;
            --radius: 16px;
}

        /* ==================== RESET & GLOBAL ==================== */
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body {
            font-family: var(--font);
            background-color: var(--bg);
            color: var(--text);
            overflow-x: hidden;
            display: flex;
            height: 100vh;
        }
        button { cursor: pointer; border: none; font-family: inherit; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
        input, select { font-family: inherit; }
        ::-webkit-scrollbar { width: 6px; height: 6px; }
        ::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 10px; }

        /* ==================== LAYOUT & SIDEBAR ==================== */
        .sidebar {
            width: var(--sidebar-width);
            background: var(--card);
            border-right: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 24px 0;
            z-index: 100;
            transition: all 0.3s ease;
        }
        .sidebar-icon {
            width: 48px; height: 48px;
            margin-bottom: 20px;
            border-radius: 12px;
            display: flex; justify-content: center; align-items: center;
            color: var(--text-light);
            font-size: 1.3rem;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        .sidebar-icon:hover, .sidebar-icon.active {
            background: rgba(59, 130, 246, 0.1);
            color: var(--blue);
        }

        .menu-toggle {
            display: none;
            font-size: 1.5rem;
            background: none;
            color: var(--text);
            z-index: 110;
        }

        .main-wrapper {
            flex: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            width: 100%;
        }

        /* ==================== HEADER ==================== */
        .header {
            height: 80px;
            background: rgba(244, 246, 249, 0.8);
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 32px;
            backdrop-filter: blur(12px);
            border-bottom: 1px solid var(--border);
            position: sticky; top: 0; z-index: 90;
            gap: 20px;
        }
        .brand { display: flex; flex-direction: column; min-width: 150px; }
        .brand h1 { font-size: 1.2rem; font-weight: 800; letter-spacing: 0.5px; color: var(--text); }
        .brand span { font-size: 0.7rem; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
        
        .search-container { position: relative; width: 100%; max-width: 400px; }
        .search-container input {
            width: 100%; padding: 12px 16px 12px 44px;
            border-radius: 24px; border: 1px solid var(--border);
            background: var(--card); outline: none;
            font-size: 0.9rem; transition: all 0.3s ease;
            box-shadow: var(--shadow);
        }
        .search-container input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15); }
        .search-container::before {
            content: '🔍'; position: absolute; left: 16px; top: 50%;
            transform: translateY(-50%); font-size: 0.9rem; opacity: 0.6;
        }

        .user-info { display: flex; align-items: center; gap: 24px; font-size: 0.9rem; }
        .time-date { text-align: right; color: var(--text-light); }
        .user-profile { display: flex; align-items: center; gap: 12px; }
        .avatar { width: 40px; height: 40px; background: linear-gradient(135deg, var(--blue), #1d4ed8); border-radius: 50%; color: white; display: flex; justify-content: center; align-items: center; font-weight: 700; box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3); }
        .user-role { font-size: 0.75rem; color: var(--text-light); }

        /* ==================== CONTENT & VIEWS ==================== */
        .content { padding: 32px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 32px; }

        .view-section { display: none; opacity: 0; transform: translateY(15px); transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
        .view-section.active { display: block; opacity: 1; transform: translateY(0); }

        /* VIEWS UTILITIES & FILTERS */
        .section-header-actions {
            display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; margin-bottom: 20px;
        }
        .filter-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; width: 100%; max-width: max-content; }
        .filter-btn { padding: 8px 16px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; font-size: 0.85rem; font-weight: 500; color: var(--text-light); white-space: nowrap; }
        .filter-btn.active, .filter-btn:hover { background: var(--blue); color: white; border-color: var(--blue); }

        .action-btn { padding: 10px 20px; background: linear-gradient(135deg, var(--blue), #1d4ed8); color: white; font-weight: 600; border-radius: 12px; font-size: 0.85rem; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2); }
        .action-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3); }

        /* ==================== COMPONENTS & GRIDS ==================== */
        .section-title { font-size: 1.2rem; font-weight: 700; display: flex; justify-content: space-between; align-items: center; color: var(--text); margin-bottom: 16px; }
        
        .stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
        .stat-card {
            background: var(--card); padding: 24px; border-radius: var(--radius);
            box-shadow: var(--shadow); border: 1px solid var(--border);
            display: flex; flex-direction: column; gap: 8px; transition: transform 0.3s;
        }
        .stat-card:hover { transform: translateY(-2px); }
        .stat-title { color: var(--text-light); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
        .stat-value { font-size: 2.2rem; font-weight: 700; color: var(--text); }

        .dashboard-split-grid { display: grid; grid-template-columns: 1fr; gap: 32px; }
        .dashboard-double-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 32px; }

        /* LOW STOCK */
        .low-stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
        .ls-card {
            background: var(--card); border-radius: var(--radius); padding: 18px;
            display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow);
            border: 1px solid var(--border); transition: all 0.3s ease;
        }
        .ls-card.danger { background: #FEF2F2; border-color: rgba(239, 68, 110, 0.2); }
        .ls-img { width: 54px; height: 54px; border-radius: 12px; background: #F1F5F9; display: flex; justify-content: center; align-items: center; font-size: 1.6rem; }
        .ls-info { flex: 1; }
        .ls-name { font-weight: 600; font-size: 0.95rem; color: var(--text); }
        .ls-stock { font-size: 0.85rem; color: var(--red); font-weight: 600; margin-top: 4px; }
        .ls-btn { padding: 6px 12px; background: var(--bg); border-radius: 8px; font-size: 0.75rem; font-weight: 600; color: var(--text); border: 1px solid var(--border); }
        .ls-btn:hover { background: var(--blue); color: white; border-color: var(--blue); }

        /* INVENTORY CATALOG */
        .inventory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 24px; }
        .inv-card {
            background: var(--card); border-radius: var(--radius); padding: 18px;
            box-shadow: var(--shadow); border: 1px solid var(--border);
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); position: relative; overflow: hidden;
        }
        .inv-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-hover); }
        .inv-img { width: 100%; height: 130px; border-radius: 12px; margin-bottom: 16px; background: linear-gradient(135deg, #F8FAFC, #E2E8F0); display: flex; justify-content: center; align-items: center; font-size: 3.2rem; }
        .inv-cat { position: absolute; top: 26px; right: 26px; font-size: 0.65rem; background: rgba(255,255,255,0.95); padding: 4px 10px; border-radius: 20px; font-weight: 700; box-shadow: 0 2px 8px rgba(0,0,0,0.06); color: var(--text-light); text-transform: uppercase;}
        .inv-code { font-size: 0.7rem; color: var(--text-light); font-weight: 500; }
        .inv-name { font-weight: 600; font-size: 1rem; margin: 4px 0 8px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
        .inv-price { font-weight: 700; color: var(--blue); font-size: 1.15rem; }
        
        .stock-bar-container { width: 100%; height: 8px; background: #E2E8F0; border-radius: 4px; margin-top: 14px; overflow: hidden; position: relative;}
        .stock-bar { height: 100%; border-radius: 4px; transition: width 0.6s ease; background-size: 30px 30px; background-image: linear-gradient(135deg, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent); animation: barStripes 2s linear infinite; }
        @keyframes barStripes { from { background-position: 0 0; } to { background-position: 30px 0; } }
        .stock-text { font-size: 0.75rem; font-weight: 600; margin-top: 6px; display: block; text-align: right; }

        /* REAL TIME SALES & TIMELINE */
        .timeline-container { background: var(--card); padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); max-height: 300px; overflow-y: auto; }
        .timeline { position: relative; padding-left: 20px; }
        .timeline::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: #E2E8F0; }
        .timeline-item { position: relative; padding-bottom: 20px; animation: slideIn 0.3s ease; }
        @keyframes slideIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
        .timeline-item::before { content: ''; position: absolute; left: -25px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--blue); border: 3px solid white; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }
        .tl-time { font-size: 0.75rem; color: var(--text-light); font-weight: 600; }
        .tl-content { display: flex; justify-content: space-between; margin-top: 4px; font-size: 0.9rem; }
        .tl-name { font-weight: 500; color: var(--text); }
        .tl-qty { color: var(--green); font-weight: 600; }

        /* CHART MOVEMENT */
        .chart-container { background: var(--card); padding: 32px; border-radius: var(--radius); border: 1px solid var(--border); height: 300px; display: flex; align-items: flex-end; justify-content: space-around; gap: 20px; box-shadow: var(--shadow); }
        .bar-col { display: flex; flex-direction: column; align-items: center; gap: 12px; flex: 1; height: 100%; justify-content: flex-end; }
        .bar-track { width: 100%; max-width: 50px; height: 180px; background: #F1F5F9; border-radius: 8px; position: relative; overflow: hidden; }
        .bar-fill { position: absolute; bottom: 0; left: 0; width: 100%; border-radius: 8px; transition: height 1.2s cubic-bezier(0.4, 0, 0.2, 1); }
        .bar-label { font-size: 0.8rem; font-weight: 600; color: var(--text-light); }
        .bar-val { font-size: 0.85rem; font-weight: 700; margin-bottom: -4px; color: var(--text); }

        /* CATEGORIES & SUPPLIERS */
        .cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 16px; }
        .cat-card { background: var(--card); padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); text-align: center; cursor: pointer; transition: all 0.3s; box-shadow: var(--shadow); }
        .cat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: var(--blue); }
        .cat-icon { font-size: 2.2rem; margin-bottom: 8px; }
        .cat-name { font-weight: 600; font-size: 0.9rem; color: var(--text); }
        .cat-count { font-size: 0.75rem; color: var(--text-light); margin-top: 4px; }

        .sup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
        .sup-card { background: var(--card); padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
        .sup-header { display: flex; align-items: center; gap: 12px; }
        .sup-logo { width: 44px; height: 44px; border-radius: 10px; background: #f0f0f0; display: flex; justify-content: center; align-items: center; font-weight: 700; font-size: 0.85rem; }
        .sup-name { font-weight: 600; font-size: 1rem; color: var(--text); }
        .sup-details { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 0.8rem; background: var(--bg); padding: 12px; border-radius: 10px; }
        .sup-lbl { color: var(--text-light); display: block; margin-bottom: 4px; }
        .sup-val { font-weight: 600; color: var(--text); }

        /* AI PANEL */
        .ai-panel {
            position: fixed; right: 32px; bottom: 32px; width: 340px;
            background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(20px);
            border-radius: 20px; padding: 20px; border: 1px solid rgba(255,255,255,0.6);
            box-shadow: 0 10px 40px rgba(59, 130, 246, 0.15);
            z-index: 95; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }
        .ai-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
        .ai-dot { width: 12px; height: 12px; background: var(--blue); border-radius: 50%; box-shadow: 0 0 10px var(--blue); animation: pulse 2s infinite; }
        @keyframes pulse { 0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5); } 70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); } 100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); } }
        .ai-title { font-weight: 700; font-size: 0.85rem; color: var(--blue); letter-spacing: 1px; text-transform: uppercase; }
        .ai-message { font-size: 0.88rem; line-height: 1.5; color: var(--text); min-height: 44px; transition: opacity 0.5s ease; font-weight: 500; }

        /* FLOATING TOGGLES & MODES */
        .mode-toggles { position: fixed; left: calc(var(--sidebar-width) + 32px); bottom: 32px; display: flex; gap: 12px; z-index: 95; }
        .mode-btn {
            padding: 14px 24px; border-radius: 30px; font-weight: 600; font-size: 0.9rem;
            background: var(--card); color: var(--text); border: 1px solid var(--border);
            box-shadow: 0 10px 25px rgba(15,23,42,0.08); display: flex; align-items: center; gap: 8px;
        }
        .mode-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(15,23,42,0.15); }
        .mode-btn.active { background: var(--text); color: white; border-color: var(--text); }

        /* WAREHOUSE MODE VIEW */
        #view-warehouse .wh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
        #view-warehouse .wh-card { display: flex; justify-content: space-between; align-items: center; padding: 24px; background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
        #view-warehouse .wh-card.glow { animation: redGlow 2s infinite alternate; border-color: var(--red); }
        @keyframes redGlow { from { box-shadow: 0 0 4px rgba(239, 68, 68, 0.1); } to { box-shadow: 0 0 20px rgba(239, 68, 68, 0.35); } }
        .wh-loc { font-family: monospace; background: var(--bg); padding: 4px 10px; border-radius: 6px; color: var(--text-light); font-weight: 600; font-size: 0.8rem; }

        /* POS MODE VIEW */
        #view-pos { display: grid; grid-template-columns: 1.8fr 1.2fr; gap: 32px; height: calc(100vh - 160px); min-height: 500px; }
        .pos-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 16px; align-content: start; overflow-y: auto; padding-right: 4px; }
        .pos-btn { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; box-shadow: var(--shadow); }
        .pos-btn:hover { border-color: var(--blue); transform: translateY(-2px); box-shadow: var(--shadow-hover); }
        .pos-btn:active { transform: scale(0.96); }
        .pos-btn-img { font-size: 2.2rem; }
        .pos-cart { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow); height: 100%;}
        .cart-items { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
        .c-item { display: flex; justify-content: space-between; font-size: 0.9rem; font-weight: 500; border-bottom: 1px dashed var(--border); padding-bottom: 10px;}
        .cart-total { background: var(--bg); padding: 24px; border-top: 1px solid var(--border); }
        .t-row { display: flex; justify-content: space-between; margin-bottom: 12px; font-weight: 600; color: var(--text-light); }
        .t-big { font-size: 1.6rem; color: var(--text); font-weight: 800; }
        .pay-btn { width: 100%; padding: 16px; background: linear-gradient(135deg, var(--blue), #1d4ed8); color: white; border-radius: 12px; font-size: 1.1rem; font-weight: 700; margin-top: 12px; box-shadow: 0 10px 20px rgba(59, 130, 246, 0.25); }
        .pay-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(59, 130, 246, 0.35); }

        /* ==================== PRODUCT MODAL FORM ==================== */
        .modal-overlay {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.4); backdrop-filter: blur(4px); z-index: 200; display: none; justify-content: center; align-items: center; opacity: 0; transition: opacity 0.3s ease;
        }
        .modal-overlay.active { display: flex; opacity: 1; }
        .modal-card {
            background: var(--card); width: 100%; max-width: 460px; padding: 32px; border-radius: 20px; box-shadow: 0 20px 50px rgba(0,0,0,0.15); animation: modalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1); margin: 16px;
        }
        @keyframes modalIn { from { transform: translateY(30px) scale(0.96); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
        .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
        .modal-header h3 { font-size: 1.3rem; font-weight: 700; }
        .close-modal { font-size: 1.5rem; background: none; color: var(--text-light); }
        .form-group { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
        .form-group label { font-size: 0.85rem; font-weight: 600; color: var(--text-light); }
        .form-group input, .form-group select { padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 0.95rem; outline: none; background: #F8FAFC; }
        .form-group input:focus, .form-group select:focus { border-color: var(--blue); background: white; }
        .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
        .submit-btn { width: 100%; padding: 14px; background: var(--text); color: white; border-radius: 10px; font-weight: 600; margin-top: 12px; }
        .submit-btn:hover { background: #0F172A; }

        /* ==================== MEDIA QUERIES (RESPONSIVE) ==================== */
        @media (max-width: 1024px) {
            .stats-grid { grid-template-columns: repeat(2, 1fr); }
            .dashboard-double-grid { grid-template-columns: 1fr; }
            #view-pos { grid-template-columns: 1fr; height: auto; }
            .pos-products { max-height: 400px; }
            .mode-toggles { left: 50%; transform: translateX(-50%); bottom: 20px; width: calc(100% - 32px); justify-content: center; }
            .ai-panel { display: none; } /* Ocultar panel flotante grande en tablets/móviles para evitar obstrucción */
        }

        @media (max-width: 768px) {
            body { position: relative; }
            .sidebar {
                position: fixed; left: -100%; top: 0; bottom: 0; width: 260px;
                align-items: flex-start; padding: 32px 24px; box-shadow: 10px 0 30px rgba(0,0,0,0.05);
            }
            .sidebar.open { left: 0; }
            .sidebar-icon { flex-direction: row; justify-content: flex-start; gap: 16px; width: 100%; font-size: 1.1rem; }
            .sidebar-icon::after { content: attr(title); font-size: 0.95rem; font-weight: 500; }
            
            .menu-toggle { display: block; margin-right: 12px; }
            .header { padding: 0 16px; height: 70px; }
            .content { padding: 20px 16px 100px 16px; gap: 24px; }
            
            .search-container { order: 3; max-width: 100%; }
            .header { flex-wrap: wrap; height: auto; padding: 16px; }
            .user-info { width: auto; }
            .time-date { display: none; }
            
            .stats-grid { grid-template-columns: 1fr; gap: 16px; }
            .section-header-actions { flex-direction: column; align-items: flex-start; }
            .filter-tabs { width: 100%; }
            .action-btn { width: 100%; justify-content: center; }
        }