:root {
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --bg-dark: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-card-hover: rgba(51, 65, 85, 0.9);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.25);
  
  --income: #10b981;
  --income-bg: rgba(16, 185, 129, 0.12);
  --income-border: rgba(16, 185, 129, 0.3);
  
  --expense: #ef4444;
  --expense-bg: rgba(239, 68, 68, 0.12);
  --expense-border: rgba(239, 68, 68, 0.3);
  
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --radius: 14px;
  --radius-sm: 8px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.12) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: all 0.2s ease;
}

a:hover {
  color: #60a5fa;
}

/* Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-color);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  padding-bottom: 24px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.svg-icon {
  flex-shrink: 0;
  transition: transform 0.2s ease, stroke 0.2s ease;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.92rem;
  transition: all 0.2s ease;
}

.nav-link .svg-icon {
  stroke: var(--text-muted);
}

.nav-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-link:hover .svg-icon {
  stroke: #ffffff;
}

.nav-link.active {
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.nav-link.active .svg-icon {
  stroke: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.user-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
}

.user-email {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #f87171;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.1);
  transition: all 0.2s;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.main-content {
  margin-left: 260px;
  flex: 1;
  padding: 32px;
  max-width: 1400px;
}

/* Header Banner */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* UI Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Grid & Stats Cards */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  filter: blur(40px);
  z-index: 0;
}

.stat-income::after { background: rgba(16, 185, 129, 0.25); }
.stat-expense::after { background: rgba(239, 68, 68, 0.25); }
.stat-balance::after { background: rgba(59, 130, 246, 0.25); }

.stat-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: #ffffff;
}

.stat-income .stat-value { color: #34d399; }
.stat-expense .stat-value { color: #f87171; }
.stat-balance .stat-value { color: #60a5fa; }

/* Form Controls */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-select option {
  background: #1e293b;
  color: #ffffff;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: white;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: #ef4444;
  color: white;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th {
  padding: 14px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.3);
}

.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.9rem;
  vertical-align: middle;
}

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-income {
  background: var(--income-bg);
  color: #34d399;
  border: 1px solid var(--income-border);
}

.badge-expense {
  background: var(--expense-bg);
  color: #f87171;
  border: 1px solid var(--expense-border);
}

.badge-cat {
  font-size: 0.8rem;
  padding: 3px 8px;
  border-radius: 6px;
  color: #ffffff;
  font-weight: 500;
  text-transform: none;
}

/* Alert Flash Messages */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.alert-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-box {
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  padding: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: translateY(-20px);
  transition: transform 0.25s ease;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #ffffff;
}

/* Form Controls & Touch Targets */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.95rem;
  min-height: 44px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  min-height: 44px;
  transition: all 0.2s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  min-height: 36px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
}

.btn-income {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-income:hover {
  background: linear-gradient(135deg, #047857, #059669);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.45);
}

.btn-expense {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.btn-expense:hover {
  background: linear-gradient(135deg, #b91c1c, #dc2626);
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.45);
}

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

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.35);
  color: #ffffff;
}

/* Mobile Topbar Navigation */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  z-index: 99;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: #ffffff;
}

.mobile-toggle {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: #ffffff;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
}

.sidebar-backdrop.active {
  display: block;
}

/* Responsive & Mobile First Adjustments */
@media (max-width: 768px) {
  .mobile-topbar {
    display: flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    z-index: 101;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 76px 16px 32px 16px;
  }

  .app-container {
    flex-direction: column;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 20px;
  }

  .page-header > div:last-child {
    width: 100%;
  }

  .page-header .btn {
    width: 100%;
    min-height: 48px;
  }

  .page-title {
    font-size: 1.4rem;
  }

  /* Form inputs mobile auto-zoom prevention (min 16px font) */
  .form-control, .form-select {
    font-size: 16px !important;
    min-height: 46px;
  }

  .btn {
    min-height: 46px;
    font-size: 0.95rem;
  }

  .grid-3 {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  div[style*="grid-template-columns: 2fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .modal-box {
    width: 94%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px 16px;
    margin: 0 auto;
  }

  .card {
    padding: 16px;
    margin-bottom: 16px;
  }
}

/* Chart Container Styles */
.chart-card {
  margin-bottom: 28px;
}

.chart-wrapper {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.chart-grid {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 220px;
  gap: 12px;
  padding-top: 24px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--border-color);
  min-width: 600px;
  position: relative;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}

.chart-bars-flex {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 100%;
  width: 100%;
  justify-content: center;
}

.chart-bar {
  width: 14px;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  transition: height 0.4s ease, opacity 0.2s ease;
  position: relative;
}

.chart-bar-income {
  background: linear-gradient(180deg, #10b981, #059669);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.chart-bar-expense {
  background: linear-gradient(180deg, #f87171, #dc2626);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

.chart-col:hover .chart-bar {
  opacity: 0.85;
}

.chart-month-name {
  font-size: 0.75rem;
  color: var(--text-muted);
  position: absolute;
  bottom: -24px;
  font-weight: 600;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 0.85rem;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}


