*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--fundo); color: var(--texto);
  font-family: var(--fonte-texto); font-size: 18px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

/* ---------- Topo ---------- */
.topo {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  background: var(--vinho); color: var(--off-white);
}
.topo-voltar, .topo-usuario {
  flex: 0 0 auto; width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: rgba(246, 239, 236, .12); color: var(--off-white);
  display: grid; place-items: center; font-weight: 600; font-size: 18px;
}
.topo-voltar svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.marca { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.marca-simbolo { width: 34px; height: 34px; color: var(--rose-claro); flex: 0 0 auto; }
.marca-nome { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.marca-atelier { font-size: 10px; letter-spacing: .32em; color: var(--rose-claro); font-weight: 400; }
.marca-lucimar { font-family: var(--fonte-titulo); font-size: 19px; letter-spacing: .14em; font-weight: 500; white-space: nowrap; }

/* ---------- Tela ---------- */
.tela { max-width: 560px; margin: 0 auto; padding: 18px 16px calc(28px + env(safe-area-inset-bottom)); }
.titulo { font-family: var(--fonte-titulo); font-weight: 500; font-size: 32px; line-height: 1.1; margin: 4px 0 4px; color: var(--vinho); }
.subtitulo { color: var(--texto-suave); margin: 0 0 18px; font-size: 16px; }
.passo { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--rose-antigo); font-weight: 600; margin: 0 0 2px; }
.secao { font-size: 14px; letter-spacing: .1em; text-transform: uppercase; color: var(--texto-suave); font-weight: 600; margin: 24px 0 10px; }

/* ---------- Botões ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 60px; padding: 14px 18px;
  border-radius: var(--raio); border: 1.5px solid var(--vinho);
  background: var(--vinho); color: var(--destaque-texto);
  font-weight: 600; font-size: 19px; text-align: center;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; }
.btn-sec { background: transparent; color: var(--vinho); }
.btn-leve { background: transparent; border-color: transparent; color: var(--texto-suave); font-weight: 500; min-height: 48px; font-size: 17px; text-decoration: underline; text-underline-offset: 3px; }
.btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pilha { display: grid; gap: 12px; margin-top: 20px; }

/* ---------- Grade da tela inicial ---------- */
.grade { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bloco {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
  min-height: 132px; padding: 16px; text-align: left;
  background: var(--cartao); border: 1px solid var(--linha); border-radius: var(--raio);
  box-shadow: var(--sombra); color: var(--texto);
}
.bloco:active { transform: scale(.98); }
.bloco-icone { width: 44px; height: 44px; border-radius: 12px; background: var(--selecao); color: var(--vinho); display: grid; place-items: center; }
.bloco-icone svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bloco-nome { font-weight: 600; font-size: 18px; line-height: 1.2; }
.bloco-principal { grid-column: 1 / -1; background: var(--vinho); color: var(--off-white); border-color: var(--vinho); flex-direction: row; align-items: center; justify-content: flex-start; min-height: 96px; }
.bloco-principal .bloco-icone { background: rgba(246, 239, 236, .14); color: var(--off-white); }
.bloco-principal .bloco-nome { font-size: 21px; }
.bloco-breve { opacity: .5; box-shadow: none; }
.bloco-breve .etiqueta { position: absolute; top: 12px; right: 12px; }

.etiqueta { display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 99px; background: var(--selecao); color: var(--vinho); }

/* ---------- Cartões e listas ---------- */
.cartao { background: var(--cartao); border: 1px solid var(--linha); border-radius: var(--raio); padding: 16px; box-shadow: var(--sombra); }
.lista { display: grid; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 64px; padding: 12px 14px;
  background: var(--cartao); border: 1px solid var(--linha); border-radius: var(--raio-p);
}
.item:active { background: var(--selecao); }
.item-texto { flex: 1; min-width: 0; }
.item-titulo { font-weight: 600; }
.item-sub { color: var(--texto-suave); font-size: 15px; }
.item-seta { color: var(--rose-antigo); font-size: 26px; line-height: 1; }

/* ---------- Campos ---------- */
.campo { display: block; margin: 0 0 16px; }
.campo-nome { display: block; font-weight: 600; margin-bottom: 6px; }
.campo-ajuda { display: block; color: var(--texto-suave); font-size: 15px; margin-top: 4px; }
.entrada {
  width: 100%; min-height: 58px; padding: 12px 14px;
  background: var(--cartao); border: 1.5px solid var(--linha); border-radius: var(--raio-p);
  font-size: 19px; outline: none;
}
.entrada:focus { border-color: var(--rose-antigo); box-shadow: 0 0 0 3px rgba(168, 111, 120, .18); }
.dinheiro { position: relative; }
.dinheiro span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--texto-suave); font-weight: 600; }
.dinheiro .entrada { padding-left: 50px; font-size: 24px; font-weight: 600; }

/* ---------- Escolhas (chips) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 48px; padding: 10px 16px; border-radius: 99px;
  background: var(--cartao); border: 1.5px solid var(--linha); font-weight: 500;
  display: inline-flex; align-items: center; gap: 8px;
}
.chip[aria-pressed="true"] { background: var(--vinho); border-color: var(--vinho); color: var(--off-white); }
.amostra { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); flex: 0 0 auto; }

/* ---------- Tamanhos ---------- */
.tamanhos { display: grid; gap: 10px; }
.tamanho {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px 10px 18px; background: var(--cartao); border: 1.5px solid var(--linha); border-radius: var(--raio-p);
}
.tamanho.ativo { border-color: var(--rose-antigo); background: #FBF6F5; }
.tamanho-nome { font-weight: 600; font-size: 22px; min-width: 48px; }
.contador { display: flex; align-items: center; gap: 6px; }
.contador button { width: 56px; height: 56px; border-radius: 50%; border: 1.5px solid var(--vinho); background: var(--cartao); color: var(--vinho); font-size: 28px; font-weight: 500; line-height: 1; }
.contador button.mais { background: var(--vinho); color: var(--off-white); }
.contador output { min-width: 44px; text-align: center; font-size: 26px; font-weight: 600; }
.total { text-align: right; color: var(--texto-suave); margin-top: 10px; }

/* ---------- Foto ---------- */
.foto-previa { position: relative; border-radius: var(--raio); overflow: hidden; background: var(--selecao); aspect-ratio: 4 / 5; margin-bottom: 16px; }
.foto-previa img { width: 100%; height: 100%; object-fit: cover; }
.foto-vazia { display: grid; place-items: center; color: var(--rose-antigo); height: 100%; }
.foto-vazia svg { width: 64px; height: 64px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.foto-mini { width: 72px; height: 88px; border-radius: 10px; object-fit: cover; background: var(--selecao); flex: 0 0 auto; }
.arquivo { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- Conferência ---------- */
.resumo { display: grid; gap: 10px; }
.linha-resumo { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--linha); }
.linha-resumo:last-child { border-bottom: 0; }
.linha-resumo dt { color: var(--texto-suave); }
.linha-resumo dd { margin: 0; font-weight: 600; text-align: right; }

/* ---------- Salvo ---------- */
.salvo { text-align: center; padding: 18px 0 6px; }
.salvo-marca { width: 84px; height: 84px; border-radius: 50%; background: var(--ok); color: #fff; display: grid; place-items: center; margin: 0 auto 12px; animation: aparece .35s ease; }
.salvo-marca svg { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.codigo { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 16px; letter-spacing: .02em; }
@keyframes aparece { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Estoque ---------- */
.busca { margin-bottom: 12px; }
.filtros { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin: 0 -16px 14px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.filtros .chip { flex: 0 0 auto; }
.pecas { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.peca { background: var(--cartao); border: 1px solid var(--linha); border-radius: var(--raio); overflow: hidden; box-shadow: var(--sombra); }
.peca-foto { aspect-ratio: 4 / 5; background: var(--selecao); }
.peca-foto img { width: 100%; height: 100%; object-fit: cover; }
.peca-info { padding: 10px 12px 12px; }
.peca-desc { font-weight: 600; font-size: 15px; line-height: 1.25; }
.peca-cod { color: var(--texto-suave); font-size: 12px; margin-top: 2px; }
.peca-saldo { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.peca-saldo span { font-size: 13px; padding: 2px 7px; border-radius: 6px; background: var(--selecao); }
.peca-saldo span.zero { opacity: .45; text-decoration: line-through; }
.peca-preco { margin-top: 8px; font-weight: 600; color: var(--vinho); font-size: 15px; }

/* ---------- Login ---------- */
.entrada-login { min-height: calc(100dvh - 40px); display: flex; flex-direction: column; justify-content: center; text-align: center; }
.logo-grande { color: var(--vinho); }
.logo-grande svg { width: 84px; height: 84px; margin: 0 auto 10px; display: block; }
.logo-grande .marca-atelier { display: block; font-size: 13px; letter-spacing: .4em; color: var(--rose-antigo); }
.logo-grande .marca-lucimar { display: block; font-family: var(--fonte-titulo); font-size: 32px; letter-spacing: .16em; font-weight: 500; margin-top: 4px; }
.pin-pontos { display: flex; justify-content: center; gap: 14px; margin: 22px 0; }
.pin-pontos i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--vinho); }
.pin-pontos i.cheio { background: var(--vinho); }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 320px; margin: 0 auto; }
.teclado button { height: 72px; border-radius: 50%; border: 0; background: var(--cartao); box-shadow: var(--sombra); font-size: 28px; font-weight: 500; }
.teclado button:active { background: var(--selecao); }
.teclado .apagar { background: transparent; box-shadow: none; font-size: 16px; color: var(--texto-suave); }

/* ---------- Mensagens ---------- */
.alerta { border-radius: var(--raio-p); padding: 14px 16px; margin: 0 0 16px; background: #FBEDEC; color: var(--erro); border: 1px solid #F0CFCC; font-size: 16px; }
.alerta.info { background: var(--selecao); color: var(--vinho); border-color: var(--rose-claro); }
.aviso {
  position: fixed; left: 16px; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 30;
  max-width: 528px; margin: 0 auto; padding: 16px 18px; border-radius: var(--raio);
  background: var(--grafite); color: #fff; font-weight: 500; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  animation: sobe .2s ease;
}
.aviso.erro { background: var(--erro); }
@keyframes sobe { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

.carregando { display: grid; place-items: center; gap: 14px; padding: 48px 0; color: var(--texto-suave); text-align: center; }
.roda { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--rose-claro); border-top-color: var(--vinho); animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.vazio { text-align: center; color: var(--texto-suave); padding: 32px 0; }

@media (min-width: 520px) { .pecas { grid-template-columns: repeat(3, 1fr); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
