/* Ensure readable inputs on dark/glass backgrounds */
.form-control {
  color: #f8f9fa;
  background-color: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}
.form-control::placeholder {
  color: rgba(248, 249, 250, 0.6);
}
.form-control:focus {
  color: #f8f9fa;
  background-color: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}
:root {
  /* Page transition timings */
  --page-fade-duration: 180ms;
}

/* Aurora canvas background */
#aurora-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* Ensure content is above canvas */
body > :not(#aurora-canvas) {
  position: relative;
  z-index: 1;
}

/* Hero trail canvas overlay */
.hero {
  position: relative;
}
.hero-trail-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

/* Page fade transitions */
body.page-fade-in {
  animation: pageFadeIn var(--page-fade-duration) ease-out both;
}
body.page-fade-out {
  animation: pageFadeOut var(--page-fade-duration) ease-in both;
}
@keyframes pageFadeIn {
  from {
    opacity: 0;
    filter: blur(4px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}
@keyframes pageFadeOut {
  from {
    opacity: 1;
    filter: blur(0);
  }
  to {
    opacity: 0;
    filter: blur(4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.page-fade-in,
  body.page-fade-out {
    animation: none !important;
  }
}
/* =====================================================
   StockVision Premium Design System
   Ultra-modern, professional financial dashboard
   ===================================================== */

/* ---------- CSS Variables - Premium Dark Theme ---------- */
:root {
  /* === Brand Colors === */
  --brand-primary: #6366f1;
  --brand-primary-dark: #4f46e5;
  --brand-primary-light: #818cf8;
  --brand-accent: #8b5cf6;
  --brand-glow: rgba(99, 102, 241, 0.4);

  /* === Background Layers === */
  --bg-base: #0a0a0f;
  --bg-elevated: #13131a;
  --bg-card: #1a1a24;
  --bg-hover: #222230;
  --bg-glass: rgba(26, 26, 36, 0.75);
  --bg-glass-hover: rgba(34, 34, 48, 0.85);

  /* === Text Colors === */
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* === Semantic Colors === */
  --success: #10b981;
  --success-light: #34d399;
  --success-dark: #059669;
  --success-bg: rgba(16, 185, 129, 0.15);
  --success-glow: rgba(16, 185, 129, 0.3);

  --danger: #ef4444;
  --danger-light: #f87171;
  --danger-dark: #dc2626;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --danger-glow: rgba(239, 68, 68, 0.3);

  --warning: #f59e0b;
  --warning-light: #fbbf24;
  --warning-dark: #d97706;
  --warning-bg: rgba(245, 158, 11, 0.15);

  --info: #3b82f6;
  --info-light: #60a5fa;
  --info-dark: #2563eb;
  --info-bg: rgba(59, 130, 246, 0.15);

  /* === Borders & Dividers === */
  --border-primary: #27272a;
  --border-secondary: #3f3f46;
  --border-accent: rgba(99, 102, 241, 0.3);

  /* === Shadows & Depth === */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 8px 0 rgba(0, 0, 0, 0.6), 0 2px 4px 0 rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 20px 0 rgba(0, 0, 0, 0.7), 0 4px 8px 0 rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 40px 0 rgba(0, 0, 0, 0.8), 0 8px 16px 0 rgba(0, 0, 0, 0.6);
  --shadow-glow-primary: 0 0 30px var(--brand-glow);
  --shadow-glow-success: 0 0 30px var(--success-glow);
  --shadow-glow-danger: 0 0 30px var(--danger-glow);

  /* === Border Radius === */
  --radius-xs: 0.25rem;
  --radius-sm: 0.5rem;
  --radius-md: 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-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 400ms cubic-bezier(0.68, -0.55, 0.265, 1.55);

  /* === Gradients === */
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  --gradient-info: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  --gradient-premium: linear-gradient(
    135deg,
    #6366f1 0%,
    #8b5cf6 50%,
    #ec4899 100%
  );
  --gradient-glass: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0.05) 100%
  );

  /* === Layout === */
  --nav-height: 70px;
  --container-max: 1400px;
  --sidebar-width: 280px;

  /* === Z-Index === */
  --z-nav: 1000;
  --z-dropdown: 1100;
  --z-modal: 1200;
  --z-tooltip: 1300;
  --z-notification: 1400;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  font-family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont,
    sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  background-image: radial-gradient(
      circle at 20% 30%,
      rgba(99, 102, 241, 0.05) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 70%,
      rgba(139, 92, 246, 0.05) 0%,
      transparent 50%
    );
  background-attachment: fixed;
}

img,
svg {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--brand-primary-light);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--brand-primary);
}

/* ---------- Utility Classes ---------- */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

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

.text-gradient {
  background: var(--gradient-premium);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.glass-card {
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-lg);
}

/* ---------- Navigation Bar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: rgba(10, 10, 15, 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-primary);
  height: var(--nav-height);
}

.nav-container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  transition: all var(--transition-base);
}

.logo:hover {
  color: var(--brand-primary-light);
  transform: scale(1.02);
}

.logo-img {
  height: 44px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
  display: block;
}

.logo:hover .logo-img {
  box-shadow: var(--shadow-lg), var(--shadow-glow-primary);
  transform: rotate(-5deg);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2rem;
  list-style: none;
}

.nav-link {
  position: relative;
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0.5rem 0;
  transition: color var(--transition-fast);
}

.nav-link::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--gradient-primary);
  transition: width var(--transition-base);
}

.nav-link:hover {
  color: var(--text-primary);
}

.nav-link:hover::after {
  width: 100%;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem;
  transition: all var(--transition-fast);
}

.menu-toggle:hover {
  color: var(--brand-primary-light);
  transform: scale(1.1);
}

/* ---------- Buttons - Premium Design ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  text-decoration: none;
}

.btn::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 var(--transition-slow);
}

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

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  box-shadow: var(--shadow-lg), var(--shadow-glow-primary);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-success {
  background: var(--gradient-success);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-success:hover {
  box-shadow: var(--shadow-lg), var(--shadow-glow-success);
  transform: translateY(-2px);
}

.btn-danger {
  background: var(--gradient-danger);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-danger:hover {
  box-shadow: var(--shadow-lg), var(--shadow-glow-danger);
  transform: translateY(-2px);
}

.btn-warning {
  background: var(--gradient-warning);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-info {
  background: var(--gradient-info);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border: 2px solid var(--border-secondary);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: var(--brand-primary);
  color: var(--brand-primary-light);
  transform: translateY(-2px);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.125rem;
}

/* ---------- Cards & Glass Effects ---------- */
.card {
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-md);
}

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

.card-premium {
  position: relative;
  overflow: hidden;
}

.card-premium::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    var(--brand-glow) 180deg,
    transparent 360deg
  );
  animation: rotate-gradient 4s linear infinite;
  opacity: 0;
  transition: opacity var(--transition-base);
}

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

.card-premium::after {
  content: "";
  position: absolute;
  inset: 2px;
  background: var(--bg-card);
  border-radius: calc(var(--radius-lg) - 2px);
  z-index: 1;
}

.card-premium > * {
  position: relative;
  z-index: 2;
}

@keyframes rotate-gradient {
  to {
    transform: rotate(1turn);
  }
}

/* ---------- Portfolio Stats Cards (Investment Page) ---------- */
.stats-card {
  position: relative;
  padding: 2rem;
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  transition: all var(--transition-base);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.stats-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--gradient-primary);
  opacity: 0.9;
  z-index: 1;
}

.stats-card.bg-primary::before {
  background: var(--gradient-primary);
}

.stats-card.bg-success::before {
  background: var(--gradient-success);
}

.stats-card.bg-danger::before {
  background: var(--gradient-danger);
}

.stats-card.bg-info::before {
  background: var(--gradient-info);
}

.stats-card.bg-warning::before {
  background: var(--gradient-warning);
}

.stats-card.bg-secondary::before {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
}

.stats-card > * {
  position: relative;
  z-index: 2;
}

.stats-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow-xl), var(--shadow-glow-primary);
}

/* Glass variant for simpler, high-contrast stats cards */
.stats-card--glass {
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-secondary);
}
.stats-card--glass::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
  opacity: 1;
}
.stats-card--glass.accent-primary::before {
  background: var(--gradient-primary);
}
.stats-card--glass.accent-info::before {
  background: var(--gradient-info);
}
.stats-card--glass.accent-success::before {
  background: var(--gradient-success);
}
.stats-card--glass.accent-danger::before {
  background: var(--gradient-danger);
}
.stats-card--glass.accent-neutral::before {
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
}

.stats-card--glass .stats-content {
  color: var(--text-primary);
}
.stats-card--glass .stats-label {
  opacity: 0.8;
  text-transform: none;
  letter-spacing: 0;
}
.stats-card--glass .stats-value {
  text-shadow: none;
}

/* Modal polish: smoother open animation and glass background */
.modal.fade .modal-dialog {
  transform: translateY(12px) scale(0.98);
  transition: transform 220ms var(--transition-snap),
    opacity 220ms var(--transition-snap);
}
.modal.show .modal-dialog {
  transform: translateY(0) scale(1);
}

.modal-content {
  background: rgba(18, 20, 28, 0.78);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

.stats-icon {
  font-size: 3rem;
  opacity: 0.9;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.stats-content {
  flex: 1;
  color: white;
}

.stats-label {
  margin: 0 0 0.5rem 0;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.95;
}

.stats-value {
  margin: 0;
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

/* ---------- Investment Cards ---------- */
.investment-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-primary);
}

.investment-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-xl), 0 0 40px rgba(99, 102, 241, 0.2);
  border-color: var(--border-accent);
}

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

.investment-header::before {
  content: "";
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 70%
  );
  pointer-events: none;
}

.stock-symbol {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0 0 0.25rem 0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  letter-spacing: 0.5px;
}

.stock-name {
  font-size: 0.875rem;
  opacity: 0.9;
  margin: 0;
  font-weight: 500;
}

.current-price {
  font-size: 2rem;
  font-weight: 800;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.investment-body {
  padding: 1.75rem;
}

.position-info {
  margin-bottom: 1.5rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border-primary);
  transition: all var(--transition-fast);
}

.info-row:last-child {
  border-bottom: none;
}

.info-row:hover {
  background: var(--bg-hover);
  padding-left: 0.5rem;
  margin: 0 -0.5rem;
  border-radius: var(--radius-sm);
}

.info-label {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
}

.info-value {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 1rem;
}

.profit-loss-section {
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  text-align: center;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-secondary);
  background: transparent;
  transition: all var(--transition-base);
}

.profit-loss-section::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.08;
  z-index: 0;
}

.profit-loss-section.profit::before {
  background: var(--gradient-success);
}

.profit-loss-section.loss::before {
  background: var(--gradient-danger);
}

.profit-loss-section.profit {
  border-color: var(--success);
  box-shadow: 0 0 20px var(--success-glow);
}

.profit-loss-section.loss {
  border-color: var(--danger);
  box-shadow: 0 0 20px var(--danger-glow);
}

.profit-loss-section > * {
  position: relative;
  z-index: 1;
}

.profit-loss-amount {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 0.5rem 0;
}

.profit-loss-section.profit .profit-loss-amount {
  background: linear-gradient(90deg, #34d399, #10b981, #a7f3d0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 24px var(--success-glow);
}

.profit-loss-section.loss .profit-loss-amount {
  background: linear-gradient(90deg, #f87171, #ef4444, #fb7185);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 24px var(--danger-glow);
}

.profit-loss-percent {
  font-size: 1.25rem;
  font-weight: 700;
}

.investment-actions {
  padding: 1.25rem;
  display: flex;
  gap: 0.75rem;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-primary);
}

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

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  border: 2px dashed var(--border-secondary);
  box-shadow: var(--shadow-md);
}

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

.empty-state h3 {
  margin: 1.5rem 0 0.75rem 0;
  font-size: 1.75rem;
  color: var(--text-primary);
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 1.125rem;
}

/* ---------- Modals ---------- */
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}

.modal-header {
  background: var(--gradient-primary);
  color: white;
  border-bottom: none;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 1.5rem 2rem;
}

.modal-title {
  font-weight: 700;
  font-size: 1.5rem;
}

.modal-body {
  padding: 2rem;
}

.modal-footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border-primary);
  background: var(--bg-elevated);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.btn-close {
  filter: brightness(0) invert(1);
  opacity: 0.8;
  transition: all var(--transition-fast);
}

.btn-close:hover {
  opacity: 1;
  transform: rotate(90deg);
}

/* ---------- Forms & Inputs ---------- */
.form-label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control,
.form-select,
textarea.form-control {
  width: 100%;
  padding: 0.875rem 1.25rem;
  background: var(--bg-elevated);
  border: 2px solid var(--border-secondary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  transition: all var(--transition-base);
}

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

.form-control::placeholder {
  color: var(--text-dim);
}

.form-check-input {
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border-secondary);
  background: var(--bg-elevated);
  transition: all var(--transition-fast);
}

.form-check-input:checked {
  background: var(--gradient-primary);
  border-color: var(--brand-primary);
}

.form-check-input:focus {
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.form-check-label {
  color: var(--text-secondary);
  font-weight: 500;
  margin-left: 0.5rem;
}

/* ---------- Alerts ---------- */
.alert {
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-lg);
  border-left: 4px solid;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 1rem;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  animation: slideDown 0.3s ease-out;
}

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

.alert-success {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success-light);
}

.alert-danger {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: var(--danger-light);
}

/* ---------- Dashboard Hero & Quick Add ---------- */
.dashboard-hero {
  padding: 0.5rem 0 0.25rem 0;
}
.dashboard-hero .hero-title {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: 0.2px;
  margin: 0 0 0.25rem 0;
}
.dashboard-hero .hero-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
}

.quickadd-card {
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}
.quickadd-card .form-label {
  color: var(--text-secondary);
}
.quickadd-card .btn-outline-light {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.3);
}
.quickadd-card .btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.5);
}
.quickadd-grid .form-control {
  height: 3rem;
}
.quickadd-label {
  font-weight: 600;
  letter-spacing: 0.3px;
}
.pill-group .btn {
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  border-color: rgba(255, 255, 255, 0.25);
}
.pill-group .btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}
.pill-group .btn.active,
.pill-group .btn[aria-pressed="true"] {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}
.pill-group .btn:focus-visible {
  box-shadow: 0 0 0 3px var(--brand-glow);
}
/* Ensure the quick add grid columns can anchor absolute children like the search dropdown */
.quickadd-grid .col-12.col-md-4.col-lg-3 {
  position: relative;
}

/* ---------- Clean Table Variant ---------- */
.table-clean {
  --row-sep: rgba(255, 255, 255, 0.05);
  --hover-bg: rgba(255, 255, 255, 0.03);
  border-collapse: separate;
  border-spacing: 0 8px;
}
.table-clean thead th {
  border: none;
  color: var(--text-secondary);
  font-weight: 600;
}
.table-clean tbody tr {
  background: var(--bg-elevated);
}
.table-clean tbody tr:hover {
  background: var(--hover-bg);
}
.table-clean tbody td {
  border-top: 1px solid var(--row-sep);
  border-bottom: 1px solid var(--row-sep);
}
.table-clean tbody tr td:first-child {
  border-left: 1px solid var(--row-sep);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}
.table-clean tbody tr td:last-child {
  border-right: 1px solid var(--row-sep);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* Investment card details (collapse) */
.investment-card .investment-more {
  display: flex;
  justify-content: flex-end;
}
.investment-card .investment-more .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  border-color: rgba(255, 255, 255, 0.2);
}
.investment-card .details {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 0 0 12px 12px;
  padding: 0.75rem 1rem;
  margin-top: 0.25rem;
}
.investment-card .details-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.25rem 0;
  font-size: 0.95rem;
}
.investment-card .details-label {
  color: rgba(255, 255, 255, 0.7);
}
.investment-card .details-value {
  color: #ffffff;
}

/* Tweak sticky Quick Add offset to account for navbar height */
@media (max-width: 992px) {
  .quickadd-card {
    position: sticky;
    top: calc(var(--nav-height, 64px) + 8px);
    z-index: 10;
  }
}

/* Subtle sticky Quick Add on small screens */
@media (max-width: 576px) {
  .quickadd-card {
    position: sticky;
    top: 8px;
    z-index: 5;
  }
}

.alert-warning {
  background: var(--warning-bg);
  border-color: var(--warning);
  color: var(--warning-light);
}

.alert-info {
  background: var(--info-bg);
  border-color: var(--info);
  color: var(--info-light);
}

.alert-dismissible .btn-close {
  filter: none;
  opacity: 0.6;
}

/* ---------- Tables ---------- */
.table {
  width: 100%;
  color: var(--text-primary);
  border-collapse: separate;
  border-spacing: 0;
}

.table thead {
  background: var(--bg-elevated);
}

.table th {
  padding: 1rem 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-secondary);
}

.table td {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-primary);
  transition: all var(--transition-fast);
}

.table tbody tr {
  transition: all var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--bg-hover);
}

.table-dark {
  background: var(--bg-card);
}

.table-hover tbody tr:hover {
  background: var(--bg-hover);
  box-shadow: inset 4px 0 0 var(--brand-primary);
}

/* ---------- Weekly Performance Table ---------- */
.weekly-performance-section {
  background: var(--bg-glass);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  padding: 2.5rem;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-secondary);
  box-shadow: var(--shadow-lg);
  margin-top: 3rem;
}

.weekly-performance-section h3 {
  margin-bottom: 2rem;
  color: var(--text-primary);
  font-size: 1.75rem;
  font-weight: 700;
}

/* ---------- Search Results Dropdown ---------- */
.search-results {
  position: absolute;
  z-index: var(--z-dropdown);
  left: 0;
  right: 0;
  width: 100%;
  max-height: min(50vh, 360px);
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  margin-top: 0.5rem;
  box-shadow: var(--shadow-xl);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  color: var(--text-primary); /* ensure readable text on dark bg */
}

/* Enable scroll chaining control where supported */
@supports (overscroll-behavior: contain) {
  .search-results {
    overscroll-behavior: contain;
  }
}

.search-result-item {
  padding: 1rem 1.25rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-primary);
  transition: all var(--transition-fast);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-primary); /* override any inherited dark theme resets */
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--bg-hover);
  padding-left: 1.5rem;
  border-left: 4px solid var(--brand-primary);
}

.search-result-item.active {
  background: var(--bg-hover);
  border-left: 4px solid var(--brand-primary);
}

/* Muted helper inside dropdown should remain legible on dark bg */
.search-results .text-muted {
  color: var(--text-secondary, rgba(255, 255, 255, 0.7));
}

/* ---------- Flash Messages ---------- */
.flash {
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  font-weight: 500;
  animation: slideDown 0.3s ease-out;
  box-shadow: var(--shadow-md);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.flash.success {
  background: var(--success-bg);
  border-left: 4px solid var(--success);
  color: var(--success-light);
}

.flash.error {
  background: var(--danger-bg);
  border-left: 4px solid var(--danger);
  color: var(--danger-light);
}

.flash.info {
  background: var(--info-bg);
  border-left: 4px solid var(--info);
  color: var(--info-light);
}

.flash.message {
  background: var(--info-bg);
  border-left: 4px solid var(--info);
  color: var(--info-light);
}

/* ---------- Footer ---------- */
.footer {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-primary);
  padding: 3rem 0;
  margin-top: 5rem;
  color: var(--text-muted);
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--text-muted);
  transition: color var(--transition-fast);
  font-weight: 500;
}

.footer-links a:hover {
  color: var(--brand-primary-light);
}

/* ---------- Responsive Design ---------- */
@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--bg-card);
    flex-direction: column;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-primary);
    box-shadow: var(--shadow-xl);
    gap: 1rem;
  }

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

  .menu-toggle {
    display: block;
  }

  .stats-card {
    padding: 1.5rem;
  }

  .stats-icon {
    font-size: 2rem;
  }

  .stats-value {
    font-size: 1.75rem;
  }

  .investment-actions {
    flex-direction: column;
  }

  .weekly-performance-section {
    padding: 1.5rem;
  }

  .table {
    font-size: 0.875rem;
  }

  .table th,
  .table td {
    padding: 0.75rem;
  }
}

@media (max-width: 640px) {
  .stats-card {
    flex-direction: column;
    text-align: center;
  }

  .profit-loss-amount {
    font-size: 1.5rem;
  }

  .stock-symbol {
    font-size: 1.25rem;
  }

  .current-price {
    font-size: 1.5rem;
  }
}

/* ---------- Scrollbar Styling ---------- */
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-base);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--brand-primary);
}

/* ---------- Loading & Animations ---------- */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 0%,
    var(--bg-hover) 50%,
    var(--bg-elevated) 100%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
  border-radius: var(--radius-md);
}

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

.focus-visible:focus {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* ---------- Input visibility fixes on dark backgrounds ---------- */
input.form-control,
input[type="number"].form-control,
textarea.form-control,
select.form-select {
  color: #f8f9fa !important;
}

/* WebKit autofill text color and background on dark inputs */
input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: #f8f9fa !important;
  box-shadow: 0 0 0px 1000px rgba(255, 255, 255, 0.06) inset !important;
  transition: background-color 99999s ease-in-out 0s !important;
}

/* ---------- Print Styles ---------- */
@media print {
  .navbar,
  .footer,
  .btn,
  .investment-actions {
    display: none;
  }

  body {
    background: white;
    color: black;
  }

  .investment-card,
  .stats-card,
  .card {
    border: 1px solid #000;
    box-shadow: none;
    page-break-inside: avoid;
  }
}
