/* ===== CSS VARIABLES ===== */
:root {
  --color-primary: #7c3aed;
  --color-primary-dark: #6d28d9;
  --color-primary-light: rgba(124,58,237,0.18);
  --color-danger: #f43f5e;
  --color-danger-dark: #e11d48;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-info: #38bdf8;

  --color-bg: #0b0d1a;
  --color-surface: #111322;
  --color-surface-2: #191c30;
  --color-border: #1e2240;
  --color-text: #e2e8f0;
  --color-text-secondary: #8892b0;
  --color-text-muted: #4a5578;

  --nav-height: 64px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.55), 0 2px 4px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 36px rgba(0,0,0,0.65), 0 4px 8px rgba(0,0,0,0.4);
  --transition: 0.18s ease;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
  --color-bg: #f1f3fb;
  --color-surface: #ffffff;
  --color-surface-2: #e8ebf7;
  --color-border: #dde1ef;
  --color-text: #1a1c2e;
  --color-text-secondary: #5a6280;
  --color-text-muted: #9099b8;
  --shadow: 0 2px 8px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.09), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg: 0 12px 36px rgba(0,0,0,0.11), 0 4px 8px rgba(0,0,0,0.06);
}
[data-theme="light"] body {
  background-image: radial-gradient(ellipse 80% 40% at 50% 0%, rgba(124,58,237,0.05) 0%, transparent 70%);
}
[data-theme="light"] .navbar {
  background: rgba(255,255,255,0.88);
}
[data-theme="light"] .form-input,
[data-theme="light"] .form-select {
  background: #f8f9fc;
  border-color: var(--color-border);
  color: var(--color-text);
}
[data-theme="light"] .auth-card {
  background: #ffffff;
}

/* ===== RESET ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  background-image: radial-gradient(ellipse 80% 40% at 50% 0%, rgba(124,58,237,0.12) 0%, transparent 70%);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== NAVBAR ===== */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: rgba(17, 19, 34, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1.25rem;
  z-index: 100;
  box-shadow: var(--shadow);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  flex-shrink: 0;
}

.brand-icon { font-size: 1.4rem; }

.navbar-nav {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--color-text);
  background: var(--color-bg);
}

.nav-link.active {
  color: #a78bfa;
  background: var(--color-primary-light);
}

.navbar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--color-text);
  padding: 0.25rem;
  border-radius: var(--radius);
  transition: background var(--transition);
  flex-shrink: 0;
}

.navbar-toggle:hover { background: var(--color-bg); }

.theme-toggle {
  background: none;
  border: none;
  font-size: 1.05rem;
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  border-radius: var(--radius);
  color: var(--color-text-secondary);
  transition: color var(--transition), background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}
.theme-toggle:hover { background: var(--color-bg); color: var(--color-text); }

/* Navbar brand clickable */
.navbar-brand { cursor: pointer; }

/* Hamburger dropdown */
.navbar-dropdown {
  display: none;
  position: fixed;
  top: calc(var(--nav-height) + 0.5rem);
  right: 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: 101;
  min-width: 200px;
  padding: 0.4rem;
}
.navbar-dropdown.open { display: block; }
.navbar-dropdown-item {
  display: flex;
  width: 100%;
  padding: 0.55rem 0.85rem;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  text-align: left;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.navbar-dropdown-item:hover {
  background: var(--color-bg);
  color: var(--color-text);
}
.nav-dropdown-logout { color: var(--color-danger); font-size: 0.82rem; }
.nav-link-drop { text-decoration: none; }
.navbar-dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: 0.3rem 0.4rem;
  opacity: 0.5;
}
/* Mobile subheader (title bar below navbar, mobile only) */
.mobile-subheader { display: none; }
/* Inline theme toggle (used in mobile subheader) */
.theme-toggle-inline {
  background: none;
  border: none;
  font-size: 1.05rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius);
  color: var(--color-text-secondary);
  transition: color var(--transition), background var(--transition);
  line-height: 1;
  flex-shrink: 0;
}
.theme-toggle-inline:hover { background: var(--color-surface); color: var(--color-text); }

/* Month navigator */
.month-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.month-nav-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background var(--transition);
  flex-shrink: 0;
}
.month-nav-btn:hover:not(:disabled) { background: var(--color-primary-light); color: var(--color-primary); }
.month-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.month-nav-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  min-width: 130px;
  text-align: center;
}
.month-nav-current { color: var(--color-primary) !important; }

.mobile-only { display: none; }

/* ===== FAB (Floating Action Button) ===== */
.fab {
  position: fixed;
  bottom: 1.75rem;
  right: 1.25rem;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 2rem;
  font-weight: 300;
  line-height: 1;
  border: none;
  cursor: pointer;
  z-index: 500;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background var(--transition);
}
.fab:active { transform: scale(0.92); }

/* ===== MAIN CONTENT ===== */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  margin-top: var(--nav-height);
}

/* ===== VIEW HEADER ===== */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.view-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
}

/* ===== PERIOD SELECTOR ===== */
.period-selector {
  display: flex;
  gap: 0.25rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.25rem;
}

.period-btn {
  padding: 0.35rem 0.75rem;
  border-radius: calc(var(--radius) - 2px);
  border: none;
  background: none;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.period-btn.active {
  background: var(--color-surface-2);
  color: #a78bfa;
  box-shadow: 0 0 0 1px rgba(124,58,237,0.3), var(--shadow);
}

.period-btn:hover:not(.active) {
  color: var(--color-text);
}

/* ===== STAT CARDS ===== */
.stat-cards {
  display: grid;
  gap: 0.875rem;
  margin-bottom: 0.875rem;
}

/* Fila principal — 4 tarjetas grandes */
.stat-cards-primary {
  grid-template-columns: repeat(4, 1fr);
}

.stat-cards-primary .stat-card {
  padding: 1.35rem 1.25rem;
}

.stat-cards-primary .stat-icon {
  font-size: 2rem;
}

.stat-cards-primary .stat-value {
  font-size: clamp(1.15rem, 2vw, 1.65rem);
}

.stat-cards-primary .stat-label {
  font-size: 0.72rem;
}


.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
  min-width: 0;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon { font-size: 1.5rem; flex-shrink: 0; }

.stat-info {
  min-width: 0;
  flex: 1;
}

.stat-label {
  font-size: 0.68rem;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-label-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 0.2rem;
}

.stat-label-row .stat-label {
  margin-bottom: 0;
}

.btn-toggle-patrimonio {
  background: none;
  border: none;
  padding: 1px 3px;
  cursor: pointer;
  color: #fff;
  opacity: 0.75;
  display: flex;
  align-items: center;
  line-height: 1;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.btn-toggle-patrimonio:hover {
  opacity: 1;
}

.stat-value {
  font-size: clamp(0.9rem, 1.6vw, 1.25rem);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value-sm {
  font-size: 0.95rem;
}

/* ===== STAT COLOR MODIFIERS ===== */
.stat-pos { color: #10b981 !important; }
.stat-neg { color: #f43f5e !important; }

/* ===== INSIGHTS ===== */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.insight-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow);
  transition: transform var(--transition);
  min-width: 0;
}

.insight-card:hover { transform: translateY(-2px); }
.insight-purple { border-left: 3px solid #8b5cf6; }
.insight-teal   { border-left: 3px solid #14b8a6; }
.insight-orange { border-left: 3px solid #f59e0b; }
.insight-pink   { border-left: 3px solid #ec4899; }

.insight-icon { font-size: 1.4rem; flex-shrink: 0; }

.insight-body { min-width: 0; flex: 1; }

.insight-value {
  font-size: clamp(0.85rem, 1.4vw, 1.05rem);
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insight-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== CHARTS ===== */
.charts-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-card-wide { grid-column: 1 / -1; }

.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.chart-card h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
}

.chart-wrapper {
  position: relative;
  height: 260px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--color-text-secondary);
}

.empty-icon { font-size: 3rem; margin-bottom: 1rem; }

.empty-state h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ===== CARD ===== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

/* ===== VIEW ACTIONS ===== */
.view-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.mobile-add-btn { display: none; }

/* ===== PROJECTION ===== */
.projection-inputs {
  margin-bottom: 1.5rem;
}

.projection-hint {
  display: none;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-bottom: 1rem;
}

.projection-no-hist {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  font-size: 0.82rem;
  color: #fbbf24;
  margin-bottom: 1rem;
}

.projection-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.proj-sum-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  text-align: center;
}

.proj-sum-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
}

.proj-sum-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
}

.projection-table-card {
  margin-top: 1.5rem;
}

.projection-table-wrapper {
  overflow-x: auto;
}

.projection-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.projection-table thead th {
  text-align: left;
  padding: 0.6rem 1rem;
  color: var(--color-text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--color-border);
}

.projection-table tbody td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--color-text);
}


.projection-table tbody tr:hover td {
  background: rgba(255,255,255,0.025);
}

.proj-month     { font-weight: 500; color: var(--color-text) !important; font-style: normal !important; }
.proj-patrimony { font-weight: 600; }
.proj-projected-val { color: var(--color-text-secondary); }
.proj-muted     { color: var(--color-text-muted) !important; }

.proj-row-current td {
  background:    rgba(124, 58, 237, 0.07);
  border-top:    1px solid rgba(124, 58, 237, 0.25) !important;
  border-bottom: 1px solid rgba(124, 58, 237, 0.25) !important;
}

.proj-now-badge {
  display:        inline-block;
  margin-left:    0.4rem;
  padding:        0.1rem 0.45rem;
  background:     rgba(124, 58, 237, 0.25);
  color:          #a78bfa;
  border-radius:  99px;
  font-size:      0.68rem;
  font-weight:    600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

.chart-wrapper-tall { height: 260px; }

.planned-badge {
  display:        inline-block;
  margin-left:    0.4rem;
  padding:        0.1rem 0.45rem;
  background:     rgba(245, 158, 11, 0.15);
  color:          #f59e0b;
  border-radius:  99px;
  font-size:      0.68rem;
  font-weight:    600;
  vertical-align: middle;
}

.proj-snapshot-info {
  margin-top:  0.75rem;
  font-size:   0.8rem;
  color:       var(--color-text-muted);
  padding:     0.5rem 0.75rem;
  background:  rgba(124, 58, 237, 0.07);
  border:      1px solid rgba(124, 58, 237, 0.15);
  border-radius: var(--radius);
}

/* ==============================================
   BUDGET INSIGHT (dashboard)
   ============================================== */

.budget-insight {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}
.budget-insight-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}
.budget-insight-title {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  font-weight: 500;
}
.budget-months-tag {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
}
.budget-bar-track {
  height: 6px;
  background: var(--color-border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.budget-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease, background 0.3s;
}
.budget-insight-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.875rem;
  font-weight: 500;
}
.budget-pct { font-weight: 700; }
.budget-footer {
  font-size: 0.78rem;
  margin-top: 0.35rem;
}

/* ==============================================
   PROJECTION IMPROVEMENTS
   ============================================== */

.view-subtitle {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin: 0.2rem 0 0;
}

.proj-trend-card {
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1rem;
}
.proj-trend-icon { font-size: 1.2rem; flex-shrink: 0; }
.proj-trend-up   { background: rgba(16,185,129,0.1); color: #10b981; border: 1px solid rgba(16,185,129,0.2); }
.proj-trend-down { background: rgba(244,63,94,0.1);  color: var(--color-danger); border: 1px solid rgba(244,63,94,0.2); }

.proj-early-income-note {
  font-size: 0.78rem;
  color: #f59e0b;
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  margin-top: 0.75rem;
  line-height: 1.5;
}

/* ==============================================
   BUDGET VIEW
   ============================================== */

.budget-setup-card h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 1rem;
}

.budget-mode-toggle {
  display: flex;
  gap: 0.5rem;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.25rem;
  align-self: flex-start;
}

.budget-mode-btn {
  padding: 0.4rem 1rem;
  border-radius: calc(var(--radius) - 2px);
  border: none;
  background: none;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.budget-mode-btn.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 0 0 1px rgba(124,58,237,0.3), var(--shadow);
  color: #a78bfa;
}

.budget-auto-hint {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  padding: 0.75rem 1rem;
  background: rgba(99, 102, 241, 0.07);
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: var(--radius);
}

.budget-computed-hint {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
  font-size: 0.82rem;
  color: var(--color-text-secondary);
  padding: 0.6rem 0.85rem;
  background: rgba(16, 185, 129, 0.07);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius);
}

.budget-computed-note {
  color: var(--color-text-muted);
  font-size: 0.78rem;
}

.budget-no-history {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.budget-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.budget-section-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.budget-months-badge {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  padding: 0.15rem 0.6rem;
  border-radius: 99px;
  border: 1px solid var(--color-border);
}

/* Category rows */
.budget-cat-row {
  margin-bottom: 1.1rem;
}

.budget-cat-row:last-child { margin-bottom: 0; }

.budget-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.budget-cat-name {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
}

.budget-cat-pct {
  font-size: 0.8rem;
  font-weight: 700;
}

.budget-cat-bar-track {
  height: 8px;
  background: var(--color-border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.35rem;
}

.budget-cat-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
}

.budget-cat-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  flex-wrap: wrap;
  gap: 0.25rem;
}

.budget-cat-avg {
  font-weight: 600;
  color: var(--color-text-secondary);
}

.budget-cat-unit {
  font-weight: 400;
  color: var(--color-text-muted);
}

.budget-cat-last { color: var(--color-text-muted); }

.budget-peak-note {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 600;
}

/* Monthly table */
.budget-table-wrapper { overflow-x: auto; }

.budget-monthly-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.budget-monthly-table thead th {
  text-align: left;
  padding: 0.5rem 0.85rem;
  color: var(--color-text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
}

.budget-monthly-table tbody td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--color-text);
}

.budget-monthly-table tbody tr:hover td { background: rgba(255,255,255,0.02); }

.budget-row-current td {
  background: rgba(124, 58, 237, 0.06);
  border-top:    1px solid rgba(124, 58, 237, 0.2) !important;
  border-bottom: 1px solid rgba(124, 58, 237, 0.2) !important;
}

.budget-tx-count { color: var(--color-text-muted); }
.budget-empty-note { font-size: 0.875rem; color: var(--color-text-muted); }

/* ==============================================
   PROJECTION HORIZONS
   ============================================== */

.projection-summary-2 {
  grid-template-columns: repeat(2, 1fr);
}

.proj-horizons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.proj-horizon-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  text-align: center;
  transition: transform var(--transition), box-shadow var(--transition);
}

.proj-horizon-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.proj-horizon-featured {
  border-color: rgba(124, 58, 237, 0.4);
  background: rgba(124, 58, 237, 0.05);
}

.proj-horizon-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.proj-horizon-value {
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.3rem;
}

.proj-horizon-delta {
  font-size: 0.82rem;
  font-weight: 600;
}

.proj-horizon-note {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  margin-top: 0.3rem;
}

/* ===== IMPORT MODAL ===== */
.import-preview-wrapper {
  overflow-x: auto;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.import-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.import-preview-table th,
.import-preview-table td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--color-border);
}
.import-preview-table th {
  background: var(--color-surface);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}
.import-preview-table .preview-desc {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.import-preview-table .preview-amount { text-align: right; white-space: nowrap; }
.import-preview-table .import-expense  { color: var(--color-danger); }
.import-preview-table .import-income   { color: var(--color-success); }
.import-row-dup { opacity: 0.55; }
.import-dup-badge {
  font-size: 0.65rem;
  background: var(--color-warning, #f59e0b);
  color: #fff;
  border-radius: 3px;
  padding: 0 3px;
  margin-left: 4px;
}
.import-dup-notice {
  color: var(--color-warning, #f59e0b);
  margin-bottom: 0.5rem;
}
.import-income-label {
  font-size: 0.75rem;
  color: var(--color-success);
  font-weight: 600;
}

/* ── Categories panel (inside Expenses) ─────────────────────────────────── */
.categories-panel {
  margin-bottom: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.categories-panel-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  background: var(--color-surface);
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  text-align: left;
}
.categories-panel-toggle:hover { background: var(--color-border); }
.cat-count-badge {
  background: var(--color-primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 99px;
  padding: 0 6px;
  min-width: 18px;
  text-align: center;
}
.categories-toggle-arrow { margin-left: auto; font-size: 0.75rem; color: var(--color-text-muted); }
.categories-panel-body { padding: 0.75rem; background: var(--color-bg); }
.cat-add-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.cat-add-row .form-input { flex: 1; min-width: 120px; font-size: 0.85rem; padding: 0.35rem 0.6rem; }
.cat-add-row .form-color { width: 36px; height: 34px; padding: 2px; border-radius: var(--radius); cursor: pointer; }
#categories-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.25rem; }
.cat-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 99px;
  padding: 0.2rem 0.5rem 0.2rem 0.35rem;
  font-size: 0.78rem;
}
.cat-chip-swatch { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cat-chip-name { font-weight: 500; }
.cat-chip-count { color: var(--color-text-muted); font-size: 0.72rem; }
.cat-chip-actions { display: flex; gap: 0.1rem; margin-left: 0.15rem; }
.cat-chip-actions .btn-icon { font-size: 0.7rem; padding: 0 2px; opacity: 0.6; }
.cat-chip-actions .btn-icon:hover { opacity: 1; }
.cat-chip .cat-edit-row {
  display: flex; gap: 0.4rem; align-items: center;
}
.cat-chip .cat-edit-row .form-input { font-size: 0.8rem; padding: 0.2rem 0.4rem; width: 120px; }
.cat-chip .cat-edit-row .form-color { width: 28px; height: 26px; padding: 1px; }

/* ── Expense modal redesign ──────────────────────────────────────────────── */
.modal-expense-new { max-width: 380px; }

/* Amount hero */
.expense-amount-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  margin-bottom: 1.1rem;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.expense-amount-hero:focus-within { border-color: var(--color-primary); }
.expense-amount-prefix {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text-muted);
  line-height: 1;
}
.expense-amount-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--color-text);
  text-align: left;
  width: 100%;
  -moz-appearance: textfield;
}
.expense-amount-input::-webkit-outer-spin-button,
.expense-amount-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.expense-amount-input::placeholder { color: var(--color-text-muted); opacity: 0.4; }

/* 2-col row */
.expense-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.form-label-sm {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

/* Planned toggle row */
.expense-planned-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  background: var(--color-surface);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
}
.expense-planned-info { display: flex; flex-direction: column; gap: 0.1rem; }
.expense-planned-title { font-size: 0.85rem; font-weight: 600; }
.expense-planned-hint { font-size: 0.72rem; color: var(--color-text-muted); }

/* Toggle switch */
.toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--color-border);
  border-radius: 99px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--color-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }
