/* ─── Design tokens (ver docs/design-system.md) ───────────── */
:root {
  /* Marca */
  --brand-navy:     #0B1220;
  --brand-blue:     #3563E9;
  --brand-cyan:     #4CC9F0;
  --brand-violet:   #7C5CFC;

  /* Ação */
  --primary:        #3563E9;
  --primary-hover:  #244BC5;
  --primary-light:  #EBF0FD;
  --primary-border: #C9D6F8;
  --secondary:      #4CC9F0;
  --accent:         #7C5CFC;

  /* Semânticas (somente para significado financeiro) */
  --success:        #16B364;
  --success-light:  #E7F7EF;
  --danger:         #F04438;
  --danger-light:   #FEEDEC;
  --warning:        #F79009;
  --warning-light:  #FEF4E6;

  /* Superfícies e texto */
  --bg:             #F6F8FC;
  --surface:        #FFFFFF;
  --surface-2:      #F2F4F8;
  --border:         #E5E7EB;
  --border-strong:  #D0D5DD;
  --text:           #0B1220;
  --text-2:         #475467;
  --text-muted:     #667085;

  /* Sidebar */
  --sidebar-bg:        #0B1220;
  --sidebar-text:      #A6B0C3;
  --sidebar-label:     #5E6A82;
  --sidebar-hover:     rgba(255,255,255,.06);
  --sidebar-active-bg: rgba(53,99,233,.16);
  --sidebar-divider:   rgba(255,255,255,.07);

  /* Espaçamento */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px; --space-5: 20px;
  --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px;

  /* Forma */
  --radius:         14px;   /* cards */
  --radius-sm:      10px;   /* botões, inputs */
  --radius-lg:      16px;   /* modais */
  --radius-pill:    999px;
  --shadow-sm:      0 1px 2px rgba(16,24,40,.04);
  --shadow:         0 4px 12px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg:      0 16px 40px rgba(11,18,32,.14);
  --focus-ring:     0 0 0 3px rgba(53,99,233,.18);
  --transition:     180ms ease;

  /* Camadas */
  --z-topbar: 30; --z-sidebar: 40; --z-fab: 40; --z-bottomnav: 50; --z-modal: 100;

  /* Layout */
  --sidebar-w:      264px;
  --topbar-h:       64px;
  --bottomnav-h:    64px;
}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
[x-cloak] { display: none !important; }

/* ─── Layout ─────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Brand (logo) ───────────────────────────────────────── */
.brand { display: inline-flex; align-items: center; gap: var(--space-3); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex-shrink: 0; display: block; }
.brand-name { display: flex; flex-direction: column; line-height: 1.05; font-weight: 800; letter-spacing: -.01em; }
.brand-first  { font-size: 1rem; color: var(--text); }
.brand-second { font-size: 1rem; color: var(--primary); }
.brand-escuro .brand-first  { color: #FFFFFF; }
.brand-escuro .brand-second { color: #6F96FF; }
.brand-sm .brand-mark { width: 28px; height: 28px; }
.brand-sm .brand-first, .brand-sm .brand-second { font-size: .875rem; }
.brand-lg .brand-mark { width: 52px; height: 52px; }
.brand-lg .brand-first, .brand-lg .brand-second { font-size: 1.5rem; }

/* Sidebar — escondida no mobile, visível no desktop */
.sidebar {
  display: none;
  flex-direction: column;
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  z-index: var(--z-sidebar);
}
@media (min-width: 1024px) {
  .sidebar { display: flex; }
}
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); }

.sidebar-logo { padding: var(--space-6) var(--space-5) var(--space-4); }
.sidebar-logo .brand { text-decoration: none; }

.sidebar-nav { flex: 1; padding: var(--space-2) var(--space-3) var(--space-4); }
.nav-section-label {
  font-size: .6875rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--sidebar-label);
  padding: var(--space-4) var(--space-3) var(--space-2);
}
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: .875rem; font-weight: 500;
  color: var(--sidebar-text);
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--sidebar-hover); color: #FFFFFF; }
.nav-item.active { background: var(--sidebar-active-bg); color: #FFFFFF; font-weight: 600; }
.nav-item.active .nav-icon { color: var(--brand-cyan); }
.nav-item .nav-icon { width: 20px; text-align: center; font-size: .9375rem; flex-shrink: 0; }

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid var(--sidebar-divider);
}
.sidebar-user {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3) var(--space-3);
}
.sidebar-user .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-violet));
  color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  font-size: .8125rem; font-weight: 700; flex-shrink: 0;
}
.sidebar-user .user-name  { font-size: .875rem; font-weight: 600; color: #FFFFFF; }
.sidebar-user .user-email { font-size: .75rem; color: var(--sidebar-label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
.sidebar-footer .nav-item-logout:hover { color: #FF8A80; }

/* Content Wrapper */
.content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* Top Bar */
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  height: var(--topbar-h);
  background: rgba(246, 248, 252, .9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
}
.topbar-logo { display: flex; align-items: center; text-decoration: none; }
.topbar-title {
  font-size: 1rem; font-weight: 700; color: var(--text); flex: 1;
  display: none;
}
@media (min-width: 1024px) {
  .topbar { padding: 0 var(--space-8); }
  .topbar-logo { display: none; }
  .topbar-title { display: block; font-size: 1.125rem; }
}
.topbar-right { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }
.topbar-date { font-size: .8125rem; color: var(--text-muted); display: none; font-variant-numeric: tabular-nums; }
@media (min-width: 640px) { .topbar-date { display: block; } }
.topbar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-violet));
  color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700;
  text-decoration: none;
}

/* Page Content */
.page-content {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  padding: var(--space-5) var(--space-4);
  padding-bottom: calc(var(--bottomnav-h) + var(--space-6));
}
@media (min-width: 1024px) {
  .page-content { padding: var(--space-8); }
}

/* Page header (título + subtítulo + ações) */
.page-header {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: var(--space-4); margin-bottom: var(--space-6);
}
.page-header h1 { font-size: 1.375rem; font-weight: 800; color: var(--text); margin: 0; letter-spacing: -.01em; }
.page-header p  { font-size: .875rem; color: var(--text-muted); margin: var(--space-1) 0 0; }
@media (min-width: 1024px) { .page-header h1 { font-size: 1.625rem; } }

/* Bottom Nav — mobile only */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: stretch;
  z-index: var(--z-bottomnav);
}
@media (min-width: 1024px) { .bottom-nav { display: none; } }
.bn-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; text-decoration: none;
  color: var(--text-muted); font-size: .6875rem; font-weight: 600;
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.bn-item.active { color: var(--primary); }
.bn-item .bn-icon {
  width: 32px; height: 28px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; transition: background var(--transition);
}
.bn-item.active .bn-icon { background: var(--primary-light); }

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-p  { padding: var(--space-5); }
.card-ph { padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
@media (min-width: 1024px) {
  .card-p  { padding: var(--space-6); }
  .card-ph { padding: var(--space-4) var(--space-6); }
}

/* Stat Cards */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
@media (min-width: 768px)  { .stat-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-4); } }
@media (min-width: 1100px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
  min-width: 0;
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-card .sc-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.stat-card .sc-label {
  font-size: .8125rem; font-weight: 500; color: var(--text-2);
}
.stat-card .sc-val {
  font-size: 1.25rem; font-weight: 800; line-height: 1.15;
  margin-bottom: var(--space-1); letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stat-card .sc-sub { font-size: .75rem; color: var(--text-muted); }
.stat-card .sc-icon {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: .9375rem; flex-shrink: 0;
  background: var(--primary-light); color: var(--primary);
}
@media (min-width: 1024px) {
  .stat-card { padding: var(--space-5); }
  .stat-card .sc-val { font-size: 1.5rem; }
}
/* Card de destaque (gradiente sutil, uso institucional) */
.stat-card.stat-highlight {
  background: linear-gradient(135deg, #2F5BE0 0%, #3563E9 55%, #4A86F0 100%);
  border-color: transparent; color: #FFFFFF;
}
.stat-card.stat-highlight .sc-label,
.stat-card.stat-highlight .sc-sub { color: rgba(255,255,255,.8); }
.stat-card.stat-highlight .sc-val { color: #FFFFFF !important; }
.stat-card.stat-highlight .sc-icon { background: rgba(255,255,255,.16); color: #FFFFFF; }

/* Variação (↑ 12% vs. mês anterior) */
.stat-var { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-var.up   { color: var(--success); }
.stat-var.down { color: var(--danger); }
.stat-var.flat { color: var(--text-muted); }

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2); padding: 10px var(--space-4);
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: .875rem; font-weight: 600; font-family: inherit; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px var(--space-3); font-size: .8125rem; }
.btn-lg { padding: 12px var(--space-6); font-size: .9375rem; }
.btn-icon { padding: 8px; }

.btn-primary { background: var(--primary); color: #FFFFFF; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-success { background: var(--success); color: #FFFFFF; }
.btn-success:hover { background: #0F9A55; }

.btn-danger  { background: var(--danger); color: #FFFFFF; }
.btn-danger:hover  { background: #D92D20; }

/* Secundário: fundo branco, borda cinza, texto marinho */
.btn-ghost, .btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover, .btn-secondary:hover { background: var(--surface-2); border-color: var(--border-strong); }

.btn-soft-primary { background: var(--primary-light); color: var(--primary); border-color: var(--primary-border); }
.btn-soft-primary:hover { background: var(--primary-border); }

/* ─── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: var(--space-4); }
.form-label {
  display: block; font-size: .8125rem; font-weight: 600;
  color: var(--text-2); margin-bottom: 6px;
}
.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: 6px; }
.form-input, .form-select, .form-textarea {
  display: block; width: 100%;
  padding: 10px var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: .9375rem; font-family: inherit; color: var(--text);
  background: var(--surface);
  outline: none; transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none; -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}
.form-input:disabled { background: var(--surface-2); color: var(--text-muted); }
.form-input.is-error { border-color: var(--danger); }
.form-input::placeholder { color: #98A2B3; }
.form-textarea { resize: vertical; min-height: 80px; }
.input-group { position: relative; }
.input-icon {
  position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .875rem; pointer-events: none;
}
.input-icon + .form-input { padding-left: 2.5rem; }
.input-prefix {
  position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .875rem; pointer-events: none; font-weight: 500;
}
.input-prefix + .form-input { padding-left: 2.375rem; }

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem; border-radius: 99px;
  font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.badge-income  { background: var(--success-light); color: var(--success); }
.badge-expense { background: var(--danger-light);  color: var(--danger); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-warning { background: var(--warning-light); color: var(--warning); }

/* ─── Progress Bar ───────────────────────────────────────── */
.progress-wrap { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: 99px; background: var(--primary);
  transition: width .6s ease;
}
.progress-fill.success { background: var(--success); }
.progress-wrap.lg { height: 8px; }

/* ─── Transaction Items ──────────────────────────────────── */
.tx-list { display: flex; flex-direction: column; gap: .5rem; }
.tx-item {
  display: flex; align-items: center; gap: .875rem;
  padding: .875rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none; color: inherit;
  transition: box-shadow .15s;
}
.tx-item:hover { box-shadow: var(--shadow); }
.tx-icon {
  width: 40px; height: 40px; border-radius: .75rem;
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem; flex-shrink: 0;
}
.tx-info { flex: 1; min-width: 0; }
.tx-desc { font-size: .9rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: .75rem; color: var(--text-muted); margin-top: 1px; }
.tx-amount { font-size: .95rem; font-weight: 700; white-space: nowrap; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.tx-amount.neutral { color: var(--primary); }
.tx-amount.income  { color: var(--success); }
.tx-amount.expense { color: var(--danger); }

/* ─── Goal Cards ─────────────────────────────────────────── */
.goal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.125rem;
  box-shadow: var(--shadow-sm);
}
.goal-title { font-size: .95rem; font-weight: 700; color: var(--text); margin-bottom: .25rem; }
.goal-meta  { font-size: .78rem; color: var(--text-muted); margin-bottom: .75rem; }
.goal-amounts { display: flex; justify-content: space-between; font-size: .8rem; margin-top: .4rem; }
.goal-amounts .saved  { color: var(--primary); font-weight: 600; }
.goal-amounts .target { color: var(--text-muted); }

/* ─── Summary Row ────────────────────────────────────────── */
.summary-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-2); margin-bottom: var(--space-4);
}
.summary-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-sm);
}
.summary-item .s-label { font-size: .75rem; font-weight: 500; color: var(--text-muted); margin-bottom: var(--space-1); }
.summary-item .s-val   { font-size: 1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.summary-item .s-head  { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.summary-item .s-edit  {
  width: 26px; height: 26px; border-radius: 8px; border: none; background: transparent;
  color: var(--text-muted); cursor: pointer; font-size: .75rem; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.summary-item .s-edit:hover, .summary-item .s-edit:focus-visible { background: var(--primary-light); color: var(--primary); outline: none; }
@media (min-width: 640px) {
  .summary-item .s-val { font-size: 1.1rem; }
}

/* ─── Section Header ─────────────────────────────────────── */
.section-hd {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.section-hd h2 {
  font-size: .95rem; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: .5rem;
}
.section-hd h2 .hd-icon { color: var(--primary); font-size: .9rem; }

/* ─── Modal ──────────────────────────────────────────────── */
.modal-bg {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(11,18,32,.5);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
@media (min-width: 640px) {
  .modal-bg { align-items: center; padding: 1.5rem; }
}
.modal-box {
  background: var(--surface); width: 100%; max-width: 480px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 1.5rem; max-height: 92vh; overflow-y: auto;
  animation: slideUp .22s ease;
}
@media (min-width: 640px) {
  .modal-box { border-radius: var(--radius-lg); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.modal-hd {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-hd h2 { font-size: 1.05rem; font-weight: 800; color: var(--text); }
.modal-close {
  width: 32px; height: 32px; border-radius: .5rem; border: none;
  background: var(--surface-2); color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; transition: background .15s;
}
.modal-close:hover { background: var(--border); }

/* Tipo toggle (receita/despesa) */
.tipo-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: 1rem; }
.tipo-btn {
  padding: .75rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: .875rem; font-weight: 600; color: var(--text-muted);
  cursor: pointer; text-align: center; transition: all .15s;
}
.tipo-btn.active-expense { border-color: var(--danger); background: var(--danger-light); color: var(--danger); }
.tipo-btn.active-income  { border-color: var(--success); background: var(--success-light); color: var(--success); }

/* ─── Filter Chips (legacy, kept for relatorios) ──────────── */
.chip-row {
  display: flex; gap: .375rem; overflow-x: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  padding-bottom: 2px; margin-bottom: .875rem;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  padding: .35rem .875rem; border-radius: 99px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: .8rem; font-weight: 600; color: var(--text-2);
  white-space: nowrap; cursor: pointer; transition: all .15s;
  text-decoration: none; flex-shrink: 0;
}
.chip:hover  { border-color: var(--primary-border); color: var(--primary); }
.chip.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

/* ─── Segmented Control ───────────────────────────────────── */
.seg-ctrl {
  display: inline-flex; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); overflow: hidden; flex-shrink: 0;
}
.seg-btn {
  padding: .5rem .95rem; font-size: .82rem; font-weight: 600;
  color: var(--text-2); text-decoration: none; white-space: nowrap;
  background: var(--surface-2); cursor: pointer;
  border-right: 1.5px solid var(--border);
  transition: background .15s, color .15s; display: flex; align-items: center; gap: .35rem;
}
.seg-btn:last-child { border-right: none; }
.seg-btn:hover { background: var(--border); color: var(--text); }
.seg-btn.active { background: var(--primary); color: #fff; border-color: var(--primary-hover); }

/* ─── Month Grid ──────────────────────────────────────────── */
.month-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: .375rem;
}
.month-btn {
  padding: .4rem .25rem; text-align: center;
  font-size: .78rem; font-weight: 600; color: var(--text-2);
  text-decoration: none; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1.5px solid transparent;
  transition: all .15s;
}
.month-btn:hover { background: var(--border); color: var(--text); }
.month-btn.active { background: var(--primary); color: #fff; border-color: var(--primary-hover); }

/* ─── Filter Box ──────────────────────────────────────────── */
.filter-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .875rem;
  display: flex; flex-direction: column; gap: .75rem;
  margin-bottom: .875rem;
}

/* ─── Meta Grid ───────────────────────────────────────────── */
.metas-grid {
  display: grid; grid-template-columns: 1fr; gap: .875rem;
}
@media (min-width: 640px) { .metas-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1280px) { .metas-grid { grid-template-columns: repeat(3, 1fr); } }

/* ─── Meta Card ───────────────────────────────────────────── */
.meta-card { overflow: hidden; display: flex; flex-direction: column; }
.meta-band { height: 5px; background: var(--surface-2); flex-shrink: 0; }
.meta-band-fill { height: 100%; border-radius: 0; transition: width .9s cubic-bezier(.4,0,.2,1); }

.meta-pct-ring {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  border: 3px solid var(--border); position: relative;
}
.meta-pct-val { font-size: .95rem; font-weight: 800; line-height: 1; }
.meta-pct-lbl { font-size: .5rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-top: 1px; }

/* ─── Meta Contributions ─────────────────────────────────── */
.meta-contrib-details { margin-top: .625rem; }
.meta-contrib-details[open] .meta-chevron { transform: rotate(90deg); }
.meta-chevron { transition: transform .2s ease; display: inline-block; font-size: .6rem; opacity: .6; }
.meta-contrib-summary {
  display: flex; align-items: center; gap: .5rem;
  font-size: .75rem; font-weight: 600; color: var(--text-muted);
  cursor: pointer; list-style: none; padding: .5rem 0 .4rem;
  border-top: 1px solid var(--border); user-select: none;
}
.meta-contrib-summary::-webkit-details-marker { display: none; }
.meta-contrib-summary:hover { color: var(--text-2); }
.meta-contrib-grid {
  display: grid; grid-template-columns: repeat(6, 1fr);
  gap: .35rem; padding: .4rem 0 .25rem;
}
.meta-contrib-cell { display: flex; flex-direction: column; align-items: center; gap: .2rem; }
.meta-contrib-label {
  font-size: .6rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.meta-contrib-input {
  width: 100%; text-align: right; font-size: .75rem;
  padding: .28rem .35rem; border: 1.5px solid var(--border);
  border-radius: 6px; outline: none; font-family: inherit;
  color: var(--text); background: var(--surface-2); transition: border-color .15s;
}
.meta-contrib-input:focus { border-color: var(--primary); background: var(--surface); }
[data-theme="dark"] .meta-contrib-input { background: var(--surface-2); border-color: var(--border-strong); }
[data-theme="dark"] .meta-contrib-input:focus { background: var(--surface); border-color: var(--primary); }

/* ─── Meta Annual Summary Row ─────────────────────────────── */
.meta-year-summary {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem;
  margin-top: .875rem;
}
@media (min-width: 640px) { .meta-year-summary { grid-template-columns: repeat(12, 1fr); } }
.meta-year-col { text-align: center; }
.meta-year-col-label { font-size: .6rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .25rem; }
.meta-year-col-val { font-size: .75rem; font-weight: 600; color: var(--text-2); }

/* ─── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1.5rem;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: .875rem; opacity: .6; }
.empty-state h3 { font-size: 1rem; font-weight: 700; color: var(--text-2); margin-bottom: .375rem; }
.empty-state p  { font-size: .875rem; }

/* ─── Table (desktop) ─────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table thead tr { border-bottom: 1px solid var(--border); }
.data-table th { padding: var(--space-3) var(--space-4); text-align: left; font-size: .75rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.data-table td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); color: var(--text); vertical-align: middle; font-variant-numeric: tabular-nums; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table tfoot tr { border-top: 2px solid var(--border); background: var(--surface-2); }
.data-table tfoot td { padding: .875rem 1rem; font-weight: 700; }

/* ─── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ─── Utilities ───────────────────────────────────────────── */
.text-income  { color: var(--success) !important; }
.text-expense { color: var(--danger) !important; }
.text-primary { color: var(--primary) !important; }
.text-muted   { color: var(--text-muted) !important; }
.fw-800 { font-weight: 800; }
.gap-row { display: flex; flex-direction: column; gap: .75rem; }
@media (min-width: 768px) { .gap-row { flex-direction: row; } }

/* ─── Auth pages ──────────────────────────────────────────── */
.auth-bg {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(53,99,233,.35), transparent 60%),
    radial-gradient(700px 400px at -10% 110%, rgba(124,92,252,.22), transparent 60%),
    var(--brand-navy);
  padding: var(--space-6) var(--space-4);
}
.auth-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 2rem; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.auth-logo  { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: var(--space-6); }
.auth-title { font-size: 1.25rem; font-weight: 800; color: var(--text); margin: var(--space-5) 0 var(--space-1); }
.auth-sub   { font-size: .875rem; color: var(--text-muted); margin: 0; }
.auth-tagline { color: rgba(255,255,255,.7); font-size: .875rem; text-align: center; margin-top: var(--space-6); }

/* ─── Alert ───────────────────────────────────────────────── */
.alert {
  padding: .875rem 1rem; border-radius: var(--radius-sm);
  font-size: .875rem; margin-bottom: 1rem;
  display: flex; align-items: flex-start; gap: .5rem;
}
.alert-error { background: var(--danger-light); color: #B42318; border: 1px solid #FECDCA; }
.alert-success { background: var(--success-light); color: #067647; border: 1px solid #ABEFC6; }

/* ─── Chart Wrapper ───────────────────────────────────────── */
.chart-wrap { position: relative; width: 100%; }

/* ─── FAB ─────────────────────────────────────────────────── */
.fab {
  position: fixed; bottom: calc(var(--bottomnav-h) + .875rem); right: 1rem;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.35rem; cursor: pointer; z-index: var(--z-fab);
  box-shadow: 0 6px 16px rgba(53,99,233,.35);
  transition: transform .15s, box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.fab:hover { background: var(--primary-hover); box-shadow: 0 8px 20px rgba(53,99,233,.45); }
@media (min-width: 1024px) {
  .fab { bottom: 1.5rem; right: 2rem; }
}

/* ─── Responsive table scroll ────────────────────────────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ─── Dark Mode ──────────────────────────────────────────── */
/* Mesma família da marca (marinho), definida apenas por tokens */
[data-theme="dark"] {
  --bg:             #0B1220;
  --surface:        #111A2E;
  --surface-2:      #18233B;
  --border:         #22304D;
  --border-strong:  #2E3E60;
  --text:           #F2F5FA;
  --text-2:         #B4BFD3;
  --text-muted:     #8390A8;

  --primary:        #4F7BF0;
  --primary-hover:  #6B91F4;
  --primary-light:  #172A55;
  --primary-border: #24407E;

  --success:        #32D583;
  --success-light:  #0B2A1C;
  --danger:         #F97066;
  --danger-light:   #33140F;
  --warning:        #FDB022;
  --warning-light:  #33230A;

  --sidebar-bg:     #070C17;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow:    0 6px 18px rgba(0,0,0,.35);
  --shadow-lg: 0 18px 48px rgba(0,0,0,.5);
  --focus-ring: 0 0 0 3px rgba(79,123,240,.3);
}
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea { background: var(--surface-2); }
[data-theme="dark"] .alert-error   { color: var(--danger); border-color: #5C2219; }
[data-theme="dark"] .alert-success { color: var(--success); border-color: #14532D; }
[data-theme="dark"] .data-table tbody tr:hover td { background: var(--surface-2); }
[data-theme="dark"] .chip { background: var(--surface-2); border-color: var(--border-strong); }
[data-theme="dark"] .chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
[data-theme="dark"] #recorrente-opts { background: var(--surface-2); border-color: var(--border-strong); }
[data-theme="dark"] .topbar { background: rgba(11,18,32,.88); }
[data-theme="dark"] .tx-check { border-color: #4A5878; }
[data-theme="dark"] .tx-check:hover { border-color: var(--success); }
[data-theme="dark"] .brand-claro .brand-first { color: #FFFFFF; }
[data-theme="dark"] .brand-claro .brand-second { color: #6F96FF; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--border-strong); }

/* smooth theme transition — only after page renders (prevents flash) */
.theme-ready *, .theme-ready *::before, .theme-ready *::after {
  transition: background-color .22s ease, border-color .22s ease, color .15s ease, box-shadow .22s ease;
}

/* ─── Theme Toggle Button ─────────────────────────────────── */
.theme-toggle {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer; font-size: .9rem;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--border); color: var(--text); }

/* ─── Recurring badge ────────────────────────────────────── */
.badge-recorrente {
  display: inline-flex; align-items: center; gap: .2rem;
  font-size: .68rem; font-weight: 600; padding: .1rem .4rem;
  border-radius: 99px; background: var(--primary-light);
  color: var(--primary); border: 1px solid var(--primary-border);
}

/* ─── Pagamento parcial ──────────────────────────────────── */
.badge-parcial {
  display: inline-flex; align-items: center; gap: .2rem;
  font-size: .68rem; font-weight: 600; padding: .1rem .4rem;
  border-radius: 99px; background: var(--warning-light); color: var(--warning);
}
.tx-parcial { display: flex; align-items: center; gap: var(--space-2); margin-top: 6px; font-size: .72rem; color: var(--text-muted); }
.tx-parcial .progress-wrap { width: 72px; flex-shrink: 0; height: 5px; }
.tx-parcial strong { color: var(--text-2); font-weight: 700; }
.tx-check.partial { border-color: var(--warning); color: var(--warning); opacity: .7; }
