:root {
  --navy: #0b1f3a;
  --navy-2: #1b3a6b;
  --verde: #12a150;
  --verde-vivo: #5ee09a;
  --verde-claro: #e3f8ec;
  --fundo: #f2f5fb;
  --branco: #ffffff;
  --texto: #0b1f3a;
  --texto-2: #5b6b82;
  --linha: #e3e8f0;
  --erro: #c0392b;
  --erro-claro: #fdecea;
  --raio: 20px;
  --sombra: 0 6px 20px rgba(11, 31, 58, .08);
  /* tons de cada ação */
  --t-entrada: #e3f8ec;
  --t-saida: #fff1e6;
  --t-iva: #e8efff;
  --t-conferir: #f3ecff;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Roboto', system-ui, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; transition: transform .12s ease; }
button:active:not(:disabled) { transform: scale(.96); }
[hidden] { display: none !important; }

.vista { max-width: 520px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

/* Cabeçalho com bolhas decorativas */
.topo {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: var(--branco);
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.topo h1 { font-size: 1.15rem; font-weight: 700; margin: 0; letter-spacing: .2px; z-index: 1; }
.topo h1 .logo { display: inline-block; animation: balancar 3s ease-in-out infinite; }
.btn-icone {
  background: rgba(255,255,255,.1); border: 0; color: var(--branco); z-index: 1;
  font-size: 1.4rem; width: 44px; height: 44px; border-radius: 50%;
}

.conteudo { padding: 16px; display: flex; flex-direction: column; gap: 16px; flex: 1; }
h2 { margin: 8px 0 0; font-size: 1.3rem; font-weight: 700; }
.ajuda { margin: 0; color: var(--texto-2); line-height: 1.45; }

/* Destaque: disponível */
.destaque {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, var(--navy-2) 0%, var(--navy) 70%);
  color: var(--branco);
  padding: 8px 20px 30px;
  margin: -16px -16px 0;
  border-radius: 0 0 32px 32px;
  display: flex; flex-direction: column; gap: 4px;
}
.destaque::before, .destaque::after, .topo::after {
  content: ''; position: absolute; border-radius: 50%; pointer-events: none;
}
.destaque::before { width: 220px; height: 220px; right: -70px; top: -90px; background: rgba(94, 224, 154, .14); }
.destaque::after { width: 140px; height: 140px; left: -50px; bottom: -70px; background: rgba(255, 255, 255, .06); }
.topo::after { width: 120px; height: 120px; right: 40px; top: -80px; background: rgba(94, 224, 154, .1); }
.saudacao {
  font-size: .92rem; line-height: 1.4; z-index: 1; opacity: .92;
  border-left: 3px solid var(--verde-vivo); padding: 2px 0 2px 10px; margin-top: 4px;
  animation: aparecer .6s ease;
}
.destaque .rotulo { font-size: .95rem; opacity: .8; margin-top: 10px; z-index: 1; }
.valor-grande {
  font-size: clamp(2.6rem, 12vw, 3.4rem); font-weight: 700; letter-spacing: -1px; z-index: 1;
  color: var(--verde-vivo); font-variant-numeric: tabular-nums;
}
.valor-grande.zero { color: var(--branco); }
.valor-grande.pulo { animation: pulo .45s ease; }
.humor {
  z-index: 1; align-self: flex-start; margin-top: 6px;
  background: rgba(255,255,255,.12); border-radius: 999px; padding: 8px 14px; font-size: .9rem;
}

.valores {
  margin: 0; background: var(--branco); border-radius: var(--raio); box-shadow: var(--sombra);
  padding: 4px 16px;
}
.valores > div { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--linha); gap: 10px; }
.valores > div:last-child { border-bottom: 0; }
.valores dt { color: var(--texto-2); display: flex; align-items: center; gap: 10px; }
.valores dt .ico { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; background: var(--fundo); font-size: 1.05rem; }
.valores dd { margin: 0; font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
#linha-por-devolver.ativo dd { color: #d9730d; }
#linha-por-devolver.ativo .ico { background: var(--t-saida); }

.acoes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.acao {
  border: 0; border-radius: var(--raio); box-shadow: var(--sombra);
  min-height: 118px; padding: 16px; font-size: 1rem; font-weight: 700;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; text-align: left;
}
.acao[data-acao="entrada"] { background: var(--t-entrada); }
.acao[data-acao="saida"] { background: var(--t-saida); }
.acao[data-acao="iva"] { background: var(--t-iva); }
.acao[data-acao="conferir"] { background: var(--t-conferir); }
.acao .emoji {
  width: 46px; height: 46px; border-radius: 16px; display: grid; place-items: center;
  background: var(--branco); font-size: 1.5rem; box-shadow: 0 2px 8px rgba(11,31,58,.08);
}
.acao:hover .emoji { animation: balancar .6s ease; }

.btn-principal, .btn-secundario, .btn-perigo {
  width: 100%; min-height: 56px; border-radius: 16px; font-size: 1.05rem; font-weight: 700; border: 0;
}
.btn-principal { background: linear-gradient(135deg, #17b85d, var(--verde)); color: var(--branco); box-shadow: 0 6px 16px rgba(18,161,80,.3); }
.btn-principal:disabled { background: #c3ccd9; box-shadow: none; }
.btn-secundario { background: var(--branco); color: var(--navy); border: 1px solid var(--linha); box-shadow: var(--sombra); }
.btn-perigo { background: var(--erro-claro); color: var(--erro); }

.btn-link { display: flex; align-items: center; justify-content: center; text-decoration: none; }

/* Formulários */
form { display: flex; flex-direction: column; gap: 16px; }
.campo { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.campo .sub { font-weight: 400; color: var(--texto-2); font-size: .9rem; }
.campo input {
  min-height: 60px; border: 2px solid var(--linha); border-radius: 16px; padding: 0 16px;
  font-size: 1.6rem; font-weight: 700; background: var(--branco); font-variant-numeric: tabular-nums;
}
.campo input:focus { outline: none; border-color: var(--verde); box-shadow: 0 0 0 4px var(--verde-claro); }
.erro { background: var(--erro-claro); color: var(--erro); padding: 12px 14px; border-radius: 14px; margin: 0; line-height: 1.4; animation: abanar .35s ease; }

.escolha { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.escolha button {
  min-height: 72px; border-radius: 16px; border: 2px solid var(--linha); background: var(--branco);
  font-weight: 700; padding: 8px; line-height: 1.2;
}
.escolha button .e { display: block; font-size: 1.4rem; margin-bottom: 2px; }
.escolha button small { display: block; font-weight: 400; color: var(--texto-2); font-size: .8rem; margin-top: 3px; }
.escolha button[aria-pressed="true"] { border-color: var(--verde); background: var(--verde-claro); }

.efeito { background: var(--fundo); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; font-size: .95rem; }
.efeito div { display: flex; justify-content: space-between; gap: 8px; }
.efeito span:first-child { color: var(--texto-2); }
.efeito b { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Painel inferior */
.fundo { position: fixed; inset: 0; background: rgba(11, 31, 58, .45); z-index: 10; animation: aparecer .2s ease; }
.painel {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 11;
  max-width: 520px; margin: 0 auto; max-height: 92dvh; overflow-y: auto;
  background: var(--branco); border-radius: 28px 28px 0 0;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  animation: subir .28s cubic-bezier(.2, 1.3, .4, 1);
}
.painel-pega { width: 44px; height: 5px; border-radius: 3px; background: var(--linha); margin: 4px auto 12px; }
.painel h2 { margin: 0 0 4px; }
.painel-conteudo-gap { display: flex; flex-direction: column; gap: 16px; }
.linha-botoes { display: flex; gap: 10px; }
.linha-botoes > * { flex: 1; }
.atalho { background: var(--verde-claro); border: 0; color: #0b6b37; font-weight: 700; padding: 8px 14px; border-radius: 999px; align-self: flex-start; }

.resultado { border-radius: 18px; padding: 18px; text-align: center; font-weight: 500; }
.resultado.ok { background: var(--verde-claro); color: #0b6b37; animation: pulo .45s ease; }
.resultado.dif { background: var(--erro-claro); color: var(--erro); }
.resultado .grande-emoji { font-size: 2.4rem; display: block; }
.resultado strong { display: block; font-size: 1.6rem; margin-top: 4px; }

/* Histórico */
.lista { list-style: none; margin: 0; padding: 0; background: var(--branco); border-radius: var(--raio); box-shadow: var(--sombra); overflow: hidden; }
.lista li { border-bottom: 1px solid var(--linha); }
.lista li:last-child { border-bottom: 0; }
.lista button {
  width: 100%; background: none; border: 0; padding: 12px 16px; display: flex; align-items: center; gap: 12px; text-align: left;
}
.lista button:active:not(:disabled) { transform: none; background: var(--fundo); }
.lista .ico { flex: none; width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: var(--fundo); font-size: 1.2rem; }
.lista .info { flex: 1; min-width: 0; }
.lista .tipo { font-weight: 500; }
.lista .data { color: var(--texto-2); font-size: .85rem; display: block; margin-top: 2px; }
.lista .montante { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lista .montante.pos { color: var(--verde); }
.lista li.anulado { opacity: .55; }
.lista li.anulado .tipo, .lista li.anulado .montante { text-decoration: line-through; }
.etiqueta { font-size: .72rem; background: var(--fundo); color: var(--texto-2); border-radius: 6px; padding: 2px 6px; margin-left: 6px; }
.vazio { text-align: center; color: var(--texto-2); padding: 32px 16px; }
.vazio .grande-emoji { font-size: 2.6rem; display: block; margin-bottom: 6px; }

.aviso {
  position: fixed; left: 16px; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 20;
  max-width: 488px; margin: 0 auto; background: var(--navy); color: var(--branco); font-weight: 500;
  padding: 14px 16px; border-radius: 16px; text-align: center; box-shadow: 0 10px 30px rgba(11,31,58,.3);
  animation: subir .3s cubic-bezier(.2, 1.3, .4, 1);
}

/* Confetti */
.confetti { position: fixed; top: -12px; width: 9px; height: 14px; border-radius: 2px; z-index: 30; pointer-events: none; animation: cair linear forwards; }

@keyframes subir { from { transform: translateY(40px); opacity: 0; } }
@keyframes aparecer { from { opacity: 0; } }
@keyframes pulo { 0% { transform: scale(1); } 40% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes balancar { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
@keyframes abanar { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes cair { to { transform: translateY(105vh) rotate(720deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
