/* Separação — identidade Proauto Kimium: topo azul-marinho com faixa menta (a mesma dos relatórios e do
   Acompanhamento de Estoque). Sempre claro: é tela de chão de fábrica, com luva, sol e pressa —
   alvos grandes (48 px ou mais), texto grande e estado do item visível de longe. */
:root {
  --marinho: #273250;
  --marinho-2: #34406a;
  --menta: #82bba8;
  --menta-escura: #2f7a63;
  --menta-clara: #e3f1ec;
  --fundo: #eef2f6;
  --cartao: #ffffff;
  --texto: #1f2a37;
  --suave: #5b6778;
  --linha: #d9e0e8;
  --vermelho: #c0392b;
  --vermelho-claro: #fbe9e7;
  --ambar: #9a5b00;
  --ambar-claro: #fff4d6;
  --azul-claro: #e1eaf7;
  --raio: 12px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--fundo); color: var(--texto);
  font: 16px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- topo */
.topo {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  min-height: 56px; padding: calc(6px + env(safe-area-inset-top)) 12px 6px; background: var(--marinho); color: #fff;
}
.topo-voltar {
  width: 44px; height: 44px; margin-left: -6px; border: 0; border-radius: 10px; background: transparent; color: #fff;
  font-size: 34px; line-height: 1;
}
.topo-voltar:active { background: var(--marinho-2); }
.marca { display: flex; flex-direction: column; justify-content: center; gap: 1px; min-width: 0; flex: 1; }
.marca img { display: block; height: auto; width: auto; max-height: 20px; max-width: min(46vw, 210px); }
.marca-nome { font-weight: 600; font-size: 13px; letter-spacing: .6px; text-transform: uppercase; color: var(--menta);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quem { display: flex; align-items: center; gap: 8px; font-size: 14px; flex: none; }
.quem-nome { opacity: .9; max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 480px) { .quem-nome { display: none; } }
.topo-sair { border: 1px solid rgba(255,255,255,.45); background: transparent; color: #fff; border-radius: 8px; padding: 6px 10px; }
.faixa { height: 4px; background: var(--menta); }

.principal { max-width: 760px; margin: 0 auto; padding: 12px 12px 90px; }
.rodape { max-width: 760px; margin: 0 auto; padding: 0 12px 24px; color: var(--suave); font-size: 12px; text-align: center; }

/* ---------------------------------------------------------------- blocos */
.cartao {
  display: block; width: 100%; text-align: left; background: var(--cartao); border: 1px solid var(--linha);
  border-radius: var(--raio); padding: 14px; margin: 0 0 10px; box-shadow: 0 1px 2px rgba(31,42,55,.05);
}
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 19px; margin: 0 0 6px; }
.suave { color: var(--suave); }
.pequeno { font-size: 13px; }
.rotulo { display: block; font-weight: 600; margin: 0 0 6px; }
.grupo { display: flex; gap: 8px; align-items: stretch; }
.grupo input { flex: 1; min-width: 0; }
input[type=text], input[type=password], input:not([type]), input[inputmode] {
  height: 52px; padding: 0 14px; border: 1.5px solid var(--linha); border-radius: 10px; background: #fff; font-size: 18px;
}
input:focus { outline: none; border-color: var(--marinho); box-shadow: 0 0 0 3px rgba(39,50,80,.15); }
label.campo { display: block; margin: 0 0 12px; font-weight: 600; }
label.campo input { display: block; width: 100%; margin-top: 6px; font-weight: 400; }

.bt {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 18px;
  border: 0; border-radius: 10px; background: var(--marinho); color: #fff; font-weight: 600; font-size: 17px;
}
.bt:active { background: var(--marinho-2); }
.bt[disabled] { opacity: .55; }
.bt-sec { background: #fff; color: var(--marinho); border: 1.5px solid var(--marinho); }
.bt-sec:active { background: var(--azul-claro); }
.bt-menta { background: var(--menta-escura); }
.bt-grande { width: 100%; min-height: 60px; font-size: 19px; }
.bt-link { background: transparent; color: var(--marinho); text-decoration: underline; padding: 0 8px; min-height: 44px; }
.bt-icone { min-width: 48px; min-height: 48px; border: 1.5px solid var(--linha); border-radius: 10px; background: #fff; font-size: 22px; }

/* ---------------------------------------------------------------- situação */
.sit {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap;
}
.sit.sem_lote { background: #e7eaee; color: #394452; }
.sit.parcial { background: var(--ambar-claro); color: var(--ambar); }
.sit.completo { background: var(--menta-clara); color: var(--menta-escura); }
.sit.sem_controle { background: #f1f3f5; color: #6b7280; }
.sit.faturado { background: var(--azul-claro); color: #23408e; }
.sit.rascunho { background: #fff; color: var(--ambar); border: 1.5px dashed var(--ambar); }

/* ---------------------------------------------------------------- entrar */
.entrar { margin-top: 18px; padding: 20px; }
.entrar .bt-grande { margin-top: 6px; }

/* ---------------------------------------------------------------- ordem */
.recentes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.recentes button { border: 1px solid var(--linha); background: #fff; border-radius: 999px; padding: 8px 14px; min-height: 40px; }
.resumo-ordem { margin: 14px 2px 10px; }
.resumo-ordem b { font-size: 18px; }
.contagem { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.pedido { border-left: 6px solid var(--linha); }
.pedido.sit-completo { border-left-color: var(--menta); }
.pedido.sit-parcial { border-left-color: #e0a100; }
.pedido.sit-faturado { border-left-color: #7d97d6; }
.pedido .linha1 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pedido .num { font-weight: 700; font-size: 18px; }
.pedido .parceiro { font-weight: 600; margin: 4px 0 2px; }
.empresas { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ---------------------------------------------------------------- pedido */
.cab-pedido { position: relative; padding-right: 70px; }
.cab-pedido .linha1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cab-pedido .bt-icone { position: absolute; top: 12px; right: 12px; }
.cab-pedido .parceiro { font-weight: 700; font-size: 18px; margin: 6px 0 2px; }
.leitura { position: sticky; top: calc(62px + env(safe-area-inset-top)); z-index: 5; padding: 10px; }
.linha-leitura { display: flex; gap: 8px; align-items: stretch; }
.linha-leitura input { flex: 1; min-width: 0; font-size: 16px; }
.linha-leitura .bt { padding: 0 14px; }
.bt-camera-mini { flex: none; background: var(--marinho); }
.item { border-left: 6px solid #c5ccd6; }
.item.sit-completo { border-left-color: var(--menta); }
.item.sit-parcial { border-left-color: #e0a100; }
.item.sit-sem_controle, .item.sit-faturado { opacity: .78; }
.item .linha1 { display: flex; gap: 10px; align-items: baseline; }
.item .cod { font-weight: 800; font-size: 20px; color: var(--marinho); }
.item .descr { font-weight: 600; }
.item .linha2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 6px; }
.item .qtd { font-size: 22px; font-weight: 800; }
.lotes { list-style: none; margin: 6px 0 0; padding: 0; }
.lotes li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 0 0 6px; border-radius: 10px;
  background: var(--fundo); min-height: 48px;
}
.lotes .lote { font-weight: 700; font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 16px; }
.lotes .q { font-weight: 700; margin-left: auto; white-space: nowrap; }
.lotes .val { color: var(--suave); font-size: 13px; white-space: nowrap; }
.lotes .val.vencido { color: var(--vermelho); font-weight: 700; }
.lotes .x { width: 44px; height: 44px; border: 0; border-radius: 10px; background: #fff; color: var(--vermelho); font-size: 20px; flex: none; }
.lotes li.sem { background: repeating-linear-gradient(45deg, #fff, #fff 8px, #f3f5f8 8px, #f3f5f8 16px); }
.acoes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.acoes .bt { flex: 1 1 auto; }
.gravando { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--azul-claro); color: #23408e; font-weight: 600; }
.motivo { margin-top: 6px; font-size: 14px; }
.alerta { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--ambar-claro); color: var(--ambar); font-weight: 600; }
.vazio { text-align: center; color: var(--suave); padding: 30px 10px; }
.carregando { text-align: center; color: var(--suave); padding: 24px 10px; }
.carregando::before {
  content: ""; display: inline-block; width: 18px; height: 18px; margin-right: 8px; vertical-align: -3px;
  border: 3px solid var(--linha); border-top-color: var(--marinho); border-radius: 50%; animation: gira .8s linear infinite;
}
@keyframes gira { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- folha (de baixo para cima) */
.folha { position: fixed; inset: 0; z-index: 40; }
.folha-fundo { position: absolute; inset: 0; background: rgba(15,20,35,.45); }
.folha-caixa {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto; background: #fff;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,.18); max-width: 760px; margin: 0 auto;
}
.info-lote { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.info-lote div { background: var(--fundo); border-radius: 10px; padding: 8px 10px; }
.info-lote dt { font-size: 12px; color: var(--suave); }
.info-lote dd { margin: 2px 0 0; font-weight: 700; font-size: 17px; }
.info-lote dd.vencido { color: var(--vermelho); }
.qtd-linha { display: flex; gap: 8px; align-items: center; }
.qtd-linha input { flex: 1; font-size: 24px; font-weight: 700; text-align: right; }
.qtd-linha .un { font-size: 20px; font-weight: 700; min-width: 34px; }
.sugestoes { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 2px; }
.sugestoes button { border: 1px solid var(--linha); background: #fff; border-radius: 999px; padding: 8px 12px; min-height: 40px; }
.qtd-aviso { min-height: 22px; margin: 8px 0 0; font-weight: 600; }
.qtd-aviso.erro { color: var(--vermelho); }
.qtd-aviso.atencao { color: var(--ambar); }
.marcar { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-weight: 600; color: var(--vermelho); min-height: 44px; }
.marcar input { width: 24px; height: 24px; }
.lista-lotes { list-style: none; padding: 0; margin: 10px 0; }
.lista-lotes button {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; width: 100%; text-align: left; padding: 12px;
  margin: 0 0 8px; border: 1.5px solid var(--linha); border-radius: 12px; background: #fff; min-height: 60px;
}
.lista-lotes button:active { border-color: var(--marinho); }
.lista-lotes .lote { font-weight: 800; font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 17px; }
.lista-lotes .saldo { font-weight: 700; text-align: right; }
.lista-lotes .val { font-size: 13px; color: var(--suave); }
.lista-lotes .val.vencido { color: var(--vermelho); font-weight: 700; }
.lista-lotes .livre { font-size: 13px; text-align: right; color: var(--suave); }
.lista-lotes .livre.pouco { color: var(--ambar); font-weight: 700; }
.lista-lotes .primeiro { grid-column: 1 / -1; font-size: 12px; font-weight: 700; color: var(--menta-escura); }
.folha .acoes { margin-top: 14px; }
.escolher-item button { display: block; width: 100%; text-align: left; margin: 0 0 8px; }

/* ---------------------------------------------------------------- diálogo */
.dialogo { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(15,20,35,.5); }
.dialogo-caixa { width: 100%; max-width: 440px; background: #fff; border-radius: 16px; padding: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.dialogo-texto { white-space: pre-line; margin: 6px 0 16px; }
.dialogo-botoes { display: flex; gap: 10px; justify-content: flex-end; }
.dialogo-botoes .bt { flex: 1; }
.dialogo.erro h2 { color: var(--vermelho); }

/* ---------------------------------------------------------------- câmera */
.camera { position: fixed; inset: 0; z-index: 80; background: #000; }
.camera video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mira {
  position: absolute; left: 50%; top: 45%; width: 62vmin; height: 62vmin; transform: translate(-50%, -50%);
  border: 4px solid var(--menta); border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35);
}
.camera-texto { position: absolute; left: 0; right: 0; top: calc(45% + 34vmin); text-align: center; color: #fff;
  font-weight: 600; text-shadow: 0 1px 3px #000; padding: 0 20px; }
.camera-botoes { position: absolute; left: 0; right: 0; bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex; gap: 12px; justify-content: center; }
.bt-camera { min-width: 130px; min-height: 54px; border-radius: 12px; border: 2px solid #fff; background: rgba(0,0,0,.45);
  color: #fff; font-weight: 700; font-size: 17px; }

/* ---------------------------------------------------------------- aviso */
.aviso {
  position: fixed; left: 12px; right: 12px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 70;
  max-width: 560px; margin: 0 auto; padding: 14px 16px; border-radius: 12px; background: var(--marinho); color: #fff;
  font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.aviso.ok { background: var(--menta-escura); }
.aviso.erro { background: var(--vermelho); }

@media (min-width: 700px) {
  .principal { padding-top: 18px; }
  .folha-caixa { border-radius: 18px; bottom: 20px; left: 20px; right: 20px; }
}
