/* =============================================
   FINANCEHUB — PREMIUM FINANCIAL DASHBOARD CSS
   ============================================= */

/* CSS VARIABLES */
:root {
  /* Colors */
  --income: #22C55E;
  --income-soft: rgba(34, 197, 94, 0.15);
  --expense: #EF4444;
  --expense-soft: rgba(239, 68, 68, 0.15);
  --invest: #0EA5E9;
  --invest-soft: rgba(14, 165, 233, 0.15);
  --debt: #F97316;
  --debt-soft: rgba(249, 115, 22, 0.15);
  --purple: #A78BFA;
  --purple-soft: rgba(167, 139, 250, 0.15);
  --warning: #F59E0B;
  --warning-soft: rgba(245, 158, 11, 0.15);

  /* Sidebar */
  --sidebar-width: 256px;
  --sidebar-collapsed: 70px;
  --topbar-height: 72px;
}

/* DARK THEME */
[data-theme="dark"] {
  --bg-primary: #0F172A;
  --bg-secondary: #1E293B;
  --bg-tertiary: #334155;
  --bg-card: #1E293B;
  --bg-hover: #2D3748;
  --border: rgba(255,255,255,0.08);
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --sidebar-bg: #111827;
  --sidebar-text: #CBD5E1;
  --sidebar-active: rgba(167, 139, 250, 0.2);
  --sidebar-active-text: #A78BFA;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --chart-grid: rgba(255,255,255,0.06);
}

/* LIGHT THEME */
[data-theme="light"] {
  --bg-primary: #F1F5F9;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-hover: #F1F5F9;
  --border: rgba(0,0,0,0.08);
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --sidebar-bg: #0F172A;
  --sidebar-text: #CBD5E1;
  --sidebar-active: rgba(167, 139, 250, 0.25);
  --sidebar-active-text: #A78BFA;
  --shadow: 0 4px 24px rgba(0,0,0,0.1);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --chart-grid: rgba(0,0,0,0.06);
}

/* RESET & BASE */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 999px; }

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.3s ease, transform 0.3s ease;
  border-right: 1px solid rgba(255,255,255,0.05);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px;
  min-height: 72px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #A78BFA, #7C3AED);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 15px;
  flex-shrink: 0;
}

.logo-text {
  font-size: 17px;
  font-weight: 700;
  color: #F1F5F9;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .user-info,
.sidebar.collapsed .theme-toggle span { opacity: 0; width: 0; overflow: hidden; }

.sidebar-toggle {
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  font-size: 14px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.08); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  margin: 8px;
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  overflow: hidden;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #A78BFA, #7C3AED);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: white;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: #F1F5F9;
  white-space: nowrap;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

/* NAV */
.sidebar-nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 12px 8px 4px;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  margin-bottom: 2px;
  white-space: nowrap;
  position: relative;
}

.nav-item i {
  width: 18px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: #F1F5F9;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-text);
}

.nav-badge {
  margin-left: auto;
  background: var(--purple);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

/* SIDEBAR FOOTER */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  width: 100%;
  border: none;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.theme-toggle:hover { background: rgba(255,255,255,0.08); }
.theme-toggle i { font-size: 14px; flex-shrink: 0; }

/* OVERLAY */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.overlay.active { display: block; }

/* =============================================
   MAIN CONTENT
   ============================================= */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }

/* TOPBAR */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
}

.page-title h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-title p {
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.period-selector {
  display: flex;
  gap: 8px;
}

.period-selector select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.period-selector select:focus { border-color: var(--purple); }

.btn-add {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #A78BFA, #7C3AED);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
}
.btn-add:hover { opacity: 0.9; transform: translateY(-1px); }

.topbar-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #A78BFA, #7C3AED);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
  cursor: pointer;
}

/* =============================================
   PAGES
   ============================================= */
.pages-container {
  flex: 1;
  overflow-y: auto;
}

.page {
  display: none;
  padding: 24px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

.page.active { display: block; }

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

/* =============================================
   CARDS GRID
   ============================================= */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.cards-grid-5 {
  grid-template-columns: repeat(5, 1fr);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.card-income .card-icon { background: var(--income-soft); color: var(--income); }
.card-expense .card-icon { background: var(--expense-soft); color: var(--expense); }
.card-balance .card-icon { background: var(--invest-soft); color: var(--invest); }
.card-savings .card-icon { background: var(--purple-soft); color: var(--purple); }

.card-content { display: flex; flex-direction: column; gap: 3px; }
.card-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.card-value { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.card-change { font-size: 11px; font-weight: 500; display: flex; align-items: center; gap: 4px; }
.card-change.positive { color: var(--income); }
.card-change.negative { color: var(--expense); }

/* SMALL CARDS */
.card-sm {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px;
}
.card-sm-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.card-sm-label i { font-size: 12px; }
.card-sm-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

/* =============================================
   CHARTS
   ============================================= */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.charts-grid-3 {
  grid-template-columns: 1fr 2fr;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.chart-card.col-span-2 { grid-column: span 1; }

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.chart-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.chart-legend {
  display: flex;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-item span {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend-item.income span { background: var(--income); }
.legend-item.expense span { background: var(--expense); }

.chart-wrapper { position: relative; }

.chart-link {
  font-size: 12px;
  color: var(--purple);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.2s;
}
.chart-link:hover { opacity: 0.7; }

/* =============================================
   RECENT TRANSACTIONS (Dashboard)
   ============================================= */
.recent-transactions { display: flex; flex-direction: column; gap: 12px; }

.transaction-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.transaction-item:last-child { border-bottom: none; }

.t-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.t-food { background: rgba(245,158,11,0.15); color: #F59E0B; }
.t-income { background: var(--income-soft); color: var(--income); }
.t-transport { background: rgba(14,165,233,0.15); color: #0EA5E9; }
.t-health { background: rgba(239,68,68,0.15); color: #EF4444; }
.t-invest { background: var(--invest-soft); color: var(--invest); }

.t-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.t-desc { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.t-cat { font-size: 11px; color: var(--text-muted); }

.t-value { font-size: 13px; font-weight: 700; white-space: nowrap; }
.t-value.positive { color: var(--income); }
.t-value.negative { color: var(--expense); }
.t-value.invest { color: var(--invest); }

/* =============================================
   ALERTS
   ============================================= */
.alerts-section { margin-top: 4px; }
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title i { color: var(--purple); }

.alerts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.alert-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
}

.alert-warning { background: var(--warning-soft); border-color: rgba(245,158,11,0.2); }
.alert-danger { background: var(--expense-soft); border-color: rgba(239,68,68,0.2); }
.alert-success { background: var(--income-soft); border-color: rgba(34,197,94,0.2); }

.alert-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.alert-warning .alert-icon { color: var(--warning); }
.alert-danger .alert-icon { color: var(--expense); }
.alert-success .alert-icon { color: var(--income); }

.alert-content { flex: 1; }
.alert-title { font-size: 13px; font-weight: 600; color: var(--text-primary); display: block; }
.alert-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; display: block; }

.alert-action {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.2s;
}
.alert-action:hover { background: var(--bg-hover); color: var(--text-primary); }

/* =============================================
   LANÇAMENTOS PAGE
   ============================================= */
.page-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  flex: 1;
  min-width: 200px;
}

.search-box i { color: var(--text-muted); font-size: 13px; }
.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  width: 100%;
}
.search-box input::placeholder { color: var(--text-muted); }

.filter-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  outline: none;
}

.summary-chips {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.chip-income { background: var(--income-soft); color: var(--income); }
.chip-expense { background: var(--expense-soft); color: var(--expense); }
.chip-balance { background: var(--invest-soft); color: var(--invest); }
.chip-pending { background: var(--warning-soft); color: var(--warning); }

/* TABLE */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

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

.table-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-hover); }

/* TAGS */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.tag-blue { background: rgba(14,165,233,0.15); color: #0EA5E9; }
.tag-green { background: rgba(34,197,94,0.15); color: #22C55E; }
.tag-orange { background: rgba(249,115,22,0.15); color: #F97316; }
.tag-purple { background: rgba(167,139,250,0.15); color: #A78BFA; }
.tag-red { background: rgba(239,68,68,0.15); color: #EF4444; }
.tag-gray { background: rgba(100,116,139,0.15); color: #64748B; }

/* STATUS BADGES */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: rgba(34,197,94,0.15); color: var(--income); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--expense); }
.badge-progress { background: rgba(167,139,250,0.15); color: var(--purple); }

/* ACTION BUTTONS */
.action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 12px;
  transition: all 0.2s;
}
.action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* PAGINATION */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 16px 0;
}

.page-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  transition: all 0.2s;
}
.page-btn:hover, .page-btn.active { background: var(--purple); border-color: var(--purple); color: white; }

.page-info {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}

/* =============================================
   BUTTONS
   ============================================= */
.btn-primary {
  background: linear-gradient(135deg, #A78BFA, #7C3AED);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* =============================================
   CALENDÁRIO PAGE
   ============================================= */
.calendar-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
}

.calendar-main {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

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

.calendar-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.cal-nav {
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-nav:hover { background: var(--purple); color: white; }

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.calendar-weekdays span {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 8px 0;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  color: var(--text-primary);
  position: relative;
  padding: 4px;
  min-height: 52px;
}

.cal-day:hover { background: var(--bg-hover); }
.cal-day.today {
  background: linear-gradient(135deg, rgba(167,139,250,0.3), rgba(124,58,237,0.3));
  color: var(--purple);
  font-weight: 700;
  border: 1px solid rgba(167,139,250,0.4);
}

.cal-day.other-month { color: var(--text-muted); opacity: 0.4; }
.cal-day.has-event::after {
  content: '';
  position: absolute;
  bottom: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--expense);
}
.cal-day.has-event-income::after { background: var(--income); }
.cal-day.has-due::after { background: var(--warning); }

.cal-day-num { font-size: 13px; font-weight: 500; }
.cal-day-dot { 
  display: flex; 
  gap: 2px; 
  margin-top: 2px;
}
.dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
}
.dot-red { background: var(--expense); }
.dot-green { background: var(--income); }
.dot-yellow { background: var(--warning); }

/* CALENDAR SIDEBAR */
.calendar-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cal-today-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.cal-today-card h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.cal-today-stats { display: flex; gap: 10px; }

.cal-stat {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cal-stat.income { background: var(--income-soft); }
.cal-stat.expense { background: var(--expense-soft); }

.cal-stat span { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.cal-stat.income span { color: var(--income); }
.cal-stat.expense span { color: var(--expense); }

.cal-stat strong {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.cal-events {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.cal-events h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.cal-event {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid transparent;
}

.event-danger { background: var(--expense-soft); border-color: rgba(239,68,68,0.2); }
.event-warning { background: var(--warning-soft); border-color: rgba(245,158,11,0.2); }
.event-normal { background: var(--bg-hover); }

.cal-event-date {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
}

.event-danger .cal-event-date { background: rgba(239,68,68,0.25); color: var(--expense); }
.event-warning .cal-event-date { background: rgba(245,158,11,0.25); color: var(--warning); }

.cal-event-info { flex: 1; }
.cal-event-title { font-size: 13px; font-weight: 600; color: var(--text-primary); display: block; }
.cal-event-value { font-size: 12px; color: var(--text-muted); }

/* =============================================
   CARTÕES PAGE
   ============================================= */
.cards-list {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.credit-card-visual {
  min-width: 280px;
  height: 160px;
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: white;
  cursor: pointer;
  transition: transform 0.3s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  position: relative;
  overflow: hidden;
}

.credit-card-visual::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}

.credit-card-visual::after {
  content: '';
  position: absolute;
  bottom: -40px;
  right: 20px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
}

.credit-card-visual:hover { transform: translateY(-4px) rotate(1deg); }

.nubank { background: linear-gradient(135deg, #6820A0, #A020F0); }
.itau { background: linear-gradient(135deg, #EC6B00, #FF9A00); }
.santander { background: linear-gradient(135deg, #CC0000, #FF2222); }

.cc-top { display: flex; justify-content: space-between; align-items: flex-start; }
.cc-name { font-size: 13px; font-weight: 600; opacity: 0.9; }
.cc-brand { font-size: 26px; opacity: 0.8; }
.cc-number { font-size: 15px; font-weight: 600; letter-spacing: 3px; }

.cc-bottom { display: flex; gap: 24px; }
.cc-label { font-size: 9px; opacity: 0.7; text-transform: uppercase; letter-spacing: 1px; display: block; }
.cc-val { font-size: 12px; font-weight: 600; }

/* CARDS DETAILS */
.cards-details-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.card-detail-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.cd-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.cd-tag {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: white;
}

.nubank-tag { background: #6820A0; }
.itau-tag { background: #EC6B00; }
.santander-tag { background: #CC0000; }

.cd-dates { display: flex; gap: 12px; }
.cd-dates span { font-size: 12px; color: var(--text-muted); }
.cd-dates strong { color: var(--text-primary); }

.cd-limits { margin-bottom: 14px; }
.cd-limit-info { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.cd-limit-info strong { color: var(--text-primary); }

.limit-bar {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  margin-bottom: 6px;
  overflow: hidden;
}

.limit-fill {
  height: 100%;
  border-radius: 999px;
}

.nubank-fill { background: linear-gradient(90deg, #6820A0, #A020F0); }
.itau-fill { background: linear-gradient(90deg, #EC6B00, #FF9A00); }
.santander-fill { background: linear-gradient(90deg, #CC0000, #FF2222); }

.cd-usage { font-size: 11px; color: var(--text-muted); }

.cd-transactions h4 { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }

.cd-tx {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
.cd-tx:last-child { border-bottom: none; }

/* =============================================
   CONTAS PAGE
   ============================================= */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s;
}
.account-card:hover { transform: translateY(-2px); }

.acc-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.acc-cc .acc-icon { background: rgba(14,165,233,0.15); color: #0EA5E9; }
.acc-digital .acc-icon { background: rgba(167,139,250,0.15); color: #A78BFA; }
.acc-savings .acc-icon { background: rgba(34,197,94,0.15); color: #22C55E; }
.acc-wallet .acc-icon { background: rgba(245,158,11,0.15); color: #F59E0B; }
.acc-invest .acc-icon { background: rgba(14,165,233,0.15); color: #0EA5E9; }
.acc-total .acc-icon { background: rgba(167,139,250,0.15); color: #A78BFA; }

.acc-info { display: flex; flex-direction: column; gap: 2px; }
.acc-name { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.acc-bank { font-size: 12px; color: var(--text-muted); }
.acc-balance { font-size: 22px; font-weight: 800; color: var(--text-primary); }
.acc-bar { display: flex; gap: 12px; font-size: 11px; color: var(--text-muted); flex-wrap: wrap; }
.acc-in { color: var(--income); }
.acc-out { color: var(--expense); }

/* =============================================
   DÍVIDAS PAGE
   ============================================= */
.debts-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.debt-summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.dsc-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.dsc-value { font-size: 20px; font-weight: 700; color: var(--text-primary); }

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

.debt-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.debt-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.debt-car { background: rgba(249,115,22,0.15); color: #F97316; }
.debt-personal { background: rgba(167,139,250,0.15); color: #A78BFA; }

.debt-info { flex: 1; min-width: 140px; }
.debt-name { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.debt-details { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.debt-progress-wrap { flex: 2; min-width: 200px; }
.debt-parcela { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.debt-parcela strong { color: var(--text-primary); font-size: 14px; }

.debt-bar-wrap { display: flex; align-items: center; gap: 8px; }

.debt-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
}

.debt-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--income), #16A34A);
  border-radius: 999px;
  transition: width 0.8s ease;
}

.debt-pct { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.debt-total { min-width: 120px; text-align: right; }
.debt-total span { font-size: 11px; color: var(--text-muted); display: block; }
.debt-total strong { font-size: 16px; font-weight: 700; }

/* =============================================
   METAS PAGE
   ============================================= */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.goal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s;
}
.goal-card:hover { transform: translateY(-2px); }

.goal-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.goal-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.goal-travel { background: rgba(14,165,233,0.15); color: #0EA5E9; }
.goal-reserve { background: var(--income-soft); color: var(--income); }
.goal-tech { background: var(--purple-soft); color: var(--purple); }

.goal-info { flex: 1; }
.goal-info h3 { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.goal-cat { font-size: 11px; color: var(--text-muted); }

.goal-values {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: 10px;
}

.goal-values div { display: flex; flex-direction: column; gap: 3px; }
.goal-values span { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.goal-values strong { font-size: 14px; font-weight: 700; color: var(--text-primary); }

.goal-bar-wrap { }

.goal-bar {
  height: 10px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.goal-fill {
  height: 100%;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  transition: width 0.8s ease;
}

.goal-pct {
  font-size: 8px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
}

.goal-fill-travel { background: linear-gradient(90deg, #0EA5E9, #38BDF8); }
.goal-fill-reserve { background: linear-gradient(90deg, #22C55E, #4ADE80); }
.goal-fill-tech { background: linear-gradient(90deg, #A78BFA, #C4B5FD); }

.goal-add {
  border: 2px dashed var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  transition: all 0.2s;
}

.goal-add:hover { border-color: var(--purple); background: var(--purple-soft); }

.goal-add-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}
.goal-add:hover .goal-add-content { color: var(--purple); }
.goal-add-content i { font-size: 28px; }
.goal-add-content span { font-size: 13px; font-weight: 600; }

/* =============================================
   INVESTIMENTOS PAGE
   ============================================= */
.invest-header-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.invest-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.ikpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.ikpi-value { font-size: 20px; font-weight: 700; color: var(--text-primary); }

.invest-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  align-items: start;
}

.invest-chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.invest-chart-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.invest-table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* =============================================
   MODAL
   ============================================= */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 1000;
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body { padding: 20px 24px; }

.modal-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
}

.modal-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.2s;
}

.modal-tab.active {
  background: linear-gradient(135deg, #A78BFA, #7C3AED);
  color: white;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input,
.form-group select {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-primary);
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus { border-color: var(--purple); }

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.form-check input { width: auto; }
.form-check label { font-size: 13px; color: var(--text-secondary); font-weight: normal; text-transform: none; letter-spacing: 0; }

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* =============================================
   COLOR UTILITIES
   ============================================= */
.positive { color: var(--income) !important; }
.negative { color: var(--expense) !important; }
.text-invest { color: var(--invest) !important; }
.text-expense { color: var(--expense) !important; }
.text-income { color: var(--income) !important; }
.text-debt { color: var(--debt) !important; }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 1280px) {
  .cards-grid-5 { grid-template-columns: repeat(3, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .charts-grid-3 { grid-template-columns: 1fr; }
  .invest-layout { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .calendar-layout { grid-template-columns: 1fr; }
  .cards-details-grid { grid-template-columns: repeat(2, 1fr); }
  .accounts-grid { grid-template-columns: repeat(2, 1fr); }
  .alerts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root {
    --sidebar-width: 256px;
    --topbar-height: 60px;
  }

  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }

  .sidebar.mobile-open { transform: translateX(0); }

  .main-content { margin-left: 0 !important; }

  .mobile-menu-btn { display: flex; }

  .topbar { padding: 0 16px; }

  .period-selector { display: none; }

  .btn-add span { display: none; }
  .btn-add { padding: 8px; }

  .page { padding: 16px; }

  .cards-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cards-grid-5 { grid-template-columns: repeat(2, 1fr); }
  .debts-summary { grid-template-columns: repeat(2, 1fr); }
  .invest-header-cards { grid-template-columns: repeat(2, 1fr); }
  .cards-details-grid { grid-template-columns: 1fr; }
  .accounts-grid { grid-template-columns: 1fr; }
  .goals-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .form-row { grid-template-columns: 1fr; }
  .debt-item { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .cards-grid { grid-template-columns: 1fr; }
  .cards-grid-5 { grid-template-columns: 1fr; }
  .debts-summary { grid-template-columns: 1fr; }
  .invest-header-cards { grid-template-columns: 1fr; }
  .goal-values { grid-template-columns: 1fr; }
  .summary-chips { flex-direction: column; }
}
