:root { 
    --bg: #0f172a;
    --card: #1e293b;
    --accent: #6366f1;
    --text: #f8fafc;
    --muted: #64748b;
    --border: #334155;
    --shadow: 0 10px 25px -5px rgba(0,0,0,0.3); 
    --success: #10b981; 
}

/* Forzar modo oscuro siempre */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
    font-family: 'SF Pro Display', sans-serif; 
    -webkit-tap-highlight-color: transparent; 
    color-scheme: dark; 
}

body { 
    background: var(--bg); 
    color: var(--text); 
    overflow: hidden; 
    height: 100vh; 
    width: 100vw; 
}

/* --- PANTALLA DE LOGIN --- */
#login-screen { 
    position: fixed; 
    inset: 0; 
    background: var(--bg); 
    z-index: 2000; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
}

.login-container { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 20px; 
}

.floating-dot { 
    width: 18px; 
    height: 18px; 
    background: var(--accent); 
    border-radius: 50%; 
    display: block; 
    margin-bottom: 50px; 
    animation: floatPulse 2.8s infinite ease-in-out; 
    box-shadow: 0 0 25px var(--accent); 
}

@keyframes floatPulse { 
    0%, 100% { transform: translateY(0); opacity: 0.7; } 
    50% { transform: translateY(-25px); opacity: 1; } 
}

.login-input { 
    border: none; 
    background: transparent; 
    text-align: center; 
    outline: none; 
    color: var(--text); 
    border-bottom: 2px solid var(--accent); 
    font-size: 1.6rem; 
    width: 280px; 
    letter-spacing: 3px; 
    padding-bottom: 5px; 
    margin-bottom: 5px; 
}

.login-footer { 
    position: absolute;
    bottom: 50px; 
    font-size: 0.7rem; 
    color: var(--muted); 
    letter-spacing: 6px; 
    text-transform: uppercase; 
    width: 100%;
    text-align: center;
}

/* --- REPORTES Y SCROLL --- */
.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 1.5rem; 
    margin-bottom: 2rem; 
    align-items: flex-start; 
}

#stat-qty {
    max-height: 180px; 
    overflow-y: auto;
    margin-top: 10px;
    padding-right: 5px;
}

#stat-qty::-webkit-scrollbar { width: 4px; }
#stat-qty::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 10px; }

/* PAGINACIÓN */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
}

.btn-page {
    background: var(--card);
    color: white;
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-page.active { background: var(--accent); border-color: var(--accent); font-weight: bold; }

/* Layout Principal */
#app-layout { 
    display: none; 
    grid-template-columns: 120px 1fr; 
    height: 100vh; 
    opacity: 0; 
    transition: 1s; 
}

nav { 
    background: var(--card); 
    border-right: 1px solid var(--border); 
    display: flex; 
    flex-direction: column; 
    padding: 2rem 0; 
}

.nav-item { 
    cursor: pointer; 
    text-align: center; 
    color: var(--muted); 
    background: none; 
    border: none; 
    padding: 15px 5px; 
    width: 100%; 
}

.nav-item.active { color: var(--accent); font-weight: bold; }
.nav-item i { font-style: normal; font-size: 1.5rem; display: block; margin-bottom: 5px; }
.nav-item span { font-size: 0.6rem; font-weight: 800; text-transform: uppercase; display: block; }

main { padding: 2rem; overflow-y: auto; height: 100vh; width: 100%; }

.header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    margin-bottom: 2rem; 
    padding-bottom: 1rem; 
    border-bottom: 1px solid var(--border); 
}

#view-title { font-size: 1.2rem; font-weight: 700; margin: 0; letter-spacing: 1px; }

.tasa-badge { 
    background: var(--card); 
    padding: 5px 10px; 
    border-radius: 7px; 
    border: 1px solid var(--border); 
    display: flex; 
    align-items: center; 
    gap: 6px; 
}

.tasa-badge input { 
    border: none; 
    background: transparent; 
    width: 60px; 
    text-align: center; 
    color: var(--accent); 
    font-weight: 900; 
    outline: none; 
}

.stat-card { 
    background: var(--card); 
    padding: 1.5rem; 
    border-radius: 20px; 
    border: 1px solid var(--border); 
    box-shadow: var(--shadow); 
    margin-bottom: 1.5rem; 
}

/* AJUSTES DE INPUTS PARA INVENTARIO Y SISTEMA */
.stat-card div {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

#p-name { flex: 2; min-width: 180px; }
#p-price, #p-stock { flex: 1; min-width: 80px; }

#db .btn-main { flex: 1; min-width: 140px; white-space: nowrap; }

.search-box { 
    padding: 1.2rem; 
    border-radius: 15px; 
    border: 2px solid var(--border); 
    background: var(--card); 
    color: var(--text); 
    width: 100%; 
    margin-bottom: 2rem; 
    outline: none; 
}

.btn-main { 
    background: var(--accent); 
    color: white; 
    border: none; 
    padding: 12px 24px; 
    border-radius: 12px; 
    font-weight: 800; 
    cursor: pointer; 
}

/* Tablas */
.report-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.report-table td { 
    padding: 1rem; 
    background: var(--card); 
    border-top: 1px solid var(--border); 
    border-bottom: 1px solid var(--border); 
    text-align: center; 
}

/* POS y Carrito */
.pos-grid { display: grid; grid-template-columns: 1fr 320px; gap: 2rem; }
.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 1.2rem; }
.cart-container { 
    background: var(--card); 
    padding: 1.5rem; 
    border-radius: 20px; 
    border: 1px solid var(--border); 
    height: fit-content; 
    position: sticky; 
    top: 0; 
}

.txt-accent { color: var(--accent); font-weight: 700; }
.section { display: none; }
.section.active { display: block; }

#toast { 
    position: fixed; 
    top: -100px; 
    left: 50%; 
    transform: translateX(-50%); 
    background: var(--success); 
    color: white; 
    padding: 1rem 2rem; 
    border-radius: 50px; 
    z-index: 3000; 
    transition: 0.5s; 
}
#toast.show { top: 20px; }

/* --- MÓVIL (CORREGIDO) --- */
@media (max-width: 768px) {
    #app-layout { grid-template-columns: 1fr; }
    nav { 
        position: fixed; bottom: 0; left: 0; width: 100%; height: 85px; 
        flex-direction: row; border-right: none; border-top: 1px solid var(--border); 
        background: var(--card); padding: 5px 0; z-index: 1000;
    }
    .nav-item { flex: 1; padding: 5px !important; }
    .nav-item i { font-size: 1.2rem; margin-bottom: 2px; }
    .nav-item span { font-size: 0.55rem; }
    
    main { padding: 1rem; padding-bottom: 110px; }
    .stats-grid { grid-template-columns: 1fr; }
    .pos-grid { grid-template-columns: 1fr; }
}