/* Conferência de Estoque: mobile-first, alto contraste, alvos de toque de 48px ou mais. */
:root {
  color-scheme: light dark;
  --fundo: #f4f6f9;
  --superficie: #ffffff;
  --superficie-2: #e9edf2;
  --texto: #14181f;
  --texto-suave: #4f5968;
  --borda: #c9d0da;
  --destaque: #0b57d0;
  --destaque-texto: #ffffff;
  --destaque-suave: #dbe7fb;
  --sucesso: #0f7b3f;
  --perigo: #b3261e;
  --perigo-texto: #ffffff;
  --alerta-fundo: #fff3d6;
  --alerta-texto: #5c3f00;
  --sombra: 0 8px 28px rgba(16, 24, 40, 0.18);
  --teclado: 0px;
  --topo-seguro: env(safe-area-inset-top, 0px);
  --base-segura: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #111418;
    --superficie: #1c2127;
    --superficie-2: #2a3038;
    --texto: #f0f3f7;
    --texto-suave: #aab4c1;
    --borda: #3d4551;
    --destaque: #8ab4f8;
    --destaque-texto: #08203f;
    --destaque-suave: #1f3250;
    --sucesso: #5fd38f;
    --perigo: #f2867e;
    --perigo-texto: #3b0906;
    --alerta-fundo: #3d2f0a;
    --alerta-texto: #ffdf9e;
    --sombra: 0 8px 28px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  background: var(--fundo);
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior-y: none;
}
#app { height: 100%; }
.tela {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  background: var(--fundo);
}
.tela-escura { max-width: none; background: #000; }

h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
a { color: inherit; text-decoration: none; }
:focus { outline: 3px solid var(--destaque); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
.icone { display: inline-flex; flex: none; }
.meta { color: var(--texto-suave); font-size: 14px; }

/* ---------- Barra superior ---------- */
.barra-topo {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: var(--topo-seguro) 4px 0;
  background: var(--superficie);
  border-bottom: 1px solid var(--borda);
}
.barra-topo h1 {
  flex: 1;
  min-width: 0;
  padding: 0 8px;
  font-size: 18px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.barra-topo-direita { display: flex; }
.titulo-tocavel {
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font-weight: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.botao-icone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 12px;
  background: transparent;
}
.botao-icone:active { background: var(--superficie-2); }

/* ---------- Botões ---------- */
.botao {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid var(--borda);
  border-radius: 12px;
  background: var(--superficie);
  font-weight: 600;
  text-align: center;
}
.botao:active { background: var(--superficie-2); }
.botao-primario { background: var(--destaque); border-color: var(--destaque); color: var(--destaque-texto); }
.botao-primario:active { background: var(--destaque); opacity: 0.85; }
.botao-perigo { background: var(--perigo); border-color: var(--perigo); color: var(--perigo-texto); }
.botao-perigo:active { background: var(--perigo); opacity: 0.85; }
.botao-perigo-texto { color: var(--perigo); }
.botao-grande { min-height: 56px; font-size: 17px; }
.botao-claro { background: #fff; border-color: #fff; color: #14181f; }
.botao-claro:active { background: #dfe3e8; }
.botao-texto {
  min-height: 48px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--destaque);
  font-weight: 600;
}
.centralizado { display: block; margin: 8px auto 0; }

.botao-passo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 48px;
  height: 48px;
  border: 1px solid var(--borda);
  border-radius: 12px;
  background: var(--superficie);
}
.botao-passo:active { background: var(--superficie-2); }

.segmentado {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--superficie-2);
}
.segmentado button {
  flex: 1;
  min-height: 48px;
  padding: 4px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
}
.segmentado button[aria-pressed="true"] { background: var(--destaque); color: var(--destaque-texto); }

/* ---------- Campos ---------- */
.campo {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--texto-suave);
  border-radius: 12px;
  background: var(--superficie);
  font-size: 16px; /* abaixo de 16px o iOS aproxima a tela ao focar */
}
.campo-codigo { font-size: 20px; font-variant-numeric: tabular-nums; }
.campo-quantidade {
  flex: 1;
  min-width: 0;
  min-height: 56px;
  font-size: 26px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.campo-ativo { border: 2px solid var(--destaque); }
.linha-quantidade { display: flex; align-items: center; gap: 8px; }
.linha-quantidade .botao-passo { width: 56px; height: 56px; }

.formulario { display: flex; flex-direction: column; gap: 10px; }
.formulario label { font-size: 14px; font-weight: 600; }
.rotulo-linha { display: flex; align-items: center; justify-content: space-between; }
.rotulo-linha .botao-texto { font-size: 14px; }
.mensagem-erro { color: var(--perigo); font-weight: 600; }
.codigo-lido {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.descricao-produto { color: var(--texto-suave); }
.aviso-repetido { font-weight: 600; }
.alerta, .alerta-simples {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--alerta-fundo);
  color: var(--alerta-texto);
  font-size: 14px;
}
.alerta { display: flex; gap: 8px; }
.acoes-sheet, .menu-sheet { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

/* ---------- Conteúdo ---------- */
.conteudo {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}
.conteudo-lista { padding: 0 12px 12px; }
.conteudo-espacado > * + * { margin-top: 12px; }
.subtitulo {
  margin-top: 24px !important;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--texto-suave);
}
.conteudo-espacado > .subtitulo:first-child { margin-top: 4px !important; }

.rodape {
  padding: 8px 12px calc(8px + var(--base-segura));
  background: var(--superficie);
  border-top: 1px solid var(--borda);
}
.rodape > .botao { width: 100%; }
.rodape-coluna { display: flex; flex-direction: column; gap: 8px; }
.rodape-acoes { display: grid; grid-template-columns: 1fr 1.2fr 1fr; align-items: stretch; gap: 8px; }
.acao-rodape, .acao-escanear {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 64px;
  padding: 4px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.15;
}
.acao-rodape { border: 1px solid var(--borda); background: var(--superficie); }
.acao-rodape:active { background: var(--superficie-2); }
.acao-escanear { min-height: 72px; border: 0; background: var(--destaque); color: var(--destaque-texto); font-size: 15px; }
.acao-escanear:active { opacity: 0.85; }

.vazio {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 24px;
  color: var(--texto-suave);
  text-align: center;
}

/* ---------- Lista de contagens ---------- */
.lista-contagens { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.cartao-contagem {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid var(--borda);
  border-radius: 14px;
  background: var(--superficie);
}
.cartao-contagem:active { background: var(--superficie-2); }
.cartao-contagem strong { font-size: 17px; overflow-wrap: anywhere; }

/* ---------- Tela de contagem ---------- */
.resumo-topo {
  padding: 8px 16px 0;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ferramentas { display: flex; gap: 8px; padding: 8px 12px; }
.campo-busca { flex: 1; min-width: 0; }
.campo-ordem { flex: none; width: 124px; padding: 0 6px; }

.lista-itens { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.item {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  content-visibility: auto;
  contain-intrinsic-size: auto 66px;
}
.item-fundo {
  position: absolute;
  top: 1px;
  left: 1px;
  right: 1px;
  bottom: 1px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding-right: 16px;
  border-radius: 11px;
  background: var(--perigo);
  color: var(--perigo-texto);
  font-weight: 700;
}
.item-frente {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 0;
  border: 1px solid var(--borda);
  border-radius: 12px;
  background: var(--superficie);
  touch-action: pan-y;
}
.item-dados {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 0 0 12px;
  border: 0;
  background: none;
  text-align: left;
}
.item-codigo {
  display: block;
  font-size: 17px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.item-nome { display: block; color: var(--texto-suave); font-size: 13px; }
.item-quantidade { display: flex; align-items: center; flex: none; gap: 2px; }
.qtd-valor {
  min-width: 48px;
  max-width: 96px;
  min-height: 48px;
  padding: 0 4px;
  border: 0;
  background: none;
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* ---------- Scanner ---------- */
.scanner {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #000;
  color: #fff;
}
.scanner-video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scanner-topo {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(8px + var(--topo-seguro)) 8px 8px;
}
.scanner-topo-direita { display: flex; align-items: center; gap: 6px; }
.sobre-video { background: rgba(0, 0, 0, 0.6); color: #fff; border-radius: 24px; }
.sobre-video:active { background: rgba(0, 0, 0, 0.8); }
.sobre-video[aria-pressed="true"] { background: #fff; color: #14181f; }
.chip-rapido {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 48px;
  padding: 0 14px;
  border: 0;
  border-radius: 24px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-weight: 600;
}
.chip-rapido[aria-pressed="true"] { background: #ffd54a; color: #14181f; }
.scanner-centro {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding-bottom: 72px;
  overflow: hidden;
  pointer-events: none;
}
.moldura {
  position: relative;
  flex: none;
  width: min(86vw, 560px);
  height: min(36vh, 300px);
  border: 3px solid #fff;
  border-radius: 16px;
  box-shadow: 0 0 0 200vmax rgba(0, 0, 0, 0.5);
  transition: border-color 0.1s, background-color 0.1s;
}
.moldura.lido {
  border-color: #38e07b;
  background: rgba(56, 224, 123, 0.3);
}
.linha-mira {
  position: absolute;
  top: 50%;
  left: 12px;
  right: 12px;
  height: 2px;
  background: #ff5252;
  box-shadow: 0 0 6px #ff5252;
}
.scanner-dica {
  position: relative;
  padding: 0 16px;
  text-align: center;
  font-weight: 600;
}
.scanner-erro {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(86vw, 420px);
  padding: 20px;
  border-radius: 16px;
  background: #1c2127;
  color: #fff;
  text-align: center;
  pointer-events: auto;
}
.scanner-erro h2 { font-size: 20px; }
.scanner-base {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px calc(12px + var(--base-segura));
  background: rgba(0, 0, 0, 0.72);
}
.scanner-resumo { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Exportar ---------- */
.numeros { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.numeros > div {
  display: flex;
  flex-direction: column;
  padding: 12px;
  border: 1px solid var(--borda);
  border-radius: 14px;
  background: var(--superficie);
}
.numeros strong { font-size: 28px; font-variant-numeric: tabular-nums; }
.numeros span { color: var(--texto-suave); font-size: 13px; }
.previa-csv {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  border: 1px solid var(--borda);
  border-radius: 12px;
  background: var(--superficie);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Configurações ---------- */
.linha-config {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 8px 12px;
  border: 1px solid var(--borda);
  border-radius: 12px;
  background: var(--superficie);
}
.linha-config label { flex: 1; font-weight: 600; }
.linha-config small { display: block; color: var(--texto-suave); font-size: 13px; font-weight: 400; }
.bloco-config { display: flex; flex-direction: column; gap: 6px; }
.rotulo-config { font-weight: 600; }
.interruptor {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  position: relative;
  width: 52px;
  height: 32px;
  margin: 0;
  border-radius: 16px;
  background: var(--texto-suave);
  cursor: pointer;
  transition: background 0.15s;
}
.interruptor::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}
.interruptor:checked { background: var(--destaque); }
.interruptor:checked::after { transform: translateX(20px); }

/* ---------- Sheets e diálogos ---------- */
.com-camada { overflow: hidden; }
.fundo-sheet, .fundo-dialogo {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  background: rgba(0, 0, 0, 0.45);
}
.fundo-sheet { align-items: flex-end; justify-content: center; padding-bottom: var(--teclado); }
.fundo-dialogo { z-index: 30; align-items: center; justify-content: center; padding: 16px; }
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 100%;
  overflow-y: auto;
  padding: 8px 16px calc(16px + var(--base-segura));
  border-radius: 20px 20px 0 0;
  background: var(--superficie);
  box-shadow: var(--sombra);
  animation: subir 0.16s ease-out;
}
.sheet:focus { outline: none; }
.sheet-topo { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.sheet-topo h2 {
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dialogo {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 400px;
  padding: 20px;
  border-radius: 18px;
  background: var(--superficie);
  box-shadow: var(--sombra);
}
.dialogo h2 { font-size: 19px; }
.dialogo-acoes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }

.teclado-numerico { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.teclado-numerico button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  border: 1px solid var(--borda);
  border-radius: 10px;
  background: var(--superficie-2);
  font-size: 22px;
  font-weight: 600;
}
.teclado-numerico button:active { background: var(--destaque-suave); }

/* ---------- Toast ---------- */
#toasts {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(96px + var(--base-segura) + var(--teclado));
  z-index: 40;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 520px;
  min-height: 48px;
  padding: 8px 14px;
  border-radius: 12px;
  background: #20252c;
  color: #fff;
  box-shadow: var(--sombra);
  pointer-events: auto;
  overflow-wrap: anywhere;
  animation: subir 0.14s ease-out;
}
.toast-sucesso { background: #0f6b38; }
.toast-erro { background: #a3211a; }
.toast button {
  flex: none;
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: #fff;
  font-weight: 700;
  text-decoration: underline;
}

@keyframes subir {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
