/* =====================================================
   FinanceFlow Pro — Design System (Mobile-First)
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ===================== CSS VARIABLES ===================== */
:root {
  /* Background */
  --bg:           #080C1E;
  --bg-elevated:  #0D1226;
  --bg-card:      rgba(255,255,255,0.035);
  --bg-hover:     rgba(255,255,255,0.06);

  /* Borders */
  --border:       rgba(255,255,255,0.07);
  --border-md:    rgba(255,255,255,0.12);
  --border-lg:    rgba(255,255,255,0.20);

  /* Brand */
  --primary:      #7C6FFF;
  --primary-dark: #5B4FD9;
  --primary-glow: rgba(124,111,255,0.25);
  --primary-bg:   rgba(124,111,255,0.10);

  --secondary:    #3B82F6;
  --secondary-glow: rgba(59,130,246,0.25);

  /* Semantic */
  --income:       #10B981;
  --income-bg:    rgba(16,185,129,0.12);
  --income-glow:  rgba(16,185,129,0.30);

  --expense:      #F43F5E;
  --expense-bg:   rgba(244,63,94,0.12);
  --expense-glow: rgba(244,63,94,0.30);

  --savings:      #F59E0B;
  --savings-bg:   rgba(245,158,11,0.12);
  --savings-glow: rgba(245,158,11,0.30);

  --goal:         #8B5CF6;
  --goal-bg:      rgba(139,92,246,0.12);
  --goal-glow:    rgba(139,92,246,0.30);

  --warning:      #F59E0B;
  --warning-bg:   rgba(245,158,11,0.12);

  --danger:       #EF4444;

  /* Text */
  --text:         #F1F5F9;
  --text-muted:   #94A3B8;
  --text-subtle:  #475569;

  /* Gradients */
  --grad-primary: linear-gradient(135deg,#7C6FFF 0%,#3B82F6 100%);
  --grad-income:  linear-gradient(135deg,#10B981 0%,#059669 100%);
  --grad-expense: linear-gradient(135deg,#F43F5E 0%,#DC2626 100%);
  --grad-savings: linear-gradient(135deg,#F59E0B 0%,#D97706 100%);
  --grad-goal:    linear-gradient(135deg,#8B5CF6 0%,#6D28D9 100%);
  --grad-bg:      radial-gradient(ellipse 80% 60% at 0% 0%,rgba(124,111,255,.14) 0%,transparent 55%),
                  radial-gradient(ellipse 70% 50% at 100% 100%,rgba(59,130,246,.10) 0%,transparent 55%),
                  #080C1E;

  /* Type Scale */
  --text-xs:   .75rem;
  --text-sm:   .875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;
  --text-4xl:  2.25rem;

  /* Spacing */
  --sp-1: .25rem;  --sp-2: .5rem;  --sp-3: .75rem;
  --sp-4: 1rem;    --sp-5: 1.25rem; --sp-6: 1.5rem;
  --sp-8: 2rem;    --sp-10: 2.5rem; --sp-12: 3rem;

  /* Radius */
  --r-sm:   .5rem;  --r-md:  .75rem; --r-lg:  1rem;
  --r-xl:   1.25rem; --r-2xl: 1.5rem; --r-full: 9999px;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,.35);
  --shadow-md:   0 4px 12px rgba(0,0,0,.45);
  --shadow-lg:   0 10px 30px rgba(0,0,0,.55);
  --shadow-prim: 0 8px 30px var(--primary-glow);

  /* Layout */
  --nav-h:  4.5rem;
  --header-h: 3.75rem;

  /* Transitions */
  --t-fast:   150ms ease;
  --t-base:   250ms ease;
  --t-slow:   380ms cubic-bezier(.16,1,.3,1);
}

/* ===================== RESET ===================== */
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html { font-size:16px; -webkit-text-size-adjust:100%; scroll-behavior:smooth; }
body {
  font-family:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  background: var(--grad-bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
img { max-width:100%; height:auto; display:block; }
a { color:inherit; text-decoration:none; }
button { cursor:pointer; border:none; background:none; font-family:inherit; color:inherit; }
input,textarea,select { font-family:inherit; color:inherit; }
ul,ol { list-style:none; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance:none; }
input[type="number"] { -moz-appearance:textfield; }

/* ===================== LAYOUT ===================== */
.page {
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + var(--sp-6));
  padding-top: var(--header-h);
}

.page-no-nav { padding-bottom: var(--sp-8); padding-top: 0; }

.container {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 var(--sp-4);
}

/* ===================== HEADER ===================== */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  z-index: 100;
  background: rgba(8,12,30,.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 var(--sp-4);
}

.app-logo {
  font-size: var(--text-xl);
  font-weight: 800;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -.02em;
}

.app-logo span {
  -webkit-text-fill-color: transparent;
  font-weight: 400;
}

/* ===================== BOTTOM NAV ===================== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 100;
  background: rgba(8,12,30,.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 var(--sp-2);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-lg);
  color: var(--text-subtle);
  transition: all var(--t-base);
  -webkit-tap-highlight-color: transparent;
  font-size: var(--text-xs);
  font-weight: 500;
  min-width: 52px;
  cursor: pointer;
  user-select: none;
}

.nav-item svg {
  width: 1.3rem; height: 1.3rem;
  transition: transform var(--t-base);
  stroke-width: 1.75;
}

.nav-item.active {
  color: var(--primary);
}

.nav-item.active svg {
  transform: scale(1.1);
  filter: drop-shadow(0 0 8px var(--primary));
}

.nav-item:active { transform: scale(.88); }

/* ===================== CARDS ===================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: var(--sp-5);
  transition: border-color var(--t-base);
}

.card:hover { border-color: var(--border-md); }

/* ===================== SUMMARY STRIP ===================== */
.summary-strip {
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  margin: 0 calc(-1 * var(--sp-4));
  padding: var(--sp-1) var(--sp-4) var(--sp-3);
}
.summary-strip::-webkit-scrollbar { display: none; }

.summary-track {
  display: flex;
  gap: var(--sp-3);
  width: max-content;
}

.sum-card {
  width: 155px;
  flex-shrink: 0;
  border-radius: var(--r-xl);
  padding: var(--sp-4);
  position: relative;
  overflow: hidden;
  transition: transform var(--t-base);
  -webkit-tap-highlight-color: transparent;
}
.sum-card:active { transform: scale(.97); }

.sum-card::after {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 70px; height: 70px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
}

.sum-card.balance  { background: var(--grad-primary); box-shadow: var(--shadow-prim); }
.sum-card.income   { background: var(--grad-income);  box-shadow: 0 6px 24px var(--income-glow); }
.sum-card.expense  { background: var(--grad-expense); box-shadow: 0 6px 24px var(--expense-glow); }
.sum-card.savings  { background: var(--grad-savings); box-shadow: 0 6px 24px var(--savings-glow); }
.sum-card.goals    { background: var(--grad-goal);    box-shadow: 0 6px 24px var(--goal-glow); }

.sum-card-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .82;
  margin-bottom: var(--sp-2);
}

.sum-card-value {
  font-size: var(--text-lg);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.01em;
}

.sum-card-sub {
  font-size: var(--text-xs);
  opacity: .72;
  margin-top: var(--sp-1);
}

/* ===================== BALANCE CARD (MAIN) ===================== */
.balance-card {
  background: var(--grad-primary);
  border-radius: var(--r-2xl);
  padding: var(--sp-6);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-prim), 0 20px 60px rgba(124,111,255,.2);
}

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

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

.balance-period {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  opacity: .75;
  margin-bottom: var(--sp-2);
}

.balance-label {
  font-size: var(--text-sm);
  opacity: .8;
  margin-bottom: var(--sp-1);
}

.balance-amount {
  font-size: var(--text-4xl);
  font-weight: 900;
  letter-spacing: -.03em;
  line-height: 1;
}

.balance-sub {
  font-size: var(--text-xs);
  opacity: .7;
  margin-top: var(--sp-2);
}

/* ===================== SECTION HEADER ===================== */
.section-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.section-title {
  font-size: var(--text-base);
  font-weight: 700;
  letter-spacing: -.01em;
}

.section-link {
  font-size: var(--text-xs);
  color: var(--primary);
  font-weight: 600;
}

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-lg);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: all var(--t-base);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  cursor: pointer;
}

.btn::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,.12);
  opacity: 0;
  transition: opacity var(--t-fast);
}

.btn:active::after { opacity: 1; }
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: var(--shadow-prim);
}
.btn-primary:hover { box-shadow: 0 12px 36px var(--primary-glow); transform: translateY(-1px); }

.btn-income  { background: var(--grad-income);  color: #fff; }
.btn-expense { background: var(--grad-expense); color: #fff; }
.btn-savings { background: var(--grad-savings); color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-md);
}
.btn-outline:hover { background: var(--bg-hover); border-color: var(--border-lg); }

.btn-ghost { color: var(--text-muted); padding: var(--sp-2) var(--sp-3); }
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); border-radius: var(--r-md); }

.btn-icon {
  width: 2.5rem; height: 2.5rem;
  padding: 0;
  border-radius: var(--r-md);
  flex-shrink: 0;
}

.btn-icon-sm {
  width: 2rem; height: 2rem;
  padding: 0;
  border-radius: var(--r-sm);
}

.btn-lg {
  padding: var(--sp-4) var(--sp-8);
  font-size: var(--text-base);
  border-radius: var(--r-xl);
}

.btn-full { width: 100%; }

/* FAB */
.btn-fab {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--sp-4));
  right: var(--sp-5);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + var(--sp-4));
  width: 3.25rem; height: 3.25rem;
  border-radius: 50%;
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 8px 28px var(--primary-glow), 0 4px 12px rgba(0,0,0,.4);
  z-index: 99;
  transition: all var(--t-base);
  display: flex; align-items: center; justify-content: center;
}

.btn-fab:hover { transform: scale(1.08) translateY(-2px); box-shadow: 0 12px 36px var(--primary-glow); }
.btn-fab:active { transform: scale(.94); }

.btn-fab svg { width: 1.4rem; height: 1.4rem; }

/* ===================== FORMS ===================== */
.form-group { display: flex; flex-direction: column; gap: var(--sp-2); }

.form-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
}

.form-input, .form-select, .form-textarea {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border-md);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  color: var(--text);
  font-size: var(--text-base);
  width: 100%;
  transition: all var(--t-base);
  -webkit-appearance: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(124,111,255,.06);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-subtle); }

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394A3B8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
  cursor: pointer;
}

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

.form-input-wrap {
  position: relative;
}

.form-input-wrap .form-icon {
  position: absolute;
  left: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
  width: 1rem; height: 1rem;
}

.form-input-wrap .form-input { padding-left: 2.5rem; }

.form-input-wrap .form-suffix {
  position: absolute;
  right: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  pointer-events: none;
}

.form-error {
  font-size: var(--text-xs);
  color: var(--expense);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

/* Type tabs */
.type-tabs {
  display: flex;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border-md);
  border-radius: var(--r-xl);
  padding: var(--sp-1);
  gap: var(--sp-1);
}

.type-tab {
  flex: 1;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-lg);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--t-base);
  text-align: center;
  cursor: pointer;
}

.type-tab.active-income  { background: var(--income-bg);  color: var(--income); }
.type-tab.active-expense { background: var(--expense-bg); color: var(--expense); }

/* ===================== TRANSACTION LIST ===================== */
.tx-list { display: flex; flex-direction: column; gap: 2px; }

.tx-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-lg);
  transition: background var(--t-fast);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tx-item:active { background: var(--bg-hover); }

.tx-icon {
  width: 2.75rem; height: 2.75rem;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.tx-icon svg { width: 1.1rem; height: 1.1rem; }

.tx-icon.income  { background: var(--income-bg);  color: var(--income); }
.tx-icon.expense { background: var(--expense-bg); color: var(--expense); }

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

.tx-title {
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: 2px;
}

.tx-category {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.tx-date {
  font-size: var(--text-xs);
  color: var(--text-subtle);
}

.tx-recurring-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: var(--r-full);
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

.tx-amount {
  font-size: var(--text-sm);
  font-weight: 700;
  flex-shrink: 0;
  text-align: right;
}

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

.tx-amount-sub {
  font-size: var(--text-xs);
  color: var(--text-subtle);
  font-weight: 400;
}

/* ===================== GOAL CARDS ===================== */
.goal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-4);
  transition: all var(--t-base);
}

.goal-card:hover { border-color: var(--border-md); transform: translateY(-1px); }

.goal-icon {
  width: 2.5rem; height: 2.5rem;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.goal-icon svg { width: 1.2rem; height: 1.2rem; }

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: var(--r-full);
  overflow: hidden;
  margin: var(--sp-3) 0 var(--sp-2);
}

.progress-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width .6s ease;
}

/* ===================== BADGES ===================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-primary  { background: var(--primary-bg);  color: var(--primary); }
.badge-income   { background: var(--income-bg);   color: var(--income); }
.badge-expense  { background: var(--expense-bg);  color: var(--expense); }
.badge-savings  { background: var(--savings-bg);  color: var(--savings); }
.badge-warning  { background: var(--warning-bg);  color: var(--warning); }
.badge-goal     { background: var(--goal-bg);     color: var(--goal); }

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-count {
  min-width: 1.25rem; height: 1.25rem;
  border-radius: var(--r-full);
  background: var(--expense);
  color: #fff;
  font-size: .65rem;
  padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
}

/* ===================== AVATAR ===================== */
.avatar {
  width: 2.5rem; height: 2.5rem;
  border-radius: 50%;
  background: var(--grad-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: var(--text-sm);
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
  text-transform: uppercase;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg  { width: 3.5rem; height: 3.5rem; font-size: var(--text-lg); }
.avatar-xl  { width: 5rem;   height: 5rem;   font-size: var(--text-2xl); }

/* ===================== MODALS / BOTTOM SHEETS ===================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  padding: 0 var(--sp-4) var(--sp-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}

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

.modal-sheet {
  background: #0D1226;
  border: 1px solid var(--border-md);
  border-radius: var(--r-2xl) var(--r-2xl) var(--r-lg) var(--r-lg);
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  transform: translateY(110%);
  transition: transform var(--t-slow);
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay.active .modal-sheet { transform: translateY(0); }

.modal-drag {
  width: 2.5rem; height: 4px;
  background: var(--border-lg);
  border-radius: var(--r-full);
  margin: var(--sp-3) auto var(--sp-1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-5) var(--sp-4);
}

.modal-title { font-size: var(--text-lg); font-weight: 700; letter-spacing: -.01em; }

.modal-body { padding: 0 var(--sp-5) var(--sp-6); }
.modal-body .form-group + .form-group { margin-top: var(--sp-4); }
.modal-body .btn-full { margin-top: var(--sp-5); }

/* ===================== TOAST ===================== */
.toast-wrap {
  position: fixed;
  top: calc(var(--header-h) + var(--sp-3));
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: calc(100% - var(--sp-8));
  max-width: 420px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: #111827;
  border: 1px solid var(--border-md);
  border-radius: var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s ease forwards;
  pointer-events: all;
}

.toast.toast-success { border-left: 3px solid var(--income); }
.toast.toast-error   { border-left: 3px solid var(--expense); }
.toast.toast-warning { border-left: 3px solid var(--warning); }
.toast.toast-info    { border-left: 3px solid var(--primary); }

.toast-icon { flex-shrink: 0; width: 1rem; height: 1rem; }
.toast-text { flex: 1; font-size: var(--text-sm); font-weight: 500; }

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

/* ===================== CHART CONTAINER ===================== */
.chart-wrap {
  position: relative;
  width: 100%;
}

.chart-legend {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.chart-legend-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
}

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

.chart-legend-label { flex: 1; color: var(--text-muted); }
.chart-legend-val   { font-weight: 700; }
.chart-legend-pct   { font-size: var(--text-xs); color: var(--text-subtle); }

/* ===================== SKELETON ===================== */
.skel {
  background: linear-gradient(90deg,
    rgba(255,255,255,.04) 25%,
    rgba(255,255,255,.08) 50%,
    rgba(255,255,255,.04) 75%
  );
  background-size: 400% 100%;
  animation: skel 1.5s ease infinite;
  border-radius: var(--r-md);
}

@keyframes skel {
  from { background-position: 100% 50%; }
  to   { background-position: 0% 50%; }
}

/* ===================== EMPTY STATE ===================== */
.empty-state {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
}

.empty-icon {
  width: 4.5rem; height: 4.5rem;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto var(--sp-4);
  color: var(--text-subtle);
}

.empty-icon svg { width: 2rem; height: 2rem; }

.empty-title { font-size: var(--text-lg); font-weight: 700; margin-bottom: var(--sp-2); }
.empty-text  { color: var(--text-muted); font-size: var(--text-sm); line-height: 1.6; }

/* ===================== TOGGLE ===================== */
.toggle {
  position: relative;
  width: 3rem; height: 1.625rem;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-track {
  position: absolute; inset: 0;
  background: var(--border-md);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background var(--t-base);
}

.toggle-track::before {
  content: '';
  position: absolute;
  width: 1.1875rem; height: 1.1875rem;
  left: .225rem;
  top: 50%; transform: translateY(-50%);
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t-base);
  box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-track { background: var(--primary); }
.toggle input:checked + .toggle-track::before { transform: translate(1.375rem, -50%); }

/* ===================== CHIPS ===================== */
.chip-scroll {
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  margin: 0 calc(-1 * var(--sp-4));
  padding: var(--sp-1) var(--sp-4);
}
.chip-scroll::-webkit-scrollbar { display: none; }

.chip-track { display: flex; gap: var(--sp-2); width: max-content; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all var(--t-fast);
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.chip:hover, .chip.active {
  background: var(--primary-bg);
  border-color: var(--primary);
  color: var(--primary);
}

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

/* ===================== DIVIDER ===================== */
.divider { height: 1px; background: var(--border); margin: var(--sp-4) 0; }

/* ===================== STATUS INDICATORS ===================== */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.on  { background: var(--income); box-shadow: 0 0 6px var(--income-glow); }
.status-dot.off { background: var(--text-subtle); }
.status-dot.pending { background: var(--warning); box-shadow: 0 0 6px var(--savings-glow); }

/* ===================== GRID ===================== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }

/* ===================== LIST ITEM ===================== */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all var(--t-fast);
}

.list-item:hover { border-color: var(--border-md); }

/* ===================== NOTIFICATIONS ===================== */
.notif-item {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  position: relative;
  transition: all var(--t-fast);
}

.notif-item.unread { border-left: 3px solid var(--primary); }
.notif-item.unread::before {
  content: '';
  position: absolute;
  top: var(--sp-4); right: var(--sp-4);
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

/* ===================== ANIMATIONS ===================== */
@keyframes fadeIn   { from { opacity:0 } to { opacity:1 } }
@keyframes slideUp  { from { opacity:0; transform:translateY(16px) } to { opacity:1; transform:translateY(0) } }
@keyframes scaleIn  { from { opacity:0; transform:scale(.95) } to { opacity:1; transform:scale(1) } }
@keyframes pulse    { 0%,100% { opacity:1 } 50% { opacity:.5 } }

.anim-fade-in  { animation: fadeIn  .3s ease both; }
.anim-slide-up { animation: slideUp .4s ease both; }
.anim-scale-in { animation: scaleIn .3s ease both; }

/* Stagger children */
.stagger > *:nth-child(1) { animation-delay: .05s; }
.stagger > *:nth-child(2) { animation-delay: .10s; }
.stagger > *:nth-child(3) { animation-delay: .15s; }
.stagger > *:nth-child(4) { animation-delay: .20s; }
.stagger > *:nth-child(5) { animation-delay: .25s; }

/* ===================== SCROLLBAR ===================== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 2px; }

/* ===================== UTILITIES ===================== */
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.p-4  { padding: var(--sp-4); }
.p-5  { padding: var(--sp-5); }
.px-4 { padding-left: var(--sp-4); padding-right: var(--sp-4); }
.py-4 { padding-top: var(--sp-4); padding-bottom: var(--sp-4); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.flex  { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.flex-1  { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.w-full  { width: 100%; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-xs   { font-size: var(--text-xs); }
.text-sm   { font-size: var(--text-sm); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }
.text-2xl  { font-size: var(--text-2xl); }
.text-muted  { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-income  { color: var(--income); }
.text-expense { color: var(--expense); }
.text-primary { color: var(--primary); }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-black { font-weight: 900; }
.hidden { display: none !important; }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }
.cursor-pointer { cursor: pointer; }
.no-select { user-select: none; -webkit-user-select: none; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== SAFE AREA ===================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav { padding-bottom: env(safe-area-inset-bottom); }
  .modal-overlay { padding-bottom: max(var(--sp-4), env(safe-area-inset-bottom)); }
}

/* ===================== RESPONSIVE ===================== */
@media (min-width: 600px) {
  .container { max-width: 600px; }
  .sum-card  { width: 180px; }
  .btn-fab   { right: var(--sp-8); }
  .grid-md-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
}

/* ===================== PWA META COLORS ===================== */
/* See <meta name="theme-color"> in HTML head */

/* ===================== DASHBOARD REDESIGN ===================== */
.dashboard-header-block {
  background: var(--grad-primary);
  margin: 0 calc(-1 * var(--sp-4));
  padding: var(--sp-4) var(--sp-4) var(--sp-6);
  color: #fff;
  border-bottom-left-radius: var(--r-2xl);
  border-bottom-right-radius: var(--r-2xl);
  box-shadow: 0 4px 20px rgba(124,111,255,0.15);
  position: relative;
  overflow: hidden;
}

.dh-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}

.dh-month {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  font-weight: 600;
  font-size: var(--text-base);
}

.dh-month-btn {
  padding: var(--sp-1);
  color: rgba(255,255,255,.8);
  transition: color var(--t-fast);
}

.dh-month-btn:hover { color: #fff; }

.dh-balances {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: var(--sp-4);
  text-align: center;
}

.dh-bal-col { flex: 1; }
.dh-bal-label { font-size: var(--text-xs); color: rgba(255,255,255,.7); display: flex; align-items: center; justify-content: center; gap: 4px; margin-bottom: 2px; }
.dh-bal-val { font-size: var(--text-sm); font-weight: 600; }
.dh-bal-main .dh-bal-val { font-size: var(--text-3xl); font-weight: 800; letter-spacing: -.02em; }
.dh-bal-main .dh-bal-label { color: rgba(255,255,255,.9); font-weight: 500; }

.overview-list {
  display: flex;
  flex-direction: column;
}

.overview-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}

.overview-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.overview-icon {
  width: 2.5rem; height: 2.5rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.overview-info { flex: 1; }
.overview-title { font-size: var(--text-sm); font-weight: 600; }
.overview-sub { font-size: var(--text-xs); color: var(--text-muted); }

.overview-values { text-align: right; }
.overview-val { font-size: var(--text-sm); font-weight: 700; }
.overview-val-sub { font-size: var(--text-xs); color: var(--text-muted); }

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-top: var(--sp-2);
}

.ranking-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.ranking-label { width: 80px; font-size: var(--text-xs); color: var(--text-muted); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ranking-bar-track { flex: 1; height: 16px; background: rgba(255,255,255,.03); position: relative; }
.ranking-bar-fill { height: 100%; position: absolute; left: 0; top: 0; transition: width .6s ease; }
.ranking-pct { width: 35px; font-size: var(--text-xs); color: var(--text-muted); text-align: left; }

.donut-card-inner {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
}

.donut-legend-vertical {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.donut-legend-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
}

.donut-legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.donut-legend-name { flex: 1; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.donut-legend-pct { font-weight: 600; color: var(--text-subtle); }
