/* ============================================
   BudgetBuddy - Premium Modern Design System
   Glassmorphism + Gradient + Micro-animations
   ============================================ */

:root {
  /* Primary palette - rich violet-indigo */
  --primary: #7c3aed;
  --primary-dark: #6d28d9;
  --primary-light: #a78bfa;
  --primary-50: #f5f3ff;
  --primary-100: #ede9fe;
  --primary-200: #ddd6fe;
  
  /* Accent - vibrant teal */
  --accent: #06b6d4;
  --accent-dark: #0891b2;
  --accent-light: #67e8f9;
  
  /* Semantic colors */
  --secondary: #10b981;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  
  /* Neutral palette - cooler grays */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --white: #ffffff;
  
  /* Glassmorphism */
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.3);
  --glass-shadow: 0 8px 32px rgba(31, 38, 135, 0.08);
  
  /* Shadows - layered for depth */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 12px 24px -4px rgba(0, 0, 0, 0.08), 0 4px 8px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 40px -8px rgba(0, 0, 0, 0.1), 0 8px 16px -4px rgba(0, 0, 0, 0.06);
  --shadow-xl: 0 32px 64px -12px rgba(0, 0, 0, 0.14), 0 12px 24px -4px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 20px rgba(124, 58, 237, 0.15);
  --shadow-glow-accent: 0 0 20px rgba(6, 182, 212, 0.15);
  
  /* Border radius */
  --radius-sm: 0.375rem;
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-2xl: 2rem;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 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);
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #7c3aed, #6d28d9, #5b21b6);
  --gradient-accent: linear-gradient(135deg, #06b6d4, #0891b2);
  --gradient-warm: linear-gradient(135deg, #f97316, #ef4444);
  --gradient-cool: linear-gradient(135deg, #7c3aed, #06b6d4);
  --gradient-success: linear-gradient(135deg, #10b981, #059669);
  --gradient-surface: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(248,250,252,0.9));
  --gradient-mesh: radial-gradient(at 40% 20%, rgba(124, 58, 237, 0.04) 0px, transparent 50%),
                   radial-gradient(at 80% 0%, rgba(6, 182, 212, 0.03) 0px, transparent 50%),
                   radial-gradient(at 0% 50%, rgba(124, 58, 237, 0.02) 0px, transparent 50%);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  background-image: var(--gradient-mesh);
  background-attachment: fixed;
  line-height: 1.5;
  font-size: 0.875rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

.wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

h1 { font-size: 1.75rem; color: var(--gray-900); }
h2 { font-size: 1.5rem; color: var(--gray-800); }
h3 { font-size: 1.25rem; color: var(--gray-800); }
h4 { font-size: 1.05rem; color: var(--gray-700); }

/* ===== HEADER ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
  z-index: 1000;
  transition: var(--transition);
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--primary);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
  transition: var(--transition);
}

.brand-link:hover {
  transform: scale(1.02);
}

.brand-link i {
  font-size: 1.2rem;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-logo {
  height: 32px;
  width: auto;
}

.brand-logo {
  height: 3.3rem;
  width: auto;
  display: block;
}

.footer-brand .brand-logo {
  height: 2rem;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.navbar-links a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--gray-600);
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  transition: var(--transition);
  white-space: nowrap;
  font-size: 0.9rem;
  position: relative;
}

.navbar-links a:hover {
  background: var(--primary-50);
  color: var(--primary);
  transform: translateY(-1px);
}

.navbar-links a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: var(--transition);
  transform: translateX(-50%);
}

.navbar-links a:hover::after {
  width: 60%;
}

/* Auth buttons */
.auth-btn.primary {
  background: var(--gradient-primary);
  color: var(--white);
  border: none;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-full);
  font-weight: 600;
  box-shadow: var(--shadow-glow);
  transition: var(--transition);
}

.auth-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.3);
  color: var(--white);
}

/* User info */
.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--primary);
  font-weight: 500;
  cursor: pointer;
  padding: 0.375rem;
  border-radius: var(--radius-full);
  transition: var(--transition);
}

.user-info:hover {
  background: var(--primary-50);
}

.settings-header .user-info {
  background: transparent;
}

.user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  color: white;
  font-size: 1.1rem;
  box-shadow: var(--shadow-glow);
  transition: var(--transition);
}

.user-info:hover .user-avatar {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35);
}

.user-details {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.user-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--gray-800);
}

.user-plan {
  font-size: 0.7rem;
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.75px;
}

.budget-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
  font-weight: 500;
}

.logout-btn {
  color: var(--danger) !important;
}

/* Language Selector */
.language-selector {
  position: relative;
  display: inline-block;
}

.language-btn {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  padding: 0.5rem 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
  color: var(--gray-600);
  font-size: 0.875rem;
  font-weight: 500;
}

.language-btn:hover {
  border-color: var(--primary-light);
  background: var(--primary-50);
  color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.language-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 140px;
  z-index: 1001;
  display: none;
  overflow: hidden;
  animation: dropdownFadeIn 0.2s ease-out;
}

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

.language-dropdown.show {
  display: block;
}

.language-dropdown a {
  display: block;
  padding: 0.75rem 1.25rem;
  color: var(--gray-700);
  text-decoration: none;
  transition: var(--transition-fast);
  font-size: 0.875rem;
  font-weight: 500;
}

.language-dropdown a:hover {
  background: var(--primary-50);
  color: var(--primary);
}

.language-dropdown a.active {
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 600;
}

/* ===== HAMBURGER / MOBILE TOGGLE ===== */
.navbar-toggle {
  display: none;
  flex-direction: column;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 0.625rem;
  transition: var(--transition);
}

.navbar-toggle:hover {
  background: var(--primary-50);
  border-color: var(--primary-light);
  transform: scale(1.05);
}

.navbar-toggle .bar {
  width: 20px;
  height: 2.5px;
  background: var(--gray-700);
  margin: 2px 0;
  border-radius: var(--radius-full);
  transition: var(--transition);
}

.navbar-toggle:hover .bar {
  background: var(--primary);
}

/* Hamburger animation */
.menu-open .navbar-toggle .bar:nth-child(1) {
  transform: rotate(-45deg) translate(-5px, 6px);
}
.menu-open .navbar-toggle .bar:nth-child(2) {
  opacity: 0;
}
.menu-open .navbar-toggle .bar:nth-child(3) {
  transform: rotate(45deg) translate(-5px, -6px);
}


/* ===== MOBILE MENU ===== */
@media (max-width: 1200px) {
  .navbar-toggle {
    display: flex;
  }

  .navbar-links {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 1rem 0 2rem 0;
    transform: translateY(-100vh);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-slow);
    z-index: 40;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .navbar-links.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }

  .navbar-links a {
    padding: 1rem 1.5rem;
    border-radius: 0;
    border-bottom: 1px solid var(--gray-100);
    justify-content: flex-start;
    font-size: 1rem;
  }

  .navbar-links a::after {
    display: none;
  }

  .navbar-links a:last-child {
    border-bottom: none;
  }

  .navbar-links .dropdown {
    display: none;
  }

  /* Mobile sheets grid */
  .mobile-sheets-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin: 0 0 1rem 0;
    width: 100%;
    padding: 0 0.5rem;
  }

  .mobile-sheet-tile {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 0.75rem 0.5rem;
    text-align: center;
    text-decoration: none;
    color: var(--gray-700);
    font-size: 0.75rem;
    font-weight: 500;
    transition: var(--transition);
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-sheet-tile:hover {
    background: var(--primary-50);
    border-color: var(--primary-light);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
  }

  .mobile-sheet-tile.current-month {
    background: var(--gradient-primary);
    color: var(--white);
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
  }

  .mobile-sheet-tile.current-month:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
  }

  .mobile-year-tile {
    background: var(--gradient-success);
    color: white !important;
    border-color: var(--success);
    grid-column: 1 / -1;
    margin-top: 0.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
  }

  .mobile-year-tile:hover {
    background: #059669;
    color: white !important;
  }

  /* Mobile sheets section */
  .mobile-sheets-section {
    padding: 1rem 1.5rem 4rem 1.5rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 3rem;
    display: block;
  }

  .mobile-sheets-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 1rem;
    font-size: 1rem;
  }

  .mobile-sheets-header i {
    color: var(--primary);
  }

  /* Mobile user section */
  .mobile-user-section {
    display: block;
  }

  .mobile-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-50), var(--gray-50));
    border-bottom: 1px solid var(--gray-200);
  }

  .mobile-user-avatar {
    width: 44px;
    height: 44px;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    box-shadow: var(--shadow-glow);
  }

  .mobile-user-details {
    flex: 1;
  }

  .mobile-user-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--gray-900);
    display: block;
  }

  .mobile-user-plan {
    font-size: 0.75rem;
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.75px;
  }

  .mobile-user-actions {
    display: block;
  }

  .mobile-user-actions a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
    text-decoration: none;
    transition: var(--transition-fast);
  }

  .mobile-user-actions a:hover {
    background: var(--gray-50);
    padding-left: 2rem;
  }

  .mobile-user-actions a.logout {
    color: var(--danger);
  }

  .mobile-user-actions a:last-child {
    border-bottom: none;
  }

  /* Mobile language selector */
  .mobile-language-selector {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
  }

  .language-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.75rem;
  }

  .language-options {
    display: flex;
    gap: 0.5rem;
  }

  .language-options a {
    padding: 0.5rem 1rem !important;
    background: var(--gray-100);
    border-radius: var(--radius-full) !important;
    color: var(--gray-700) !important;
    text-decoration: none;
    font-size: 0.875rem;
    border-bottom: none !important;
    transition: var(--transition);
    font-weight: 500;
  }

  .language-options a.active {
    background: var(--gradient-primary);
    color: white !important;
    box-shadow: var(--shadow-glow);
  }

  .language-options a:hover {
    background: var(--primary-dark);
    color: white !important;
  }

  #navbarAuthLinks {
    display: none !important;
  }

  .nav-text {
    display: inline;
  }
}

/* Hide mobile sections on desktop */
@media (min-width: 1200px) {
  .mobile-user-section,
  .mobile-sheets-section {
    display: none;
  }
}

/* ===== DESKTOP DROPDOWN ===== */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 1000;
  display: none;
  overflow: hidden;
  animation: dropdownFadeIn 0.2s ease-out;
}

/* Only open on click (via .open class), NOT on hover */
.dropdown.open .dropdown-content {
  display: block;
}

.dropdown-content a {
  display: block;
  padding: 0.75rem 1.25rem;
  color: var(--gray-700);
  text-decoration: none;
  transition: var(--transition-fast);
  font-size: 0.875rem;
  font-weight: 500;
}

.dropdown-content a:hover {
  background: var(--primary-50);
  color: var(--primary);
}

.dropdown-content a.current-month {
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 600;
  border-left: 3px solid var(--primary);
}

.dropdown-content a.year-link {
  border-top: 1px solid var(--gray-200);
  background: var(--gradient-success);
  color: var(--white);
  font-weight: 600;
}

.dropdown-content a.year-link:hover {
  background: #059669;
}

/* ===== MAIN CONTENT ===== */
.content {
  flex: 1;
  padding: 90px 1.5rem 5rem;
  max-width: 1300px;
  margin: 0 auto;
  width: 100%;
}

/* ===== CARDS & CONTAINERS ===== */
.container {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 2rem;
  margin-bottom: 2rem;
  border: 1px solid var(--gray-100);
  transition: var(--transition);
}

.container:hover {
  box-shadow: var(--shadow-md);
}

/* ===== BUTTONS ===== */
.btn, .add-button, .action-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
}

.btn::before, .add-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.btn:hover::before, .add-button:hover::before {
  left: 100%;
}

.btn, .add-button {
  background: var(--gradient-primary);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

.btn:hover, .add-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.3);
}

.btn:active, .add-button:active {
  transform: translateY(0);
}

.action-button {
  background: var(--gray-100);
  color: var(--gray-700);
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  border-radius: var(--radius-full);
  box-shadow: none;
  font-weight: 600;
}

.action-button::before {
  /* Don't block tooltip - only hide shine effect */
  content: none;
}

.action-button:hover {
  background: var(--gray-200);
  transform: translateY(-1px);
}

.action-button.purple-button {
  background: var(--gradient-primary);
  color: var(--white);
}

.action-button.purple-button:hover {
  box-shadow: var(--shadow-glow);
}

.action-button.green {
  background: var(--gradient-success);
  color: var(--white);
}

.action-button.green:hover {
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.action-button.red {
  background: var(--gradient-warm);
  color: white;
}

.action-button.red:hover {
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn.danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border-color: var(--danger);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.btn.danger:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3);
}

.btn.secondary {
  background: var(--white);
  color: var(--gray-700);
  border: 1.5px solid var(--gray-200);
  box-shadow: var(--shadow-xs);
}

.btn.secondary::before {
  display: none;
}

.btn.secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  box-shadow: var(--shadow-sm);
}


/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  min-width: 320px;
  max-width: 420px;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: toastSlideIn 0.4s var(--transition-spring);
  position: relative;
  pointer-events: auto;
  backdrop-filter: blur(12px);
}

.toast.info {
  background: linear-gradient(135deg, #dbeafe, #eff6ff);
  border-left: 4px solid #3b82f6;
  color: #1e40af;
}

.toast.success {
  background: linear-gradient(135deg, #dcfce7, #f0fdf4);
  border-left: 4px solid var(--success);
  color: #166534;
}

.toast.warning {
  background: linear-gradient(135deg, #fef3c7, #fffbeb);
  border-left: 4px solid var(--warning);
  color: #92400e;
}

.toast.error {
  background: linear-gradient(135deg, #fee2e2, #fef2f2);
  border-left: 4px solid var(--danger);
  color: #991b1b;
}

.toast.confirm {
  background: linear-gradient(135deg, #fef3c7, #fffbeb);
  border-left: 4px solid var(--warning);
  color: #92400e;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.15);
}

.toast-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
  font-weight: 500;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  transition: var(--transition-fast);
}

.toast-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
}

.confirm-toast {
  min-width: 360px;
}

.toast-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.toast-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  transition: var(--transition);
}

.toast-btn.confirm-btn {
  background: var(--gradient-success) !important;
  color: white !important;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.toast-btn.confirm-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4) !important;
}

.toast-btn.cancel-btn {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  color: white !important;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.toast-btn.cancel-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4) !important;
}

@keyframes toastSlideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastSlideOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(120%); opacity: 0; }
}

/* ===== TABLES ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin: 1.5rem 0;
  border: 1px solid var(--gray-100);
}

.category-table, .sheets-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
}

.table-header {
  background: linear-gradient(135deg, var(--gray-50), var(--gray-100));
}

.table-header .table-cell {
  padding: 1rem 1.25rem;
  font-weight: 700;
  color: var(--gray-700);
  border-bottom: 2px solid var(--gray-200);
  text-align: left;
  border-left: none;
  border-right: none;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table-cell, .table-cell-2 {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  border-left: none;
  border-right: none;
  vertical-align: middle;
  transition: var(--transition-fast);
}

.table-cell-2 {
  text-align: center;
}

.category-row {
  background: var(--gray-50);
}

.subcategory-row {
  background: var(--white);
}

.category-row:hover, .subcategory-row:hover {
  background: var(--primary-50);
}

/* ===== FORMS ===== */
.input-field, .input-select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: var(--transition);
  background: var(--white);
  color: var(--gray-800);
}

.input-field:focus, .input-select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.08);
}

.input-field::placeholder {
  color: var(--gray-400);
}

/* ===== STATUS COLORS ===== */
.text-green { color: var(--success); font-weight: 700; }
.text-red { color: var(--danger); font-weight: 700; }
.important-variable { color: var(--primary); font-weight: 700; }

/* ===== MODALS ===== */
.modal, .modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  z-index: 9999;
  justify-content: center;
  align-items: center;
}

.modal-overlay {
  display: flex;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--white);
  padding: 0;
  border-radius: var(--radius-2xl);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  box-shadow: var(--shadow-xl);
  position: relative;
  animation: modalSlideIn 0.4s var(--transition-spring);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--gray-100);
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  background: var(--gradient-primary);
  color: white;
  padding: 1.75rem 2rem;
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  overflow: hidden;
}

.modal-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
}

.modal-header::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 150px;
  height: 150px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 50%;
}

.modal-close {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 1;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

.modal-header h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  color: white;
  line-height: 1.3;
  word-wrap: break-word;
  z-index: 1;
}

.modal-body {
  padding: 2rem;
  overflow-y: auto;
  flex: 1;
}

.close-button {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-size: 1.5rem;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.8);
  transition: var(--transition);
  background: none;
  border: none;
  padding: 0.5rem;
  border-radius: var(--radius-full);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.close-button:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
  transform: rotate(90deg);
}

.modal-submit-button {
  background: var(--gradient-primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2);
}

.modal-submit-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.3);
}

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

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

.modal .form-group label {
  font-weight: 600;
  color: var(--gray-700);
  font-size: 0.875rem;
}

.modal .form-group input,
.modal .form-group select,
.modal .form-group textarea {
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  transition: var(--transition);
}

.modal .form-group input:focus,
.modal .form-group select:focus,
.modal .form-group textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.08);
}

/* Ensure all modal text on colored backgrounds is light */
.modal-header,
.modal-header h1,
.modal-header h2,
.modal-header h3,
.modal-header h4,
.modal-header h5,
.modal-header h6,
.modal-header p,
.modal-header span {
  color: white !important;
}

/* ===== SUMMARY CARDS (Sheets page) ===== */
.sheets-summary {
  background: var(--gradient-primary);
  color: var(--white);
  padding: 2.5rem;
  border-radius: var(--radius-2xl);
  margin-bottom: 2rem;
  box-shadow: 0 12px 40px rgba(124, 58, 237, 0.2);
  position: relative;
  overflow: hidden;
}

.sheets-summary::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
}

.sheets-summary::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 300px;
  height: 300px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 50%;
}

.summary-content {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 2rem;
  align-items: center;
  position: relative;
  z-index: 1;
}

.summary-column-planned, .summary-column-actual {
  text-align: center;
}

.summary-column-planned h3, .summary-column-actual h3 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
  opacity: 0.9;
}

.summary-column-planned p, .summary-column-actual p {
  font-size: 1rem;
  margin: 0.5rem 0;
}

.summary-title {
  color: var(--white);
  text-align: center;
  margin-bottom: 1rem;
}

/* ===== PROGRESS BAR ===== */
.progress-container {
  margin: 2rem 0;
  text-align: center;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 0.5rem 0;
}

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

.progress-fill::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%); }
}

.progress-fill[style*="width: 0%"] {
  display: none;
}


/* ===== FOOTER ===== */
.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--glass-border);
  padding: 0.875rem 1rem;
  text-align: center;
  z-index: 100;
}

@media (max-width: 1200px) {
  .footer {
    position: static;
    margin-top: 2rem;
  }
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  max-width: 1300px;
  margin: 0 auto;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
  font-weight: 700;
}

.footer p {
  color: var(--gray-500);
  font-size: 0.8rem;
}

.footer-links {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-left: 1rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--gray-500) !important;
  text-decoration: none !important;
  font-size: 0.8rem;
  transition: var(--transition-fast);
  font-weight: 500;
}

.footer-links a:hover {
  color: var(--primary) !important;
}

.footer-links a i {
  margin-right: 0.25rem;
}

/* ===== UTILITY CLASSES ===== */
.d-none { display: none; }
.text-center { text-align: center; }
.mb-4 { margin-bottom: 1rem; }
.mt-4 { margin-top: 1rem; }

/* ===== REGISTER ACTIONS ===== */
.register-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
  width: 100%;
}

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

/* ===== DARK MODE ===== */
body.dark-mode {
  --gray-50: #1e293b;
  --gray-100: #334155;
  --gray-200: #475569;
  --gray-300: #64748b;
  --gray-400: #94a3b8;
  --gray-500: #cbd5e1;
  --gray-600: #e2e8f0;
  --gray-700: #f1f5f9;
  --gray-800: #f8fafc;
  --gray-900: #ffffff;
  --white: #1e293b;
  --glass-bg: rgba(30, 41, 59, 0.85);
  --glass-border: rgba(71, 85, 105, 0.4);
  background: #0f172a;
  background-image: radial-gradient(at 40% 20%, rgba(124, 58, 237, 0.06) 0px, transparent 50%),
                    radial-gradient(at 80% 0%, rgba(6, 182, 212, 0.04) 0px, transparent 50%);
  color: #f8fafc;
}

body.dark-mode .header {
  background: rgba(30, 41, 59, 0.9);
  border-bottom-color: rgba(71, 85, 105, 0.4);
}

body.dark-mode .footer {
  background: rgba(30, 41, 59, 0.9);
  border-top-color: rgba(71, 85, 105, 0.4);
}

body.dark-mode .container {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .modal-content {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .text-green { color: #34d399 !important; }
body.dark-mode .text-red { color: #f87171 !important; }
body.dark-mode .positive { color: #34d399 !important; }
body.dark-mode .negative { color: #f87171 !important; }
body.dark-mode .table-cell-2.text-green { color: #34d399 !important; }
body.dark-mode .table-cell-2.text-red { color: #f87171 !important; }
body.dark-mode .diff.positive { color: #34d399 !important; }
body.dark-mode .diff.negative { color: #f87171 !important; }

body.dark-mode .input-field,
body.dark-mode .input-select {
  background: #334155;
  border-color: #475569;
  color: #f8fafc;
}

body.dark-mode .navbar-links a:hover {
  background: #334155;
  color: var(--primary-light);
}

body.dark-mode .dropdown-content {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .dropdown-content a {
  color: #f8fafc;
}

body.dark-mode .dropdown-content a:hover {
  background: #334155;
}

body.dark-mode .table-header .table-cell {
  background: #334155;
  color: #f8fafc;
}

body.dark-mode .category-table,
body.dark-mode .sheets-table {
  background: #1e293b;
}

body.dark-mode .table-cell,
body.dark-mode .table-cell-2 {
  border-color: #334155;
  color: #f8fafc;
}

/* ===== RESPONSIVE NAVIGATION ===== */
@media (max-width: 1320px) {
  .navbar-links .nav-text {
    display: none;
  }
  
  .navbar-links a {
    padding: 0.5rem;
    min-width: 40px;
    text-align: center;
    justify-content: center;
  }
  
  .navbar-links a i {
    margin: 0;
  }
}

/* ===== MOBILE TOAST ===== */
@media (max-width: 768px) {
  .toast-container {
    position: fixed !important;
    top: 20px !important;
    left: 2.5% !important;
    right: 2.5% !important;
    width: 95% !important;
    transform: none !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    z-index: 10000 !important;
  }
  
  .toast {
    width: 100% !important;
    min-width: auto !important;
    max-width: 100% !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
  }
  
  .confirm-toast {
    min-width: auto !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .toast-actions {
    flex-wrap: nowrap !important;
    gap: 0.5rem !important;
    margin-top: 0.75rem !important;
  }
  
  .toast-btn {
    flex: 1 !important;
    min-width: 0 !important;
    padding: 0.5rem 0.75rem !important;
    font-size: 0.875rem !important;
    white-space: nowrap !important;
  }
  
  .toast-content {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
  }
  
  .modal-header {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

/* ===== MOBILE COOKIES MODAL ===== */
@media (max-width: 480px) {
  .cookies-modal-content {
    margin: 0 !important;
    width: 95% !important;
    max-width: 95% !important;
    height: 80vh !important;
    max-height: 80vh !important;
    border-radius: var(--radius-xl) !important;
  }
  
  .cookies-modal-header {
    padding: 1rem 1.5rem !important;
    border-radius: 0 !important;
  }
  
  .cookies-modal-body {
    padding: 1.5rem !important;
    max-height: calc(80vh - 160px) !important;
  }
  
  .cookies-category-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 1rem !important;
    padding: 1rem !important;
  }
  
  .cookies-category-info {
    width: 100% !important;
  }
  
  .cookies-toggle {
    align-self: flex-end !important;
    width: auto !important;
  }
  
  .toggle-label {
    width: 50px !important;
    height: 25px !important;
  }
  
  .toggle-slider:before {
    height: 19px !important;
    width: 19px !important;
    left: 3px !important;
    bottom: 3px !important;
  }
  
  input:checked + .toggle-label .toggle-slider:before {
    transform: translateX(25px) !important;
  }
  
  .cookies-modal-footer {
    padding: 1rem 1.5rem !important;
    flex-direction: column !important;
    gap: 0.75rem !important;
  }
  
  .cookies-btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 12px 20px !important;
  }
}

/* ===== MOBILE 2FA ===== */
@media (max-width: 480px) {
  .verify-header p {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    hyphens: auto !important;
    line-height: 1.6 !important;
  }
  
  .verify-header strong {
    word-break: break-all !important;
    display: block !important;
    margin-top: 0.5rem !important;
  }
  
  .qr-header p,
  .verification-header p {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
  }
}

/* ===== MOBILE SECURITY ===== */
@media (max-width: 480px) {
  .security-actions {
    gap: 0.75rem !important;
    width: 100% !important;
  }
  
  .security-actions .btn-secondary,
  .security-actions .btn-danger {
    width: 100% !important;
    padding: 0.75rem 1rem !important;
    font-size: 0.85rem !important;
    text-align: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
  
  .session-item {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 1rem !important;
    padding: 1rem !important;
  }
  
  .session-info { width: 100% !important; }
  
  .session-device {
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 0.75rem !important;
  }
  
  .session-details {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.25rem !important;
  }
  
  .session-actions {
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
  }
  
  .btn-terminate {
    width: 100% !important;
    max-width: 200px !important;
    justify-content: center !important;
  }
  
  .session-details span:nth-child(2),
  .session-details span:nth-child(4) {
    display: none !important;
  }
}

/* ===== MOBILE PREFERENCES ===== */
@media (max-width: 480px) {
  .form-actions {
    flex-direction: column !important;
    gap: 0.75rem !important;
  }
  
  .form-actions .btn {
    width: 100% !important;
    justify-content: center !important;
    padding: 1rem 1.5rem !important;
  }
  
  .preference-item,
  .notification-item,
  .display-item,
  .privacy-item {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 1rem !important;
    text-align: left !important;
  }
  
  .preference-header,
  .notification-header,
  .display-header,
  .privacy-header {
    width: 100% !important;
  }
  
  .preference-control,
  .notification-control,
  .display-control,
  .privacy-control {
    width: 100% !important;
    display: flex !important;
    justify-content: flex-end !important;
  }
  
  .preference-select {
    width: 100% !important;
    min-width: auto !important;
  }
  
  .security-btn,
  a.security-btn {
    width: 100% !important;
    min-width: auto !important;
  }
  
  button[name="change_email"] {
    width: 100% !important;
    justify-content: center !important;
  }
  
  /* Toggle switches */
  .preference-control .toggle-label,
  .notification-control .toggle-label,
  .display-control .toggle-label,
  .privacy-control .toggle-label {
    width: 60px !important;
    height: 30px !important;
  }
  
  .preference-control .toggle-slider,
  .notification-control .toggle-slider,
  .display-control .toggle-slider,
  .privacy-control .toggle-slider {
    background: var(--gray-300) !important;
    border-radius: 30px !important;
  }
  
  .preference-control .toggle-slider:before,
  .notification-control .toggle-slider:before,
  .display-control .toggle-slider:before,
  .privacy-control .toggle-slider:before {
    height: 24px !important;
    width: 24px !important;
    left: 3px !important;
    top: 3px !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2) !important;
  }
  
  .preference-control input:checked + .toggle-label .toggle-slider,
  .notification-control input:checked + .toggle-label .toggle-slider,
  .display-control input:checked + .toggle-label .toggle-slider,
  .privacy-control input:checked + .toggle-label .toggle-slider {
    background-color: #10b981 !important;
    background: #10b981 !important;
  }
  
  .preference-control input:checked + .toggle-label .toggle-slider:before,
  .notification-control input:checked + .toggle-label .toggle-slider:before,
  .display-control input:checked + .toggle-label .toggle-slider:before,
  .privacy-control input:checked + .toggle-label .toggle-slider:before {
    transform: translateX(30px) !important;
  }
  
  .toggle-switch input:checked + .toggle-slider {
    background-color: #10b981 !important;
    background: #10b981 !important;
  }
}


/* ===== ALERTS ===== */
.alert {
  display: block;
  position: relative;
  padding: 1.25rem 1.25rem 1.25rem 3.5rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
  border: 1px solid transparent;
  backdrop-filter: blur(8px);
}

.alert-warning {
  background: linear-gradient(135deg, #fef3c7, #fffbeb);
  border-color: rgba(245, 158, 11, 0.3);
  color: #92400e;
}

.alert-danger {
  background: linear-gradient(135deg, #fee2e2, #fef2f2);
  border-color: rgba(239, 68, 68, 0.3);
  color: #991b1b;
}

.alert-success {
  background: linear-gradient(135deg, #dcfce7, #f0fdf4);
  border-color: rgba(16, 185, 129, 0.3);
  color: #166534;
}

.alert i {
  position: absolute;
  left: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
}

.alert-content {
  text-align: center;
}

.alert-content h4,
.alert-content p {
  text-align: center !important;
  margin: 0;
}

.alert-content h4 {
  margin-bottom: 0.5rem;
}

/* ===== CATEGORY TOGGLES ===== */
.mobile-category-toggle {
  pointer-events: auto;
  cursor: pointer;
  z-index: 10;
  position: relative;
  touch-action: manipulation;
  user-select: none;
  font-size: 14px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: var(--transition) !important;
  color: var(--primary) !important;
  flex-shrink: 0 !important;
  margin-right: 0.5rem !important;
  vertical-align: middle !important;
}

.mobile-category-toggle:hover {
  color: var(--primary-dark) !important;
  transform: scale(1.15) !important;
}

.mobile-category-toggle.rotated {
  transform: rotate(180deg) !important;
}

.category-toggle {
  font-size: 14px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: var(--transition) !important;
  margin-right: 0.5rem !important;
  vertical-align: middle !important;
  cursor: pointer !important;
  color: var(--primary) !important;
  flex-shrink: 0 !important;
}

.category-toggle:hover {
  color: var(--primary-dark) !important;
  transform: scale(1.15) !important;
}

.category-toggle.rotated {
  transform: rotate(180deg) !important;
}

.category-toggle.rotated:hover {
  transform: rotate(180deg) scale(1.15) !important;
}

.mobile-category-header {
  position: relative;
  touch-action: manipulation;
  user-select: none;
}

/* Step layout fix for mobile */
@media (max-width: 480px) {
  .step {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
  }
  
  .step-number {
    align-self: center;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
  }
  
  .step-content {
    text-align: center;
    width: 100%;
  }
  
  .step-content h3 {
    text-align: center;
    margin-bottom: 1rem;
  }
  
  .step-content ul {
    text-align: left;
    max-width: 100%;
    margin: 0 auto;
  }
}

/* ===== MOBILE RESPONSIVE (1200px) ===== */
@media (max-width: 1200px) {
  .navbar {
    padding: 0 1rem;
    height: 70px;
  }

  .navbar-brand {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .navbar-toggle {
    display: flex;
  }

  .navbar-links {
    display: none;
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    background: var(--white);
    flex-direction: column;
    padding: 1rem 0 1rem 0;
    gap: 0.5rem;
    z-index: 40;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .navbar-links.active {
    display: flex;
  }

  .navbar-links .nav-text {
    display: inline;
  }

  .navbar-links a {
    padding: 1rem;
    border-radius: var(--radius);
    transition: var(--transition);
    text-align: left;
    min-width: auto;
  }

  .navbar-links a:hover {
    background: var(--primary-50);
    transform: translateX(4px);
  }

  #navbarAuthLinks {
    display: none;
    position: absolute;
    top: calc(70px + 200px);
    left: 0;
    right: 0;
    background: var(--white);
    flex-direction: column;
    padding: 1rem;
    gap: 0.5rem;
    z-index: 39;
    box-shadow: var(--shadow-md);
  }

  #navbarAuthLinks.active {
    display: flex;
  }

  .user-info {
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin: 0.25rem 0;
  }

  .auth-btn {
    justify-content: center;
    padding: 1rem;
    font-weight: 600;
  }

  .auth-btn.primary {
    background: var(--gradient-primary);
    color: white;
    margin-top: 0.5rem;
  }

  .logout-btn {
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger) !important;
    border: 1px solid rgba(239, 68, 68, 0.15);
    margin-top: 0.5rem;
  }

  /* Dropdown mobile */
  .dropdown {
    position: relative;
  }

  .dropdown > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
  }

  .dropdown > a::after {
    content: '\f107';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    transition: var(--transition);
  }

  .dropdown.open > a::after {
    transform: rotate(180deg);
  }

  .dropdown-content {
    display: none;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin: 0.5rem 0;
    padding: 0.5rem;
    text-align: center;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
  }

  .dropdown.open .dropdown-content {
    display: block;
  }

  .dropdown-content a {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    color: var(--gray-600);
    border-radius: var(--radius);
    display: block;
    pointer-events: auto;
  }

  .dropdown-content a:hover {
    background: var(--gray-100);
    color: var(--primary);
  }

  .dropdown-content a:active {
    background: var(--primary);
    color: white;
  }
  
  .dropdown-content a.current-month {
    background: var(--gradient-primary);
    color: white;
    font-weight: 600;
  }
  
  .dropdown-content a.current-month:hover {
    background: var(--primary-dark);
    color: white;
  }

  .content {
    padding: 90px 0rem 1rem;
  }

  .container {
    padding: 1.5rem;
    border-radius: var(--radius-lg);
  }

  .summary-content {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .table-wrapper {
    font-size: 0.875rem;
  }

  .table-cell, .table-cell-2 {
    padding: 0.75rem 0.5rem;
  }

  .modal-content {
    width: 95%;
    border-radius: var(--radius-xl);
  }
  
  .footer-content {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .footer-links {
    margin-left: 0;
    justify-content: center;
    gap: 0.5rem;
  }
  
  .footer-links a {
    font-size: 0.8rem;
  }

  /* ===== MOBILE CATEGORIES TABLE ===== */
  .category-table {
    display: block;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
  }

  .category-table thead {
    display: none;
  }

  .category-table tbody {
    display: block;
  }

  .category-table tr {
    display: block;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
  }

  .category-table tr:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
  }

  .category-table td {
    display: block;
    border: none;
    padding: 0.5rem 0;
    text-align: left !important;
  }

  .category-table td:before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--gray-500);
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.75px;
  }

  /* Category row styling */
  .category-row {
    background: linear-gradient(135deg, var(--primary-50), var(--gray-50)) !important;
    border-left: 4px solid var(--primary) !important;
  }

  .category-row:hover {
    background: linear-gradient(135deg, var(--primary-100), var(--gray-100)) !important;
  }

  .subcategory-row {
    background: var(--white) !important;
    border-left: 4px solid var(--gray-300) !important;
    margin-left: 1rem;
    margin-top: 0.5rem;
  }

  .subcategory-add-row {
    background: var(--gray-50) !important;
    border-left: 4px solid var(--success) !important;
    margin-left: 1rem;
    margin-top: 0.5rem;
  }

  .category-add-row {
    background: var(--gradient-success) !important;
    color: white;
    border-left: 4px solid var(--success) !important;
  }

  .category-add-row td:before {
    color: rgba(255, 255, 255, 0.8) !important;
  }

  .category-add-row .input-field,
  .category-add-row .input-select {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--gray-800);
  }

  /* Mobile action buttons */
  .mobile-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
  }

  .action-button {
    flex: 1;
    min-width: 80px;
    padding: 0.4rem 0.6rem;
    font-size: 0.7rem;
    text-align: center;
    justify-content: center;
  }
  
  .action-button i {
    font-size: 0.7rem !important;
  }

  .table-cell:first-child:before {
    content: "Nazwa";
  }

  .table-cell-2:nth-child(2):before {
    content: "Typ";
  }

  .table-cell-2:nth-child(3):before {
    content: "Akcje";
  }

  /* Mobile sheets header */
  .header-actions {
    flex-direction: column;
    gap: 0.75rem;
    width: 100%;
  }

  .header-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
  }

  /* Keep page-header actions as desktop layout at 768px–1200px */
  .page-header .header-actions {
    flex-direction: row;
    width: auto;
    gap: 0.75rem;
  }

  .page-header .header-actions .btn {
    width: auto;
  }

  .mobile-header-row {
    display: flex;
    gap: 0.5rem;
    width: 100%;
  }

  .mobile-header-row .btn {
    flex: 1;
    min-width: 0;
  }

  .table-wrapper {
    overflow: visible;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
  }

  .table-wrapper:not(.categories-page) .action-button {
    display: inline-flex;
    margin: 0.25rem 0.25rem 0.25rem 0;
    padding: 0.4rem 0.6rem;
    font-size: 0.7rem;
  }
  
  .table-wrapper:not(.categories-page) .action-button i {
    font-size: 0.7rem !important;
  }

  /* Summary cards mobile */
  .summary-cards {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .summary-card {
    margin-bottom: 1rem;
  }

  .card-content {
    padding: 1rem;
  }

  .metric {
    padding: 0.5rem 0;
  }

  .metric .label {
    font-size: 0.85rem;
  }

  .metric .value {
    font-size: 1rem;
  }

  /* Mobile user preferences */
  .email-display {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
    padding: 0.75rem;
  }
  
  .email-display span:first-of-type {
    word-break: break-all;
    font-size: 0.9rem;
  }
  
  .email-status {
    align-self: center;
    margin-left: 0 !important;
    font-size: 0.8rem;
  }
  
  .new-email {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
  }
  
  .new-email .value {
    word-break: break-all;
    width: 100%;
  }
  
  .preference-item,
  .notification-item,
  .display-item,
  .privacy-item {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 1rem !important;
    text-align: left !important;
  }
  
  .preference-header,
  .notification-header,
  .display-header,
  .privacy-header {
    width: 100%;
  }
  
  .preference-control,
  .notification-control,
  .display-control,
  .privacy-control {
    width: 100%;
    display: flex;
    justify-content: flex-end;
  }
  
  .preference-select {
    width: 100%;
    min-width: auto;
  }
  
  .form-grid {
    grid-template-columns: 1fr !important;
  }
  
  .avatar-section {
    flex-direction: column !important;
    text-align: center !important;
  }
  
  .status-steps {
    gap: 0.5rem;
  }
  
  .step {
    font-size: 0.85rem;
  }
  
  .rate-limit-info {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
  
  .rate-limit-text {
    text-align: center;
  }
}


/* ===== EXTRA SMALL MOBILE (480px) ===== */
@media (max-width: 480px) {
  .email-display {
    padding: 0.5rem;
    font-size: 0.85rem;
  }
  
  .email-display i { font-size: 0.9rem; }
  .email-display span:first-of-type { font-size: 0.8rem; line-height: 1.3; }
  .email-status { font-size: 0.75rem; }
  
  .preferences-settings-page,
  .profile-settings-page {
    padding: 0 0.5rem;
  }
  
  .page-header {
    padding: 1rem;
    margin-bottom: 1rem;
  }
  
  .header-text h1 { font-size: 1.25rem; }
  .header-text p { font-size: 0.85rem; }
  
  .preferences-grid,
  .notifications-grid,
  .display-grid,
  .privacy-grid {
    padding: 1rem;
    gap: 1rem;
  }
  
  .preference-item,
  .notification-item,
  .display-item,
  .privacy-item {
    padding: 1rem;
  }
  
  .preference-info h4,
  .notification-info h4,
  .display-info h4,
  .privacy-info h4 { font-size: 0.9rem; }
  
  .preference-info p,
  .notification-info p,
  .display-info p,
  .privacy-info p { font-size: 0.8rem; }
  
  .section-header {
    padding: 1rem;
    flex-direction: column;
    text-align: center;
  }
  
  .section-title h3 { font-size: 1rem; }
  .section-title p { font-size: 0.8rem; }
  
  .form-actions {
    padding: 1rem;
    flex-direction: column;
  }
  
  .btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
  }
  
  .new-email .value { padding: 0.5rem; font-size: 0.8rem; }
  .status-badge { font-size: 0.7rem; padding: 0.2rem 0.5rem; }
  .email-change-container { padding: 1rem; }
  .current-email { margin: 1rem 0; }
  .email-change-status { padding: 1rem; }
  .status-header h4 { font-size: 0.9rem; }
  
  .avatar-circle {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
  }
  
  .avatar-upload-btn {
    width: 25px;
    height: 25px;
    font-size: 0.7rem;
  }
  
  .form-section { padding: 1rem; }
  .form-group input, .form-group select { padding: 0.75rem; font-size: 0.9rem; }
  .form-group label { font-size: 0.85rem; }
  .input-help { font-size: 0.75rem; }
  
  .toggle-switch { width: 50px; height: 25px; }
  .toggle-slider:before { height: 19px; width: 19px; left: 3px; bottom: 3px; }
  input:checked + .toggle-slider:before { transform: translateX(25px); }
  
  .rate-limit-info { padding: 0.75rem; }
  .rate-limit-text { font-size: 0.8rem; }
  .info-steps h4 { font-size: 0.9rem; }
  .info-steps li { font-size: 0.8rem; }

  /* Balance page */
  .balance-summary-cards {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }
  
  .summary-card { padding: 1rem; }
  .card-content h3 { font-size: 1.25rem; }
  
  .accounts-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem;
    padding: 1rem;
  }
  
  .account-card { padding: 1rem; }
  .account-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .account-balance { font-size: 1.25rem; }
  .account-actions { flex-direction: column; gap: 0.5rem; }
  .action-btn { padding: 0.75rem; font-size: 0.9rem; }
  .goal-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .goal-actions { align-self: flex-end; }
  
  .section-header {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
  
  .page-header > .header-content {
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 0.5rem;
  }
  
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .register-table {
    min-width: 600px;
    font-size: 0.85rem;
  }
  
  .register-table th,
  .register-table td {
    padding: 0.5rem;
    white-space: nowrap;
  }
  
  .register-actions {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 1rem;
    width: 100%;
  }
  
  .register-actions .btn {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
  }

  h1 { font-size: 1.875rem; }
  h2 { font-size: 1.5rem; }
  
  .btn, .add-button, .action-button {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
  }
  
  .table-cell, .table-cell-2 {
    padding: 0.5rem 0.25rem;
    font-size: 0.8rem;
  }

  .container { padding: 1rem; }
  .header-content { padding: 1rem; }
  .header-info h1 { font-size: 1.25rem; }

  .category-table tr {
    padding: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .action-button {
    padding: 0.4rem 0.6rem;
    font-size: 0.7rem;
  }

  .mobile-header-row .btn {
    padding: 0.6rem 0.5rem;
    font-size: 0.75rem;
  }

  .summary-card { padding: 1rem; }
  .card-content { padding: 0.75rem; }
  .progress-container { padding: 1rem; }
  .ai-header { padding: 0.75rem; }
  .ai-insights { padding: 0.75rem; }

  /* Balance modal */
  #balanceRegisterModal .modal-content {
    width: 98%;
    max-width: none;
    margin: 1% auto;
  }
  
  .modal-content {
    width: 95% !important;
    margin: 2% auto;
  }
  
  .form-group { padding: 0 1rem; }
  .form-actions { flex-direction: column; gap: 0.5rem; }
  .form-actions .btn { width: 100%; justify-content: center; }

  /* Extra small balance */
  .card-icon { width: 50px; height: 50px; font-size: 1.25rem; }
  .card-content h3 { font-size: 1.1rem; }
  .card-content p { font-size: 0.85rem; }
  .card-detail { font-size: 0.75rem; }
  .account-card { padding: 0.75rem; }
  .account-balance { font-size: 1.1rem; }
  .account-type { font-size: 0.75rem; padding: 0.2rem 0.5rem; }
  .action-btn { padding: 0.5rem; font-size: 0.8rem; }
  .goal-item { margin-bottom: 0.75rem; }
  .goal-name { font-size: 0.9rem; }
  .goal-progress-text { font-size: 0.8rem; }
  .edit-goal-btn, .delete-goal-btn { width: 18px; height: 18px; font-size: 0.7rem; }
  .register-table { font-size: 0.8rem; }
  .register-table th, .register-table td { padding: 0.4rem; }
  .register-actions { display: flex; justify-content: space-between; gap: 0.5rem; width: 100%; }
  .register-actions .btn { flex: 1; padding: 0.5rem 0.8rem; font-size: 0.8rem; }
  .modal-header h3 { font-size: 1rem; }
  .form-group { margin-bottom: 1rem; padding: 0 0.75rem; }
  .form-group label { font-size: 0.9rem; }
  .form-group input, .form-group select, .form-group textarea { padding: 0.6rem; font-size: 0.9rem; }
  .form-actions { padding: 1rem 0.75rem; }
  .form-actions .btn { padding: 0.6rem; font-size: 0.9rem; }
  .empty-state { padding: 2rem 1rem; }
  .empty-icon { font-size: 3rem; }
  .empty-state h3 { font-size: 1.1rem; }
  .empty-state p { font-size: 0.9rem; }

  /* Progress container mobile */
  .progress-container { padding: 1.5rem; margin: 1rem 0; }
  .progress-header { flex-direction: column; text-align: center; gap: 0.5rem; }
  .progress-percentage { font-size: 1.25rem; }

  /* AI Assistant mobile */
  .ai-header { padding: 1rem; }
  .ai-icon { font-size: 1.5rem; margin-right: 0.75rem; }
  .ai-title h3 { font-size: 1.1rem; }
  .ai-insights { padding: 1rem; }

  /* Budget alerts mobile */
  .alert { padding: 1rem 1rem 1rem 3rem; }
  .alert i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); font-size: 1.25rem; margin-bottom: 0; }
  .alert-content h4 { font-size: 1rem; text-align: center; }
  .alert-content p { font-size: 0.875rem; text-align: center; }

  /* Mobile sheets tables */
  .table-wrapper:not(.categories-page) .category-table { display: block; }
  .table-wrapper:not(.categories-page) .category-table thead { display: none; }
  .table-wrapper:not(.categories-page) .category-table tbody { display: block; }
  
  .table-wrapper:not(.categories-page) .category-table tr {
    display: block;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
    padding: 1rem;
    box-shadow: var(--shadow-sm);
  }
  
  .table-wrapper:not(.categories-page) .category-table td {
    display: block;
    border: none;
    padding: 0.5rem 0;
    text-align: left !important;
  }
  
  .table-wrapper:not(.categories-page) .category-table td:before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--gray-500);
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.75px;
  }
}

/* ===== DOCUMENT SCANNER ===== */
.transaction-summary {
  background: linear-gradient(135deg, var(--gray-50), var(--gray-100));
  padding: 1.5rem;
  border-radius: var(--radius-xl);
  margin-bottom: 2rem;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}

.transaction-summary p {
  margin: 0.75rem 0;
  color: var(--gray-700);
  font-size: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.transaction-summary p strong {
  color: var(--gray-800);
  font-weight: 700;
}

/* ===== BULK ADD MODAL ===== */
.bulk-add-container { max-width: 100%; }

.bulk-add-header {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-200);
}

.bulk-table-container {
  overflow-x: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  max-height: 400px;
  overflow-y: auto;
}

.bulk-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  min-width: 800px;
}

.bulk-table th {
  background: linear-gradient(135deg, var(--gray-50), var(--gray-100));
  padding: 0.75rem;
  text-align: left;
  font-weight: 700;
  color: var(--gray-700);
  border-bottom: 2px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 10;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bulk-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.bulk-table th:last-child { text-align: center; }
.bulk-table td:last-child { text-align: center; vertical-align: middle; }

.bulk-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: var(--transition);
}

.bulk-input:focus {
  border-color: var(--primary-light);
  outline: none;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.08);
}

.bulk-input:invalid {
  border-color: var(--danger);
}

.btn-remove {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border: none;
  padding: 0.5rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.btn-remove:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

#bulkAddModal .modal-content {
  max-width: 1200px;
  width: 95%;
}

#bulkAddModal .modal-body {
  max-height: calc(90vh - 200px);
}

/* Recent items modal */
.recent-items-modal {
  max-width: 1400px;
  width: 95%;
}

.recent-items-modal .modal-body {
  max-height: calc(80vh - 150px);
}

.recent-items-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  table-layout: fixed;
}

.recent-items-table th:nth-child(1), .recent-items-table td:nth-child(1) { width: 5%; }
.recent-items-table th:nth-child(2), .recent-items-table td:nth-child(2) { width: 5%; }
.recent-items-table th:nth-child(3), .recent-items-table td:nth-child(3) { width: 16%; }
.recent-items-table th:nth-child(4), .recent-items-table td:nth-child(4) { width: 10%; }
.recent-items-table th:nth-child(5), .recent-items-table td:nth-child(5) { width: 12%; }
.recent-items-table th:nth-child(6), .recent-items-table td:nth-child(6) { width: 12%; }
.recent-items-table th:nth-child(7), .recent-items-table td:nth-child(7) { width: 15%; }
.recent-items-table th:nth-child(8), .recent-items-table td:nth-child(8) { width: 15%; }

.recent-items-table th,
.recent-items-table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--gray-100);
  text-align: left;
}

.recent-items-table th {
  background: linear-gradient(135deg, var(--gray-50), var(--gray-100));
  font-weight: 700;
  color: var(--gray-700);
  position: sticky;
  top: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.recent-items-table tr:hover {
  background: var(--primary-50);
}

@media (max-width: 1200px) {
  .recent-items-modal {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  
  .recent-items-modal .modal-body { max-height: calc(100vh - 150px); }
  .recent-items-table { font-size: 0.8rem; }
  .recent-items-table th, .recent-items-table td { padding: 0.5rem 0.25rem; }
  .recent-items-container .table-wrapper { overflow-x: auto; }
  .recent-items-table { min-width: 600px; }
}

#bulkAddModal .footer-left { flex: 1; justify-content: flex-start; }
#bulkAddModal .footer-right { justify-content: flex-end; }


/* ===== COOKIES CONSENT ===== */
.cookies-banner {
  position: fixed;
  bottom: 120px;
  left: 20px;
  right: 20px;
  background: var(--gradient-primary);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-2xl);
  box-shadow: 
    0 20px 60px rgba(124, 58, 237, 0.2),
    0 8px 16px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  z-index: 9999;
  transform: translateY(calc(100% + 40px));
  transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 1200px;
  margin: 0 auto;
}

.cookies-banner.show {
  transform: translateY(0);
}

.cookies-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.5rem;
  align-items: center;
}

.cookies-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  color: white;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  animation: cookieFloat 3s ease-in-out infinite;
  backdrop-filter: blur(8px);
}

@keyframes cookieFloat {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-5px); }
}

.cookies-text h3 {
  margin: 0 0 0.5rem 0;
  color: white;
  font-size: 1.25rem;
  font-weight: 700;
}

.cookies-text p {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
  line-height: 1.5;
}

.cookies-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.cookies-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition-spring);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.025em;
}

.cookies-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.6s;
}

.cookies-btn:hover::before {
  left: 100%;
}

.cookies-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.cookies-btn-accept,
.cookies-btn-necessary,
.cookies-btn-settings {
  background: rgba(255, 255, 255, 0.95);
  color: var(--gray-800);
  border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.cookies-btn-accept:hover,
.cookies-btn-necessary:hover,
.cookies-btn-settings:hover {
  background: white;
  border-color: rgba(255, 255, 255, 0.5);
  color: var(--gray-900);
}

.cookies-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
}

.cookies-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  color: white;
}

.cookies-modal-footer .cookies-btn-accept {
  background: rgba(255, 255, 255, 0.9);
  color: var(--primary);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.cookies-modal-footer .cookies-btn-accept:hover {
  background: white;
  color: var(--primary-dark);
  border-color: white;
}

/* Cookies Modal */
.cookies-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10002;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cookies-modal.show {
  opacity: 1;
  visibility: visible;
}

.cookies-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(12px) saturate(150%);
}

.cookies-modal-content {
  position: relative;
  background: linear-gradient(135deg, #1e293b, #334155, #475569);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.8) translateY(40px);
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}

.cookies-modal.show .cookies-modal-content {
  transform: scale(1) translateY(0);
}

.cookies-modal-header {
  background: var(--gradient-primary);
  color: white;
  padding: 2rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.cookies-modal-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.05) 50%, transparent 70%);
  pointer-events: none;
}

.cookies-modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: white;
}

.cookies-modal-close {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.75rem;
  border-radius: var(--radius-lg);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-spring);
  backdrop-filter: blur(10px);
}

.cookies-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: scale(1.1) rotate(90deg);
}

.cookies-modal-body {
  padding: 2.5rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 58, 237, 0.3) transparent;
  color: white;
  flex: 1;
}

.cookies-modal-body::-webkit-scrollbar { width: 6px; }
.cookies-modal-body::-webkit-scrollbar-track { background: transparent; }
.cookies-modal-body::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.3), rgba(109, 40, 217, 0.4));
  border-radius: 10px;
}
.cookies-modal-body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.5), rgba(109, 40, 217, 0.6));
}

.cookies-category {
  margin-bottom: 1.5rem;
  background: linear-gradient(145deg, rgba(51, 65, 85, 0.8), rgba(71, 85, 99, 0.9));
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-xl);
  overflow: hidden;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: var(--transition);
}

.cookies-category:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  border-color: rgba(124, 58, 237, 0.3);
}

.cookies-category-header {
  background: linear-gradient(145deg, rgba(71, 85, 99, 0.9), rgba(100, 116, 139, 0.95));
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.cookies-category-info h4 {
  margin: 0 0 0.5rem 0;
  color: white;
  font-size: 1.125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cookies-category-info p {
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.9rem;
  line-height: 1.5;
}

.cookies-toggle {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.cookies-toggle input[type="checkbox"] {
  display: none;
}

.toggle-label {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 30px;
  cursor: pointer;
}

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--gray-300);
  border-radius: var(--radius-full);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 24px;
  width: 24px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: var(--radius-full);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

input:checked + .toggle-label .toggle-slider {
  background: var(--gradient-success);
}

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

input:disabled + .toggle-label {
  opacity: 0.6;
  cursor: not-allowed;
}

input:disabled + .toggle-label .toggle-slider {
  background: var(--gray-400);
}

.cookies-details {
  padding: 1.5rem;
  background: linear-gradient(145deg, rgba(51, 65, 85, 0.7), rgba(71, 85, 99, 0.8));
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.cookies-details ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.cookies-details li {
  padding: 0.5rem 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.cookies-details li:before {
  content: "•";
  color: var(--primary-light);
  font-weight: bold;
  flex-shrink: 0;
}

.cookies-details strong {
  color: white;
  font-weight: 600;
}

.cookies-info-section {
  background: linear-gradient(135deg, rgba(71, 85, 99, 0.9), rgba(100, 116, 139, 0.95));
  padding: 2rem;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(148, 163, 184, 0.3);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.cookies-info-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--gradient-cool);
  background-size: 200% 100%;
  animation: gradientMove 3s ease-in-out infinite;
}

@keyframes gradientMove {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.cookies-info-section h4 {
  margin: 0 0 1rem 0;
  color: white;
  font-size: 1.125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cookies-info-section p {
  margin: 0;
  color: rgba(255, 255, 255, 0.95);
  font-size: 0.9rem;
  line-height: 1.6;
}

.cookies-info-section a {
  color: var(--primary-light);
  text-decoration: none;
  font-weight: 600;
}

.cookies-info-section a:hover {
  color: var(--primary-200);
  text-decoration: underline;
}

.cookies-modal-footer {
  background: var(--gradient-primary);
  padding: 2rem 2.5rem;
  border-top: none;
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  backdrop-filter: blur(10px);
}

/* Cookies responsive */
@media (max-width: 1200px) {
  .cookies-banner {
    bottom: 100px;
    left: 10px;
    right: 10px;
    border-radius: var(--radius-xl);
  }
  
  .cookies-modal { padding: 20px 10px 120px 10px; }
  
  .cookies-content {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    text-align: center;
    padding: 2rem 1.5rem;
  }

  .cookies-icon { width: 50px; height: 50px; font-size: 1.25rem; margin: 0 auto; }
  .cookies-actions { justify-content: center; gap: 0.5rem; }
  .cookies-btn { padding: 0.75rem 1rem; font-size: 0.8rem; }
  .cookies-modal-content { width: 95%; max-height: 95vh; }
  .cookies-modal-header { padding: 1rem 1.5rem; }
  .cookies-modal-header h2 { font-size: 1.25rem; }
  .cookies-modal-body { padding: 1.5rem; max-height: 70vh; }
  .cookies-category-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .cookies-toggle { align-self: flex-end; }
  .cookies-modal-footer { padding: 1rem 1.5rem; flex-direction: column; }
  .cookies-btn { justify-content: center; }
}

@media (max-width: 480px) {
  .cookies-banner { bottom: 95px; left: 8px; right: 8px; }
  .cookies-modal { padding: 60px 8px 60px 8px; }
  .cookies-content { padding: 1.5rem 1rem; }
  .cookies-text h3 { font-size: 1.125rem; }
  .cookies-text p { font-size: 0.875rem; }
  .cookies-actions { flex-direction: column; gap: 0.75rem; }
  .cookies-btn { width: 100%; justify-content: center; padding: 14px 20px; }
  .cookies-modal-content { margin: 0; max-height: 75vh; width: calc(100% - 16px); }
  .cookies-modal-header { padding: 1.5rem; }
  .cookies-modal-body { padding: 1.5rem; max-height: 60vh; }
  .cookies-category-header { padding: 1.5rem; }
  .cookies-details { padding: 1.5rem; }
  .cookies-info-section { padding: 1.5rem; }
  .cookies-modal-footer { padding: 1.5rem; flex-direction: column; }
}


/* ===== DEMO BANNER ===== */
.demo-banner {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  padding: 0.75rem 0;
  text-align: center;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
  position: relative;
  z-index: 999;
}

.demo-banner-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0 1rem;
}

.demo-banner i { font-size: 1.25rem; flex-shrink: 0; }

.demo-text {
  font-weight: 600;
  font-size: 0.9rem;
  flex: 1;
  text-align: center;
}

.demo-signup-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.875rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  flex-shrink: 0;
}

.demo-signup-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  color: white;
  transform: translateY(-2px);
}

@media (max-width: 768px) {
  .demo-banner-content { flex-direction: column; gap: 0.75rem; padding: 0 1rem; }
  .demo-text { font-size: 0.85rem; line-height: 1.4; }
  .demo-signup-btn { padding: 0.6rem 1.2rem; font-size: 0.8rem; }
}

@media (max-width: 480px) {
  .demo-banner { padding: 1rem 0; }
  .demo-banner-content { gap: 1rem; }
  .demo-text { font-size: 0.8rem; }
  .demo-signup-btn { width: 100%; justify-content: center; max-width: 200px; }
}

.demo-readonly { opacity: 0.7; pointer-events: none; cursor: not-allowed; }

.demo-nav-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  border: none;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.demo-nav-btn:hover {
  background: linear-gradient(135deg, #d97706, #b45309);
  transform: translateY(-2px);
  color: white;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

@media (max-width: 1200px) {
  .demo-nav-btn:not(.desktop) {
    width: 100%;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    border-radius: 0;
    justify-content: flex-start;
    font-size: 1rem;
    margin: 0;
  }
  .demo-nav-btn.desktop { display: none; }
}

@media (min-width: 1200px) {
  .demo-nav-btn:not(.desktop) { display: none; }
}

/* ===== EXTENDED DARK MODE ===== */
body.dark-mode .toast { background: unset; border-color: unset; color: unset; }
body.dark-mode .toast.info { background: linear-gradient(135deg, #dbeafe, #eff6ff); border-left: 4px solid #3b82f6; color: #1e40af; }
body.dark-mode .toast.success { background: linear-gradient(135deg, #dcfce7, #f0fdf4); border-left: 4px solid var(--success); color: #166534; }
body.dark-mode .toast.warning { background: linear-gradient(135deg, #fef3c7, #fffbeb); border-left: 4px solid var(--warning); color: #92400e; }
body.dark-mode .toast.error { background: linear-gradient(135deg, #fee2e2, #fef2f2); border-left: 4px solid var(--danger); color: #991b1b; }

/* Dark mode for Financial News */
body.dark-mode .news-card {
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.95), rgba(51, 65, 85, 0.98));
  border-color: #475569;
  color: #f8fafc;
}
body.dark-mode .news-title-text { color: #f8fafc; }
body.dark-mode .news-meta { color: #94a3b8; }
body.dark-mode .news-source { color: var(--primary-light); }
body.dark-mode .news-category-badge {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(139, 92, 246, 0.25));
  color: var(--primary-light);
}
body.dark-mode .news-link { color: var(--primary-light); }
body.dark-mode .news-card-link:hover .news-link { color: var(--primary-200); }

/* Dark mode for AI Assistant */
body.dark-mode .ai-assistant-widget { background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%); }
body.dark-mode .ai-content { background: #1e293b; }
body.dark-mode .ai-card { background: #334155; color: #f8fafc; }
body.dark-mode .ai-card:hover { background: #475569; }
body.dark-mode .ai-card-title { color: #f8fafc; }
body.dark-mode .ai-card-message { color: #cbd5e1; }
body.dark-mode .ai-confidence { background: #475569; color: #cbd5e1; }
body.dark-mode .ai-empty { color: #94a3b8; }
body.dark-mode .ai-loading { color: #cbd5e1; }
body.dark-mode .privacy-section { background: linear-gradient(135deg, #059669, #047857); }
body.dark-mode .privacy-details h4 { color: #f8fafc; }
body.dark-mode .privacy-details li { color: #cbd5e1; }
body.dark-mode .privacy-guarantee { background: #334155; border-left-color: #10b981; }
body.dark-mode .privacy-guarantee p { color: #cbd5e1; }

/* Dark mode cards */
body.dark-mode .feature-card,
body.dark-mode .welcome-card,
body.dark-mode .auth-card {
  background: #1e293b;
  color: #f8fafc;
}
body.dark-mode .summary-card { background: #1e293b; }
body.dark-mode .card-header { background: #334155; border-color: #475569; }
body.dark-mode .card-header h3 { color: #f8fafc; }
body.dark-mode .metric .label { color: #cbd5e1; }
body.dark-mode .metric .value { color: #f8fafc; }
body.dark-mode .progress-container { background: #1e293b; }
body.dark-mode .progress-info h4 { color: #f8fafc; }
body.dark-mode .progress-info p { color: #cbd5e1; }
body.dark-mode .alert { background: #334155; border-color: #475569; color: #f8fafc; }
body.dark-mode .alert-content h4 { color: #f8fafc; }
body.dark-mode .alert-content p { color: #cbd5e1; }

/* Desktop header actions */
@media (min-width: 1200px) {
  .mobile-header-row { display: contents; }
  .header-actions { flex-direction: row; flex-wrap: wrap; }
  .header-actions .btn { width: auto; }
}

/* Dark mode mobile table */
body.dark-mode .category-table tr { background: #1e293b; border-color: #334155; }
body.dark-mode .category-table tr:hover { background: #334155; }
body.dark-mode .category-row { background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), #1e293b) !important; border-left-color: var(--primary) !important; }
body.dark-mode .category-row:hover { background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), #334155) !important; }
body.dark-mode .subcategory-row { background: #1e293b !important; border-left-color: #475569 !important; }
body.dark-mode .subcategory-add-row { background: #334155 !important; border-left-color: var(--success) !important; }
body.dark-mode .category-add-row { background: var(--gradient-success) !important; }
body.dark-mode .category-table td:before { color: #94a3b8; }
body.dark-mode .category-add-row td:before { color: rgba(255, 255, 255, 0.8) !important; }

@media (max-width: 1200px) {
  body.dark-mode .table-wrapper .category-table tr { background: #1e293b; }
  body.dark-mode .table-wrapper .category-table tr:hover { background: #334155; }
}

/* Dark mode news cards borders */
body.dark-mode .news-card.banking { border-left: 4px solid #10b981; }
body.dark-mode .news-card.markets { border-left: 4px solid var(--primary); }
body.dark-mode .news-card.economy { border-left: 4px solid #f59e0b; }
body.dark-mode .news-card.crypto { border-left: 4px solid #f97316; }
body.dark-mode .news-card.general { border-left: 4px solid #8b5cf6; }

/* Dark mode AI cards */
body.dark-mode .ai-card.warning { border-left-color: var(--warning); background: rgba(245, 158, 11, 0.15); }
body.dark-mode .ai-card.danger { border-left-color: var(--danger); background: rgba(239, 68, 68, 0.15); }
body.dark-mode .ai-card.success { border-left-color: var(--success); background: rgba(34, 197, 94, 0.15); }

/* Dark mode progress bar */
body.dark-mode .progress-fill { background: var(--gradient-cool); }

/* Dark mode alerts */
body.dark-mode .alert-danger { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.25); color: #fca5a5; }
body.dark-mode .alert-warning { background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.25); color: #fcd34d; }
body.dark-mode .alert-success { background: rgba(34, 197, 94, 0.12); border: 1px solid rgba(34, 197, 94, 0.25); color: #86efac; }

/* Dark mode category badges */
body.dark-mode .news-category-badge {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.3), rgba(139, 92, 246, 0.4));
  color: var(--primary-200);
  border: 1px solid rgba(124, 58, 237, 0.4);
}

/* ===== DASHBOARD CARDS ===== */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.summary-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.summary-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  color: white;
}

.balance-card .card-icon,
.main-balance-card .card-icon { background: var(--gradient-primary); }
.income-card .card-icon { background: var(--gradient-success); }
.outcome-card .card-icon { background: var(--gradient-warm); }
.savings-card .card-icon { background: var(--gradient-accent); }
.stats-card .card-icon { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.total-card .card-icon { background: linear-gradient(135deg, #f59e0b, #d97706); }
.change-card .card-icon { background: linear-gradient(135deg, #06b6d4, #0891b2); }

.card-content h3 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}

.card-content p {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin: 0;
  font-weight: 500;
}

.card-detail {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 0.25rem;
  display: block;
}

/* ===== PAGE HEADER ===== */
.page-header {
  margin-bottom: 2rem;
}

/* Old structure — kept for backward compat (sheets, scanner etc.) */
.page-header > .header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.header-info h1 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.75rem;
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* ===== NEW HEADER STRUCTURE (dashboard, balance, categories, budget-select) ===== */
.page-header:has(> .header-title) {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-header .title-icon {
  width: 48px;
  height: 48px;
  min-width: 48px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  backdrop-filter: blur(10px);
  color: white;
}

.page-header .title-content h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  color: white;
}

.page-header .title-content p {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.85);
}

/* ===== DASHBOARD SECTIONS ===== */
.dashboard-sections {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.alerts-section,
.transactions-section,
.goals-section {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.section-header h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 1.125rem;
  color: var(--gray-800);
}

.section-header h3 i {
  color: var(--primary);
}

/* Settings pages have their own section-header layout - don't override */
.security-settings-page .section-header,
.profile-settings-page .section-header,
.preferences-settings-page .section-header,
.change-password-page .section-header,
.data-export-page .section-header,
.setup-2fa-page .section-header,
.disable-2fa-page .section-header,
.backup-codes-page .section-header,
.subscription-settings-page .section-header {
  display: revert;
  justify-content: revert;
  align-items: revert;
  margin-bottom: revert;
}

/* Alert cards */
.alerts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

.alert-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-100);
  transition: var(--transition);
}

.alert-card:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-sm);
}

.alert-card.warning { border-left: 3px solid var(--warning); background: linear-gradient(135deg, #fffbeb, transparent); }
.alert-card.danger { border-left: 3px solid var(--danger); background: linear-gradient(135deg, #fef2f2, transparent); }
.alert-card.success { border-left: 3px solid var(--success); background: linear-gradient(135deg, #f0fdf4, transparent); }
.alert-card.info { border-left: 3px solid var(--info); background: linear-gradient(135deg, #eff6ff, transparent); }

.alert-icon { font-size: 1.25rem; flex-shrink: 0; margin-top: 0.125rem; }
.alert-card.warning .alert-icon { color: var(--warning); }
.alert-card.danger .alert-icon { color: var(--danger); }
.alert-card.success .alert-icon { color: var(--success); }
.alert-card.info .alert-icon { color: var(--info); }

.alert-card h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.25rem; color: var(--gray-800); }
.alert-card p { font-size: 0.8rem; color: var(--gray-600); margin: 0; }
.alert-action { font-size: 0.75rem; color: var(--primary); font-weight: 600; cursor: pointer; }

/* ===== MICRO-INTERACTIONS ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.dashboard-cards .summary-card {
  animation: fadeInUp 0.5s ease-out both;
}

.dashboard-cards .summary-card:nth-child(1) { animation-delay: 0.05s; }
.dashboard-cards .summary-card:nth-child(2) { animation-delay: 0.1s; }
.dashboard-cards .summary-card:nth-child(3) { animation-delay: 0.15s; }
.dashboard-cards .summary-card:nth-child(4) { animation-delay: 0.2s; }

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* ===== SELECTION ===== */
::selection {
  background: rgba(124, 58, 237, 0.15);
  color: var(--primary-dark);
}

/* ===== FOCUS VISIBLE ===== */
:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ===== PRINT STYLES ===== */
@media print {
  .header, .footer, .navbar-toggle, .toast-container { display: none !important; }
  .content { padding: 0; max-width: 100%; }
  body { background: white; }
}

/* ===== HOME PAGE - HERO ===== */
.hero-section {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--gradient-primary);
  color: white;
  border-radius: var(--radius-2xl);
  margin-bottom: 3rem;
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 500px;
  height: 500px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
  pointer-events: none;
}

.hero-section::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 350px;
  height: 350px;
  background: rgba(255,255,255,0.03);
  border-radius: 50%;
  pointer-events: none;
}

.hero-section h1 {
  font-weight: 800;
  color: white;
  position: relative;
  z-index: 1;
  font-size: 2.5rem;
  letter-spacing: -0.03em;
}

.hero-icon {
  font-size: 4rem;
  margin-bottom: 1.5rem;
  opacity: 0.9;
  position: relative;
  z-index: 1;
  animation: heroFloat 3s ease-in-out infinite;
}

@keyframes heroFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.hero-subtitle {
  font-size: 1.25rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  line-height: 1.6;
}

/* ===== HOME PAGE - FEATURES GRID ===== */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-bottom: 3rem;
}

.feature-card {
  background: var(--white);
  padding: 2.5rem 2rem;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  text-align: center;
  transition: var(--transition);
  border: 1px solid var(--gray-100);
  position: relative;
  overflow: hidden;
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-cool);
  opacity: 0;
  transition: var(--transition);
}

.feature-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
}

.feature-card:hover::before {
  opacity: 1;
}

.feature-icon {
  font-size: 2.5rem;
  margin-bottom: 1.25rem;
  color: var(--primary);
}

/* Only apply gradient to feature icons that contain Font Awesome icons */
.features-grid .feature-icon i {
  background: var(--gradient-cool);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.feature-card h3 {
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
}

.feature-card p {
  color: var(--gray-500);
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0;
}

/* ===== HOME PAGE - WELCOME & AUTH CARDS ===== */
.welcome-card, .auth-card {
  background: var(--white);
  padding: 2.5rem;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid var(--gray-100);
  margin-top: 2rem;
}

.auth-card p {
  margin-bottom: 2rem;
  color: var(--gray-600);
}

.welcome-content {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  text-align: left;
}

.welcome-avatar {
  font-size: 3rem;
  color: var(--primary);
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-50);
  flex-shrink: 0;
}

.welcome-avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-full);
}

.quick-actions, .auth-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== HOME PAGE - GUIDE BANNER ===== */
.guide-info-banner {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.06), rgba(6, 182, 212, 0.04));
  border: 1.5px solid rgba(124, 58, 237, 0.15);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  margin-bottom: 2.5rem;
  transition: var(--transition);
}

.guide-info-banner:hover {
  border-color: rgba(124, 58, 237, 0.3);
  box-shadow: var(--shadow-glow);
}

.guide-info-content {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.guide-info-icon {
  font-size: 2.5rem;
  color: var(--primary);
  flex-shrink: 0;
}

.guide-info-text {
  flex: 1;
}

.guide-info-text h3 {
  margin: 0 0 0.5rem 0;
  color: var(--gray-800);
  font-size: 1.2rem;
}

.guide-info-text p {
  margin: 0;
  color: var(--gray-600);
  line-height: 1.5;
}

.guide-info-btn {
  background: var(--gradient-primary);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  text-decoration: none;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.guide-info-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.3);
  color: white;
}

@media (max-width: 1200px) {
  .guide-info-content {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }
  .guide-info-btn {
    align-self: center;
  }
  .welcome-content {
    flex-direction: column;
    text-align: center;
  }
  .quick-actions, .auth-actions {
    flex-direction: column;
  }
}

/* ===== HOME PAGE - FINANCIAL NEWS ===== */
.financial-news-section {
  margin: 3rem 0;
  position: relative;
}

.news-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.news-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.news-icon {
  font-size: 2rem;
  background: var(--gradient-cool);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.news-subtitle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--gray-500);
  font-size: 0.9rem;
}

.news-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

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

.news-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.news-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  position: relative;
  overflow: hidden;
  transition: var(--transition-spring);
  cursor: pointer;
  box-shadow: var(--shadow);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.news-card-link:hover .news-card,
.news-card:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: var(--shadow-lg);
}

.news-card.banking { border-left: 4px solid #10b981; }
.news-card.markets { border-left: 4px solid var(--primary); }
.news-card.economy { border-left: 4px solid #f59e0b; }
.news-card.crypto { border-left: 4px solid #f97316; }
.news-card.general { border-left: 4px solid #8b5cf6; }

.news-category-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.08), rgba(6, 182, 212, 0.06));
  color: var(--primary);
  padding: 0.4rem 0.875rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.news-content {
  margin-bottom: 1rem;
  flex-grow: 1;
}

.news-title-text {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 0.75rem;
  color: var(--gray-800);
}

.news-meta {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  color: var(--gray-500);
  font-size: 0.8rem;
}

.news-date, .news-source {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.news-source {
  color: var(--primary);
  font-weight: 600;
}

.news-actions {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-100);
}

.news-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.85rem;
  transition: var(--transition);
}

.news-card-link:hover .news-link {
  color: var(--primary-dark);
  transform: translateX(4px);
}

.news-glow {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(45deg, transparent 30%, rgba(124, 58, 237, 0.03) 50%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.news-card-link:hover .news-glow,
.news-card:hover .news-glow {
  opacity: 1;
}

.news-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--gray-400);
}

.news-placeholder i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
  animation: pulse 2s infinite;
}

@media (max-width: 1200px) {
  .news-title {
    flex-direction: column;
    gap: 0.5rem;
  }
  .news-icon { font-size: 1.5rem; }
}

/* ===== AUTH PAGES (Login/Signup) ===== */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 200px);
  padding: 2rem 1rem;
}

.auth-card {
  background: var(--white);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  padding: 3rem;
  width: 100%;
  max-width: 460px;
  border: 1px solid var(--gray-100);
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-cool);
}

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.auth-icon {
  width: 72px;
  height: 72px;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  font-size: 1.75rem;
  color: white;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.25);
}

.auth-header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.auth-header p {
  color: var(--gray-500);
  font-size: 0.9rem;
}

.security-notice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.06), rgba(16, 185, 129, 0.02));
  border: 1px solid rgba(16, 185, 129, 0.15);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.8rem;
  color: #059669;
  font-weight: 500;
}

.auth-form .form-group {
  margin-bottom: 1.25rem;
}

.auth-form .form-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.form-input {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  transition: var(--transition);
  background: var(--white);
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.08);
}

.password-input-wrapper {
  position: relative;
}

.password-toggle {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 0.25rem;
  transition: var(--transition-fast);
}

.password-toggle:hover {
  color: var(--primary);
}

.form-error {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 0.5rem;
  font-weight: 500;
}

.checkbox-group {
  margin: 1rem 0;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--gray-700);
}

.btn-submit {
  width: 100%;
  padding: 1rem;
  background: var(--gradient-primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.25);
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.35);
}

.rate-limit-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  color: var(--gray-400);
  font-size: 0.75rem;
}

.forgot-password {
  text-align: center;
  margin-top: 1.25rem;
}

.forgot-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  transition: var(--transition-fast);
}

.forgot-link:hover {
  color: var(--primary-dark);
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 1.5rem 0;
  color: var(--gray-400);
  font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

.auth-divider span {
  padding: 0 1rem;
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--gray-100);
}

.auth-footer p {
  color: var(--gray-500);
  font-size: 0.875rem;
}

.auth-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition-fast);
}

.auth-link:hover {
  color: var(--primary-dark);
}

/* ===== BALANCE PAGE ===== */
.balance-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.accounts-section {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
}

.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.account-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  transition: var(--transition);
  position: relative;
}

.account-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.account-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.account-info h4 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.account-type {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
  background: var(--primary-50);
  color: var(--primary);
}

.account-balance {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}

.account-details {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-100);
}

.detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.375rem 0;
  font-size: 0.85rem;
  color: var(--gray-600);
}

.detail-label { font-weight: 500; }
.detail-value { font-weight: 700; color: var(--gray-800); }

.sync-status {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.sync-status.active {
  color: var(--success);
}

/* Goals in balance */
.goals-section h5 {
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-bottom: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.goal-item {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: 1px solid var(--gray-100);
}

.goal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.goal-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--gray-800);
}

.goal-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.goal-progress-text {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
}

.edit-goal-btn, .delete-goal-btn {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.7rem;
  transition: var(--transition-fast);
}

.edit-goal-btn {
  background: var(--primary-50);
  color: var(--primary);
}

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

.delete-goal-btn {
  background: rgba(239, 68, 68, 0.08);
  color: var(--danger);
}

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

.goal-progress {
  height: 6px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 0.375rem;
}

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

.goal-values {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: 500;
}

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

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-700);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.action-btn:hover {
  border-color: var(--primary-light);
  color: var(--primary);
  background: var(--primary-50);
}

.action-btn.edit-btn:hover {
  border-color: var(--primary-light);
  color: var(--primary);
}

.action-btn.delete-btn:hover {
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
  background: rgba(239, 68, 68, 0.05);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-icon {
  font-size: 4rem;
  color: var(--gray-300);
  margin-bottom: 1.5rem;
}

.empty-state h3 {
  color: var(--gray-700);
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--gray-500);
  margin-bottom: 1.5rem;
}

/* ===== SHEETS PAGE - AI ASSISTANT ===== */
.ai-assistant-widget {
  background: var(--gradient-cool);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin: 2rem 0;
  box-shadow: 0 8px 32px rgba(124, 58, 237, 0.15);
}

.ai-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
}

.ai-icon {
  font-size: 1.75rem;
  margin-right: 0.75rem;
}

.ai-title h3 {
  margin: 0;
  font-size: 1.1rem;
  color: white;
}

.ai-content {
  background: var(--white);
  padding: 1.5rem;
}

.ai-card {
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--gray-100);
  margin-bottom: 0.75rem;
  transition: var(--transition);
  border-left: 3px solid var(--gray-300);
}

.ai-card:hover {
  background: var(--gray-50);
  transform: translateX(4px);
}

.ai-card.warning { border-left-color: var(--warning); }
.ai-card.danger { border-left-color: var(--danger); }
.ai-card.success { border-left-color: var(--success); }
.ai-card.info { border-left-color: var(--info); }

.ai-card-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  color: var(--gray-800);
}

.ai-card-message {
  font-size: 0.8rem;
  color: var(--gray-600);
  line-height: 1.5;
}

.ai-confidence {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--gray-100);
  color: var(--gray-600);
  margin-top: 0.5rem;
}

.ai-empty, .ai-loading {
  text-align: center;
  padding: 2rem;
  color: var(--gray-400);
  font-size: 0.9rem;
}

/* ===== TRANSACTIONS LIST (Dashboard) ===== */
.transactions-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.transaction-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--gray-100);
  transition: var(--transition-fast);
}

.transaction-item:hover {
  background: var(--gray-50);
  transform: translateX(4px);
}

.transaction-info h4 {
  font-size: 0.9rem;
  margin: 0 0 0.125rem;
  font-weight: 600;
}

.transaction-info p {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin: 0;
}

.transaction-date {
  font-size: 0.7rem;
  color: var(--gray-400);
}

.transaction-amount {
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

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

/* ===== GOALS GRID (Dashboard) ===== */
.goals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.goal-card {
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-100);
  transition: var(--transition);
}

.goal-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-sm);
}

.goal-card .goal-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.goal-icon {
  font-size: 1.25rem;
}

.goal-card .goal-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.875rem;
}

.goal-percentage {
  font-weight: 800;
  font-size: 0.875rem;
  color: var(--primary);
}

/* ===== QUICK ACTIONS (Dashboard) ===== */
.quick-actions-section {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.quick-action-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--gray-100);
  text-decoration: none;
  color: var(--gray-700);
  transition: var(--transition);
}

.quick-action-card:hover {
  border-color: var(--primary-light);
  background: var(--primary-50);
  color: var(--primary);
  transform: translateY(-2px);
}

.quick-action-card i {
  font-size: 1.5rem;
  color: var(--primary);
}

.quick-action-card span {
  font-weight: 600;
  font-size: 0.875rem;
}

/* ===== LAST UPDATE TEXT ===== */
.last-update {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

/* ===== PRIVACY SECTION ===== */
.privacy-section {
  background: var(--gradient-success);
  border-radius: var(--radius-xl);
  padding: 2rem;
  color: white;
  margin: 2rem 0;
}

.privacy-details h4 { color: white; }
.privacy-details li { color: rgba(255,255,255,0.9); }

.privacy-guarantee {
  background: rgba(255,255,255,0.1);
  border-left: 3px solid rgba(255,255,255,0.5);
  padding: 1rem;
  border-radius: var(--radius);
  margin-top: 1rem;
}

.privacy-guarantee p { color: rgba(255,255,255,0.9); margin: 0; }

/* ===== AURORA ANIMATED GRADIENT (Hero) ===== */
.hero-section {
  background: linear-gradient(-45deg, #7c3aed, #06b6d4, #8b5cf6, #0891b2, #6d28d9);
  background-size: 400% 400%;
  animation: aurora 12s ease infinite;
}

@keyframes aurora {
  0% { background-position: 0% 50%; }
  25% { background-position: 50% 100%; }
  50% { background-position: 100% 50%; }
  75% { background-position: 50% 0%; }
  100% { background-position: 0% 50%; }
}

/* ===== GRADIENT TEXT on key headings ===== */
.hero-section h1 {
  background: linear-gradient(135deg, #ffffff, rgba(255,255,255,0.85));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-section .hero-icon {
  -webkit-text-fill-color: rgba(255,255,255,0.9);
}

/* Don't apply gradient text to icon elements or cards with icons */
.feature-icon,
.nav-icon,
.feature-card i {
  -webkit-text-fill-color: initial;
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
}

/* ===== CARD TILT 3D EFFECT ===== */
.feature-card,
.summary-card,
.news-card,
.account-card,
.goal-card {
  transform-style: preserve-3d;
  perspective: 1000px;
}

.feature-card:hover {
  transform: translateY(-6px) rotateX(2deg) rotateY(-1deg);
}

.summary-card:hover {
  transform: translateY(-4px) rotateX(1.5deg) rotateY(-1deg);
}

.news-card-link:hover .news-card,
.news-card:hover {
  transform: translateY(-6px) rotateX(2deg) rotateY(-1.5deg) scale(1.01);
}

.account-card:hover {
  transform: translateY(-3px) rotateX(1deg) rotateY(-0.5deg);
}

/* ===== SCROLL-TRIGGERED ANIMATIONS ===== */
.scroll-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

.scroll-reveal-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-reveal-left.revealed {
  opacity: 1;
  transform: translateX(0);
}

.scroll-reveal-right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.scroll-reveal-right.revealed {
  opacity: 1;
  transform: translateX(0);
}

/* Stagger delays for grid items */
.scroll-reveal:nth-child(1) { transition-delay: 0.05s; }
.scroll-reveal:nth-child(2) { transition-delay: 0.1s; }
.scroll-reveal:nth-child(3) { transition-delay: 0.15s; }
.scroll-reveal:nth-child(4) { transition-delay: 0.2s; }
.scroll-reveal:nth-child(5) { transition-delay: 0.25s; }
.scroll-reveal:nth-child(6) { transition-delay: 0.3s; }

/* ===== SKELETON LOADING ===== */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--gray-100);
  border-radius: var(--radius);
}

.skeleton::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255, 255, 255, 0.6), 
    transparent
  );
  animation: skeletonShimmer 1.5s infinite;
}

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

.skeleton-card {
  height: 120px;
  border-radius: var(--radius-xl);
  margin-bottom: 1rem;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 0.75rem;
  border-radius: var(--radius-full);
}

.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }
.skeleton-text.long { width: 95%; }

.skeleton-circle {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
}

/* ===== TABLE ROW HOVER ACCENT ===== */
.category-table tr {
  position: relative;
  transition: var(--transition);
}

.category-table tr::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  opacity: 0;
  transition: var(--transition);
}

.category-table tr:hover::before {
  opacity: 1;
}

.category-row:hover,
.subcategory-row:hover {
  background: linear-gradient(90deg, var(--primary-50), transparent) !important;
}

/* ===== FLOATING ACTION BUTTON (Mobile) ===== */
.fab-container {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 900;
  display: none;
}

@media (max-width: 1200px) {
  .fab-container {
    display: block;
  }
}

.fab-button {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  color: white;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.35);
  transition: var(--transition-spring);
  position: relative;
}

.fab-button:hover {
  transform: scale(1.1);
  box-shadow: 0 12px 32px rgba(124, 58, 237, 0.45);
}

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

.fab-button::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: var(--radius-full);
  background: var(--gradient-cool);
  opacity: 0;
  z-index: -1;
  transition: var(--transition);
  filter: blur(8px);
}

.fab-button:hover::before {
  opacity: 0.5;
}

/* FAB pulse animation */
.fab-button::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  animation: fabPulse 2s ease-in-out infinite;
  z-index: -1;
}

@keyframes fabPulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.3); opacity: 0; }
}

/* ===== ANIMATED COUNTERS ===== */
.counter-animate {
  display: inline-block;
  transition: var(--transition);
}

.counter-animate.counting {
  animation: counterPop 0.3s ease-out;
}

@keyframes counterPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* ===== SMOOTH PAGE TRANSITIONS ===== */
.content {
  animation: pageEnter 0.4s ease-out;
}

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

/* ===== BETTER EMPTY STATES ===== */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  position: relative;
}

.empty-state::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.05) 0%, transparent 70%);
  border-radius: var(--radius-full);
  pointer-events: none;
}

.empty-icon {
  font-size: 4rem;
  color: var(--primary);
  margin-bottom: 1.5rem;
  animation: emptyFloat 3s ease-in-out infinite;
  position: relative;
  z-index: 1;
}

.empty-icon i {
  background: var(--gradient-cool);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@keyframes emptyFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-5px) rotate(-2deg); }
  75% { transform: translateY(-5px) rotate(2deg); }
}

.empty-state h3 {
  color: var(--gray-700);
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
  position: relative;
  z-index: 1;
}

.empty-state p {
  color: var(--gray-500);
  margin-bottom: 1.5rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
  z-index: 1;
}

/* ===== ENHANCED BUTTON INTERACTIONS ===== */
.btn:active, .add-button:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.15);
}

/* Ripple effect on buttons */
.btn-ripple {
  position: relative;
  overflow: hidden;
}

.btn-ripple::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-full);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s, opacity 0.6s;
  opacity: 0;
}

.btn-ripple:active::after {
  width: 300px;
  height: 300px;
  opacity: 1;
  transition: 0s;
}

/* ===== ENHANCED MODAL BACKDROP ===== */
.modal.active,
.modal-overlay {
  background: radial-gradient(ellipse at center, rgba(15, 23, 42, 0.4), rgba(15, 23, 42, 0.7));
}

/* ===== NOTIFICATION BADGE PULSE ===== */
.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 10px;
  height: 10px;
  background: var(--danger);
  border-radius: var(--radius-full);
  border: 2px solid var(--white);
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ===== ENHANCED FOCUS STATES ===== */
.btn:focus-visible,
.action-button:focus-visible,
.action-btn:focus-visible {
  outline: 2px solid var(--primary-light);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
}

/* ===== SMOOTH SCROLLBAR ===== */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--primary-light) transparent;
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .hero-section {
    animation: none;
    background-size: 100% 100%;
  }
  
  .scroll-reveal,
  .scroll-reveal-left,
  .scroll-reveal-right {
    opacity: 1;
    transform: none;
  }
}

/* ===== AUTH CARD CENTERING FIX ===== */
.auth-card h2,
.auth-card p,
.auth-actions {
  text-align: center;
}

.auth-actions {
  justify-content: center;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ===== MODAL SCROLL OVERFLOW FIX ===== */
.modal-content {
  overflow: hidden;
  border-radius: var(--radius-2xl);
}

.modal-body {
  overflow-y: auto;
  border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
}

/* Ensure scrollbar stays within rounded corners */
.modal-content,
.cookies-modal-content,
.upgrade-modal-content {
  isolation: isolate;
}

/* ===== PAGE HEADER - only for budget pages (dashboard, sheets, categories, balance) ===== */

/* Header action buttons - glassmorphic style on colored headers */
.page-header .header-actions .btn {
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.25);
  color: white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-radius: var(--radius-full);
  padding: 0.625rem 1.25rem;
  font-weight: 600;
}

.page-header .header-actions .btn:hover {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.page-header .header-actions .btn::before {
  display: none;
}

/* ===== AUTH CARD FULL CENTER FIX ===== */
.auth-card {
  margin: 0 auto;
  text-align: center;
}

.auth-actions {
  justify-content: center;
}

/* ===== FIX: Dashboard card icons - show FA icons properly ===== */

/* ===== FIX: Scroll reveal - show immediately, animate only on first view ===== */
.scroll-reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.scroll-reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Reduce delay and distance for faster appearance */
.scroll-reveal:nth-child(1) { transition-delay: 0s; }
.scroll-reveal:nth-child(2) { transition-delay: 0.05s; }
.scroll-reveal:nth-child(3) { transition-delay: 0.1s; }
.scroll-reveal:nth-child(4) { transition-delay: 0.15s; }

/* ===== FIX: Modal close button (X) ===== */
.modal-close,
.close-button,
.close-btn {
  cursor: pointer !important;
  pointer-events: auto !important;
  z-index: 100 !important;
  position: relative;
}

/* ===== FIX: Modal overflow/scroll ===== */
.modal-content {
  overflow: hidden !important;
  border-radius: var(--radius-2xl) !important;
}

.modal-body {
  overflow-y: auto;
  max-height: calc(90vh - 120px);
}

/* ===== FIX: Table action buttons - icon-only style ===== */
@media (min-width: 768px) {
  .action-button {
    min-width: auto;
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    gap: 0.375rem;
  }
}

/* ===== FIX: Alert cards height - remove excessive empty space ===== */
.alert-card {
  padding: 1rem 1.25rem;
  min-height: auto;
}

/* ===== FIX: Sections should not have scroll-reveal if above fold ===== */
.dashboard-cards .summary-card {
  opacity: 1;
  transform: none;
  animation: fadeInUp 0.4s ease-out both;
}

/* ===== DARK MODE CONTRAST FIXES ===== */

/* Current month in dropdown - white text on gradient */
body.dark-mode .dropdown-content a.current-month {
  background: var(--gradient-primary);
  color: white !important;
  font-weight: 600;
}

/* Buttons in dark mode - ensure readable text */
body.dark-mode .btn,
body.dark-mode .add-button {
  color: white !important;
}

body.dark-mode .btn.secondary {
  background: #334155;
  color: #f1f5f9 !important;
  border-color: #475569;
}

body.dark-mode .btn.secondary:hover {
  background: #475569;
  border-color: #64748b;
  color: white !important;
}

/* Welcome card / auth card buttons */
body.dark-mode .quick-actions .btn,
body.dark-mode .auth-actions .btn {
  color: white !important;
}

/* Mobile sheet tiles - current month contrast */
body.dark-mode .mobile-sheet-tile.current-month {
  color: white !important;
}

/* Dropdown in dark mode */
body.dark-mode .dropdown-content {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .dropdown-content a {
  color: #e2e8f0 !important;
}

body.dark-mode .dropdown-content a:hover {
  background: #334155;
  color: white !important;
}

/* Page header text always white (on gradient bg) */
body.dark-mode .page-header .header-info h1,
body.dark-mode .page-header .header-info p {
  color: white !important;
  -webkit-text-fill-color: white !important;
}

body.dark-mode .page-header .header-actions .btn {
  color: white !important;
}

/* Cards text in dark mode */
body.dark-mode .card-content h3 {
  color: #f8fafc !important;
}

body.dark-mode .card-content p {
  color: #94a3b8 !important;
}

body.dark-mode .card-detail {
  color: #64748b !important;
}

/* Section headers */
body.dark-mode .section-header h3 {
  -webkit-text-fill-color: #f1f5f9;
  color: #f1f5f9;
}

/* Action buttons in dark mode */
body.dark-mode .action-button {
  background: #334155;
  color: #e2e8f0;
  border: 1px solid #475569;
}

body.dark-mode .action-button:hover {
  background: #475569;
  color: white;
}

body.dark-mode .action-button.purple-button {
  background: var(--gradient-primary);
  color: white !important;
  border: none;
}

body.dark-mode .action-button.red {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white !important;
  border: none;
}

/* ===== FIX: Settings pages layout - keep original colors ===== */
/* Don't override settings page section layouts - they have their own inline styles */

.security-section .section-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.security-section .section-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

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

.security-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  text-decoration: none;
  color: var(--gray-700);
  transition: var(--transition);
  width: 100%;
}

body.dark-mode .security-btn {
  border-color: #334155;
  color: #e2e8f0;
}

.security-btn:hover {
  border-color: var(--primary-light);
  background: var(--primary-50);
}

body.dark-mode .security-btn:hover {
  border-color: var(--primary);
  background: rgba(124, 58, 237, 0.1);
}

/* ===== FIX: All settings pages - layout fixes (keep original colors) ===== */

/* Settings content cards - dark mode fix */
body.dark-mode .preferences-grid,
body.dark-mode .notifications-grid,
body.dark-mode .display-grid,
body.dark-mode .privacy-grid,
body.dark-mode .security-content,
body.dark-mode .profile-content,
body.dark-mode .form-section {
  background: #1e293b;
  border-color: #334155;
}

/* Preference items in dark mode */
body.dark-mode .preference-item,
body.dark-mode .notification-item,
body.dark-mode .display-item,
body.dark-mode .privacy-item {
  background: #1e293b;
  border-color: #334155;
}

/* Select inputs in dark mode */
body.dark-mode select,
body.dark-mode .preference-select,
body.dark-mode .form-input,
body.dark-mode input[type="text"],
body.dark-mode input[type="email"],
body.dark-mode input[type="password"],
body.dark-mode textarea {
  background: #334155 !important;
  border-color: #475569 !important;
  color: #f1f5f9 !important;
}

/* Section icons in dark mode */
body.dark-mode .section-icon,
body.dark-mode .preference-icon,
body.dark-mode .header-icon {
  opacity: 0.9;
}

/* Back button on settings pages - always white on colored header */
.back-btn {
  color: rgba(255,255,255,0.9) !important;
  -webkit-text-fill-color: rgba(255,255,255,0.9) !important;
}

/* ===== TABLE ACTION BUTTONS - Compact pill style ===== */
.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  background: var(--gray-100);
  color: var(--gray-700);
  width: 32px;
  height: 32px;
}

/* If button has text (no icon child), show as pill with text */
.action-button.system-btn {
  width: auto;
  height: auto;
  padding: 0.4rem 0.75rem;
}

.action-button:hover {
  transform: translateY(-1px);
}

.action-button i {
  font-size: 0.8rem !important;
  line-height: 1;
}

.action-button.purple-button,
.action-button.edit-btn {
  background: var(--gradient-primary);
  color: white;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.2);
}

.action-button.purple-button:hover,
.action-button.edit-btn:hover {
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
}

.action-button.red,
.action-button.delete-btn {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

.action-button.red:hover,
.action-button.delete-btn:hover {
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

.action-button.green {
  background: var(--gradient-success);
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.action-button.green:hover {
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}

.action-button.orange {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}


/* ===== FIX: Settings page-header text alignment ===== */
.security-settings-page .header-text,
.profile-settings-page .header-text,
.preferences-settings-page .header-text,
.change-password-page .header-text,
.data-export-page .header-text,
.setup-2fa-page .header-text,
.disable-2fa-page .header-text,
.backup-codes-page .header-text {
  flex: 1;
  text-align: left;
}

/* ===== FIX: Settings section headers - icon left, text right (always) ===== */
.section-header {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 1rem !important;
}

.section-header .section-icon {
  flex-shrink: 0;
}

.section-header .section-title {
  flex: 1;
  text-align: left !important;
}

/* ===== FIX: Page header - no empty space, icon visible ===== */
.page-header .header-icon {
  display: none;
}

/* ===== CUSTOM SELECT DROPDOWNS ===== */
select,
.input-select,
.form-input[type="select"],
select.form-input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 16px;
  padding-right: 2.5rem;
  cursor: pointer;
  background-color: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--gray-800);
  transition: var(--transition);
  width: 100%;
}

select:hover,
.input-select:hover {
  border-color: var(--primary-light);
}

select:focus,
.input-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.08);
}

/* Dark mode select */
body.dark-mode select,
body.dark-mode .input-select {
  background-color: #334155;
  border-color: #475569;
  color: #f1f5f9;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

body.dark-mode select:hover,
body.dark-mode .input-select:hover {
  border-color: var(--primary-light);
}

body.dark-mode select:focus,
body.dark-mode .input-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.15);
}

/* Remove default Firefox arrow */
select::-ms-expand {
  display: none;
}

/* ===== FIX: Sheets page header - text and icon visible ===== */
.page-header h1,
.page-header .header-info h1 {
  color: white !important;
  -webkit-text-fill-color: white !important;
}

.page-header h1 i,
.page-header .header-info h1 i {
  color: rgba(255,255,255,0.85) !important;
  -webkit-text-fill-color: rgba(255,255,255,0.85) !important;
}

.page-header p,
.page-header .last-update,
.page-header .header-info p {
  color: rgba(255,255,255,0.75) !important;
  -webkit-text-fill-color: rgba(255,255,255,0.75) !important;
}

/* ===== FIX: Summary cards (Planowane/Rzeczywiste) - proper layout ===== */
.summary-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.summary-column-planned,
.summary-column-actual {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 0;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  overflow: hidden;
}

/* Labels "Planowane" / "Rzeczywiste" as card header */
.summary-column-planned h3,
.summary-column-actual h3 {
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0;
  padding: 0.875rem 1.25rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.summary-column-planned p,
.summary-column-actual p {
  padding: 0.5rem 1.25rem;
  margin: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--gray-50);
  font-size: 0.8rem;
}

@media (max-width: 768px) {
  .summary-content {
    grid-template-columns: 1fr;
  }
}

/* ===== FIX: MODALS - scrollbar inside rounded corners, X works ===== */
.modal-content,
.modal-overlay .modal-content {
  overflow: hidden !important;
  border-radius: var(--radius-2xl) !important;
  max-height: 90vh;
  display: flex !important;
  flex-direction: column !important;
}

.modal-body,
.modal-overlay .modal-body {
  overflow-y: auto !important;
  flex: 1 !important;
  min-height: 0 !important;
}

/* Modal footer - always visible, never cut off */
.modal-footer {
  padding: 1rem 1.5rem !important;
  border-top: 1px solid var(--gray-100) !important;
  display: flex !important;
  justify-content: flex-end !important;
  flex-shrink: 0 !important;
  background: var(--white) !important;
  border-radius: 0 0 var(--radius-2xl) var(--radius-2xl) !important;
}

/* X close button - always clickable */
.modal-close,
.close-button,
.close-btn,
button[onclick*="close"],
button[onclick*="Close"] {
  cursor: pointer !important;
  pointer-events: auto !important;
  z-index: 10 !important;
  position: relative !important;
}

/* ===== FIX: Modal footer button - right aligned with padding ===== */
.modal-body .btn:last-child,
.modal-body > button:last-child,
.modal-body > .btn-primary:last-child {
  display: block;
  margin: 1.5rem 1.5rem 0.5rem auto;
  width: auto;
}

/* ===== CUSTOM TOOLTIPS (theme-aware) ===== */
[data-tooltip] {
  position: relative;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: white;
  color: var(--gray-800);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.08);
  animation: tooltipFadeIn 0.1s ease-out;
  letter-spacing: 0.01em;
  border: 1px solid var(--gray-100);
}

[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: white;
  z-index: 9999;
  pointer-events: none;
  animation: tooltipFadeIn 0.1s ease-out;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.05));
}

@keyframes tooltipFadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(3px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Dark mode tooltips */
body.dark-mode [data-tooltip]:hover::after {
  background: #334155;
  color: #f1f5f9;
  border-color: #475569;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

body.dark-mode [data-tooltip]:hover::before {
  border-top-color: #334155;
}

/* Don't show empty tooltips */
[data-tooltip=""]:hover::after,
[data-tooltip=""]:hover::before {
  display: none;
}

/* Tooltip position fix for buttons in tables */
td [data-tooltip]:hover::after,
.table-cell-2 [data-tooltip]:hover::after {
  bottom: calc(100% + 8px);
  top: auto;
}

/* ===== FIX: Dashboard sections - proper inner padding ===== */
.transaction-item {
  padding: 1rem 1.25rem;
  margin: 0;
}

/* ===== FIX: Sheets summary cards - header on TOP not left ===== */
.summary-cards {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 1.5rem !important;
  margin-bottom: 2rem !important;
}

.summary-cards .summary-card {
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  padding: 0 !important;
  gap: 0 !important;
  overflow: hidden !important;
}

.summary-cards .summary-card .card-header {
  padding: 0.875rem 1.25rem !important;
  background: var(--gray-50) !important;
  border-bottom: 1px solid var(--gray-100) !important;
  border-radius: 0 !important;
}

.summary-cards .summary-card .card-header h3 {
  margin: 0 !important;
  font-size: 0.85rem !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
}

.summary-cards .summary-card .card-content {
  padding: 0.75rem 1.25rem !important;
}

.summary-cards .summary-card .card-content .metric {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 0.5rem 0 !important;
  border-bottom: none !important;
  border-top: none !important;
}

.summary-cards .summary-card .card-content .metric + .metric {
  border-top: 1px solid var(--gray-100) !important;
}

.summary-cards .summary-card .card-content .metric:last-child {
  border-bottom: none !important;
}

/* Saldo row - bold */
.summary-cards .summary-card .card-content .metric.main .label,
.summary-cards .summary-card .card-content .metric.main .value {
  font-weight: 800 !important;
  font-size: 0.9rem !important;
}

.summary-cards .summary-card .card-content .metric .label {
  color: var(--gray-600) !important;
  font-size: 0.8rem !important;
}

.summary-cards .summary-card .card-content .metric .value {
  font-weight: 700 !important;
  font-size: 0.85rem !important;
  color: var(--gray-800) !important;
  white-space: nowrap !important;
}

.summary-cards .summary-card::before {
  display: none !important;
}

.summary-cards .summary-card .card-icon {
  display: none !important;
}

@media (max-width: 768px) {
  .summary-cards {
    grid-template-columns: 1fr !important;
  }
}

/* ===== MOBILE REFACTOR - Complete overhaul ===== */
@media (max-width: 768px) {
  /* Base */
  body { font-size: 0.8rem; }
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.2rem; }
  h3 { font-size: 1rem; }
  
  .content {
    padding: 80px 1rem 5rem;
  }

  /* Header */
  .header { height: 60px; }
  .brand-logo { height: 42px; }
  .brand-link span { font-size: 0.95rem; }

  /* Page headers */
  .page-header {
    padding: 1.25rem 1rem !important;
    border-radius: var(--radius-lg) !important;
    margin-bottom: 1.25rem;
  }

  .page-header h1 {
    font-size: 1.2rem !important;
  }

  .page-header p {
    font-size: 0.75rem !important;
  }

  .page-header .header-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .page-header .header-actions .btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.7rem;
  }

  /* Dashboard cards */
  .dashboard-cards {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .summary-card {
    padding: 1rem;
    gap: 0.75rem;
  }

  .card-icon {
    width: 40px;
    height: 40px;
    font-size: 1rem;
    border-radius: var(--radius);
  }

  .card-content h3 {
    font-size: 1.1rem !important;
  }

  .card-content p {
    font-size: 0.7rem !important;
  }

  .card-detail {
    display: none;
  }

  /* Summary cards (Planowane/Rzeczywiste) */
  .summary-cards {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  /* Alerts grid */
  .alerts-grid {
    grid-template-columns: 1fr;
  }

  .alert-card {
    padding: 0.875rem 1rem;
  }

  /* Tables - card view on mobile */
  .table-wrapper {
    border-radius: var(--radius-lg);
    overflow: hidden;
  }

  /* Action buttons - smaller on mobile */
  .action-button {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
  }

  .action-button i {
    font-size: 0.7rem !important;
  }

  .action-button.edit-btn,
  .action-button.delete-btn,
  .action-button.system-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.65rem;
  }

  /* Sections */
  .alerts-section,
  .transactions-section,
  .goals-section {
    padding: 1.25rem;
    border-radius: var(--radius-lg);
  }

  .section-header h3 {
    font-size: 0.9rem;
  }

  /* Transactions */
  .transaction-item {
    padding: 0.75rem 1rem;
  }

  .transaction-info h4 { font-size: 0.8rem; }
  .transaction-info p { font-size: 0.7rem; }
  .transaction-amount { font-size: 0.85rem; }

  /* Modals */
  .modal-content {
    width: 95% !important;
    max-height: 85vh;
    border-radius: var(--radius-xl) !important;
  }

  .modal-header {
    padding: 1.25rem 1.5rem;
  }

  .modal-header h2 {
    font-size: 1rem;
  }

  .modal-body {
    padding: 1.25rem;
  }

  /* Forms */
  .form-input, select, .input-select, .input-field {
    padding: 0.625rem 0.875rem;
    font-size: 0.8rem;
  }

  /* Footer */
  .footer {
    padding: 0.75rem;
  }

  .footer-content {
    font-size: 0.7rem;
    gap: 0.5rem;
  }

  .footer-links a {
    font-size: 0.7rem;
  }

  /* Buttons */
  .btn, .add-button {
    padding: 0.5rem 0.875rem;
    font-size: 0.75rem;
  }

  /* Categories page - icon buttons */
  .category-table .action-button {
    width: 30px;
    height: 30px;
  }

  /* Balance page */
  .balance-summary-cards {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .accounts-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .account-card {
    padding: 1.25rem;
  }

  /* Settings pages */
  .section-header {
    flex-direction: row !important;
    gap: 0.75rem !important;
  }

  .section-icon {
    width: 36px !important;
    height: 36px !important;
    font-size: 0.9rem !important;
  }

  /* News grid */
  .news-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .news-card {
    padding: 1.25rem;
  }

  /* Features grid */
  .features-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .feature-card {
    padding: 1.5rem;
  }

  /* Hero */
  .hero-section {
    padding: 2.5rem 1.5rem;
    border-radius: var(--radius-lg);
  }

  .hero-section h1 {
    font-size: 1.5rem !important;
  }

  .hero-icon {
    font-size: 2.5rem;
  }

  .hero-subtitle {
    font-size: 0.9rem;
  }

  /* Tooltips - hide on mobile (touch devices) */
  [data-tooltip]:hover::after,
  [data-tooltip]:hover::before {
    display: none;
  }

  /* FAB position */
  .fab-container {
    bottom: 70px;
    right: 16px;
  }

  .fab-button {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }

  /* Scroll reveal - no animation on mobile for performance */
  .scroll-reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ===== EXTRA SMALL MOBILE (< 400px) ===== */
@media (max-width: 400px) {
  .dashboard-cards {
    grid-template-columns: 1fr;
  }

  .balance-summary-cards {
    grid-template-columns: 1fr;
  }

  .card-icon {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
  }

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

  .page-header .header-actions .btn {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-full);
  }
}

/* ===== FIX: Summary cards header full width + Saldo not cut off ===== */
.summary-cards .summary-card .card-header {
  margin: 0;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
}

.summary-cards .summary-card {
  overflow: hidden;
}

.summary-cards .summary-card .card-content .metric .value {
  white-space: nowrap;
  text-align: right;
}

.summary-cards .summary-card .card-content .metric .label {
  white-space: nowrap;
  min-width: 0;
}

/* ===== FIX: Settings page headers - full width ===== */
.security-settings-page .page-header,
.profile-settings-page .page-header,
.preferences-settings-page .page-header,
.change-password-page .page-header,
.data-export-page .page-header,
.setup-2fa-page .page-header,
.disable-2fa-page .page-header,
.backup-codes-page .page-header {
  border-radius: var(--radius-xl) !important;
  width: 100%;
  box-sizing: border-box;
}

/* ===== FIX: Categories mobile - proper icon buttons ===== */
@media (max-width: 1200px) {
  /* Category action buttons - same as desktop */
  .category-table .action-button {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .category-table .action-button.edit-btn {
    background: var(--gradient-primary);
    color: white;
  }

  .category-table .action-button.delete-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
  }

  .category-table .action-button i {
    font-size: 0.8rem !important;
  }

  /* Category row header - buttons inline */
  .category-table .category-row td[data-label]:last-child {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
  }

  /* Subcategory row - buttons inline right */
  .category-table .subcategory-row td[data-label]:last-child {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
  }

  /* Hide data-label on action column */
  .category-table td[data-label]:last-child::before {
    display: none !important;
  }
}

/* ===== FIX: Mobile - text padding from border ===== */
@media (max-width: 768px) {
  .transaction-item {
    padding: 1rem 1.25rem;
    margin: 0;
  }
}

/* ===== FIX: Tooltips on action buttons specifically ===== */
.action-button[data-tooltip] {
  position: relative;
}

.action-button[data-tooltip]:hover::after {
  content: attr(data-tooltip) !important;
  position: absolute !important;
  bottom: calc(100% + 8px) !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  background: white !important;
  color: var(--gray-800) !important;
  padding: 0.35rem 0.7rem !important;
  border-radius: var(--radius) !important;
  font-size: 0.65rem !important;
  font-weight: 600 !important;
  white-space: nowrap !important;
  z-index: 9999 !important;
  pointer-events: none !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12) !important;
  border: 1px solid var(--gray-100) !important;
  display: block !important;
}

.action-button[data-tooltip]:hover::before {
  content: '' !important;
  position: absolute !important;
  bottom: calc(100% + 4px) !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  border: 4px solid transparent !important;
  border-top-color: white !important;
  z-index: 9999 !important;
  pointer-events: none !important;
  display: block !important;
}

body.dark-mode .action-button[data-tooltip]:hover::after {
  background: #334155 !important;
  color: #f1f5f9 !important;
  border-color: #475569 !important;
}

body.dark-mode .action-button[data-tooltip]:hover::before {
  border-top-color: #334155 !important;
}

/* ===== FIX: Categories mobile buttons - proper styling ===== */
.category-mobile-btn,
.mobile-sub-btn {
  width: 34px !important;
  height: 34px !important;
  border-radius: var(--radius-full) !important;
  border: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0;
  padding: 0 !important;
}

.category-mobile-btn i,
.mobile-sub-btn i {
  font-size: 0.8rem !important;
}

/* Same colors as desktop */
.category-mobile-btn.edit,
.mobile-sub-btn.edit {
  background: var(--gradient-primary) !important;
  color: white !important;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.25);
}

.category-mobile-btn.delete,
.mobile-sub-btn.delete {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  color: white !important;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.category-mobile-btn.save,
.mobile-sub-btn.save {
  background: var(--gradient-success) !important;
  color: white !important;
}

.category-mobile-btn.cancel,
.mobile-sub-btn.cancel {
  background: var(--gray-200) !important;
  color: var(--gray-700) !important;
}

.mobile-sub-btn.plan {
  background: var(--gray-100) !important;
  color: var(--gray-600) !important;
  border: 1.5px solid var(--gray-200) !important;
}

.mobile-sub-btn.plan:hover {
  border-color: var(--primary-light) !important;
  color: var(--primary) !important;
}

.category-mobile-btn.system {
  width: auto !important;
  padding: 0.3rem 0.75rem !important;
  font-size: 0.7rem !important;
  background: var(--gray-100) !important;
  color: var(--gray-500) !important;
}

/* Override mobile icons to match desktop */
.category-mobile-btn.edit i.fa-edit::before,
.mobile-sub-btn.edit i.fa-edit::before {
  content: "\f303";
}

.category-mobile-btn.delete i.fa-trash::before,
.mobile-sub-btn.delete i.fa-trash::before {
  content: "\f2ed";
}

.mobile-sub-btn.plan i.fa-calendar-plus::before {
  content: "\f01e";
}

/* ===== FIX: Quick action icons - perfect circles ===== */
.quick-action-card i,
.quick-actions-grid .quick-action-card i {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
}

/* ===== FIX: Hidden buttons must stay hidden ===== */
.d-none {
  display: none !important;
}

/* ===== FIX: Hide placeholder dash row in summary ===== */
.summary-cards .metric .label:only-child,
.summary-cards .metric:has(.label:empty) {
  display: none;
}

/* Hide metric where label is just a dash */
.summary-cards .card-content .metric {
  min-height: 0;
}

/* ===== FIX: Tooltips must escape overflow:hidden parents ===== */
[data-tooltip] {
  overflow: visible !important;
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
  z-index: 99999 !important;
}

/* Parents of tooltip elements must not clip */
.ai-header,
.ai-controls,
.header-actions,
.table-cell-2,
td {
  overflow: visible !important;
}

/* ===== FIX: Modal header X button position + footer buttons side by side ===== */
.modal-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
}

.modal-header .close-button,
.modal-header .modal-close {
  position: static !important;
  flex-shrink: 0;
  margin-left: auto;
}

/* Modal footer - buttons side by side */
.modal-footer {
  display: flex !important;
  flex-direction: row !important;
  gap: 0.75rem !important;
  justify-content: flex-end !important;
  align-items: center !important;
}

.modal-footer .btn {
  flex: none !important;
  width: auto !important;
}

/* ===== FIX: Categories mobile - header layout ===== */
@media (max-width: 1200px) {
  /* Category card header - name, chip, buttons in one row */
  .category-mobile-header {
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem !important;
    flex-wrap: wrap;
  }

  .category-mobile-name {
    font-weight: 700;
    font-size: 1rem;
  }

  .category-mobile-type {
    font-size: 0.65rem !important;
    padding: 0.2rem 0.6rem !important;
    border-radius: var(--radius-full) !important;
  }

  .category-mobile-actions {
    margin-left: auto !important;
    display: flex !important;
    gap: 0.4rem !important;
  }

  /* Subcategory rows - name left, buttons right */
  .mobile-subcategory-item {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0.75rem 1rem !important;
    border-bottom: 1px solid var(--gray-100);
  }

  .mobile-subcategory-actions {
    display: flex !important;
    gap: 0.4rem !important;
    flex-shrink: 0;
    margin-left: 1rem;
  }
}

/* ===== FIX: Modal double-animation flash ===== */
.modal .modal-content,
.modal.active .modal-content {
  animation: modalSlideIn 0.2s ease-out !important;
  animation-iteration-count: 1 !important;
}

/* Prevent scroll-reveal from affecting modals */
.modal,
.modal-content,
.modal-body,
.modal-header,
.modal-footer {
  opacity: 1 !important;
  transform: none !important;
  transition: none !important;
}

.modal .scroll-reveal {
  opacity: 1 !important;
  transform: none !important;
}

/* ===== FIX: Year summary table - horizontal scroll on mobile ===== */
@media (max-width: 768px) {
  .table-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .monthly-table {
    min-width: 700px;
  }
}

/* ===== FIX: All modals must have visible X button ===== */
.modal-header {
  position: relative;
}

/* If modal header doesn't have a close button, add one via CSS */
.modal-header::after {
  content: '\00d7';
  position: absolute;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  font-size: 1.5rem;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  pointer-events: none;
  opacity: 0;
}

/* Hide pseudo X when real close button exists */
.modal-header:has(.close-button)::after,
.modal-header:has(.modal-close)::after,
.modal-header:has(button)::after {
  display: none;
}

/* ===== FIX: Info button contrast ===== */
.info-btn {
  background: var(--white) !important;
  color: var(--primary) !important;
  border: 1.5px solid var(--gray-200) !important;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.8rem;
}

.info-btn:hover {
  background: var(--primary-50) !important;
  border-color: var(--primary-light) !important;
}

body.dark-mode .info-btn {
  background: #334155 !important;
  color: var(--primary-light) !important;
  border-color: #475569 !important;
}

/* ===== FIX: Currency amounts never wrap ===== */
.metric .value,
.card-content h3,
.account-balance,
.transaction-amount,
.table-cell-2,
.summary-card .value,
[class*="amount"],
[class*="balance"],
[class*="currency"] {
  white-space: nowrap !important;
}

/* ===== FIX: Analysis modal close button always visible ===== */
.analysis-modal-content .modal-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
}

.analysis-modal-content .modal-header .close-button {
  position: static !important;
  display: flex !important;
  flex-shrink: 0;
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.25rem;
}

/* ===== FIX: Quick actions grid - all items aligned left ===== */
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.quick-actions-grid .action-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  text-align: left;
  text-decoration: none;
  color: var(--gray-700);
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
}

.quick-actions-grid .action-card:hover {
  border-color: var(--primary-light);
  background: var(--primary-50);
  transform: translateY(-2px);
}

.quick-actions-grid .action-card .action-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.quick-actions-grid .action-card .action-content h4 {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
}

.quick-actions-grid .action-card .action-content p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--gray-500);
}

/* (removed - replaced by PAGE HEADER MOBILE block below) */

/* ===== MOBILE UI IMPROVEMENTS ===== */
@media (max-width: 768px) {
  /* 1. Bigger touch targets for nav links */
  .navbar-links a {
    min-height: 44px;
    padding: 0.875rem 1.5rem !important;
  }

  /* 2. Tighter section spacing - less scrolling */
  .dashboard-sections {
    gap: 1rem;
  }

  .alerts-section,
  .transactions-section,
  .goals-section,
  .quick-actions-section {
    padding: 1rem;
    margin-bottom: 0;
  }

  /* 3. Footer - compact single line */
  .footer {
    padding: 0.5rem 0.75rem;
  }

  .footer-content {
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    font-size: 0.65rem;
  }

  .footer-brand {
    display: none;
  }

  .footer p {
    font-size: 0.6rem;
    margin: 0;
  }

  .footer-links {
    margin-left: 0;
    gap: 0.5rem;
  }

  .footer-links a {
    font-size: 0.6rem !important;
  }

  /* 4. Page headers - more compact */
  .page-header {
    padding: 1rem !important;
    margin-bottom: 1rem;
  }

  /* 5. Summary cards gap */
  .dashboard-cards {
    gap: 0.625rem;
    margin-bottom: 1rem;
  }

  /* 6. Quick actions - 2 columns tighter */
  .quick-actions-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }

  .quick-actions-grid .action-card {
    padding: 0.75rem;
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }

  .quick-actions-grid .action-card .action-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 0.75rem;
  }

  .quick-actions-grid .action-card .action-content h4 {
    font-size: 0.75rem;
  }

  .quick-actions-grid .action-card .action-content p {
    display: none;
  }

  /* 7. Alerts - more compact */
  .alert-card {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }

  .alert-card h4 {
    font-size: 0.8rem;
  }

  .alert-card p {
    font-size: 0.7rem;
  }

  /* 8. Transactions - tighter */
  .transaction-item {
    padding: 0.75rem 1rem;
  }

  .transactions-list {
    gap: 0.25rem;
  }
}

/* ===== FIX: Mobile - remove unnecessary padding/margin from screen edges ===== */
@media (max-width: 768px) {
  .content {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }

  .container {
    border-radius: var(--radius) !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 1rem !important;
  }

  .alerts-section,
  .transactions-section,
  .goals-section,
  .quick-actions-section,
  .accounts-section {
    border-radius: var(--radius) !important;
    padding: 0.875rem !important;
  }

  .page-header {
    margin-left: 0 !important;
    margin-right: 0 !important;
    border-radius: var(--radius) !important;
  }

  .summary-cards {
    gap: 0.5rem !important;
  }

  .table-wrapper {
    border-radius: var(--radius) !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .category-table tr {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

/* ===== FIX: Mobile hamburger menu - months grid ===== */
@media (max-width: 1200px) {
  .mobile-sheets-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 0.4rem !important;
    padding: 0 0.75rem !important;
  }

  .mobile-sheet-tile {
    padding: 0.5rem 0.25rem !important;
    font-size: 0.7rem !important;
    min-height: 38px !important;
    border-radius: var(--radius) !important;
  }

  .mobile-year-tile {
    grid-column: 1 / -1 !important;
    margin-top: 0.25rem !important;
    padding: 0.5rem !important;
    font-size: 0.75rem !important;
    min-height: 36px !important;
  }

  .mobile-sheets-section {
    padding: 0.75rem 1rem 1rem !important;
    margin-bottom: 0.5rem !important;
  }

  .mobile-sheets-header {
    font-size: 0.85rem !important;
    margin-bottom: 0.5rem !important;
  }
}

/* ===== FIX: Sheets page header mobile - compact layout ===== */
@media (max-width: 768px) {
  .page-header[data-month-no] > .header-content {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }

  .page-header[data-month-no] .header-info h1 {
    font-size: 1.1rem !important;
  }

  .page-header[data-month-no] .last-update {
    font-size: 0.65rem !important;
  }

  .page-header[data-month-no] .header-actions {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 0.35rem !important;
  }

  .page-header[data-month-no] .mobile-header-row {
    display: contents !important;
  }

  .page-header[data-month-no] .header-actions .btn {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    padding: 0.35rem 0.5rem !important;
    font-size: 0.65rem !important;
    white-space: nowrap !important;
  }

  .page-header[data-month-no] .header-actions .btn span {
    display: none !important;
  }

  .page-header[data-month-no] .header-actions .btn i {
    margin: 0 !important;
  }
}

/* ===== FIX: Mobile - footer gap, modal safe area, categories header ===== */
@media (max-width: 768px) {
  /* Remove gap above footer */
  .content {
    padding-bottom: 1rem !important;
  }

  /* Modals - respect safe areas (notch, bottom bar) */
  .modal-content {
    max-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 20px) !important;
    max-height: calc(100dvh - 20px) !important;
    margin: 10px auto !important;
  }

  .modal.active,
  .modal[style*="display: flex"] {
    padding: env(safe-area-inset-top, 10px) 0.5rem env(safe-area-inset-bottom, 10px) !important;
    align-items: flex-start !important;
    padding-top: 10px !important;
  }

  /* Modal footer - above system bar */
  .modal-footer {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Categories header - icon buttons smaller, inline */
  .page-header .header-actions .btn {
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    border-radius: var(--radius-full) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

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

  .page-header .header-actions .btn i {
    margin: 0 !important;
    font-size: 0.8rem !important;
  }

  .page-header .header-actions {
    gap: 0.4rem !important;
    flex-direction: row !important;
  }

  /* Categories mobile - tighter card spacing */
  .category-table tr {
    padding: 0.75rem !important;
    margin-bottom: 0.5rem !important;
  }
}

/* ===== FIX: Footer gap + hamburger menu scroll ===== */
@media (max-width: 1200px) {
  /* Remove space above footer */
  .footer {
    margin-top: 0 !important;
  }

  /* Hamburger menu - scrollable, full height */
  .navbar-links {
    max-height: calc(100vh - 60px) !important;
    max-height: calc(100dvh - 60px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 2rem !important;
  }

  /* Months grid - 3 columns, compact */
  .mobile-sheets-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 0.35rem !important;
  }

  .mobile-sheet-tile {
    padding: 0.4rem 0.2rem !important;
    font-size: 0.65rem !important;
    min-height: 34px !important;
  }

  .mobile-sheets-section {
    padding: 0.5rem 0.75rem 0.75rem !important;
    margin-bottom: 0 !important;
  }
}

/* ===== PAGE HEADER MOBILE ===== */
@media (max-width: 768px) {
  /* New structure: stack title on top, buttons below */
  .page-header:not([data-month-no]):has(> .header-title) {
    padding: 0 !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0 !important;
    overflow: hidden !important;
  }

  .page-header:not([data-month-no]) .header-title {
    padding: 1rem 1.25rem !important;
    gap: 0.75rem !important;
  }

  .page-header:not([data-month-no]) .title-icon {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    font-size: 1rem !important;
  }

  .page-header:not([data-month-no]) .title-content h1 {
    font-size: 1.1rem !important;
  }

  .page-header:not([data-month-no]) .title-content p {
    font-size: 0.8rem !important;
    margin-top: 0.15rem !important;
  }

  /* Buttons section: full-width bar below title, same background as header */
  .page-header:not([data-month-no]) .header-actions {
    background: transparent !important;
    padding: 0 1rem 0.85rem !important;
    display: grid !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }

  /* Buttons: icon + text, full width of cell */
  .page-header:not([data-month-no]) .header-actions .btn {
    width: 100% !important;
    padding: 0.55rem 0.75rem !important;
    font-size: 0.78rem !important;
    border-radius: var(--radius) !important;
    justify-content: center !important;
    gap: 0.4rem !important;
    background: rgba(255,255,255,0.18) !important;
    border: 1px solid rgba(255,255,255,0.28) !important;
    color: white !important;
  }

  .page-header:not([data-month-no]) .header-actions .btn span {
    display: inline !important;
  }

  .page-header:not([data-month-no]) .header-actions .btn i {
    font-size: 0.85rem !important;
    flex-shrink: 0 !important;
  }

  /* ---- Adaptive grid by button count ---- */

  /* 1 button: full width */
  .page-header:not([data-month-no]) .header-actions:has(> .btn:only-child) {
    grid-template-columns: 1fr !important;
  }

  /* 2 buttons: 2 columns */
  .page-header:not([data-month-no]) .header-actions:has(> .btn:nth-child(2):last-child) {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* 3 buttons: 3 columns */
  .page-header:not([data-month-no]) .header-actions:has(> .btn:nth-child(3):last-child) {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* 4 buttons: 2x2 */
  .page-header:not([data-month-no]) .header-actions:has(> .btn:nth-child(4):last-child) {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* 5 buttons: 3+2 — use 6-column base grid */
  .page-header:not([data-month-no]) .header-actions:has(> .btn:nth-child(5):last-child) {
    grid-template-columns: repeat(6, 1fr) !important;
  }
  .page-header:not([data-month-no]) .header-actions:has(> .btn:nth-child(5):last-child) > .btn:nth-child(-n+3) {
    grid-column: span 2 !important;
  }
  .page-header:not([data-month-no]) .header-actions:has(> .btn:nth-child(5):last-child) > .btn:nth-child(n+4) {
    grid-column: span 3 !important;
  }

  /* 6 buttons: 3x2 */
  .page-header:not([data-month-no]) .header-actions:has(> .btn:nth-child(6):last-child) {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

/* ===== FIX: Tooltip clipping - all parents must not clip ===== */
.ai-assistant-widget,
.ai-header,
.ai-controls,
.sheets-summary,
.summary-cards,
.summary-card,
.card-header {
  overflow: visible !important;
}

/* Sheets mobile-header-row */
@media (max-width: 768px) {
  .mobile-header-row {
    display: contents !important;
  }
}
