:root {
  --fundo: #0b0d10; --tinta: #f5f7fa; --sutil: #9aa4b2; --amarelo: #ffcc00; --verde: #22c55e;
  --vermelho: #ef4444; --painel: #151920; --borda: #262c36;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--fundo); color: var(--tinta);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* Ativação */
#ativar { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.ativar-caixa { width: min(420px, 100%); }
.ativar-caixa h1 { font-size: 34px; margin: 0 0 8px; }
.ativar-caixa h1 span { color: var(--amarelo); }
#form-ativar { display: grid; gap: 10px; margin-top: 16px; }
.erro-texto { color: var(--vermelho); min-height: 1.5em; }

/* Captura */
#tela { position: fixed; inset: 0; }
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }

#produto { position: absolute; top: 0; left: 0; right: 0; padding: calc(env(safe-area-inset-top) + 14px) 16px 16px;
  background: linear-gradient(rgba(0,0,0,.85), rgba(0,0,0,.55)); border-bottom: 6px solid var(--borda);
  transition: border-color .15s, background .15s; }
#produto-codigo { font-size: 15px; color: var(--sutil); font-variant-numeric: tabular-nums; letter-spacing: .03em; }
#produto-nome { font-size: clamp(26px, 7vw, 46px); font-weight: 800; line-height: 1.1; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
#produto.aguardando #produto-nome { color: var(--sutil); font-weight: 600; }
#produto.ok { border-color: var(--verde); }
#produto.atencao { border-color: var(--amarelo); }
#produto.desconhecido { border-color: var(--vermelho); background: linear-gradient(rgba(80,0,0,.9), rgba(60,0,0,.6)); }

#mira { position: absolute; left: 12%; right: 12%; top: 42%; height: 18%; border: 3px solid rgba(255,255,255,.55);
  border-radius: 14px; pointer-events: none; }
#tela.com-produto #mira { border-color: var(--verde); }

#flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#flash.ativo { animation: flash .3s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }

#aviso { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); padding: 14px 22px; border-radius: 14px;
  font-size: 22px; font-weight: 800; background: rgba(0,0,0,.8); opacity: 0; transition: opacity .2s; pointer-events: none;
  text-align: center; max-width: 90vw; }
#aviso.visivel { opacity: 1; }
#aviso.ok { background: var(--verde); color: #04130a; }
#aviso.erro { background: var(--vermelho); }

.alerta { position: absolute; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 170px); z-index: 2;
  padding: 12px 14px; border: 0; border-radius: 12px; background: var(--vermelho); color: #fff; font-weight: 700; font-size: 15px;
  text-align: left; line-height: 1.3; box-shadow: 0 4px 20px rgba(0,0,0,.4); }
.chips.com-problema .chip.erro { background: var(--vermelho); animation: pisca 1.2s ease-in-out infinite; }
.chips.com-problema .chip.erro b { color: #fff; }
@keyframes pisca { 50% { opacity: .55; } }

#barra { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 16px calc(env(safe-area-inset-bottom) + 18px);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: linear-gradient(transparent, rgba(0,0,0,.85) 40%); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; background: none; border: 0; padding: 0; }
.chip { font-size: 13px; padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.12); white-space: nowrap; }
.chip b { font-variant-numeric: tabular-nums; }
.chip.local b { color: var(--amarelo); }
.chip.bling b { color: var(--verde); }
.chip.erro b { color: var(--vermelho); }
.chip.rede { color: var(--vermelho); }
.chip.rede.online { color: var(--verde); }

#btn-foto { width: 86px; height: 86px; border-radius: 50%; border: 6px solid #fff; background: var(--amarelo);
  box-shadow: 0 4px 24px rgba(0,0,0,.5); transition: transform .08s, opacity .15s; touch-action: manipulation; }
#btn-foto:active { transform: scale(.92); }
#btn-foto:disabled { opacity: .35; background: #666; }
.lateral { position: absolute; right: 20px; bottom: calc(env(safe-area-inset-bottom) + 34px); width: 52px; height: 52px;
  border-radius: 50%; border: 0; background: rgba(255,255,255,.15); font-size: 22px; }
.lateral.ligada { background: var(--amarelo); }

/* Painel */
dialog#painel { width: min(560px, 100vw); max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0 0 0 auto;
  border: 0; padding: 0 16px 32px; background: var(--painel); color: var(--tinta); overflow-y: auto; }
dialog::backdrop { background: rgba(0,0,0,.6); }
.painel-topo { display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0;
  background: var(--painel); padding: 14px 0; border-bottom: 1px solid var(--borda); }
.painel-topo h2 { margin: 0; font-size: 20px; }
.fechar { background: none; border: 0; font-size: 24px; padding: 4px 8px; }
dialog section { padding: 14px 0; border-bottom: 1px solid var(--borda); }
h3 { margin: 0 0 10px; font-size: 14px; color: var(--sutil); text-transform: uppercase; letter-spacing: .06em; }
.linha { display: flex; gap: 8px; flex-wrap: wrap; }
.linha button, .linha input { min-height: 44px; }
dialog button, #ativar button { background: #232a35; border: 1px solid var(--borda); border-radius: 10px; padding: 8px 14px; min-height: 44px; }
button.primario { background: var(--amarelo) !important; color: #111 !important; border-color: var(--amarelo) !important; font-weight: 700; }
input { font: inherit; color: var(--tinta); background: #0f1217; border: 1px solid var(--borda); border-radius: 10px;
  padding: 10px 12px; flex: 1; min-width: 0; width: 100%; }
.sutil { color: var(--sutil); font-size: 14px; margin: 8px 0; }
.botao-link { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px; border-radius: 10px; background: #232a35; border: 1px solid var(--borda); color: var(--tinta); text-decoration: none; }
.resumo { font-size: 17px; font-weight: 700; margin: 4px 0; }
#lista-fotos { list-style: none; padding: 0; margin: 12px 0 0; }
#lista-fotos li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--borda); font-size: 14px; }
#lista-fotos img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; background: #000; flex: none; }
#lista-fotos .info { flex: 1; min-width: 0; display: grid; }
#lista-fotos .info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lista-fotos .info span { color: var(--sutil); font-size: 13px; }
#lista-fotos .info .msg { color: var(--vermelho); }
.selo { flex: none; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,.1); }
.selo.ok { color: var(--verde); }
.selo.fila { color: var(--amarelo); }
.selo.erro { color: var(--vermelho); }
#lista-fotos .reenviar { flex: none; min-height: 36px; padding: 4px 10px; font-size: 13px; }
.selo.semfoto { color: #fff; background: #6b3f00; }
#lista-fotos li.sem-foto img { opacity: .25; }
