/* ADQP — camada mobile comum (sócios, financeiro, POS backoffice, portal, francesinhas).
   Fonte única: shared/mobile/ — copiar para os módulos com shared/mobile/sincronizar.sh.
   Só atua abaixo de 760px: no computador nada muda.
   - tabelas com 3+ colunas passam a cards (o adqp-mobile.js põe data-label em cada célula)
   - tabelas pequenas ficam com scroll horizontal
   - grelhas largas passam a 2 colunas; formulários sem zoom no iPhone
   Exceções: data-mobile="off" num elemento (ou num pai) deixa-o como está. */

:root { --m-acento: #3B6D11; --m-linha: rgba(127,127,127,.26); --m-fundo: rgba(127,127,127,.07); }

@media (max-width: 760px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overflow-wrap: break-word; }
  img, video, iframe { max-width: 100%; }
  img { height: auto; }

  /* Formulários: 16px evita o zoom automático do iOS; nada mais largo que o ecrã */
  input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea {
    font-size: 16px !important; max-width: 100%;
  }
  button, .btn, input[type=submit], input[type=button] { min-height: 40px; }

  /* Tabelas pequenas (2 colunas ou sem cabeçalho): scroll horizontal */
  .m-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

  /* Grelhas com 3+ colunas (exceto calendários de 7 colunas) */
  .m-grelha { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important; }
  .m-grelha > * { grid-column: auto !important; min-width: 0; }
  .m-flex { flex-wrap: wrap !important; }

  /* ── Tabelas → cards ─────────────────────────────────────────────── */
  table.m-cards { display: block; width: 100% !important; min-width: 0 !important; border: 0 !important;
    background: none !important; box-shadow: none !important; border-collapse: separate; }
  table.m-cards > thead, table.m-cards tr.m-cab, table.m-cards > colgroup, table.m-cards > caption { display: none !important; }
  table.m-cards > tbody, table.m-cards > tfoot { display: block; width: 100%; }
  table.m-cards tr {
    display: block; position: relative; margin: 0 0 12px; padding: 8px 14px;
    border: 1px solid var(--m-linha) !important; border-left: 4px solid var(--m-acento) !important;
    border-radius: 14px; background-color: var(--m-fundo); box-shadow: 0 1px 3px rgba(0,0,0,.06);
  }
  table.m-cards > tfoot tr { border-left-color: var(--m-linha) !important; font-weight: 700; }
  table.m-cards td, table.m-cards tbody th, table.m-cards tfoot th {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    width: auto !important; min-width: 0 !important; max-width: none !important; height: auto !important;
    padding: 7px 0 !important; border: 0 !important; border-bottom: 1px dashed var(--m-linha) !important;
    text-align: right !important; white-space: normal !important; background: none !important;
    position: static !important;
  }
  table.m-cards td::before, table.m-cards tbody th::before, table.m-cards tfoot th::before {
    content: attr(data-label); flex: 0 1 auto; max-width: 48%; text-align: left;
    font-size: .74em; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; opacity: .62;
  }
  table.m-cards td > *, table.m-cards th > * { max-width: 100%; }
  table.m-cards [data-label=""]::before { display: none; }
  table.m-cards tr > :last-child { border-bottom: 0 !important; }

  /* 1.ª coluna = título do card */
  table.m-cards .m-titulo { justify-content: flex-start; text-align: left !important; font-size: 1.06em; font-weight: 700; }
  table.m-cards .m-titulo::before { display: none; }
  /* Coluna de ações (botões/ligações sem texto próprio) */
  table.m-cards .m-acoes { justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding-top: 10px !important; }
  table.m-cards .m-acoes::before { display: none; }
  /* Caixa de seleção: canto do card */
  table.m-cards .m-check { position: absolute !important; top: 10px; right: 12px; border: 0 !important; padding: 0 !important; }
  table.m-cards .m-check::before { display: none; }
  table.m-cards tr:has(> .m-check) > .m-titulo { padding-right: 32px !important; }
  /* Células vazias e linhas de largura total (ex.: "sem resultados", subtotal) */
  table.m-cards .m-vazio { display: none !important; }
  table.m-cards .m-total { display: block; text-align: center !important; }
  table.m-cards .m-total::before { display: none; }
  table.m-cards tr.m-linha-total { border-left-color: var(--m-linha) !important; }
}
