/* ==========================================================================
   PDV - estilos mobile-first (Android). Sem dependencias externas.
   ========================================================================== */

:root {
  --fundo: #f1f5f9;
  --fundo-2: #ffffff;
  --fundo-3: #f8fafc;
  --borda: #e2e8f0;
  --texto: #0f172a;
  --texto-2: #64748b;
  --primaria: #1d4ed8;
  --primaria-escura: #1e3fa8;
  --primaria-clara: #dbeafe;
  --ok: #15803d;
  --ok-clara: #dcfce7;
  --erro: #b91c1c;
  --erro-clara: #fee2e2;
  --aviso: #b45309;
  --aviso-clara: #fef3c7;
  --raio: 14px;
  --raio-p: 9px;
  --sombra: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .08);
  --topo-altura: 56px;
  --seguro-baixo: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #0b1220;
    --fundo-2: #131c2e;
    --fundo-3: #1b2740;
    --borda: #26334d;
    --texto: #e8eef8;
    --texto-2: #94a3b8;
    --primaria: #3b82f6;
    --primaria-escura: #2563eb;
    --primaria-clara: #1e3a8a;
    --ok: #4ade80;
    --ok-clara: #14532d;
    --erro: #f87171;
    --erro-clara: #7f1d1d;
    --aviso: #fbbf24;
    --aviso-clara: #78350f;
    --sombra: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--fundo);
  color: var(--texto);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
}

body { padding-bottom: var(--seguro-baixo); }

h1, h2, h3 { margin: 0; line-height: 1.25; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85em; }
.oculto { display: none !important; }
.sub { color: var(--texto-2); font-size: .82rem; }
.nota { color: var(--texto-2); font-size: .78rem; margin: .5rem 0 0; }

/* ----------------------------- Botoes ----------------------------------- */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--raio-p);
  padding: .8rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  transition: background .12s, opacity .12s, transform .06s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn--primario { background: var(--primaria); color: #fff; }
.btn--primario:hover { background: var(--primaria-escura); }
.btn--fantasma { background: transparent; color: var(--texto); border-color: var(--borda); }
.btn--fantasma:hover { background: var(--fundo-3); }
.btn--perigo { background: var(--erro); color: #fff; }
.btn--bloco { display: block; width: 100%; margin-top: .6rem; }

.btn-icone {
  appearance: none; background: transparent; border: 0; color: var(--texto);
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.btn-icone:hover { background: var(--fundo-3); }

/* ----------------------------- Campos ----------------------------------- */

.campo { display: block; margin-bottom: .85rem; }
.campo > span { display: block; font-size: .8rem; font-weight: 600; color: var(--texto-2); margin-bottom: .3rem; }
.campo--linha { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.campo--linha > span { margin: 0; flex: 0 0 5.5rem; }

input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--texto);
  background: var(--fundo-2);
  border: 1px solid var(--borda);
  border-radius: var(--raio-p);
  padding: .7rem .8rem;
  min-height: 46px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primaria);
  outline-offset: -1px;
  border-color: var(--primaria);
}
textarea { min-height: auto; resize: vertical; font-size: .85rem; }
select { appearance: none; background-image: none; }

/* ----------------------------- Telas ------------------------------------ */

.tela--centro {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}

.cartao {
  background: var(--fundo-2);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: 1.2rem;
  box-shadow: var(--sombra);
}
.cartao--login { width: 100%; max-width: 380px; }

.marca { display: flex; gap: .85rem; align-items: center; margin-bottom: 1.4rem; color: var(--primaria); }
.marca h1 { font-size: 1.5rem; color: var(--texto); letter-spacing: -.02em; }

.alerta { border-radius: var(--raio-p); padding: .7rem .85rem; font-size: .85rem; margin: .8rem 0 0; }
.alerta--erro { background: var(--erro-clara); color: var(--erro); }
.alerta--ok { background: var(--ok-clara); color: var(--ok); }
.alerta--aviso { background: var(--aviso-clara); color: var(--aviso); }

/* ----------------------------- Topo ------------------------------------- */

.topo {
  position: sticky; top: 0; z-index: 40;
  height: var(--topo-altura);
  display: flex; align-items: center; gap: .5rem;
  padding: 0 .4rem 0 .2rem;
  background: var(--fundo-2);
  border-bottom: 1px solid var(--borda);
}
.topo__titulo { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.topo__titulo strong { font-size: 1rem; }
.topo__titulo .sub { font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topo__acoes { display: flex; gap: .3rem; align-items: center; }

.chip {
  font-size: .68rem; font-weight: 700; padding: .25rem .5rem;
  border-radius: 999px; white-space: nowrap; letter-spacing: .02em;
}
.chip--ok { background: var(--ok-clara); color: var(--ok); }
.chip--erro { background: var(--erro-clara); color: var(--erro); }
.chip--neutro { background: var(--fundo-3); color: var(--texto-2); }
.chip--aviso { background: var(--aviso-clara); color: var(--aviso); }

/* ----------------------------- Gaveta ----------------------------------- */

.gaveta { position: fixed; inset: 0; z-index: 60; }
.gaveta__fundo { position: absolute; inset: 0; background: rgba(15, 23, 42, .5); }
.gaveta__painel {
  position: absolute; inset: 0 auto 0 0; width: min(80vw, 300px);
  background: var(--fundo-2); padding: 1rem .7rem;
  display: flex; flex-direction: column; gap: .15rem;
  animation: entrar-esquerda .18s ease;
}
@keyframes entrar-esquerda { from { transform: translateX(-100%); } }
.gaveta__usuario { padding: .6rem .7rem 1rem; border-bottom: 1px solid var(--borda); margin-bottom: .6rem; display: flex; flex-direction: column; }
.gaveta__item {
  appearance: none; background: transparent; border: 0; color: var(--texto);
  text-align: left; padding: .85rem .7rem; border-radius: var(--raio-p);
  font: inherit; font-weight: 500; cursor: pointer; min-height: 48px;
}
.gaveta__item:hover { background: var(--fundo-3); }
.gaveta__item[aria-current="true"] { background: var(--primaria-clara); color: var(--primaria); font-weight: 700; }
.gaveta__rodape { margin-top: auto; padding-top: .8rem; }

/* ----------------------------- Conteudo --------------------------------- */

.conteudo { padding: .8rem .8rem calc(1rem + var(--seguro-baixo)); max-width: 900px; margin: 0 auto; }

.busca { display: flex; gap: .5rem; margin-bottom: .7rem; }
.busca input { flex: 1 1 auto; }

.barra-acoes { display: flex; gap: .5rem; margin-bottom: .8rem; }
.barra-acoes input, .barra-acoes select { flex: 1 1 auto; }
.barra-acoes .btn { flex: 0 0 auto; }

.pilulas { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .6rem; scrollbar-width: none; }
.pilulas::-webkit-scrollbar { display: none; }
.pilula {
  appearance: none; border: 1px solid var(--borda); background: var(--fundo-2);
  color: var(--texto); border-radius: 999px; padding: .45rem .9rem;
  font: inherit; font-size: .82rem; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.pilula[aria-pressed="true"] { background: var(--primaria); border-color: var(--primaria); color: #fff; }

/* ----------------------------- Grade de produtos ------------------------ */

.grade {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .6rem;
  padding-bottom: 8.5rem;
}
.produto {
  appearance: none; text-align: left; cursor: pointer;
  background: var(--fundo-2); border: 1px solid var(--borda); border-radius: var(--raio);
  padding: .7rem; display: flex; flex-direction: column; gap: .3rem; min-height: 96px;
  font: inherit; color: var(--texto);
}
.produto:active { border-color: var(--primaria); background: var(--primaria-clara); }
.produto__nome { font-weight: 600; font-size: .88rem; line-height: 1.25; }
.produto__preco { margin-top: auto; font-weight: 700; color: var(--primaria); }
.produto__estoque { font-size: .7rem; color: var(--texto-2); }
.produto__estoque--baixo { color: var(--aviso); font-weight: 700; }
.produto--esgotado { opacity: .55; }

/* ----------------------------- Carrinho --------------------------------- */

.carrinho {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--fundo-2); border-top: 1px solid var(--borda);
  box-shadow: 0 -8px 24px rgba(15, 23, 42, .12);
  padding-bottom: var(--seguro-baixo);
  max-height: 85dvh; display: flex; flex-direction: column;
}
.carrinho__resumo {
  appearance: none; width: 100%; background: transparent; border: 0; color: var(--texto);
  display: flex; align-items: center; gap: .7rem; padding: .85rem 1rem;
  font: inherit; font-weight: 600; cursor: pointer; min-height: 56px;
}
.carrinho__badge {
  background: var(--primaria); color: #fff; border-radius: 999px;
  min-width: 26px; height: 26px; display: grid; place-items: center;
  font-size: .78rem; font-weight: 700; padding: 0 .4rem;
}
.carrinho__resumo strong { margin-left: auto; font-size: 1.05rem; }
.carrinho__seta { transition: transform .18s; color: var(--texto-2); }
.carrinho--aberto .carrinho__seta { transform: rotate(180deg); }
.carrinho__corpo { display: none; overflow-y: auto; padding: 0 1rem 1rem; }
.carrinho--aberto .carrinho__corpo { display: block; }

.carrinho__itens { display: flex; flex-direction: column; gap: .15rem; margin-bottom: .8rem; }
.item {
  display: grid; grid-template-columns: 1fr auto auto; gap: .5rem; align-items: center;
  padding: .55rem 0; border-bottom: 1px solid var(--borda);
}
.item__nome { font-size: .88rem; font-weight: 500; }
.item__detalhe { font-size: .72rem; color: var(--texto-2); }
.item__qtd { display: flex; align-items: center; gap: .1rem; }
.item__qtd button {
  appearance: none; width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--borda); background: var(--fundo-3); color: var(--texto);
  font: inherit; font-weight: 700; cursor: pointer;
}
.item__qtd span { min-width: 2rem; text-align: center; font-weight: 600; font-size: .88rem; }
.item__total { font-weight: 700; min-width: 4.5rem; text-align: right; font-size: .9rem; }

.carrinho__ajustes { padding: .5rem 0 .2rem; }

.totais { margin: .4rem 0 .9rem; padding: .7rem 0 0; border-top: 1px solid var(--borda); }
.totais > div { display: flex; justify-content: space-between; padding: .2rem 0; }
.totais dt { color: var(--texto-2); font-size: .85rem; margin: 0; }
.totais dd { margin: 0; font-weight: 600; font-size: .88rem; }
.totais__grande dt { color: var(--texto); font-weight: 700; font-size: 1rem; }
.totais__grande dd { font-size: 1.3rem; font-weight: 800; color: var(--primaria); }

.carrinho__botoes { display: grid; grid-template-columns: 1fr 2fr; gap: .5rem; }

.vazio { text-align: center; color: var(--texto-2); padding: 2rem 1rem; font-size: .88rem; }

/* ----------------------------- Listas ----------------------------------- */

.lista { display: flex; flex-direction: column; gap: .5rem; padding-bottom: 2rem; }
.linha {
  background: var(--fundo-2); border: 1px solid var(--borda); border-radius: var(--raio);
  padding: .8rem .9rem; display: flex; gap: .7rem; align-items: center;
}
.linha__corpo { flex: 1 1 auto; min-width: 0; }
.linha__titulo { font-weight: 600; font-size: .92rem; }
.linha__sub { font-size: .76rem; color: var(--texto-2); }
.linha__valor { font-weight: 700; text-align: right; white-space: nowrap; }
.linha button { flex: 0 0 auto; }

/* ----------------------------- Modais ----------------------------------- */

.modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; }
.modal__fundo { position: absolute; inset: 0; background: rgba(15, 23, 42, .6); }
.modal__painel {
  position: relative; width: 100%; max-height: 92dvh;
  background: var(--fundo-2); border-radius: var(--raio) var(--raio) 0 0;
  display: flex; flex-direction: column; animation: subir .2s ease;
  padding-bottom: var(--seguro-baixo);
}
@keyframes subir { from { transform: translateY(100%); } }
@media (min-width: 640px) {
  .modal { align-items: center; justify-content: center; padding: 1.5rem; }
  .modal__painel { max-width: 460px; border-radius: var(--raio); }
}
.modal__topo {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1rem; border-bottom: 1px solid var(--borda); flex: 0 0 auto;
}
.modal__corpo { padding: 1.1rem 1rem 1.4rem; overflow-y: auto; }

.valor-grande {
  font-size: 2.1rem; font-weight: 800; text-align: center;
  letter-spacing: -.02em; margin-bottom: 1.1rem; color: var(--primaria);
}

.metodos { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.metodo {
  appearance: none; cursor: pointer; font: inherit; color: var(--texto);
  background: var(--fundo-2); border: 1.5px solid var(--borda); border-radius: var(--raio);
  padding: 1rem .6rem; display: flex; flex-direction: column; align-items: center; gap: .35rem;
  font-weight: 600; font-size: .88rem; min-height: 92px; justify-content: center;
}
.metodo:active, .metodo:hover { border-color: var(--primaria); background: var(--primaria-clara); }
.metodo svg { color: var(--primaria); }
.metodo small { font-weight: 500; font-size: .68rem; color: var(--texto-2); }
.metodo:disabled { opacity: .45; pointer-events: none; }

.atalhos-cedulas { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.atalhos-cedulas button {
  appearance: none; border: 1px solid var(--borda); background: var(--fundo-3); color: var(--texto);
  border-radius: 999px; padding: .45rem .8rem; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
}
.troco { text-align: center; font-size: 1rem; margin: .3rem 0 .8rem; }
.troco strong { color: var(--ok); font-size: 1.2rem; }

.parcelas { display: flex; align-items: center; gap: .7rem; margin-bottom: 1rem; }
.parcelas > span { font-size: .8rem; font-weight: 600; color: var(--texto-2); }

/* Alvo NFC com animacao de onda */
.nfc-alvo { text-align: center; padding: 1.4rem .5rem; position: relative; color: var(--primaria); }
.nfc-alvo p { color: var(--texto); font-size: .9rem; margin: .8rem 0 0; }
.nfc-onda {
  position: absolute; left: 50%; top: 2.2rem; width: 80px; height: 80px;
  transform: translateX(-50%); border-radius: 50%;
  border: 2px solid var(--primaria); opacity: 0;
  animation: onda 1.8s ease-out infinite;
}
@keyframes onda {
  0% { transform: translateX(-50%) scale(.6); opacity: .7; }
  100% { transform: translateX(-50%) scale(1.9); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .nfc-onda { animation: none; } }

.pix-qr { display: block; width: min(260px, 70vw); height: auto; margin: 0 auto 1rem; border-radius: var(--raio-p); background: #fff; padding: .5rem; }

.aguardando { text-align: center; padding: 1.5rem .5rem .5rem; }
.girador {
  width: 44px; height: 44px; margin: 0 auto 1.1rem;
  border: 3px solid var(--borda); border-top-color: var(--primaria);
  border-radius: 50%; animation: girar .9s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

.resultado { text-align: center; padding: 1rem .5rem .5rem; }
.resultado__icone {
  width: 68px; height: 68px; margin: 0 auto 1rem; border-radius: 50%;
  display: grid; place-items: center; font-size: 2rem; font-weight: 800;
}
.resultado__icone--ok { background: var(--ok-clara); color: var(--ok); }
.resultado__icone--erro { background: var(--erro-clara); color: var(--erro); }
.resultado strong { display: block; font-size: 1.2rem; margin-bottom: .3rem; }

.comprovante {
  text-align: left; background: var(--fundo-3); border: 1px solid var(--borda);
  border-radius: var(--raio-p); padding: .8rem; margin: 1rem 0;
  font-family: ui-monospace, Consolas, monospace; font-size: .74rem;
  white-space: pre-wrap; max-height: 180px; overflow-y: auto;
}

/* ----------------------------- Avisos ----------------------------------- */

.avisos {
  position: fixed; left: 0; right: 0; bottom: calc(1rem + var(--seguro-baixo));
  z-index: 100; display: flex; flex-direction: column; gap: .4rem;
  align-items: center; pointer-events: none; padding: 0 1rem;
}
.aviso {
  background: var(--texto); color: var(--fundo-2);
  padding: .7rem 1.1rem; border-radius: 999px; font-size: .85rem; font-weight: 600;
  box-shadow: var(--sombra); max-width: 100%; animation: aviso-entra .2s ease;
}
.aviso--erro { background: var(--erro); color: #fff; }
.aviso--ok { background: var(--ok); color: #fff; }
@keyframes aviso-entra { from { opacity: 0; transform: translateY(8px); } }

/* ----------------------------- Painel ----------------------------------- */

.metricas { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.metrica { background: var(--fundo-2); border: 1px solid var(--borda); border-radius: var(--raio); padding: .9rem; }
.metrica__rotulo { font-size: .72rem; color: var(--texto-2); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.metrica__valor { font-size: 1.45rem; font-weight: 800; letter-spacing: -.02em; margin-top: .2rem; }

.secao-titulo { font-size: .8rem; font-weight: 700; color: var(--texto-2); text-transform: uppercase; letter-spacing: .04em; margin: 1.2rem 0 .5rem; }

.barra-dados { display: flex; flex-direction: column; gap: .4rem; }
.barra-dados__linha { display: grid; grid-template-columns: 1fr 3fr auto; gap: .5rem; align-items: center; font-size: .82rem; }
.barra-dados__trilha { background: var(--fundo-3); border-radius: 999px; height: 8px; overflow: hidden; }
.barra-dados__preenchido { background: var(--primaria); height: 100%; border-radius: 999px; }

table.tabela { width: 100%; border-collapse: collapse; font-size: .82rem; }
table.tabela th { text-align: left; color: var(--texto-2); font-size: .72rem; text-transform: uppercase; padding: .4rem .5rem; }
table.tabela td { padding: .5rem; border-top: 1px solid var(--borda); }
table.tabela td:last-child, table.tabela th:last-child { text-align: right; }
