/* ==========================================================================
   台股每季 EPS 分析與合理價位估算儀表板 - Modern Financial Dark & Glassmorphism
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-base: #0a0e17;
  --bg-surface: #111827;
  --bg-surface-elevated: #162032;
  --bg-glass: rgba(18, 26, 43, 0.75);
  --bg-glass-card: rgba(22, 33, 54, 0.7);
  --bg-glass-hover: rgba(30, 45, 74, 0.9);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(99, 102, 241, 0.35);
  --border-active: rgba(56, 189, 248, 0.5);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-dim: #475569;

  /* Accent Colors */
  --accent-cyan: #38bdf8;
  --accent-indigo: #6366f1;
  --accent-violet: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-emerald-light: #34d399;
  --accent-rose: #f43f5e;
  --accent-rose-light: #fb7185;
  --accent-amber: #f59e0b;
  --accent-amber-light: #fbbf24;

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Shadows & Glows */
  --glow-cyan: 0 0 25px rgba(56, 189, 248, 0.25);
  --glow-indigo: 0 0 25px rgba(99, 102, 241, 0.25);
  --glow-emerald: 0 0 25px rgba(16, 185, 129, 0.25);
  --glow-rose: 0 0 25px rgba(244, 63, 94, 0.25);
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.hidden {
  display: none !important;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Glow Spheres */
.glow-sphere {
  position: fixed;
  border-radius: 50%;
  /* The radial-gradient already fades to transparent at 70%, so most of the
     softness comes from the fill, not the blur. 60px reads the same as 120px
     here but costs a quarter of the offscreen render. */
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  /* Promote to its own compositor layer so the blur is rasterized once and
     the animation only moves the finished texture. */
  will-change: transform;
  animation: floatSphere 20s infinite alternate ease-in-out;
}
.sphere-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #4f46e5 0%, transparent 70%);
  top: -150px;
  left: -100px;
}
.sphere-2 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, #0284c7 0%, transparent 70%);
  top: 30%;
  right: -150px;
  animation-duration: 25s;
}
.sphere-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #059669 0%, transparent 70%);
  bottom: -100px;
  left: 20%;
  animation-duration: 22s;
}

/* Translate only: scaling a blurred layer invalidates its cached raster, so
   every frame would otherwise re-run the gaussian blur. */
@keyframes floatSphere {
  0% { transform: translate(0, 0); }
  50% { transform: translate(40px, 30px); }
  100% { transform: translate(-30px, -20px); }
}

@media (prefers-reduced-motion: reduce) {
  .glow-sphere {
    animation: none;
    will-change: auto;
  }
}

/* Layout Container */
.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 28px 48px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ==========================================================================
   Header & Search Bar
   ========================================================================== */

.app-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 24px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  position: relative;
  z-index: 50;
}

.header-top-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto auto auto;
  align-items: center;
  column-gap: 14px;
  row-gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  grid-column: 1;
  grid-row: 1;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 30%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text .sub-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Search Bar (full-width third row) */
.header-search-row {
  width: 100%;
}

.header-center {
  flex: 2 1 0;
  min-width: 260px;
  max-width: 680px;
}

.search-container {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

.search-container input {
  width: 100%;
  padding: 10px 80px 10px 42px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-fast);
}

.search-container input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
  background: rgba(15, 23, 42, 0.95);
}

.search-shortcut {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  pointer-events: none;
}

/* Autocomplete Dropdown */
.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  max-height: 360px;
  overflow-y: auto;
  z-index: 100;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.search-dropdown.hidden {
  display: none !important;
}

.search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
  color: var(--text-primary);
  text-decoration: none;
}

.search-item:hover, .search-item.selected {
  background: rgba(56, 189, 248, 0.15);
  color: #fff;
}

.search-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-item-id {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.search-item-name {
  font-weight: 600;
  font-size: 0.92rem;
}

.search-item-cat {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.header-right {
  display: contents;
}


.header-right .notification-header-wrapper {
  grid-column: 6;
  grid-row: 1;
}

.header-right .user-auth-header-wrapper {
  grid-column: 7;
  grid-row: 1;
}

.header-right #dividendCalendarToggleBtn {
  grid-column: 4;
  grid-row: 2;
}

.header-right .market-badge {
  grid-column: 2;
  grid-row: 1;
}

.header-right #screenerToggleBtn {
  grid-column: 5;
  grid-row: 2;
}

.header-right #compareModeToggleBtn {
  grid-column: 6;
  grid-row: 2;
}

.header-right #portfolioToggleBtn {
  grid-column: 7;
  grid-row: 2;
}

.market-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--accent-emerald-light);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-emerald);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulseAnimation 2s infinite;
}

@keyframes pulseAnimation {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 12px var(--accent-emerald); }
  100% { transform: scale(0.9); opacity: 0.8; }
}

/* ==========================================================================
   Quick Picks & Watchlist Bar
   ========================================================================== */

.quick-picks-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 12px 18px;
  background: var(--bg-glass);
  backdrop-filter: blur(15px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
}

.quick-picks-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.quick-picks-label {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
}

.quick-picks-chips, .watchlist-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.stock-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition-fast);
  user-select: none;
}

.stock-chip:hover {
  background: rgba(99, 102, 241, 0.18);
  border-color: var(--border-highlight);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.stock-chip.active {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.35), rgba(6, 182, 212, 0.35));
  border-color: var(--accent-cyan);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.2);
}

.stock-chip .chip-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stock-chip .chip-id {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.75rem;
  opacity: 0.85;
}

.stock-chip .chip-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  margin-left: 2px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.stock-chip .chip-remove:hover {
  background: rgba(244, 63, 94, 0.25);
  color: var(--accent-rose-light);
}

.watchlist-chips .stock-chip[draggable="true"] {
  cursor: grab;
}

.watchlist-chips .stock-chip[draggable="true"]:active {
  cursor: grabbing;
}

.watchlist-chips.drag-active .stock-chip {
  transition: transform 120ms ease, opacity 120ms ease;
}

.watchlist-chips .stock-chip.dragging {
  opacity: 0.35;
  cursor: grabbing;
  transform: scale(0.96);
  box-shadow: none;
}

.watchlist-separator {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin: 0 4px;
}

.watchlist-section {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.watchlist-title {
  color: var(--accent-amber-light);
  font-weight: 600;
  font-size: 0.8rem;
}

.btn-chip {
  padding: 4px 12px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px dashed rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-full);
  color: var(--accent-amber-light);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-chip:hover {
  background: rgba(245, 158, 11, 0.25);
  border-color: var(--accent-amber);
}

/* Stock Open Mode Switch (Current Page vs New Tab) - Dropdown Selector */
.stock-open-mode-row {
  display: flex;
  align-items: center;
  width: 100%;
}

.stock-open-mode-container {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  padding: 3px 6px 3px 10px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  user-select: none;
  transition: var(--transition-fast);
}

.stock-open-mode-container:hover {
  border-color: rgba(56, 189, 248, 0.3);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.open-mode-label {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  cursor: pointer;
}

.open-mode-select-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.open-mode-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: rgba(0, 0, 0, 0.4);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-full);
  padding: 3px 26px 3px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
  line-height: 1.3;
}

.open-mode-select:hover {
  background: rgba(0, 0, 0, 0.6);
  border-color: rgba(56, 189, 248, 0.7);
  box-shadow: 0 1px 8px rgba(56, 189, 248, 0.25);
}

.open-mode-select:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.stock-open-mode-container[data-mode="newTab"] .open-mode-select {
  color: #c084fc;
  border-color: rgba(192, 132, 252, 0.45);
  box-shadow: 0 1px 6px rgba(192, 132, 252, 0.2);
}

.stock-open-mode-container[data-mode="newTab"] .open-mode-select:hover {
  border-color: rgba(192, 132, 252, 0.75);
  box-shadow: 0 1px 10px rgba(192, 132, 252, 0.3);
}

.open-mode-select option {
  background: #0f172a;
  color: #f8fafc;
  font-size: 0.82rem;
  padding: 8px;
}

.open-mode-select-arrow {
  position: absolute;
  right: 8px;
  pointer-events: none;
  color: var(--text-muted);
  transition: transform 0.2s ease, color 0.2s ease;
}

.open-mode-select:hover + .open-mode-select-arrow,
.open-mode-select:focus + .open-mode-select-arrow {
  color: #38bdf8;
}

.stock-open-mode-container[data-mode="newTab"] .open-mode-select:hover + .open-mode-select-arrow,
.stock-open-mode-container[data-mode="newTab"] .open-mode-select:focus + .open-mode-select-arrow {
  color: #c084fc;
}

/* ETF Notice Banner */
.etf-notice-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(79, 70, 229, 0.15));
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  margin-bottom: 20px;
  animation: slideInToast 0.3s ease;
}

.etf-notice-banner.hidden {
  display: none !important;
}

.etf-notice-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.etf-notice-content {
  font-size: 0.85rem;
  color: #fef08a;
  line-height: 1.4;
}

.etf-notice-content strong {
  color: #fff;
}

/* ==========================================================================
   Stock Hero Card & Live Price Banner
   ========================================================================== */

.stock-hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 22px 26px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}

.stock-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.stock-name {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #fff;
}

.stock-id {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.stock-category {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.status-badge.bullish {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald-light);
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: var(--glow-emerald);
}

.status-badge.bearish {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose-light);
  border: 1px solid rgba(244, 63, 94, 0.35);
  box-shadow: var(--glow-rose);
}

.status-badge.positive {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.status-badge.neutral {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

/* Live Market Price Banner in Hero */
.stock-price-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 10px;
  padding: 8px 14px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: var(--radius-md);
  width: fit-content;
}

.live-price-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.price-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.live-price-val {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

.price-currency {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.price-spread-badge {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
}

.price-spread-badge.up {
  background: rgba(244, 63, 94, 0.18);
  color: var(--accent-rose-light);
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.price-spread-badge.down {
  background: rgba(16, 185, 129, 0.18);
  color: var(--accent-emerald-light);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.price-spread-badge.flat {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.live-price-details {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  padding-left: 14px;
}

.quote-source-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 999px;
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.1);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.quote-source-badge.fugle {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.13);
  border-color: rgba(16, 185, 129, 0.4);
}

.quote-source-badge.fallback {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.13);
  border-color: rgba(245, 158, 11, 0.4);
}

.quote-source-badge.unavailable {
  color: #fda4af;
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.35);
}

.kline-btn-live {
  border-color: rgba(16, 185, 129, 0.32) !important;
}

.kline-btn-live.active {
  color: #6ee7b7 !important;
  background: rgba(16, 185, 129, 0.16) !important;
  border-color: rgba(16, 185, 129, 0.55) !important;
}

.kline-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.kline-live-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.28);
  white-space: nowrap;
}

.kline-live-status.live::before {
  content: '';
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.12);
}

.kline-live-status.live {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.4);
}

.kline-live-status.fallback {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.4);
}

.kline-live-status.error {
  color: #fda4af;
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.35);
}

.stock-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.stock-info-main {
  flex: 1 1 520px;
  min-width: 0;
}

.stock-hero-actions {
  display: flex;
  flex: 0 1 560px;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  min-width: 0;
}

.stock-section-nav {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
}

.section-nav-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  background: rgba(15, 23, 42, 0.7);
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition-fast);
}

.section-nav-chip:hover,
.section-nav-chip:focus-visible {
  color: #fff;
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.13);
  outline: none;
  transform: translateY(-1px);
}

.section-nav-chip.active {
  color: var(--accent-cyan);
  border-color: rgba(56, 189, 248, 0.6);
  background: rgba(56, 189, 248, 0.16);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.12);
}

.section-nav-chip[hidden] {
  display: none;
}

.section-jump-target {
  scroll-margin-top: 18px;
}

.section-jump-target.section-jump-highlight {
  animation: sectionJumpHighlight 1.25s ease-out;
}

@keyframes sectionJumpHighlight {
  0% { box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.75), 0 0 28px rgba(56, 189, 248, 0.22); }
  100% { box-shadow: var(--shadow-card); }
}

.stock-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.time-range-group {
  display: flex;
  background: rgba(15, 23, 42, 0.9);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.range-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
}

.range-btn:hover {
  color: #fff;
}

.range-btn.active {
  background: linear-gradient(135deg, #4f46e5, #0284c7);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
  border: none;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-highlight);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

.btn-outline:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--accent-indigo);
}

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

/* ==========================================================================
   KPI Cards Grid
   ========================================================================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.glass-card {
  background: var(--bg-glass-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  transition: transform 0.25s ease, border-color 0.25s ease;
  position: relative;
  overflow: hidden;
}

.glass-card:hover {
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-2px);
}

.card-glow-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
}

.card-glow-indigo::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #6366f1, #a855f7);
}

.card-glow-amber::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #f59e0b, #ec4899);
}

.card-glow-cyan::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #10b981, #06b6d4);
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.kpi-badge, .kpi-icon-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  font-family: var(--font-mono);
}

.kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 14px;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

.kpi-unit {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.kpi-sub-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.sub-metric {
  display: flex;
  flex-direction: column;
}

.sub-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.sub-val {
  font-size: 0.88rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.sub-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.08);
}

.kpi-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.kpi-projected-ttm {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(129, 140, 248, 0.22);
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.08);
}

.kpi-projected-ttm-main {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
}

.kpi-projected-ttm-label,
.kpi-projected-ttm-unit {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.kpi-projected-ttm-value {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 800;
  color: #a5b4fc;
}

.kpi-projected-ttm-source {
  flex: 0 0 auto;
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.kpi-extrema-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.extrema-item {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
}

.extrema-label {
  color: var(--text-secondary);
  width: 75px;
}

.extrema-val {
  font-family: var(--font-mono);
  font-weight: 700;
  margin-right: 6px;
}

.extrema-q {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.kpi-rating-box {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.rating-badge-large {
  font-size: 1.1rem;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald-light);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* ==========================================================================
   Valuation & Reasonable Price Range Calculator Section
   ========================================================================== */

.valuation-section {
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid rgba(56, 189, 248, 0.25);
  background: linear-gradient(180deg, rgba(22, 33, 54, 0.85) 0%, rgba(15, 23, 42, 0.9) 100%);
  position: relative;
}

.valuation-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #38bdf8, #818cf8, #34d399);
}

.valuation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.valuation-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.val-icon-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.valuation-title-group h3 {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
}

.valuation-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.val-model-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: rgba(15, 23, 42, 0.9);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.val-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.val-tab:hover {
  color: #fff;
}

.val-tab.active {
  background: linear-gradient(135deg, #4f46e5, #0284c7);
  color: #fff;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.3);
}

.val-tab-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
  transition: var(--transition-fast);
  pointer-events: none;
}

.val-tab-badge.badge-recommended {
  background: rgba(251, 191, 36, 0.22);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.5);
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.25);
  animation: pulseBadge 2.5s infinite ease-in-out;
}

@keyframes pulseBadge {
  0%, 100% { opacity: 0.95; }
  50% { opacity: 1; transform: scale(1.04); }
}

.val-tab.active .val-tab-badge.badge-recommended {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: none;
  animation: none;
}

.val-tab-badge.badge-suitable {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.val-tab.active .val-tab-badge.badge-suitable {
  background: rgba(255, 255, 255, 0.22);
  color: #e0f2fe;
  border-color: rgba(255, 255, 255, 0.5);
}

.val-tab-badge.badge-caution {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.val-tab.active .val-tab-badge.badge-caution {
  background: rgba(255, 255, 255, 0.2);
  color: #ffe4e6;
  border-color: rgba(255, 255, 255, 0.4);
}

/* Smart Valuation Recommendation Bar */
.val-smart-recommendation-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.92));
  border: 1px solid rgba(99, 102, 241, 0.3);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  margin-bottom: 14px;
  transition: all 0.3s ease;
}

.val-smart-recommendation-bar.hidden {
  display: none !important;
}

.val-rec-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.val-rec-icon {
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(99, 102, 241, 0.35);
  flex-shrink: 0;
}

.val-rec-text-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.82rem;
}

.val-rec-header-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.val-rec-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.val-rec-title {
  color: #f1f5f9;
  font-size: 0.84rem;
  font-weight: 700;
}

.val-rec-desc {
  color: var(--text-secondary);
  line-height: 1.4;
}

.val-rec-caution {
  color: #fb7185;
  font-size: 0.76rem;
  line-height: 1.3;
}

.val-rec-action {
  flex-shrink: 0;
}

.val-rec-apply-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.16);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
}

.val-rec-apply-btn:hover {
  background: linear-gradient(135deg, #4f46e5, #0284c7);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.45);
}

.val-rec-apply-btn.active-match {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.4);
  cursor: default;
}

/* Market Compare Summary Banner inside Valuation */
.val-market-compare-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  background: rgba(15, 23, 42, 0.85);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(56, 189, 248, 0.25);
  margin-bottom: 18px;
}

.market-compare-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.banner-stock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.banner-stock-name {
  font-size: 0.9rem;
  font-weight: 800;
  color: #f8fafc;
}

.banner-stock-id {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.banner-tag {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.banner-price {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
}

.banner-sub {
  font-size: 0.8rem;
  color: var(--accent-cyan);
}

.market-compare-right {
  display: flex;
  align-items: center;
}

.gap-text {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.gap-premium {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose-light);
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.gap-discount {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald-light);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.gap-fair {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.valuation-body {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 24px;
  align-items: center;
}

@media (max-width: 992px) {
  .valuation-body {
    grid-template-columns: 1fr;
  }
}

/* Valuation Controls */
.val-controls-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(15, 23, 42, 0.6);
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.val-controls-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.val-preset-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.val-preset-tag.etf-preset {
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
}

.val-preset-tag.user-preset {
  color: #34d399;
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.val-preset-tag.local-preset {
  color: #a78bfa;
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.4);
}

.val-preset-tag .preset-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
}

.val-control-set {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.val-control-set.active {
  display: flex;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.slider-val {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
}

.text-cyan {
  color: var(--accent-cyan) !important;
}

.custom-range {
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.custom-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.custom-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

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

.price-input-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-wrap: wrap;
}

.price-input-bar label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.price-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.price-input-wrapper input {
  width: 140px;
  padding: 6px 12px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  outline: none;
}

.price-input-wrapper input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* Valuation Results Cards with Explicit Interval Badges */
.val-results-box {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.price-cards-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 600px) {
  .price-cards-row {
    grid-template-columns: 1fr;
  }
}

.price-card {
  padding: 16px 14px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  transition: transform 0.2s ease;
}

.price-card:hover {
  transform: translateY(-2px);
}

.card-cheap {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.1);
}
.card-cheap .price-tag-val {
  color: var(--accent-emerald-light);
}

.card-fair {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.1);
}
.card-fair .price-tag-val {
  color: #38bdf8;
}

.card-expensive {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.3);
  box-shadow: 0 4px 15px rgba(244, 63, 94, 0.1);
}
.card-expensive .price-tag-val {
  color: var(--accent-rose-light);
}

.price-tag-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.price-range-badge {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  margin: 2px 0;
  letter-spacing: 0.02em;
}

.badge-green {
  background: rgba(16, 185, 129, 0.18);
  color: var(--accent-emerald-light);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-blue {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.badge-red {
  background: rgba(244, 63, 94, 0.18);
  color: var(--accent-rose-light);
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.price-tag-val {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.price-tag-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Verdict & Range Bar */
.valuation-verdict-box {
  background: rgba(15, 23, 42, 0.7);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.verdict-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.verdict-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.verdict-badge {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.verdict-badge.status-cheap {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald-light);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.verdict-badge.status-fair {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.verdict-badge.status-expensive {
  background: rgba(244, 63, 94, 0.2);
  color: var(--accent-rose-light);
  border: 1px solid rgba(244, 63, 94, 0.4);
}

/* Gauge Bar */
.gauge-bar-container {
  position: relative;
  padding-top: 24px;
  padding-bottom: 6px;
}

.gauge-bar {
  height: 28px;
  border-radius: var(--radius-md);
  display: flex;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.gauge-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  position: relative;
}

.sec-name {
  font-size: 0.68rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.1;
}

.sec-range-text {
  font-size: 0.62rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.1;
}

.sec-cheap {
  background: linear-gradient(90deg, #059669, #10b981);
}

.sec-fair {
  background: linear-gradient(90deg, #0284c7, #38bdf8);
}

.sec-expensive {
  background: linear-gradient(90deg, #e11d48, #f43f5e);
}

.gauge-pointer {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  z-index: 10;
}

.gauge-pointer.hidden {
  display: none !important;
}

.pointer-label {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 800;
  background: #fff;
  color: #0f172a;
  padding: 1px 6px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}

.pointer-pin {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #fff;
}

.gauge-ticks-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding-top: 6px;
}

.gauge-tick {
  display: inline-block;
}

.tick-mid {
  color: var(--accent-cyan);
  font-weight: 700;
}

/* ==========================================================================
   Charts Section
   ========================================================================== */

.chart-section {
  padding: 24px;
  margin-bottom: 20px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chart-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chart-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.chart-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.chart-tab.active {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.25), rgba(6, 182, 212, 0.25));
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.2);
}

.chart-tip {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.chart-body {
  position: relative;
  width: 100%;
  min-height: 440px;
}

.chart-body:has(#klineChartContainer.active) {
  min-height: 920px;
}

.chart-canvas-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#klineChartContainer.chart-canvas-wrapper {
  position: relative;
  height: auto;
  min-height: 920px;
  display: none;
}

#klineChartContainer.chart-canvas-wrapper.active {
  display: block;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 2;
}

.chart-canvas-wrapper.active:not(#klineChartContainer) {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 2;
}

/* The comparison view has no in-flow chart child to establish its height.
   Give its ECharts host an explicit box instead of relying on 100% of a
   parent that only has min-height. */
#compareChartContainer.chart-canvas-wrapper {
  position: relative;
  top: auto;
  left: auto;
  width: 100%;
  height: 440px;
}

/* ==========================================================================
   Data Tables & Sub-Tabs
   ========================================================================== */

.table-section {
  padding: 24px;
}

.table-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}

.table-title-group h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.table-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Table Mode Sub-Tabs (Segment Control) */
.table-mode-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.85);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  gap: 4px;
}

.table-mode-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.table-mode-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.table-mode-btn.active {
  background: linear-gradient(135deg, #3b82f6, #0284c7);
  color: #fff;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.4);
}

/* Dividend KPI Summary Strip */
.dividend-kpi-strip {
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  animation: fadeIn 0.25s ease-out;
}

.dividend-kpi-strip.hidden {
  display: none !important;
}

.monthly-revenue-kpi-strip {
  border-color: rgba(16, 185, 129, 0.28);
  background: linear-gradient(135deg, rgba(6, 78, 59, 0.2), rgba(15, 23, 42, 0.78));
}

.dividend-fill-kpi-strip {
  border-color: rgba(168, 85, 247, 0.28);
  background: linear-gradient(135deg, rgba(88, 28, 135, 0.18), rgba(15, 23, 42, 0.85));
}

.monthly-high-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
  color: #7dd3fc;
  font-size: 0.76rem;
  font-weight: 700;
}

.monthly-high-badge.record {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fcd34d;
}

.div-kpi-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.div-kpi-sub {
  font-size: 0.72rem;
  color: #94a3b8;
  font-family: var(--font-mono);
}

.strategy-insight-item {
  min-width: 220px;
  max-width: 320px;
  align-items: flex-start;
  gap: 3px;
}

.strategy-badge-wrapper {
  margin-top: 2px;
}

.badge-strategy {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.badge-strategy.bullish {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.45);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.badge-strategy.positive {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.badge-strategy.warning {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.badge-strategy.danger {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
}

.etf-nav-composition-kpi .strategy-summary-text {
  max-width: 360px;
}

.badge-strategy.caution {
  background: rgba(248, 113, 113, 0.2);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.4);
}

.badge-strategy.neutral {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.strategy-summary-text {
  font-size: 0.73rem;
  color: #cbd5e1;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.div-kpi-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.div-kpi-val {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.div-kpi-divider {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.08);
}

.text-purple {
  color: #c084fc !important;
}

.text-amber {
  color: #fcd34d !important;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 189, 248, 0.3) rgba(15, 23, 42, 0.6);
}

.table-wrapper::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.3);
  border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.5);
}

#screenerTableWrapper,
.table-wrapper.table-scrollable {
  max-height: 680px;
  overflow-y: auto;
  overflow-x: auto;
}

.financial-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
  white-space: nowrap;
}

.financial-table th {
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

#backtestLedgerTable th,
.table-wrapper[style*="overflow-y"] .financial-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #0f172a;
  box-shadow: 0 1px 0 var(--border-subtle);
}

.financial-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  transition: background-color 0.15s ease;
}

#quarterlyTable th:first-child,
#quarterlyTable tbody tr:not(.eps-estimate-reason-row) td:first-child {
  width: 1%;
  min-width: 145px;
}

#quarterlyTable th:nth-child(2),
#quarterlyTable tbody tr:not(.eps-estimate-reason-row) td:nth-child(2) {
  width: 1%;
  min-width: 110px;
}

#quarterlyTable th:nth-child(3),
#quarterlyTable tbody tr:not(.eps-estimate-reason-row) td:nth-child(3) {
  width: 1%;
  min-width: 76px;
}

.financial-table tbody tr:hover td {
  background: rgba(56, 189, 248, 0.06);
}

/* 篩選排行榜：橫向捲動時凍結「標的代號 / 標的名稱」兩欄，縱向捲動時凍結表頭 */
#screenerTable {
  border-collapse: separate;
  border-spacing: 0;
}

#screenerTable th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #0f172a;
  box-shadow: 0 1px 0 var(--border-subtle);
}

#screenerTable th:nth-child(-n + 2),
#screenerTable tbody tr:not(.table-empty-row) td:nth-child(-n + 2) {
  position: sticky;
  z-index: 4;
  background: #141d2f;
  background-clip: padding-box;
}

#screenerTable th:nth-child(-n + 2) {
  top: 0;
  z-index: 20;
  background: #0f172a;
}

#screenerTable th:nth-child(1),
#screenerTable tbody tr:not(.table-empty-row) td:nth-child(1) {
  left: 0;
  width: 110px;
  min-width: 110px;
}

/* left 必須等於第一欄的寬度，調整代號欄寬度時要同步改這裡 */
#screenerTable th:nth-child(2),
#screenerTable tbody tr:not(.table-empty-row) td:nth-child(2) {
  left: 110px;
  border-right: 1px solid var(--border-subtle);
  box-shadow: 8px 0 12px -8px rgba(0, 0, 0, 0.7);
}

/* sticky 欄需自帶不透明底色，hover 時改用等效實色避免透出底層內容 */
#screenerTable tbody tr:not(.table-empty-row):hover td:nth-child(-n + 2) {
  background: #16273b;
}

@media (max-width: 768px) {
  /* 窄螢幕只鎖代號欄，避免固定區塊吃掉大半可視寬度 */
  #screenerTable th:nth-child(2),
  #screenerTable tbody tr:not(.table-empty-row) td:nth-child(2) {
    position: static;
    border-right: none;
    box-shadow: none;
  }

  #screenerTable th:nth-child(1),
  #screenerTable tbody tr:not(.table-empty-row) td:nth-child(1) {
    border-right: 1px solid var(--border-subtle);
    box-shadow: 8px 0 12px -8px rgba(0, 0, 0, 0.7);
  }
}

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

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

.text-green {
  color: var(--accent-emerald-light) !important;
}

.text-red {
  color: var(--accent-rose-light) !important;
}

.badge-growth {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
}

.badge-growth.pos {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald-light);
}

.badge-growth.neg {
  background: rgba(244, 63, 94, 0.12);
  color: var(--accent-rose-light);
}

.badge-growth.zero {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
}

.financial-table tbody tr.eps-estimate-row td {
  background: rgba(56, 189, 248, 0.07);
  border-top: 1px solid rgba(56, 189, 248, 0.35);
  border-bottom-color: rgba(56, 189, 248, 0.16);
}

.estimate-tag {
  display: inline-flex;
  margin-left: 5px;
  padding: 2px 7px;
  border: 1px solid rgba(56, 189, 248, 0.38);
  border-radius: var(--radius-full);
  color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.1);
  font-size: 0.68rem;
  font-weight: 700;
}

.estimate-eps-value {
  color: var(--accent-cyan);
  font-size: 0.9rem;
  font-weight: 800;
}

.estimate-eps-value small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 500;
}

.estimate-confidence {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
}

.estimate-confidence.high {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
}

.estimate-confidence.medium {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
}

.estimate-confidence.low {
  color: #fda4af;
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.35);
}

.estimate-confidence.actual {
  min-width: auto;
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.18);
  font-weight: 600;
}

.financial-table tbody tr.eps-estimate-reason-row td {
  padding: 9px 14px 11px;
  color: var(--text-secondary);
  background: rgba(15, 23, 42, 0.7);
  border-bottom: 1px solid rgba(56, 189, 248, 0.2);
  font-size: 0.72rem;
  line-height: 1.6;
  white-space: normal;
  overflow-wrap: anywhere;
}

.estimate-reason-title {
  margin-right: 7px;
  color: var(--accent-cyan);
  font-weight: 800;
}

.estimate-reason-item::after {
  content: '・';
  margin: 0 5px;
  color: var(--text-dim);
}

.estimate-reason-item:last-child::after {
  content: '';
  margin: 0;
}

/* Dividend Specific Badges */
.badge-payout {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
}

.badge-payout.high {
  background: rgba(168, 85, 247, 0.18);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.35);
}

.badge-payout.healthy {
  background: rgba(16, 185, 129, 0.18);
  color: var(--accent-emerald-light);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-payout.conservative {
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.badge-payout.none {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
}

.badge-fill-days {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
}

.badge-fill-days.fast {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-fill-days.normal {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-fill-days.slow {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.badge-fill-days.discount {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.badge-fill-days.pending {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.badge-fill-days.in-progress {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-frequency {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   Multi-Stock Comparison View
   ========================================================================== */

.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

.compare-hero-card {
  padding: 24px;
  margin-bottom: 20px;
  position: relative;
  z-index: 10;
}

.compare-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}

.compare-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
}

.compare-header .subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.compare-selectors {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  z-index: 20;
}

.compare-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.compare-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.compare-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid var(--accent-indigo);
  border-radius: var(--radius-full);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  user-select: none;
}

.compare-chip:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--accent-cyan);
}

.compare-chip .compare-chip-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.compare-chip .compare-chip-name {
  color: #fff;
  font-weight: 600;
}

.compare-chip .compare-chip-id {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-cyan);
  opacity: 0.9;
  font-weight: 600;
}

.compare-chip .remove-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  margin-left: 2px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.compare-chip .remove-btn:hover {
  background: rgba(244, 63, 94, 0.25);
  color: var(--accent-rose-light);
}

.compare-add-input-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 30;
}

.compare-add-input-wrapper input {
  padding: 7px 14px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  min-width: 200px;
}

.compare-add-input-wrapper input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* ==========================================================================
   Dividend Yield Screener View
   ========================================================================== */

.screener-title-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.screener-badge-icon {
  font-size: 1.5rem;
}

.screener-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-top: 14px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.filter-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  background: rgba(15, 23, 42, 0.9);
  padding: 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.filter-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.filter-btn:hover {
  color: #fff;
}

.filter-btn.active {
  background: linear-gradient(135deg, #4f46e5, #0284c7);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.35);
}

.filter-checkbox-group {
  margin-left: auto;
}

.multi-factor-filter-group {
  width: 100%;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.factor-select-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
}

.screener-factor-select {
  padding: 5px 9px;
  color: var(--text-primary);
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.factor-checkbox {
  padding: 5px 9px;
  border: 1px solid rgba(52, 211, 153, 0.2);
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.06);
}

.screener-factor-evidence-row {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 5px;
}

.screener-factor-evidence {
  padding: 2px 5px;
  color: #a5f3fc;
  background: rgba(8, 145, 178, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.18);
  border-radius: 999px;
  font-size: 0.66rem;
  white-space: nowrap;
}

.screener-factor-evidence.fcf {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(52, 211, 153, 0.3);
  font-weight: 600;
}

.screener-factor-evidence.cash-quality {
  color: #fde047;
  background: rgba(251, 191, 36, 0.15);
  border-color: rgba(251, 191, 36, 0.3);
  font-weight: 600;
}

.screener-search-input {
  padding: 6px 12px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
  width: 220px;
  transition: var(--transition-fast);
}

.screener-search-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--accent-emerald-light);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-emerald);
  cursor: pointer;
}

.btn-table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.76rem;
  text-decoration: none;
  border-radius: var(--radius-sm);
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.35);
  cursor: pointer;
  transition: var(--transition-fast);
  font-weight: 600;
  line-height: 1.4;
}

.btn-table-action:hover {
  background: var(--accent-cyan);
  color: #0f172a;
  text-decoration: none;
}

/* ==========================================================================
   Loading Overlay & Toasts
   ========================================================================== */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
  gap: 16px;
  transition: opacity 0.2s ease;
}

.loading-overlay.hidden {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), var(--glow-cyan);
  z-index: 1000;
  animation: slideInToast 0.3s ease;
}

.toast.hidden {
  display: none !important;
}

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

/* ==========================================================================
   Footer
   ========================================================================== */

.app-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 24px 0 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.app-footer .disclaimer {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

@media (max-width: 1024px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }
  .header-center {
    max-width: 100%;
  }
  .header-right {
    justify-content: space-between;
  }
  .chart-body {
    min-height: 380px;
    height: auto;
  }
  #compareChartContainer.chart-canvas-wrapper {
    height: 380px;
  }
  .stock-hero-actions {
    flex: 1 1 100%;
    align-items: stretch;
    width: 100%;
  }
  .stock-section-nav,
  .stock-controls {
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  .app-container {
    padding: 12px 14px 36px;
  }
  .stock-hero-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .stock-hero-actions {
    flex: none;
  }
  .stock-controls {
    width: 100%;
    justify-content: space-between;
  }
  .stock-section-nav {
    justify-content: flex-start;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .chart-body {
    min-height: 340px;
    height: auto;
  }
  #compareChartContainer.chart-canvas-wrapper {
    height: 340px;
  }
}

/* ==========================================================================
   API Settings Modal Styles
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 16px;
  animation: fadeIn 0.2s ease-out forwards;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-card {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
  animation: scaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-header .close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s;
}

.modal-header .close-btn:hover {
  color: #fff;
}

@keyframes scaleUp {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ==========================================================================
   Screener Universe Scope Modal & Trigger Styles
   ========================================================================== */

.modal-card-lg {
  max-width: 860px;
}

.header-actions-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-scope-info {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: var(--accent-cyan);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  transition: var(--transition-fast);
}

.btn-scope-info:hover {
  background: rgba(56, 189, 248, 0.22);
  color: #fff;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.25);
}

.scope-tip-link-btn {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0 4px;
  margin-left: 6px;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
  font-family: inherit;
}

.scope-tip-link-btn:hover {
  color: #fff;
}

.scope-notice-box {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.scope-notice-box p {
  margin-bottom: 8px;
}

.scope-tip-highlight {
  background: rgba(56, 189, 248, 0.08);
  border-left: 3px solid var(--accent-cyan);
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: #e2e8f0;
  font-size: 0.83rem;
  margin-top: 10px;
  line-height: 1.5;
}

.universe-sections-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.universe-cat-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  transition: border-color 0.2s ease;
}

.universe-cat-card:hover {
  border-color: rgba(56, 189, 248, 0.3);
}

.universe-cat-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.universe-tags-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.universe-tag {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.universe-tag:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent-cyan);
  color: #fff;
  transform: translateY(-1px);
}

.universe-tag.etf {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.universe-tag.etf:hover {
  background: rgba(16, 185, 129, 0.25);
  border-color: #34d399;
  color: #fff;
}

.universe-tag.etf-foreign {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.35);
  color: #d8b4fe;
}

.universe-tag.etf-foreign:hover {
  background: rgba(168, 85, 247, 0.28);
  border-color: #c084fc;
  color: #fff;
}

/* Screener Adjustable Yield Slider & Presets */
.screener-yield-control-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.screener-slider-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.9);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.screener-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 110px;
  height: 6px;
  background: #334155;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.screener-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.1s ease;
}

.screener-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #60a5fa;
}

.screener-yield-display {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 700;
  color: #38bdf8;
  min-width: 54px;
  text-align: center;
}

.yield-presets-group .filter-btn {
  padding: 4px 9px;
  font-size: 0.76rem;
}

/* Domestic vs Foreign ETF Badges */
.badge-etf-tw {
  background: rgba(16, 185, 129, 0.18) !important;
  color: #34d399 !important;
  border: 1px solid rgba(16, 185, 129, 0.35) !important;
  font-size: 0.72rem !important;
  padding: 1px 7px !important;
  border-radius: var(--radius-full) !important;
  font-weight: 700 !important;
}

.badge-etf-global {
  background: rgba(168, 85, 247, 0.18) !important;
  color: #c084fc !important;
  border: 1px solid rgba(168, 85, 247, 0.35) !important;
  font-size: 0.72rem !important;
  padding: 1px 7px !important;
  border-radius: var(--radius-full) !important;
  font-weight: 700 !important;
}

/* ==========================================================================
   20-Year Long-Term K-Line Chart Styles
   ========================================================================== */
.kline-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: 14px;
}

.kline-tool-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.kline-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.kline-btn-group {
  display: flex;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  padding: 2px;
  border-radius: var(--radius-sm);
}

.kline-btn {
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.kline-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.kline-btn.active {
  background: #38bdf8;
  color: #0f172a;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.kline-zoom-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.73rem;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 3px 8px;
  border-radius: 9999px;
  font-weight: 600;
  user-select: none;
  cursor: help;
  transition: all 0.2s ease;
}

.kline-zoom-hint:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.kline-ma-toggles {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.kline-toggle-label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}

.kline-toggle-label input[type="checkbox"] {
  accent-color: #38bdf8;
  cursor: pointer;
}

.ma-tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

.ma-tag.ma5 { background: rgba(251, 113, 133, 0.15); color: #fb7185; border: 1px solid rgba(251, 113, 133, 0.3); }
.ma-tag.ma8 { background: rgba(168, 85, 247, 0.15); color: #a855f7; border: 1px solid rgba(168, 85, 247, 0.3); }
.ma-tag.ma20 { background: rgba(56, 189, 248, 0.15); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.3); }
.ma-tag.ma60 { background: rgba(234, 179, 8, 0.15); color: #eab308; border: 1px solid rgba(234, 179, 8, 0.3); }
.ma-tag.ma240 { background: rgba(236, 72, 153, 0.15); color: #f472b6; border: 1px solid rgba(236, 72, 153, 0.3); }
.ma-tag.maboll { background: rgba(129, 140, 248, 0.15); color: #818cf8; border: 1px solid rgba(129, 140, 248, 0.3); }
.ma-tag.madiv { background: rgba(245, 158, 11, 0.18); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.4); }

.kline-tv-wrapper {
  position: relative;
  width: 100%;
  height: 800px;
  min-height: 700px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.kline-tv-container {
  width: 100%;
  height: 100%;
}

.kline-floating-legend {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  pointer-events: none;
  box-shadow: none;
  max-width: calc(100% - 120px);
  overflow: hidden;
  white-space: nowrap;
}

.legend-stock-title {
  font-weight: 700;
  color: #fff;
  font-size: 0.74rem;
}

.legend-item {
  font-family: var(--font-mono, monospace);
  font-size: 0.7rem;
}

.legend-item strong {
  color: #fff;
}

.kline-sub-indicator {
  font-size: 0.75rem;
  color: #94a3b8;
}

.kline-sub-indicator {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-adjusted-tag {
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
}

.legend-ma-row {
  display: flex;
  gap: 2px 6px;
  flex-wrap: wrap;
  font-family: var(--font-mono, monospace);
  font-size: 0.68rem;
  font-weight: 600;
}

/* Screener Pool Switcher */
.screener-pool-switcher {
  display: flex;
  background: rgba(15, 23, 42, 0.7);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  gap: 2px;
}

.pool-tab-btn {
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.pool-tab-btn:hover {
  color: #fff;
}

.pool-tab-btn.active {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

.btn-custom-pool-edit {
  border-color: rgba(245, 158, 11, 0.4) !important;
  color: #fbbf24 !important;
}

.btn-custom-pool-edit:hover {
  background: rgba(245, 158, 11, 0.15) !important;
  color: #fde68a !important;
}

/* Custom Watchlist Pool Management Modal */
.custom-pool-add-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.custom-pool-search-wrap {
  position: relative;
  flex: 1;
}

.custom-pool-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  color: #fff;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
}

.custom-pool-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.custom-pool-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: #0f172a;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
}

.custom-pool-dropdown-item {
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  font-size: 0.84rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background 0.15s;
}

.custom-pool-dropdown-item:hover {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
}

.custom-pool-batch-box {
  background: rgba(15, 23, 42, 0.4);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  margin-bottom: 18px;
}

.custom-pool-label {
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.custom-pool-chips-section {
  background: rgba(15, 23, 42, 0.5);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.custom-pool-chips-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.custom-pool-quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-text-action {
  background: none;
  border: none;
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 4px;
  transition: color 0.15s;
}

.btn-text-action:hover {
  color: #38bdf8;
}

.btn-text-action.text-red:hover {
  color: #f87171;
}

.custom-pool-chips-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 2px;
}

.custom-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #e2e8f0;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s;
}

.custom-chip:hover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
}

.custom-chip.chip-etf {
  border-color: rgba(16, 185, 129, 0.3);
  color: #a7f3d0;
}

.custom-chip.chip-foreign {
  border-color: rgba(168, 85, 247, 0.3);
  color: #e9d5ff;
}

.custom-chip-del {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.15s;
}

.custom-chip-del:hover {
  color: #f87171;
}

/* ==========================================================================
   User Authentication & Profile Header Styles
   ========================================================================== */

.user-auth-header-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.btn-auth-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.15), rgba(99, 102, 241, 0.2));
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  font-family: var(--font-main);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.1);
}

.btn-auth-trigger:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(99, 102, 241, 0.35));
  border-color: #38bdf8;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.25);
}

.user-profile-dropdown-container {
  position: relative;
}

.btn-user-profile {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #f8fafc;
  padding: 5px 12px 5px 6px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-user-profile:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}

.user-avatar-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid #38bdf8;
}

.user-avatar-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0284c7, #6366f1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.user-display-name {
  font-size: 0.86rem;
  font-weight: 600;
  max-width: 100px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #e2e8f0;
}

.user-sync-badge {
  font-size: 0.8rem;
  opacity: 0.9;
  transition: transform 0.2s;
}

.user-sync-badge.syncing {
  display: inline-block;
  animation: spin 1s linear infinite;
}

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

.user-profile-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 250px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 8px 0;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5), 0 0 20px rgba(56, 189, 248, 0.1);
  z-index: 1000;
  animation: fadeInDown 0.15s ease-out;
}

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

.user-menu-header {
  padding: 10px 16px 12px 16px;
}

.user-menu-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
}

.user-menu-email {
  font-size: 0.78rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.badge-provider {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 8px;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-radius: 4px;
  font-weight: 600;
}

.user-menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 4px 0;
}

.user-menu-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 9px 16px;
  font-size: 0.85rem;
  color: #cbd5e1;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
}

.user-menu-item:hover {
  background: rgba(56, 189, 248, 0.1);
  color: #fff;
}

.user-menu-item.text-amber:hover {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
}

.user-menu-item.text-danger:hover {
  background: rgba(244, 63, 94, 0.15);
  color: #fda4af;
}

/* ==========================================================================
   Auth Modal & Tabs
   ========================================================================== */

.modal-card-auth {
  max-width: 480px;
  width: 95%;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 30px rgba(56, 189, 248, 0.15);
}

.auth-modal-logo-badge {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(99, 102, 241, 0.3));
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.auth-tabs {
  display: flex;
  background: rgba(30, 41, 59, 0.7);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.auth-tab:hover {
  color: #e2e8f0;
}

.auth-tab.active {
  background: #0284c7;
  color: #fff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.auth-alert-box {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  margin-bottom: 14px;
  line-height: 1.5;
}

.auth-alert-box.success {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #6ee7b7;
}

.auth-alert-box.error {
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fda4af;
}

/* ==========================================================================
   Mobile layout hardening
   Keep long labels and desktop action groups from widening the page.
   ========================================================================== */

html {
  max-width: 100%;
  overflow-x: hidden;
}

.app-container,
.app-header,
.header-top-row,
.header-left,
.brand-logo,
.brand-text,
.header-right,
.main-content,
.view-section,
.glass-card {
  min-width: 0;
}

@media (max-width: 768px) {
  .app-container {
    width: 100%;
    max-width: 100%;
    padding: 10px 12px 28px;
    gap: 14px;
  }

  .app-header {
    padding: 14px;
    gap: 14px;
    border-radius: var(--radius-md);
  }

  .header-top-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 8px;
  }

  .header-left,
  .brand-logo {
    width: 100%;
  }

  .header-left {
    grid-column: 1 / -1;
    grid-row: 1;
    margin-bottom: 6px;
  }

  .logo-icon {
    flex: 0 0 42px;
  }

  .brand-text {
    overflow: hidden;
  }

  .brand-text h1 {
    font-size: 1.1rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .brand-text .sub-title {
    display: block;
    margin-top: 2px;
    font-size: 0.64rem;
    line-height: 1.35;
    white-space: normal;
  }

  .header-right {
    display: contents;
  }


  .header-right .notification-header-wrapper {
    grid-column: 1;
    grid-row: 2;
  }

  .header-right .user-auth-header-wrapper {
    grid-column: 2;
    grid-row: 2;
  }

  .header-right #dividendCalendarToggleBtn {
    grid-column: 1;
    grid-row: 3;
  }

  .header-right #screenerToggleBtn {
    grid-column: 2;
    grid-row: 3;
  }

  .header-right .market-badge {
    grid-column: 1 / -1;
    grid-row: 4;
    justify-content: center;
    min-width: 0;
    text-align: center;
    white-space: normal;
  }

  .header-right #compareModeToggleBtn {
    grid-column: 1;
    grid-row: 5;
  }

  .header-right #portfolioToggleBtn {
    grid-column: 2;
    grid-row: 5;
    justify-self: stretch;
  }

  .header-right > .btn,
  .header-right > .user-auth-header-wrapper,
  .header-right > .user-auth-header-wrapper > .btn,
  .header-right > .user-auth-header-wrapper > .user-profile-dropdown-container,
  .header-right .btn-user-profile {
    width: 100%;
    min-width: 0;
  }

  .header-right > .btn,
  .header-right > .user-auth-header-wrapper > .btn {
    padding: 8px 9px;
  }

  .header-right .btn span,
  .header-right .market-badge span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-center {
    min-width: 0;
  }

  .search-container input {
    padding-right: 58px;
    font-size: 0.84rem;
  }

  .quick-picks-bar,
  .stock-hero-card,
  .glass-card,
  .chart-section,
  .table-section,
  .compare-hero-card {
    padding: 16px;
  }

  .quick-picks-bar,
  .watchlist-section,
  .quick-picks-chips,
  .watchlist-chips,
  .stock-open-mode-container {
    max-width: 100%;
  }

  .stock-open-mode-container {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }

  .watchlist-separator {
    width: 100%;
    height: 1px;
    margin: 4px 0;
  }

  .stock-hero-card,
  .stock-title-row,
  .stock-price-banner,
  .stock-controls,
  .time-range-group,
  .chart-header,
  .table-header-row,
  .compare-header,
  .compare-selectors,
  .screener-filter-bar,
  .filter-group,
  .header-actions-group,
  .kline-toolbar,
  .custom-pool-add-row {
    max-width: 100%;
  }

  .stock-price-banner {
    width: 100%;
  }

  .stock-controls,
  .time-range-group {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .live-price-details {
    width: 100%;
    padding-left: 0;
    border-left: 0;
  }

  .table-mode-tabs,
  .screener-pool-switcher {
    max-width: 100%;
    overflow-x: auto;
  }

  .compare-add-input-wrapper,
  .compare-add-input-wrapper input,
  .screener-search-input,
  .custom-pool-search-wrap {
    width: 100%;
    min-width: 0;
  }

  .filter-checkbox-group {
    margin-left: 0;
  }

  .notification-dropdown-panel {
    position: fixed;
    top: 72px;
    left: 12px;
    right: 12px;
    width: auto;
    max-width: 440px;
    margin: 0 auto;
    max-height: calc(100vh - 90px);
    max-height: calc(100dvh - 90px);
    z-index: 10000;
  }

  .user-profile-menu {
    right: 0;
    left: auto;
    max-width: calc(100vw - 24px);
    width: 280px;
  }

  .modal-overlay {
    padding: 10px;
  }

  .modal-card,
  .modal-card-auth {
    max-width: calc(100vw - 20px);
  }
}

@media (max-width: 380px) {
  .header-right {
    grid-template-columns: 1fr;
  }

  .header-right .market-badge {
    grid-column: auto;
  }

  .stock-name {
    font-size: 1.45rem;
  }

  .range-btn,
  .chart-tab,
  .table-mode-btn {
    padding-left: 10px;
    padding-right: 10px;
  }
}

.auth-panel {
  display: none;
}

.auth-panel.active {
  display: block;
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.google-auth-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.google-benefit-card {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.benefit-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.benefit-icon {
  font-size: 1.2rem;
  line-height: 1.2;
}

.benefit-item strong {
  display: block;
  font-size: 0.86rem;
  color: #f1f5f9;
  margin-bottom: 2px;
}

.google-btn-wrapper {
  display: flex;
  justify-content: center;
  margin: 8px 0;
  min-height: 44px;
}

.google-fallback-notice {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.8rem;
  color: #fcd34d;
  line-height: 1.5;
}

/* ==========================================================================
   Portfolio & Dividend Tracker Styles
   ========================================================================== */

.btn-portfolio {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.4);
}

.btn-portfolio:hover,
.btn-portfolio.active {
  background: linear-gradient(135deg, #10b981, #0891b2);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
}

/* ==========================================================================
   Dividend Calendar
   ========================================================================== */

.calendar-hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  margin-bottom: 16px;
}

.calendar-title-row,
.calendar-header-actions,
.calendar-legend,
.calendar-agenda-item {
  display: flex;
  align-items: center;
}

.calendar-title-row { gap: 14px; }
.calendar-title-icon { font-size: 2rem; }
.calendar-title-row h2 { font-size: 1.35rem; margin-bottom: 3px; }
.calendar-title-row p,
.calendar-panel-header p { color: var(--text-muted); font-size: 0.82rem; }
.calendar-header-actions { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.calendar-header-actions .btn { min-width: 40px; }

.calendar-month-input {
  min-height: 38px;
  padding: 7px 10px;
  color: var(--text-primary);
  color-scheme: dark;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font: 600 0.85rem var(--font-mono);
}

.calendar-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.calendar-kpi-card {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 15px 18px;
}

.calendar-kpi-card span { color: var(--text-secondary); font-size: 0.82rem; margin-right: auto; }
.calendar-kpi-card strong { color: var(--accent-cyan); font: 700 1.65rem var(--font-mono); }
.calendar-kpi-card small { color: var(--text-muted); }
.calendar-kpi-ex strong { color: #34d399; }
.calendar-kpi-pay strong { color: #fbbf24; }

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.calendar-panel,
.calendar-agenda { padding: 20px; }
.calendar-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.calendar-panel-header h3 { font-size: 1rem; margin-bottom: 3px; }
.calendar-legend { gap: 14px; color: var(--text-secondary); font-size: 0.78rem; }
.calendar-legend span { display: inline-flex; align-items: center; gap: 5px; }
.calendar-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.calendar-dot.ex { background: #10b981; box-shadow: 0 0 8px rgba(16, 185, 129, 0.7); }
.calendar-dot.pay { background: #f59e0b; box-shadow: 0 0 8px rgba(245, 158, 11, 0.7); }

.calendar-weekdays,
.dividend-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.calendar-weekdays span {
  padding: 7px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
}
.calendar-day {
  min-height: 112px;
  padding: 8px;
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.38);
}
.calendar-day:nth-child(7n + 1) { border-left: 1px solid var(--border-subtle); }
.calendar-day:nth-child(-n + 7) { border-top: 1px solid var(--border-subtle); }
.calendar-day-empty { background: rgba(15, 23, 42, 0.14); }
.calendar-day-number {
  display: inline-flex;
  width: 25px;
  height: 25px;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font: 600 0.75rem var(--font-mono);
}
.calendar-day.is-today .calendar-day-number { color: #fff; background: var(--accent-indigo); border-radius: 50%; }
.calendar-day-events { display: flex; flex-direction: column; gap: 4px; margin-top: 5px; }
.calendar-event {
  width: 100%;
  border: 0;
  border-radius: 5px;
  padding: 4px 5px;
  overflow: hidden;
  color: #dbeafe;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  font: 600 0.68rem var(--font-mono);
}
.calendar-event span { margin-right: 4px; }
.calendar-event-ex { background: rgba(16, 185, 129, 0.2); border-left: 2px solid #10b981; }
.calendar-event-pay { background: rgba(245, 158, 11, 0.2); border-left: 2px solid #f59e0b; }
.calendar-event:hover { filter: brightness(1.35); }
.calendar-event-more { color: var(--text-muted); font-size: 0.68rem; padding-left: 4px; }

.calendar-agenda-list { max-height: 670px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.calendar-agenda-item {
  width: 100%;
  gap: 10px;
  padding: 10px;
  color: var(--text-primary);
  text-align: left;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.calendar-agenda-item:hover { border-color: var(--accent-cyan); transform: translateY(-1px); }
.calendar-agenda-item time { min-width: 36px; text-align: center; color: var(--text-muted); }
.calendar-agenda-item time strong { display: block; color: #fff; font: 700 1rem var(--font-mono); }
.calendar-agenda-item time span { font-size: 0.65rem; }
.calendar-event-kind { padding: 3px 6px; border-radius: 999px; font-size: 0.68rem; font-weight: 700; }
.calendar-event-kind.ex { color: #6ee7b7; background: rgba(16, 185, 129, 0.16); }
.calendar-event-kind.pay { color: #fcd34d; background: rgba(245, 158, 11, 0.16); }
.calendar-agenda-stock { min-width: 0; display: flex; flex-direction: column; }
.calendar-agenda-stock strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.82rem; }
.calendar-agenda-stock small { color: var(--text-muted); font-size: 0.7rem; }
.calendar-empty-state,
.calendar-load-error { grid-column: 1 / -1; padding: 48px 16px; text-align: center; color: var(--text-muted); }
.calendar-empty-state span { display: block; font-size: 2rem; margin-bottom: 8px; }
.calendar-empty-state strong { display: block; color: var(--text-secondary); }
.calendar-empty-state p { margin-top: 4px; font-size: 0.75rem; }

@media (max-width: 1050px) {
  .calendar-layout { grid-template-columns: 1fr; }
  .calendar-agenda-list { max-height: 420px; }
}

@media (max-width: 700px) {
  .calendar-hero-card { align-items: flex-start; flex-direction: column; }
  .calendar-header-actions { justify-content: flex-start; }
  .calendar-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calendar-panel { padding: 12px; overflow-x: auto; }
  .calendar-weekdays,
  .dividend-calendar-grid { min-width: 650px; }
  .calendar-day { min-height: 94px; }
}

.portfolio-hero-card {
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .portfolio-hero-card {
    flex-direction: column;
    align-items: flex-start;
  }
}

.portfolio-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.portfolio-title-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #34d399;
}

.portfolio-title-badge h2 {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0;
  color: #fff;
}

.portfolio-sync-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #34d399;
}

.portfolio-sync-status-badge.cloud {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.3);
  color: #38bdf8;
}

.portfolio-subtitle {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
  margin: 0;
  max-width: 760px;
}

.portfolio-hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* 8 KPI Cards Grid */
.portfolio-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

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

@media (max-width: 640px) {
  .portfolio-kpi-grid {
    grid-template-columns: 1fr;
  }
}

.portfolio-kpi-grid .kpi-card {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.portfolio-kpi-grid .kpi-title {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 600;
  margin-bottom: 6px;
}

.portfolio-kpi-grid .kpi-value {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: var(--font-numeric);
  margin-bottom: 4px;
  line-height: 1.2;
}

.portfolio-kpi-grid .kpi-subtitle {
  font-size: 0.74rem;
  color: #64748b;
}

/* Dual Charts Row */
.portfolio-charts-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
}

@media (max-width: 1024px) {
  .portfolio-charts-row {
    grid-template-columns: 1fr;
  }
}

.portfolio-charts-row .chart-card {
  padding: 20px;
  border-radius: var(--radius-xl);
}

/* Portfolio Table Details */
.portfolio-table th {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 12px 10px;
}

.portfolio-table td {
  font-size: 0.85rem;
  padding: 12px 10px;
  vertical-align: middle;
}

/* Sticky First Column for Portfolio Table */
.portfolio-table th:first-child,
.portfolio-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 5;
  background: #0f172a;
  min-width: 170px;
  box-shadow: 4px 0 10px rgba(0, 0, 0, 0.5);
  border-right: 1px solid rgba(56, 189, 248, 0.2);
}

.portfolio-table th:first-child {
  z-index: 6;
  background: #1e293b;
}

.portfolio-table tbody tr:hover td:first-child {
  background: #1e293b;
}

/* Accordion Drawer Row should not be sticky */
.portfolio-table tr.portfolio-tx-drawer-row td {
  position: static !important;
  box-shadow: none !important;
  border-right: none !important;
  background: rgba(15, 23, 42, 0.96) !important;
}

.portfolio-stock-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.portfolio-stock-link {
  font-weight: 700;
  color: #38bdf8;
  text-decoration: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.portfolio-stock-link .stock-link-ext-icon {
  font-size: 0.72rem;
  color: #38bdf8;
  opacity: 0.7;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.portfolio-stock-link:hover {
  text-decoration: underline;
  color: #7dd3fc;
}

.portfolio-stock-link:hover .stock-link-ext-icon {
  opacity: 1;
  transform: translate(2px, -2px);
  color: #67e8f9;
}

.portfolio-type-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.portfolio-type-pill.stock {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.portfolio-type-pill.etf {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.portfolio-actions-group {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-icon-action {
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  transition: all 0.15s ease;
}

.btn-icon-action:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.btn-icon-action.delete:hover {
  background: rgba(244, 63, 94, 0.2);
  border-color: rgba(244, 63, 94, 0.4);
  color: #f43f5e;
}

/* Empty State */
.portfolio-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.portfolio-empty-state.hidden {
  display: none !important;
}

.portfolio-empty-state .empty-state-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.portfolio-empty-state h4 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.portfolio-empty-state p {
  color: #94a3b8;
  font-size: 0.88rem;
  max-width: 480px;
  line-height: 1.5;
  margin-bottom: 20px;
}

/* Modal Calculation Preview Box */
.portfolio-modal-preview-box {
  background: rgba(15, 23, 42, 0.85);
  border: 1px dashed rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.portfolio-modal-preview-box .preview-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.portfolio-modal-preview-box .preview-label {
  font-size: 0.74rem;
  color: #94a3b8;
}

.portfolio-modal-preview-box .preview-val {
  font-size: 0.95rem;
  font-family: var(--font-numeric);
  font-weight: 700;
  color: #f8fafc;
}

/* Modal Form Controls & Inputs */
.form-control,
.form-input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-fast);
  box-sizing: border-box;
  font-family: inherit;
}

.form-control:focus,
.form-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
  background: rgba(15, 23, 42, 0.95);
}

.form-control:disabled {
  background: rgba(30, 41, 59, 0.5);
  color: #94a3b8;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.08);
}

.modal-card {
  overflow: visible !important;
}

.modal-close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.modal-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* Portfolio Display Mode Toggle Group */
.portfolio-mode-toggle-group {
  display: inline-flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 3px;
}

.portfolio-mode-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.portfolio-mode-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.portfolio-mode-btn.active {
  background: linear-gradient(135deg, #0ea5e9, #06b6d4);
  color: #fff;
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.4);
}

/* Multi-Portfolio Bucket Tab Pills */
.portfolio-tab-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.portfolio-tab-pill:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(56, 189, 248, 0.35);
}

.portfolio-tab-pill.active {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.22), rgba(6, 182, 212, 0.22));
  border-color: #38bdf8;
  color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

.portfolio-tab-badge {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 6px;
  border-radius: 10px;
  color: #cbd5e1;
}

.portfolio-tab-pill.active .portfolio-tab-badge {
  background: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  font-weight: 700;
}

/* Fee Discount Chips */
.fee-discount-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.fee-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fee-chip:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: #fff;
}

.fee-chip.active {
  background: rgba(56, 189, 248, 0.25);
  border-color: var(--accent-cyan);
  color: #38bdf8;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

/* Modal Tabs */
.btn-modal-tab {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-modal-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.btn-modal-tab.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-cyan);
  color: #38bdf8;
}

/* Modal Transaction Rows Editor */
/* 分批買入明細一列有五個欄位，共用的 480px modal 放不下，此對話框單獨加寬 */
#portfolioItemModal .modal-card {
  max-width: 620px;
}

.tx-item-card {
  display: grid;
  /* 日期欄需容納原生 date 輸入的 YYYY/MM/DD 與日曆圖示，低於 140px 會被截斷 */
  grid-template-columns: 72px 140px 84px 92px minmax(0, 1fr) 32px;
  gap: 8px;
  align-items: center;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
}

.tx-item-card .form-control {
  padding: 6px 8px;
  font-size: 0.82rem;
  min-width: 0;
}

/* 日期輸入內距收窄，把空間全留給日期文字本身 */
.tx-item-card .tx-row-date {
  padding-left: 6px;
  padding-right: 4px;
}

/* 賣出列以紅框標示，與買進列一眼區分 */
.tx-item-card.is-sell {
  border-color: rgba(244, 63, 94, 0.45);
  background: rgba(76, 5, 25, 0.35);
}

.tx-item-card .tx-row-type {
  padding-left: 6px;
  padding-right: 4px;
  background: rgba(15, 23, 42, 0.8);
  color: #fff;
}

/* 窄螢幕改為三列：買賣別獨佔一列，日期／股數／成交價一列，備註與刪除另起一列 */
@media (max-width: 560px) {
  .tx-item-card {
    grid-template-columns: 140px 1fr 1fr;
    row-gap: 6px;
  }

  .tx-item-card .tx-row-type {
    grid-column: 1 / -1;
  }

  .tx-item-card .tx-row-note {
    grid-column: 1 / 3;
  }
}

.btn-tx-delete {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fb7185;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s ease;
}

.btn-tx-delete:hover {
  background: #f43f5e;
  color: #fff;
}

/* Portfolio Table Transaction Expansion Drawer */
.btn-tx-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 4px;
  transition: all 0.15s ease;
}

.btn-tx-badge:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  color: #fff;
}

.portfolio-tx-drawer-row {
  background: rgba(15, 23, 42, 0.95);
}

.portfolio-tx-drawer-row > td {
  padding: 14px 20px !important;
  border-top: none !important;
  border-bottom: 2px solid rgba(56, 189, 248, 0.25) !important;
}

.portfolio-tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  background: rgba(30, 41, 59, 0.4);
  border-radius: 8px;
  overflow: hidden;
}

.portfolio-tx-table th {
  background: rgba(15, 23, 42, 0.8);
  color: #94a3b8;
  font-weight: 600;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.portfolio-tx-table td {
  padding: 8px 12px;
  color: #e2e8f0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.portfolio-tx-table tr:last-child td {
  border-bottom: none;
}

/* ==========================================================================
   Phase 2: Notification Center & Price / Yield Alert Styles
   ========================================================================== */

.notification-header-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.btn-notification-bell {
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-notification-bell:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.25);
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ef4444, #f43f5e);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.65);
  border: 2px solid #0f172a;
  animation: pulseNotifBadge 2s infinite;
}

@keyframes pulseNotifBadge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); box-shadow: 0 0 16px rgba(239, 68, 68, 0.9); }
}

/* Notification Dropdown Panel */
.notification-dropdown-panel {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 390px;
  max-width: calc(100vw - 24px);
  max-height: 520px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 16px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.6), 0 0 20px rgba(56, 189, 248, 0.12);
  display: flex;
  flex-direction: column;
  z-index: 10000;
  overflow: hidden;
  animation: dropdownSlideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.notif-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #f8fafc;
}

.notif-header-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.notif-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-text-action {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.btn-text-action:hover {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
}

.btn-close-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-close-circle:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

/* Tabs */
.notif-panel-tabs {
  display: flex;
  background: rgba(10, 15, 30, 0.6);
  padding: 4px 10px;
  gap: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.notif-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 6px 4px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #94a3b8;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
}

.notif-tab-btn:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.04);
}

.notif-tab-btn.active {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.14);
}

/* Items List */
.notif-items-container,
.alert-rules-container {
  padding: 10px;
  overflow-y: auto;
  max-height: 380px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notif-items-container::-webkit-scrollbar,
.alert-rules-container::-webkit-scrollbar {
  width: 5px;
}

.notif-items-container::-webkit-scrollbar-thumb,
.alert-rules-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

/* Empty State */
.notif-empty-state,
.alert-rules-empty-state {
  padding: 36px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #64748b;
}

.notif-empty-icon {
  font-size: 2.2rem;
  margin-bottom: 10px;
  opacity: 0.7;
}

.notif-empty-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.notif-empty-desc {
  font-size: 0.75rem;
  color: #64748b;
  line-height: 1.45;
  max-width: 280px;
}

/* Notification Card */
.notif-card {
  position: relative;
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 11px 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.notif-card:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.3);
  transform: translateX(2px);
}

.notif-card.unread {
  background: rgba(14, 165, 233, 0.09);
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.12);
}

.notif-card.unread::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 4px 4px 0;
  background: #38bdf8;
  box-shadow: 0 0 8px #38bdf8;
}

.notif-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.notif-stock-tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.notif-stock-tag.yield-tag {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.notif-time {
  font-size: 0.7rem;
  color: #64748b;
}

.notif-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: #f1f5f9;
  line-height: 1.35;
}

.notif-message {
  font-size: 0.76rem;
  color: #94a3b8;
  line-height: 1.45;
  white-space: pre-line;
}

.notif-card-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
}

/* Alert Rule Card inside Dropdown */
.alert-rule-card {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.2s ease;
}

.alert-rule-card:hover {
  border-color: rgba(56, 189, 248, 0.3);
}

.alert-rule-card.inactive {
  opacity: 0.5;
}

.alert-rule-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.alert-rule-stock {
  font-weight: 700;
  font-size: 0.85rem;
  color: #f8fafc;
}

.alert-rule-cond {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: #cbd5e1;
}

.cond-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.cond-badge.below { background: rgba(56, 189, 248, 0.15); color: #38bdf8; }
.cond-badge.above { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.cond-badge.yield { background: rgba(16, 185, 129, 0.15); color: #34d399; }

.alert-rule-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 2px;
}

.alert-rule-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-rule-action {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-rule-action:hover {
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
}

.btn-rule-action.danger:hover {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.1);
}

/* Alert Action Button in Valuation Banner */
.btn-alert-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(99, 102, 241, 0.18));
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #e0f2fe;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.15);
}

.btn-alert-action:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.3), rgba(99, 102, 241, 0.3));
  border-color: #38bdf8;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
}

/* Modal Styling for Alert */
.modal-card-alert {
  max-width: 540px;
  width: 95%;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(28px);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 20px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7), 0 0 30px rgba(56, 189, 248, 0.15);
}

.alert-modal-logo-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.alert-stock-info-card {
  background: rgba(30, 41, 59, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
}

.alert-stock-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.alert-stock-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffffff;
}

.alert-stock-code {
  font-size: 0.85rem;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
}

.alert-stock-type-tag {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-left: auto;
}

.alert-stock-metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 8px;
}

.alert-metric-item {
  display: flex;
  flex-direction: column;
}

.alert-metric-lbl {
  font-size: 0.68rem;
  color: #64748b;
}

.alert-metric-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f1f5f9;
}

/* Alert Type Selector Options */
.alert-type-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.alert-technical-hint {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  color: #94a3b8;
  font-size: 0.75rem;
  line-height: 1.5;
}

.cond-badge.technical {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
}

.backtest-technical-compare {
  margin-bottom: 24px;
  padding: 16px 20px;
  border-radius: 12px;
  border-left: 4px solid #a855f7;
  background: rgba(15, 23, 42, 0.85);
}

.backtest-technical-compare-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.backtest-technical-compare-head h4 {
  margin: 0;
  font-size: 0.95rem;
  color: #fff;
}

.backtest-technical-compare-note {
  font-size: 0.75rem;
  color: #94a3b8;
}

.backtest-technical-compare-scroll {
  overflow-x: auto;
}

.backtest-technical-compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  white-space: nowrap;
}

.backtest-technical-compare-table th,
.backtest-technical-compare-table td {
  padding: 6px 10px;
  text-align: right;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
}

.backtest-technical-compare-table th:first-child,
.backtest-technical-compare-table td:first-child {
  text-align: left;
}

.backtest-technical-compare-table th {
  color: #94a3b8;
  font-weight: 600;
}

.backtest-technical-compare-table tr.is-filtered td {
  background: rgba(168, 85, 247, 0.08);
  font-weight: 600;
}

.technical-factor-group {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.screener-factor-evidence.technical {
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.35);
}

.alert-type-option {
  position: relative;
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.alert-type-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.alert-type-option:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.25);
}

.alert-type-option.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: #38bdf8;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.2);
}

.option-icon {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.option-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #f8fafc;
}

.option-desc {
  font-size: 0.65rem;
  color: #94a3b8;
  margin-top: 2px;
  line-height: 1.3;
}

/* Presets */
.alert-presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preset-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.18s ease;
}

.preset-chip:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}

.input-with-unit {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-unit .form-input {
  width: 100%;
  padding-right: 36px;
}

.input-unit {
  position: absolute;
  right: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #94a3b8;
}

.alert-status-notice {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 12px;
}

.alert-status-notice.success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.alert-status-notice.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

/* Toast Container & Cards */
.toast-notification-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  min-width: 320px;
  max-width: 420px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5), 0 0 16px rgba(56, 189, 248, 0.2);
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.25s ease;
  cursor: pointer;
}

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

.toast-item.dismissing {
  opacity: 0;
  transform: translateX(30px) scale(0.9);
}

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

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #f8fafc;
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.76rem;
  color: #94a3b8;
  line-height: 1.4;
}

.toast-close-btn {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.toast-close-btn:hover {
  color: #f87171;
}

/* ==========================================================================
   External Notification Channels Modal Styles
   ========================================================================== */

.modal-card-channels {
  max-width: 820px;
  width: 95%;
}

.channel-modal-logo-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

.channel-tabs-bar {
  display: flex;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 14px 0 14px;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 189, 248, 0.25) transparent;
}

.channel-tabs-bar::-webkit-scrollbar {
  height: 4px;
}

.channel-tabs-bar::-webkit-scrollbar-track {
  background: transparent;
}

.channel-tabs-bar::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.25);
  border-radius: 4px;
}

.channel-tab-btn {
  flex: 1 1 0;
  justify-content: center;
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.channel-tab-btn:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.03);
}

.channel-tab-btn.active {
  color: #38bdf8;
  border-bottom-color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
  border-radius: 6px 6px 0 0;
}

.channel-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}

.channel-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.channel-toggle-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #f8fafc;
}

.channel-toggle-desc {
  font-size: 0.74rem;
  color: #94a3b8;
  margin-top: 2px;
}

.channel-status-pill {
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
}

.channel-status-pill.active {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.channel-guide-box {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 14px;
}

.guide-box-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 6px;
}

.guide-steps-list {
  margin: 0;
  padding-left: 18px;
  font-size: 0.76rem;
  color: #cbd5e1;
  line-height: 1.6;
}

.guide-steps-list code {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: var(--font-mono, monospace);
  color: #38bdf8;
}

.guide-steps-list strong {
  color: #f8fafc;
}

.link-cyan {
  color: #38bdf8;
  text-decoration: underline;
}

.link-cyan:hover {
  color: #7dd3fc;
}

.channel-test-action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.btn-test-channel {
  padding: 7px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.channel-test-status-msg {
  font-size: 0.78rem;
  padding: 6px 12px;
  border-radius: 6px;
  line-height: 1.4;
  flex: 1;
}

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

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

.input-with-action {
  position: relative;
  display: flex;
  align-items: center;
}

.btn-input-toggle-pw {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
  font-size: 0.9rem;
}

.btn-input-toggle-pw:hover {
  color: #fff;
}

/* ==========================================================================
   ETF Dividend Components & Breakdown Styles (Phase 3.1)
   ========================================================================== */

.etf-components-kpi-strip {
  position: relative;
  padding-top: 48px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(17, 24, 39, 0.9));
  border: 1px solid rgba(56, 189, 248, 0.25);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.etf-components-sync-tools {
  position: absolute;
  top: 10px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #94a3b8;
  font-size: 12px;
}

.etf-components-kpi-strip .strategy-insight-item {
  max-width: 460px;
}

.etf-components-kpi-strip .strategy-summary-text {
  display: block;
  overflow: visible;
}

.etf-components-refresh {
  padding: 6px 10px;
  font-size: 12px;
}

.text-purple {
  color: #c084fc !important;
}

.badge-etf-component {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
}

.badge-etf-component.c54 {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.badge-etf-component.c73 {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.badge-etf-component.eq-fund {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.badge-etf-component.c76 {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
  border: 1px solid rgba(168, 85, 247, 0.35);
}

.badge-strategy.bullish {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-strategy.positive {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.badge-strategy.warning {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* Cash Flow & Profit Cash Quality Badges */
.badge-cash-quality {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.02em;
  font-family: var(--font-main, inherit);
  transition: all 0.2s ease;
}

.badge-cash-quality.bullish {
  background: rgba(6, 182, 212, 0.18);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.4);
  box-shadow: 0 0 8px rgba(6, 182, 212, 0.15);
}

.badge-cash-quality.positive {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-cash-quality.neutral {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.badge-cash-quality.warning {
  background: rgba(249, 115, 22, 0.18);
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.4);
}

.badge-cash-quality.danger,
.badge-cash-quality.bearish {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.15);
}

/* Non-operating Income & Profit Quality Badges */
.badge-nonop {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1.3;
  cursor: help;
  white-space: nowrap;
}

.badge-nonop.warning {
  background: rgba(249, 115, 22, 0.18);
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.4);
}

.badge-nonop.danger {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.15);
}

.badge-nonop.info {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.nonop-badge-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.nonop-badge-group .badge-nonop {
  margin-left: 0;
}

.badge-nonop-pattern {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid rgba(100, 116, 139, 0.35);
  border-radius: 4px;
  background: rgba(100, 116, 139, 0.12);
  color: #cbd5e1;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: help;
  white-space: nowrap;
}

.badge-nonop-pattern.one-off {
  border-color: rgba(251, 146, 60, 0.45);
  background: rgba(249, 115, 22, 0.12);
  color: #fdba74;
}

.badge-nonop-pattern.recurring {
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(14, 165, 233, 0.1);
  color: #7dd3fc;
}

.badge-nonop-pattern.insufficient-baseline {
  color: #94a3b8;
}

.margin-inverted {
  color: #f87171 !important;
  font-weight: 700 !important;
}

.margin-inverted::after {
  content: ' ⚠️';
  font-size: 0.75rem;
}

.profit-quality-valuation-warning {
  background: rgba(249, 115, 22, 0.12);
  border: 1px solid rgba(249, 115, 22, 0.35);
  color: #fb923c;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 10px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.08);
}

.cash-flow-kpi-strip .div-kpi-item {
  min-width: 140px;
}

/* ETF Dividend Basis Switcher Bar (Actual vs Projected) */
.etf-dividend-basis-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 8px;
  padding: 6px 12px;
  margin-top: 8px;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.basis-bar-title {
  color: #38bdf8;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.basis-pill-group {
  display: inline-flex;
  gap: 6px;
  background: rgba(15, 23, 42, 0.8);
  padding: 3px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.basis-pill {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.basis-pill:hover {
  color: #fff;
}

.basis-pill.active {
  background: linear-gradient(135deg, #0284c7, #06b6d4);
  color: #fff;
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.35);
}

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

/* River Basis Switcher (P/E vs Dividend Yield for Individual Stocks) */
.river-basis-switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

.river-basis-switcher.hidden {
  display: none !important;
}

.river-switcher-label {
  color: #38bdf8;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.river-pill-group {
  display: inline-flex;
  gap: 5px;
  background: rgba(15, 23, 42, 0.85);
  padding: 3px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.river-pill {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.river-pill:hover {
  color: #fff;
}

.river-pill.active {
  background: linear-gradient(135deg, #0284c7, #06b6d4);
  color: #fff;
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.35);
}

/* ==========================================================================
   Backtesting & DCA Simulation (Phase 3.3) Styles
   ========================================================================== */

.btn-strategy-tab {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-strategy-tab:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.4) !important;
}

.btn-chip-xs {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-family: monospace;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-chip-xs:hover {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}

.btn-chip-xs.active {
  background: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.2);
}

.toggle-switch-sm {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.toggle-switch-sm input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider-sm {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.toggle-slider-sm:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

.toggle-switch-sm input:checked + .toggle-slider-sm {
  background-color: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

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

.backtest-target-chip {
  position: relative;
}

/* Fading a pre-rendered shadow layer in and out stays on the compositor.
   Animating box-shadow on the element itself repaints it every frame. */
.backtest-target-chip::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
  pointer-events: none;
  opacity: 0;
  animation: pulseGlow 3s infinite ease-in-out;
}

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

@media (prefers-reduced-motion: reduce) {
  .backtest-target-chip::after {
    animation: none;
  }
}

/* ==========================================================================
   Backtest Strategy Recommendation & Diagnostic Styles
   ========================================================================== */

.backtest-rec-banner {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.backtest-rec-banner:hover {
  border-left-color: #0ea5e9 !important;
  box-shadow: 0 6px 24px rgba(56, 189, 248, 0.12);
}

/* Dynamic Category Badges */
.badge-growth {
  background: rgba(56, 189, 248, 0.15) !important;
  color: #38bdf8 !important;
  border: 1px solid rgba(56, 189, 248, 0.35) !important;
}

.badge-cyclical {
  background: rgba(168, 85, 247, 0.18) !important;
  color: #c084fc !important;
  border: 1px solid rgba(168, 85, 247, 0.4) !important;
}

.badge-financial {
  background: rgba(34, 197, 94, 0.15) !important;
  color: #4ade80 !important;
  border: 1px solid rgba(34, 197, 94, 0.35) !important;
}

.badge-defensive {
  background: rgba(234, 179, 8, 0.15) !important;
  color: #facc15 !important;
  border: 1px solid rgba(234, 179, 8, 0.35) !important;
}

.badge-etf {
  background: rgba(99, 102, 241, 0.18) !important;
  color: #818cf8 !important;
  border: 1px solid rgba(99, 102, 241, 0.4) !important;
}

.badge-general {
  background: rgba(148, 163, 184, 0.15) !important;
  color: #cbd5e1 !important;
  border: 1px solid rgba(148, 163, 184, 0.3) !important;
}

/* Strategy Tab Badges */
.strategy-tab-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.strategy-tab-badge.badge-recommended {
  background: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.45);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.2);
}

.strategy-tab-badge.badge-suitable {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.strategy-tab-badge.badge-caution {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.strategy-tab-badge.badge-neutral {
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Post-Backtest Smart Diagnostic Card */
.backtest-diagnostic-card {
  transition: all 0.3s ease;
  animation: fadeIn 0.3s ease-out;
}

.backtest-diagnostic-card.diagnostic-warning {
  border-left: 4px solid #f59e0b !important;
  background: rgba(245, 158, 11, 0.08) !important;
  border-right: 1px solid rgba(245, 158, 11, 0.2) !important;
  border-top: 1px solid rgba(245, 158, 11, 0.2) !important;
  border-bottom: 1px solid rgba(245, 158, 11, 0.2) !important;
}

.backtest-diagnostic-card.diagnostic-success {
  border-left: 4px solid #10b981 !important;
  background: rgba(16, 185, 129, 0.08) !important;
  border-right: 1px solid rgba(16, 185, 129, 0.2) !important;
  border-top: 1px solid rgba(16, 185, 129, 0.2) !important;
  border-bottom: 1px solid rgba(16, 185, 129, 0.2) !important;
}

.backtest-diagnostic-card.diagnostic-info {
  border-left: 4px solid #38bdf8 !important;
  background: rgba(56, 189, 248, 0.08) !important;
  border-right: 1px solid rgba(56, 189, 248, 0.2) !important;
  border-top: 1px solid rgba(56, 189, 248, 0.2) !important;
  border-bottom: 1px solid rgba(56, 189, 248, 0.2) !important;
}





/* ===== 每月現金流試算機制說明框 ===== */
.cashflow-note {
  margin: 0 0 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(52, 211, 153, 0.06);
  border: 1px solid rgba(52, 211, 153, 0.18);
  border-left: 3px solid #34d399;
  font-size: 0.78rem;
  line-height: 1.65;
  color: var(--text-secondary, #94a3b8);
}

.cashflow-note-main {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.cashflow-note-icon {
  flex-shrink: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.cashflow-note strong {
  color: var(--text-primary, #e2e8f0);
  font-weight: 600;
}

.cashflow-note-hl {
  color: #34d399 !important;
}

.cashflow-note-sub {
  margin-top: 4px;
  font-size: 0.72rem;
  color: rgba(148, 163, 184, 0.85);
}

.cashflow-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin: 0 5px 0 0;
  vertical-align: baseline;
}

.cashflow-dot-ex { background: #34d399; }
.cashflow-dot-pay { background: #38bdf8; margin-left: 12px; }

.cashflow-note-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(148, 163, 184, 0.2);
}

.cashflow-stat {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(148, 163, 184, 0.1);
}

.cashflow-stat strong {
  font-family: 'JetBrains Mono', monospace;
}

.cashflow-stat-confirmed {
  background: rgba(52, 211, 153, 0.12);
  color: #6ee7b7;
}

.cashflow-stat-confirmed strong { color: #34d399; }

.cashflow-stat-estimated {
  background: rgba(148, 163, 184, 0.12);
}


/* ==========================================================================
   ETF Holdings & Constituents Visualization & Inverse ETF Cards (Phase 1)
   ========================================================================== */

.etf-holdings-chart-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.etf-holdings-kpi-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md, 8px);
  font-size: 0.85rem;
}

.etf-holdings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  width: 100%;
}

@media (max-width: 960px) {
  .etf-holdings-grid {
    grid-template-columns: 1fr;
  }
}

.etf-subchart-box {
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md, 8px);
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 460px;
}

.etf-subchart-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-light, #f8fafc);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 8px;
}

.etf-subchart-canvas {
  width: 100%;
  flex: 1;
  min-height: 400px;
}

/* Disclosure & Completeness Badges */
.badge-actual {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.78rem;
}

.badge-pcf {
  background: rgba(168, 85, 247, 0.18);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.35);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.78rem;
}

.badge-index {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.35);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.78rem;
}

.badge-full {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
}

.badge-top {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
}

/* Table Toolbar & Search Filter */
.etf-holdings-table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.etf-search-input {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 6px 12px;
  color: #fff;
  font-size: 0.85rem;
  width: 280px;
  outline: none;
  transition: all 0.2s ease;
}

.etf-search-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.etf-holding-name,
.etf-holding-quote {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.etf-holding-name {
  align-items: flex-start;
}

.etf-holding-industry {
  font-size: 0.75rem;
  font-weight: 400;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
}

.etf-holding-quote {
  align-items: flex-end;
  white-space: nowrap;
}

.etf-holding-change {
  font-size: 0.75rem;
}

.etf-price-up {
  color: #f87171;
}

.etf-price-down {
  color: #4ade80;
}

.etf-weight-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.etf-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

.etf-rank-badge.top-1 {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #0f172a;
}
.etf-rank-badge.top-2 {
  background: linear-gradient(135deg, #94a3b8, #cbd5e1);
  color: #0f172a;
}
.etf-rank-badge.top-3 {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #0f172a;
}

/* Stock In ETFs Section */
.stock-in-etfs-badge {
  font-size: 0.82rem;
  font-weight: 600;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 4px 10px;
  border-radius: 9999px;
  transition: all 0.2s ease;
}

.stock-in-etfs-badge.complete {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.3);
}

.stock-in-etfs-badge.partial {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.35);
}

.stock-in-etfs-badge.empty-complete {
  color: #94a3b8;
  background: rgba(148, 163, 184, 0.1);
  border-color: rgba(148, 163, 184, 0.25);
}

.stock-in-etfs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.stock-in-etf-card {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md, 8px);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.stock-in-etf-card:hover {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

.stock-in-etf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stock-in-etf-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: #f8fafc;
}

.stock-in-etf-weight {
  font-size: 1.1rem;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: #38bdf8;
}

.stock-in-etf-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #94a3b8;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 6px;
}

.stock-in-etfs-empty-card {
  grid-column: 1 / -1;
  background: rgba(15, 23, 42, 0.4);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md, 8px);
  padding: 20px 24px;
}

.stock-in-etfs-notice-incomplete,
.stock-in-etfs-notice-complete {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.stock-in-etfs-notice-incomplete .notice-icon,
.stock-in-etfs-notice-complete .notice-icon {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.stock-in-etfs-notice-incomplete .notice-content h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fbbf24;
  margin: 0 0 6px 0;
}

.stock-in-etfs-notice-complete .notice-content h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #94a3b8;
  margin: 0 0 6px 0;
}

.stock-in-etfs-notice-incomplete .notice-content p,
.stock-in-etfs-notice-complete .notice-content p {
  font-size: 0.85rem;
  color: #cbd5e1;
  line-height: 1.5;
  margin: 0;
}

/* ==========================================================================
   ETF Indicative NAV (iNAV) & Premium / Discount Styles
   ========================================================================== */

.badge-prem-disc {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-left: 4px;
}

.bg-high-premium {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.5);
  animation: pulse-border 2s infinite;
}

.bg-med-premium {
  background: rgba(249, 115, 22, 0.2);
  color: #fb923c;
  border: 1px solid rgba(249, 115, 22, 0.4);
}

.bg-slight-premium {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.bg-fair {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.bg-slight-discount {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.bg-med-discount {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.bg-high-discount {
  background: rgba(168, 85, 247, 0.25);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.5);
  animation: pulse-border 2s infinite;
}

.etf-inav-notice-strip {
  margin-top: 8px;
  padding: 6px 12px;
  background: rgba(30, 41, 59, 0.7);
  border-left: 3px solid #38bdf8;
  border-radius: 4px;
  font-size: 0.8rem;
  color: #94a3b8;
  line-height: 1.4;
}

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Optional low-load mode for older computers. */
html.low-performance .glow-sphere { display: none; }
html.low-performance *,
html.low-performance *::before,
html.low-performance *::after {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
