/* ═══ MOBILE / RESPONSIVE — Vendas System ════════════════════════════════
   Complemento do app.css para melhorar a UX em telas pequenas.
   Não sobrescreve o app.css; apenas adiciona ajustes específicos para mobile.
══════════════════════════════════════════════════════════════════════════ */

/* ── Sidebar: transição suave ao abrir/fechar em mobile ────────────────── */
@media (max-width: 991px) {
  .sidebar {
    transition: margin-left 0.25s ease, visibility 0.25s ease !important;
  }

  /* Overlay ao abrir o sidebar é visível imediatamente */
  .main-wrapper::before {
    transition: opacity 0.25s ease !important;
  }
}

/* ── Breadcrumb + botão lado-a-lado ─────────────────────────────────────
   Muitas páginas colocam <div> dentro de <ol class="breadcrumb"> para
   posicionar um botão à direita. Esta regra organiza isso corretamente. */
.page-breadcrumb .breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
}
.page-breadcrumb .breadcrumb > div {
  margin-left: auto;
  padding: 0;
  text-align: right;
}
.page-breadcrumb .breadcrumb > div .btn + .btn {
  margin-left: 0.35rem;
}

@media (max-width: 575px) {
  .page-breadcrumb .breadcrumb > div .btn {
    font-size: 0.78rem;
    padding: 0.25rem 0.55rem;
  }
}

/* ── Nav tabs: scroll horizontal em mobile ──────────────────────────────
   Impede quebra de linha nas abas e permite scroll suave horizontal. */
.nav-tabs {
  flex-wrap: nowrap !important;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 1px; /* mostra a borda ativa */
}
.nav-tabs::-webkit-scrollbar {
  display: none;
}
.nav-tabs .nav-link {
  white-space: nowrap;
}

/* ── iOS: previne zoom automático ao focar em input ─────────────────────
   O iOS faz zoom quando font-size < 16px em inputs. */
@media (max-width: 767px) {
  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="tel"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* ── Botões em tabelas: touch targets maiores (mínimo ~34px) ────────────
   Feather icons muito pequenos são difíceis de tocar em mobile. */
@media (max-width: 767px) {
  .table .btn-sm {
    min-height: 34px;
    min-width: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.45rem;
  }

  .table td {
    vertical-align: middle;
  }

  /* Grupos de ação: permite quebra de linha se necessário */
  .table td > .d-flex {
    flex-wrap: wrap;
    gap: 0.3rem !important;
  }
}

/* ── Tabela: fonte menor em phones pequenos ─────────────────────────────── */
@media (max-width: 575px) {
  .table {
    font-size: 0.79rem;
  }
  .table th,
  .table td {
    padding: 0.4rem 0.35rem;
  }
}

/* ── DataTables: controles empilhados em mobile ─────────────────────────── */
@media (max-width: 767px) {
  .dataTables_wrapper > .row:first-child > div,
  .dataTables_wrapper > .row:last-child > div {
    width: 100% !important;
    text-align: left !important;
    float: none !important;
  }

  .dataTables_wrapper .dataTables_filter {
    text-align: left !important;
  }

  .dataTables_wrapper .dataTables_filter input {
    width: 180px;
  }

  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    padding-top: 0.5rem;
  }
}

/* ── Página: padding reduzido em phones ─────────────────────────────────── */
@media (max-width: 575px) {
  .page-content {
    padding: 12px !important;
  }
}

/* ── Card body: padding menor em phones ─────────────────────────────────── */
@media (max-width: 575px) {
  .card-body {
    padding: 0.9rem;
  }
  .card-body .card-title {
    font-size: 0.9rem;
  }
  .grid-margin {
    margin-bottom: 1rem !important;
  }
}

/* ── Tipografia: valores monetários menores em phones ───────────────────── */
@media (max-width: 575px) {
  .card-body h3.mb-0 {
    font-size: 1.35rem;
  }
  .card-body h4.mb-0 {
    font-size: 1.05rem;
  }
  .card-body h5.mb-0 {
    font-size: 0.92rem;
  }
}

/* ── Alertas: mais compactos em mobile ──────────────────────────────────── */
@media (max-width: 575px) {
  .alert {
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
  }
}

/* ── Dashboard "Visão 6 meses": empilha chart e tabela em mobile ─────────
   col-lg-7 e col-lg-5 ficam 100% abaixo de 992px por default do Bootstrap,
   mas garantimos aqui para o caso do chart não redimensionar. */
@media (max-width: 991px) {
  #chartVisao {
    height: 200px !important;
  }
}

/* ── Charts: sempre responsivos ─────────────────────────────────────────── */
canvas {
  max-width: 100% !important;
}

/* ── Navbar profile dropdown: garante que não saia da tela ─────────────── */
.navbar-nav .dropdown-menu {
  right: 0;
  left: auto;
}

/* ── Formulários: espaçamento entre campos em mobile ────────────────────── */
@media (max-width: 575px) {
  .form-label {
    font-size: 0.83rem;
    margin-bottom: 0.2rem;
  }

  /* Row de form: garante que col-sm-* empilhem corretamente */
  .row .col-sm-2,
  .row .col-sm-3,
  .row .col-sm-6 {
    /* já empilham para col-12 por padrão do Bootstrap < 576px */
  }
}

/* ── Botões de ação no breadcrumb: não achatam texto ────────────────────── */
.page-breadcrumb .btn {
  flex-shrink: 0;
}

/* ── Badges: legíveis em mobile ─────────────────────────────────────────── */
@media (max-width: 575px) {
  .badge {
    font-size: 0.62rem;
    padding: 0.25em 0.45em;
  }
}

/* ── Tabela de série de recorrências: progresso legível ─────────────────── */
@media (max-width: 575px) {
  [style*="min-width:140px"] {
    min-width: 100px !important;
  }
}

/* ── Página de projeção financeira: KPI cards ───────────────────────────── */
/* col-sm-6 col-xl-3 já funciona bem: 2 por linha em phones */

/* ── Sombra nos cards do dashboard em mobile ────────────────────────────── */
@media (max-width: 575px) {
  .col-6 > .card .card-body {
    padding: 0.75rem;
  }
}

/* ── Barra de pesquisa DataTables: tamanho mínimo usável ────────────────── */
@media (max-width: 767px) {
  #dataTableFinalizadas_filter input,
  #dataTableAtivas_filter input,
  #dataTableCanceladas_filter input,
  #dataTableAbertos_filter input,
  #dataTableExample_filter input,
  #tblRecorrencias_filter input {
    width: 150px;
  }
}

/* ── Botão salvar parcela: sempre visível em mobile ─────────────────────── */
@media (max-width: 575px) {
  .btns-edit .btn-primary {
    font-size: 0.78rem;
    padding: 0.25rem 0.5rem;
  }
}

/* ── Filtro de relatório com inputs de data: legível em phones ──────────── */
@media (max-width: 575px) {
  /* O filtro de período usa d-flex flex-wrap — no mobile, empilha o range */
  .card-body form.d-flex.flex-wrap {
    row-gap: 0.4rem;
  }
  /* Inputs de data com width fixo em style="" — remove o estilo inline */
  .card-body input[type="date"][style*="width:145px"],
  .card-body input[type="date"][style*="width: 145px"] {
    width: 130px !important;
  }
  /* O inner d-flex do range de data deve poder quebrar */
  .card-body form.d-flex .d-flex.align-items-center {
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-left: 0 !important;
  }
}

/* ── Form de item inline (vendas/show, viagens/show): cols pequenas ─────── */
/* col-sm-2 empilha para col-12 no mobile — dá muita altura; mínimo 2 por linha */
@media (max-width: 575px) {
  .row.g-2 > .col-sm-2 {
    width: 50%;
    flex: 0 0 50%;
    max-width: 50%;
  }
  /* Campo de quantidade e produto: podem ser mais largos */
  .row.g-2 > .col-sm-2:first-child {
    width: 100%;
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* ── Modais e SweetAlert: já são responsivos por padrão ─────────────────── */

/* ── Tabela inline (input de data/valor na série): fullwidth em mobile ─────── */
@media (max-width: 575px) {
  .inp-data {
    width: 100% !important;
    font-size: 0.82rem;
  }
  .inp-valor {
    width: 100% !important;
    font-size: 0.82rem;
  }
}

/* ── Coluna de progresso nas recorrências ────────────────────────────────── */
.col-progresso { min-width: 140px; }
@media (max-width: 575px) { .col-progresso { min-width: 90px; } }

/* ── Viagens/index: ocultar colunas de análise em mobile (10 colunas) ──────
   Mantém: Nome, Venda total, Lucro recebido, Ações — essencial para operar. */
@media (max-width: 767px) {
  #dataTableFinalizadas th:nth-child(2),
  #dataTableFinalizadas td:nth-child(2),  /* Destino */
  #dataTableFinalizadas th:nth-child(4),
  #dataTableFinalizadas td:nth-child(4),  /* Venda projetada */
  #dataTableFinalizadas th:nth-child(6),
  #dataTableFinalizadas td:nth-child(6),  /* Em aberto */
  #dataTableFinalizadas th:nth-child(7),
  #dataTableFinalizadas td:nth-child(7),  /* Lucro projetado */
  #dataTableFinalizadas th:nth-child(9),
  #dataTableFinalizadas td:nth-child(9) { /* Lucro a receber */
    display: none;
  }
}

/* ── Tabela de itens da viagem: ocultar colunas de análise em mobile ────────
   Mantém: Produto, Quantidade, Valor unit., Pagamento, Ações. */
@media (max-width: 767px) {
  .table-itens-viagem th:nth-child(2),
  .table-itens-viagem td:nth-child(2),  /* Fornecedor */
  .table-itens-viagem th:nth-child(6),
  .table-itens-viagem td:nth-child(6),  /* % rateio */
  .table-itens-viagem th:nth-child(7),
  .table-itens-viagem td:nth-child(7),  /* Rateio despesas */
  .table-itens-viagem th:nth-child(8),
  .table-itens-viagem td:nth-child(8) { /* Custo unit. compra */
    display: none;
  }
}

/* ── Viagens/perdidos: ocultar colunas redundantes em mobile ────────────── */
@media (max-width: 575px) {
  #dataTableExample th:nth-child(4),
  #dataTableExample td:nth-child(4),  /* Valor unit. perdedor */
  #dataTableExample th:nth-child(6),
  #dataTableExample td:nth-child(6),  /* Fornecedor vencedor */
  #dataTableExample th:nth-child(7),
  #dataTableExample td:nth-child(7) { /* Valor unit. vencedor */
    display: none;
  }
}

/* ── Gráfico de Faturamento e Lucro: altura adaptada em mobile ──────────── */
@media (max-width: 575px) {
  #chartFinanceiroWrapper { height: 220px !important; }
}

/* ── Dois botões longos no breadcrumb (ex: vendas/index) ────────────────── */
@media (max-width: 480px) {
  .page-breadcrumb .breadcrumb > div {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3rem;
  }
  .page-breadcrumb .breadcrumb > div .btn + .btn {
    margin-left: 0;
  }
}

/* ── Modal modal-lg: diminui o dialog em phones ─────────────────────────── */
@media (max-width: 575px) {
  .modal-lg {
    --bs-modal-width: 100%;
  }
  .modal-dialog.modal-lg {
    margin: 0.5rem;
  }
}

/* ── #tabelaPagamentos: card layout em mobile (vendas/show) ─────────────── */
@media (max-width: 575px) {
  #tabelaPagamentos thead { display: none; }
  #tabelaPagamentos tr {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    gap: 0.4rem;
  }
  #tabelaPagamentos td { border: none; padding: 0; }
  #tabelaPagamentos td .campoForma,
  #tabelaPagamentos td .campoConta,
  #tabelaPagamentos td .campoValor { width: 100% !important; }
  #tabelaPagamentos td:last-child { text-align: right; }
}

/* ── SweetAlert2: iOS zoom fix em inputs ────────────────────────────────── */
@media (max-width: 767px) {
  .swal2-input,
  .swal2-textarea,
  .swal2-select { font-size: 16px !important; }
}

/* ── SweetAlert2: 3 botões empilhados (usar customClass: {actions: 'swal-actions-stacked'}) */
@media (max-width: 480px) {
  .swal-actions-stacked {
    flex-direction: column !important;
    width: 100%;
    padding: 0 1rem;
    gap: 0.4rem !important;
  }
  .swal-actions-stacked button {
    width: 100% !important;
    margin: 0 !important;
  }
}

/* ── Tabela A retirar / Retirado (viagens/show): ocultar colunas
   Cols: 1=Produto 2=Fornecedor 3=Qtd. 4=Valor total 5=Custo unit. 6=Custo total 7=Pago em 8=Status 9=botão */
@media (max-width: 767px) {
  .table-itens-retirada th:nth-child(2),
  .table-itens-retirada td:nth-child(2),  /* Fornecedor */
  .table-itens-retirada th:nth-child(3),
  .table-itens-retirada td:nth-child(3),  /* Qtd. comprada */
  .table-itens-retirada th:nth-child(6),
  .table-itens-retirada td:nth-child(6) { /* Custo total */
    display: none;
  }
}
@media (max-width: 575px) {
  .table-itens-retirada th:nth-child(5),
  .table-itens-retirada td:nth-child(5),  /* Custo unit. */
  .table-itens-retirada th:nth-child(7),
  .table-itens-retirada td:nth-child(7),  /* Pago em */
  .table-itens-retirada th:nth-child(8),
  .table-itens-retirada td:nth-child(8) { /* Status */
    display: none;
  }
}

/* ── Itens da viagem: ocultar Custo total final em mobile ───────────────── */
@media (max-width: 767px) {
  .table-itens-viagem th:nth-child(9),
  .table-itens-viagem td:nth-child(9) { /* Custo total final */
    display: none;
  }
}

/* ── vendas/index: tabela A retirar — ocultar colunas extras ───────────── */
@media (max-width: 767px) {
  #dataTableARetirar th:nth-child(4),
  #dataTableARetirar td:nth-child(4),  /* Pago */
  #dataTableARetirar th:nth-child(5),
  #dataTableARetirar td:nth-child(5) { /* Pendente */
    display: none;
  }
}
@media (max-width: 575px) {
  #dataTableARetirar th:nth-child(6),
  #dataTableARetirar td:nth-child(6) { /* Convertida em */
    display: none;
  }
}

/* ── Histórico de ajustes: ocultar "Quem" em phones pequenos ───────────── */
@media (max-width: 575px) {
  .table-ajustes th:nth-child(5),
  .table-ajustes td:nth-child(5) { /* Quem */
    display: none;
  }
}

/* ── financeiro/lancamentos: ocultar colunas em mobile ─────────────────── */
@media (max-width: 767px) {
  .table-lancamentos th:nth-child(4),
  .table-lancamentos td:nth-child(4) { /* Origem */
    display: none;
  }
}
@media (max-width: 575px) {
  .table-lancamentos th:nth-child(2),
  .table-lancamentos td:nth-child(2) { /* Conta */
    display: none;
  }
}

/* ── formItem: col-sm-3 → 100%, input-group de desconto empilha ─────────── */
@media (max-width: 575px) {
  #formItem .col-sm-3 {
    width: 100%;
    flex: 0 0 100%;
    max-width: 100%;
  }
  #formItem .input-group {
    flex-wrap: wrap;
  }
  #formItem .input-group > * {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 0.375rem !important;
  }
  .campo-total-preview { display: none; }
}

/* ── Dashboard: chartVisao menor em phones pequenos ─────────────────────── */
@media (max-width: 575px) {
  #chartVisao { height: 160px !important; }
}

/* ── Dashboard: tabela visão 6 meses — ocultar Custo e Pessoal em phones ── */
@media (max-width: 575px) {
  .table-visao6meses th:nth-child(3),
  .table-visao6meses td:nth-child(3),  /* Custo */
  .table-visao6meses th:nth-child(4),
  .table-visao6meses td:nth-child(4) { /* Pessoal */
    display: none;
  }
}

/* ── viagens/index: aba Orçamento/Confirmadas — ocultar colunas ─────────── */
@media (max-width: 767px) {
  #dataTableAtivas th:nth-child(2),
  #dataTableAtivas td:nth-child(2),  /* Destino */
  #dataTableAtivas th:nth-child(4),
  #dataTableAtivas td:nth-child(4) { /* Total geral */
    display: none;
  }
}
@media (max-width: 575px) {
  #dataTableAtivas th:nth-child(5),
  #dataTableAtivas td:nth-child(5) { /* Venda projetada */
    display: none;
  }
}

/* ── Repasse por fornecedor (viagens/show) ──────────────────────────────── */
@media (max-width: 767px) {
  .table-repasse-fornecedor th:nth-child(2),
  .table-repasse-fornecedor td:nth-child(2),  /* Itens */
  .table-repasse-fornecedor th:nth-child(3),
  .table-repasse-fornecedor td:nth-child(3) { /* Total */
    display: none;
  }
}
@media (max-width: 575px) {
  .table-repasse-fornecedor th:nth-child(5),
  .table-repasse-fornecedor td:nth-child(5) { /* A pagar */
    display: none;
  }
  .table-repasse-fornecedor th:nth-child(6),
  .table-repasse-fornecedor td:nth-child(6) {
    min-width: 80px !important;
  }
}

/* ── Vendas reais (viagens/show) ────────────────────────────────────────── */
@media (max-width: 767px) {
  .table-vendas-reais th:nth-child(4),
  .table-vendas-reais td:nth-child(4),  /* Custo atribuído */
  .table-vendas-reais th:nth-child(6),
  .table-vendas-reais td:nth-child(6),  /* % pago */
  .table-vendas-reais th:nth-child(8),
  .table-vendas-reais td:nth-child(8) { /* Lucro a receber */
    display: none;
  }
}
@media (max-width: 575px) {
  .table-vendas-reais th:nth-child(3),
  .table-vendas-reais td:nth-child(3),  /* Receita atribuída */
  .table-vendas-reais th:nth-child(7),
  .table-vendas-reais td:nth-child(7) { /* Lucro recebido */
    display: none;
  }
}

/* ── Despesas da viagem (viagens/show) ──────────────────────────────────── */
@media (max-width: 767px) {
  .table-despesas th:nth-child(2),
  .table-despesas td:nth-child(2),  /* Descrição */
  .table-despesas th:nth-child(3),
  .table-despesas td:nth-child(3) { /* Data */
    display: none;
  }
}
@media (max-width: 575px) {
  .table-despesas th:nth-child(5),
  .table-despesas td:nth-child(5) { /* Pagamento */
    display: none;
  }
}

/* ── formDespesa: campo Data (col-sm-2 isolado) → 100% em mobile ────────── */
@media (max-width: 575px) {
  #formDespesa .col-sm-2 {
    width: 100%;
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* ── Itens da venda (vendas/show) ── cols: Produto|Qtd|Unit.|Total|Ações ─── */
@media (max-width: 575px) {
  .table-itens-venda th:nth-child(3),
  .table-itens-venda td:nth-child(3) { /* Unit. (já aparece junto ao Qtd) */
    display: none;
  }
}

/* ── Histórico de pagamentos da venda ── cols: Forma/Conta|Data|Valor|Ações  */
@media (max-width: 575px) {
  .table-historico-pagamentos th:nth-child(2),
  .table-historico-pagamentos td:nth-child(2) { /* Data (badge já colore Valor) */
    display: none;
  }
}

/* ── vendas/index: tabela Pagas ─────────────────────────────────────────── */
@media (max-width: 767px) {
  #dataTablePagas th:nth-child(3),
  #dataTablePagas td:nth-child(3) { /* Pago */
    display: none;
  }
}
@media (max-width: 575px) {
  #dataTablePagas th:nth-child(4),
  #dataTablePagas td:nth-child(4) { /* Convertida em */
    display: none;
  }
}

/* ── vendas/index: tabela A prazo ───────────────────────────────────────── */
@media (max-width: 767px) {
  #dataTableAPrazo th:nth-child(4),
  #dataTableAPrazo td:nth-child(4),  /* Pago */
  #dataTableAPrazo th:nth-child(6),
  #dataTableAPrazo td:nth-child(6) { /* Convertida em */
    display: none;
  }
}
@media (max-width: 575px) {
  #dataTableAPrazo th:nth-child(2),
  #dataTableAPrazo td:nth-child(2) { /* Status */
    display: none;
  }
}

/* ── vendas/index: tabela Canceladas ────────────────────────────────────── */
@media (max-width: 767px) {
  #dataTableCanceladas th:nth-child(4),
  #dataTableCanceladas td:nth-child(4) { /* Motivo */
    display: none;
  }
}
@media (max-width: 575px) {
  #dataTableCanceladas th:nth-child(3),
  #dataTableCanceladas td:nth-child(3) { /* Cancelada em */
    display: none;
  }
}

/* ── orcamentos/index: tabela Abertos ───────────────────────────────────── */
@media (max-width: 767px) {
  #dataTableAbertos th:nth-child(3),
  #dataTableAbertos td:nth-child(3) { /* Previsão de conclusão */
    display: none;
  }
}
@media (max-width: 575px) {
  #dataTableAbertos th:nth-child(4),
  #dataTableAbertos td:nth-child(4) { /* Criado em */
    display: none;
  }
}

/* ── orcamentos/index: tabela Concluídos ────────────────────────────────── */
@media (max-width: 767px) {
  #dataTableConcluidos th:nth-child(4),
  #dataTableConcluidos td:nth-child(4),  /* Pago */
  #dataTableConcluidos th:nth-child(5),
  #dataTableConcluidos td:nth-child(5),  /* Pendente */
  #dataTableConcluidos th:nth-child(6),
  #dataTableConcluidos td:nth-child(6) { /* Convertida em */
    display: none;
  }
}
@media (max-width: 575px) {
  #dataTableConcluidos th:nth-child(2),
  #dataTableConcluidos td:nth-child(2) { /* Status */
    display: none;
  }
}

/* ── orcamentos/index: tabela Cancelados ────────────────────────────────── */
@media (max-width: 767px) {
  #dataTableCancelados th:nth-child(4),
  #dataTableCancelados td:nth-child(4) { /* Motivo */
    display: none;
  }
}
@media (max-width: 575px) {
  #dataTableCancelados th:nth-child(3),
  #dataTableCancelados td:nth-child(3) { /* Cancelada em */
    display: none;
  }
}

/* ── Lançamentos pessoais (pessoal/index) ───────────────────────────────── */
@media (max-width: 767px) {
  .table-pessoal-lancamentos th:nth-child(2),
  .table-pessoal-lancamentos td:nth-child(2),  /* Subcategoria */
  .table-pessoal-lancamentos th:nth-child(3),
  .table-pessoal-lancamentos td:nth-child(3) { /* Descrição */
    display: none;
  }
}
@media (max-width: 575px) {
  .table-pessoal-lancamentos th:nth-child(5),
  .table-pessoal-lancamentos td:nth-child(5) { /* Status (redundante com cor) */
    display: none;
  }
}

/* ── Busca DataTables: campo search em tabelas adicionais ───────────────── */
@media (max-width: 767px) {
  #dataTablePagas_filter input,
  #dataTableAPrazo_filter input,
  #dataTableConcluidos_filter input,
  #dataTableCancelados_filter input,
  #dataTableCanceladas_filter input {
    width: 150px;
  }
}

/* ── Relatório pessoal: charts menores em phones ────────────────────────── */
@media (max-width: 575px) {
  #chartMensal,
  #chartSubcategoria { height: 160px !important; }
}

/* ── Projeção financeira: h2 do saldo projetado ─────────────────────────── */
@media (max-width: 575px) {
  .card-body h2.mb-0 {
    font-size: 1.4rem;
  }
}

/* ── vendedores/index: column hiding ────────────────────────────────────── */
@media (max-width: 575px) {
  #dataTableVendedores th:nth-child(4),
  #dataTableVendedores td:nth-child(4),  /* Whatsapp */
  #dataTableVendedores th:nth-child(5),
  #dataTableVendedores td:nth-child(5) { /* Tabela de preço */
    display: none;
  }
}

/* ── contas/index: column hiding ────────────────────────────────────────── */
@media (max-width: 575px) {
  #dataTableContas th:nth-child(2),
  #dataTableContas td:nth-child(2),  /* Tipo */
  #dataTableContas th:nth-child(3),
  #dataTableContas td:nth-child(3) { /* Banco */
    display: none;
  }
}

/* ── pessoal/recorrencias: #tblRecorrencias — column hiding ─────────────── */
@media (max-width: 767px) {
  #tblRecorrencias th:nth-child(2),
  #tblRecorrencias td:nth-child(2),  /* Subcategoria */
  #tblRecorrencias th:nth-child(3),
  #tblRecorrencias td:nth-child(3) { /* Conta */
    display: none;
  }
}
@media (max-width: 575px) {
  #tblRecorrencias th:nth-child(6),
  #tblRecorrencias td:nth-child(6),  /* Total série */
  #tblRecorrencias th:nth-child(8),
  #tblRecorrencias td:nth-child(8),  /* Início */
  #tblRecorrencias th:nth-child(9),
  #tblRecorrencias td:nth-child(9) { /* Fim */
    display: none;
  }
}

/* ── relatorios/viagem: tabela por produto ──────────────────────────────── */
@media (max-width: 767px) {
  .table-relatorio-produtos th:nth-child(4),
  .table-relatorio-produtos td:nth-child(4),  /* Disponíveis */
  .table-relatorio-produtos th:nth-child(6),
  .table-relatorio-produtos td:nth-child(6),  /* Preço médio real */
  .table-relatorio-produtos th:nth-child(9),
  .table-relatorio-produtos td:nth-child(9) { /* Previsão esgot. */
    display: none;
  }
}
@media (max-width: 575px) {
  .table-relatorio-produtos th:nth-child(3),
  .table-relatorio-produtos td:nth-child(3) { /* Vendidas */
    display: none;
  }
}

/* ── relatorios/viagem: tabela análise de preço ─────────────────────────── */
@media (max-width: 575px) {
  .table-relatorio-analise th:nth-child(3),
  .table-relatorio-analise td:nth-child(3),  /* Preço sugerido/cx */
  .table-relatorio-analise th:nth-child(4),
  .table-relatorio-analise td:nth-child(4) { /* Lucro sugerido/cx */
    display: none;
  }
}

/* ── relatorios/financeiro: detalhe por dia ─────────────────────────────── */
@media (max-width: 767px) {
  .table-relatorio-financeiro th:nth-child(4),
  .table-relatorio-financeiro td:nth-child(4),  /* Recebimentos */
  .table-relatorio-financeiro th:nth-child(6),
  .table-relatorio-financeiro td:nth-child(6) { /* Margem */
    display: none;
  }
}
@media (max-width: 575px) {
  .table-relatorio-financeiro th:nth-child(2),
  .table-relatorio-financeiro td:nth-child(2) { /* Qtd. vendas */
    display: none;
  }
}

/* ── vendas/financeiro: tabela pendentes ────────────────────────────────── */
@media (max-width: 767px) {
  .table-vendas-pendentes th:nth-child(3),
  .table-vendas-pendentes td:nth-child(3),  /* Total */
  .table-vendas-pendentes th:nth-child(4),
  .table-vendas-pendentes td:nth-child(4) { /* Pago */
    display: none;
  }
}
@media (max-width: 575px) {
  .table-vendas-pendentes th:nth-child(2),
  .table-vendas-pendentes td:nth-child(2) { /* Convertida em */
    display: none;
  }
}

/* ── contas/show: histórico de movimentos ───────────────────────────────── */
@media (max-width: 575px) {
  .table-conta-movimentos th:nth-child(3),
  .table-conta-movimentos td:nth-child(3),  /* Origem */
  .table-historico-conta th:nth-child(4),
  .table-historico-conta td:nth-child(4) { /* Origem (legado) */
    display: none;
  }
}

/* ── clientes/form: histórico de compras ────────────────────────────────── */
@media (max-width: 767px) {
  .table-historico-cliente th:nth-child(4),
  .table-historico-cliente td:nth-child(4),  /* Pago */
  .table-historico-cliente th:nth-child(5),
  .table-historico-cliente td:nth-child(5) { /* Pendente */
    display: none;
  }
}
@media (max-width: 575px) {
  .table-historico-cliente th:nth-child(1),
  .table-historico-cliente td:nth-child(1) { /* Data */
    display: none;
  }
}

/* ── estoque/index: tabela resumo por produto ───────────────────────────── */
@media (max-width: 767px) {
  .table-estoque-resumo th:nth-child(3),
  .table-estoque-resumo td:nth-child(3),  /* Cx. compradas */
  .table-estoque-resumo th:nth-child(4),
  .table-estoque-resumo td:nth-child(4) { /* Cx. vendidas */
    display: none;
  }
}
@media (max-width: 575px) {
  .table-estoque-resumo th:nth-child(6),
  .table-estoque-resumo td:nth-child(6) { /* Custo médio */
    display: none;
  }
}

/* ── tabelas_precos/form: ocultar colunas de custo médio ────────────────── */
@media (max-width: 767px) {
  .table-tabela-precos th:nth-child(2),
  .table-tabela-precos td:nth-child(2),  /* Custo médio (caixa) */
  .table-tabela-precos th:nth-child(4),
  .table-tabela-precos td:nth-child(4) { /* Custo médio (frac.) */
    display: none;
  }
  .table-tabela-precos th:nth-child(3),
  .table-tabela-precos th:nth-child(5) {
    width: auto !important;
    min-width: 100px;
  }
}

/* ── fornecedores/form: histórico de compras ────────────────────────────── */
@media (max-width: 575px) {
  .table-historico-fornecedor th:nth-child(1),
  .table-historico-fornecedor td:nth-child(1) { /* Viagem */
    display: none;
  }
}

/* ── produtos/index: column hiding ──────────────────────────────────────── */
@media (max-width: 575px) {
  #dataTableProdutos th:nth-child(3),
  #dataTableProdutos td:nth-child(3),  /* Conversão */
  #dataTableProdutos th:nth-child(4),
  #dataTableProdutos td:nth-child(4) { /* Preço de venda */
    display: none;
  }
}

/* ── administracao/user: column hiding ───────────────────────────────────── */
@media (max-width: 575px) {
  #dataTableUsers th:nth-child(3),
  #dataTableUsers td:nth-child(3) { /* Tipo */
    display: none;
  }
}

/* ── estoque/index: tabela de lotes (sem filtro — 7 cols) ───────────────── */
/* col1=Produto col2=Viagem col3=Fornecedor col4=Qtd.comprada col5=Qtd.disp. col6=Custo unit. col7=Data */
@media (max-width: 767px) {
  .table-estoque-lotes-todos th:nth-child(4),
  .table-estoque-lotes-todos td:nth-child(4),  /* Qtd. comprada */
  .table-estoque-lotes-todos th:nth-child(6),
  .table-estoque-lotes-todos td:nth-child(6) { /* Custo unitário */
    display: none;
  }
}
@media (max-width: 575px) {
  .table-estoque-lotes-todos th:nth-child(2),
  .table-estoque-lotes-todos td:nth-child(2) { /* Viagem de origem */
    display: none;
  }
}

/* ── estoque/index: tabela de lotes (com filtro por viagem — 6 cols) ────── */
/* col1=Produto col2=Fornecedor col3=Qtd.comprada col4=Qtd.disp. col5=Custo unit. col6=Data */
@media (max-width: 767px) {
  .table-estoque-lotes-filtrado th:nth-child(3),
  .table-estoque-lotes-filtrado td:nth-child(3),  /* Qtd. comprada */
  .table-estoque-lotes-filtrado th:nth-child(5),
  .table-estoque-lotes-filtrado td:nth-child(5) { /* Custo unitário */
    display: none;
  }
}
@media (max-width: 575px) {
  .table-estoque-lotes-filtrado th:nth-child(2),
  .table-estoque-lotes-filtrado td:nth-child(2) { /* Fornecedor */
    display: none;
  }
}

/* ── administracao/perfis-edit: tabela de usuários ──────────────────────── */
/* col1=Nome col2=E-mail col3=Status col4=Ações */
@media (max-width: 575px) {
  .table-perfil-usuarios th:nth-child(2),
  .table-perfil-usuarios td:nth-child(2) { /* E-mail */
    display: none;
  }
}

/* ── Botões collapse de seção (chevron animado) ─────────────────────────── */
.btn-collapse-sec [data-feather] {
  transition: transform 0.2s ease;
}

/* ── Resumo por produto (vendas/show) ───────────────────────────────────── */
.resumo-produto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.5rem;
}
@media (max-width: 575px) {
  .resumo-produto-grid {
    grid-template-columns: 1fr 1fr;
  }
  .resumo-produto-card .fw-bold {
    font-size: .9rem;
  }
}
@media (max-width: 359px) {
  .resumo-produto-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Produtos por fornecedor (viagens/show) ─────────────────────────────── */
@media (max-width: 575px) {
  .card-forn-item {
    padding: 0.625rem !important;
  }
  .card-forn-item .fw-semibold {
    font-size: .85rem;
  }
  .card-forn-item .small {
    font-size: .78rem;
  }
  /* Total geral de unidades: empilha verticalmente se necessário */
  .row-produtos-fornecedor ~ div .d-flex.flex-wrap {
    gap: 0.75rem !important;
  }
}

