/* ============================================
   MY CUAN — Design System & Styles
   Gen Z Finance Tracker
   ============================================ */

/* --- CSS Variables --- */
:root {
  /* Colors */
  --brand: #8b5cf6;
  --brand-light: #a78bfa;
  --brand-dark: #7c3aed;
  --brand-gradient: linear-gradient(135deg, #8b5cf6 0%, #ec4899 50%, #f97316 100%);
  --brand-gradient-soft: linear-gradient(135deg, rgba(139,92,246,0.15) 0%, rgba(236,72,153,0.10) 100%);

  --green: #10b981;
  --green-light: #d1fae5;
  --red: #ef4444;
  --red-light: #fee2e2;
  --blue: #3b82f6;
  --blue-light: #dbeafe;
  --orange: #f97316;
  --orange-light: #ffedd5;
  --yellow: #f59e0b;
  --purple: #8b5cf6;
  --purple-light: #ede9fe;
  --pink: #ec4899;
  --pink-light: #fce7f3;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 28px;
  --radius-full: 9999px;

  /* Typography */
  --font-body: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --font-display: 'Space Grotesk', -apple-system, sans-serif;
  --font-size-xs: 11px;
  --font-size-sm: 13px;
  --font-size-base: 15px;
  --font-size-md: 16px;
  --font-size-lg: 18px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 30px;
  --font-size-4xl: 36px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.20);
  --shadow-brand: 0 8px 24px rgba(139, 92, 246, 0.35);
  --shadow-green: 0 4px 16px rgba(16, 185, 129, 0.25);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --topbar-height: 60px;
  --bottom-nav-height: 64px;
  --sidebar-width: 280px;
  --content-max: 700px;
}

/* --- Dark Mode --- */
[data-theme="dark"] {
  --bg: #0f0f14;
  --bg-surface: #16161f;
  --bg-card: #1e1e2e;
  --bg-card-hover: #252538;
  --bg-input: #252538;
  --border: rgba(255,255,255,0.08);
  --border-subtle: rgba(255,255,255,0.05);
  --text-primary: #f0f0f8;
  --text-secondary: #9898b0;
  --text-muted: #5a5a72;
  --text-inverse: #0f0f14;
  --overlay: rgba(0,0,0,0.6);
  --scrollbar: rgba(255,255,255,0.1);
  --glass: rgba(255,255,255,0.04);
  --glass-border: rgba(255,255,255,0.08);
}

/* --- Light Mode --- */
[data-theme="light"] {
  --bg: #f5f4ff;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8f7ff;
  --bg-input: #f3f2ff;
  --border: rgba(0,0,0,0.08);
  --border-subtle: rgba(0,0,0,0.04);
  --text-primary: #1a1a2e;
  --text-secondary: #5a5a72;
  --text-muted: #9898b0;
  --text-inverse: #ffffff;
  --overlay: rgba(0,0,0,0.4);
  --scrollbar: rgba(0,0,0,0.1);
  --glass: rgba(255,255,255,0.7);
  --glass-border: rgba(255,255,255,0.6);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

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

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 999px; }

/* --- Utilities --- */
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

/* --- Splash Screen --- */
.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--brand-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: splashFadeOut 0.5s ease 2s forwards;
}

.splash-content {
  text-align: center;
  color: white;
}

.splash-logo {
  margin-bottom: 40px;
  animation: splashEntry 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.splash-emoji {
  font-size: 72px;
  display: block;
  margin-bottom: 16px;
  animation: splashPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

.splash-logo h1 {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.splash-logo p {
  font-size: 16px;
  opacity: 0.85;
}

.splash-loader {
  width: 200px;
  margin: 0 auto;
}

.loader-bar {
  height: 4px;
  background: rgba(255,255,255,0.25);
  border-radius: 999px;
  overflow: hidden;
}

.loader-fill {
  height: 100%;
  background: white;
  border-radius: 999px;
  animation: loaderFill 2s ease forwards;
  width: 0%;
}

@keyframes splashFadeOut { to { opacity: 0; visibility: hidden; } }
@keyframes splashEntry { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes splashPop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes loaderFill { from { width: 0%; } to { width: 100%; } }

/* --- App Layout --- */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  max-width: 100%;
  position: relative;
}

/* --- Top Bar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.brand-emoji { font-size: 22px; }
.brand-name {
  font-family: var(--font-display);
  font-size: var(--font-size-xl);
  font-weight: 700;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Buttons --- */
.btn-icon {
  width: 38px;
  height: 38px;
  border: none;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  position: relative;
}

.btn-icon:hover {
  background: var(--brand);
  color: white;
  transform: scale(1.05);
}

.btn-icon-sm {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-primary {
  padding: 8px 18px;
  background: var(--brand-gradient);
  border: none;
  border-radius: var(--radius-full);
  color: white;
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-brand);
  white-space: nowrap;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(139, 92, 246, 0.45);
}

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

.btn-ghost {
  padding: 8px 18px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-ghost:hover {
  background: var(--bg-card-hover);
  border-color: var(--brand);
  color: var(--brand);
}

.btn-danger {
  padding: 8px 18px;
  background: var(--red);
  border: none;
  border-radius: var(--radius-full);
  color: white;
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-danger:hover { background: #dc2626; transform: translateY(-1px); }

.btn-text {
  background: none;
  border: none;
  color: var(--brand);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-text:hover { background: var(--brand-gradient-soft); }

.btn-text-sm {
  background: none;
  border: none;
  color: var(--brand);
  font-family: var(--font-body);
  font-size: var(--font-size-xs);
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
}

.btn-text-inline {
  background: none;
  border: none;
  color: var(--brand);
  font-weight: 600;
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}

.btn-outline-danger {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--red);
  border-radius: var(--radius-md);
  color: var(--red);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-outline-danger:hover { background: var(--red-light); }

/* Notification Badge */
.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  background: var(--red);
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-surface);
}

/* --- Search Bar --- */
.search-bar {
  position: sticky;
  top: var(--topbar-height);
  z-index: 99;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 8px var(--space-md);
}

.search-inner {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--bg-input);
  border-radius: var(--radius-lg);
  padding: 8px 14px;
  border: 1px solid var(--border);
}

.search-inner svg { color: var(--text-muted); flex-shrink: 0; }

#search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
}

#search-input::placeholder { color: var(--text-muted); }

.search-results {
  margin-top: 8px;
  max-height: 300px;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 12px var(--space-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border-subtle);
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-card-hover); }

/* --- Notification Panel --- */
.notif-panel {
  position: fixed;
  top: var(--topbar-height);
  right: var(--space-md);
  z-index: 200;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideDown 0.2s ease;
}

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

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

.notif-header h3 { font-size: var(--font-size-md); font-weight: 700; }

.notif-list { max-height: 300px; overflow-y: auto; }

.notif-item {
  display: flex;
  gap: var(--space-md);
  padding: 12px var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
}

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

.notif-item-icon { font-size: 24px; flex-shrink: 0; }

.notif-item-body p { font-size: var(--font-size-sm); font-weight: 600; color: var(--text-primary); }
.notif-item-body span { font-size: var(--font-size-xs); color: var(--text-muted); }

/* --- Sidebar --- */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  animation: fadeIn var(--transition-base);
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 160;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideInLeft 0.25s cubic-bezier(0.34, 1.20, 0.64, 1);
}

@keyframes slideInLeft { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-display);
  font-size: var(--font-size-xl);
  font-weight: 700;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  margin: var(--space-sm);
  background: var(--brand-gradient-soft);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(139,92,246,0.2);
}

.avatar {
  width: 44px;
  height: 44px;
  background: var(--brand-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.profile-name { font-weight: 700; font-size: var(--font-size-md); }
.profile-sub { font-size: var(--font-size-xs); color: var(--text-muted); }

.sidebar-nav {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm) 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 12px var(--space-md);
  cursor: pointer;
  border-radius: var(--radius-md);
  margin: 2px var(--space-sm);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  transform: translateX(4px);
}

.nav-item.active {
  background: var(--brand-gradient-soft);
  color: var(--brand);
  font-weight: 700;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--brand-gradient);
  border-radius: 0 3px 3px 0;
}

.nav-icon { font-size: 18px; }

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

/* --- Main Content --- */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--bottom-nav-height) + var(--space-md));
}

/* --- Pages --- */
.page { display: none; padding: var(--space-md); max-width: var(--content-max); margin: 0 auto; }
.page.active { display: block; animation: pageEntry 0.3s ease; }

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

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.page-header h2 {
  font-family: var(--font-display);
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--text-primary);
}

.page-date {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-md);
  border: 1px solid var(--border);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
}

.card:hover { box-shadow: var(--shadow-md); }

/* --- Balance Card --- */
.balance-card {
  position: relative;
  background: var(--brand-gradient);
  border-radius: var(--radius-2xl);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  overflow: hidden;
  box-shadow: var(--shadow-brand);
}

.balance-card-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 80% -10%, rgba(255,255,255,0.2) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 110%, rgba(0,0,0,0.2) 0%, transparent 60%);
  pointer-events: none;
}

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

.balance-card::after {
  content: '';
  position: absolute;
  bottom: -30px;
  left: -30px;
  width: 140px;
  height: 140px;
  background: rgba(0,0,0,0.1);
  border-radius: 50%;
}

.balance-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  position: relative;
  z-index: 1;
}

.balance-label {
  font-size: var(--font-size-sm);
  color: rgba(255,255,255,0.8);
  margin-bottom: 4px;
  font-weight: 500;
}

.balance-amount {
  font-family: var(--font-display);
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: white;
  letter-spacing: -1px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.balance-icon {
  font-size: 40px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.balance-bottom {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  position: relative;
  z-index: 1;
  background: rgba(0,0,0,0.15);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
}

.balance-stat { display: flex; align-items: center; gap: var(--space-sm); flex: 1; }
.balance-divider { width: 1px; height: 32px; background: rgba(255,255,255,0.2); }
.stat-icon { font-size: 20px; font-weight: 800; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.stat-icon.up { background: rgba(16,185,129,0.3); color: #6ee7b7; }
.stat-icon.down { background: rgba(239,68,68,0.3); color: #fca5a5; }
.stat-label { font-size: var(--font-size-xs); color: rgba(255,255,255,0.7); }
.stat-value { font-size: var(--font-size-sm); font-weight: 700; color: white; }
.stat-value.green { color: #6ee7b7; }
.stat-value.red { color: #fca5a5; }

/* --- Health Banner --- */
.health-banner {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-md);
  border: 1px solid;
  animation: bounceIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.health-banner.good { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.3); }
.health-banner.warning { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); }
.health-banner.danger { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); }

.health-banner span { font-size: 28px; flex-shrink: 0; }
.health-banner strong { font-size: var(--font-size-md); font-weight: 700; display: block; }
.health-banner p { font-size: var(--font-size-sm); color: var(--text-secondary); }

@keyframes bounceIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

/* --- Section Title --- */
.section-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px;
}

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-md);
  border: 1px solid var(--border);
  transition: all var(--transition-base);
  cursor: default;
}

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

.stat-card.purple { border-left: 3px solid var(--purple); }
.stat-card.blue { border-left: 3px solid var(--blue); }
.stat-card.green { border-left: 3px solid var(--green); }
.stat-card.orange { border-left: 3px solid var(--orange); }

.stat-card-icon { font-size: 24px; margin-bottom: 8px; }
.stat-card-label { font-size: var(--font-size-xs); color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card-value { font-family: var(--font-display); font-size: var(--font-size-lg); font-weight: 700; color: var(--text-primary); margin-top: 4px; }

/* --- Badge Pill --- */
.badge-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  background: var(--brand-gradient-soft);
  color: var(--brand);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  border: 1px solid rgba(139,92,246,0.2);
}

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.select-sm {
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
  flex-shrink: 0;
}

.select-sm:focus { border-color: var(--brand); }

/* --- Summary Row --- */
.summary-row {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.summary-chip {
  flex: 1;
  min-width: 80px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px var(--space-md);
}

.summary-chip span { font-size: var(--font-size-xs); color: var(--text-muted); display: block; font-weight: 500; }
.summary-chip strong { font-size: var(--font-size-sm); font-weight: 700; color: var(--text-primary); }
.summary-chip.green strong { color: var(--green); }
.summary-chip.red strong { color: var(--red); }
.summary-chip.purple strong { color: var(--purple); }
.summary-chip.orange strong { color: var(--orange); }
.summary-chip.blue strong { color: var(--blue); }

/* --- Transaction List --- */
.tx-list { display: flex; flex-direction: column; gap: var(--space-sm); }

.tx-group-header {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 0;
}

.tx-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 14px var(--space-md);
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
}

.tx-item:hover {
  border-color: var(--brand);
  background: var(--bg-card-hover);
  transform: translateX(4px);
}

.tx-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.tx-icon.income { background: rgba(16,185,129,0.15); }
.tx-icon.expense { background: rgba(239,68,68,0.12); }
.tx-icon.transfer { background: rgba(59,130,246,0.15); }

.tx-body { flex: 1; min-width: 0; }
.tx-title { font-size: var(--font-size-sm); font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 2px; }

.tx-right { text-align: right; flex-shrink: 0; }
.tx-amount { font-family: var(--font-display); font-size: var(--font-size-md); font-weight: 700; }
.tx-amount.income { color: var(--green); }
.tx-amount.expense { color: var(--red); }
.tx-amount.transfer { color: var(--blue); }

.tx-actions {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  gap: 4px;
}

.tx-item:hover .tx-actions { display: flex; }

.tx-action-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all var(--transition-fast);
}

.tx-action-btn.edit { background: var(--blue-light); color: var(--blue); }
.tx-action-btn.delete { background: var(--red-light); color: var(--red); }

[data-theme="dark"] .tx-action-btn.edit { background: rgba(59,130,246,0.2); }
[data-theme="dark"] .tx-action-btn.delete { background: rgba(239,68,68,0.2); }

.tx-recurring-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 600;
  color: var(--purple);
  background: var(--purple-light);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-left: 6px;
}

[data-theme="dark"] .tx-recurring-badge { background: rgba(139,92,246,0.2); }

/* --- Budget List --- */
.budget-list { display: flex; flex-direction: column; gap: var(--space-sm); }

.budget-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-md);
  transition: all var(--transition-fast);
}

.budget-item:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); }

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

.budget-cat-info { display: flex; align-items: center; gap: var(--space-sm); }
.budget-cat-icon { font-size: 22px; }
.budget-cat-name { font-weight: 600; font-size: var(--font-size-sm); }
.budget-cat-sub { font-size: var(--font-size-xs); color: var(--text-muted); }

.budget-amounts { text-align: right; }
.budget-used-amount { font-weight: 700; font-size: var(--font-size-sm); }
.budget-limit-amount { font-size: var(--font-size-xs); color: var(--text-muted); }

/* --- Progress Bar --- */
.progress-bar-wrap {
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--brand-gradient);
  transition: width var(--transition-slow);
  position: relative;
  overflow: hidden;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 2s infinite;
}

.progress-bar.warning { background: linear-gradient(90deg, var(--orange), var(--yellow)); }
.progress-bar.danger { background: linear-gradient(90deg, var(--red), #f97316); }

@keyframes shimmer { to { left: 200%; } }

.progress-label { font-size: var(--font-size-xs); color: var(--text-muted); }

/* --- Savings List --- */
.savings-list { display: flex; flex-direction: column; gap: var(--space-md); }

.savings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-md);
  transition: all var(--transition-fast);
  position: relative;
}

.savings-card:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); }

.savings-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.savings-card-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  background: var(--brand-gradient-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border: 1px solid rgba(139,92,246,0.2);
}

.savings-card-info { flex: 1; }
.savings-card-name { font-weight: 700; font-size: var(--font-size-md); }
.savings-card-deadline { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 2px; }

.savings-amounts {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.savings-collected-label { font-size: var(--font-size-xs); color: var(--text-muted); }
.savings-collected-value { font-weight: 700; font-size: var(--font-size-md); color: var(--purple); }
.savings-target-label { font-size: var(--font-size-xs); color: var(--text-muted); text-align: right; }
.savings-target-value { font-weight: 700; font-size: var(--font-size-md); text-align: right; }

.savings-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

/* --- Emergency Overview --- */
.emergency-overview {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-xl);
  background: linear-gradient(135deg, rgba(239,68,68,0.08), rgba(249,115,22,0.08));
  border-color: rgba(239,68,68,0.2) !important;
}

.emergency-icon { font-size: 56px; margin-bottom: var(--space-md); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

.emergency-stats {
  display: flex;
  gap: var(--space-2xl);
  margin-bottom: var(--space-md);
}

/* --- Investment List --- */
.investment-list { display: flex; flex-direction: column; gap: var(--space-sm); }

.investment-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-md);
  transition: all var(--transition-fast);
}

.investment-item:hover { border-color: var(--green); box-shadow: var(--shadow-sm); }

.investment-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.investment-name-wrap { display: flex; align-items: center; gap: var(--space-sm); }
.investment-type-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--brand-gradient-soft);
  color: var(--brand);
  border: 1px solid rgba(139,92,246,0.2);
  text-transform: uppercase;
}

.investment-name { font-weight: 700; font-size: var(--font-size-md); }
.investment-return { font-size: var(--font-size-sm); font-weight: 600; }
.investment-return.positive { color: var(--green); }
.investment-return.negative { color: var(--red); }

.investment-amounts {
  display: flex;
  justify-content: space-between;
}

/* --- Bills List --- */
.bills-list { display: flex; flex-direction: column; gap: var(--space-sm); }

.bill-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  transition: all var(--transition-fast);
}

.bill-item:hover { border-color: var(--orange); box-shadow: var(--shadow-sm); }
.bill-item.paid { opacity: 0.6; }

.bill-icon { font-size: 28px; }
.bill-body { flex: 1; }
.bill-name { font-weight: 700; font-size: var(--font-size-sm); }
.bill-meta { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 2px; }

.bill-right { text-align: right; }
.bill-amount { font-family: var(--font-display); font-size: var(--font-size-md); font-weight: 700; color: var(--red); }
.bill-due-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  margin-top: 4px;
}

.bill-due-badge.due { background: rgba(239,68,68,0.15); color: var(--red); }
.bill-due-badge.soon { background: rgba(245,158,11,0.15); color: var(--yellow); }
.bill-due-badge.ok { background: rgba(16,185,129,0.15); color: var(--green); }
.bill-due-badge.paid { background: rgba(16,185,129,0.15); color: var(--green); }

/* --- Chart --- */
.chart-card { padding: var(--space-lg); }
#dash-category-chart {
  display: block;
  width: 100% !important;
  height: 220px !important;
  max-height: 220px;
}
#dash-category-chart + .chart-legend { max-height: 180px; overflow-y: auto; }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

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

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

.category-breakdown { display: flex; flex-direction: column; gap: var(--space-sm); margin-bottom: var(--space-md); }

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

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

.breakdown-cat { display: flex; align-items: center; gap: var(--space-sm); font-weight: 600; font-size: var(--font-size-sm); }
.breakdown-pct { font-size: var(--font-size-xs); color: var(--text-muted); }

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
  color: var(--text-muted);
}

.empty-icon { font-size: 48px; margin-bottom: var(--space-md); display: block; opacity: 0.7; }
.empty-state p { font-weight: 600; font-size: var(--font-size-md); color: var(--text-secondary); margin-bottom: 6px; }
.empty-state span { font-size: var(--font-size-sm); }

.empty-state-sm {
  text-align: center;
  padding: var(--space-lg) var(--space-md);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* --- Bottom Nav --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--bottom-nav-height);
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  transition: all var(--transition-fast);
  position: relative;
}

.bnav-item:hover { color: var(--brand); }

.bnav-item.active {
  color: var(--brand);
}

.bnav-item.active svg {
  filter: drop-shadow(0 0 6px rgba(139,92,246,0.5));
}

.bnav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 3px;
  background: var(--brand-gradient);
  border-radius: 0 0 4px 4px;
}

.bnav-fab {
  width: 52px;
  height: 52px;
  background: var(--brand-gradient) !important;
  border-radius: 50% !important;
  color: white !important;
  box-shadow: var(--shadow-brand);
  flex: none;
  padding: 0 !important;
  font-size: 0;
  transform: translateY(-8px);
  transition: all var(--transition-fast) !important;
}

.bnav-fab:hover { transform: translateY(-10px) scale(1.05); box-shadow: 0 12px 30px rgba(139, 92, 246, 0.5); }

/* --- FAB Menu --- */
.fab-menu {
  position: fixed;
  inset: 0;
  z-index: 300;
}

.fab-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
}

.fab-options {
  position: absolute;
  bottom: calc(var(--bottom-nav-height) + 20px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-width: 220px;
}

.fab-option {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 14px var(--space-md);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--text-primary);
  backdrop-filter: blur(20px);
  transition: all var(--transition-fast);
  animation: fabOptionEntry 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  box-shadow: var(--shadow-md);
}

.fab-option:nth-child(1) { animation-delay: 0.05s; }
.fab-option:nth-child(2) { animation-delay: 0.1s; }
.fab-option:nth-child(3) { animation-delay: 0.15s; }
.fab-option:nth-child(4) { animation-delay: 0.2s; }

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

.fab-option:hover { transform: scale(1.02); border-color: var(--brand); }

.fab-opt-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.fab-opt-icon.green { background: rgba(16,185,129,0.15); }
.fab-opt-icon.red { background: rgba(239,68,68,0.12); }
.fab-opt-icon.blue { background: rgba(59,130,246,0.15); }
.fab-opt-icon.purple { background: rgba(139,92,246,0.15); }

/* --- Modals --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: var(--overlay);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(6px);
  padding: var(--space-md);
  animation: fadeIn 0.2s ease;
}

@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalEntry 0.3s cubic-bezier(0.34, 1.20, 0.64, 1);
  border: 1px solid var(--border);
  border-bottom: none;
}

@media (min-width: 600px) {
  .modal {
    border-radius: var(--radius-2xl);
    border-bottom: 1px solid var(--border);
  }
}

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

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 10;
}

.modal-header h3 { font-family: var(--font-display); font-size: var(--font-size-xl); font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 18px; padding: 4px; border-radius: var(--radius-sm); transition: all var(--transition-fast); }
.modal-close:hover { background: var(--bg-input); color: var(--text-primary); }

.modal-body { padding: var(--space-md) var(--space-lg); }
.modal-footer { display: flex; gap: var(--space-sm); padding: var(--space-md) var(--space-lg) var(--space-lg); border-top: 1px solid var(--border); justify-content: flex-end; }

/* --- Forms --- */
.form-group { margin-bottom: var(--space-md); }
.form-group label { display: block; font-size: var(--font-size-sm); font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select {
  width: 100%;
  padding: 12px var(--space-md);
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.15);
}

.input-prefix {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-prefix:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.15);
}

.input-prefix span {
  padding: 12px var(--space-md);
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--font-size-sm);
  background: var(--border-subtle);
  border-right: 1.5px solid var(--border);
  white-space: nowrap;
}

.input-prefix input {
  flex: 1;
  padding: 12px var(--space-md);
  background: transparent;
  border: none !important;
  box-shadow: none !important;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
}

.form-tabs {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-lg);
}

.form-tab {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  color: var(--text-primary) !important;
  margin-bottom: 0 !important;
}

.checkbox-label input[type="checkbox"] {
  width: 18px !important;
  height: 18px !important;
  padding: 0 !important;
  border: 2px solid var(--border) !important;
  accent-color: var(--brand);
  flex-shrink: 0;
}

/* --- Emoji Picker --- */
.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.emoji-picker span {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.emoji-picker span:hover { border-color: var(--brand); transform: scale(1.1); }
.emoji-picker span.selected { border-color: var(--brand); background: var(--brand-gradient-soft); }

/* --- Toast --- */
.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
  min-width: 280px;
  max-width: calc(100vw - 32px);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 12px var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
  animation: toastEntry 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(20px);
  pointer-events: all;
  white-space: nowrap;
}

.toast.success { border-color: rgba(16,185,129,0.4); background: rgba(16,185,129,0.1); color: var(--green); }
.toast.error { border-color: rgba(239,68,68,0.4); background: rgba(239,68,68,0.1); color: var(--red); }
.toast.warning { border-color: rgba(245,158,11,0.4); background: rgba(245,158,11,0.1); color: var(--yellow); }
.toast.info { border-color: rgba(139,92,246,0.4); background: rgba(139,92,246,0.1); color: var(--purple); }

@keyframes toastEntry { from { opacity: 0; transform: translateY(20px) scale(0.9); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastExit { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(0.9); } }
.toast.exiting { animation: toastExit 0.2s ease forwards; }

/* --- Responsive --- */
@media (min-width: 768px) {
  .app { flex-direction: row; }
  .topbar { padding: 0 var(--space-lg); }
  .main-content { padding-bottom: var(--space-md); }
  .bottom-nav { display: none; }
  .page { padding: var(--space-lg); }

  /* Static sidebar on desktop */
  .sidebar {
    position: relative;
    height: calc(100vh - var(--topbar-height));
    flex-shrink: 0;
  }
}

@media (max-width: 767px) {
  .balance-amount { font-size: var(--font-size-2xl); }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* --- Animations --- */
@keyframes spin { to { transform: rotate(360deg); } }

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: var(--space-lg) auto;
}

/* Micro interactions */
.card, .tx-item, .budget-item, .savings-card, .investment-item, .bill-item {
  will-change: transform;
}

/* Budget progress in dashboard */
.budget-dash-item {
  margin-bottom: var(--space-md);
}
.budget-dash-item:last-child { margin-bottom: 0; }
.budget-dash-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.budget-dash-cat { display: flex; align-items: center; gap: var(--space-sm); font-size: var(--font-size-sm); font-weight: 600; }
.budget-dash-amounts { font-size: var(--font-size-xs); color: var(--text-muted); }

/* Savings goal mini in dashboard */
.savings-goal-mini {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.savings-goal-mini:last-child { border-bottom: none; }
.savings-goal-mini-icon { font-size: 24px; }
.savings-goal-mini-body { flex: 1; }
.savings-goal-mini-name { font-size: var(--font-size-sm); font-weight: 600; }
.savings-goal-mini-pct { font-size: var(--font-size-xs); color: var(--text-muted); }

/* Number animation */
@keyframes countUp { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.count-animated { animation: countUp 0.3s ease; }

/* Glow on balance card when positive */
.balance-card.positive { box-shadow: 0 8px 32px rgba(16,185,129,0.3), var(--shadow-brand); }
.balance-card.warning { box-shadow: 0 8px 32px rgba(245,158,11,0.3), var(--shadow-brand); }
.balance-card.danger { box-shadow: 0 8px 32px rgba(239,68,68,0.3), var(--shadow-brand); }

/* Additional helper classes */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mb-md { margin-bottom: var(--space-md); }

/* Recurring badge in search */
.tag-recurring {
  font-size: 10px;
  background: rgba(139,92,246,0.2);
  color: var(--purple);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

/* ============================================
   RESPONSIVE + SVG ICON POLISH
   ============================================ */
.nav-icon {
  width: 20px; height: 20px; flex: 0 0 20px; display: inline-block; font-size: 0;
  background: currentColor; -webkit-mask: var(--nav-icon) center / contain no-repeat; mask: var(--nav-icon) center / contain no-repeat;
}
.nav-item:nth-child(1) .nav-icon { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3 10 9-7 9 7v10a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1V10Z'/%3E%3C/svg%3E"); }
.nav-item:nth-child(2) .nav-icon { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M12 3v14m0 0 5-5m-5 5-5-5M5 21h14'/%3E%3C/svg%3E"); }
.nav-item:nth-child(3) .nav-icon { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M3 4h2l2 12h10l3-8H6'/%3E%3Ccircle cx='9' cy='20' r='1'/%3E%3Ccircle cx='17' cy='20' r='1'/%3E%3C/svg%3E"); }
.nav-item:nth-child(4) .nav-icon { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='m17 2 4 4-4 4M3 11V9a3 3 0 0 1 3-3h15M7 22l-4-4 4-4M21 13v2a3 3 0 0 1-3 3H3'/%3E%3C/svg%3E"); }
.nav-item:nth-child(5) .nav-icon { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M12 3 14.8 9.2 21 12l-6.2 2.8L12 21l-2.8-6.2L3 12l6.2-2.8L12 3Z'/%3E%3C/svg%3E"); }
.nav-item:nth-child(6) .nav-icon { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M12 3c-4 0-7 2-7 5v9h14V8c0-3-3-5-7-5Z'/%3E%3Cpath d='M8 17v2a4 4 0 0 0 8 0v-2'/%3E%3C/svg%3E"); }
.nav-item:nth-child(7) .nav-icon { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M12 3 4 6v5c0 5 3.4 8.5 8 10 4.6-1.5 8-5 8-10V6l-8-3Z'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E"); }
.nav-item:nth-child(8) .nav-icon { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='m3 17 6-6 4 4 8-9M14 6h7v7'/%3E%3C/svg%3E"); }
.nav-item:nth-child(9) .nav-icon { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M4 19V5m0 14h16M8 16v-3m4 3V8m4 8V5'/%3E%3C/svg%3E"); }
.nav-item:nth-child(10) .nav-icon { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M3 4h18v16H3zM7 8h10M7 12h6M7 16h8'/%3E%3C/svg%3E"); }
.nav-item:nth-child(11) .nav-icon { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M3 5h18v14H3zM7 9h10M7 13h6M7 17h8'/%3E%3C/svg%3E"); }

@media (min-width: 768px) {
  :root { --topbar-height: 68px; --sidebar-width: 288px; --content-max: 980px; }
  .app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); grid-template-rows: var(--topbar-height) minmax(0, 1fr); min-height: 100vh; }
  .topbar { grid-column: 1 / -1; grid-row: 1; padding: 0 28px; }
  .sidebar { grid-column: 1; grid-row: 2; position: relative; inset: auto; width: var(--sidebar-width); height: calc(100vh - var(--topbar-height)); animation: none; }
  .sidebar.hidden { display: flex !important; }
  .sidebar-overlay { display: none !important; }
  .main-content { grid-column: 2; grid-row: 2; min-width: 0; height: calc(100vh - var(--topbar-height)); padding: 0 32px 32px; overflow-y: auto; }
  .page { width: min(100%, var(--content-max)); padding: 32px 0 48px; }
  .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .page-header h2 { font-size: 28px; }
  .modal { max-width: 560px; }
}
@media (min-width: 1200px) {
  :root { --sidebar-width: 310px; --content-max: 1080px; }
  .main-content { padding-left: 48px; padding-right: 48px; }
  .balance-card { padding: 32px; }
}
@media (min-width: 600px) and (max-width: 767px) {
  .page { padding: 24px; }
  .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .modal-overlay { align-items: center; }
  .modal { border-radius: var(--radius-2xl); border-bottom: 1px solid var(--border); }
}
@media (max-width: 599px) {
  .topbar { padding-inline: 12px; }
  .topbar-brand .brand-name { font-size: 18px; }
  .topbar-right { gap: 4px; }
  .page { padding: 16px 12px 24px; }
  .page-header { gap: 8px; margin-bottom: 16px; }
  .page-header h2 { font-size: 21px; line-height: 1.2; }
  .page-date { display: none; }
  .balance-card { padding: 18px; border-radius: 22px; }
  .balance-bottom { gap: 10px; padding: 12px; }
  .balance-stat { gap: 6px; min-width: 0; }
  .stat-value { font-size: 12px; white-space: nowrap; }
  .stats-grid { gap: 8px; }
  .stat-card { padding: 12px 10px; border-radius: 16px; }
  .stat-card-icon { font-size: 20px; margin-bottom: 5px; }
  .stat-card-value { font-size: 14px; overflow-wrap: anywhere; }
  .filter-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .select-sm { width: 100%; min-width: 0; font-size: 12px; }
  .summary-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-chip { min-width: 0; padding: 10px; }
  .summary-chip strong { font-size: 13px; overflow-wrap: anywhere; }
  .tx-item { padding: 12px 10px; gap: 10px; }
  .tx-icon { width: 38px; height: 38px; font-size: 19px; }
  .tx-amount { font-size: 13px; }
  .tx-actions { display: flex; position: static; transform: none; margin-top: 4px; justify-content: flex-end; }
  .modal-overlay { padding: 0; }
  .modal { max-height: 94vh; border-radius: 22px 22px 0 0; }
  .form-tabs { flex-direction: column; }
  .bottom-nav { padding-inline: 4px; }
}
@media (max-width: 360px) {
  .brand-name { display: none; }
  .page { padding-inline: 10px; }
  .balance-amount { font-size: 22px; }
  .stat-card-label { font-size: 9px; }
  .stat-card-value { font-size: 12px; }
  .bnav-item { font-size: 9px; }
}
button, select, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid rgba(139,92,246,.35); outline-offset: 2px; }
@media (pointer: coarse) {
  .btn-icon, .btn-icon-sm, .tx-action-btn { min-width: 40px; min-height: 40px; }
  .tx-action-btn { width: 40px !important; height: 40px !important; }
}

/* Report and dashboard transaction actions: keep controls below amount on desktop */
@media (min-width: 768px) {
  #page-report .tx-right,
  #page-dashboard .tx-right {
    min-width: 172px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }
  #page-report .tx-actions,
  #page-dashboard .tx-actions {
    position: static;
    transform: none;
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    min-height: 0;
  }
  #page-report .tx-amount,
  #page-dashboard .tx-amount { white-space: nowrap; }
}

/* Dana Siaga: compact overview */
.emergency-overview {
  padding: 20px 24px;
  gap: 10px;
}
.emergency-overview .emergency-icon {
  font-size: 34px;
  line-height: 1;
  margin-bottom: 2px;
}
.emergency-overview .emergency-stats {
  width: min(100%, 430px);
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 2px;
}
.emergency-overview .emergency-stats > div {
  flex: 1;
}
.emergency-overview .stat-label {
  font-size: 11px;
  margin-bottom: 2px;
}
.emergency-overview .stat-value {
  font-size: 15px;
  line-height: 1.2;
}
.emergency-overview .progress-bar-wrap {
  width: min(100%, 430px);
  margin-top: 2px;
}
.emergency-overview .progress-label {
  font-size: 11px;
  margin-top: 2px;
}
.emergency-overview .emergency-advice {
  margin-top: 2px !important;
  max-width: 560px;
  font-size: 11px !important;
  line-height: 1.35;
}
@media (max-width: 599px) {
  .emergency-overview { padding: 16px 14px; gap: 8px; }
  .emergency-overview .emergency-icon { font-size: 30px; }
  .emergency-overview .emergency-stats { gap: 12px; }
  .emergency-overview .stat-label { font-size: 10px; }
  .emergency-overview .stat-value { font-size: 13px; }
  .emergency-overview .progress-label { font-size: 10px; }
}

/* Peta Duit Kabur: prevent analytics canvases from growing indefinitely */
#page-chart .chart-card {
  overflow: hidden;
}
#page-chart #donut-chart,
#page-chart #trend-chart {
  display: block;
  width: 100% !important;
  max-width: 100%;
}
#page-chart #donut-chart {
  height: min(360px, 72vw) !important;
  max-height: 360px;
}
#page-chart #trend-chart {
  height: min(260px, 55vw) !important;
  max-height: 260px;
}
#page-chart #donut-legend {
  max-height: 150px;
  overflow-y: auto;
}
@media (max-width: 599px) {
  #page-chart #donut-chart { height: min(280px, 78vw) !important; max-height: 280px; }
  #page-chart #trend-chart { height: min(210px, 58vw) !important; max-height: 210px; }
}

/* --- Accounts & Rekening --- */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-md);
}
.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  transition: all var(--transition-fast);
}
.account-card:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.account-card-top { display: flex; align-items: center; gap: var(--space-sm); }
.account-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--account-color) 18%, transparent);
  border: 1px solid color-mix(in srgb, var(--account-color) 30%, transparent);
  font-size: 24px;
}
.account-info { min-width: 0; flex: 1; }
.account-info h3 { margin: 0; font-size: var(--font-size-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-info span, .account-opening, .account-balance-label { color: var(--text-muted); font-size: var(--font-size-xs); }
.account-actions { display: flex; gap: 4px; }
.account-actions .danger { color: var(--red); }
.account-balance-label { margin-top: var(--space-lg); }
.account-balance { margin-top: 4px; font-family: var(--font-display); font-size: 23px; font-weight: 800; color: var(--text-primary); }
.account-opening { margin-top: 8px; }
@media (max-width: 599px) {
  .accounts-grid { grid-template-columns: 1fr; }
  .account-card { padding: var(--space-md); }
}



