.dashboard-page {
  box-sizing: border-box;
  padding: 40px;
  font-family: var(--font);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.page-title {
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 24px;
}

.dashboard-resumo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.dashboard-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.card-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.card-valor {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
}

.card-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--surface-2);
}

.card-icon svg {
  width: 22px;
  height: 22px;
}

.card-saldo {
  border-left: 3px solid var(--accent);
}
.card-saldo .card-icon {
  background: var(--accent-soft);
  color: var(--accent);
}

.card-entradas {
  border-left: 3px solid var(--positive);
}
.card-entradas .card-icon {
  background: var(--accent-soft);
  color: var(--positive);
}
.card-entradas .card-valor {
  color: var(--positive);
}

.card-saidas {
  border-left: 3px solid var(--negative);
}
.card-saidas .card-icon {
  background: var(--danger-soft);
  color: var(--negative);
}
.card-saidas .card-valor {
  color: var(--negative);
}

.card-investido {
  border-left: 3px solid var(--border-strong);
}
.card-investido .card-icon {
  background: var(--surface-2);
  color: var(--text-secondary);
}

/* ===== Grid inferior ===== */
.dashboard-grid {
  display: grid;
  /* minmax(0,…): sem isso a faixa não encolhe abaixo do conteúdo mínimo
     da tabela interna e a página alarga no celular */
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.grid-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  min-height: 0;
  min-width: 0;
}

.grid-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

.card-title h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.btn-ver-todas {
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-ver-todas:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: var(--accent);
}

.table-container {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.tabela-recentes {
  width: 100%;
  border-collapse: collapse;
}

.tabela-recentes th {
  text-align: left;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.tabela-recentes td {
  padding: 12px;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

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

/* ===== Gasto por categoria ===== */
.insights-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  min-height: 0;
}

.maior-gasto-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  background: var(--danger-soft);
  box-sizing: border-box;
}

.maior-gasto-alert .alert-icon {
  width: 22px;
  height: 22px;
  color: var(--negative);
}

.alert-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--negative);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.alert-desc {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* Filtros do topo (categoria + mês) */
.dash-filtros {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.categories-progress-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-progress-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.category-progress-item:hover {
  background: var(--surface-2);
}

.category-progress-item.ativo {
  background: var(--accent-soft);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.progress-header .pct {
  font-weight: 600;
  color: var(--text-muted);
}

.progress-bar-bg {
  height: 8px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (max-width: 1050px) {
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 650px) {
  .dashboard-page {
    padding: 24px;
  }
  /* filtros lado a lado ocupando a largura toda */
  .dash-filtros {
    width: 100%;
  }
  .dash-filtros .month-select {
    flex: 1;
    min-width: 0;
  }
  /* recentes: some a coluna Data (cabe sem scroll; a data completa está em Transações) */
  .tabela-recentes th:nth-child(3),
  .tabela-recentes td:nth-child(3) {
    display: none;
  }
  .recent-transactions .table-container {
    overflow-x: auto; /* plano B para descrições muito longas */
  }
}

@media (max-width: 500px) {
  .dashboard-page {
    padding: 16px;
  }
  .card-valor {
    font-size: 22px;
  }
}
