/* Dono único dos ajustes mobile do produto. Carregar após o tema da tela.
   Não altera dados, cálculos, câmera, impressão ou o layout de desktop. */
@media screen and (max-width: 640px) {
  html { -webkit-text-size-adjust: 100%; }
  body input:not([type=checkbox]):not([type=radio]):not([type=hidden]),
  body select, body textarea, body:not(.bt-tela) select, body:not(.bt-tela) textarea { font-size: 16px; min-height: 44px; max-width: 100%; }
  body #colab-search, body #nf-texto { font-size: 16px !important; }
  body button, body a.btn, body a.btn-claro, body .abas a {
    min-height: 44px; min-width: 44px; touch-action: manipulation;
  }
  body button, body a.btn, body a.btn-claro { white-space: normal; overflow-wrap: anywhere; }
  body .tabs { position: static; flex-wrap: wrap; overflow-x: visible; padding: 4px 8px; gap: 2px; }
  body .tabs button { flex: 1 1 auto; padding: 10px; font-size: 13px; min-height: 46px; }
  body .card, body .kpi { min-width: 0; }
  body:not(.bt-tela) .card { padding: 16px; }
  body .item { flex-wrap: wrap; }
  body .item > div { min-width: 0; overflow-wrap: anywhere; }
  body .item .actions { display: flex; flex-wrap: wrap; gap: 8px; }
  body .card h2, body header .who, body code.copy { overflow-wrap: anywhere; }
  body header { flex-wrap: wrap; gap: 8px; }
  body #modal { padding: 12px 8px; }
  body #modal .box { width: 100%; max-height: calc(100dvh - 24px); overflow-y: auto; padding: 16px; }
  body #modal-x { min-width: 44px; min-height: 44px; }
  body #paywall .pw { max-height: calc(100dvh - 32px); overflow-y: auto; }
  body .row, body .row3 { grid-template-columns: minmax(0, 1fr); }

  /* Somente tabelas de registros simples selecionadas pelo helper. NF e
     comparações financeiras mantêm seus próprios layouts. Cabeçalho acessível. */
  body table[data-bt-records] { display: block; width: 100%; min-width: 0; border-collapse: separate; }
  body table[data-bt-records] > tbody { display: block; width: 100%; }
  body table[data-bt-records] .bt-record-head {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap;
  }
  body table[data-bt-records] tr[data-bt-record] {
    display: block; margin: 0 0 12px; padding: 10px 12px;
    border: 1px solid #E4E6EB; border-radius: 12px; background: #fff;
    animation: bt-record-in 180ms ease-out both;
  }
  body table[data-bt-records] tr[data-bt-record]:nth-child(2) { animation-delay: 35ms; }
  body table[data-bt-records] tr[data-bt-record]:nth-child(3) { animation-delay: 70ms; }
  body table[data-bt-records] td[data-bt-label] {
    display: block; padding: 7px 0; border: 0;
    text-align: left; white-space: normal; width: auto; font-size: 15px; overflow-wrap: anywhere;
  }
  body table[data-bt-records] td[data-bt-label]::before {
    content: attr(data-bt-label); display: block; margin-bottom: 3px; font-size: 12px; font-weight: 600; color: #6C6F7A; padding-top: 3px;
  }
  body table[data-bt-records] td[data-bt-label]:first-child { font-size: 17px; font-weight: 600; color: #111135; }
  body table[data-bt-records] td[data-bt-label] > * { min-width: 0; max-width: 100%; }
  body table[data-bt-records] tr[data-bt-message],
  body table[data-bt-records] tr[data-bt-message] td { display: block; width: 100%; }
  body.bt-tela .result-name { font-size: clamp(30px, 10vw, 48px); max-width: 94vw; overflow-wrap: anywhere; line-height: 1.08; }
  body.bt-tela .pin-modal { overflow-y: auto; justify-content: flex-start; padding: 16px 12px; gap: 10px; }
  body.bt-tela .pin-modal .keypad { grid-template-columns: repeat(3, minmax(0, 1fr)); width: min(100%, 320px); gap: 8px; margin: 4px 0; }
  body.bt-tela .pin-modal .keypad button { padding: 12px 0; }
  body.bt-tela .pin-modal input.pin-display { font-size: clamp(32px, 10vw, 48px); max-width: 100%; padding: 8px; }
  @keyframes bt-record-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }
}
@media screen and (prefers-reduced-motion: reduce) {
  /* A leitura e as ações ficam disponíveis sem animações, inclusive no tablet. */
  html { scroll-behavior: auto; }
  body *, body *::before, body *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
