:root {
  --bg: #14181f;
  --surface: #1d2430;
  --surface-2: #232b38;
  --border: #2b3442;
  --divider: #242c38;
  --text: #f2f4f7;
  --text-2: #9aa4b2;
  --text-3: #6b7684;
  --accent: #5fb8ad;
  --on-accent: #10171a;
  --success: #5fb8ad;
  --success-bg: #1c3330;
  --danger: #d97757;
  --cat-mercado: #c8935a;
  --cat-casa: #b09fe0;
  --cat-lazer: #d98fb3;
  --cat-transporte: #7fa8c9;
  --cat-saude: #8fc98f;
  --cat-assinaturas: #6fbfae;
  --cat-outros: #9aa0a6;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', sans-serif;
  overscroll-behavior-y: contain;
}
.mono { font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; }

.view { min-height: 100vh; }

/* ---- Login ---- */
#login-view {
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-box { width: 100%; max-width: 320px; text-align: center; }
.login-mark {
  width: 64px; height: 64px; border-radius: 18px; background: var(--surface);
  border: 2px solid var(--accent); margin: 0 auto 18px;
  position: relative;
}
.login-mark::before, .login-mark::after {
  content: ""; position: absolute; background: var(--accent);
}
.login-mark::before { top: 30px; left: 16px; right: 16px; height: 4px; border-radius: 2px; }
.login-mark::after { top: 14px; left: 30px; width: 4px; height: 12px; border-radius: 2px; }
.login-box h1 { font-size: 22px; margin: 0 0 4px; }
.login-sub { color: var(--text-2); font-size: 13px; margin: 0 0 28px; }
.login-box input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 13px 14px; color: var(--text); font-size: 15px;
  margin-bottom: 10px; font-family: inherit;
}
.login-box input:focus { outline: none; border-color: var(--accent); }
.erro-msg { color: var(--danger); font-size: 13px; min-height: 16px; margin-bottom: 8px; }
.btn-primary {
  width: 100%; background: var(--accent); color: var(--on-accent); border: none;
  border-radius: 10px; padding: 14px; font-size: 15px; font-weight: 700; margin-top: 6px;
}

/* ---- Shell / nav ---- */
.tela { padding: 20px 20px 100px; max-width: 480px; margin: 0 auto; min-height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-title.left { font-size: 19px; font-weight: 700; }
.wordmark { font-size: 12px; color: var(--text-3); letter-spacing: .08em; }
.icon-btn { color: var(--text-2); display: flex; align-items: center; justify-content: center; cursor: pointer; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; height: 82px;
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto;
}
.nav-item { color: var(--text-3); cursor: pointer; display: flex; padding: 10px; }
.nav-item.active { color: var(--accent); }
.nav-fab {
  width: 50px; height: 50px; border-radius: 16px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; margin-top: -20px;
  cursor: pointer;
}

/* ---- Cards / generic ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; }
.label-sm { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
.valor-grande { font-size: 40px; font-weight: 600; margin: 8px 0 14px; }
.dias-bar { height: 4px; border-radius: 3px; background: var(--divider); overflow: hidden; margin-bottom: 8px; }
.dias-bar-fill { height: 100%; background: var(--accent); }

.simular-row { display: flex; gap: 8px; margin-top: 12px; }
.input-mono {
  flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; color: var(--text); font-family: 'IBM Plex Mono', monospace; font-size: 16px;
}
.btn-accent {
  background: var(--accent); color: var(--on-accent); border: none; border-radius: 8px;
  padding: 10px 18px; font-size: 13px; font-weight: 700; letter-spacing: .02em; cursor: pointer;
}
.btn-secondary {
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 18px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.resultado-box { margin-top: 12px; border-radius: 8px; padding: 9px 12px; font-size: 13px; font-family: 'IBM Plex Mono', monospace; }
.resultado-box.ok { background: var(--success-bg); color: var(--success); }
.resultado-box.no { background: #3a2420; color: var(--danger); }

.section-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.section-title { font-size: 13px; font-weight: 600; }
.link-sm { color: var(--accent); font-size: 12px; text-decoration: none; }

.cat-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--divider);
}
.cat-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.cat-nome { flex: 1; font-size: 14px; }
.cat-valor { font-size: 13px; color: var(--text-2); }
.lista-categorias-mini .cat-row:last-child { border-bottom: none; }

/* ---- Lançamento ---- */
.segmented { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px; margin-bottom: 6px; }
.segmented-opt { flex: 1; text-align: center; padding: 10px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.segmented-opt.active { background: var(--success); color: var(--on-accent); }
.segmented-opt.active.tipo-despesa { background: var(--danger); }

.valor-input-wrap { text-align: center; padding: 30px 0 18px; }
.valor-input-row { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.valor-prefix { color: var(--text-2); font-size: 26px; }
.valor-input {
  background: transparent; border: none; color: var(--text); font-size: 46px; font-weight: 600;
  width: 220px; text-align: left; caret-color: var(--accent);
}
.valor-input:focus { outline: none; }

.cat-label { margin-bottom: 12px; }
.grid-categorias { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin-bottom: 18px; }
.cat-chip {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer;
}
.cat-chip.selected { background: var(--surface-2); border-color: var(--accent); }
.cat-chip-swatch { width: 30px; height: 30px; border-radius: 9px; }
.cat-chip-label { font-size: 12px; color: var(--text-2); text-align: center; }
.cat-chip.selected .cat-chip-label { color: var(--text); }

.lanc-extra-row { margin-bottom: 12px; }
.input-generic {
  width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; color: var(--text); font-size: 14px; font-family: inherit;
}
.input-generic::placeholder { color: var(--text-3); }

.bottom-cta { position: fixed; left: 0; right: 0; bottom: 0; padding: 14px 20px 28px; max-width: 480px; margin: 0 auto; }
.btn-accent.full { width: 100%; padding: 16px; font-size: 15px; border-radius: 12px; }

/* ---- Categorias ---- */
.donut-wrap { display: flex; justify-content: center; margin: 10px 0 22px; position: relative; }
.donut-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); text-align: center; }
.donut-total { font-size: 22px; font-weight: 600; }
.lista-categorias-full .cat-row:last-child { border-bottom: none; }
.cat-pct { font-size: 12px; color: var(--text-2); margin-right: 10px; }

/* ---- Gastos fixos ---- */
.fixo-row {
  display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; margin-bottom: 10px; cursor: pointer;
}
.fixo-swatch { width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; }
.fixo-nome { font-size: 14px; font-weight: 600; }
.fixo-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.fixo-valor { font-size: 14px; font-weight: 600; margin-left: auto; }

.overlay-form {
  position: fixed; inset: 0; background: rgba(10,13,18,.6); display: flex; align-items: flex-end; justify-content: center; z-index: 10;
}
.overlay-card { background: var(--surface); border-radius: 20px 20px 0 0; padding: 24px 20px 32px; width: 100%; max-width: 480px; }
.overlay-actions { display: flex; gap: 10px; margin-top: 20px; }
.overlay-actions button { flex: 1; }
select.input-generic { appearance: none; }

/* ---- Config ---- */
.perfil-row { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.avatar { width: 52px; height: 52px; border-radius: 16px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.perfil-nome { font-size: 15px; font-weight: 600; }
.perfil-email { font-size: 12px; color: var(--text-2); }
.section-label { margin-bottom: 10px; margin-top: 4px; }
.lista-config { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 22px; }
.config-row { display: flex; align-items: center; justify-content: space-between; padding: 15px 16px; border-bottom: 1px solid var(--divider); font-size: 14px; }
.config-row:last-child { border-bottom: none; }
.config-row.danger { color: var(--danger); cursor: pointer; }
.input-mono-inline {
  background: var(--surface-2); border: none; border-radius: 6px; padding: 4px 10px; color: var(--accent);
  font-family: 'IBM Plex Mono', monospace; font-size: 13px; width: 50px; text-align: center;
}
