/* ==========================================================================
   PADRONIZAÇÃO MOBILE (APENAS DISPOSITIVOS MÓVEIS E TABLETS COMPACTOS <= 768px)
   O layout Desktop (> 768px) permanece 100% inalterado.
   ========================================================================== */
@media (max-width: 768px) {
  html { overflow-x: hidden !important; overscroll-behavior-x: none !important; }
  html body { overflow-x: hidden !important; overscroll-behavior-x: none !important; }
  html, body {
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    -webkit-text-size-adjust: 100%;
  }

  body,
  html body,
  html body.standard-layout,
  html body.finance-page,
  html body.reports-page {
    display: block !important;
    font-size: 12px !important;
  }

  /* 1. MENU LATERAL: Gaveta deslizante (Off-Canvas Drawer) */
  html body .sidebar,
  html body .sidebar.shared-sidebar,
  html body.standard-layout .sidebar,
  html body:has(.sales-content) .sidebar,
  html body:has(.purchase-content) .sidebar,
  html body:has(.clients) .sidebar,
  html body:has(.finance-page) .sidebar,
  html body:has(.products-topbar) .sidebar {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 240px !important;
    min-width: 240px !important;
    max-width: 82vw !important;
    height: 100vh !important;
    min-height: 100vh !important;
    z-index: 999 !important;
    background: #344750 !important;
    transform: translateX(-105%) !important;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    box-shadow: none !important;
  }

  html body.mobile-menu-open .sidebar,
  html body.mobile-menu-open .sidebar.shared-sidebar {
    transform: translateX(0) !important;
    box-shadow: 6px 0 24px rgba(0, 0, 0, 0.38) !important;
  }

  html body .sidebar > .brand,
  html body .sidebar.shared-sidebar .brand {
    display: block !important;
    visibility: visible !important;
    width: 100% !important;
    height: 52px !important;
    min-height: 52px !important;
    max-height: 52px !important;
    background-color: #0d315e !important;
    background-image: url('public/images/TOPO1.png') !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    background-size: 145px auto !important;
  }

  html body .sidebar nav,
  html body .sidebar.shared-sidebar nav {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    padding: 4px 0 24px !important;
    overflow: visible !important;
  }

  html body .sidebar nav a,
  html body .sidebar.shared-sidebar nav a {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    height: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;
    padding: 0 16px !important;
    font-size: 13px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
  }

  /* Backdrop escuro ao abrir o menu no mobile */
  body .mobile-menu-backdrop {
    display: none !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: 998 !important;
    border: 0 !important;
    background: rgba(15, 25, 32, 0.48) !important;
  }
  body.mobile-menu-open .mobile-menu-backdrop {
    display: block !important;
  }

  /* 2. CONTAINER PRINCIPAL: 100% da tela, sem margem de 143px */
  html body main,
  html body main.products-page,
  html body.standard-layout main,
  html body.finance-page main,
  html body.fleet-page main,
  html body.pix-page main,
  html body.reports-page main,
  html body:has(.shared-sidebar) main,
  html body:has(.finance-page) main,
  html body:has(.sales-content) main,
  html body:has(.purchase-content) main,
  html body:has(.clients) main,
  html body.standard-layout:has(.sales-content) main,
  html body.standard-layout:has(.purchase-content) main,
  html body.standard-layout:has(.clients) main {
    display: block !important;
    margin: 0 !important;
    margin-left: 0 !important;
    padding: 0 !important;
    padding-top: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    min-width: 0 !important;
  }

  /* 3. TOPBAR PWA APRIMORADA (Azul marinho com textura automotiva, busca expansível e avatar) */
  html body main > .topbar,
  html body main > .products-topbar,
  html body.standard-layout main > .topbar,
  html body.standard-layout main > .products-topbar,
  html body.finance-page main > .topbar,
  html body.fleet-page main > .topbar,
  html body.pix-page main > .topbar,
  html body.reports-page main > .topbar,
  html body:has(.sales-content) main > .topbar,
  html body:has(.purchase-content) main > .topbar,
  html body:has(.clients) main > .topbar,
  html body:has(.finance-page) main > .topbar,
  html body.standard-layout:has(.sales-content) main > .topbar,
  html body.standard-layout:has(.purchase-content) main > .topbar,
  html body.standard-layout:has(.clients) main > .topbar {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(54px + env(safe-area-inset-top, 0px)) !important;
    min-height: calc(54px + env(safe-area-inset-top, 0px)) !important;
    max-height: none !important;
    padding: env(safe-area-inset-top, 0px) 10px 0 10px !important;
    background-color: #0d315e !important;
    background-image: url('public/images/topo-textura-automotiva.svg?v=2') !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    background-size: cover !important;
    border-bottom: 1px solid rgba(130, 198, 255, 0.24) !important;
    box-shadow: 0 4px 14px rgba(9, 30, 66, 0.34) !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    z-index: 150 !important;
    box-sizing: border-box !important;
    overflow: visible !important;
  }

  /* Remove pseudo-elementos antigos que duplicavam o ícone ☰ e o ↻ vermelho */
  html body main > .topbar:before,
  html body main > .topbar:after,
  html body main > .products-topbar:before,
  html body main > .products-topbar:after {
    content: none !important;
    display: none !important;
  }

  body .mobile-menu-toggle {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    order: 0 !important;
    width: 36px !important;
    height: 36px !important;
    flex: 0 0 36px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.28) !important;
    border-radius: 9px !important;
    background: rgba(255, 255, 255, 0.14) !important;
    color: #fff !important;
    font-size: 19px !important;
    line-height: 1 !important;
    cursor: pointer !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
  }

  html body .topbar .brand-mini,
  html body .products-topbar .brand-mini,
  html body main > .topbar .brand-mini.brand-mini,
  html body main > .products-topbar .brand-mini.brand-mini,
  html body.standard-layout .topbar .brand-mini,
  html body.standard-layout main > .topbar .brand-mini.brand-mini,
  html body.finance-page .topbar .brand-mini,
  html body.finance-page main > .topbar .brand-mini.brand-mini,
  html body.fleet-page main > .topbar .brand-mini.brand-mini,
  html body.pix-page main > .topbar .brand-mini.brand-mini,
  html body.reports-page main > .topbar .brand-mini.brand-mini {
    display: block !important;
    flex: 0 0 104px !important;
    width: 104px !important;
    min-width: 104px !important;
    max-width: 104px !important;
    height: 38px !important;
    min-height: 38px !important;
    background-image: url('public/images/TOPO1.png') !important;
    background-position: left center !important;
    background-repeat: no-repeat !important;
    background-size: 102px auto !important;
    font-size: 0 !important;
    color: transparent !important;
    transition: width 0.16s ease, opacity 0.16s ease !important;
  }

  /* Quando o usuário toca na busca no PWA/Mobile, a barra ganha espaço total */
  html body .topbar.pwa-search-active .brand-mini,
  html body .products-topbar.pwa-search-active .brand-mini,
  html body main > .topbar.pwa-search-active .brand-mini.brand-mini,
  html body.standard-layout main > .topbar.pwa-search-active .brand-mini.brand-mini,
  html body.finance-page main > .topbar.pwa-search-active .brand-mini.brand-mini {
    display: none !important;
  }

  html body .topbar .search,
  html body .products-topbar .products-search,
  html body main > .topbar .search,
  html body main > .products-topbar .products-search,
  html body.standard-layout .topbar .search,
  html body.standard-layout main > .topbar .search,
  html body.finance-page .topbar .search,
  html body.finance-page main > .topbar .search,
  html body.fleet-page main > .topbar .search,
  html body.pix-page main > .topbar .search,
  html body.reports-page main > .topbar .search {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 34px !important;
    margin: 0 !important;
    padding: 0 0 0 12px !important;
    background: rgba(255, 255, 255, 0.97) !important;
    border: 1px solid rgba(199, 211, 232, 0.85) !important;
    border-radius: 18px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    font-size: 12px !important;
    color: #17366f !important;
    overflow: visible !important;
    white-space: nowrap !important;
    position: relative !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22) !important;
  }

  html body .topbar .search .topbar-search-input,
  html body .products-topbar .products-search .topbar-search-input {
    font-size: 12px !important;
    height: 32px !important;
  }

  html body .topbar .search button.topbar-search-btn,
  html body .products-topbar .products-search button.topbar-search-btn,
  html body .topbar .search > button:not(.topbar-search-clear),
  html body .products-topbar .products-search > button:not(.topbar-search-clear) {
    float: none !important;
    margin: 0 !important;
    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    height: 34px !important;
    flex: 0 0 36px !important;
    border-radius: 0 18px 18px 0 !important;
    background: linear-gradient(135deg, #08b8bb 0%, #069699 100%) !important;
    color: #fff !important;
    font-size: 16px !important;
    border: 0 !important;
  }

  html body .topbar .topbar-search-results,
  html body .products-topbar .topbar-search-results {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    top: calc(56px + env(safe-area-inset-top, 0px)) !important;
    width: auto !important;
    max-height: 68vh !important;
    z-index: 320 !important;
  }

  html body main > .topbar .user,
  html body main > .products-topbar .products-user,
  html body main > .products-topbar .user,
  html body .topbar .user,
  html body .products-topbar .products-user {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 38px !important;
    margin: 0 0 0 auto !important;
    padding: 0 !important;
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 38px !important;
    font-size: 0 !important;
    position: relative !important;
    overflow: visible !important;
    z-index: 160 !important;
  }
  html body .topbar .user:before,
  html body .topbar .user:after,
  html body .products-topbar .user:after {
    content: none !important;
    display: none !important;
  }
  html body main > .topbar .user .user-avatar,
  html body main > .products-topbar .user .user-avatar,
  html body .topbar .user .user-avatar,
  html body .products-topbar .user .user-avatar {
    display: block !important;
    position: static !important;
    width: 34px !important;
    height: 34px !important;
    flex: 0 0 34px !important;
    margin: 0 auto !important;
    border: 2px solid rgba(255, 255, 255, 0.9) !important;
  }
  html body main > .topbar .user .user-menu,
  html body main > .products-topbar .user .user-menu,
  html body .topbar .user .user-menu,
  html body .products-topbar .user .user-menu {
    position: fixed !important;
    font-size: 12px !important;
    right: 8px !important;
    left: auto !important;
    top: calc(54px + env(safe-area-inset-top, 0px)) !important;
    width: min(272px, calc(100vw - 16px)) !important;
    min-width: 240px !important;
    max-height: calc(100vh - 118px) !important;
    overflow-y: auto !important;
    z-index: 9999 !important;
  }

  /* 4. BARRA DE TÍTULO DA JANELA (Sempre abaixo da Topbar, nunca ao lado) */
  html body main > .titlebar,
  html body main > .clients-title,
  html body main > .purchase-header,
  html body main > .dashboard-title,
  html body main > .finance-title,
  html body main > .fleet-title,
  html body main > .products-title,
  html body main > .reports-title,
  html body main > .config-title,
  html body .product-top,
  html body .service-top,
  html body .buyer-head {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    min-height: 46px !important;
    height: auto !important;
    max-height: none !important;
    padding: 8px 12px !important;
    background-color: #5e7d89 !important;
    color: #fff !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    font-size: 15px !important;
    z-index: 40 !important;
    box-sizing: border-box !important;
  }
  html body.standard-layout main > .titlebar,
  html body.standard-layout main > .finance-title,
  html body.finance-page main > .finance-title,
  html body.fleet-page main > .fleet-title,
  html body.reports-page main > .reports-title {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
  }

  html body .titlebar button,
  html body .finance-title button,
  html body .clients-title button,
  html body .purchase-header button,
  html body .products-title button,
  html body .config-title button {
    padding: 6px 10px !important;
    font-size: 11px !important;
    margin-left: 4px !important;
    height: auto !important;
  }

  /* 5. CONTEÚDO DAS JANELAS PADRONIZADO */
  html body .dashboard,
  html body .finance-content,
  html body .sales-content,
  html body .purchase-content,
  html body .products-content,
  html body .fleet-content,
  html body .reports-content,
  html body .pix-content,
  html body .clients,
  html body .config-body,
  html body .new-client,
  html body .buyer-page {
    padding: 12px 10px calc(92px + env(safe-area-inset-bottom, 0px)) !important;
    width: 100% !important;
    max-width: 100vw !important;
    background: #e7edf9 !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  html body main > .sales-content:before {
    display: none !important;
  }

  /* 6. ABAS HORIZONTAIS PADRONIZADAS (Deslizáveis por toque, sem empilhar) */
  html body .tabs,
  html body main > .sales-content > .tabs,
  html body .finance-tabs,
  html body .purchase-tabs,
  html body .client-tabs,
  html body .product-tabs,
  html body .categories,
  html body .buyer-tabs,
  html body .fleet-tabs,
  html body .service-tabs {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    width: 100% !important;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x !important;
    scrollbar-width: none !important;
    gap: 4px !important;
    margin: 0 !important;
    padding: 0 4px !important;
    box-sizing: border-box !important;
  }

  html body .tabs::-webkit-scrollbar,
  html body .finance-tabs::-webkit-scrollbar,
  html body .purchase-tabs::-webkit-scrollbar,
  html body .client-tabs::-webkit-scrollbar,
  html body .product-tabs::-webkit-scrollbar,
  html body .categories::-webkit-scrollbar,
  html body .buyer-tabs::-webkit-scrollbar,
  html body .fleet-tabs::-webkit-scrollbar,
  html body .service-tabs::-webkit-scrollbar {
    display: none !important;
  }

  html body .tabs .tab,
  html body .finance-tabs button,
  html body .purchase-tab,
  html body .client-tabs button,
  html body .product-tabs button,
  html body .categories button,
  html body .buyer-tabs button,
  html body .fleet-tabs button,
  html body .service-tabs button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: max-content !important;
    height: 38px !important;
    min-height: 38px !important;
    max-height: 38px !important;
    padding: 0 14px !important;
    margin: 0 !important;
    font-size: 11px !important;
    white-space: nowrap !important;
    border-radius: 4px 4px 0 0 !important;
    cursor: pointer !important;
    touch-action: manipulation !important;
    user-select: none !important;
  }

  /* 7. BARRAS DE FERRAMENTAS (TOOLBARS) PADRONIZADAS SEM ESTOURAR A LARGURA */
  html body .toolbar,
  html body main > .sales-content > .toolbar,
  html body .finance-toolbar,
  html body .purchase-toolbar,
  html body .collections-toolbar,
  html body .client-toolbar,
  html body .product-toolbar {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 46px !important;
    padding: 10px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 6px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
  }

  html body .collections-toolbar select,
  html body .collections-toolbar input,
  html body .purchase-toolbar select,
  html body .purchase-toolbar input,
  html body .client-toolbar input,
  html body .product-toolbar input,
  html body .toolbar input {
    flex: 1 1 135px !important;
    width: auto !important;
    min-width: 120px !important;
    max-width: 100% !important;
    height: 34px !important;
    font-size: 12px !important;
  }

  html body .finance-balance {
    margin: 2px 0 !important;
    padding: 6px 10px !important;
    flex: 1 1 100% !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    text-align: left !important;
    box-sizing: border-box !important;
  }
  html body .finance-balance br {
    display: none !important;
  }
  html body .finance-toolbar button,
  html body .finance-toolbar .finance-month,
  html body .finance-toolbar .finance-arrows {
    height: 32px !important;
    min-height: 32px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  html body .finance-toolbar > span {
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #416276 !important;
    white-space: nowrap !important;
  }
  html body .finance-edit-options,
  html body .finance-receive-menu {
    min-width: 0 !important;
    width: min(320px, calc(100vw - 36px)) !important;
    max-width: calc(100vw - 36px) !important;
    left: 0 !important;
  }
  html body .finance-edit-options button,
  html body .finance-receive-menu button {
    width: 100% !important;
    height: auto !important;
    min-height: 32px !important;
    white-space: normal !important;
    line-height: 1.35 !important;
    padding: 8px 12px !important;
    justify-content: flex-start !important;
  }

  /* 8. TABELAS PADRONIZADAS (Colunas reais preservadas com rolagem horizontal fluida) */
  html body .sales-table-wrapper,
  html body .purchase-table-wrapper,
  html body .client-table-wrapper,
  html body .finance-table-wrapper,
  html body .table-responsive,
  html body .clients,
  html body .finance-panel,
  html body #finance-receivables,
  html body #finance-other,
  html body .purchase-panel,
  html body #purchases-panel,
  html body #collections-panel,
  html body .client-panel,
  html body .product-panel,
  html body .fleet-panel,
  html body .panel {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
  }
  html body #finance-receivables:has(> .table-responsive),
  html body #finance-other:has(.table-responsive) {
    overflow-x: visible !important;
  }
  html body .satellite-panel {
    margin: 14px 0 24px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }
  html body .satellite-controls {
    flex-wrap: wrap !important;
  }

  html body .sales-table,
  html body .finance-table,
  html body .finance-panel table,
  html body .purchase-table,
  html body .client-table,
  html body .product-table,
  html body .service-table,
  html body .user-table {
    display: table !important;
    width: 100% !important;
    min-width: 640px !important;
    table-layout: auto !important;
    border-collapse: collapse !important;
  }
  html body .sales-table-wrapper,
  html body .purchase-table-wrapper,
  html body .client-table-wrapper,
  html body .finance-table-wrapper,
  html body .table-responsive {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
    margin: 0 0 12px 0 !important;
  }

  html body .sales-table thead,
  html body .finance-table thead,
  html body .finance-panel table thead,
  html body .purchase-table thead,
  html body .client-table thead,
  html body .product-table thead,
  html body .service-table thead,
  html body .user-table thead {
    display: table-header-group !important;
  }

  html body .sales-table tbody,
  html body .finance-table tbody,
  html body .finance-panel table tbody,
  html body .purchase-table tbody,
  html body .client-table tbody,
  html body .product-table tbody,
  html body .service-table tbody,
  html body .user-table tbody {
    display: table-row-group !important;
  }

  html body .sales-table tr,
  html body .finance-table tr,
  html body .finance-panel table tr,
  html body .purchase-table tr,
  html body .client-table tr,
  html body .product-table tr,
  html body .service-table tr,
  html body .user-table tr {
    display: table-row !important;
    height: auto !important;
  }

  html body .sales-table th,
  html body .sales-table td,
  html body .finance-table th,
  html body .finance-table td,
  html body .finance-panel table th,
  html body .finance-panel table td,
  html body .purchase-table th,
  html body .purchase-table td,
  html body .client-table th,
  html body .client-table td,
  html body .product-table th,
  html body .product-table td,
  html body .service-table th,
  html body .service-table td,
  html body .user-table th,
  html body .user-table td {
    display: table-cell !important;
    padding: 9px 10px !important;
    font-size: 12px !important;
    line-height: 1.35 !important;
    white-space: nowrap !important;
    vertical-align: middle !important;
  }

  html body .sales-table thead th:nth-child(2):after,
  html body .finance-table thead th:nth-child(2):after,
  html body .finance-panel table thead th:nth-child(2):after,
  html body .purchase-table thead th:nth-child(2):after,
  html body .product-table thead th:nth-child(2):after,
  html body .service-table thead th:nth-child(2):after {
    content: none !important;
  }

  html body .finance-total,
  html body .finance-payable-total,
  html body .finance-payables-total,
  html body .finance-transfers-total,
  html body .finance-receipts-total,
  html body .finance-footer {
    min-width: 0 !important;
    width: 100% !important;
    padding: 10px 12px !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    box-sizing: border-box !important;
  }

  /* 9. INDICADORES E FORMULÁRIOS / MODAIS PADRONIZADOS */
  html body .dash-metrics,
  html body .fleet-metrics {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    margin: 0 0 14px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  html body .dash-card,
  html body .fleet-metric {
    margin: 0 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  html body .dash-grid,
  html body .dash-cat-box,
  html body .reports-content {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
    margin: 0 0 14px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  html body .dash-grid > div,
  html body .report-left {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  html body .new-purchase,
  html body .finance-form-overlay,
  html body .transfer-form-overlay,
  html body .recurrence-form-overlay,
  html body .receipt-form-overlay,
  html body .receipt-history-overlay,
  html body .conciliation-upload-overlay,
  html body .stock-adjust-modal,
  html body .account-modal,
  html body .user-modal-overlay,
  html body .collection-modal {
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: 100vh !important;
    z-index: 240 !important;
  }
  html body .finance-form-overlay,
  html body .transfer-form-overlay,
  html body .recurrence-form-overlay,
  html body .receipt-form-overlay,
  html body .receipt-history-overlay,
  html body .conciliation-upload-overlay {
    background: #f1f5fd !important;
    padding: 0 0 calc(28px + env(safe-area-inset-bottom, 0px)) 0 !important;
    box-sizing: border-box !important;
  }
  html body .finance-form-actions,
  html body .transfer-form-actions,
  html body .recurrence-form-actions,
  html body .receipt-form-actions {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 15 !important;
    background: #ffffff !important;
    border-top: 1px solid #c7d3e8 !important;
    padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px)) !important;
    margin-top: 12px !important;
    box-shadow: 0 -2px 10px rgba(23, 54, 111, 0.08) !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    box-sizing: border-box !important;
  }
  html body #newSale,
  html body .new-sale,
  html body .return-wizard {
    position: relative !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: auto !important;
    z-index: 1 !important;
    background: #e7edf9 !important;
    padding: 12px 12px calc(96px + env(safe-area-inset-bottom, 0px)) !important;
    box-sizing: border-box !important;
  }
  html body #newSale .actions,
  html body .return-wizard .return-actions,
  html body .new-client .actions,
  html body .buyer-actions {
    position: relative !important;
    z-index: 2 !important;
    background: #f1f5fd !important;
    border: 1px solid #c7d3e8 !important;
    border-radius: 8px !important;
    padding: 12px !important;
    margin-top: 16px !important;
    margin-bottom: 8px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
    gap: 8px !important;
    box-shadow: 0 2px 8px rgba(23, 54, 111, 0.08) !important;
    box-sizing: border-box !important;
  }
  html body #newSale .actions button,
  html body .return-wizard .return-actions button,
  html body .new-client .actions button,
  html body .buyer-actions button {
    flex: 1 1 auto !important;
    min-height: 36px !important;
    border-radius: 5px !important;
  }
  html body .product-body,
  html body .service-body {
    background: #e7edf9 !important;
    padding: 14px 10px calc(136px + env(safe-area-inset-bottom, 0px)) !important;
    box-sizing: border-box !important;
  }
  html body .footer-actions,
  html body .service-footer {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: calc(54px + env(safe-area-inset-bottom, 0px)) !important;
    z-index: 215 !important;
    background: #ffffff !important;
    border-top: 1px solid #c7d3e8 !important;
    padding: 10px 12px !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.12) !important;
    box-sizing: border-box !important;
  }

  html body .form-grid,
  html body .finance-form-grid,
  html body .purchase-form-grid,
  html body .user-form-grid,
  html body .perm-grid,
  html body .account-grid,
  html body .grid-2,
  html body .grid-3,
  html body .grid-4,
  html body .grid-address {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    padding: 12px !important;
  }
  html body .form-grid label,
  html body .finance-form-field.half,
  html body .finance-form-field.wide {
    grid-column: 1 / -1 !important;
  }
  html body .cart-head,
  html body .finance-head {
    display: none !important;
  }
  html body .cart-row,
  html body .installment {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    padding: 8px 0 !important;
  }
  html body .cart-row .product-wrap {
    grid-column: 1 / -1 !important;
  }

  /* Modal de Compras Mobile (Full viewport, scroll suave, sem overflow quebrado) */
  html body .new-purchase {
    inset: 0 !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    height: 100% !important;
    max-height: 100vh !important;
    z-index: 235 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  html body .new-purchase .purchase-modal-head {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
  }
  html body .new-purchase .purchase-form {
    padding: 12px 14px !important;
  }
  html body .new-purchase .purchase-section {
    padding: 12px !important;
    margin-top: 12px !important;
  }
  html body .new-purchase .purchase-section > label {
    display: flex !important;
    width: 100% !important;
    margin-right: 0 !important;
  }
  html body .new-purchase .purchase-wide {
    width: 100% !important;
  }
  html body .new-purchase .external-values {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }
  html body .new-purchase .external-values label {
    width: 100% !important;
  }
  html body .new-purchase .products-section {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 8px !important;
  }
  html body .new-purchase .product-head,
  html body .new-purchase .purchase-product {
    min-width: 780px !important;
  }
  html body .new-purchase .purchase-finance {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  html body .new-purchase .finance-head-purchase,
  html body .new-purchase .finance-row-purchase {
    min-width: 680px !important;
  }
  html body .new-purchase .finance-options {
    position: fixed !important;
    inset: auto 12px 60px 12px !important;
    width: auto !important;
    max-width: 320px !important;
    margin: 0 auto !important;
  }
  html body .new-purchase .purchase-actions {
    position: sticky !important;
    bottom: 0 !important;
    background: #f2f3f4 !important;
    z-index: 10 !important;
    padding: 12px 14px !important;
  }

  /* Modal de Coletas / Visitas Mobile */
  html body .collection-modal {
    padding: 0 !important;
    align-items: stretch !important;
    z-index: 250 !important;
  }
  html body .collection-modal .collection-dialog,
  html body .collection-modal .visit-hub-dialog {
    width: 100% !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  html body .collection-modal .visit-step-body {
    padding: 12px !important;
    -webkit-overflow-scrolling: touch !important;
  }
  html body .collection-modal .visit-app-footer {
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  }
  html body .collection-modal .collection-form {
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 12px !important;
  }
  html body .collection-modal .collection-form-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  html body .collection-modal .collection-items {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  html body .collection-modal .collection-item-head,
  html body .collection-modal .collection-item-row {
    min-width: 560px !important;
  }

  /* 12. BARRA DE NAVEGAÇÃO INFERIOR PWA (BOTTOM NAVIGATION) */
  html body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    background-color: #e7edf9 !important;
  }

  .pwa-bottom-nav {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: calc(54px + env(safe-area-inset-bottom, 0px)) !important;
    background: #2b3b44 !important;
    background-color: #2b3b44 !important;
    opacity: 1 !important;
    border-top: 1px solid #3d4f59 !important;
    z-index: 225 !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.24) !important;
    justify-content: space-around !important;
    align-items: center !important;
    padding: 0 2px env(safe-area-inset-bottom, 0px) !important;
    box-sizing: border-box !important;
    margin: 0 !important;
  }

  .pwa-bottom-nav .pwa-nav-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 1 0 !important;
    height: 100% !important;
    text-decoration: none !important;
    color: #9cb1bc !important;
    font-size: 10px !important;
    font-weight: 600 !important;
    background: transparent !important;
    border: 0 !important;
    padding: 4px 0 2px !important;
    margin: 0 !important;
    cursor: pointer !important;
    gap: 3px !important;
    line-height: 1 !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  .pwa-bottom-nav .pwa-nav-item.active {
    color: #00d982 !important;
  }

  .pwa-bottom-nav .pwa-nav-item img,
  .pwa-bottom-nav .pwa-nav-item .pwa-nav-icon {
    width: 20px !important;
    height: 20px !important;
    max-width: 20px !important;
    max-height: 20px !important;
    object-fit: contain !important;
    pointer-events: none !important;
  }

  .pwa-bottom-nav .pwa-nav-item.active img {
    filter: drop-shadow(0 0 2px #00d982) !important;
  }

  .pwa-bottom-nav .pwa-nav-icon-text {
    font-size: 19px !important;
    line-height: 1 !important;
    display: block !important;
    height: 20px !important;
  }

  /* 13. BANNER DE INSTALAÇÃO PWA */
  .pwa-install-banner {
    position: fixed;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 230;
    background: #344750;
    color: #fff;
    border-radius: 6px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    font-size: 12px;
    animation: pwaSlideDown 0.3s ease-out;
  }
  @keyframes pwaSlideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
  .pwa-install-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
  }
  .pwa-install-info img {
    width: 28px;
    height: 28px;
    border-radius: 4px;
  }
  .pwa-install-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .pwa-install-confirm {
    background: #00d982;
    border: 0;
    border-radius: 4px;
    color: #1a3328;
    font-weight: bold;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 11px;
  }
  .pwa-install-close {
    background: transparent;
    border: 0;
    color: #b0c2cb;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
  }
}

@media (max-width: 480px) {
  html body .dash-metrics {
    grid-template-columns: 1fr !important;
  }
}

/* PWA: mantém toda a página arrastável, inclusive abaixo da barra inferior. */
@media (max-width: 768px) {
  html {
    height: auto !important;
    min-height: 100% !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain !important;
  }
  html body {
    height: auto !important;
    min-height: 100vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    position: relative !important;
  }
  html body main,
  html body main.products-page,
  html body:has(.shared-sidebar) main {
    height: auto !important;
    min-height: calc(100vh - 54px) !important;
    overflow: visible !important;
  }
  html body .dashboard,
  html body .finance-content,
  html body .sales-content,
  html body .purchase-content,
  html body .products-content,
  html body .fleet-content,
  html body .reports-content,
  html body .pix-content,
  html body .clients,
  html body .config-body,
  html body .new-client,
  html body .buyer-page {
    height: auto !important;
    min-height: calc(100vh - 104px) !important;
    overflow: visible !important;
    background: #e7edf9 !important;
    padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)) !important;
  }
  html body .dash-grid {
    overflow: visible !important;
  }
  html body .dash-panel {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }
  html body .pwa-bottom-nav {
    bottom: 0 !important;
    position: fixed !important;
  }

  /* Indicadores: encaixe 100% na largura da tela física do celular sem ocultar informações à direita. */
  html body .dashboard {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
    touch-action: pan-y !important;
  }
  html body .dashboard-title,
  html body .dash-panel > h3 {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 4px 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  html body .dashboard-title > span,
  html body .dash-panel > h3 > span:first-child {
    min-width: 0 !important;
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }
  html body .dashboard-title small,
  html body .dash-panel > h3 small {
    display: block !important;
    width: 100% !important;
    margin: 2px 0 0 !important;
    text-align: left !important;
    white-space: normal !important;
  }
  html body .dash-notices,
  html body .dash-notices > #dash-notices-body {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }
  html body .dash-notices p {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 4px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 10px 12px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
  }
  html body .dash-notices p > span {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }
  html body .dash-notices p > a {
    display: block !important;
    width: auto !important;
    align-self: flex-end !important;
    margin: 2px 0 0 auto !important;
    text-align: right !important;
  }
  html body .dash-chart {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 236px !important;
    padding: 26px 12px 10px !important;
    gap: 12px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
    scroll-behavior: smooth;
  }
  html body .dash-chart::-webkit-scrollbar {
    height: 4px !important;
  }
  html body .dash-chart::-webkit-scrollbar-thumb {
    background: #cbd6e2 !important;
    border-radius: 2px !important;
  }
  html body .dash-chart .dash-bar {
    flex: 0 0 auto !important;
    width: 58px !important;
    min-width: 58px !important;
    max-width: 58px !important;
  }
  html body .dash-chart .dash-bar-val {
    font-size: 8.5px !important;
    transform: translateY(-22px) !important;
    margin-bottom: -17px !important;
    white-space: nowrap !important;
    letter-spacing: -0.2px !important;
  }
  html body .dash-chart .dash-bar-val .bar-val-full {
    display: none !important;
  }
  html body .dash-chart .dash-bar-val .bar-val-compact {
    display: inline !important;
  }
  html body .dash-chart .dash-bar i {
    width: 56% !important;
  }
  html body .dash-chart .dash-bar i::before {
    height: 5px !important;
    top: -5px !important;
  }
  html body .dash-chart .dash-bar i::after {
    width: 5px !important;
    right: -5px !important;
    top: -3px !important;
  }
  html body .dash-chart .dash-bar span {
    font-size: 9.5px !important;
    white-space: nowrap !important;
  }
  html body .dash-chart .dash-bar small {
    font-size: 8px !important;
    white-space: nowrap !important;
    text-align: center !important;
  }
  html body .dash-top-products {
    display: table !important;
    table-layout: fixed !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    white-space: normal !important;
    overflow: visible !important;
    border-collapse: collapse !important;
  }
  html body .dash-top-products thead {
    display: table-header-group !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  html body .dash-top-products tbody {
    display: table-row-group !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  html body .dash-top-products tr {
    display: table-row !important;
    width: 100% !important;
  }
  html body .dash-top-products th,
  html body .dash-top-products td {
    display: table-cell !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    padding: 8px 8px !important;
    font-size: 11px !important;
    vertical-align: middle !important;
  }
  html body .dash-top-products th:nth-child(1),
  html body .dash-top-products td:nth-child(1) {
    width: 44% !important;
    text-align: left !important;
  }
  html body .dash-top-products th:nth-child(2),
  html body .dash-top-products td:nth-child(2) {
    width: 22% !important;
    text-align: center !important;
  }
  html body .dash-top-products th:nth-child(3),
  html body .dash-top-products td:nth-child(3) {
    width: 34% !important;
    text-align: right !important;
  }
  html body .dash-cat-box {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 14px 10px !important;
    gap: 12px !important;
    box-sizing: border-box !important;
  }
  html body .dash-cat-legend {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  html body .dash-cat-item {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  html body .dash-cat-item > span {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }
  html body .dash-cat-item > b {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
  }
  html body .dash-fin-summary {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 10px 12px !important;
    box-sizing: border-box !important;
  }
  html body .dash-fin-summary div {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    width: 100% !important;
    min-width: 0 !important;
  }
  html body .audit-filters {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    display: flex !important;
    gap: 4px !important;
    margin-top: 4px !important;
  }
  html body .audit-list {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }
  html body .audit-row {
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) auto !important;
    gap: 8px !important;
    padding: 9px 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    align-items: center !important;
  }
  html body .audit-info,
  html body .audit-info strong,
  html body .audit-info small {
    min-width: 0 !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    white-space: normal !important;
  }
  html body .audit-val {
    grid-column: auto !important;
    text-align: right !important;
    white-space: nowrap !important;
    font-size: 11px !important;
  }
}

@media (min-width: 769px) {
  .mobile-menu-toggle,
  .mobile-menu-backdrop,
  .pwa-bottom-nav,
  .pwa-install-banner {
    display: none !important;
  }
}

@media print {
  .mobile-menu-toggle,
  .mobile-menu-backdrop,
  .mobile-drawer,
  .pwa-bottom-nav,
  .pwa-install-banner,
  #pwaInstallBanner {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
  }
}
