/**
 * =============================================================================
 * Deur ERP - Extension: ui.movil_responsiva
 * Estilos de optimizacion y responsividad para dispositivos moviles y tablets
 * =============================================================================
 */

/* =============================================================================
   1. Normalización de Contenedores y Estructura Base en Móviles (< 992px)
   ============================================================================= */
@media (max-width: 991.98px) {
    /* Anulación limpia del anti-patrón inline style="height: 100vh; padding: 30px;" */
    .main-panel[style*="height: 100vh"],
    .main-panel[style*="height:100vh"],
    .main-panel[style*="height: 100vh;"],
    .main-panel[style*="height:100vh;"] {
        height: auto !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
    }

    .main-panel[style*="padding: 30px"],
    .main-panel[style*="padding:30px"],
    .main-panel[style*="padding: 30px;"],
    .main-panel[style*="padding:30px;"] {
        padding: 12px 10px !important;
    }

    .main-panel > .content {
        padding: 12px 10px 85px 10px !important;
        margin-top: 60px !important;
    }

    /* Títulos de tarjetas más equilibrados en pantallas pequeñas */
    .card-title,
    h1.card-title {
        font-size: 1.5rem !important;
        line-height: 1.3 !important;
        margin-bottom: 0.5rem !important;
    }

    /* Contenedor fluido sin desbordamiento horizontal */
    .content,
    .container-fluid,
    .main-panel {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
}

/* =============================================================================
   2. Tablas Masivas Responsivas con Desplazamiento Táctil
   ============================================================================= */
@media (max-width: 991.98px) {
    /* La tabla es el carril de scroll. Cabecera y cuerpo siguen alineados. */
    .table:not(#table_product_venta):not(#table_product_list):not(.body-wrap .table) {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-collapse: collapse !important;
        margin-bottom: 1rem !important;
    }

    .table:not(#table_product_venta):not(#table_product_list):not(.body-wrap .table) > thead,
    .table:not(#table_product_venta):not(#table_product_list):not(.body-wrap .table) > tbody {
        display: table;
        width: 100%;
        min-width: 560px;
        border-collapse: collapse;
    }

    .table th,
    .table td {
        padding: 8px 10px !important;
        font-size: 13px !important;
        white-space: nowrap !important;
    }

    .table td.col-nombre,
    .table td.col-detalle {
        white-space: normal !important;
        min-width: 130px !important;
        max-width: 220px !important;
    }

    /* Paginación adaptable para dedos */
    .pagination {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 4px !important;
    }

    .pagination .page-link {
        padding: 8px 14px !important;
        font-size: 14px !important;
        min-width: 40px !important;
        text-align: center !important;
    }
}

/* =============================================================================
   3. Ergonomía Táctil y Touch Targets (Mínimo 44x44px según HIG)
   ============================================================================= */
@media (max-width: 991.98px) {
    .btn-icon {
        min-width: 44px !important;
        min-height: 44px !important;
        width: 44px !important;
        height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
        margin: 2px !important;
        border-radius: 8px !important;
    }

    .btn-icon i,
    .btn-icon .nc-icon {
        font-size: 18px !important;
        line-height: 1 !important;
    }

    /* Botonera de acciones superiores en módulos (Producto, Pedidos, Inventario) */
    .row > .col-md-1,
    .row > .col-md-2,
    .row > .col-2 {
        flex: 1 1 auto !important;
        max-width: 100% !important;
        margin-bottom: 6px !important;
    }

    .btn-acc-block {
        min-width: 76px !important;
        min-height: 56px !important;
        width: auto !important;
        flex: 1 1 calc(33.333% - 8px) !important;
        padding: 6px 8px !important;
    }

    .panel-x2-op {
        padding-left: 0 !important;
        gap: 6px !important;
    }

    /* Botones gigantes de apertura de caja adaptados a pantalla móvil */
    .btn-boton-size {
        font-size: clamp(20px, 5.5vw, 36px) !important;
        white-space: normal !important;
        padding: 18px 12px !important;
        width: 100% !important;
        height: auto !important;
        border-radius: 12px !important;
    }

    /* Vistas de facturación y POS en pantallas < 992px */
    .content.block_sp .d-flex {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .content.block_sp .d-flex .form-group {
        width: calc(50% - 6px) !important;
        margin-right: 0 !important;
        min-width: 140px !important;
    }

    .col-btn-option {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        margin-bottom: 14px !important;
    }

    .col-btn-option .btn-acc-block,
    .col-btn-option .btn-acc-block-o {
        flex: 1 1 calc(33.333% - 6px) !important;
        width: auto !important;
        min-height: 54px !important;
        margin: 0 !important;
    }

    .facturcion-block {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .block-preci-total .preci_total_v {
        font-size: 20px !important;
    }
}

/* =============================================================================
   4. Barra Flotante de Cobro y Acciones para POS Móvil (Bottom Bar)
   ============================================================================= */
.pos-mobile-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1045;
    background: #1e1e2d;
    color: #ffffff;
    padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

body.modal-open .pos-mobile-bottom-bar {
    display: none !important;
}

.pos-mobile-bottom-bar .pm-info {
    display: flex;
    flex-direction: column;
}

.pos-mobile-bottom-bar .pm-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #94a3b8;
    margin: 0;
    line-height: 1.1;
}

.pos-mobile-bottom-bar .pm-total {
    font-size: 22px;
    font-weight: 800;
    color: #10b981;
    margin: 0;
    line-height: 1.2;
}

.pos-mobile-bottom-bar .pm-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pos-mobile-bottom-bar .btn-cobrar-pos {
    background: #10b981;
    color: #ffffff;
    font-weight: 700;
    font-size: 16px;
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    transition: all 0.2s ease;
}

.pos-mobile-bottom-bar .btn-cobrar-pos:hover,
.pos-mobile-bottom-bar .btn-cobrar-pos:focus {
    background: #059669;
    color: #ffffff;
}

.pos-mobile-bottom-bar .btn-cobrar-pos:active {
    transform: scale(0.97);
}

.pos-mobile-bottom-bar .btn-aux-pos {
    background: #334155;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: 8px;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
}

/* =============================================================================
   5. Modales Adaptativos y Medios de Pago en Móvil
   ============================================================================= */
@media (max-width: 767.98px) {
    .modal-dialog {
        margin: 0.5rem auto !important;
        max-width: calc(100% - 1rem) !important;
    }

    .modal-content {
        border-radius: 14px !important;
        overflow: hidden !important;
    }

    /* Modal de Medios de Pago en cuadrícula de 2 columnas táctiles */
    .modal_mediopago .modal-body {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
        justify-content: center !important;
        padding: 14px !important;
    }

    .modal_mediopago .btn_medio_pago {
        flex: 1 1 calc(50% - 10px) !important;
        max-width: calc(50% - 10px) !important;
        height: 108px !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 4px !important;
        padding: 10px !important;
        border-radius: 10px !important;
        background: #f8fafc !important;
        border: 2px solid #e2e8f0 !important;
        cursor: pointer !important;
        font-size: 14px !important;
        font-weight: 700 !important;
        color: #0f172a !important;
    }

    .modal_mediopago .btn_efectivo::after { content: "Efectivo"; }
    .modal_mediopago .btn_medio_pago[data-id="2"]::after { content: "Tarjeta"; }
    .modal_mediopago .btn_medio_pago[data-id="3"]::after { content: "Nequi"; }
    .modal_mediopago .btn_medio_pago[data-id="4"]::after { content: "Daviplata"; }
    .modal_mediopago .btn_medio_pago[data-id="5"]::after { content: "Bancolombia"; }

    .modal_mediopago .btn_medio_pago:focus,
    .modal_mediopago .btn_medio_pago:active {
        border-color: #BE347F !important;
        background: #fdf2f8 !important;
    }

    .modal_mediopago .btn_medio_pago img {
        max-width: 55px !important;
        max-height: 55px !important;
        object-fit: contain !important;
    }

    /* Prevenir auto-zoom en iOS Safari (font-size >= 16px) */
    input.form-control,
    select.form-control,
    textarea.form-control {
        font-size: 16px !important;
        height: auto !important;
        min-height: 42px !important;
    }
}

/* =============================================================================
   6. Pulido General de Formularios, Tarjetas y Módulos Secundarios en Móviles
   ============================================================================= */
@media (max-width: 991.98px) {
    /* Tarjetas y formularios limpios */
    .card {
        border-radius: 12px !important;
        margin-bottom: 16px !important;
    }

    .card .card-header {
        padding: 12px 14px !important;
    }

    .card .card-body {
        padding: 14px !important;
    }

    /* Formularios en columna en pantallas pequeñas */
    .form-group {
        margin-bottom: 12px !important;
    }

    /* Ajuste para Select2 en pantallas móviles */
    .select2-container {
        width: 100% !important;
    }

    .select2-container .select2-selection--single {
        height: 42px !important;
        border-radius: 8px !important;
    }

    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 40px !important;
        font-size: 15px !important;
    }

    .select2-container--default .select2-selection--single .select2-selection__arrow {
        height: 40px !important;
    }

    /* Contenedores de DataTables para evitar desbordes */
    .dataTables_wrapper {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_length {
        text-align: left !important;
        margin-bottom: 8px !important;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
    }

    /* Barra superior (Navbar) móvil */
    .navbar.navbar-absolute {
        padding-top: 6px !important;
        padding-bottom: 6px !important;
    }

    .navbar-toggler {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 10px !important;
    }

    .sidebar .nav li > a {
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    /* Ocultar botones de atajos de escritorio redundantes en barra superior en pantallas pequeñas */
    .navbar .ventana_factura {
        display: none !important;
    }
}

/* En escritorio el grupo "ver mas" no existe: sus botones siguen en la fila. */
.market-shortcuts-toggle {
    display: none;
}

.market-shortcuts-dropup {
    display: contents;
}

.mobile-detail-header-grid {
    display: none;
}

/* =============================================================================
   7. Punto de venta en el teléfono, igual que la compra de Alfredo
   Hasta 991px: en ese ancho los atajos ya se parten y Consulta queda enorme.
   Desde 992px la caja de escritorio no cambia.
   ============================================================================= */
@media (max-width: 991.98px) {
    body:has(.pos-mobile-bottom-bar) .main-panel,
    body:has(.pos-mobile-bottom-bar) .content {
        padding-bottom: calc(84px + env(safe-area-inset-bottom)) !important;
    }

    .main-panel-new .col-md-8,
    .main-panel-new .col-md-4,
    .main-panel-new .col-md-9,
    .main-panel-new .col-8 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    .img-deur-logo--pos,
    .img-deur-logo--mobile {
        max-width: 72px !important;
        max-height: 32px !important;
        margin: 0 4px 0 0 !important;
    }

    .pos-layout-alfredo .comand-btn-pos {
        display: none !important;
    }

    .pos-layout-alfredo.main-panel {
        padding-top: 6px !important;
    }

    .pos-layout-alfredo .market-shortcuts {
        display: grid !important;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
        align-items: stretch;
        position: sticky;
        top: 0;
        z-index: 36;
        background: #f4f3ef;
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-top: 6px !important;
        padding: 4px 8px 6px !important;
        overflow: visible !important;
        box-sizing: border-box !important;
    }

    .pos-layout-alfredo .market-shortcuts > .btn_save_factura:not(.btn_print_factura) {
        display: none !important;
    }

    .pos-layout-alfredo .market-shortcuts .img-deur-logo {
        display: none !important;
    }

    .pos-layout-alfredo .market-shortcuts > .btn-acc-block,
    .pos-layout-alfredo .market-shortcuts-toggle {
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        justify-content: center;
        width: 100% !important;
        min-width: 0 !important;
        min-height: 36px !important;
        height: 36px !important;
        margin: 0 !important;
        padding: 0 6px !important;
        text-align: center !important;
        flex: none !important;
    }

    .pos-layout-alfredo .market-shortcuts .title-btn-pos {
        position: static !important;
        right: auto !important;
        font-size: 11px !important;
        line-height: 1.1;
    }

    .pos-layout-alfredo .market-shortcuts .icono-btn-pos {
        display: none !important;
    }

    .pos-layout-alfredo .market-shortcuts-dropup {
        display: none;
        position: absolute;
        left: 0;
        right: 0;
        top: calc(100% + 6px);
        z-index: 40;
        padding: 8px;
        border: 1px solid #c8d9ec;
        border-radius: 10px;
        background: #f7fbff;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
    }

    .pos-layout-alfredo .market-shortcuts.shortcuts-expanded .market-shortcuts-dropup {
        display: grid;
    }

    .pos-layout-alfredo .market-shortcuts-dropup .market-shortcuts-secondary:not(.hidden_pro) {
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100% !important;
        min-width: 0 !important;
        min-height: 52px !important;
        margin: 0 !important;
        padding: 4px 2px !important;
    }

    .pos-layout-alfredo .market-shortcuts-dropup .hidden_pro {
        display: none !important;
    }

    .main-panel-new .content.block_sp {
        margin-top: 0 !important;
        padding-top: 4px !important;
    }

    #block-code-prod,
    #block-code-prod-search,
    #block-code-cliet-search {
        position: sticky;
        top: 0;
        z-index: 30;
        background: #f4f3ef;
        padding: 8px 2px 6px;
    }

    #id_producto_f,
    #producto_id_buscador,
    #autocomplete-client {
        min-height: 52px !important;
        font-size: 18px !important;
        border-radius: 12px !important;
    }

    .code-prod,
    .auto_cl {
        font-size: 14px !important;
        margin-bottom: 4px;
    }

    .autocomplete-items {
        width: calc(100% - 8px) !important;
        max-height: 46vh !important;
        border-radius: 0 0 12px 12px;
        box-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
    }

    .autocomplete-items div {
        min-height: 48px;
        display: flex;
        align-items: center;
        font-size: 16px;
    }

    body:has(.pos-layout-alfredo) .pk-bascula-live.is-offline,
    body:has(.pos-layout-alfredo) .pk-bascula-live.is-disabled {
        display: none !important;
    }

    body:has(.pos-layout-alfredo) .pk-bascula-live {
        left: 8px;
        right: 8px;
        bottom: calc(78px + env(safe-area-inset-bottom));
        min-width: 0;
        z-index: 1044;
    }

    .pos-layout-alfredo .row-panel-p,
    .pos-layout-alfredo .content.block_sp > .row {
        display: flex !important;
        flex-wrap: wrap;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .pos-layout-alfredo .row-panel-p {
        flex-direction: column;
        align-items: stretch;
    }

    /* Primero el campo de búsqueda, después las líneas y al final la caja. */
    .pos-layout-alfredo .row-panel-p > .market-order-atajos { order: 1; }
    .pos-layout-alfredo .row-panel-p > .content.block_sp {
        order: 2;
        flex: 0 0 100%;
        max-width: 100%;
        width: 100% !important;
        padding: 0 0 8px !important;
    }
    .pos-layout-alfredo .row-panel-p > .market-order-caja { order: 3; }

    .pos-layout-alfredo .content.block_sp > .row {
        flex-direction: column;
        flex-wrap: nowrap;
    }

    .pos-layout-alfredo .market-shortcuts-product-search,
    .pos-layout-alfredo .market-order-6,
    .pos-layout-alfredo .block-prod-descrp,
    .pos-layout-alfredo .market-order-8,
    .pos-layout-alfredo .market-order-1 {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
        box-sizing: border-box !important;
    }

    .pos-layout-alfredo .market-shortcuts-product-search {
        display: block !important;
        grid-column: 1 / -1;
        order: -1;
        position: sticky;
        top: 0;
        z-index: 35;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 0 6px !important;
        padding: 0 !important;
        background: #f4f3ef;
    }

    .pos-layout-alfredo .market-shortcuts-product-search .form-control {
        width: 100%;
        height: 42px !important;
        min-height: 42px !important;
        margin: 0;
        padding: 8px 12px !important;
        font-size: 16px !important;
        font-weight: 400;
        line-height: 1.2;
        border-radius: 8px !important;
        box-shadow: none;
    }

    .pos-layout-alfredo .market-shortcuts > #btn-consulta-prod,
    .pos-layout-alfredo #btn_mobile_consulta_toggle_d {
        display: none !important;
    }

    .pos-layout-alfredo .market-order-6,
    .pos-layout-alfredo .block-prod-descrp { order: 2; }
    .pos-layout-alfredo .market-order-1 { order: 4; }

    /* El total vive en la barra Cobrar; el bloque grande no debe robar altura. */
    .pos-layout-alfredo .market-order-8 {
        display: none !important;
    }

    /* Como Alfredo: el código desktop, el resumen del cliente y F9 salen del teléfono. */
    .pos-layout-alfredo #block-code-prod,
    .pos-layout-alfredo #block-code-prod-search,
    .pos-layout-alfredo #block-code-cliet-search,
    .pos-layout-alfredo .market-order-7,
    .pos-layout-alfredo .market-order-9,
    .pos-layout-alfredo .content.block_sp > .row > .col-md-4:has(.body-wrap),
    .pos-layout-alfredo .content.block_sp > .row > .col-md-4:has(#code_producto) {
        display: none !important;
    }

    .pos-layout-alfredo .market-shortcuts > #btn-consulta-prod {
        display: none !important;
    }

    .pos-layout-alfredo .cons-fact {
        float: none !important;
        font-size: 18px !important;
        margin: 0 !important;
    }

    .pos-layout-alfredo .market-order-caja {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        flex-wrap: wrap;
        padding: 0 8px;
        opacity: 0.92;
    }

    .pos-layout-alfredo .market-order-caja .btn,
    .pos-layout-alfredo .market-order-caja a.btn {
        float: none !important;
        margin: 0 !important;
        padding: 6px 8px !important;
        font-size: 12px !important;
        min-height: 36px;
        flex: 1 1 auto;
    }

    .pos-layout-alfredo .facturcion-block {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        background: transparent !important;
        border: 0 !important;
        padding-bottom: 8px;
    }

    .pos-layout-alfredo #table-product-list.facturcion-block:not(.hidden_pro) {
        display: block !important;
        max-height: none !important;
    }

    .pos-mobile-bottom-bar {
        transition: transform 0.12s ease-out;
        will-change: transform;
    }

    .pos-layout-alfredo .pos-mobile-bottom-bar .btn-cobrar-pos {
        flex: 1 1 auto;
    }

    .pos-layout-alfredo #table-product-list.hidden_pro,
    .pos-layout-alfredo #table-product-factura.hidden_pro {
        display: none !important;
    }

    .pos-layout-alfredo .market-order-6::before {
        content: 'En esta venta';
        display: block;
        margin: 2px 8px 6px;
        font-size: 13px;
        font-weight: 700;
        color: #36536f;
    }

    .pos-layout-alfredo #table_product_venta,
    .pos-layout-alfredo #table_product_venta tr {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    .pos-layout-alfredo #table_product_venta tbody {
        display: flex !important;
        flex-direction: column-reverse;
        gap: 8px;
        width: 100% !important;
        min-width: 0 !important;
    }

    .pos-layout-alfredo #table_product_venta thead {
        display: none !important;
    }

    .pos-layout-alfredo #table_product_venta tbody tr {
        background: #fff;
        border: 1px solid #e4e0d8;
        border-radius: 12px;
        margin: 0;
    }

    .pos-layout-alfredo #table_product_venta tbody tr:last-child {
        border-color: #BE347F;
        box-shadow: inset 3px 0 0 #BE347F;
    }

    .pos-layout-alfredo #table_product_venta tbody td:not(:nth-child(3)) {
        display: none !important;
    }

    .pos-layout-alfredo #table_product_venta tbody td:nth-child(3) {
        display: block !important;
        width: 100% !important;
        padding: 10px 12px !important;
        white-space: normal !important;
    }

    .pos-layout-alfredo #table_product_venta .mobile-detail-header-desktop,
    .pos-layout-alfredo #table_product_venta .mobile-item-desktop-content {
        display: none !important;
    }

    .pos-layout-alfredo #table_product_venta .mobile-item-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "texts total"
            "texts actions";
        column-gap: 10px;
        row-gap: 4px;
        align-items: center;
        width: 100%;
    }

    .pos-layout-alfredo #table_product_venta .mobile-item-texts {
        grid-area: texts;
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
    }

    .pos-layout-alfredo #table_product_venta .mobile-item-name {
        font-weight: 700;
        line-height: 1.2;
        word-break: break-word;
        white-space: normal !important;
    }

    .pos-layout-alfredo #table_product_venta .mobile-item-qty,
    .pos-layout-alfredo #table_product_venta .mobile-item-code,
    .pos-layout-alfredo #table_product_venta .mobile-item-unit {
        color: #36536f;
        font-size: 12px;
        line-height: 1.15;
        white-space: normal !important;
    }

    .pos-layout-alfredo #table_product_venta .mobile-item-code:empty,
    .pos-layout-alfredo #table_product_venta .mobile-item-unit:empty {
        display: none;
    }

    .pos-layout-alfredo #table_product_venta .mobile-item-actions {
        grid-area: actions;
        display: grid;
        grid-template-columns: repeat(4, 34px);
        gap: 6px;
        justify-content: end;
    }

    .pos-layout-alfredo #table_product_venta .mobile-item-actions .btn {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        min-height: 34px !important;
        padding: 0 !important;
        font-size: 14px !important;
    }

    .pos-layout-alfredo #table_product_venta .mobile-item-total {
        grid-area: total;
        font-weight: 800;
        font-size: 20px;
        text-align: right;
        white-space: nowrap;
    }

    .pos-layout-alfredo #table_product_venta tr.active td:nth-child(3) {
        box-shadow: inset 3px 0 0 #BE347F;
    }

    #table_product_list:not(.hidden_pro),
    #table-product-list:not(.hidden_pro) #table_product_list {
        display: block !important;
        width: 100% !important;
        overflow: visible !important;
    }

    #table_product_list thead {
        display: none !important;
    }

    #table_product_list tbody,
    #table_product_list tr {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    #table_product_list tr {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "detalle precios";
        gap: 8px 12px;
        align-items: start;
        min-height: 72px;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        padding: 10px 12px;
        margin-bottom: 8px;
        cursor: pointer;
    }

    #table_product_list tr:active {
        background: #f4e8ef;
    }

    #table_product_list td {
        display: block !important;
        width: auto !important;
        padding: 0 !important;
        border: 0 !important;
        white-space: normal !important;
    }

    #table_product_list td:nth-child(1) { display: none !important; }

    #table_product_list td.product-search-detail {
        grid-area: detalle;
        text-align: left;
        min-width: 0;
    }

    #table_product_list td.product-search-prices {
        grid-area: precios;
        text-align: right;
    }

    #table_product_list .ps-name {
        font-weight: 700;
        font-size: 16px;
        line-height: 1.2;
        margin-bottom: 4px;
    }

    #table_product_list .ps-meta,
    #table_product_list .ps-price {
        color: #36536f;
        font-size: 13px;
        line-height: 1.25;
    }

    .body-wrap,
    .body-wrap > tbody,
    .body-wrap > tbody > tr,
    .body-wrap > tbody > tr > td {
        display: block !important;
        width: 100% !important;
    }

    .body-wrap .table,
    .body-wrap .table > thead,
    .body-wrap .table > tbody {
        display: block !important;
        width: 100% !important;
        min-width: 0 !important;
        overflow: visible !important;
    }

    .body-wrap .table tr {
        display: flex !important;
        justify-content: space-between;
        gap: 12px;
        align-items: baseline;
        width: 100% !important;
        padding: 7px 0;
        border-bottom: 1px solid #ece7df;
    }

    .body-wrap .table th {
        white-space: normal !important;
        font-size: 14px !important;
    }

    .body-wrap .content-block {
        display: inline-block;
    }

    .block-preci-total {
        display: flex;
        flex-wrap: wrap;
        gap: 8px 16px;
        align-items: baseline;
    }

    .block-preci-total .preci_total_v {
        float: none !important;
        font-size: 16px !important;
        margin: 0 !important;
    }

    .pos-layout-alfredo .market-order-8 .block-preci-total,
    .pos-layout-alfredo .block-preci-total {
        position: sticky;
        bottom: calc(78px + env(safe-area-inset-bottom));
        z-index: 18;
        display: flex !important;
        flex-direction: column;
        gap: 4px;
        background: #fff;
        border-radius: 12px;
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
        padding: 10px 12px;
        margin: 0 0 8px;
        width: 100%;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    .pos-layout-alfredo .block-preci-total .preci_total_v {
        float: none !important;
        margin: 0 !important;
        line-height: 1.2;
    }

    .pos-layout-alfredo .block-preci-total .preci_iva {
        font-size: 15px !important;
    }

    .pos-layout-alfredo .block-preci-total .preci_total_v:not(.preci_iva) {
        display: flex;
        justify-content: space-between;
        font-size: 22px !important;
        font-weight: 800;
    }

    .modal_product_cantidad .modal-dialog {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100%;
        min-height: 0;
        height: auto;
        display: flex;
        align-items: flex-end;
    }

    .modal_product_cantidad .modal-content {
        border-radius: 16px 16px 0 0 !important;
        width: 100%;
    }

    .modal_product_cantidad .modal-header,
    .modal_product_cantidad .modal-footer {
        padding: 10px 14px;
    }

    .modal_product_cantidad .modal-body {
        padding: 10px 14px 4px;
    }

    .modal_product_cantidad .modal-title {
        font-size: 16px;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: calc(100% - 32px);
    }

    .modal_product_cantidad .pk-bascula-status.is-offline {
        display: none !important;
    }

    .modal_product_cantidad .pk-bascula-status {
        margin-bottom: 8px;
        padding: 6px 8px;
        font-size: 13px;
    }

    #cantidad_produc {
        font-size: 22px !important;
        text-align: center;
        height: 48px !important;
        min-height: 48px !important;
        font-weight: 700;
        margin-bottom: 0;
    }

    .modal_product_cantidad .btn-cantidad_product {
        width: 100%;
        min-height: 48px;
        font-size: 18px;
        font-weight: 700;
    }
}

/* En escritorio la barra de cobro no ocupa la caja. */
@media (min-width: 992px) {
    .pos-mobile-bottom-bar {
        display: none !important;
    }
}

/* =============================================================================
   8. Vistas operativas: empresa, productos, compra, venta, caja, cartera
   ============================================================================= */
@media (max-width: 991.98px) {
    .wrapper > .main-panel,
    .main-panel > .content {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* La tabla sigue siendo una sola pieza. El scroll lo hace .table-responsive. */
    .main-panel table.table:not(#table_product_venta):not(#table_product_list):not(.body-wrap .table) {
        display: table !important;
        width: max-content !important;
        min-width: 100% !important;
        overflow: visible !important;
        margin-bottom: 0 !important;
    }

    .main-panel table.table:not(#table_product_venta):not(#table_product_list):not(.body-wrap .table) > thead {
        display: table-header-group !important;
        width: auto !important;
        min-width: 0 !important;
    }

    .main-panel table.table:not(#table_product_venta):not(#table_product_list):not(.body-wrap .table) > tbody {
        display: table-row-group !important;
        width: auto !important;
        min-width: 0 !important;
    }

    .table-responsive {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar .dropdown-menu {
        position: static !important;
        float: none !important;
        width: auto !important;
        min-width: 0 !important;
        transform: none !important;
        box-shadow: none;
        border: 0;
        margin: 0 8px 8px;
    }

    .navbar-collapse {
        background: #fff;
    }

    .navbar .navbar-nav {
        flex-direction: row;
        align-items: center;
    }

    .productos-page .col-nombre,
    .proveedor-page td,
    .cartera-page td,
    .fc-list-page td,
    .fv-list-page td {
        white-space: normal !important;
    }

    .productos-page .col-nombre {
        min-width: 160px;
        max-width: 240px;
    }

    .fc-page .card-header,
    .fc-list-page .card-header,
    .fv-page .card-header,
    .fv-list-page .card-header,
    .caja-page .card-header,
    .cartera-page .card-header,
    .proveedor-page .card-header,
    .empresa-page .card-header,
    .productos-page .card-header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .fc-page .card-header .btn,
    .fv-page .card-header .btn,
    .fc-list-page .row > [class*="col-"] > .btn,
    .fv-list-page .row > [class*="col-"] > .btn,
    .caja-page .row > [class*="col-"] > .btn,
    .cartera-page .row > [class*="col-"] > .btn,
    .proveedor-page .row > [class*="col-"] > .btn,
    .productos-page .col-12.d-flex > .btn {
        width: 100%;
        height: auto !important;
        white-space: normal;
        margin: 0 0 8px;
    }

    .fc-page .col-md-2,
    .fc-page .col-md-3,
    .fc-page .col-md-4,
    .fc-page .col-md-6,
    .fc-page .col-md-8,
    .fv-page .col-md-2,
    .fv-page .col-md-3,
    .fv-page .col-md-4,
    .fv-page .col-md-6,
    .fv-page .col-md-8 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    .fc-page .btn_guard_co,
    .fv-page .btn_guard_co {
        float: none !important;
        width: 100% !important;
        margin: 8px 0 0 !important;
    }

    .fc-page [style*="left: 35px"],
    .fc-page [style*="left:35px"] {
        left: 0 !important;
        justify-content: flex-start !important;
    }

    .fc-page #recuperar_factura_id,
    .fc-page #total_factura_proveedor_control {
        max-width: none !important;
        width: 100%;
        flex: 1 1 140px;
    }

    .fc-page .card.my-4 .d-flex,
    .fc-page #barra_control_cuadre_factura .d-flex,
    .fc-page #panel_empaque_conversor_col .d-flex {
        flex-wrap: wrap !important;
        gap: 8px;
    }

    .fc-page #barra_control_cuadre_factura label,
    .fc-page #barra_control_cuadre_factura span {
        white-space: normal !important;
    }

    .empresa-page .card-stats .card-title,
    .empresa-page .numbers .card-title {
        font-size: 1.15rem !important;
        word-break: break-word;
    }

    .empresa-page .pr-1,
    .empresa-page .pl-1 {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }

    .zpl-printer-panel__workspace {
        grid-template-columns: 1fr !important;
    }

    .zpl-printer-panel__header {
        align-items: flex-start;
    }

    .main-panel table.clientes-table:not(#table_product_venta):not(#table_product_list):not(.body-wrap .table) {
        display: table !important;
        width: 100% !important;
        min-width: 0 !important;
        table-layout: fixed;
    }

    .main-panel table.clientes-table:not(#table_product_venta):not(#table_product_list):not(.body-wrap .table) > thead {
        display: table-header-group !important;
        width: auto !important;
        min-width: 0 !important;
    }

    .main-panel table.clientes-table:not(#table_product_venta):not(#table_product_list):not(.body-wrap .table) > tbody {
        display: table-row-group !important;
        width: auto !important;
        min-width: 0 !important;
    }

    .clientes-page .table th,
    .clientes-page .table td {
        white-space: normal !important;
    }
}

/* Consulta de productos: detalle y los tres precios, como en Alfredo. */
#table_product_list td.product-search-detail,
#table_product_list td.product-search-prices {
    white-space: normal;
    vertical-align: top;
    line-height: 1.25;
}

#table_product_list .ps-name {
    font-weight: 700;
    margin-bottom: 2px;
}

#table_product_list .ps-meta,
#table_product_list .ps-price {
    color: #36536f;
    font-size: 13px;
}

#table_product_list td.product-search-prices {
    text-align: right;
}

/* =============================================================================
   9. Venta, mismo armado que modificarenlacompra_alfredo
   ============================================================================= */
.pos-layout-alfredo .market-shortcuts-product-search {
    display: none;
}

.pos-layout-alfredo .market-mobile-collapsible > summary {
    display: none;
}

.pos-layout-alfredo .market-mobile-collapsible {
    border: 0;
    background: transparent;
    padding: 0;
}

@media (max-width: 991.98px) {
    .pos-layout-alfredo .market-order-1 .market-mobile-collapsible {
        border: 1px solid #dce6f2;
        border-radius: 8px;
        background: #f8fbff;
        padding: 8px;
    }

    .pos-layout-alfredo .market-order-1 .market-mobile-collapsible > summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        list-style: none;
        cursor: pointer;
        font-size: 13px;
        font-weight: 700;
        color: #31506f;
    }

    .pos-layout-alfredo .market-order-1 .market-mobile-collapsible > summary::-webkit-details-marker {
        display: none;
    }

    .pos-layout-alfredo .market-order-1 .market-mobile-collapsible > summary::after {
        content: '+';
        font-weight: 800;
    }

    .pos-layout-alfredo .market-order-1 .market-mobile-collapsible[open] > summary {
        margin-bottom: 8px;
    }

    .pos-layout-alfredo .market-order-1 .market-mobile-collapsible[open] > summary::after {
        content: '-';
    }

    .pos-layout-alfredo .market-order-1 .pos-input-row {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .pos-layout-alfredo .market-order-1 .pos-input-row .form-group {
        width: 100% !important;
        margin: 0 !important;
    }

    .pos-layout-alfredo .market-order-5.market-client-actions-floating {
        position: fixed !important;
        right: 12px;
        bottom: calc(88px + env(safe-area-inset-bottom));
        left: auto;
        top: auto;
        width: auto !important;
        max-width: calc(100vw - 16px);
        z-index: 1046;
        overflow: visible !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        flex: none !important;
    }

    .pos-layout-alfredo .market-order-5 .market-mobile-collapsible {
        border: 0;
        background: transparent;
        padding: 0;
    }

    .pos-layout-alfredo .market-order-5 .market-mobile-collapsible > summary {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 56px;
        height: 56px;
        margin-left: auto;
        border-radius: 50%;
        background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
        color: transparent;
        font-size: 0;
        list-style: none;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
        position: relative;
    }

    .pos-layout-alfredo .market-order-5 .market-mobile-collapsible > summary::-webkit-details-marker {
        display: none;
    }

    .pos-layout-alfredo .market-order-5 .market-mobile-collapsible > summary::after {
        content: '☰';
        color: #fff;
        font-size: 24px;
        line-height: 1;
    }

    .pos-layout-alfredo .market-order-5 .market-mobile-collapsible[open] {
        position: absolute;
        right: 0;
        bottom: 64px;
        width: min(220px, calc(100vw - 24px));
        border: 1px solid #e1e8f2;
        border-radius: 12px;
        background: #fff;
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
        padding: 8px;
    }

    .pos-layout-alfredo .market-order-5 .market-mobile-collapsible[open] > summary {
        position: absolute;
        right: 0;
        bottom: -64px;
    }

    .pos-layout-alfredo .market-order-5 .market-mobile-collapsible[open] > summary::after {
        content: '✕';
        font-size: 18px;
    }

    .pos-layout-alfredo .market-order-5 .market-mobile-collapsible[open] .btn,
    .pos-layout-alfredo .market-order-5 .market-mobile-collapsible[open] .btn-acc-block {
        width: 100% !important;
        min-width: 0 !important;
        min-height: 44px !important;
        margin: 4px 0 !important;
        flex: none !important;
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        overflow: visible !important;
    }

    .pos-layout-alfredo .market-order-5 .market-mobile-collapsible[open] .comand-btn-pos {
        display: none !important;
    }

    .pos-layout-alfredo .market-order-5 .market-mobile-collapsible[open] .title-btn-pos {
        position: static !important;
        right: auto !important;
        font-size: 12px !important;
    }
}

/* =============================================================================
   20. Vista Empresa Móvil (ui.empresa_movil)
   ============================================================================= */
.empresa-page {
    min-height: 100vh;
    padding: 24px 20px;
}

.logo-upload-wrapper {
    position: relative;
    display: inline-block;
    border-radius: 50%;
}

.logo-edit-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #BE347F;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    border: 2px solid #fff;
    transition: transform 0.2s ease, background 0.2s ease;
    cursor: pointer;
}

.logo-upload-wrapper:hover .logo-edit-badge,
.logo-upload-wrapper:active .logo-edit-badge {
    transform: scale(1.1);
    background: #9c2766;
}

.card-empresa-profile .author .title {
    word-break: break-word;
}

.card-empresa-sedes {
    border-radius: 12px;
}

.sede-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-color: #e2e8f0 !important;
    border-radius: 12px !important;
}

.sede-card:hover {
    box-shadow: 0 6px 18px rgba(0,0,0,0.08) !important;
}

#sedesViewTab .nav-link.active {
    background-color: #BE347F !important;
    color: #fff !important;
    box-shadow: 0 2px 6px rgba(190, 52, 127, 0.35);
}

#sedesViewTab .nav-link {
    color: #555;
    background: #f1f5f9;
    margin-left: 4px;
    transition: all 0.2s ease;
}

.card-empresa-table-card .table th,
.card-empresa-table-card .table td {
    vertical-align: middle;
}

.btn-touch-mobile {
    min-height: 44px;
    min-width: 120px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    padding: 10px 16px;
}

@media (max-width: 991.98px) {
    .empresa-page {
        padding: 12px 10px 85px 10px !important;
        height: auto !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
    }

    .empresa-page .content {
        padding: 10px 0 !important;
        margin-top: 50px !important;
    }

    .row-empresa-stats .card-stats {
        margin-bottom: 12px !important;
        border-radius: 12px;
    }

    .row-empresa-stats .card-stats .numbers {
        text-align: right;
    }

    .row-empresa-stats .card-stats .numbers .card-title {
        font-size: 18px !important;
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .card-empresa-profile,
    .card-empresa-form,
    .card-empresa-table-card,
    .card-empresa-sedes {
        border-radius: 12px;
        margin-bottom: 16px;
    }

    .sede-card {
        padding: 14px 12px !important;
        border-radius: 10px;
    }

    .sede-card .edit_empresa_btn {
        width: 100% !important;
        margin-top: 8px;
        min-height: 42px;
        font-size: 14px !important;
        justify-content: center;
    }

    .sede-cajas-box {
        margin: 10px 0 !important;
    }

    .card-empresa-form .form-group label {
        font-size: 13px !important;
        margin-bottom: 4px;
    }

    .card-empresa-form .form-control {
        font-size: 15px !important;
        height: 42px !important;
    }

    .card-empresa-table-card .card-header {
        padding: 12px 14px !important;
    }

    .modal_edit_empresa .modal-dialog,
    .modal_create_empresa .modal-dialog {
        margin: 10px !important;
        max-width: calc(100vw - 20px) !important;
    }

    .modal_edit_empresa .modal-content,
    .modal_create_empresa .modal-content {
        border-radius: 14px;
        max-height: 90vh;
        max-height: 90dvh;
        display: flex;
        flex-direction: column;
    }

    .modal_edit_empresa .modal-body,
    .modal_create_empresa .modal-body {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 14px !important;
    }

    .modal_edit_empresa .form-control,
    .modal_create_empresa .form-control {
        font-size: 16px !important; /* Previene auto-zoom en iOS Safari */
        height: 42px !important;
    }

    .modal_edit_empresa .modal-footer,
    .modal_create_empresa .modal-footer {
        padding: 10px 14px !important;
        background: #f8f9fa;
        border-top: 1px solid #e9ecef;
    }

    .modal_edit_empresa .modal-footer .btn,
    .modal_create_empresa .modal-footer .btn {
        flex: 1;
        margin: 0 4px;
    }
}

/* =============================================================================
   21. Cajas, Informes y Extracto Móvil (ui.caja_informes_extracto)
   ============================================================================= */
.caja-page,
.informes-page {
    min-height: 100vh;
    padding: 24px 20px;
}

#cajasViewTab .nav-link.active {
    background-color: #BE347F !important;
    color: #fff !important;
    box-shadow: 0 2px 6px rgba(190, 52, 127, 0.35);
}

#cajasViewTab .nav-link {
    color: #555;
    background: #f1f5f9;
    margin-left: 4px;
    transition: all 0.2s ease;
}

.card-caja-item {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-color: #e2e8f0 !important;
    border-radius: 12px !important;
}

.card-caja-item:hover {
    box-shadow: 0 6px 18px rgba(0,0,0,0.08) !important;
}

.caja-actions-grid .btn {
    min-height: 38px;
}

@media (max-width: 991.98px) {
    .caja-page,
    .informes-page {
        padding: 12px 10px 85px 10px !important;
        height: auto !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
    }

    .caja-page .content,
    .informes-page .content {
        padding: 10px 0 !important;
        margin-top: 50px !important;
    }

    .card-caja-item {
        border-radius: 12px !important;
    }

    .caja-actions-grid .btn {
        min-height: 42px !important;
    }

    /* Informes: Ajuste de filtros */
    .informes-page .form-control {
        font-size: 15px !important;
        height: 42px !important;
    }

    .informes-page .mes-rapido-atajos {
        display: flex;
        gap: 6px;
        margin-top: 4px;
    }

    .informes-page .mes-rapido-atajos .btn {
        flex: 1;
        font-size: 11px !important;
        padding: 4px 6px !important;
    }

    /* Informes reporte (.ex-report) */
    .ex-report {
        padding: 8px 6px 28px !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    .ex-hero {
        padding: 14px 14px !important;
        border-radius: 12px !important;
    }

    .ex-hero__title {
        font-size: 1.2rem !important;
    }

    .ex-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    .ex-kpi {
        padding: 8px 10px !important;
    }

    .ex-kpi__val {
        font-size: 1rem !important;
    }

    .ex-cierre {
        padding: 14px 12px !important;
        border-radius: 12px !important;
    }

    .ex-cierre__val {
        font-size: 1.4rem !important;
    }

    .imprimir {
        padding: 8px 10px !important;
        gap: 8px !important;
    }

    .imprimir a,
    .imprimir .boton,
    .imprimir input[type="button"] {
        flex: 1 1 calc(50% - 8px);
        text-align: center !important;
        min-height: 42px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Tablas dentro de los informes */
    .ex-report .tabla {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-radius: 8px !important;
        margin-bottom: 12px !important;
    }

    .ex-report .tabla th,
    .ex-report .tabla td {
        padding: 6px 8px !important;
        font-size: 12px !important;
        white-space: nowrap !important;
    }

    /* Extracto modal y vista */
    .extracto-ticket-wrapper {
        padding: 8px 6px !important;
        max-width: 100% !important;
        font-size: 12px !important;
    }

    .extracto-table-responsive {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin-bottom: 12px !important;
    }

    .extracto-ticket-wrapper .tabla {
        min-width: 480px;
    }
}
