/* ===== v6.24 mobile ergonomics ===== */
@media (max-width:760px){
  html,
  body{
    max-width:100%;
    overflow-x:hidden;
  }

  .app-shell,
  html[data-sidebar="collapsed"] .app-shell{
    display:block !important;
    grid-template-columns:1fr !important;
  }

  .app-sidebar,
  html[data-sidebar="collapsed"] .app-sidebar{
    position:relative !important;
    top:auto !important;
    height:auto !important;
    width:100% !important;
    min-height:0 !important;
    padding:10px !important;
    overflow:visible !important;
    border-right:0 !important;
    border-bottom:1px solid var(--border);
  }

  .sidebar-top,
  html[data-sidebar="collapsed"] .sidebar-top{
    flex-direction:row !important;
    align-items:center !important;
    gap:8px !important;
    margin-bottom:8px !important;
    padding:0 0 8px !important;
  }

  .sidebar-toggle{
    display:none !important;
  }

  .sidebar-brand,
  .sidebar-top .sidebar-brand,
  html[data-sidebar="collapsed"] .sidebar-top .sidebar-brand{
    flex:1 1 auto !important;
    justify-content:flex-start !important;
    gap:9px !important;
    padding:4px !important;
  }

  .sidebar-brand-mark{
    width:40px !important;
    height:40px !important;
    flex:0 0 40px !important;
    overflow:visible !important;
  }

  .sidebar-brand-mark img{
    width:40px !important;
    height:40px !important;
    object-fit:contain !important;
    border-radius:10px !important;
  }

  .sidebar-brand-text,
  .nav-label,
  .theme-label,
  .power-label,
  .account-label,
  html[data-sidebar="collapsed"] .sidebar-brand-text,
  html[data-sidebar="collapsed"] .nav-label,
  html[data-sidebar="collapsed"] .theme-label,
  html[data-sidebar="collapsed"] .power-label,
  html[data-sidebar="collapsed"] .account-label{
    display:inline !important;
    width:auto !important;
    height:auto !important;
    opacity:1 !important;
    visibility:visible !important;
    clip:auto !important;
    overflow:hidden !important;
    white-space:nowrap !important;
  }

  .side-nav,
  html[data-sidebar="collapsed"] .side-nav{
    display:flex !important;
    flex-direction:row !important;
    gap:8px !important;
    overflow-x:auto !important;
    padding:2px 0 8px !important;
    scroll-snap-type:x proximity;
  }

  .side-nav-group,
  html[data-sidebar="collapsed"] .side-nav-group{
    display:none !important;
  }

  .side-nav a,
  html[data-sidebar="collapsed"] .side-nav a{
    flex:0 0 auto !important;
    width:auto !important;
    min-width:max-content !important;
    min-height:44px !important;
    padding:8px 10px !important;
    justify-content:center !important;
    gap:8px !important;
    scroll-snap-align:start;
    border-radius:10px !important;
  }

  .nav-icon,
  html[data-sidebar="collapsed"] .nav-icon{
    margin:0 !important;
  }

  .sidebar-footer,
  html[data-sidebar="collapsed"] .sidebar-footer{
    display:flex !important;
    flex-direction:row !important;
    align-items:center !important;
    gap:8px !important;
    margin-top:8px !important;
    overflow-x:auto;
  }

  .sidebar-footer .theme-toggle,
  .sidebar-footer .power-btn,
  .account-btn,
  html[data-sidebar="collapsed"] .sidebar-footer .theme-toggle,
  html[data-sidebar="collapsed"] .sidebar-footer .power-btn,
  html[data-sidebar="collapsed"] .account-btn{
    width:auto !important;
    min-height:42px !important;
    flex:0 0 auto;
    padding:0 12px !important;
  }

  .app-content-shell,
  .app-main,
  .card{
    min-width:0 !important;
    max-width:100% !important;
  }

  .workspace-topbar{
    position:relative !important;
    top:auto !important;
    min-height:0 !important;
    padding:10px 12px !important;
    gap:10px !important;
  }

  .workspace-kicker{
    display:none;
  }

  .workspace-title{
    font-size:18px;
    line-height:1.2;
  }

  .workspace-actions{
    width:100%;
    display:grid;
    grid-template-columns:minmax(0, 1fr) auto;
    align-items:center;
    gap:8px;
  }

  .user-chip{
    max-width:none !important;
    min-width:0;
  }

  .quick-sale{
    min-height:42px;
    padding:0 12px !important;
  }

  .app-main{
    padding:10px !important;
  }

  .card{
    padding:14px !important;
    margin-bottom:12px;
    border-radius:8px;
  }

  h1{ font-size:25px; line-height:1.15; }
  h2{ font-size:22px; line-height:1.18; }
  h3{ font-size:17px; line-height:1.25; }

  input,
  select,
  textarea,
  button,
  .btn-primary,
  .btn-secondary,
  a.btn-secondary{
    min-height:42px;
    font-size:16px;
  }

  .grid{
    grid-template-columns:1fr !important;
    gap:12px;
  }

  .module-card{
    padding:14px !important;
  }

  .module-card p{
    line-height:1.38;
  }

  .module-actions,
  .purchase-module-actions{
    display:grid !important;
    grid-template-columns:1fr !important;
    width:100%;
    gap:8px;
  }

  .module-actions .btn-secondary,
  .purchase-module-actions .btn-secondary,
  .purchase-module-actions .products-shortcut{
    width:100% !important;
    min-width:0 !important;
  }

  .form-grid,
  .move-grid,
  .adjust-grid{
    grid-template-columns:1fr !important;
  }

  .home-actions,
  .home-default-location,
  .stock-top-filters,
  .sales-filter-card form,
  #filterForm{
    display:grid !important;
    grid-template-columns:1fr !important;
    align-items:stretch !important;
    gap:8px !important;
  }

  .home-default-location select,
  .stock-top-filters select,
  .stock-filter-chip,
  .sales-product-filter,
  #filterForm label,
  #filterForm input{
    width:100% !important;
    min-width:0 !important;
  }

  .stock-filter-chip{
    height:auto;
    min-height:42px;
  }

  .dataTables_wrapper{
    width:100%;
    max-width:100%;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
  }

  .dataTables_wrapper table.dataTable{
    min-width:760px;
  }

  .dataTables_wrapper .dt-bottom{
    justify-content:center;
    gap:8px;
  }

  .dataTables_wrapper .dt-bottom .dataTables_info{
    width:100%;
    margin-right:0 !important;
    text-align:center;
  }

  .dataTables_wrapper .dataTables_paginate{
    display:flex;
    justify-content:center;
    flex-wrap:wrap;
    gap:4px;
  }

  table.dataTable thead tr.filters input{
    min-height:36px;
    font-size:14px;
  }

  .product-input-wrap .suggestions,
  .suggest-box,
  .suggestions{
    max-width:calc(100vw - 24px) !important;
    max-height:52vh !important;
  }

  .sales-suggest-list,
  #filter_product_suggest,
  #filter_location_suggest{
    width:100% !important;
    left:0 !important;
    right:auto !important;
  }

  .items-table-wrap,
  .stock-table-scroll{
    margin-left:-2px;
    margin-right:-2px;
    padding-bottom:6px;
    overflow-x:auto !important;
    -webkit-overflow-scrolling:touch;
  }

  #itemsTable{
    min-width:920px;
  }

  .stock-actions{
    flex-wrap:wrap !important;
    justify-content:flex-end;
    white-space:normal;
  }

  .stock-action-panel{
    position:fixed !important;
    left:10px !important;
    right:10px !important;
    top:auto !important;
    bottom:10px !important;
    width:auto !important;
    max-width:none !important;
    max-height:calc(100vh - 24px) !important;
    border-radius:12px !important;
    overflow-y:auto !important;
    z-index:22000 !important;
  }
}

@media (max-width:420px){
  .workspace-actions{
    grid-template-columns:1fr;
  }

  .quick-sale,
  .user-chip{
    width:100%;
    justify-content:center;
  }

  .side-nav a,
  html[data-sidebar="collapsed"] .side-nav a{
    padding:8px 9px !important;
  }
}

/* ===== v6.26 mobile table/card pass ===== */
@media (max-width:760px){
  .sales-list-card{
    width:100%;
  }

  .sales-filter-card .small,
  .home-subtitle,
  .module-card p{
    font-size:13px;
  }

  .module-head{
    align-items:flex-start;
  }

  .module-icon{
    width:36px;
    height:36px;
  }

  .workspace-topbar{
    border-bottom:1px solid var(--border);
  }

  .dataTables_wrapper{
    overflow-x:visible;
  }

  .dataTables_wrapper table.dataTable{
    min-width:0;
  }

  #itemsTable{
    min-width:920px !important;
  }

  .stock-table-scroll #stockTable{
    min-width:1180px !important;
  }
}

@media (max-width:640px){
  .card{
    padding:12px !important;
  }

  .mobile-card-table,
  .dataTables_wrapper table.mobile-card-table.dataTable{
    display:block !important;
    width:100% !important;
    min-width:0 !important;
    border:0 !important;
    background:transparent !important;
    border-radius:0 !important;
  }

  .mobile-card-table colgroup,
  .mobile-card-table thead{
    display:none !important;
  }

  .mobile-card-table tbody{
    display:grid !important;
    gap:10px;
  }

  .mobile-card-table tbody tr{
    display:block !important;
    padding:10px 12px;
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:8px;
    box-shadow:0 4px 12px rgba(0,42,74,.05);
  }

  .mobile-card-table tbody tr:hover td{
    background:transparent !important;
  }

  .mobile-card-table tbody tr.month-sep{
    padding:0;
    background:transparent;
    border:0;
    box-shadow:none;
  }

  .mobile-card-table tbody tr.month-sep td{
    display:block !important;
    padding:4px 0 0 !important;
    border:0 !important;
    background:transparent !important;
    color:var(--muted);
    font-weight:900;
  }

  .mobile-card-table tbody tr.month-sep td::before{
    content:none !important;
  }

  .mobile-card-table tbody td{
    display:grid !important;
    grid-template-columns:112px minmax(0, 1fr);
    gap:10px;
    align-items:center;
    min-height:30px;
    padding:6px 0 !important;
    border:0 !important;
    background:transparent !important;
    white-space:normal !important;
  }

  .mobile-card-table tbody td:empty{
    display:none !important;
  }

  .mobile-card-table tbody td::before{
    content:attr(data-label);
    color:var(--muted);
    font-size:11px;
    font-weight:900;
    text-transform:uppercase;
  }

  .mobile-card-table tbody td[data-label="Itens"],
  .mobile-card-table tbody td[data-label="Produto"]{
    grid-template-columns:1fr;
    gap:4px;
  }

  .mobile-card-table tbody td[data-label="Itens"]::before,
  .mobile-card-table tbody td[data-label="Produto"]::before{
    display:none;
  }

  .mobile-card-table .sale-items-single,
  .mobile-card-table .sale-items-details,
  .mobile-card-table .sale-items-details summary{
    max-width:100%;
    width:100%;
  }

  .mobile-card-table .sale-items-popover{
    position:static;
    max-width:none;
    margin-top:8px;
  }

  .dataTables_wrapper .dt-bottom{
    border-top:0;
    margin-top:8px;
    padding-top:0;
  }

  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate{
    font-size:12px;
  }

  .stock-table-scroll{
    overflow-x:auto !important;
  }

  .stock-table-scroll .dataTables_wrapper{
    min-width:1180px;
    overflow-x:visible;
  }

  .stock-table-scroll #stockTable{
    display:table !important;
  }

  .stock-table-scroll #stockTable thead{
    display:table-header-group !important;
  }

  .stock-table-scroll #stockTable tbody{
    display:table-row-group !important;
  }

  .stock-table-scroll #stockTable tr{
    display:table-row !important;
    padding:0;
    border:0;
    box-shadow:none;
  }

  .stock-table-scroll #stockTable td,
  .stock-table-scroll #stockTable th{
    display:table-cell !important;
    padding:8px !important;
    border-bottom:1px solid var(--border) !important;
  }

  .stock-table-scroll #stockTable td::before{
    content:none !important;
  }
}
