/* Inventario CCB - mobile first, alto contraste, botoes grandes */
:root {
  --azul: #1F3A5F;
  --azul-2: #2c5282;
  --azul-claro: #e6edf6;
  --fundo: #f3f5f8;
  --cartao: #ffffff;
  --texto: #111827;
  --texto-2: #4b5563;
  --borda: #c3ccd8;
  --verde: #166534;
  --verde-claro: #dcfce7;
  --ambar: #92400e;
  --ambar-claro: #fef3c7;
  --amarelo: #fff4c2;
  --amarelo-borda: #d4a106;
  --vermelho: #b42318;
  --vermelho-claro: #fee4e2;
  --cinza-claro: #e5e7eb;
  --raio: 12px;
  --altura-abas: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: var(--texto);
  background: var(--fundo);
  overflow-x: hidden;
}
img, svg, video, canvas { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--azul-2); }
h2 { font-size: 1.25rem; margin: 4px 0 12px; }
h3 { font-size: 1.08rem; margin: 18px 0 8px; }
p { margin: 8px 0; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace; }

/* ---------- topo ---------- */
.topo {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  min-height: 56px; padding: 6px 12px; padding-top: max(6px, env(safe-area-inset-top));
  background: var(--azul); color: #fff;
}
.topo h1 { font-size: 1.15rem; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo .voltar {
  width: 44px; height: 44px; margin-left: -6px; border: 0; border-radius: 10px;
  background: transparent; color: #fff; display: inline-flex; align-items: center; justify-content: center;
}
.topo .voltar svg { width: 26px; height: 26px; }
.topo .rede { font-size: .8rem; background: var(--ambar-claro); color: var(--ambar); padding: 4px 8px; border-radius: 999px; font-weight: 700; }

main {
  padding: 14px 14px calc(var(--altura-abas) + 28px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto; outline: none;
}
.carregando { color: var(--texto-2); text-align: center; padding: 40px 0; }

/* ---------- abas inferiores ---------- */
.abas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--altura-abas) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #fff; border-top: 1px solid var(--borda);
}
.abas a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--texto-2); text-decoration: none; font-size: .82rem; font-weight: 600; min-height: 48px;
}
.abas a svg { width: 26px; height: 26px; }
.abas a.ativa { color: var(--azul); }
.abas a.ativa span { border-bottom: 3px solid var(--azul); }

/* ---------- formularios ---------- */
label { display: block; font-weight: 600; margin: 12px 0 4px; }
label.inline { display: flex; align-items: center; gap: 10px; font-weight: 500; margin: 12px 0; min-height: 48px; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=month], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  font: inherit; color: inherit; background: #fff;
  border: 2px solid var(--borda); border-radius: 10px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid #93b4dd; outline-offset: 1px; border-color: var(--azul-2); }
input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--azul); flex: 0 0 auto; }
.linha2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.linha2 > div { min-width: 0; }
.ajuda { font-size: .9rem; color: var(--texto-2); margin: 4px 0; }

/* ---------- botoes ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; width: 100%;
  font: inherit; font-weight: 700; text-align: center; text-decoration: none;
  color: #fff; background: var(--azul); border: 2px solid var(--azul); border-radius: 12px;
  cursor: pointer; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.sec { background: #fff; color: var(--azul); }
.btn.perigo { background: var(--vermelho); border-color: var(--vermelho); }
.btn.perigo.sec { background: #fff; color: var(--vermelho); }
.btn.verde { background: var(--verde); border-color: var(--verde); }
.btn.grande { min-height: 68px; font-size: 1.2rem; border-radius: 14px; }
.btn.auto { width: auto; }
.btn svg { width: 26px; height: 26px; }
.botoes { display: grid; gap: 10px; margin: 14px 0; }
.botoes.dois { grid-template-columns: 1fr 1fr; }
.lista-menu { display: grid; gap: 10px; }
.lista-menu .btn { justify-content: flex-start; background: #fff; color: var(--texto); border-color: var(--borda); font-weight: 600; }

/* ---------- cartoes ---------- */
.cartao {
  background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio);
  padding: 14px; margin: 12px 0;
}
.cartao.atencao { background: var(--amarelo); border: 2px solid var(--amarelo-borda); }
.cartao.ok { background: var(--verde-claro); border-color: #86efac; }
.cartao.erro { background: var(--vermelho-claro); border-color: #fda29b; }
.cartao h3 { margin-top: 0; }
.aviso-conf { font-weight: 800; color: var(--ambar); margin: 0 0 6px; }
.seletor { background: var(--azul-claro); border: 1px solid #b9cbe3; border-radius: var(--raio); padding: 4px 12px 12px; margin-bottom: 12px; }
.vazio { color: var(--texto-2); text-align: center; padding: 22px 8px; }

.foto-previa { width: 100%; max-height: 280px; object-fit: contain; background: #000; border-radius: 10px; display: block; }
.analisando { display: flex; align-items: center; gap: 12px; font-weight: 700; padding: 12px 0; }
.giro { width: 28px; height: 28px; border-radius: 50%; border: 4px solid var(--azul-claro); border-top-color: var(--azul); animation: giro 0.9s linear infinite; flex: 0 0 auto; }
@keyframes giro { to { transform: rotate(360deg); } }

/* ---------- lista de bens ---------- */
.filtros { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.filtros > div { min-width: 0; }
.filtros .cheia { grid-column: 1 / -1; }
.contador { color: var(--texto-2); font-size: .95rem; margin: 10px 0 4px; }
.itens { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; gap: 12px; align-items: center;
  background: #fff; border: 1px solid var(--borda); border-radius: var(--raio);
  padding: 10px; margin: 8px 0; color: inherit; text-decoration: none; min-height: 76px;
}
.item .mini { width: 64px; height: 64px; flex: 0 0 64px; border-radius: 8px; object-fit: cover; background: var(--cinza-claro); }
.item .mini.sem { display: flex; align-items: center; justify-content: center; color: var(--texto-2); font-size: .7rem; text-align: center; }
.item .info { min-width: 0; flex: 1; }
.item .cod { font-weight: 800; font-size: 1rem; }
.item .sub { color: var(--texto-2); font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .tit { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.chip.aguardando_etiqueta { background: var(--ambar-claro); color: var(--ambar); }
.chip.etiquetado { background: var(--verde-claro); color: var(--verde); }
.chip.baixado { background: var(--cinza-claro); color: #374151; }

/* ---------- detalhe ---------- */
.foto-grande { width: 100%; max-height: 360px; object-fit: contain; background: #000; border-radius: var(--raio); display: block; }
.codigo-grande { font-size: 1.5rem; font-weight: 800; letter-spacing: .5px; margin: 12px 0 4px; word-break: break-all; }
dl.campos { margin: 8px 0; display: grid; grid-template-columns: minmax(96px, 38%) 1fr; gap: 6px 10px; }
dl.campos dt { color: var(--texto-2); font-weight: 600; }
dl.campos dd { margin: 0; min-width: 0; overflow-wrap: anywhere; white-space: pre-line; }

/* ---------- leitor de QR ---------- */
.leitor { width: 100%; min-height: 240px; background: #000; border-radius: var(--raio); overflow: hidden; position: relative; }
.leitor video { width: 100% !important; height: auto !important; display: block; }
.placar { display: flex; gap: 10px; margin: 10px 0; }
.placar > div { flex: 1; background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); padding: 8px 10px; text-align: center; }
.placar b { display: block; font-size: 1.7rem; line-height: 1.1; }
.placar span { font-size: .85rem; color: var(--texto-2); }
.pendentes { background: var(--ambar-claro); color: var(--ambar); font-weight: 700; border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.pendentes.zero { background: var(--verde-claro); color: var(--verde); }
.estados { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.estados .btn { padding: 6px 2px; font-size: .78rem; min-height: 48px; }
.estados .btn.marcado { background: var(--azul); color: #fff; }
.digitar { display: flex; gap: 8px; margin-top: 10px; }
.digitar input { flex: 1; min-width: 0; text-transform: uppercase; }
.digitar .btn { width: auto; }

/* ---------- resumo ---------- */
.numeros { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.numeros > div { background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); padding: 10px 12px; }
.numeros b { display: block; font-size: 1.8rem; line-height: 1.1; }
.numeros span { color: var(--texto-2); font-size: .9rem; }
.numeros .falta b { color: var(--vermelho); }
.numeros .dif b { color: var(--ambar); }
.numeros .acha b { color: var(--verde); }
.tabela { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--raio); overflow: hidden; font-size: .95rem; table-layout: fixed; }
.tabela th, .tabela td { padding: 8px 6px; border-bottom: 1px solid var(--cinza-claro); text-align: right; overflow-wrap: anywhere; }
.tabela th:first-child, .tabela td:first-child { text-align: left; width: 46%; }
.tabela th { background: var(--azul-claro); font-size: .85rem; }

/* ---------- cadastros ---------- */
.subabas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.subabas a { text-align: center; padding: 10px 2px; border-radius: 10px; background: #fff; border: 1px solid var(--borda); color: var(--texto); text-decoration: none; font-weight: 700; font-size: .9rem; min-height: 48px; display: flex; align-items: center; justify-content: center; }
.subabas a.ativa { background: var(--azul); border-color: var(--azul); color: #fff; }
.registro { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); padding: 8px 10px; margin: 8px 0; }
.registro .info { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.registro .info small { display: block; color: var(--texto-2); }
.registro.inativo { opacity: .6; }
.registro .btn { width: auto; padding: 8px 14px; }
.sugestoes { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.sugestoes .btn { width: auto; min-height: 44px; padding: 6px 14px; font-weight: 600; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 12px; right: 12px; z-index: 50;
  bottom: calc(var(--altura-abas) + 12px + env(safe-area-inset-bottom));
  max-width: 616px; margin: 0 auto;
  background: #0f2440; color: #fff; padding: 14px 16px; border-radius: 12px;
  font-weight: 700; box-shadow: 0 6px 20px #0005;
}
.toast.erro { background: var(--vermelho); }
.toast.ok { background: var(--verde); }

/* ---------- login e rodape ---------- */
.login { max-width: 420px; margin: 18px auto 0; }
.login .marca { text-align: center; margin: 10px 0 18px; }
.login .marca img { width: 84px; height: 84px; border-radius: 18px; }
.login .marca h2 { margin: 10px 0 0; }
.rodape { text-align: center; color: var(--texto-2); font-size: .85rem; margin-top: 28px; }
.rodape .fe { font-size: 11px; opacity: .7; margin-top: 6px; }

/* ---------- tour de apresentacao ---------- */
.tour { position: fixed; inset: 0; z-index: 100; }
.tour.sem-alvo { background: rgba(10, 20, 35, .66); }
.tour-foco {
  position: fixed; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(10, 20, 35, .66); outline: 3px solid #fff;
  transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease;
}
.tour-balao {
  position: fixed; left: 12px; right: 12px; max-width: 440px; margin: 0 auto;
  background: #fff; color: var(--texto); border-radius: 16px; padding: 16px 16px 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35);
}
.tour-passo { font-size: .85rem; font-weight: 700; color: var(--texto-2); }
.tour-balao h2 { margin: 4px 0 6px; font-size: 1.2rem; color: var(--azul); }
.tour-balao p { margin: 0 0 14px; }
.tour-botoes { display: flex; gap: 8px; }
.tour-botoes .btn { flex: 1 1 0; padding: 8px 10px; }
.tour-botoes .btn.pular { flex: 0 0 auto; width: auto; background: transparent; border-color: transparent; color: var(--texto-2); text-decoration: underline; }
.tour-botoes .btn[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { .tour-foco { transition: none; } }
