/* Clother · estoque — identidade "luxo silencioso" (mesma paleta do site) */
:root {
  --bg: #F3F0E9; --card: #FBFAF6; --linha: #E5DFD4; --tinta: #171713; --tinta2: #4D463A; --suave: #8A8273;
  --ok: #2F6B3F; --ok-bg: #E3EEDF; --alerta: #9A6A12; --alerta-bg: #F6EBD2; --perigo: #A33A2B; --perigo-bg: #F6E0DA;
  --full: #2D5B8A; --full-bg: #DFE8F2;
  --raio: 14px; --sombra: 0 1px 2px rgba(23,23,19,.06), 0 4px 16px rgba(23,23,19,.05);
  --fonte: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; --mono: 'Geist Mono', ui-monospace, Menlo, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--tinta); font-family: var(--fonte); font-size: 16px; line-height: 1.4; }
body { min-height: 100dvh; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1 { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin: 6px 0 2px; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--suave); margin: 26px 0 10px; }
.sub { color: var(--suave); font-size: 14px; margin: 0 0 16px; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: .01em; }

/* topo e abas */
.topo { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top, 0px)) 18px 10px; background: var(--tinta); color: var(--bg); }
.marca { display: block; color: var(--bg); line-height: 0; }
.marca svg { height: 15px; width: auto; }
.topo-dir { display: flex; align-items: center; gap: 10px; font-size: 13px; opacity: .85; }
.sync { width: 8px; height: 8px; border-radius: 50%; background: #7FB38A; transition: background .3s; }
.sync.off { background: #D98068; }
.app { max-width: 760px; margin: 0 auto; padding: 14px 16px calc(96px + var(--safe-b)); }
.abas { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--card); border-top: 1px solid var(--linha); padding: 6px 4px calc(6px + var(--safe-b)); }
.abas a { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 11px; color: var(--suave); padding: 4px 0; }
.abas a .ic { font-size: 20px; line-height: 1.1; }
.abas a.ativa { color: var(--tinta); font-weight: 600; }
.abas .aba-central .ic { background: var(--tinta); color: var(--bg); width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; margin-top: -22px; box-shadow: 0 6px 18px rgba(23,23,19,.25); font-size: 22px; }
.abas .aba-central { color: var(--tinta); font-weight: 600; }

/* blocos */
.card { background: var(--card); border: 1px solid var(--linha); border-radius: var(--raio); padding: 16px; box-shadow: var(--sombra); }
.card + .card { margin-top: 12px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--linha); border-radius: var(--raio); padding: 14px; }
.kpi b { display: block; font-size: 30px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.kpi span { font-size: 13px; color: var(--suave); }
.kpi.escuro { background: var(--tinta); color: var(--bg); border-color: var(--tinta); }
.kpi.escuro span { color: #C9C2B3; }
.kpi.alerta b { color: var(--alerta); }
.kpi.full b { color: var(--full); }
.acoes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.acao { display: flex; align-items: center; gap: 10px; padding: 16px 14px; background: var(--card); border: 1px solid var(--linha); border-radius: var(--raio); font-weight: 600; font-size: 15px; cursor: pointer; text-align: left; }
.acao .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--linha); font-size: 18px; flex: none; }
.acao.entrada .ic { background: var(--ok-bg); color: var(--ok); }
.acao.venda .ic { background: var(--perigo-bg); color: var(--perigo); }
.acao.full .ic { background: var(--full-bg); color: var(--full); }

.lista { background: var(--card); border: 1px solid var(--linha); border-radius: var(--raio); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-top: 1px solid var(--linha); }
.item:first-child { border-top: 0; }
.item .meio { flex: 1; min-width: 0; }
.item .t { font-weight: 600; font-size: 15px; }
.item .s { font-size: 13px; color: var(--suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .num { font-weight: 600; font-size: 17px; font-variant-numeric: tabular-nums; }
.vazio { padding: 22px 16px; text-align: center; color: var(--suave); font-size: 14px; }
.bolinha { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); flex: none; display: inline-block; vertical-align: -2px; }
.etq { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 20px; background: var(--linha); color: var(--tinta2); }
.etq.entrada { background: var(--ok-bg); color: var(--ok); }
.etq.venda, .etq.saida { background: var(--perigo-bg); color: var(--perigo); }
.etq.transferencia { background: var(--full-bg); color: var(--full); }
.etq.ajuste, .etq.contagem { background: var(--alerta-bg); color: var(--alerta); }
.riscado { text-decoration: line-through; opacity: .55; }

/* botões e campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--linha); background: var(--card); font-weight: 600; font-size: 15px; cursor: pointer; }
.btn.prim { background: var(--tinta); color: var(--bg); border-color: var(--tinta); }
.btn.grande { width: 100%; min-height: 54px; font-size: 16px; }
.btn.perigo { color: var(--perigo); }
.btn.peq { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .45; }
.linha-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.linha-btns > .btn { flex: 1; }
label.campo { display: block; font-size: 13px; color: var(--tinta2); font-weight: 500; margin-bottom: 12px; }
.campo input, .campo select, .campo textarea, input.in { display: block; width: 100%; margin-top: 5px; min-height: 46px; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--linha); background: #fff; font-size: 16px; }
.campo input:focus, input.in:focus { outline: 2px solid var(--tinta2); outline-offset: 0; border-color: transparent; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { flex: none; min-height: 40px; padding: 0 15px; border-radius: 22px; border: 1px solid var(--linha); background: var(--card); font-weight: 600; font-size: 14px; cursor: pointer; }
.chip.on { background: var(--tinta); color: var(--bg); border-color: var(--tinta); }
.chip.on.entrada { background: var(--ok); border-color: var(--ok); }
.chip.on.venda, .chip.on.saida { background: var(--perigo); border-color: var(--perigo); }
.chip.on.transferencia { background: var(--full); border-color: var(--full); }

/* grade de estoque (cor × tamanho) */
.prod-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.prod-head b { font-size: 17px; }
.grade-wrap { overflow-x: auto; margin: 0 -4px; }
table.grade { width: 100%; border-collapse: separate; border-spacing: 3px; font-variant-numeric: tabular-nums; }
.grade th { font-size: 12px; font-weight: 600; color: var(--suave); text-align: center; padding: 2px; }
.grade th.cor { text-align: left; font-weight: 500; color: var(--tinta); font-size: 13px; line-height: 1.2; padding-right: 4px; width: 1%; min-width: 64px; max-width: 96px; }
.grade th.cor .bolinha { margin-right: 3px; }
.grade td { text-align: center; padding: 0; }
.cel { display: block; min-width: 34px; padding: 9px 2px; border-radius: 9px; background: #fff; border: 1px solid var(--linha); font-weight: 600; font-size: 16px; cursor: pointer; position: relative; }
.cel.zero { color: #B8B0A0; background: transparent; }
.cel.baixo { background: var(--alerta-bg); border-color: #E7CF9C; color: var(--alerta); }
.cel.nada { background: var(--perigo-bg); border-color: #EBC2B8; color: var(--perigo); }
.cel sup { position: absolute; top: 2px; right: 4px; font-size: 10px; color: var(--full); font-weight: 600; }
.grade td.tot, .grade th.tot { color: var(--suave); font-size: 13px; font-weight: 600; }
.grade input { width: 100%; min-width: 34px; height: 42px; text-align: center; border: 1px solid var(--linha); border-radius: 9px; background: #fff; font-size: 16px; font-weight: 600; padding: 0; }
.grade input:focus { outline: 2px solid var(--tinta2); }
.legenda { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--suave); margin-top: 8px; }
.legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* movimentar / carrinho */
.leitor-linha { display: flex; gap: 8px; }
.leitor-linha input { flex: 1; margin: 0; font-family: var(--mono); text-transform: uppercase; }
.leitor-linha input::placeholder { text-transform: none; font-family: var(--fonte); }
.carrinho .item .qtd { display: flex; align-items: center; gap: 6px; }
.qbtn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--linha); background: #fff; font-size: 18px; font-weight: 600; cursor: pointer; }
.qtd input { width: 52px; height: 36px; text-align: center; border: 1px solid var(--linha); border-radius: 10px; font-weight: 600; font-size: 16px; }
.resumo-barra { position: sticky; bottom: calc(72px + var(--safe-b)); margin: 14px -16px 0; padding: 10px 16px; background: linear-gradient(transparent, var(--bg) 22%); }
.aviso { padding: 12px 14px; border-radius: 12px; font-size: 14px; margin: 10px 0; }
.aviso.erro { background: var(--perigo-bg); color: var(--perigo); }
.aviso.info { background: var(--linha); color: var(--tinta2); }
.aviso.ok { background: var(--ok-bg); color: var(--ok); }

/* câmera */
.camera { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; }
.camera video { flex: 1; width: 100%; object-fit: cover; min-height: 0; }
.camera .mira { position: absolute; left: 8%; right: 8%; top: 36%; height: 22%; border: 2px solid rgba(255,255,255,.85); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); pointer-events: none; }
.camera .mira::after { content: ''; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: #E5584A; animation: pisca 1.2s infinite; }
@keyframes pisca { 50% { opacity: .25; } }
.camera .cam-topo { position: absolute; top: 0; left: 0; right: 0; padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 14px; color: #fff; display: flex; justify-content: space-between; align-items: center; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.camera .cam-base { background: #111; color: #fff; padding: 14px 16px calc(16px + var(--safe-b)); }
.camera .lido { min-height: 48px; font-size: 15px; }
.camera .lido b { font-size: 18px; }
.camera .lido.ok { color: #9FD4A9; }
.camera .lido.erro { color: #F2A595; }
.camera .btn { background: #fff; color: #111; border-color: #fff; }
.camera .cont { font-size: 13px; opacity: .8; }

/* modal */
.modal-fundo { position: fixed; inset: 0; z-index: 50; background: rgba(23,23,19,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal { width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--bg); border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); }
.modal h3 { margin: 0 0 12px; font-size: 19px; }
@media (min-width: 700px) { .modal-fundo { align-items: center; } .modal { border-radius: 20px; } }

/* toasts */
.toasts { position: fixed; top: calc(60px + env(safe-area-inset-top, 0px)); left: 0; right: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: var(--tinta); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: var(--sombra); max-width: 92%; animation: entra .2s ease-out; }
.toast.erro { background: var(--perigo); color: #fff; }
@keyframes entra { from { transform: translateY(-8px); opacity: 0; } }

/* login */
.login { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.login .marca-g { color: var(--tinta); line-height: 0; margin-bottom: 10px; }
.login .marca-g svg { height: 34px; width: auto; }
.login form { text-align: left; margin-top: 26px; }

/* cadastro */
.cor-linha { display: grid; grid-template-columns: 40px 1fr 74px 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.cor-linha input[type=color] { width: 40px; height: 44px; padding: 2px; border: 1px solid var(--linha); border-radius: 10px; background: #fff; }
.cor-linha input.in { margin: 0; min-height: 44px; }
.tam-chips .chip { min-width: 52px; }

/* etiquetas — impressão em folha A4 Pimaco 21 etiquetas (63,5 × 38,1 mm) */
.impressao { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  body > *:not(.impressao) { display: none !important; }
  .impressao { display: block; }
}
.folha { width: 210mm; height: 297mm; position: relative; page-break-after: always; overflow: hidden; }
.folha:last-child { page-break-after: auto; }
.etiqueta { position: absolute; width: 63.5mm; height: 38.1mm; padding: 2.6mm 3.2mm; display: flex; flex-direction: column; font-family: var(--fonte); color: #000; }
.etiqueta .e-marca { line-height: 0; }
.etiqueta .e-marca svg { height: 2.6mm; width: auto; }
.etiqueta .e-prod { font-size: 8pt; line-height: 1.15; margin-top: .6mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.etiqueta .e-lin { display: flex; justify-content: space-between; align-items: baseline; }
.etiqueta .e-cor { font-size: 9pt; font-weight: 600; }
.etiqueta .e-tam { font-size: 17pt; font-weight: 700; line-height: 1; }
.etiqueta > svg { width: 100%; height: 11mm; margin-top: auto; display: block; }
.etiqueta .e-sku { font-family: var(--mono); font-size: 7.5pt; text-align: center; letter-spacing: .06em; margin-top: .4mm; }
.etiqueta.contorno { outline: .2mm dashed #777; outline-offset: -.1mm; }
/* etiqueta mais alta (Colacril 63,5 × 46,6): mais respiro, tamanho maior e código mais alto (lê melhor) */
.etiqueta.alta { padding: 3.4mm 3.6mm 3mm; }
.etiqueta.alta .e-marca svg { height: 3mm; }
.etiqueta.alta .e-prod { font-size: 8.5pt; margin-top: 1.2mm; }
.etiqueta.alta .e-lin { margin-top: .6mm; }
.etiqueta.alta .e-cor { font-size: 10pt; }
.etiqueta.alta .e-tam { font-size: 21pt; }
.etiqueta.alta > svg { height: 14mm; }
.etiqueta.alta .e-sku { font-size: 8pt; margin-top: .6mm; }
.previa-folha { background: #fff; border: 1px solid var(--linha); border-radius: 8px; overflow: hidden; width: 100%; aspect-ratio: 210 / 297; position: relative; }
.previa-folha .folha { transform-origin: 0 0; position: absolute; top: 0; left: 0; }

/* ---------- fluidez: resposta ao toque, carregamento e transição ---------- */
html { touch-action: manipulation; }
.btn, .chip, .acao, .kpi, a.item, .abas a, .cel, .qbtn, button { transition: transform .08s ease, opacity .08s ease, background-color .15s ease; }
.btn:active, .chip:active, .acao:active, a.kpi:active, a.item:active, .cel:active, .qbtn:active { transform: scale(.96); opacity: .8; }
a.item:active { transform: none; background: var(--linha); }
.abas a:active .ic { transform: scale(.88); }
.abas .aba-central:active .ic { transform: scale(.92); }
.carregando { position: fixed; top: calc(41px + env(safe-area-inset-top, 0px)); left: 0; right: 0; height: 3px; z-index: 40; pointer-events: none; opacity: 0; overflow: hidden; transition: opacity .15s; }
.carregando::before { content: ''; position: absolute; top: 0; bottom: 0; width: 40%; background: var(--tinta2); border-radius: 2px; animation: corre 1s ease-in-out infinite; }
.carregando.on { opacity: 1; }
@keyframes corre { from { left: -40%; } to { left: 100%; } }
.app.entra > * { animation: aparece .2s ease-out both; }
@keyframes aparece { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .app.entra > * { animation: none; } .carregando::before { animation-duration: 2s; } }
.titulo-linha { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.titulo-linha .btn { flex: none; }
