/* Contagem Quitanda: celular primeiro, letras e botões grandes. */
:root {
  --fundo: #F4F5F2;
  --papel: #FFFFFF;
  --texto: #1B1E1C;
  --suave: #4E5550;
  --linha: #D5D9D3;
  --primaria: #0A4F96;
  --primaria-escura: #073A70;
  --perigo: #B3261E;
  --alerta-fundo: #FFF4D6;
  --alerta-borda: #B7791F;
  --ok: #1E6B34;
  --foco: #F2A900;
  --raio: 12px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fundo); color: var(--texto);
  font: 18px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3 { line-height: 1.2; text-wrap: balance; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; margin-top: 1.4em; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
a { color: var(--primaria); }
main { max-width: 960px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-left)) 96px; outline: none; }
.pular { position: absolute; left: -999px; top: 8px; background: var(--papel); padding: 12px; z-index: 10; }
.pular:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--foco); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a.botao, label.botao { touch-action: manipulation; }

/* Topo */
.topo {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--papel); border-bottom: 1px solid var(--linha);
  padding: 10px max(16px, env(safe-area-inset-left)); position: sticky; top: 0; z-index: 5;
}
.marca { font-weight: 800; font-size: 1.15rem; color: var(--texto); text-decoration: none; padding: 8px 0; }
#menu { display: flex; gap: 4px; flex-wrap: wrap; }
#menu a, #menu button {
  background: none; border: 0; color: var(--primaria); padding: 10px 10px; min-height: 44px;
  text-decoration: none; cursor: pointer; border-radius: 8px; font-size: 1rem;
}
#menu a[aria-current="page"] { font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }

/* Botões */
.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 20px; border-radius: var(--raio); border: 2px solid var(--primaria);
  background: var(--primaria); color: #fff; font-weight: 700; text-decoration: none; cursor: pointer; text-align: center;
}
.botao:hover { background: var(--primaria-escura); border-color: var(--primaria-escura); }
.botao:disabled { opacity: .55; cursor: not-allowed; }
.botao.secundario { background: var(--papel); color: var(--primaria); }
.botao.secundario:hover { background: #E8EEF6; }
.botao.perigo { background: var(--perigo); border-color: var(--perigo); }
.botao.perigo.secundario { background: var(--papel); color: var(--perigo); }
.botao.ok { background: var(--ok); border-color: var(--ok); }
.botao.grande { width: 100%; min-height: 72px; font-size: 1.3rem; }
.botao.pequeno { min-height: 44px; padding: 8px 14px; font-size: 1rem; }
.botao.cheio { width: 100%; }
.acoes { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.acoes > * { flex: 1 1 200px; }

/* Cartões e listas */
.cartao { background: var(--papel); border: 1px solid var(--linha); border-radius: var(--raio); padding: 16px; margin: 0 0 12px; }
.lista { list-style: none; padding: 0; margin: 0; }
.lista-item a {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center;
  background: var(--papel); border: 1px solid var(--linha); border-radius: var(--raio);
  padding: 14px; margin-bottom: 10px; color: var(--texto); text-decoration: none; min-height: 72px;
}
.lista-item a:hover { border-color: var(--primaria); }
.lista-item .meta { color: var(--suave); font-size: .95rem; grid-column: 1 / -1; }
.vazio { color: var(--suave); padding: 24px 0; }

/* Loja em destaque (cor de cada loja vem do banco) */
.loja-selo {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px;
  color: #fff; font-weight: 800; font-size: .95rem; background: var(--cor-loja, #37474F); white-space: nowrap;
}
.loja-faixa {
  border-left: 10px solid var(--cor-loja, #37474F); background: var(--papel); border-radius: var(--raio);
  padding: 12px 16px; margin-bottom: 16px; border-top: 1px solid var(--linha); border-right: 1px solid var(--linha); border-bottom: 1px solid var(--linha);
}
.loja-faixa .loja-nome { font-size: 1.4rem; font-weight: 800; color: var(--cor-loja, #37474F); }
.escolha-loja { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .escolha-loja { grid-template-columns: 1fr 1fr; } }
.escolha-loja label {
  display: flex; flex-direction: column; justify-content: center; min-height: 96px; padding: 16px;
  border: 3px solid var(--cor-loja); border-radius: var(--raio); background: var(--papel); cursor: pointer;
  color: var(--cor-loja); font-weight: 800; font-size: 1.35rem; line-height: 1.2;
}
.escolha-loja label small { font-weight: 600; font-size: 1rem; color: var(--suave); }
.escolha-loja input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.escolha-loja input:checked + label { background: var(--cor-loja); color: #fff; }
.escolha-loja input:checked + label small { color: #fff; }
.escolha-loja input:focus-visible + label { outline: 3px solid var(--foco); outline-offset: 3px; }
.escolha-loja input:checked + label::before { content: "✓ Escolhida"; font-size: .95rem; margin-bottom: 4px; }

.opcoes { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) { .opcoes { grid-template-columns: 1fr 1fr; } }
.opcoes label {
  display: flex; gap: 12px; align-items: center; min-height: 60px; padding: 12px 14px;
  border: 2px solid var(--linha); border-radius: var(--raio); background: var(--papel); cursor: pointer; font-weight: 600;
}
.opcoes input { width: 24px; height: 24px; accent-color: var(--primaria); }
.opcoes label:has(input:checked) { border-color: var(--primaria); background: #E8EEF6; }

/* Status */
.status {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-weight: 700; font-size: .9rem; border: 2px solid currentColor; background: var(--papel); white-space: nowrap;
}
.status::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.st-recebida { color: #455A64; }
.st-em_leitura, .st-lida { color: #8A5A00; }
.st-calculada { color: #0A4F96; }
.st-aprovada { color: #1E6B34; }
.st-lancada { color: #0F4A23; }
.st-recusada, .st-erro { color: #B3261E; }
.st-enviando { color: #6B4E00; }

/* Formulários */
.campo { margin: 0 0 18px; }
.campo > label, .rotulo { display: block; font-weight: 700; margin-bottom: 6px; }
.campo .ajuda { color: var(--suave); font-size: .95rem; margin: 4px 0 0; }
input[type="text"], input[type="password"], input[type="datetime-local"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; min-height: 52px; padding: 10px 12px; border: 2px solid #8C948E; border-radius: 10px; background: var(--papel);
}
textarea { min-height: 96px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--primaria); }
.erro-campo { color: var(--perigo); font-weight: 600; margin: 6px 0 0; }
[aria-invalid="true"] { border-color: var(--perigo) !important; }
fieldset { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
legend { font-weight: 800; font-size: 1.15rem; margin-bottom: 10px; padding: 0; }
.horas { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .horas { grid-template-columns: 1fr 1fr; } }

/* Fotos */
.fotos-botoes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.fotos-botoes input[type="file"] { position: absolute; opacity: 0; width: 1px; height: 1px; }
.fotos-botoes input[type="file"]:focus-visible + label { outline: 3px solid var(--foco); outline-offset: 2px; }
.grade-fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; list-style: none; padding: 0; margin: 0; }
.foto-previa { background: var(--papel); border: 1px solid var(--linha); border-radius: var(--raio); padding: 8px; }
.foto-previa .moldura { aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; background: #E9ECE8; border-radius: 8px; }
.foto-previa img { max-width: 100%; max-height: 100%; transition: transform .2s; }
.foto-previa .sem-previa { padding: 8px; text-align: center; color: var(--suave); font-size: .9rem; overflow-wrap: anywhere; }
.foto-previa .botoes { display: flex; gap: 6px; margin-top: 8px; }
.foto-previa .botoes button { flex: 1; min-height: 44px; }
.foto-miniatura { display: block; width: 100%; padding: 0; border: 1px solid var(--linha); border-radius: var(--raio); background: #E9ECE8; cursor: zoom-in; aspect-ratio: 1; overflow: hidden; }
.foto-miniatura img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Progresso e fila */
progress { width: 100%; height: 18px; accent-color: var(--primaria); }
.fila-aviso { background: var(--alerta-fundo); border-bottom: 2px solid var(--alerta-borda); padding: 10px 16px; font-weight: 600; }
.envio { background: var(--papel); border: 2px dashed var(--alerta-borda); border-radius: var(--raio); padding: 14px; margin-bottom: 12px; }

/* Avisos */
.aviso {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 600px; margin: 0 auto; background: #1B1E1C; color: #fff; border-radius: var(--raio);
  padding: 14px 16px; font-weight: 600; opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.aviso.visivel { opacity: 1; transform: none; }
.aviso.erro { background: var(--perigo); }
.alerta { background: var(--alerta-fundo); border: 2px solid var(--alerta-borda); border-radius: var(--raio); padding: 12px 14px; margin: 0 0 14px; }
.alerta ul { margin: 6px 0 0; padding-left: 20px; }
.erro-geral { color: var(--perigo); font-weight: 700; }
.carregando { color: var(--suave); }

/* Detalhe */
.dados { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
.dados dt { color: var(--suave); }
.dados dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.linha-tempo { list-style: none; padding: 0; margin: 0; border-left: 3px solid var(--linha); }
.linha-tempo li { padding: 4px 0 10px 14px; position: relative; }
.linha-tempo li::before { content: ""; position: absolute; left: -8px; top: 10px; width: 13px; height: 13px; border-radius: 50%; background: var(--suave); }
.linha-tempo time { color: var(--suave); font-size: .9rem; display: block; }

/* Conferência: cartões no celular, tabela no computador */
.conf { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.conf th { text-align: left; font-size: .9rem; color: var(--suave); padding: 8px; border-bottom: 2px solid var(--linha); }
.conf td { padding: 10px 8px; border-bottom: 1px solid var(--linha); vertical-align: top; }
.conf .num { text-align: right; }
.conf tr.grande { background: #FFF1E0; }
.conf tr.ignorada { opacity: .55; }
.conf tr.ignorada .produto { text-decoration: line-through; }
.conf tr.pendente { background: #FDECEA; }
.ajuste-grande { color: #9A3B00; font-weight: 800; }
.confianca { font-weight: 700; font-size: .9rem; }
.cf-certa { color: var(--ok); }
.cf-duvidosa { color: #8A5A00; }
.cf-nao_encontrada { color: var(--perigo); }
.recorte { max-width: 160px; max-height: 60px; border: 1px solid var(--linha); border-radius: 6px; background: #fff; }
.correcao { font-size: .85rem; color: var(--suave); margin-top: 4px; }
.edicao { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.edicao input[type="number"] { width: 120px; min-height: 44px; }
.busca-produto ul { list-style: none; padding: 0; margin: 6px 0 0; max-height: 260px; overflow: auto; border: 1px solid var(--linha); border-radius: 8px; }
.busca-produto li button { width: 100%; text-align: left; background: var(--papel); border: 0; border-bottom: 1px solid var(--linha); padding: 12px; min-height: 48px; cursor: pointer; }
.busca-produto li button:hover { background: #E8EEF6; }
@media (max-width: 759px) {
  .conf thead { position: absolute; left: -9999px; }
  .conf, .conf tbody, .conf tr, .conf td { display: block; width: 100%; }
  .conf tr { border: 1px solid var(--linha); border-radius: var(--raio); margin-bottom: 12px; padding: 8px 12px; background: var(--papel); }
  .conf tr.grande { background: #FFF1E0; }
  .conf tr.pendente { background: #FDECEA; }
  .conf td { border: 0; padding: 4px 0; display: grid; grid-template-columns: 9.5em 1fr; gap: 8px; text-align: left; }
  .conf td::before { content: attr(data-rotulo); color: var(--suave); font-size: .9rem; }
  .conf .num { text-align: left; }
  .conf td > .correcao, .conf td > .alerta, .conf td > .busca-produto, .conf td > .edicao { grid-column: 1 / -1; }
}
.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 14px; }
.filtros a { padding: 8px 14px; min-height: 44px; display: inline-flex; align-items: center; border-radius: 999px; border: 2px solid var(--linha); background: var(--papel); text-decoration: none; color: var(--texto); font-weight: 600; }
.filtros a[aria-current="true"] { border-color: var(--cor-loja, var(--primaria)); background: var(--cor-loja, var(--primaria)); color: #fff; }
.tabela-rolagem { overflow-x: auto; }
.tabela-simples { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tabela-simples th, .tabela-simples td { text-align: left; padding: 8px; border-bottom: 1px solid var(--linha); vertical-align: top; }
.senha-temporaria { font-family: ui-monospace, Consolas, monospace; font-size: 1.4rem; letter-spacing: .05em; background: #fff; padding: 8px 12px; border: 2px dashed var(--primaria); border-radius: 8px; display: inline-block; user-select: all; }
.ampliar { width: min(96vw, 1200px); max-height: 96vh; padding: 0; border: 0; border-radius: var(--raio); overscroll-behavior: contain; }
.ampliar::backdrop { background: rgba(0,0,0,.75); }
.ampliar-barra { display: flex; gap: 8px; justify-content: flex-end; padding: 8px; position: sticky; top: 0; background: var(--papel); }
.ampliar img { display: block; max-width: 100%; margin: 0 auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
