/* Celular e tablet estreito: mesmas funções, layout empilhado e alvos de toque grandes. */

.sidebar-fundo {
  display: none;
}
.ordem-movel {
  display: none;
}

@media (max-width: 760px) {
  /* Menu lateral vira gaveta com fundo escurecido */
  .sidebar {
    width: min(82vw, 290px);
  }
  .sidebar.aberta {
    box-shadow: 0 0 40px rgba(30, 35, 24, 0.35);
  }
  .sidebar.aberta ~ .sidebar-fundo {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(30, 35, 24, 0.45);
    z-index: 35;
  }
  .nav-item {
    padding: 12px;
    font-size: 15px;
  }
  .btn-home-side {
    padding: 12px;
    font-size: 15px;
  }

  /* Barra do topo enxuta */
  .topbar {
    padding: 0 10px;
    gap: 8px;
  }
  .topbar .titulo-pagina {
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-esq {
    min-width: 0;
    gap: 6px;
  }
  .rot-btn {
    display: none;
  }
  #abreMenu {
    min-width: 44px;
    height: 44px;
    font-size: 22px;
  }
  .conteudo {
    padding: 12px;
  }

  /* 16px nos campos: o iPhone não dá zoom ao tocar */
  .input,
  .fu-bar .input,
  .ra-bar .input {
    font-size: 16px;
    height: 46px;
  }
  .btn,
  .fu-bar .btn,
  .ra-bar > .campo > .btn {
    min-height: 44px;
    height: auto;
    font-size: 15px;
  }
  .btn-sm {
    min-height: 40px;
    font-size: 14px;
  }

  /* Formulário da contagem em grade de 2 colunas */
  .ra-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 14px;
  }
  .ra-bar .campo,
  .ra-bar .campo-cod,
  .ra-bar .campo-desc,
  .ra-bar .campo-num,
  .ra-bar .campo-data {
    min-width: 0;
    width: auto;
  }
  .ra-bar .campo-cod,
  .ra-bar .campo-desc,
  .ra-bar .ra-acao {
    grid-column: 1 / -1;
  }
  .ra-bar .ra-acao > label {
    display: none;
  }
  .ra-bar .ra-acao .btn {
    width: 100%;
    justify-content: center;
  }
  .opcoes-produto {
    width: 100%;
    max-width: none;
  }
  .opcao-produto {
    padding: 13px 14px;
    font-size: 15px;
  }

  /* Barras de filtro */
  .fu-bar {
    gap: 10px;
  }
  .fu-bar .g,
  .fu-bar .g-cod {
    width: 100%;
    min-width: 0;
  }
  .fu-bar .g-acao .btn {
    flex: 1;
    justify-content: center;
  }
  .fu-presets {
    width: 100%;
    height: 44px;
  }
  .fu-presets a {
    flex: 1;
    justify-content: center;
    padding: 0 6px;
    font-size: 14px;
  }

  /* Cartões, cabeçalhos e confirmações */
  .cd {
    padding: 14px;
  }
  .cd-tabela {
    padding: 0;
  }
  .cd-cab {
    padding: 12px 14px;
  }
  .confirma-bar {
    justify-content: stretch;
  }
  .confirma-bar span {
    flex-basis: 100%;
  }
  .confirma-bar .btn {
    flex: 1;
    justify-content: center;
  }
  .inv-faixa {
    padding: 10px 12px;
  }
  .btn-icone {
    min-width: 44px;
    height: 44px;
  }
  .cd-cab .menu-tabela .btn {
    min-width: 44px;
  }
  .menu-tabela-lista {
    min-width: 220px;
  }
  .menu-tabela-item {
    padding: 14px;
    font-size: 15px;
  }

  /* Tabela de inventários vira lista de cartões */
  .tabela-cartoes thead {
    display: none;
  }
  .tabela-cartoes,
  .tabela-cartoes tbody,
  .tabela-cartoes tr,
  .tabela-cartoes td {
    display: block;
    width: 100%;
  }
  .tabela-cartoes tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--borda);
  }
  .tabela-cartoes td {
    border: 0;
    padding: 3px 0;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    text-align: right;
    white-space: normal;
  }
  .tabela-cartoes td::before {
    content: attr(data-rotulo);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--texto-secundario);
    text-align: left;
    flex: none;
    padding-top: 2px;
  }
  .tabela-cartoes td.col-nome {
    font-size: 16px;
  }
  /* Cartões das tabelas de contagem: o nome do produto vem primeiro e destacado */
  .tabela-cartoes tr {
    display: flex;
    flex-direction: column;
  }
  .tabela-cartoes td.col-desc {
    order: -1;
    display: block;
    text-align: left;
    font-weight: 600;
    font-size: 15px;
    padding-bottom: 6px;
    min-width: 0;
  }
  .tabela-cartoes td.col-desc::before {
    display: none;
  }
  .tabela-cartoes td:empty {
    display: none;
  }
  .tabela-cartoes td.col-acao {
    width: 100%;
    justify-content: flex-end;
  }
  .tabela-cartoes td.col-acao::before {
    display: none;
  }
  .tabela-cartoes td.total-cod {
    font-size: 17px;
  }
  .tabela-cartoes td.col-acoes {
    display: block;
    padding-top: 10px;
  }
  .tabela-cartoes td.col-acoes::before {
    display: none;
  }
  .acoes-inv {
    justify-content: stretch;
  }
  .acoes-inv .btn {
    flex: 1;
    justify-content: center;
  }

  /* Tabelas largas rolam de lado */
  .cd-tabela .tabela td.col-desc,
  .cd-tabela .tabela th.col-desc {
    min-width: 200px;
  }
  .tabela td,
  .tabela th {
    padding: 10px;
  }

  /* Barra "Ordenar por": no celular o cabeçalho da tabela some, então a ordem vai aqui */
  .ordem-movel {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 14px;
    border-bottom: 1px solid var(--borda);
    font-size: 13px;
    color: var(--texto-secundario);
  }
  .ordem-movel a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--borda);
    border-radius: var(--raio-full);
    color: var(--texto-suave);
    text-decoration: none;
    font-weight: 500;
  }
  .ordem-movel a.on {
    background: var(--cor-primaria-suave);
    border-color: var(--cor-primaria);
    color: var(--cor-primaria-escura);
    font-weight: 600;
  }
}
