:root {
  --primaria: #075e54; --primaria-esc: #054c44; --acento: #128c7e; --zap: #25d366; --zap-esc: #1da851;
  --fundo: #f2f4f6; --card: #ffffff; --texto: #111b21; --muted: #667781; --borda: #e2e8f0; --campo: #f8fafc;
  --neg: #dc2626; --neg-fundo: #fee2e2; --pos: #16a34a; --pos-fundo: #dcfce7;
  --aviso: #b45309; --aviso-fundo: #fef3c7; --azul: #2563eb; --azul-fundo: #dbeafe;
  --sombra: 0 1px 3px rgba(0,0,0,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #0b141a; --card: #111b21; --texto: #e9edef; --muted: #8696a0; --borda: #26343d; --campo: #1a262d;
    --neg: #f87171; --neg-fundo: #3b1a1a; --pos: #4ade80; --pos-fundo: #14301f;
    --aviso: #fbbf24; --aviso-fundo: #3a2e10; --azul: #60a5fa; --azul-fundo: #172554; --sombra: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--fundo); color: var(--texto); -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.p { font-size: .82rem; margin-bottom: 10px; }
.neg { color: var(--neg); } .pos { color: var(--pos); } .info { color: var(--acento); } .aviso { color: var(--aviso); }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(160deg, var(--primaria), var(--acento)); }
.login-caixa { background: var(--card); border-radius: 18px; padding: 26px 20px; width: 100%; max-width: 360px; display: grid; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.login-logo { font-size: 2.6rem; text-align: center; }
.login h1 { text-align: center; font-size: 1.25rem; color: var(--primaria); }
.login p { text-align: center; font-size: .85rem; }
.erro { color: var(--neg); min-height: 1.2em; font-size: .85rem; }

/* ---------- topo: barra fina e fixa, como app ---------- */
html, body { overflow-x: clip; max-width: 100%; }
/* Casca do app: topo, conteúdo que rola e barra, num container da altura da
   tela. Só .conteudo rola — a barra fica no fluxo, nunca por cima de nada. */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
#app { height: 100dvh; display: flex; flex-direction: column; max-width: 100vw; overflow: hidden; }
#app > .topo, #app > .barra { flex: none; }
.topo { background: var(--primaria); color: #fff; position: relative; z-index: 20;
  padding: env(safe-area-inset-top) 14px 0; box-shadow: 0 1px 6px rgba(0,0,0,.18); }
.topo-in { max-width: 680px; margin: 0 auto; height: 52px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.topo-titulo { min-width: 0; }
.topo h1 { font-size: 1.05rem; line-height: 1.2; }
.topo p { font-size: .72rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pilula { flex: none; border: 0; border-radius: 16px; padding: 6px 10px; font: 700 .72rem/1 inherit; color: #fff; background: rgba(255,255,255,.18); cursor: pointer; white-space: nowrap; }
.pilula.offline { background: #b45309; } .pilula.pendente { background: #2563eb; } .pilula.erro { background: #dc2626; }

/* Totais: rolam com a página (não ficam presos no topo). */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.kpis div { background: var(--card); border: 1px solid var(--borda); border-radius: 12px; padding: 7px 6px; text-align: center; min-width: 0; }
.kpis span { display: block; font-size: .6rem; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); font-weight: 700; }
.kpis strong { display: block; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- layout ---------- */
.conteudo { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  width: 100%; padding: 10px max(12px, calc((100% - 680px) / 2)) 16px; }
.card { background: var(--card); border: 1px solid var(--borda); border-radius: 14px; padding: 12px; margin-bottom: 10px; box-shadow: var(--sombra); display: grid; gap: 9px; min-width: 0; }
.card-destaque { border: 1.5px solid var(--acento); }
.card-titulo { font-weight: 700; color: var(--primaria); display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .95rem; }
@media (prefers-color-scheme: dark) { .card-titulo { color: #5fd4c4; } }
.card-titulo.neg { color: var(--neg); } .card-titulo.pos { color: var(--pos); }
.card-titulo .total { color: var(--texto); font-size: 1.05rem; }
.linha2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: end; }
.linha-acao { display: flex; gap: 6px; flex-wrap: wrap; }
.linha-acao select { flex: 1 1 120px; } .linha-acao input { flex: 0 0 70px; }

/* ---------- campos ---------- */
label, .rotulo { display: grid; gap: 4px; font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
input, select, textarea {
  width: 100%; padding: 10px 11px; border: 1.5px solid var(--borda); border-radius: 9px; font: 400 16px/1.3 inherit;
  background: var(--campo); color: var(--texto); text-transform: none; letter-spacing: 0;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--acento); box-shadow: 0 0 0 3px rgba(18,140,126,.18); }
input[type=file] { padding: 8px; font-size: .85rem; }
.dica { font-size: .78rem; color: var(--muted); margin-top: -4px; min-height: 0; }
.dica:empty { display: none; }
.busca { margin-bottom: 10px; background: var(--card); }

/* ---------- botões ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 12px 14px; border-radius: 10px;
  font: 700 .9rem/1.1 inherit; border: 0; cursor: pointer; text-decoration: none; transition: transform .08s, opacity .15s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; }
.btn-primario { background: var(--primaria); color: #fff; }
.btn-zap { background: var(--zap); color: #fff; }
.btn-sec { background: var(--borda); color: var(--texto); }
.btn-borda { background: transparent; color: var(--texto); border: 1.5px solid var(--borda); }
.btn-perigo { background: transparent; color: var(--neg); border: 1.5px solid var(--neg); }
.btn-azul { background: transparent; color: var(--azul); border: 1.5px solid var(--azul); }
.btn-p { width: auto; padding: 7px 10px; font-size: .78rem; border-radius: 8px; }
.btn-pp { width: auto; padding: 4px 8px; font-size: .74rem; border-radius: 7px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip, .chips input + span { display: inline-block; padding: 9px 12px; border-radius: 20px; border: 1.5px solid var(--borda); background: var(--campo);
  font: 700 .85rem/1 inherit; color: var(--texto); cursor: pointer; }
.chips-p .chip { padding: 6px 10px; font-size: .78rem; }
.chips label { display: inline-block; text-transform: none; letter-spacing: 0; font-size: inherit; }
.chips label, .segmentos label { position: relative; }
.chips input, .segmentos input { position: absolute; inset: 0; width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.chips input:checked + span, .chip.ativo { background: var(--primaria); border-color: var(--primaria); color: #fff; }

.segmentos { display: flex; background: var(--campo); border: 1.5px solid var(--borda); border-radius: 10px; padding: 3px; gap: 3px; }
.segmentos label { flex: 1; display: block; text-transform: none; letter-spacing: 0; }
.segmentos span { display: block; text-align: center; padding: 8px 4px; border-radius: 7px; font-size: .85rem; font-weight: 700; color: var(--muted); cursor: pointer; }
.segmentos input:checked + span { background: var(--card); color: var(--primaria); box-shadow: 0 1px 4px rgba(0,0,0,.12); }

.qtd { display: flex; gap: 6px; align-items: center; }
.qtd input { width: 64px; text-align: center; font-weight: 800; font-size: 1.1rem; }
.qtd-b { width: 44px; height: 44px; border-radius: 10px; border: 1.5px solid var(--borda); background: var(--campo); font: 800 1.3rem/1 inherit; color: var(--texto); cursor: pointer; }
.qtd-rapida { display: flex; gap: 4px; margin-left: auto; }
.qtd-rapida button { width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--borda); background: var(--campo); font-weight: 700; color: var(--texto); cursor: pointer; }

/* ---------- listas ---------- */
.item { border: 1px solid var(--borda); border-radius: 12px; padding: 10px 11px; min-width: 0; display: grid; gap: 6px; background: var(--card); }
.item + .item { margin-top: 8px; }
.item.deve { border-left: 5px solid var(--neg); } .item.credito { border-left: 5px solid var(--pos); } .item.zerado { border-left: 5px solid #94a3b8; }
.item-topo { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.item-nome { font-weight: 700; }
.item-valor { font-weight: 800; white-space: nowrap; }
.item-meta { font-size: .74rem; color: var(--muted); display: flex; gap: 4px 10px; flex-wrap: wrap; min-width: 0; }
.item-meta > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.item-acoes { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.item-acoes .btn { padding: 8px 4px; font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.reg { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 2px; border-bottom: 1px solid var(--borda); }
.reg:last-child { border-bottom: 0; }
.reg-info { min-width: 0; flex: 1; }
.reg-titulo { font-weight: 700; font-size: .9rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.reg-sub { font-size: .74rem; color: var(--muted); }
.reg-dir { text-align: right; display: grid; gap: 4px; justify-items: end; }
.reg-valor { font-weight: 800; white-space: nowrap; }
.reg-acoes { display: flex; gap: 4px; }
.pendente-mark { font-size: .66rem; background: var(--azul-fundo); color: var(--azul); padding: 1px 6px; border-radius: 6px; font-weight: 700; }

.selo { font-size: .72rem; background: var(--borda); color: var(--texto); padding: 2px 8px; border-radius: 12px; font-weight: 700; }
.selo-neg { background: var(--neg-fundo); color: var(--neg); } .selo-pos { background: var(--pos-fundo); color: var(--pos); }
.tag { padding: 1px 6px; border-radius: 6px; font-size: .64rem; font-weight: 800; text-transform: uppercase; }
.tag-consumo { background: var(--neg-fundo); color: var(--neg); } .tag-pagamento { background: var(--pos-fundo); color: var(--pos); }
.tag-ajuste, .tag-entrada { background: var(--aviso-fundo); color: var(--aviso); }
.vazio { text-align: center; padding: 18px 8px; color: var(--muted); font-size: .85rem; }

.metricas { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--campo); border: 1px solid var(--borda); border-radius: 10px; padding: 8px 4px; text-align: center; }
.metricas span { display: block; font-size: .62rem; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.metricas strong { font-size: .92rem; }

/* estoque */
.estq { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--borda); font-size: .9rem; }
.estq strong.baixo { color: var(--neg); }

/* ---------- conciliação ---------- */
.tabela { display: grid; gap: 0; font-size: .88rem; }
.tabela > div { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--borda); }
.tabela > div:last-child { border-bottom: 0; }
.tabela .sub { padding-left: 14px; color: var(--muted); font-size: .82rem; }
.tabela .total { font-weight: 800; font-size: .95rem; }
.tabela strong { white-space: nowrap; }
.quadro { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quadro > div { background: var(--campo); border: 1px solid var(--borda); border-radius: 10px; padding: 9px; }
.quadro span { display: block; font-size: .66rem; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.quadro strong { font-size: 1.05rem; }
.alerta { background: var(--aviso-fundo); color: var(--aviso); border-radius: 10px; padding: 9px 11px; font-size: .82rem; }
details > summary { cursor: pointer; font-weight: 700; font-size: .88rem; padding: 4px 0; list-style: none; }
details > summary::before { content: "▸ "; } details[open] > summary::before { content: "▾ "; }
.mov select { width: auto; padding: 4px 6px; font-size: .78rem; border-radius: 7px; }

/* ---------- barra inferior (estilo app) ---------- */
.barra { position: relative; z-index: 30; height: calc(60px + env(safe-area-inset-bottom));
  padding: 0 max(4px, calc((100% - 680px) / 2)) env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  background: var(--card); border-top: 1px solid var(--borda); box-shadow: 0 -2px 8px rgba(0,0,0,.04); }
.barra a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0;
  text-decoration: none; color: var(--muted); font-size: .62rem; font-weight: 600; letter-spacing: -.1px; }
.barra a span { display: grid; place-items: center; width: 44px; height: 26px; border-radius: 13px; font-size: 1.05rem; line-height: 1;
  filter: grayscale(1); opacity: .65; transition: background .15s; }
.barra a.ativo { color: var(--primaria); font-weight: 800; }
.barra a.ativo span { filter: none; opacity: 1; background: color-mix(in srgb, var(--acento) 18%, transparent); }
@media (prefers-color-scheme: dark) { .barra a.ativo { color: #5fd4c4; } }

/* ---------- modal / toast ---------- */
.modal { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  border-radius: 18px 18px 0 0; background: var(--card); color: var(--texto); overscroll-behavior: contain; }
.modal[open] { animation: subir .18s ease-out; }
@keyframes subir { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (min-width: 600px) { .modal { margin: auto; border-radius: 18px; } }
.modal::backdrop { background: rgba(0,0,0,.55); }
.modal-caixa { padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); display: grid; gap: 10px; min-width: 0; }
.modal-caixa::before { content: ""; justify-self: center; width: 40px; height: 4px; border-radius: 2px; background: var(--borda); margin-top: -4px; }
.modal-topo { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--borda); padding-bottom: 8px; color: var(--primaria); }
.fechar { background: none; border: 0; font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer; }
#modal-corpo { display: grid; gap: 10px; }
.modal-botoes { margin-top: 4px; }

.toast { position: fixed; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100;
  background: #111b21; color: #fff; padding: 10px 18px; border-radius: 22px; font-size: .85rem; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,.3); opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100% - 32px); text-align: center; }
.toast.visivel { opacity: 1; }
.toast.erro { background: #b91c1c; }

.texto { min-height: 200px; font: .8rem/1.4 ui-monospace, monospace; resize: vertical; }
.codigo { font: .74rem/1.4 ui-monospace, monospace; background: var(--campo); border: 1px solid var(--borda); border-radius: 9px; padding: 10px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

@media (max-width: 380px) {
  .linha2 { grid-template-columns: 1fr; }
  .segmentos span { font-size: .78rem; }
}

/* QR Pix */
.qr { display: grid; justify-items: center; gap: 8px; text-align: center; }
.qr-valor { font-size: 2rem; font-weight: 800; color: var(--primaria); }
.qr-valor { font-size: 1.8rem; line-height: 1.1; }
/* A imagem da InfinitePay é 750×1080 com muita margem: recorta no QR. */
.qr-img { width: min(100%, 300px); aspect-ratio: 1; overflow: hidden; border-radius: 12px; background: #fff; border: 1px solid var(--borda); padding: 12px; box-sizing: border-box; }
.qr-img > div { width: 100%; height: 100%; overflow: hidden; }
.qr-img img { display: block; width: 231%; max-width: none; margin: -111.5% 0 0 -64.5%; }

/* Sugestões de cliente */
label:has(> .sugestoes) { position: relative; }
.sugestoes { position: absolute; left: 0; right: 0; top: 100%; z-index: 40; margin-top: 4px; background: var(--card);
  border: 1px solid var(--borda); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18); overflow: hidden; text-transform: none; letter-spacing: 0; }
.sugestoes button { display: flex; width: 100%; justify-content: space-between; gap: 8px; padding: 12px; border: 0; border-bottom: 1px solid var(--borda);
  background: none; color: var(--texto); font: 600 .95rem/1.2 inherit; text-align: left; cursor: pointer; }
.sugestoes button:last-child { border-bottom: 0; }
.sugestoes button:active { background: var(--campo); }
.sugestoes em { font-style: normal; font-size: .78rem; font-weight: 700; white-space: nowrap; }

/* Vendas por local */
.local-linha { display: grid; gap: 4px; padding: 6px 0; border-bottom: 1px solid var(--borda); }
.local-linha:last-child { border-bottom: 0; }
.local-topo { display: flex; justify-content: space-between; gap: 8px; }
.local-barra { height: 8px; border-radius: 4px; background: var(--campo); overflow: hidden; }
.local-barra i { display: block; height: 100%; background: var(--acento); border-radius: 4px; }
