:root {
  --purple: #6C3CE1;
  --purple-dark: #4f28b8;
  --green: #00b386;
  --red: #e63946;
  --bg: #f0f2f8;
  --card: #ffffff;
  --text: #1a1a2e;
  --muted: #7a7a9a;
  --radius: 16px;
  --nav-h: 72px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ── LOGIN ── */
#login {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 60px 28px 40px;
  min-height: 100dvh;
  background: linear-gradient(160deg, var(--purple) 0%, var(--purple-dark) 100%);
}
.login-logo { font-size: 56px; margin-bottom: 4px; }
#login h1 { font-size: 2rem; color: #fff; font-weight: 700; }
.login-sub { color: rgba(255,255,255,.7); font-size: .9rem; margin-bottom: 8px; }
#login input {
  width: 100%; padding: 15px 16px; font-size: 16px;
  border: none; border-radius: 12px;
  background: rgba(255,255,255,.15); color: #fff;
  outline: none;
}
#login input::placeholder { color: rgba(255,255,255,.6); }
#login input:focus { background: rgba(255,255,255,.25); }
#login button#entrar {
  width: 100%; padding: 15px; font-size: 16px; font-weight: 600;
  border: none; border-radius: 12px;
  background: #fff; color: var(--purple); cursor: pointer;
  margin-top: 4px;
}
#erro { color: rgba(255,255,255,.85); font-size: .85rem; min-height: 20px; }

/* ── APP LAYOUT ── */
#app {
  display: flex; flex-direction: column;
  min-height: 100dvh;
}

/* ── HEADER ── */
#header {
  background: linear-gradient(160deg, var(--purple) 0%, var(--purple-dark) 100%);
  padding: env(safe-area-inset-top, 44px) 20px 24px;
  border-radius: 0 0 28px 28px;
  color: #fff;
}
.header-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.header-greeting { font-size: .95rem; opacity: .85; }
.sair {
  background: rgba(255,255,255,.2); color: #fff;
  border: none; border-radius: 8px;
  padding: 5px 12px; font-size: .8rem; cursor: pointer;
}
.header-mes {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; margin-bottom: 12px;
}
.mes-nav {
  background: rgba(255,255,255,.2); color: #fff;
  border: none; border-radius: 50%;
  width: 30px; height: 30px; font-size: 1.1rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#mes-label { font-size: 1rem; font-weight: 600; opacity: .95; }
.saldo-total { text-align: center; margin-bottom: 16px; }
.saldo-label { font-size: .8rem; opacity: .75; display: block; margin-bottom: 4px; }
.saldo-total b { font-size: 2.4rem; font-weight: 700; letter-spacing: -1px; }
.saldo-cards {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-bottom: 12px;
}
.saldo-card {
  background: rgba(255,255,255,.18);
  border-radius: 12px; padding: 10px 14px;
}
.saldo-card span { font-size: .75rem; opacity: .8; display: block; margin-bottom: 4px; }
.saldo-card b { font-size: 1rem; font-weight: 700; }
.saldo-card.entrada { border-left: 3px solid #4dffb4; }
.saldo-card.saida   { border-left: 3px solid #ff6b8a; }
.contas-row {
  display: flex; gap: 10px; justify-content: center;
}
.conta-chip {
  background: rgba(255,255,255,.15);
  border-radius: 20px; padding: 5px 12px;
  font-size: .78rem; display: flex; align-items: center; gap: 6px;
}
.conta-chip b { font-weight: 600; }
.conta-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.conta-dot.inter { background: #ff6b35; }
.conta-dot.din   { background: #4dffb4; }

/* ── CONTEÚDO ── */
#conteudo {
  flex: 1; padding: 16px 16px calc(var(--nav-h) + 16px);
  overflow-y: auto;
}
.section-title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
  margin: 16px 0 8px;
}

/* ── VENCIMENTOS ── */
#venc { list-style: none; display: flex; flex-direction: column; gap: 8px; }
#venc li {
  background: var(--card); border-radius: 12px;
  padding: 12px 14px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
#venc li .dia {
  background: var(--purple); color: #fff;
  border-radius: 8px; padding: 4px 8px;
  font-size: .75rem; font-weight: 700; min-width: 38px; text-align: center;
}
#venc li .desc { flex: 1; font-size: .9rem; }
#venc li .val { font-weight: 600; color: var(--red); font-size: .9rem; }

/* ── TRANSAÇÕES ── */
#recentes { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.tx-group-label {
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
  margin: 14px 0 6px 2px;
}
.tx-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.tx-item {
  background: var(--card); border-radius: 12px;
  padding: 12px 14px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.tx-icon {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.tx-icon.income { background: #e6f9f3; }
.tx-icon.expense { background: #fdeef0; }
.tx-info { flex: 1; min-width: 0; }
.tx-desc { font-size: .9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.tx-val { font-weight: 700; font-size: .95rem; flex-shrink: 0; }
.tx-val.income { color: var(--green); }
.tx-val.expense { color: var(--red); }

/* ── BOTTOM NAV ── */
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  background: var(--card);
  box-shadow: 0 -1px 12px rgba(0,0,0,.1);
  display: flex; align-items: flex-start; justify-content: space-around;
  padding: 10px 20px 0;
  border-radius: 20px 20px 0 0;
  z-index: 100;
}
.nav-btn {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: .68rem; color: var(--muted); padding: 4px 16px;
  transition: color .15s;
}
.nav-btn.on { color: var(--purple); }
.nav-icon { font-size: 1.3rem; }
.fab-wrap { margin-top: -24px; }
#fab {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--purple); color: #fff;
  border: none; font-size: 1.8rem; line-height: 1;
  box-shadow: 0 4px 16px rgba(108,60,225,.45);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* ── MODAL ── */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 200; display: flex; align-items: flex-end;
}
#modal-overlay[hidden] { display: none; }
#modal {
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(env(safe-area-inset-bottom, 0px) + 24px);
  width: 100%; max-height: 92dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header span { font-size: 1.1rem; font-weight: 700; }
#modal-fechar {
  background: var(--bg); border: none; border-radius: 50%;
  width: 30px; height: 30px; cursor: pointer; font-size: .9rem;
}
.tipo-toggle {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--bg); border-radius: 12px; padding: 4px; gap: 4px;
}
.tipo-btn {
  border: none; border-radius: 9px; padding: 10px;
  font-size: .9rem; font-weight: 600; cursor: pointer;
  background: transparent; color: var(--muted);
  transition: all .15s;
}
.tipo-btn.on.expense { background: var(--red); color: #fff; }
.tipo-btn.on.income  { background: var(--green); color: #fff; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.form-group input[type="text"],
.form-group input[type="date"] {
  padding: 12px 14px; border: 1.5px solid #e0e0ee;
  border-radius: 12px; font-size: 16px; outline: none;
  background: var(--bg);
}
.form-group input:focus { border-color: var(--purple); }
.valor-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1.5px solid #e0e0ee;
  border-radius: 12px; padding: 0 14px;
}
.valor-wrap span { font-size: .95rem; color: var(--muted); font-weight: 600; }
.valor-wrap input {
  border: none; background: transparent; padding: 12px 0;
  font-size: 1.3rem; font-weight: 700; outline: none; flex: 1; width: 0;
}
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid #e0e0ee; border-radius: 20px;
  padding: 7px 14px; font-size: .82rem; cursor: pointer;
  background: transparent; color: var(--text);
  transition: all .15s;
}
.chip.on { background: var(--purple); color: #fff; border-color: var(--purple); }
#f-salvar {
  width: 100%; padding: 15px; border: none; border-radius: 14px;
  background: var(--purple); color: #fff;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  margin-top: 4px;
}
#f-erro { color: var(--red); font-size: .82rem; min-height: 16px; text-align: center; }
