:root {
  --fundo: #0e0e10;
  --card: #1a1a1d;
  --card-2: #232327;
  --borda: #2e2e33;
  --texto: #f2f2f3;
  --texto-2: #a1a1a8;
  --vermelho: #e8141e;
  --vermelho-escuro: #b50e16;
  --verde: #22c55e;
  --amarelo: #f5b50b;
  --raio: 14px;
  --nav-altura: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { background: var(--fundo); color: var(--texto); }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  min-height: 100vh;
  min-height: 100dvh;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
svg.ic { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- Logo ---------- */
.logo { text-align: center; line-height: 1; user-select: none; }
.logo .chapeu svg { width: 60px; height: 60px; margin: 0 auto 4px; display: block; }
.logo .nome { font-family: 'Playfair Display', Georgia, serif; font-weight: 800; font-size: 44px; color: #f6ead7; letter-spacing: -1px; }
.logo .nome b { color: var(--vermelho); }
.logo .slogan { font-family: 'Playfair Display', Georgia, serif; font-size: 16px; color: #f6ead7; margin-top: 4px; }
.logo.pequena .chapeu svg { width: 30px; height: 30px; margin-bottom: 2px; }
.logo.pequena .nome { font-size: 20px; letter-spacing: 0; }
.logo.pequena .slogan { font-size: 9px; }

/* ---------- Layout ---------- */
.container { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(var(--nav-altura) + 24px); }

.topo {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: rgba(14, 14, 16, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--borda);
}
.topo h1 { flex: 1; font-size: 17px; font-weight: 600; text-align: center; }
.topo .btn-icone { width: 36px; }

.btn-icone {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; position: relative;
}
.btn-icone:active { background: var(--card-2); }
.badge {
  position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--vermelho); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Barra inferior ---------- */
.nav-inferior {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: center;
  background: #141416; border-top: 1px solid var(--borda);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-inferior .itens { display: flex; width: 100%; max-width: 720px; }
.nav-inferior a, .nav-inferior button {
  flex: 1; height: var(--nav-altura); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 11px; color: var(--texto-2); background: none; border: 0; cursor: pointer;
}
.nav-inferior .ativo { color: var(--vermelho); }

/* ---------- Menu lateral ---------- */
.menu-fundo { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 30; opacity: 0; pointer-events: none; transition: opacity .2s; }
.menu-lateral {
  position: fixed; top: 0; bottom: 0; left: 0; width: 280px; max-width: 85vw; z-index: 31;
  background: #121214; border-right: 1px solid var(--borda); padding: 20px 14px;
  transform: translateX(-100%); transition: transform .25s; display: flex; flex-direction: column; overflow-y: auto;
}
body.menu-aberto .menu-fundo { opacity: 1; pointer-events: auto; }
body.menu-aberto .menu-lateral { transform: none; }
.menu-lateral .perfil { display: flex; align-items: center; gap: 12px; padding: 20px 8px; border-bottom: 1px solid var(--borda); margin-bottom: 8px; }
.menu-lateral .avatar { width: 44px; height: 44px; }
.menu-lateral nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 10px; border-radius: 10px; font-size: 14px;
}
.menu-lateral nav a.ativo { background: var(--card-2); }
.menu-lateral nav a.bloqueado { color: var(--texto-2); }
.menu-lateral nav a .em-breve { margin-left: auto; font-size: 10px; padding: 2px 7px; border-radius: 6px; background: var(--card-2); color: var(--texto-2); }
.menu-lateral .versao { margin-top: auto; padding-top: 16px; text-align: center; color: var(--texto-2); font-size: 12px; }

/* ---------- Componentes ---------- */
.card { background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--vermelho); color: #fff; font-weight: 600; font-size: 15px; width: 100%;
}
.btn:active { background: var(--vermelho-escuro); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secundario { background: var(--card-2); border: 1px solid var(--borda); }
.btn.pequeno { height: 36px; padding: 0 14px; font-size: 13px; width: auto; border-radius: 10px; }
.btn.perigo { background: transparent; border: 1px solid var(--vermelho); color: var(--vermelho); }

.campo { margin-bottom: 14px; }
.campo label { display: block; font-size: 13px; margin-bottom: 6px; }
.campo label .obrig { color: var(--vermelho); }
.input, .campo input, .campo select, .campo textarea {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--borda); outline: none;
}
.campo textarea { height: 90px; padding: 12px 14px; resize: vertical; }
.input:focus, .campo input:focus, .campo select:focus, .campo textarea:focus { border-color: var(--vermelho); }
.campo .dica { font-size: 12px; color: var(--texto-2); margin-top: 4px; }
.linha { display: flex; gap: 10px; }
.linha > * { flex: 1; min-width: 0; }

.input-icone { position: relative; }
.input-icone svg.ic { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--texto-2); width: 20px; height: 20px; }
.input-icone input { padding-left: 44px; }
.input-icone .acao { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); color: var(--texto-2); }
.input-icone .acao svg.ic { position: static; transform: none; }

.busca { margin-bottom: 14px; }

.chave { position: relative; width: 50px; height: 28px; flex-shrink: 0; }
.chave input { opacity: 0; width: 0; height: 0; }
.chave span { position: absolute; inset: 0; border-radius: 14px; background: var(--card-2); border: 1px solid var(--borda); cursor: pointer; transition: .2s; }
.chave span::before { content: ''; position: absolute; width: 22px; height: 22px; left: 2px; top: 2px; border-radius: 50%; background: #fff; transition: .2s; }
.chave input:checked + span { background: var(--vermelho); border-color: var(--vermelho); }
.chave input:checked + span::before { transform: translateX(22px); }

.abas { display: flex; background: var(--card); border: 1px solid var(--borda); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.abas button { flex: 1; height: 38px; border: 0; background: none; border-radius: 9px; cursor: pointer; font-size: 14px; color: var(--texto-2); }
.abas button.ativo { background: var(--vermelho); color: #fff; font-weight: 600; }

.chips { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex-shrink: 0; height: 34px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--borda); background: var(--card); cursor: pointer; font-size: 14px; }
.chips button.ativo { background: var(--vermelho); border-color: var(--vermelho); font-weight: 600; }

.status { display: inline-block; min-width: 54px; padding: 4px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; text-align: center; }
.status.ok { background: var(--verde); color: #04280f; }
.status.baixo { background: var(--amarelo); color: #3a2800; }
.status.zerado { background: var(--vermelho); color: #fff; }

.vazio { text-align: center; color: var(--texto-2); padding: 40px 16px; }
.vazio svg.ic { width: 40px; height: 40px; margin: 0 auto 10px; }

.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--card-2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.foto-produto { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--card-2); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; }

.lista { display: flex; flex-direction: column; gap: 10px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--card); border: 1px solid var(--borda); border-radius: 12px; }
.item .info { flex: 1; min-width: 0; }
/* Nome em até 2 linhas: cortar com "..." escondia produtos de nome longo
   ("Café da manhã especial") justo na tela de venda, onde é preciso identificá-los. */
.item .titulo { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.item .sub { font-size: 13px; color: var(--texto-2); overflow-wrap: anywhere; }
.item .preco { font-weight: 600; font-size: 14px; }

.qtd { display: flex; align-items: center; gap: 6px; }
.qtd button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--borda); background: var(--card-2); cursor: pointer; font-size: 17px; line-height: 1; }
.qtd span { min-width: 22px; text-align: center; font-weight: 600; }

.toast {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translate(-50%, -20px); z-index: 80;
  background: #2a2a2f; border: 1px solid var(--borda); padding: 12px 18px; border-radius: 12px; font-size: 14px;
  opacity: 0; transition: .25s; pointer-events: none; max-width: calc(100vw - 32px);
}
.toast.visivel { opacity: 1; transform: translate(-50%, 0); }
.toast.erro { border-color: var(--vermelho); }

.modal-fundo { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .7); display: flex; align-items: flex-end; justify-content: center; }
.modal { width: 100%; max-width: 520px; background: #151517; border: 1px solid var(--borda); border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 90vh; overflow-y: auto; }
.modal h2 { font-size: 17px; margin-bottom: 14px; }
@media (min-width: 600px) { .modal-fundo { align-items: center; } .modal { border-radius: 20px; } }

.carregando { display: flex; justify-content: center; padding: 40px; }
.carregando::after { content: ''; width: 28px; height: 28px; border: 3px solid var(--borda); border-top-color: var(--vermelho); border-radius: 50%; animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

/* ---------- Splash e login ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #2a1a12 0%, var(--fundo) 70%); transition: opacity .4s;
}
.splash.saindo { opacity: 0; pointer-events: none; }

.tela-login { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 32px 20px; max-width: 420px; margin: 0 auto; }
.tela-login .logo { margin-bottom: 36px; }
.tela-login h2 { text-align: center; font-size: 18px; font-weight: 500; margin-bottom: 20px; }
.tela-login .rodape { display: flex; gap: 10px; margin-top: 40px; }
.tela-login .rodape a { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; height: 44px; border: 1px solid var(--borda); border-radius: 12px; font-size: 13px; }
.tela-login .demo { margin-top: 16px; text-align: center; font-size: 12px; color: var(--texto-2); }
.instalar-link { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; padding: 12px; font-size: 14px; color: var(--vermelho); border: 1px dashed var(--borda); border-radius: 12px; }
.instalar-link svg.ic { width: 18px; height: 18px; }

/* ---------- Painel ---------- */
.saudacao { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.saudacao .ola { flex: 1; }
.saudacao .ola strong { font-size: 18px; }
.tag-perfil { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--card-2); color: var(--texto-2); margin-top: 2px; text-transform: capitalize; }

.grade-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 22px; }
.stat { display: flex; gap: 10px; align-items: flex-start; }
.stat .icone { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat .icone svg.ic { width: 20px; height: 20px; }
.stat .rotulo { font-size: 12px; color: var(--texto-2); }
.stat .valor { font-size: 17px; font-weight: 700; white-space: nowrap; }
.stat .variacao { font-size: 12px; font-weight: 600; }
.stat .variacao.pos { color: var(--verde); }
.stat .variacao.neg { color: var(--vermelho); }
.cor-verde { background: rgba(34, 197, 94, .15); color: var(--verde); }
.cor-laranja { background: rgba(245, 146, 11, .15); color: #f5920b; }
.cor-amarelo { background: rgba(245, 181, 11, .15); color: var(--amarelo); }
.cor-vermelho { background: rgba(232, 20, 30, .15); color: var(--vermelho); }
.cor-azul { background: rgba(59, 130, 246, .15); color: #60a5fa; }
a.stat:active { background: var(--card-2); }

.secao-titulo { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.grade-atalhos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.atalho { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 4px; text-align: center; font-size: 12px; position: relative; }
.atalho.bloqueado { opacity: .45; }
.atalho:active { background: var(--card-2); }

/* ---------- Venda ---------- */
/* Fica colado no rodapé enquanto a lista rola e se solta no fim dela. O respiro
   abaixo vem do padding-bottom do .container, que deixa o último produto aparecer. */
.resumo-venda { position: sticky; bottom: calc(var(--nav-altura) + 8px); margin-top: 16px; z-index: 5; }
.resumo-venda .linha-total { display: flex; justify-content: space-between; font-size: 14px; color: var(--texto-2); margin-bottom: 4px; }
.resumo-venda .linha-total.total { color: var(--texto); font-size: 18px; font-weight: 700; margin: 8px 0 12px; }
.resumo-venda .linha-total input { width: 90px; height: 32px; text-align: right; padding: 0 8px; border-radius: 8px; background: var(--card-2); border: 1px solid var(--borda); }

/* ---------- Produto ---------- */
.foto-upload {
  width: 150px; height: 150px; margin: 0 auto 20px; border-radius: 16px; border: 1px dashed var(--borda); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: pointer; overflow: hidden; font-size: 12px; color: var(--texto-2);
}
.foto-upload img { width: 100%; height: 100%; object-fit: cover; }

.campo-chave { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--card); border: 1px solid var(--borda); border-radius: 10px; margin-bottom: 14px; }

/* ---------- Scanner ---------- */
.scanner { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; }
.scanner video { flex: 1; width: 100%; object-fit: cover; }
.scanner .moldura { position: absolute; left: 10%; right: 10%; top: 35%; height: 22%; border: 3px solid rgba(255, 255, 255, .9); border-radius: 14px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
.scanner .moldura::after { content: ''; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: var(--vermelho); box-shadow: 0 0 8px var(--vermelho); }
.scanner .topo-scanner { position: absolute; top: 0; left: 0; right: 0; padding: 16px; display: flex; align-items: center; justify-content: space-between; z-index: 2; }
.scanner .instrucao { position: absolute; bottom: 60px; left: 0; right: 0; text-align: center; font-size: 15px; z-index: 2; }

/* ---------- Detalhe da venda ---------- */
.tabela { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabela th { text-align: left; font-weight: 500; color: var(--texto-2); font-size: 12px; padding: 8px 0; border-bottom: 1px solid var(--borda); }
.tabela td { padding: 10px 0; border-bottom: 1px solid var(--borda); }
.tabela .dir { text-align: right; }
.tabela .cen { text-align: center; }

.instalar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; border-color: var(--vermelho); }
.instalar .info { flex: 1; font-size: 13px; }

/* Celulares estreitos (iPhone SE, Android de entrada): com o espaçamento padrão
   os rótulos do painel quebravam em 3 linhas e os cards ficavam desalinhados. */
@media (max-width: 360px) {
  .container { padding-left: 12px; padding-right: 12px; }
  .card { padding: 12px; }

  .saudacao { gap: 8px; margin-bottom: 14px; }
  .saudacao .ola strong { font-size: 17px; }

  .grade-stats { gap: 8px; }
  .stat { gap: 8px; }
  .stat .icone { width: 32px; height: 32px; border-radius: 8px; }
  .stat .icone svg.ic { width: 18px; height: 18px; }
  .stat .rotulo { font-size: 11px; line-height: 1.25; }
  .stat .valor { font-size: 16px; }

  .grade-atalhos { gap: 8px; }
  .atalho { font-size: 11px; padding: 12px 2px; gap: 6px; line-height: 1.2; }

  .instalar { gap: 10px; }
  .instalar .info { font-size: 12px; }

  .item { gap: 10px; padding: 8px; }
  .foto-produto { width: 46px; height: 46px; }
  .item .sub { font-size: 12px; }

  .nav-inferior a, .nav-inferior button { font-size: 10px; gap: 3px; }
}

@media (min-width: 600px) {
  .grade-stats { grid-template-columns: repeat(3, 1fr); }
  .grade-atalhos { grid-template-columns: repeat(4, 1fr); }
}
