/* WIMEGEST Móvel — telemóvel primeiro (ecrãs de 320 px em diante), tema escuro da marca e tema claro para o sol. */
:root {
  --bg: #020617; --pn: #0f172a; --pn2: #111c33; --ln: #1e293b; --ln2: #334155;
  --tx: #f1f5f9; --tx2: #cbd5e1; --mu: #94a3b8; --di: #64748b;
  --em: #10b981; --em2: #34d399; --emT: #022c22; --amb: #fbbf24; --ambT: #2a1d03; --red: #f87171; --redT: #2a0d0d; --blue: #60a5fa;
  --r: 16px; --sombra: 0 10px 30px #0009;
  --tab: 64px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-tema="escuro"]) {
    --bg: #eef2f6; --pn: #ffffff; --pn2: #f6f8fb; --ln: #dfe5ee; --ln2: #c7d0dc;
    --tx: #0b1324; --tx2: #24324a; --mu: #55657d; --di: #7a879b;
    --em: #059669; --em2: #047857; --emT: #d1fae5; --amb: #b45309; --ambT: #fef3c7; --red: #dc2626; --redT: #fee2e2; --blue: #2563eb;
    --sombra: 0 10px 30px #0f172a22; color-scheme: light;
  }
}
:root[data-tema="claro"] {
  --bg: #eef2f6; --pn: #ffffff; --pn2: #f6f8fb; --ln: #dfe5ee; --ln2: #c7d0dc;
  --tx: #0b1324; --tx2: #24324a; --mu: #55657d; --di: #7a879b;
  --em: #059669; --em2: #047857; --emT: #d1fae5; --amb: #b45309; --ambT: #fef3c7; --red: #dc2626; --redT: #fee2e2; --blue: #2563eb;
  --sombra: 0 10px 30px #0f172a22; color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--tx); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { width: 100%; background: var(--pn2); border: 1px solid var(--ln2); border-radius: 12px; padding: 12px 13px; outline: none; min-height: 46px; }
input:focus, select:focus, textarea:focus { border-color: var(--em); box-shadow: 0 0 0 3px #10b98133; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--mu); margin: 0 0 6px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.sub { color: var(--mu); font-size: 13px; }
.cx { display: flex; align-items: center; gap: 10px; }
.entre { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pilha > * + * { margin-top: 12px; }
.oculto { display: none !important; }

/* arranque */
.arranque { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--mu); }
.logo-g { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-weight: 900; font-size: 30px; color: #022c22;
  background: linear-gradient(45deg, #10b981, #2dd4bf); box-shadow: 0 10px 30px #10b98144; }
.arranque b { color: var(--tx); font-size: 18px; letter-spacing: .04em; }

/* topo */
.topo { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  padding: calc(10px + var(--safe-t)) 16px 10px; border-bottom: 1px solid var(--ln); display: flex; align-items: center; gap: 10px; }
.topo .logo-p { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 900; color: #022c22; background: linear-gradient(45deg, #10b981, #2dd4bf); flex: none; }
.topo .tit { min-width: 0; flex: 1; }
.topo .tit b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo .tit small { color: var(--mu); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.estado { border: 1px solid var(--ln2); background: var(--pn); border-radius: 999px; padding: 6px 11px; display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; flex: none; }
.estado i { width: 9px; height: 9px; border-radius: 50%; background: var(--em); box-shadow: 0 0 0 3px #10b98133; }
.estado.off i { background: var(--amb); box-shadow: 0 0 0 3px #fbbf2433; }
.estado.sync i { animation: pulsar 1s infinite; }
.estado .n { background: var(--amb); color: #1a1203; border-radius: 999px; padding: 0 6px; font-size: 11px; }
@keyframes pulsar { 50% { opacity: .3; } }

/* conteúdo */
main { padding: 14px 16px calc(var(--tab) + var(--safe-b) + 92px); max-width: 760px; margin: 0 auto; }
h2 { font-size: 20px; margin: 4px 0 12px; }
h3 { font-size: 15px; margin: 0 0 10px; }
.cartao { background: var(--pn); border: 1px solid var(--ln); border-radius: var(--r); padding: 14px; }
.cartao + .cartao { margin-top: 12px; }
.aviso { border-radius: 12px; padding: 11px 13px; font-size: 13px; background: var(--ambT); color: var(--amb); border: 1px solid color-mix(in srgb, var(--amb) 40%, transparent); }
.aviso.ok { background: var(--emT); color: var(--em2); border-color: color-mix(in srgb, var(--em) 40%, transparent); }
.aviso.mau { background: var(--redT); color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.vazio { text-align: center; color: var(--di); padding: 26px 10px; font-size: 14px; }

/* botões */
.btn { border: 1px solid var(--ln2); background: var(--pn); border-radius: 13px; padding: 12px 16px; min-height: 46px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.pri { background: var(--em); border-color: var(--em); color: #03241b; }
.btn.amb { background: var(--amb); border-color: var(--amb); color: #1a1203; }
.btn.red { background: transparent; border-color: color-mix(in srgb, var(--red) 55%, transparent); color: var(--red); }
.btn.lg { width: 100%; padding: 15px; font-size: 16px; border-radius: 15px; }
.btn.sm { min-height: 36px; padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn.ic { width: 46px; padding: 0; flex: none; }
.lnk { background: none; border: 0; color: var(--em2); font-weight: 700; padding: 6px 0; cursor: pointer; }

/* pesquisa */
.busca { position: relative; display: flex; gap: 8px; }
.busca input { padding-left: 40px; }
.busca svg.lupa { position: absolute; left: 13px; top: 15px; color: var(--di); pointer-events: none; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--ln2); background: var(--pn); border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600; color: var(--tx2); }
.chip.on { background: var(--emT); border-color: var(--em); color: var(--em2); }

/* listas */
.lista { margin-top: 10px; background: var(--pn); border: 1px solid var(--ln); border-radius: var(--r); overflow: hidden; }
.it { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--ln); min-height: 62px; width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.it:first-child { border-top: 0; }
button.it:active { background: var(--pn2); }
.it .meio { flex: 1; min-width: 0; }
.it .meio b { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.it .meio small { color: var(--mu); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.it .dir { text-align: right; flex: none; }
.it .dir b { display: block; font-variant-numeric: tabular-nums; }
.it .dir small { color: var(--mu); font-size: 12px; }
.qtd-in { background: var(--emT); color: var(--em2); border-radius: 9px; padding: 2px 8px; font-size: 12px; font-weight: 800; margin-left: 6px; }
.etq { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 7px; padding: 2px 7px; background: var(--ln); color: var(--tx2); }
.etq.ok { background: var(--emT); color: var(--em2); }
.etq.amb { background: var(--ambT); color: var(--amb); }
.etq.mau { background: var(--redT); color: var(--red); }

/* barra do carrinho */
.carrinho-barra { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tab) + var(--safe-b) + 10px); z-index: 25; max-width: 736px; margin: 0 auto;
  background: var(--em); color: #03241b; border-radius: 16px; padding: 10px 10px 10px 16px; display: flex; align-items: center; gap: 12px; box-shadow: 0 12px 30px #10b98155; border: 0; width: auto; }
.carrinho-barra .meio { flex: 1; text-align: left; }
.carrinho-barra small { display: block; font-size: 12px; font-weight: 600; opacity: .8; }
.carrinho-barra b { font-size: 18px; font-variant-numeric: tabular-nums; }
.carrinho-barra span.ir { background: #03241b; color: var(--em2); border-radius: 12px; padding: 10px 14px; font-weight: 800; }

/* separadores em baixo */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--tab) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--pn) 94%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--ln); display: flex; }
.tabs button { flex: 1; border: 0; background: none; color: var(--di); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 700; position: relative; }
.tabs button.on { color: var(--em2); }
.tabs button.on::before { content: ""; position: absolute; top: 0; width: 34px; height: 3px; border-radius: 0 0 4px 4px; background: var(--em); }
.tabs .bol { position: absolute; top: 7px; left: calc(50% + 6px); background: var(--amb); color: #1a1203; border-radius: 999px; font-size: 10px; padding: 0 5px; min-width: 16px; }

/* folha (modal em baixo) */
.fundo { position: fixed; inset: 0; background: #000a; z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: aparecer .15s; }
.folha { background: var(--pn); width: 100%; max-width: 760px; max-height: 92dvh; border-radius: 22px 22px 0 0; padding: 8px 16px calc(16px + var(--safe-b)); overflow-y: auto; box-shadow: var(--sombra); animation: subir .2s ease-out; }
.folha .pega { width: 42px; height: 5px; border-radius: 9px; background: var(--ln2); margin: 4px auto 12px; }
.folha h3 { font-size: 18px; margin: 0 0 14px; }
@keyframes subir { from { transform: translateY(40px); opacity: .5; } }
@keyframes aparecer { from { opacity: 0; } }

.linha-c { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--ln); }
.linha-c .meio { flex: 1; min-width: 0; }
.linha-c .meio b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.passo { display: flex; align-items: center; border: 1px solid var(--ln2); border-radius: 12px; overflow: hidden; flex: none; }
.passo button { width: 40px; height: 40px; border: 0; background: var(--pn2); font-size: 20px; font-weight: 700; }
.passo input { width: 56px; min-height: 40px; height: 40px; border: 0; border-radius: 0; text-align: center; padding: 0; background: var(--pn); }
.seg { display: flex; background: var(--pn2); border: 1px solid var(--ln2); border-radius: 13px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 10px; padding: 10px 6px; font-weight: 700; font-size: 13px; color: var(--mu); }
.seg button.on { background: var(--pn); color: var(--tx); box-shadow: 0 2px 8px #0003; }
.meios { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.meios button { border: 1px solid var(--ln2); background: var(--pn2); border-radius: 12px; padding: 12px; font-weight: 700; font-size: 13px; text-align: left; }
.meios button.on { border-color: var(--em); background: var(--emT); color: var(--em2); }
.total-g { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0; }
.total-g b { font-size: 26px; font-variant-numeric: tabular-nums; }

/* picar */
.relogio { text-align: center; padding: 18px 0 8px; }
.relogio b { font-size: 54px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; display: block; line-height: 1.05; }
.picar-bts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.picar-bts button { border: 0; border-radius: 20px; padding: 26px 10px; font-size: 19px; font-weight: 800; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.picar-bts .e { background: var(--em); color: #03241b; }
.picar-bts .s { background: var(--pn); border: 1px solid var(--ln2); color: var(--tx); }
.picar-bts .sug { outline: 3px solid color-mix(in srgb, var(--em) 50%, transparent); outline-offset: 3px; }
.picar-bts small { font-size: 12px; font-weight: 600; opacity: .75; }

/* painel */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--pn); border: 1px solid var(--ln); border-radius: var(--r); padding: 13px; }
.kpi.l { grid-column: 1 / -1; }
.kpi small { color: var(--mu); font-size: 12px; font-weight: 600; display: block; }
.kpi b { font-size: 21px; font-variant-numeric: tabular-nums; display: block; margin-top: 4px; }
.kpi.l b { font-size: 28px; }
.barras { display: flex; align-items: flex-end; gap: 6px; height: 92px; margin-top: 12px; }
.barras div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.barras i { width: 100%; background: var(--em); border-radius: 6px 6px 3px 3px; min-height: 3px; opacity: .85; }
.barras div:last-child i { opacity: 1; }
.barras span { font-size: 10px; color: var(--mu); }

/* PIN */
.pin { max-width: 340px; margin: 0 auto; padding: calc(28px + var(--safe-t)) 18px 24px; min-height: 100dvh; display: flex; flex-direction: column; }
.pin .pontos { display: flex; justify-content: center; gap: 14px; margin: 26px 0; }
.pin .pontos i { width: 15px; height: 15px; border-radius: 50%; border: 2px solid var(--ln2); }
.pin .pontos i.on { background: var(--em); border-color: var(--em); }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: auto; }
.teclado button { height: 66px; border-radius: 18px; border: 1px solid var(--ln); background: var(--pn); font-size: 24px; font-weight: 700; }
.teclado button.v { background: none; border: 0; font-size: 14px; color: var(--mu); }
.treme { animation: tremer .3s; }
@keyframes tremer { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* entrada */
.entrar { max-width: 420px; margin: 0 auto; padding: calc(34px + var(--safe-t)) 18px 30px; }
.entrar .marca { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.entrar .marca b { font-size: 21px; letter-spacing: .06em; display: block; }
.entrar .marca small { color: var(--em2); font-weight: 700; }

/* leitor de códigos */
.leitor { position: fixed; inset: 0; background: #000; z-index: 60; display: flex; flex-direction: column; }
.leitor video { flex: 1; width: 100%; object-fit: cover; }
.leitor .mira { position: absolute; left: 12%; right: 12%; top: 34%; height: 22%; border: 3px solid #34d399; border-radius: 18px; box-shadow: 0 0 0 100vmax #0007; }
.leitor .barra { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px calc(18px + var(--safe-b)); display: flex; gap: 10px; align-items: center; color: #fff; background: linear-gradient(transparent, #000c); }
.leitor .barra .meio { flex: 1; }

/* avisos rápidos */
#toasts { position: fixed; left: 12px; right: 12px; top: calc(12px + var(--safe-t)); z-index: 80; display: flex; flex-direction: column; gap: 8px; pointer-events: none; align-items: center; }
.toast { background: var(--tx); color: var(--bg); border-radius: 13px; padding: 11px 15px; font-weight: 600; font-size: 14px; box-shadow: var(--sombra); max-width: 520px; animation: subir .2s; }
.toast.mau { background: var(--red); color: #fff; }

@media (min-width: 700px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .kpi.l { grid-column: span 2; }
}

/* marca WIMEGEST (2.13) */
.logo-img { background: #fff !important; padding: 3px; overflow: hidden; }
.logo-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.entrar { position: relative; }
.entrar > *:not(.entrar-marca) { position: relative; z-index: 1; }
.entrar-marca { position: fixed; inset: 0; pointer-events: none; background: url(img/logo-wimegest.png) center 60%/86vmin no-repeat; opacity: .07; }
.it-img { width: 40px; height: 40px; flex: none; object-fit: contain; border-radius: 9px; background: #ffffff10; }

/* ---------------------------------------------------------------- WIMEGEST Móvel Autónomo */
.cartao { background: var(--pn); border: 1px solid var(--ln); border-radius: var(--r); padding: 14px; }
.grelha2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-l > * + * { margin-top: 12px; }
.chave { font-family: ui-monospace, Consolas, monospace; font-size: 15px; letter-spacing: .04em; font-weight: 700; word-break: break-all; }
.textarea-lic { min-height: 110px; font-family: ui-monospace, Consolas, monospace; font-size: 11px; }
.menu-mais .it .meio small { white-space: normal; }
.estado-fe { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--pn2); border: 1px solid var(--ln2); color: var(--mu); }
.estado-fe.VALIDO { background: var(--emT); color: var(--em2); border-color: transparent; }
.estado-fe.PENDENTE, .estado-fe.ENVIADO, .estado-fe.ERRO { background: var(--ambT); color: var(--amb); border-color: transparent; }
.estado-fe.INVALIDO { background: var(--redT); color: var(--red); border-color: transparent; }
.det-lin { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--ln); font-size: 14px; }
.det-lin:last-child { border-bottom: 0; }
.faixa { border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-bottom: 10px; background: var(--ambT); color: var(--amb); }
.faixa.ok { background: var(--emT); color: var(--em2); }
.faixa.mau { background: var(--redT); color: var(--red); }
.linha-meio { display: grid; grid-template-columns: 1fr 120px 36px; gap: 8px; align-items: center; margin-top: 8px; }
.troco { font-size: 22px; font-weight: 800; color: var(--em2); }
.pv { color: var(--mu); font-size: 12px; }
