:root {
  --primary: #8b5cf6;
  --primary-dark: #6d28d9;
  --bg: #0f0b1e;
  --card: #1a1530;
  --border: #2d2547;
  --text: #f1eefc;
  --muted: #a79fc7;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.35);
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
.main-content { max-width: 720px; margin: 0 auto; padding: 20px 16px 100px; }

.sidebar { display: none; }
.mobile-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.mobile-header .brand { font-weight: 800; font-size: 18px; display:flex; align-items:center; gap:8px; }
.mobile-header .brand .logo-badge {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center; font-weight: 900; color: #fff;
}
.mobile-header .sair { color: var(--muted); font-size: 14px; }

@media (min-width: 1024px) {
  .sidebar {
    display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0;
    width: 256px; background: var(--card); border-right: 1px solid var(--border); padding: 24px 16px;
  }
  .sidebar .brand { font-weight: 800; font-size: 20px; display:flex; align-items:center; gap:10px; margin-bottom: 32px; }
  .sidebar .brand .logo-badge {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    display: flex; align-items: center; justify-content: center; font-weight: 900; color: #fff;
  }
  .sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
  .sidebar nav a { color: var(--muted); padding: 10px 14px; border-radius: 10px; font-size: 15px; font-weight: 600; }
  .sidebar nav a.ativo, .sidebar nav a:hover { background: rgba(139,92,246,0.15); color: var(--text); }
  .sidebar .sair { color: var(--muted); font-size: 14px; padding: 10px 14px; }
  .mobile-header { display: none; }
  .main-content { margin-left: 256px; max-width: 720px; padding: 32px 24px 60px; }
  .bottom-nav { display: none !important; }
}

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--card);
  border-top: 1px solid var(--border); display: grid; grid-template-columns: repeat(6, 1fr);
  z-index: 20; padding: 6px 0 8px;
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 10px; padding: 6px 0; }
.bottom-nav a.ativo { color: var(--primary); }
.bottom-nav .ic { font-size: 18px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 480px) { .grid-3 { grid-template-columns: repeat(2, 1fr); } }

.saldo-hero { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); border-radius: 20px; padding: 24px; margin-bottom: 16px; color: #fff; }
.saldo-hero .rotulo { font-size: 13px; opacity: 0.85; }
.saldo-hero .valor { font-size: 34px; font-weight: 900; margin: 4px 0 14px; }
.saldo-hero .linha { display: flex; justify-content: space-between; font-size: 13px; opacity: 0.9; margin-top: 4px; }

.stat-card { text-align: center; }
.stat-card .num { font-size: 22px; font-weight: 800; }
.stat-card .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-card.receita .num { color: var(--green); }
.stat-card.despesa .num { color: var(--red); }
.stat-card.investimento .num { color: #38bdf8; }

.insight-card { border-left: 4px solid var(--primary); }
.insight-card.alerta { border-left-color: var(--red); }
.insight-card.atencao { border-left-color: var(--yellow); }
.insight-card.positivo { border-left-color: var(--green); }
.dica-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.dica-item:last-child { border-bottom: none; }
.dica-item .titulo { font-weight: 700; font-size: 14px; }
.dica-item .msg { font-size: 13px; color: var(--muted); margin-top: 2px; }

.nivel-card { display: flex; align-items: center; gap: 14px; }
.nivel-emoji { width: 48px; height: 48px; border-radius: 14px; background: rgba(139,92,246,0.15); display:flex; align-items:center; justify-content:center; font-size: 20px; font-weight:800; color:var(--primary); }
.nivel-info { flex: 1; }
.nivel-titulo { font-weight: 800; font-size: 15px; }
.nivel-sub { font-size: 12px; color: var(--muted); }
.xp-bar { height: 8px; border-radius: 4px; background: var(--border); margin-top: 8px; overflow: hidden; }
.xp-bar > div { height: 100%; background: linear-gradient(90deg, var(--primary), #c084fc); }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: #14102570; color: var(--text); font-size: 15px;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 20px; border-radius: 12px; font-weight: 700; font-size: 15px; border: none; cursor: pointer; text-align: center; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--red); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 10px 8px; text-align: left; font-size: 14px; border-bottom: 1px solid var(--border); }
table.list th { color: var(--muted); font-size: 12px; text-transform: uppercase; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-receita { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-despesa { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-investimento { background: rgba(56,189,248,0.15); color: #38bdf8; }
.badge-pendente { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-aprovado, .badge-pago { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-rejeitado { background: rgba(239,68,68,0.15); color: var(--red); }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 16px; border-radius: 20px; font-size: 13px; font-weight: 700; color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.tabs a.ativo { background: var(--primary); color: #fff; border-color: var(--primary); }

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 32px 26px; box-shadow: var(--shadow); }
.auth-card .logo-badge { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); display:flex; align-items:center; justify-content:center; font-weight:900; color:#fff; font-size:20px; margin: 0 auto 16px; }
.auth-card h1 { text-align: center; font-size: 20px; margin: 0 0 4px; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.auth-card .foot { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.msg-erro { background: rgba(239,68,68,0.15); color: #fca5a5; padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.msg-ok { background: rgba(34,197,94,0.15); color: #86efac; padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.pagetitle { font-size: 22px; font-weight: 800; margin-bottom: 16px; }
.section-label { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; margin: 20px 0 10px; }


/* ---- Tema claro ---- */
[data-theme="light"] {
  --bg: #f5f5fb;
  --card: #ffffff;
  --border: #e5e2f0;
  --text: #191333;
  --muted: #6f6789;
  --shadow: 0 2px 14px rgba(30,20,60,0.07);
}
[data-theme="light"] .form-group input,
[data-theme="light"] .form-group select,
[data-theme="light"] .form-group textarea { background: #ffffff; }
[data-theme="light"] .mobile-header { background: var(--bg); }
[data-theme="light"] .nivel-emoji { background: rgba(139,92,246,0.10); }

/* ---- Toggle de tema ---- */
.theme-toggle { display:inline-flex; align-items:center; justify-content:center; gap:6px; padding:9px 12px; border-radius:10px; border:1px solid var(--border); background:transparent; color:var(--muted); font-size:12.5px; font-weight:700; cursor:pointer; font-family:inherit; }
.theme-toggle:hover { color:var(--text); border-color:var(--primary); }
.sidebar .theme-toggle { margin:14px 0 10px; width:100%; }
.mobile-header .theme-toggle { padding:7px 10px; font-size:11.5px; }

/* ---- Filtros de historico ---- */
.filtro-tabs { display:flex; gap:6px; overflow-x:auto; margin-bottom:10px; padding-bottom:2px; }
.filtro-tabs button { flex-shrink:0; padding:7px 14px; border-radius:20px; font-size:12.5px; font-weight:700; color:var(--muted); border:1px solid var(--border); background:transparent; cursor:pointer; font-family:inherit; white-space:nowrap; }
.filtro-tabs button.ativo { background:var(--primary); color:#fff; border-color:var(--primary); }
.filtro-total { display:flex; justify-content:space-between; align-items:center; padding:12px 2px 16px; font-size:13px; color:var(--muted); }
.filtro-total strong { color:var(--text); font-size:19px; font-weight:800; }

/* ---- Historico agrupado ---- */
.hist-grupo { margin-bottom:14px; }
.hist-grupo:last-child { margin-bottom:0; }
.hist-grupo-header { display:flex; justify-content:space-between; align-items:center; padding:6px 2px; font-size:12px; font-weight:800; text-transform:uppercase; letter-spacing:.3px; color:var(--muted); }
.hist-grupo-header .valor { font-size:14px; color:var(--text); font-weight:800; }
.table-wrap { overflow-x:auto; }
.table-wrap table.list { min-width:520px; }

/* ---- Graficos ---- */
.chart-card svg { width:100%; height:auto; display:block; }
.chart-legend { display:flex; gap:14px; flex-wrap:wrap; margin-top:12px; font-size:12px; color:var(--muted); }
.chart-legend span { display:inline-flex; align-items:center; gap:6px; }
.chart-legend i { width:10px; height:10px; border-radius:3px; display:inline-block; }
.barra-cat { display:flex; align-items:center; gap:10px; padding:7px 0; }
.barra-cat .nome { width:100px; font-size:12.5px; color:var(--muted); flex-shrink:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.barra-cat .trilho { flex:1; height:8px; border-radius:4px; background:var(--border); overflow:hidden; }
.barra-cat .trilho > div { height:100%; border-radius:4px; }
.barra-cat .val { width:76px; text-align:right; font-size:12.5px; font-weight:700; flex-shrink:0; }
.chart-empty { text-align:center; color:var(--muted); font-size:13px; padding:20px 0; }


/* ---- Botoes de icone (editar/excluir) e nome de categoria compacto ---- */
.btn-icon { width:32px; height:32px; padding:0; border-radius:9px; flex-shrink:0; }
.btn-icon svg { width:15px; height:15px; display:block; margin:0 auto; }
.acoes-linha { display:inline-flex; gap:6px; align-items:center; }
.hist-grupo-header .nome-cat { text-transform:none; font-weight:600; font-size:11.5px; color:var(--muted); margin-left:2px; }
.hist-grupo-header .badge { font-size:10.5px; padding:2px 8px; }
