:root {
  --bg: #0b0d10;
  --card: #16191d;
  --texto: #e8eaed;
  --texto-fraco: #9aa0a6;
  --linha: #2a2e33;
  --verde: #34d399;
  --vermelho: #f87171;
  --acento: #60a5fa;
  --raio: 12px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --card: #ffffff;
    --texto: #1a1d21;
    --texto-fraco: #5f6368;
    --linha: #e2e5e9;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--texto);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

#login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
}

#login h1 { font-size: 1.2rem; color: var(--texto-fraco); font-weight: 500; }

#login input {
  width: 100%;
  max-width: 280px;
  padding: 14px 16px;
  font-size: 1rem;
  border-radius: var(--raio);
  border: 1px solid var(--linha);
  background: var(--card);
  color: var(--texto);
  text-align: center;
}

#login button, .acao {
  width: 100%;
  max-width: 280px;
  padding: 14px;
  font-size: 1rem;
  border-radius: var(--raio);
  border: none;
  background: var(--acento);
  color: #0b0d10;
  font-weight: 600;
}

#login .erro { color: var(--vermelho); font-size: 0.9rem; min-height: 1.2em; }

#app { display: none; min-height: 100vh; flex-direction: column; }
#app.ativo { display: flex; }

header.topo {
  padding: 16px 20px 8px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

header.topo h1 { font-size: 1.1rem; margin: 0; }
header.topo span { font-size: 0.75rem; color: var(--texto-fraco); }

main { flex: 1; padding: 8px 16px 90px; overflow-y: auto; }

.vista { display: none; }
.vista.ativa { display: block; }

.card {
  background: var(--card);
  border-radius: var(--raio);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--linha);
}

.card .rotulo { font-size: 0.8rem; color: var(--texto-fraco); margin-bottom: 4px; }
.card .valor { font-size: 1.6rem; font-weight: 700; }
.card .valor.pos { color: var(--verde); }
.card .valor.neg { color: var(--vermelho); }

.linha {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--linha);
  font-size: 0.92rem;
}
.linha:last-child { border-bottom: none; }
.linha .nome { flex: 1; }
.linha .meta { color: var(--texto-fraco); font-size: 0.78rem; }
.linha .num { font-weight: 600; white-space: nowrap; margin-left: 12px; }
.linha .num.gasto { color: var(--vermelho); }
.linha .num.ganho { color: var(--verde); }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}
.badge.atrasado { background: rgba(248,113,113,.15); color: var(--vermelho); }
.badge.previsto { background: rgba(96,165,250,.15); color: var(--acento); }
.badge.pago { background: rgba(52,211,153,.15); color: var(--verde); }

.mes-bloco { margin-bottom: 18px; }
.mes-bloco h3 { font-size: 0.95rem; margin: 0 0 8px; display: flex; justify-content: space-between; }
.mes-bloco h3 .saldo.neg { color: var(--vermelho); }
.mes-bloco h3 .saldo.pos { color: var(--verde); }

.vazio, .carregando, .aviso {
  color: var(--texto-fraco);
  font-size: 0.9rem;
  text-align: center;
  padding: 24px 8px;
}
.aviso { color: var(--vermelho); }

nav.tabs {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--linha);
  padding-bottom: env(safe-area-inset-bottom);
}

nav.tabs button {
  flex: 1;
  background: none;
  border: none;
  color: var(--texto-fraco);
  font-size: 0.72rem;
  padding: 10px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

nav.tabs button .ic { font-size: 1.2rem; }
nav.tabs button.ativa { color: var(--acento); }
