/* ========================================
   QUANTSAGE TERMINAL LAYOUT
   ========================================
   VectorBT Pro / QuantConnect inspired
   White Theme Terminal Design

   This file contains ONLY terminal layout components:
   - CSS Variables (terminal theme)
   - Global Navigation (60px)
   - Context Sidebar (280px)
   - Main Content Area
   - App Header
   - KPI Cards (Master Styles)
   - Chart Cards (Master Styles)
   - Data Tables (Master Styles)
   - Mobile Support

   Load order: terminal.css → page.css (e.g., insights.css)
   ======================================== */

/* All design tokens are defined in tokens.css (loaded first).
   terminal.css only adds layout-specific styles. */

/* === GHOST SCROLLBAR STYLING === */
/* Scrollbars are hidden by default, only appear on hover */

/* WebKit browsers (Chrome, Safari, Edge) */
.terminal-page ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.terminal-page ::-webkit-scrollbar-track {
  background: transparent;
}

.terminal-page ::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 10px;
  transition: background-color 0.3s ease;
}

/* Show scrollbar on container hover */
.terminal-page *:hover::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.15);
}

.terminal-page *:hover::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.3);
}

/* Firefox - thin scrollbar, transparent until hover */
.terminal-page * {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.terminal-page *:hover {
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

/* Global ghost scrollbar for body/html */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 10px;
  transition: background-color 0.3s ease;
}

body:hover::-webkit-scrollbar-thumb,
html:hover::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.15);
}

body:hover::-webkit-scrollbar-thumb:hover,
html:hover::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.3);
}

* {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

*:hover {
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

/* === BASE RESET === */
.terminal-page {
  margin: 0;
  padding: 0;
  font-family: var(--font-primary);
  background: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.5;
}

/* Reset all buttons in terminal to remove browser defaults */
.terminal-page button {
  border: none;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
}

/* === TERMINAL CONTAINER (Full Layout) === */
.terminal-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* === GLOBAL NAVIGATION BAR (60px) === */
.global-nav {
  width: var(--global-nav-width);
  min-width: var(--global-nav-width);
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
}

.global-nav-header {
  height: 52px;
  min-height: 52px;
  max-height: 52px;
  border-bottom: 1px solid var(--border-subtle);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  background: var(--bg-panel);
  flex-shrink: 0;
  position: relative;
}

.global-nav-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.global-nav-logo img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  object-fit: cover;
  filter: grayscale(0.3) contrast(1.1);
  opacity: 0.9;
  transition: filter 0.3s ease, opacity 0.3s ease;
}

.global-nav-logo img:hover {
  filter: grayscale(0);
  opacity: 1;
}

.global-nav-items {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0;
  gap: 0.25rem;
}

.global-nav-item {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
}

.global-nav-item:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-primary, #111111);
}

.global-nav-item.active {
  background: rgba(0, 0, 0, 0.06);
  color: #111111;
}

.global-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: #111111;
  border-radius: 0 3px 3px 0;
}

.global-nav-item i,
.global-nav-item svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.75;
  font-size: 1.125rem;
}

/* Tooltip on hover — only show when sidebar is collapsed */
.sidebar-collapsed .global-nav-item[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--text-primary);
  color: white;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  z-index: 1000;
}

.global-nav-footer {
  padding: 0;
  border-top: 1px solid var(--border-subtle);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  min-height: 52px;
  box-sizing: border-box;
  margin-top: auto;
  flex-shrink: 0;
}

/* === CONTEXT SIDEBAR (280px) === */
.context-sidebar {
  width: var(--context-sidebar-width);
  min-width: var(--context-sidebar-width);
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  margin-left: var(--global-nav-width);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  overflow: hidden;
  transition: width 0.3s ease, min-width 0.3s ease;
  height: 100vh;
}

/* Collapsed sidebar state - fully hidden */
.context-sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
  overflow: hidden;
}

.context-sidebar.collapsed + .sidebar-resize-handle {
  display: none;
}

/* Sidebar resize handle — inside sidebar, on right edge */
.sidebar-resize-handle {
  position: fixed;
  top: 52px;
  width: 5px;
  bottom: 0;
  cursor: col-resize;
  background: transparent;
  z-index: 25;
  transition: background 0.15s ease;
  /* left is set by JS based on sidebar width */
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.dragging {
  background: var(--accent, #00be8c);
}

/* Ensure sidebar border-right is visible through header */
.context-sidebar-header {
  border-right: 1px solid var(--border-subtle);
  margin-right: -1px;
}

/* Sidebar header — same height as unified header for line alignment */
.sidebar-header,
.context-sidebar-header {
  height: 52px;
  min-height: 52px;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 0.75rem;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  background: var(--bg-panel);
  flex-shrink: 0;
}

.context-sidebar-header {
  padding: 0 0.75rem 0 0.5rem;
  gap: 0.5rem;
}

.sidebar-title {
  flex: 1;
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* When sidebar has chat tabs, use flex column for tab content */
.context-sidebar.has-chat .context-sidebar-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  height: auto;
  flex: 1;
  min-height: 0;
}

/* Hide sidebar title when tabs are present */
.context-sidebar.has-chat .sidebar-title { display: none; }

.sidebar-toggle-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
}

/* Sidebar close button (mobile) */
.sidebar-close-btn {
  width: 28px;
  height: 28px;
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.sidebar-close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Sidebar content (scrollable) */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0; /* Important for flexbox scroll */
}

/* Sidebar section spacing */
.sidebar-section {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.75rem;
}

.sidebar-section:last-child {
  border-bottom: none;
}

.sidebar-section-title {
  display: flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.625rem;
}

.sidebar-section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  margin-right: 0.5rem;
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.sidebar-section-icon:hover {
  color: var(--accent);
}

/* Sidebar action footer - fixed at bottom of sidebar, aligned with global-nav-footer */
.sidebar-action-footer {
  margin-top: auto;
  padding: 0 1rem 18px;
  background: var(--bg-panel);
  flex-shrink: 0;
  border-top: 1px solid var(--border-subtle);
  position: sticky;
  bottom: 0;
  z-index: 10;
  width: 100%;
  box-sizing: border-box;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Symbol search autocomplete suggestions */
.symbol-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 6px 6px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.symbol-suggestion-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}

.symbol-suggestion-item:last-child {
  border-bottom: none;
}

.symbol-suggestion-item:hover {
  background: var(--bg-hover);
}

.symbol-suggestion-item .symbol {
  font-weight: 600;
  color: var(--text-primary);
}

.symbol-suggestion-item .company {
  color: var(--text-muted);
  font-size: 0.6875rem;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  max-width: 150px;
}

/* Sidebar expand button (for collapsed state) */
.sidebar-expand-btn {
  position: fixed;
  left: var(--global-nav-width);
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 40px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-left: none;
  border-radius: 0 6px 6px 0;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 101;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.sidebar-expand-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.terminal-container.sidebar-collapsed .sidebar-expand-btn {
  display: flex;
}

/* === MAIN CONTENT AREA === */
.terminal-main {
  flex: 1;
  margin-left: calc(var(--global-nav-width) + var(--context-sidebar-width));
  width: calc(100% - var(--global-nav-width) - var(--context-sidebar-width));
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  background: var(--bg-canvas);
  transition: margin-left 0.3s ease, width 0.3s ease;
  overflow: hidden;
}

.terminal-container.sidebar-collapsed .terminal-main {
  margin-left: var(--global-nav-width);
  width: calc(100% - var(--global-nav-width));
}

/* Full width terminal main (no context sidebar) */
.terminal-main.full-width {
  margin-left: var(--global-nav-width);
  width: calc(100% - var(--global-nav-width));
}

/* App header — now handled by unified-header.css (uh-* classes) */

/* header-icon-btn through user-dropdown — removed, now in unified-header.css */

/* Content area */
.terminal-content {
  flex: 1;
  padding: var(--space-6);
  padding-left: calc(var(--space-6) + 0.5rem);  /* Extra 8px left padding for sidebar separation */
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  /* Calculate height: 100vh - header height (52px + 1px border) */
  max-height: calc(100vh - 53px);
}

/* === COMMON BUTTON STYLES === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

/* Scoped to .trading-page for trading-specific button styles */
.trading-page .btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.trading-page .btn-primary:hover {
  background: var(--accent-hover, #009970);
  border-color: var(--accent-hover, #009970);
}

.trading-page .btn-secondary {
  background: var(--bg-panel);
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.trading-page .btn-secondary:hover {
  background: var(--bg-canvas);
  border-color: var(--border-strong);
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* === COMMON FORM ELEMENTS === */
.param-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.375rem 0;
  gap: 0.5rem;
}

.param-row:last-child {
  padding-bottom: 0;
}

.param-name {
  flex: 0 0 65px;
  font-size: 0.6875rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.param-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  font-size: 0.75rem;
  padding: 0.3125rem 0.5rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  color: var(--text-primary);
  height: 28px;
  box-sizing: border-box;
}

.param-input:focus {
  outline: none;
  border-color: var(--accent);
}

.param-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%236A737D' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  padding-right: 1.5rem;
}

/* === KPI CARDS (Master Styles) === */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.kpi-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  min-height: 80px;
  max-height: 80px;
}

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.kpi-icon.positive {
  background: rgba(40, 167, 69, 0.1);
  color: var(--color-positive);
}

.kpi-icon.negative {
  background: rgba(220, 53, 69, 0.1);
  color: var(--color-negative);
}

.kpi-icon.neutral {
  background: rgba(108, 117, 125, 0.1);
  color: var(--color-neutral);
}

.kpi-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.kpi-label {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-value {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-value.positive { color: var(--color-positive); }
.kpi-value.negative { color: var(--color-negative); }

.kpi-change {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-change.positive { color: var(--color-positive); }
.kpi-change.negative { color: var(--color-negative); }

/* === CHART CARDS (Master Styles) === */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--card-gap, 1rem);          /* 16px - Standardized grid gap */
  margin-bottom: var(--section-gap-y, 1.5rem); /* 24px - Standardized section margin */
}

/* 2-column chart grid (Sector & Industry) */
.charts-grid.charts-grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

/* 1-column chart grid (Recommendations - full width) */
.charts-grid.charts-grid-1 {
  grid-template-columns: 1fr;
}

/* 3-column chart grid layout (legacy) */
.charts-grid.charts-grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

/* Responsive: 1 column on medium screens */
@media (max-width: 1200px) {
  .charts-grid.charts-grid-2,
  .charts-grid.charts-grid-3 {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--card-border-radius, 8px); /* Standardized 8px */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  height: auto;
  max-height: none;
}

/* Scrollable chart cards for Sector/Industry */
.chart-card.chart-card-scrollable {
  min-height: 420px;
  max-height: 480px;
}

/* Recommendation chart card - wider layout */
.chart-card.chart-card-recommendation {
  min-height: 360px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: var(--space-3) var(--space-4);   /* 12px 16px - Standardized */
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-panel);
  flex-wrap: wrap;                          /* Allow wrapping on small screens */
}

.chart-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-header i {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Chart Toggle Buttons */
.chart-toggle-group {
  display: flex;
  gap: 2px;
  background: var(--bg-canvas);
  border-radius: 6px;
  padding: 2px;
}

.chart-toggle-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.chart-toggle-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

.chart-toggle-btn.active {
  color: var(--accent);
  background: var(--bg-panel);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Legacy tall chart card (for backwards compatibility) */
.chart-card-tall {
  min-height: 380px;
}

.chart-card-tall .chart-container {
  height: 320px;
  min-height: 280px;
}

.chart-body {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* Scrollable chart body for Sector/Industry with ghost scrollbar */
.chart-body.chart-body-scrollable {
  overflow-y: auto;
  max-height: 420px;
}

.chart-container {
  width: 100%;
  height: 320px;
  min-height: 280px;
  position: relative;
  flex: 1;
}

/* Scrollable chart container for Sector/Industry */
.chart-container.chart-container-scrollable {
  height: auto;
  min-height: 320px;
}

/* Recommendation chart container - centered donut */
.chart-container.chart-container-recommendation {
  height: 280px;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Ensure Plotly charts fill container */
.chart-container .js-plotly-plot,
.chart-container .plot-container,
.chart-container .svg-container {
  width: 100% !important;
  height: 100% !important;
}

/* Force Plotly main SVG to respect container bounds */
.chart-container .main-svg {
  width: 100% !important;
  height: 100% !important;
}

.chart-loading span {
  color: var(--loading-text-color);
  font-size: var(--loading-text-size);
}

/* === ICON COLOR CLASSES (Standardized) === */

/* Asset type icon colors */
.asset-icon-stocks {
  color: var(--accent);
}

.asset-icon-forex {
  color: var(--color-positive);
}

.asset-icon-crypto {
  color: #f7931a; /* Bitcoin orange */
}

.asset-icon-risk {
  color: var(--color-negative);
}

.asset-icon-momentum {
  color: var(--color-warning); /* Amber */
}

.asset-icon-fundamental {
  color: var(--accent);
}

.asset-icon-purple {
  color: var(--accent-purple, #8b5cf6); /* Purple for special categories */
}

/* Category icon colors (for macro.html) */
.category-icon-liquidity {
  color: var(--accent);
}

.category-icon-economy {
  color: var(--color-positive);
}

.category-icon-global {
  color: var(--accent-purple, #8b5cf6); /* Purple */
}

.category-icon-sentiment {
  color: #f97316; /* Orange */
}

/* Log level colors (for monitor.html) */
.log-level {
  margin-right: 0.5rem;
}

.log-level.info {
  color: var(--accent);
}

.log-level.error {
  color: var(--color-negative);
}

.log-level.warning {
  color: #fbbf24; /* Yellow */
}

.log-process {
  color: #60a5fa; /* Light blue */
  font-weight: 600;
  margin-right: 0.5rem;
}

.log-message {
  color: #f8f8f2; /* Light text */
}

/* === RECOMMENDATIONS SECTION (Master Styles) === */
.recommendations-section {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);   /* 12px 16px - Standardized with chart-header */
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-panel);
  font-size: 0.8125rem;                     /* 13px - Standardized with chart-header */
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 25;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: inherit;                       /* Inherit from section-header */
  font-weight: inherit;                     /* Inherit from section-header */
  color: var(--text-primary);
}

.section-title i {
  color: var(--text-muted);
}

/* Panel header - standardized to match chart-header and section-header */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4) !important;   /* 12px 16px - Standardized, !important to override trading.css */
  font-size: 0.8125rem !important;                     /* 13px - Standardized, !important to override trading.css */
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}

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

.table-container {
  overflow-x: auto;
}

/* === CARDS === */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}

.card-body {
  padding: 1rem;
}

/* === DATA TABLE - Clean White Theme === */
/* IMPORTANT: Must use border-collapse: separate for sticky positioning to work! */
.terminal-page .data-table {
  background: var(--bg-panel);
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  border: none;
}

.terminal-page .data-table th {
  background: var(--bg-panel);
  color: var(--text-primary);
  border: none;
  padding: 0.625rem 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-align: left;
}

.terminal-page .data-table td {
  background: var(--bg-panel);
  color: var(--text-primary);
  border: none;
  padding: 0.625rem 0.75rem;
  font-size: 0.75rem;
}

.terminal-page .data-table tbody tr {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
}

.terminal-page .data-table tbody tr:last-child {
  border-bottom: none;
}

.terminal-page .data-table tbody tr:hover td {
  background: var(--bg-canvas);
}

/* Loading message in table */
.terminal-page .data-table .loading-message {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}

.terminal-page .data-table .loading-message .loading-spinner {
  display: inline-block;
  margin-right: 0.5rem;
}

/* Table pagination */
.terminal-page .table-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-canvas);
  border-top: 1px solid var(--border-subtle);
  min-height: 50px;
  flex-shrink: 0;
}

.terminal-page .table-pagination .btn {
  background: var(--bg-panel);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.terminal-page .table-pagination .btn:hover:not(:disabled) {
  background: var(--bg-canvas);
  border-color: var(--border-strong);
}

.terminal-page .table-pagination .btn:disabled {
  opacity: 0.5;
  color: var(--text-muted);
  cursor: not-allowed;
}

#page-info {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* === SIGNAL BADGES === */
.signal-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
}

.signal-badge.strong-buy {
  background: rgba(40, 167, 69, 0.15);
  color: var(--color-positive);
}

.signal-badge.buy {
  background: rgba(40, 167, 69, 0.1);
  color: var(--color-positive);
}

.signal-badge.hold {
  background: rgba(108, 117, 125, 0.1);
  color: var(--color-neutral);
}

.signal-badge.sell {
  background: rgba(220, 53, 69, 0.1);
  color: var(--color-negative);
}

.signal-badge.strong-sell {
  background: rgba(220, 53, 69, 0.15);
  color: var(--color-negative);
}

/* === MOBILE SUPPORT === */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
}

.sidebar-overlay.active,
.sidebar-overlay.visible {
  display: block;
}

.mobile-sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 102, 255, 0.3);
  z-index: 200;
  transition: transform 0.2s ease, background 0.2s ease;
  align-items: center;
  justify-content: center;
}

.mobile-sidebar-toggle:hover {
  transform: scale(1.05);
  background: var(--accent-hover, #009970);
}

.mobile-sidebar-toggle.active {
  background: var(--color-negative);
}

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

@media (max-width: 768px) {
  /* === BOTTOM TAB BAR — replaces hidden sidebar nav === */
  .global-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto !important;
    width: 100%;
    min-width: 100%;
    height: calc(52px + env(safe-area-inset-bottom, 0px));
    flex-direction: row;
    transform: none !important;
    z-index: 200;
    border-right: none;
    border-top: 1px solid var(--border-subtle);
    padding: 0 2px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    transition: none;
    align-items: flex-start;
    background: var(--bg-panel);
  }

  .global-nav.open {
    transform: none;
  }

  .global-nav-header {
    display: none;
  }

  /* Flatten all wrappers — all <a> become direct flex children of .global-nav */
  .global-nav-items,
  .global-nav-footer {
    display: contents;
  }

  .global-nav-item {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: auto;
    height: 100%;
    padding: 6px 0 2px;
    border-radius: 0;
    gap: 2px;
    min-width: 0;
    font-size: 0.625rem;
    text-decoration: none;
  }

  .global-nav-item i {
    font-size: 1rem;
    line-height: 1;
  }

  /* Show text labels under icons on mobile — override desktop hover tooltip */
  .global-nav-item[data-tooltip]::after,
  .global-nav-item[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: static;
    display: block;
    background: none;
    color: inherit;
    padding: 0;
    font-size: 0.5625rem;
    font-weight: 500;
    line-height: 1;
    transform: none;
    white-space: nowrap;
    border-radius: 0;
    z-index: auto;
  }

  .global-nav-item.active::before {
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    border-radius: 0 0 3px 3px;
  }

  /* === CONTEXT SIDEBAR — slide-in overlay from left === */
  .context-sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: calc(52px + env(safe-area-inset-bottom, 0px));
    margin-left: 0;
    z-index: 150;
    width: 280px;
    min-width: 280px;
    height: auto;
    transition: left 0.3s ease;
    transform: none;
  }

  .context-sidebar.mobile-visible,
  .context-sidebar.mobile-open,
  .context-sidebar.open {
    left: 0;
    transform: none;
  }

  /* === MAIN CONTENT — full width, above bottom tab bar === */
  .terminal-main {
    margin-left: 0;
    width: 100%;
    height: auto;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px));
  }

  .terminal-main.full-width {
    margin-left: 0;
    width: 100%;
  }

  /* Hide the FAB toggle — bottom nav replaces it */
  .mobile-sidebar-toggle {
    display: none !important;
  }

  /* Old .app-header mobile overrides removed — now in unified-header.css */

  .terminal-content {
    padding: var(--space-3);
    max-height: none;
  }

  /* Hide sidebar collapse chevron on mobile but keep its space for centering */
  .sidebar-toggle-btn {
    visibility: hidden;
    width: 28px;
    height: 28px;
  }

  /* Show close button in sidebar header on mobile */
  .sidebar-close-btn {
    display: flex;
  }

  /* Shrink title icon on mobile */
  .title-icon {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }

  /* Keep animated-title gap tight */
  .animated-title {
    gap: 0.375rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .kpi-card {
    padding: 0.875rem 1rem;
  }

  .kpi-icon {
    width: 40px;
    height: 40px;
  }

  .kpi-value {
    font-size: 1.25rem;
  }

  /* Legal disclaimer — static on mobile, sits in content flow above bottom nav */
  .legal-disclaimer {
    position: static;
    z-index: auto;
    opacity: 0.5;
  }

  /* Sidebar overlay */
  .sidebar-overlay {
    z-index: 140;
  }

  /* Sidebar expand button — hide on mobile (use filter toggle in header) */
  .sidebar-expand-btn {
    display: none !important;
  }

  /* Old user-profile mobile overrides removed — now in unified-header.css */
}

/* H8: Bottom nav — hide text labels on narrow screens with 7+ items */
@media (max-width: 480px) {
  .global-nav-item[data-tooltip]::after,
  .global-nav-item[data-tooltip]:hover::after {
    display: none;
  }
  .global-nav-item {
    padding: 8px 0 4px;
  }
  .global-nav-item i {
    font-size: 1.125rem;
  }
}

/* === UTILITY CLASSES === */
.text-positive { color: var(--color-positive); }
.text-negative { color: var(--color-negative); }
.text-neutral { color: var(--color-neutral); }
.text-muted { color: var(--text-muted); }

/* Loading states */
/* .loading-spinner and @keyframes spin are now defined in tokens.css */
.loading-spinner {
  width: var(--spinner-sm);
  height: var(--spinner-sm);
  border: 2px solid var(--spinner-border-color);
  border-top-color: var(--spinner-active-color);
  border-radius: var(--radius-full);
  animation: spin var(--spinner-speed) linear infinite;
}

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

/* === STICKY TABLE FOR STOCK RECOMMENDATIONS === */
/*
 * TABLE STRUCTURE:
 * - Row 1 (thead tr:first-child):
 *   - Cols 1-9: rowspan="2" (Ticker, Company, Country, Sector, Industry, Price, Upside, Health, Volume)
 *   - Cols 10-12: Strategy headers with colspan="4" (Dividend, Momentum, Fundamental)
 *   - Col 13: rowspan="2" (Overall)
 * - Row 2 (thead tr:nth-child(2)):
 *   - 12 strategy sub-columns only
 * - Body: 22 columns total
 *
 * Z-INDEX HIERARCHY (from highest to lowest):
 * - 200: Frozen header cells (Ticker, Company - both sticky top AND left) - HIGHEST
 * - 60:  Rowspan="2" header cells (Country, Sector, etc - sticky top only)
 * - 40:  Row 2 strategy sub-column headers (sticky top only, scroll horizontally UNDER frozen cols)
 * - 30:  Frozen body cells (Ticker, Company - sticky left only)
 * - 1:   Regular body cells (no sticky)
 */

.sticky-table-wrapper {
  overflow: hidden;
  border-radius: 0;
}

.sticky-table-container {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 600px;
  position: relative;
}

/* Base table setup */
.terminal-page .data-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  table-layout: auto;
}

/* ========================================
   HEADER ROW 1 - All cells sticky at top:0
   IMPORTANT: Must use !important to override any conflicting styles
   ======================================== */
.terminal-page .data-table thead tr:first-child th {
  position: sticky !important;
  top: 0 !important;
  z-index: 50;
  background: var(--bg-panel) !important;
  padding: 0.5rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-subtle);
  height: 32px;
  line-height: 32px;
  box-sizing: border-box;
}

/* ========================================
   HEADER ROW 2 - Strategy sub-columns at top:32px
   IMPORTANT: These cells ONLY stick vertically, NOT horizontally!
   z-index: 40 so they slide UNDER frozen columns (z-index: 200)
   ======================================== */
.terminal-page .data-table thead tr:nth-child(2) th {
  position: sticky !important;
  top: 32px !important;
  left: auto !important;  /* CRITICAL: Don't stick horizontally - scroll with table */
  z-index: 40 !important;  /* Lower than frozen columns (200) so they slide under */
  background: var(--bg-panel) !important;
  padding: 0.5rem 0.5rem;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-subtle);
  height: 32px;
  line-height: 32px;
  box-sizing: border-box;
}

/* ========================================
   ROWSPAN="2" CELLS - Span full header height
   These cells span both rows so must be at top:0
   z-index: 60 to be above row 2 headers (z-index: 50)
   ======================================== */
.terminal-page .data-table thead th[rowspan="2"] {
  top: 0 !important;
  z-index: 60 !important;
  height: 64px;
  line-height: 1.2;
  vertical-align: middle;
  background: var(--bg-panel) !important;
}

/* ========================================
   FROZEN COLUMN 1: TICKER (left: 0)
   Header uses rowspan="2" so spans both header rows
   Must have highest z-index to overlay ALL other cells
   ======================================== */
/* Header - frozen corner cell (highest z-index) */
.terminal-page .data-table thead th:first-child {
  position: sticky !important;
  top: 0 !important;
  left: 0 !important;
  z-index: 200 !important;  /* Highest - above everything */
  background: var(--bg-panel) !important;
  min-width: 90px;
  width: 90px;
  box-shadow: 1px 0 0 0 var(--border-subtle);
}

/* Body - frozen left column */
.terminal-page .data-table tbody td:first-child {
  position: sticky !important;
  left: 0 !important;
  z-index: 30 !important;  /* Higher than other body cells */
  background: var(--bg-panel) !important;
  min-width: 90px;
  width: 90px;
  box-shadow: 1px 0 0 0 var(--border-subtle);
}

/* ========================================
   FROZEN COLUMN 2: COMPANY (left: 90px)
   Header uses rowspan="2" so spans both header rows
   Must have highest z-index to overlay ALL other cells
   ======================================== */
/* Header - frozen corner cell (highest z-index) */
.terminal-page .data-table thead th:nth-child(2) {
  position: sticky !important;
  top: 0 !important;
  left: 90px !important;
  z-index: 200 !important;  /* Highest - above everything */
  background: var(--bg-panel) !important;
  min-width: 160px;
  max-width: 160px;
  width: 160px;
}

/* Body - frozen left column */
.terminal-page .data-table tbody td:nth-child(2) {
  position: sticky !important;
  left: 90px !important;
  z-index: 30 !important;  /* Higher than other body cells */
  background: var(--bg-panel) !important;
  min-width: 160px;
  max-width: 160px;
  width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Shadow on frozen boundary (right edge of column 2) */
.terminal-page .data-table thead th:nth-child(2)::after,
.terminal-page .data-table tbody td:nth-child(2)::after {
  content: '';
  position: absolute;
  right: -4px;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(to right, rgba(0,0,0,0.08), transparent);
  pointer-events: none;
}

/* ========================================
   COLUMN WIDTHS - Regular columns (3-9)
   ======================================== */
/* Country */
.terminal-page .data-table thead th:nth-child(3),
.terminal-page .data-table tbody td:nth-child(3) {
  min-width: 70px;
}

/* Sector */
.terminal-page .data-table thead th:nth-child(4),
.terminal-page .data-table tbody td:nth-child(4) {
  min-width: 100px;
}

/* Industry */
.terminal-page .data-table thead th:nth-child(5),
.terminal-page .data-table tbody td:nth-child(5) {
  min-width: 100px;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Price, Upside, Health, Volume */
.terminal-page .data-table thead th:nth-child(6),
.terminal-page .data-table thead th:nth-child(7),
.terminal-page .data-table thead th:nth-child(8),
.terminal-page .data-table thead th:nth-child(9),
.terminal-page .data-table tbody td:nth-child(6),
.terminal-page .data-table tbody td:nth-child(7),
.terminal-page .data-table tbody td:nth-child(8),
.terminal-page .data-table tbody td:nth-child(9) {
  min-width: 80px;
  text-align: right;
}

/* ========================================
   BODY CELL STYLING
   ======================================== */
.terminal-page .data-table tbody td {
  background: var(--bg-panel);
  padding: 0.625rem 0.5rem;
  font-size: 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-subtle);
}

/* Row hover */
.terminal-page .data-table tbody tr:hover td {
  background: var(--bg-canvas);
}

/* Ensure frozen columns maintain solid background on hover */
.terminal-page .data-table tbody tr:hover td:first-child,
.terminal-page .data-table tbody tr:hover td:nth-child(2) {
  background: var(--bg-canvas);
}

/* Full width table card */
.table-card {
  margin-top: 1rem;
}

.table-card .section-header {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-panel);
}

.table-card .section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.table-card .section-title-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.table-card .section-title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0;
}

.table-card .section-actions {
  display: flex;
  gap: 0.5rem;
}

/* Ensure table action buttons are clearly visible */
.table-card .section-actions .btn {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  font-weight: 500;
}

.table-card .section-actions .btn:hover {
  background: var(--accent-hover, #009970);
  border-color: var(--accent-hover, #009970);
}

/* Strategy column headers (colspan headers in first row)
   IMPORTANT: Use SOLID colors for backgrounds to prevent bleed-through */
.terminal-page .data-table .strategy-header {
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid !important;
  box-shadow: none !important;
  height: 32px !important;
  line-height: 1.4 !important;
}

.terminal-page .data-table .strategy-header.dividend {
  background: #f4fbf6 !important; /* Solid light green */
  border-bottom-color: var(--color-positive) !important;
  color: var(--color-positive);
}

.terminal-page .data-table .strategy-header.momentum {
  background: #f0f6ff !important; /* Solid light blue */
  border-bottom-color: var(--accent) !important;
  color: var(--accent);
}

.terminal-page .data-table .strategy-header.fundamental {
  background: #f5f5f6 !important; /* Solid light gray */
  border-bottom-color: var(--color-neutral) !important;
  color: var(--color-neutral);
}

/* Strategy sub-columns (second row) - ensure consistent width with regular columns
   IMPORTANT: Use SOLID colors for backgrounds to prevent bleed-through */
.terminal-page .data-table .strategy-column {
  text-align: center;
  font-size: 0.625rem;
  min-width: 90px;
  width: 90px;
}

.terminal-page .data-table .strategy-column.dividend {
  background: #fcfefc !important; /* Solid very light green */
}

.terminal-page .data-table .strategy-column.momentum {
  background: #f9fbff !important; /* Solid very light blue */
}

.terminal-page .data-table .strategy-column.fundamental {
  background: #fbfbfc !important; /* Solid very light gray */
}

/* Ensure body cells under strategy columns have same width */
.terminal-page .data-table tbody td:nth-child(n+10):nth-child(-n+21) {
  text-align: center;
  min-width: 90px;
}

/* Sortable columns - DO NOT use position: relative here as it breaks sticky */
.terminal-page .data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.terminal-page .data-table th.sortable:hover {
  background: var(--bg-canvas);
}

.terminal-page .data-table th.sortable::after {
  content: '↕';
  display: inline-block;
  margin-left: 0.25rem;
  font-size: 0.625rem;
  color: var(--text-muted);
  opacity: 0.5;
  vertical-align: middle;
}

.terminal-page .data-table th.sortable.asc::after {
  content: '↑';
  opacity: 1;
  color: var(--accent);
}

.terminal-page .data-table th.sortable.desc::after {
  content: '↓';
  opacity: 1;
  color: var(--accent);
}

/* Page size selector */
.page-size {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

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

.select-styled {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  color: var(--text-primary);
  cursor: pointer;
}

/* Symbol link styling in table */
.terminal-page .data-table .symbol-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.terminal-page .data-table .symbol-link:hover {
  text-decoration: underline;
}

/* Score badges in table */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 600;
}

.score-badge.high {
  background: rgba(40, 167, 69, 0.1);
  color: var(--color-positive);
}

.score-badge.medium {
  background: rgba(255, 193, 7, 0.1);
  color: #856404;
}

.score-badge.low {
  background: rgba(220, 53, 69, 0.1);
  color: var(--color-negative);
}

/* ================================================================
   SHARED: Animated Header Title (used across all pages)
   Extracted from universe.css for cross-page consistency
   ================================================================ */
.header-title-wrapper {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.animated-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
}
.title-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--agent-brand-hover, #00a67e));
  border-radius: var(--radius-md);
  color: white;
  font-size: var(--fs-md);
  animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 190, 140, 0.4); }
  50% { box-shadow: 0 0 12px 4px rgba(0, 190, 140, 0.2); }
}
.title-text {
  background: linear-gradient(90deg, var(--text-primary), var(--accent), var(--text-primary));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 4s ease infinite;
}
@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ================================================================
   SHARED: Filter Group Title (sidebar section headers)
   Extracted from universe.css for cross-page consistency
   ================================================================ */
.filter-group-title {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  margin: var(--space-3) 0 var(--space-2) 0;
  padding: var(--space-1-5) 0;
  border-top: 1px solid var(--border-subtle);
}
.filter-group-title:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.filter-group-title i {
  font-size: var(--fs-xs);
  color: var(--accent);
  width: 14px;
  text-align: center;
}
.filter-group-title.collapsible {
  cursor: pointer;
  transition: color 0.2s;
}
.filter-group-title.collapsible:hover {
  color: var(--text-primary);
}
.filter-group-title .toggle-icon {
  margin-left: auto;
  font-size: 0.5rem;
  transition: transform 0.2s;
}

/* ================================================================
   SHARED: Unified Tabs (horizontal tab navigation)
   ================================================================ */
.qs-tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-4);
}
.qs-tab {
  padding: var(--space-2) var(--space-4);
  background: none;
  border: none;
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}
.qs-tab:hover { color: var(--text-primary); }
.qs-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ================================================================
   SHARED: Filter Controls (sidebar buttons, chips, sliders)
   ================================================================ */
.filter-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}
.filter-chip {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.filter-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.filter-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.sidebar-status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
}
.sidebar-status-badge.fresh { background: rgba(16,185,129,0.1); color: var(--color-positive); }
.sidebar-status-badge.stale { background: rgba(245,158,11,0.1); color: var(--color-warning); }
.sidebar-status-badge.loading { background: rgba(0,0,0,0.04); color: var(--text-muted); }

/* =============================================================================
   QS STANDARD CONTENT TABS
   Canonical shared styles for .qs-tab-bar / .qs-tab across all QS pages.
   Page-specific CSS may override padding/gap for layout needs but must NOT
   change color or interaction behavior (active = accent, hover = text-primary).
   ============================================================================= */

.qs-tab-bar {
  display: flex;
  gap: var(--tab-gap);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.qs-tab-bar::-webkit-scrollbar { display: none; }

.qs-tab {
  padding: var(--tab-padding);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font-primary);
  font-size: var(--tab-font-size);
  font-weight: var(--tab-font-weight);
  color: var(--tab-inactive-color);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}
.qs-tab:hover { color: var(--text-primary); }
.qs-tab.active {
  color: var(--tab-active-color);
  border-bottom-color: var(--tab-active-color);
}
.sidebar-status-badge.error { background: rgba(239,68,68,0.1); color: var(--color-negative); }

/* =============================================================================
   QS STANDARD EMPTY STATE
   Use .qs-empty-state for all data-absent states across QS pages.
   Never use bare text, blank divs, or inline styles for empty content.
   ============================================================================= */

.qs-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--text-muted);
  gap: var(--space-3);
}

.qs-empty-state__icon {
  font-size: var(--icon-2xl);
  opacity: 0.4;
}

.qs-empty-state__title {
  margin: 0;
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
}

.qs-empty-state__desc {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  max-width: 280px;
}

.qs-empty-state__cta {
  margin-top: var(--space-1);
}
