/* =============================================
   FLOWTRACK — Premium Fintech Dashboard
   style.css
   ============================================= */

/* ---- CSS VARIABLES ---- */
:root {
  /* Dark theme (default) */
  --bg-base: #0D0F14;
  --bg-surface: #13161E;
  --bg-card: #181C26;
  --bg-card-hover: #1E2332;
  --bg-elevated: #1E2332;
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.12);

  --text-primary: #E8EAF0;
  --text-secondary: #8890A4;
  --text-tertiary: #4E566A;
  --text-inverse: #0D0F14;

  --gold: #C9A84C;
  --gold-light: #E8C86D;
  --gold-dim: rgba(201,168,76,0.15);
  --gold-glow: rgba(201,168,76,0.25);

  --green: #3EC97E;
  --green-dim: rgba(62,201,126,0.12);
  --red: #E05555;
  --red-dim: rgba(224,85,85,0.12);
  --blue: #4D8EFF;
  --blue-dim: rgba(77,142,255,0.12);
  --purple: #9B72F5;
  --purple-dim: rgba(155,114,245,0.12);
  --orange: #F59B42;
  --orange-dim: rgba(245,155,66,0.12);
  --teal: #3EC9C3;
  --teal-dim: rgba(62,201,195,0.12);

  --sidebar-width: 240px;
  --topbar-height: 64px;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
  --shadow-gold: 0 0 30px rgba(201,168,76,0.15);

  --transition: 0.2s ease;
  --transition-slow: 0.35s cubic-bezier(0.4,0,0.2,1);

  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

[data-theme="light"] {
  --bg-base: #F4F5F8;
  --bg-surface: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F8F9FC;
  --bg-elevated: #FFFFFF;
  --border: rgba(0,0,0,0.07);
  --border-strong: rgba(0,0,0,0.12);

  --text-primary: #141820;
  --text-secondary: #5A6278;
  --text-tertiary: #A0A8BC;
  --text-inverse: #FFFFFF;

  --gold: #B8922E;
  --gold-light: #D4A840;
  --gold-dim: rgba(184,146,46,0.1);
  --gold-glow: rgba(184,146,46,0.15);

  --green-dim: rgba(62,201,126,0.08);
  --red-dim: rgba(224,85,85,0.08);
  --blue-dim: rgba(77,142,255,0.08);
  --purple-dim: rgba(155,114,245,0.08);
  --orange-dim: rgba(245,155,66,0.08);
  --teal-dim: rgba(62,201,195,0.08);

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.1);
  --shadow-gold: 0 0 30px rgba(184,146,46,0.08);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
  transition: background var(--transition-slow), color var(--transition-slow);
  overflow-x: hidden;
}

/* ---- MOBILE NAVIGATION (NEW) ---- */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  z-index: 150;
  padding: 0 10px;
  justify-content: space-around;
  align-items: center;
  backdrop-filter: blur(10px);
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition);
}

.mobile-nav-item svg { width: 22px; height: 22px; }
.mobile-nav-item.active { color: var(--gold); }

.mobile-nav-fab-space { width: 60px; }

/* ---- FLOATING ACTION BUTTON (NEW) ---- */
.fab {
  position: fixed;
  bottom: 35px;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border-radius: 50%;
  border: none;
  display: none;
  align-items: center;
  justify-content: center;
  color: #000;
  box-shadow: 0 8px 16px rgba(201,168,76,0.3);
  z-index: 160;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fab svg { width: 24px; height: 24px; }

.fab:active {
  transform: translateX(-50%) scale(0.9);
  box-shadow: 0 4px 8px rgba(201,168,76,0.3);
}

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--topbar-height);
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.logo-mark svg {
  width: 32px;
  height: 32px;
  display: block;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.nav-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gold-dim);
  opacity: 0;
  transition: opacity var(--transition);
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.nav-item.active {
  color: var(--gold);
  background: var(--gold-dim);
  font-weight: 600;
}

.nav-item.active .nav-icon svg {
  stroke: var(--gold);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

.nav-label {
  font-family: var(--font-body);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  transition: background var(--transition);
  cursor: pointer;
}

.user-profile:hover {
  background: var(--bg-elevated);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--bg-base);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

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

.user-plan {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ---- MAIN CONTENT ---- */
.main-content {
  /* margin-left will be controlled by JS/class for desktop */
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-slow);
}

/* ---- TOPBAR ---- */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  z-index: 50;
  backdrop-filter: blur(12px);
  transition: background var(--transition-slow);
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition);
}

/* ---- COACH WIDGET ---- */
.coach-widget {
  background: var(--gold-dim);
  border: 1px solid var(--gold-glow);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  align-items: center;
}

.coach-avatar {
  width: 48px;
  height: 48px;
  background: var(--gold);
  color: var(--text-inverse);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.coach-avatar svg { width: 28px; height: 28px; }

.coach-name {
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold);
  margin-bottom: 4px;
}

.coach-bubble {
  font-size: 15px;
  line-height: 1.4;
  color: var(--text-primary);
}

/* ---- SCORE PILL ---- */
.score-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-elevated);
  border-radius: 100px;
  font-weight: 700;
  font-size: 13px;
  border: 1px solid var(--gold-glow);
}

/* ---- WEEKLY REVIEW ---- */
.weekly-review-content {
  padding: 0 22px 22px;
}

.review-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.review-val {
  font-weight: 700;
  color: var(--gold);
}

/* ---- BUTTONS ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: #0D0F14;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-gold);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary.full-width {
  width: 100%;
  justify-content: center;
  padding: 12px;
  border-radius: var(--radius-md);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-tertiary);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(224,85,85,0.25);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-danger:hover {
  background: rgba(224,85,85,0.2);
}

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

.btn-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ---- SECTIONS ---- */
.section {
  display: none;
  padding: 28px;
  flex: 1;
  animation: fadeSlideIn 0.3s ease;
}

.section.active {
  display: block;
}

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

.section-header {
  margin-bottom: 24px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.section-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  cursor: default;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  opacity: 0.05;
  transform: translate(30%, -30%);
  transition: opacity var(--transition);
}

.balance-card::after { background: var(--gold); }
.income-card::after  { background: var(--green); }
.expense-card::after { background: var(--red); }
.savings-card::after { background: var(--blue); }

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

.stat-card:hover::after { opacity: 0.1; }

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

.stat-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg {
  width: 18px;
  height: 18px;
}

.balance-icon { background: var(--gold-dim); color: var(--gold); }
.income-icon  { background: var(--green-dim); color: var(--green); }
.expense-icon { background: var(--red-dim); color: var(--red); }
.savings-icon { background: var(--blue-dim); color: var(--blue); }

.stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -1px;
  margin-bottom: 8px;
  transition: all 0.5s ease;
}

.stat-trend {
  display: flex;
  align-items: center;
  gap: 6px;
}

.trend-label {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ---- DASHBOARD GRID ---- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
}

/* ---- CARDS ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: background var(--transition-slow), border-color var(--transition-slow);
}

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

.card-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-action {
  font-size: 13px;
  color: var(--gold);
  text-decoration: none;
  font-weight: 500;
  transition: opacity var(--transition);
  cursor: pointer;
}

.card-action:hover { opacity: 0.75; }

/* ---- RECENT TRANSACTIONS (DASHBOARD) ---- */
.recent-transactions-card {
  padding-bottom: 8px;
}

.recent-list {
  padding: 0 10px 12px;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  transition: background var(--transition);
  cursor: default;
}

.recent-item:hover {
  background: var(--bg-card-hover);
}

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

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

.recent-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-item-cat {
  font-size: 12px;
  color: var(--text-tertiary);
}

.recent-item-amount {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  flex-shrink: 0;
}

.amount-income { color: var(--green); }
.amount-expense { color: var(--red); }

/* ---- CHART CONTAINERS ---- */
.chart-container {
  padding: 0 22px 22px;
  position: relative;
}

.chart-container.tall {
  height: 280px;
}

.chart-container canvas {
  max-height: 220px;
}

.chart-container.tall canvas {
  max-height: 280px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 22px 20px;
}

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

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---- TRANSACTIONS SECTION ---- */
.txn-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-tertiary);
  stroke: currentColor;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  transition: all var(--transition);
  outline: none;
}

.search-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.filter-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-select {
  padding: 9px 32px 9px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238890A4' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
}

.filter-select:focus {
  border-color: var(--gold);
}

/* ---- TRANSACTIONS TABLE ---- */
.transactions-card {
  overflow: hidden;
}

.transactions-table-wrap {
  overflow-x: auto;
}

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

.transactions-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

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

.transactions-table tbody tr {
  transition: background var(--transition);
}

.transactions-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.txn-title-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.txn-cat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.txn-title-info strong {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.txn-notes {
  font-size: 12px;
  color: var(--text-tertiary);
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-income {
  background: var(--green-dim);
  color: var(--green);
}

.badge-expense {
  background: var(--red-dim);
  color: var(--red);
}

.txn-amount {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}

.action-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--transition);
}

.action-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.action-btn.delete:hover {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(224,85,85,0.25);
}

.action-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
}

/* ---- BUDGETS SECTION ---- */
.budgets-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}

.budget-form-card {
  padding-bottom: 22px;
}

.budget-form {
  padding: 0 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.budget-list {
  display: grid;
  gap: 12px;
}

.budget-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: all var(--transition);
}

.budget-item:hover {
  border-color: var(--border-strong);
}

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

.budget-cat-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.budget-cat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.budget-cat-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.budget-amounts {
  text-align: right;
}

.budget-spent {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.budget-limit {
  font-size: 12px;
  color: var(--text-tertiary);
}

.budget-progress-wrap {
  position: relative;
}

.budget-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
}

.budget-progress-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}

.budget-progress-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
}

.budget-pct {
  font-size: 12px;
  font-weight: 600;
}

.budget-remaining {
  font-size: 12px;
  color: var(--text-tertiary);
}

.budget-warning {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--orange);
  font-weight: 500;
}

.budget-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: color var(--transition);
  padding: 4px;
}

.budget-delete-btn:hover { color: var(--red); }

.budget-delete-btn svg {
  width: 14px; height: 14px; stroke: currentColor;
}

/* ---- GOALS SECTION ---- */
.goals-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
}

.goal-item {
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

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

.goal-name { font-weight: 700; font-size: 16px; }

.goal-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.reflection-options {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.reflection-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
}

/* ---- ANALYTICS SECTION ---- */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.analytics-card {
  padding-bottom: 22px;
}

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

.monthly-summary-list {
  padding: 0 22px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.monthly-summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px;
  border-radius: var(--radius-md);
  transition: background var(--transition);
}

.monthly-summary-item:hover {
  background: var(--bg-card-hover);
}

.month-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 80px;
}

.month-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
}

.month-income { color: var(--green); font-weight: 500; }
.month-expense { color: var(--red); font-weight: 500; }

/* ---- SETTINGS SECTION ---- */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.settings-card {
  padding: 22px;
}

.settings-group-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.settings-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.settings-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.settings-desc {
  font-size: 12px;
  color: var(--text-tertiary);
}

.danger-text { color: var(--red) !important; }

.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

/* ---- TOGGLE SWITCH ---- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 100px;
  cursor: pointer;
  transition: all var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background: var(--text-tertiary);
  border-radius: 50%;
  transition: all var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--gold-dim);
  border-color: var(--gold);
}

.toggle-switch input:checked + .toggle-slider::before {
  background: var(--gold);
  transform: translateY(-50%) translateX(20px);
}

/* ---- ABOUT CARD ---- */
.about-card {
  display: flex;
  flex-direction: column;
}

.about-info {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding-top: 4px;
}

.about-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.about-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ---- FORMS ---- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.form-control {
  padding: 10px 14px;
  background: var(--bg-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  transition: all var(--transition);
  outline: none;
  width: 100%;
}

.form-control:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.form-control.textarea {
  resize: vertical;
  min-height: 80px;
}

.form-control::placeholder { color: var(--text-tertiary); }

.form-error {
  font-size: 12px;
  color: var(--red);
  min-height: 16px;
}

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

.input-prefix-wrap {
  position: relative;
  display: flex;
}

.input-prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  pointer-events: none;
  z-index: 1;
}

.input-prefix-wrap .form-control {
  padding-left: 28px;
}

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-slow);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal.modal-sm {
  max-width: 380px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 0;
  margin-bottom: 20px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.modal-close svg {
  width: 16px; height: 16px; stroke: currentColor;
}

.modal-close:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.modal-body {
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 24px 22px;
}

/* ---- TYPE TOGGLE ---- */
.type-toggle {
  display: flex;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}

.type-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px;
  border-radius: calc(var(--radius-md) - 2px);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.type-btn.active[data-type="expense"] {
  background: var(--red-dim);
  color: var(--red);
}

.type-btn.active[data-type="income"] {
  background: var(--green-dim);
  color: var(--green);
}

.confirm-message {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

/* ---- EMPTY STATE ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  gap: 8px;
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 4px;
  opacity: 0.7;
}

.empty-state p {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state span {
  font-size: 13px;
  color: var(--text-tertiary);
  max-width: 240px;
}

.empty-row td {
  border: none;
}

/* ---- TOAST ---- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  pointer-events: all;
  animation: toastIn 0.3s ease;
  min-width: 240px;
  max-width: 340px;
}

.toast.success { border-color: rgba(62,201,126,0.3); }
.toast.error   { border-color: rgba(224,85,85,0.3); }

.toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toast.success .toast-dot { background: var(--green); }
.toast.error .toast-dot   { background: var(--red); }
.toast.info .toast-dot    { background: var(--gold); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.removing {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

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

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ---- ANIMATED COUNTER ---- */
@keyframes countUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stat-value.animating {
  animation: countUp 0.4s ease;
}

/* ---- INPUT DATE COLOR FIX ---- */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.5);
  cursor: pointer;
}

[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.3);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1200px) {
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .spending-chart-card {
    max-width: 100%;
  }

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

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

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

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

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

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

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

  .hamburger {
    display: flex;
  }

  .section {
    padding: 16px;
  }

  .topbar {
    padding: 0 16px;
  }

  .stat-cards {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-value {
    font-size: 22px;
  }

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

  .txn-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-group {
    justify-content: stretch;
  }

  .filter-select {
    flex: 1;
  }

  .btn-primary span {
    display: none;
  }

  .topbar-actions .btn-primary {
    padding: 9px 12px;
  }

  .mobile-nav { display: flex; }
  .fab { display: flex; }
  .topbar-actions .btn-primary { display: none; }

  /* On mobile, main-content should never have a left margin from the sidebar */
  .main-content {
    margin-left: 0 !important; /* Ensure no margin on mobile */
  }
  
  body:not(.landing-active) {
    padding-bottom: 70px; /* Space for mobile nav */
  }

  /* Tighten sidebar for mobile to prevent scrolling */
  .sidebar { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
  .sidebar-logo { border-bottom: none; }
  #sidebarAuthHeader { flex-shrink: 0; }
  #sidebarAuthHeader .user-profile { margin-bottom: 0; }
  .sidebar-nav { padding: 4px 8px; flex: 1; overflow-y: auto; }
  .nav-item { padding: 8px 12px; font-size: 13px; margin-bottom: 1px; }
  .sidebar-footer { padding: 12px 16px 85px; border-top: 1px solid var(--border); flex-shrink: 0; }
}

/* Apply margin-left to main-content only when dashboard layout is active and on desktop */
@media (min-width: 769px) { /* Assuming 768px is the breakpoint for mobile */
  body.dashboard-layout-active .main-content {
    margin-left: var(--sidebar-width);
  }
}

@media (max-width: 480px) {
  .modal {
    border-radius: var(--radius-lg);
  }

  .transactions-table th:nth-child(2),
  .transactions-table td:nth-child(2),
  .transactions-table th:nth-child(4),
  .transactions-table td:nth-child(4) {
    display: none;
  }
}

/* ---- LANDING PAGE STYLES ---- */
#section-landing {
  padding: 0;
  display: none;
  height: 100dvh;
  background: radial-gradient(circle at top right, var(--gold-dim), transparent), var(--bg-base);
}

#section-landing.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.landing-hero {
  text-align: center;
  max-width: 600px;
  padding: 40px;
  animation: countUp 0.8s ease-out;
}

.landing-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-bottom: 10px;
}

.landing-logo-mark svg {
  width: 96px;
  height: 96px;
}

.landing-title {
  font-family: var(--font-display);
  font-size: 84px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.landing-subtext {
  font-size: 20px;
  color: var(--text-secondary);
  margin-bottom: 40px;
}

.landing-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 16px;
  border-radius: var(--radius-lg);
}

/* ---- AUTH STYLES ---- */
#section-auth {
  display: none;
  height: 100vh;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
}

#section-auth.active {
  display: flex;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 40px;
  position: relative;
  animation: countUp 0.6s ease-out;
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

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

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  border-radius: calc(var(--radius-md) - 2px);
  transition: all var(--transition);
}

.auth-tab.active {
  background: var(--bg-card);
  color: var(--gold);
  box-shadow: var(--shadow-sm);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}