:root {
  --bg: #0B0B0F;
  --surface-1: #1C1C22;
  --surface-2: #26262E;
  --surface-3: #32323D;
  --border: #2A2A33;
  --accent: #5B5BF6;
  --accent-alt: #8A6BFF;
  --accent-gradient: linear-gradient(135deg, #5B5BF6 0%, #8A6BFF 100%);
  --positive: #00C48C;
  --positive-bg: rgba(0, 196, 140, 0.12);
  --negative: #FF5C5C;
  --negative-bg: rgba(255, 92, 92, 0.12);
  --warning: #FFB020;
  --warning-bg: rgba(255, 176, 32, 0.12);
  --text-primary: #FFFFFF;
  --text-secondary: #9A9AA5;
  --text-muted: #656573;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding-bottom: calc(75px + env(safe-area-inset-bottom, 16px));
}

@media (min-width: 768px) {
  body {
    padding-bottom: 30px;
  }
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(11, 11, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.user-badge:hover {
  background: var(--surface-3);
  border-color: var(--accent);
}

.user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--positive);
}

/* Container */
.container {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Month Selector */
.month-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
}

.month-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.month-btn:hover {
  color: var(--text-primary);
  background: var(--surface-2);
}

.month-title {
  font-size: 15px;
  font-weight: 600;
  text-transform: capitalize;
}

/* Balance Hero Card */
.hero-card {
  background: linear-gradient(180deg, var(--surface-1) 0%, rgba(28, 28, 34, 0.6) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 150px;
  height: 150px;
  background: radial-gradient(circle, rgba(91, 91, 246, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.hero-amount {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-title {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
}

.stat-value.pos {
  color: var(--positive);
}

.stat-value.neg {
  color: var(--negative);
}

/* Subscriptions Banner Card */
.sub-banner {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.sub-banner:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.sub-banner-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sub-banner-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-alt);
}

.sub-banner-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sub-banner-title {
  font-size: 14px;
  font-weight: 600;
}

.sub-banner-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

.sub-banner-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sub-banner-amount {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.section-action {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-alt);
  background: none;
  border: none;
  cursor: pointer;
}

/* Categories Progress List */
.card-list {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cat-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cat-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cat-item-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
}

.cat-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-alt);
}

.cat-item-amt {
  font-size: 14px;
  font-weight: 700;
}

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

.progress-bar-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* Transaction & Subscription Item Rows */
.tx-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tx-item {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s ease;
}

.tx-item:hover {
  background: var(--surface-2);
}

.tx-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.tx-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tx-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}

.tx-desc {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-meta {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  gap: 8px;
  align-items: center;
}

.tx-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  flex-shrink: 0;
}

.tx-amount {
  font-size: 15px;
  font-weight: 700;
}

.tx-amount.neg {
  color: var(--negative);
}

.tx-amount.pos {
  color: var(--positive);
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-secondary);
}

.badge.active {
  background: var(--positive-bg);
  color: var(--positive);
}

.badge.frequency {
  background: var(--warning-bg);
  color: var(--warning);
}

/* Floating Action Button */
.fab {
  position: fixed;
  bottom: calc(85px + env(safe-area-inset-bottom, 16px));
  right: 20px;
  z-index: 40;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--accent-gradient);
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(91, 91, 246, 0.45);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fab:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 28px rgba(91, 91, 246, 0.55);
}

.fab:active {
  transform: scale(0.95);
}

@media (min-width: 768px) {
  .fab {
    bottom: 30px;
    right: 40px;
  }
}

/* Bottom Navigation Bar for Mobile */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 45;
  background: rgba(11, 11, 15, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 8px));
  display: flex;
  justify-content: space-around;
}

@media (min-width: 768px) {
  .bottom-nav {
    display: none;
  }
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: color 0.15s ease;
}

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

.nav-item svg {
  width: 22px;
  height: 22px;
}

/* Desktop Top Nav */
.desktop-nav {
  display: none;
}

@media (min-width: 768px) {
  .desktop-nav {
    display: flex;
    gap: 8px;
  }
  .desktop-nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
  }
  .desktop-nav-btn.active, .desktop-nav-btn:hover {
    background: var(--surface-2);
    color: var(--text-primary);
  }
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 16px));
  box-shadow: var(--shadow);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

@media (min-width: 768px) {
  .modal-overlay {
    align-items: center;
  }
  .modal-card {
    border-radius: var(--radius-xl);
    padding: 28px 24px;
    transform: translateY(20px);
  }
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.close-btn {
  background: var(--surface-2);
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

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

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

.form-control {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-control:focus {
  border-color: var(--accent);
}

/* Segmented Buttons for Expense / Income */
.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}

.segment-btn {
  background: transparent;
  border: none;
  padding: 10px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.segment-btn.active.expense {
  background: var(--negative-bg);
  color: var(--negative);
}

.segment-btn.active.income {
  background: var(--positive-bg);
  color: var(--positive);
}

.btn-primary {
  background: var(--accent-gradient);
  border: none;
  color: white;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(91, 91, 246, 0.35);
  transition: all 0.2s ease;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  opacity: 0.95;
}

.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.btn-secondary:hover {
  background: var(--surface-3);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
}
