﻿/* =========================================
   1. ESTRUCTURA Y MARCA (BREXO)
   ========================================= */
.bg-login-custom {
    background-color: #052c3c;
    background-image: radial-gradient(circle at center, #e30613 0%, #1e1e1c 100%);
}

.bg-header-custom {
    background-color: #052c3c;
    border-bottom: 1px solid #0a3a4e;
}

.custom-scroll::-webkit-scrollbar { width: 6px; }
.custom-scroll::-webkit-scrollbar-thumb { background: #052c3c; border-radius: 10px; }

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* =========================================
   2. ANIMACIONES Y ESTADOS
   ========================================= */
.fade-in { animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.scale-in, .zoom-in { animation: scaleIn 0.3s ease-out; }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

.stock-rojo { background: #fef2f2; border: 2px solid #ef4444; color: #991b1b; animation: pulse 2s infinite; }
.stock-naranja { background: #fff7ed; border: 2px solid #fb923c; color: #9a3412; }
.solo-lectura { opacity: 0.6; pointer-events: none; filter: grayscale(1); }

/* =========================================
   3. ESTILOS DE FORMULARIOS (MODERNO)
   ========================================= */
select, input {
    height: 54px !important;
    background-color: #f8fafc !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 18px !important;
    padding: 0 16px !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    transition: all 0.3s ease !important;
    outline: none !important;
    appearance: none;
}

select:focus, input:focus {
    border-color: #009fe3 !important;
    background-color: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(0, 159, 227, 0.1) !important;
}

select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 40px !important;
}

/* "appearance:none" (arriba) deja los input[type=date] como una caja en
   blanco sin ícono ni forma reconocible, sobre todo en Chrome Android.
   Se les devuelve su apariencia nativa (ícono de calendario + "dd/mm/aaaa"
   con el formato del dispositivo) para que se identifiquen como selector
   de fecha, conservando el resto del estilo del formulario. */
input[type="date"] {
    -webkit-appearance: auto !important;
    appearance: auto !important;
    color: #0f172a !important;
}
input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 1;
    cursor: pointer;
    padding: 4px;
}
input[type="date"]::-webkit-datetime-edit { color: #0f172a; }

/* =========================================
   4. SEGURIDAD Y PERFIL
   ========================================= */
.role-vendedor #tab-produccion button,
.role-vendedor .btn-finalizar,
.role-vendedor .btn-insumos {
    display: none !important;
}

.btn-insumos {
    display: flex !important;
}

*:focus { outline: none !important; }

#perfil_new_pin::placeholder,
#perfil_confirm_pin::placeholder {
    letter-spacing: normal;
    font-size: 12px;
    font-weight: 700;
}

#modalMateriales .max-h-\[60vh\],
#modalMateriales .overflow-y-auto {
    overflow-y: visible !important;
    overflow-x: visible !important;
}

.fila-insumo {
    position: relative !important;
}

#whatsappMaster {
    padding-left: 40px !important;
}

@keyframes parpadeo-alerta {
    0%   { box-shadow: 0 0 0px #ef4444; border-color: transparent; }
    50%  { box-shadow: 0 0 20px #ef4444; border-color: #ef4444; }
    100% { box-shadow: 0 0 0px #ef4444; border-color: transparent; }
}

.orden-editada-reciente {
    animation: parpadeo-alerta 1.5s infinite;
    border-width: 2px !important;
    position: relative;
}

.orden-editada-reciente::after {
    content: "EDITADA";
    position: absolute;
    top: -10px;
    right: 10px;
    background: #ef4444;
    color: white;
    font-size: 8px;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 10px;
    z-index: 20;
}

/* =========================================
   5. MÓDULO VENTAS — TARJETAS DE ÍTEM
   Clase real: "p-4 bg-white border border-slate-100
   rounded-2xl shadow-sm mb-3 relative group"
   generada en addVentaItem()
   ========================================= */

/* Cada fila/ítem del formulario de venta */
#listaVentas > div {
    background: #ffffff;
    border: 2px solid #f1f5f9 !important;
    border-radius: 20px !important;
    padding: 16px !important;
    box-shadow: 0 4px 16px rgba(5, 44, 60, 0.06) !important;
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
    animation: fadeIn 0.3s ease-out;
    position: relative;
}

#listaVentas > div:hover {
    border-color: #e2e8f0 !important;
    box-shadow: 0 8px 28px rgba(5, 44, 60, 0.10) !important;
}

/* Botón × cerrar del ítem */
#listaVentas > div .btn-cerrar {
    position: absolute !important;
    top: -10px !important;
    right: -10px !important;
    width: 26px !important;
    height: 26px !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    border: 2px solid #fee2e2 !important;
    color: #fca5a5 !important;
    font-size: 14px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.15) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    z-index: 10;
}

#listaVentas > div .btn-cerrar:hover {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    color: #ffffff !important;
    transform: scale(1.15) rotate(90deg) !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.35) !important;
}

/* Input nombre del producto */
#listaVentas .input-nombre {
    height: 42px !important;
    border-radius: 12px !important;
    border: 2px solid #f1f5f9 !important;
    background: #f8fafc !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    color: #1e293b !important;
    transition: all 0.2s ease !important;
    padding: 0 12px !important;
}

#listaVentas .input-nombre:focus {
    border-color: #009fe3 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(0, 159, 227, 0.1) !important;
}

#listaVentas .input-nombre::placeholder {
    color: #cbd5e1 !important;
    font-weight: 600 !important;
    text-transform: none;
}

/* Select tipo (Und / M2) */
#listaVentas .select-tipo {
    height: 42px !important;
    border-radius: 12px !important;
    border: 2px solid #f1f5f9 !important;
    background: #f8fafc !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    color: #475569 !important;
    padding: 0 32px 0 10px !important;
    min-width: 64px;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

#listaVentas .select-tipo:focus {
    border-color: #009fe3 !important;
    background: #ffffff !important;
}

/* Botón buscar (+) */
#listaVentas .btn-buscar {
    width: 42px !important;
    height: 42px !important;
    border-radius: 12px !important;
    background: linear-gradient(135deg, #052c3c 0%, #0a4d65 100%) !important;
    color: #ffffff !important;
    border: none !important;
    font-size: 20px !important;
    font-weight: 900 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 4px 12px rgba(5, 44, 60, 0.25) !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0;
}

#listaVentas .btn-buscar:hover {
    background: linear-gradient(135deg, #009fe3 0%, #0077b6 100%) !important;
    box-shadow: 0 6px 18px rgba(0, 159, 227, 0.35) !important;
    transform: scale(1.06) !important;
}

#listaVentas .btn-buscar:active {
    transform: scale(0.95) !important;
}

/* Referencia precio m2 */
#listaVentas #ref-precio {
    font-size: 9px !important;
    font-weight: 800 !important;
    color: #10b981 !important;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 3px 10px !important;
    display: inline-block;
    margin-top: 4px !important;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* Input detalle */
#listaVentas .input-detalle {
    height: 38px !important;
    border-radius: 12px !important;
    border: 2px solid #f1f5f9 !important;
    background: #f8fafc !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    color: #475569 !important;
    padding: 0 12px !important;
    transition: all 0.2s ease !important;
}

#listaVentas .input-detalle:focus {
    border-color: #a5b4fc !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(165, 180, 252, 0.15) !important;
}

#listaVentas .input-detalle::placeholder {
    color: #cbd5e1 !important;
    font-style: italic;
}

/* Inputs medidas (ancho / alto) */
#listaVentas .input-ancho,
#listaVentas .input-alto {
    height: 46px !important;
    border-radius: 14px !important;
    border: 2px solid #d1fae5 !important;
    background: #f0fdf4 !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    color: #065f46 !important;
    text-align: center !important;
    transition: all 0.2s ease !important;
}

#listaVentas .input-ancho:focus,
#listaVentas .input-alto:focus {
    border-color: #10b981 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12) !important;
}

/* Separador inferior del ítem */
#listaVentas > div .border-t {
    border-color: #f8fafc !important;
    margin-top: 12px !important;
    padding-top: 12px !important;
}

/* Label "Total ($)" */
#listaVentas > div .border-t span {
    font-size: 9px !important;
    font-weight: 900 !important;
    color: #94a3b8 !important;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Input precio final del ítem */
#listaVentas .input-precio {
    height: 40px !important;
    width: 100px !important;
    border-radius: 14px !important;
    border: 2px solid #d1fae5 !important;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%) !important;
    font-size: 15px !important;
    font-weight: 900 !important;
    color: #059669 !important;
    text-align: right !important;
    padding: 0 12px !important;
    box-shadow: inset 0 2px 4px rgba(16, 185, 129, 0.08) !important;
    transition: all 0.2s ease !important;
}

#listaVentas .input-precio:focus {
    border-color: #10b981 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15) !important;
    color: #047857 !important;
}

/* =========================================
   6. MÓDULO VENTAS — TOTAL GENERAL
   ID real: #displayTotalPedido
   ========================================= */

#displayTotalPedido {
    font-size: 28px !important;
    font-weight: 900 !important;
    color: #052c3c !important;
    letter-spacing: -0.5px;
    transition: all 0.3s ease;
}

/* Contenedor padre del total — apuntamos al wrapper cercano */
#displayTotalPedido {
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    border-radius: 16px;
    padding: 8px 20px;
    border: 2px solid #bbf7d0;
    display: inline-block;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.12);
}

/* =========================================
   7. MÓDULO VENTAS — BUSCADOR EN SWAL
   (Estilos inyectados en el popup de SweetAlert)
   ========================================= */

/* El SweetAlert de búsqueda hereda algunos globales,
   reforzamos los que redefine el JS inline */
#buscador-input {
    height: 46px !important;
    border-radius: 14px !important;
    border: 2px solid #e2e8f0 !important;
    background: #f8fafc !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    padding: 0 16px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    transition: all 0.2s ease !important;
    margin-bottom: 12px !important;
}

#buscador-input:focus {
    border-color: #009fe3 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(0, 159, 227, 0.1) !important;
}

#resultados-lista {
    border-radius: 16px !important;
    border: 1.5px solid #f1f5f9 !important;
    background: #f8fafc !important;
    overflow: hidden !important;
    max-height: 240px !important;
    overflow-y: auto !important;
}

/* Fila de resultado individual (generada por JS) */
#resultados-lista > div {
    padding: 12px 14px !important;
    border-bottom: 1px solid #f1f5f9 !important;
    cursor: pointer !important;
    background: #ffffff !important;
    transition: all 0.15s ease !important;
    text-align: left !important;
}

#resultados-lista > div:last-child {
    border-bottom: none !important;
}

#resultados-lista > div:hover {
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5) !important;
    padding-left: 20px !important;
}

#resultados-lista > div span {
    font-size: 12px !important;
    font-weight: 700 !important;
    color: #1e293b !important;
}

/* =========================================
   8. MÓDULO VENTAS — AVISOS / CHIPS DE ÓRDENES
   Clase real generada en escucharOrdenesListas()
   ========================================= */

/* Chip individual de orden lista */
#contenedorAvisosVendedor > div {
    background: #ffffff !important;
    border: 1.5px solid #f1f5f9 !important;
    border-radius: 30px !important;
    padding: 5px 14px 5px 5px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    box-shadow: 0 2px 10px rgba(5, 44, 60, 0.08) !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    animation: fadeIn 0.3s ease-out;
}

#contenedorAvisosVendedor > div:hover {
    border-color: #009fe3 !important;
    box-shadow: 0 4px 16px rgba(0, 159, 227, 0.2) !important;
    transform: translateY(-1px) !important;
}

#contenedorAvisosVendedor > div:active {
    transform: scale(0.96) !important;
}

/* Badge de número de orden dentro del chip */
#contenedorAvisosVendedor > div > div:first-child {
    background: linear-gradient(135deg, #052c3c 0%, #0a4d65 100%) !important;
    color: #ffffff !important;
    font-size: 9px !important;
    font-weight: 900 !important;
    height: 26px !important;
    padding: 0 10px !important;
    border-radius: 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 8px rgba(5, 44, 60, 0.3) !important;
    letter-spacing: 0.5px;
}

/* Nombre del cliente en el chip */
#contenedorAvisosVendedor .text-\[10px\] {
    font-size: 10px !important;
    font-weight: 800 !important;
    color: #1e293b !important;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* =========================================
   9. MÓDULO VENTAS — MODAL DETALLE ORDEN
   ID real: #modalDetalleOrden / #contenidoModalOrden
   ========================================= */

#modalDetalleOrden {
    backdrop-filter: blur(8px) !important;
    background: rgba(5, 44, 60, 0.5) !important;
}

/* Contenedor interno del modal */
#contenidoModalOrden {
    border-radius: 28px !important;
    box-shadow: 0 24px 64px rgba(5, 44, 60, 0.25) !important;
    animation: scaleIn 0.3s ease-out;
}

/* Tarjeta de cada producto dentro del modal */
#contenidoModalOrden .bg-white.border.border-slate-100.rounded-\[24px\] {
    border: 1.5px solid #f1f5f9 !important;
    box-shadow: 0 2px 8px rgba(5, 44, 60, 0.05) !important;
    transition: box-shadow 0.2s ease !important;
}

#contenidoModalOrden .bg-white.border.border-slate-100.rounded-\[24px\]:hover {
    box-shadow: 0 6px 20px rgba(5, 44, 60, 0.1) !important;
}

/* Botón cobrar dentro del modal */
#contenidoModalOrden .bg-emerald-500 {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35) !important;
    border-radius: 14px !important;
    font-size: 10px !important;
    font-weight: 900 !important;
    letter-spacing: 0.3px;
    transition: all 0.2s ease !important;
}

#contenidoModalOrden .bg-emerald-500:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45) !important;
}

/* Botón confirmar entrega (oscuro) */
#contenidoModalOrden .bg-\[\#052c3c\].text-white.shadow-xl {
    background: linear-gradient(135deg, #052c3c 0%, #0a4d65 100%) !important;
    box-shadow: 0 8px 28px rgba(5, 44, 60, 0.3) !important;
    transition: all 0.25s ease !important;
    letter-spacing: 0.5px;
}

#contenidoModalOrden .bg-\[\#052c3c\].text-white.shadow-xl:hover {
    background: linear-gradient(135deg, #0a4d65 0%, #0d6080 100%) !important;
    box-shadow: 0 12px 36px rgba(5, 44, 60, 0.4) !important;
    transform: translateY(-2px) !important;
}

/* =========================================
   10. SECCIÓN DE AVISOS VENDEDOR
   ID: #seccionAvisosVendedor
   ========================================= */

#seccionAvisosVendedor {
    border-radius: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border: 1.5px solid #f1f5f9;
    box-shadow: 0 4px 20px rgba(5, 44, 60, 0.06);
    padding: 12px 16px;
    margin-bottom: 16px;
    transition: all 0.3s ease;
}

/* =========================================
   11. INPUTS GLOBALES — CLIENTE Y WHATSAPP
   IDs: #clienteMaster / #whatsappMaster
   ========================================= */

#clienteMaster {
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%) !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 18px !important;
    font-weight: 800 !important;
    font-size: 13px !important;
    color: #1e293b !important;
    letter-spacing: 0.3px;
    transition: all 0.3s ease !important;
}

#clienteMaster:focus {
    border-color: #009fe3 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(0, 159, 227, 0.1) !important;
}

#clienteMaster::placeholder {
    color: #cbd5e1 !important;
    font-weight: 600 !important;
    letter-spacing: normal;
}

#whatsappMaster {
    padding-left: 48px !important;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%) !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 18px !important;
    font-weight: 800 !important;
    font-size: 13px !important;
    color: #1e293b !important;
    transition: all 0.3s ease !important;
}

#whatsappMaster:focus {
    border-color: #25D366 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.1) !important;
}

#whatsappMaster::placeholder {
    color: #cbd5e1 !important;
    font-weight: 600 !important;
}

/* =========================================
   12. SCROLLBARS PERSONALIZADOS
   ========================================= */

#resultados-lista::-webkit-scrollbar { width: 5px; }
#resultados-lista::-webkit-scrollbar-track { background: transparent; }
#resultados-lista::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
#resultados-lista::-webkit-scrollbar-thumb:hover { background: #009fe3; }

.max-h-\[160px\]::-webkit-scrollbar { width: 4px; }
.max-h-\[160px\]::-webkit-scrollbar-track { background: transparent; }
.max-h-\[160px\]::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 10px; }

/* =========================================
   13. RESPONSIVE
   ========================================= */

@media (max-width: 640px) {
    #listaVentas > div {
        padding: 12px !important;
        border-radius: 16px !important;
    }

    #listaVentas .btn-buscar {
        width: 38px !important;
        height: 38px !important;
    }

    #listaVentas .input-nombre {
        font-size: 10px !important;
    }

    #listaVentas .input-precio {
        width: 85px !important;
        font-size: 13px !important;
    }

    #displayTotalPedido {
        font-size: 22px !important;
    }
}

/* =========================================
   14. SISTEMA VISUAL CREATIGRAF ERP
   ========================================= */
:root {
    --erp-navy: #082f49;
    --erp-navy-deep: #062333;
    --erp-cyan: #0891b2;
    --erp-surface: #ffffff;
    --erp-canvas: #f1f5f9;
    --erp-border: #e2e8f0;
    --erp-muted: #64748b;
}

html { background: var(--erp-canvas); }
body {
    background: var(--erp-canvas) !important;
    min-height: 100vh;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}
.bg-login-custom {
    background-color: var(--erp-navy-deep);
    background-image: radial-gradient(circle at 15% 20%, rgba(8,145,178,.28), transparent 32%), radial-gradient(circle at 85% 80%, rgba(14,116,144,.22), transparent 34%);
}
.bg-header-custom {
    background: rgba(6,35,51,.97);
    border-bottom-color: rgba(255,255,255,.08);
}
#mainHeader { backdrop-filter: blur(18px); }
#mainContent { max-width: 1480px; }
.erp-panel {
    background: var(--erp-surface);
    border: 1px solid var(--erp-border);
    border-radius: 24px;
    box-shadow: 0 16px 45px rgba(15,23,42,.055);
}
.erp-panel-header {
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid #eef2f7;
}
.erp-panel-header h3 { color: #0f172a; font-size: 16px; font-weight: 900; }
.erp-eyebrow {
    color: var(--erp-cyan);
    font-size: 9px;
    line-height: 1.2;
    font-weight: 900;
    letter-spacing: .18em;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.erp-kpi {
    position: relative;
    min-height: 112px;
    padding: 18px;
    border-radius: 22px;
    background: white;
    border: 1px solid var(--erp-border);
    box-shadow: 0 10px 30px rgba(15,23,42,.04);
    overflow: hidden;
}
.erp-kpi span { display: block; color: var(--erp-muted); font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.erp-kpi strong { display: block; color: #0f172a; font-size: 23px; line-height: 1; font-weight: 900; margin-top: 12px; }
.erp-kpi > i { position: absolute; right: 16px; bottom: 17px; font-size: 20px; }
.erp-field { display: block; }
.erp-field > span { display: block; color: #475569; font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 7px 4px; }
.erp-field input,
.erp-field select {
    width: 100%;
    height: 48px !important;
    border: 1px solid var(--erp-border) !important;
    border-radius: 13px !important;
    background-color: #f8fafc !important;
    padding: 0 13px !important;
    font-size: 12px !important;
}
.erp-field input:focus,
.erp-field select:focus { border-color: var(--erp-cyan) !important; box-shadow: 0 0 0 3px rgba(8,145,178,.1) !important; }
/* Los textarea quedaban fuera de la regla de arriba (solo cubría input/select),
   así que se veían angostos con el tamaño nativo del navegador en vez de
   ocupar el ancho del modal. */
.erp-field textarea {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    box-sizing: border-box !important;
    border: 1px solid var(--erp-border) !important;
    border-radius: 13px !important;
    background-color: #f8fafc !important;
    font-size: 12px !important;
    font-family: inherit;
    line-height: 1.5;
}
.erp-field textarea:focus { border-color: var(--erp-cyan) !important; box-shadow: 0 0 0 3px rgba(8,145,178,.1) !important; }
.erp-switch { display: flex; align-items: center; gap: 10px; min-height: 48px; color: #475569; font-size: 10px; font-weight: 800; }
.erp-switch input { position: absolute; opacity: 0; pointer-events: none; }
.erp-switch span { position: relative; width: 42px; height: 24px; flex: 0 0 auto; border-radius: 999px; background: #cbd5e1; transition: .2s ease; }
.erp-switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(15,23,42,.2); transition: .2s ease; }
.erp-switch input:checked + span { background: var(--erp-cyan); }
.erp-switch input:checked + span::after { transform: translateX(18px); }

/* Checkbox cuadrado moderno con check propio (evita la regla legada
   "select, input {height:54px !important; appearance:none}" que aplastaba
   los checkboxes nativos en rectángulos en blanco sin marca visible). */
.erp-checkbox {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 22px !important;
    height: 22px !important;
    min-height: 22px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 2px solid #cbd5e1 !important;
    border-radius: 7px !important;
    background: #f8fafc !important;
    display: inline-block;
    position: relative;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background .15s ease, border-color .15s ease !important;
}
.erp-checkbox:hover { border-color: var(--erp-cyan) !important; }
.erp-checkbox:checked { background: var(--erp-cyan) !important; border-color: var(--erp-cyan) !important; }
.erp-checkbox:checked::after {
    content: "";
    position: absolute;
    left: 7px;
    top: 3px;
    width: 5px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.erp-checkbox:focus-visible { box-shadow: 0 0 0 3px rgba(8,145,178,.18) !important; }

/* Fila clicable para listados (usuarios, insumos, etc.) dentro de erp-panel */
.erp-list-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 15px;
    border-radius: 16px;
    border: 1px solid #f1f5f9;
    background: #fff;
    text-align: left;
    transition: all .15s ease;
}
.erp-list-item:hover { border-color: var(--erp-cyan); background: #f0fdff; transform: translateY(-1px); }
.erp-list-item.is-active { border-color: var(--erp-cyan); background: #ecfeff; box-shadow: 0 0 0 3px rgba(8,145,178,.1); }
.erp-details { border: 1px solid var(--erp-border); border-radius: 15px; padding: 0 15px; background: #f8fafc; }
.erp-details summary { padding: 14px 0; color: #334155; font-size: 10px; font-weight: 900; text-transform: uppercase; cursor: pointer; }
.erp-details[open] { padding-bottom: 16px; }
.erp-primary-button,
.erp-secondary-button,
.erp-action-button,
.erp-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 0;
    font-weight: 900;
    transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.erp-primary-button {
    min-height: 50px;
    padding: 0 20px;
    border-radius: 15px;
    background: var(--erp-navy);
    color: white;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .07em;
    box-shadow: 0 10px 24px rgba(8,47,73,.18);
}
.erp-secondary-button { min-height: 42px; padding: 0 15px; border-radius: 12px; background: #ecfeff; color: #0e7490; font-size: 10px; text-transform: uppercase; }
.erp-icon-button { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 13px; background: #f1f5f9; color: #475569; }
.erp-primary-button:hover,
.erp-icon-button:hover,
.erp-secondary-button:hover { transform: translateY(-1px); }
.erp-primary-button:active,
.erp-icon-button:active,
.erp-secondary-button:active { transform: scale(.97); }
.erp-action-button { width: 100%; min-height: 42px; padding: 0 14px; border-radius: 13px; background: #cffafe; color: #0e7490; font-size: 9px; text-transform: uppercase; }
.erp-action-success { background: #d1fae5; color: #047857; }
.erp-action-warning { background: #fef3c7; color: #b45309; }
.erp-upload {
    min-height: 145px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 2px dashed #a5f3fc;
    border-radius: 20px;
    background: #ecfeff;
    color: #0e7490;
    cursor: pointer;
    text-align: center;
    padding: 20px;
}
.erp-upload input { display: none; }
.erp-upload i { font-size: 27px; }
.erp-upload strong { font-size: 11px; }
.erp-upload span { color: #64748b; font-size: 9px; font-weight: 700; }

@media (max-width: 767px) {
    #mainContent { padding: 12px !important; }
    .erp-panel { border-radius: 20px; }
    .erp-panel-header { padding: 17px; min-height: 68px; }
    .erp-kpi { min-height: 98px; padding: 14px; border-radius: 18px; }
    .erp-kpi strong { font-size: 18px; }
    .erp-kpi > i { right: 13px; bottom: 13px; font-size: 17px; }
    .swal2-popup { border-radius: 24px !important; padding: 18px !important; }
}

/* =========================================
   15. MENÚ LATERAL (SIDEBAR) + HAMBURGUESA MÓVIL
   ========================================= */
.app-sidebar {
    width: 272px;
    flex: 0 0 272px;
}
#navTabs .tab-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    border-bottom-width: 0 !important;
    text-align: left;
}
#navTabs .tab-btn.text-white.border-white {
    background: rgba(255, 255, 255, .12);
}
#navTabs .tab-btn:hover {
    background: rgba(255, 255, 255, .06);
}
.app-topbar-mobile { display: none; }

@media (max-width: 900px) {
    .app-sidebar:not(.hidden) {
        display: flex;
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform .25s ease;
    }
    .app-sidebar.sidebar-abierta { transform: translateX(0); }
    .app-topbar-mobile:not(.hidden) { display: flex; }
    .app-sidebar-overlay.sidebar-abierta { display: block; }
}
@media (min-width: 901px) {
    .app-sidebar-overlay { display: none !important; }
}
.app-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, .6);
    z-index: 55;
}

/* =========================================
   16. VENTAS — PUNTO DE VENTA (POS)
   ========================================= */
.pos-shell { display: flex; flex-direction: column; gap: 20px; padding-bottom: 110px; }
.pos-panel { overflow: visible; }

.pos-doc-toggle {
    height: 42px;
    padding: 0 16px;
    border-radius: 12px;
    border: 1px solid var(--erp-border);
    background: #f8fafc;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    color: #0f172a;
    outline: none;
}
.pos-doc-toggle:focus { border-color: var(--erp-cyan); box-shadow: 0 0 0 3px rgba(8,145,178,.1); }

.pos-label { display: block; color: #475569; font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 7px 4px; }
.pos-subheading { color: #0f172a; font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 14px; display: flex; align-items: center; }

.pos-input {
    width: 100%;
    height: 50px;
    border: 1px solid var(--erp-border);
    border-radius: 14px;
    background: #f8fafc;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.pos-input::placeholder { color: #94a3b8; font-weight: 600; }
.pos-input:focus { border-color: var(--erp-cyan); box-shadow: 0 0 0 3px rgba(8,145,178,.1); background: #fff; }
.pos-input.pl-11 { padding-left: 44px !important; }

.pos-autocomplete { position: relative; }
.pos-input-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 13px; pointer-events: none; }

.pos-suggestions {
    position: absolute;
    left: 0; right: 0; top: calc(100% + 6px);
    background: #fff;
    border: 1px solid var(--erp-border);
    border-radius: 16px;
    box-shadow: 0 20px 45px rgba(15,23,42,.14);
    overflow: hidden;
    z-index: 80;
    max-height: 320px;
    overflow-y: auto;
}
.pos-suggestion-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
}
.pos-suggestion-item:last-child { border-bottom: 0; }
.pos-suggestion-item:hover, .pos-suggestion-item.activo { background: #ecfeff; }
.pos-suggestion-title { font-size: 12px; font-weight: 800; color: #0f172a; }
.pos-suggestion-meta { font-size: 10px; color: #64748b; font-weight: 600; }
.pos-suggestion-price { font-size: 12px; font-weight: 900; color: #0e7490; white-space: nowrap; }
.pos-suggestion-empty, .pos-suggestion-new {
    padding: 14px 16px;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
}
.pos-suggestion-new { color: #0e7490; cursor: pointer; }
.pos-suggestion-new:hover { background: #ecfeff; }

/* Carrito de ítems */
.pos-cart { display: flex; flex-direction: column; gap: 10px; min-height: 140px; }
.pos-cart-item {
    border: 1px solid var(--erp-border);
    border-radius: 18px;
    background: #f8fafc;
    padding: 14px;
    position: relative;
    transition: border-color .15s ease;
}
.pos-cart-item:focus-within { border-color: var(--erp-cyan); }
.pos-cart-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pos-cart-row .input-nombre { flex: 1 1 220px; min-width: 0; }
.pos-cart-close {
    width: 26px; height: 26px; border-radius: 50%; background: #fff; border: 1px solid var(--erp-border);
    color: #94a3b8; display: flex; align-items: center; justify-content: center; font-size: 11px; flex: 0 0 auto;
    transition: color .15s ease, border-color .15s ease;
}
.pos-cart-close:hover { color: #e11d48; border-color: #fecdd3; }
.pos-cart-grid { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; flex-wrap: wrap; }
.pos-cart-field label { display: block; font-size: 8px; font-weight: 900; color: #94a3b8; text-transform: uppercase; margin-bottom: 4px; }
.pos-cart-field { flex: 0 0 auto; }
.pos-cart-field.pos-field-cant { width: 64px; }
.pos-cart-field.pos-field-vunit { width: 84px; }
.pos-cart-field.pos-field-iva { width: 96px; }
.pos-cart-field.pos-field-total { flex: 0 0 auto; width: 110px; }
.pos-cart-field input,
.pos-cart-field select {
    width: 100%;
    height: 34px !important;
    font-size: 12px !important;
    padding: 0 6px !important;
    text-align: center;
}
.pos-cart-field.pos-field-vunit input { text-align: right; padding: 0 8px !important; }
#listaVentas .pos-cart-field.pos-field-total .input-precio {
    height: 34px !important;
    width: 100% !important;
    text-align: right !important;
    padding: 0 8px !important;
    font-weight: 900 !important;
    font-size: 13px !important;
    color: #0e7490 !important;
    background: #ecfeff !important;
    border: 1px solid #a5f3fc !important;
    border-radius: 14px !important;
    box-shadow: none !important;
}
.pos-cart-field.pos-field-iva select { font-size: 11px !important; padding: 0 4px !important; }

/* Filas superiores del ítem (nombre/tipo y detalle/medidas): tamaños
   consistentes que ganan a la regla legada "select, input {...!important}". */
.pos-input-lg { height: 42px !important; }
.pos-input-sm { height: 38px !important; font-size: 11px !important; }
.pos-input-sm.text-center { text-align: center; }

/* Barra de total fija */
.pos-totalbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 45;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--erp-border);
    box-shadow: 0 -12px 30px rgba(15,23,42,.08);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.pos-total-label { font-size: 9px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: #64748b; }
.pos-total-value { font-size: 28px; font-weight: 900; color: #0f172a; line-height: 1.1; }
.pos-total-breakdown { font-size: 10px; font-weight: 700; color: #64748b; margin-top: 2px; }
.pos-totalbar-actions { display: flex; gap: 10px; }
.pos-action-btn { min-height: 52px; padding: 0 20px; }
.pos-action-main { min-width: 220px; justify-content: center; }

/* En escritorio la barra de sidebar ocupa 272px fijos a la izquierda; la
   barra de total (position:fixed, relativa al viewport) debe respetar ese
   espacio o queda flotando encima del menú lateral. */
@media (min-width: 901px) {
    .pos-totalbar { left: 272px; }
}

@media (max-width: 900px) {
    .pos-shell { padding-bottom: 130px; }
    .pos-cart-grid { grid-template-columns: repeat(3, 1fr); }
    .pos-totalbar { padding: 12px 14px; flex-direction: column; align-items: stretch; }
    .pos-totalbar-amount { text-align: center; }
    .pos-totalbar-actions { flex-direction: column; }
    .pos-action-main { min-width: 0; }
}
