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

:root {
  --bg: #F7F8FC;
  --surface: #FFFFFF;
  --border: #E8ECF4;
  --border-soft: #F0F2F8;
  --text-primary: #1A1D2E;
  --text-secondary: #6B7280;
  --text-muted: #9AA3B4;
  --text-hint: #B0B8CC;

  --primary: #5B4CF5;
  --primary-light: #EEEDFE;
  --primary-dark: #3C3489;

  --green: #10B981;
  --green-light: #D1FAE5;
  --green-dark: #065F46;

  --red: #EF4444;
  --red-light: #FEE2E2;
  --red-dark: #991B1B;

  --amber: #F59E0B;
  --amber-light: #FEF3C7;
  --amber-dark: #92400E;

  --blue: #3B82F6;
  --blue-light: #EFF6FF;

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

  --shadow-sm: 0 1px 3px rgba(26, 29, 46, 0.06);
  --shadow-md: 0 4px 16px rgba(26, 29, 46, 0.08);
  --shadow-lg: 0 12px 32px rgba(91, 76, 245, 0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  font-family: 'Inter', sans-serif;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }

::-webkit-scrollbar { width: 0; height: 0; }

/* ---------- App shell (mobile-first, centered on desktop) ---------- */
.app-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(26,29,46,0.06);
}

.app-main {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 90px;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Page transitions ---------- */
.view {
  display: none;
  animation: fadeSlideIn 0.35s cubic-bezier(.4,0,.2,1);
}
.view.active { display: block; }

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

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

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 4px;
}

.greeting { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.username { font-size: 20px; font-weight: 700; color: var(--text-primary); font-family: 'Space Grotesk', sans-serif; }

.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.avatar:active { transform: scale(0.92); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 16px;
}

.card-hero {
  background: var(--primary);
  border-radius: var(--radius-lg);
  padding: 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.hero-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; color: rgba(255,255,255,0.7); }
.hero-amount { font-size: 36px; font-weight: 700; font-family: 'Space Grotesk', sans-serif; margin: 4px 0 2px; }
.hero-change { font-size: 12px; color: rgba(255,255,255,0.8); display: flex; align-items: center; gap: 5px; }

/* ---------- Section headers ---------- */
.sec-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 20px 10px;
}
.sec-title { font-size: 15px; font-weight: 700; color: var(--text-primary); font-family: 'Space Grotesk', sans-serif; }
.sec-link { font-size: 12px; color: var(--primary); font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 3px; }
.sec-link:hover { text-decoration: underline; }

/* ---------- Chips / filters ---------- */
.chip-row { display: flex; gap: 7px; padding: 0 20px 10px; overflow-x: auto; }
.chip {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- Stat grid ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 10px;
  padding: 12px 20px 0;
}
.stat-card { padding: 14px; }
.stat-icon-wrap {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.stat-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-value { font-size: 18px; font-weight: 700; margin-top: 3px; font-family: 'Space Grotesk', sans-serif; }

/* ---------- Transaction rows ---------- */
.tx-list { padding: 0 20px; }
.tx-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  border: 1px solid var(--border-soft);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  animation: slideUp 0.35s both;
}
.tx-row:active { transform: scale(0.98); }
.tx-row:hover { box-shadow: var(--shadow-sm); }

.tx-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.tx-info { flex: 1; min-width: 0; }
.tx-name { font-size: 14px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-cat { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.tx-amount { font-size: 15px; font-weight: 700; text-align: right; }
.tx-amount.plus { color: var(--green); }
.tx-amount.minus { color: var(--red); }
.tx-date { font-size: 11px; color: var(--text-hint); text-align: right; margin-top: 2px; }

/* ---------- Progress bars ---------- */
.progress-track { height: 7px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 1s cubic-bezier(.4,0,.2,1); }

/* ---------- Bottom navigation ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
  display: flex;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 14px));
  z-index: 100;
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer;
  padding: 4px 0;
  color: var(--text-hint);
  transition: color 0.2s;
  background: none; border: none;
}
.nav-item i { font-size: 21px; }
.nav-item span { font-size: 10px; font-weight: 600; }
.nav-item.active { color: var(--primary); }

.fab {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: #fff;
  cursor: pointer;
  margin-top: -16px;
  border: 3px solid var(--bg);
  transition: transform 0.2s;
  box-shadow: var(--shadow-lg);
}
.fab:active { transform: scale(0.92); }

/* ---------- Modal / bottom sheet ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(26,29,46,0.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s;
}
.overlay.open { opacity: 1; pointer-events: all; }

.sheet {
  width: 100%; max-width: 480px;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 18px 20px 32px;
  transform: translateY(100%);
  transition: transform 0.38s cubic-bezier(.4,0,.2,1);
  max-height: 88vh;
  overflow-y: auto;
}
.overlay.open .sheet { transform: translateY(0); }

.sheet-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 0 auto 16px; }
.sheet-title { font-size: 17px; font-weight: 700; text-align: center; margin-bottom: 18px; font-family: 'Space Grotesk', sans-serif; }

/* ---------- Form elements ---------- */
.type-toggle { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.type-btn {
  flex: 1; padding: 9px; border-radius: 8px; text-align: center;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s;
  color: var(--text-muted);
}
.type-btn.active-red { background: var(--surface); color: var(--red); box-shadow: var(--shadow-sm); }
.type-btn.active-green { background: var(--surface); color: var(--green); box-shadow: var(--shadow-sm); }
.type-btn.active-purple { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

.field-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin: 0 0 6px 2px; display: block; }
.input-field {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}
.input-field:focus { border-color: var(--primary); }
.input-field::placeholder { color: var(--text-hint); }

.amount-input {
  width: 100%; background: none; border: none;
  font-size: 38px; font-weight: 700; text-align: center;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text-primary);
  outline: none;
  margin-bottom: 16px;
}
.amount-input::placeholder { color: #D1D5E0; }

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border-radius: 13px;
  padding: 13px;
  font-size: 15px; font-weight: 700;
  transition: all 0.2s;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  background: var(--bg);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  border-radius: 13px;
  padding: 12px;
  font-size: 14px; font-weight: 600;
  transition: all 0.2s;
}
.btn-secondary:active { transform: scale(0.98); }

.error-text { font-size: 12px; color: var(--red); margin: -6px 0 12px 2px; display: none; }
.error-text.show { display: block; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 10px; font-weight: 700; }
.badge-green { background: var(--green-light); color: var(--green-dark); }
.badge-red { background: var(--red-light); color: var(--red-dark); }
.badge-amber { background: var(--amber-light); color: var(--amber-dark); }
.badge-purple { background: var(--primary-light); color: var(--primary-dark); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 50px 30px;
  color: var(--text-muted);
}
.empty-state i { font-size: 38px; color: var(--text-hint); margin-bottom: 10px; display: block; }
.empty-state p { font-size: 13px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 100px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text-primary);
  color: #fff;
  padding: 11px 20px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  z-index: 999;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }
.toast.success { background: var(--green-dark); }

/* ---------- Loading spinner ---------- */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--border-soft) 25%, var(--border) 50%, var(--border-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-md);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
