/* Caderneta digital — app do lojista. Celular primeiro, claro e escuro. */

:root {
  --fundo: #f6f4ef;
  --superficie: #ffffff;
  --superficie-2: #f0ede6;
  --texto: #1c2420;
  --texto-fraco: #5d6862;
  --borda: #e2ddd2;
  --marca: #0f5e45;
  --marca-forte: #0a4632;
  --marca-suave: #e3f0ea;
  --sobre-marca: #ffffff;
  --atraso: #b4471b;
  --atraso-suave: #fbe9e0;
  --hoje: #8a5a00;
  --hoje-suave: #fbf0d6;
  --ok: #1f7a4d;
  --sombra: 0 1px 2px rgba(28, 36, 32, 0.06), 0 4px 16px rgba(28, 36, 32, 0.06);
  --raio: 14px;
  --raio-pequeno: 10px;
  --altura-abas: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #0d1714;
    --superficie: #15211d;
    --superficie-2: #1b2a25;
    --texto: #e6ece9;
    --texto-fraco: #9aa9a2;
    --borda: #273832;
    --marca: #3fb886;
    --marca-forte: #5fd09f;
    --marca-suave: #173b2e;
    --sobre-marca: #04150e;
    --atraso: #f08a5d;
    --atraso-suave: #3a2219;
    --hoje: #e6b450;
    --hoje-suave: #362b12;
    --ok: #5fd09f;
    --sombra: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--fundo); }

body {
  margin: 0;
  background: var(--fundo);
  color: var(--texto);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  min-height: 100dvh;
  padding-bottom: calc(var(--altura-abas) + env(safe-area-inset-bottom) + 16px);
}

[hidden] { display: none !important; }

a { color: var(--marca); }

.pular {
  position: absolute; left: -9999px; top: 8px;
  background: var(--marca); color: var(--sobre-marca); padding: 8px 12px; border-radius: 8px; z-index: 50;
}
.pular:focus { left: 8px; }

:focus-visible { outline: 3px solid var(--marca); outline-offset: 2px; }
/* O app põe o foco no título a cada tela (para leitores de tela); sem contorno nele */
[tabindex="-1"]:focus { outline: none; }

/* ---------- Topo ---------- */
.topo {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--fundo) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--borda);
}
.topo-marca { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topo-titulo { font-weight: 700; font-size: 15px; letter-spacing: 0.01em; }
.topo-loja { font-size: 13px; color: var(--texto-fraco); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 52vw; }
.topo-acoes { display: flex; gap: 6px; flex-shrink: 0; }

.aviso-offline {
  background: var(--hoje-suave); color: var(--hoje);
  padding: 8px 16px; font-size: 14px; text-align: center; border-bottom: 1px solid var(--borda);
}

/* ---------- Conteúdo ---------- */
main { max-width: 640px; margin: 0 auto; padding: 16px; outline: none; }

h1 { font-size: 22px; line-height: 1.25; margin: 4px 0 16px; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 24px 0 10px; color: var(--texto-fraco); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

.subtitulo { color: var(--texto-fraco); margin: -10px 0 16px; }

.cartao {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 16px;
}
.cartao + .cartao { margin-top: 12px; }

.numeros { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.numero { padding: 14px; }
.numero-rotulo { font-size: 13px; color: var(--texto-fraco); }
.numero-valor { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; overflow-wrap: anywhere; }
.numero-extra { font-size: 13px; color: var(--texto-fraco); margin-top: 2px; }
.numero.destaque { background: var(--marca); border-color: var(--marca); color: var(--sobre-marca); }
.numero.destaque .numero-rotulo, .numero.destaque .numero-extra { color: color-mix(in srgb, var(--sobre-marca) 80%, transparent); }
.numero.alerta .numero-valor { color: var(--atraso); }

.atalhos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.atalho {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 72px; padding: 10px 6px; text-align: center; text-decoration: none;
  background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio);
  color: var(--texto); font-size: 14px; font-weight: 600;
}
.atalho-icone { font-size: 22px; line-height: 1; color: var(--marca); }

/* ---------- Listas ---------- */
.lista { list-style: none; margin: 0; padding: 0; background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); overflow: hidden; }
.lista > li + li { border-top: 1px solid var(--borda); }
.linha {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 60px;
  color: inherit; text-decoration: none; width: 100%; background: none; border: 0; font: inherit; text-align: left;
}
a.linha:active, button.linha:active { background: var(--superficie-2); }
.linha-corpo { flex: 1; min-width: 0; }
.linha-titulo { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.linha-detalhe { font-size: 14px; color: var(--texto-fraco); }
.linha-valor { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.linha-valor small { display: block; font-weight: 500; font-size: 12px; color: var(--texto-fraco); }

.selo { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }
.selo-atraso { background: var(--atraso-suave); color: var(--atraso); }
.selo-hoje { background: var(--hoje-suave); color: var(--hoje); }
.selo-breve { background: var(--marca-suave); color: var(--marca); }
.selo-ok { background: var(--marca-suave); color: var(--ok); }

.vazio { text-align: center; color: var(--texto-fraco); padding: 28px 16px; }
.vazio strong { display: block; color: var(--texto); margin-bottom: 4px; }

/* ---------- Botões ---------- */
.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  background: var(--marca); color: var(--sobre-marca); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.botao:active { background: var(--marca-forte); }
.botao:disabled { opacity: 0.55; cursor: progress; }
.botao-largo { width: 100%; }
.botao-secundario { background: var(--superficie); color: var(--texto); border-color: var(--borda); }
.botao-secundario:active { background: var(--superficie-2); }
.botao-whats { background: #1f8f4e; color: #fff; }
.botao-pequeno { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.botao-fantasma {
  background: none; border: 1px solid var(--borda); color: var(--texto); border-radius: 10px;
  min-height: 36px; padding: 0 12px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.acoes { display: grid; gap: 10px; margin-top: 16px; }
.acoes-lado { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }

/* ---------- Formulários ---------- */
.campo { display: block; margin-bottom: 16px; }
.campo-rotulo { display: block; font-weight: 600; margin-bottom: 6px; }
.campo-ajuda { display: block; font-size: 13px; color: var(--texto-fraco); margin-top: 6px; }
input, select, textarea {
  width: 100%; min-width: 0; min-height: 48px; padding: 10px 12px;
  border: 1px solid var(--borda); border-radius: 12px; background: var(--superficie); color: var(--texto);
  font: inherit; font-size: 17px;
}
input:focus, select:focus, textarea:focus { border-color: var(--marca); outline: none; box-shadow: 0 0 0 3px var(--marca-suave); }
.dupla { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.opcoes { display: flex; flex-wrap: wrap; gap: 8px; }
.opcao input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.opcao span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--borda); background: var(--superficie); font-weight: 600; cursor: pointer;
}
.opcao input:checked + span { background: var(--marca); border-color: var(--marca); color: var(--sobre-marca); }
.opcao input:focus-visible + span { outline: 3px solid var(--marca); outline-offset: 2px; }

.escolha-cliente { position: relative; }
.escolhido {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--marca); background: var(--marca-suave); border-radius: 12px; min-height: 48px;
}
.escolhido strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sugestoes { margin-top: 6px; max-height: 260px; overflow: auto; }

.previa { background: var(--superficie-2); border-radius: var(--raio-pequeno); padding: 10px 12px; font-size: 14px; color: var(--texto-fraco); margin: -4px 0 16px; }
.previa strong { color: var(--texto); font-variant-numeric: tabular-nums; }

.erro-form { background: var(--atraso-suave); color: var(--atraso); border-radius: var(--raio-pequeno); padding: 10px 12px; margin-bottom: 16px; font-weight: 600; }

.resultado { text-align: center; padding: 24px 16px; }
.resultado-icone {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 12px; display: grid; place-items: center;
  background: var(--marca-suave); color: var(--ok); font-size: 28px; font-weight: 700;
}
.resultado h1 { margin-bottom: 6px; }
.resultado .detalhes { text-align: left; margin-top: 16px; }

.cabecalho-cliente { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: var(--marca-suave); color: var(--marca); font-weight: 700; font-size: 18px;
}
.saldo-grande { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }

.busca { margin-bottom: 12px; }

/* ---------- Entrar ---------- */
.entrar { max-width: 440px; margin: 8vh auto 0; text-align: center; }
.entrar img { width: 72px; height: 72px; }
.entrar h1 { margin-top: 12px; }
.passos { text-align: left; counter-reset: passo; list-style: none; padding: 0; margin: 20px 0; }
.passos li { position: relative; padding: 0 0 14px 44px; }
.passos li::before {
  counter-increment: passo; content: counter(passo);
  position: absolute; left: 0; top: -2px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; background: var(--marca); color: var(--sobre-marca); font-weight: 700;
}
.codigo { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--superficie-2); padding: 2px 8px; border-radius: 6px; font-weight: 700; }

/* ---------- Abas ---------- */
.abas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--altura-abas) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--superficie); border-top: 1px solid var(--borda);
}
.abas a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--texto-fraco); text-decoration: none; font-size: 12px; font-weight: 600;
}
.aba-icone { font-size: 20px; line-height: 1; }
.abas a[aria-current="page"] { color: var(--marca); }
.aba-destaque .aba-icone {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--marca); color: var(--sobre-marca); font-size: 24px; margin-top: -6px;
}

/* ---------- Avisos ---------- */
.avisos {
  position: fixed; left: 0; right: 0; bottom: calc(var(--altura-abas) + env(safe-area-inset-bottom) + 12px);
  display: grid; justify-items: center; gap: 8px; padding: 0 16px; z-index: 20; pointer-events: none;
}
.aviso {
  pointer-events: auto; max-width: 560px; width: 100%;
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: var(--texto); color: var(--fundo); border-radius: 12px; padding: 12px 14px; box-shadow: var(--sombra);
}
.aviso button { background: none; border: 0; color: var(--marca-suave); font: inherit; font-weight: 700; cursor: pointer; padding: 6px; }
.aviso.erro { background: var(--atraso); color: #fff; }

.carregando { height: 3px; margin: 40px auto; width: 40%; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--marca), transparent); background-size: 200% 100%; animation: carregar 1.1s linear infinite; }
@keyframes carregar { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .carregando { animation: none; background: var(--marca-suave); } }

.noscript { padding: 24px; text-align: center; }

@media (min-width: 720px) {
  .numeros { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
