/* ============ TOKENS ============ */
:root,
[data-theme="dark"] {
  --bg-deep: #070a1c;
  --bg-primary: #0c1030;
  --bg-secondary: #131938;
  --card-bg: #12163a;
  --card-bg-hover: #171c46;
  --border: #262c5c;
  --border-soft: #1c2149;

  --accent: #818cf8;
  --accent-2: #38bdf8;
  --accent-strong: #6366f1;
  --accent-soft: rgba(129, 140, 248, 0.14);
  --gradient: linear-gradient(135deg, #8b5cf6, #38bdf8);
  --gradient-soft: linear-gradient(135deg, rgba(139,92,246,0.16), rgba(56,189,248,0.16));

  --text-primary: #eef0fc;
  --text-secondary: #a2a8d6;
  --text-muted: #6c72a0;

  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.14);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.14);
  --indigo: #a78bfa;
  --indigo-soft: rgba(167, 139, 250, 0.14);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.14);

  --shadow-card: 0 1px 2px rgba(0,0,0,0.2);
  --grid-line: rgba(129, 140, 248, 0.055);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg-deep: #eef0fb;
  --bg-primary: #f6f7fd;
  --bg-secondary: #eceffb;
  --card-bg: #ffffff;
  --card-bg-hover: #f7f8ff;
  --border: #dfe2f5;
  --border-soft: #e9ebf9;

  --accent: #6366f1;
  --accent-2: #0ea5e9;
  --accent-strong: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.10);
  --gradient: linear-gradient(135deg, #7c3aed, #0ea5e9);
  --gradient-soft: linear-gradient(135deg, rgba(124,58,237,0.08), rgba(14,165,233,0.08));

  --text-primary: #1c2046;
  --text-secondary: #565c8c;
  --text-muted: #8489b8;

  --success: #0d9f6e;
  --success-soft: rgba(13, 159, 110, 0.10);
  --danger: #e11d48;
  --danger-soft: rgba(225, 29, 72, 0.10);
  --indigo: #7c3aed;
  --indigo-soft: rgba(124, 58, 237, 0.10);
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, 0.10);

  --shadow-card: 0 1px 3px rgba(30,32,80,0.08);
  --grid-line: rgba(99, 102, 241, 0.05);
  color-scheme: light;
}

:root {
  --radius: 16px;
  --radius-sm: 10px;
  --font-display: 'Sora', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 0%, var(--gradient-soft) 0%, transparent 45%),
    radial-gradient(circle at 100% 10%, var(--gradient-soft) 0%, transparent 40%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    var(--bg-deep);
  background-size: auto, auto, 34px 34px, 34px 34px, auto;
  background-position: 15% 0%, 100% 10%, 0 0, 0 0;
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  transition: background-color .2s ease, color .2s ease;
  animation: bg-breathe 18s ease-in-out infinite alternate;
}
@keyframes bg-breathe {
  0%   { background-position: 15% 0%, 100% 10%, 0 0, 0 0; }
  100% { background-position: 22% 6%, 92% 16%, 0 0, 0 0; }
}

a { color: inherit; text-decoration: none; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 21px; letter-spacing: -0.02em; }
.brand-your { color: var(--text-secondary); font-weight: 500; }
.brand-din { background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }

.icon-btn {
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; color: var(--text-muted); border: 1px solid var(--border); transition: all .15s;
  background: var(--card-bg); cursor: pointer; font-size: 14px; flex-shrink: 0;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

.avatar-thumb {
  width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.avatar-initials {
  background: var(--gradient); color: #fff; font-size: 11px; font-weight: 700;
  font-family: var(--font-display); letter-spacing: 0;
}

/* ============ LAYOUT COM SIDEBAR (usuário logado) ============ */
.app-shell-sidebar { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: 254px; flex-shrink: 0; background: var(--card-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; overflow-y: auto;
  padding: 18px 14px; z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 18px; }
.sidebar-close-btn { display: none; background: none; border: none; color: var(--text-muted); font-size: 16px; cursor: pointer; padding: 4px; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.sidebar-section-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted);
  font-weight: 700; margin: 16px 10px 6px;
}
.sidebar-section-label:first-child { margin-top: 2px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  font-size: 14px; font-weight: 500; color: var(--text-secondary); transition: background .15s ease, color .15s ease, transform .1s ease;
}
.sidebar-link:hover { background: var(--bg-secondary); color: var(--text-primary); transform: translateX(2px); }
.sidebar-link:active { transform: scale(0.98); }
.sidebar-link.active { background: var(--gradient); color: #fff; font-weight: 700; box-shadow: 0 4px 14px rgba(99,102,241,0.28); }

.sidebar-footer { border-top: 1px solid var(--border-soft); padding-top: 10px; margin-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-footer-btn {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 14px;
  font-family: var(--font-body); text-align: left; width: 100%; transition: background .15s, color .15s;
}
.sidebar-footer-btn:hover { background: var(--bg-secondary); color: var(--text-primary); }
.sidebar-footer-btn.logout:hover { color: var(--danger); }
.sidebar-profile {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  transition: background .15s;
}
.sidebar-profile:hover, .sidebar-profile.active { background: var(--bg-secondary); }
.sidebar-profile-name {
  font-size: 13.5px; font-weight: 600; color: var(--text-primary); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-main { flex: 1; padding: 28px 32px 60px; max-width: 1100px; width: 100%; margin: 0 auto; }
.mobile-topbar { display: none; }
.hamburger-btn { display: none; }
.sidebar-overlay { display: none; }

/* ---------- Limite do cartão (dentro do cartão) ---------- */
.card-limit { margin: 10px 0 2px; position: relative; z-index: 1; }
.card-limit-head { display: flex; justify-content: space-between; font-size: 10.5px; font-weight: 600; opacity: .9; margin-bottom: 5px; }
.card-limit-track { height: 5px; border-radius: 999px; background: rgba(255,255,255,0.25); overflow: hidden; }
.card-limit-fill { display: block; height: 100%; border-radius: 999px; background: #fff; transition: width .6s ease; }
.card-limit-fill.lvl1 { background: #fbbf24; }
.card-limit-fill.lvl2 { background: #fb7185; }
.card-limit-sub { margin: 5px 0 0; font-size: 10.5px; opacity: .85; transition: filter .15s ease; }
.card-limit-sub.masked { filter: blur(6px); user-select: none; }

/* ---------- Alertas de orçamento (dashboard) ---------- */
.budget-alerts { border-left: 3px solid var(--amber); }
.budget-alert-row { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); --ba: var(--amber); }
.budget-alert-row:last-child { border-bottom: none; padding-bottom: 0; }
.budget-alert-row.lvl2 { --ba: var(--danger); }
.budget-alert-icon { font-size: 18px; line-height: 1.3; }
.budget-alert-body { flex: 1; min-width: 0; }
.budget-alert-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.budget-alert-title { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.budget-alert-pct { font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--ba); }
.budget-alert-track { height: 5px; border-radius: 999px; background: var(--bg-secondary); overflow: hidden; margin: 7px 0 5px; }
.budget-alert-track span { display: block; height: 100%; border-radius: 999px; background: var(--ba); }
.budget-alert-sub { margin: 0; font-size: 12px; color: var(--text-muted); }

/* ---------- Avisos (toast) ---------- */
.dd-toast-wrap {
  position: fixed; right: 20px; bottom: 86px; z-index: 500; display: flex; flex-direction: column; gap: 10px;
  width: min(360px, calc(100vw - 32px)); pointer-events: none;
}
.dd-toast {
  pointer-events: auto; cursor: pointer; padding: 13px 16px; border-radius: 12px; font-size: 13px; line-height: 1.45; font-weight: 500;
  background: var(--card-bg); color: var(--text-primary); border: 1px solid var(--border); border-left-width: 4px;
  box-shadow: 0 10px 30px -8px rgba(0,0,0,0.45); animation: ddToastIn .3s ease both;
}
.dd-toast.warn { border-left-color: var(--amber); }
.dd-toast.danger { border-left-color: var(--danger); }
.dd-toast.ok { border-left-color: var(--success); }
.dd-toast.leaving { opacity: 0; transform: translateY(8px); transition: opacity .25s ease, transform .25s ease; }
@keyframes ddToastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (max-width: 900px) {
  .dd-toast-wrap { right: 16px; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- Botão de lançamento rápido + modais ---------- */
.quick-add-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  background: var(--gradient); color: #fff;
  box-shadow: 0 6px 16px -4px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.25);
  transition: transform .15s ease, box-shadow .15s ease;
}
.quick-add-fab:hover { transform: translateY(-2px) scale(1.06); box-shadow: 0 10px 22px -4px rgba(0,0,0,0.4); }
.quick-add-fab:active { transform: scale(.96); }
@media (max-width: 900px) {
  .quick-add-fab { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: 50px; height: 50px; font-size: 20px; }
}
.dd-modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 400;
  opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s;
}
.dd-modal-overlay.open { opacity: 1; visibility: visible; }
.dd-modal {
  position: fixed; left: 50%; top: 50%; z-index: 401; width: min(440px, calc(100vw - 32px));
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-card), 0 20px 60px rgba(0,0,0,0.4); padding: 22px;
  transform: translate(-50%, -50%) scale(.96); opacity: 0; visibility: hidden;
  transition: opacity .18s ease, transform .18s ease, visibility .18s; max-height: 88vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.dd-modal.open { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); }
.dd-modal form { display: flex; flex-direction: column; gap: 12px; }
.dd-modal-head { display: flex; align-items: center; justify-content: space-between; }
@media (max-width: 640px) {
  .dd-modal {
    top: auto; bottom: 0; left: 0; width: 100%; border-radius: 18px 18px 0 0;
    padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    transform: translateY(24px);
  }
  .dd-modal.open { transform: none; }
}
.qa-amount { font-family: var(--font-mono); font-size: 26px; font-weight: 700; text-align: center; }
.dd-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dd-chip {
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
  background: var(--bg-secondary); color: var(--text-secondary); border: 1px solid var(--border);
  transition: border-color .15s, color .15s;
}
.dd-chip:hover { color: var(--text-primary); }
.dd-chip.selected { border-color: var(--cc); color: var(--text-primary); font-weight: 600; box-shadow: inset 0 0 0 1px var(--cc); }

/* ---------- Passo a passo (onboarding) ---------- */
.tour-dots { display: flex; gap: 6px; justify-content: center; }
.tour-dot { width: 26px; height: 4px; border-radius: 999px; background: var(--border); transition: background .25s; }
.tour-dot.active { background: var(--accent); }
.tour-step { display: none; text-align: center; }
.tour-step.active { display: block; animation: ddToastIn .3s ease both; }
.tour-emoji { font-size: 42px; margin: 8px 0 4px; }
.tour-title { margin: 0 0 8px; font-family: var(--font-display); font-size: 21px; color: var(--text-primary); }
.tour-text { margin: 0 0 14px; font-size: 13.5px; line-height: 1.55; color: var(--text-secondary); }
.tour-row { display: flex; gap: 8px; }
.tour-row select { flex: 1; }
.tour-row input { max-width: 150px; }
.tour-list { list-style: none; margin: 0; padding: 0; text-align: left; display: flex; flex-direction: column; gap: 10px; }
.tour-list li { font-size: 13px; line-height: 1.5; color: var(--text-secondary); padding: 10px 12px; border-radius: 10px; background: var(--bg-secondary); border: 1px solid var(--border-soft); }
.tour-list strong { color: var(--text-primary); }
.tour-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; }

/* ============ TOPBAR simples (telas de login/setup, sem sidebar) ============ */
.app-shell { max-width: 1200px; margin: 0 auto; padding: 0 20px 60px; }
.topbar-simple {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 16px 4px;
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 82vw; max-width: 300px;
    transform: translateX(-100%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
    box-shadow: 24px 0 60px rgba(0,0,0,0.35); z-index: 300;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close-btn { display: flex; }
  .sidebar-overlay {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 250;
    opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s;
  }
  .sidebar-overlay.open { opacity: 1; visibility: visible; }
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 14px 16px; position: sticky; top: 0; z-index: 100;
    background: var(--bg-deep); background: color-mix(in srgb, var(--bg-deep) 88%, transparent);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-soft);
  }
  .hamburger-btn {
    display: flex; width: 36px; height: 36px; align-items: center; justify-content: center;
    border-radius: 9px; background: var(--card-bg); border: 1px solid var(--border);
    color: var(--text-primary); font-size: 17px; cursor: pointer; flex-shrink: 0;
  }
}

/* ---------- Cartões (visual flat, minimalista, tipo app de banco) ---------- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 250px)); gap: 20px; margin-bottom: 4px; padding: 6px 2px 10px; }
.credit-card-visual {
  position: relative; border-radius: 22px; padding: 20px; aspect-ratio: 1.7 / 1; min-height: 138px; max-width: 100%;
  display: flex; flex-direction: column; justify-content: space-between; color: #fff; overflow: hidden;
  box-shadow: 0 4px 8px -2px rgba(0,0,0,0.2), 0 14px 28px -10px rgba(0,0,0,0.35);
  transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s ease;
}
.credit-card-visual:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 14px -2px rgba(0,0,0,0.25), 0 22px 40px -10px rgba(0,0,0,0.4);
}
.credit-card-visual::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(110% 90% at 100% 0%, rgba(255,255,255,0.14), transparent 55%);
}
.credit-card-top { display: flex; align-items: center; justify-content: space-between; z-index: 1; position: relative; gap: 8px; }
.card-top-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-icon-badge {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,0.16); display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 12px;
}
.card-type-label { font-size: 12.5px; font-weight: 500; opacity: 0.9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-eye-btn {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.14); border: none; color: #fff; cursor: pointer; font-size: 12px;
  transition: background .15s, transform .15s;
}
.card-eye-btn:hover { background: rgba(255,255,255,0.26); }
.card-eye-btn:active { transform: scale(0.85); }
.card-actions-overlay {
  position: absolute; top: 16px; right: 16px; display: flex; gap: 6px; opacity: 0; z-index: 2;
  transition: opacity .15s;
}
.credit-card-visual:hover .card-actions-overlay { opacity: 1; }
.credit-card-visual:hover .card-eye-btn { opacity: 0; pointer-events: none; transition: opacity .1s; }
.card-icon-btn {
  width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.32); border: 1px solid rgba(255,255,255,0.3); color: #fff; font-size: 10.5px;
  cursor: pointer; backdrop-filter: blur(4px); transition: background .15s;
}
.card-icon-btn:hover { background: rgba(0,0,0,0.52); }
.card-divider {
  border: none; border-top: 1.5px dotted rgba(255,255,255,0.35); margin: 10px 0; z-index: 1; position: relative;
}
.card-body-bottom { z-index: 1; position: relative; }
.card-label-tiny { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; opacity: 0.7; margin: 0 0 4px; font-weight: 500; }
.card-spend-value { font-family: var(--font-display); font-weight: 700; font-size: 21px; margin: 0; letter-spacing: -0.02em; line-height: 1.1; transition: filter .15s ease; }
.card-spend-value.masked { filter: blur(7px); user-select: none; }
.card-footer-row { display: flex; align-items: flex-end; justify-content: space-between; margin-top: 10px; gap: 8px; }
.card-nickname { font-family: var(--font-body); font-weight: 500; font-size: 11px; line-height: 1.2; margin: 0; opacity: 0.75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-chevron {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.16); font-size: 13px; font-weight: 700; transition: transform .18s ease, background .15s;
}
.credit-card-visual:hover .card-chevron { transform: translateX(3px); background: rgba(255,255,255,0.28); }
.add-card-tile {
  border-radius: 22px; aspect-ratio: 1.7 / 1; min-height: 138px; border: 1.5px dashed var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--text-secondary); cursor: pointer; background: var(--bg-secondary); transition: all .15s;
}
.add-card-tile:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.add-card-tile .plus-icon { font-size: 24px; line-height: 1; font-weight: 300; }
.card-register-form-wrap { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border-soft); }

/* Seletor de cor do cartão */
.color-picker-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.color-swatch {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
  padding: 0; transition: transform .12s, border-color .12s; position: relative;
}
.color-swatch:hover { transform: scale(1.1); }
.color-swatch.selected { border-color: var(--text-primary); box-shadow: 0 0 0 2px var(--card-bg); }
.color-swatch-custom {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; overflow: hidden;
  border: 2px dashed var(--border); display: flex; align-items: center; justify-content: center;
  background: conic-gradient(from 0deg, #f43f5e, #f59e0b, #22c55e, #06b6d4, #6366f1, #f43f5e);
}
.color-swatch-custom input[type=color] {
  width: 40px; height: 40px; padding: 0; border: none; cursor: pointer; opacity: 0;
}
.installment-preview { font-family: var(--font-mono); font-size: 13px; color: var(--accent); min-height: 18px; margin: 10px 0; }

/* ---------- Upload de comprovantes ---------- */
.file-drop {
  display: flex; align-items: center; justify-content: center; text-align: center;
  border: 1.5px dashed var(--border); border-radius: 12px; padding: 18px 14px;
  background: var(--bg-secondary); cursor: pointer; color: var(--text-secondary); font-size: 13.5px;
  transition: border-color .15s, color .15s;
}
.file-drop:hover { border-color: var(--accent); color: var(--accent); }
.file-drop input[type=file] { display: none; }

/* ---------- Perfil: cabeçalho de destaque ---------- */
.profile-hero {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow-card);
  position: relative; overflow: hidden; animation: panel-fade-in .35s ease both;
}
.profile-hero::before {
  content: ''; position: absolute; inset: 0; background: var(--gradient-soft); opacity: .7; pointer-events: none;
}
.profile-hero-avatar {
  width: 76px; height: 76px; border-radius: 50%; flex-shrink: 0; position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--gradient); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 26px;
  box-shadow: 0 10px 22px -6px rgba(99,102,241,0.5);
}
.profile-hero-info { position: relative; z-index: 1; min-width: 0; }
.profile-hero-name {
  font-family: var(--font-display); font-size: 21px; font-weight: 700; margin: 0 0 6px;
  letter-spacing: -0.01em; display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
}
.profile-hero-meta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; color: var(--text-secondary); font-size: 13px; }
.profile-hero-meta span { display: flex; align-items: center; gap: 5px; }

/* ---------- Perfil ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.form-grid-full { grid-column: 1 / -1; }
.theme-choice { display: flex; gap: 10px; }
.theme-option {
  flex: 1; display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg-secondary); cursor: pointer; transition: border-color .15s;
}
.theme-option input { width: auto; }
.theme-option.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* ============ AUTH SCREENS ============ */
.auth-wrap { min-height: 90vh; display: flex; align-items: center; justify-content: center; padding: 20px 0; }
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.auth-logo {
  margin: 0 auto 20px; font-family: var(--font-display); font-weight: 700;
  font-size: 30px; letter-spacing: -0.02em;
}
.auth-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin: 0 0 6px; }
.auth-sub { color: var(--text-secondary); font-size: 14px; margin: 0 0 28px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: left; }

/* ============ FORMS ============ */
label { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-secondary); font-weight: 600; display: block; margin-bottom: 6px; }
input, select {
  width: 100%; background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 14px; color: var(--text-primary); font-family: var(--font-body); font-size: 14px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--text-muted); }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 12px; font-weight: 700; font-size: 14px;
  border: none; cursor: pointer; font-family: var(--font-body); transition: all .15s;
}
.btn-primary { background: var(--gradient); color: #fff; box-shadow: 0 4px 14px rgba(99,102,241,0.32), 0 1px 2px rgba(0,0,0,0.15); border-radius: 999px; }
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1.5px); box-shadow: 0 8px 20px rgba(99,102,241,0.4), 0 2px 4px rgba(0,0,0,0.15); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); border-color: var(--accent); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(225,29,72,0.25); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.alert { padding: 10px 14px; border-radius: 10px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(225,29,72,0.25); }
.alert-success { background: var(--success-soft); color: var(--success); border: 1px solid rgba(13,159,110,0.25); }
.hint { color: var(--text-muted); font-size: 12px; margin-top: 14px; line-height: 1.5; }

/* ============ HERO / WAVE ============ */
.hero {
  position: relative; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--card-bg); overflow: hidden; margin-bottom: 24px;
  box-shadow: var(--shadow-card), 0 20px 40px -24px rgba(0,0,0,0.35);
}
.hero-wave { width: 100%; height: 70px; display: block; }
.hero-body { padding: 0 24px 24px; margin-top: -20px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.month-nav { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; font-weight: 600; }
.month-nav a { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; border-radius: 6px; }
.month-nav a:hover { background: var(--accent-soft); color: var(--accent); }
.balance-label { color: var(--text-secondary); font-size: 13px; margin: 0 0 2px; }
.balance-value { font-family: var(--font-mono); font-size: clamp(28px, 6vw, 40px); font-weight: 600; margin: 0; }
.balance-positive {
  background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.balance-negative { color: var(--danger); }
.salary-field { width: 220px; max-width: 100%; }
.salary-hint { font-size: 11.5px; color: var(--text-muted); margin: 6px 0 0; }

/* ============ GRID / CARDS ============ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card {
  position: relative;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; padding: 18px;
  box-shadow: var(--shadow-card); transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s ease, border-color .18s ease;
  overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: var(--gradient); opacity: 0; transition: opacity .2s ease;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px -8px rgba(0,0,0,0.28); }
.stat-card:hover::before { opacity: 0.55; }
.stat-icon { width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 15px; margin-bottom: 10px; }
.stat-icon.sky { background: var(--accent-soft); color: var(--accent); }
.stat-icon.rose { background: var(--danger-soft); color: var(--danger); }
.stat-icon.emerald { background: var(--success-soft); color: var(--success); }
.stat-icon.indigo { background: var(--indigo-soft); color: var(--indigo); }
.stat-icon.amber { background: var(--amber-soft); color: var(--amber); }
.stat-label { font-size: 11px; text-transform: uppercase; color: var(--text-secondary); letter-spacing: .04em; margin: 0 0 4px; }
.stat-value { font-family: var(--font-mono); font-size: 19px; font-weight: 600; margin: 0; word-break: break-word; }
.stat-sub { font-size: 11px; color: var(--text-muted); margin: 4px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-delta { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 700; margin-top: 7px; padding: 2px 7px; border-radius: 999px; }
.stat-delta.stat-delta-good { color: var(--success); background: var(--success-soft); }
.stat-delta.stat-delta-bad { color: var(--danger); background: var(--danger-soft); }

/* ---------- Divisor de seção com rótulo ---------- */
.section-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted);
  font-weight: 700; margin: 30px 0 12px; display: flex; align-items: center; gap: 10px;
}
.section-label::after { content: ''; flex: 1; height: 1px; background: var(--border-soft); }
.section-label:first-child { margin-top: 0; }

/* ---------- Comprometimento do salário ---------- */
.commit-bar-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 6px; }
.commit-bar-pct { font-family: var(--font-mono); font-weight: 700; font-size: 16px; }

.panel {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 20px;
  box-shadow: var(--shadow-card), 0 1px 0 rgba(255,255,255,0.02) inset;
  animation: panel-fade-in .35s ease both;
}
@keyframes panel-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.panel-title {
  font-size: 13.5px; font-weight: 600; margin: 0 0 14px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px;
  text-transform: uppercase; letter-spacing: .04em;
  border-left: 3px solid transparent;
  border-image: var(--gradient) 1;
  padding-left: 10px;
}
.panel-sub { color: var(--text-muted); font-weight: 400; font-size: 12.5px; }

.slider-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
input[type=range] { accent-color: var(--accent); width: 100%; }
.slider-hint { color: var(--text-muted); font-size: 12.5px; margin-top: 10px; line-height: 1.5; }

.columns-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
.columns-2-even { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 120px; }

.expense-list, .invest-list { display: flex; flex-direction: column; max-height: 340px; overflow-y: auto; }
.row-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 6px; border-bottom: 1px solid var(--border-soft);
}
.row-item:last-child { border-bottom: none; }
.row-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.row-name { font-size: 14px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }
.row-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.row-amount { font-family: var(--font-mono); font-size: 14px; font-weight: 600; }
.delete-btn { color: var(--text-muted); background: none; border: none; cursor: pointer; font-size: 15px; padding: 4px; }
.delete-btn:hover { color: var(--danger); }
.empty-state {
  text-align: center; color: var(--text-muted); font-size: 13.5px; padding: 36px 20px;
  background: var(--bg-secondary); border: 1px dashed var(--border); border-radius: 14px; line-height: 1.6;
}

.legend-row { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; padding: 4px 0; }
.legend-left { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); }
.legend-value { font-family: var(--font-mono); color: var(--text-primary); }

.gain-positive { color: var(--success); }
.gain-negative { color: var(--danger); }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
table.data-table th { text-align: left; color: var(--text-secondary); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data-table td { padding: 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 10.5px; font-weight: 700; white-space: nowrap; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .03em; }
.badge-admin { background: var(--accent-soft); color: var(--accent); }
.badge-user { background: rgba(148,163,184,0.14); color: var(--text-secondary); }
.badge-pending { background: var(--amber-soft); color: var(--amber); }
.badge-active { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Admin: usuários em cards ---------- */
.users-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.users-toolbar input[type=search] { flex: 1; min-width: 180px; }
.users-count-pill { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.users-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.user-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-card);
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s ease, border-color .18s ease;
}
.user-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px -8px rgba(0,0,0,0.28); border-color: var(--accent); }
.user-card.is-you { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.user-card.is-blocked { opacity: .68; }
.user-card.is-blocked:hover { opacity: .9; }
.user-card-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.user-card-avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: var(--gradient); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 15px;
}
.user-card-names { min-width: 0; }
.user-card-name { font-size: 14.5px; font-weight: 600; margin: 0 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.user-card-username { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.user-card-meta { font-size: 11.5px; color: var(--text-muted); }
.user-card-actions { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--border-soft); padding-top: 12px; margin-top: auto; }
.user-card-actions .btn-sm { flex: 1; min-width: 0; }
.user-card-you-tag { font-size: 9.5px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; background: var(--accent-soft); padding: 2px 6px; border-radius: 999px; }

.chart-wrap { position: relative; height: 210px; }
.chart-wrap.tall { height: 260px; }

.page-title { font-family: var(--font-display); font-size: 21px; font-weight: 700; margin: 4px 0 20px; letter-spacing: -0.01em; }

/* ============ CAIXINHAS ============ */
.goals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.goal-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-card); }
.goal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.goal-name { font-size: 15px; font-weight: 600; margin: 0; }
.goal-sub { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }
.progress-track { width: 100%; height: 9px; background: var(--bg-secondary); border-radius: 999px; overflow: hidden; border: 1px solid var(--border-soft); }
.progress-fill { height: 100%; background: var(--gradient); border-radius: 999px; transition: width .3s ease; }
.progress-fill.complete { background: linear-gradient(90deg, var(--success), #10b981); }
.progress-fill.over-budget { background: linear-gradient(90deg, var(--danger), #f43f5e); }

/* ---------- Maiores gastos (ranking real) ---------- */
.top-expenses-list { display: flex; flex-direction: column; gap: 14px; }
.top-expense-row { display: flex; align-items: flex-start; gap: 12px; }
.top-expense-rank {
  flex-shrink: 0; width: 26px; height: 26px; margin-top: 1px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  color: var(--text-muted); background: var(--bg-secondary); border: 1px solid var(--border-soft);
}
.top-expense-rank.has-medal { background: none; border: none; font-size: 17px; }
.top-expense-body { flex: 1; min-width: 0; }
.top-expense-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.top-expense-name { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--text-primary); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-expense-amount { font-family: var(--font-mono); font-weight: 700; font-size: 13.5px; white-space: nowrap; flex-shrink: 0; }
.top-expense-sub { margin: 6px 0 0; font-size: 11.5px; color: var(--text-secondary); }
@media (max-width: 640px) {
  .top-expense-name { font-size: 13px; }
  .top-expense-sub { font-size: 11px; }
}

/* ---------- Insights automáticos ---------- */
.insights-panel { padding-top: 18px; padding-bottom: 8px; }
.insight-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 2px;
  border-bottom: 1px solid var(--border-soft); font-size: 13.5px; line-height: 1.45;
}
.insight-row:last-child { border-bottom: none; }
.insight-icon {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 9px; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.insight-text { color: var(--text-secondary); }
.insight-danger .insight-icon { background: var(--danger-soft); }
.insight-warning .insight-icon { background: var(--amber-soft); }
.insight-success .insight-icon { background: var(--success-soft); }
.insight-info .insight-icon { background: var(--accent-soft); }

/* ---------- Contas a vencer ---------- */
.due-soon-list { display: flex; flex-direction: column; }
.due-soon-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.due-soon-row:last-child { border-bottom: none; }
.due-soon-badge {
  flex-shrink: 0; font-size: 11px; font-weight: 700; font-family: var(--font-mono); text-align: center;
  padding: 5px 9px; border-radius: 999px; background: var(--bg-secondary); color: var(--text-secondary);
  border: 1px solid var(--border-soft); white-space: nowrap;
}
.due-soon-badge.due-close { background: var(--amber-soft); color: var(--amber); border-color: var(--amber); }
.due-soon-badge.due-today { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.due-soon-body { flex: 1; min-width: 0; }
.due-soon-name { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.due-soon-sub { margin: 2px 0 0; font-size: 11.5px; color: var(--text-muted); }
.due-soon-amount { font-family: var(--font-mono); font-weight: 700; font-size: 13.5px; flex-shrink: 0; }
.panel-link-more {
  display: inline-block; margin-top: 12px; font-size: 12.5px; font-weight: 600; color: var(--accent);
}
.panel-link-more:hover { text-decoration: underline; }

/* ---------- Assinaturas recorrentes detectadas (fixos.php) ---------- */
.recurring-list { display: flex; flex-direction: column; }
.recurring-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.recurring-row:last-child { border-bottom: none; }
.recurring-row .dot { flex-shrink: 0; }
.recurring-body { flex: 1; min-width: 0; }
.recurring-name { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.recurring-sub { margin: 3px 0 0; font-size: 11.5px; color: var(--text-muted); }
@media (max-width: 640px) {
  .recurring-row { flex-wrap: wrap; }
  .recurring-row .btn { margin-left: auto; }
}

/* ---------- Saúde financeira ---------- */
.health-card { padding: 0; overflow: hidden; }
.health-top {
  display: flex; align-items: center; gap: 28px; padding: 24px 26px;
  background: radial-gradient(120% 140% at 0% 0%, var(--health-soft) 0%, transparent 60%);
  border-bottom: 1px solid var(--border-soft);
}
.health-ring { position: relative; width: 132px; height: 132px; flex-shrink: 0; }
.health-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.health-ring .ring-track { fill: none; stroke: var(--bg-secondary); stroke-width: 10; }
.health-ring .ring-fill {
  fill: none; stroke: var(--health-color); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 326.73; stroke-dashoffset: 326.73;
  animation: healthRing 1.1s cubic-bezier(.22,.9,.3,1) .1s forwards;
  filter: drop-shadow(0 0 6px var(--health-soft));
}
@keyframes healthRing { to { stroke-dashoffset: var(--ring-offset); } }
.health-ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.health-ring-score { font-family: var(--font-mono); font-size: 34px; font-weight: 700; line-height: 1; color: var(--text-primary); }
.health-ring-max { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.health-summary { flex: 1; min-width: 0; }
.health-badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; color: var(--health-color); background: var(--health-soft);
  border: 1px solid var(--health-color);
}
.health-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--health-color); }
.health-headline { margin: 10px 0 4px; font-size: 17px; font-weight: 700; color: var(--text-primary); }
.health-desc { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-secondary); }
.health-focus {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 6px 11px;
  font-size: 12px; color: var(--text-secondary); background: var(--bg-secondary);
  border: 1px solid var(--border-soft); border-radius: 10px;
}
.health-focus strong { color: var(--text-primary); font-weight: 600; }
.health-grid { display: grid; grid-template-columns: repeat(4, 1fr); }
.health-metric { padding: 18px 20px; border-right: 1px solid var(--border-soft); min-width: 0; }
.health-metric:last-child { border-right: none; }
.health-metric-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.health-metric-icon {
  width: 32px; height: 32px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 15px; background: var(--mc-soft);
}
.health-metric-score { font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--mc); }
.health-metric-name { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.health-metric-value { margin: 3px 0 10px; font-size: 12px; color: var(--text-muted); min-height: 16px; }
.health-metric-bar { height: 6px; border-radius: 999px; background: var(--bg-secondary); overflow: hidden; }
.health-metric-bar span {
  display: block; height: 100%; border-radius: 999px; background: var(--mc);
  transform-origin: left; animation: healthBar .9s cubic-bezier(.22,.9,.3,1) .2s both;
}
@keyframes healthBar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.health-metric-weight { margin: 8px 0 0; font-size: 10.5px; color: var(--text-muted); }
@media (max-width: 900px) {
  .health-grid { grid-template-columns: repeat(2, 1fr); }
  .health-metric:nth-child(2) { border-right: none; }
  .health-metric:nth-child(-n+2) { border-bottom: 1px solid var(--border-soft); }
}
@media (max-width: 560px) {
  .health-top { flex-direction: column; text-align: center; padding: 22px 18px; gap: 18px; }
  .health-focus { text-align: left; }
  .health-metric { padding: 16px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .health-ring .ring-fill { animation: none; stroke-dashoffset: var(--ring-offset); }
  .health-metric-bar span { animation: none; }
}
.export-link {
  margin-left: auto; font-size: 11px; font-weight: 600; color: var(--text-secondary);
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); width: auto !important; height: auto !important;
  transition: color .15s, border-color .15s;
}
.export-link:hover { color: var(--accent); border-color: var(--accent); }
.goal-numbers { display: flex; align-items: baseline; justify-content: space-between; font-family: var(--font-mono); font-size: 13px; }
.goal-saved { color: var(--text-primary); font-weight: 600; }
.goal-target { color: var(--text-muted); }
.goal-remaining { font-size: 12.5px; color: var(--text-secondary); margin: 0; }
.goal-remaining strong { color: var(--accent); font-family: var(--font-mono); }
.goal-remaining.done strong { color: var(--success); }
.goal-deposit-form { display: flex; gap: 6px; margin-top: 4px; }
.goal-deposit-form input { flex: 1; }
.goal-icon-btn { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; border-radius: 7px; background: none; border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; flex-shrink: 0; }
.goal-icon-btn:hover { color: var(--danger); border-color: var(--danger); }
.goal-history { max-height: 100px; overflow-y: auto; margin-top: 2px; }
.goal-history .row-item { padding: 6px 2px; }
.goal-history .row-name { font-size: 12.5px; }

/* ============ RESPONSIVIDADE ============ */
@media (max-width: 900px) {
  .columns-2, .columns-2-even { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .app-shell { padding: 0 14px 40px; }
  .app-main { padding: 20px 16px 40px; }
  .salary-field { width: 100%; }
  .hero-body { flex-direction: column; align-items: stretch; }
  .inline-form input, .inline-form select { flex: 1 1 100%; min-width: 0; }
  .panel { padding: 14px; }
  .goals-grid { grid-template-columns: 1fr; }
  .chart-wrap { height: 190px; }
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .month-nav { flex-wrap: wrap; row-gap: 6px; }
  .theme-choice { flex-direction: column; }
  table.data-table { font-size: 13px; }
}
@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .balance-value { font-size: 30px; }
}

/* ============================================================
   CAMADA DE INTERATIVIDADE
   Microanimações e feedback visual em toda a interface.
   ============================================================ */

/* ---------- Acessibilidade / foco ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible, a:focus-visible, .sidebar-link:focus-visible { outline-offset: 3px; }

/* ---------- Seleção de texto ---------- */
::selection { background: var(--accent); color: #fff; }

/* ---------- Scrollbar customizada (desktop) ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--accent); background-clip: padding-box; }

/* ---------- Botões: resposta tátil ao clique ---------- */
.btn { position: relative; overflow: hidden; -webkit-tap-highlight-color: transparent; }
.btn::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(circle, rgba(255,255,255,0.35) 0%, transparent 70%);
  opacity: 0; transform: scale(0.4); transition: opacity .4s ease, transform .4s ease; pointer-events: none;
}
.btn:active::after { opacity: 1; transform: scale(1); transition: opacity 0s, transform 0s; }
.btn:active { transform: scale(0.97); }
.btn-primary:active { transform: translateY(0) scale(0.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }

.icon-btn, .card-icon-btn, .goal-icon-btn, .month-nav a, .delete-btn {
  transition: transform .15s cubic-bezier(.34,1.56,.64,1), color .15s, border-color .15s, background .15s;
}
.icon-btn:active, .card-icon-btn:active, .goal-icon-btn:active, .delete-btn:active { transform: scale(0.85); }
.delete-btn:hover { transform: scale(1.15) rotate(90deg); }

/* ---------- Sidebar: item ativo entra com um leve "pop" ---------- */
.sidebar-link.active { animation: tab-pop .25s cubic-bezier(.34,1.56,.64,1); }
@keyframes tab-pop { 0% { transform: scale(0.94); } 60% { transform: scale(1.02); } 100% { transform: scale(1); } }

/* ---------- Linhas de lista/tabela: reagem ao mouse ---------- */
.row-item {
  transition: background .15s ease, padding-left .15s ease, transform .15s ease;
  border-radius: 8px;
}
.row-item:hover { background: var(--bg-secondary); padding-left: 10px; }
.row-item .row-right { transition: transform .15s ease; }
table.data-table tbody tr { transition: background .15s ease; }
table.data-table tbody tr:hover { background: var(--bg-secondary); }
table.data-table tbody tr td:first-child { border-radius: 8px 0 0 8px; }
table.data-table tbody tr td:last-child { border-radius: 0 8px 8px 0; }

/* ---------- Cards de estatística: ícone reage ao hover ---------- */
.stat-icon { transition: transform .25s cubic-bezier(.34,1.56,.64,1); }
.stat-card:hover .stat-icon { transform: scale(1.12) rotate(-4deg); }

/* ---------- Inputs: leve elevação no foco ---------- */
input, select {
  transition: border-color .15s, box-shadow .15s, transform .1s ease;
}
input:focus, select:focus { transform: translateY(-1px); }

/* ---------- Checkbox/radio customizados (tema, aplicar pra frente, etc.) ---------- */
input[type="checkbox"], input[type="radio"] {
  width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer;
  transition: transform .12s ease;
}
input[type="checkbox"]:active, input[type="radio"]:active { transform: scale(0.85); }

.theme-option { transition: border-color .18s ease, box-shadow .18s ease, transform .15s ease; }
.theme-option:hover { transform: translateY(-2px); }
.theme-option.selected { animation: theme-select-pulse .3s ease; }
@keyframes theme-select-pulse { 0% { transform: scale(0.97); } 100% { transform: scale(1); } }

/* ---------- Alertas: entram deslizando ---------- */
.alert { animation: alert-slide-in .25s cubic-bezier(.2,.8,.2,1) both; }
@keyframes alert-slide-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Badges: pulso sutil no status "ativo/andamento" ---------- */
.badge-active { position: relative; }
.badge-active::before {
  content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--success); margin-right: 5px; vertical-align: 1px;
  animation: badge-pulse 1.8s ease-in-out infinite;
}
@keyframes badge-pulse { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--success-soft); } 50% { opacity: .6; box-shadow: 0 0 0 3px transparent; } }

/* ---------- Barra de progresso das caixinhas: brilho percorrendo ---------- */
.progress-fill { position: relative; overflow: hidden; }
.progress-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  animation: progress-shine 2.2s ease-in-out infinite;
}
@keyframes progress-shine { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* ---------- Cartões: badge do ícone com leve reação no hover ---------- */
.card-icon-badge { transition: transform .2s ease; }
.credit-card-visual:hover .card-icon-badge { transform: scale(1.08); }

/* ---------- Add-card-tile: ícone "respira" no hover ---------- */
.add-card-tile .plus-icon { transition: transform .25s cubic-bezier(.34,1.56,.64,1); }
.add-card-tile:hover .plus-icon { transform: rotate(90deg) scale(1.15); }

/* ---------- Color swatches: pop ao selecionar ---------- */
.color-swatch.selected { animation: swatch-pop .25s cubic-bezier(.34,1.56,.64,1); }
@keyframes swatch-pop { 0% { transform: scale(0.8); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* ---------- Links de navegação de mês ---------- */
.month-nav a:active { transform: scale(0.85); }

/* ---------- Spinner de carregamento reutilizável ---------- */
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Empty state: leve fade + ícone flutuante quando presente ---------- */
.empty-state { animation: panel-fade-in .4s ease both; transition: border-color .2s ease; }
.empty-state:hover { border-color: var(--accent); }

/* ---------- Goal cards: leve elevação no hover, como os demais cards ---------- */
.goal-card { transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s ease, border-color .18s ease; }
.goal-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px -8px rgba(0,0,0,0.28); border-color: var(--accent); }

/* ---------- Botão de trocar tema: rotação ao clicar ---------- */
.theme-spin { animation: theme-spin-anim .4s cubic-bezier(.34,1.56,.64,1); }
@keyframes theme-spin-anim { from { transform: rotate(0deg) scale(1); } 50% { transform: rotate(180deg) scale(1.2); } to { transform: rotate(360deg) scale(1); } }

/* ---------- Respeita quem prefere menos movimento ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   ENTRADA EM CASCATA
   Cards e linhas aparecem suavemente ao carregar a página, com
   um pequeno atraso progressivo entre eles (efeito cascata).
   ============================================================ */
@keyframes fade-slide-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.stat-grid .stat-card,
.cards-grid > .credit-card-visual,
.cards-grid > .add-card-tile,
.goals-grid .goal-card,
.users-grid .user-card {
  animation: fade-slide-up .45s cubic-bezier(.2,.8,.2,1) both;
}
.stat-grid .stat-card:nth-child(2),
.cards-grid > *:nth-child(2),
.goals-grid .goal-card:nth-child(2),
.users-grid .user-card:nth-child(2) { animation-delay: .05s; }
.stat-grid .stat-card:nth-child(3),
.cards-grid > *:nth-child(3),
.goals-grid .goal-card:nth-child(3),
.users-grid .user-card:nth-child(3) { animation-delay: .1s; }
.stat-grid .stat-card:nth-child(4),
.cards-grid > *:nth-child(4),
.goals-grid .goal-card:nth-child(4),
.users-grid .user-card:nth-child(4) { animation-delay: .15s; }
.stat-grid .stat-card:nth-child(n+5),
.cards-grid > *:nth-child(n+5),
.goals-grid .goal-card:nth-child(n+5),
.users-grid .user-card:nth-child(n+5) { animation-delay: .2s; }

/* Listas de gastos/investimentos entram deslizando de leve, uma vez, ao montar a página */
.expense-list .row-item,
.invest-list .row-item {
  animation: fade-slide-up .35s cubic-bezier(.2,.8,.2,1) both;
}

/* Cabeçalho do perfil */
.profile-hero-avatar { animation: fade-slide-up .4s ease both; }

/* Painéis herdam a mesma curva de entrada da hero pra ficar consistente */
.hero, .profile-hero { animation: fade-slide-up .4s cubic-bezier(.2,.8,.2,1) both; }

/* Botões primários "respiram" de leve no hover pra parecerem mais vivos */
.btn-primary { transition: filter .15s, transform .18s cubic-bezier(.34,1.56,.64,1), box-shadow .18s ease; }

/* ============================================================
   FEEDBACK AO LANÇAR UM GASTO
   O botão do formulário pisca em verde com um "pop" ao confirmar,
   e o novo lançamento chega na lista com um destaque suave.
   ============================================================ */
@keyframes btn-success-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.045); }
  100% { transform: scale(1); }
}
.btn-success-flash {
  background: var(--success) !important;
  border-color: var(--success) !important;
  color: #fff !important;
  animation: btn-success-pop .4s cubic-bezier(.34,1.56,.64,1);
}

@keyframes new-entry-pop {
  0%   { transform: scale(.97); background: var(--success-soft); box-shadow: 0 0 0 0 var(--success-soft); }
  40%  { transform: scale(1.008); background: var(--success-soft); box-shadow: 0 0 0 5px var(--success-soft); }
  100% { transform: scale(1); background: transparent; box-shadow: 0 0 0 0 transparent; }
}
.row-item.row-item-new {
  animation: fade-slide-up .35s cubic-bezier(.2,.8,.2,1) both,
             new-entry-pop 1.3s cubic-bezier(.2,.8,.2,1) .3s both;
  border-radius: 10px;
}
