/* ==========================================================================
   FOREMAN TRADER ANALYST - TRADINGVIEW PRO TERMINAL STYLES
   Pixel-Perfect TradingView UI with Light & Dark Theme Support
   Vanilla CSS (Zero External Frameworks)
   ========================================================================== */

/* Terminal Container */
.foreman-pro-terminal {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid #2a2e39;
  display: flex;
  flex-direction: column;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif;
  user-select: none;
  width: 100%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  background: #131722;
  color: #d1d4dc;
}

[data-theme="light"] .foreman-pro-terminal {
  background: #ffffff;
  color: #131722;
  border-color: #e0e3eb;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
}

/* 1. TOP HEADER TOOLBAR */
.tv-topbar {
  height: 36px;
  background: #131722;
  border-bottom: 1px solid #2a2e39;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.4rem;
  font-size: 0.75rem;
  z-index: 50;
  gap: 0.35rem;
  overflow: visible;
  position: relative;
}

.tv-topbar::-webkit-scrollbar {
  display: none;
}

[data-theme="light"] .tv-topbar {
  background: #ffffff;
  border-bottom-color: #e0e3eb;
}

.tv-topbar-left {
  display: flex;
  align-items: center;
  gap: 0.12rem;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.tv-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.18rem;
  flex-wrap: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}

/* Symbol & Status Badge */
.tv-symbol-pill {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  background: rgba(41, 98, 255, 0.12);
  color: #2962ff;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  line-height: 1;
  flex-shrink: 0;
}

[data-theme="light"] .tv-symbol-pill {
  background: rgba(41, 98, 255, 0.08);
  color: #1e53e5;
}

.tv-market-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.12rem 0.32rem;
  border-radius: 3px;
  background: rgba(8, 153, 129, 0.15);
  color: #089981;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.tv-market-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #089981;
  animation: tvPulse 1.8s infinite;
}

@keyframes tvPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(8, 153, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 4px rgba(8, 153, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(8, 153, 129, 0); }
}

/* Toolbar Buttons & Dividers */
.tv-divider {
  width: 1px;
  height: 16px;
  background: #2a2e39;
  margin: 0 0.15rem;
  flex-shrink: 0;
}

[data-theme="light"] .tv-divider {
  background: #e0e3eb;
}

.tv-btn {
  background: transparent;
  border: none;
  color: #787b86;
  font-size: 0.73rem;
  font-weight: 600;
  padding: 0.18rem 0.35rem;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  transition: all 0.15s ease;
  height: 26px;
  white-space: nowrap;
  flex-shrink: 0;
}

.tv-btn:hover {
  color: #d1d4dc;
  background: #2a2e39;
}

[data-theme="light"] .tv-btn {
  color: #5d606b;
}

[data-theme="light"] .tv-btn:hover {
  color: #131722;
  background: #f0f3fa;
}

.tv-btn.active {
  color: #2962ff !important;
  background: rgba(41, 98, 255, 0.15) !important;
  font-weight: 700;
}

.tv-icon-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #787b86;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  flex-shrink: 0;
}

.tv-icon-btn:hover {
  color: #d1d4dc;
  background: #2a2e39;
}

[data-theme="light"] .tv-icon-btn {
  color: #5d606b;
}

[data-theme="light"] .tv-icon-btn:hover {
  color: #131722;
  background: #f0f3fa;
}

.tv-icon-btn.active {
  color: #2962ff;
  background: rgba(41, 98, 255, 0.15);
}

/* Technical Summary Signal Badge */
.tv-signal-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tv-signal-badge.strong-buy {
  background: rgba(8, 153, 129, 0.2);
  color: #089981;
  border: 1px solid rgba(8, 153, 129, 0.4);
}

.tv-signal-badge.buy {
  background: rgba(16, 185, 129, 0.15);
  color: #10B981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.tv-signal-badge.neutral {
  background: rgba(120, 123, 134, 0.15);
  color: #787b86;
  border: 1px solid rgba(120, 123, 134, 0.3);
}

.tv-signal-badge.sell {
  background: rgba(242, 54, 69, 0.15);
  color: #f23645;
  border: 1px solid rgba(242, 54, 69, 0.3);
}

.tv-signal-badge.strong-sell {
  background: rgba(183, 28, 28, 0.25);
  color: #ef5350;
  border: 1px solid rgba(239, 83, 80, 0.4);
}

/* Live Pulse State */
.tv-btn-live.active {
  background: rgba(8, 153, 129, 0.15) !important;
  color: #089981 !important;
  font-weight: 700;
}

.tv-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #089981;
  display: inline-block;
  animation: tvPulse 1.2s infinite;
}

/* 2. MAIN BODY (LEFT TOOLBAR + CHART VIEWPORT) */
.tv-main-body {
  display: flex;
  position: relative;
  height: 560px;
  background: #131722;
  overflow: hidden;
}

[data-theme="light"] .tv-main-body {
  background: #ffffff;
}

/* Left Vertical Drawing Toolbar */
.tv-left-toolbar {
  width: 44px;
  background: #131722;
  border-right: 1px solid #2a2e39;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.35rem 0;
  gap: 0.12rem;
  z-index: 15;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

.tv-left-toolbar::-webkit-scrollbar {
  display: none;
}

[data-theme="light"] .tv-left-toolbar {
  background: #ffffff;
  border-right-color: #e0e3eb;
}

.tv-tool-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  background: transparent;
  border: none;
  color: #787b86;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  flex-shrink: 0;
}

.tv-tool-btn:hover {
  color: #d1d4dc;
  background: #2a2e39;
}

[data-theme="light"] .tv-tool-btn {
  color: #5d606b;
}

[data-theme="light"] .tv-tool-btn:hover {
  color: #131722;
  background: #f0f3fa;
}

.tv-tool-btn.active {
  color: #2962ff;
  background: rgba(41, 98, 255, 0.15);
}

/* Tool Groups with Flyout Dropdowns (TradingView Style) */
.tv-tool-group {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tv-tool-btn.has-flyout {
  position: relative;
}

.tv-tool-arrow {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 2px 2px 0;
  pointer-events: auto;
  cursor: pointer;
  z-index: 5;
}

.tv-tool-arrow::after {
  content: '';
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 5px 5px;
  border-color: transparent transparent #787b86 transparent;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.tv-tool-btn:hover .tv-tool-arrow::after,
.tv-tool-btn.active .tv-tool-arrow::after {
  border-color: transparent transparent #2962ff transparent;
}

/* Flyout Floating Popup Panel */
.tv-tool-flyout {
  position: absolute;
  left: 44px;
  top: 0;
  background: #1e222d;
  border: 1px solid #2a2e39;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.4);
  min-width: 255px;
  max-height: 480px;
  overflow-y: auto;
  z-index: 999;
  padding: 6px 0;
  display: none;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: #363a45 transparent;
  animation: tvFlyoutFadeIn 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tvFlyoutFadeIn {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}

.tv-tool-flyout::-webkit-scrollbar {
  width: 4px;
}
.tv-tool-flyout::-webkit-scrollbar-thumb {
  background: #363a45;
  border-radius: 3px;
}

.tv-flyout-header {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #787b86;
  padding: 8px 14px 4px 14px;
  text-transform: uppercase;
}

.tv-flyout-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  color: #d1d4dc;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  user-select: none;
}

.tv-flyout-item:hover {
  background: #2a2e39;
  color: #ffffff;
}

.tv-flyout-item.active {
  background: rgba(41, 98, 255, 0.16);
  color: #2962ff;
  font-weight: 600;
}

.tv-flyout-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9db2c8;
  flex-shrink: 0;
}

.tv-flyout-item:hover .tv-flyout-icon,
.tv-flyout-item.active .tv-flyout-icon {
  color: #2962ff;
}

.tv-flyout-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tv-flyout-shortcut {
  font-size: 0.68rem;
  color: #787b86;
  font-family: monospace;
  background: #131722;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid #2a2e39;
  margin-left: auto;
}

.tv-flyout-divider {
  height: 1px;
  background: #2a2e39;
  margin: 4px 0;
}

/* Light Theme Flyout Styles */
[data-theme="light"] .tv-tool-flyout {
  background: #ffffff;
  border-color: #e0e3eb;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .tv-flyout-header {
  color: #787b86;
}
[data-theme="light"] .tv-flyout-item {
  color: #131722;
}
[data-theme="light"] .tv-flyout-item:hover {
  background: #f0f3fa;
  color: #2962ff;
}
[data-theme="light"] .tv-flyout-item.active {
  background: rgba(41, 98, 255, 0.1);
  color: #2962ff;
}
[data-theme="light"] .tv-flyout-divider {
  background: #e0e3eb;
}
[data-theme="light"] .tv-flyout-shortcut {
  background: #f0f3fa;
  border-color: #e0e3eb;
  color: #5d606b;
}
[data-theme="light"] .tv-tool-arrow {
  border-color: transparent transparent #5d606b transparent;
}

.tv-tool-divider {
  width: 20px;
  height: 1px;
  background: #2a2e39;
  margin: 0.2rem 0;
  flex-shrink: 0;
}

[data-theme="light"] .tv-tool-divider {
  background: #e0e3eb;
}

.tv-tool-spacer {
  flex: 1;
}

/* Chart Canvas Viewport */
.tv-chart-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  height: 100%;
  background: #131722;
}

[data-theme="light"] .tv-chart-viewport {
  background: #ffffff;
}

/* Interactive Drawing Overlay & Canvas */
.tv-drawing-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 12;
  pointer-events: none;
}

.tv-drawing-overlay.interactive {
  pointer-events: auto;
  cursor: crosshair !important;
}

.tv-drawing-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: rgba(19, 23, 34, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #d1d4dc;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  border: 1px solid rgba(41, 98, 255, 0.4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  display: none;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  animation: tvHintFade 0.2s ease;
}

[data-theme="light"] .tv-drawing-hint {
  background: rgba(255, 255, 255, 0.96);
  color: #131722;
  border-color: rgba(41, 98, 255, 0.5);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

@keyframes tvHintFade {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Top-Left Floating OHLC & Indicator Legend */
.tv-floating-legend {
  position: absolute;
  top: 10px;
  left: 14px;
  z-index: 20;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, sans-serif;
}

.tv-legend-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: #787b86;
  pointer-events: auto;
  line-height: 1.25;
  flex-wrap: wrap;
}

.tv-legend-title {
  font-weight: 800;
  color: #d1d4dc;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

[data-theme="light"] .tv-legend-title {
  color: #131722;
}

.tv-legend-val {
  font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, sans-serif;
  font-weight: 700;
  color: #d1d4dc;
}

[data-theme="light"] .tv-legend-val {
  color: #131722;
}

.tv-legend-up {
  color: #089981 !important;
}

.tv-legend-down {
  color: #f23645 !important;
}

.tv-legend-badge {
  background: #ff9800;
  color: #131722;
  font-size: 0.65rem;
  font-weight: 900;
  padding: 0.05rem 0.25rem;
  border-radius: 2px;
}

.tv-legend-sub-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.74rem;
  flex-wrap: wrap;
}

.tv-ind-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
}

/* Indicators Popover Drawer */
.tv-indicators-drawer {
  position: absolute;
  top: 42px;
  left: 80px;
  width: 320px;
  background: #1e222d;
  border: 1px solid #2a2e39;
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
  z-index: 120;
  padding: 0.6rem;
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  animation: tvFadeIn 0.15s ease-out;
}

[data-theme="light"] .tv-indicators-drawer {
  background: #ffffff;
  border-color: #e0e3eb;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

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

.tv-drawer-header {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #787b86;
  padding: 0.25rem 0.4rem 0.4rem;
  border-bottom: 1px solid #2a2e39;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

[data-theme="light"] .tv-drawer-header {
  border-bottom-color: #e0e3eb;
  color: #5d606b;
}

.tv-ind-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: #d1d4dc;
  transition: all 0.15s;
}

[data-theme="light"] .tv-ind-option {
  color: #131722;
}

.tv-ind-option:hover {
  background: #2a2e39;
}

[data-theme="light"] .tv-ind-option:hover {
  background: #f0f3fa;
}

.tv-ind-option.active {
  color: #2962ff;
}

.tv-ind-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.tv-ind-check {
  font-size: 0.85rem;
  font-weight: 800;
  color: #2962ff;
}

/* 3. BOTTOM STATUS BAR */
.tv-bottombar {
  height: 34px;
  background: #131722;
  border-top: 1px solid #2a2e39;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.65rem;
  font-size: 0.74rem;
  color: #787b86;
  z-index: 20;
}

[data-theme="light"] .tv-bottombar {
  background: #ffffff;
  border-top-color: #e0e3eb;
  color: #5d606b;
}

.tv-range-bar {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.tv-range-btn {
  background: transparent;
  border: none;
  color: #787b86;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.18rem 0.42rem;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s;
}

.tv-range-btn:hover {
  color: #d1d4dc;
  background: #2a2e39;
}

[data-theme="light"] .tv-range-btn:hover {
  color: #131722;
  background: #f0f3fa;
}

.tv-range-btn.active {
  color: #2962ff;
  font-weight: 700;
  background: rgba(41, 98, 255, 0.12);
}

.tv-clock-display {
  font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, monospace;
  font-size: 0.72rem;
  color: #787b86;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Fullscreen Mode */
.foreman-pro-terminal:fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0;
  border: none;
}

.foreman-pro-terminal:fullscreen .tv-main-body {
  height: calc(100vh - 74px) !important;
}

/* Responsive Terminal */
@media (max-width: 768px) {
  .tv-left-toolbar {
    display: none;
  }
  .tv-main-body {
    height: 440px;
  }
  .tv-topbar {
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tv-topbar::-webkit-scrollbar {
    display: none;
  }
}

/* ==========================================================================
   ADVANCED PRO FEATURES STYLES: 7 MAJOR TRADING TERMINAL EXTENSIONS
   ========================================================================== */

/* 1. Bar Replay Floating Controller */
.tv-replay-bar {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(19, 23, 34, 0.95);
  border: 1px solid #2962ff;
  border-radius: 8px;
  padding: 0.35rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  z-index: 50;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  animation: tvReplayPop 0.25s ease-out;
}

[data-theme="light"] .tv-replay-bar {
  background: rgba(255, 255, 255, 0.96);
  border-color: #2962ff;
  box-shadow: 0 8px 24px rgba(41, 98, 255, 0.15);
}

@keyframes tvReplayPop {
  0% { opacity: 0; transform: translate(-50%, -10px) scale(0.95); }
  100% { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.tv-replay-badge {
  background: #2962ff;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.tv-replay-btn {
  background: #2a2e39;
  border: 1px solid #363a45;
  color: #d1d4dc;
  border-radius: 4px;
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s;
}

.tv-replay-btn:hover {
  background: #363a45;
  color: #ffffff;
  border-color: #2962ff;
}

.tv-replay-btn.active {
  background: #2962ff;
  color: #fff;
  border-color: #2962ff;
}

[data-theme="light"] .tv-replay-btn {
  background: #f0f3fa;
  border-color: #e0e3eb;
  color: #131722;
}

[data-theme="light"] .tv-replay-btn:hover {
  background: #e0e3eb;
}

/* 2. Interactive KAP Events Markers */
.tv-kap-marker {
  position: absolute;
  bottom: 28px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  transform: translateX(-50%);
  z-index: 20;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tv-kap-marker:hover {
  transform: translateX(-50%) scale(1.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  z-index: 30;
}

.tv-kap-marker.dividend { background: #e91e63; }
.tv-kap-marker.earnings { background: #ff9800; }
.tv-kap-marker.buyback { background: #089981; }
.tv-kap-marker.conversion { background: #9c27b0; }
.tv-kap-marker.disclosure { background: #2962ff; }

/* 3. Dropdown Menu (Templates, Multi-chart grid, Indicators) */
.tv-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tv-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #1e222d;
  border: 1px solid #2a2e39;
  border-radius: 6px;
  padding: 0.35rem 0;
  min-width: 250px;
  z-index: 99999;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75);
  display: none;
  white-space: nowrap;
}

[data-theme="light"] .tv-dropdown-menu {
  background: #ffffff;
  border-color: #e0e3eb;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.tv-dropdown-item {
  padding: 0.45rem 0.85rem;
  font-size: 0.78rem;
  color: #d1d4dc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.tv-dropdown-item:hover {
  background: #2a2e39;
  color: #2962ff;
}

.tv-dropdown-item.active {
  background: rgba(41, 98, 255, 0.18);
  color: #2962ff !important;
  font-weight: 700;
}

[data-theme="light"] .tv-dropdown-item {
  color: #131722;
}

[data-theme="light"] .tv-dropdown-item:hover {
  background: #f0f3fa;
}

[data-theme="light"] .tv-dropdown-item.active {
  background: rgba(41, 98, 255, 0.1);
  color: #2962ff !important;
}

.tv-dropdown-header {
  padding: 0.35rem 0.85rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: #787b86;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tv-timeframe-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem !important;
  cursor: pointer;
}

.tv-timeframe-btn:hover, .tv-timeframe-btn.active {
  background: #2a2e39;
  color: #2962ff;
}

[data-theme="light"] .tv-timeframe-btn:hover, [data-theme="light"] .tv-timeframe-btn.active {
  background: #f0f3fa;
  color: #2962ff;
}

.tv-dropdown-divider {
  height: 1px;
  background: #2a2e39;
  margin: 0.3rem 0;
}

[data-theme="light"] .tv-dropdown-divider {
  background: #e0e3eb;
}

/* 4. Universal Modal Dialogs (Indicator Settings, Alerts, Compare) */
.tv-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: tvFadeIn 0.18s ease-out;
}

@keyframes tvFadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.tv-modal-card {
  background: #1e222d;
  border: 1px solid #2a2e39;
  border-radius: 10px;
  width: 440px;
  max-width: 92vw;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  color: #d1d4dc;
  font-family: inherit;
  animation: tvCardSlide 0.2s ease-out;
}

[data-theme="light"] .tv-modal-card {
  background: #ffffff;
  border-color: #e0e3eb;
  color: #131722;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
}

@keyframes tvCardSlide {
  0% { transform: scale(0.94) translateY(10px); }
  100% { transform: scale(1) translateY(0); }
}

.tv-modal-header {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid #2a2e39;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

[data-theme="light"] .tv-modal-header {
  border-bottom-color: #e0e3eb;
}

.tv-modal-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.tv-modal-close {
  background: transparent;
  border: none;
  color: #787b86;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
  border-radius: 4px;
}

.tv-modal-close:hover {
  color: #ffffff;
  background: #2a2e39;
}

.tv-modal-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 70vh;
  overflow-y: auto;
}

.tv-modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid #2a2e39;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
}

[data-theme="light"] .tv-modal-footer {
  border-top-color: #e0e3eb;
}

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

.tv-form-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: #787b86;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tv-form-input, .tv-form-select {
  background: #131722;
  border: 1px solid #2a2e39;
  color: #d1d4dc;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

.tv-form-input:focus, .tv-form-select:focus {
  border-color: #2962ff;
}

[data-theme="light"] .tv-form-input, [data-theme="light"] .tv-form-select {
  background: #f8fafc;
  border-color: #e0e3eb;
  color: #131722;
}

/* 5. Floating Alert Toast Notification */
.tv-alert-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e222d;
  border: 1px solid #2962ff;
  border-left: 4px solid #2962ff;
  border-radius: 8px;
  padding: 0.85rem 1.15rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 10000;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  max-width: 360px;
  color: #d1d4dc;
  animation: tvToastSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="light"] .tv-alert-toast {
  background: #ffffff;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  color: #131722;
}

@keyframes tvToastSlide {
  0% { opacity: 0; transform: translateX(50px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* 6. Multi-Chart Grid Layouts */
.tv-grid-container {
  display: grid;
  width: 100%;
  height: 100%;
  gap: 4px;
  background: #2a2e39;
}

[data-theme="light"] .tv-grid-container {
  background: #e0e3eb;
}

.tv-grid-1x1 {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.tv-grid-1x2 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}

.tv-grid-2x2 {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.tv-grid-cell {
  background: #131722;
  position: relative;
  overflow: hidden;
  height: 100%;
}

[data-theme="light"] .tv-grid-cell {
  background: #ffffff;
}

/* Pattern Recognition Tags on Canvas Overlay */
.tv-pattern-badge {
  position: absolute;
  padding: 0.2rem 0.45rem;
  background: rgba(41, 98, 255, 0.9);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 3px;
  pointer-events: none;
  z-index: 15;
  white-space: nowrap;
}
