/* TradingView-inspired theme (default: dark) */
:root,
html[data-theme="dark"] {
  --tv-bg: #131722;
  --tv-pane: #1e222d;
  --tv-deep: #0b0e14;
  --tv-border: #363a45;
  --tv-text: #d1d4dc;
  --tv-symbol-strong: #f0f3fa;
  --tv-muted: #787b86;
  --tv-accent: #2962ff;
  --tv-up: #089981;
  --tv-down: #f23645;
  --tv-header-h: 42px;
  --tv-rail-w: 52px;
  --tv-right-rail-w: 44px;
  --tv-watch-w: 360px;
  --tv-technicals-w: 320px;
  --tv-status-h: 28px;
  --tv-chart-tabs-bg: rgba(19, 23, 34, 0.94);
  --tv-hover: #2a2f3d;
  --tv-row-hover: rgba(30, 34, 45, 0.45);
  --tv-row-active: rgba(41, 98, 255, 0.14);
  --tv-news-headline: #e8eaed;
  --tv-news-body: #b0b8c4;
  --tv-news-meta-color: #9aa0ab;
  --tv-news-link-hover: #90caf9;
  --tv-news-symbol-border: #5f6672;
  --tv-sentiment-strong-buy-bg: rgba(8, 153, 129, 0.28);
  --tv-sentiment-strong-buy-text: #5eead4;
  --tv-sentiment-buy-bg: rgba(8, 153, 129, 0.16);
  --tv-sentiment-buy-text: #34d399;
  --tv-sentiment-neutral-bg: rgba(120, 123, 134, 0.22);
  --tv-sentiment-neutral-text: #b0b8c4;
  --tv-sentiment-sell-bg: rgba(242, 54, 69, 0.16);
  --tv-sentiment-sell-text: #f87171;
  --tv-sentiment-strong-sell-bg: rgba(242, 54, 69, 0.28);
  --tv-sentiment-strong-sell-text: #fca5a5;
}

html[data-theme="light"] {
  --tv-bg: #ffffff;
  --tv-pane: #f0f3fa;
  --tv-deep: #ffffff;
  --tv-border: #e0e3eb;
  --tv-text: #131722;
  --tv-symbol-strong: #131722;
  --tv-muted: #787b86;
  --tv-accent: #2962ff;
  --tv-up: #089981;
  --tv-down: #f23645;
  --tv-chart-tabs-bg: rgba(255, 255, 255, 0.94);
  --tv-hover: #e8ebf2;
  --tv-row-hover: rgba(240, 243, 250, 0.9);
  --tv-row-active: rgba(41, 98, 255, 0.12);
  --tv-news-headline: #131722;
  --tv-news-body: #5f6672;
  --tv-news-meta-color: #787b86;
  --tv-news-link-hover: #2962ff;
  --tv-news-symbol-border: #c8ccd6;
  --tv-sentiment-strong-buy-bg: rgba(8, 153, 129, 0.18);
  --tv-sentiment-strong-buy-text: #047857;
  --tv-sentiment-buy-bg: rgba(8, 153, 129, 0.12);
  --tv-sentiment-buy-text: #089981;
  --tv-sentiment-neutral-bg: rgba(120, 123, 134, 0.14);
  --tv-sentiment-neutral-text: #5f6672;
  --tv-sentiment-sell-bg: rgba(242, 54, 69, 0.12);
  --tv-sentiment-sell-text: #dc2626;
  --tv-sentiment-strong-sell-bg: rgba(242, 54, 69, 0.18);
  --tv-sentiment-strong-sell-text: #b91c1c;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, sans-serif;
  background: var(--tv-bg);
  color: var(--tv-text);
  display: flex;
  flex-direction: column;
}

/* Top header */
.tv-header {
  height: var(--tv-header-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-bottom: 1px solid var(--tv-border);
  background: var(--tv-bg);
}
.tv-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
.tv-header-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.tv-auth-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.tv-auth-user {
  font-size: 12px;
  color: var(--tv-muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tv-auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--tv-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--tv-text);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.tv-auth-btn:hover {
  border-color: #2962ff;
  color: #2962ff;
}
.tv-auth-btn-muted {
  background: transparent;
  color: var(--tv-muted);
}
.tv-watch-guest {
  padding: 24px 16px;
  text-align: center;
  color: var(--tv-muted);
  font-size: 13px;
}
.tv-watch-guest p {
  margin: 0 0 12px;
}
.tv-watch-guest.hidden,
.tv-auth-btn.hidden,
.tv-auth-user.hidden {
  display: none !important;
}
.tv-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
}
.tv-logo-img {
  display: block;
  height: 26px;
  width: auto;
}
html[data-theme="light"] .tv-logo-img {
  filter: brightness(0);
}
.tv-symbol-block {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tv-symbol {
  font-size: 16px;
  font-weight: 600;
  color: var(--tv-symbol-strong);
}
.tv-indices-ticker {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  padding: 0 4px;
  position: relative;
}
.tv-indices-ticker::before,
.tv-indices-ticker::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 24px;
  z-index: 1;
  pointer-events: none;
}
.tv-indices-ticker::before {
  left: 0;
  background: linear-gradient(to right, var(--tv-bg), transparent);
}
.tv-indices-ticker::after {
  right: 0;
  background: linear-gradient(to left, var(--tv-bg), transparent);
}
.tv-indices-marquee {
  overflow: hidden;
  width: 100%;
}
.tv-indices-track {
  display: flex;
  align-items: center;
  gap: 28px;
  width: max-content;
  animation: tv-indices-scroll 90s linear infinite;
}
.tv-indices-ticker:hover .tv-indices-track {
  animation-play-state: paused;
}
@keyframes tv-indices-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .tv-indices-track {
    animation: none;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    gap: 10px 20px;
  }
}
.tv-index-item {
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-shrink: 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tv-index-item--etf .tv-index-label {
  color: var(--tv-text);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.tv-index-label {
  color: var(--tv-muted);
  font-weight: 500;
}
.tv-index-price {
  color: var(--tv-text);
  font-weight: 600;
}
.tv-index-chg.up { color: var(--tv-up); font-weight: 600; }
.tv-index-chg.down { color: var(--tv-down); font-weight: 600; }
.tv-index-chg.flat { color: var(--tv-muted); }
.tv-indices-empty {
  font-size: 12px;
  color: var(--tv-muted);
  white-space: nowrap;
}
.tv-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--tv-pane);
  border: 1px solid var(--tv-border);
  color: var(--tv-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.tv-renko-badge {
  font-weight: 500;
}

/* Main layout */
.tv-body {
  flex: 1;
  min-height: 0;
  display: flex;
}
.tv-rail {
  width: var(--tv-rail-w);
  flex-shrink: 0;
  background: var(--tv-bg);
  border-right: 1px solid var(--tv-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
}
.tv-rail button {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  font-size: 16px;
}
.tv-rail button:hover,
.tv-rail button.active {
  background: var(--tv-pane);
  color: var(--tv-text);
}
.tv-rail [data-tooltip] {
  position: relative;
}
.tv-rail [data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  padding: 5px 10px;
  background: var(--tv-pane);
  color: var(--tv-text);
  border: 1px solid var(--tv-border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.tv-rail [data-tooltip]:hover::after,
.tv-rail [data-tooltip]:focus-visible::after {
  opacity: 1;
  visibility: visible;
}
.tv-rail-add {
  width: 40px;
  height: 40px;
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
  border: 1px solid var(--tv-border);
  background: var(--tv-pane);
  color: var(--tv-text);
}
.tv-rail-add:hover {
  border-color: var(--tv-accent);
  color: #7eb0ff;
}
.tv-workspace-head {
  flex-shrink: 0;
  border-bottom: 1px solid var(--tv-border);
  background: var(--tv-bg);
}
.tv-asset-tabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 6px 8px;
  overflow-x: auto;
  min-height: 34px;
}
.tv-asset-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--tv-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.tv-asset-tab:hover {
  color: var(--tv-text);
  background: rgba(255, 255, 255, 0.04);
}
.tv-asset-tab.active {
  color: var(--tv-text);
  background: var(--tv-pane);
  border-color: var(--tv-border);
}
.tv-asset-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  font-size: 14px;
  line-height: 1;
  opacity: 0.6;
}
.tv-asset-tab-close:hover {
  opacity: 1;
  background: rgba(242, 54, 69, 0.2);
  color: #ff8a96;
}
.tv-strategy-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 8px 8px;
}
.tv-strategy-divider {
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: var(--tv-border);
}
.tv-strategy-bar .strategy-toggle,
.tv-strategy-bar .technicals-toggle {
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--tv-muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.tv-strategy-bar .strategy-toggle.active {
  background: rgba(41, 98, 255, 0.18);
  border-color: rgba(41, 98, 255, 0.55);
  color: #7eb0ff;
}
.tv-strategy-bar .strategy-toggle[data-strategy="cf"].active {
  background: rgba(8, 153, 129, 0.16);
  border-color: rgba(8, 153, 129, 0.55);
  color: #6ee7c8;
}
.tv-strategy-bar .strategy-toggle[data-strategy="bf"].active {
  background: rgba(242, 54, 69, 0.14);
  border-color: rgba(242, 54, 69, 0.5);
  color: #ff8a96;
}
.tv-strategy-bar .strategy-toggle[data-strategy="pennant"].active {
  background: rgba(38, 166, 154, 0.16);
  border-color: rgba(38, 166, 154, 0.55);
  color: #5eead4;
}
.tv-strategy-bar .strategy-toggle[data-strategy="dtb"].active {
  background: rgba(171, 71, 188, 0.16);
  border-color: rgba(171, 71, 188, 0.55);
  color: #e1bee7;
}
.tv-strategy-bar .strategy-toggle[data-strategy="sott"].active {
  background: rgba(255, 152, 0, 0.16);
  border-color: rgba(255, 152, 0, 0.55);
  color: #ffb74d;
}
.tv-strategy-bar .strategy-toggle.strategy-aggressive.active {
  background: rgba(242, 54, 69, 0.14);
  border-color: rgba(242, 54, 69, 0.5);
  color: #ff8a96;
}
.tv-strategy-bar .strategy-toggle.strategy-moderate.active {
  background: rgba(255, 193, 7, 0.14);
  border-color: rgba(255, 193, 7, 0.5);
  color: #ffd54f;
}
.tv-strategy-bar .strategy-toggle.strategy-conservative.active {
  background: rgba(8, 153, 129, 0.16);
  border-color: rgba(8, 153, 129, 0.55);
  color: #6ee7c8;
}
.tv-strategy-bar .technicals-toggle.active {
  background: rgba(41, 98, 255, 0.18);
  border-color: rgba(41, 98, 255, 0.55);
  color: #7eb0ff;
}
.tv-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tv-modal.hidden { display: none; }
.tv-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.tv-modal-panel {
  position: relative;
  width: min(420px, 92vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--tv-pane);
  border: 1px solid var(--tv-border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.tv-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--tv-border);
}
.tv-modal-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
.tv-modal-close {
  border: none;
  background: transparent;
  color: var(--tv-muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
.tv-modal-close:hover { color: var(--tv-text); }
.tv-picker-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--tv-border);
}
.tv-picker-tabs button {
  flex: 1;
  padding: 6px 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--tv-muted);
  font-size: 12px;
  cursor: pointer;
}
.tv-picker-tabs button.active {
  background: rgba(41, 98, 255, 0.15);
  color: #7eb0ff;
}
.tv-picker-list {
  overflow-y: auto;
  padding: 6px;
}
.tv-picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--tv-text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
.tv-picker-row:hover { background: var(--tv-row-hover); }
.tv-picker-row.open { opacity: 0.45; cursor: default; }
.tv-picker-row .sym { font-weight: 600; }
.tv-picker-row .tag {
  font-size: 10px;
  color: var(--tv-muted);
}
.tv-rail-divider {
  width: 28px;
  height: 1px;
  margin: 6px 0 4px;
  background: var(--tv-border);
}
.tv-rail-strategies {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}
.tv-rail-pane-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}
.tv-rail .strategy-toggle {
  width: 36px;
  height: 28px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}
.tv-rail .strategy-toggle.active {
  background: rgba(41, 98, 255, 0.18);
  border-color: rgba(41, 98, 255, 0.55);
  color: #7eb0ff;
  box-shadow: inset 0 0 0 1px rgba(41, 98, 255, 0.15);
}
.tv-rail .strategy-toggle[data-strategy="cf"].active {
  background: rgba(8, 153, 129, 0.16);
  border-color: rgba(8, 153, 129, 0.55);
  color: #6ee7c8;
}
.tv-rail .strategy-toggle[data-strategy="bf"].active {
  background: rgba(242, 54, 69, 0.14);
  border-color: rgba(242, 54, 69, 0.5);
  color: #ff8a96;
}
.tv-rail .strategy-toggle[data-strategy="pennant"].active {
  background: rgba(38, 166, 154, 0.16);
  border-color: rgba(38, 166, 154, 0.55);
  color: #5eead4;
}
.tv-rail .strategy-toggle[data-strategy="dtb"].active {
  background: rgba(171, 71, 188, 0.16);
  border-color: rgba(171, 71, 188, 0.55);
  color: #e1bee7;
}
.tv-rail .strategy-toggle[data-strategy="sott"].active {
  background: rgba(255, 152, 0, 0.16);
  border-color: rgba(255, 152, 0, 0.55);
  color: #ffcc80;
}
.tv-rail .strategy-toggle.strategy-aggressive.active {
  background: rgba(255, 193, 7, 0.18);
  border-color: rgba(255, 193, 7, 0.6);
  color: #ffe082;
}
.tv-rail .strategy-toggle.strategy-moderate.active {
  background: rgba(33, 150, 243, 0.18);
  border-color: rgba(33, 150, 243, 0.55);
  color: #90caf9;
}
.tv-rail .strategy-toggle.strategy-conservative.active {
  background: rgba(76, 175, 80, 0.18);
  border-color: rgba(76, 175, 80, 0.55);
  color: #a5d6a7;
}

.tv-main-col {
  flex: 1;
  min-width: 360px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.tv-chart-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
#chart-container { width: 100%; height: 100%; }
#chart-container.hidden { display: none; }

.tv-pipeline-feed {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  background: var(--tv-bg);
  overflow: hidden;
}
.tv-pipeline-feed.hidden { display: none; }
.tv-pipeline-feed-head {
  flex: 0 0 auto;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--tv-border);
  color: var(--tv-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.tv-pipeline-feed-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.tv-pipeline-feed-title {
  font: inherit;
}
.tv-pipeline-session-status {
  flex: 0 0 auto;
  font: 600 10px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--tv-border);
  color: var(--tv-muted);
  background: var(--tv-chart-tabs-bg);
}
.tv-pipeline-session-status.hidden { display: none; }
.tv-pipeline-session-status.seg-rth {
  color: #3dd68c;
  border-color: rgba(61, 214, 140, 0.45);
  background: rgba(61, 214, 140, 0.12);
}
.tv-pipeline-session-status.seg-premarket,
.tv-pipeline-session-status.seg-postmarket {
  color: #f0b429;
  border-color: rgba(240, 180, 41, 0.45);
  background: rgba(240, 180, 41, 0.12);
}
.tv-pipeline-session-status.seg-closed {
  color: var(--tv-muted);
  border-color: var(--tv-border);
  background: var(--tv-chart-tabs-bg);
}
.tv-pipeline-group-toggle {
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  background: var(--tv-chart-tabs-bg);
  color: var(--tv-muted);
  cursor: pointer;
  font: 600 11px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  padding: 5px 10px;
  flex: 0 0 auto;
}
.tv-pipeline-group-toggle:hover {
  color: var(--tv-text);
  background: var(--tv-hover);
}
.tv-pipeline-group-toggle.active {
  background: var(--tv-pane);
  color: var(--tv-text);
  border-color: rgba(41, 98, 255, 0.55);
}
.tv-pipeline-feed-list.grouped .pipeline-symbol-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tv-muted);
  background: var(--tv-pane);
  border-bottom: 1px solid var(--tv-border);
  border-top: 1px solid var(--tv-border);
  cursor: default;
}
.tv-pipeline-feed-list.grouped .pipeline-symbol-group-header:first-child {
  border-top: none;
}
.tv-pipeline-feed-list.grouped .pipeline-symbol-label {
  color: var(--tv-text);
}
.tv-pipeline-feed-list.grouped .pipeline-symbol-count {
  font-weight: 600;
  font-size: 10px;
  opacity: 0.75;
}
.tv-pipeline-feed-list.grouped .pipeline-grouped-item {
  padding-left: 18px;
}
.tv-pipeline-feed-list.grouped .pipeline-cycle-divider {
  height: 1px;
  margin: 4px 12px 4px 18px;
  background: var(--tv-border);
  list-style: none;
  padding: 0;
  border: none;
}
.tv-pipeline-feed-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 0;
}
.tv-pipeline-feed-empty {
  padding: 24px 14px;
  color: var(--tv-muted);
  font-size: 13px;
  margin: 0;
}
.tv-pipeline-feed-empty.hidden { display: none; }

.tv-chart-tabs {
  position: absolute;
  left: auto;
  top: auto;
  right: 92px;
  bottom: 42px;
  z-index: 20;
  display: flex;
  gap: 4px;
  background: var(--tv-chart-tabs-bg);
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  padding: 3px;
}
#chart-view-tabs {
  left: auto !important;
  top: auto !important;
  right: 92px !important;
  bottom: 42px !important;
}
.tv-chart-tabs button {
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  font: 600 11px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  padding: 5px 9px;
}
.tv-chart-tabs button.active {
  background: var(--tv-pane);
  color: var(--tv-text);
}

.tv-rail-right-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
}
.tv-rail-theme-btn .tv-theme-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.tv-rail-theme-btn .tv-theme-icon.hidden {
  display: none;
}

.tv-legend {
  position: absolute;
  left: 4px;
  top: 4px;
  z-index: 10;
  pointer-events: none;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  font: 12px/1.5 ui-monospace, monospace;
  min-width: 0;
}
.tv-legend .ohlc-row {
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
  white-space: nowrap;
  color: var(--tv-text);
}
.tv-legend .k { color: var(--tv-muted); margin-right: 4px; }

.tv-trade-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
  font: 600 10px/1.3 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-muted);
}
.tv-trade-legend .tl-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}
.tv-trade-legend .tl-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  font-size: 11px;
  font-weight: 700;
}
.tv-trade-legend .tl-dot.le { color: #089981; }
.tv-trade-legend .tl-dot.lx { color: #ff9800; }
.tv-trade-legend .tl-dot.se { color: #f23645; }
.tv-trade-legend .tl-dot.sx { color: #2196f3; }
.tv-trade-legend .tl-dot.open { color: #e040fb; font-size: 10px; }

.tv-zoom {
  position: absolute;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 15;
}
.tv-zoom button {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  border: 1px solid var(--tv-border);
  background: var(--tv-pane);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}

.tv-sidebar-resizer {
  width: 6px;
  flex: 0 0 6px;
  cursor: col-resize;
  background: var(--tv-bg);
  border-left: 1px solid var(--tv-border);
  border-right: 1px solid var(--tv-border);
}
.tv-sidebar-resizer:hover,
body.resizing-sidebar .tv-sidebar-resizer {
  background: rgba(41, 98, 255, 0.28);
}
body.resizing-sidebar {
  cursor: col-resize;
  user-select: none;
}

/* Right column: sidebar + icon rail */
.tv-right-col {
  display: flex;
  flex-shrink: 0;
  width: calc(var(--tv-watch-w) + var(--tv-right-rail-w));
  min-width: 0;
  height: 100%;
}
.tv-sidebar-stack {
  position: relative;
  width: var(--tv-watch-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  height: 100%;
  border-left: 1px solid var(--tv-border);
}
.tv-sidebar-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--tv-bg);
  border-left: 1px solid var(--tv-border);
}
.tv-sidebar-overlay.hidden {
  display: none;
}
.tv-sidebar-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.tv-sidebar-panel[hidden] {
  display: none !important;
}
.tv-sidebar-panel-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--tv-border);
  background: var(--tv-pane);
}
.tv-sidebar-panel-head h4 {
  flex: 1;
  margin: 0;
  font: 700 13px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-symbol-strong);
}
.tv-sidebar-panel-head .tv-panel-search {
  flex: 0 1 auto;
}
.tv-panel-back {
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  font: 600 16px/1 ui-monospace, monospace;
  padding: 4px 8px;
}
.tv-panel-back:hover {
  color: var(--tv-text);
  background: var(--tv-hover);
}
.tv-panel-action {
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  padding: 4px 8px;
}
.tv-panel-action:hover {
  color: var(--tv-text);
}
.tv-sidebar-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
}
.tv-panel-placeholder,
.tv-panel-note {
  padding: 14px 12px;
  margin: 0;
  color: var(--tv-muted);
  font-size: 12px;
  line-height: 1.45;
}
.tv-alert-panel-head {
  flex-wrap: wrap;
  row-gap: 6px;
}
.tv-alert-head-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tv-alert-head-main h4 {
  flex: 0 0 auto;
}
.tv-alert-filters {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.tv-alert-filter {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--tv-border);
  border-radius: 50%;
  background: transparent;
  color: var(--tv-muted);
  font: 700 10px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  cursor: pointer;
  transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.tv-alert-filter:hover {
  color: var(--tv-text);
  border-color: var(--tv-muted);
}
.tv-alert-filter.inactive {
  opacity: 0.35;
}
.tv-alert-filter[data-alert-filter="S"].active:not(.inactive) {
  border-color: rgba(41, 98, 255, 0.65);
  background: rgba(41, 98, 255, 0.18);
  color: #7eb0ff;
}
.tv-alert-filter[data-alert-filter="R"].active:not(.inactive) {
  border-color: rgba(242, 54, 69, 0.65);
  background: rgba(242, 54, 69, 0.16);
  color: #ff8a93;
}
.tv-alert-filter[data-alert-filter="P"].active:not(.inactive) {
  border-color: rgba(240, 180, 41, 0.65);
  background: rgba(240, 180, 41, 0.14);
  color: #f0c85a;
}
.tv-alert-filter[data-alert-filter="O"].active:not(.inactive) {
  border-color: rgba(8, 153, 129, 0.65);
  background: rgba(8, 153, 129, 0.16);
  color: #6ee7c8;
}
.tv-sidebar-alert-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tv-news-item {
  padding: 12px;
  border-bottom: 1px solid var(--tv-border);
}
.tv-news-item:hover {
  background: var(--tv-row-hover);
}
.tv-news-item time {
  display: block;
  font-size: 10px;
  color: var(--tv-news-meta-color);
  margin-bottom: 4px;
}
.tv-news-item .tv-news-link,
.tv-news-item > a {
  display: block;
  font: 600 12px/1.35 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-news-headline);
  text-decoration: none;
  margin-bottom: 4px;
}
.tv-news-item .tv-news-link:hover,
.tv-news-item > a:hover {
  color: var(--tv-news-link-hover);
  text-decoration: underline;
}
.tv-news-item strong {
  display: block;
  font-size: 12px;
  color: var(--tv-news-headline);
  margin-bottom: 4px;
  line-height: 1.35;
}
.tv-news-item p {
  margin: 0;
  font-size: 11px;
  color: var(--tv-news-body);
  line-height: 1.45;
}
.tv-news-symbol {
  display: inline-block;
  font: 700 10px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-news-headline);
  background: transparent;
  border: 1px solid var(--tv-news-symbol-border);
  border-radius: 999px;
  padding: 2px 7px;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
.tv-news-headline-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 4px;
}
.tv-news-headline-row .tv-news-link,
.tv-news-headline-row > a,
.tv-news-headline-row > strong {
  flex: 1 1 auto;
  min-width: 0;
  margin-bottom: 0;
}
.tv-news-sentiment {
  display: inline-block;
  flex: 0 0 auto;
  font: 700 9px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  border-radius: 999px;
  padding: 2px 7px;
  letter-spacing: 0.02em;
  vertical-align: middle;
  white-space: nowrap;
  border: 1px solid transparent;
}
.tv-sentiment-strong-buy {
  color: var(--tv-sentiment-strong-buy-text);
  background: var(--tv-sentiment-strong-buy-bg);
  border-color: var(--tv-sentiment-strong-buy-text);
}
.tv-sentiment-buy {
  color: var(--tv-sentiment-buy-text);
  background: var(--tv-sentiment-buy-bg);
  border-color: var(--tv-sentiment-buy-text);
}
.tv-sentiment-neutral {
  color: var(--tv-sentiment-neutral-text);
  background: var(--tv-sentiment-neutral-bg);
  border-color: var(--tv-news-symbol-border);
}
.tv-sentiment-sell {
  color: var(--tv-sentiment-sell-text);
  background: var(--tv-sentiment-sell-bg);
  border-color: var(--tv-sentiment-sell-text);
}
.tv-sentiment-strong-sell {
  color: var(--tv-sentiment-strong-sell-text);
  background: var(--tv-sentiment-strong-sell-bg);
  border-color: var(--tv-sentiment-strong-sell-text);
}
.tv-news-meta .tv-news-sentiment {
  margin-left: 6px;
}
.tv-screener-card,
.tv-broker-card {
  margin: 10px 12px;
  padding: 10px 12px;
  border: 1px solid var(--tv-border);
  border-radius: 6px;
  background: var(--tv-pane);
}
.tv-screener-title,
.tv-broker-name {
  font: 700 12px/1.3 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-text);
}
.tv-screener-desc {
  margin: 6px 0 10px;
  font-size: 11px;
  color: var(--tv-muted);
  line-height: 1.4;
}
.tv-screener-run {
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  background: var(--tv-bg);
  color: var(--tv-muted);
  font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  padding: 6px 10px;
  cursor: not-allowed;
}
.tv-broker-status {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--tv-muted);
}
.tv-broker-status.connected {
  color: var(--tv-up);
}
.tv-sentiments-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}
.tv-sentiment-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--tv-border);
  position: sticky;
  top: 0;
  background: var(--tv-panel);
  z-index: 2;
}
.tv-sentiment-chip {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 4px 10px;
  font: 600 10px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.tv-sentiment-chip.inactive {
  opacity: 0.35;
}
.tv-sentiment-chip:not(.inactive):hover {
  transform: translateY(-1px);
}
.tv-sentiments-list {
  padding: 0;
}
.tv-sentiment-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px 76px 40px 32px;
  gap: 4px;
  align-items: center;
  padding: 4px 10px 6px;
  border-bottom: 1px solid var(--tv-border);
  font: 600 10px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--tv-muted);
  position: sticky;
  top: 42px;
  background: var(--tv-panel);
  z-index: 1;
}
.tv-sentiment-head .watch-col.sym {
  text-align: left;
}
.tv-sentiment-head .watch-col.type,
.tv-sentiment-head .watch-col.sent,
.tv-sentiment-head .watch-col.conf,
.tv-sentiment-head .watch-col.arts {
  text-align: right;
}
.tv-sentiment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px 76px 40px 32px;
  gap: 4px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--tv-border);
  font: 500 11px/1.3 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
}
.tv-sentiment-row:hover {
  background: rgba(255, 255, 255, 0.03);
}
.tv-sentiment-row-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px 76px 40px 32px auto;
  gap: 4px;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--tv-text);
  font: 500 11px/1.3 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  text-align: left;
  cursor: pointer;
}
.tv-sentiment-row-main:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.03);
}
.tv-sentiment-row-main:disabled {
  cursor: default;
}
.tv-sentiment-symbol-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.tv-sentiment-symbol-wrap .asset-logo {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.04);
}
.tv-sentiment-symbol {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--tv-text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}
.tv-sentiment-symbol:hover {
  color: var(--tv-accent, #f0b90b);
}
.tv-sentiment-type {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--tv-muted);
  text-transform: uppercase;
  text-align: right;
}
.tv-sentiment-conf {
  font-variant-numeric: tabular-nums;
  color: var(--tv-muted);
  text-align: right;
}
.tv-sentiment-count {
  font-variant-numeric: tabular-nums;
  color: var(--tv-muted);
  text-align: right;
}
.tv-sentiment-pending {
  opacity: 0.45;
}
.tv-sentiment-loading-pill {
  animation: tv-sentiment-pulse 1.2s ease-in-out infinite;
}
@keyframes tv-sentiment-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}
.tv-sentiment-mixed {
  font-size: 9px;
  font-weight: 700;
  color: #fbbf24;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tv-sentiment-detail {
  padding: 0 12px 12px 12px;
  border-top: 1px dashed var(--tv-border);
  background: rgba(0, 0, 0, 0.12);
}
.tv-sentiment-debate {
  margin: 8px 0 6px;
  font-size: 11px;
  color: var(--tv-muted);
}
.tv-sentiment-articles {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tv-sentiment-article {
  padding: 8px 0;
  border-bottom: 1px solid var(--tv-border);
}
.tv-sentiment-article:last-child {
  border-bottom: none;
}
.tv-sentiment-article-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.tv-sentiment-article-meta {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--tv-news-meta-color);
}
.tv-sentiment-article-summary {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--tv-news-body);
  line-height: 1.45;
}
#sentiment-body .tv-sentiment-article-head .tv-news-link,
#sentiment-body .tv-sentiment-article-head .tv-sentiment-article-link,
#sentiment-body .tv-sentiment-article-head > a {
  flex: 1 1 auto;
  min-width: 0;
  font: 600 12px/1.35 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-news-headline);
  text-decoration: none;
}
#sentiment-body .tv-sentiment-article-head .tv-news-link:hover,
#sentiment-body .tv-sentiment-article-head .tv-sentiment-article-link:hover,
#sentiment-body .tv-sentiment-article-head > a:hover {
  color: var(--tv-news-link-hover);
  text-decoration: underline;
}
#sentiment-body .tv-sentiment-article-head > strong {
  flex: 1 1 auto;
  min-width: 0;
  font: 600 12px/1.35 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-news-headline);
}
#sentiment-body .tv-sentiment-debate {
  color: var(--tv-news-body);
}
.tv-sentiments-empty,
.tv-sentiments-loading {
  padding: 12px;
  font-size: 12px;
  color: var(--tv-muted);
}

/* Seer360 panel */
.tv-rail-right-divider {
  width: 28px;
  height: 1px;
  margin: 4px 0;
  background: var(--tv-border);
  flex-shrink: 0;
}
.tv-rail-seer360-btn .tv-rail-seer-logo {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  object-fit: contain;
}
.tv-rail-label-360 {
  letter-spacing: 0.08em;
}
.tv-seer360-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.tv-seer360-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.tv-seer360-list {
  min-width: 720px;
}
.tv-seer360-head,
.tv-seer360-row {
  display: grid;
  grid-template-columns: 88px 72px 88px 88px 120px 72px 88px 88px;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  font-size: 11px;
}
.tv-seer360-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--tv-bg);
  border-bottom: 1px solid var(--tv-border);
  color: var(--tv-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tv-seer360-row {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.tv-seer360-row:hover {
  background: rgba(255, 255, 255, 0.03);
}
.tv-seer360-row-main {
  display: contents;
}
.tv-seer360-symbol-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.tv-seer360-symbol-wrap .asset-logo {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  flex-shrink: 0;
}
.tv-seer360-symbol {
  font-weight: 700;
  color: var(--tv-text);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  text-align: left;
}
.tv-seer360-symbol:hover {
  color: #7eb0ff;
}
.tv-seer360-price {
  font-variant-numeric: tabular-nums;
  color: var(--tv-text);
}
.tv-seer360-fund {
  font-size: 10px;
  line-height: 1.25;
  color: var(--tv-muted);
}
.tv-seer360-intrinsic {
  font-variant-numeric: tabular-nums;
  color: var(--tv-text);
}
.tv-seer360-expand {
  grid-column: 1 / -1;
  padding: 4px 0 8px 24px;
  font-size: 10px;
  line-height: 1.4;
  color: var(--tv-muted);
}
.tv-seer360-empty,
.tv-seer360-loading {
  padding: 12px;
  font-size: 12px;
  color: var(--tv-muted);
}
.tv-seer360-empty.hidden,
.tv-seer360-loading.hidden {
  display: none;
}
.tv-seer360-pill {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.tv-seer360-loading-pill {
  animation: tv-sentiment-pulse 1.2s ease-in-out infinite;
}

.tv-events-list {
  padding: 0;
}
.tv-events-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}
.tv-events-tabs {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
  padding: 10px 12px 0;
  border-bottom: 1px solid var(--tv-border);
}
.tv-events-tabs button {
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  font-size: 12px;
}
.tv-events-tabs button:hover { color: var(--tv-text); background: var(--tv-pane); }
.tv-events-tabs button.active {
  color: var(--tv-symbol-strong);
  background: var(--tv-pane);
  border-color: var(--tv-border);
  border-bottom-color: var(--tv-pane);
}
.tv-events-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--tv-border);
  position: sticky;
  top: 0;
  background: var(--tv-panel);
  z-index: 2;
}
.tv-events-filters[hidden] {
  display: none;
}
.tv-events-chip {
  border: 1px solid var(--tv-border);
  border-radius: 999px;
  padding: 4px 10px;
  font: 600 10px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  cursor: pointer;
  background: transparent;
  color: var(--tv-muted);
  transition: opacity 0.15s ease, transform 0.1s ease;
}
.tv-events-chip.active {
  opacity: 1;
  color: var(--tv-text);
  border-color: var(--tv-accent);
}
.tv-events-chip:not(.active) {
  opacity: 0.45;
}
.tv-events-chip:not(.active):hover {
  opacity: 0.75;
}
.tv-events-day {
  border-bottom: 1px solid var(--tv-border);
}
.tv-events-day-label {
  margin: 0;
  padding: 8px 12px 4px;
  font: 700 11px/1.3 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-accent);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.tv-orders-list {
  padding: 0;
}
.tv-orders-summary {
  margin: 0;
  padding: 8px 12px 0;
  font-size: 11px;
  color: var(--tv-muted);
}
.tv-orders-empty,
.tv-orders-loading {
  padding: 12px;
  font-size: 12px;
  color: var(--tv-muted);
}
.tv-orders-load-more {
  display: block;
  width: calc(100% - 24px);
  margin: 8px 12px 12px;
  padding: 8px 12px;
  font: 600 12px/1.3 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-accent);
  background: transparent;
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  cursor: pointer;
}
.tv-orders-load-more:hover:not(:disabled) {
  border-color: var(--tv-accent);
  background: rgba(255, 255, 255, 0.04);
}
.tv-orders-load-more:disabled {
  opacity: 0.6;
  cursor: default;
}
.tv-orders-day {
  border-bottom: 1px solid var(--tv-border);
}
.tv-orders-day-label {
  margin: 0;
  padding: 8px 12px 4px;
  font: 700 11px/1.3 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-accent);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.tv-orders-table-wrap {
  overflow-x: auto;
}
.tv-orders-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.tv-orders-table th,
.tv-orders-table td {
  padding: 6px 8px;
  border-top: 1px solid var(--tv-border);
  text-align: left;
  vertical-align: top;
}
.tv-orders-table th {
  font-weight: 600;
  color: var(--tv-muted);
  background: var(--tv-pane);
  white-space: nowrap;
}
.tv-orders-table td.reason {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--tv-muted);
  font-size: 10px;
}
.tv-orders-table .sym {
  font-weight: 700;
}
.tv-orders-table .side-buy { color: var(--tv-up); }
.tv-orders-table .side-sell { color: var(--tv-down); }
.tv-orders-table .status-rejected { color: #e57373; }
.tv-orders-table .status-skipped { color: #ffb74d; }
.tv-orders-table .status-pending { color: var(--tv-accent); }
.tv-orders-table .status-filled { color: var(--tv-up); }
.tv-orders-symbol-btn {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.tv-orders-symbol-btn:hover {
  color: var(--tv-accent);
  text-decoration: underline;
}
.tv-orders-retry-btn {
  border: 1px solid var(--tv-border);
  border-radius: 3px;
  background: var(--tv-bg);
  color: var(--tv-text);
  font: 600 10px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  padding: 3px 6px;
  cursor: pointer;
}
.tv-orders-retry-btn:hover {
  border-color: var(--tv-accent);
  color: var(--tv-accent);
}

/* Risk sidebar panel */
.tv-risk-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tv-risk-summary {
  margin: 0;
  padding: 8px 12px 0;
  font: 600 11px/1.4 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-muted);
}
.tv-risk-empty,
.tv-risk-loading {
  margin: 0;
  padding: 12px;
  font: 400 12px/1.45 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-muted);
}
.tv-risk-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tv-risk-section {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.tv-risk-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font: 700 10px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tv-muted);
  border-top: 1px solid var(--tv-border);
}
.tv-risk-section-head:first-child {
  border-top: none;
}
.tv-risk-section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  font: 700 9px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
}
.tv-risk-section--high .tv-risk-section-count {
  background: rgba(229, 115, 115, 0.2);
  color: #e57373;
}
.tv-risk-section--medium .tv-risk-section-count {
  background: rgba(255, 183, 77, 0.15);
  color: #ffb74d;
}
.tv-risk-section--low .tv-risk-section-count {
  background: rgba(120, 144, 156, 0.15);
  color: #90a4ae;
}
.tv-risk-item {
  padding: 10px 12px;
  border-top: 1px solid var(--tv-border);
}
.tv-risk-item:hover {
  background: var(--tv-row-hover);
}
.tv-risk-item-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.tv-risk-symbol-btn {
  font: 700 10px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-news-headline);
  background: transparent;
  border: 1px solid var(--tv-news-symbol-border);
  border-radius: 999px;
  padding: 2px 7px;
  cursor: pointer;
}
.tv-risk-symbol-btn:hover {
  border-color: var(--tv-accent);
  color: var(--tv-accent);
}
.tv-risk-type {
  font: 600 10px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-text);
}
.tv-risk-item--high .tv-risk-type { color: #e57373; }
.tv-risk-item--medium .tv-risk-type { color: #ffb74d; }
.tv-risk-item--low .tv-risk-type { color: #90a4ae; }
.tv-risk-message {
  margin: 0 0 6px;
  font: 400 11px/1.45 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-muted);
}
.tv-risk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tv-risk-action-btn {
  background: var(--tv-panel);
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  color: var(--tv-text);
  font: 600 10px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  padding: 3px 6px;
  cursor: pointer;
}
.tv-risk-action-btn:hover {
  border-color: var(--tv-accent);
  color: var(--tv-accent);
}
.tv-rail-risk-btn .tv-rail-badge {
  background: rgba(229, 115, 115, 0.85);
}

.tv-event-item {
  padding: 10px 12px;
  border-top: 1px solid var(--tv-border);
}
.tv-event-item:hover {
  background: var(--tv-row-hover);
}
.tv-event-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.tv-event-symbol {
  font: 700 10px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-news-headline);
  background: transparent;
  border: 1px solid var(--tv-news-symbol-border);
  border-radius: 999px;
  padding: 2px 7px;
  letter-spacing: 0.02em;
}
.tv-event-badge {
  font: 600 9px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 3px;
  padding: 2px 5px;
}
.tv-event-type-earnings { background: rgba(38, 166, 154, 0.2); color: #26a69a; }
.tv-event-type-leadership { background: rgba(120, 123, 134, 0.25); color: #b2b5be; }
.tv-event-type-ma { background: rgba(255, 152, 0, 0.2); color: #ff9800; }
.tv-event-type-sec { background: rgba(66, 133, 244, 0.2); color: #6ea8fe; }
.tv-event-type-product { background: rgba(156, 39, 176, 0.2); color: #ce93d8; }
.tv-event-type-macro { background: rgba(255, 193, 7, 0.15); color: #ffc107; }
.tv-event-type-fomc { background: rgba(244, 67, 54, 0.18); color: #ef5350; }
.tv-event-type-regulatory { background: rgba(255, 87, 34, 0.18); color: #ff7043; }
.tv-event-type-other { background: rgba(33, 150, 243, 0.18); color: #64b5f6; }
.tv-event-type-news { background: rgba(33, 150, 243, 0.18); color: #64b5f6; }
.tv-event-time { margin-left: auto; font-size: 0.72rem; color: var(--tv-news-meta-color); white-space: nowrap; }
.tv-news-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--tv-news-meta-color);
}
.tv-event-title,
.tv-event-link {
  display: block;
  font: 600 12px/1.35 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-news-headline);
  text-decoration: none;
}
.tv-event-link:hover {
  color: var(--tv-news-link-hover);
  text-decoration: underline;
}
.tv-event-summary {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--tv-news-body);
  line-height: 1.45;
}
.tv-event-source {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--tv-news-meta-color);
}
.tv-events-empty,
.tv-events-loading {
  padding: 14px 12px;
  margin: 0;
  color: var(--tv-muted);
  font-size: 12px;
  line-height: 1.45;
}
.tv-events-empty.hidden,
.tv-events-loading.hidden {
  display: none;
}

/* Right icon rail */
.tv-rail-right {
  width: var(--tv-right-rail-w);
  flex-shrink: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
  background: var(--tv-bg);
  border-left: 1px solid var(--tv-border);
}
.tv-rail-right-btn {
  position: relative;
  width: 36px;
  min-height: 36px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
}
.tv-rail-right-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 1.75;
}
.tv-rail-label {
  font: 600 8px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.tv-rail-right-btn:hover,
.tv-rail-right-btn.active {
  background: var(--tv-pane);
  color: var(--tv-text);
}
.tv-rail-right-btn.active {
  box-shadow: inset 0 0 0 1px rgba(41, 98, 255, 0.35);
}
.tv-rail-right-btn.tv-rail-watch-btn {
  margin-top: 0;
}
.tv-rail-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 7px;
  background: var(--tv-down);
  color: #fff;
  font: 700 9px/14px ui-monospace, monospace;
  text-align: center;
}
.tv-rail-badge.hidden {
  display: none;
}

.tv-watch {
  width: 100%;
  flex: 1;
  min-height: 0;
  border-left: none;
  background: var(--tv-bg);
  display: flex;
  flex-direction: column;
}
.tv-watch-assets {
  flex: 0 0 178px;
  min-height: 96px;
  overflow-y: auto;
  overflow-x: hidden;
}
.tv-sidebar-pane-resizer {
  height: 6px;
  flex: 0 0 6px;
  cursor: row-resize;
  background: var(--tv-bg);
  border-top: 1px solid var(--tv-border);
  border-bottom: 1px solid var(--tv-border);
}
.tv-sidebar-pane-resizer:hover,
body.resizing-sidebar-pane .tv-sidebar-pane-resizer {
  background: rgba(41, 98, 255, 0.28);
}
body.resizing-sidebar-pane {
  cursor: row-resize;
  user-select: none;
}
.tv-watch-restore-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin: 0 8px 6px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(41, 98, 255, 0.12);
  border: 1px solid rgba(41, 98, 255, 0.35);
  font-size: 11px;
  line-height: 1.3;
  color: var(--tv-text);
}
.tv-watch-restore-banner.hidden {
  display: none;
}
.tv-watch-restore-msg {
  flex: 1 1 auto;
  min-width: 0;
}
.tv-watch-restore-action {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(41, 98, 255, 0.5);
  background: rgba(41, 98, 255, 0.18);
  color: var(--tv-text);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.tv-watch-restore-action:hover {
  background: rgba(41, 98, 255, 0.28);
}
.tv-watch-restore-dismiss {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--tv-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  margin-left: 2px;
}
.tv-watch-restore-dismiss:hover {
  color: var(--tv-text);
}
.tv-watch-toolbar {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--tv-border);
}
.tv-watch-category-select {
  flex: 0 0 auto;
  min-width: 72px;
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  background: var(--tv-pane);
  color: var(--tv-text);
  cursor: pointer;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 700;
}
.tv-watch-category-select:focus {
  outline: none;
  border-color: rgba(41, 98, 255, 0.55);
}
.tv-watch-category-select option:disabled {
  color: var(--tv-muted);
}
.tv-watch-add {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}
.tv-watch-add:hover {
  color: var(--tv-text);
  border-color: rgba(41, 98, 255, 0.55);
  background: rgba(41, 98, 255, 0.12);
}
.tv-panel-search {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}
.tv-panel-search.hidden {
  display: none;
}
.tv-search-toggle {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tv-search-toggle svg {
  width: 16px;
  height: 16px;
}
.tv-search-toggle:hover,
.tv-search-toggle.active {
  color: var(--tv-text);
  background: rgba(41, 98, 255, 0.12);
}
.tv-search-input {
  flex: 1;
  min-width: 0;
  max-width: 140px;
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  background: var(--tv-bg);
  color: var(--tv-text);
  font-size: 11px;
  padding: 5px 8px;
}
.tv-search-input.collapsed {
  width: 0;
  max-width: 0;
  padding: 0;
  border-color: transparent;
  opacity: 0;
  pointer-events: none;
}
.tv-search-input.expanded {
  width: auto;
  max-width: 140px;
  opacity: 1;
  pointer-events: auto;
}
.tv-search-input:focus {
  outline: none;
  border-color: rgba(41, 98, 255, 0.55);
}
.tv-picker-tabs button.hidden {
  display: none;
}
.tv-screener-panel {
  width: min(480px, 94vw);
  max-height: 75vh;
}
.tv-screener-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 10px 0;
  border-bottom: 1px solid var(--tv-border);
}
.tv-screener-tabs button {
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--tv-muted);
  font-size: 12px;
  padding: 5px 10px;
  cursor: pointer;
}
.tv-screener-tabs button.active {
  color: var(--tv-text);
  border-color: var(--tv-border);
  background: rgba(41, 98, 255, 0.12);
}
.tv-screener-search-wrap {
  padding: 8px 10px;
  border-bottom: 1px solid var(--tv-border);
}
.tv-screener-search-wrap input {
  width: 100%;
  border: 1px solid var(--tv-border);
  border-radius: 6px;
  background: var(--tv-bg);
  color: var(--tv-text);
  font-size: 13px;
  padding: 8px 10px;
}
.tv-screener-search-wrap input:focus {
  outline: none;
  border-color: rgba(41, 98, 255, 0.55);
}
.tv-screener-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 0;
}
.tv-screener-head,
.tv-screener-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) minmax(72px, 118px) 52px 28px;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  font-size: 12px;
}
.tv-screener-head {
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--tv-border);
  background: var(--tv-panel);
  color: var(--tv-muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tv-screener-head .screener-col {
  min-width: 0;
}
.tv-screener-head .screener-col.sym,
.tv-screener-head .screener-col.mid {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.tv-screener-head .screener-col.sym:hover,
.tv-screener-head .screener-col.mid:hover {
  color: var(--tv-text);
}
.tv-screener-head .screener-col.sym.sort-asc::after,
.tv-screener-head .screener-col.mid.sort-asc::after {
  content: " ▲";
  font-size: 8px;
  opacity: 0.8;
}
.tv-screener-head .screener-col.sym.sort-desc::after,
.tv-screener-head .screener-col.mid.sort-desc::after {
  content: " ▼";
  font-size: 8px;
  opacity: 0.8;
}
.tv-screener-head .screener-col.exch {
  text-align: right;
}
.tv-screener-row {
  border-bottom: 1px solid var(--tv-border);
}
.tv-screener-row:hover {
  background: var(--tv-row-hover);
}
.tv-screener-row .sym {
  font-weight: 700;
  color: var(--tv-symbol-strong);
}
.tv-screener-row .name {
  color: var(--tv-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tv-screener-row .exch {
  color: var(--tv-muted);
  font-size: 10px;
  text-align: right;
}
.tv-screener-row .mid {
  color: var(--tv-muted);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tv-screener-add {
  width: 24px;
  height: 24px;
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0;
}
.tv-screener-add:hover:not(:disabled) {
  color: var(--tv-text);
  border-color: rgba(41, 98, 255, 0.55);
  background: rgba(41, 98, 255, 0.12);
}
.tv-screener-add:disabled {
  opacity: 0.35;
  cursor: default;
}
.tv-screener-empty {
  padding: 16px 12px;
  color: var(--tv-muted);
  font-size: 12px;
  text-align: center;
}
.tv-screener-databento-note {
  padding: 10px 12px 0;
  color: var(--tv-muted);
  font-size: 11px;
  line-height: 1.4;
  text-align: left;
}
.tv-screener-databento-note--warn {
  color: #d4a017;
}
.tv-screener-databento-note--error {
  color: #f23645;
}
.tv-research-jobs-panel {
  width: min(640px, 94vw);
  max-height: 75vh;
}
.tv-research-jobs-body {
  overflow: auto;
  flex: 1;
  min-height: 120px;
}
.tv-research-jobs-head,
.tv-research-jobs-row {
  display: grid;
  grid-template-columns: 52px 72px 44px minmax(0, 1fr) 88px 72px auto;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  font-size: 12px;
}
.tv-research-jobs-head {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--tv-pane);
  border-bottom: 1px solid var(--tv-border);
  font: 600 10px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--tv-muted);
}
.tv-research-jobs-row {
  border-bottom: 1px solid var(--tv-border);
}
.tv-research-jobs-row:hover {
  background: rgba(255, 255, 255, 0.03);
}
.tv-research-jobs-row .job-id {
  font-weight: 600;
  color: var(--tv-text);
}
.tv-research-jobs-row .job-symbols {
  color: var(--tv-muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tv-research-jobs-row .job-elapsed,
.tv-research-jobs-row .job-created {
  color: var(--tv-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.tv-research-jobs-status {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font: 700 10px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}
.tv-research-jobs-status.pending {
  background: rgba(240, 185, 11, 0.16);
  color: #f0b90b;
}
.tv-research-jobs-status.running {
  background: rgba(41, 98, 255, 0.18);
  color: #5b9cff;
}
.tv-research-jobs-status.done {
  background: rgba(8, 153, 129, 0.16);
  color: #6ee7c8;
}
.tv-research-jobs-status.error {
  background: rgba(242, 54, 69, 0.14);
  color: #f23645;
}
.tv-research-jobs-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.tv-research-jobs-btn {
  border: 1px solid var(--tv-border);
  background: transparent;
  color: var(--tv-text);
  border-radius: 4px;
  padding: 3px 8px;
  font: 600 10px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  cursor: pointer;
  white-space: nowrap;
}
.tv-research-jobs-btn:hover {
  border-color: rgba(41, 98, 255, 0.55);
  color: #7eb0ff;
}
.tv-research-jobs-btn.cancel:hover {
  border-color: rgba(242, 54, 69, 0.55);
  color: #f23645;
}
.tv-research-jobs-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.tv-research-jobs-section {
  padding: 10px 12px 4px;
  font: 600 10px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--tv-muted);
  opacity: 0.75;
}
.tv-research-jobs-empty {
  padding: 24px 12px;
  color: var(--tv-muted);
  font-size: 13px;
  text-align: center;
}
.tv-watch-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px 24px 44px 52px 64px;
  gap: 4px;
  align-items: center;
  padding: 4px 10px 6px;
  border-bottom: 1px solid var(--tv-border);
  font: 600 10px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--tv-muted);
}
.tv-watch-head .watch-col.sym {
  text-align: left;
  border: none;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}
.tv-watch-head .watch-col.sym:hover {
  color: var(--tv-text);
}
.tv-watch-head .watch-col.sym.sort-asc::after {
  content: " ▲";
  font-size: 8px;
  opacity: 0.8;
}
.tv-watch-head .watch-col.sym.sort-desc::after {
  content: " ▼";
  font-size: 8px;
  opacity: 0.8;
}
.tv-watch-head .watch-col.pos,
.tv-watch-head .watch-col.side,
.tv-watch-head .watch-col.pnl,
.tv-watch-head .watch-col.chg,
.tv-watch-head .watch-col.px {
  text-align: right;
}
.tv-watch-row {
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--tv-border);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px 24px 44px 52px 64px;
  align-items: center;
  gap: 4px;
}
.tv-watch-row.active {
  background: rgba(41, 98, 255, 0.12);
  box-shadow: inset 3px 0 0 var(--tv-accent);
}
.tv-watch-row .watch-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}
.tv-watch-remove {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: auto;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--tv-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.tv-watch-row:hover .tv-watch-remove,
.tv-watch-row .tv-watch-remove:focus-visible {
  opacity: 0.55;
}
.tv-watch-remove:hover {
  opacity: 1 !important;
  background: rgba(242, 54, 69, 0.2);
  color: #ff8a96;
}
.tv-watch-row .watch-pos,
.tv-watch-row .watch-side,
.tv-watch-row .watch-pnl,
.tv-watch-row .watch-chg {
  flex-shrink: 0;
  text-align: right;
  font: 600 11px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-muted);
  font-variant-numeric: tabular-nums;
}
.tv-watch-row .watch-pos.open { color: #f0b90b; font-weight: 700; }
.tv-watch-row .watch-side.long { color: var(--tv-up); font-weight: 700; }
.tv-watch-row .watch-side.short { color: var(--tv-down); font-weight: 700; }
.tv-watch-row .watch-pnl.up { color: var(--tv-up); font-weight: 700; }
.tv-watch-row .watch-pnl.down { color: var(--tv-down); font-weight: 700; }
.tv-watch-row .watch-pnl.flat { color: var(--tv-muted); }
.tv-watch-row .watch-pnl-research {
  flex-shrink: 0;
  text-align: right;
}
.watch-research-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font: 700 10px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: none;
  vertical-align: middle;
}
.watch-research-pill.progress {
  background: rgba(240, 185, 11, 0.16);
  color: #f0b90b;
  cursor: default;
}
.tv-watch-row .watch-chg.up { color: var(--tv-up); font-weight: 700; }
.tv-watch-row .watch-chg.down { color: var(--tv-down); font-weight: 700; }
.tv-watch-row .watch-chg.flat { color: var(--tv-muted); }
.tv-watch-row .asset-logo {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--tv-pane);
}
.tv-watch-row .sym {
  font: 700 13px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-symbol-strong);
  letter-spacing: 0.02em;
}
.tv-watch-row .px {
  flex-shrink: 0;
  text-align: right;
  font: 600 13px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-text);
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}
.tv-watch-row .px.up { color: var(--tv-up); font-weight: 700; }
.tv-watch-row .px.down { color: var(--tv-down); font-weight: 700; }
.tv-watch-row .px.flat { color: var(--tv-muted); }
.tv-watch-row.hidden { display: none; }
.tv-watch-empty {
  padding: 14px 12px;
  color: var(--tv-muted);
  font-size: 12px;
}
.tv-watch-empty.hidden { display: none; }

.tv-sidebar-strategy {
  flex: 1 1 32%;
  min-height: 110px;
  overflow: auto;
  padding: 10px 12px;
  background: var(--tv-deep);
}
.tv-sidebar-strategy h4 {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--tv-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.tv-sidebar-performance {
  flex: 1 1 30%;
  min-height: 130px;
  overflow: auto;
  padding: 10px 10px;
  background: var(--tv-deep);
}
.tv-sidebar-performance h4 {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--tv-muted);
  font-weight: 600;
  text-transform: uppercase;
}
.performance-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.performance-row-title {
  color: #f0f3fa;
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.performance-row-cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}
.performance-card {
  min-width: 0;
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  background: var(--tv-pane);
  padding: 5px 3px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.performance-card.pos { background: rgba(8, 153, 129, 0.23); }
.performance-card.neg { background: rgba(242, 54, 69, 0.22); }
.performance-value {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--tv-muted);
  white-space: nowrap;
}
.performance-card.pos .performance-value { color: var(--tv-up); }
.performance-card.neg .performance-value { color: var(--tv-down); }
.performance-label {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  color: var(--tv-muted);
}

.tv-status {
  height: var(--tv-status-h);
  flex-shrink: 0;
  border-top: 1px solid var(--tv-border);
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11px;
  color: var(--tv-muted);
  background: var(--tv-pane);
}
.tv-status .conn.ok { color: #4caf50; }
.tv-status .conn.err { color: var(--tv-down); }

.cf-stats {
  font-size: 11px;
  line-height: 1.5;
  color: var(--tv-text);
}
.cf-stats .pnl-pos { color: var(--tv-up); font-weight: 600; }
.cf-stats .pnl-neg { color: var(--tv-down); font-weight: 600; }
/* Strategy tester — collapsible bottom pane */
.tv-trades-split {
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--tv-border);
  background: var(--tv-deep);
  height: 300px;
  min-height: 0;
  max-height: 42vh;
  overflow: hidden;
}
.tv-trades-split.collapsed {
  flex-basis: 34px;
  height: 34px;
}
.tv-trades-split.collapsed .tv-trades-body { display: none; }
.tv-trades-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tv-text);
  border-bottom: 1px solid #1e222d;
  user-select: none;
}
.ask-form {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ask-label {
  color: #f0f3fa;
  font-weight: 700;
}
.ask-form input {
  flex: 1;
  min-width: 120px;
  height: 26px;
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  background: var(--tv-bg);
  color: var(--tv-text);
  padding: 0 9px;
  font: 12px -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
}
.ask-form input:focus {
  outline: none;
  border-color: var(--tv-accent);
}
.ask-form button,
#trades-toggle {
  font: inherit;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--tv-border);
  background: var(--tv-pane);
  color: var(--tv-text);
  font-size: 11px;
}
.ask-form button:hover,
#trades-toggle:hover { background: var(--tv-hover); }
.ask-form button:disabled {
  cursor: wait;
  opacity: 0.65;
}
.tv-trades-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.tv-trades-body .trades-scroll {
  overflow: auto;
  height: 100%;
}
.tv-trades-body.show-ask .trades-scroll { display: none; }
.tv-trades-body.show-ask .ask-response-pane { display: block; }
.ask-response-pane {
  display: none;
  height: 100%;
  overflow: auto;
  padding: 12px 14px;
}
.ask-response-pane.hidden { display: none !important; }
.ask-response-head {
  color: var(--tv-muted);
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.ask-response-body {
  color: var(--tv-text);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  max-width: 980px;
}
.ask-question {
  color: #f0f3fa;
  font-weight: 600;
  margin-bottom: 10px;
}
.ask-answer { color: var(--tv-text); white-space: pre-wrap; }
.ask-error { color: var(--tv-down); }
.trade-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  table-layout: fixed;
}
.trade-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--tv-bg);
  color: var(--tv-muted);
  font-weight: 600;
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--tv-border);
  white-space: nowrap;
}
.trade-table thead th.num { width: 52px; }
.trade-table thead th.type { width: 44px; }
.trade-table thead th.dt { width: 150px; }
.trade-table thead th.sig { width: 44px; }
.trade-table thead th.px { width: 88px; }
.trade-table thead th.sz { width: 72px; }
.trade-table thead th.pnl { width: 88px; }
.trade-table thead th.exc { width: 88px; }
.trade-table thead th.cum { width: 110px; }
.trade-table tr.trade-group { cursor: pointer; }
.trade-table tr.trade-entry { border-bottom: 1px solid #2a2e39; }
.trade-table tr.trade-exit:nth-child(4n + 1),
.trade-table tr.trade-exit:nth-child(4n + 1) + tr.trade-entry {
  background: var(--tv-row-hover);
}
.trade-table tr.trade-group:hover,
.trade-table tr.trade-group:hover + tr.trade-entry,
.trade-table tr.trade-exit:has(+ tr.trade-entry:hover) {
  background: var(--tv-row-active);
}
.trade-table td {
  padding: 4px 8px;
  vertical-align: middle;
  color: var(--tv-text);
  border-bottom: 1px solid #1e222d;
}
.trade-table tbody.trade-group tr:last-child td { border-bottom: none; }
.trade-num-wrap { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.trade-num { font-weight: 700; color: #f0f3fa; }
.trade-side { font-size: 10px; font-weight: 600; }
.trade-side.long { color: #2962ff; }
.trade-side.short { color: var(--tv-down); }
.trade-view-link {
  border: none;
  background: transparent;
  color: var(--tv-accent);
  cursor: pointer;
  font: 600 10px -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  padding: 0;
  text-decoration: underline;
}
.trade-table td.muted { color: var(--tv-muted); }
.trade-table td.tc-time { font-variant-numeric: tabular-nums; }
.trade-table td.tc-price,
.trade-table td.tc-sz,
.trade-table td.tc-metric { text-align: right; font-variant-numeric: tabular-nums; }
.trade-table .sig-open { color: #e040fb; font-weight: 600; }
.trade-table .pnl-pos { color: var(--tv-up); }
.trade-table .pnl-neg { color: var(--tv-down); }
.trade-empty { text-align: center; color: var(--tv-muted); padding: 16px !important; }

/* Quant research trigger */
.tv-research-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}
.tv-research-btn {
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  background: var(--tv-pane);
  color: var(--tv-muted);
  cursor: pointer;
  font: 600 11px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  padding: 6px 10px;
  white-space: nowrap;
}
.tv-research-btn:hover:not(:disabled) {
  color: var(--tv-text);
  background: var(--tv-hover);
}
.tv-research-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}
.tv-research-btn.tv-research-all {
  padding: 6px 8px;
  font-weight: 500;
}
.tv-research-wrap.hidden { display: none; }

/* Research in-progress badge */
.tv-research-badge {
  border: none;
  cursor: pointer;
  font: 700 10px/1.2 ui-monospace, monospace;
  white-space: nowrap;
  color: #1a1200;
  background: #f0b429;
  box-shadow: 0 0 0 0 rgba(240, 180, 41, 0.55);
  animation: tv-research-badge-pulse 2s ease-in-out infinite;
}
.tv-research-badge.hidden {
  display: none;
}
.tv-research-badge--header {
  border-radius: 999px;
  padding: 5px 10px;
  margin-right: 2px;
}
.tv-research-badge--rail {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 8px;
  height: 8px;
  min-width: 8px;
  padding: 0;
  border-radius: 50%;
  font-size: 0;
  line-height: 0;
  overflow: hidden;
  text-indent: -9999px;
  z-index: 1;
  pointer-events: auto;
}
.tv-research-badge--rail:not(.hidden)::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #f0b429;
}
@keyframes tv-research-badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240, 180, 41, 0.45); }
  50% { box-shadow: 0 0 0 4px rgba(240, 180, 41, 0); }
}

.tv-toast.research { border-left: 4px solid var(--tv-accent); }
.tv-toast.research.running { border-left-color: #f0b429; }
.tv-toast.research.done { border-left-color: var(--tv-up); }
.tv-toast.research.error { border-left-color: var(--tv-down); }

.tv-alert-sub-add {
  font: 700 18px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  padding: 2px 10px !important;
  color: var(--tv-accent) !important;
}
.tv-alert-sub-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tv-alert-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--tv-border);
}
.tv-alert-sub-symbol {
  flex: 0 0 auto;
  font: 600 13px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-symbol-strong);
}
.tv-alert-sub-meta {
  flex: 1;
  min-width: 0;
  font: 500 11px/1.2 ui-monospace, monospace;
  color: var(--tv-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tv-alert-sub-delete {
  flex: 0 0 auto;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--tv-down);
  cursor: pointer;
  font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  padding: 4px 8px;
}
.tv-alert-sub-delete:hover {
  background: rgba(242, 54, 69, 0.12);
}
.tv-alert-sub-empty,
.tv-alert-sub-loading {
  padding: 14px 12px;
  margin: 0;
  color: var(--tv-muted);
  font-size: 12px;
  line-height: 1.45;
}
.tv-alert-sub-modal-note {
  padding: 8px 12px 0;
  margin: 0;
}
.tv-alert-sub-picker-list {
  overflow-y: auto;
  max-height: 50vh;
  padding: 6px;
}
.tv-alert-sub-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--tv-text);
  cursor: pointer;
  font-size: 12px;
  padding: 10px 12px;
  text-align: left;
}
.tv-alert-sub-picker-item:hover {
  background: var(--tv-hover);
}
.tv-alert-sub-picker-label {
  font-weight: 600;
}
.tv-alert-sub-picker-meta {
  color: var(--tv-muted);
  font: 500 11px/1 ui-monospace, monospace;
}

/* Alert log (sidebar panel) */
.tv-alert-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 320px;
  max-height: 280px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--tv-pane);
  border: 1px solid var(--tv-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 120;
}
.tv-alert-panel.hidden { display: none; }
.tv-alert-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--tv-border);
  font-size: 12px;
  font-weight: 600;
}
.tv-alert-panel-head button {
  border: none;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  font-size: 11px;
}
.tv-alert-panel-head button:hover { color: var(--tv-text); }
.tv-alert-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}
.tv-alert-list li {
  padding: 8px 10px;
  border-bottom: 1px solid var(--tv-border);
  font-size: 12px;
  line-height: 1.35;
  cursor: default;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.tv-alert-list li.stage-s { border-left: 3px solid #2962ff; }
.tv-alert-list li.stage-r { border-left: 3px solid var(--tv-down); }
.tv-alert-list li.stage-p { border-left: 3px solid #f0b429; }
.tv-alert-list li.stage-o { border-left: 3px solid var(--tv-up); }
.tv-alert-list .alert-stage {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 10px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  margin-top: 1px;
}
.tv-alert-list .alert-stage.stage-s {
  border: 1px solid rgba(41, 98, 255, 0.65);
  background: rgba(41, 98, 255, 0.18);
  color: #7eb0ff;
}
.tv-alert-list .alert-stage.stage-r {
  border: 1px solid rgba(242, 54, 69, 0.65);
  background: rgba(242, 54, 69, 0.16);
  color: #ff8a93;
}
.tv-alert-list .alert-stage.stage-p {
  border: 1px solid rgba(240, 180, 41, 0.65);
  background: rgba(240, 180, 41, 0.14);
  color: #f0c85a;
}
.tv-alert-list .alert-stage.stage-o {
  border: 1px solid rgba(8, 153, 129, 0.65);
  background: rgba(8, 153, 129, 0.16);
  color: #6ee7c8;
}
.tv-alert-list .alert-body {
  flex: 1;
  min-width: 0;
}
.tv-alert-list li:last-child { border-bottom: none; }
.tv-alert-list li.alert-jump {
  cursor: pointer;
}
.tv-alert-list li.alert-jump:hover {
  background: var(--tv-row-hover);
}
.tv-alert-list .alert-meta {
  display: block;
  font-size: 10px;
  color: var(--tv-muted);
  margin-top: 2px;
}
.tv-alert-empty {
  margin: 0;
  padding: 12px 10px;
  font-size: 12px;
  color: var(--tv-muted);
}
.tv-alert-empty.hidden { display: none; }
.tv-toast-stack {
  position: fixed;
  top: calc(var(--tv-header-h) + 8px);
  right: 12px;
  z-index: 350;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 360px;
}
.tv-toast {
  pointer-events: auto;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--tv-pane);
  border: 1px solid var(--tv-border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  font-size: 13px;
  line-height: 1.35;
  animation: tv-toast-in 0.2s ease-out;
}
.tv-toast.stage-s { border-left: 4px solid #2962ff; }
.tv-toast.stage-r { border-left: 4px solid var(--tv-down); }
.tv-toast.stage-p { border-left: 4px solid #f0b429; }
.tv-toast.stage-o { border-left: 4px solid var(--tv-up); }
@keyframes tv-toast-in {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Left rail — chart indicators */
.tv-rail-indicators {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.tv-rail .indicator-toggle {
  width: 44px;
  min-height: 28px;
  height: auto;
  padding: 3px 2px;
  font-size: 8px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0;
  border: 1px solid transparent;
  border-radius: 4px;
}
.tv-rail .indicator-toggle[data-indicator="ema100"].active {
  background: rgba(41, 98, 255, 0.18);
  border-color: rgba(41, 98, 255, 0.55);
  color: #7eb0ff;
}
.tv-rail .indicator-toggle[data-indicator="ema200"].active {
  background: rgba(240, 180, 41, 0.16);
  border-color: rgba(240, 180, 41, 0.55);
  color: #ffd166;
}

/* Left rail — Technicals toggle */
.tv-rail .technicals-toggle {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.tv-rail .technicals-toggle.active {
  background: rgba(41, 98, 255, 0.18);
  border: 1px solid rgba(41, 98, 255, 0.55);
  color: #7eb0ff;
}

/* Technicals panel (between chart and right sidebar) */
.tv-technicals-panel {
  flex: 0 0 var(--tv-technicals-w);
  width: var(--tv-technicals-w);
  min-width: 260px;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--tv-pane);
  border-left: 1px solid var(--tv-border);
  border-right: 1px solid var(--tv-border);
}
.tv-technicals-panel.hidden {
  display: none;
}
.tv-technicals-resizer {
  width: 5px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  margin-left: -2px;
  z-index: 5;
}
.tv-technicals-resizer.hidden {
  display: none;
}
.tv-technicals-resizer:hover,
body.resizing-technicals .tv-technicals-resizer {
  background: var(--tv-accent);
}
body.resizing-technicals {
  cursor: col-resize;
  user-select: none;
}
.tv-technicals-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--tv-border);
}
.tv-technicals-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--tv-symbol-strong);
  flex-shrink: 0;
}
.tv-technicals-head h3 .pnl-pos { color: var(--tv-up); font-weight: 600; }
.tv-technicals-head h3 .pnl-neg { color: var(--tv-down); font-weight: 600; }
.tv-technicals-head h3 .pnl-muted { color: var(--tv-muted); }
.tv-technicals-head .tv-panel-search {
  flex: 1;
  justify-content: flex-end;
}
.tv-technicals-meta {
  flex: 1;
  font-size: 11px;
  color: var(--tv-muted);
  text-align: right;
}
.tv-technicals-close {
  border: none;
  background: transparent;
  color: var(--tv-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.tv-technicals-close:hover {
  color: var(--tv-text);
}
.tv-technicals-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px 12px;
}
.tv-technicals-body.hidden {
  display: none;
}
/* Research pane (side panel mode) */
.tv-research-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.tv-research-stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}
.tv-research-stream > * {
  flex-shrink: 0;
}
.tv-research-form {
  flex-shrink: 0;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
  border-top: 1px solid var(--tv-border);
  background: var(--tv-pane);
}
.tv-research-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  background: var(--tv-bg);
  color: var(--tv-text);
  font-size: 12px;
  padding: 6px 8px;
}
.tv-research-form input:focus {
  outline: none;
  border-color: var(--tv-accent);
}
.tv-research-form button {
  border: 1px solid var(--tv-accent);
  border-radius: 4px;
  background: rgba(41, 98, 255, 0.15);
  color: #7eb0ff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  white-space: nowrap;
}
.tv-research-form button:hover:not(:disabled) {
  background: rgba(41, 98, 255, 0.28);
}
.tv-research-form button:disabled {
  opacity: 0.55;
  cursor: wait;
}
.tv-research-cancel-form-btn {
  border-color: var(--tv-down) !important;
  background: rgba(242, 54, 69, 0.12) !important;
  color: #ff8a8a !important;
}
.tv-research-cancel-form-btn:hover:not(:disabled) {
  background: rgba(242, 54, 69, 0.22) !important;
  color: #ffb4b4 !important;
}
.tv-research-btn.tv-research-btn--cancel {
  border-color: var(--tv-down);
  color: #ff8a8a;
}
.tv-research-btn.tv-research-btn--cancel:hover:not(:disabled) {
  background: rgba(242, 54, 69, 0.15);
  color: #ffb4b4;
}
.tv-research-prompt {
  align-self: flex-end;
  max-width: 92%;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 10px 10px 2px 10px;
  background: rgba(41, 98, 255, 0.08);
  border: 1px solid rgba(41, 98, 255, 0.2);
  font-size: 12px;
  color: var(--tv-text);
  white-space: pre-wrap;
}
.tv-research-response {
  align-self: flex-start;
  max-width: 96%;
  margin: 4px 0 10px;
  padding: 8px 10px;
  border-radius: 10px 10px 10px 2px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--tv-border);
  font-size: 12px;
  line-height: 1.45;
  color: var(--tv-text);
  white-space: pre-wrap;
}
.tv-research-step {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--tv-muted);
}
.tv-research-step-body {
  flex: 1;
  min-width: 0;
}
.tv-research-cancel-btn {
  flex-shrink: 0;
  margin-left: auto;
  padding: 2px 8px;
  font-size: 11px;
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
}
.tv-research-cancel-btn:hover {
  color: var(--tv-down);
  border-color: var(--tv-down);
}
.tv-research-step.running .tv-research-step-icon {
  color: #f0b429;
}
.tv-research-step.done .tv-research-step-icon {
  color: var(--tv-up);
}
.tv-research-step.error .tv-research-step-icon {
  color: var(--tv-down);
}
.tv-research-step.canceled .tv-research-step-icon {
  color: var(--tv-muted);
}
.tv-research-step-icon {
  flex-shrink: 0;
  width: 14px;
  font-weight: 700;
}
.tv-research-step-detail {
  font-size: 11px;
  color: var(--tv-muted);
  margin-top: 2px;
}
.tv-research-delta {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--tv-text);
  white-space: pre-wrap;
}
.tv-research-delta.streaming::after {
  content: '▋';
  display: inline-block;
  margin-left: 2px;
  color: var(--tv-accent);
  animation: tv-research-cursor-blink 0.9s step-end infinite;
}
@keyframes tv-research-cursor-blink {
  50% { opacity: 0; }
}
.tv-research-card {
  margin-bottom: 12px;
  border: 1px solid var(--tv-border);
  border-radius: 6px;
  background: var(--tv-bg);
  overflow: hidden;
}
.tv-research-card-head {
  padding: 8px 10px;
  border-bottom: 1px solid var(--tv-border);
  font-size: 12px;
  font-weight: 600;
  color: var(--tv-symbol-strong);
}
.tv-research-table-wrap {
  max-height: min(380px, 50vh);
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.tv-research-table-wrap .tv-research-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--tv-bg);
  box-shadow: 0 1px 0 var(--tv-border);
}
.tv-research-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.tv-research-table th,
.tv-research-table td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--tv-border);
  text-align: left;
}
.tv-research-table th.num,
.tv-research-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.tv-research-table tr:last-child td {
  border-bottom: none;
}
.tv-research-table .sym-link {
  color: #7eb0ff;
  cursor: pointer;
  font-weight: 600;
}
.tv-research-table .sym-link:hover {
  text-decoration: underline;
}
.tv-research-compare {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
}
.tv-research-compare-col {
  padding: 8px;
  border-radius: 4px;
  background: var(--tv-pane);
  border: 1px solid var(--tv-border);
  font-size: 11px;
}
.tv-research-compare-col h5 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--tv-symbol-strong);
}
.tv-research-compare-col .metric {
  margin: 2px 0;
  color: var(--tv-muted);
}
.tv-research-compare-col .metric strong {
  color: var(--tv-text);
}
.tv-research-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid var(--tv-border);
}
.tv-research-action-btn {
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 4px 8px;
}
.tv-research-action-btn:hover {
  color: var(--tv-text);
  background: var(--tv-hover);
}
.tv-research-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.tv-research-chip {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--tv-border);
  background: var(--tv-panel);
  color: var(--tv-muted);
  cursor: pointer;
}
.tv-research-chip:hover {
  border-color: var(--tv-accent);
  color: var(--tv-text);
}
.tv-research-followup-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px 4px;
  border-top: 1px solid var(--tv-border);
  background: var(--tv-panel);
}
.tv-research-followup-chips.hidden,
.tv-research-followup-chips[hidden] {
  display: none;
}
.tv-research-followup-chip {
  font-size: 11px;
}
.tv-research-tier-slices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 10px 10px;
}
.tv-research-tier-slice {
  flex: 1 1 120px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--tv-border);
  text-align: center;
  font-size: 11px;
}
.tv-research-tier-slice strong {
  display: block;
  font-size: 15px;
  color: var(--tv-accent);
  margin-top: 4px;
}
.tv-research-gap {
  padding: 10px;
  margin: 8px 10px 10px;
  border-left: 3px solid #f0b429;
  background: rgba(240, 180, 41, 0.08);
  font-size: 12px;
  line-height: 1.45;
}
.tv-research-narrative-body {
  padding: 8px 10px 10px;
}
.tv-research-callout {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-left: 3px solid #f0b429;
  background: rgba(240, 180, 41, 0.08);
  border-radius: 0 4px 4px 0;
  font-size: 12px;
  line-height: 1.45;
}
.tv-research-callout-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #f0b429;
  margin-bottom: 4px;
}
.tv-research-callout-text {
  color: var(--tv-text);
}
.tv-research-section-head {
  margin: 10px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tv-symbol-strong);
}
.tv-research-section-sub {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 400;
  color: var(--tv-muted);
}
.tv-research-paragraph {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--tv-text);
}
.tv-research-takeaway {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: 4px;
  background: rgba(41, 98, 255, 0.08);
  border: 1px solid rgba(41, 98, 255, 0.2);
  font-size: 12px;
  line-height: 1.5;
  color: var(--tv-text);
}
.tv-research-bullets {
  margin: 0 0 8px 16px;
  padding: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--tv-text);
}
.tv-research-bullets li {
  margin-bottom: 4px;
}
.tv-research-sources {
  padding: 6px 10px 8px;
  border-top: 1px solid var(--tv-border);
  font-size: 10px;
  line-height: 1.4;
  color: var(--tv-muted);
}
.tv-research-delta--md {
  white-space: normal;
}
.tv-research-delta--md p {
  margin: 0 0 8px;
}
.tv-research-delta--md p:last-child {
  margin-bottom: 0;
}
.tv-research-md-h {
  margin: 10px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tv-symbol-strong);
}
.tv-research-md-list {
  margin: 0 0 8px 16px;
  padding: 0;
}
.tv-research-md-list li {
  margin-bottom: 4px;
}
.tv-research-persona {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tv-muted);
  margin-left: 8px;
}
.tv-rail-research-btn.active {
  background: rgba(41, 98, 255, 0.2);
  color: #7eb0ff;
}
.tv-technicals-meta.hidden {
  display: none;
}
.tv-technicals-head .tv-signals-refresh {
  flex: 0 0 26px;
}
.tv-tech-section {
  margin-bottom: 14px;
}
.tv-tech-section h4 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--tv-text);
}
.tv-tech-pivot-note {
  margin: 0 0 6px;
  font-size: 10px;
  color: var(--tv-muted);
}
.tv-tech-gauge-wrap {
  margin-bottom: 8px;
}
.tv-tech-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.tv-tech-gauge-label {
  font-size: 13px;
  font-weight: 600;
}
.tv-tech-gauge-label.buy,
.tv-tech-gauge-label.strong-buy { color: var(--tv-up); }
.tv-tech-gauge-label.sell,
.tv-tech-gauge-label.strong-sell { color: var(--tv-down); }
.tv-tech-gauge-label.neutral { color: var(--tv-muted); }
.tv-tech-gauge-counts {
  display: flex;
  gap: 10px;
  font-size: 10px;
  color: var(--tv-muted);
}
.tv-tech-gauge-counts .sell-count { color: var(--tv-down); }
.tv-tech-gauge-counts .buy-count { color: var(--tv-up); }
.tv-tech-gauge-arc {
  width: 100%;
  max-width: 220px;
}
.tv-tech-gauge-arc svg {
  display: block;
  width: 100%;
  height: auto;
}
.tv-tech-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.tv-tech-table th,
.tv-tech-table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--tv-border);
  text-align: left;
}
.tv-tech-table th.num,
.tv-tech-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.tv-tech-table th {
  color: var(--tv-muted);
  font-weight: 500;
}
.tv-tech-table td.action-buy { color: var(--tv-up); }
.tv-tech-table td.action-sell { color: var(--tv-down); }
.tv-tech-table td.action-neutral { color: var(--tv-muted); }
.tv-pivot-table {
  font-size: 10px;
}
.tv-pivot-table th,
.tv-pivot-table td {
  padding: 3px 4px;
}

/* Signals / Positions panel (shared side pane with Technicals) */
.tv-rail .sentiment-toggle {
  font-size: 11px;
}
.tv-rail .pnl-toggle {
  font-size: 10px;
  letter-spacing: -0.02em;
}
.tv-rail .bh-toggle {
  font-size: 10px;
  letter-spacing: -0.02em;
}
.tv-positions-scroll,
.tv-pnl-scroll,
.tv-bh-scroll {
  overflow-x: auto;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.tv-positions-table td.sym {
  font-weight: 600;
}
.tv-positions-table td.side-long { color: var(--tv-up); }
.tv-positions-table td.side-short { color: var(--tv-down); }
.tv-positions-table td.pnl-pos { color: var(--tv-up); }
.tv-positions-table td.pnl-neg { color: var(--tv-down); }
.tv-positions-table td.pnl-muted { color: var(--tv-muted); }
.tv-positions-table th,
.tv-positions-table td {
  white-space: nowrap;
}
.tv-positions-table th.positions-sortable {
  cursor: pointer;
  user-select: none;
}
.tv-positions-table th.positions-sortable:hover {
  color: var(--tv-text);
}
.tv-positions-table th.positions-sortable.sort-asc::after {
  content: ' ▲';
  font-size: 9px;
  opacity: 0.7;
}
.tv-positions-table th.positions-sortable.sort-desc::after {
  content: ' ▼';
  font-size: 9px;
  opacity: 0.7;
}
.tv-asset-sentiment-scroll {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.tv-asset-sentiment-summary {
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--tv-border);
}
.tv-asset-sentiment-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.tv-asset-sentiment-head .tv-news-sentiment {
  font-size: 12px;
  padding: 4px 10px;
}
.tv-asset-sentiment-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  font-size: 11px;
  color: var(--tv-muted);
}
.tv-asset-sentiment-stats strong {
  color: var(--tv-text);
  font-weight: 600;
}
.tv-fundamentals-scroll {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tv-fund-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.tv-fund-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--tv-panel);
  border: 1px solid var(--tv-border);
  color: var(--tv-text);
}
.tv-fund-badge--strong { color: var(--tv-up); border-color: var(--tv-up); }
.tv-fund-badge--moderate { color: var(--tv-muted); }
.tv-fund-badge--weak { color: var(--tv-down); border-color: var(--tv-down); }
.tv-fund-badge--under { color: var(--tv-up); border-color: var(--tv-up); }
.tv-fund-badge--over { color: var(--tv-down); border-color: var(--tv-down); }
.tv-fund-badge--fair { color: var(--tv-muted); }
.tv-fund-intrinsic {
  flex-basis: 100%;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--tv-text);
}
.tv-fund-intrinsic strong {
  color: var(--tv-up);
  font-weight: 600;
}
.tv-fund-intrinsic-upside {
  color: var(--tv-muted);
  font-size: 11px;
}
.tv-fund-intrinsic-note {
  flex-basis: 100%;
  font-size: 11px;
  color: var(--tv-muted);
  line-height: 1.35;
}
.tv-fund-table td:first-child {
  color: var(--tv-muted);
  width: 45%;
}
.tv-fund-empty {
  color: var(--tv-muted);
  font-style: italic;
}
.tv-fund-note {
  margin: 0 0 6px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--tv-text);
}
.tv-fund-disclaimer {
  margin: 0;
  font-size: 10px;
  line-height: 1.35;
  color: var(--tv-muted);
}
.tv-signals-scroll {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tv-signals-day-head {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--tv-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tv-signals-table td.side-long { color: var(--tv-up); }
.tv-signals-table td.side-short { color: var(--tv-down); }
.tv-signals-table th,
.tv-signals-table td {
  white-space: nowrap;
}
.tv-signals-table td:nth-child(2),
.tv-signals-table td:nth-child(6) {
  white-space: normal;
}

/* Broker overlay (Alpaca paper account) */
.tv-broker-overlay {
  position: fixed;
  inset: 0;
  z-index: 280;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 12px 12px calc(var(--tv-status-h) + 12px);
}
.tv-broker-overlay.hidden {
  display: none;
}
.tv-broker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
}
.tv-broker-panel {
  position: relative;
  z-index: 1;
  width: min(1180px, 96vw);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--tv-bg);
  border: 1px solid var(--tv-border);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.tv-broker-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--tv-border);
  background: var(--tv-pane);
}
.tv-broker-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.tv-broker-head h3 {
  margin: 0;
  font: 700 15px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-symbol-strong);
}
.tv-broker-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font: 600 10px/1.4 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  background: rgba(8, 153, 129, 0.16);
  color: var(--tv-up);
  border: 1px solid rgba(8, 153, 129, 0.35);
}
.tv-broker-account-tabs {
  display: flex;
  gap: 4px;
  margin-left: 4px;
}
.tv-broker-account-tabs button {
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  padding: 5px 10px;
  white-space: nowrap;
}
.tv-broker-account-tabs button:hover {
  color: var(--tv-text);
  background: var(--tv-hover);
}
.tv-broker-account-tabs button.active {
  color: #7eb0ff;
  background: rgba(41, 98, 255, 0.15);
  border-color: rgba(41, 98, 255, 0.35);
}
.tv-broker-status-area {
  flex-shrink: 0;
}
.tv-broker-panel[data-broker-status="ready"] .tv-broker-status-area {
  display: none;
}
.tv-broker-unconfigured.hidden,
.tv-broker-loading.hidden,
.tv-broker-content.hidden {
  display: none;
}
.tv-broker-unconfigured,
.tv-broker-loading {
  margin: 0;
  padding: 20px 16px;
  color: var(--tv-muted);
  font-size: 13px;
  line-height: 1.5;
}
.tv-broker-unconfigured code {
  font-size: 11px;
  color: var(--tv-text);
}
.tv-broker-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tv-broker-panel[data-broker-status="ready"] .tv-broker-content {
  display: flex;
}
.tv-broker-equity-section {
  flex: 1 1 0;
  min-height: 180px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 8px 16px 0;
  overflow: hidden;
}
.tv-broker-splitter {
  flex-shrink: 0;
  background: var(--tv-bg);
}
.tv-broker-splitter-v {
  height: 6px;
  flex: 0 0 6px;
  cursor: row-resize;
  border-top: 1px solid var(--tv-border);
  border-bottom: 1px solid var(--tv-border);
}
.tv-broker-splitter-h {
  width: 6px;
  flex: 0 0 6px;
  cursor: col-resize;
  border-left: 1px solid var(--tv-border);
  border-right: 1px solid var(--tv-border);
}
.tv-broker-splitter-v:hover,
.tv-broker-splitter-h:hover,
body.resizing-broker-pane .tv-broker-splitter-v,
body.resizing-broker-pane .tv-broker-splitter-h {
  background: rgba(41, 98, 255, 0.28);
}
body.resizing-broker-pane {
  user-select: none;
}
body.resizing-broker-pane-v {
  cursor: row-resize;
}
body.resizing-broker-pane-h {
  cursor: col-resize;
}
.tv-broker-equity-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 6px;
  flex-shrink: 0;
}
.tv-broker-total-label {
  display: block;
  font-size: 11px;
  color: var(--tv-muted);
  margin-bottom: 4px;
}
.tv-broker-equity-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.tv-broker-total {
  font: 700 28px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--tv-symbol-strong);
  font-variant-numeric: tabular-nums;
}
.tv-broker-change {
  font: 600 14px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
}
.tv-broker-change.up { color: var(--tv-up); }
.tv-broker-change.down { color: var(--tv-down); }
.tv-broker-change.flat { color: var(--tv-muted); }
.tv-broker-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--tv-muted);
  text-align: right;
}
.tv-broker-period-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  flex-shrink: 0;
}
.tv-broker-period-tabs button {
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  padding: 5px 10px;
}
.tv-broker-period-tabs button:hover {
  color: var(--tv-text);
  background: var(--tv-hover);
}
.tv-broker-period-tabs button.active {
  color: #7eb0ff;
  background: rgba(41, 98, 255, 0.15);
  border-color: rgba(41, 98, 255, 0.35);
}
.tv-broker-chart-wrap {
  flex: 1 1 0;
  min-height: 80px;
  height: auto;
  max-height: none;
  margin-bottom: 10px;
  border: 1px solid var(--tv-border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--tv-deep);
  position: relative;
  isolation: isolate;
}
.tv-broker-tables {
  flex: 1 1 0;
  min-height: 140px;
  display: flex;
  flex-direction: row;
  gap: 0;
  overflow: hidden;
  position: relative;
  z-index: 1;
  background: var(--tv-bg);
}
@media (max-width: 900px) {
  .tv-broker-tables {
    flex-direction: column;
  }
  .tv-broker-splitter-h {
    display: none;
  }
}
.tv-broker-table-section {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--tv-border);
}
.tv-broker-table-section:last-child {
  border-right: none;
}
@media (max-width: 900px) {
  .tv-broker-table-section {
    flex: 1 1 auto;
    border-right: none;
    border-bottom: 1px solid var(--tv-border);
  }
  .tv-broker-table-section:last-child {
    border-bottom: none;
  }
}
.tv-broker-table-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--tv-border);
  background: var(--tv-pane);
}
.tv-broker-table-head h4 {
  margin: 0;
  font: 700 12px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-symbol-strong);
}
.tv-broker-table-head .tv-panel-search {
  flex: 0 1 auto;
}
.tv-broker-table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.tv-broker-table-resizable {
  table-layout: fixed;
  width: 100%;
}
.tv-broker-table-resizable thead th {
  position: relative;
  overflow: hidden;
  min-width: 40px;
}
.tv-broker-table-resizable thead th .th-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 6px;
}
.tv-broker-table-resizable thead th .col-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
}
.tv-broker-table-resizable thead th .col-resize-handle:hover,
body.resizing-broker-col .tv-broker-table-resizable thead th .col-resize-handle {
  background: rgba(41, 98, 255, 0.28);
}
body.resizing-broker-col {
  cursor: col-resize;
  user-select: none;
}
.tv-broker-table thead th.num,
.tv-broker-table td.num {
  text-align: right;
}
.tv-broker-table thead th.dt,
.tv-broker-table td.dt {
  font-variant-numeric: tabular-nums;
}
.tv-broker-table td.sym {
  font-weight: 700;
  color: var(--tv-symbol-strong);
}
.tv-broker-table td.side-buy { color: var(--tv-up); }
.tv-broker-table td.side-sell { color: var(--tv-down); }
.tv-broker-table td.status-filled { color: var(--tv-up); }
.tv-broker-table td.status-canceled,
.tv-broker-table td.status-cancelled { color: var(--tv-muted); }
.tv-broker-table td.status-rejected { color: var(--tv-down); }

/* OMT overlay (Order Management & Traceability) */
.tv-omt-overlay {
  position: fixed;
  inset: 0;
  z-index: 280;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 12px 12px calc(var(--tv-status-h) + 12px);
}
.tv-omt-overlay.hidden { display: none; }
.tv-omt-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
}
.tv-omt-panel {
  position: relative;
  z-index: 1;
  width: min(1180px, 96vw);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--tv-bg);
  border: 1px solid var(--tv-border);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.tv-omt-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--tv-border);
  background: var(--tv-pane);
}
.tv-omt-head-left { display: flex; align-items: center; gap: 10px; }
.tv-omt-head h3 {
  margin: 0;
  font: 700 15px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-symbol-strong);
}
.tv-omt-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font: 600 10px/1.4 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  background: rgba(41, 98, 255, 0.16);
  color: #6b9bff;
  border: 1px solid rgba(41, 98, 255, 0.35);
}
.tv-omt-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--tv-border);
  background: var(--tv-bg);
}
.tv-omt-search-wrap { flex: 1; max-width: 280px; }
.tv-omt-search-wrap .tv-search-input,
.tv-omt-search-wrap input[type="search"] {
  width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--tv-border);
  background: var(--tv-pane);
  color: var(--tv-text);
}
.tv-omt-summary {
  flex: 1;
  font-size: 12px;
  color: var(--tv-muted);
}
.tv-omt-status-area { flex-shrink: 0; }
.tv-omt-panel[data-omt-status="ready"] .tv-omt-status-area { display: none; }
.tv-omt-loading.hidden,
.tv-omt-unconfigured.hidden,
.tv-omt-content.hidden { display: none; }
.tv-omt-loading,
.tv-omt-unconfigured {
  margin: 0;
  padding: 20px 16px;
  color: var(--tv-muted);
}
.tv-omt-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 0 12px;
}
.tv-omt-panel[data-omt-status="ready"] .tv-omt-content { display: flex; }
.tv-omt-tabs {
  flex-shrink: 0;
  display: flex;
  gap: 4px;
  padding: 10px 16px 0;
}
.tv-omt-tabs button {
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  font-size: 12px;
}
.tv-omt-tabs button:hover { color: var(--tv-text); background: var(--tv-pane); }
.tv-omt-tabs button.active {
  color: var(--tv-symbol-strong);
  background: var(--tv-pane);
  border-color: var(--tv-border);
  border-bottom-color: var(--tv-pane);
}
.tv-omt-position-banner {
  flex-shrink: 0;
  margin: 8px 16px 0;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  background: rgba(255, 152, 0, 0.12);
  border: 1px solid rgba(255, 152, 0, 0.35);
  color: #ffb74d;
}
.tv-omt-position-banner.hidden { display: none; }
.tv-omt-table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 8px 16px 0;
  border: 1px solid var(--tv-border);
  border-radius: 6px;
}
.tv-omt-table { width: 100%; font-size: 12px; }
.tv-omt-table-resizable {
  table-layout: fixed;
  width: 100%;
}
.tv-omt-table-resizable thead th {
  position: relative;
  overflow: hidden;
  min-width: 48px;
}
.tv-omt-table-resizable td {
  overflow: hidden;
  vertical-align: top;
}
.tv-omt-table-resizable td.omt-qty {
  white-space: nowrap;
  text-align: right;
}
.tv-omt-table-resizable td.omt-orders {
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tv-omt-table-resizable td.omt-reason {
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.tv-omt-table-resizable thead th .th-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 6px;
}
.tv-omt-table-resizable thead th .col-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
  z-index: 2;
}
.tv-omt-table-resizable thead th .col-resize-handle:hover,
body.resizing-omt-col .tv-omt-table-resizable thead th .col-resize-handle {
  background: rgba(41, 98, 255, 0.28);
}
body.resizing-omt-col {
  cursor: col-resize;
  user-select: none;
}
.tv-omt-table thead th {
  position: sticky;
  top: 0;
  background: var(--tv-pane);
  z-index: 1;
}
.tv-omt-table td.gap-yes { color: var(--tv-down); font-weight: 600; }
.tv-omt-table td.gap-benign { color: var(--tv-muted); font-style: italic; }
.tv-omt-table td.omt-idle { color: var(--tv-muted); }
.tv-omt-table tr.omt-idle-row td { color: var(--tv-muted); }
.tv-omt-table tr.omt-idle-row td.sym { color: var(--tv-text); }
.tv-omt-table td.gap-ok { color: var(--tv-muted); }
.tv-omt-gap-legend {
  font-size: 12px;
  color: var(--tv-muted);
  margin: 0 0 8px;
  line-height: 1.4;
}
.tv-omt-retry-btn {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--tv-border);
  background: var(--tv-panel);
  color: var(--tv-text);
  cursor: pointer;
}
.tv-omt-retry-btn:hover { border-color: var(--tv-accent); color: var(--tv-accent); }
.tv-omt-retry-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.tv-omt-table td.type-exit { color: #ffb74d; }
.tv-omt-table td.type-enter_long { color: var(--tv-up); }
.tv-omt-toolbar .tv-panel-action.active {
  border-color: var(--tv-accent);
  color: var(--tv-accent);
  background: rgba(41, 98, 255, 0.12);
}
.tv-omt-search-wrap.hidden { display: none; }
.tv-omt-table th.omt-sortable {
  cursor: pointer;
  user-select: none;
}
.tv-omt-table th.omt-sortable.sort-asc::after { content: ' ▲'; font-size: 9px; opacity: 0.7; }
.tv-omt-table th.omt-sortable.sort-desc::after { content: ' ▼'; font-size: 9px; opacity: 0.7; }
.tv-omt-table td.pos { color: var(--tv-up); }
.tv-omt-table td.neg { color: var(--tv-down); }

/* Agentic research — goal, plan, tool progress, deploy */
.tv-research-goal,
.tv-research-plan {
  align-self: stretch;
  margin: 6px 0;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--tv-border);
  background: rgba(41, 98, 255, 0.06);
  font-size: 12px;
}
.tv-research-goal-label,
.tv-research-plan-label {
  font-weight: 600;
  color: #7eb0ff;
  margin-bottom: 4px;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
}
.tv-research-goal-body {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--tv-text);
}
.tv-research-plan-summary {
  color: var(--tv-muted);
  margin-bottom: 6px;
  line-height: 1.35;
}
.tv-research-plan-steps {
  margin: 0;
  padding-left: 0;
  list-style: none;
}
.tv-research-plan-steps li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  color: var(--tv-muted);
}
.tv-research-plan-steps li.running { color: var(--tv-text); }
.tv-research-plan-steps li.done { color: var(--tv-up); }
.tv-research-plan-steps li.error { color: var(--tv-down); }
.tv-research-plan-num {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--tv-border);
  font-size: 10px;
  flex-shrink: 0;
}
.tv-research-tool-detail {
  font-size: 11px;
  color: var(--tv-muted);
  margin-left: 4px;
}
.tv-research-data-used {
  margin: 8px 0;
  font-size: 11px;
  color: var(--tv-muted);
}
.tv-research-data-used summary {
  cursor: pointer;
  color: #7eb0ff;
  user-select: none;
}
.tv-research-data-used-body {
  margin-top: 6px;
  padding: 6px 8px;
  border-left: 2px solid var(--tv-border);
  white-space: pre-wrap;
}
.tv-research-deploy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--tv-border);
}
.tv-research-action-btn {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--tv-border);
  background: var(--tv-pane);
  color: var(--tv-text);
  cursor: pointer;
}
.tv-research-action-btn:hover {
  border-color: var(--tv-accent);
  color: #7eb0ff;
}
.tv-research-div-status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
}
.tv-research-div-status.pass { background: rgba(38, 166, 91, 0.2); color: var(--tv-up); }
.tv-research-div-status.warn { background: rgba(242, 54, 69, 0.15); color: var(--tv-down); }
.tv-research-table tr.pass td:last-child { color: var(--tv-up); }
.tv-research-table tr.fail td:last-child { color: var(--tv-down); }
.tv-research-perf-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.tv-research-perf-cell {
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--tv-border);
  text-align: center;
  font-size: 11px;
}
.tv-research-perf-cell span {
  display: block;
  color: var(--tv-muted);
  margin-bottom: 4px;
}
.tv-research-perf-cell strong {
  font-size: 14px;
  color: var(--tv-text);
}
.tv-research-wizard-stub {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 0;
  font-size: 11px;
  color: var(--tv-muted);
  cursor: not-allowed;
  opacity: 0.7;
}
.tv-research-followup-chips:not(.hidden) {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px 0;
}

/* Portfolio Designer overlay */
.tv-portfolio-overlay {
  position: fixed;
  inset: 0;
  z-index: 285;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 12px 12px calc(var(--tv-status-h) + 12px);
}
.tv-portfolio-overlay.hidden {
  display: none;
}
.tv-portfolio-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
}
.tv-portfolio-panel {
  position: relative;
  z-index: 1;
  width: min(1280px, 98vw);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--tv-bg);
  border: 1px solid var(--tv-border);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
.tv-portfolio-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--tv-border);
  background: var(--tv-pane);
}
.tv-portfolio-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.tv-portfolio-head h3 {
  margin: 0;
  font: 700 15px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-symbol-strong);
}
.tv-portfolio-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font: 600 10px/1.4 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  background: rgba(41, 98, 255, 0.14);
  color: #6b9fff;
  border: 1px solid rgba(41, 98, 255, 0.35);
}
.tv-portfolio-toolbar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}
.tv-portfolio-name-input {
  flex: 1 1 160px;
  min-width: 120px;
  max-width: 280px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--tv-border);
  background: var(--tv-bg);
  color: var(--tv-text);
  font-size: 13px;
}
.tv-portfolio-risk-btn {
  border-color: rgba(242, 54, 69, 0.45);
  color: var(--tv-down);
}
.tv-portfolio-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr min(320px, 34vw);
  gap: 0;
  overflow: hidden;
}
.tv-portfolio-loading,
.tv-portfolio-empty {
  grid-column: 1 / -1;
  padding: 16px;
  color: var(--tv-muted);
  font-size: 13px;
}
.tv-portfolio-loading.hidden,
.tv-portfolio-empty.hidden {
  display: none;
}
.tv-portfolio-tier-grid {
  min-height: 0;
  overflow: auto;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-content: start;
}
.tv-portfolio-tier-grid.hidden {
  display: none;
}
.tv-portfolio-tier-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--tv-pane);
  border: 1px solid var(--tv-border);
  border-radius: 8px;
  padding: 8px;
}
.tv-portfolio-tier-head {
  font: 700 12px/1.3 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-symbol-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--tv-border);
}
.tv-portfolio-tier-count {
  font-weight: 600;
  color: var(--tv-muted);
  font-size: 11px;
}
.tv-portfolio-tier-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 48px;
}
.tv-portfolio-card {
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--tv-border);
  background: var(--tv-bg);
}
.tv-portfolio-card--risk {
  border-color: rgba(242, 54, 69, 0.55);
  background: rgba(242, 54, 69, 0.08);
}
.tv-portfolio-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}
.tv-portfolio-card-symbol {
  font: 700 12px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-symbol-strong);
}
.tv-portfolio-card-type {
  font-size: 10px;
  color: var(--tv-muted);
  text-transform: uppercase;
}
.tv-portfolio-card-reason {
  margin: 0 0 8px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--tv-muted);
}
.tv-portfolio-add-btn {
  width: 100%;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--tv-border);
  background: transparent;
  color: var(--tv-text);
  font-size: 11px;
  cursor: pointer;
}
.tv-portfolio-add-btn:hover {
  border-color: var(--tv-up);
  color: var(--tv-up);
}
.tv-portfolio-add-btn.added {
  opacity: 0.55;
  cursor: default;
}
.tv-portfolio-basket {
  border-left: 1px solid var(--tv-border);
  background: var(--tv-pane);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.tv-portfolio-basket-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--tv-border);
}
.tv-portfolio-basket-head h4 {
  margin: 0;
  font-size: 13px;
  color: var(--tv-symbol-strong);
}
.tv-portfolio-weight-total {
  font-size: 12px;
  color: var(--tv-up);
  font-weight: 600;
}
.tv-portfolio-weight-total.invalid {
  color: var(--tv-down);
}
.tv-portfolio-tier-summary {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--tv-muted);
  border-bottom: 1px solid var(--tv-border);
}
.tv-portfolio-basket-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 12px;
}
.tv-portfolio-basket-row {
  display: grid;
  grid-template-columns: 56px 72px 1fr 24px;
  gap: 6px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--tv-border);
}
.tv-portfolio-basket-row--risk {
  background: rgba(242, 54, 69, 0.08);
  border-radius: 4px;
  padding: 6px 4px;
}
.tv-portfolio-basket-symbol {
  font-weight: 700;
  font-size: 12px;
}
.tv-portfolio-basket-tier {
  font-size: 10px;
  color: var(--tv-muted);
}
.tv-portfolio-weight-input {
  width: 100%;
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid var(--tv-border);
  background: var(--tv-bg);
  color: var(--tv-text);
  font-size: 12px;
}
.tv-portfolio-remove-btn {
  border: none;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.tv-portfolio-risk-panel {
  flex-shrink: 0;
  border-top: 1px solid var(--tv-border);
  padding: 10px 12px;
  max-height: 180px;
  overflow: auto;
}
.tv-portfolio-risk-panel.hidden {
  display: none;
}
.tv-portfolio-risk-panel h4 {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--tv-down);
}
.tv-portfolio-risk-summary {
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--tv-muted);
}
.tv-portfolio-risk-list {
  margin: 0;
  padding-left: 16px;
  font-size: 11px;
  line-height: 1.4;
}
.tv-portfolio-risk-item.tv-portfolio-risk--high {
  color: var(--tv-down);
}
.tv-rail-portfolio-btn svg {
  width: 18px;
  height: 18px;
}
@media (max-width: 960px) {
  .tv-portfolio-body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .tv-portfolio-tier-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tv-portfolio-basket {
    border-left: none;
    border-top: 1px solid var(--tv-border);
    max-height: 40vh;
  }
}

.tv-portfolio-body.hidden,
#portfolio-design-panel.hidden {
  display: none;
}
.tv-portfolio-tabs {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--tv-border);
  background: var(--tv-pane);
}
.tv-portfolio-tab {
  padding: 7px 16px;
  border: 1px solid var(--tv-border);
  border-radius: 999px;
  background: transparent;
  color: var(--tv-text);
  font: 600 12px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.tv-portfolio-tab:hover {
  color: var(--tv-symbol-strong);
  border-color: var(--tv-accent);
  background: rgba(41, 98, 255, 0.08);
}
.tv-portfolio-tab.active {
  color: #fff;
  background: var(--tv-accent);
  border-color: var(--tv-accent);
}
html[data-theme="light"] .tv-portfolio-tab {
  color: var(--tv-text);
  background: var(--tv-bg);
}
html[data-theme="light"] .tv-portfolio-tab:hover {
  background: var(--tv-hover);
}
html[data-theme="light"] .tv-portfolio-tab.active {
  color: #fff;
  background: var(--tv-accent);
  border-color: var(--tv-accent);
}
.tv-portfolio-saved {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tv-portfolio-saved.hidden {
  display: none;
}
.tv-portfolio-saved-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: min(240px, 28vw) 1fr;
  gap: 0;
  overflow: hidden;
}
.tv-portfolio-saved-list-wrap {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--tv-border);
  background: var(--tv-pane);
}
.tv-portfolio-saved-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--tv-border);
}
.tv-portfolio-saved-list-head h4 {
  margin: 0;
  font: 700 13px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-symbol-strong);
}
.tv-portfolio-saved-refresh {
  padding: 2px 8px;
  font-size: 14px;
}
.tv-portfolio-saved-loading,
.tv-portfolio-saved-empty {
  padding: 12px;
  font-size: 12px;
  color: var(--tv-muted);
}
.tv-portfolio-saved-loading.hidden,
.tv-portfolio-saved-empty.hidden {
  display: none;
}
.tv-portfolio-saved-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow: auto;
  flex: 1;
}
.tv-portfolio-saved-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--tv-text);
  cursor: pointer;
  font-size: 12px;
}
.tv-portfolio-saved-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--tv-border);
}
.tv-portfolio-saved-item.active {
  background: rgba(41, 98, 255, 0.12);
  border-color: rgba(41, 98, 255, 0.35);
}
.tv-portfolio-saved-item-name {
  display: block;
  font-weight: 600;
  color: var(--tv-symbol-strong);
}
.tv-portfolio-saved-item-date {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  color: var(--tv-muted);
}
.tv-portfolio-perf-wrap {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.tv-portfolio-perf-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--tv-border);
  flex-shrink: 0;
}
.tv-portfolio-perf-head h4 {
  margin: 0;
  font: 700 13px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-symbol-strong);
}
.tv-portfolio-perf-meta {
  font-size: 11px;
  color: var(--tv-muted);
}
.tv-portfolio-perf-loading,
.tv-portfolio-perf-placeholder {
  padding: 16px;
  font-size: 13px;
  color: var(--tv-muted);
}
.tv-portfolio-perf-loading.hidden,
.tv-portfolio-perf-placeholder.hidden,
.tv-portfolio-perf-table-wrap.hidden {
  display: none;
}
.tv-portfolio-perf-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 8px 12px;
}
.tv-portfolio-perf-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.tv-portfolio-perf-table th,
.tv-portfolio-perf-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--tv-border);
  text-align: right;
  white-space: nowrap;
}
.tv-portfolio-perf-table th:first-child,
.tv-portfolio-perf-table td:first-child,
.tv-portfolio-perf-table th:nth-child(2),
.tv-portfolio-perf-table td:nth-child(2),
.tv-portfolio-perf-table th:nth-child(3),
.tv-portfolio-perf-table td:nth-child(3) {
  text-align: left;
}
.tv-portfolio-perf-table thead th {
  position: sticky;
  top: 0;
  background: var(--tv-bg);
  z-index: 1;
  font-weight: 600;
  color: var(--tv-muted);
}
.tv-portfolio-perf-table tfoot td {
  font-weight: 700;
  background: rgba(41, 98, 255, 0.06);
  border-top: 2px solid var(--tv-border);
}
.tv-portfolio-perf-table .pos {
  color: var(--tv-up);
}
.tv-portfolio-perf-table .neg {
  color: var(--tv-down);
}
.tv-portfolio-perf-table .metric-sub {
  color: var(--tv-muted);
  font-size: 10px;
}
.tv-portfolio-perf-table .symbol-cell {
  font-weight: 600;
  color: var(--tv-symbol-strong);
}
@media (max-width: 900px) {
  .tv-portfolio-saved-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .tv-portfolio-saved-list-wrap {
    border-right: none;
    border-bottom: 1px solid var(--tv-border);
    max-height: 28vh;
  }
}

.tv-portfolio-active {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tv-portfolio-active.hidden {
  display: none;
}
.tv-portfolio-active-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--tv-border);
  flex-shrink: 0;
}
.tv-portfolio-active-head h4 {
  margin: 0;
  font: 700 13px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-symbol-strong);
}
.tv-portfolio-active-sub {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--tv-muted);
}
.tv-portfolio-active-summary {
  font: 600 12px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-accent);
  white-space: nowrap;
}
.tv-portfolio-active-loading,
.tv-portfolio-active-empty {
  padding: 16px;
  font-size: 13px;
  color: var(--tv-muted);
}
.tv-portfolio-active-loading.hidden,
.tv-portfolio-active-empty.hidden,
.tv-portfolio-active-table-wrap.hidden {
  display: none;
}
.tv-portfolio-active-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 8px 12px;
}
.tv-portfolio-active-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.tv-portfolio-active-table th,
.tv-portfolio-active-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--tv-border);
  text-align: right;
  white-space: nowrap;
}
.tv-portfolio-active-table th:first-child,
.tv-portfolio-active-table td:first-child,
.tv-portfolio-active-table th:last-child,
.tv-portfolio-active-table td:last-child {
  text-align: left;
}
.tv-portfolio-active-table thead th {
  position: sticky;
  top: 0;
  background: var(--tv-bg);
  z-index: 1;
  font-weight: 600;
  color: var(--tv-muted);
}
.tv-portfolio-active-table .symbol-cell {
  font-weight: 600;
  color: var(--tv-symbol-strong);
}
.tv-portfolio-active-table tr.is-active {
  background: rgba(41, 98, 255, 0.04);
}
.tv-portfolio-active-table .pos {
  color: var(--tv-up);
}
.tv-portfolio-active-table .neg {
  color: var(--tv-down);
}
.tv-portfolio-active-table .dd {
  color: var(--tv-muted);
}
.tv-portfolio-active-tier {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid transparent;
}
.tv-portfolio-active-tier--tier1 {
  color: #7dffb2;
  background: rgba(0, 200, 83, 0.12);
  border-color: rgba(0, 200, 83, 0.25);
}
.tv-portfolio-active-tier--tier2 {
  color: #ffd166;
  background: rgba(255, 209, 102, 0.12);
  border-color: rgba(255, 209, 102, 0.25);
}
.tv-portfolio-active-tier--close {
  color: var(--tv-muted);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--tv-border);
}
.tv-portfolio-active-toggle {
  min-width: 88px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--tv-border);
  background: transparent;
  color: var(--tv-muted);
  font: 600 10px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.tv-portfolio-active-toggle:hover {
  border-color: var(--tv-accent);
  color: var(--tv-symbol-strong);
}
.tv-portfolio-active-toggle.is-on {
  color: #fff;
  background: var(--tv-accent);
  border-color: var(--tv-accent);
}
html[data-theme="light"] .tv-portfolio-active-toggle.is-on {
  color: #fff;
}


/* —— Flows main pane —— */
.tv-flows-pane {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  background: var(--tv-bg);
  overflow: hidden;
}
.tv-flows-pane.hidden { display: none; }
.tv-flows-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--tv-border);
}
.tv-flows-head-left,
.tv-flows-head-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.tv-flows-title {
  font: 600 13px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-text);
}
.tv-flows-meta {
  font-size: 11px;
  color: var(--tv-muted);
}
.tv-flows-horizons {
  display: inline-flex;
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  overflow: hidden;
}
.tv-flows-horizon {
  border: 0;
  background: var(--tv-chart-tabs-bg);
  color: var(--tv-muted);
  font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  padding: 6px 10px;
  cursor: pointer;
}
.tv-flows-horizon:hover { color: var(--tv-text); }
.tv-flows-horizon.active {
  background: rgba(41, 98, 255, 0.18);
  color: var(--tv-text);
}
.tv-flows-refresh {
  border: 1px solid var(--tv-border);
  border-radius: 4px;
  background: var(--tv-chart-tabs-bg);
  color: var(--tv-muted);
  font: 600 11px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  padding: 6px 10px;
  cursor: pointer;
}
.tv-flows-refresh:hover { color: var(--tv-text); }
.tv-flows-note {
  margin: 0;
  padding: 8px 14px 0;
  font-size: 11px;
  color: var(--tv-muted);
  line-height: 1.35;
}
.tv-flows-loading,
.tv-flows-empty,
.tv-flows-error {
  margin: 16px 14px;
  font-size: 13px;
  color: var(--tv-muted);
}
.tv-flows-error { color: #f23645; }
.tv-flows-loading.hidden,
.tv-flows-empty.hidden,
.tv-flows-error.hidden,
.tv-flows-detail.hidden,
.tv-flows-body.hidden { display: none; }
.tv-flows-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 14px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  align-content: start;
}
.tv-flows-card {
  border: 1px solid var(--tv-border);
  border-radius: 6px;
  background: var(--tv-pane, rgba(19, 23, 34, 0.55));
  padding: 10px 12px;
  min-width: 0;
}
.tv-flows-card-title {
  margin: 0 0 8px;
  font: 600 12px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-text);
}
.tv-flows-card-sub {
  margin: -4px 0 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tv-muted);
}
.tv-flows-card-sub.inflow { color: #3dd68c; }
.tv-flows-card-sub.outflow { color: #f23645; }
.tv-flows-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: baseline;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 5px 4px;
  border-radius: 4px;
  cursor: pointer;
  font: 12px/1.3 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
}
.tv-flows-row:hover { background: rgba(255, 255, 255, 0.04); }
.tv-flows-row-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--tv-text);
}
.tv-flows-row-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}
.tv-flows-row-value.inflow { color: #3dd68c; }
.tv-flows-row-value.outflow { color: #f23645; }
.tv-flows-detail {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 14px 18px;
}
.tv-flows-detail-back {
  border: 0;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  font: 600 12px/1 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  padding: 0 0 10px;
}
.tv-flows-detail-back:hover { color: var(--tv-text); }
.tv-flows-detail-title {
  margin: 0 0 12px;
  font: 600 14px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  color: var(--tv-text);
}
.tv-flows-detail-group {
  margin-bottom: 14px;
  border: 1px solid var(--tv-border);
  border-radius: 6px;
  padding: 8px 10px;
}
.tv-flows-detail-group-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font: 600 12px/1.2 -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
  margin-bottom: 6px;
  color: var(--tv-text);
}
.tv-flows-asset-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  color: var(--tv-muted);
}
.tv-flows-asset-row .sym { color: var(--tv-text); font-weight: 600; }
.tv-rail-flows-btn.active {
  color: var(--tv-text);
  background: rgba(41, 98, 255, 0.12);
}
