/* 
  Expense Tracker — Premium Dark UI
  Professional redesign with sidebar, glassmorphism, micro-animations
*/

/* ===== CSS Variables ===== */
:root {
  /* Core palette */
  --bg-primary: #0b0f1e;
  --bg-secondary: #131a2b;
  --bg-card: rgba(12, 16, 30, 0.95);
  --bg-card-solid: #0c101e;
  --bg-elevated: #161c30;
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-hover: rgba(255, 255, 255, 0.08);

  /* Accent */
  --accent-primary: #7c3aed;
  --accent-secondary: #a78bfa;
  --accent-gradient: linear-gradient(135deg, #7c3aed, #6d28d9);
  --accent-gradient-vibrant: linear-gradient(135deg, #8b5cf6, #6366f1, #06b6d4);
  --accent-glow: rgba(124, 58, 237, 0.25);

  /* Semantic */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --info: #06b6d4;
  --info-bg: rgba(6, 182, 212, 0.12);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  /* Border */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(124, 58, 237, 0.3);

  /* Category Colors */
  --cat-transport: #3b82f6;
  --cat-food: #f97316;
  --cat-housing: #8b5cf6;
  --cat-entertainment: #ec4899;
  --cat-subscriptions: #06b6d4;
  --cat-habits: #ef4444;
  --cat-coffee: #d97706;
  --cat-shopping: #14b8a6;
  --cat-health: #22c55e;
  --cat-education: #6366f1;
  --cat-other: #6b7280;

  /* Layout */
  --sidebar-width: 72px;
  --header-height: 64px;

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

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px var(--accent-glow);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.04);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  /* Safe area padding for devices with rounded screens (iPhone) */
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* Ambient background glow */
body::before {
  content: '';
  position: fixed;
  top: -200px;
  right: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -200px;
  left: -100px;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1.125rem;
}

a {
  color: var(--accent-secondary);
  text-decoration: none;
}

/* ===== App Layout ===== */
.app-layout {
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-lg) 0;
  z-index: 100;
  gap: var(--space-xs);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-xl);
  flex-shrink: 0;
}

.sidebar-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  flex: 1;
}

.sidebar-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.25rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
}

.sidebar-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.sidebar-btn.active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(99, 102, 241, 0.15));
  color: var(--accent-secondary);
  box-shadow: 0 0 16px rgba(124, 58, 237, 0.15);
}

.sidebar-btn.active::before {
  content: '';
  position: absolute;
  left: -14px;
  width: 3px;
  height: 24px;
  background: var(--accent-primary);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.sidebar-btn[title]::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 12px);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
}

.sidebar-btn:hover[title]::after {
  opacity: 1;
}

.sidebar-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  margin-top: auto;
}

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  padding: var(--space-xl) var(--space-2xl);
  max-width: 1440px;
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
}

/* ===== Container (legacy support) ===== */
.container {
  width: 100%;
  position: relative;
  z-index: 1;
}

/* ===== Welcome Section ===== */
.welcome-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.welcome-info h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

.welcome-info h1 span {
  background: var(--accent-gradient-vibrant);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-date {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: var(--space-2xs);
}

.welcome-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* ===== Header (legacy, now inside welcome) ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.header-title {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  width: 100%;
}

.header-title .user-token-badge {
  margin-left: auto;
}

.logo {
  width: 44px;
  height: 44px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: var(--shadow-glow);
}

.logo-img {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  object-fit: cover;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* ===== Grid System ===== */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-2 {
  grid-template-columns: 1fr 1fr;
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1100px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {

  .grid,
  .grid-2,
  .grid-3,
  .grid-4 {
    max-width: 100% !important;
    overflow: hidden;
  }

  .grid>* {
    min-width: 0;
    overflow: hidden;
  }

  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ===== Card ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  backdrop-filter: blur(16px);
  transition: all var(--transition-normal);
  animation: cardFadeIn 0.4s ease backwards;
  box-shadow: var(--shadow-card);
}

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

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

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ===== Stat Cards ===== */
.stat-card {
  background: var(--bg-card);
  border: 2px solid var(--accent-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
  animation: cardSlideUp 0.5s ease backwards;
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.1);
}

.stat-card.success {
  border-color: var(--info);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.1);
}

.stat-card.warning {
  border-color: var(--success);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.1);
}

.stat-card.danger {
  border-color: var(--warning);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.1);
}

.stat-card:nth-child(1) {
  animation-delay: 0.05s;
}

.stat-card:nth-child(2) {
  animation-delay: 0.1s;
}

.stat-card:nth-child(3) {
  animation-delay: 0.15s;
}

.stat-card:nth-child(4) {
  animation-delay: 0.2s;
}

.stat-card:hover {
  transform: translateY(-3px);
}

.stat-card:hover {
  box-shadow: 0 0 30px rgba(124, 58, 237, 0.2);
}

.stat-card.success:hover {
  box-shadow: 0 0 30px rgba(6, 182, 212, 0.2);
}

.stat-card.warning:hover {
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.2);
}

.stat-card.danger:hover {
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.2);
}

/* No top line - full border is used instead */
.stat-card::before {
  display: none;
}

.stat-card.success::before,
.stat-card.warning::before,
.stat-card.danger::before {
  display: none;
}

/* Colored dot indicator */
.stat-card::after {
  content: '';
  position: absolute;
  top: 18px;
  right: 18px;
  width: 24px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--accent-primary);
  z-index: 1;
}

.stat-card.success::after {
  background: var(--info);
}

.stat-card.warning::after {
  background: var(--success);
}

.stat-card.danger::after {
  background: var(--warning);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
  margin-top: var(--space-sm);
  margin-bottom: var(--space-2xs);
  position: relative;
  z-index: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
  white-space: nowrap;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  border: none;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover {
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-glass);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-accent);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-full);
}

/* ===== Form Elements ===== */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: all var(--transition-normal);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Input Row */
.input-row {
  display: flex;
  gap: var(--space-md);
}

.input-row .form-group {
  flex: 1;
}

@media (max-width: 768px) {
  .input-row {
    flex-direction: column;
  }
}

/* ===== Progress Bar ===== */
.progress-bar {
  height: 8px;
  background: var(--bg-glass);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.15) 50%, transparent 100%);
  animation: progressShine 2s ease-in-out infinite;
}

.progress-fill.warning {
  background: linear-gradient(90deg, var(--warning), #e67e22);
}

.progress-fill.danger {
  background: linear-gradient(90deg, var(--danger), #dc2626);
}

/* ===== Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-glass);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

/* ===== Expense List ===== */
.expense-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 520px;
  overflow-y: auto;
  padding-right: var(--space-xs);
}

.expense-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-md) var(--space-md) var(--space-lg);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-primary);
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
  cursor: default;
  gap: var(--space-md);
}

.expense-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-light);
  transform: translateX(4px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.expense-info {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex: 1;
  min-width: 0;
}

.expense-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.expense-details {
  min-width: 0;
  flex: 1;
}

.expense-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.expense-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.expense-amount {
  font-size: 1rem;
  font-weight: 700;
  color: var(--danger);
  margin-right: var(--space-xs);
  white-space: nowrap;
  text-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

/* Action buttons in expense items */
.expense-item .btn-sm {
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-normal);
}

.expense-item .btn-edit {
  color: var(--warning);
}

.expense-item .btn-edit:hover {
  background: var(--warning);
  color: white;
  border-color: var(--warning);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}

.expense-item .btn-danger {
  color: var(--danger);
}

.expense-item .btn-danger:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
}

/* ===== Search ===== */
.search-container {
  position: relative;
}

.search-container .form-input {
  padding-left: 16px;
  background: var(--bg-glass);
  border-color: var(--border-subtle);
}

.search-container .form-input:focus {
  background: var(--bg-primary);
}

/* ===== Month Navigation ===== */
.month-navigation {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

.month-display {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 140px;
  text-align: center;
}

/* ===== Chart ===== */
.chart-container {
  height: 280px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Category Breakdown ===== */
.category-breakdown {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.category-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-sm) 0;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.category-name {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.9rem;
  color: var(--text-primary);
  min-width: 0;
  overflow: hidden;
}

.category-name>span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-amount {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.category-value-group {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-shrink: 0;
  text-align: right;
  white-space: nowrap;
}

.category-pct {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.category-percentage {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: var(--space-xs);
}

.category-progress {
  height: 6px;
  background: var(--bg-glass);
  border-radius: var(--radius-full);
  overflow: hidden;
}

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

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: var(--space-xs);
  background: var(--bg-glass);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.tab {
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-normal);
  white-space: nowrap;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-glass-hover);
}

.tab.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
  padding: var(--space-md);
  overflow: hidden;
}

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

body.modal-open {
  overflow: hidden !important;
}

.modal-overlay {
  overscroll-behavior: contain;
}

/* ===== Spending Dynamics Chart (Premium) ===== */
.spending-dynamics {
  position: relative;
  background: linear-gradient(145deg, #0c1222 0%, #111b30 50%, #0f172a 100%);
  border: 1px solid rgba(99, 102, 241, 0.12);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), 0 0 60px rgba(99, 102, 241, 0.05);
}

.dynamics-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.25rem 1.5rem 0.75rem;
  position: relative;
  z-index: 2;
}

.dynamics-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  background: linear-gradient(135deg, #e2e8f0, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.01em;
}

.dynamics-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.dynamics-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  backdrop-filter: blur(4px);
}

.dynamics-badge.up {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.15);
}

.dynamics-badge.down {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.15);
}

.dynamics-badge.neutral {
  background: rgba(148, 163, 184, 0.1);
  color: #64748b;
}

.dynamics-period {
  font-size: 0.78rem;
  color: #475569;
  font-weight: 500;
}

.dynamics-stats {
  display: flex;
  gap: 1rem;
}

.dynamics-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 0.4rem 0.75rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: all 0.2s ease;
}

.dynamics-stat:hover {
  background: rgba(99, 102, 241, 0.06);
  border-color: rgba(99, 102, 241, 0.15);
}

.dynamics-stat-label {
  font-size: 0.65rem;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  white-space: nowrap;
}

.dynamics-stat-value {
  font-size: 1.05rem;
  font-weight: 800;
  color: #e2e8f0;
  letter-spacing: -0.02em;
}

.dynamics-max {
  color: #fb923c !important;
}

.dynamics-chart-wrapper {
  height: 200px;
  position: relative;
  margin: 0;
  padding: 0 0.5rem 0.5rem;
}

.dynamics-chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
  position: relative;
  z-index: 2;
}

.dynamics-glow {
  position: absolute;
  bottom: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 50%;
  background: radial-gradient(ellipse, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
  filter: blur(30px);
  pointer-events: none;
  z-index: 1;
  animation: glowPulse 4s ease-in-out infinite;
}

@keyframes glowPulse {

  0%,
  100% {
    opacity: 0.6;
  }

  50% {
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .dynamics-header {
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
  }

  .dynamics-stats {
    width: 100%;
    justify-content: space-between;
  }

  .dynamics-stat {
    align-items: center;
    flex: 1;
  }

  .dynamics-stat-value {
    font-size: 0.9rem;
  }

  .dynamics-chart-wrapper {
    height: 160px;
  }
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  width: 100%;
  max-width: 480px;
  transform: translateY(16px) scale(0.98);
  transition: transform var(--transition-spring);
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}

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

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 1rem;
}

.modal-close:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.modal-body {
  padding: var(--space-md) 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

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

/* ===== Expense Card (login-style) ===== */
.expense-card {
  background: linear-gradient(180deg, rgba(18, 22, 40, 0.95) 0%, rgba(6, 8, 16, 0.98) 100%) !important;
  border: 1px solid rgba(59, 130, 246, 0.12) !important;
  border-radius: 24px !important;
  padding: 40px 36px !important;
  max-width: 460px;
  position: relative;
  box-shadow:
    0 0 80px rgba(59, 130, 246, 0.07),
    0 0 2px rgba(100, 140, 255, 0.15),
    0 30px 60px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.expense-card-title {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
}

.expense-card-subtitle {
  text-align: center;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.expense-form .form-group {
  margin-bottom: 14px;
}

/* Select styled like login inputs */
.expense-select {
  padding: 0 24px 0 64px !important;
  background: linear-gradient(180deg, rgba(15, 18, 35, 0.8) 0%, rgba(8, 10, 22, 0.9) 100%) !important;
  border: 1px solid rgba(100, 140, 255, 0.15) !important;
  height: 60px !important;
  font-size: 0.95rem;
  border-radius: 999px !important;
  color: var(--text-primary);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.3),
    0 1px 0 rgba(255, 255, 255, 0.02);
  width: 100%;
}

.expense-select:focus {
  background: linear-gradient(180deg, rgba(18, 22, 40, 0.9) 0%, rgba(10, 12, 28, 0.95) 100%) !important;
  border-color: rgba(59, 130, 246, 0.45) !important;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.2),
    0 0 0 3px rgba(59, 130, 246, 0.1),
    0 0 20px rgba(59, 130, 246, 0.08) !important;
}

/* Close button */
.expense-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.4);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.expense-close-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

/* Category modal extras */
.category-section-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.category-list-section {
  margin-bottom: 8px;
}

.category-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.15), transparent);
  margin: 16px 0;
}

/* Color picker in pill */
.color-input-wrap {
  cursor: pointer;
  padding: 0 20px 0 64px !important;
  height: 60px;
  background: linear-gradient(180deg, rgba(15, 18, 35, 0.8) 0%, rgba(8, 10, 22, 0.9) 100%);
  border: 1px solid rgba(100, 140, 255, 0.15);
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.color-picker {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px;
  padding: 0 !important;
  border: 2px solid rgba(255, 255, 255, 0.15) !important;
  background: none !important;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50% !important;
  -webkit-appearance: none;
  appearance: none;
}

.color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-picker::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.color-label {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.95rem;
  flex: 1;
}

/* Export radio pills */
.export-radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.export-radio {
  cursor: pointer;
}

.export-radio input[type="radio"] {
  display: none;
}

.export-radio-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: linear-gradient(180deg, rgba(15, 18, 35, 0.8) 0%, rgba(8, 10, 22, 0.9) 100%);
  border: 1px solid rgba(100, 140, 255, 0.15);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.export-radio-pill:hover {
  border-color: rgba(59, 130, 246, 0.3);
  color: rgba(255, 255, 255, 0.7);
}

.export-radio-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  transition: all 0.3s ease;
  position: relative;
}

.export-radio input:checked+.export-radio-pill {
  border-color: rgba(59, 130, 246, 0.45);
  background: linear-gradient(180deg, rgba(18, 22, 40, 0.9) 0%, rgba(10, 12, 28, 0.95) 100%);
  color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.export-radio input:checked+.export-radio-pill .export-radio-dot {
  border-color: rgba(59, 130, 246, 0.8);
  background: rgba(59, 130, 246, 0.8);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

/* Export date fields */
.export-dates {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.export-date-field .category-section-label {
  margin-bottom: 6px;
  font-size: 0.75rem;
}

/* Budget adjust pills */
.budget-adjust-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.budget-pill {
  flex: 1;
  padding: 10px 4px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid;
}

.budget-pill-minus {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.budget-pill-minus:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
  transform: translateY(-1px);
}

.budget-pill-plus {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}

.budget-pill-plus:hover {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
  transform: translateY(-1px);
}

.budget-pill:active {
  transform: translateY(1px);
}

/* Floating Telegram button */
/* ===== FAB Add Expense Button ===== */
.fab-add-expense {
  position: fixed;
  bottom: 24px;
  right: 90px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0 1.25rem;
  height: 52px;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff;
  border: none;
  border-radius: 26px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  z-index: 99;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4), 0 0 40px rgba(99, 102, 241, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: fabFloat 3s ease-in-out infinite;
}

.fab-add-expense:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.5), 0 0 50px rgba(99, 102, 241, 0.15);
  animation: none;
}

.fab-add-expense:active {
  transform: translateY(0) scale(0.97);
}

.fab-icon {
  font-size: 1.4rem;
  font-weight: 300;
  line-height: 1;
}

.fab-text {
  font-size: 0.85rem;
  font-weight: 600;
}

@keyframes fabFloat {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

.tg-float-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0088cc, #0099e6);
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(0, 136, 204, 0.4), 0 0 0 0 rgba(0, 136, 204, 0.3);
  z-index: 99;
  transition: all 0.3s ease;
  animation: tgPulse 2s ease-in-out infinite;
  text-decoration: none;
}

.tg-float-btn:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 136, 204, 0.5);
  animation: none;
}

.tg-float-btn:active {
  transform: scale(0.95);
}

@keyframes tgPulse {

  0%,
  100% {
    box-shadow: 0 4px 16px rgba(0, 136, 204, 0.4), 0 0 0 0 rgba(0, 136, 204, 0.3);
  }

  50% {
    box-shadow: 0 4px 16px rgba(0, 136, 204, 0.4), 0 0 0 8px rgba(0, 136, 204, 0);
  }
}

/* User token badge */
.user-token-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 12px;
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: 999px;
  width: fit-content;
}

.token-icon {
  font-size: 0.75rem;
}

.token-label {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
  font-weight: 500;
}

.token-value {
  font-size: 0.8rem;
  font-weight: 700;
  color: #3b82f6;
  letter-spacing: 0.08em;
  background: none;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.token-copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px;
  transition: transform 0.2s;
}

.token-copy-btn:hover {
  transform: scale(1.2);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
}

.empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: var(--space-md);
  opacity: 0.4;
  filter: grayscale(0.3);
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.empty-state-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 280px;
  line-height: 1.5;
}

/* ===== Loading Screen ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: #050810;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
  overflow: hidden;
}

.loading-overlay.active {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

.loading-overlay.fade-out {
  opacity: 0;
}

/* Floating orbs matching login */
.loading-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
}

.loading-orb-1 {
  width: 400px;
  height: 400px;
  background: rgba(30, 64, 175, 0.12);
  top: -100px;
  left: 30%;
  animation: orbFloat 8s ease-in-out infinite;
}

.loading-orb-2 {
  width: 300px;
  height: 300px;
  background: rgba(59, 130, 246, 0.08);
  bottom: -80px;
  right: 20%;
  animation: orbFloat 10s ease-in-out infinite reverse;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}

/* Spinner with rings */
.loading-spinner {
  position: relative;
  width: 100px;
  height: 100px;
  margin-bottom: 32px;
}

.loading-ring {
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-top: 2px solid rgba(59, 130, 246, 0.6);
  border-right: 2px solid rgba(59, 130, 246, 0.2);
  border-radius: 50%;
  animation: loadingSpin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.loading-ring-2 {
  inset: 10px;
  border-top-color: rgba(124, 58, 237, 0.5);
  border-right-color: rgba(124, 58, 237, 0.15);
  animation-duration: 0.9s;
  animation-direction: reverse;
}

.loading-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  animation: loadingPulse 2s ease-in-out infinite;
}

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

@keyframes loadingPulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 0.8;
  }

  50% {
    transform: scale(1.1);
    opacity: 1;
  }
}

.loading-text {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

/* Animated dots */
.loading-dots {
  display: flex;
  gap: 6px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.5);
  animation: loadingDot 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes loadingDot {

  0%,
  80%,
  100% {
    transform: scale(0.4);
    opacity: 0.3;
  }

  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===== Login Screen ===== */
#loginModal {
  background: #050810;
  backdrop-filter: none;
}

#loginModal.active {
  background: #050810;
  backdrop-filter: none;
}

/* Full-screen login container */
.login-screen {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  pointer-events: none;
  animation: orbFloat 8s ease-in-out infinite;
}

.login-orb-1 {
  width: 500px;
  height: 500px;
  background: rgba(30, 64, 175, 0.12);
  top: -150px;
  left: 50%;
  margin-left: -250px;
}

.login-orb-2 {
  width: 400px;
  height: 400px;
  background: rgba(6, 95, 212, 0.08);
  bottom: -100px;
  right: -100px;
  animation-delay: -3s;
  animation-duration: 10s;
}

.login-orb-3 {
  width: 300px;
  height: 300px;
  background: rgba(59, 130, 246, 0.06);
  top: 50%;
  left: -80px;
  animation-delay: -5s;
  animation-duration: 12s;
}


@keyframes orbFloat {

  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }

  25% {
    transform: translate(30px, -40px) scale(1.05);
  }

  50% {
    transform: translate(-20px, 20px) scale(0.95);
  }

  75% {
    transform: translate(40px, 30px) scale(1.02);
  }
}

/* Login card — blue glow border + 3D */
.login-card {
  position: relative;
  width: 100%;
  max-width: 500px;
  background: linear-gradient(180deg, rgba(18, 22, 40, 0.95) 0%, rgba(6, 8, 16, 0.98) 100%);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(59, 130, 246, 0.12);
  border-radius: 24px;
  padding: 60px 48px;
  z-index: 2;
  animation: cardFloat 6s ease-in-out infinite;
  box-shadow:
    0 0 80px rgba(59, 130, 246, 0.07),
    0 0 2px rgba(100, 140, 255, 0.15),
    0 30px 60px rgba(0, 0, 0, 0.4),
    0 60px 120px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.login-card * {
  pointer-events: auto;
}

.login-form {
  position: relative;
  z-index: 100;
}

/* No shine overlay */
.login-card::before {
  display: none;
}

@keyframes cardFloat {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-12px);
  }
}

@keyframes cardShine {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

.login-card:hover {
  animation-play-state: paused;
  transform: translateY(-8px) scale(1.01);
  box-shadow:
    0 0 100px rgba(59, 130, 246, 0.1),
    0 0 3px rgba(100, 140, 255, 0.2),
    0 40px 80px rgba(0, 0, 0, 0.4),
    0 80px 140px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.login-accent {
  display: none;
}

.login-logo {
  display: none;
}

.login-logo-img {
  display: none;
}

.login-title {
  text-align: center;
  font-size: 2.5rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 12px;
  letter-spacing: -0.03em;
}

.login-subtitle {
  text-align: center;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.95rem;
  margin-bottom: 48px;
  line-height: 1.6;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

/* Login tabs */
.login-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 28px;
}

.login-tab {
  flex: 1;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
}

.login-tab:hover {
  color: rgba(255, 255, 255, 0.6);
}

.login-tab.active {
  background: rgba(59, 130, 246, 0.15);
  color: rgba(59, 130, 246, 0.9);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.1);
}

/* Register fields transition */
.register-field {
  animation: fieldSlide 0.3s ease;
}

@keyframes fieldSlide {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Login form */
.login-form .form-group {
  margin-bottom: 16px;
  position: relative;
  z-index: 5;
}

.login-form .form-label {
  display: none;
}

.login-input-wrap {
  position: relative;
  z-index: 5;
}

.login-input-icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  z-index: 1;
  pointer-events: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.login-input-wrap .form-input {
  padding: 0 24px 0 64px;
  background: linear-gradient(180deg, rgba(15, 18, 35, 0.8) 0%, rgba(8, 10, 22, 0.9) 100%);
  border: 1px solid rgba(100, 140, 255, 0.15);
  height: 60px;
  font-size: 0.95rem;
  border-radius: 999px;
  transition: all 0.3s ease;
  color: var(--text-primary);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.3),
    0 1px 0 rgba(255, 255, 255, 0.02);
}

.login-input-wrap .form-input::placeholder {
  color: rgba(255, 255, 255, 0.22);
  font-weight: 400;
  letter-spacing: 0.01em;
}

.login-input-wrap .form-input:focus {
  background: linear-gradient(180deg, rgba(18, 22, 40, 0.9) 0%, rgba(10, 12, 28, 0.95) 100%);
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.2),
    0 0 0 3px rgba(59, 130, 246, 0.1),
    0 0 20px rgba(59, 130, 246, 0.08);
}

.login-input-wrap .form-input:focus+.login-input-icon,
.login-input-wrap:focus-within .login-input-icon {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.2);
}

/* 3D bevel button */
.login-btn {
  width: 100%;
  height: 56px;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: linear-gradient(180deg, rgba(65, 70, 85, 0.95) 0%, rgba(30, 33, 45, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
  margin-top: 28px;
}

.login-btn:hover {
  background: linear-gradient(180deg, rgba(80, 85, 100, 0.98) 0%, rgba(40, 43, 58, 1) 100%);
  transform: translateY(-2px);
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.5),
    0 4px 8px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.login-btn:active {
  transform: translateY(1px);
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Footer */
.login-footer {
  text-align: center;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

@media (max-width: 540px) {
  .login-card {
    margin: 16px;
    padding: 40px 24px;
    border-radius: 20px;
  }

  .login-title {
    font-size: 2rem;
  }

  .login-subtitle {
    margin-bottom: 32px;
  }
}

/* ===== Checkbox ===== */
.checkbox-container {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.checkbox-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.checkmark {
  width: 18px;
  height: 18px;
  background: var(--bg-primary);
  border: 2px solid var(--border-light);
  border-radius: 5px;
  transition: all var(--transition-fast);
}

.checkbox-container:hover .checkmark {
  border-color: var(--accent-primary);
}

.checkbox-container input:checked~.checkmark {
  background: var(--accent-gradient);
  border-color: var(--accent-primary);
}

.checkmark::after {
  content: '✓';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  color: white;
  font-size: 11px;
  font-weight: bold;
  transition: transform var(--transition-fast);
}

.checkbox-container input:checked~.checkmark::after {
  transform: translate(-50%, -50%) scale(1);
}

/* ===== Selection Controls ===== */
.selection-controls {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  animation: cardFadeIn 0.2s ease;
}

.selection-controls span {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ===== Expense Item Selected ===== */
.expense-item.selected {
  background: rgba(124, 58, 237, 0.1);
  border-color: var(--accent-primary);
}

/* ===== Filter Section ===== */
.filter-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.date-range-filter {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  flex-wrap: wrap;
}

.date-range-filter .form-input {
  width: auto;
  min-width: 130px;
  padding: 8px 12px;
}

.date-range-filter span {
  color: var(--text-muted);
}

/* ===== Tags ===== */
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2xs);
  margin-top: var(--space-2xs);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--accent-glow);
  color: var(--accent-secondary);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 500;
}

.tag::before {
  content: '#';
  opacity: 0.6;
}

/* ===== Budget Adjust Buttons ===== */
.budget-adjust-buttons {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.budget-adjust-buttons .btn {
  flex: 1;
  min-width: 70px;
}

/* ===== Radio Group ===== */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.radio-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  border: 1px solid transparent;
}

.radio-label:hover {
  background: var(--bg-glass);
  border-color: var(--border-subtle);
}

.radio-label input[type="radio"] {
  accent-color: var(--accent-primary);
  width: 16px;
  height: 16px;
}

/* ===== Date Range Inputs ===== */
.date-range-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

/* ===== Edit Button ===== */
.btn-edit {
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.btn-edit:hover {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

/* ===== Custom Categories List ===== */
.custom-categories-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.custom-category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-glass);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

/* ===== Small Text ===== */
small.text-muted {
  display: block;
  margin-top: var(--space-xs);
  font-size: 0.75rem;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ===== Animations ===== */
@keyframes cardFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes progressShine {
  0% {
    transform: translateX(-100%);
  }

  100% {
    transform: translateX(200%);
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-16px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

.animate-fade-in {
  animation: cardFadeIn var(--transition-normal) ease forwards;
}

.animate-slide-in {
  animation: slideIn var(--transition-normal) ease forwards;
}

/* ===== Loading ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  z-index: 9999;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--bg-glass);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-overlay p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.error-message {
  text-align: center;
  color: var(--danger);
}

.error-message p:first-child {
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
}

/* ===== Utilities ===== */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-success {
  color: var(--success);
}

.text-warning {
  color: var(--warning);
}

.text-danger {
  color: var(--danger);
}

.text-muted {
  color: var(--text-muted);
}

.mt-sm {
  margin-top: var(--space-sm);
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mb-sm {
  margin-bottom: var(--space-sm);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

.flex {
  display: flex;
}

.flex-wrap {
  flex-wrap: wrap;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-sm {
  gap: var(--space-sm);
}

.gap-md {
  gap: var(--space-md);
}

.hidden {
  display: none !important;
}

/* ===== Bottom Navigation (Mobile) ===== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  left: 16px;
  right: 16px;
  background: rgba(11, 15, 30, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.bottom-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.bottom-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.35);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px 16px;
  border-radius: 12px;
  transition: all 0.25s ease;
  position: relative;
}

.bottom-nav-btn span {
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.bottom-nav-btn.active {
  color: var(--accent-secondary);
}

.bottom-nav-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: var(--accent-secondary);
  border-radius: 50%;
}

.bottom-nav-btn:active {
  transform: scale(0.92);
}

/* ===== Responsive: Tablet ===== */
@media (max-width: 1200px) {
  .main-content {
    padding: var(--space-lg) var(--space-lg) var(--space-lg) calc(var(--sidebar-width) + var(--space-lg));
  }
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 768px) {

  /* GLOBAL: prevent ANY horizontal overflow on mobile */
  html,
  body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    width: 100% !important;
  }

  .app-layout {
    max-width: 100vw;
    overflow-x: hidden;
    width: 100%;
  }

  /* Hide sidebar, show bottom nav */
  .sidebar {
    display: none;
  }

  .bottom-nav {
    display: block;
  }

  .tg-float-btn {
    bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    width: 48px;
    height: 48px;
  }

  .fab-add-expense {
    bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    right: 72px;
    height: 46px;
    padding: 0 1rem;
  }

  .tg-float-btn svg {
    width: 24px;
    height: 24px;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    padding: 16px 16px 90px 16px !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  .container {
    max-width: 100% !important;
    width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  /* Header — clean, centered */
  .header {
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding-bottom: 16px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  }

  .header-title {
    justify-content: center;
    gap: 8px;
  }

  .header-title p {
    display: none;
  }

  .header-title h1 {
    font-size: 1.35rem;
  }

  .header-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: nowrap;
    width: 100%;
  }

  .header-actions .btn span {
    display: none;
  }

  .header-actions .btn {
    padding: 10px 12px;
    min-width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
  }

  .header-actions .btn-primary {
    background: var(--accent-gradient);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 12px;
    flex: 1;
    max-width: 200px;
  }

  .header-actions .btn-primary span {
    display: inline;
    font-size: 0.8rem;
  }

  .header-actions .btn-danger {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    color: var(--danger);
  }

  /* Welcome */
  .welcome-section {
    flex-direction: column;
    align-items: flex-start;
  }

  .welcome-actions {
    width: 100%;
  }

  .welcome-actions .btn {
    flex: 1;
  }

  /* Stat Cards */
  .grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }

  .stat-card {
    padding: 14px 16px;
    border-radius: 14px;
    border-width: 1.5px;
  }

  .stat-value {
    font-size: 1.25rem;
    margin-top: 2px;
  }

  .stat-label {
    font-size: 0.7rem;
    letter-spacing: 0.03em;
  }

  .stat-indicator {
    top: 10px;
    right: 10px;
    padding: 2px 8px;
    font-size: 0.6rem;
  }

  /* Cards */
  .card {
    padding: 16px;
    border-radius: 16px;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
  }

  .card-title {
    font-size: 0.9rem;
  }

  .card-header {
    margin-bottom: 12px;
  }

  /* Category Breakdown — card-style items */
  .category-breakdown {
    gap: 6px;
  }

  .category-item {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.04);
  }

  .category-name {
    font-size: 0.85rem;
  }

  .category-amount {
    font-size: 0.85rem;
  }

  /* Hide percentage on mobile to prevent overflow */
  .category-pct {
    display: none;
  }

  .category-progress {
    height: 4px;
    border-radius: 4px;
  }

  /* Chart */
  .chart-container {
    height: 240px;
    margin: 0 auto;
    max-width: 280px;
  }

  /* Expense List */
  .expense-list {
    max-height: 400px;
  }

  .expense-item {
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.03);
  }

  .expense-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
    border-radius: 10px;
  }

  .expense-title {
    font-size: 0.85rem;
    max-width: 140px;
  }

  .expense-amount {
    font-size: 0.9rem;
  }

  /* Tabs */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-radius: 12px;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    padding: 10px 14px;
    font-size: 0.78rem;
    border-radius: 8px;
  }

  /* Modal */
  .modal {
    width: 95%;
    padding: var(--space-lg);
    border-radius: 20px;
  }

  /* Form elements */
  .form-input,
  .form-select {
    padding: 12px 14px;
    font-size: 16px;
    border-radius: 12px;
  }

  /* Month nav */
  .month-navigation {
    width: 100%;
    justify-content: space-between;
  }

  .month-navigation .btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    border-radius: 10px;
  }

  /* Progress */
  .progress-bar {
    height: 6px;
    border-radius: 6px;
  }

  /* Date filter */
  .date-range-filter {
    flex-direction: column;
    align-items: stretch;
  }

  .date-range-filter .form-input {
    width: 100%;
  }

  /* Selection */
  .selection-controls {
    width: 100%;
    justify-content: space-between;
  }

  /* Logo */
  .logo-img,
  .logo {
    width: 36px;
    height: 36px;
  }

  /* Two-column to single column */
  .content-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
}

/* ===== Telegram WebApp Mode ===== */
body.telegram-webapp,
body.telegram-webapp * {
  box-sizing: border-box;
}

/* Uses official Telegram CSS variables + JS-set --tg-app-width */

body.telegram-webapp {
  overflow-x: hidden !important;
  max-width: var(--tg-app-width, 100%);
  padding-top: var(--tg-content-safe-area-inset-top, 0px);
  padding-left: var(--tg-safe-area-inset-left, 0px);
  padding-right: var(--tg-safe-area-inset-right, 0px);
  padding-bottom: var(--tg-safe-area-inset-bottom, 0px);
}

body.telegram-webapp::before {
  display: none;
}

body.telegram-webapp .app-layout {
  max-width: 100%;
  overflow-x: hidden;
}

body.telegram-webapp .main-content {
  padding: 8px 12px 90px 8px !important;
  margin-left: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
}

body.telegram-webapp .header-actions .btn-danger {
  display: none;
}

body.telegram-webapp .login-screen {
  display: none;
}

body.telegram-webapp .card {
  padding: 12px;
  box-sizing: border-box;
}

body.telegram-webapp .stat-card {
  padding: 10px 12px;
}

body.telegram-webapp .stat-value {
  font-size: 1.15rem;
}

body.telegram-webapp .category-header {
  gap: 8px;
}

body.telegram-webapp .category-amount {
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===== Responsive: Small phones ===== */
@media (max-width: 380px) {
  .grid-4 {
    grid-template-columns: 1fr !important;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .header-actions {
    flex-wrap: wrap;
    justify-content: center;
  }
}