/* ===== Tema e variáveis ===== */
:root {
  /* Tema claro — versão quente e clara, com dourado */
  --bg: #f3efe7;
  --surface: #ffffff;
  --surface-2: #efeae0;
  --border: #0809091a;
  --text: #17150f;
  --text-soft: #5f5d54;
  --text-faint: #8b897f;
  --primary: #9f741f;
  --primary-strong: #c7a447;
  --on-primary: #ffffff;
  --primary-soft: rgba(159, 116, 31, .12);
  --income: #15803d;
  --income-soft: #e6f4ea;
  --expense: #dc2626;
  --expense-soft: #fdecec;
  --shadow: 0 1px 2px rgba(20, 18, 12, .05), 0 10px 26px rgba(20, 18, 12, .08);
  --radius: 16px;
  --radius-sm: 10px;
}
[data-theme="dark"] {
  /* Tema escuro — identidade do portfólio (preto + dourado, texto off-white) */
  --bg: #080909;
  --surface: #151616;
  --surface-2: #1f201f;
  --border: #f5f2ec1f;
  --text: #f5f2ec;
  --text-soft: #b9b7b0;
  --text-faint: #7f878d;
  --primary: #c7a447;
  --primary-strong: #e1b842;
  --on-primary: #0b0b0a;
  --primary-soft: rgba(199, 164, 71, .14);
  --income: #4ec48a;
  --income-soft: rgba(78, 196, 138, .13);
  --expense: #f0796f;
  --expense-soft: rgba(240, 121, 111, .13);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 14px 36px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

/* ===== Barra superior ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  position: relative;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -11px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  background-size: 200% 100%; opacity: .5;
  animation: slideLine 5s linear infinite;
}
.brand { display: flex; align-items: center; gap: 14px; }

/* Logo num anel dourado giratório + brilho pulsante + flutuação */
@property --angle { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
.brand-logo {
  --angle: 0deg;
  position: relative; width: 60px; height: 60px; flex-shrink: 0;
  padding: 2px; border-radius: 17px;
  background: conic-gradient(from var(--angle), transparent 0%, #9f741f 12%, #ffd56b 28%, #c7a447 44%, transparent 60%, transparent 100%);
  animation: logoIn .9s cubic-bezier(.2,.85,.25,1) both, spinAngle 4.5s linear infinite, glowPulse 3.2s ease-in-out infinite;
}
.brand-logo-inner {
  width: 100%; height: 100%; border-radius: 15px; overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #1a1b1a, #0a0b0a);
  display: grid; place-items: center;
}
.brand-logo-img {
  width: 76%; height: 76%; object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .6));
  animation: floatBob 4s ease-in-out infinite;
}
.brand-logo:hover { animation-play-state: paused, paused, paused; }
.brand-logo:hover .brand-logo-img { transform: scale(1.1) rotate(-4deg); transition: transform .35s cubic-bezier(.2,.85,.25,1); }

.brand-text { min-width: 0; }
.brand-title {
  font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 0;
  background: linear-gradient(100deg, var(--text) 0%, var(--text) 38%, #ffe9a8 46%, #c7a447 52%, var(--text) 60%, var(--text) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: titleIn .8s ease .15s both, shimmer 6.5s ease-in-out 1.2s infinite;
}
.tagline { margin: 2px 0 0; font-size: 13px; color: var(--text-soft); animation: fadeUp .8s ease .3s both; }

/* Ações: entrada escalonada + varredura de luz no botão principal */
.topbar-actions > * { animation: fadeUp .55s ease both; }
.topbar-actions > *:nth-child(1) { animation-delay: .34s; }
.topbar-actions > *:nth-child(2) { animation-delay: .41s; }
.topbar-actions > *:nth-child(3) { animation-delay: .48s; }
.topbar-actions > *:nth-child(4) { animation-delay: .55s; }
.topbar-actions > *:nth-child(5) { animation-delay: .62s; }
.topbar-actions > *:nth-child(6) { animation-delay: .69s; }
#addBtn { position: relative; overflow: hidden; }
#addBtn::after {
  content: ""; position: absolute; top: 0; left: -130%; width: 55%; height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, .6), transparent);
  transform: skewX(-20deg); pointer-events: none;
}
#addBtn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(199, 164, 71, .4); }
#addBtn:hover::after { animation: shine .85s ease; }

@keyframes spinAngle { to { --angle: 360deg; } }
@keyframes glowPulse { 0%, 100% { box-shadow: 0 0 14px rgba(199, 164, 71, .22); } 50% { box-shadow: 0 0 30px rgba(199, 164, 71, .55); } }
@keyframes floatBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes logoIn { from { opacity: 0; transform: scale(.35) rotate(-30deg); } 60% { transform: scale(1.08) rotate(6deg); } to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes titleIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { 0% { background-position: 150% 0; } 100% { background-position: -150% 0; } }
@keyframes shine { to { left: 140%; } }
@keyframes slideLine { 0% { background-position: 0 0; } 100% { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  .brand-logo, .brand-logo-img, .brand-title, .tagline, .topbar-actions > *, .topbar::after { animation: none !important; }
  .brand-title { -webkit-text-fill-color: var(--text); color: var(--text); }
  #addBtn::after { display: none; }
}
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ===== Botões ===== */
button { font: inherit; cursor: pointer; border: none; }
.btn-primary {
  background: var(--primary); color: var(--on-primary);
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-weight: 700; transition: background .15s, transform .05s;
}
.btn-primary:hover { background: var(--primary-strong); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost {
  background: var(--surface); color: var(--text-soft);
  padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-weight: 500;
  transition: background .15s, color .15s;
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-soft); width: 38px; height: 38px;
  border-radius: var(--radius-sm); font-size: 18px;
  display: grid; place-items: center; transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; display: block; }
.btn-ico svg { width: 17px; height: 17px; display: block; }
/* Alterna lua/sol conforme o tema */
#themeBtn .ic-sun { display: none; }
[data-theme="dark"] #themeBtn .ic-moon { display: none; }
[data-theme="dark"] #themeBtn .ic-sun { display: block; }
.link-danger {
  background: none; color: var(--expense);
  font-size: 13px; text-decoration: underline; padding: 4px;
}
.btn-ico { display: none; } /* só aparece no mobile (ver media query) */

/* ===== Navegação por mês ===== */
.month-nav {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 18px;
}
.month-nav h2 {
  font-size: 18px; min-width: 190px; text-align: center;
}

/* ===== Cartões de resumo ===== */
.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
}
.card-income::before { background: var(--income); }
.card-expense::before { background: var(--expense); }
.card-balance::before { background: var(--primary); }
.card-savings::before { background: #f59e0b; }
.card-label { font-size: 13px; color: var(--text-soft); font-weight: 500; }
.card-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.card-income .card-value { color: var(--income); }
.card-expense .card-value { color: var(--expense); }
.card-sub { font-size: 12px; color: var(--text-faint); }
.progress {
  height: 7px; background: var(--surface-2); border-radius: 99px;
  overflow: hidden; margin-top: 8px; border: 1px solid var(--border);
}
.progress-fill {
  height: 100%; width: 0%; background: #f59e0b;
  border-radius: 99px; transition: width .4s ease;
}

/* ===== Banner de saldo acumulado ===== */
.total-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
  border-radius: var(--radius); padding: 18px 22px; margin-bottom: 18px;
  color: #fff; box-shadow: var(--shadow);
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}
.total-banner.pos { background: linear-gradient(135deg, var(--primary-strong), var(--primary)); color: #0b0b0a; }
.total-banner.pos .bd { background: rgba(0, 0, 0, .12); }
.total-banner.neg { background: linear-gradient(135deg, #b91c1c, #e11d48); }
.total-main { display: flex; flex-direction: column; gap: 2px; }
.total-label { font-size: 13px; font-weight: 600; opacity: .9; }
.total-label em { font-style: normal; opacity: .8; font-weight: 400; }
.total-value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.total-breakdown { display: flex; gap: 14px; flex-wrap: wrap; }
.total-breakdown .bd {
  display: flex; flex-direction: column; gap: 1px;
  background: rgba(255, 255, 255, .15); border-radius: var(--radius-sm); padding: 8px 14px;
}
.total-breakdown .bd-label { font-size: 11px; opacity: .85; }
.total-breakdown .bd-val { font-size: 15px; font-weight: 700; }

/* ===== Painéis ===== */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.panel-head h3 { font-size: 16px; }
.panel-hint { font-size: 12px; color: var(--text-faint); }

.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
.chart-wrap { position: relative; height: 240px; }
.chart-wrap-tall { height: 280px; }
.chart-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--text-faint); font-size: 14px;
}

/* Legenda de categorias */
.legend { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.legend li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.legend .dot { width: 11px; height: 11px; border-radius: 4px; }
.legend .legend-name { font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 6px; }
.legend .legend-val { font-size: 13px; font-weight: 600; }
.legend .legend-pct { font-size: 11px; color: var(--text-faint); margin-left: 6px; }
.legend-bar { grid-column: 1 / -1; height: 5px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.legend-bar span { display: block; height: 100%; border-radius: 99px; }

/* ===== Lista de transações ===== */
.transactions { margin-bottom: 18px; }
.transactions-head { align-items: center; }
.badge {
  background: var(--primary-soft); color: var(--primary);
  font-size: 12px; font-weight: 600; padding: 2px 8px;
  border-radius: 99px; margin-left: 6px;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters input, .filters select {
  font: inherit; padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.filters input { min-width: 200px; }

.tx-list { list-style: none; margin: 0; padding: 0; }
.tx-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 14px; align-items: center;
  padding: 12px 8px; border-bottom: 1px solid var(--border);
}
.tx-item:last-child { border-bottom: none; }
.tx-icon {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-size: 20px; flex-shrink: 0;
}
.tx-main { min-width: 0; }
.tx-desc { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 12px; color: var(--text-faint); }
.tx-amount { font-weight: 700; font-size: 15px; white-space: nowrap; }
.tx-amount.income { color: var(--income); }
.tx-amount.expense { color: var(--expense); }
.tx-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.tx-item:hover .tx-actions { opacity: 1; }
.tx-actions button {
  background: none; color: var(--text-faint); font-size: 15px;
  width: 30px; height: 30px; border-radius: 8px;
}
.tx-actions button:hover { background: var(--surface-2); color: var(--text); }

.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-soft);
  display: none; flex-direction: column; align-items: center; gap: 10px;
}
.empty-state.show { display: flex; }
.empty-emoji { font-size: 40px; }

.app-footer {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-faint); margin-top: 8px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .55);
  backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 440px; box-shadow: var(--shadow);
  border: 1px solid var(--border);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 17px; }
#transactionForm { padding: 20px; display: grid; gap: 16px; }

.type-toggle {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--surface-2); padding: 5px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.type-btn {
  background: transparent; padding: 9px; border-radius: 7px;
  font-weight: 600; color: var(--text-soft); transition: all .15s;
}
.type-btn.is-active[data-type="expense"] { background: var(--expense); color: #fff; }
.type-btn.is-active[data-type="income"] { background: var(--income); color: #fff; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.field > span em { color: var(--text-faint); font-weight: 400; font-style: normal; }
.field input, .field select {
  font: inherit; padding: 11px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  width: 100%;
}
.field input:focus, .field select:focus, .filters input:focus, .filters select:focus {
  outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent;
}
.field .error { color: var(--expense); font-size: 12px; min-height: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 99px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

/* ===== Animações gerais (entradas, cascata e hover) ===== */
.month-nav, .total-banner, .summary .card, .panel, .howto { animation: fadeUp .5s ease both; }
.summary .card:nth-child(1) { animation-delay: .04s; }
.summary .card:nth-child(2) { animation-delay: .10s; }
.summary .card:nth-child(3) { animation-delay: .16s; }
.summary .card:nth-child(4) { animation-delay: .22s; }
.reveal { animation: fadeUp .42s ease both; }

/* Hover: elevar com brilho dourado */
.card, .goal-card, .budget-item, .tip { transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.card:hover { transform: translateY(-3px); box-shadow: 0 14px 32px rgba(0, 0, 0, .45), 0 0 0 1px var(--primary-soft); }
.goal-card:hover { transform: translateY(-3px); }
.budget-item:hover, .tip:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0, 0, 0, .32); }
.btn-ghost:hover, .icon-btn:hover { transform: translateY(-1px); }

/* Modal: fade do fundo */
.modal-overlay.open { animation: overlayIn .2s ease; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .month-nav, .total-banner, .summary .card, .panel, .howto, .reveal, .modal-overlay.open { animation: none !important; }
  .card:hover, .goal-card:hover, .budget-item:hover, .tip:hover, .btn-ghost:hover, .icon-btn:hover, #addBtn:hover { transform: none !important; }
}

/* ===== Abas ===== */
.tabs {
  display: inline-flex; gap: 4px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 18px;
}
.tab {
  background: transparent; color: var(--text-soft);
  padding: 9px 18px; border-radius: 8px; font-weight: 600; font-size: 14px;
  transition: background .15s, color .15s;
}
.tab.is-active { background: var(--primary); color: var(--on-primary); }

/* ===== Como funciona (orientação) ===== */
.howto {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--primary); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 18px;
}
.howto-title { font-size: 15px; margin: 0 0 10px; }
.howto-steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.howto-steps li { font-size: 13px; color: var(--text-soft); line-height: 1.5; padding-right: 26px; }
.howto-steps strong { color: var(--primary); }
.howto-close {
  position: absolute; top: 12px; right: 12px;
  background: none; color: var(--text-faint); font-size: 14px;
  width: 28px; height: 28px; border-radius: 8px;
}
.howto-close:hover { background: var(--surface-2); color: var(--text); }

/* ===== Onde guardar o dinheiro (linguagem simples) ===== */
.rate-bar { margin-bottom: 18px; }
.rate-q { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.rate-label { font-size: 15px; color: var(--text); font-weight: 700; }
.rate-controls { display: flex; align-items: center; gap: 8px; flex: 1 1 300px; min-width: 0; justify-content: flex-end; }
#rateProfile, #rateCustom {
  font: inherit; font-weight: 600; padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
#rateProfile { flex: 1 1 auto; min-width: 0; max-width: 100%; } /* min-width:0 evita que o <select> estoure a tela */
#rateCustom { flex: 0 0 120px; }
.rate-help { font-size: 13px; color: var(--text-soft); margin: 12px 0 0; line-height: 1.55; }
.rate-help strong { color: var(--primary); }
.rate-details { margin-top: 12px; }
.rate-details summary {
  cursor: pointer; font-size: 12px; color: var(--text-faint);
  width: fit-content; list-style: none; user-select: none;
}
.rate-details summary::-webkit-details-marker { display: none; }
.rate-details summary::before { content: "▸ "; }
.rate-details[open] summary::before { content: "▾ "; }
.rate-details summary:hover { color: var(--text-soft); }
.rate-tech { margin-top: 10px; display: flex; flex-direction: column; gap: 9px; }
.rate-tech-line { font-size: 12px; color: var(--text-soft); }
.rate-tech-line strong { color: var(--primary); }
.rate-source { color: var(--text-faint); }
.rate-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.rate-chip {
  font-size: 12px; padding: 6px 10px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft);
}
.rate-chip strong { color: var(--text); }

/* ===== Cabeçalho metas ===== */
.metas-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 12px;
}
.metas-head h3 { font-size: 17px; }

/* ===== Grade de metas ===== */
.goals-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.goal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  cursor: pointer; transition: border-color .15s, transform .05s;
}
.goal-card:hover { border-color: var(--primary); }
.goal-card.is-selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft), var(--shadow); }
.goal-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.goal-emoji {
  width: 46px; height: 46px; border-radius: 13px; background: var(--primary-soft);
  display: grid; place-items: center; font-size: 24px; flex-shrink: 0;
}
.goal-name { font-weight: 700; font-size: 15px; }
.goal-target-label { font-size: 12px; color: var(--text-faint); }
.goal-amounts { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.goal-saved { font-size: 18px; font-weight: 700; }
.goal-of { font-size: 13px; color: var(--text-soft); }
.goal-progress { height: 9px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.goal-progress span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--primary-strong)); transition: width .4s ease; }
.goal-strategy { font-size: 12px; color: var(--text-soft); margin-top: 8px; padding: 6px 9px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; display: inline-block; }
.goal-meta-line { display: flex; justify-content: space-between; margin-top: 10px; font-size: 12px; color: var(--text-soft); }
.goal-eta { font-weight: 600; color: var(--text); }
.goal-actions { display: flex; gap: 8px; margin-top: 14px; }
.goal-actions .btn-ghost, .goal-actions .btn-primary { padding: 8px 12px; font-size: 13px; flex: 1; text-align: center; }
.goal-del { background: none; color: var(--text-faint); font-size: 14px; width: 34px; flex: 0 0 auto !important; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.goal-del:hover { color: var(--expense); border-color: var(--expense); }

/* ===== Detalhe / projeção ===== */
.goal-detail { margin-bottom: 18px; }
.detail-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.stat-label { font-size: 12px; color: var(--text-soft); display: block; }
.stat-value { font-size: 18px; font-weight: 700; }
.stat-value.good { color: var(--income); }
.stat-value.warn { color: #d97706; }
.detail-note { font-size: 12px; color: var(--text-faint); margin: 14px 0 0; }

/* Bloco de financiamento (entrada + cartão) */
.financing:empty { display: none; }
.financing {
  margin-bottom: 18px; padding: 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.financing-head { font-weight: 700; font-size: 14px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.financing .detail-stats { margin-bottom: 0; }
.stat.highlight { background: var(--primary-soft); border-color: var(--primary); }
.stat.highlight .stat-value { color: var(--primary); }
.comparison-head { font-weight: 600; font-size: 13px; color: var(--text); margin: 18px 0 4px; }
.comparison-wrap { position: relative; height: 150px; }
.comparison-cap { font-size: 12px; color: var(--text-soft); margin: 10px 0 0; line-height: 1.5; }
.comparison-cap strong { color: var(--text); }
.financing-note { font-size: 13px; color: var(--text-soft); margin: 12px 0 0; line-height: 1.5; }
.financing-note strong { color: var(--text); }
.financing-note .extra-warn { color: #d97706; font-weight: 600; }
.financing-note .extra-good { color: var(--income); font-weight: 600; }

/* ===== Dicas ===== */
.tips { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.tip {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
}
.tip-icon { font-size: 20px; line-height: 1.3; flex-shrink: 0; }
.tip-text { font-size: 14px; color: var(--text); }
.tip-text strong { color: var(--primary); }

/* ===== Modal: meta ===== */
.icon-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-opt {
  width: 40px; height: 40px; border-radius: 10px; font-size: 20px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: grid; place-items: center; cursor: pointer; transition: all .12s;
}
.icon-opt:hover { border-color: var(--primary); }
.icon-opt.is-active { background: var(--primary); border-color: var(--primary); transform: scale(1.05); }
.plan-toggle {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--surface-2); padding: 5px; border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.plan-btn, .strat-btn { background: transparent; padding: 9px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--text-soft); transition: all .15s; }
.plan-btn.is-active, .strat-btn.is-active { background: var(--primary); color: var(--on-primary); }
#financingFields { display: grid; gap: 16px; padding: 14px; border: 1px dashed var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.rate-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.rate-preset {
  background: var(--surface); border: 1px solid var(--border); color: var(--text-soft);
  font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 99px;
  cursor: pointer; transition: all .12s;
}
.rate-preset:hover { border-color: var(--primary); color: var(--text); }
.rate-preset.is-active { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.financing-hint { font-size: 12px; color: var(--text-soft); margin: 0; line-height: 1.55; }
.financing-hint a { color: var(--primary); font-weight: 600; white-space: nowrap; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.aporte-goal { margin: 0 0 4px; font-size: 14px; color: var(--text-soft); }
.aporte-goal strong { color: var(--text); }

/* ===== Orçamentos ===== */
.budgets { margin-bottom: 18px; }
.badge-alert { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; margin-left: 6px; }
.badge-alert.warn { background: #fef3c7; color: #b45309; }
.badge-alert.over { background: var(--expense-soft); color: var(--expense); }
.badge-alert.ok { background: var(--income-soft); color: var(--income); }
[data-theme="dark"] .badge-alert.warn { background: #3a2f12; color: #fbbf24; }
.budgets-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.budgets-empty { display: none; text-align: center; color: var(--text-soft); padding: 10px 0; }
.budgets-empty.show { display: block; }
.budgets-empty p { margin: 0 0 12px; font-size: 14px; }
.budget-item {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
  border-left: 4px solid var(--text-faint);
}
.budget-item.ok { border-left-color: var(--income); }
.budget-item.warn { border-left-color: #f59e0b; }
.budget-item.over { border-left-color: var(--expense); }
.budget-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 9px; }
.budget-name { font-weight: 600; font-size: 14px; }
.budget-amt { font-size: 14px; font-weight: 700; white-space: nowrap; }
.budget-lim { color: var(--text-faint); font-weight: 500; }
.budget-bar { height: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.budget-bar span { display: block; height: 100%; border-radius: 99px; transition: width .4s ease; background: var(--income); }
.budget-item.warn .budget-bar span { background: #f59e0b; }
.budget-item.over .budget-bar span { background: var(--expense); }
.budget-status { font-size: 12px; color: var(--text-soft); margin-top: 8px; }
.budget-item.over .budget-status { color: var(--expense); font-weight: 600; }

/* Modal de orçamentos */
.budget-help { margin: 0 0 14px; font-size: 13px; color: var(--text-soft); }
.budget-fields { display: grid; gap: 8px; max-height: 50vh; overflow-y: auto; padding-right: 4px; }
.budget-field { display: grid; grid-template-columns: 1fr 130px; align-items: center; gap: 10px; }
.budget-field > span { font-size: 14px; }
.budget-field input {
  font: inherit; padding: 9px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); width: 100%;
}
.budget-field input:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }

/* ===== Tutorial guiado (spotlight) ===== */
.tour-layer { position: fixed; inset: 0; z-index: 10055; background: transparent; }
.tour-spot {
  position: relative; z-index: 10050 !important;
  box-shadow: 0 0 0 9999px rgba(6, 7, 6, .82), 0 0 0 3px var(--primary), 0 0 28px rgba(199, 164, 71, .5) !important;
  border-radius: 14px !important;
  transition: box-shadow .25s ease;
}
.tour-tip {
  position: fixed; z-index: 10060; width: min(340px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--primary);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6);
  animation: tipIn .25s ease;
}
@keyframes tipIn { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.tour-step-count { font-size: 11px; color: var(--primary); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.tour-title { margin: 5px 0 6px; font-size: 16px; }
.tour-text { margin: 0 0 14px; font-size: 13px; color: var(--text-soft); line-height: 1.55; }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tour-skip { background: none; color: var(--text-faint); font-size: 13px; padding: 4px; }
.tour-skip:hover { color: var(--text); }
.tour-nav { display: flex; gap: 6px; }

/* ===== Responsivo ===== */
@media (max-width: 860px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .app { padding: 16px 14px 50px; }
  .summary { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card-value { font-size: 20px; }
  /* Importar/Exportar viram botões de ícone (em vez de sumir) */
  #importBtn, #exportBtn { padding: 0; width: 38px; height: 38px; display: grid; place-items: center; }
  #importBtn .btn-label, #exportBtn .btn-label { display: none; }
  #importBtn .btn-ico, #exportBtn .btn-ico { display: block; font-size: 16px; }
  .filters input { min-width: 0; flex: 1; }
  .tagline { display: none; }
  .field-row { grid-template-columns: 1fr; }
  .goals-grid { grid-template-columns: 1fr; }
  .total-value { font-size: 24px; }
  .total-breakdown { width: 100%; }
  .total-breakdown .bd { flex: 1; }
}
