/* ====================
   Reset & Base
   ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'SF Pro Display', Roboto, sans-serif;
  color: #1a2942;
  line-height: 1.4;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  background: #4A90E2;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

/* ====================
   Background — Light Blue Gradient + Flares
   ==================== */
.bg-gradient {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #B8D4FF 0%, #7BB8FF 35%, #4A90E2 100%);
  z-index: -2;
}

.bg-flare {
  position: fixed;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.5;
  z-index: -1;
  pointer-events: none;
}
.bg-flare-1 {
  top: -10%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #ffffff 0%, transparent 70%);
}
.bg-flare-2 {
  bottom: 10%;
  left: -15%;
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, #d4e6ff 0%, transparent 70%);
  opacity: 0.6;
}

/* ====================
   App Frame (phone-like)
   ==================== */
.app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  max-height: 920px;
  margin: 0 auto;
  overflow: hidden;
  background: transparent;
}

/* ====================
   Screens
   ==================== */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 20px 0 20px;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  scrollbar-width: none;
  padding-bottom: 100px;
}
.screen::-webkit-scrollbar { display: none; }

.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.screen-home, .screen-history, .screen-profile {
  padding-bottom: 110px;
}

/* ====================
   Header
   ==================== */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 18px;
  flex-shrink: 0;
}

.greeting {
  display: flex;
  flex-direction: column;
}
.greeting-line {
  font-size: 0.85rem;
  color: #4a6285;
  font-weight: 500;
}
.greeting-name {
  font-size: 1.6rem;
  font-weight: 700;
  color: #0f1d33;
  letter-spacing: -0.3px;
}

.header-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f1d33;
  letter-spacing: -0.2px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a2942;
  border: 1px solid rgba(255, 255, 255, 0.6);
  transition: transform 0.1s, background 0.15s;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 20px; height: 20px; }

/* ====================
   Hero Card (Balance)
   ==================== */
.hero-card {
  position: relative;
  border-radius: 24px;
  padding: 22px 22px 20px;
  color: white;
  background: linear-gradient(135deg, #4A90E2 0%, #357ABD 50%, #2A5F9E 100%);
  box-shadow: 0 20px 50px -10px rgba(42, 95, 158, 0.5),
              0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  overflow: hidden;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.hero-shine {
  position: absolute;
  top: -50%;
  right: -30%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
  pointer-events: none;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 1;
}
.hero-label {
  font-size: 0.85rem;
  opacity: 0.9;
  font-weight: 500;
}
.hero-account {
  font-size: 0.75rem;
  opacity: 0.75;
  background: rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.hero-amount {
  font-size: 2.4rem;
  font-weight: 700;
  margin: 14px 0 6px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  position: relative;
  z-index: 1;
}

.hero-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 1;
}
.hero-meta-item {
  font-size: 0.85rem;
  opacity: 0.85;
  font-weight: 500;
}
.hero-meta-item.positive { color: #b3f0c5; }
.hero-meta-item.negative { color: #ffb3b3; }

.hero-eye {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}
.hero-eye svg { width: 16px; height: 16px; }

/* ====================
   Quick Action Row
   ==================== */
.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
  flex-shrink: 0;
}

.action-btn {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 18px;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.1s, background 0.15s;
}
.action-btn:active { transform: scale(0.96); background: rgba(255, 255, 255, 0.7); }

.action-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}
.action-icon svg { width: 18px; height: 18px; }
.action-icon-up      { background: linear-gradient(135deg, #34D399, #10B981); }
.action-icon-down    { background: linear-gradient(135deg, #F87171, #EF4444); }
.action-icon-transfer{ background: linear-gradient(135deg, #60A5FA, #4A90E2); }

.action-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #1a2942;
}

/* ====================
   Section Title Row
   ==================== */
.section-block { margin-bottom: 8px; }
.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f1d33;
  letter-spacing: -0.2px;
}
.section-title-mt { margin-top: 20px; margin-bottom: 14px; }

.link-btn {
  font-size: 0.85rem;
  font-weight: 600;
  color: #4A90E2;
}

/* ====================
   Transaction List
   ==================== */
.tx-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  transition: transform 0.1s;
}
.tx-item:active { transform: scale(0.99); }

.tx-icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.7);
}

.tx-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tx-name {
  font-weight: 600;
  color: #0f1d33;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tx-cat {
  font-size: 0.78rem;
  color: #6b7d99;
}

.tx-amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
  white-space: nowrap;
}
.tx-amount.income  { color: #10B981; }
.tx-amount.expense { color: #EF4444; }

.tx-delete {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #b0bccd;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.tx-delete:hover { background: rgba(239, 68, 68, 0.1); color: #EF4444; }

/* ====================
   Empty State
   ==================== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #4a6285;
}
.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  opacity: 0.7;
}
.empty-state p {
  font-weight: 600;
  color: #1a2942;
  margin-bottom: 4px;
}
.empty-state span {
  font-size: 0.85rem;
}

/* ====================
   Tabs (Analytics)
   ==================== */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 18px;
  flex-shrink: 0;
}

.tab {
  padding: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #4a6285;
  border-radius: 10px;
  transition: background 0.15s, color 0.15s;
}
.tab.active {
  background: white;
  color: #0f1d33;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.period-selector {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-shrink: 0;
}
.period-btn {
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #4a6285;
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  transition: all 0.15s;
}
.period-btn.active {
  background: #4A90E2;
  color: white;
  border-color: #4A90E2;
}

.analytics-total {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
  flex-shrink: 0;
}
.analytics-total-label {
  font-size: 0.85rem;
  color: #4a6285;
  font-weight: 500;
  margin-bottom: 4px;
}
.analytics-total-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: #0f1d33;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.4px;
}

/* ====================
   Chart
   ==================== */
.chart-card {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  padding: 20px 16px 16px;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  height: 140px;
  align-items: end;
}

.chart-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 100%;
  background: linear-gradient(180deg, #7BB8FF, #4A90E2);
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.chart-bar.highlight {
  background: linear-gradient(180deg, #B8D4FF, #7BB8FF);
}
.chart-bar.empty {
  background: rgba(74, 144, 226, 0.15);
}

.chart-label {
  font-size: 0.7rem;
  color: #6b7d99;
  font-weight: 600;
}

/* ====================
   Category Grid
   ==================== */
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.category-card {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  padding: 14px;
}
.category-card-label {
  font-size: 0.78rem;
  color: #4a6285;
  font-weight: 500;
  margin-bottom: 4px;
}
.category-card-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f1d33;
  font-variant-numeric: tabular-nums;
}

/* ====================
   Add Screen — Amount Display
   ==================== */
.amount-display {
  position: relative;
  text-align: center;
  margin: 20px 0 24px;
  flex-shrink: 0;
}
.amount-currency {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-110px, -50%);
  font-size: 1.8rem;
  font-weight: 600;
  color: #4a6285;
}
.amount-input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 3.5rem;
  font-weight: 700;
  color: #0f1d33;
  text-align: center;
  width: 100%;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.amount-input::placeholder { color: rgba(15, 29, 51, 0.3); }
.amount-input::-webkit-outer-spin-button,
.amount-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.amount-hint {
  display: block;
  font-size: 0.8rem;
  color: #6b7d99;
  margin-top: 4px;
}

/* ====================
   Segmented Control
   ==================== */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 18px;
  flex-shrink: 0;
}

.segment {
  padding: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #4a6285;
  border-radius: 10px;
  transition: all 0.15s;
}
.segment.active {
  background: white;
  color: #0f1d33;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ====================
   Form Card
   ==================== */
.form-card {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  padding: 4px 16px;
  margin-bottom: 24px;
  flex-shrink: 0;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  min-height: 50px;
}
.form-row-stack { align-items: flex-start; }

.form-icon {
  font-size: 1.1rem;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.form-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.form-label {
  font-size: 0.75rem;
  color: #6b7d99;
  font-weight: 500;
}
.form-input, .form-select {
  background: transparent;
  border: none;
  outline: none;
  font-size: 0.95rem;
  color: #0f1d33;
  font-weight: 600;
  padding: 0;
  width: 100%;
}
.form-select { appearance: none; cursor: pointer; }
.form-input::placeholder { color: rgba(107, 125, 153, 0.6); font-weight: 500; }

.form-chevron {
  color: #6b7d99;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.form-divider {
  height: 1px;
  background: rgba(74, 144, 226, 0.12);
}

/* ====================
   Add Actions (bottom of add screen)
   ==================== */
.add-actions {
  display: flex;
  gap: 12px;
  margin-top: auto;
  margin-bottom: 30px;
  flex-shrink: 0;
}

.add-btn {
  flex: 1;
  height: 54px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, background 0.15s;
}
.add-btn:active { transform: scale(0.96); }
.add-btn svg { width: 22px; height: 22px; }

.add-btn-cancel { background: rgba(255, 255, 255, 0.55); color: #EF4444; border: 1px solid rgba(255, 255, 255, 0.6); }
.add-btn-attach { background: rgba(255, 255, 255, 0.55); color: #1a2942; border: 1px solid rgba(255, 255, 255, 0.6); }
.add-btn-confirm {
  background: linear-gradient(135deg, #4A90E2, #357ABD);
  color: white;
  flex: 1.4;
  box-shadow: 0 8px 20px -5px rgba(74, 144, 226, 0.5);
}

/* ====================
   Filter Pills (History)
   ==================== */
.filter-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-shrink: 0;
}
.pill {
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #4a6285;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  transition: all 0.15s;
}
.pill.active {
  background: #4A90E2;
  color: white;
  border-color: #4A90E2;
}

/* ====================
   Bottom Nav
   ==================== */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 78px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border-top: 1px solid rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 10px 14px;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: #6b7d99;
  padding: 8px 0;
  transition: color 0.15s;
}
.nav-btn.active { color: #4A90E2; }
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn span { font-size: 0.7rem; font-weight: 600; }

.nav-fab {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4A90E2, #357ABD);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px -5px rgba(74, 144, 226, 0.6);
  margin-top: -22px;
  transition: transform 0.1s;
}
.nav-fab:active { transform: scale(0.95); }
.nav-fab svg { width: 24px; height: 24px; }

.nav-spacer { height: 24px; flex-shrink: 0; }

/* ====================
   Profile
   ==================== */
.profile-card {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  margin-top: 8px;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4A90E2, #357ABD);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  margin: 0 auto 14px;
  box-shadow: 0 8px 20px -5px rgba(74, 144, 226, 0.4);
}

.profile-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: #0f1d33;
  margin-bottom: 4px;
}

.profile-email {
  font-size: 0.85rem;
  color: #6b7d99;
  margin-bottom: 24px;
}

.profile-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.profile-stat {
  background: rgba(255, 255, 255, 0.6);
  border-radius: 14px;
  padding: 14px 8px;
}
.profile-stat-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f1d33;
  margin-bottom: 2px;
}
.profile-stat-label {
  font-size: 0.75rem;
  color: #6b7d99;
  font-weight: 500;
}

.danger-btn {
  background: rgba(239, 68, 68, 0.1);
  color: #EF4444;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s;
}
.danger-btn:hover { background: rgba(239, 68, 68, 0.18); }

/* ====================
   Loading Overlay
   ==================== */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(184, 212, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(74, 144, 226, 0.2);
  border-top-color: #4A90E2;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 0.9rem;
  color: #1a2942;
  font-weight: 600;
}

/* ====================
   Error Banner
   ==================== */
.error-banner {
  position: absolute;
  bottom: 90px;
  left: 16px;
  right: 16px;
  background: rgba(239, 68, 68, 0.95);
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  z-index: 150;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  box-shadow: 0 8px 20px -5px rgba(239, 68, 68, 0.4);
}
.error-banner.show {
  opacity: 1;
  transform: translateY(0);
}

/* ====================
   Responsive — desktop preview
   ==================== */
@media (min-width: 600px) {
  body {
    background: #1a2942;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .app {
    border-radius: 36px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4),
                0 0 0 8px #0f1d33,
                0 0 0 10px #2a3a55;
    height: 90vh;
    max-height: 900px;
  }
  .bg-flare { opacity: 0.7; }
}
