* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #f5f5f5; color: #333; }
.container { max-width: 1400px; margin: 0 auto; padding: 20px; }
header { background: #2c3e50; color: white; padding: 20px; border-radius: 8px; margin-bottom: 20px; }
header h1 { margin-bottom: 15px; }
nav { display: flex; gap: 10px; flex-wrap: wrap; }

/* 🔧 FIX 3: NAVBAR - Quitar subrayado de los enlaces */
.nav-btn {
    background: #34495e;
    color: white !important;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    text-decoration: none !important;
    display: inline-block;
}
.nav-btn:visited { color: white !important; }
.nav-btn:hover { background: #3d566e; }
.nav-btn.active { background: #3498db; }

.section { display: none; background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.section.active { display: block; }

/* VENTAS */
.ventas-container { display: grid; grid-template-columns: 1fr 450px; gap: 20px; }
.productos-venta { background: #f9f9f9; padding: 15px; border-radius: 8px; }
#buscar-producto { width: 100%; padding: 10px; margin: 10px 0; border: 1px solid #ddd; border-radius: 5px; }
.productos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 500px; overflow-y: auto; }
.producto-card { background: white; padding: 15px; border-radius: 5px; text-align: center; cursor: pointer; transition: all 0.3s; border: 2px solid #ddd; }
.producto-card:hover { border-color: #3498db; transform: translateY(-2px); }
.producto-card h4 { font-size: 14px; margin-bottom: 5px; }
.producto-card p { color: #3498db; font-weight: bold; }

.carrito { background: #f9f9f9; padding: 15px; border-radius: 8px; display: flex; flex-direction: column; }
#carrito-items { flex: 1; overflow-y: auto; max-height: 200px; margin: 10px 0; }
.carrito-item { background: white; padding: 10px; margin-bottom: 5px; border-radius: 5px; display: flex; justify-content: space-between; align-items: center; }
.carrito-item-info { flex: 1; }
.carrito-item-cantidad { display: flex; align-items: center; gap: 5px; }
.carrito-item-cantidad button { width: 25px; height: 25px; border: none; background: #3498db; color: white; border-radius: 3px; cursor: pointer; }
.carrito-item-cantidad input { width: 50px; text-align: center; border: 1px solid #ddd; border-radius: 3px; }
.btn-eliminar-item { background: #e74c3c; color: white; border: none; padding: 5px 10px; border-radius: 3px; cursor: pointer; }

.carrito-total { border-top: 2px solid #ddd; padding-top: 15px; }
.descuento-container { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.descuento-container input { width: 80px; padding: 5px; border: 1px solid #ddd; border-radius: 3px; }

.desglose-total { margin-bottom: 10px; padding: 10px; background: #fef9e7; border-radius: 5px; border: 1px solid #f9e79f; }
.desglose-linea { display: flex; justify-content: space-between; padding: 3px 0; font-size: 14px; color: #555; }
.desglose-linea.recargo { color: #e74c3c; font-weight: bold; }
.desglose-linea.total-final { font-size: 16px; color: #2c3e50; padding: 8px 0 0 0; margin-top: 8px; border-top: 2px dashed #2c3e50; }

.pagos-container { background: #eaf2f8; padding: 15px; border-radius: 8px; margin-bottom: 15px; border: 2px solid #aed6f1; }
.pagos-container h3 { margin-bottom: 5px; color: #2c3e50; }
.pagos-info { font-size: 12px; color: #555; margin-bottom: 10px; padding: 8px; background: white; border-radius: 5px; border-left: 3px solid #3498db; }
#lista-pagos { margin-bottom: 15px; max-height: 150px; overflow-y: auto; }
.pago-item { background: white; padding: 10px; margin-bottom: 8px; border-radius: 5px; display: flex; justify-content: space-between; align-items: center; border-left: 4px solid #3498db; }
.pago-item-info { flex: 1; }
.pago-item-monto { font-size: 16px; font-weight: bold; color: #27ae60; }
.pago-item-recargo { font-size: 11px; color: #e74c3c; margin-left: 8px; display: block; }
.btn-eliminar-pago { background: #e74c3c; color: white; border: none; padding: 5px 10px; border-radius: 3px; cursor: pointer; margin-left: 10px; }

/* 🔧 FIX 2: AGREGAR PAGO - Que no sobresalga */
.agregar-pago {
    display: grid;
    grid-template-columns: 1fr 90px auto;
    gap: 8px;
    margin-bottom: 15px;
    align-items: center;
}
.agregar-pago select, .agregar-pago input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    min-width: 0;
    width: 100%;
}
.agregar-pago button {
    padding: 8px 12px;
    white-space: nowrap;
    font-size: 14px;
    margin: 0;
    width: auto;
}

.pago-resumen { background: white; padding: 10px; border-radius: 5px; border: 1px solid #ddd; }
.falta-pagar { color: #e74c3c; font-weight: bold; }
.vuelto { color: #27ae60; font-weight: bold; }

/* TABLAS */
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #ddd; }
th { background: #2c3e50; color: white; }
tr:hover { background: #f5f5f5; }
.btn-editar, .btn-eliminar { padding: 5px 10px; border: none; border-radius: 3px; cursor: pointer; margin-right: 5px; }
.btn-editar { background: #f39c12; color: white; }
.btn-eliminar { background: #e74c3c; color: white; }

/* 🔧 FIX 1: MODAL COMPACTO EN CELULARES */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); overflow-y: auto; }
.modal-content { background: white; margin: 30px auto; padding: 25px; border-radius: 8px; width: 90%; max-width: 550px; position: relative; }
.modal-compacto { max-height: 90vh; overflow-y: auto; }
.close { position: absolute; right: 20px; top: 15px; font-size: 28px; font-weight: bold; cursor: pointer; color: #aaa; z-index: 10; }
.close:hover { color: #000; }
.modal-compacto h3 { margin-bottom: 15px; padding-right: 30px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 15px; }
.form-grid .form-group { margin-bottom: 0; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: bold; font-size: 13px; }
.form-group input { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 5px; font-size: 14px; }
.form-group small { display: block; margin-top: 3px; color: #888; font-size: 11px; }
.btn-guardar-sticky { margin-top: 15px; position: sticky; bottom: 0; box-shadow: 0 -2px 5px rgba(0,0,0,0.1); }

/* INVENTARIO */
.inventario-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 20px; }
.stat-card { background: #3498db; color: white; padding: 20px; border-radius: 8px; text-align: center; }
.stat-card.warning { background: #e74c3c; }
.stat-card h3 { font-size: 14px; margin-bottom: 10px; }
.stat-card p { font-size: 32px; font-weight: bold; }
.stock-bajo { color: #e74c3c; font-weight: bold; }
.stock-ok { color: #27ae60; font-weight: bold; }

/* GANANCIAS */
.filtro-fecha { display: flex; gap: 10px; margin-bottom: 20px; }
.filtro-btn { padding: 10px 20px; border: 1px solid #ddd; background: white; border-radius: 5px; cursor: pointer; }
.filtro-btn.active { background: #3498db; color: white; border-color: #3498db; }
.kpi-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.kpi-card { padding: 20px; border-radius: 8px; text-align: center; color: white; }
.kpi-card.ventas { background: #3498db; }
.kpi-card.costos { background: #e74c3c; }
.kpi-card.ganancia { background: #27ae60; }
.kpi-card.margen { background: #8e44ad; }
.kpi-card h3 { font-size: 14px; margin-bottom: 10px; opacity: 0.9; }
.kpi-card p { font-size: 28px; font-weight: bold; }

/* CIERRE DE CAJA */
.cierre-container { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 20px; }
.cierre-resumen, .cierre-calculos { background: #f9f9f9; padding: 20px; border-radius: 8px; border: 1px solid #ddd; }
.cierre-resumen h3 { margin-bottom: 15px; color: #2c3e50; border-bottom: 2px solid #3498db; padding-bottom: 5px; }
.diferencia-positiva { color: #27ae60 !important; }
.diferencia-negativa { color: #e74c3c !important; }
.diferencia-cero { color: #2c3e50 !important; }

/* 🔧 ARQUEO POR MÉTODO DE PAGO */
.arqueo-metodo {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #ddd;
}
.arqueo-metodo h4 {
    margin-bottom: 10px;
}

/* HISTORIAL */
.venta-card, .cierre-card { background: #f9f9f9; padding: 15px; margin-bottom: 10px; border-radius: 5px; border-left: 4px solid #3498db; }
.cierre-card { border-left-color: #8e44ad; }
.venta-header { display: flex; justify-content: space-between; margin-bottom: 10px; font-weight: bold; }
.venta-metodo { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: bold; color: white; margin-left: 5px; }
.metodo-efectivo { background: #27ae60; }
.metodo-transferencia { background: #2980b9; }
.metodo-qr { background: #8e44ad; }
.metodo-debito { background: #e67e22; }
.metodo-credito { background: #e74c3c; }
.venta-items, .cierre-items { margin: 10px 0; padding-left: 20px; }
.venta-pagos { margin-top: 10px; padding: 10px; background: white; border-radius: 5px; border: 1px solid #ddd; }
.venta-pagos h4 { margin-bottom: 8px; color: #2c3e50; }

/* CONFIG */
.config-section { margin-bottom: 30px; padding-bottom: 30px; border-bottom: 2px solid #eee; }
.config-section:last-child { border-bottom: none; }
.config-section h3 { margin-bottom: 10px; color: #2c3e50; }
.config-descripcion { color: #666; margin-bottom: 20px; padding: 10px; background: #eaf2f8; border-radius: 5px; border-left: 4px solid #3498db; }
.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 20px; }
.config-card { background: #f9f9f9; padding: 20px; border-radius: 8px; border: 2px solid #ddd; text-align: center; }
.config-card h3 { margin-bottom: 15px; color: #2c3e50; }
.config-card input { width: 100%; padding: 10px; font-size: 20px; text-align: center; border: 2px solid #3498db; border-radius: 5px; }

/* BOTONES */
.btn-primary { background: #3498db; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; font-size: 16px; transition: background 0.3s; width: 100%; margin-bottom: 5px; }
.btn-primary:hover { background: #2980b9; }
.btn-secondary { background: #95a5a6; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; font-size: 16px; width: 100%; }
.btn-secondary:hover { background: #7f8c8d; }

/* BOTÓN PELIGRO (ROJO) */
.btn-danger { background: #e74c3c; color: white; border: none; padding: 10px 20px; border-radius: 5px; cursor: pointer; font-size: 14px; transition: background 0.3s; }
.btn-danger:hover { background: #c0392b; }

/* SYNC STATUS */
.sync-status-success { background: #d4edda !important; color: #155724; border: 1px solid #c3e6cb; }
.sync-status-error { background: #f8d7da !important; color: #721c24; border: 1px solid #f5c6cb; }
.sync-status-info { background: #d1ecf1 !important; color: #0c5460; border: 1px solid #bee5eb; }

/* 🔧 RESPONSIVE MEJORADO */
@media (max-width: 768px) {
    .ventas-container, .cierre-container { grid-template-columns: 1fr; }
    .productos-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .config-grid { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    
    /* 🔧 MODAL AJUSTADO PARA CELULARES */
    .modal-content {
        margin: 10px;
        width: calc(100% - 20px);
        max-width: none;
        padding: 20px 15px;
    }
    .modal-compacto {
        max-height: calc(100vh - 20px);
    }
    .modal-compacto h3 {
        font-size: 18px;
    }
    .form-group input {
        font-size: 16px; /* Evita zoom en iOS */
    }
    
    /* 🔧 AGREGAR PAGO EN CELULARES - Se apila */
    .agregar-pago {
        grid-template-columns: 1fr;
    }
    .agregar-pago button {
        width: 100%;
    }
    
    /* Navbar más compacto en móvil */
    .nav-btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    header {
        padding: 15px;
    }
    header h1 {
        font-size: 22px;
    }
    
    /* 🔧 Arqueo por método en móvil */
    .arqueo-metodo {
        margin-bottom: 15px;
    }
}

/* 🔧 CELULARES MUY CHICOS */
@media (max-width: 400px) {
    .config-grid { grid-template-columns: 1fr; }
    .kpi-card p { font-size: 22px; }
    .nav-btn {
        padding: 7px 10px;
        font-size: 12px;
    }
}