:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #8b5cf6;
  --secondary: #06b6d4;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.85);

  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --text-inverse: #ffffff;

  --border-color: #e2e8f0;
  --border-light: #f1f5f9;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 20px;
  --radius-xl: 24px;

  --font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);

  --backdrop-blur: blur(20px);

  /* Added mobile-specific spacing variables */
  --mobile-padding: 1rem;
  --mobile-gap: 0.75rem;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* Enhanced dark theme with better contrast and modern colors */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-card: #1e293b;
  --bg-glass: rgba(30, 41, 59, 0.85);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-tertiary: #94a3b8;

  --border-color: #334155;
  --border-light: #475569;

  --primary: #8b5cf6;
  --primary-dark: #7c3aed;
}

/* Enhanced reset and base styles for better mobile support */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  height: 100%;
  position: relative;
}

/* Enhanced app container with better mobile optimization */
.app-container {
  min-height: 100vh;
  max-width: 430px;
  margin: 0 auto;
  position: relative;
  background-color: var(--bg-primary);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Better responsive breakpoints for all devices */
@media (min-width: 768px) {
  .app-container {
    margin: 1rem auto;
    border-radius: var(--radius-xl);
    height: calc(100vh - 2rem);
    max-height: 900px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border-color);
  }
}

@media (min-width: 1024px) {
  .app-container {
    margin: 2rem auto;
    height: calc(100vh - 4rem);
    max-width: 480px;
  }
}

@media (min-width: 1440px) {
  .app-container {
    max-width: 520px;
  }
}

/* Enhanced tablet landscape support */
@media (min-width: 1024px) and (orientation: landscape) {
  .app-container {
    max-width: 600px;
    height: calc(100vh - 2rem);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
}

/* Enhanced PIN screen with glassmorphism effect */
.pin-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--mobile-padding);
}

.pin-container {
  width: 100%;
  max-width: 320px;
  text-align: center;
  background: var(--bg-glass);
  backdrop-filter: var(--backdrop-blur);
  border-radius: var(--radius-xl);
  padding: 2rem var(--mobile-padding);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.pin-header {
  margin-bottom: 3rem;
}

.app-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

/* Updated logo with financial SVG icon */
.logo-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-lg);
}

.logo-icon svg {
  width: 32px;
  height: 32px;
}

.app-logo h1 {
  font-size: 2rem;
  font-weight: 800;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pin-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.pin-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: var(--transition);
}

.pin-dot.active {
  background-color: white;
  border-color: white;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.pin-error {
  color: var(--danger);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  min-height: 1.25rem;
  background: rgba(239, 68, 68, 0.1);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  backdrop-filter: var(--backdrop-blur);
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  max-width: 240px;
  margin: 0 auto;
}

/* Enhanced PIN keys with better touch feedback */
.pin-key {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: var(--backdrop-blur);
  color: white;
  font-size: 1.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  touch-action: manipulation;
}

.pin-key:hover,
.pin-key:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
  box-shadow: var(--shadow-lg);
}

.pin-key.empty {
  background: none;
  cursor: default;
  border: none;
}

.pin-key.empty:hover {
  background: none;
  transform: none;
}

/* Enhanced main app layout for better mobile support */
.main-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  flex: 1;
}

/* Main Content */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(100px + var(--safe-area-bottom));
  background: var(--bg-primary);
  -webkit-overflow-scrolling: touch;
}

/* Enhanced page transitions with smooth animations */
.page {
  display: none;
  animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.page.active {
  display: block;
}

/* Enhanced page content with better mobile padding */
.page-content {
  padding: var(--mobile-padding);
  max-width: 100%;
  overflow-x: hidden;
}

@media (min-width: 640px) {
  .page-content {
    padding: 1.5rem;
  }
}

@media (min-width: 768px) {
  .page-content {
    padding: 2rem;
  }
}

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

/* Enhanced balance card with modern gradient and glassmorphism */
.balance-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-xl);
  padding: 2rem var(--mobile-padding);
  color: white;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-xl);
  position: relative;
  overflow: hidden;
}

.balance-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  pointer-events: none;
}

.balance-header {
  text-align: center;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 1;
}

.balance-label {
  font-size: 0.875rem;
  opacity: 0.9;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

/* Enhanced balance amount with better mobile typography */
.balance-amount {
  font-size: clamp(2rem, 5vw, 2.5rem);
  font-weight: 800;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  word-break: break-all;
}

.balance-details {
  display: flex;
  justify-content: space-between;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  z-index: 1;
  gap: var(--mobile-gap);
}

.balance-item {
  text-align: center;
  flex: 1;
  min-width: 0;
}

.balance-item-label {
  font-size: 0.75rem;
  opacity: 0.8;
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.balance-item-value {
  font-size: clamp(0.875rem, 3vw, 1rem);
  font-weight: 700;
  word-break: break-all;
}

/* Enhanced stats grid with better mobile layout */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--mobile-gap);
  margin-bottom: 2rem;
}

@media (min-width: 640px) {
  .stats-grid {
    gap: 1rem;
  }
}

.stat-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  transition: var(--transition);
  cursor: pointer;
  min-width: 0;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

/* Enhanced stat icons with financial SVG icons */
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 20px;
  height: 20px;
}

.stat-card.income .stat-icon {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
  color: var(--success);
}

.stat-card.expense .stat-icon {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
  color: var(--danger);
}

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.stat-value {
  font-size: clamp(1rem, 3vw, 1.125rem);
  font-weight: 700;
  color: var(--text-primary);
  word-break: break-all;
}

/* Enhanced budget section with better progress visualization */
.budget-section {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem var(--mobile-padding);
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.budget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: var(--mobile-gap);
}

.budget-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 0;
}

.budget-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: right;
  word-break: break-all;
}

.budget-progress {
  width: 100%;
  height: 12px;
  background-color: var(--bg-tertiary);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.5rem;
  position: relative;
}

.budget-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 6px;
  transition: var(--transition-slow);
  width: 0%;
  position: relative;
}

.budget-progress-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

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

.budget-progress-bar.warning {
  background: linear-gradient(90deg, var(--warning), #fbbf24);
}

.budget-progress-bar.danger {
  background: linear-gradient(90deg, var(--danger), #f87171);
}

.budget-warning {
  font-size: 0.75rem;
  text-align: center;
  color: var(--text-secondary);
  min-height: 1rem;
  font-weight: 500;
}

/* Transactions Section */
.transactions-section {
  margin-bottom: 2rem;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.transactions-list {
  display: flex;
  flex-direction: column;
  gap: var(--mobile-gap);
}

/* Enhanced transaction items with better mobile layout */
.transaction-item {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1rem var(--mobile-padding);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.transaction-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary);
  transform: scaleY(0);
  transition: var(--transition);
}

.transaction-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.transaction-item:hover::before {
  transform: scaleY(1);
}

.transaction-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.transaction-icon svg {
  width: 18px;
  height: 18px;
}

.transaction-icon.income {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05));
  color: var(--success);
}

.transaction-icon.expense {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.05));
  color: var(--danger);
}

.transaction-content {
  flex: 1;
  min-width: 0;
}

.transaction-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.transaction-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.transaction-amount {
  font-weight: 700;
  font-size: clamp(0.875rem, 3vw, 1rem);
  flex-shrink: 0;
  text-align: right;
}

.transaction-amount.income {
  color: var(--success);
}

.transaction-amount.expense {
  color: var(--danger);
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
  gap: var(--mobile-gap);
}

.page-title {
  font-size: clamp(1.5rem, 4vw, 1.75rem);
  font-weight: 800;
  color: var(--text-primary);
  min-width: 0;
}

.page-stats {
  text-align: right;
  flex-shrink: 0;
}

.page-stat-value {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  font-weight: 800;
  color: var(--text-primary);
  display: block;
  word-break: break-all;
}

.page-stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Enhanced tabs with modern design */
.tabs {
  display: flex;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-lg);
  padding: 0.25rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.tab-button {
  flex: 1;
  padding: 0.75rem 0.5rem;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.8rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-button.active {
  background-color: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* Debts List */
.debts-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Enhanced debt items with better visual design */
.debt-item {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem var(--mobile-padding);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  transition: var(--transition);
  cursor: pointer;
}

.debt-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

.debt-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: var(--mobile-gap);
}

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

.debt-info h4 {
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debt-info p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.debt-amount {
  font-size: clamp(1.125rem, 3vw, 1.25rem);
  font-weight: 800;
  text-align: right;
  flex-shrink: 0;
}

.debt-amount.owe {
  color: var(--danger);
}

.debt-amount.owed {
  color: var(--success);
}

.debt-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.debt-action-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.debt-action-btn.settle {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  box-shadow: var(--shadow-sm);
}

.debt-action-btn.settle:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Enhanced settings with modern card design */
.settings-sections {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.settings-section {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem var(--mobile-padding);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.settings-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

/* Profile Card */
.profile-card {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.profile-avatar-container {
  position: relative;
  flex-shrink: 0;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: var(--shadow-md);
}

.avatar-upload-btn {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.avatar-upload-btn:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-md);
}

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

.profile-name-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 500;
  transition: var(--transition);
}

.profile-name-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.save-profile-btn {
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.save-profile-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Settings Items */
.settings-items {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  gap: var(--mobile-gap);
}

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

.settings-item-label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.settings-item-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-weight: 500;
}

/* Enhanced toggle switch with modern design */
.toggle {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-tertiary);
  transition: var(--transition);
  border-radius: 28px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: var(--transition);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-slider {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

.toggle input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

/* Settings Select */
.settings-select {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.875rem;
  min-width: 120px;
  font-weight: 500;
  transition: var(--transition);
  flex-shrink: 0;
}

.settings-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Settings Input */
.settings-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  font-weight: 500;
  transition: var(--transition);
}

.settings-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Auto Income Settings */
.auto-income-settings {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* Added KPI section styles */
.kpi-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.add-kpi-btn {
  width: 100%;
  padding: 0.75rem;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.add-kpi-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.kpi-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.kpi-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 1rem;
  border: 1px solid var(--border-color);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  gap: var(--mobile-gap);
}

.kpi-amount {
  font-weight: 700;
  color: var(--primary);
  font-size: 1rem;
  word-break: break-all;
}

.kpi-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.kpi-delete {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  flex-shrink: 0;
}

.kpi-delete:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Settings Actions */
.settings-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.settings-action-btn {
  flex: 1;
  min-width: 140px;
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.settings-action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
  transform: translateY(-1px);
}

.settings-action-btn.export:hover {
  border-color: var(--success);
  color: var(--success);
  background: rgba(16, 185, 129, 0.05);
}

.settings-action-btn.import:hover {
  border-color: var(--info);
  color: var(--info);
  background: rgba(59, 130, 246, 0.05);
}

/* Enhanced bottom navigation with financial SVG icons and better mobile support */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: var(--bg-glass);
  backdrop-filter: var(--backdrop-blur);
  border-top: 1px solid var(--border-color);
  padding: 0.75rem 0 calc(0.75rem + var(--safe-area-bottom)) 0;
  display: flex;
  justify-content: space-around;
  z-index: 200;
  box-shadow: var(--shadow-xl);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.5rem 0.25rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  min-width: 60px;
  position: relative;
  transform: scale(1);
  touch-action: manipulation;
}

.nav-item::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 24px;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 0 0 3px 3px;
  transition: var(--transition);
}

.nav-item.active {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
  transform: scale(1.05);
}

.nav-item.active::before {
  transform: translateX(-50%) scaleX(1);
}

.nav-item:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-secondary);
  transform: scale(1.02);
}

.nav-item span {
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
}

.nav-item svg {
  width: 20px;
  height: 20px;
  transition: var(--transition);
}

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

.input-with-button {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.settings-input {
  width: 100%;
  padding-right: 40px; /* Tugma uchun joy ochish */
}

.input-button {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 4px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.input-button:hover {
  background: var(--primary-dark);
}

.input-button i {
  width: 20px;
  height: 20px;
}

/* Enhanced floating action button with financial icon */
.fab {
  position: fixed;
  bottom: calc(100px + var(--safe-area-bottom));
  right: 1rem;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  box-shadow: var(--shadow-xl);
  transition: var(--transition);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.fab svg {
  width: 24px;
  height: 24px;
}

.fab:hover {
  transform: scale(1.1);
  box-shadow: 0 20px 40px rgba(99, 102, 241, 0.4);
}

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

/* Enhanced modals with glassmorphism */
.modals-container {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: var(--backdrop-blur);
  pointer-events: all;
  animation: fadeIn 0.3s ease-out;
}

/* Enhanced modal with better mobile support */
.modal {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-glass);
  backdrop-filter: var(--backdrop-blur);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-height: 90vh;
  overflow-y: auto;
  pointer-events: all;
  animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-color);
  -webkit-overflow-scrolling: touch;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem var(--mobile-padding);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 10;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  touch-action: manipulation;
}

.modal-close:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.modal-content {
  padding: 1.5rem var(--mobile-padding);
  background: var(--bg-card);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.form-input,
.form-select,
.form-textarea {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
  transition: var(--transition);
  font-weight: 500;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* Enhanced buttons with modern design */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  touch-action: manipulation;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  flex: 1;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
  background-color: var(--bg-tertiary);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #f87171);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Enhanced toast notifications */
.toast-container {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  pointer-events: none;
  max-width: calc(100vw - 2rem);
}

.toast {
  background: var(--bg-glass);
  backdrop-filter: var(--backdrop-blur);
  color: var(--text-primary);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
  animation: slideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: all;
  max-width: 320px;
  font-weight: 500;
  word-wrap: break-word;
}

.toast.success {
  border-left: 4px solid var(--success);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), var(--bg-glass));
}

.toast.error {
  border-left: 4px solid var(--danger);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), var(--bg-glass));
}

.toast.warning {
  border-left: 4px solid var(--warning);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), var(--bg-glass));
}

.toast.info {
  border-left: 4px solid var(--info);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), var(--bg-glass));
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Empty States */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  opacity: 0.5;
  color: var(--text-tertiary);
}

.empty-state-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.empty-state-description {
  font-size: 0.875rem;
  line-height: 1.6;
  font-weight: 500;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Enhanced responsive design for all screen sizes with better mobile optimization */
@media (min-width: 640px) {
  :root {
    --mobile-padding: 1.5rem;
    --mobile-gap: 1rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .page-content {
    padding: 2rem;
  }
}

@media (min-width: 768px) {
  .modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    bottom: auto;
    right: auto;
    width: 90%;
    max-width: 500px;
    border-radius: var(--radius-xl);
    animation: scaleIn 0.3s ease-out;
  }

  @keyframes scaleIn {
    from {
      transform: translate(-50%, -50%) scale(0.9);
      opacity: 0;
    }
    to {
      transform: translate(-50%, -50%) scale(1);
      opacity: 1;
    }
  }

  .fab {
    bottom: 2rem;
    right: 2rem;
  }

  .bottom-nav {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-width: 480px;
  }
}

.sync-status {
  color: var(--text-secondary);
  margin-top: 10px;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--text-secondary);
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 5px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@media (min-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }

  .page-content {
    padding: 2.5rem;
  }

  .bottom-nav {
    max-width: 520px;
  }
}

/* Print Styles */
@media print {
  .bottom-nav,
  .fab,
  .pin-screen {
    display: none !important;
  }

  .main-content {
    padding-bottom: 0;
  }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --border-color: #000000;
    --text-secondary: #000000;
  }

  [data-theme="dark"] {
    --border-color: #ffffff;
    --text-secondary: #ffffff;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Enhanced custom scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Focus styles for accessibility */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Enhanced touch and mobile interaction styles */
@media (hover: none) and (pointer: coarse) {
  .transaction-item:hover,
  .stat-card:hover,
  .debt-item:hover {
    transform: none;
    box-shadow: var(--shadow-md);
  }

  .nav-item:hover:not(.active) {
    transform: none;
    background: none;
  }

  .fab:hover {
    transform: none;
    box-shadow: var(--shadow-xl);
  }
}

/* Better safe area handling for modern mobile devices */
@supports (padding: max(0px)) {
  .bottom-nav {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }

  .fab {
    bottom: max(100px, calc(100px + env(safe-area-inset-bottom)));
  }

  .main-content {
    padding-bottom: max(100px, calc(100px + env(safe-area-inset-bottom)));
  }
}
