/* ============================================================
   FinanceApp — Design System
   Dark theme · DM Sans · Mobile-first
   ============================================================ */

/* ── Reset & Tokens ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens compartilhados ──────────────────────────── */
:root {
  /* Sizing (iguais nos 2 temas) */
  --sidebar-w: 256px;
  --topbar-h:  60px;
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* Escala de spacing — use estes tokens em vez de valores soltos */
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 2rem;

  /* Padding padrão de containers de conteúdo (cards / banners) */
  --pad-card: 1.35rem;
  --pad-card-lg: 1.5rem;

  /* Escala tipográfica — preferir estes tokens a valores soltos */
  --text-xs:   .72rem;   /* labels, badges, metadados */
  --text-sm:   .82rem;   /* texto auxiliar, .small */
  --text-base: .875rem;  /* corpo padrão, body text dos cards */
  --text-md:   .95rem;   /* headings de section-card, body grande */
  --text-lg:   1.1rem;   /* h2 modal, valores grandes secundários */
  --text-xl:   1.32rem;  /* card-value, números em destaque */
  --text-2xl:  1.5rem;   /* títulos de página, h1 */
  --line-tight: 1.25;
  --line-base:  1.5;

  /* Curvas de easing — preferir tokens a strings soltas
     out: desacelera no fim (transições UI naturais)
     in-out: aceleração e desaceleração simétrica
     spring: leve overshoot, sensação tátil
     fast: timing curto pra micro-interações (hover, focus) */
  --ease-out:    cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast:    .15s;
  --dur-base:    .25s;
  --dur-slow:    .6s;

  /* Type */
  --font:      'DM Sans', system-ui, sans-serif;
  --mono:      'DM Mono', monospace;

  /* Cores semânticas (mesmas nos 2 temas) */
  --green:     #22c55e;
  --red:       #ef4444;
  --yellow:    #f59e0b;
  --purple:    #8b5cf6;
  --orange:    #f97316;

  color-scheme: dark;
}

/* ── Tema escuro (padrão) ──────────────────────────────────── */
:root,
[data-theme="dark"] {
  color-scheme: dark;

  --bg:        #0a0e17;
  --bg-2:      #0f172a;
  --surface:   #131b2e;
  --surface-2: #1c2640;
  --border:    #1f2b42;
  --border-2:  #2d3e55;

  --text:      #f1f5f9;
  --text-2:    #94a3b8;
  --text-3:    #64748b;

  --primary:   #22c55e;   /* verde vibrante como nas referências */
  --primary-h: #16a34a;
  --primary-t: #22c55e22;  /* translúcido para backgrounds */
  --accent:    #06b6d4;

  --shadow-sm: 0 2px 8px rgba(0,0,0,.25);
  --shadow:    0 4px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.45);

  /* Gradientes do tema escuro */
  --gradient-bg: radial-gradient(ellipse at top, #0f1828 0%, #0a0e17 60%);
}

/* ── Tema claro ────────────────────────────────────────────── */
[data-theme="light"] {
  color-scheme: light;

  --bg:        #f6f8fb;
  --bg-2:      #eef1f6;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --border:    #e2e8f0;
  --border-2:  #cbd5e1;

  --text:      #0f172a;
  --text-2:    #475569;
  --text-3:    #94a3b8;

  --primary:   #16a34a;   /* verde mais escuro para contraste com fundo claro */
  --primary-h: #15803d;
  --primary-t: #16a34a18;
  --accent:    #0891b2;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow:    0 4px 12px rgba(15, 23, 42, .08), 0 2px 4px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12), 0 4px 8px rgba(15, 23, 42, .06);

  --gradient-bg: linear-gradient(180deg, #f6f8fb 0%, #eef1f6 100%);
}

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

/* Acessibilidade: respeita preferência do SO por menos movimento.
   Sem isso, usuários com vestibular/foto-sensibilidade pegavam todas
   as animações do app — agora viram quase instantâneas. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--gradient-bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .25s ease;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-h); }
img { max-width: 100%; }
code { font-family: var(--mono); font-size: .875rem; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }

/* ── Layout ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .25s ease;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.4rem 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--text) !important;
  font-weight: 600;
  font-size: 1.05rem;
}
.logo-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}
.logo-text { color: var(--text); }

.sidebar-close {
  display: none;
  background: none; border: none; color: var(--text-2);
  font-size: 1.1rem; cursor: pointer; padding: .25rem;
}

.sidebar-search {
  position: relative;
  margin: .25rem .85rem .15rem;
}
.sidebar-search input {
  width: 100%;
  padding: .5rem .55rem .5rem 2rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .85rem;
  font-family: inherit;
  transition: border-color .15s, background .15s;
}
.sidebar-search input::placeholder { color: var(--text-3); }
.sidebar-search input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}
.sidebar-search-ico {
  position: absolute; left: .65rem; top: 50%; transform: translateY(-50%);
  display: inline-flex; color: var(--text-3); pointer-events: none;
}
.sidebar-search-clear {
  position: absolute; right: .3rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-2);
  width: 22px; height: 22px; border-radius: 50%;
  font-size: 1.1rem; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.sidebar-search-clear:hover { background: var(--surface-2); color: var(--text); }
/* Estado: "sem resultados" — adiciona feedback no fim da lista */
.sidebar-nav .nav-empty {
  display: none;
  padding: .85rem 1.1rem;
  font-size: .78rem;
  color: var(--text-3);
  text-align: center;
}
.sidebar-nav.is-searching .nav-empty.visible { display: block; }
/* Compact mode oculta o campo de busca pra não estourar a largura */
body.sidebar-compact .sidebar-search { display: none; }

.sidebar-nav {
  flex: 1;
  padding: .75rem 0;
  overflow-y: auto;
}

.nav-section {
  padding: 1.15rem 1.1rem .35rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
}
.nav-section:first-of-type { padding-top: .5rem; }

.nav-item {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .65rem .9rem;
  margin: .15rem .55rem;
  color: var(--text-2);
  font-size: .9rem;
  transition: background .15s ease, color .15s ease;
  border: none;
  background: none;
  width: calc(100% - 1.1rem);
  cursor: pointer;
  text-align: left;
  border-radius: 10px;
  position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--primary-t);
  color: var(--primary);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -.55rem; top: 22%; bottom: 22%;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.nav-icon { width: 22px; height: 22px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; opacity: .8; }
.nav-icon svg { display: block; width: 19px; height: 19px; }
.nav-item:hover .nav-icon,
.nav-item.active .nav-icon { opacity: 1; }

/* Avatar do usuário (helpers userAvatarHtml) */
.user-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; object-fit: cover; flex-shrink: 0;
  background: color-mix(in srgb, var(--primary) 18%, transparent);
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  overflow: hidden;
  font-size: .85rem;
}
.user-avatar.user-avatar-fallback { font-size: clamp(.75rem, calc(1em - 4px), 2rem); }
.nav-item .user-avatar { width: 22px; height: 22px; font-size: .7rem; }

/* Badge da marca/banco (Nubank, Itaú, etc.) */
.bank-brand-badge {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
/* Wrapper do SVG real do banco — mantém formato quadrado arredondado */
.bank-brand-img {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,.10);
}
.bank-brand-img img { display:block; width:100%; height:100%; object-fit: contain; }

/* ── Lista de transações em cards (compartilhado entre /transactions e /fatura) ── */
.tx-list { display: flex; flex-direction: column; gap: 1.25rem; margin-bottom: 1.5rem; }

.tx-day-group { display: flex; flex-direction: column; gap: .4rem; }
.tx-day-head {
    display: flex; align-items: baseline; gap: .65rem;
    padding: 0 .25rem .25rem;
    border-bottom: 1px solid var(--border);
}
.tx-day-label { font-size: .85rem; font-weight: 600; color: var(--text); }
.tx-day-date { font-size: .72rem; }
.tx-day-total { margin-left: auto; font-size: .8rem; font-weight: 600; }

.tx-card {
    display: grid;
    grid-template-columns: 44px 1fr auto auto;
    align-items: center;
    gap: .75rem;
    padding: .75rem .85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background .12s, border-color .12s, transform .12s;
}
.tx-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tx-card:hover { background: var(--surface-2); border-color: var(--border-2); }
.tx-card:active { transform: scale(.99); }
.tx-card.tx-status-overdue   { border-left: 3px solid var(--red); }
.tx-card.tx-status-pending   { border-left: 3px solid var(--yellow); }
.tx-card.tx-status-planned   { border-left: 3px solid var(--accent); }
.tx-card.tx-status-cancelled { opacity: .55; }

.tx-card-icon {
    width: 40px; height: 40px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.tx-card-body { min-width: 0; display: flex; flex-direction: column; gap: .2rem; }
.tx-card-meta { display: flex; align-items: center; gap: .35rem; font-size: .72rem; }
.tx-card-account { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.tx-card-desc { font-size: .92rem; font-weight: 500; color: var(--text); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-card-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .15rem; }
.tx-tag-chip {
    display: inline-flex; align-items: center;
    padding: .12rem .5rem; border-radius: 999px;
    font-size: .68rem; font-weight: 500;
    background: var(--bg-2); color: var(--text-2);
    border: 1px solid var(--border);
}

.tx-card-right { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; flex-shrink: 0; }
.tx-card-amount { font-size: .95rem; font-weight: 600; white-space: nowrap; }
.tx-card-amount.positive { color: var(--green); }
.tx-card-amount.negative { color: var(--red); }
.tx-card-status { font-size: .65rem; padding: .12rem .4rem; }

.tx-card-actions {
    display: flex; align-items: center; gap: .15rem; opacity: 0; transition: opacity .15s;
}
.tx-card:hover .tx-card-actions { opacity: 1; }
.tx-card-actions .btn-icon { width: 28px; height: 28px; }

@media (max-width: 720px) {
    .tx-card { grid-template-columns: 40px 1fr auto; row-gap: .35rem; }
    .tx-card-actions {
        grid-column: 1 / -1; opacity: 1;
        justify-content: flex-end; padding-top: .25rem;
        border-top: 1px solid var(--border);
        margin-top: .35rem;
    }
    .tx-card-account { max-width: 140px; }
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: .5rem 0;
}
.nav-logout { color: var(--text-3) !important; }
.nav-logout:hover { color: var(--red) !important; }
.sidebar-version { padding: .25rem 1rem .4rem; font-size: .65rem; color: var(--text-3); letter-spacing: .04em; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 199;
}

/* ── Sidebar compact (desktop only) ─────────────────────────── */
.sidebar-compact-btn {
  display: flex;
  align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--text-3); cursor: pointer;
  padding: .35rem;
  border-radius: 6px;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.sidebar-compact-btn:hover { background: var(--surface-2); color: var(--text); }

body.sidebar-compact { --sidebar-w: 56px; }
body.sidebar-compact .sidebar { overflow: hidden; }
body.sidebar-compact .logo,
body.sidebar-compact .logo-text,
body.sidebar-compact .nav-section,
body.sidebar-compact .sidebar-version { display: none; }
body.sidebar-compact .sidebar-header { justify-content: center; padding: .75rem 0; }
body.sidebar-compact .sidebar-compact-btn {
  width: 36px; height: 36px;
  background: var(--surface-2);
  color: var(--text);
}
body.sidebar-compact .sidebar-compact-btn:hover { background: var(--primary-t); color: var(--primary); }
body.sidebar-compact .nav-item {
  justify-content: center;
  gap: 0;
  padding: .6rem 0;
  width: 40px;
  margin: .1rem auto;
}
body.sidebar-compact .nav-item > span:not(.nav-icon) { display: none; }
body.sidebar-compact .nav-item::before { display: none; }
body.sidebar-compact .nav-item.active {
  border-radius: var(--radius-sm);
}
body.sidebar-compact .sidebar-footer { padding: .35rem 0; justify-content: center; }
body.sidebar-compact .sidebar-footer .nav-item span:not(.nav-icon) { display: none; }

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg-2) 80%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  position: sticky; top: 0; z-index: 50;
  position: sticky; top: 0; z-index: 100;
}

.menu-toggle {
  display: none;
  flex-direction: column; gap: 4px;
  background: none; border: none; cursor: pointer; padding: .25rem;
  flex-shrink: 0;
}
.menu-toggle span {
  display: block; width: 22px; height: 2px;
  background: var(--text-2); border-radius: 2px; transition: .2s;
}

.topbar-center { flex: 1; }
.topbar-title { font-weight: 600; font-size: 1rem; }

.topbar-actions { display: flex; align-items: center; gap: .75rem; }

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1280px;
  width: 100%;
}

/* ── Flash Messages ─────────────────────────────────────────── */
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-base); font-weight: 500;
  animation: slideDown .25s ease;
}
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } }
.flash-success { background: color-mix(in srgb, var(--green) 20%, var(--bg)); color: var(--green); border-bottom: 1px solid color-mix(in srgb, var(--green) 40%, transparent); }
.flash-error   { background: color-mix(in srgb, var(--red) 20%, var(--bg));   color: var(--red);   border-bottom: 1px solid color-mix(in srgb, var(--red) 40%, transparent); }
.flash-warning { background: color-mix(in srgb, var(--yellow) 20%, var(--bg)); color: var(--yellow); border-bottom: 1px solid color-mix(in srgb, var(--yellow) 40%, transparent); }
.flash-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: inherit; opacity: .7; padding: 0 .25rem; }

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.75rem; gap: 1rem; flex-wrap: wrap;
}
.page-header h1 { font-size: 1.65rem; font-weight: 700; letter-spacing: -.01em; display: inline-flex; align-items: center; gap: .65rem; line-height: var(--line-tight); }
.page-header h1 svg { color: var(--primary); flex-shrink: 0; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
@media (max-width: 540px) {
  .page-header h1 { font-size: 1.4rem; }
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.2rem;
  border-radius: var(--radius-lg);
  font-family: var(--font); font-size: var(--text-base); font-weight: 600;
  border: none; cursor: pointer; transition: all .15s ease;
  white-space: nowrap; text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn svg { flex-shrink: 0; }
.btn-primary  { background: var(--primary); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 30%, transparent); }
.btn-primary:hover { background: var(--primary-h); color: #fff; transform: translateY(-1px); box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 40%, transparent); }
.btn-accent   { background: var(--accent); color: #fff; }
.btn-accent:hover { opacity: .9; color: #fff; }
.btn-outline  { background: transparent; color: var(--text); border: 1px solid var(--border-2); }
.btn-outline:hover { background: var(--surface); color: var(--text); }
.btn-ghost    { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-danger-outline { background: transparent; color: var(--red); border: 1px solid var(--red)44; }
.btn-danger-outline:hover { background: var(--red)11; }
.btn-sm  { padding: .38rem .85rem; font-size: var(--text-sm); }
.btn-lg  { padding: .75rem 1.5rem; font-size: var(--text-md); }
.btn-full { width: 100%; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  color: var(--text-2); font-size: 1rem; padding: .3rem .5rem;
  border-radius: 6px; transition: background .15s, color .15s;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon.btn-danger:hover { color: var(--red); background: var(--red)11; }

/* ── Estado de loading ─────────────────────────────────────── */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
  cursor: progress;
}
.btn-loading > * { visibility: hidden; }
.btn-loading::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  top: 50%; left: 50%;
  margin: -9px 0 0 -9px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin .65s linear infinite;
  /* O `color` original do botão (que ficou transparent) é restaurado
     com initial pra a borda do spinner herdar a cor de fundo certa */
  color: initial;
}
.btn-primary.btn-loading::after { color: #fff; }
.btn-accent.btn-loading::after  { color: #fff; }
.btn-outline.btn-loading::after,
.btn-ghost.btn-loading::after   { color: var(--text); }
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ── Cards Summary ──────────────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--pad-card);
  display: flex; align-items: center; gap: var(--space-4);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  min-width: 0;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border-2);
}
.card-body { min-width: 0; flex: 1; }
.card-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 700; flex-shrink: 0;
}
.card-income .card-icon  { background: var(--green)22;  color: var(--green);  }
.card-expense .card-icon { background: var(--red)22;    color: var(--red);    }
.card-invest .card-icon  { background: var(--purple)22; color: var(--purple); }
.card-balance .card-icon { background: var(--accent)22; color: var(--accent); }
.card-label { font-size: var(--text-xs); color: var(--text-2); margin-bottom: .25rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 500; }
.card-value { font-size: var(--text-xl); font-weight: 700; letter-spacing: -.01em; }
.help-tip { display:inline-flex; align-items:center; justify-content:center; width:14px; height:14px; border-radius:50%; background:transparent; color:var(--text-2); border:1px solid var(--text-2); font-size:.62rem; font-weight:700; line-height:1; cursor:default; margin-left:.3rem; vertical-align:middle; position:relative; transition:background .15s,color .15s; flex-shrink:0; }
.help-tip:hover { background:var(--text-2); color:var(--bg); }
.help-tip::after { content:attr(aria-label); display:none; position:absolute; bottom:calc(100% + 8px); left:50%; transform:translateX(-50%); width:230px; background:var(--surface); color:var(--text); font-size:.73rem; font-weight:400; line-height:1.45; padding:.55rem .7rem; border-radius:8px; border:1px solid var(--border); box-shadow:0 6px 18px #0007; z-index:200; white-space:normal; pointer-events:none; }
.help-tip:hover::after { display:block; }

/* ── Section Cards ──────────────────────────────────────────── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--pad-card);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.section-card h3 { font-size: var(--text-md); font-weight: 600; margin-bottom: var(--space-4); display: flex; align-items: center; gap: var(--space-2); }
.section-icon { display: inline-flex; align-items: center; color: var(--primary); }
.section-icon svg { display: block; }
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.section-header h3 { margin-bottom: 0; }
.highlight-card { border-color: var(--green)44; background: var(--green)08; }

.link-sm { font-size: .8rem; color: var(--text-2); }
.link-sm:hover { color: var(--primary); }

/* ── Dashboard Grid ─────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
.col-span-2 { grid-column: span 2; }

/* ── Daily Banner ───────────────────────────────────────────── */
.daily-banner {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--primary) 18%, var(--surface)) 0%,
    var(--surface) 100%);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border));
  border-radius: var(--radius-lg);
  padding: var(--pad-card-lg);
  margin-bottom: var(--space-6);
}
.daily-banner-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.daily-label { font-size: var(--text-sm); color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
.daily-amount { font-size: 2rem; font-weight: 700; color: var(--green); line-height: var(--line-tight); }
.daily-sub { font-size: var(--text-sm); color: var(--text-2); margin-top: .2rem; }
.daily-source { font-size: var(--text-xs); color: var(--text-2); margin-top: .15rem; opacity: .8; }

/* ── Topbar icon buttons (olho / tema) ───────────────────────────────── */
.topbar-icon-btn {
    width: 38px; height: 38px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-2);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all .15s ease;
}
.topbar-icon-btn:hover { background: var(--surface-2); border-color: var(--primary); color: var(--primary); }
.topbar-icon-btn svg { display: block; }


/* Alterna olho aberto/fechado */
.topbar-icon-btn .eye-icon-closed { display: none; }
body.values-hidden .topbar-icon-btn .eye-icon-open { display: none; }
body.values-hidden .topbar-icon-btn .eye-icon-closed { display: block; }

/* Classes de valor monetário que serão ocultadas */
body.values-hidden .card-value,
body.values-hidden .card-sub,
body.values-hidden .daily-amount,
body.values-hidden .daily-sub,
body.values-hidden .tx-amount,
body.values-hidden .tx-card-amount,
body.values-hidden .tx-day-total,
body.values-hidden .account-balance,
body.values-hidden .account-balance-lg,
body.values-hidden .dream-stat-value,
body.values-hidden .summary-item strong,
body.values-hidden .summary-item .muted,
body.values-hidden .fatura-value,
body.values-hidden .credit-card-amount,
body.values-hidden .cat-bar-value,
body.values-hidden .progress-label,
body.values-hidden .progress-circle-label,
body.values-hidden .category-bars strong,
body.values-hidden .dream-progress-labels span,
body.values-hidden .dream-hero-meta strong,
body.values-hidden .dream-hero-meta span,
body.values-hidden .section-card .muted strong,
body.values-hidden .section-header .muted strong,
body.values-hidden .invest-summary span,
body.values-hidden .invest-summary strong,
body.values-hidden .pending-value,
body.values-hidden .data-table td.text-right,
body.values-hidden .data-table td.negative,
body.values-hidden .data-table td.positive,
body.values-hidden .total-row td,
body.values-hidden .bsc-sum,
body.values-hidden .items-total-row strong,
body.values-hidden .item-price,
body.values-hidden .donut-total strong,
/* Tela de Contas */
body.values-hidden .acct-total-value,
/* Dívidas */
body.values-hidden .debt-value,
/* Investimentos */
body.values-hidden .invest-account-balance,
body.values-hidden .aporte-account-balance,
/* Card Comprometido (próximo mês) */
body.values-hidden .nm-stat-value,
body.values-hidden .nm-top-amount,
/* Relatórios — gráficos e listas */
body.values-hidden .cat-bar-row strong,
body.values-hidden .legend-val,
body.values-hidden .breakdown-line strong,
body.values-hidden .expense-item-amount,
body.values-hidden .expense-group-head strong,
body.values-hidden .budget-row-head strong,
body.values-hidden .budget-row-remain,
body.values-hidden .budget-total-row strong,
body.values-hidden .budget-total-row .muted,
body.values-hidden .item-tx-link,
/* Recorrências */
body.values-hidden .rec-amount,
/* Cartões de crédito (lista + cards individuais) */
body.values-hidden .cc-summary-value,
body.values-hidden .cc-metric-value,
body.values-hidden .cc-invoices-sum,
body.values-hidden .cc-invoice-amount,
body.values-hidden .cc-fatura-amount,
/* Fatura — totalizador final */
body.values-hidden .fatura-grand-total strong,
body.values-hidden [data-private] {
    filter: blur(7px);
    transition: filter .15s;
    user-select: none;
    cursor: default;
}
/* Ao passar o mouse sobre um valor ocultado, revela temporariamente */
body.values-hidden .card-value:hover,
body.values-hidden .daily-amount:hover,
body.values-hidden .tx-card-amount:hover,
body.values-hidden .tx-day-total:hover,
body.values-hidden .account-balance:hover,
body.values-hidden .account-balance-lg:hover,
body.values-hidden .fatura-value:hover,
body.values-hidden .credit-card-amount:hover,
body.values-hidden .acct-total-value:hover,
body.values-hidden .debt-value:hover,
body.values-hidden .invest-account-balance:hover,
body.values-hidden .aporte-account-balance:hover,
body.values-hidden .rec-amount:hover,
body.values-hidden .cc-summary-value:hover,
body.values-hidden .cc-metric-value:hover,
body.values-hidden .cc-invoices-sum:hover,
body.values-hidden .cc-invoice-amount:hover,
body.values-hidden .cc-fatura-amount:hover,
body.values-hidden .fatura-grand-total strong:hover,
body.values-hidden [data-private]:hover {
    filter: blur(0);
    transition-delay: .3s;
}

/* ── Offline queue — toast e badge ─────────────────────────────────────── */
.offline-toast {
    position: fixed;
    bottom: 5.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    border-radius: 12px;
    padding: .75rem 1.1rem;
    font-size: .9rem;
    font-weight: 600;
    z-index: 9999;
    opacity: 0;
    transition: opacity .2s, transform .2s;
    white-space: normal;
    max-width: min(360px, calc(100vw - 2rem));
    text-align: center;
    box-shadow: 0 6px 24px rgba(0,0,0,.5);
    pointer-events: none;
    line-height: 1.4;
}
.offline-toast--visible   { opacity: 1; transform: translateX(-50%) translateY(0); }
.offline-toast--success   { background: #166534; color: #bbf7d0; border: 1px solid color-mix(in srgb, var(--green) 40%, transparent); }
.offline-toast--info      { background: #1e3a5f; color: #bfdbfe; border: 1px solid color-mix(in srgb, #3b82f6 40%, transparent); }
.offline-toast--warning   { background: #78350f; color: #fde68a; border: 1px solid color-mix(in srgb, var(--yellow) 40%, transparent); }
.offline-toast--error     { background: #7f1d1d; color: #fecaca; border: 1px solid color-mix(in srgb, var(--red) 40%, transparent); }

/* Badge vermelho no FAB com contagem de pendentes */
.offline-pending-badge {
    position: absolute;
    top: -4px; right: -4px;
    background: var(--red);
    color: #fff;
    font-size: .6rem;
    font-weight: 700;
    min-width: 17px;
    height: 17px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    border: 2px solid var(--bg);
    line-height: 1;
    pointer-events: none;
}

/* PWA install card (dentro do perfil) */
.pwa-install-card { display: none; }
.pwa-install-card.is-available { display: flex; }
.pwa-install-card.is-installed .pwa-install-primary { display: none; }

/* ── Page help (botão ? + painel) ──────────────────────────────────────── */
.page-help { margin: 0 0 1rem; }
.page-help-btn { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .7rem; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; color: var(--text-2); font-size: .78rem; cursor: pointer; transition: all .15s; }
.page-help-btn:hover { background: var(--bg); color: var(--text); border-color: var(--primary); }
.page-help-btn[aria-expanded="true"] { background: var(--primary); color: white; border-color: var(--primary); }
.phb-icon { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; color: currentColor; }
.phb-icon svg { display: block; width: 18px; height: 18px; }
.page-help-panel { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: var(--radius); padding: 1rem 1.25rem; margin-top: .5rem; font-size: .85rem; line-height: 1.55; animation: phpSlide .2s ease-out; }
.page-help-panel.hidden { display: none; }
.page-help-panel h4 { margin: .75rem 0 .35rem; font-size: .88rem; color: var(--text); }
.page-help-panel h4:first-child { margin-top: 0; }
.page-help-panel p { margin: .35rem 0; color: var(--text-2); }
.page-help-panel ul, .page-help-panel ol { margin: .35rem 0 .6rem; padding-left: 1.3rem; color: var(--text-2); }
.page-help-panel li { margin: .15rem 0; }
.page-help-panel strong { color: var(--text); }
.page-help-panel code { background: var(--bg); padding: .1rem .35rem; border-radius: 3px; font-size: .76rem; }
.page-help-panel a { color: var(--accent); }
@keyframes phpSlide { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.daily-source a { color: var(--accent); text-decoration: none; }
.daily-source a:hover { text-decoration: underline; }

/* ── Transactions ───────────────────────────────────────────── */
.transactions-list { display: flex; flex-direction: column; gap: .25rem; }
.tx-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .5rem; border-radius: 8px;
  transition: background .15s; color: var(--text);
}
.tx-row:hover { background: var(--surface-2); }
.tx-cat {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.tx-info { flex: 1; min-width: 0; }
.tx-desc { display: block; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { display: block; font-size: .75rem; color: var(--text-2); }
.tx-amount {
  font-size: .9rem; font-weight: 600; white-space: nowrap;
  /* Coluna fixa à direita: text-align left + flex 0 0 garante que TODOS
     os valores começam no mesmo x, independente de prefix +/- ou de quantos
     dígitos tem (ex: "+R$ 2.837,66" alinha com "-R$ 80,00"). */
  text-align: left;
  flex: 0 0 130px;
}
.tx-desc-cell { display: flex; align-items: center; gap: .4rem; }

/* ── Category Bars ──────────────────────────────────────────── */
.category-bars { display: flex; flex-direction: column; gap: .75rem; }
.cat-bar-row { display: flex; align-items: center; gap: .75rem; }
.cat-bar-label {
    display: grid;
    grid-template-columns: 120px 90px;  /* nome fixo à esquerda, valor fixo à direita */
    column-gap: .5rem;
    align-items: center;
    font-size: .8rem;
    overflow: hidden; /* impede blur de vazar para a barra */
}
.cat-bar-name {
    display: inline-flex; align-items: center; gap: .4rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    min-width: 0;
}
.cat-bar-label .cat-bar-value {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-align: left;    /* valores alinhados à esquerda, todos começam no mesmo X */
}
.cat-bar-ico { display: inline-flex; align-items: center; color: var(--text-2); }
.cat-bar-ico svg { display: block; }
.cat-pill { display: inline-flex; align-items: center; gap: .3rem; }
.cat-pill svg { display: block; }
.cat-list-ico { display: inline-flex; align-items: center; vertical-align: middle; }
.cat-list-ico svg { display: block; }
.cat-bar-value { font-weight: 500; color: var(--text-2); }
.cat-bar-track { flex: 1; height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.cat-bar-fill  { height: 100%; border-radius: 4px; transition: width var(--dur-slow) var(--ease-out); }
.cat-bar-pct   { font-size: .75rem; color: var(--text-3); width: 32px; text-align: right; }

/* ── Accounts ───────────────────────────────────────────────── */
.accounts-list { display: flex; flex-direction: column; gap: .5rem; }
.account-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem; border-radius: 8px;
}
.account-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.account-dot-lg { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
.account-brand { display: inline-flex; flex-shrink: 0; }
.account-brand .bank-brand-img,
.account-brand .bank-brand-badge { box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.account-info { flex: 1; }
.account-name { display: block; font-size: .875rem; font-weight: 500; }
.account-type { font-size: .75rem; color: var(--text-2); }
.account-balance { font-weight: 600; font-size: .95rem; }
.account-balance-lg { font-size: 1.8rem; font-weight: 700; margin: 1rem 0 .25rem; }
.account-meta { font-size: .78rem; color: var(--text-2); margin-bottom: .75rem; }
.account-card-header { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: .5rem; }
.account-actions { display: flex; gap: .5rem; margin-top: .75rem; }
.account-card { display: flex; flex-direction: column; }

/* ── Dreams ─────────────────────────────────────────────────── */
.dreams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.dream-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex; flex-direction: column; gap: .75rem;
}
.dream-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.dream-card-header h3 { font-size: 1rem; font-weight: 600; }
.dream-description { font-size: .83rem; color: var(--text-2); line-height: 1.4; }
.dream-progress-section { display: flex; flex-direction: column; gap: .4rem; }
.dream-progress-labels { display: flex; justify-content: space-between; font-size: .75rem; color: var(--text-2); }
.dream-meta { display: flex; flex-wrap: wrap; gap: .75rem; font-size: .78rem; color: var(--text-2); align-items: center; }
.meta-with-ico { display: inline-flex; align-items: center; gap: .35rem; }
.meta-with-ico svg { color: var(--text-2); flex-shrink: 0; }
.dream-actions { display: flex; gap: .5rem; margin-top: auto; }
.dream-priority { font-size: .75rem; color: var(--text-3); }

/* Dream detail */
.dream-hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1rem;
}
.dream-hero-stats { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.dream-stat { text-align: center; }
.dream-stat-value { font-size: 1.4rem; font-weight: 700; }
.dream-stat-label { font-size: .75rem; color: var(--text-2); }
.dream-stat-center { flex: 1; display: flex; justify-content: center; }
.dream-hero-meta { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; font-size: .83rem; color: var(--text-2); }
.dream-desc-text { font-size: .9rem; color: var(--text-2); margin-top: .75rem; line-height: 1.5; }

/* Progress Circle */
.progress-circle { position: relative; width: 80px; height: 80px; }
.progress-circle svg { width: 100%; height: 100%; }
.progress-circle-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; font-weight: 700;
}

/* ── Progress Bars ──────────────────────────────────────────── */
.progress-track {
  height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden;
}
.progress-track.large { height: 12px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 4px; transition: width var(--dur-slow) var(--ease-out); }
.progress-label { font-size: .78rem; color: var(--text-2); }
.mini-progress { height: 5px; width: 80px; background: var(--surface-2); border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: .4rem; }
.mini-fill { height: 100%; border-radius: 3px; }

/* ── Investments ────────────────────────────────────────────── */
.invest-summary { display: flex; flex-direction: column; gap: .5rem; }
.invest-row { display: flex; justify-content: space-between; align-items: center; padding: .4rem 0; font-size: .875rem; border-bottom: 1px solid var(--border); }
.invest-row:last-child { border-bottom: none; font-weight: 600; }

/* ── Recommendations ────────────────────────────────────────── */
.recs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.rec-card {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 1rem;
  border-left: 3px solid var(--primary);
  display: flex; flex-direction: column; gap: .5rem;
}
.rec-card.rec-alert  { border-left-color: var(--red); }
.rec-card.rec-investment { border-left-color: var(--purple); }
.rec-card.rec-saving { border-left-color: var(--green); }
.rec-card.rec-dream  { border-left-color: var(--yellow); }
.rec-title { font-size: .875rem; font-weight: 600; }
.rec-desc  { font-size: .8rem; color: var(--text-2); line-height: 1.45; }
.rec-action { font-size: .78rem; color: var(--primary); font-weight: 500; align-self: flex-start; }

/* ── Pending List ───────────────────────────────────────────── */
.pending-list { display: flex; flex-direction: column; gap: .5rem; }
.pending-item { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--border); font-size: .875rem; }
.pending-info { display: flex; align-items: center; gap: .5rem; min-width: 0; flex: 1; }
.pending-text { display: flex; flex-direction: column; gap: .15rem; min-width: 0; flex: 1; }
.pending-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-meta { font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-value {
    white-space: nowrap;
    font-weight: 600;
    /* Coluna fixa à direita — valores começam todos no mesmo x (alinhados à esquerda dentro da coluna) */
    text-align: left;
    flex: 0 0 120px;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1rem;
}
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
  text-align: left; padding: .75rem 1rem;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-size: .75rem; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap;
}
.data-table td { padding: .7rem 1rem; border-bottom: 1px solid var(--border)55; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface-2); }
.row-overdue td { background: var(--red)08; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.action-btns { display: flex; justify-content: center; gap: .25rem; }
.date-cell { white-space: nowrap; color: var(--text-2); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .55rem;
  border-radius: 20px; font-size: .7rem; font-weight: 600;
}
.badge-paid      { background: var(--green)22;  color: var(--green); }
.badge-pending   { background: var(--yellow)22; color: var(--yellow); }
.badge-planned   { background: var(--accent)22; color: var(--accent); }
.badge-overdue   { background: var(--red)22;    color: var(--red); }
.badge-cancelled { background: var(--text-3)22; color: var(--text-3); }
.badge-muted     { background: var(--surface-2); color: var(--text-2); }
.badge-green     { background: var(--green)22;  color: var(--green); }
.badge-red       { background: var(--red)22;    color: var(--red); }
.badge-small     { font-size: .65rem; padding: .1rem .4rem; border-radius: 4px; background: var(--surface-2); color: var(--text-2); }

/* ── Chart loading skeleton ──────────────────────────────────────────── */
/* Aplicado pelo JS em qualquer wrapper que tenha um <canvas> dentro
   enquanto o Chart.js não termina de renderizar. */
.chart-loading { position: relative; }
.chart-loading::after {
    content: '';
    position: absolute; inset: 0;
    border-radius: 8px;
    background:
        linear-gradient(90deg,
            color-mix(in srgb, var(--surface) 0%, transparent) 0%,
            color-mix(in srgb, var(--text-2) 12%, transparent) 50%,
            color-mix(in srgb, var(--surface) 0%, transparent) 100%
        ),
        var(--surface);
    background-size: 200% 100%;
    animation: chart-shimmer 1.4s ease-in-out infinite;
    pointer-events: none;
    z-index: 1;
}
.chart-loading canvas { opacity: 0; transition: opacity .35s ease; }
.chart-loading.chart-ready::after { opacity: 0; transition: opacity .3s ease; pointer-events: none; }
.chart-loading.chart-ready canvas { opacity: 1; }
@keyframes chart-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.cat-pill { display: inline-flex; align-items: center; gap: .25rem; padding: .2rem .55rem; border-radius: 20px; font-size: .75rem; }

/* ── Summary Bar ────────────────────────────────────────────── */
.summary-bar {
  display: flex; flex-wrap: wrap; gap: .75rem 1.5rem;
  padding: .75rem 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 1rem;
  font-size: .83rem;
}
.summary-item { display: flex; align-items: center; gap: .4rem; }
.summary-item.danger { color: var(--red); }
.summary-item.muted  { color: var(--text-2); }

/* ── Filters ────────────────────────────────────────────────── */
.filters-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: .875rem 1rem;
  margin-bottom: 1rem;
}
.filters-form { width: 100%; }
.filter-row {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end;
}
.field-search { flex: 1; min-width: 140px; }
.field-search input { width: 100%; }

/* Atalhos de período (filtros de data) */
.date-presets {
  display: flex; flex-wrap: wrap; gap: .35rem;
  margin: 0 0 .65rem;
}
.dp-btn {
  background: var(--bg);
  border: 1px solid var(--border-2);
  color: var(--text-2);
  padding: .35rem .7rem;
  border-radius: 999px;
  font-size: .75rem; font-weight: 500;
  cursor: pointer;
  transition: all .12s ease;
  white-space: nowrap;
}
.dp-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--surface);
}
.dp-btn.active {
  background: var(--primary)18;
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.form-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1.1rem; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.form-grid-profile { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
@media (max-width: 640px) {
  .form-grid-2,
  .form-grid-3,
  .form-grid-profile { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3 { grid-column: 1; }
}

.field { display: flex; flex-direction: column; gap: .45rem; }
.field label { font-size: .8rem; font-weight: 500; color: var(--text-2); }
.field-hint { font-size: .72rem; color: var(--text-3); }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="file"],
select, textarea {
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font); font-size: .875rem;
  padding: .65rem .85rem;
  transition: border .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary)22;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 70px; }
input[type="color"] { padding: .25rem; height: 40px; cursor: pointer; }
input[type="file"] { cursor: pointer; }

.input-sm { padding: .45rem .7rem; font-size: .82rem; }

.field-inline { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field-inline label { font-size: .75rem; color: var(--text-2); white-space: nowrap; }

.input-prefix-wrap { position: relative; display: flex; align-items: center; }
.input-prefix {
  position: absolute; left: .75rem;
  color: var(--text-2); font-size: .85rem; font-weight: 500;
  pointer-events: none; user-select: none;
}
.with-prefix { padding-left: 2.5rem !important; }

.form-row-inline { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.form-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

.section-divider {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem; margin-top: 1.25rem; margin-bottom: 1rem;
}
.section-divider h3 { font-size: .9rem; font-weight: 600; color: var(--text-2); }
.toggle-label { display: flex; align-items: center; gap: .6rem; cursor: pointer; font-size: .875rem; font-weight: 500; }
.toggle-label input { width: auto; accent-color: var(--primary); }

.collapsible-section { display: none; padding: 1rem; background: var(--surface-2); border-radius: 8px; margin-bottom: 1rem; }
.collapsible-section.open { display: block; }

/* Checkbox grid */
.checkbox-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.checkbox-item { display: flex; align-items: center; gap: .4rem; cursor: pointer; font-size: .875rem; padding: .45rem .75rem; background: var(--surface-2); border-radius: 8px; border: 1px solid var(--border); }
.checkbox-item:hover { border-color: var(--primary); }
.checkbox-item input { accent-color: var(--primary); }

/* Budget items */
.budget-item-row { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; flex-wrap: wrap; }

/* ── Quick Launch ────────────────────────────────────────────── */
.quick-container { max-width: 520px; margin: 0 auto; padding-bottom: 2rem; }
.quick-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.75rem;
}
.quick-title { font-size: 1.3rem; font-weight: 600; margin-bottom: 1.5rem; }

.type-toggle { display: flex; gap: .5rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.type-opt {
  flex: 1; min-width: 90px;
  display: flex; align-items: center; justify-content: center;
  padding: .6rem .75rem;
  border: 1.5px solid var(--border-2); border-radius: 8px;
  cursor: pointer; font-size: .83rem; font-weight: 500;
  transition: border-color .15s, background .15s;
  white-space: nowrap; gap: .3rem;
}
.type-opt input { display: none; }
.type-opt:hover { border-color: var(--border); background: var(--surface-2); }
.type-opt.selected, .expense-opt.selected  { border-color: var(--red);    background: var(--red)11;    color: var(--red); }
.income-opt.selected  { border-color: var(--green);  background: var(--green)11;  color: var(--green); }
.invest-opt.selected  { border-color: var(--purple); background: var(--purple)11; color: var(--purple); }
.transfer-opt.selected{ border-color: var(--accent); background: var(--accent)11; color: var(--accent); }

.amount-field {
  display: flex; align-items: center;
  background: var(--bg); border: 2px solid var(--border-2);
  border-radius: 10px; margin-bottom: 1rem;
  transition: border-color .15s;
}
.amount-field:focus-within { border-color: var(--primary); }
.currency-prefix { padding: 0 .75rem; color: var(--text-2); font-size: 1.1rem; font-weight: 600; }
.amount-input {
  flex: 1; background: none; border: none !important; box-shadow: none !important;
  font-size: 2rem !important; font-weight: 700 !important; padding: .75rem .5rem !important;
  color: var(--text); text-align: right;
}
.amount-input:focus { outline: none; border: none; box-shadow: none; }
.desc-input { font-size: 1rem; padding: .75rem !important; }

.quick-cats { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.quick-cat-btn {
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  padding: .5rem .65rem; border: 1.5px solid var(--border);
  border-radius: 10px; background: none; cursor: pointer; color: var(--text-2);
  font-size: .72rem; min-width: 58px; transition: border-color .15s, background .15s;
  font-family: var(--font);
}
.quick-cat-btn span:first-child { font-size: 1.2rem; }
.quick-cat-btn:hover { border-color: var(--border-2); background: var(--surface-2); color: var(--text); }
.quick-cat-btn.active { border-color: var(--cat-color, var(--primary)); background: var(--cat-color, var(--primary))22; color: var(--cat-color, var(--primary)); }

.cat-suggestion {
  margin-top: .4rem; padding: .4rem .75rem;
  background: var(--surface-2); border-radius: 6px;
  font-size: .8rem; color: var(--primary); cursor: pointer;
}
.cat-suggestion:hover { background: var(--primary)22; }

.all-cats-panel {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: .75rem; margin-bottom: 1rem;
}
.cat-search { margin-bottom: .5rem; }
.all-cats-list { display: flex; flex-direction: column; gap: .25rem; max-height: 200px; overflow-y: auto; }
.cat-list-btn {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .75rem;
  background: none; border: none; border-left: 3px solid transparent;
  color: var(--text-2); font-family: var(--font); font-size: .83rem;
  cursor: pointer; text-align: left; border-radius: 0 6px 6px 0;
  transition: background .1s, color .1s;
}
.cat-list-btn:hover { background: var(--surface); color: var(--text); }

.quick-details-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.quick-details-row .field-inline { flex: 1; min-width: 140px; }

.extra-opts { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.extra-opt-btn {
  padding: .4rem .85rem; border-radius: 8px;
  border: 1px solid var(--border); background: none;
  color: var(--text-2); font-size: .8rem; cursor: pointer;
  font-family: var(--font); transition: background .15s, color .15s; text-decoration: none;
  display: inline-flex; align-items: center; gap: .3rem;
}
.extra-opt-btn:hover, .extra-opt-btn.active { background: var(--primary)11; border-color: var(--primary); color: var(--primary); }
.extra-panel {
  background: var(--surface-2); border-radius: 8px; padding: 1rem;
  margin-bottom: 1rem; border: 1px solid var(--border);
}
.field-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.field-row .field-inline { flex: 1; }

/* ── Categories Grid ────────────────────────────────────────── */
.categories-grid { display: flex; flex-direction: column; gap: .5rem; }
.cat-item-card {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .75rem; background: var(--surface-2);
  border-radius: 8px;
}
.cat-item-card.cat-child { margin-left: 2rem; opacity: .9; }
.cat-icon-lg {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.cat-info { flex: 1; }
.cat-name { font-size: .875rem; font-weight: 500; }
.cat-actions { display: flex; gap: .25rem; }

/* ── Danger Zone ────────────────────────────────────────────── */
.danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination { display: flex; gap: .35rem; padding: 1rem 1rem; justify-content: center; flex-wrap: wrap; }
.page-btn {
  min-width: 36px; height: 36px; padding: 0 .65rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; font-size: .85rem; font-weight: 500;
  background: var(--surface); color: var(--text-2);
  border: 1px solid var(--border);
  transition: background .15s, border-color .15s, color .15s;
  text-decoration: none;
}
.page-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-2); }
.page-btn.active {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 30%, transparent);
}

/* ── Inline form ────────────────────────────────────────────── */
.inline-form .form-row-inline { align-items: flex-end; }

/* ── Chart ──────────────────────────────────────────────────── */
.chart-wrap { position: relative; width: 100%; }
.chart-donut { max-width: 260px; margin: 0 auto; }
.chart-legend { display: flex; flex-direction: column; gap: .4rem; margin-top: 1rem; }
.legend-item { display: flex; align-items: center; gap: .5rem; font-size: .8rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-val { margin-left: auto; font-weight: 500; color: var(--text-2); }

/* ── Auth ───────────────────────────────────────────────────── */
.auth-body { background: radial-gradient(ellipse at top, #1e1b4b 0%, var(--bg) 60%); }
.auth-container {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 2rem 1rem;
}
.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-brand .logo-icon { width: 72px; height: 72px; border-radius: 16px; margin: 0 auto .75rem; display: block; }
.auth-brand h1 { font-size: 1.6rem; font-weight: 700; }
.auth-brand p  { color: var(--text-2); font-size: .9rem; }
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2rem;
}
.auth-card h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: .25rem; }
.auth-sub { color: var(--text-2); font-size: .875rem; margin-bottom: 1.5rem; }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: .875rem; color: var(--text-2); }
.auth-demo { text-align: center; margin-top: .5rem; }
.auth-demo code { background: var(--surface-2); padding: .1rem .4rem; border-radius: 4px; }

/* ── Skeleton loader — placeholder enquanto conteúdo carrega
   Use:
   <div class="skeleton skeleton-text"></div>
   <div class="skeleton skeleton-card"></div>
   <div class="skeleton skeleton-circle"></div>
   ───────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg,
    var(--surface-2) 0%,
    color-mix(in srgb, var(--surface-2) 70%, var(--border-2)) 50%,
    var(--surface-2) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: skeleton-shimmer 1.4s var(--ease-in-out) infinite;
  pointer-events: none;
  user-select: none;
  color: transparent;
}
.skeleton-text   { height: .9em; width: 100%; }
.skeleton-text--sm { height: .7em; width: 60%; }
.skeleton-title  { height: 1.2em; width: 70%; }
.skeleton-circle { border-radius: 50%; }
.skeleton-card   { height: 80px; border-radius: var(--radius); margin-bottom: var(--space-3); }
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Nav progress bar (NProgress-style) ────────────────────── */
/* Aparece no topo da página quando o usuário clica num link interno.
   Some sozinho quando a próxima página carrega (porque o body é
   substituído inteiro). Não precisa de JS de "loading complete". */
.nav-progress {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 3px;
  background: transparent;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
}
.nav-progress.active { opacity: 1; }
.nav-progress::after {
  content: '';
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  box-shadow: 0 0 8px color-mix(in srgb, var(--primary) 60%, transparent);
  transition: width .25s var(--ease-out);
}
/* Estágios pré-definidos: como não dá pra medir progresso real de
   uma navegação clássica de HTML, a barra avança em saltos crescentes
   até 90%, segurando enquanto espera resposta. */
.nav-progress.active::after        { width: 30%; }
.nav-progress.active.step-2::after { width: 60%; }
.nav-progress.active.step-3::after { width: 85%; }
.nav-progress.active.done::after   { width: 100%; transition: width .15s var(--ease-out); }

/* ── FAB ────────────────────────────────────────────────────── */
.fab {
  display: none;
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 1.8rem; line-height: 1; font-weight: 300;
  align-items: center; justify-content: center;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 50%, transparent),
              0 2px 8px color-mix(in srgb, var(--primary) 30%, transparent);
  z-index: 300; transition: all .2s ease;
  text-decoration: none;
}
/* Esconde FAB em telas com input/chat próprio pra não sobrepor */
body:has(.ai-chat-card) .fab,
body:has(#chatForm) .fab,
body:has(#payFaturaForm) .fab { display: none !important; }
.fab:hover { transform: scale(1.08); color: #fff; }

/* ── Utility ────────────────────────────────────────────────── */
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.muted    { color: var(--text-2); }
.small    { font-size: var(--text-sm); }
.hidden   { display: none !important; }
.empty-state { color: var(--text-3); font-size: var(--text-base); text-align: center; padding: var(--space-6) 0; }
.empty-state-card {
  display: flex; flex-direction: column; align-items: center; gap: .55rem;
  text-align: center;
  padding: 2rem 1.25rem;
  color: var(--text-2);
}
.empty-state-card .empty-state-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 999px;
  background: var(--primary-t); color: var(--primary);
  margin-bottom: .15rem;
}
.empty-state-card p { font-size: .95rem; color: var(--text); }
.empty-state-card .muted { font-size: .82rem; max-width: 320px; line-height: 1.4; }
.empty-state-card .btn { margin-top: .5rem; }
.empty-state-lg {
  text-align: center; padding: 4rem 2rem;
  display: flex; flex-direction: column; align-items: center; gap: .75rem;
}
.empty-state-lg .empty-icon { font-size: 3rem; opacity: .4; display: inline-flex; align-items: center; justify-content: center; }
.empty-state-lg .empty-icon svg { color: var(--text-2); }
.empty-state-lg h3 { font-size: 1.15rem; }
.empty-state-lg p  { color: var(--text-2); }

/* ── Fatura nav (shared with category plan) ─────────────────── */
.fatura-nav { display:flex; gap:.4rem; overflow-x:auto; padding-bottom:.5rem; flex-wrap:wrap; }
.fatura-month-btn { padding:.35rem .85rem; border-radius:20px; font-size:.8rem; background:var(--surface); border:1px solid var(--border); color:var(--text-2); white-space:nowrap; transition:border-color .15s,color .15s; }
.fatura-month-btn:hover { border-color:var(--primary); color:var(--primary); }
.fatura-month-btn.active { background:var(--primary); border-color:var(--primary); color:#fff; font-weight:600; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .col-span-2 { grid-column: span 1; }
  .cat-report-layout { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .sidebar-overlay.visible { display: block; }
  .sidebar-compact-btn { display: none; }

  /* compact mode não se aplica no mobile */
  body.sidebar-compact { --sidebar-w: 260px; }
  body.sidebar-compact .sidebar { overflow-y: auto; }
  body.sidebar-compact .logo,
  body.sidebar-compact .logo-text,
  body.sidebar-compact .nav-section,
  body.sidebar-compact .sidebar-version { display: revert; }
  body.sidebar-compact .logo { display: flex; }
  body.sidebar-compact .sidebar-header { justify-content: space-between; padding: 1.25rem 1rem; }
  body.sidebar-compact .nav-item { justify-content: flex-start; gap: .75rem; padding: .55rem .85rem; margin: .15rem .5rem; width: calc(100% - 1rem); }
  body.sidebar-compact .nav-item > span:not(.nav-icon) { display: inline; }
  body.sidebar-compact .nav-item::before { display: block; }

  .main-wrapper { margin-left: 0; }
  .menu-toggle { display: flex; }
  .quick-btn { display: none; }
  .fab { display: flex; }

  /* Topbar mobile: título trunca, não quebra */
  .topbar { padding: .5rem .85rem; gap: .5rem; }
  .topbar-center { min-width: 0; flex: 1; }
  .topbar-title { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
  .topbar-actions { flex-shrink: 0; }
  .topbar-icon-btn { width: 32px; height: 32px; }

  .main-content { padding: .85rem; }
  .cards-grid { grid-template-columns: 1fr 1fr; gap: .65rem; }
  .card { padding: .85rem; }
  .card-value { font-size: 1.1rem; }
  .card-icon { width: 34px; height: 34px; font-size: 1rem; }

  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3 { grid-column: span 1; }
  .form-grid-profile { grid-template-columns: 1fr; }
  .form-card { padding: 1rem; }

  .daily-banner-inner { flex-direction: column; align-items: flex-start; }
  .daily-banner { padding: 1rem; }
  .daily-amount { font-size: 1.8rem; }

  .recs-grid { grid-template-columns: 1fr; }
  .dreams-grid { grid-template-columns: 1fr !important; }
  .shopping-grid { grid-template-columns: 1fr !important; }
  .credit-cards-grid { grid-template-columns: 1fr 1fr !important; }
  .quick-actions-grid { grid-template-columns: 1fr !important; }

  .dream-hero-stats { gap: .5rem; }
  .dream-stat-value { font-size: 1rem; }
  .cat-bar-label { min-width: 0; flex: 1; font-size: .75rem; grid-template-columns: minmax(0, 1fr) 72px; }
  .cat-bar-row { gap: .5rem; }

  .filter-row { flex-direction: column; align-items: stretch; }
  .filter-row .field-inline { width: 100%; }
  .filter-row .field-inline input, .filter-row .field-inline select { width: 100%; }

  .summary-bar { flex-direction: column; gap: .5rem; align-items: stretch; }

  .page-header { flex-direction: column; align-items: stretch; gap: .75rem; }
  .page-header h1 { display: none; } /* título mobile já aparece no topbar */
  .page-actions { flex-wrap: wrap; }

  .quick-title { font-size: 1.1rem; }
  .amount-input { font-size: 1.6rem !important; }

  /* Tabelas — força scroll horizontal e reduz padding */
  .table-card { overflow: hidden; }
  .data-table { font-size: .8rem; }
  .data-table th, .data-table td { padding: .5rem .55rem; }
  .data-table .badge { font-size: .65rem; padding: .1rem .35rem; }

  .form-row-inline { flex-direction: column; }
  .form-row-inline .field-inline { width: 100%; }
  .budget-item-row { flex-direction: column; align-items: stretch; }
  .budget-item-row > * { width: 100% !important; }

  /* Modais — aproveitam tela toda */
  .modal-overlay { padding: .5rem; align-items: flex-end; }
  .modal-box { max-width: 100% !important; max-height: 95vh; }

  /* Tx rows no dashboard */
  .tx-row { padding: .6rem .5rem; gap: .5rem; }
  .tx-desc { font-size: .85rem; }
  .tx-meta { font-size: .7rem; }

  /* AI chat */
  .ai-chat-messages { max-height: 50vh; padding: .75rem; }
  .ai-msg-body { max-width: 95% !important; font-size: .85rem; padding: .55rem .7rem; }
  .ai-chat-input { padding: .6rem; gap: .35rem; }
  .ai-chat-input textarea { font-size: .9rem; }

  /* Monthly report expense rows */
  .expense-item-row { grid-template-columns: 1fr auto; }
  .expense-item-meta { grid-column: 1/3; margin-top: .15rem; }

  /* Admin ações mais compactas */
  .user-actions { gap: .15rem; }
  .user-actions .btn-sm { padding: .3rem .5rem; font-size: .7rem; }

  /* Fatura nav — scroll-x */
  .fatura-nav { overflow-x: auto; flex-wrap: nowrap; }
  .fatura-nav-wrap { gap: .5rem; }

  /* Wipe grid 2 cols em mobile */
  .wipe-grid { grid-template-columns: 1fr 1fr; }

  /* Install button não sobrepõe FAB */
}

@media (max-width: 480px) {
  :root { --radius: 10px; --radius-lg: 12px; }

  .main-content { padding: .65rem; }
  .cards-grid { grid-template-columns: 1fr; }
  .credit-cards-grid { grid-template-columns: 1fr !important; }
  .wipe-grid { grid-template-columns: 1fr !important; }

  .card-value { font-size: 1.25rem; }
  .section-card { padding: 1rem; }

  .page-header { align-items: flex-start; }
  .page-header h1 { display: none; }

  .type-toggle { gap: .35rem; flex-wrap: wrap; }
  .type-opt { padding: .5rem; font-size: .72rem; flex: 1 1 calc(50% - .35rem); }

  .auth-card { padding: 1.25rem 1rem; }

  /* Dream hero: stats em coluna */
  .dream-hero-stats { flex-direction: column; align-items: stretch; text-align: center; }
  .dream-stat { width: 100%; }

  /* Shopping modal bulk items */
  .bulk-item-row { grid-template-columns: auto 1fr auto; gap: .4rem; font-size: .8rem; }
  .bulk-item-qty { display: none; }

  /* Filtros (chips) */
  .filter-chip { font-size: .72rem; padding: .25rem .6rem; }

  /* Budget row em 1 coluna */
  .budget-row-head { flex-direction: column; align-items: stretch; gap: .25rem; }
  .budget-row-head > span:last-child { text-align: left; }

  /* Gráficos */
  .donut-wrap { width: 160px; height: 160px; }

  /* Botão "O que é esta tela?" mais discreto */
  .page-help-btn { font-size: .72rem; padding: .3rem .55rem; }
  .phb-text { font-size: .72rem; }

  /* PageHelp painel com menos padding */
  .page-help-panel { padding: .75rem .85rem; font-size: .82rem; }

  /* Lista de transações: aperta categoria + valor para caber bem */
  .tx-row { gap: .5rem; padding: .55rem .35rem; }
  .tx-cat { width: 32px; height: 32px; border-radius: 8px; }
  .tx-amount { font-size: .82rem; min-width: 92px; }
  .tx-desc { font-size: .82rem; }
  .tx-meta { font-size: .68rem; }

  /* FAB não cobre conteúdo no scroll */
  .fab { bottom: .85rem; right: .85rem; }

  /* Page header: botões menores */
  .page-actions .btn { padding: .4rem .7rem; font-size: .78rem; }

  /* Recurring grid: card mais compacto */
  .rec-card-header { padding: .7rem .8rem .55rem; }
  .rec-card-body { padding: .55rem .8rem; gap: .35rem; }
  .rec-card-footer { padding: .5rem .8rem; }
  .rec-stat { font-size: .76rem; }
  .rec-amount { font-size: .9rem; }
}

/* ── Telas muito estreitas (< 360px) ────────────────────────── */
@media (max-width: 360px) {
  .tx-amount { min-width: 80px; font-size: .78rem; }
  .tx-desc { font-size: .78rem; }
  .card-value { font-size: 1.05rem; }
  .section-card { padding: .85rem; }
}

/* ── Overflow horizontal safeguard ──────────────────────────── */
html, body { overflow-x: hidden; }
