/* =========================================================
   MEU DINHEIRO — tema clean, claro e moderno
   Paleta: fundo branco, cinzas suaves, verde e vermelho
   ========================================================= */

:root {
  --bg:          #F5F7FA;
  --surface:     #FFFFFF;
  --surface-2:   #F0F2F5;
  --border:      #E4E7ED;
  --text:        #1A1D23;
  --text-dim:    #717788;
  --income:      #16A34A;
  --expense:     #DC2626;
  --accent:      #2563EB;
  --accent-dim:  rgba(37,99,235,0.08);
  --accent-glow: rgba(37,99,235,0.18);
  --warn:        #D97706;
  --radius:      16px;
  --radius-sm:   10px;
  --shadow-sm:   0 1px 4px rgba(0,0,0,0.07);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.09);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .num {
  font-family: 'Sora', 'Inter', system-ui, sans-serif;
}

button { font-family: inherit; }

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 84px;
  position: relative;
}

.hidden { display: none !important; }

/* ---------- TELA DE LOGIN ---------- */
#authScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
}
.auth-card { width: 100%; }
.auth-logo {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.auth-logo span { color: var(--accent); }
.auth-logo-icon { font-size: 26px; line-height: 1; }
.auth-sub { color: var(--text-dim); margin-bottom: 28px; font-size: 14px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

#txSearchInput {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#txSearchInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-primary:hover { background: #1D4ED8; }
.btn-primary:active { opacity: 0.88; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost { background: transparent; color: var(--accent); }
.btn-danger { background: rgba(220,38,38,0.08); color: var(--expense); border: 1px solid rgba(220,38,38,0.15); }
.btn-sm { padding: 7px 12px; font-size: 13px; width: auto; }

.error-msg {
  background: rgba(220,38,38,0.07);
  color: var(--expense);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid rgba(220,38,38,0.15);
}
.switch-auth {
  text-align: center;
  margin-top: 18px;
  font-size: 14px;
  color: var(--text-dim);
}
.switch-auth a { color: var(--accent); cursor: pointer; text-decoration: none; font-weight: 600; }

/* ---------- HEADER ---------- */
.app-header {
  padding: 18px 20px 14px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 5;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.app-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.greeting { font-size: 13px; color: var(--text-dim); }
.greeting strong { color: var(--text); }

.user-avatar-btn {
  background: var(--accent);
  border: none;
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 2px 8px var(--accent-glow);
  transition: box-shadow 0.2s, transform 0.1s;
  overflow: hidden;
  padding: 0;
}
.user-avatar-btn:active { transform: scale(0.95); }

.icon-btn {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  color: var(--text-dim);
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* Saldo */
.balance-hero { margin-bottom: 14px; }
.balance-label { font-size: 13px; color: var(--text-dim); margin-bottom: 4px; font-weight: 500; }
.balance-value {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.flow-compare {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.flow-bar {
  flex: 1;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.flow-bar .flow-label { font-size: 12px; color: var(--text-dim); display:flex; align-items:center; gap:6px; font-weight: 500; }
.flow-bar .flow-value { font-size: 17px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.flow-bar.income .flow-value { color: var(--income); }
.flow-bar.expense .flow-value { color: var(--expense); }
.dot { width: 8px; height: 8px; border-radius: 50%; display:inline-block; }
.dot.income { background: var(--income); }
.dot.expense { background: var(--expense); }
.dot.gold { background: var(--accent); }

/* ---------- CONTEÚDO ---------- */
.view { padding: 0 20px 20px; }
.section-title {
  font-size: 14px;
  font-weight: 700;
  margin: 22px 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-dim);
}
.section-title .link { font-size: 13px; color: var(--accent); cursor: pointer; font-weight: 600; text-transform: none; letter-spacing: 0; }

.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 10px; }

.card-accent {
  border-color: rgba(37,99,235,0.2);
  background: linear-gradient(135deg, var(--surface) 0%, rgba(37,99,235,0.03) 100%);
}

/* contas (scroll horizontal) */
.accounts-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin: 0 -20px;
  padding-left: 20px;
  padding-right: 20px;
  scrollbar-width: none;
}
.accounts-scroll::-webkit-scrollbar { display: none; }
.account-pill {
  position: relative;
  flex: 0 0 auto;
  min-width: 145px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.acc-drag-handle {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  opacity: 0.5;
  cursor: grab;
  touch-action: none;
}
.acc-drag-handle:hover { opacity: 0.9; }
.acc-drag-handle:active { cursor: grabbing; opacity: 1; }
.account-pill:hover { border-color: var(--accent); box-shadow: 0 2px 10px var(--accent-glow); }
.account-pill .acc-name { font-size: 12px; color: var(--text-dim); display:flex; align-items:center; gap:6px; margin-bottom: 6px; font-weight: 500; }
.account-pill .acc-balance { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.account-pill.add-account {
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-weight: 600; cursor: pointer;
  border-style: dashed;
  border-color: rgba(37,99,235,0.3);
  background: rgba(37,99,235,0.03);
}

/* categorias */
.cat-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0;
}
.cat-row + .cat-row { border-top: 1px solid var(--border); }
.cat-row .cat-color { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.cat-row .cat-name { flex: 1; font-size: 14px; color: var(--text); }
.cat-row .cat-amount { font-size: 14px; font-weight: 600; color: var(--expense); font-variant-numeric: tabular-nums; }

.cat-bar-track {
  flex: 1;
  background: var(--surface-2);
  border-radius: 4px;
  height: 5px;
  overflow: hidden;
}
.cat-bar-fill { height: 100%; border-radius: 4px; }

/* ---------- Evolução mensal (dashboard) ---------- */
.trend-legend {
  display: flex; gap: 16px; font-size: 12px; color: var(--text-dim);
  margin-bottom: 10px;
}
.trend-legend span { display: flex; align-items: center; gap: 6px; }
.trend-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
}
.trend-row + .trend-row { border-top: 1px solid var(--border); }
.trend-month { width: 34px; font-size: 12px; text-transform: capitalize; color: var(--text-dim); flex: 0 0 auto; }
.trend-bars { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.trend-values { font-size: 11px; color: var(--text-dim); flex: 0 0 auto; white-space: nowrap; }

/* lançamentos */
.tx-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.tx-item:last-child { border-bottom: none; }
.tx-icon {
  width: 38px; height: 38px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto; font-size: 16px;
}
.tx-info { flex: 1; min-width: 0; }
.tx-desc { font-size: 14.5px; font-weight: 600; color: var(--text); }
.tx-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.tx-attach-icon { font-size: 12px; opacity: 0.7; }
.tx-amount { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-amount.entrada { color: var(--income); }
.tx-amount.saida { color: var(--expense); }

.empty-state {
  text-align: center;
  padding: 36px 12px;
  color: var(--text-dim);
  font-size: 14px;
}
.empty-state-icon { font-size: 32px; margin-bottom: 8px; }

/* recorrentes */
.rec-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.rec-item:last-child { border-bottom: none; }
.rec-top { display: flex; justify-content: space-between; align-items: center; }
.rec-desc { font-weight: 600; font-size: 14.5px; color: var(--text); }
.rec-amount { font-weight: 700; font-size: 14.5px; }
.rec-progress-track {
  background: var(--surface-2);
  border-radius: 6px;
  height: 6px;
  margin-top: 10px;
  overflow: hidden;
}
.rec-progress-fill { height: 100%; background: var(--accent); }
.rec-sub { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-weight: 600;
}
.badge.paused { color: var(--warn); background: rgba(217,119,6,0.1); }
.badge.gold { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(37,99,235,0.15); }

/* metas */
.goal-card { margin-top: 0; }
.cofrinho-card { border: 1px solid rgba(52,211,153,0.35); background: linear-gradient(135deg, rgba(52,211,153,0.06), transparent); }
.goal-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.goal-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex: 0 0 auto;
}
.goal-name { font-weight: 700; font-size: 15px; color: var(--text); }
.goal-type { font-size: 12px; color: var(--text-dim); }
.goal-amounts { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-dim); margin-top: 8px; }
.goal-amounts strong { color: var(--text); }
.goal-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- Navegação de mês (lançamentos) ---------- */
.month-nav {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 8px 6px; margin-top: 12px;
}
.month-nav button {
  width: 36px; height: 36px; border: none; background: var(--surface);
  color: var(--text); font-size: 18px; border-radius: 8px; cursor: pointer;
}
.month-nav span { font-weight: 700; text-transform: capitalize; }

/* segmented */
.segmented {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}
.segmented button {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 9px 0;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}
.segmented button.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* ---------- BOTTOM NAV ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  border-top: 1.5px solid var(--border);
  display: flex;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 10;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--text-dim);
  font-size: 11px; cursor: pointer; padding: 6px 0;
  transition: color 0.15s;
  font-weight: 500;
}
.nav-item.active { color: var(--accent); }
.nav-item svg { width: 21px; height: 21px; }

.fab {
  position: fixed;
  bottom: 78px;
  right: calc(50% - 240px + 20px);
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px var(--accent-glow);
  cursor: pointer;
  z-index: 9;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab:hover { background: #1D4ED8; }
.fab:active { transform: scale(0.93); }
@media (max-width: 520px) {
  .fab { right: 20px; }
}

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: flex-end;
  z-index: 600;
  backdrop-filter: blur(2px);
}
.modal-sheet {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px;
  border-top: 1.5px solid var(--border);
  box-shadow: 0 -8px 32px rgba(0,0,0,0.12);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px;
}
.modal-header h3 { margin: 0; font-size: 17px; color: var(--text); }
.modal-close {
  background: var(--surface-2);
  border: none; color: var(--text-dim);
  width: 30px; height: 30px; border-radius: 50%;
  cursor: pointer; font-size: 16px;
}

/* Variante em tela cheia (ex: Lista de desejos) */
.modal-overlay.modal-fullscreen {
  align-items: stretch;
  justify-content: stretch;
  backdrop-filter: none;
}
.modal-overlay.modal-fullscreen .modal-sheet {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  border-radius: 0;
  border-top: none;
  box-shadow: none;
  margin: 0;
}

/* ---------- PERFIL ---------- */
.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.profile-avatar-large {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700;
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
  flex: 0 0 auto;
  overflow: hidden;
}
.profile-avatar-large img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block;
}
.profile-info-name { font-size: 20px; font-weight: 700; font-family: 'Sora', sans-serif; }
.profile-info-email { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.profile-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(37,99,235,0.2);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  margin-top: 6px;
}

.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.profile-stat-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}
.profile-stat-label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; font-weight: 500; }
.profile-stat-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.profile-stat-value.gold { color: var(--accent); }
.profile-stat-value.green { color: var(--income); }
.profile-stat-value.red { color: var(--expense); }

.profile-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 20px 0 10px;
}

.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: opacity 0.15s;
}
.profile-menu-item:last-child { border-bottom: none; }
.profile-menu-item:active { opacity: 0.7; }
.profile-menu-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex: 0 0 auto;
}
.profile-menu-label { flex: 1; font-size: 15px; font-weight: 500; }
.profile-menu-arrow { color: var(--text-dim); font-size: 16px; }
.profile-menu-value { font-size: 13px; color: var(--text-dim); }

/* ---------- SPLIT ROW ---------- */
.split-row {
  display: flex; gap: 8px; align-items: center; margin-bottom: 8px;
}
.split-row select { flex: 1.3; }
.split-row input { flex: 1; }
.split-row .remove-split { color: var(--expense); background: none; border: none; font-size: 18px; cursor: pointer; padding: 0 4px; }
.add-split-btn { font-size: 13px; color: var(--accent); background: none; border: none; cursor: pointer; padding: 6px 0; font-weight: 600; }

.chip-list { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.chip {
  padding: 7px 12px;
  border-radius: 20px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  color: var(--text);
}
.chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.chip .chip-del { color: var(--text-dim); font-size: 12px; }
.chip.emoji-chip { padding: 6px 10px; font-size: 17px; }

.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 10px 18px; border-radius: 30px;
  font-size: 13.5px; z-index: 100;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
}

.row-between { display: flex; justify-content: space-between; align-items: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-dim { color: var(--text-dim); font-size: 13px; }

.divider-text {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0;
  color: var(--text-dim); font-size: 12px;
}
.divider-text::before, .divider-text::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.health-ring {
  width: 60px; height: 60px;
  border-radius: 50%;
  border: 3px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
  position: relative;
  flex: 0 0 auto;
}
.health-ring.good { border-color: var(--income); color: var(--income); }
.health-ring.warn { border-color: var(--warn); color: var(--warn); }
.health-ring.bad { border-color: var(--expense); color: var(--expense); }
.health-ring.muted { border-color: var(--border); color: var(--text-dim); font-size: 12px; }

.health-breakdown { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.health-breakdown-row-wrap { display: flex; flex-direction: column; gap: 2px; }
.health-breakdown-row { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; gap: 8px; }
.health-breakdown-label { color: var(--text-dim); }
.health-breakdown-value { font-weight: 600; white-space: nowrap; }
.health-breakdown-value.good { color: var(--income); }
.health-breakdown-value.warn { color: var(--warn); }
.health-breakdown-value.bad { color: var(--expense); }
.health-breakdown-helper { font-size: 11.5px; color: var(--text-dim); line-height: 1.4; }

.health-recommendations { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.health-recommendations-title { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.health-recommendation-item { font-size: 12.5px; color: var(--text-dim); line-height: 1.45; margin-bottom: 5px; }
.health-recommendation-item:last-child { margin-bottom: 0; }

.insight-card {
  background: var(--accent-dim);
  border: 1px solid rgba(37,99,235,0.15);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.insight-icon { font-size: 20px; flex: 0 0 auto; margin-top: 2px; }
.insight-text { font-size: 13px; color: var(--text-dim); line-height: 1.5; }
.insight-text strong { color: var(--text); }

/* --- Ingrid (assistente financeira) --- */
/* Botão compacto no dashboard, que abre o chat da Ingrid no modal */
.ingrid-trigger {
  display: flex; align-items: center; gap: 10px;
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  cursor: pointer; text-align: left; font: inherit;
}
.ingrid-trigger:hover, .ingrid-trigger:focus-visible { border-color: var(--accent); outline: none; }
.ingrid-trigger-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-dim); display: flex; align-items: center;
  justify-content: center; font-size: 18px; flex: 0 0 auto;
}
.ingrid-trigger-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.ingrid-trigger-title { font-weight: 600; font-size: 14px; color: var(--text); }
.ingrid-trigger-sub { font-size: 12px; color: var(--text-dim); }
.ingrid-trigger-arrow { color: var(--text-dim); font-size: 20px; flex: 0 0 auto; }

/* Conteúdo do chat, renderizado dentro do modal ao clicar no botão acima */
.ingrid-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-dim); display: flex; align-items: center;
  justify-content: center; font-size: 18px; flex: 0 0 auto;
}
.ingrid-insights { display: flex; flex-direction: column; gap: 8px; }
.ingrid-insight-item {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 13px; color: var(--text); line-height: 1.45;
}
.ingrid-insight-icon { flex: 0 0 auto; font-size: 15px; }
.ingrid-chat {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 220px; overflow-y: auto;
}
.ingrid-msg {
  max-width: 85%; padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.45; word-wrap: break-word;
}
.ingrid-msg-user {
  align-self: flex-end; background: var(--accent); color: #fff;
}
.ingrid-msg-bot {
  align-self: flex-start; background: var(--surface-2); color: var(--text);
}
.ingrid-ask-form { display: flex; gap: 8px; }
.ingrid-ask-form input {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13px; background: var(--surface); color: var(--text);
}
.ingrid-ask-form input:focus { outline: none; border-color: var(--accent); }

/* Bolha temporária exibida enquanto a IA processa a pergunta */
.ingrid-msg-thinking { font-style: italic; opacity: 0.7; animation: ingridPulse 1.2s ease-in-out infinite; }
@keyframes ingridPulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.85; }
}

/* =========================================================
   NOVOS ESTILOS — v2
   ========================================================= */

/* --- Conta com saldo reservado para meta --- */
.account-pill .acc-reserved {
  font-size: 11px;
  color: var(--accent);
  margin-top: 4px;
  font-weight: 500;
}
.account-pill .acc-real {
  font-size: 11px;
  color: var(--income);
  font-weight: 600;
}
.account-pill .acc-excluded {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  opacity: 0.75;
}
.account-pill.dragging {
  cursor: grabbing;
  box-shadow: 0 10px 26px rgba(0,0,0,0.28);
  opacity: 0.92;
  transition: none;
}

/* --- Proteção do mês atual: velas entrada/saída --- */
.candle-chart {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 48px;
  padding: 10px 0 4px;
}
.candle-group { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.candle-track { display: flex; align-items: flex-end; width: 46px; }
.candle-body { width: 100%; display: flex; flex-direction: column-reverse; border-radius: 6px; overflow: hidden; }
.candle-segment { width: 100%; }
.candle-segment.candle-real { opacity: 1; }
.candle-segment.candle-prev { opacity: 0.35; }
.candle-value { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.candle-label { font-size: 12px; color: var(--text-dim); }
.candle-legend { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.legend-dot-solid { background: var(--text-dim); opacity: 1; }
.legend-dot-light { background: var(--text-dim); opacity: 0.35; }

/* --- Gráfico dia a dia (modal de detalhe da projeção) --- */
.day-chart {
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  padding: 8px 2px 4px;
}
.day-bar-col {
  flex: 0 0 auto;
  width: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.day-bar-up { width: 8px; background: var(--income); border-radius: 3px 3px 0 0; align-self: flex-end; margin-bottom: 1px; }
.day-bar-down { width: 8px; background: var(--expense); border-radius: 0 0 3px 3px; align-self: flex-end; margin-top: 1px; }
.day-bar-tick { font-size: 8px; color: var(--text-dim); margin: 2px 0; }
.day-bar-future .day-bar-up, .day-bar-future .day-bar-down { opacity: 0.4; }


.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 20px;
  height: 120px;
  padding: 12px 0 0;
}
.bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}
.bar-track {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  background: var(--surface-2);
  border-radius: 8px 8px 0 0;
  overflow: hidden;
}
.bar-fill {
  width: 100%;
  border-radius: 8px 8px 0 0;
  transition: height 0.4s ease;
}
.bar-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  margin-top: 4px;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.bar-name {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}

/* --- Goal account badge --- */
.goal-account-badges {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.goal-account-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--surface-2);
  border-radius: 8px;
}

/* --- Calendário --- */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cal-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.cal-nav {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  width: 34px; height: 34px;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-dow {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  padding: 4px 0;
}
.cal-day {
  border-radius: 10px;
  padding: 6px 2px;
  min-height: 46px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
  background: var(--surface);
  border: 1.5px solid var(--border);
}
.cal-day:hover { border-color: var(--accent); background: var(--accent-dim); }
.cal-day.empty { background: transparent; border: none; cursor: default; }
.cal-day.past {
  cursor: not-allowed;
  opacity: 0.45;
  background: var(--surface);
}
.cal-day.past:hover { border-color: var(--border); background: var(--surface); }
.cal-day.past .cal-day-num { color: var(--text-muted, #9CA3AF); }
.cal-day.today {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.cal-day-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.cal-day.today .cal-day-num { color: var(--accent); }
.cal-dots {
  display: flex;
  gap: 3px;
  margin-top: 4px;
}
.cal-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}
.cal-dot.confirmed { background: var(--income); }
.cal-dot.pending   { background: var(--warn); }

/* --- Eventos listados --- */
.event-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.event-item:last-child { border-bottom: none; }
.event-item.confirmed { opacity: 0.7; }
.event-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.event-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.event-date {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.event-confirmed-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--income);
  background: rgba(22,163,74,0.08);
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.event-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

/* --- FAB melhorado --- */
.fab {
  position: fixed;
  bottom: 90px;
  right: calc(50% - 240px + 16px);
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 24px rgba(37,99,235,0.45);
  cursor: pointer;
  z-index: 9;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab:hover { background: #1D4ED8; box-shadow: 0 8px 28px rgba(37,99,235,0.5); }
.fab:active { transform: scale(0.92); }
@media (max-width: 520px) {
  .fab { right: 16px; bottom: 86px; }
}

/* =========================================================
   VERSÃO WEB / DESKTOP — interface de sistema (sidebar fixa,
   topo em destaque, conteúdo em grade). Mobile permanece
   intocado abaixo de 901px.
   ========================================================= */

.desktop-sidebar,
.sidebar-fab,
.header-stats-row { display: none; }

@media (min-width: 901px) {

  body { background: var(--bg); }

  /* esconde navegação e elementos mobile */
  .bottom-nav { display: none; }

  /* O botão redondo (.fab) usa um cálculo de posição pensado pra tela
     mobile de até 480px (right: calc(50% - 240px + 16px)). No desktop
     o layout tem sidebar fixa + conteúdo largo, então esse cálculo
     posiciona errado. Aqui fixamos a posição certa, no canto
     inferior direito da tela. */
  #app .fab {
    right: 32px;
    bottom: 32px;
    z-index: 30;
  }

  #app {
    max-width: none;
    margin: 0;
    padding-bottom: 0;
    display: block;
  }

  /* ---------- SIDEBAR ---------- */
  .desktop-sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 248px;
    background: var(--surface);
    border-right: 1.5px solid var(--border);
    padding: 22px 16px;
    z-index: 20;
  }
  .sidebar-logo {
    font-size: 21px;
    font-weight: 700;
    font-family: 'Sora', sans-serif;
    display: flex;
    align-items: baseline;
    gap: 7px;
    padding: 0 10px;
    margin-bottom: 28px;
  }
  .sidebar-logo span { color: var(--accent); }
  .sidebar-logo-icon { font-size: 20px; }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
  }
  .sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 14.5px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s;
  }
  .sidebar-nav-item svg { width: 19px; height: 19px; flex: 0 0 auto; }
  .sidebar-nav-item:hover { background: var(--surface-2); color: var(--text); }
  .sidebar-nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }

  .sidebar-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px var(--accent-glow);
    transition: background 0.15s, transform 0.1s;
  }
  .sidebar-fab:hover { background: #1D4ED8; }
  .sidebar-fab:active { transform: scale(0.98); }

  /* ---------- ÁREA PRINCIPAL ---------- */
  .desktop-main {
    margin-left: 248px;
    min-height: 100vh;
  }

  .app-header {
    position: sticky;
    top: 0;
    padding: 24px 36px;
    border-bottom: 1.5px solid var(--border);
  }
  .app-header-top { margin-bottom: 20px; }
  .greeting { font-size: 15px; }
  .user-avatar-btn { width: 40px; height: 40px; font-size: 15px; }

  .header-stats-row {
    display: flex;
    align-items: stretch;
    gap: 24px;
  }
  .balance-hero { flex: 0 0 auto; min-width: 220px; }
  .balance-value { font-size: 40px; }
  .flow-compare { margin-top: 0; flex: 1; max-width: 480px; }

  /* conteúdo centralizado com largura confortável de leitura,
     mas usando o espaço extra para colunas */
  .view {
    padding: 28px 36px 60px;
    max-width: 1280px;
  }

  .section-title { margin: 26px 0 14px; font-size: 13px; }

  /* ---------- DASHBOARD EM GRADE ---------- */
  #view-dashboard {
    display: grid;
    grid-template-columns: 1fr 360px;
    column-gap: 28px;
    align-content: start;
  }
  #view-dashboard > * { grid-column: 1 / -1; }

  .dash-charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    grid-column: 1 / -1;
  }
  .dash-charts-row .section-title { margin-top: 0; }

  .accounts-scroll {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    overflow-x: visible;
    margin: 0;
    padding: 0;
  }
  .account-pill { min-width: 0; }

  /* ---------- LANÇAMENTOS / RECORRENTES / METAS EM LARGURA CONTROLADA ---------- */
  #view-transactions, #view-recurring, #view-settings, #view-events {
    max-width: 920px;
  }
  .segmented { max-width: 360px; }

  #goalsList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
  }
  #goalsList .card { margin-top: 0; }

  #view-events { max-width: 1100px; }
  .cal-day { min-height: 64px; }

  /* ---------- MODAL COMO DIÁLOGO CENTRAL ---------- */
  .modal-overlay {
    align-items: center;
    justify-content: center;
  }
  .modal-sheet {
    border-radius: var(--radius);
    width: 92%;
    max-width: 540px;
    max-height: 84vh;
    box-shadow: 0 16px 48px rgba(0,0,0,0.18);
  }
  .modal-overlay.modal-fullscreen {
    align-items: stretch;
    justify-content: stretch;
  }
  .modal-overlay.modal-fullscreen .modal-sheet {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  /* ---------- TELA DE LOGIN ---------- */
  #authScreen {
    max-width: none;
    background: linear-gradient(135deg, var(--bg) 0%, var(--accent-dim) 100%);
  }
  .auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px;
    box-shadow: var(--shadow-md);
  }
}

@media (min-width: 1280px) {
  .view { padding-left: 48px; padding-right: 48px; }
  .app-header { padding-left: 48px; padding-right: 48px; }
}

/* ---------- TELA "QUEM ESTÁ USANDO" (perfis estilo Netflix) ---------- */
#profileScreen {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}
#profileScreen.hidden { display: none; }
.profile-select-wrap { width: 100%; max-width: 560px; text-align: center; }
.profile-select-title { font-size: 24px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.profile-select-sub { font-size: 14px; color: var(--text-dim); margin-bottom: 32px; }
.profile-select-grid {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; margin-bottom: 8px;
}
.profile-select-card {
  width: 104px; cursor: pointer; background: none; border: none; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.profile-select-avatar {
  width: 88px; height: 88px; border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; border: 2.5px solid transparent;
  transition: border-color .15s, transform .15s;
}
.profile-select-card:hover .profile-select-avatar,
.profile-select-card:focus .profile-select-avatar {
  border-color: var(--accent); transform: scale(1.04);
}
.profile-select-name { font-size: 14px; font-weight: 600; color: var(--text-dim); }
.profile-select-card:hover .profile-select-name { color: var(--text); }
.profile-select-add .profile-select-avatar {
  background: var(--surface); border: 2px dashed var(--border); color: var(--text-dim); font-size: 30px;
}
.profile-select-logout { margin-top: 32px; font-size: 13px; color: var(--text-dim); cursor: pointer; text-decoration: underline; }

/* Botão de trocar de perfil no cabeçalho */
.profile-switch-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--surface); display: flex; align-items: center; justify-content: center;
  font-size: 17px; cursor: pointer; margin-left: 8px;
}

/* Tag de autor num lançamento ("Ingrid lançou") */
.tx-author {
  display: inline-flex; align-items: center; gap: 3px; font-weight: 600;
}

/* Lista de perfis em Ajustes */
.profile-manage-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border);
}
.profile-manage-row:last-child { border-bottom: none; }
.profile-manage-avatar {
  width: 42px; height: 42px; border-radius: 12px; display:flex; align-items:center; justify-content:center; font-size: 20px; flex-shrink: 0;
}
.profile-manage-name { flex: 1; font-weight: 600; font-size: 14.5px; color: var(--text); }
.profile-manage-edit { color: var(--accent); font-size: 13px; font-weight: 600; cursor: pointer; }

.avatar-pick-grid { display:flex; flex-wrap:wrap; gap:8px; margin-top:6px; }
.avatar-pick-opt {
  width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--surface); font-size: 19px; cursor: pointer; display:flex; align-items:center; justify-content:center;
}
.avatar-pick-opt.selected { border-color: var(--accent); background: var(--accent-dim); }

/* Link inline simples (usado em formulários, ex: "dividir entre contas") */
.inline-link {
  display: inline-block; margin-top: 8px; font-size: 13px; color: var(--accent);
  font-weight: 600; cursor: pointer; text-decoration: underline;
}

/* ---------- FOTO DE PERFIL (upload) ---------- */
.profile-select-avatar img,
.profile-manage-avatar img,
.avatar-preview img {
  width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block;
}
#userAvatarInitial {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; border-radius: 50%; overflow: hidden;
}
.user-avatar-btn img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block;
}
.profile-select-avatar, .profile-manage-avatar { overflow: hidden; }

.avatar-preview-wrap { display: flex; justify-content: center; margin-bottom: 4px; }
.avatar-preview {
  width: 84px; height: 84px; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 700;
}

/* ---------- COMPROVANTE DO LANÇAMENTO (upload) ---------- */
.tx-attach-preview {
  display: block; max-width: 100%; max-height: 220px; border-radius: 10px;
  border: 1.5px solid var(--border); cursor: zoom-in; object-fit: cover;
}

/* ---------- LIGHTBOX (popup de imagem em tamanho maior) ---------- */
.lightbox-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 23, 42, 0.85);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; cursor: zoom-out;
}
.lightbox-img {
  max-width: 100%; max-height: 100%; border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4); cursor: default;
}
.lightbox-close {
  position: absolute; top: 16px; right: 20px;
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.15); color: #fff; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.lightbox-close:hover { background: rgba(255,255,255,0.25); }

/* ---------- RECORTE DE FOTO (cropper) ---------- */
.crop-stage {
  width: 220px; height: 220px; border-radius: 50%; overflow: hidden;
  margin: 0 auto; position: relative; background: var(--surface-2);
  cursor: grab; touch-action: none;
}
.crop-stage:active { cursor: grabbing; }
.crop-stage img {
  position: absolute; left: 50%; top: 50%; max-width: none;
  transform: translate(-50%, -50%); user-select: none; -webkit-user-drag: none;
}
.crop-controls { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.crop-controls input[type="range"] { flex: 1; }
.crop-actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }


.tx-author-pic {
  width: 16px; height: 16px; border-radius: 50%; object-fit: cover;
  vertical-align: middle; margin-right: 2px;
}