:root {
  --color-primary: #3b5b70;        /* azul dessaturado */
  --color-secondary: #6b8a99;      /* cinza-azulado suave */
  --color-accent: #8ecae6;         /* azul claro suave */
  --color-warning: #e0a458;        /* âmbar suave */
  --color-bg: #f6f7fb;             /* fundo muito claro */
  --color-surface: #ffffff;        /* cartões */
  --color-error: #c75146;          /* vermelho suave */
  --color-text: #1d1d1d;           /* texto */
  --shadow-sm: 0 6px 16px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Roboto', system-ui, -apple-system, Segoe UI, Helvetica, Arial, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.layout { display: flex; flex-direction: column; height: 100vh; }
.sidebar {
  width: 100%;
  background: linear-gradient(180deg, #3b5b70 0%, #324f60 100%);
  color: #fff;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.logo { font-weight: 700; font-size: 1.4rem; text-align: center; margin: 12px 0 24px; }
.nav { display: flex; flex-direction: row; gap: 8px; flex-wrap: wrap; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  color: #ffffffcc;
  text-decoration: none;
  border-radius: 10px;
  transition: background-color .2s ease, color .2s ease;
}
.nav-link:hover { background-color: rgba(255,255,255,0.12); }
.nav-link.active { background-color: rgba(255,255,255,0.20); color: #fff; }

.content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.header {
  background-color: var(--color-surface);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: flex; justify-content: space-between; align-items: center;
  border-radius: 0 0 14px 14px;
}
.summary { display: flex; gap: 12px; flex-wrap: wrap; }
.summary-item { display: flex; flex-direction: column; align-items: flex-end; }
.summary-item .label { font-size: 0.9rem; color: #00000080; }
.summary-item .value { font-size: 1.25rem; font-weight: 600; }
.value-income { color: #2e7d32; }
.value-expense { color: #c62828; }

.page-container { flex: 1; padding: 16px; overflow-y: auto; }
.page.hidden { display: none; }

.card {
  background-color: var(--color-surface);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}
.card-title { margin: 0 0 12px; color: var(--color-primary); font-size: 1.2rem; display: flex; align-items: center; gap: 8px; justify-content: center; }

.chart-info { margin-top: 8px; font-size: 0.95rem; color: #00000099; }

/* Altura dos gráficos para mobile-first */
.card canvas { width: 100% !important; height: 340px !important; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.form-grid.small { grid-template-columns: 1fr auto; }
.form-group { display: flex; flex-direction: column; gap: 6px; position: relative; }
/* Dropdown pesquisável de categorias */
.picker { position: absolute; left: 0; top: calc(100% + 6px); width: 100%; background: #fff; border: 1px solid rgba(0,0,0,0.12); border-radius: 8px; box-shadow: 0 10px 24px rgba(0,0,0,0.08); z-index: 20; max-height: 260px; overflow: hidden; }
.picker-search { padding: 8px; border-bottom: 1px solid rgba(0,0,0,0.08); }
.picker-search input { width: 100%; padding: 8px 10px; border: 1px solid rgba(0,0,0,0.12); border-radius: 6px; }
.picker-list { list-style: none; margin: 0; padding: 4px 0; max-height: 200px; overflow-y: auto; }
.picker-list li { padding: 8px 12px; cursor: pointer; }
.picker-list li:hover { background: #f3f4f6; }
label { font-size: 0.9rem; color: #00000080; }
input, select { padding: 10px; border: 1px solid #ddd; border-radius: 10px; font-size: 1rem; }
.form-actions { align-self: end; }

/* Base button standardization */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  background-color: var(--color-primary);
  color: #fff;
  transition: background-color .2s ease, box-shadow .2s ease;
}
button:hover { background-color: #2f4a5a; }

/* Existing button classes remain compatible */
.btn { border: none; border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer; }
.btn-primary { background-color: var(--color-primary); color: #fff; }
.btn-primary:hover { background-color: #2f4a5a; }

/* Icon button used for month filter and similar actions */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 12px;
  border: none;
  border-radius: 10px;
  background-color: var(--color-primary);
  color: #fff;
}
.icon-button:hover { background-color: #2f4a5a; }
.icon-button svg { width: 18px; height: 18px; }

/* Exceptions and special button variants */
.btn-link { background: transparent; color: var(--color-primary); padding: 0; border: none; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.btn-back { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; border: none; background: #e7e8ec; color: var(--color-primary); cursor: pointer; }
.btn-back:active { transform: scale(0.98); }
.action { background: transparent; border: none; color: var(--color-primary); cursor: pointer; }
.action.delete { color: var(--color-error); }
.action:hover { text-decoration: underline; }

.progress { margin-top: 8px; }
.progress-bar { height: 22px; background-color: #e7e8ec; border-radius: 10px; overflow: hidden; }
.progress-fill { height: 100%; display: flex; background-color: transparent; transition: width 0.3s ease; }
.progress-segment { height: 100%; }
.progress-text { display: flex; justify-content: space-between; font-size: 0.92rem; margin-top: 8px; }
.warning { color: var(--color-error); font-weight: 600; }

.grid-categories { display: grid; grid-template-columns: 1fr; gap: 16px; }
.category-card { border-left: 4px solid transparent; background: var(--color-surface); border-radius: 14px; padding: 12px; box-shadow: var(--shadow-sm); }
.category-header { display: flex; justify-content: flex-start; align-items: center; margin-bottom: 8px; }
.category-color { width: 24px; height: 24px; border-radius: 999px; }

.grid-category-goals { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.goal-card { border-left: 4px solid transparent; background: var(--color-surface); border-radius: 14px; padding: 12px; box-shadow: var(--shadow-sm); }
.goal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

@media (min-width: 900px) {
  .layout { flex-direction: row; }
  .sidebar { width: 260px; padding: 16px; position: static; }
  .nav { flex-direction: column; }
  .page-container { padding: 28px; }
  .card canvas { height: 460px !important; }
  .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* FAB - Ações rápidas */
.fab-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
}
.fab-main {
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: var(--color-primary); color: #fff; font-size: 28px; line-height: 0;
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform .2s ease, background .2s ease;
}
.fab-container.open .fab-main { transform: rotate(45deg); background: #2f4a5a; }
.fab-items { position: absolute; right: 0; bottom: 64px; display: grid; gap: 10px; }
.fab-item {
  width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--color-accent); color: #000;
  box-shadow: var(--shadow-sm); cursor: pointer; opacity: 0; transform: scale(.8);
  transition: opacity .2s ease, transform .2s ease;
}
.fab-container.open .fab-item { opacity: 1; transform: scale(1); }

/* Oculta FAB no desktop */
@media (min-width: 900px) {
  .fab-container { display: none; }
}
/* ----------------------- Ajustes complementares ----------------------- */
/* Botão de voltar no header */
.header-left { position: relative; display: flex; align-items: center; min-height: 40px; }
 .header-controls { display: flex; align-items: center; gap: 10px; }
 .header-title { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }
 .header-title h1 { margin: 0; text-align: center; }
.btn-back { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; border: none; background: #e7e8ec; color: var(--color-primary); cursor: pointer; }
.btn-back:active { transform: scale(0.98); }

/* Grid para gráficos no desktop */
.dashboard-grid-charts { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .dashboard-grid-charts { grid-template-columns: 1fr 1fr; }
  .dashboard-grid-charts .card { margin-bottom: 0; }
  /* Card especial para Gastos vs Meta: ocupa largura total no desktop */
  .dashboard-grid-charts .chart-card-income-expense { grid-column: 1 / -1; width: 100%; }
}

/* Container quadrado para o gráfico de pizza (desktop) */
.chart-square { width: 100%; }
@media (min-width: 900px) {
  .chart-square { aspect-ratio: 1 / 1; }
  .chart-square canvas { height: 100% !important; }
  #pie-expenses-by-category { height: auto !important; }
}

/* Labels visíveis nos itens do FAB */
.fab-item-wrap { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.fab-label { background: var(--color-surface); color: var(--color-text); border-radius: 999px; padding: 6px 10px; font-size: 0.85rem; box-shadow: var(--shadow-sm); opacity: 0; transform: translateX(10px); transition: opacity .2s ease, transform .2s ease; }
.fab-container.open .fab-label { opacity: 1; transform: translateX(0); }



/* Ajustes de tipografia para mobile */
@media (max-width: 899px) {
  body { font-size: 15px; }
  .header h1 { font-size: 1.1rem; }
  .summary-item .value { font-size: 1.1rem; }
  /* Ajuste dos valores de Gasto e Meta para evitar sobreposição */
  .goal-stats .stat { min-width: 0; }
  .goal-stats .stat .stat-value { font-size: 1.5rem; line-height: 1.2; }
}

/* Menu hambúrguer e drawer (mobile) */
.btn-menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border: none; border-radius: 10px;
  background: var(--color-primary); color: #fff;
  box-shadow: var(--shadow-sm); cursor: pointer;
  margin-right: 8px;
}
.btn-menu:hover { background: #2f4a5a; }

.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.25);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
  z-index: 900;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

/* Off-canvas sidebar no mobile */
.sidebar {
  width: 100%;
  background: var(--color-surface);
  color: var(--color-text);
  padding: 12px 16px;
  position: fixed;
  top: 0; left: 0;
  height: 100vh; width: 300px;
  transform: translateX(-100%);
  transition: transform .25s ease, box-shadow .25s ease;
  z-index: 1000;
  box-shadow: 0 12px 30px rgba(0,0,0,0.18);
}
.sidebar.open { transform: translateX(0); }
.sidebar .nav { flex-direction: column; }
.logo { font-weight: 700; font-size: 1.3rem; text-align: left; margin: 8px 0 16px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  color: #2b2b2b;
  text-decoration: none;
  border-radius: 10px;
  transition: background-color .2s ease, color .2s ease;
}
.nav-link svg { width: 18px; height: 18px; }
.card-title svg { width: 20px; height: 20px; }
.nav-link:hover { background-color: #f0f2f6; }
.nav-link.active { background-color: #e8eef6; color: #1e3a8a; }

/* Drawer overlay ativo em todas as larguras */
.drawer-overlay { display: block; }

/* Botão de menu visível em desktop também */
@media (min-width: 900px) {
  .btn-menu { display: inline-flex; }
  .drawer-overlay { display: block; }
}

/* Header ajustado para design mobile-first, com título centralizado */
.header { flex-direction: column; align-items: stretch; gap: 8px; }

/* Card refinements conforme o modelo */
.card { border-radius: 16px; padding: 20px; }
.card-title { font-weight: 600; color: #0f172a; }

/* Barra de progresso mais espessa e com texto verde de sucesso */
.progress-bar { height: 24px; background-color: #edf2f7; border-radius: 12px; }
.progress-text { font-size: 0.95rem; }
.warning { color: #dc2626; }

/* Grids dos gráficos: empilha no mobile, lado a lado no desktop */
.dashboard-grid-charts { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .dashboard-grid-charts { grid-template-columns: 1fr 1fr; }
}

/* FAB no estilo do modelo (preto) */
.fab-main {
  background: #0b0b12;
}
.fab-main:hover { background: #12121b; }

/* Legenda dos gráficos como ponteiro ao passar o mouse */
canvas + .chart-info, .chart-container .legend { cursor: pointer; }

.header { flex-direction: column; align-items: stretch; gap: 8px; }

/* Desktop mantém sidebar visível e esconde overlay e botão */
@media (min-width: 900px) {
  .btn-menu { display: none; }
  .drawer-overlay { display: none; }
  .sidebar { position: static; height: auto; width: 260px; transform: none; }
}

/* Oculta hambúrguer quando [hidden] */
.btn-menu[hidden] { display: none !important; }

/* Centralizar títulos das cards */
.card-title { text-align: center; justify-content: center; }
.category-card { text-align: center; }
.category-header { flex-direction: column; align-items: center; gap: 8px; }
.category-color { margin: 8px auto; }
.category-card .action.delete { align-self: center; }

/* ----------------------- Login (Auth) layout ----------------------- */
body.auth-mode .sidebar, body.auth-mode .header, body.auth-mode .fab-container { display: none !important; }
body.auth-mode .page-container { padding: 0; }

body.auth-mode #page-auth { display: block; }
.auth-wrapper { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .auth-wrapper { grid-template-columns: 1.4fr 1fr; }
}
.auth-hero { display: none; }
@media (min-width: 900px) {
  .auth-hero { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #3b5b70, #6b8a99); color: #fff; padding: 40px; }
  .auth-hero-inner { max-width: 520px; }
  .auth-hero .brand { font-weight: 700; font-size: 2rem; margin-bottom: 12px; }
  .auth-hero .subtitle { font-size: 1.1rem; opacity: 0.9; }
}
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 32px; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card .card { margin-bottom: 16px; }
.form-message { margin-top: 8px; text-align: center; color: var(--color-error); }

/* Botão de link para alternar login/registro */
.btn-link { background: transparent; color: var(--color-primary); padding: 0; border: none; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.action { background: transparent; border: none; color: var(--color-primary); cursor: pointer; }
.action.delete { color: var(--color-error); }
.action:hover { text-decoration: underline; }

/* ------- Auth UI refinements (inspirado no modelo) ------- */
.auth-card-header { text-align: center; margin-bottom: 8px; }
.auth-lock-circle { width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(135deg, #3b82f6, #4f46e5); display: flex; align-items: center; justify-content: center; color: #fff; margin: 0 auto 12px; box-shadow: var(--shadow-sm); }
.auth-lock-circle svg { width: 32px; height: 32px; }
.card-desc { font-size: 0.95rem; color: #00000099; text-align: center; }

.auth-tabs { margin-top: 8px; }
.tabs-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 16px; }
.tabs-trigger { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border-radius: 10px; background: #f0f2f6; color: #333; cursor: pointer; border: 1px solid #e0e0e0; }
.tabs-trigger svg { width: 16px; height: 16px; }
.tabs-trigger.active { background: var(--color-accent); color: #000; border-color: transparent; }

.tabs-content[hidden] { display: none; }

.input-with-icon { position: relative; }
.input-with-icon svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: #888; }
input.with-icon { padding-left: 34px; }

.btn-link.small { font-size: 0.85rem; display: block; text-align: center; margin-top: 8px; }

/* ------- Ajustes mobile específicos para tela de login ------- */
/* Empilhar campos e evitar overflow no mobile */
#page-auth .auth-ui .form-grid.small { grid-template-columns: 1fr; }
#page-auth .auth-ui .form-group { grid-column: 1 / -1; }
#page-auth .auth-ui .form-actions { align-self: stretch; display: grid; grid-template-columns: 1fr; gap: 8px; }
#page-auth .auth-ui .form-actions .btn { width: 100%; }

/* Reduzir tamanho dos botões para caber no container */
@media (max-width: 899px) {
  #page-auth .auth-ui .btn-primary { padding: 8px 12px; font-size: 0.95rem; }
  #page-auth .auth-ui .btn-link { font-size: 0.95rem; }
  #page-auth .auth-ui .tabs-trigger { padding: 8px; font-size: 0.95rem; }
}
/* Garantir largura total dos campos na tela de login/cadastro */
#page-auth .auth-ui .form-group .input-with-icon,
#page-auth .auth-ui .form-group input,
#page-auth .auth-ui .form-group select {
  width: 100%;
}
.action { background: transparent; border: none; color: var(--color-primary); cursor: pointer; }
.action.delete { color: var(--color-error); }
.action:hover { text-decoration: underline; }
:root {
  /* Tokens do modelo (Nova pasta) mapeados para o tema atual */
  --primary: #030213;
  --background: #ffffff;
  --foreground: oklch(0.145 0 0);
  --card: #ffffff;
  --muted: #ececf0;
  --muted-foreground: #717182;
  --radius: 10px;
  /* Mapas para variáveis já usadas no projeto */
  --color-primary: var(--primary);
  --color-secondary: #6b8a99;
  --color-accent: #8ecae6;
  --color-warning: #e0a458;
  --color-bg: var(--background);
  --color-surface: var(--card);
  --color-error: #d4183d;
  --color-text: var(--foreground);
}
.card.shadow-sm { box-shadow: 0 1px 2px rgba(3,2,19,0.06); }
.card-header { padding: 16px 16px 0; }
.card-content { padding: 0 16px 16px; }
.icon-wallet { display: inline-flex; align-items: center; margin-right: 8px; color: #2563eb; }
.goal-stats-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 12px; }

.stat-card {
   background-color: var(--color-surface);
   border-radius: 12px;
   padding: 16px;
   box-shadow: var(--shadow-sm);
   border: 1px solid rgba(0,0,0,0.06);
   transition: all 0.2s ease;
   text-align: center;
 }
 
 .stat-card:hover {
   background-color: rgba(59, 130, 246, 0.02);
   box-shadow: 0 4px 14px rgba(0,0,0,0.08);
   border-color: rgba(0,0,0,0.12);
   transform: translateY(-1px);
 }
 
 .stat-card { position: relative; overflow: visible; }
 .card-info { position: absolute; top: 0px; right: 8px; display: inline-flex; align-items: center; justify-content: center; }
 
 .stat-label-row { display: flex; align-items: center; justify-content: center; gap: 8px; position: relative; margin-bottom: 8px; }
  .stat-label-row .muted { margin: 0; line-height: 1; }
 .stat-info-row { display: inline-flex; align-items: center; gap: 8px; position: relative; justify-content: center; }
 .info-icon { background: transparent; border: none; color: var(--muted-foreground); display: inline-flex; align-items: center; justify-content: center; width: 1em; height: 1em; line-height: 1; padding: 0; margin: 0; box-sizing: border-box; cursor: pointer; }
 .info-icon:hover { color: var(--color-primary); }
 .info-icon:focus { outline: 2px solid rgba(37, 99, 235, 0.4); outline-offset: 2px; }
 .info-icon svg { display: block; width: 100%; height: 100%; }
  .info-icon img { display: block; width: 100%; height: 100%; }
 
 .tooltip { position: absolute; top: calc(100% + 6px); right: 0; left: auto; background: var(--color-surface); color: var(--color-text); border: 1px solid rgba(0,0,0,0.12); box-shadow: var(--shadow-sm); border-radius: 8px; padding: 8px 10px; font-size: 0.85rem; white-space: normal; overflow-wrap: anywhere; word-break: break-word; opacity: 0; pointer-events: none; transition: opacity .15s ease, transform .15s ease; z-index: 1000; transform: translateY(-2px); }
   .tooltip.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
   .info-icon:hover + .tooltip, .info-icon:focus + .tooltip { opacity: 1; transform: translateY(0); pointer-events: auto; }
 
 .stat-card .muted { 
   color: var(--muted-foreground); 
   font-size: 0.9rem; 
   margin: 0 0 8px 0;
 }
 
 .stat-card .stat-info {
   color: var(--muted-foreground);
   font-size: 0.85rem;
   margin: 4px 0 8px;
 }
 
 /* Desktop: usar tooltip e ocultar texto descritivo para reduzir ruído */
 @media (min-width: 601px) {
   .stat-card .stat-info { display: none; }
 }
 
 /* Mobile: aumentar fonte dos labels e manter tooltip por clique */
 @media (max-width: 768px) {
   .stat-card .muted { font-size: 1.08rem; }
   .stat-label-row { gap: 8px; }
 }
 
 .stat-card .stat-value { 
   color: var(--color-text); 
   line-height: 1.2; 
   margin: 0;
   font-weight: 600;
   font-size: 1.75rem;
 }
.muted { color: var(--muted-foreground); }

/* Desktop-only font size for goal values */
@media (min-width: 900px) {
  .goal-stats .stat .stat-value { font-size: 1.75rem; }
}
.sidebar { display: flex; flex-direction: column; }
.menu-footer { margin-top: auto; padding: 16px; border-top: 1px solid var(--muted); background: var(--background); }
/* Card de usuário em grid para evitar sobreposição */
.user-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); background: #f8fafc; }
/* Avatar menor para caber no card */
.user-card .avatar { height: 32px; width: 32px; border-radius: 999px; background: #2563eb; color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.user-left { display: flex; align-items: center; }
.user-center { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 2px; }
.user-center .user-name { margin: 0; font-size: 0.95rem; line-height: 1.2; }
.user-center .user-email { margin: 0; font-size: 0.85rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-right { display: flex; align-items: center; }

/* Garantir visibilidade do user-info quando não estiver hidden */
#user-info:not([hidden]) { display: block !important; }
#user-info[hidden] { display: none !important; }

/* ------- Bancos: cards e header (inspirado no modelo) ------- */
.bank-card {
  background: #f8fafc;
  border: 1px solid var(--muted);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s ease;
}
.bank-card:hover { border-color: #d1d5db; }
.bank-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bank-header h3 { margin: 0; color: var(--color-text); font-weight: 500; }
/* Feedback messages */
.feedback {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.95rem;
}
.feedback.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.feedback.error { background: #fef2f2; color: #7f1d1d; border: 1px solid #fecaca; }

/* Overlay delete button positioning */
.bank-card { position: relative; }
.bank-delete { position: absolute; top: 50%; transform: translateY(-50%); right: 8px; z-index: 10; color: #dc2626; }
.bank-delete svg { width: 18px; height: 18px; stroke: #dc2626; }
.bank-header .action { width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.bank-header .action.delete { color: #dc2626; }
.bank-header .action.delete:hover { background: #fee2e2; }
.bank-header .action.delete svg, .bank-actions .action.delete svg { width: 18px; height: 18px; stroke: #dc2626; }
/* Banks page refinements */
.banks-card .card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e7e8ec;
  color: var(--color-text);
  font-size: 0.85rem;
}

.grid-banks {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 600px) {
  .grid-banks {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 900px) {
  .grid-banks {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.bank-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow-sm);
}

.bank-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ------- Categorias: cards e header (alinhado ao Bancos) ------- */
.category-card {
   background: #fff;
   border: 1px solid #e5e7eb;
   border-radius: 8px;
   padding: 12px;
   box-shadow: var(--shadow-sm);
   position: relative;
   text-align: left; /* força alinhamento à esquerda, sobrepõe regra antiga */
   transition: border-color .2s ease, background-color .2s ease;
 }
 .category-card:hover { border-color: #d1d5db; background: #f9fafb; }
 .category-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}
.category-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.category-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.category-name { margin: 0; color: var(--color-text); font-weight: 500; }
.category-delete { position: absolute; top: 50%; transform: translateY(-50%); right: 8px; z-index: 10; color: #dc2626; }
.category-delete svg { width: 18px; height: 18px; stroke: #dc2626; }
.categories-card .card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Ajustes anteriores de centralização não se aplicam mais às categorias */
.category-card.text-center { text-align: initial; }

.bank-actions button {
  background: transparent;
  color: #e11d48;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.bank-actions button:hover {
  text-decoration: underline;
}
.bank-actions button {
  background: transparent;
  color: #e11d48;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.bank-actions button:hover {
  text-decoration: underline;
}
/* Color picker enhancements for Categories */
.color-picker-row { position: relative; display: flex; align-items: center; gap: 10px; }
#cat-color { width: 48px; height: 36px; padding: 0; border-radius: 10px; border: 2px solid #ccc; }
/* Overlay e acessibilidade */
.color-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.2); display: none; }
.color-overlay.show { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
/* Popup com opção acima se necessário */
.color-popup {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 50; background: #fff; border: 1px solid #ddd; border-radius: 12px; box-shadow: var(--shadow-md); padding: 12px; width: max-content; max-width: 90vw; display: none; }
.color-popup.show { display: block; }
.color-popup.above { top: auto; bottom: calc(100% + 8px); }
/* Paleta e custom color */
.color-options { display: grid; grid-template-columns: repeat(6, 28px); gap: 8px; margin-bottom: 10px; }
.color-swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.color-swatch:hover { transform: scale(1.06); box-shadow: var(--shadow-md); }
.color-swatch.selected { outline: 2px solid var(--color-primary); }
.color-custom { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
#cat-color-custom { width: 36px; height: 28px; padding: 0; border-radius: 6px; border: 1px solid #ccc; }
/* Responsividade geral para evitar cortes em mobile */
@media (max-width: 600px) {
  .color-popup { max-width: calc(100vw - 24px); left: 12px; right: 12px; }
  .color-options { grid-template-columns: repeat(6, 36px); justify-content: space-between; }
  .color-swatch { width: 32px; height: 32px; }
  #cat-color { width: 56px; height: 40px; }
  
  /* Cards de gasto e meta em coluna única em mobile */
  .goal-stats-cards { 
    grid-template-columns: 1fr; 
    gap: 12px; 
  }
  
  .stat-card {
    padding: 14px;
  }
  
  .stat-card .stat-value {
    font-size: 1.5rem;
  }
}
.color-preview { width: 36px; height: 36px; border-radius: 10px; border: 3px solid #ddd; box-shadow: var(--shadow-sm); transition: background-color .2s ease, border-color .2s ease, transform .2s ease; }
.color-preview.confirmed { border-color: var(--color-primary); transform: scale(1.02); }
.btn-secondary { background-color: #e7e8ec; color: var(--color-primary); }
.btn-secondary:hover { background-color: #dcdde2; }

/* Pagination Controls */
.pager {
  margin-top: 24px;
  padding: 16px 0;
  border-top: 1px solid rgba(0,0,0,0.08);
}
.pager-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.pager-info {
  font-size: 0.9rem;
  color: #00000080;
  font-weight: 500;
}
.pager .btn {
  padding: 8px 16px;
  font-size: 0.9rem;
  min-width: 80px;
}
.pager .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

@media (min-width: 900px) {
  .color-picker-row { gap: 12px; }
  #cat-color { width: 56px; height: 40px; }
  .color-preview { width: 40px; height: 40px; }
}

/* Padronização de tamanhos dos gráficos */
/* Mobile default: 250x250 */
canvas#pie-expenses-by-category,
canvas#pie-expenses-by-bank {
  width: 250px !important;
  height: 250px !important;
  max-width: 250px !important;
  max-height: 250px !important;
}
/* Terceiro gráfico: ocupar largura máxima disponível */
canvas#bar-income-vs-expense {
  width: 100% !important;
  max-width: none !important;
  height: 250px !important;
  margin-bottom: 90px !important;
}
/* Centraliza o canvas dentro dos contêineres */
.chart-square, .chart-wide {
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Desktop: 300x300 para pizzas; barra mantém largura máxima e altura 300 */
@media (min-width: 900px) {
  canvas#pie-expenses-by-category,
  canvas#pie-expenses-by-bank {
    width: 300px !important;
    height: 300px !important;
    max-width: 300px !important;
    max-height: 300px !important;
  }
  canvas#bar-income-vs-expense {
    height: 300px !important;
    margin-bottom: 0 !important;
  }
}

/* Z-index hierarchy fixes */
#month-filter-popover { z-index: 2000 !important; }
#btn-open-color { position: relative; z-index: 1; }
.color-popup { z-index: 1000 !important; }
.color-overlay { z-index: 999 !important; background: transparent !important; }
.color-overlay.show { background: transparent !important; }

/* Color picker: enforce true viewport centering */
.color-popup {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  right: auto !important;
  bottom: auto !important;
  margin: 0 !important;
  z-index: 1001;
  width: min(90vw, 360px);
  max-height: min(80vh, 520px);
  overflow: auto;
}
.color-overlay {
  position: fixed !important;
  inset: 0 !important;
  background: transparent;
  z-index: 1000;
}
/* ensure button dot displays chosen color */
#color-dot {
  display: inline-block;
  width: 20px; height: 20px;
  border-radius: 50%;
}
@media (max-width: 480px) {
  .color-popup { width: 92vw; }
}
.btn-link.small { font-size: 0.85rem; display: block; text-align: center; margin-top: 8px; }

/* Popup header + full-width button styling */
.color-popup .popup-title { margin: 0 0 8px; font-size: 1rem; color: var(--color-text); }
.color-popup .btn { display: block; width: 100%; margin-top: 8px; }
#btn-color-apply { border-width: 3px; border-style: solid; transition: border-color .2s ease, filter .15s ease; }
#btn-color-apply:hover { filter: brightness(0.95); }

/* Categorias: botão Adicionar em largura total do formulário */
#page-categories .form-grid.small .form-actions { grid-column: 1 / -1; align-self: stretch; }
#page-categories .form-grid.small .form-actions .btn { width: 100%; display: block; }

/* ------- Transações: listagem em cards (layout refinado) ------- */
/* Transações: botão Adicionar full-width no desktop */
@media (min-width: 900px) {
  #page-transactions .form-grid .form-actions .btn { width: 100%; display: block; }
}
.transactions-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.tx-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  padding: 12px 14px;
}
/* Hover sutil nas cards de transação */
.tx-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.08); border-color: rgba(0,0,0,0.12); }

/* Cabeçalho: título à esquerda e data à direita */
.tx-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.tx-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.tx-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.06);
  color: #333;
}
.tx-icon.income { background: rgba(22,163,74,0.15); color: #16a34a; }
.tx-icon.expense { background: rgba(220,38,38,0.15); color: #dc2626; }

.tx-title {
  margin: 0;
  font-weight: 600;
  color: #111827;
}

.tx-date {
  font-size: 12px;
  color: #6b7280;
}

/* Corpo: meta (categoria - banco) e valores/ações à direita */
.tx-body {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.tx-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #6b7280;
  font-size: 12px;
}
.tx-meta .sep { color: #9ca3af; }

.tx-right {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.tx-amount {
  font-weight: 600;
}
.tx-amount.income { color: #16a34a; }
.tx-amount.expense { color: #dc2626; }

.tx-delete {
  background: transparent;
  border: none;
  color: #dc2626;
  font-size: 12px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
}
.tx-delete:hover { background: rgba(220,38,38,0.08); }
.tx-delete svg { width: 18px; height: 18px; display: block; }

/* Consistência de padding e box-sizing */
.tx-card * { box-sizing: border-box; }
.tx-header, .tx-body { padding: 0; }

/* Reduzir tamanho dos botões para caber no container */
@media (max-width: 899px) {
  #page-auth .auth-ui .btn-primary { padding: 8px 12px; font-size: 0.95rem; }
  #page-auth .auth-ui .btn-link { font-size: 0.95rem; }
  #page-auth .auth-ui .tabs-trigger { padding: 8px; font-size: 0.95rem; }
}
/* Garantir largura total dos campos na tela de login/cadastro */
#page-auth .auth-ui .form-group .input-with-icon,
#page-auth .auth-ui .form-group input,
#page-auth .auth-ui .form-group select {
  width: 100%;
}
.action { background: transparent; border: none; color: var(--color-primary); cursor: pointer; }
.action.delete { color: var(--color-error); }
.action:hover { text-decoration: underline; }
:root {
  /* Tokens do modelo (Nova pasta) mapeados para o tema atual */
  --primary: #030213;
  --background: #ffffff;
  --foreground: oklch(0.145 0 0);
  --card: #ffffff;
  --muted: #ececf0;
  --muted-foreground: #717182;
  --radius: 10px;
  /* Mapas para variáveis já usadas no projeto */
  --color-primary: var(--primary);
  --color-secondary: #6b8a99;
  --color-accent: #8ecae6;
  --color-warning: #e0a458;
  --color-bg: var(--background);
  --color-surface: var(--card);
  --color-error: #d4183d;
  --color-text: var(--foreground);
}
.card.shadow-sm { box-shadow: 0 1px 2px rgba(3,2,19,0.06); }
.card-header { padding: 16px 16px 0; }
.card-content { padding: 0 16px 16px; }
.icon-wallet { display: inline-flex; align-items: center; margin-right: 8px; color: #2563eb; }
.goal-stats { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.goal-stats .stat .muted { color: var(--muted-foreground); font-size: 0.9rem; }
.goal-stats .stat .stat-value { color: var(--color-text); line-height: 1.2; }
.goal-stats .stat.right { text-align: right; }
.muted { color: var(--muted-foreground); }

/* Desktop-only font size for goal values */
@media (min-width: 900px) {
  .goal-stats .stat .stat-value { font-size: 1.75rem; }
}
.sidebar { display: flex; flex-direction: column; }
.menu-footer { margin-top: auto; padding: 16px; border-top: 1px solid var(--muted); background: var(--background); }
/* Card de usuário em grid para evitar sobreposição */
.user-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); background: #f8fafc; }
/* Avatar menor para caber no card */
.user-card .avatar { height: 32px; width: 32px; border-radius: 999px; background: #2563eb; color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.user-left { display: flex; align-items: center; }
.user-center { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 2px; }
.user-center .user-name { margin: 0; font-size: 0.95rem; line-height: 1.2; }
.user-center .user-email { margin: 0; font-size: 0.85rem; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-right { display: flex; align-items: center; }
.logout-btn { 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  width: 32px; 
  height: 32px; 
  border-radius: 8px; 
  border: none; 
  background: #e7e8ec; 
  color: #3b5b70 !important; 
  cursor: pointer; 
  flex-shrink: 0; 
  transition: all 0.15s ease;
}
.logout-btn:hover { 
  background: #dfe2e7; 
}
.logout-btn:active { 
  transform: scale(0.98); 
}
.logout-btn svg { 
  width: 18px; 
  height: 18px; 
  display: block; 
  fill: none !important; 
  stroke: #3b5b70 !important; 
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.logout-btn svg path, .logout-btn svg rect, .logout-btn svg circle {
  stroke: #3b5b70 !important;
  fill: none !important;
}
/* Suporte ao uso de imagem SVG externa */
.logout-btn img {
  width: 18px;
  height: 18px;
  display: block;
}

 /* ------- Bancos: cards e header (inspirado no modelo) ------- */
.bank-card {
  background: #f8fafc;
  border: 1px solid var(--muted);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s ease;
}
.bank-card:hover { border-color: #d1d5db; }
.bank-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bank-header h3 { margin: 0; color: var(--color-text); font-weight: 500; }
/* Feedback messages */
.feedback {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.95rem;
}
.feedback.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.feedback.error { background: #fef2f2; color: #7f1d1d; border: 1px solid #fecaca; }

/* Overlay delete button positioning */
.bank-card { position: relative; }
.bank-delete { position: absolute; top: 50%; transform: translateY(-50%); right: 8px; z-index: 10; color: #dc2626; }
.bank-delete svg { width: 18px; height: 18px; stroke: #dc2626; }
.bank-header .action { width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.bank-header .action.delete { color: #dc2626; }
.bank-header .action.delete:hover { background: #fee2e2; }
.bank-header .action.delete svg, .bank-actions .action.delete svg { width: 18px; height: 18px; stroke: #dc2626; }
/* Banks page refinements */
.banks-card .card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e7e8ec;
  color: var(--color-text);
  font-size: 0.85rem;
}

.grid-banks {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 600px) {
  .grid-banks {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 900px) {
  .grid-banks {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.bank-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow-sm);
}

.bank-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ------- Categorias: cards e header (alinhado ao Bancos) ------- */
.category-card {
   background: #fff;
   border: 1px solid #e5e7eb;
   border-radius: 8px;
   padding: 12px;
   box-shadow: var(--shadow-sm);
   position: relative;
   text-align: left; /* força alinhamento à esquerda, sobrepõe regra antiga */
   transition: border-color .2s ease, background-color .2s ease;
 }
 .category-card:hover { border-color: #d1d5db; background: #f9fafb; }
 .category-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}
.category-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.category-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}
.category-name { margin: 0; color: var(--color-text); font-weight: 500; }
.category-delete { position: absolute; top: 50%; transform: translateY(-50%); right: 8px; z-index: 10; color: #dc2626; }
.category-delete svg { width: 18px; height: 18px; stroke: #dc2626; }
.categories-card .card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* Ajustes anteriores de centralização não se aplicam mais às categorias */
.category-card.text-center { text-align: initial; }

.bank-actions button {
  background: transparent;
  color: #e11d48;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.bank-actions button:hover {
  text-decoration: underline;
}
.bank-actions button {
  background: transparent;
  color: #e11d48;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.bank-actions button:hover {
  text-decoration: underline;
}
/* Color picker enhancements for Categories */
.color-picker-row { position: relative; display: flex; align-items: center; gap: 10px; }
#cat-color { width: 48px; height: 36px; padding: 0; border-radius: 10px; border: 2px solid #ccc; }
/* Overlay e acessibilidade */
.color-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.2); display: none; }
.color-overlay.show { display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
/* Popup com opção acima se necessário */
.color-popup {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 50; background: #fff; border: 1px solid #ddd; border-radius: 12px; box-shadow: var(--shadow-md); padding: 12px; width: max-content; max-width: 90vw; display: none; }
.color-popup.show { display: block; }
.color-popup.above { top: auto; bottom: calc(100% + 8px); }
/* Paleta e custom color */
.color-options { display: grid; grid-template-columns: repeat(6, 28px); gap: 8px; margin-bottom: 10px; }
.color-swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.color-swatch:hover { transform: scale(1.06); box-shadow: var(--shadow-md); }
.color-swatch.selected { outline: 2px solid var(--color-primary); }
.color-custom { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
#cat-color-custom { width: 36px; height: 28px; padding: 0; border-radius: 6px; border: 1px solid #ccc; }
/* Responsividade geral para evitar cortes em mobile */
@media (max-width: 600px) {
  .color-popup { max-width: calc(100vw - 24px); left: 12px; right: 12px; }
  .color-options { grid-template-columns: repeat(6, 36px); justify-content: space-between; }
  .color-swatch { width: 32px; height: 32px; }
  #cat-color { width: 56px; height: 40px; }
}
.color-preview { width: 36px; height: 36px; border-radius: 10px; border: 3px solid #ddd; box-shadow: var(--shadow-sm); transition: background-color .2s ease, border-color .2s ease, transform .2s ease; }
.color-preview.confirmed { border-color: var(--color-primary); transform: scale(1.02); }
.btn-secondary { background-color: #e7e8ec; color: var(--color-primary); }
.btn-secondary:hover { background-color: #dcdde2; }
@media (min-width: 900px) {
  .color-picker-row { gap: 12px; }
  #cat-color { width: 56px; height: 40px; }
  .color-preview { width: 40px; height: 40px; }
}