/* Ventas mobile adaptation. Desktop and print are outside every media query. */
/* Responsive overrides loaded after module styles. Desktop and print styles
   remain unchanged outside the media queries below. */
@media screen and (max-width: 760px), screen and (max-width: 1023px) and (max-height: 500px) {
  body.app-ventas #appShell[data-active-view="sell"] .pos-shell:not(.pos-mode-cart) .pos-products {
    display: flex !important;
    flex-direction: column !important;
  }
  body.app-ventas #appShell[data-active-view="sell"] .pos-products > * {
    order: 3;
    min-width: 0;
  }
  body.app-ventas #appShell[data-active-view="sell"] .pos-products > .touch-pos-head {
    order: 0;
  }
  body.app-ventas #appShell[data-active-view="sell"] .pos-products > .pos-search-row {
    order: 1;
  }
  body.app-ventas #appShell[data-active-view="sell"] .pos-products > .last-sale-receipt {
    order: 2;
  }
  body.app-ventas #appShell {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding-inline: 8px !important;
  }

  /* Company identity and existing actions, without dropping any action. */
  body.app-ventas #appShell .topbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    position: relative !important;
    inset: auto !important;
    min-height: 0 !important;
    height: auto !important;
    gap: 6px !important;
    margin: 0 0 8px !important;
    padding: 8px !important;
    border-radius: 12px !important;
  }
  body.app-ventas #appShell .topbar > div:first-child {
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex: initial !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 48px !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  body.app-ventas #appShell .company-brand-logo {
    box-sizing: border-box !important;
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    flex: 0 0 48px !important;
    margin: 0 !important;
    padding: 0 !important;
    object-fit: contain !important;
  }
  body.app-ventas #appShell .topbar #companyName {
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    font-size: 20px !important;
    line-height: 1.2 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
  }
  body.app-ventas #appShell .topbar-actions {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex-wrap: wrap !important;
    gap: 5px !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }
  body.app-ventas #appShell .topbar-actions > * {
    flex: 0 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: 100% !important;
  }
  body.app-ventas #appShell .topbar-actions button:not([hidden]):not([data-permission-hidden]) {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 44px !important;
    padding: 7px 9px !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    white-space: normal !important;
  }
  body.app-ventas #appShell .topbar-actions .notification-button strong {
    font-size: 12px !important;
  }
  body.app-ventas #appShell .ventas-connection-status {
    min-width: 26px !important;
    padding: 7px 6px !important;
    margin-right: auto !important;
  }
  body.app-ventas #appShell .ventas-menu-toggle {
    min-height: 44px !important;
    gap: 8px !important;
    padding: 7px 10px !important;
    margin-block: 0 8px !important;
  }

  /* Horizontal subview tabs: keep every destination reachable by native scroll.
     These selectors exclude .pos-mobile-switch (owned by the POS candidate). */
  body.app-ventas #appShell .module-window-nav:not([hidden]),
  body.app-ventas #appShell .settings-window-nav:not([hidden]),
  body.app-ventas #appShell .history-window-nav:not([hidden]) {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    gap: 6px !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 5px !important;
    margin-block: 0 10px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  body.app-ventas #appShell .module-window-nav > button,
  body.app-ventas #appShell .settings-window-nav > button,
  body.app-ventas #appShell .history-window-nav > button {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 104px !important;
    max-width: 180px !important;
    min-height: 48px !important;
    padding: 7px 10px !important;
    white-space: normal !important;
    line-height: 1.2 !important;
  }
  body.app-ventas #appShell .module-window-nav button strong,
  body.app-ventas #appShell .settings-window-nav button strong,
  body.app-ventas #appShell .history-window-nav button strong {
    font-size: 14px !important;
    line-height: 1.25 !important;
  }
  body.app-ventas #appShell .module-window-nav button span,
  body.app-ventas #appShell .settings-window-nav button span,
  body.app-ventas #appShell .history-window-nav button span {
    font-size: 12px !important;
    line-height: 1.2 !important;
  }

  /* Let content shrink inside grid/flex containers instead of clipping the page. */
  body.app-ventas #appShell .ventas-workspace,
  body.app-ventas #appShell .content-grid,
  body.app-ventas #appShell .document-list,
  body.app-ventas #appShell #mainList,
  body.app-ventas #appShell .admin-panel,
  body.app-ventas #appShell .purchase-window-panel,
  body.app-ventas #appShell .purchase-card-panel,
  body.app-ventas #appShell .purchase-detail-panel {
    box-sizing: border-box !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  body.app-ventas #appShell .admin-panel-head {
    align-items: flex-start !important;
    flex-wrap: wrap !important;
    gap: 9px !important;
    min-width: 0 !important;
  }
  body.app-ventas #appShell .admin-panel-head > div:first-child {
    min-width: 0 !important;
    max-width: 100% !important;
  }
  body.app-ventas #appShell .admin-head-actions,
  body.app-ventas #appShell .inventory-location-work-actions,
  body.app-ventas #appShell .mini-action-row {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: stretch !important;
    gap: 7px !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  body.app-ventas #appShell .admin-head-actions button,
  body.app-ventas #appShell .inventory-location-work-actions button,
  body.app-ventas #appShell .mini-action-row button {
    flex: 1 1 140px !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 44px !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }
  body.app-ventas #appShell .inventory-search-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: end !important;
    gap: 8px !important;
    min-width: 0 !important;
  }
  body.app-ventas #appShell .inventory-search-actions .toolbar-search {
    min-width: 0 !important;
    margin: 0 !important;
  }
  body.app-ventas #appShell .inventory-search-actions input,
  body.app-ventas #appShell .product-classification-grid select {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px !important;
    font-size: 16px !important;
  }
  body.app-ventas #appShell .inventory-filter-bar,
  body.app-ventas #appShell .inventory-filter-actions,
  body.app-ventas #appShell .purchase-filter-bar,
  body.app-ventas #appShell .purchase-discount-editor {
    grid-template-columns: minmax(0, 1fr) !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  body.app-ventas #appShell .purchase-discount-editor > *,
  body.app-ventas #appShell .purchase-card-panel label,
  body.app-ventas #appShell .purchase-line-row > *,
  body.app-ventas #appShell .purchase-history-row > * {
    min-width: 0 !important;
    max-width: 100% !important;
  }
  body.app-ventas #appShell .inventory-filter-bar > .ghost-button {
    min-width: 0 !important;
    min-height: 44px !important;
    width: 100% !important;
    white-space: normal !important;
  }
  body.app-ventas #appShell .purchase-line-row,
  body.app-ventas #appShell .purchase-history-row,
  body.app-ventas #appShell .admin-row.cash-movement-row {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 9px !important;
  }
  body.app-ventas #appShell .admin-row > div:first-child,
  body.app-ventas #appShell .admin-row-meta {
    min-width: 0 !important;
    max-width: 100% !important;
  }
  body.app-ventas #appShell .admin-row-meta {
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
    gap: 7px !important;
  }
  body.app-ventas #appShell .purchase-line-row strong,
  body.app-ventas #appShell .purchase-line-row span,
  body.app-ventas #appShell .purchase-line-row small,
  body.app-ventas #appShell .purchase-history-row strong,
  body.app-ventas #appShell .purchase-history-row span,
  body.app-ventas #appShell .admin-row > div:first-child > strong,
  body.app-ventas #appShell .admin-row > div:first-child > span {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }

  /* Preserve all product content; do not clamp names or presentation data. */
  body.app-ventas #appShell[data-active-view="sell"] .pos-products .touch-product-card {
    padding: 12px !important;
    gap: 8px !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
  }
  body.app-ventas #appShell[data-active-view="sell"] .pos-products .touch-product-card > strong {
    font-size: 17px !important;
    line-height: 1.35 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    -webkit-line-clamp: unset !important;
  }
  body.app-ventas #appShell[data-active-view="sell"] .pos-products .product-visual.has-image {
    height: 96px !important;
    min-height: 96px !important;
  }

  /* Wide finance/collection tables stay usable by intentional native scrolling. */
  body.app-ventas #appShell .profit-table-scroll,
  body.app-ventas #appShell .collections-table-wrap {
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }
  body.app-ventas #appShell table.table {
    width: 100% !important;
    table-layout: fixed !important;
  }
  body.app-ventas #appShell table.table th,
  body.app-ventas #appShell table.table td {
    padding: 8px 6px !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }
}

/* Purchase filters and descriptions need their own rows before the phone
   breakpoint: four filter groups cannot share the old three-column toolbar. */
@media screen and (max-width: 1023px) {
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-filter-bar {
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: start;
    gap: 10px;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-filter-actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    min-width: 0;
    align-items: stretch;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-filter-actions button {
    align-content: start;
    min-width: 0;
    min-height: 88px;
    gap: 6px;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-history-search {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 8px;
    min-width: 0;
    margin: 0;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-history-search > :first-child,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-history-search > button {
    grid-column: 1 / -1;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-history-search label,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-filter-bar > label {
    display: grid;
    align-content: start;
    gap: 6px;
    min-width: 0;
    margin: 0;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-filter-bar input,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-filter-bar select {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: auto;
    min-height: 44px;
    margin: 0;
    font-size: 16px;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-filter-bar button {
    min-height: 44px;
    max-width: 100%;
    white-space: normal;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-filter-bar > .ghost-button {
    align-self: end;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-history-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    align-items: start;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-history-row > :first-child,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-history-actions {
    grid-column: 1 / -1;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-line-row {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-history-row > *,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-line-row > * {
    min-width: 0;
    max-width: 100%;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-filter-actions span,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-filter-actions small,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-history-row strong,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-history-row span,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-history-row small,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-line-row strong,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-line-row span,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-line-row small {
    white-space: normal;
    overflow-wrap: break-word;
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.4;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-history-actions,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-line-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-start;
    gap: 8px;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-history-actions > button,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-line-actions > button {
    flex: 1 1 180px;
    min-width: 0;
    min-height: 44px;
    max-width: 100%;
    white-space: normal;
  }
}

@media screen and (max-width: 420px) {
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-filter-bar,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-history-search,
  body.app-ventas #appShell[data-active-view="purchases"] .purchase-history-row {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.app-ventas #appShell[data-active-view="purchases"] .purchase-filter-bar > .ghost-button {
    width: 100%;
  }

  body.app-ventas #appShell .inventory-search-actions {
    grid-template-columns: minmax(0, 1fr) !important;
  }
  body.app-ventas #appShell .inventory-search-actions .camera-scan-button {
    width: 100% !important;
    min-height: 44px !important;
  }
}

@media screen and (min-width: 761px) and (max-width: 1023px) and (max-height: 500px) {
  /* A landscape phone still needs a drawer; the tablet navigation otherwise
     expands into a thousand-pixel list before the actual module. */
  body.app-ventas #appShell .ventas-workspace {
    display: block !important;
  }
  body.app-ventas #appShell .topbar-actions .user-badge {
    display: none !important;
  }
  body.app-ventas #appShell .ventas-tabs.module-tabs[data-organized] {
    display: none !important;
  }
  body.app-ventas #appShell.ventas-menu-open .ventas-tabs.module-tabs[data-organized] {
    display: flex !important;
    position: fixed !important;
    inset: 58px 8px 8px !important;
    z-index: 140 !important;
    width: auto !important;
    min-width: 0 !important;
    max-height: calc(var(--checkout-height, 100dvh) - 70px) !important;
    margin: 0 !important;
    padding: 10px !important;
    overflow: auto !important;
    background: #fff !important;
  }
  body.app-ventas #appShell.ventas-menu-open .ventas-menu-toggle {
    position: fixed !important;
    inset: 6px 8px auto !important;
    z-index: 150 !important;
    width: auto !important;
    min-height: 44px !important;
    margin: 0 !important;
  }
  body.app-ventas #appShell[data-active-view="sell"] .pos-products .pos-search-row {
    grid-template-columns: minmax(160px, 1fr) auto auto auto !important;
    align-items: end !important;
  }
  body.app-ventas #appShell[data-active-view="sell"] .pos-search-row .touch-search {
    grid-column: 1 !important;
  }
  body.app-ventas #appShell .topbar {
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
  }
  body.app-ventas #appShell .topbar-actions {
    width: auto !important;
  }
}

/* Mobile-only candidate. Append after the existing Ventas styles.
   The shared dialog rule uses two :not(#id) selectors and !important, so a
   plain module class cannot restore scrolling. These selectors deliberately
   target the four affected dialogs with greater specificity; checkout and
   its viewport controller remain untouched. */
@media screen and (max-width: 760px), screen and (max-width: 1023px) and (max-height: 500px) {
  body.app-ventas dialog:is(#catalogSharingModal, #catalogCartModal, #catalogImageModal, #productTaxonomyModal):not(#paymentModal):not(#cartReviewModal) {
    box-sizing: border-box !important;
    position: fixed !important;
    inset: calc(var(--checkout-top, 0px) + 6px) 0 auto !important;
    width: calc(100vw - 12px) !important;
    max-width: calc(100vw - 12px) !important;
    max-height: calc(var(--checkout-height, 100dvh) - 12px) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 auto !important;
  }

  /* Sharing has no .modal-body wrapper: the dialog itself is its scroller.
     Keep every action in that flow instead of clipping the last controls. */
  body.app-ventas dialog#catalogSharingModal:not(#paymentModal):not(#cartReviewModal) {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    padding: 16px 16px max(16px, env(safe-area-inset-bottom)) !important;
    scroll-padding-block: 16px;
  }
  body.app-ventas #catalogSharingModal .catalog-sharing-head,
  body.app-ventas #catalogSharingModal [data-share-controls],
  body.app-ventas #catalogSharingModal .catalog-sharing-actions {
    min-width: 0;
    max-width: 100%;
  }
  body.app-ventas #catalogSharingModal .catalog-sharing-head h2 {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  body.app-ventas #catalogSharingModal .catalog-sharing-actions > * {
    box-sizing: border-box;
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  /* A long catalog cart scrolls only its product list. The existing footer
     occupies a grid row, so its total and actions cannot cover that list. */
  body.app-ventas dialog#catalogCartModal[open]:not(#paymentModal):not(#cartReviewModal) {
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr) auto !important;
    height: calc(var(--checkout-height, 100dvh) - 12px) !important;
    padding: 0 !important;
  }
  body.app-ventas #catalogCartModal .catalog-modal-header {
    min-width: 0;
    padding: 12px;
  }
  body.app-ventas #catalogCartModal .catalog-review-list {
    min-width: 0 !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scroll-padding-block: 12px;
    padding-inline: 12px;
  }
  body.app-ventas #catalogCartModal .catalog-review-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }
  body.app-ventas #catalogCartModal .catalog-review-row > div {
    grid-column: 1 / -1;
  }
  body.app-ventas #catalogCartModal .catalog-review-row > strong {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  body.app-ventas #catalogCartModal .catalog-review-footer {
    position: static !important;
    min-width: 0;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
    gap: 8px;
  }
  body.app-ventas #catalogCartModal .catalog-review-footer > div {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex: 1 1 100%;
    min-width: 0;
    gap: 8px;
  }
  body.app-ventas #catalogCartModal .catalog-review-footer button {
    width: 100%;
    min-width: 0;
    margin: 0;
    min-height: 44px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  body.app-ventas #catalogCartModal .catalog-review-footer button:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  /* Size the image stage from the remaining dialog height, not 68dvh plus
     a separate header and tool strip. Zoom remains inside the image stage. */
  body.app-ventas dialog#catalogImageModal[open]:not(#paymentModal):not(#cartReviewModal) {
    display: grid !important;
    grid-template-rows: auto auto auto minmax(0, 1fr) !important;
    height: calc(var(--checkout-height, 100dvh) - 12px) !important;
    padding: 0 !important;
  }
  body.app-ventas #catalogImageModal .catalog-modal-header {
    padding: 12px;
  }
  body.app-ventas #catalogImageModal .catalog-image-tools {
    gap: 8px;
    padding: 8px 12px;
  }
  body.app-ventas #catalogImageModal [data-catalog-image-status]:empty {
    display: none;
  }
  body.app-ventas #catalogImageModal .catalog-image-stage {
    grid-row: 4;
    min-width: 0 !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: auto !important;
    margin: 0 12px max(12px, env(safe-area-inset-bottom));
  }

  /* Taxonomy has no wrapper between its toolbar and list. Make its existing
     manager one scroll area; a forced 45vh list would still clip the footer
     when the keyboard leaves only a few hundred visible pixels. */
  body.app-ventas dialog#productTaxonomyModal:not(#paymentModal):not(#cartReviewModal) {
    padding: 0 !important;
  }
  body.app-ventas #productTaxonomyModal .taxonomy-manager {
    box-sizing: border-box !important;
    display: block !important;
    width: 100%;
    min-width: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    max-height: calc(var(--checkout-height, 100dvh) - 14px) !important;
    padding: 16px 16px 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    scroll-padding: 12px 12px calc(var(--checkout-actions-height, 68px) + 12px);
  }
  body.app-ventas #productTaxonomyModal .taxonomy-manager > .modal-header {
    position: static !important;
    margin: 0 0 16px !important;
  }
  body.app-ventas #productTaxonomyModal .taxonomy-manager-toolbar {
    min-width: 0;
    margin-bottom: 12px;
  }
  body.app-ventas #productTaxonomyModal .taxonomy-manager-list {
    min-width: 0 !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }
  body.app-ventas #productTaxonomyModal .taxonomy-manager > .modal-actions {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 2;
    margin: 12px 0 0 !important;
    padding: 12px 0 max(12px, env(safe-area-inset-bottom)) !important;
    background: #fff;
  }
  body.app-ventas #productTaxonomyModal .taxonomy-row-actions {
    min-width: 0;
    max-width: 100%;
  }
  body.app-ventas #productTaxonomyModal .taxonomy-manager > .modal-actions button {
    width: 100%;
    margin: 0;
    min-height: 44px;
  }

  body.app-ventas dialog#productModal .modal-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-column: 1 / -1 !important;
    position: sticky !important;
    bottom: 0 !important;
    z-index: 5 !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom)) !important;
    background: #fff !important;
  }
  body.app-ventas dialog#productModal .modal-actions button {
    min-width: 0 !important;
    min-height: 48px !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 7px !important;
    font-size: 14px !important;
    white-space: normal !important;
  }

  /* Keep native fields readable and touch-sized. Do not change payment,
     cart review, scanner sliders, checkboxes or radio geometry. */
  body.app-ventas dialog:not(#paymentModal):not(#cartReviewModal):not(#cameraScanModal) input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]):not([type="file"]),
  body.app-ventas dialog:not(#paymentModal):not(#cartReviewModal):not(#cameraScanModal) select,
  body.app-ventas dialog:not(#paymentModal):not(#cartReviewModal):not(#cameraScanModal) textarea {
    box-sizing: border-box !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 44px !important;
    font-size: 16px !important;
  }
}

/* Phone POS: one navigation layer, readable products and an unobstructed checkout. */
@media screen and (max-width: 760px), screen and (max-width: 1023px) and (max-height: 500px) {
  body.app-ventas #appShell .offline-sales-status.is-resolved-history {
    min-height: 44px !important;
    background: #f4faf7 !important;
    border-color: #d4e5dc !important;
  }
  body.app-ventas #appShell .offline-sales-status.is-resolved-history > strong,
  body.app-ventas #appShell .offline-sales-status.is-resolved-history > span {
    display: none !important;
  }
  body.app-ventas #appShell .touch-pos-head {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    min-height: 0 !important;
    gap: 6px !important;
    padding: 10px !important;
    margin-bottom: 8px !important;
  }
  body.app-ventas #appShell .touch-pos-head h3 {
    margin: 0 !important;
    font-size: 20px !important;
    line-height: 1.2 !important;
  }
  body.app-ventas #appShell .touch-pos-head > div:first-child {
    display: flex !important;
    align-items: center !important;
    min-width: 0 !important;
    width: auto !important;
    gap: 6px !important;
  }
  body.app-ventas #appShell .touch-pos-head .eyebrow,
  body.app-ventas #appShell .touch-shortcuts > span:not(:first-child) {
    display: none !important;
  }
  body.app-ventas #appShell .touch-pos-head .touch-shortcuts {
    min-width: 0 !important;
    margin: 0 !important;
  }
  body.app-ventas #appShell .pos-products .last-sale-receipt {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 7px !important;
    padding: 9px !important;
    margin-bottom: 10px !important;
  }
  body.app-ventas #appShell .last-sale-receipt-main {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 4px 8px !important;
    align-items: baseline !important;
  }
  body.app-ventas #appShell .last-sale-receipt-main > small {
    grid-column: 1 / -1 !important;
    font-size: 12px !important;
    line-height: 1.35 !important;
    white-space: normal !important;
  }
  body.app-ventas #appShell .last-sale-receipt-main > span {
    font-size: 12px !important;
  }
  body.app-ventas #appShell .last-sale-receipt-main > strong {
    font-size: 14px !important;
  }
  body.app-ventas #appShell .last-sale-receipt-actions {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 4px !important;
  }
  body.app-ventas #appShell .last-sale-receipt-actions button {
    min-width: 0 !important;
    min-height: 44px !important;
    width: 100% !important;
    padding: 5px 2px !important;
    font-size: 12px !important;
    line-height: 1.25 !important;
    white-space: normal !important;
  }
  body.app-ventas #appShell .pos-products .pos-search-row {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
    padding: 9px !important;
  }
  body.app-ventas #appShell .pos-search-row .touch-search {
    grid-column: 1 / -1 !important;
    min-width: 0 !important;
    width: 100% !important;
    margin: 0 !important;
  }
  body.app-ventas #appShell .pos-search-row > button {
    min-width: 0 !important;
    min-height: 44px !important;
    padding: 6px 4px !important;
    font-size: 13px !important;
  }
  body.app-ventas #appShell #posOperationNotice {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 9px !important;
  }
  body.app-ventas #appShell #posOperationNotice > strong {
    flex: 1 1 160px !important;
    font-size: 13px !important;
    line-height: 1.35 !important;
  }
  body.app-ventas #appShell #posOperationNotice > button {
    flex: 0 0 auto !important;
    min-height: 44px !important;
    width: auto !important;
    padding: 6px 8px !important;
    font-size: 13px !important;
  }
  body.app-ventas #appShell.ventas-touch-shell[data-active-view="sell"] .pos-mobile-switch.mobile-cashier-actions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    position: static !important;
    width: 100% !important;
    min-width: 0 !important;
    gap: 5px !important;
    padding: 5px !important;
    margin: 0 0 10px !important;
  }
  body.app-ventas #appShell.ventas-touch-shell[data-active-view="sell"] .pos-mobile-switch.mobile-cashier-actions button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    min-width: 0 !important;
    min-height: 44px !important;
    padding: 6px 3px !important;
    font-size: 13px !important;
    white-space: normal !important;
  }
  body.app-ventas #appShell.ventas-touch-shell[data-active-view="sell"] .pos-mobile-switch .ui-ico {
    flex: 0 0 18px !important;
    width: 18px !important;
    min-width: 18px !important;
    height: 18px !important;
  }
  body.app-ventas #appShell.ventas-touch-shell[data-active-view="sell"] .mobile-pos-summary.mobile-cashier-checkout {
    display: grid !important;
    position: fixed !important;
    inset: auto 8px calc(72px + env(safe-area-inset-bottom)) !important;
    z-index: 120 !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr) !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    gap: 5px !important;
    margin: 0 !important;
    padding: 6px 8px 8px !important;
    border-radius: 12px !important;
  }
  body.app-ventas #appShell.ventas-touch-shell[data-active-view="sell"] .mobile-pos-summary.mobile-cashier-checkout .mobile-sale-summary-meta {
    display: flex !important;
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
    align-items: center !important;
    justify-content: space-between !important;
    min-width: 0 !important;
    gap: 8px !important;
  }
  /* The quantity and total already identify this summary; the repeated caption is not an action. */
  body.app-ventas #appShell.ventas-touch-shell[data-active-view="sell"] .mobile-sale-summary-meta > span {
    display: none !important;
  }
  body.app-ventas #appShell.ventas-touch-shell[data-active-view="sell"] .mobile-sale-summary-meta > strong {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    font-size: 14px !important;
    line-height: 1.3 !important;
    overflow-wrap: anywhere !important;
  }
  body.app-ventas #appShell.ventas-touch-shell[data-active-view="sell"] .mobile-pos-summary.mobile-cashier-checkout button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 0 !important;
    min-height: 44px !important;
    width: auto !important;
    max-width: 100% !important;
    padding: 6px !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
    white-space: normal !important;
  }
  body.app-ventas #appShell.ventas-touch-shell[data-active-view="sell"] .mobile-sale-summary-meta .mobile-suspend-sale-button {
    flex: 0 0 auto !important;
    grid-column: auto !important;
    grid-row: auto !important;
    min-height: 44px !important;
  }
  body.app-ventas #appShell.ventas-touch-shell[data-active-view="sell"] .mobile-cart-review-button {
    grid-column: 1 !important;
    grid-row: 2 !important;
    gap: 4px !important;
  }
  body.app-ventas #appShell.ventas-touch-shell[data-active-view="sell"] .mobile-quick-cash-button {
    grid-column: 2 !important;
    grid-row: 2 !important;
  }
  body.app-ventas #appShell.ventas-touch-shell[data-active-view="sell"] #mobileCheckoutBtn {
    grid-column: 3 !important;
    grid-row: 2 !important;
  }
  /* An empty sale has no payment action. The Products/Camera/Cart tabs stay available. */
  body.app-ventas #appShell.ventas-touch-shell[data-active-view="sell"] .mobile-pos-summary.mobile-cashier-checkout.is-empty,
  body.app-ventas #appShell.ventas-touch-shell.ventas-menu-open[data-active-view="sell"] .mobile-pos-summary.mobile-cashier-checkout {
    display: none !important;
  }
  body.app-ventas #appShell[data-active-view="sell"] #mainList {
    padding-bottom: calc(200px + env(safe-area-inset-bottom)) !important;
  }
  body.app-ventas #appShell .offline-sales-status {
    grid-template-columns: minmax(0, 1fr) !important;
    padding: 9px 10px !important;
    margin-bottom: 8px !important;
    gap: 5px !important;
  }
  body.app-ventas #appShell .offline-sales-status > strong,
  body.app-ventas #appShell .offline-sales-status > span,
  body.app-ventas #appShell .pending-sales-detail > summary {
    font-size: 13px !important;
    line-height: 1.35 !important;
  }
  body.app-ventas #appShell .offline-sales-status > .pending-sales-detail {
    margin: 0 !important;
  }
  body.app-ventas #appShell .pos-products .admin-panel-head {
    margin-bottom: 10px !important;
  }
  body.app-ventas #appShell .pos-products .toolbar-search input {
    min-width: 0 !important;
    min-height: 44px !important;
    font-size: 16px !important;
  }
  body.app-ventas #paymentModal .touch-payment-total {
    min-height: 0 !important;
    padding: 12px 14px !important;
    gap: 4px !important;
  }
  body.app-ventas #paymentModal .touch-payment-total > strong {
    font-size: 32px !important;
    line-height: 1.15 !important;
    overflow-wrap: anywhere;
  }
  body.app-ventas #paymentModal .touch-payment-methods {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 6px !important;
  }
  body.app-ventas #paymentModal .touch-payment-methods > button {
    min-width: 0 !important;
    min-height: 64px !important;
    padding: 6px 3px !important;
    gap: 4px !important;
    white-space: normal !important;
  }
  body.app-ventas #paymentModal .touch-payment-methods > button strong {
    font-size: 13px !important;
    line-height: 1.25 !important;
    overflow-wrap: anywhere !important;
  }
  body.app-ventas #paymentModal .touch-payment-methods > button > span {
    min-width: 22px !important;
    width: auto !important;
    height: 22px !important;
    padding: 2px 5px !important;
    line-height: 18px !important;
  }
}

@media screen and (min-width: 761px) and (max-width: 1023px) and (max-height: 500px) {
  /* Landscape phones do not use the portrait bottom navigation. */
  body.app-ventas #appShell.ventas-touch-shell[data-active-view="sell"] .mobile-pos-summary.mobile-cashier-checkout {
    bottom: max(8px, env(safe-area-inset-bottom)) !important;
  }
}
