/* ==========================================================================
   SISTEMA DE CORES E VARIÁVEIS DO TEMA (PREMIUM DARK)
   ========================================================================== */
:root {
  --bg-primary: #0f172a;      /* Slate 900 - Fundo principal */
  --bg-secondary: #1e293b;    /* Slate 800 - Sidebar e cards */
  --bg-tertiary: #334155;     /* Slate 700 - Inputs e hover secundário */
  
  --text-primary: #f8fafc;    /* Slate 50 - Texto principal */
  --text-secondary: #94a3b8;  /* Slate 400 - Legendas e texto menor */
  --text-muted: #64748b;      /* Slate 500 - Textos desabilitados ou mudos */
  
  --border-color: #334155;    /* Slate 700 - Bordas em geral */
  --border-focus: #3b82f6;    /* Blue 500 - Foco em inputs */
  
  --accent-income: #10b981;   /* Emerald 500 - Receitas / Sucesso */
  --accent-income-hover: #059669;
  --accent-income-light: rgba(16, 185, 129, 0.1);
  
  --accent-expense: #ef4444;  /* Red 500 - Despesas / Perigo */
  --accent-expense-hover: #dc2626;
  --accent-expense-light: rgba(239, 68, 68, 0.1);
  
  --accent-goal: #3b82f6;     /* Blue 500 - Metas / Informativo */
  --accent-goal-hover: #2563eb;
  --accent-goal-light: rgba(59, 130, 246, 0.1);
  
  --accent-warning: #f59e0b;  /* Amber 500 - Pendente / Alerta */
  --accent-warning-light: rgba(245, 158, 11, 0.1);
  
  --sidebar-width: 260px;
  --header-height: 70px;
  --border-radius-sm: 6px;
  --border-radius-md: 12px;
  --border-radius-lg: 18px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
  
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ==========================================================================
   RESETS E CONFIGURAÇÕES GERAIS
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
}

/* Scrollbar Personalizado */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--border-radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================================
   LAYOUT E ESTRUTURA
   ========================================================================== */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-logo {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-logo img {
  width: 36px;
  height: 36px;
  border-radius: var(--border-radius-sm);
}

.sidebar-logo h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #f8fafc 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  flex: 1;
}

/* Botão de fechar sidebar (dentro do drawer, só aparece no mobile) */
/* Especificidade .btn-icon.sidebar-close (2 classes) para vencer a regra global .btn-icon { display:flex } */
.btn-icon.sidebar-close {
  display: none;
  flex-shrink: 0;
}

/* Botão hambúrguer no header (só aparece no mobile) */
/* Especificidade .btn-icon.menu-toggle (2 classes) para vencer a regra global .btn-icon { display:flex } */
.btn-icon.menu-toggle {
  display: none;
  flex-shrink: 0;
  margin-right: 8px;
}

/* Título "Controle Financeiro" no topo (só aparece no mobile, ao lado do hambúrguer) */
.mobile-brand-title {
  display: none;
}

/* Overlay escuro atrás da sidebar no mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  z-index: 15;
  opacity: 0;
  transition: opacity 0.25s ease-in-out;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--border-radius-md);
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  transition: transform 0.2s ease;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.nav-link:hover svg {
  transform: translateX(2px);
}

.nav-link.active {
  background-color: var(--accent-goal-light);
  color: var(--accent-goal);
  font-weight: 600;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-user {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Área de Conteúdo Principal */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.top-header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border-color);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(10px);
}

.top-header h2 {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-primary);
}

.quick-actions {
  display: flex;
  gap: 12px;
}

/* Conteúdo da Tela */
.tab-pane {
  display: none;
  flex: 1;
  padding: 32px;
  overflow-y: auto;
  animation: fadeIn 0.3s ease-in-out forwards;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   COMPONENTES DE CARTÕES (STAT CARDS)
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.card-stat {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.card-stat:hover {
  transform: translateY(-2px);
  border-color: var(--text-muted);
}

.card-stat::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.card-stat.saldo::after { background-color: var(--accent-goal); }
.card-stat.receitas::after { background-color: var(--accent-income); }
.card-stat.despesas::after { background-color: var(--accent-expense); }
.card-stat.resultado.positivo::after { background-color: var(--accent-income); }
.card-stat.resultado.negativo::after { background-color: var(--accent-expense); }

.card-stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-stat-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  font-weight: 600;
}

.card-stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.saldo .card-stat-icon { background-color: var(--accent-goal-light); color: var(--accent-goal); }
.receitas .card-stat-icon { background-color: var(--accent-income-light); color: var(--accent-income); }
.despesas .card-stat-icon { background-color: var(--accent-expense-light); color: var(--accent-expense); }
.resultado.positivo .card-stat-icon { background-color: var(--accent-income-light); color: var(--accent-income); }
.resultado.negativo .card-stat-icon { background-color: var(--accent-expense-light); color: var(--accent-expense); }

.card-stat-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2.5;
  fill: none;
}

.card-stat-value {
  font-size: clamp(1.2rem, 1.8vw, 1.65rem);
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* ==========================================================================
   SEÇÕES DO DASHBOARD (CHARTS GRID)
   ========================================================================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.dashboard-panel {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 24px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.panel-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-wrapper {
  position: relative;
  flex: 1;
  width: 100%;
  min-height: 250px;
  max-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   METAS NO DASHBOARD E ABA METAS
   ========================================================================== */
.dashboard-goals-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.goal-item-small {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 12px;
}

.goal-item-small-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.goal-item-small-title {
  font-weight: 600;
}

.goal-item-small-values {
  color: var(--text-secondary);
}

/* Barras de progresso */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background-color: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-goal) 0%, #60a5fa 100%);
  border-radius: 4px;
  transition: width 0.4s ease-out;
}

/* Grade de metas na aba metas */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.card-goal {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 24px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  position: relative;
}

.card-goal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.card-goal-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.card-goal-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.card-goal-progress-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-goal-progress-info {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 0.85rem;
}

.card-goal-percentage {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-goal);
}

.card-goal-values {
  text-align: right;
  color: var(--text-secondary);
}

.card-goal-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  height: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-goal-actions {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

/* ==========================================================================
   TABELAS E LISTAGENS
   ========================================================================== */
.table-panel {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.table-filter-bar {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.filter-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.table-container {
  overflow-x: auto;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background-color: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: rgba(255, 255, 255, 0.01);
}

.col-valor {
  font-weight: 600;
}

.receitas-list .col-valor {
  color: var(--accent-income);
}

.despesas-list .col-valor {
  color: var(--accent-expense);
}

.col-status {
  white-space: nowrap;
}

.col-acoes {
  display: flex;
  gap: 8px;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-pago {
  background-color: var(--accent-income-light);
  color: var(--accent-income);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-pendente {
  background-color: var(--accent-warning-light);
  color: var(--accent-warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Linha vazia ou sem dados */
.table-empty-state {
  text-align: center;
  padding: 48px;
  color: var(--text-secondary);
}

.table-empty-state svg {
  width: 48px;
  height: 48px;
  stroke: var(--text-muted);
  stroke-width: 1.5;
  margin-bottom: 16px;
}

/* ==========================================================================
   INPUTS, FORMULÁRIOS E FILTROS
   ========================================================================== */
select, input[type="text"], input[type="number"], input[type="date"], textarea {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

select:focus, input:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.filter-input {
  min-width: 120px;
}

.search-input {
  min-width: 220px;
}

/* Formulário de Modal */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-checkbox {
  flex-direction: row !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}

.form-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-goal);
  cursor: pointer;
}

/* ==========================================================================
   BOTÕES E COMPONENTES INTERATIVOS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  outline: none;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background-color: var(--accent-goal);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--accent-goal-hover);
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.btn-success {
  background-color: var(--accent-income);
  color: #fff;
}
.btn-success:hover {
  background-color: var(--accent-income-hover);
}

.btn-danger {
  background-color: var(--accent-expense);
  color: #fff;
}
.btn-danger:hover {
  background-color: var(--accent-expense-hover);
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.btn-icon.delete:hover {
  background-color: var(--accent-expense-light);
  color: var(--accent-expense);
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.75rem;
  border-radius: var(--border-radius-sm);
}

/* ==========================================================================
   MODAIS (EFEITO GLASSMORPHISM E OVERLAY)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.25s ease-in-out;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  width: 500px;
  max-width: 90%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

.modal-body {
  padding: 24px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Modal de Confirmação customizado */
.confirm-modal .modal-content {
  width: 400px;
}

.confirm-message {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 8px;
}

/* ==========================================================================
   ABA DE RELATÓRIOS
   ========================================================================== */
.reports-grid-large {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.reports-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.month-summary-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.month-summary-item {
  background-color: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 16px 24px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  align-items: center;
}

.month-summary-name {
  font-weight: 600;
}

.month-summary-val-inc {
  color: var(--accent-income);
  font-weight: 500;
}

.month-summary-val-exp {
  color: var(--accent-expense);
  font-weight: 500;
}

.month-summary-val-res {
  font-weight: 600;
}

/* ==========================================================================
   CONFIGURAÇÕES E CATEGORIAS
   ========================================================================== */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.category-manager {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.category-list-wrapper {
  background-color: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 16px;
  max-height: 250px;
  overflow-y: auto;
}

.category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.category-item:last-child {
  border-bottom: none;
}

.category-item span {
  font-size: 0.9rem;
}

.db-info-box {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 16px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  line-height: 1.5;
}

.db-info-path {
  font-family: monospace;
  background-color: rgba(0, 0, 0, 0.2);
  padding: 4px 8px;
  border-radius: 4px;
  word-break: break-all;
  display: block;
  margin-top: 6px;
  color: var(--accent-goal);
  user-select: text;
}

/* ==========================================================================
   TOAST SYSTEM (NOTIFICAÇÕES FLUTUANTES)
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 999;
}

.toast {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-goal);
  padding: 14px 20px;
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 400px;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
  transform: translateX(0);
}

.toast.sucesso { border-left-color: var(--accent-income); }
.toast.erro { border-left-color: var(--accent-expense); }
.toast.info { border-left-color: var(--accent-goal); }

.toast-message {
  font-size: 0.85rem;
  font-weight: 500;
}

/* ==========================================================================
   TELA DE AUTENTICAÇÃO (LOGIN / CADASTRO)
   ========================================================================== */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  background-color: var(--bg-primary);
  padding: 24px;
}

.auth-card {
  width: 400px;
  max-width: 100%;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  text-align: center;
}

.auth-logo img {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-sm);
}

.auth-logo h1 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.auth-tabs {
  display: flex;
  gap: 6px;
  background-color: var(--bg-tertiary);
  border-radius: var(--border-radius-md);
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: var(--border-radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-tab.active {
  background-color: var(--accent-goal);
  color: #fff;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-submit {
  width: 100%;
  margin-top: 6px;
}

.auth-error {
  background-color: var(--accent-expense-light);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--accent-expense);
  border-radius: var(--border-radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}

.auth-error.active {
  display: block;
}

/* ==========================================================================
   MEDIA QUERIES - RESPONSIVIDADE E AJUSTE PARA VALORES GRANDES
   ========================================================================== */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .reports-charts-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .settings-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  /* Sidebar vira um drawer off-canvas no mobile */
  .btn-icon.menu-toggle {
    display: flex;
    order: 2;
  }

  .btn-icon.sidebar-close {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    max-width: 85vw;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 20;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-overlay.open {
    display: block;
    opacity: 1;
  }

  .top-header {
    height: auto;
    min-height: var(--header-height);
    padding: 12px 16px;
    flex-wrap: wrap;
    row-gap: 10px;
  }

  /* Título da marca fica sozinho, acima do hambúrguer e dos botões */
  .mobile-brand-title {
    display: block;
    order: 1;
    flex: 0 0 100%;
    min-width: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Título da página some no mobile: sobra só hambúrguer + botões na segunda linha */
  .top-header h2 {
    display: none;
  }

  .quick-actions {
    order: 4;
  }

  .tab-pane {
    padding: 16px;
  }

  .dashboard-panel {
    padding: 16px;
  }

  .card-stat {
    padding: 16px;
  }

  .goals-grid {
    grid-template-columns: 1fr;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-header,
  .modal-footer {
    padding: 14px 16px;
  }
}

/* ==========================================================================
   AJUSTES DE TOQUE E FORMULÁRIOS PARA TELAS PEQUENAS (MOBILE)
   ========================================================================== */
@media (max-width: 600px) {
  /* Alvo de toque confortável e font-size 16px evita zoom automático no Safari */
  select, input[type="text"], input[type="number"], input[type="date"], textarea {
    font-size: 16px;
    padding: 12px 14px;
    min-height: 44px;
  }

  textarea {
    min-height: 80px;
  }

  .btn {
    padding: 12px 18px;
    min-height: 44px;
    font-size: 0.95rem;
  }

  .btn-small {
    min-height: 40px;
    padding: 10px 16px;
  }

  .btn-icon {
    width: 40px;
    height: 40px;
  }

  /* Tabelas (lista de lançamentos) mais compactas e legíveis no iPhone */
  th, td {
    padding: 12px 14px;
    font-size: 0.85rem;
  }

  .quick-actions {
    gap: 8px;
  }

  .quick-actions .btn-small {
    padding: 8px 12px;
    font-size: 0.75rem;
    min-height: 38px;
  }

  .top-header h2 {
    font-size: 1.1rem;
  }

  /* Barra de filtros das tabelas empilha em coluna cheia */
  .table-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .search-input,
  .filter-input {
    min-width: 0;
    width: 100%;
  }

  .table-filter-bar > .btn {
    width: 100%;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .card-goal-actions {
    flex-direction: column;
  }

  .month-summary-item {
    grid-template-columns: 1fr 1fr;
    row-gap: 6px;
  }
}
