:root {
  --bg: #f3f6fb;
  --card: #ffffff;
  --ink: #0a1224;
  --muted: #5a6479;
  --line: #dbe3ef;
  --brand: #0055f7;
  --brand-dark: #0042d8;
  --brand-soft: #e4eeff;
  --ciano: #00d4ff;
  --noite: #00040c;
  --marinho: #011948;
  --ok: #2e7d32;
  --ok-soft: #e3f2e4;
  --warn: #9a5b00;
  --warn-soft: #fff1d6;
  --danger: #c0392b;
  --danger-soft: #fbe4e1;
  --radius: 12px;
  --sombra: 0 1px 2px rgba(10, 18, 36, .08), 0 4px 14px rgba(10, 18, 36, .07);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
}
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- botões e campos ---------- */
button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: .6rem 1rem; border-radius: 10px; min-height: 44px; font-weight: 600;
}
button:hover { border-color: var(--brand); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #6ea8ff; outline-offset: 1px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.primario { background: var(--brand); border-color: var(--brand); color: #fff; }
.primario:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.perigo { color: var(--danger); }
.pequeno { min-height: 34px; padding: .3rem .7rem; font-size: .9rem; }
.link { background: none; border: none; color: var(--brand-dark); text-decoration: underline; padding: .2rem; min-height: 0; font-weight: 500; }

input, select, textarea {
  font: inherit; padding: .6rem .75rem; border: 1px solid #c5d0e2; border-radius: 10px; background: #fff; color: var(--ink);
  min-height: 44px; width: 100%;
}
textarea { resize: vertical; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.campo { margin-bottom: .9rem; }
.campo small { color: var(--muted); font-weight: 400; display: block; margin-top: .2rem; }
.linha { display: flex; gap: .75rem; }
.linha > * { flex: 1; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--sombra); padding: 1rem; }
.erro-msg { background: var(--danger-soft); color: var(--danger); padding: .6rem .8rem; border-radius: 10px; margin-bottom: .8rem; font-weight: 600; }
.ok-msg { background: var(--ok-soft); color: var(--ok); padding: .6rem .8rem; border-radius: 10px; margin-bottom: .8rem; font-weight: 600; }

.pilula { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--brand-soft); color: var(--brand-dark); }
.pilula.ok { background: var(--ok-soft); color: var(--ok); }
.pilula.alerta { background: var(--warn-soft); color: var(--warn); }
.pilula.ruim { background: var(--danger-soft); color: var(--danger); }

/* ---------- cabeçalho / abas ---------- */
.topo { background: linear-gradient(90deg, var(--noite) 0%, var(--marinho) 100%); color: #fff; display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem; flex-wrap: wrap; }
.marca { font-weight: 800; font-size: 1.15rem; letter-spacing: .2px; }
.marca span { color: #35b6ff; }
.marca-wrap { display: flex; align-items: center; gap: .6rem; }
.logo { width: 38px; height: 38px; display: block; flex: none; }
.topo .loja { color: #fff; font-weight: 800; font-size: 1.15rem; letter-spacing: .2px; }
.topo .espaco { flex: 1; }
.topo button { background: transparent; color: #fff; border-color: #2b3f6b; min-height: 36px; padding: .3rem .8rem; }
.status-sync { font-size: .85rem; padding: .2rem .6rem; border-radius: 999px; background: #0f2150; color: #a9b8d6; }
.status-sync.ok { background: #1f4d23; color: #c8f0cb; }
.status-sync.off { background: #6b3a12; color: #ffe0bd; }
.status-sync.pend { background: #5c4a12; color: #ffe9a8; }

nav.abas { display: flex; gap: .25rem; padding: .5rem 1rem 0; background: #e6edf8; border-bottom: 1px solid var(--line); overflow-x: auto; }
nav.abas button { border-radius: 10px 10px 0 0; border-bottom: none; background: transparent; border-color: transparent; color: var(--muted); }
nav.abas button[aria-selected="true"] { background: var(--bg); color: var(--ink); border-color: var(--line); }

.banner { padding: .55rem 1rem; display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; font-weight: 600; }
.banner.aviso { background: var(--warn-soft); color: var(--warn); }
.banner.erro { background: var(--danger-soft); color: var(--danger); }
.banner.info { background: var(--brand-soft); color: var(--brand-dark); }
.banner button { min-height: 34px; padding: .25rem .8rem; }

main { padding: 1rem; max-width: 1200px; margin: 0 auto; }
.tela[hidden] { display: none; }

/* ---------- tabelas ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.right, th.right { text-align: right; }
.tabela-rolagem { overflow-x: auto; }
.barra { display: flex; gap: .75rem; align-items: center; margin-bottom: .75rem; flex-wrap: wrap; }
.barra input[type="search"], .barra input[type="text"] { max-width: 320px; }

/* ---------- PDV ---------- */
.pdv { display: grid; grid-template-columns: 1fr 340px; gap: 1rem; align-items: start; }
@media (max-width: 860px) { .pdv { grid-template-columns: 1fr; } }
.entrada-codigo { font-size: 1.6rem; padding: .9rem 1rem; border: 2px solid var(--brand); border-radius: 12px; min-height: 60px; }
.entrada-wrap { position: relative; margin-bottom: .75rem; }
.leitor-estoque { padding: .9rem 1rem; margin-bottom: 1rem; }
.leitor-estoque label { font-weight: 700; margin-bottom: .4rem; }
.leitor-estoque-linha { display: flex; gap: .6rem; }
.leitor-estoque-linha input { flex: 1; min-height: 52px; font-size: 1.15rem; border: 2px solid var(--brand); border-radius: 12px; }
.sugestoes { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--sombra); overflow: hidden; }
.sugestoes button { display: flex; width: 100%; justify-content: space-between; border: none; border-radius: 0; border-bottom: 1px solid var(--line); text-align: left; font-weight: 500; }
.aviso-leitor { min-height: 1.6em; font-weight: 700; margin: 0 0 .5rem; }
.aviso-leitor.erro { color: var(--danger); }
.aviso-leitor.ok { color: var(--ok); }
.carrinho td { font-size: 1.05rem; }
.carrinho .qtd-controle { display: inline-flex; align-items: center; gap: .3rem; }
.carrinho .qtd-controle button { min-height: 34px; min-width: 34px; padding: 0; }
.carrinho .vazio { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.painel-total { position: sticky; top: 1rem; }
.total-valor { font-size: 2.8rem; font-weight: 800; color: var(--brand-dark); line-height: 1.1; margin: .2rem 0 1rem; }
.painel-total .primario { width: 100%; font-size: 1.2rem; min-height: 56px; margin-bottom: .5rem; }
.painel-total button { width: 100%; }
.dica { color: var(--muted); font-size: .85rem; margin-top: .8rem; }
kbd { background: #e6edf8; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 .35rem; font-size: .8rem; }
.ultima-venda { margin-top: 1rem; font-size: .9rem; color: var(--muted); }

/* ---------- modais ---------- */
.janela-fundo { position: fixed; inset: 0; background: rgba(0, 4, 12, .6); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 100; overflow-y: auto; }
.janela { background: var(--card); border-radius: 16px; padding: 1.25rem; width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.janela.largo { max-width: 560px; }
.janela h2 { margin-bottom: .75rem; }
.janela .acoes { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; }
.formas { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin-bottom: 1rem; }
.formas button { min-height: 56px; font-size: 1.05rem; }
.formas button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.notas { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .5rem; }
.notas button { min-height: 36px; padding: .2rem .7rem; }
.troco-box { background: var(--ok-soft); color: var(--ok); border-radius: 10px; padding: .6rem .9rem; font-size: 1.4rem; font-weight: 800; margin-top: .8rem; }
.troco-box.falta { background: var(--danger-soft); color: var(--danger); }
.sucesso-venda { text-align: center; }
.sucesso-venda .grande { font-size: 2.4rem; font-weight: 800; color: var(--ok); }

/* ---------- sugestões no cadastro de produto ---------- */
.sugestoes-produto { max-height: 170px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: .3rem .6rem .6rem; background: #fafcff; }
.sugestoes-produto h5 { margin: .55rem 0 .3rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.sugestoes-produto .chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.chip { min-height: 32px; padding: .2rem .65rem; font-size: .88rem; font-weight: 500; border-radius: 999px; background: #fff; }
.chip:hover { background: var(--brand-soft); color: var(--brand-dark); }
.chip[hidden], .sugestoes-produto h5[hidden] { display: none; }

/* ---------- importar nota (XML) ---------- */
.janela.nota { max-width: 820px; }
.nota-cab { margin: .8rem 0 .5rem; }
.nota-margem { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: .6rem 0; }
.nota-margem label { margin: 0; font-weight: 600; }
.catalogo-cab.nota-cab-cols, .nota-linha { display: grid; grid-template-columns: 28px 1fr 96px 104px; gap: .5rem; align-items: center; }
.catalogo-cab.nota-cab-cols { padding: 0 .7rem; }
.catalogo-cab.nota-cab-cols span:nth-child(2) { text-align: left; }
.nota-linha { padding: .4rem .7rem; border-bottom: 1px solid var(--line); }
.nota-linha input:not([type=checkbox]) { min-height: 36px; padding: .3rem .5rem; }
.nota-linha input[data-qtd], .nota-linha input[data-preco] { text-align: right; }
.nota-linha input[type=checkbox] { width: auto; min-height: 0; }
.nota-linha.desmarcada { opacity: .45; }
.nota-info { font-size: .8rem; margin-top: .15rem; }

/* ---------- catálogo pronto ---------- */
.janela.catalogo { max-width: 680px; }
.catalogo-lista { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; margin-top: .6rem; }
.catalogo-lista h4 { position: sticky; top: 0; margin: 0; padding: .4rem .7rem; background: var(--brand-soft); color: var(--brand-dark); font-size: .85rem; z-index: 1; }
.catalogo-linha { display: grid; grid-template-columns: 1fr 110px 80px; gap: .5rem; align-items: center; padding: .3rem .7rem; border-bottom: 1px solid var(--line); }
.catalogo-linha input { min-height: 36px; padding: .3rem .5rem; text-align: right; }
.catalogo-linha.tem-preco { background: var(--ok-soft); }
.catalogo-linha.existe { opacity: .5; }
.catalogo-cab { display: grid; grid-template-columns: 1fr 110px 80px; gap: .5rem; padding: .3rem .7rem; font-size: .75rem; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.catalogo-cab span:nth-child(n+2) { text-align: right; }

/* ---------- QR / assinatura ---------- */
.qr-img { display: block; margin: .5rem auto; width: 240px; height: 240px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }
.copia-cola { display: flex; gap: .5rem; }
.copia-cola input { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; }
.bloqueio { position: fixed; inset: 0; background: var(--bg); z-index: 90; overflow-y: auto; padding: 1.5rem 1rem; }
.bloqueio .conteudo { max-width: 520px; margin: 0 auto; }

/* ---------- login / admin ---------- */
body.escuro { background: radial-gradient(ellipse at 50% 0%, #0a2a6e 0%, var(--marinho) 38%, var(--noite) 100%) fixed; }
.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }
.login-logo { width: 116px; height: 116px; display: block; margin: 0 auto .6rem; filter: drop-shadow(0 6px 18px rgba(0, 85, 247, .45)); }
.login-card .marca { font-size: 1.6rem; color: var(--ink); text-align: center; margin-bottom: .25rem; }
.login-card .marca span { color: var(--brand); }
.bloqueio .marca span { color: var(--brand); }
.bloqueio .logo { width: 44px; height: 44px; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 1.25rem; }
.cards-resumo { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.cards-resumo .card .rotulo { color: var(--muted); font-size: .85rem; font-weight: 600; }
.cards-resumo .card .valor { font-size: 1.7rem; font-weight: 800; }
.dois-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 860px) { .dois-col { grid-template-columns: 1fr; } }

.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .7rem 1.2rem; border-radius: 10px; z-index: 200; font-weight: 600; max-width: 90vw; }
.toast.erro { background: var(--danger); }

/* ---------- caixa, desconto, pagamento dividido ---------- */
.barra-caixa { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .5rem .8rem; margin-bottom: .75rem; border-radius: 10px; font-size: .95rem; }
.barra-caixa.aberto { background: var(--ok-soft); }
.barra-caixa.fechado { background: var(--warn-soft); }
.barra-caixa .espaco { flex: 1; }
.barra-caixa[hidden] { display: none; }
.caixa-esperado { margin-bottom: 1rem; }
.caixa-esperado .total-valor { margin: .2rem 0; }
.pago-linha { display: flex; align-items: center; gap: .6rem; padding: .3rem .6rem; background: var(--brand-soft); border-radius: 8px; margin-bottom: .3rem; }
.pago-linha span { flex: 1; font-weight: 600; }
tr.cancelada td { opacity: .55; text-decoration: line-through; }
tr.cancelada td .pilula, tr.cancelada td .muted { text-decoration: none; }
#linha-desconto { margin: -.2rem 0 .6rem; font-size: .9rem; }

/* ---------- cupom (impressão) ---------- */
#cupom-area { display: none; }
@media print {
  body > *:not(#cupom-area) { display: none !important; }
  #cupom-area { display: block !important; width: 72mm; margin: 0 auto; color: #000; font-family: 'Courier New', monospace; font-size: 12px; }
  #cupom-area h1 { font-size: 15px; text-align: center; margin: 0 0 4px; }
  #cupom-area .c { text-align: center; }
  #cupom-area hr { border: none; border-top: 1px dashed #000; margin: 6px 0; }
  #cupom-area table { width: 100%; }
  #cupom-area td, #cupom-area th { padding: 1px 0; border: none; font-size: 12px; text-transform: none; letter-spacing: 0; color: #000; }
  #cupom-area .tot { font-size: 15px; font-weight: 700; }
  @page { margin: 4mm; }
}
