:root {
  --fundo: #f4f1ec;
  --cartao: #ffffff;
  --texto: #1d1b18;
  --suave: #6f6a62;
  --linha: #e4dfd6;
  --acento: #1f5f4a;
  --acento-2: #2b7a60;
  --acento-claro: #e3f0ea;
  --ouro: #c8962e;
  --perigo: #b3402e;
  --raio: 16px;
  --sombra: 0 1px 2px rgba(0,0,0,.05), 0 6px 20px rgba(0,0,0,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--fundo); color: var(--texto);
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input, select { font: inherit; }
.escondido { display: none !important; }

/* Topo */
#topo {
  position: sticky; top: 0; z-index: 10;
  background: var(--acento); color: #fff;
  padding: calc(env(safe-area-inset-top) + 12px) 18px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
#topo .marca { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
#topo h1 { margin: 2px 0 0; font-size: 18px; font-weight: 700; line-height: 1.2; }
#topo button { background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 999px; padding: 8px 14px; font-size: 14px; }

main { max-width: 560px; margin: 0 auto; padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }

/* Navegação inferior */
#nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  background: #fff; border-top: 1px solid var(--linha);
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
#nav button {
  background: none; border: 0; padding: 10px 4px 12px; color: var(--suave);
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; font-weight: 600;
}
#nav button .ic { font-size: 22px; line-height: 1; }
#nav button.ativo { color: var(--acento); }

/* Blocos */
.card { background: var(--cartao); border-radius: var(--raio); box-shadow: var(--sombra); padding: 18px; margin-bottom: 14px; }
.card h2 { margin: 0 0 12px; font-size: 17px; }
.card h3 { margin: 18px 0 8px; font-size: 14px; color: var(--suave); text-transform: uppercase; letter-spacing: .05em; }
.sub { color: var(--suave); font-size: 14px; margin: 4px 0 0; line-height: 1.45; }
.centro { text-align: center; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--suave); margin: 12px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=search] {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--linha); border-radius: 12px; background: #fff; font-size: 16px; color: var(--texto);
}
input:focus { outline: none; border-color: var(--acento-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 16px; border: 0; border-radius: 12px;
  background: var(--acento); color: #fff; font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; cursor: default; transform: none; }
.btn.sec { background: var(--acento-claro); color: var(--acento); }
.btn.linha { background: #fff; color: var(--texto); border: 1.5px solid var(--linha); }
.btn.peq { width: auto; padding: 9px 14px; font-size: 14px; border-radius: 10px; }
.btn.grande { padding: 20px; font-size: 18px; border-radius: 16px; }
.btn.perigo { background: #fbeae7; color: var(--perigo); }
.mt { margin-top: 12px; }
.linha-btns { display: flex; gap: 8px; }
.linha-btns > * { flex: 1; }

.abas { display: flex; background: var(--acento-claro); border-radius: 12px; padding: 4px; margin-bottom: 6px; }
.abas button { flex: 1; border: 0; background: none; padding: 10px; border-radius: 9px; font-weight: 700; color: var(--acento); }
.abas button.ativo { background: #fff; box-shadow: var(--sombra); }

/* Estatísticas */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { background: var(--cartao); border-radius: var(--raio); box-shadow: var(--sombra); padding: 14px; }
.stat b { display: block; font-size: 26px; }
.stat span { font-size: 13px; color: var(--suave); }

/* Leitor */
#leitor { width: 100%; border-radius: 14px; overflow: hidden; background: #000; }
#leitor video { width: 100% !important; display: block; }

/* Listas */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 2px; border-bottom: 1px solid var(--linha); }
.lista li:last-child { border-bottom: 0; }
.lista li.clicavel { cursor: pointer; }
.lista .nome { font-weight: 600; }
.lista .info { font-size: 13px; color: var(--suave); margin-top: 2px; }
.lista .inativo { opacity: .45; }
.pill { background: var(--acento-claro); color: var(--acento); font-weight: 800; font-size: 14px; border-radius: 999px; padding: 6px 11px; white-space: nowrap; }
.pill.ouro { background: #f7ecd4; color: #8a6418; }
.vazio { text-align: center; color: var(--suave); padding: 20px 8px; font-size: 14px; }

.form-linha { display: grid; grid-template-columns: 1fr 92px auto; gap: 8px; margin-top: 10px; align-items: end; }
.form-linha input { padding: 11px 12px; }

/* Folha (modal) */
#folha-fundo { position: fixed; inset: 0; background: rgba(20,18,15,.45); z-index: 20; }
#folha {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 560px; margin: 0 auto; max-height: 92dvh; overflow-y: auto;
  background: var(--fundo); border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(24px + env(safe-area-inset-bottom));
  animation: sobe .22s ease-out;
}
@keyframes sobe { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
#folha .pega { width: 44px; height: 5px; background: #cfc8bc; border-radius: 9px; margin: 2px auto 12px; }
#folha .fechar { float: right; border: 0; background: #fff; border-radius: 999px; width: 36px; height: 36px; font-size: 18px; box-shadow: var(--sombra); }

.cliente-topo { text-align: center; padding: 6px 0 4px; }
.cliente-topo h2 { margin: 0; font-size: 22px; }
.saldo-grande { font-size: 52px; font-weight: 800; color: var(--acento); line-height: 1; margin-top: 10px; }
.saldo-grande small { font-size: 18px; font-weight: 700; }

.grelha-servicos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-servico {
  border: 0; border-radius: 14px; background: #fff; box-shadow: var(--sombra); padding: 16px 10px; text-align: center; cursor: pointer;
}
.btn-servico b { display: block; font-size: 24px; color: var(--acento); }
.btn-servico span { font-size: 14px; font-weight: 600; }
.btn-servico:active { transform: scale(.97); }
.btn-servico.troca b { color: var(--ouro); font-size: 18px; }
.btn-servico[disabled] { opacity: .4; cursor: default; }

.qr-caixa { background: #fff; border-radius: 16px; padding: 14px; max-width: 260px; margin: 0 auto; }
.qr-caixa svg { width: 100%; height: auto; display: block; }

.hist li { font-size: 14px; }
.mais { color: var(--acento); font-weight: 800; }
.menos { color: var(--ouro); font-weight: 800; }

/* Modelos no registo */
.modelos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modelo { border: 1.5px solid var(--linha); background: #fff; border-radius: 12px; padding: 12px; text-align: left; cursor: pointer; }
.modelo b { display: block; font-size: 15px; }
.modelo span { font-size: 12px; color: var(--suave); }
.modelo.ativo { border-color: var(--acento); background: var(--acento-claro); }

/* Aviso */
#aviso {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 40; background: #1d1b18; color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 15px;
  max-width: calc(100% - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.25); text-align: center;
}
#aviso.erro { background: var(--perigo); }
#aviso.ok { background: var(--acento); }

.entrada { max-width: 420px; margin: 8vh auto 0; }
.entrada .logo { width: 64px; height: 64px; border-radius: 18px; background: var(--acento); color: #fff; display: grid; place-items: center; font-size: 30px; margin: 0 auto 14px; }
.entrada h1 { text-align: center; margin: 0; font-size: 26px; }
.link { background: none; border: 0; color: var(--acento); font-weight: 600; padding: 8px; cursor: pointer; }

/* Página do cliente */
.cartao-cliente { max-width: 460px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 18px) 16px 40px; }
.cartao-cabeca {
  background: linear-gradient(135deg, var(--acento), #123d30); color: #fff; border-radius: 22px; padding: 22px; box-shadow: var(--sombra); margin-bottom: 14px;
}
.cartao-cabeca .neg { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.cartao-cabeca h1 { margin: 4px 0 16px; font-size: 24px; }
.cartao-cabeca .saldo { font-size: 56px; font-weight: 800; line-height: 1; }
.cartao-cabeca .saldo small { font-size: 18px; opacity: .85; }
.pulsa { animation: pulsa .9s ease-out; }
@keyframes pulsa { 0% { transform: scale(1); } 30% { transform: scale(1.18); } 100% { transform: scale(1); } }
.premio { margin: 12px 0 0; }
.premio .topo { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; }
.barra { height: 10px; background: var(--acento-claro); border-radius: 9px; overflow: hidden; margin-top: 6px; }
.barra i { display: block; height: 100%; background: var(--acento-2); border-radius: 9px; transition: width .6s; }
.barra.cheia i { background: var(--ouro); }
.premio .falta { font-size: 13px; color: var(--suave); margin-top: 4px; }
.premio .pronto { font-size: 13px; color: #8a6418; font-weight: 700; margin-top: 4px; }

/* Marca Pontuvo */
#topo .marca { display: flex; align-items: center; gap: 6px; }
.marca-ico { width: 16px; height: 16px; border-radius: 4px; box-shadow: 0 0 0 1px rgba(255,255,255,.35); }
.logo-img { display: block; width: 72px; height: 72px; margin: 0 auto 14px; filter: drop-shadow(0 6px 16px rgba(31,95,74,.25)); }
.rodape-marca { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 18px auto 0; color: var(--suave); font-size: 13px; text-decoration: none; }
.rodape-marca img { width: 18px; height: 18px; }
select.campo { width: 100%; padding: 13px 14px; border: 1.5px solid var(--linha); border-radius: 12px; background: #fff; font-size: 16px; color: var(--texto); }
.form-linha { grid-template-columns: 1fr auto; }
.form-linha > div:first-child { grid-column: 1 / -1; }
