/**
 * V2 Overlay & Tray Styles + Global Theme System
 * 
 * This file contains:
 * 1. GLOBAL THEME SYSTEM - Light/Dark mode CSS variables
 * 2. Styles for Fund Profile Overlay, Compare Tray, and Recent Funds bar
 * 
 * =============================================================================
 * THEME SYSTEM DOCUMENTATION
 * =============================================================================
 * 
 * The theme system uses CSS custom properties (variables) that automatically
 * switch between light and dark values when the .dark-theme class is toggled
 * on the <html> element.
 * 
 * HOW TO USE IN NEW PAGES/COMPONENTS:
 * ------------------------------------
 * Use these CSS variables instead of hardcoded colors:
 * 
 * BACKGROUNDS:
 *   --v2-bg-page       Page background (lightest/darkest)
 *   --v2-bg-surface    Card/panel background
 *   --v2-bg-elevated   Elevated elements (modals, dropdowns)
 *   --v2-bg-hover      Hover state background
 *   --v2-bg-active     Active/pressed state background
 *   --v2-bg-input      Form input background
 * 
 * TEXT:
 *   --v2-text-primary     Primary text (headings, body)
 *   --v2-text-secondary   Secondary text (descriptions)
 *   --v2-text-muted       Muted text (labels, hints)
 *   --v2-text-placeholder Placeholder text
 * 
 * BORDERS:
 *   --v2-border        Standard border
 *   --v2-border-light  Subtle border
 *   --v2-border-focus  Focus ring border
 * 
 * ACCENT/BRAND:
 *   --v2-accent          Brand color (buttons, links)
 *   --v2-accent-hover    Brand hover state
 *   --v2-accent-bg       Brand background (pills, badges)
 *   --v2-accent-bg-hover Brand background hover
 * 
 * STATUS:
 *   --v2-success   Success/positive
 *   --v2-warning   Warning/caution
 *   --v2-danger    Error/destructive
 * 
 * SHADOWS:
 *   --v2-shadow-sm   Small shadow
 *   --v2-shadow-md   Medium shadow
 *   --v2-shadow-lg   Large shadow
 * 
 * LEGACY VARIABLES (for existing pages):
 *   --color-bg, --color-bg-soft, --color-text, --color-muted, --color-border
 *   --bg, --bg-elev, --text, --muted, --border
 * 
 * EXAMPLE USAGE:
 *   .my-component {
 *     background: var(--v2-bg-surface);
 *     color: var(--v2-text-primary);
 *     border: 1px solid var(--v2-border);
 *   }
 *   .my-component:hover {
 *     background: var(--v2-bg-hover);
 *   }
 * 
 * The theme is controlled by themeToggleV2.js which:
 * - Persists preference to localStorage
 * - Respects system preference on first visit
 * - Provides API: themeToggleV2.toggle(), .setTheme(), .isDark(), etc.
 * 
 * =============================================================================
 */

/* ============================================================================
   THEME VARIABLES - Light Theme (Default)
   Also overrides legacy app-shell variables for consistent theming
   ============================================================================ */
:root {
  /* V2 Backgrounds */
  --v2-bg-page: #f8f9fa;
  --v2-bg-surface: #ffffff;
  --v2-bg-elevated: #ffffff;
  --v2-bg-hover: #f1f3f4;
  --v2-bg-active: #e9ecef;
  --v2-bg-input: #ffffff;
  /* Some component CSS references `--v2-bg-primary` / `--v2-bg-secondary`
     (e.g. chart-lab share popover, share-hub modal, ETF universe cards).
     Alias them to the existing surface/page colours so they stay in sync
     with theme switches without editing every consumer. */
  --v2-bg-primary: #ffffff;
  --v2-bg-secondary: #f9fafb;
  
  /* V2 Text */
  --v2-text-primary: #212529;
  --v2-text-secondary: #495057;
  --v2-text-muted: #6c757d;
  --v2-text-placeholder: #adb5bd;
  
  /* V2 Borders */
  --v2-border: #dee2e6;
  --v2-border-light: #e9ecef;
  --v2-border-focus: #0964A0;
  
  /* V2 Accent */
  --v2-accent: #0964A0;
  --v2-accent-hover: #075280;
  --v2-accent-bg: rgba(9, 100, 160, 0.1);
  --v2-accent-bg-hover: rgba(9, 100, 160, 0.15);
  
  /* V2 Status */
  --v2-success: #28a745;
  --v2-warning: #ffc107;
  --v2-danger: #dc3545;
  
  /* V2 Shadows */
  --v2-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --v2-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --v2-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  
  /* Legacy overlay variables (for backwards compat) */
  --overlay-bg: var(--v2-bg-elevated);
  --overlay-border: var(--v2-border);
  --overlay-header-h: 64px;
  --overlay-tabs-h: 44px;
  --sidebar-w: 280px;
  
  /* ========================================================================
     LEGACY APP-SHELL VARIABLE OVERRIDES (Light Theme)
     These override the dark defaults in app-shell.css
     ======================================================================== */
  --bg: #f7f9fc;
  --bg-elev: #ffffff;
  --text: #212529;
  --text-strong: #1a1a2e;
  --muted: #6c757d;
  --border: #dee2e6;
  --success: #28a745;
  --warning: #ffc107;
  --danger: #dc3545;

  /* Chart Lab / share-save popover / scp panel variables. These were
     referenced by Chart Lab CSS with light-only hard-coded fallbacks,
     causing any surface / hover colour inside dark mode to render white.
     Defining them centrally makes every consumer reactive to the theme. */
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --hover: #f1f5f9;
  --accent: #0964a0;
  --accent-hover: #07537e;
  --accent-bg: #e0f2fe;

  /* Short generic aliases used by component CSS (compare tool, reports,
     chart lab, etc.) that were never declared. Without these every
     `var(--bg-surface)` / `var(--text-primary)` falls through to its
     hard-coded light fallback even when dark mode is active. */
  --bg-surface: #ffffff;
  --bg-secondary: #f9fafb;
  --text-primary: #212529;
  --text-secondary: #495057;
  --muted-bg: #f1f3f4;
  --card-bg: #ffffff;
  --bg-card: #ffffff;
  --bg-offset: #f3f4f6;
  --bg-sidebar: #111827;
  --positive: #16a34a;
  --negative: #dc2626;
  /* Short hover alias used by `.cb-scp__scope-btn`, `.cb-scope-btn` and a
     handful of other components. Left undeclared previously, which caused
     any `var(--bg-hover)` in dark mode to land on its light fallback
     (#f1f5f9) and flash white on hover. */
  --bg-hover: #f1f5f9;

  /* ========================================================================
     ETF DATABASE / PAGE-LEVEL VARIABLE OVERRIDES (Light Theme)
     These override etfMainV2.css variables
     ======================================================================== */
  --color-primary: #1C98D4;
  --color-primary-600: #0964A0;
  --color-accent: #1C98D4;
  --color-text: #2B2B2B;
  --color-muted: #6B7280;
  --color-border: #E5E7EB;
  --color-bg: #FFFFFF;
  --color-bg-soft: #F7F8FA;
  --color-success: #17B26A;
  --color-warning: #F4B740;
  --color-danger: #E11D48;
}

/* ============================================================================
   THEME VARIABLES - Dark Theme
   Also overrides legacy app-shell variables for consistent theming
   ============================================================================ */
.dark-theme {
  /* V2 Backgrounds */
  --v2-bg-page: #0c111a;
  --v2-bg-surface: #111520;
  --v2-bg-elevated: #161b26;
  --v2-bg-hover: rgba(255, 255, 255, 0.05);
  --v2-bg-active: rgba(255, 255, 255, 0.08);
  --v2-bg-input: rgba(255, 255, 255, 0.05);
  --v2-bg-primary: #111520;
  --v2-bg-secondary: #161b26;
  
  /* V2 Text */
  --v2-text-primary: #e6e9f0;
  --v2-text-secondary: #c4c9d4;
  --v2-text-muted: #8b92a5;
  --v2-text-placeholder: #6b7280;
  
  /* V2 Borders */
  --v2-border: #1e2433;
  --v2-border-light: #252d3d;
  --v2-border-focus: #0964A0;
  
  /* V2 Accent (slightly brighter in dark mode) */
  --v2-accent: #0d7cc4;
  --v2-accent-hover: #0a9bea;
  --v2-accent-bg: rgba(9, 100, 160, 0.2);
  --v2-accent-bg-hover: rgba(9, 100, 160, 0.3);
  
  /* V2 Shadows (more subtle in dark mode) */
  --v2-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --v2-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --v2-shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
  
  /* Legacy overlay variables */
  --overlay-bg: var(--v2-bg-elevated);
  --overlay-border: var(--v2-border);
  
  /* ========================================================================
     LEGACY APP-SHELL VARIABLE OVERRIDES (Dark Theme)
     ======================================================================== */
  --bg: #0b0e13;
  --bg-elev: #111520;
  --text: #e6e9f0;
  --text-strong: #E8F2F9;
  --muted: #ADADAD;
  --border: #1e2433;
  --success: #1fa971;
  --warning: #e2b534;
  --danger: #e05b5b;

  /* Dark-mode equivalents for the Chart Lab shared vars defined in :root.
     Surfaces use the elevated panel colour, hover is a subtle white tint,
     accent-bg is a translucent accent fill that reads against both the
     surface and the hover row. */
  --surface: #161b26;
  --surface-hover: rgba(255, 255, 255, 0.06);
  --hover: rgba(255, 255, 255, 0.06);
  --accent: #0d7cc4;
  --accent-hover: #0a9bea;
  --accent-bg: rgba(13, 124, 196, 0.22);

  /* Dark-mode values for generic short-name aliases. */
  --bg-surface: #111520;
  --bg-secondary: #161b26;
  --text-primary: #e6e9f0;
  --text-secondary: #c4c9d4;
  --muted-bg: rgba(255, 255, 255, 0.05);
  --card-bg: #161b26;
  --bg-card: #161b26;
  --bg-offset: rgba(255, 255, 255, 0.05);
  --bg-sidebar: #0b0e13;
  --positive: #22c55e;
  --negative: #ef4444;
  --bg-hover: rgba(255, 255, 255, 0.05);
  
  /* ========================================================================
     ETF DATABASE / PAGE-LEVEL VARIABLE OVERRIDES (Dark Theme)
     These override etfMainV2.css variables
     ======================================================================== */
  --color-primary: #2BA8E8;
  --color-primary-600: #1C98D4;
  --color-accent: #2BA8E8;
  --color-text: #e6e9f0;
  --color-muted: #9CA3AF;
  --color-border: #2d3748;
  --color-bg: #111520;
  --color-bg-soft: #1a202c;
  --color-success: #34D399;
  --color-warning: #FBBF24;
  --color-danger: #F87171;
}

/* ============================================================================
   HEADER & SIDEBAR THEME ADJUSTMENTS
   Ensure header/sidebar elements respond to theme toggle
   ============================================================================ */

/* Header buttons - light theme */
.app-header .btn-ghost,
.app-header .header-actions button {
  color: var(--text, #212529);
}

.app-header .btn-ghost:hover,
.app-header .header-actions button:hover {
  background: var(--v2-bg-hover, #f1f3f4);
  color: var(--v2-accent, #0964A0);
}

/* Header search - light theme */
.app-header .header-search input,
#v2-global-search {
  background: var(--v2-bg-input, #fff);
  border-color: var(--border, #dee2e6);
  color: var(--text, #212529);
}

.app-header .header-search input::placeholder,
#v2-global-search::placeholder {
  color: var(--muted, #6c757d);
}

.app-header .header-search input:focus,
#v2-global-search:focus {
  border-color: var(--v2-accent, #0964A0);
  box-shadow: 0 0 0 2px var(--v2-accent-bg, rgba(9, 100, 160, 0.1));
}

/* Sidebar links - ensure text is visible */
.app-sidebar .sidebar-link,
.app-sidebar .etf-sidebar-list-head,
.app-sidebar .flyout-header {
  color: var(--text, #212529);
}

.app-sidebar .sidebar-link:hover,
.app-sidebar .etf-sidebar-list-head:hover {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}

.app-sidebar h4,
.app-sidebar .etf-sidebar-head h4 {
  color: var(--text, #212529);
}

/* Active sidebar head text should always be white (on accent background) */
.app-sidebar .etf-sidebar-head.active h4 {
  color: #fff;
}

/* Dark theme overrides for header/sidebar */
.dark-theme .app-header .btn-ghost,
.dark-theme .app-header .header-actions button {
  color: var(--text, #e6e9f0);
}

.dark-theme .app-header .btn-ghost:hover,
.dark-theme .app-header .header-actions button:hover {
  background: var(--v2-bg-hover, rgba(255, 255, 255, 0.05));
  color: var(--v2-accent, #0d7cc4);
}

.dark-theme .app-header .header-search input,
.dark-theme #v2-global-search {
  background: var(--v2-bg-input, rgba(255, 255, 255, 0.05));
  border-color: var(--border, #1e2433);
  color: var(--text, #e6e9f0);
}

.dark-theme .app-sidebar .sidebar-link,
.dark-theme .app-sidebar .etf-sidebar-list-head,
.dark-theme .app-sidebar .flyout-header {
  color: var(--text, #e6e9f0);
}

.dark-theme .app-sidebar .sidebar-link:hover,
.dark-theme .app-sidebar .etf-sidebar-list-head:hover {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
}

.dark-theme .app-sidebar h4,
.dark-theme .app-sidebar .etf-sidebar-head h4 {
  color: var(--text, #e6e9f0);
}

/* Theme toggle button icon color */
#v2-theme-toggle {
  font-size: 16px;
}

#v2-theme-toggle i {
  color: var(--text, #212529);
  transition: color 0.15s ease;
}

.dark-theme #v2-theme-toggle i {
  color: var(--text, #e6e9f0);
}

/* Logo switching for light/dark mode */
.header-brand .logo-light {
  display: block;
}

.header-brand .logo-dark {
  display: none;
}

.dark-theme .header-brand .logo-light {
  display: none;
}

.dark-theme .header-brand .logo-dark {
  display: block;
}

/* ============================================================================
   GLOBAL BODY & MAIN CONTENT THEMING
   Ensures the entire page background and content areas respond to theme
   ============================================================================ */

/* Base page background */
html, body {
  background-color: var(--v2-bg-page, var(--color-bg, #f8f9fa));
  color: var(--v2-text-primary, var(--color-text, #212529));
  transition: background-color 0.15s ease, color 0.15s ease;
}

/* Main content area */
.app-main,
.app-body main,
#app-main,
.etf-content-main,
.terminal-wrapper,
#dash-wrapper {
  background-color: var(--v2-bg-page, var(--color-bg, #f8f9fa));
  color: var(--v2-text-primary, var(--color-text, #212529));
}

/* Cards, panels, and elevated surfaces */
.card,
.panel,
.etf-v2-container,
.etf-v2-header,
.etf-v2-toast,
.etf-v2-control-bar,
.etf-v2-main,
[class*="etf-v2-"],
.ag-root-wrapper {
  background-color: var(--v2-bg-surface, var(--color-bg, #ffffff));
  color: var(--v2-text-primary, var(--color-text, #212529));
}

/* Form inputs globally */
input,
select,
textarea,
.form-control {
  background-color: var(--v2-bg-input, var(--color-bg, #ffffff));
  color: var(--v2-text-primary, var(--color-text, #212529));
  border-color: var(--v2-border, var(--color-border, #dee2e6));
}

input::placeholder,
select::placeholder,
textarea::placeholder,
.form-control::placeholder {
  color: var(--v2-text-placeholder, var(--color-muted, #6c757d));
}

input:focus,
select:focus,
textarea:focus,
.form-control:focus {
  border-color: var(--v2-border-focus, var(--color-primary, #0964A0));
  outline: none;
  box-shadow: 0 0 0 2px var(--v2-accent-bg, rgba(9, 100, 160, 0.1));
}

/* Dark theme overrides for main content - using hardcoded colors */
html.dark-theme .app-main,
html.dark-theme .app-body main,
html.dark-theme #app-main,
html.dark-theme .etf-content-main,
html.dark-theme .terminal-wrapper,
html.dark-theme #dash-wrapper,
.dark-theme .app-main,
.dark-theme .app-body main,
.dark-theme #app-main,
.dark-theme .etf-content-main,
.dark-theme .terminal-wrapper,
.dark-theme #dash-wrapper {
  background-color: #0c111a !important;
  color: #e6e9f0 !important;
}

html.dark-theme .card,
html.dark-theme .panel,
html.dark-theme .etf-v2-container,
html.dark-theme .etf-v2-header,
html.dark-theme .etf-v2-toast,
html.dark-theme .etf-v2-control-bar,
html.dark-theme .etf-v2-main,
html.dark-theme [class*="etf-v2-"],
html.dark-theme .ag-root-wrapper,
.dark-theme .card,
.dark-theme .panel,
.dark-theme .etf-v2-container,
.dark-theme .etf-v2-header,
.dark-theme .etf-v2-toast,
.dark-theme .etf-v2-control-bar,
.dark-theme .etf-v2-main,
.dark-theme [class*="etf-v2-"],
.dark-theme .ag-root-wrapper {
  background-color: #111520 !important;
  color: #e6e9f0 !important;
}

html.dark-theme input,
html.dark-theme select,
html.dark-theme textarea,
html.dark-theme .form-control,
html.dark-theme .control-select,
.dark-theme input,
.dark-theme select,
.dark-theme textarea,
.dark-theme .form-control,
.dark-theme .control-select {
  background-color: #0c111a !important;
  color: #e6e9f0 !important;
  border-color: #1e2433 !important;
}

html.dark-theme .control-select:focus,
.dark-theme .control-select:focus {
  border-color: #0d7cc4 !important;
  box-shadow: 0 0 0 2px rgba(13, 124, 196, 0.2) !important;
}

html.dark-theme .control-select option,
.dark-theme .control-select option {
  background-color: #111520 !important;
  color: #e6e9f0 !important;
}

/* Generic <option> rule for every native <select> in dark mode. Browsers
   render the expanded <option> popup in the OS native control, which
   ignores the parent <select>'s background/color unless each <option> is
   styled directly. Without this, the expanded list flashes back to the
   OS default (white) on every dark-mode page with a raw <select> —
   affects: perf-asof-select, hist-view-select, hist-freq-select2,
   hist-field-select, hist-chart-type-select, visualizer viewSelector &
   groupBySelector, and many others. */
html.dark-theme select option,
.dark-theme select option {
  background-color: #111520 !important;
  color: #e6e9f0 !important;
}
html.dark-theme select option:hover,
html.dark-theme select option:checked,
.dark-theme select option:hover,
.dark-theme select option:checked {
  background-color: #1a2030 !important;
  color: #ffffff !important;
}

/* Control labels and separators */
html.dark-theme .control-label,
.dark-theme .control-label {
  color: #8b92a5 !important;
}

html.dark-theme .control-separator,
.dark-theme .control-separator {
  border-color: #1e2433 !important;
}

html.dark-theme .control-group,
html.dark-theme .control-item,
.dark-theme .control-group,
.dark-theme .control-item {
  color: #e6e9f0 !important;
}

/* Utility buttons */
html.dark-theme .btn-utility,
.dark-theme .btn-utility {
  background-color: #1e2433 !important;
  border-color: #2d3748 !important;
  color: #e6e9f0 !important;
}

html.dark-theme .btn-utility:hover,
.dark-theme .btn-utility:hover {
  background-color: #2d3748 !important;
  border-color: #3d4a5c !important;
}

html.dark-theme .btn-utility:focus,
.dark-theme .btn-utility:focus {
  box-shadow: 0 0 0 2px rgba(13, 124, 196, 0.3) !important;
  border-color: #0d7cc4 !important;
}

html.dark-theme .btn-utility svg,
.dark-theme .btn-utility svg {
  color: #c4c9d4 !important;
  fill: currentColor !important;
}

html.dark-theme .btn-utility:hover svg,
.dark-theme .btn-utility:hover svg {
  color: #e6e9f0 !important;
}

/* Action buttons (primary blue) - slightly brighter in dark mode */
html.dark-theme .btn-action,
.dark-theme .btn-action {
  background-color: #0d7cc4 !important;
  color: #ffffff !important;
}

html.dark-theme .btn-action:hover,
.dark-theme .btn-action:hover {
  background-color: #0a9bea !important;
}

/* Secondary buttons */
html.dark-theme .btn-secondary,
.dark-theme .btn-secondary {
  background-color: #1e2433 !important;
  border-color: #2d3748 !important;
  color: #e6e9f0 !important;
}

html.dark-theme .btn-secondary:hover,
.dark-theme .btn-secondary:hover {
  background-color: #2d3748 !important;
}

/* Outline buttons */
html.dark-theme .btn-outline,
.dark-theme .btn-outline {
  background-color: transparent !important;
  border-color: #0d7cc4 !important;
  color: #e6e9f0 !important;
}

html.dark-theme .btn-outline:hover,
.dark-theme .btn-outline:hover {
  background-color: rgba(13, 124, 196, 0.15) !important;
}

/* Ghost buttons */
html.dark-theme .btn-ghost,
.dark-theme .btn-ghost {
  background-color: transparent !important;
  color: #e6e9f0 !important;
}

html.dark-theme .btn-ghost:hover,
.dark-theme .btn-ghost:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
  color: #0d7cc4 !important;
}

/* Link buttons */
html.dark-theme .btn-link,
.dark-theme .btn-link {
  color: #0d7cc4 !important;
}

html.dark-theme .btn-link:hover,
.dark-theme .btn-link:hover {
  color: #0a9bea !important;
}

/* Tables */
table,
.table {
  background-color: var(--v2-bg-surface, var(--color-bg, #ffffff));
  color: var(--v2-text-primary, var(--color-text, #212529));
}

table th,
.table th {
  background-color: var(--v2-bg-page, var(--color-bg-soft, #f8f9fa));
  color: var(--v2-text-primary, var(--color-text, #212529));
  border-color: var(--v2-border, var(--color-border, #dee2e6));
}

table td,
.table td {
  border-color: var(--v2-border, var(--color-border, #dee2e6));
}

html.dark-theme table,
html.dark-theme .table,
.dark-theme table,
.dark-theme .table {
  background-color: #111520 !important;
  color: #e6e9f0 !important;
}

html.dark-theme table th,
html.dark-theme .table th,
.dark-theme table th,
.dark-theme .table th {
  background-color: #0c111a !important;
  color: #e6e9f0 !important;
  border-color: #1e2433 !important;
}

html.dark-theme table td,
html.dark-theme .table td,
.dark-theme table td,
.dark-theme .table td {
  border-color: #1e2433 !important;
  color: #e6e9f0 !important;
}

/* Links */
a {
  color: var(--v2-accent, var(--color-primary, #0964A0));
}

a:hover {
  color: var(--v2-accent-hover, var(--color-primary-600, #075280));
}

/* Modals and overlays */
.modal-content,
.dropdown-menu,
.popover,
.tooltip-inner {
  background-color: var(--v2-bg-elevated, var(--color-bg, #ffffff));
  color: var(--v2-text-primary, var(--color-text, #212529));
  border-color: var(--v2-border, var(--color-border, #dee2e6));
}

html.dark-theme .modal-content,
html.dark-theme .dropdown-menu,
html.dark-theme .popover,
html.dark-theme .tooltip-inner,
.dark-theme .modal-content,
.dark-theme .dropdown-menu,
.dark-theme .popover,
.dark-theme .tooltip-inner {
  background-color: #161b26 !important;
  color: #e6e9f0 !important;
  border-color: #1e2433 !important;
}

/* Page header theming */
.page-header {
  background: var(--v2-bg-surface, #ffffff);
  border-color: var(--v2-border, #dee2e6);
  color: var(--v2-text-primary, #212529);
}

html.dark-theme .page-header,
.dark-theme .page-header {
  background: #111520 !important;
  border-color: #1e2433 !important;
  color: #e6e9f0 !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ============================================================================
   CUSTOM DROPDOWN - Global Dark Theme Overrides (hardcoded colors)
   ============================================================================ */
html.dark-theme .custom-dropdown .dropdown-selected,
.dark-theme .custom-dropdown .dropdown-selected {
  background-color: #0c111a !important;
  border-color: #1e2433 !important;
  color: #e6e9f0 !important;
}

html.dark-theme .custom-dropdown .dropdown-selected:hover,
.dark-theme .custom-dropdown .dropdown-selected:hover {
  border-color: #0d7cc4 !important;
}

html.dark-theme .custom-dropdown.open .dropdown-selected,
.dark-theme .custom-dropdown.open .dropdown-selected {
  border-color: #0d7cc4 !important;
  box-shadow: 0 0 0 2px rgba(13, 124, 196, 0.2) !important;
}

html.dark-theme .custom-dropdown .dropdown-selected::after,
.dark-theme .custom-dropdown .dropdown-selected::after {
  border-color: #8b92a5 !important;
}

html.dark-theme .custom-dropdown .dropdown-options,
.dark-theme .custom-dropdown .dropdown-options {
  background-color: #161b26 !important;
  color: #e6e9f0 !important;
  border-color: #1e2433 !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
}

html.dark-theme .custom-dropdown .dropdown-option-header,
.dark-theme .custom-dropdown .dropdown-option-header {
  color: #8b92a5 !important;
  border-color: #1e2433 !important;
  background-color: #111520 !important;
}

html.dark-theme .custom-dropdown .dropdown-option,
.dark-theme .custom-dropdown .dropdown-option {
  color: #e6e9f0 !important;
  background-color: transparent !important;
}

html.dark-theme .custom-dropdown .dropdown-option:hover,
.dark-theme .custom-dropdown .dropdown-option:hover {
  background-color: #0d7cc4 !important;
  color: #ffffff !important;
}

html.dark-theme .custom-dropdown .dropdown-option.selected,
.dark-theme .custom-dropdown .dropdown-option.selected {
  background-color: rgba(13, 124, 196, 0.2) !important;
  color: #e6e9f0 !important;
}

/* Page header & toolbar dropdowns - higher specificity to override app-shell.css */
html.dark-theme .page-header .custom-dropdown .dropdown-selected,
html.dark-theme .toolbar .custom-dropdown .dropdown-selected,
body.dark-theme .page-header .custom-dropdown .dropdown-selected,
body.dark-theme .toolbar .custom-dropdown .dropdown-selected,
.dark-theme .page-header .custom-dropdown .dropdown-selected,
.dark-theme .toolbar .custom-dropdown .dropdown-selected {
  background: #0c111a !important;
  border-color: #1e2433 !important;
  color: #e6e9f0 !important;
}

html.dark-theme .page-header .custom-dropdown .dropdown-selected:hover,
html.dark-theme .toolbar .custom-dropdown .dropdown-selected:hover,
body.dark-theme .page-header .custom-dropdown .dropdown-selected:hover,
body.dark-theme .toolbar .custom-dropdown .dropdown-selected:hover,
.dark-theme .page-header .custom-dropdown .dropdown-selected:hover,
.dark-theme .toolbar .custom-dropdown .dropdown-selected:hover {
  border-color: #0d7cc4 !important;
}

html.dark-theme .page-header .custom-dropdown.open .dropdown-selected,
html.dark-theme .toolbar .custom-dropdown.open .dropdown-selected,
body.dark-theme .page-header .custom-dropdown.open .dropdown-selected,
body.dark-theme .toolbar .custom-dropdown.open .dropdown-selected,
.dark-theme .page-header .custom-dropdown.open .dropdown-selected,
.dark-theme .toolbar .custom-dropdown.open .dropdown-selected {
  border-color: #0d7cc4 !important;
  box-shadow: 0 0 0 2px rgba(13, 124, 196, 0.2) !important;
}

html.dark-theme .page-header .custom-dropdown .dropdown-selected::after,
html.dark-theme .toolbar .custom-dropdown .dropdown-selected::after,
body.dark-theme .page-header .custom-dropdown .dropdown-selected::after,
body.dark-theme .toolbar .custom-dropdown .dropdown-selected::after,
.dark-theme .page-header .custom-dropdown .dropdown-selected::after,
.dark-theme .toolbar .custom-dropdown .dropdown-selected::after {
  border-color: #8b92a5 !important;
}

html.dark-theme .page-header .custom-dropdown .dropdown-options,
html.dark-theme .toolbar .custom-dropdown .dropdown-options,
body.dark-theme .page-header .custom-dropdown .dropdown-options,
body.dark-theme .toolbar .custom-dropdown .dropdown-options,
.dark-theme .page-header .custom-dropdown .dropdown-options,
.dark-theme .toolbar .custom-dropdown .dropdown-options {
  background: #161b26 !important;
  color: #e6e9f0 !important;
  border-color: #1e2433 !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4) !important;
}

html.dark-theme .page-header .custom-dropdown .dropdown-option-header,
html.dark-theme .toolbar .custom-dropdown .dropdown-option-header,
body.dark-theme .page-header .custom-dropdown .dropdown-option-header,
body.dark-theme .toolbar .custom-dropdown .dropdown-option-header,
.dark-theme .page-header .custom-dropdown .dropdown-option-header,
.dark-theme .toolbar .custom-dropdown .dropdown-option-header {
  color: #8b92a5 !important;
  border-color: #1e2433 !important;
  background: #111520 !important;
}

html.dark-theme .page-header .custom-dropdown .dropdown-option,
html.dark-theme .toolbar .custom-dropdown .dropdown-option,
body.dark-theme .page-header .custom-dropdown .dropdown-option,
body.dark-theme .toolbar .custom-dropdown .dropdown-option,
.dark-theme .page-header .custom-dropdown .dropdown-option,
.dark-theme .toolbar .custom-dropdown .dropdown-option {
  color: #e6e9f0 !important;
  background: transparent !important;
}

html.dark-theme .page-header .custom-dropdown .dropdown-option:hover,
html.dark-theme .toolbar .custom-dropdown .dropdown-option:hover,
body.dark-theme .page-header .custom-dropdown .dropdown-option:hover,
body.dark-theme .toolbar .custom-dropdown .dropdown-option:hover,
.dark-theme .page-header .custom-dropdown .dropdown-option:hover,
.dark-theme .toolbar .custom-dropdown .dropdown-option:hover {
  background: #0d7cc4 !important;
  color: #ffffff !important;
}

/* Page header inputs in dark mode */
.dark-theme .page-header input,
.dark-theme .page-header select,
.dark-theme .page-header .etf-auto-input {
  background: var(--v2-bg-input);
  border-color: var(--v2-border);
  color: var(--v2-text-primary);
}

.dark-theme .page-header input:focus,
.dark-theme .page-header select:focus,
.dark-theme .page-header .etf-auto-input:focus {
  border-color: var(--v2-accent);
  box-shadow: 0 0 0 2px var(--v2-accent-bg);
}

/* Page header buttons in dark mode */
.dark-theme .page-header button,
.dark-theme .page-header .btn {
  background: var(--v2-bg-hover);
  border-color: var(--v2-border);
  color: var(--v2-text-primary);
}

.dark-theme .page-header button:hover,
.dark-theme .page-header .btn:hover {
  background: var(--v2-bg-active);
  border-color: var(--v2-accent);
}

/* Dark theme: settings drawer + watchlist panel + columns modal tabs */
.dark-theme .v2-settings-drawer {
  background: #111520;
  border-color: #1e2433;
  color: #e6e9f0;
}
.dark-theme .v2-settings-drawer__header { border-color: #1e2433; }
.dark-theme .v2-settings-theme-toggle { border-color: #1e2433; }
.dark-theme .v2-settings-theme-toggle__option {
  background: #0c111a;
  color: #8b92a5;
  border-color: #1e2433;
}
.dark-theme .v2-wl-panel {
  background: #111520;
  border-color: #1e2433;
  color: #e6e9f0;
}
.dark-theme .v2-wl-panel__header { background: #161b26; border-color: #1e2433; }
.dark-theme .v2-wl-panel__sidebar { border-color: #1e2433; background: #111520; }
.dark-theme .v2-wl-card { border-color: #1e2433; }
.dark-theme .v2-wl-card:hover { background: rgba(13,124,196,0.08); }
.dark-theme .v2-wl-card--active { border-color: #0d7cc4; background: rgba(13,124,196,0.12); }
.dark-theme .v2-columns-tabs { background: #161b26; border-color: #1e2433; }
.dark-theme .v2-columns-tab { color: #8b92a5; }
.dark-theme .v2-columns-tab--active { color: #0d7cc4; border-bottom-color: #0d7cc4; }
.dark-theme .v2-popular-card {
  background: #161b26;
  border-color: #1e2433;
  color: #e6e9f0;
}
.dark-theme .v2-popular-card:hover { border-color: #0d7cc4; }
.dark-theme .v2-my-view-card {
  background: #161b26;
  border-color: #1e2433;
  color: #e6e9f0;
}
.dark-theme .controls-row__separator { background: #1e2433; }
.dark-theme .btn-utility--labeled { color: #e6e9f0; background: #161b26; border-color: #1e2433; }
.dark-theme .btn-utility--labeled:hover { background: #1e2433; }

/* Toolbar theming (often paired with page-header) */
.toolbar {
  background: var(--v2-bg-surface, var(--card-bg, #ffffff));
  border-color: var(--v2-border, var(--card-border, #dee2e6));
  color: var(--v2-text-primary, #212529);
}

html.dark-theme .toolbar,
.dark-theme .toolbar {
  background: #111520 !important;
  border-color: #1e2433 !important;
  color: #e6e9f0 !important;
}

.dark-theme .toolbar .custom-dropdown .dropdown-selected {
  background: #0c111a !important;
  border-color: #1e2433 !important;
  color: #e6e9f0 !important;
}

.dark-theme .toolbar .custom-dropdown .dropdown-options {
  background: #161b26 !important;
  color: #e6e9f0 !important;
  border-color: #1e2433 !important;
}

.dark-theme .toolbar .custom-dropdown .dropdown-option {
  color: #e6e9f0 !important;
}

.dark-theme .toolbar .custom-dropdown .dropdown-option:hover {
  background: #0d7cc4 !important;
  color: #ffffff !important;
}

/* AG Grid dark theme support - CSS Variables
   NOTE: CSS variables don't support !important, so we set them without it
   and rely on the explicit class overrides below for guaranteed styling */
html.dark-theme .ag-theme-balham,
html.dark-theme .ag-theme-alpine,
html.dark-theme .ag-theme-quartz,
html.dark-theme [class*="ag-theme-"],
.dark-theme .ag-theme-balham,
.dark-theme .ag-theme-alpine,
.dark-theme .ag-theme-quartz,
.dark-theme [class*="ag-theme-"] {
  --ag-background-color: #111520;
  --ag-header-background-color: #0c111a;
  --ag-odd-row-background-color: #161b26;
  --ag-foreground-color: #e6e9f0;
  --ag-data-color: #e6e9f0;
  --ag-header-foreground-color: #e6e9f0;
  --ag-secondary-foreground-color: #c4c9d4;
  --ag-border-color: #1e2433;
  --ag-row-hover-color: rgba(255, 255, 255, 0.05);
  --ag-selected-row-background-color: rgba(9, 100, 160, 0.2);
  --ag-range-selection-background-color: rgba(9, 100, 160, 0.2);
  --ag-input-focus-border-color: #0964A0;
  --ag-input-border-color: #1e2433;
  --ag-modal-overlay-background-color: rgba(0, 0, 0, 0.5);
  --ag-cell-horizontal-border: solid #1e2433;
  --ag-row-border-color: #1e2433;
}

/* AG Grid dark theme - Explicit overrides for rows and cells
   Using html.dark-theme for maximum specificity */
html.dark-theme .ag-theme-balham .ag-row,
html.dark-theme .ag-theme-alpine .ag-row,
html.dark-theme [class*="ag-theme-"] .ag-row,
.dark-theme .ag-theme-balham .ag-row,
.dark-theme .ag-theme-alpine .ag-row,
.dark-theme [class*="ag-theme-"] .ag-row {
  background-color: #111520 !important;
  color: #e6e9f0 !important;
}

html.dark-theme .ag-theme-balham .ag-row-odd,
html.dark-theme .ag-theme-alpine .ag-row-odd,
html.dark-theme [class*="ag-theme-"] .ag-row-odd,
.dark-theme .ag-theme-balham .ag-row-odd,
.dark-theme .ag-theme-alpine .ag-row-odd,
.dark-theme [class*="ag-theme-"] .ag-row-odd {
  background-color: #161b26 !important;
}

html.dark-theme .ag-theme-balham .ag-row-even,
html.dark-theme .ag-theme-alpine .ag-row-even,
html.dark-theme [class*="ag-theme-"] .ag-row-even,
.dark-theme .ag-theme-balham .ag-row-even,
.dark-theme .ag-theme-alpine .ag-row-even,
.dark-theme [class*="ag-theme-"] .ag-row-even {
  background-color: #111520 !important;
}

html.dark-theme .ag-theme-balham .ag-row:hover,
html.dark-theme .ag-theme-alpine .ag-row:hover,
html.dark-theme [class*="ag-theme-"] .ag-row:hover,
.dark-theme .ag-theme-balham .ag-row:hover,
.dark-theme .ag-theme-alpine .ag-row:hover,
.dark-theme [class*="ag-theme-"] .ag-row:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
}

html.dark-theme .ag-theme-balham .ag-cell,
html.dark-theme .ag-theme-alpine .ag-cell,
html.dark-theme [class*="ag-theme-"] .ag-cell,
.dark-theme .ag-theme-balham .ag-cell,
.dark-theme .ag-theme-alpine .ag-cell,
.dark-theme [class*="ag-theme-"] .ag-cell {
  color: #e6e9f0 !important;
}

html.dark-theme .ag-theme-balham .ag-cell-value,
html.dark-theme .ag-theme-alpine .ag-cell-value,
html.dark-theme [class*="ag-theme-"] .ag-cell-value,
.dark-theme .ag-theme-balham .ag-cell-value,
.dark-theme .ag-theme-alpine .ag-cell-value,
.dark-theme [class*="ag-theme-"] .ag-cell-value {
  color: #e6e9f0 !important;
}

/* AG Grid dark theme - Header */
html.dark-theme .ag-theme-balham .ag-header,
html.dark-theme .ag-theme-alpine .ag-header,
html.dark-theme [class*="ag-theme-"] .ag-header,
.dark-theme .ag-theme-balham .ag-header,
.dark-theme .ag-theme-alpine .ag-header,
.dark-theme [class*="ag-theme-"] .ag-header {
  background-color: #0c111a !important;
  color: #e6e9f0 !important;
  border-bottom-color: #1e2433 !important;
}

html.dark-theme .ag-theme-balham .ag-header-cell,
html.dark-theme .ag-theme-alpine .ag-header-cell,
html.dark-theme [class*="ag-theme-"] .ag-header-cell,
.dark-theme .ag-theme-balham .ag-header-cell,
.dark-theme .ag-theme-alpine .ag-header-cell,
.dark-theme [class*="ag-theme-"] .ag-header-cell {
  color: #e6e9f0 !important;
}

html.dark-theme .ag-theme-balham .ag-header-cell-label,
html.dark-theme .ag-theme-alpine .ag-header-cell-label,
html.dark-theme [class*="ag-theme-"] .ag-header-cell-label,
.dark-theme .ag-theme-balham .ag-header-cell-label,
.dark-theme .ag-theme-alpine .ag-header-cell-label,
.dark-theme [class*="ag-theme-"] .ag-header-cell-label {
  color: #e6e9f0 !important;
}

/* AG Grid dark theme - Root wrapper */
html.dark-theme .ag-theme-balham .ag-root-wrapper,
html.dark-theme .ag-theme-alpine .ag-root-wrapper,
html.dark-theme [class*="ag-theme-"] .ag-root-wrapper,
.dark-theme .ag-theme-balham .ag-root-wrapper,
.dark-theme .ag-theme-alpine .ag-root-wrapper,
.dark-theme [class*="ag-theme-"] .ag-root-wrapper {
  background-color: #111520 !important;
  border-color: #1e2433 !important;
}

/* AG Grid dark theme - Pinned columns */
.dark-theme .ag-theme-balham .ag-pinned-left-cols-container .ag-row,
.dark-theme .ag-theme-balham .ag-pinned-right-cols-container .ag-row,
.dark-theme .ag-theme-alpine .ag-pinned-left-cols-container .ag-row,
.dark-theme .ag-theme-alpine .ag-pinned-right-cols-container .ag-row {
  background-color: #111520 !important;
}

.dark-theme .ag-theme-balham .ag-pinned-left-cols-container .ag-row-odd,
.dark-theme .ag-theme-balham .ag-pinned-right-cols-container .ag-row-odd,
.dark-theme .ag-theme-alpine .ag-pinned-left-cols-container .ag-row-odd,
.dark-theme .ag-theme-alpine .ag-pinned-right-cols-container .ag-row-odd {
  background-color: #161b26 !important;
}

/* AG Grid — Row Group Drop Zone (drag columns here to group) */
.ag-theme-balham .ag-column-drop-horizontal {
  background-color: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  min-height: 32px;
  padding: 4px 8px;
}
.ag-theme-balham .ag-column-drop-horizontal .ag-column-drop-empty-message {
  color: #94a3b8;
  font-size: 12px;
}
.ag-theme-balham .ag-column-drop-horizontal .ag-column-drop-cell {
  background: #e0e7ff;
  border: 1px solid #c7d2fe;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #3730a3;
}

/* Pinned summary rows (Total / Min / Max) — always visible at top */
.ag-theme-balham .ag-row-pinned .ag-cell {
  font-weight: 600;
  font-size: 11.5px;
}

/* First pinned row = Total — most prominent */
.ag-theme-balham .ag-row-pinned[row-index="0"] .ag-cell {
  background-color: #f1f5f9 !important;
  border-bottom: 1px solid #cbd5e1 !important;
  font-weight: 700;
}

/* Second pinned row = Min */
.ag-theme-balham .ag-row-pinned[row-index="1"] .ag-cell {
  background-color: #f8fafc !important;
  color: #0369a1;
}

/* Third pinned row = Max */
.ag-theme-balham .ag-row-pinned[row-index="2"] .ag-cell {
  background-color: #f8fafc !important;
  color: #7c3aed;
  border-bottom: 2px solid #cbd5e1 !important;
}

/* Status bar — shows Sum, Min, Max, Avg, Count for selections */
.ag-theme-balham .ag-status-bar {
  font-size: 12px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  padding: 4px 12px;
}
.ag-theme-balham .ag-status-bar .ag-status-name-value-value {
  font-weight: 700;
  color: #1e3a5f;
}

/* AG Grid dark theme - Row Group Drop Zone */
.dark-theme .ag-theme-balham .ag-column-drop-horizontal,
.dark-theme [class*="ag-theme-"] .ag-column-drop-horizontal {
  background-color: #0c111a !important;
  border-color: #1e2433 !important;
}
.dark-theme .ag-theme-balham .ag-column-drop-horizontal .ag-column-drop-cell {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #93c5fd !important;
}

/* AG Grid dark theme - Pinned summary rows */
.dark-theme .ag-theme-balham .ag-row-pinned[row-index="0"] .ag-cell {
  background-color: #111827 !important;
  border-bottom-color: #374151 !important;
}
.dark-theme .ag-theme-balham .ag-row-pinned[row-index="1"] .ag-cell {
  background-color: #0f172a !important;
  color: #38bdf8;
}
.dark-theme .ag-theme-balham .ag-row-pinned[row-index="2"] .ag-cell {
  background-color: #0f172a !important;
  color: #a78bfa;
  border-bottom-color: #374151 !important;
}

/* AG Grid dark theme - Status bar */
.dark-theme .ag-theme-balham .ag-status-bar,
.dark-theme .ag-theme-alpine .ag-status-bar,
.dark-theme [class*="ag-theme-"] .ag-status-bar {
  background-color: #0c111a !important;
  border-color: #1e2433 !important;
  color: #c4c9d4 !important;
}

/* AG Grid dark theme - Filter panel */
.dark-theme .ag-theme-balham .ag-filter-toolpanel,
.dark-theme .ag-theme-alpine .ag-filter-toolpanel,
.dark-theme [class*="ag-theme-"] .ag-filter-toolpanel {
  background-color: #111520 !important;
  color: #e6e9f0 !important;
}

/* AG Grid dark theme - Column panel / sidebar */
.dark-theme [class*="ag-theme-"] .ag-column-panel {
  background-color: #111520 !important;
  color: #e6e9f0 !important;
}
.dark-theme [class*="ag-theme-"] .ag-column-select {
  background-color: #111520 !important;
}
.dark-theme [class*="ag-theme-"] .ag-column-select-header {
  background-color: #161b26 !important;
  border-color: #1e2433 !important;
}
.dark-theme [class*="ag-theme-"] .ag-column-select-header .ag-input-field-input {
  background-color: #0c111a !important;
  border-color: #1e2433 !important;
  color: #e6e9f0 !important;
}
.dark-theme [class*="ag-theme-"] .ag-column-select-list {
  background-color: #111520 !important;
}
.dark-theme [class*="ag-theme-"] .ag-column-select-column,
.dark-theme [class*="ag-theme-"] .ag-column-select-column-group {
  color: #e6e9f0 !important;
}
.dark-theme [class*="ag-theme-"] .ag-column-drop-vertical {
  background-color: #0c111a !important;
  border-color: #1e2433 !important;
}
.dark-theme [class*="ag-theme-"] .ag-column-drop-vertical .ag-column-drop-empty-message {
  color: #64748b !important;
}
.dark-theme [class*="ag-theme-"] .ag-column-drop-vertical .ag-column-drop-cell {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #93c5fd !important;
}
.dark-theme [class*="ag-theme-"] .ag-side-bar {
  background-color: #111520 !important;
  border-color: #1e2433 !important;
}
.dark-theme [class*="ag-theme-"] .ag-side-button {
  color: #8b92a5 !important;
}
.dark-theme [class*="ag-theme-"] .ag-side-button .ag-side-button-button {
  background-color: #111520 !important;
  border-color: #1e2433 !important;
}
.dark-theme [class*="ag-theme-"] .ag-side-button .ag-selected .ag-side-button-button {
  background-color: #161b26 !important;
  border-color: #1e2433 !important;
}

/* AG Grid dark theme - Context menu */
.dark-theme .ag-theme-balham .ag-menu,
.dark-theme .ag-theme-alpine .ag-menu,
.dark-theme [class*="ag-theme-"] .ag-menu {
  background-color: #161b26 !important;
  border-color: #1e2433 !important;
  color: #e6e9f0 !important;
}

.dark-theme .ag-theme-balham .ag-menu-option-active,
.dark-theme .ag-theme-alpine .ag-menu-option-active,
.dark-theme [class*="ag-theme-"] .ag-menu-option-active {
  background-color: rgba(9, 100, 160, 0.2) !important;
}

/* AG Grid dark theme - No rows overlay */
.dark-theme .ag-theme-balham .ag-overlay-no-rows-wrapper,
.dark-theme .ag-theme-alpine .ag-overlay-no-rows-wrapper,
.dark-theme [class*="ag-theme-"] .ag-overlay-no-rows-wrapper {
  background-color: #111520 !important;
}

.dark-theme .ag-theme-balham .ag-overlay-no-rows-center,
.dark-theme .ag-theme-alpine .ag-overlay-no-rows-center,
.dark-theme [class*="ag-theme-"] .ag-overlay-no-rows-center {
  color: #8b92a5 !important;
}

/* AG Grid scrollbar styling - Dark Mode */
.dark-theme .ag-body-vertical-scroll,
.dark-theme .ag-body-horizontal-scroll,
.dark-theme .ag-body-vertical-scroll-viewport,
.dark-theme .ag-body-horizontal-scroll-viewport {
  background-color: var(--v2-bg-surface, #111520);
}

/* WebKit scrollbar styling (Chrome, Safari, Edge) */
.dark-theme .ag-body-vertical-scroll::-webkit-scrollbar,
.dark-theme .ag-body-horizontal-scroll::-webkit-scrollbar,
.dark-theme .ag-body-viewport::-webkit-scrollbar,
.dark-theme [class*="ag-"]::-webkit-scrollbar {
  width: 10px;
  height: 10px;
  background-color: var(--v2-bg-surface, #111520);
}

.dark-theme .ag-body-vertical-scroll::-webkit-scrollbar-track,
.dark-theme .ag-body-horizontal-scroll::-webkit-scrollbar-track,
.dark-theme .ag-body-viewport::-webkit-scrollbar-track,
.dark-theme [class*="ag-"]::-webkit-scrollbar-track {
  background-color: var(--v2-bg-surface, #111520);
  border-radius: 5px;
}

.dark-theme .ag-body-vertical-scroll::-webkit-scrollbar-thumb,
.dark-theme .ag-body-horizontal-scroll::-webkit-scrollbar-thumb,
.dark-theme .ag-body-viewport::-webkit-scrollbar-thumb,
.dark-theme [class*="ag-"]::-webkit-scrollbar-thumb {
  background-color: var(--v2-border, #2d3748);
  border-radius: 5px;
  border: 2px solid var(--v2-bg-surface, #111520);
}

.dark-theme .ag-body-vertical-scroll::-webkit-scrollbar-thumb:hover,
.dark-theme .ag-body-horizontal-scroll::-webkit-scrollbar-thumb:hover,
.dark-theme .ag-body-viewport::-webkit-scrollbar-thumb:hover,
.dark-theme [class*="ag-"]::-webkit-scrollbar-thumb:hover {
  background-color: var(--v2-text-muted, #6b7280);
}

/* Firefox scrollbar styling */
.dark-theme .ag-body-vertical-scroll,
.dark-theme .ag-body-horizontal-scroll,
.dark-theme .ag-body-viewport,
.dark-theme [class*="ag-"] {
  scrollbar-color: var(--v2-border, #2d3748) var(--v2-bg-surface, #111520);
  scrollbar-width: thin;
}

/* AG Grid scrollbar corner (where vertical and horizontal meet) */
.dark-theme .ag-body-vertical-scroll::-webkit-scrollbar-corner,
.dark-theme .ag-body-horizontal-scroll::-webkit-scrollbar-corner,
.dark-theme [class*="ag-"]::-webkit-scrollbar-corner {
  background-color: var(--v2-bg-surface, #111520);
}

/* ============================================================================
   BREADCRUMB
   ============================================================================ */
.v2-breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted, #ADADAD);
  margin-left: 16px;
}

.v2-breadcrumb-path {
  color: var(--text, #e6e9f0);
}

.v2-breadcrumb-fund {
  color: var(--accent, #0964A0);
  font-weight: 600;
}

.v2-breadcrumb-ticker {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.v2-breadcrumb-link {
  color: var(--accent, #0964A0);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s;
}

.v2-breadcrumb-link:hover {
  color: var(--accent-light, #3b9ed6);
  text-decoration: underline;
}

.v2-breadcrumb-sep {
  color: var(--muted, #ADADAD);
  font-size: 11px;
}

.v2-breadcrumb-current {
  color: var(--text, #e6e9f0);
}

/* ============================================================================
   RECENT FUNDS BAR
   ============================================================================ */
.v2-recent-funds {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-elev, #111520);
  border-bottom: 1px solid var(--border, #1e2433);
  overflow-x: auto;
  white-space: nowrap;
}

.v2-recent-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, #ADADAD);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.v2-recent-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.v2-recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(9, 100, 160, 0.15);
  border: 1px solid rgba(9, 100, 160, 0.3);
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text, #e6e9f0);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.v2-recent-chip:hover {
  background: rgba(9, 100, 160, 0.25);
  border-color: var(--accent, #0964A0);
}

.v2-recent-chip .chip-remove {
  display: none;
  margin-left: 2px;
  color: var(--muted);
  cursor: pointer;
}

.v2-recent-chip:hover .chip-remove {
  display: inline;
}

/* ============================================================================
   COMPARE TRAY (sticky bottom)
   ============================================================================ */
.v2-compare-tray {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  background: var(--bg-elev, #111520);
  border-top: 1px solid var(--border, #1e2433);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.2);
  z-index: 200;
  transition: left 0.2s ease;
}

.is-collapsed .v2-compare-tray {
  left: 76px;
}

@media (max-width: 767px) {
  .v2-compare-tray {
    left: 0;
  }
}

/*
 * When the compare tray is visible, shrink the main content pane by the
 * tray's height so grid content + AG Grid pagination remain reachable.
 * `--compare-tray-h` is published by compareTrayV2.js based on the actual
 * rendered tray height so the reservation stays accurate if the tray
 * wraps/grows.
 */
body.has-compare-tray #v2-main.app-main {
  height: calc(100vh - var(--header-h, 54px) - var(--compare-tray-h, 64px)) !important;
  height: calc(100dvh - var(--header-h, 54px) - var(--compare-tray-h, 64px)) !important;
}

.v2-tray-content {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  max-width: 100%;
  overflow-x: auto;
}

.v2-tray-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  flex-shrink: 0;
}

.v2-tray-chips {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  min-width: 0;
}

.v2-tray-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--accent);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.v2-tray-chip .chip-remove {
  cursor: pointer;
  opacity: 0.7;
}

.v2-tray-chip .chip-remove:hover {
  opacity: 1;
}

.v2-tray-more {
  font-size: 11px;
  color: var(--muted);
  flex-shrink: 0;
}

.v2-tray-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Action-group visibility is driven by the tray mode. The two groups are
 * always present in the DOM (so handlers bind once) but only one renders
 * at a time. */
.v2-compare-tray .v2-tray-actions--model { display: none; }
.v2-compare-tray[data-tray-mode="model"] .v2-tray-actions--default { display: none; }
.v2-compare-tray[data-tray-mode="model"] .v2-tray-actions--model   { display: flex; }

/* ----------------------------------------------------------------------------
 * Model-mode tray skin — mirrors `.mp-tray` from the model marketplace so
 * the Models & SMAs database surfaces the same lighter, accent-bordered
 * tray users already know from the marketplace.
 * -------------------------------------------------------------------------- */
.v2-compare-tray[data-tray-mode="model"] {
  background: var(--bg-card, #fff);
  border-top: 2px solid var(--accent);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
}

.v2-compare-tray[data-tray-mode="model"] .v2-tray-content {
  padding: 10px 24px;
}

.v2-compare-tray[data-tray-mode="model"] .v2-tray-label {
  font-size: 13px;
  color: var(--text-strong);
}

.v2-compare-tray[data-tray-mode="model"] .v2-tray-chip {
  background: rgba(173, 173, 173, 0.1);
  color: var(--text);
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: normal;
}

.v2-compare-tray[data-tray-mode="model"] .v2-tray-chip .chip-name {
  font-weight: 500;
}

.v2-compare-tray[data-tray-mode="model"] .v2-tray-chip .chip-remove {
  font-size: 14px;
  color: var(--muted);
  margin-left: 2px;
  line-height: 1;
  opacity: 1;
}

.v2-compare-tray[data-tray-mode="model"] .v2-tray-chip .chip-remove:hover {
  color: var(--v2-danger, #de350b);
}

.v2-compare-tray[data-tray-mode="model"] .v2-tray-more {
  font-size: 12px;
  color: var(--muted);
}

/* ============================================================================
   FUND PROFILE OVERLAY (STATE: PROFILE_OVERLAY)
   
   IMPORTANT: Overlay must NOT cover the global site header.
   It sits below the header and fills remaining viewport height.
   ============================================================================ */
.v2-overlay-root {
  position: fixed;
  top: var(--header-h, 54px); /* Sits below the header */
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  z-index: 500;
  display: none;
  transition: left 0.2s ease;
}

.v2-overlay-root[aria-hidden="false"] {
  display: block;
}

.is-collapsed .v2-overlay-root {
  left: 76px;
}

@media (max-width: 767px) {
  .v2-overlay-root {
    left: 0;
  }
}

.v2-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.v2-overlay-container {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 100%;
  background: var(--overlay-bg);
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.3);
  animation: slideInRight 0.25s ease-out;
}

@keyframes slideInRight {
  from {
    transform: translateX(20%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Overlay Header */
.v2-overlay-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--overlay-border);
  min-height: var(--overlay-header-h);
  flex-shrink: 0;
}

.v2-overlay-title-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 200px;
}

.v2-overlay-ticker {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.v2-overlay-name {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

.v2-overlay-stats {
  display: flex;
  gap: 24px;
  margin-left: auto;
}

.v2-overlay-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
}

.v2-stat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.v2-stat-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.v2-overlay-actions {
  display: flex;
  gap: 8px;
  margin-left: 16px;
}

/* Overlay Tabs */
.v2-overlay-tabs {
  display: flex;
  gap: 0;
  padding: 0 20px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--overlay-border);
  overflow-x: auto;
  flex-shrink: 0;
}

.v2-overlay-tab {
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.v2-overlay-tab:hover {
  color: var(--text);
}

.v2-overlay-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Overlay Content */
.v2-overlay-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.v2-tab-panel {
  display: none;
  animation: fadeIn 0.2s ease;
}

.v2-tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Loading Spinner */
.v2-loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

.v2-loading-spinner::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================================
   OVERLAY TAB CONTENT LAYOUTS
   ============================================================================ */
.v2-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.v2-overview-card {
  background: var(--v2-bg-surface);
  border: 1px solid var(--v2-border);
  border-radius: 8px;
  padding: 16px;
}

.v2-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--v2-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--v2-border);
}

.v2-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.v2-stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.v2-stat-item-label {
  font-size: 11px;
  color: var(--muted);
}

.v2-stat-item-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.v2-description-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}

/* Holdings Table */
.v2-holdings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.v2-holdings-table th,
.v2-holdings-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--overlay-border);
}

.v2-holdings-table th {
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.5px;
}

.v2-holdings-table td {
  color: var(--text);
}

.v2-holdings-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

/* Chart Container */
.v2-chart-container {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--overlay-border);
  border-radius: 8px;
  padding: 16px;
  min-height: 300px;
}

/* ============================================================================
   AG GRID CELL STYLES (ported from legacy)
   ============================================================================ */
/* Positive/Negative value coloring */
.ag-theme-balham .pos-value,
.ag-theme-alpine .pos-value {
  color: #26a69a !important;
}

.ag-theme-balham .neg-value,
.ag-theme-alpine .neg-value {
  color: #ef5350 !important;
}

/* Dark-mode preservation of positive/negative tint for AG Grid cells.
   The blanket `.dark-theme .ag-theme-* .ag-cell-value { color: #e6e9f0 !important }`
   rule above has higher specificity than the default `.pos-value` / `.neg-value`
   rules, which made red/green flow columns (fund navigator FMV %, league
   tables flows, dashboard leaders) reset to plain white in dark mode. Target
   both `.ag-cell` (in case the class lands on the cell wrapper) and the
   inner `.ag-cell-value` span so the tint survives regardless of where
   AG Grid applies `cellClassRules`. */
html.dark-theme .ag-theme-balham .ag-cell.pos-value,
html.dark-theme .ag-theme-alpine .ag-cell.pos-value,
html.dark-theme [class*="ag-theme-"] .ag-cell.pos-value,
html.dark-theme .ag-theme-balham .pos-value .ag-cell-value,
html.dark-theme .ag-theme-alpine .pos-value .ag-cell-value,
html.dark-theme [class*="ag-theme-"] .pos-value .ag-cell-value,
.dark-theme .ag-theme-balham .ag-cell.pos-value,
.dark-theme .ag-theme-alpine .ag-cell.pos-value,
.dark-theme [class*="ag-theme-"] .ag-cell.pos-value,
.dark-theme .ag-theme-balham .pos-value .ag-cell-value,
.dark-theme .ag-theme-alpine .pos-value .ag-cell-value,
.dark-theme [class*="ag-theme-"] .pos-value .ag-cell-value {
  color: #1fa971 !important;
}

html.dark-theme .ag-theme-balham .ag-cell.neg-value,
html.dark-theme .ag-theme-alpine .ag-cell.neg-value,
html.dark-theme [class*="ag-theme-"] .ag-cell.neg-value,
html.dark-theme .ag-theme-balham .neg-value .ag-cell-value,
html.dark-theme .ag-theme-alpine .neg-value .ag-cell-value,
html.dark-theme [class*="ag-theme-"] .neg-value .ag-cell-value,
.dark-theme .ag-theme-balham .ag-cell.neg-value,
.dark-theme .ag-theme-alpine .ag-cell.neg-value,
.dark-theme [class*="ag-theme-"] .ag-cell.neg-value,
.dark-theme .ag-theme-balham .neg-value .ag-cell-value,
.dark-theme .ag-theme-alpine .neg-value .ag-cell-value,
.dark-theme [class*="ag-theme-"] .neg-value .ag-cell-value {
  color: #e05b5b !important;
}

/* Same dark-mode preservation for the v2 red/green helper classes
   (`.v2-pos` / `.v2-neg`) used by the History tab on security profiles and
   any other v2 grid whose cellClassRules opt into the shared helpers. */
html.dark-theme .ag-theme-balham .ag-cell.v2-pos,
html.dark-theme .ag-theme-alpine .ag-cell.v2-pos,
html.dark-theme [class*="ag-theme-"] .ag-cell.v2-pos,
html.dark-theme .ag-theme-balham .v2-pos .ag-cell-value,
html.dark-theme .ag-theme-alpine .v2-pos .ag-cell-value,
html.dark-theme [class*="ag-theme-"] .v2-pos .ag-cell-value,
.dark-theme .ag-theme-balham .ag-cell.v2-pos,
.dark-theme .ag-theme-alpine .ag-cell.v2-pos,
.dark-theme [class*="ag-theme-"] .ag-cell.v2-pos,
.dark-theme .ag-theme-balham .v2-pos .ag-cell-value,
.dark-theme .ag-theme-alpine .v2-pos .ag-cell-value,
.dark-theme [class*="ag-theme-"] .v2-pos .ag-cell-value {
  color: #1fa971 !important;
}

html.dark-theme .ag-theme-balham .ag-cell.v2-neg,
html.dark-theme .ag-theme-alpine .ag-cell.v2-neg,
html.dark-theme [class*="ag-theme-"] .ag-cell.v2-neg,
html.dark-theme .ag-theme-balham .v2-neg .ag-cell-value,
html.dark-theme .ag-theme-alpine .v2-neg .ag-cell-value,
html.dark-theme [class*="ag-theme-"] .v2-neg .ag-cell-value,
.dark-theme .ag-theme-balham .ag-cell.v2-neg,
.dark-theme .ag-theme-alpine .ag-cell.v2-neg,
.dark-theme [class*="ag-theme-"] .ag-cell.v2-neg,
.dark-theme .ag-theme-balham .v2-neg .ag-cell-value,
.dark-theme .ag-theme-alpine .v2-neg .ag-cell-value,
.dark-theme [class*="ag-theme-"] .v2-neg .ag-cell-value {
  color: #e05b5b !important;
}

/* Dark-mode preservation of positive/negative tint for plain HTML tables.
   The blanket `.dark-theme table td { color: #e6e9f0 !important }` rule
   earlier in this file overrides per-cell tint classes used by the markets
   dashboard (`.mkd-pos` / `.mkd-neg`) and the ETF dashboard leaders grid
   (`.leader-value.positive` / `.leader-value.negative`). */
html.dark-theme table td.mkd-pos,
html.dark-theme .mkd-dense-list td.mkd-pos,
html.dark-theme table td.leader-value.positive,
html.dark-theme .leader-value.positive,
.dark-theme table td.mkd-pos,
.dark-theme .mkd-dense-list td.mkd-pos,
.dark-theme table td.leader-value.positive,
.dark-theme .leader-value.positive {
  color: #1fa971 !important;
}

html.dark-theme table td.mkd-neg,
html.dark-theme .mkd-dense-list td.mkd-neg,
html.dark-theme table td.leader-value.negative,
html.dark-theme .leader-value.negative,
.dark-theme table td.mkd-neg,
.dark-theme .mkd-dense-list td.mkd-neg,
.dark-theme table td.leader-value.negative,
.dark-theme .leader-value.negative {
  color: #e05b5b !important;
}

/* Ticker link styling */
.ag-theme-balham .ag-link,
.ag-theme-alpine .ag-link {
  color: var(--accent, #0964A0);
  cursor: pointer;
}

.ag-theme-balham .ag-link:hover,
.ag-theme-alpine .ag-link:hover {
  text-decoration: underline;
}

/* V2 Ticker Link */
.v2-ticker-link {
  color: var(--accent, #0964A0);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}

.v2-ticker-link:hover {
  text-decoration: underline;
}

/* Header text wrapping */
.ag-theme-balham .ag-header-cell-label,
.ag-theme-alpine .ag-header-cell-label {
  white-space: normal;
  line-height: 1.3;
}

/* ============================================================================
   V2 TOOL CONTAINER & PANES
   ============================================================================ */
/* V2 Main Content - Flexbox layout for recent funds + tool container */
#v2-main.app-main {
  display: flex !important;
  flex-direction: column !important;
  height: calc(100vh - var(--header-h, 54px)) !important;
  height: calc(100dvh - var(--header-h, 54px)) !important;
  overflow: hidden !important;
  overflow-y: hidden !important;
}

/* V2 Recent Funds Bar */
.v2-recent-funds {
  flex-shrink: 0;
}

/* V2 Tool Container - flex column so tool panes fill via flex:1 */
.v2-tool-container {
  position: relative;
  flex: 1 1 0%;
  min-height: 0;
  height: calc(100vh - var(--header-h, 55px));
  height: calc(100dvh - var(--header-h, 55px));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* V2 Tool Pane - CSS Grid layout like legacy viewport-pane */
.v2-tool-pane {
  display: none; /* Hidden by default */
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  background-color: var(--v2-bg-page);
}

/* When a tool pane is active, show it with grid layout and fill container */
.v2-tool-pane.active {
  display: grid;
  flex: 1 1 0%;
  height: 100%;
}

/* Ensure direct children of active tool panes can shrink for overflow scrolling */
.v2-tool-pane.active > * {
  min-height: 0;
}

/* Dark theme for tool panes */
html.dark-theme .v2-tool-pane,
html.dark-theme .v2-tool-pane.active,
html.dark-theme .v2-tool-container,
.dark-theme .v2-tool-pane,
.dark-theme .v2-tool-pane.active,
.dark-theme .v2-tool-container {
  background-color: #0c111a !important;
  color: #e6e9f0 !important;
}

/* ============================================================================
   DARK THEME: Scrollbar Styling
   Custom scrollbar colors for dark mode across all scrollable areas
   ============================================================================ */
.dark-theme {
  scrollbar-color: #2a3344 #0c111a;
  scrollbar-width: thin;
}
.dark-theme ::-webkit-scrollbar { width: 8px; height: 8px; }
.dark-theme ::-webkit-scrollbar-track { background: #0c111a; }
.dark-theme ::-webkit-scrollbar-thumb {
  background: #2a3344;
  border-radius: 4px;
  border: 2px solid #0c111a;
}
.dark-theme ::-webkit-scrollbar-thumb:hover { background: #3a4a5e; }
.dark-theme ::-webkit-scrollbar-corner { background: #0c111a; }

/* ============================================================================
   DARK THEME: Security Profile (.v2-sp) Overrides
   These overrides ensure the fund/ETF profile page respects dark mode.
   Uses hardcoded colors (not variables) to avoid @layer cascade issues.
   ============================================================================ */
.dark-theme .v2-sp {
  background: #0c111a !important;
  color: #e6e9f0 !important;
}
.dark-theme .v2-sp__header {
  background: #111520 !important;
  border-bottom-color: #1e2433 !important;
}
.dark-theme .v2-sp__ticker { color: #e6e9f0 !important; }
.dark-theme .v2-sp__name { color: #8b92a5 !important; }
.dark-theme .v2-sp__badge { background: rgba(9,100,160,0.2) !important; }
.dark-theme .v2-sp__header-sep { color: #8b92a5 !important; }
.dark-theme .v2-sp__header-row2 { border-top-color: #1e2433 !important; }
.dark-theme .v2-sp__price-label,
.dark-theme .v2-sp__stat-label,
.dark-theme .v2-sp__control-label,
.dark-theme .v2-sp__kpi-subtitle { color: #8b92a5 !important; }
.dark-theme .v2-sp__price,
.dark-theme .v2-sp__stat-value,
.dark-theme .v2-sp__price-volume,
.dark-theme .v2-sp__kpi-value { color: #e6e9f0 !important; }
.dark-theme .v2-sp__kpi-title { color: #c4c9d4 !important; }
.dark-theme .v2-sp__select {
  background: rgba(255,255,255,0.05) !important;
  border-color: #1e2433 !important;
  color: #c4c9d4 !important;
}
.dark-theme .v2-sp__select-label { color: #8b92a5 !important; }

/* Tabs */
.dark-theme .v2-sp__tabs {
  background: #111520 !important;
  border-bottom-color: #1e2433 !important;
}
.dark-theme .v2-sp__tab { color: #8b92a5 !important; }
.dark-theme .v2-sp__tab:hover { color: #e6e9f0 !important; background: rgba(255,255,255,0.05) !important; }
.dark-theme .v2-sp__tab.is-active { color: var(--v2-accent, #0d7cc4) !important; }

/* Content area */
.dark-theme .v2-sp__content {
  background: #0c111a !important;
}

/* Cards — elevated surface with visible border for depth */
.dark-theme .v2-card {
  background: #111520 !important;
  border: 1px solid #1e2433 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.03) inset !important;
}
.dark-theme .v2-card__header {
  background: #1a2030 !important;
  border-bottom: 1px solid #252d3d !important;
}
.dark-theme .v2-card__title { color: #e6e9f0 !important; }
.dark-theme .v2-card__subtitle { color: #8b92a5 !important; }
.dark-theme .v2-card__body { background: #111520 !important; }

/* Segmented toggle */
.dark-theme .v2-segToggle {
  background: #161b26 !important;
  border-color: #1e2433 !important;
}
.dark-theme .v2-segToggle__btn { color: #8b92a5 !important; }
.dark-theme .v2-segToggle__btn:hover { background: rgba(255,255,255,0.05) !important; color: #e6e9f0 !important; }

/* KPI cards */
.dark-theme .v2-sp__kpi-card {
  background: #111520 !important;
  border: 1px solid #1e2433 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.03) inset !important;
}
.dark-theme .v2-sp__kpi-icon { background: rgba(9,100,160,0.2) !important; }

/* Signal cards */
.dark-theme .v2-sp__signal-card {
  background: #111520 !important;
  border: 1px solid #1e2433 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.03) inset !important;
}
.dark-theme .v2-sp__signal-card-label { color: #8b92a5 !important; }

/* 52-week range */
.dark-theme .v2-52w {
  background: #111520 !important;
  border: 1px solid #1e2433 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.03) inset !important;
}
.dark-theme .v2-52w__label { color: #8b92a5 !important; background: #161b26 !important; }
.dark-theme .v2-52w__price--high { color: #c4c9d4 !important; }
.dark-theme .v2-52w__legend-item { color: #8b92a5 !important; }
.dark-theme .v2-sp__range-label { color: #c4c9d4 !important; }
.dark-theme .v2-sp__range-track { background: #1e2433 !important; }

/* Stat boxes */
.dark-theme .v2-sp__stat-box {
  background: #111520 !important;
  border: 1px solid #1e2433 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.03) inset !important;
}
.dark-theme .v2-sp__stat-box .v2-sp__stat-label { color: #8b92a5 !important; }
.dark-theme .v2-sp__stat-box .v2-sp__stat-value { color: #e6e9f0 !important; }

/* Overview stat boxes */
.dark-theme .v2-sp__ov-stat-box {
  background: #161b26 !important;
  border: 1px solid #1e2433 !important;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25) !important;
}
.dark-theme .v2-sp__ov-stat-label { color: #8b92a5 !important; }
.dark-theme .v2-sp__ov-stat-value,
.dark-theme .v2-sp__ov-aum-value,
.dark-theme .v2-sp__ov-kv-value,
.dark-theme .v2-sp__ov-bar-value,
.dark-theme .v2-sp__ov-hold-ticker { color: #e6e9f0 !important; }
.dark-theme .v2-sp__ov-kv-label,
.dark-theme .v2-sp__ov-bar-label,
.dark-theme .v2-sp__ov-hold-total { color: #8b92a5 !important; }
.dark-theme .v2-sp__ov-bar-track { background: #161b26 !important; }

/* Tables */
.dark-theme .v2-sp__trading-table thead th,
.dark-theme .v2-sp__metrics-table thead th,
.dark-theme .v2-sp__alloc-table thead th,
.dark-theme .v2-sp__scenario-table thead th,
.dark-theme .v2-sp__ov-table th {
  background: #161b26 !important;
  color: #8b92a5 !important;
  border-bottom-color: #1e2433 !important;
}
.dark-theme .v2-sp__trading-table tbody td,
.dark-theme .v2-sp__metrics-table tbody td,
.dark-theme .v2-sp__alloc-table tbody td,
.dark-theme .v2-sp__scenario-table tbody td,
.dark-theme .v2-sp__ov-table td {
  color: #c4c9d4 !important;
  border-bottom-color: #252d3d !important;
}
.dark-theme .v2-sp__trading-table tbody tr:hover,
.dark-theme .v2-sp__metrics-table tbody tr:hover,
.dark-theme .v2-sp__alloc-table tbody tr:hover,
.dark-theme .v2-sp__scenario-table tbody tr:hover {
  background: rgba(255,255,255,0.05) !important;
}
.dark-theme .v2-sp__alloc-parent td { background: #161b26 !important; }

/* Loading & placeholder */
.dark-theme .v2-sp__loading { color: #8b92a5 !important; }
.dark-theme .v2-sp__placeholder { color: #8b92a5 !important; }

/* Strategy text */
.dark-theme .v2-sp__strategy-text { color: #c4c9d4 !important; }

/* Recent Portfolio Moves — holdings tab date header */
.dark-theme .v2-sp-rebalance__date { color: #e6e9f0 !important; }

/* Payout & countdown */
.dark-theme .v2-sp__payout-label { color: #8b92a5 !important; }
.dark-theme .v2-sp__payout-value { color: #e6e9f0 !important; }
.dark-theme .v2-sp__payout-countdown { background: #161b26 !important; }

/* Management team */
.dark-theme .v2-sp__mgmt-name { color: #e6e9f0 !important; }
.dark-theme .v2-sp__mgmt-title { color: #8b92a5 !important; }
.dark-theme .v2-sp__mgmt-badge { background: #161b26 !important; color: #c4c9d4 !important; }
.dark-theme .v2-sp__mgmt-location { color: #8b92a5 !important; }
.dark-theme .v2-sp__mgmt-bio { color: #c4c9d4 !important; }
.dark-theme .v2-sp__mgmt-contact { border-top-color: #252d3d !important; }

/* Badges */
.dark-theme .v2-sp__sector-badge { background: #161b26 !important; color: #c4c9d4 !important; }
.dark-theme .v2-sp__type-badge { background: #161b26 !important; color: #c4c9d4 !important; }

/* Watchlist overlay */
.dark-theme .v2-wl-overlay {
  background: #111520 !important;
  border: 1px solid #252d3d !important;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04) inset !important;
}
.dark-theme .v2-wl-overlay__title { color: #e6e9f0 !important; }
.dark-theme .v2-wl-overlay__header { border-bottom-color: #1e2433 !important; }
.dark-theme .v2-wl-overlay__name { color: #c4c9d4 !important; }
.dark-theme .v2-wl-overlay__item:hover { background: rgba(255,255,255,0.05) !important; }
.dark-theme .v2-wl-overlay__item + .v2-wl-overlay__item { border-top-color: #252d3d !important; }
.dark-theme .v2-wl-overlay__item-count { background: #161b26 !important; color: #8b92a5 !important; }
.dark-theme .v2-wl-overlay__footer .btn { background: #111520 !important; color: #c4c9d4 !important; border-color: #1e2433 !important; }
.dark-theme .v2-wl-overlay__close:hover { background: rgba(255,255,255,0.05) !important; color: #e6e9f0 !important; }

/* Autocomplete dropdown */
.dark-theme .v2-sp__autocomplete-dropdown {
  background: #111520 !important;
  border-color: #1e2433 !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4) !important;
}
.dark-theme .v2-sp__ac-item { border-color: #1e2433 !important; }
.dark-theme .v2-sp__ac-item:hover { background: rgba(255,255,255,0.05) !important; }
.dark-theme .v2-sp__ac-name { color: #e6e9f0 !important; }
.dark-theme .v2-sp__ac-ticker { color: var(--v2-accent, #0d7cc4) !important; }

/* Highcharts inside security profile */
.dark-theme .v2-sp .highcharts-background { fill: #111520 !important; }
.dark-theme .v2-sp .highcharts-title,
.dark-theme .v2-sp .highcharts-subtitle { fill: #e6e9f0 !important; }
.dark-theme .v2-sp .highcharts-axis-title,
.dark-theme .v2-sp .highcharts-axis-labels text { fill: #8b92a5 !important; }
.dark-theme .v2-sp .highcharts-grid-line { stroke: #1e2433 !important; }
.dark-theme .v2-sp .highcharts-tooltip-box { fill: #161b26 !important; stroke: #1e2433 !important; }
.dark-theme .v2-sp .highcharts-label text { fill: #e6e9f0 !important; }

/* AG Grid inside security profile */
.dark-theme .v2-sp .ag-theme-balham {
  --ag-background-color: #111520;
  --ag-header-background-color: #161b26;
  --ag-odd-row-background-color: #0c111a;
  --ag-foreground-color: #e6e9f0;
  --ag-secondary-foreground-color: #8b92a5;
  --ag-border-color: #1e2433;
  --ag-row-hover-color: rgba(255,255,255,0.05);
}

/* Performance table (custom) */
.dark-theme .mp-perf-th {
  background: #161b26 !important;
  color: #8b92a5 !important;
  border-bottom-color: #1e2433 !important;
}
.dark-theme .mp-perf-th--name { background: #161b26 !important; }
.dark-theme .mp-perf-cell { color: #c4c9d4 !important; border-bottom-color: #252d3d !important; }
.dark-theme .mp-perf-cell--name { background: #111520 !important; color: #e6e9f0 !important; }
.dark-theme .mp-perf-row:hover .mp-perf-cell { background: rgba(255,255,255,0.05) !important; }

/* Treelist / breakdown rows */
.dark-theme .v2-tl__row { border-bottom-color: #252d3d !important; }
.dark-theme .v2-tl__label { color: #8b92a5 !important; }
.dark-theme .v2-tl__value { color: #e6e9f0 !important; }
.dark-theme .v2-tl__bar-track { background: #1e2433 !important; }

/* Scenario comparison */
.dark-theme .v2-sp__scenario-comp-label { color: #8b92a5 !important; }
.dark-theme .v2-sp__scenario-comp-value { color: #e6e9f0 !important; }

/* Insight & highlight cards */
.dark-theme .v2-sp__insight { background: #111520 !important; border: 1px solid #1e2433 !important; color: #c4c9d4 !important; box-shadow: 0 2px 8px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.03) inset !important; }
.dark-theme .v2-sp__highlight-card { background: #111520 !important; border: 1px solid #1e2433 !important; box-shadow: 0 2px 8px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.03) inset !important; }
.dark-theme .v2-sp__growth-card { background: #111520 !important; border: 1px solid #1e2433 !important; box-shadow: 0 2px 8px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.03) inset !important; }

/* Risk table AG Grid rows */
.dark-theme #perf-trailing-grid .ag-row:hover { background: rgba(255,255,255,0.05) !important; }
.dark-theme #risk-table-grid .risk-group-header-row,
.dark-theme #sp-stock-risk-grid .risk-group-header-row { background: #161b26 !important; }

/* ETF Database container - 4-row grid: universe-bar | controls | filter-bar | grid */
#v2-etf-database {
  grid-template-rows: auto auto auto minmax(0, 1fr) !important;
  min-height: 0 !important;
}
#v2-etf-database > #v2-db-universe-bar { grid-row: 1; }
#v2-etf-database > #v2-db-header       { grid-row: 2; }
#v2-etf-database > #v2-filter-bar      { grid-row: 3; }
#v2-etf-database > #v2-etf-grid        { grid-row: 4; }

.v2-tool-pane .page-header {
  flex-shrink: 0;
}

/* Grid container - fills the 1fr row */
.v2-tool-pane #v2-etf-grid,
#v2-etf-database #v2-etf-grid {
  min-height: 0 !important;
  height: 100% !important;
  width: 100%;
  overflow: auto;
}

/* ============================================================================
   V2 ADMIN PANES
   ============================================================================ */
/* Admin panes use 3-row grid: toolbar (auto) + stats (auto) + content (fills) */
.v2-admin-pane {
  grid-template-rows: auto auto minmax(0, 1fr) !important;
}

.v2-admin-pane.active {
  display: grid;
}

/* Admin page header row - compact controls bar */
.v2-admin-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-elev, #111520);
  border-bottom: 1px solid var(--border, #2a3142);
}

.v2-admin-toolbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
}

.v2-admin-toolbar-title i {
  color: var(--accent);
}

.v2-admin-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.v2-admin-toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border, #2a3142);
  margin: 0 4px;
}

.v2-admin-toolbar label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.v2-admin-toolbar input[type="date"] {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}

.v2-admin-toolbar select {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}

.v2-admin-toolbar .v2-admin-btn {
  padding: 4px 10px;
  font-size: 11px;
}

/* Stats bar - compact inline metrics */
.v2-admin-stats-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 16px;
  background: var(--muted-bg, rgba(255,255,255,0.03));
  border-bottom: 1px solid var(--border, #2a3142);
  flex-wrap: wrap;
}

.v2-admin-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.v2-admin-stat-label {
  color: var(--muted);
}

.v2-admin-stat-value {
  font-weight: 600;
  color: var(--text);
}

/* Job status - inline compact version */
.v2-admin-job-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  margin-left: auto;
}

.v2-admin-job-status-label {
  color: var(--muted);
}

/* Admin page content area - fills remaining space */
.v2-admin-content {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Admin page header */
.v2-admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.v2-admin-header h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.v2-admin-header h1 i {
  color: var(--accent);
}

/* Admin date range picker */
.v2-admin-date-picker {
  display: flex;
  gap: 12px;
  align-items: center;
}

.v2-admin-date-picker input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

/* Admin panels/cards */
.v2-admin-panel {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.v2-admin-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--muted-bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.v2-admin-panel-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.v2-admin-panel-body {
  padding: 20px;
}

/* Admin overview cards grid */
.v2-admin-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.v2-admin-card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
}

.v2-admin-card-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.v2-admin-card-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
}

/* Admin tabs */
.v2-admin-tabs {
  display: flex;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--muted-bg);
  padding: 0 8px;
}

.v2-admin-tab {
  padding: 10px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.v2-admin-tab:hover {
  color: var(--accent);
  background: rgba(var(--accent-rgb, 26, 115, 232), 0.04);
}

.v2-admin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--card-bg);
}

/* Admin tab content */
.v2-admin-tab-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.v2-admin-tab-pane {
  display: none;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  padding: 12px 16px;
  overflow: hidden;
}

.v2-admin-tab-pane.active {
  display: flex;
}

/* Admin grid container - fills remaining space */
.v2-admin-grid {
  flex: 1;
  min-height: 0;
  width: 100%;
}

/* Tab-level toolbar (inline filters/controls) */
.v2-admin-tab-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  flex-shrink: 0;
}

.v2-admin-tab-toolbar select,
.v2-admin-tab-toolbar input[type="text"],
.v2-admin-tab-toolbar input[type="date"] {
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}

/* Admin chart container */
.v2-admin-chart {
  width: 100%;
  height: 280px;
  min-height: 280px;
  flex-shrink: 0;
  margin-top: 12px;
  background: var(--muted-bg);
  border-radius: 6px;
  padding: 12px;
  box-sizing: border-box;
}

/* Ensure Highcharts renders properly inside the container */
.v2-admin-chart .highcharts-container {
  width: 100% !important;
  height: 100% !important;
}

.v2-admin-chart .highcharts-root {
  width: 100% !important;
}

/* Pagination footer */
.v2-admin-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

/* Admin status badges */
.v2-admin-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.v2-admin-badge.success { background: #e8f5e9; color: #2e7d32; }
.v2-admin-badge.running { background: #e3f2fd; color: #1565c0; }
.v2-admin-badge.failed { background: #ffebee; color: #c62828; }
.v2-admin-badge.pending { background: #f5f5f5; color: #616161; }

/* Dark theme adjustments for admin badges */
.dark-theme .v2-admin-badge.success { background: rgba(46, 125, 50, 0.2); color: #81c784; }
.dark-theme .v2-admin-badge.running { background: rgba(21, 101, 192, 0.2); color: #64b5f6; }
.dark-theme .v2-admin-badge.failed { background: rgba(198, 40, 40, 0.2); color: #e57373; }
.dark-theme .v2-admin-badge.pending { background: rgba(97, 97, 97, 0.2); color: #bdbdbd; }

/* ============================================================================
   DARK THEME - Admin Page Overrides (explicit hardcoded colors)
   ============================================================================ */
html.dark-theme .v2-admin-pane,
html.dark-theme .v2-admin-content,
html.dark-theme .v2-admin-tab-content,
html.dark-theme .v2-admin-tab-pane,
html.dark-theme .v2-admin-tab-pane.active,
.dark-theme .v2-admin-pane,
.dark-theme .v2-admin-content,
.dark-theme .v2-admin-tab-content,
.dark-theme .v2-admin-tab-pane,
.dark-theme .v2-admin-tab-pane.active {
  background-color: #0c111a !important;
  color: #e6e9f0 !important;
}

html.dark-theme .v2-admin-toolbar,
html.dark-theme .v2-admin-stats-bar,
html.dark-theme .v2-admin-tabs,
.dark-theme .v2-admin-toolbar,
.dark-theme .v2-admin-stats-bar,
.dark-theme .v2-admin-tabs {
  background-color: #111520 !important;
  border-color: #1e2433 !important;
  color: #e6e9f0 !important;
}

html.dark-theme .v2-admin-panel,
html.dark-theme .v2-admin-card,
html.dark-theme .v2-admin-panel-header,
html.dark-theme .v2-admin-panel-body,
html.dark-theme .v2-admin-filters,
html.dark-theme .v2-admin-chart,
.dark-theme .v2-admin-panel,
.dark-theme .v2-admin-card,
.dark-theme .v2-admin-panel-header,
.dark-theme .v2-admin-panel-body,
.dark-theme .v2-admin-filters,
.dark-theme .v2-admin-chart {
  background-color: #111520 !important;
  border-color: #1e2433 !important;
  color: #e6e9f0 !important;
}

html.dark-theme .v2-admin-tab,
.dark-theme .v2-admin-tab {
  color: #8b92a5 !important;
}

html.dark-theme .v2-admin-tab:hover,
.dark-theme .v2-admin-tab:hover {
  color: #0d7cc4 !important;
  background-color: rgba(13, 124, 196, 0.1) !important;
}

html.dark-theme .v2-admin-tab.active,
.dark-theme .v2-admin-tab.active {
  color: #0d7cc4 !important;
  border-bottom-color: #0d7cc4 !important;
  background-color: #0c111a !important;
}

html.dark-theme .v2-admin-toolbar-title,
html.dark-theme .v2-admin-card-value,
html.dark-theme .v2-admin-stat-value,
html.dark-theme .v2-admin-panel-header h3,
.dark-theme .v2-admin-toolbar-title,
.dark-theme .v2-admin-card-value,
.dark-theme .v2-admin-stat-value,
.dark-theme .v2-admin-panel-header h3 {
  color: #e6e9f0 !important;
}

html.dark-theme .v2-admin-toolbar label,
html.dark-theme .v2-admin-card-label,
html.dark-theme .v2-admin-stat-label,
html.dark-theme .v2-admin-pagination,
.dark-theme .v2-admin-toolbar label,
.dark-theme .v2-admin-card-label,
.dark-theme .v2-admin-stat-label,
.dark-theme .v2-admin-pagination {
  color: #8b92a5 !important;
}

html.dark-theme .v2-admin-toolbar input,
html.dark-theme .v2-admin-toolbar select,
html.dark-theme .v2-admin-tab-toolbar input,
html.dark-theme .v2-admin-tab-toolbar select,
html.dark-theme .v2-admin-filter-group input,
html.dark-theme .v2-admin-filter-group select,
.dark-theme .v2-admin-toolbar input,
.dark-theme .v2-admin-toolbar select,
.dark-theme .v2-admin-tab-toolbar input,
.dark-theme .v2-admin-tab-toolbar select,
.dark-theme .v2-admin-filter-group input,
.dark-theme .v2-admin-filter-group select {
  background-color: #0c111a !important;
  border-color: #1e2433 !important;
  color: #e6e9f0 !important;
}

html.dark-theme .v2-admin-modal,
html.dark-theme .v2-admin-modal-header,
html.dark-theme .v2-admin-modal-body,
.dark-theme .v2-admin-modal,
.dark-theme .v2-admin-modal-header,
.dark-theme .v2-admin-modal-body {
  background-color: #111520 !important;
  border-color: #1e2433 !important;
  color: #e6e9f0 !important;
}

/* Modal footer needs an explicit dark background — without this it falls back to
   the light-mode value of --v2-bg-elevated (white) because v2AdvisorCenter.css's
   :root block loads after v2-overlay.css and re-declares that variable. */
html.dark-theme .v2-admin-modal-footer,
.dark-theme .v2-admin-modal-footer {
  background-color: #161b26 !important;
  border-color: #1e2433 !important;
  color: #e6e9f0 !important;
}

/* Force readable text for labels, headings, and form helper text inside the
   admin modal in dark mode (same reason as the footer override above). */
html.dark-theme .v2-admin-modal label,
html.dark-theme .v2-admin-modal h3,
html.dark-theme .v2-admin-modal h4,
html.dark-theme .v2-admin-modal h5,
html.dark-theme .v2-admin-modal .v2-admin-form-group label,
.dark-theme .v2-admin-modal label,
.dark-theme .v2-admin-modal h3,
.dark-theme .v2-admin-modal h4,
.dark-theme .v2-admin-modal h5,
.dark-theme .v2-admin-modal .v2-admin-form-group label {
  color: #e6e9f0 !important;
}

html.dark-theme .v2-admin-modal small,
html.dark-theme .v2-admin-modal .v2-admin-form-group small,
.dark-theme .v2-admin-modal small,
.dark-theme .v2-admin-modal .v2-admin-form-group small {
  color: #8b92a5 !important;
}

/* Footer buttons: the secondary button uses var(--muted-bg)/var(--text)/var(--border)
   which all resolve correctly in dark mode, but pin them explicitly to avoid any
   :root re-declaration in another stylesheet shadowing the dark values. */
html.dark-theme .v2-admin-modal-footer .v2-admin-btn-secondary,
.dark-theme .v2-admin-modal-footer .v2-admin-btn-secondary {
  background-color: rgba(255, 255, 255, 0.05) !important;
  color: #e6e9f0 !important;
  border-color: #1e2433 !important;
}

html.dark-theme .v2-admin-modal-footer .v2-admin-btn-secondary:hover,
.dark-theme .v2-admin-modal-footer .v2-admin-btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
}

/* The modal close (×) button color in dark mode. */
html.dark-theme .v2-admin-modal-close,
.dark-theme .v2-admin-modal-close {
  color: #8b92a5 !important;
}

html.dark-theme .v2-admin-modal-close:hover,
.dark-theme .v2-admin-modal-close:hover {
  color: #e6e9f0 !important;
  background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Admin buttons */
.v2-admin-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.v2-admin-btn-primary {
  background: var(--accent);
  color: white;
}

.v2-admin-btn-primary:hover {
  filter: brightness(1.1);
}

.v2-admin-btn-secondary {
  background: var(--muted-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.v2-admin-btn-secondary:hover {
  background: var(--border);
}

/* Admin filter panel (legacy - kept for compatibility) */
.v2-admin-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 12px;
  background: var(--muted-bg);
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.v2-admin-filter-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.v2-admin-filter-group label {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.v2-admin-filter-group input,
.v2-admin-filter-group select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  min-width: 100px;
  background: var(--bg);
  color: var(--text);
}

/* Admin modal */
.v2-admin-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.v2-admin-modal-overlay.active {
  display: flex;
}

.v2-admin-modal {
  background: var(--card-bg);
  border-radius: 12px;
  width: 90%;
  max-width: 1000px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.v2-admin-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.v2-admin-modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.v2-admin-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
}

.v2-admin-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* Large modal variant for charts */
.v2-admin-modal.v2-admin-modal-lg {
  max-width: 900px;
  max-height: 520px;
}

.v2-admin-modal.v2-admin-modal-lg .v2-admin-modal-header {
  padding: 16px 20px;
}

.v2-admin-modal.v2-admin-modal-lg .v2-admin-modal-body {
  padding: 16px 20px 20px;
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */
@media (max-width: 1024px) {
  .v2-overlay-stats {
    display: none;
  }
  
  .v2-overlay-name {
    max-width: 200px;
  }
}

@media (max-width: 767px) {
  .v2-overlay-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }
  
  .v2-overlay-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }
  
  .v2-overlay-tabs {
    padding: 0 12px;
  }
  
  .v2-overlay-tab {
    padding: 10px 12px;
    font-size: 12px;
  }
  
  .v2-overlay-content {
    padding: 12px;
  }
  
  .v2-breadcrumb {
    display: none;
  }
}

/* ============================================================================
   CUSTOM DROPDOWN ENHANCEMENTS (V2)
   ============================================================================ */
.page-header .custom-dropdown .dropdown-option-empty {
  color: var(--muted, #6B7280);
  font-style: italic;
  cursor: default;
}

.page-header .custom-dropdown .dropdown-option-empty:hover {
  background: transparent;
  color: var(--muted, #6B7280);
}

.page-header .custom-dropdown .dropdown-option-clear {
  color: var(--muted, #6B7280);
  border-bottom: 1px solid var(--border, #E5E7EB);
  margin-bottom: 4px;
  padding-bottom: 8px;
}

.page-header .custom-dropdown .dropdown-selected.has-selection {
  color: var(--accent, #0964A0);
  font-weight: 500;
}

/* Dark theme for dropdown empty/clear states */
html.dark-theme .custom-dropdown .dropdown-option-empty,
.dark-theme .custom-dropdown .dropdown-option-empty {
  color: #8b92a5 !important;
}

html.dark-theme .custom-dropdown .dropdown-option-empty:hover,
.dark-theme .custom-dropdown .dropdown-option-empty:hover {
  background: transparent !important;
  color: #8b92a5 !important;
}

html.dark-theme .custom-dropdown .dropdown-option-clear,
.dark-theme .custom-dropdown .dropdown-option-clear {
  color: #8b92a5 !important;
  border-bottom-color: #1e2433 !important;
}

html.dark-theme .custom-dropdown .dropdown-selected.has-selection,
.dark-theme .custom-dropdown .dropdown-selected.has-selection {
  color: #0d7cc4 !important;
}

/* ============================================================================
   V2 MODAL STYLES
   ============================================================================ */
.v2-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.v2-modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.v2-modal-content {
  background: var(--bg-elev, #1a1f2e);
  border-radius: 8px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.v2-modal-overlay.open .v2-modal-content {
  transform: scale(1);
}

.v2-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, #2a3142);
}

.v2-modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text, #e6e9f0);
  margin: 0;
}

.v2-modal-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--muted, #6B7280);
  font-size: 18px;
  line-height: 1;
  transition: color 0.15s ease;
}

.v2-modal-close:hover {
  color: var(--text, #e6e9f0);
}

.v2-modal-body {
  padding: 20px;
}

.v2-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border, #2a3142);
}

.v2-form-group {
  margin-bottom: 16px;
}

.v2-form-group:last-child {
  margin-bottom: 0;
}

.v2-form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted, #9CA3AF);
  margin-bottom: 6px;
}

.v2-form-input,
.v2-form-select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text, #e6e9f0);
  background: var(--bg, #111520);
  border: 1px solid var(--border, #2a3142);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.v2-form-input:focus,
.v2-form-select:focus {
  border-color: var(--accent, #0964A0);
  box-shadow: 0 0 0 3px rgba(9, 100, 160, 0.2);
}

.v2-form-input::placeholder {
  color: var(--muted, #6B7280);
}

.v2-radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.v2-radio-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text, #e6e9f0);
}

.v2-radio-item input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #0964A0);
}

.v2-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.v2-btn-primary {
  background: var(--accent, #0964A0);
  color: white;
}

.v2-btn-primary:hover {
  background: #0a7bc2;
}

.v2-btn-secondary {
  background: var(--bg, #111520);
  color: var(--text, #e6e9f0);
  border: 1px solid var(--border, #2a3142);
}

.v2-btn-secondary:hover {
  background: var(--bg-elev, #1a1f2e);
}

/* Outline variant (e.g. model builder Close / Settings buttons). Defined
   here because the class was referenced in JS without a matching style
   rule — in light mode it inherited the browser default button chrome and
   in dark mode it rendered as a solid white box. Mirrors v2-btn-secondary
   but with a transparent background so it sits well on any surface. */
.v2-btn-outline {
  background: transparent;
  color: var(--text, #1a202c);
  border: 1px solid var(--border, #d1d5db);
}

.v2-btn-outline:hover {
  background: var(--bg-elev, #f5f7fa);
  border-color: var(--accent, #0964a0);
  color: var(--accent, #0964a0);
}

html.dark-theme .v2-btn-outline {
  color: #e6e9f0;
  border-color: #2d3748;
}

html.dark-theme .v2-btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent, #0d7cc4);
  color: var(--accent, #0d7cc4);
}

/* Wide modal variant for Edit Columns */
.v2-modal-wide .v2-modal-content-wide {
  max-width: 900px;
  width: 95%;
}

/* Columns modal tabs */
.v2-columns-tabs {
  display: flex;
  gap: 0;
  padding: 0 20px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: var(--bg-secondary, #f9fafb);
}
.v2-columns-tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted, #6b7280);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.v2-columns-tab:hover { color: var(--text-primary, #374151); }
.v2-columns-tab--active {
  color: var(--accent, #0964a0);
  border-bottom-color: var(--accent, #0964a0);
}
.v2-columns-tab-panel { min-height: 300px; }

/* Popular views grouped cards */
.v2-popular-group { margin-bottom: 16px; }
.v2-popular-group__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted, #6b7280);
  margin: 0 0 8px 0;
}
.v2-popular-group__cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.v2-popular-card {
  padding: 10px 14px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary, #374151);
}
.v2-popular-card:hover {
  border-color: var(--accent, #0964a0);
  box-shadow: 0 0 0 2px rgba(9, 100, 160, 0.12);
}
.v2-popular-card--active {
  border-color: var(--accent, #0964a0);
  background: rgba(9, 100, 160, 0.06);
}

/* My Views cards */
.v2-my-views-list { display: flex; flex-direction: column; gap: 8px; }
.v2-my-view-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  background: #fff;
}
.v2-my-view-card__name { font-size: 13px; font-weight: 500; }
.v2-my-view-card__actions { display: flex; gap: 6px; }
.v2-my-view-card__btn {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}
.v2-my-view-card__btn--apply {
  background: var(--accent, #0964a0);
  color: #fff;
  border-color: var(--accent, #0964a0);
}
.v2-my-view-card__btn--delete { color: var(--danger, #ef4444); }
.v2-my-views-empty {
  padding: 30px 0;
  text-align: center;
  color: var(--muted, #6b7280);
  font-size: 13px;
}
.v2-my-views-save-btn {
  margin-top: 12px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent, #0964a0);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.v2-columns-modal-body {
  padding: 16px 20px !important;
}

.v2-columns-grid-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  min-height: 400px;
}

.v2-columns-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg, #111520);
  border: 1px solid var(--border, #2a3142);
  border-radius: 6px;
  padding: 12px;
}

.v2-columns-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #e6e9f0);
  margin: 0 0 4px 0;
}

.v2-columns-panel-subtitle {
  font-size: 12px;
  color: var(--muted, #6B7280);
  margin: 0 0 12px 0;
}

.v2-columns-grid {
  flex: 1;
  min-height: 350px;
}

.v2-columns-note {
  font-size: 12px;
  color: var(--muted, #6B7280);
  margin: 12px 0 0 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.v2-columns-note i {
  color: var(--accent, #0964A0);
}

/* Edit columns grid styling */
.v2-columns-grid .ag-row-group {
  font-weight: 600;
}

.v2-columns-grid .ag-header-cell-label {
  font-weight: 500;
}

/* Remove button in selected columns */
.v2-column-remove-btn {
  background: none;
  border: none;
  color: var(--muted, #6B7280);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
  transition: all 0.15s ease;
}

.v2-column-remove-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

@media (max-width: 768px) {
  .v2-columns-grid-container {
    grid-template-columns: 1fr;
  }
  
  .v2-modal-wide .v2-modal-content-wide {
    max-width: 100%;
    margin: 10px;
  }
}

/* ============================================================================
   STUB TAB STYLES (Supports light/dark themes)
   ============================================================================ */
.v2-stub-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  padding: 48px 24px;
  text-align: center;
  background: var(--v2-bg-surface);
  border-radius: 8px;
  border: 1px solid var(--v2-border);
}

.v2-stub-icon {
  font-size: 48px;
  color: var(--v2-accent);
  margin-bottom: 16px;
  opacity: 0.7;
}

.v2-stub-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--v2-text-primary);
  margin: 0 0 8px 0;
}

.v2-stub-message {
  font-size: 14px;
  color: var(--v2-text-muted);
  margin: 0 0 24px 0;
}

.v2-stub-debug {
  padding: 8px 16px;
  background: var(--v2-bg-hover);
  border-radius: 4px;
}

.v2-stub-debug code {
  font-size: 11px;
  color: var(--v2-text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ============================================================================
   OLD STANDALONE PROFILE STYLES (kept for backwards compat with overlay)
   ============================================================================ */
.v2-standalone-profile-old {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-base, #0c111a);
}

.v2-standalone-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--bg-elev, #111520);
  border-bottom: 1px solid var(--border, #1e2433);
}

.v2-standalone-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text, #e6e9f0);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.v2-entity-type-badge {
  padding: 4px 10px;
  background: var(--v2-accent-bg);
  border: 1px solid var(--v2-accent);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--v2-accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.v2-standalone-tabs {
  display: flex;
  gap: 0;
  padding: 0 24px;
  background: var(--bg-elev, #111520);
  border-bottom: 1px solid var(--border, #1e2433);
}

.v2-standalone-tab {
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted, #ADADAD);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.v2-standalone-tab:hover {
  color: var(--text, #e6e9f0);
}

.v2-standalone-tab.active {
  color: var(--accent, #0964A0);
  border-bottom-color: var(--accent, #0964A0);
}

.v2-standalone-tab:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.v2-standalone-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.v2-standalone-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  text-align: center;
}

/* ============================================================================
   HEADER METRICS IN OVERLAY
   ============================================================================ */
.v2-overlay-metrics {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.v2-header-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.v2-metric-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted, #ADADAD);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.v2-metric-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text, #e6e9f0);
}

.v2-date-badge {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted, #ADADAD);
  margin-left: 8px;
}

.v2-date-range {
  font-size: 12px;
  color: var(--muted, #ADADAD);
  margin: 0 0 16px 0;
}

/* ============================================================================
   COMPARE TOOL PLACEHOLDER
   ============================================================================ */
.v2-compare-header {
  margin-bottom: 24px;
}

.v2-compare-header h3 {
  margin: 0 0 8px 0;
  font-size: 20px;
  color: var(--text, #e6e9f0);
}

.v2-compare-placeholder,
.v2-compare-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  text-align: center;
  padding: 48px 24px;
}

/* ============================================================================
   GLOBAL SEARCH DROPDOWN
   ============================================================================ */

/* Override header overflow to allow dropdown to appear */
.app-header {
  overflow: visible !important;
}

.header-search {
  position: relative;
  z-index: 9999; /* Ensure dropdown appears above all page content */
}

.v2-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  min-width: 350px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-elev, #111520);
  border: 1px solid var(--border, #1e2433);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 99999; /* Very high to appear above everything */
  margin-top: 4px;
}

.v2-search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
  border-bottom: 1px solid var(--border, #1e2433);
}

.v2-search-result:last-child {
  border-bottom: none;
}

.v2-search-result:hover,
.v2-search-result.selected {
  background: rgba(9, 100, 160, 0.15);
}

.v2-search-ticker {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
  font-size: 13px;
  color: var(--accent, #0964A0);
  min-width: 60px;
}

.v2-search-name {
  flex: 1;
  font-size: 13px;
  color: var(--text, #e6e9f0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-search-type {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted, #ADADAD);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

.v2-search-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted, #ADADAD);
  font-size: 13px;
}

.v2-search-pills {
  display: flex;
  gap: 4px;
  padding: 8px 10px 4px;
  border-bottom: 1px solid var(--border, #1e2433);
  flex-wrap: wrap;
}
.v2-search-pill {
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border, #2d3748);
  border-radius: 12px;
  background: transparent;
  color: var(--muted, #9CA3AF);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.v2-search-pill:hover {
  border-color: var(--accent, #0964A0);
  color: var(--text, #e6e9f0);
}
.v2-search-pill.active {
  background: var(--accent, #0964A0);
  border-color: var(--accent, #0964A0);
  color: #fff;
}

.v2-search-results-list {
  max-height: 340px;
  overflow-y: auto;
}

/* Make header search input wider */
#v2-global-search {
  width: 280px;
  padding: 8px 12px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border, #1e2433);
  border-radius: 6px;
  color: var(--text, #e6e9f0);
  transition: all 0.15s ease;
}

#v2-global-search:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent, #0964A0);
  box-shadow: 0 0 0 3px rgba(9, 100, 160, 0.2);
}

#v2-global-search::placeholder {
  color: var(--muted, #ADADAD);
}

/* ============================================================================
   V2 ENHANCED AUTOCOMPLETE (page-level search dropdowns)
   ============================================================================ */

.v2-autocomplete {
  position: relative;
  z-index: 100;
}

.v2-ac-dropdown {
  position: absolute;
  z-index: 9999;
  top: 100%;
  left: 0;
  right: 0;
  min-width: 300px;
  max-height: 420px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev, #111520);
  border: 1px solid var(--border, #1e2433);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  margin-top: 2px;
}

.v2-ac-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border, #1e2433);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.v2-ac-pills {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  flex: 1;
}

.v2-ac-pill {
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--border, #2d3748);
  border-radius: 10px;
  background: transparent;
  color: var(--muted, #9CA3AF);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.v2-ac-pill:hover {
  border-color: var(--accent, #0964A0);
  color: var(--text, #e6e9f0);
}

.v2-ac-pill.active {
  background: var(--accent, #0964A0);
  border-color: var(--accent, #0964A0);
  color: #fff;
}

.v2-ac-country-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--border, #2d3748);
  border-radius: 10px;
  background: transparent;
  color: var(--muted, #9CA3AF);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  margin-left: auto;
}

.v2-ac-country-toggle:hover {
  border-color: var(--accent, #0964A0);
  color: var(--text, #e6e9f0);
}

.v2-ac-country-toggle .fi {
  font-size: 12px;
  border-radius: 2px;
}

.v2-ac-country-picker {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 10;
  min-width: 180px;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 4px;
  background: var(--bg-elev, #111520);
  border: 1px solid var(--border, #1e2433);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.v2-ac-country-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 11px;
  color: var(--text, #e6e9f0);
  transition: background 0.12s ease;
}

.v2-ac-country-opt:hover {
  background: rgba(9, 100, 160, 0.15);
}

.v2-ac-country-opt.active {
  background: rgba(9, 100, 160, 0.2);
}

.v2-ac-country-opt .fi {
  font-size: 14px;
  border-radius: 2px;
}

.v2-ac-country-opt-label {
  flex: 1;
}

.v2-ac-country-opt-code {
  color: var(--muted, #9CA3AF);
  font-weight: 600;
  font-size: 10px;
}

.v2-ac-country-opt-all {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--text, #e6e9f0);
  border-bottom: 1px solid var(--border, #1e2433);
  transition: background 0.12s ease;
}

.v2-ac-country-opt-all:hover {
  background: rgba(9, 100, 160, 0.15);
}

.v2-ac-country-opt-all.active {
  background: rgba(9, 100, 160, 0.2);
}

.v2-ac-results {
  flex: 1;
  overflow-y: auto;
  max-height: 340px;
}

.v2-ac-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.12s ease;
  border-bottom: 1px solid var(--border, #1e2433);
}

.v2-ac-result:last-child {
  border-bottom: none;
}

.v2-ac-result:hover,
.v2-ac-result.selected {
  background: rgba(9, 100, 160, 0.15);
}

.v2-ac-result-flag {
  font-size: 14px;
  border-radius: 2px;
  flex-shrink: 0;
}

.v2-ac-result-ticker {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
  font-size: 13px;
  color: var(--accent, #0964A0);
  min-width: 55px;
}

.v2-ac-result-name {
  flex: 1;
  font-size: 12px;
  color: var(--text, #e6e9f0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-ac-result-type {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted, #ADADAD);
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.v2-ac-empty {
  padding: 20px;
  text-align: center;
  color: var(--muted, #ADADAD);
  font-size: 12px;
}

.v2-ac-browse-label {
  padding: 4px 12px 2px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted, #9CA3AF);
}

/* ============================================================================
   STANDALONE PROFILE PLACEHOLDER
   ============================================================================ */
.v2-standalone-profile-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  height: 100%;
}

.v2-standalone-info {
  text-align: center;
  padding: 48px 24px;
}

.v2-standalone-info i {
  color: var(--accent, #0964A0);
  margin-bottom: 16px;
}

.v2-standalone-info h2 {
  font-size: 24px;
  color: var(--text, #e6e9f0);
  margin: 0 0 8px 0;
}

.v2-entity-type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent, #0964A0);
  background: rgba(9, 100, 160, 0.15);
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 16px;
}

.v2-standalone-info .text-muted {
  color: var(--muted, #ADADAD);
  font-size: 14px;
  margin: 8px 0;
}

.v2-standalone-quick-search {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.v2-standalone-quick-search input {
  width: 200px;
  padding: 10px 14px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border, #1e2433);
  border-radius: 6px;
  color: var(--text, #e6e9f0);
}

.v2-standalone-quick-search input:focus {
  outline: none;
  border-color: var(--accent, #0964A0);
  box-shadow: 0 0 0 3px rgba(9, 100, 160, 0.2);
}

.v2-standalone-quick-search .btn-primary {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  background: var(--accent, #0964A0);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.v2-standalone-quick-search .btn-primary:hover {
  background: #0a75b8;
}

/* ============================================================================
   PROFILE HOME STYLES (STATE: PROFILE_HOME)
   Supports light/dark themes via CSS variables
   ============================================================================ */
.v2-profile-home-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 48px 24px;
  background: var(--v2-bg-page);
}

.v2-profile-home-content {
  width: 100%;
  max-width: 600px;
  text-align: center;
}

.v2-profile-home-header {
  margin-bottom: 32px;
}

.v2-profile-home-icon {
  font-size: 48px;
  color: var(--v2-accent);
  margin-bottom: 16px;
  opacity: 0.9;
}

.v2-profile-home-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--v2-text-primary);
  margin: 0 0 8px 0;
}

.v2-profile-home-subtitle {
  font-size: 14px;
  color: var(--v2-text-muted);
  margin: 0;
  line-height: 1.5;
}

/* Entity Type Selector */
.v2-profile-home-type-selector {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.v2-type-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--v2-bg-surface);
  border: 1px solid var(--v2-border);
  border-radius: 8px;
  color: var(--v2-text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.v2-type-btn:hover {
  background: var(--v2-bg-hover);
  border-color: var(--v2-accent);
  color: var(--v2-accent);
}

.v2-type-btn.active {
  background: var(--v2-accent);
  border-color: var(--v2-accent);
  color: #fff;
}

.v2-type-btn i {
  font-size: 14px;
}

/* Search Box */
.v2-profile-home-search {
  margin-bottom: 32px;
}

.v2-profile-home-search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.v2-profile-home-search-input-wrapper > i {
  position: absolute;
  left: 16px;
  color: var(--v2-text-muted);
  font-size: 16px;
  pointer-events: none;
}

.v2-profile-home-search-input {
  width: 100%;
  padding: 16px 60px 16px 48px;
  font-size: 16px;
  background: var(--v2-bg-input);
  border: 1px solid var(--v2-border);
  border-radius: 12px;
  color: var(--v2-text-primary);
  transition: all 0.15s ease;
}

.v2-profile-home-search-input:focus {
  outline: none;
  background: var(--v2-bg-surface);
  border-color: var(--v2-border-focus);
  box-shadow: 0 0 0 3px var(--v2-accent-bg);
}

.v2-profile-home-search-input::placeholder {
  color: var(--v2-text-placeholder);
}

.v2-search-kbd {
  position: absolute;
  right: 12px;
  padding: 4px 8px;
  background: var(--v2-bg-active);
  border-radius: 4px;
  font-size: 11px;
  color: var(--v2-text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Search Dropdown */
.v2-profile-home-search {
  position: relative;
}
.v2-profile-home-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 200;
  margin-top: 4px;
  background: var(--v2-bg-surface, #fff);
  border: 1px solid var(--v2-border, #e5e7eb);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  max-height: 380px;
  overflow-y: auto;
  overflow-x: hidden;
}
.v2-ph-dd-empty {
  padding: 16px;
  text-align: center;
  color: var(--v2-text-muted, #9ca3af);
  font-size: 13px;
}
.v2-ph-dd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.1s;
}
.v2-ph-dd-item:hover,
.v2-ph-dd-item.active {
  background: var(--v2-bg-hover, #f3f4f6);
}
.v2-ph-dd-ticker {
  font-weight: 700;
  font-size: 13px;
  min-width: 64px;
  color: var(--v2-accent, #0964A0);
}
.v2-ph-dd-ticker strong {
  color: inherit;
}
.v2-ph-dd-name {
  flex: 1;
  font-size: 13px;
  color: var(--v2-text-primary, #111);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.v2-ph-dd-type {
  font-size: 11px;
  color: var(--v2-text-muted, #9ca3af);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Recent Items */
.v2-profile-home-recent {
  text-align: left;
  margin-bottom: 32px;
}

.v2-profile-home-recent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.v2-profile-home-recent-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--v2-text-muted);
  margin: 0;
}

.v2-profile-home-recent-title i {
  font-size: 12px;
}

.v2-profile-home-clear-recent {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--v2-text-muted);
  cursor: pointer;
  transition: color 0.15s ease;
}

.v2-profile-home-clear-recent:hover {
  color: var(--v2-accent);
}

.v2-profile-home-recent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.v2-profile-home-recent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--v2-bg-surface);
  border: 1px solid var(--v2-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.v2-profile-home-recent-item:hover {
  background: var(--v2-accent-bg);
  border-color: var(--v2-accent);
}

.v2-recent-item-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
  font-size: 13px;
  color: var(--v2-accent);
}

.v2-recent-item-name {
  font-size: 12px;
  color: var(--v2-text-muted);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-profile-home-empty-recent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px;
  color: var(--v2-text-placeholder);
  font-size: 13px;
}

.v2-profile-home-empty-recent i {
  font-size: 24px;
  opacity: 0.5;
}

/* Quick Links */
.v2-profile-home-quicklinks {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.v2-profile-home-quicklink {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--v2-bg-surface);
  border: 1px solid var(--v2-border);
  border-radius: 8px;
  color: var(--v2-text-muted);
  font-size: 13px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.v2-profile-home-quicklink:hover {
  background: var(--v2-bg-hover);
  color: var(--v2-accent);
  border-color: var(--v2-accent);
}

.v2-profile-home-quicklink i {
  font-size: 14px;
  color: var(--v2-accent);
}

/* ============================================================================
   PROFILE STANDALONE STYLES (STATE: PROFILE_STANDALONE)
   Supports light/dark themes via CSS variables
   ============================================================================ */
.v2-standalone-profile {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--v2-bg-page);
}

/* Standalone Header */
.v2-standalone-profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--v2-bg-surface);
  border-bottom: 1px solid var(--v2-border);
  flex-shrink: 0;
}

.v2-standalone-profile-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.v2-standalone-back-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--v2-bg-hover);
  border-radius: 8px;
  color: var(--v2-text-muted);
  text-decoration: none;
  transition: all 0.15s ease;
}

.v2-standalone-back-link:hover {
  background: var(--v2-bg-active);
  color: var(--v2-accent);
}

.v2-standalone-profile-title-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.v2-standalone-profile-ticker {
  font-size: 22px;
  font-weight: 700;
  color: var(--v2-accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin: 0;
}

.v2-standalone-profile-name {
  font-size: 13px;
  color: var(--v2-text-muted);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v2-standalone-profile-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.v2-standalone-profile-metrics {
  display: flex;
  gap: 20px;
}

.v2-standalone-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: right;
}

.v2-standalone-metric .v2-metric-label {
  font-size: 11px;
  color: var(--v2-text-muted);
  text-transform: uppercase;
}

.v2-standalone-metric .v2-metric-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--v2-text-primary);
}

.v2-standalone-profile-actions {
  display: flex;
  gap: 8px;
}

/* Standalone Tab Bar */
.v2-standalone-profile-tabs {
  display: flex;
  gap: 0;
  padding: 0 24px;
  background: var(--v2-bg-surface);
  border-bottom: 1px solid var(--v2-border);
  overflow-x: auto;
  flex-shrink: 0;
}

.v2-standalone-tab {
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--v2-text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.v2-standalone-tab:hover:not(:disabled) {
  color: var(--v2-accent);
}

.v2-standalone-tab.active {
  color: var(--v2-accent);
  border-bottom-color: var(--v2-accent);
}

.v2-standalone-tab:disabled {
  color: var(--v2-text-placeholder);
  cursor: not-allowed;
}

/* Standalone Content */
.v2-standalone-profile-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--v2-bg-page);
}

.v2-standalone-tab-content {
  animation: fadeIn 0.2s ease;
}

/* Responsive adjustments for standalone profile */
@media (max-width: 1024px) {
  .v2-standalone-profile-metrics {
    display: none;
  }
}

@media (max-width: 768px) {
  .v2-standalone-profile-header {
    flex-wrap: wrap;
    padding: 12px 16px;
  }

  .v2-standalone-profile-header-left {
    width: 100%;
  }

  .v2-standalone-profile-header-right {
    width: 100%;
    justify-content: flex-end;
  }

  .v2-standalone-profile-tabs {
    padding: 0 16px;
  }

  .v2-standalone-profile-content {
    padding: 16px;
  }

  .v2-profile-home-content {
    padding: 24px 16px;
  }

  .v2-profile-home-type-selector {
    flex-direction: column;
    align-items: stretch;
  }

  .v2-type-btn {
    justify-content: center;
  }
}

/* ============================================================================
   MODEL DATABASE GATE - Financial Professional Disclosure
   ============================================================================ */

#v2-model-gate-pane.v2-tool-pane.active {
  display: block !important;
  overflow-y: auto;
  height: 100%;
}

.v2-model-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 40px 20px;
  background: var(--v2-bg-page, #f8f9fa);
}

/* ---------- MODAL VARIANT ----------
   Used for sponsored-marketplace disclosures triggered from the populated
   Browse Marketplaces landing. Full-viewport overlay with a backdrop.
   The modal wrapper itself is the scroll container so tall disclosure
   content is always reachable (including the "I Agree" button) on mobile. */
.v2-model-gate-modal-root {
  position: fixed;
  inset: 0;
  z-index: 10000;
}

.v2-model-gate--modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  background: transparent;
  z-index: 10000;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* dvh = dynamic viewport height, respects mobile browser chrome
     (address bar) so we never clip the bottom of the card. */
  height: 100vh;
  height: 100dvh;
  min-height: auto;
}

.v2-model-gate--modal .v2-model-gate__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: v2GateBackdropFadeIn 0.2s ease-out;
}

@keyframes v2GateBackdropFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.v2-model-gate--modal .v2-model-gate__card {
  position: relative;
  z-index: 1;
  /* Let the modal wrapper scroll; card sizes to its content but never
     grows beyond the viewport (minus wrapper padding). */
  margin: auto;
  max-height: none;
  overflow: visible;
}

.v2-model-gate__close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(15, 23, 42, 0.65);
  color: #ffffff;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  transition: background 0.15s, transform 0.15s;
}

.v2-model-gate__close:hover {
  background: rgba(15, 23, 42, 0.85);
  transform: scale(1.08);
}

body.v2-model-gate-open {
  overflow: hidden;
}

/* ---------- MOBILE: small-screen tuning ----------
   Shrink card padding + banner negative margins and cap internal terms
   scroll so the action button is always visible without scrolling past
   the viewport on phones. */
@media (max-width: 600px) {
  .v2-model-gate--modal {
    padding: 16px 12px 24px 12px;
    align-items: flex-start;
  }

  .v2-model-gate--modal .v2-model-gate__card {
    padding: 32px 20px;
    border-radius: 10px;
  }

  .v2-model-gate--modal .v2-model-gate__banner {
    margin: -32px -20px 20px -20px;
    max-height: 160px;
  }

  .v2-model-gate--modal .v2-model-gate__banner img {
    max-height: 160px;
  }

  .v2-model-gate--modal .v2-model-gate__scroll {
    max-height: 40vh;
    padding: 14px 16px;
    font-size: 12.5px;
    line-height: 1.6;
  }

  .v2-model-gate--modal .v2-model-gate__title {
    font-size: 18px;
  }

  .v2-model-gate--modal .v2-model-gate__subtitle {
    font-size: 14px;
    margin-bottom: 16px;
  }

  .v2-model-gate--modal .v2-model-gate__badge {
    width: 48px;
    height: 48px;
    font-size: 20px;
    margin-bottom: 14px;
  }

  .v2-model-gate--modal .v2-model-gate__btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 15px;
  }

  .v2-model-gate--modal .v2-model-gate__footnote {
    font-size: 11.5px;
    margin: 12px 0 16px 0;
  }

  .v2-model-gate__close {
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
  }
}

.v2-model-gate__card {
  background: var(--v2-bg-surface, #ffffff);
  border: 1px solid var(--v2-border, #dee2e6);
  border-radius: 12px;
  box-shadow: var(--v2-shadow-lg, 0 10px 15px rgba(0,0,0,0.1));
  max-width: 640px;
  width: 100%;
  padding: 48px 40px;
  text-align: center;
  animation: v2GateFadeIn 0.3s ease-out;
  overflow: hidden;
}

/* Sponsor banner shown above the disclosure card content. Mirrors the
   legacy sponsoredMktplaceLanding.scala.html banner (max 300px tall). */
.v2-model-gate__banner {
  margin: -48px -40px 24px -40px;
  background: var(--v2-bg-hover, #f1f3f4);
  max-height: 300px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.v2-model-gate__banner img {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  display: block;
}

.v2-model-gate__footnote {
  font-size: 12px;
  color: var(--v2-text-muted, #6c757d);
  margin: 16px 0 20px 0;
  text-align: center;
  line-height: 1.5;
}

@keyframes v2GateFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.v2-model-gate__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--v2-accent-bg, rgba(9,100,160,0.1));
  color: var(--v2-accent, #0964A0);
  font-size: 24px;
  margin-bottom: 20px;
}

.v2-model-gate__badge--muted {
  background: var(--v2-bg-hover, #f1f3f4);
  color: var(--v2-text-muted, #6c757d);
}

.v2-model-gate__title {
  font-size: 20px;
  font-weight: 700;
  color: var(--v2-text-primary, #212529);
  margin: 0 0 8px 0;
}

.v2-model-gate__subtitle {
  font-size: 15px;
  font-weight: 600;
  color: var(--v2-text-secondary, #495057);
  margin: 0 0 20px 0;
}

.v2-model-gate__scroll {
  max-height: 260px;
  overflow-y: auto;
  text-align: left;
  padding: 20px 24px;
  margin: 0 0 24px 0;
  background: var(--v2-bg-page, #f8f9fa);
  border: 1px solid var(--v2-border-light, #e9ecef);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--v2-text-secondary, #495057);
}

.v2-model-gate__scroll p {
  margin: 0;
}

.v2-model-gate__body {
  font-size: 14px;
  line-height: 1.7;
  color: var(--v2-text-secondary, #495057);
  margin: 0 0 16px 0;
  text-align: left;
}

.v2-model-gate__link {
  color: var(--v2-accent, #0964A0);
  text-decoration: underline;
  cursor: pointer;
}

.v2-model-gate__link:hover {
  color: var(--v2-accent-hover, #075280);
}

.v2-model-gate__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 32px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.v2-model-gate__btn:active {
  transform: scale(0.97);
}

.v2-model-gate__btn--primary {
  background: var(--v2-accent, #0964A0);
  color: #ffffff;
}

.v2-model-gate__btn--primary:hover {
  background: var(--v2-accent-hover, #075280);
}

.v2-model-gate__btn--primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.v2-model-gate__btn--success {
  background: var(--v2-success, #28a745);
}

.v2-model-gate__btn--success:hover {
  background: var(--v2-success, #28a745);
}

/* Dark-mode overrides for the model-gate disclosure.
   Specificity notes:
   - The gate pane carries `.v2-tool-pane.active`, which has an !important
     background-color rule elsewhere in this file. We need !important here
     too to beat it on the pane itself.
   - We also target both `html.dark-theme` and `.dark-theme` so the rules
     apply regardless of whether the theme class ends up on <html> (normal)
     or <body> (some legacy flows). */
html.dark-theme #v2-model-gate-pane.v2-tool-pane,
html.dark-theme #v2-model-gate-pane.v2-tool-pane.active,
.dark-theme #v2-model-gate-pane.v2-tool-pane,
.dark-theme #v2-model-gate-pane.v2-tool-pane.active {
  background-color: #0c111a !important;
  color: #e6e9f0 !important;
}
html.dark-theme .v2-model-gate,
.dark-theme .v2-model-gate {
  background: #0c111a !important;
}
html.dark-theme .v2-model-gate__card,
.dark-theme .v2-model-gate__card {
  background: #111520 !important;
  border-color: #1e2433 !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45) !important;
  color: #e6e9f0 !important;
}
html.dark-theme .v2-model-gate__title,
.dark-theme .v2-model-gate__title {
  color: #e6e9f0 !important;
}
html.dark-theme .v2-model-gate__subtitle,
.dark-theme .v2-model-gate__subtitle {
  color: #c4c9d4 !important;
}
html.dark-theme .v2-model-gate__body,
.dark-theme .v2-model-gate__body {
  color: #c4c9d4 !important;
}
html.dark-theme .v2-model-gate__scroll,
.dark-theme .v2-model-gate__scroll {
  background: #161b26 !important;
  border-color: #252d3d !important;
  color: #c4c9d4 !important;
}
html.dark-theme .v2-model-gate__scroll p,
.dark-theme .v2-model-gate__scroll p {
  color: #c4c9d4 !important;
}
html.dark-theme .v2-model-gate__badge,
.dark-theme .v2-model-gate__badge {
  background: rgba(13, 124, 196, 0.22) !important;
  color: #0d7cc4 !important;
}
html.dark-theme .v2-model-gate__badge--muted,
.dark-theme .v2-model-gate__badge--muted {
  background: rgba(255, 255, 255, 0.05) !important;
  color: #8b92a5 !important;
}
html.dark-theme .v2-model-gate__link,
.dark-theme .v2-model-gate__link {
  color: #0d7cc4 !important;
}
html.dark-theme .v2-model-gate__link:hover,
.dark-theme .v2-model-gate__link:hover {
  color: #0a9bea !important;
}

/* =========================================================================
   Highcharts fullscreen: override browser default black background
   The :fullscreen pseudo-class targets the element passed to requestFullscreen().
   Highcharts v10 fullscreens chart.renderTo (a .highcharts-container parent).
   ========================================================================= */
.v2-sp :fullscreen {
  background: #ffffff !important;
}

.v2-sp :-webkit-full-screen {
  background: #ffffff !important;
}

.dark-theme .v2-sp :fullscreen {
  background: #111520 !important;
}

.dark-theme .v2-sp :-webkit-full-screen {
  background: #111520 !important;
}

/* =========================================================================
   Icon button (download, etc.)
   ========================================================================= */
.v2-sp__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--v2-border, #e5e7eb);
  border-radius: 6px;
  background: transparent;
  color: var(--v2-text-muted, #64748b);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.v2-sp__icon-btn:hover {
  background: var(--v2-surface-alt, #f1f5f9);
  color: var(--v2-accent, #0964A0);
  border-color: var(--v2-accent, #0964A0);
}

.dark-theme .v2-sp__icon-btn {
  border-color: var(--v2-border, #2d3748);
  color: var(--v2-text-muted, #9CA3AF);
}

.dark-theme .v2-sp__icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--v2-accent, #38BDF8);
  border-color: var(--v2-accent, #38BDF8);
}

/* =========================================================================
   Highcharts "View Data Table" formatting (V2)
   ========================================================================= */
.v2-sp .highcharts-data-table table {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  border-collapse: collapse;
  border: 1px solid var(--v2-border, #e5e7eb);
  margin: 12px auto;
  text-align: right;
  width: 100%;
  max-width: 100%;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.v2-sp .highcharts-data-table caption {
  padding: 10px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--v2-text, #1e293b);
  text-align: left;
}

.v2-sp .highcharts-data-table th {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--v2-text-muted, #64748b);
  padding: 8px 12px;
  border-bottom: 2px solid var(--v2-border, #e5e7eb);
  background: var(--v2-surface-alt, #f8fafc);
  white-space: nowrap;
}

.v2-sp .highcharts-data-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--v2-border, #f1f5f9);
  color: var(--v2-text, #334155);
  font-size: 12px;
}

.v2-sp .highcharts-data-table td:first-child,
.v2-sp .highcharts-data-table th:first-child {
  text-align: left;
  font-weight: 500;
}

.v2-sp .highcharts-data-table tbody tr:nth-child(even) {
  background: var(--v2-surface-alt, #f8fafc);
}

.v2-sp .highcharts-data-table tbody tr:hover {
  background: rgba(9, 100, 160, 0.06);
}

.dark-theme .v2-sp .highcharts-data-table table {
  border-color: var(--v2-border, #2d3748);
}

.dark-theme .v2-sp .highcharts-data-table th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--v2-text-muted, #9CA3AF);
  border-bottom-color: var(--v2-border, #2d3748);
}

.dark-theme .v2-sp .highcharts-data-table td {
  color: var(--v2-text, #e6e9f0);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

.dark-theme .v2-sp .highcharts-data-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

.dark-theme .v2-sp .highcharts-data-table tbody tr:hover {
  background: rgba(9, 100, 160, 0.12);
}

/* ============================================================================
   GLOBAL HIGHCHARTS DARK MODE
   ----------------------------------------------------------------------------
   Any Highcharts chart rendered anywhere in the V2 app picks up these rules
   when `html.dark-theme` is active. These replace the per-container overrides
   (`.v2-sp .highcharts-*`, `.v2-proposal-container .highcharts-*`, etc.) that
   were scattered through individual page stylesheets and left many charts
   un-themed (see: perf chart tooltip, relative/rolling return tooltips,
   shares-outstanding chart on History, beta tracker, econ dashboards, filer
   profile, issuer channel dashboard, etc.).

   Strategy:
   - All Highcharts SVG text/grid/axis colors go through `fill` / `stroke`,
     not `color`. Inline styles set by Highcharts from JS options use `fill`
     on text nodes, so `!important` here wins over the JS theme without
     chart.update() being required.
   - Scoped under `html.dark-theme` so this can never affect light-mode.
   - Per-page overrides (e.g. .v2-sp-stock specific layouts) still win
     because they come later in the cascade or have tighter specificity.
   ============================================================================ */
html.dark-theme .highcharts-background {
  fill: transparent;
}
html.dark-theme .highcharts-plot-background,
html.dark-theme .highcharts-plot-border {
  fill: transparent;
  stroke: transparent;
}
html.dark-theme .highcharts-title,
html.dark-theme .highcharts-subtitle {
  fill: #e6e9f0 !important;
}
html.dark-theme .highcharts-axis-title,
html.dark-theme .highcharts-axis-labels text {
  fill: #8b92a5 !important;
}
html.dark-theme .highcharts-axis-line {
  stroke: #2d3748 !important;
}
html.dark-theme .highcharts-grid-line,
html.dark-theme .highcharts-tick {
  stroke: #1e2433 !important;
}
html.dark-theme .highcharts-minor-grid-line {
  stroke: #141923 !important;
}
html.dark-theme .highcharts-legend-item text {
  fill: #cdd1dc !important;
}
html.dark-theme .highcharts-legend-item:hover text {
  fill: #e6e9f0 !important;
}

/* Tooltip — covers every variant Highcharts renders:
     (a) Classic single SVG tooltip: <g class="highcharts-tooltip"> with a
         <rect class="highcharts-label-box highcharts-tooltip-box">
     (b) Split stock tooltip: each series gets its own <g class="highcharts-label
         highcharts-tooltip-box highcharts-color-N"> with a nested callout
         <path class="highcharts-label-box highcharts-tooltip-box">
     (c) useHTML tooltip: a <span class="highcharts-label highcharts-tooltip">
         inside an SVG foreignObject (or a body-level <div class=
         "highcharts-tooltip-container"> when `outside: true`).

   We blanket-target (a) rect, (b) path, and the shared class names, and use
   `body.dark-theme` to bump specificity above the existing
   `.v2-sp .highcharts-tooltip-box` rule so the match-all ruleset wins
   regardless of container. No fill-opacity — the prior value was bleeding
   background color through in some browsers. */
html.dark-theme .highcharts-tooltip-box,
html.dark-theme .highcharts-label.highcharts-tooltip-box,
html.dark-theme .highcharts-tooltip .highcharts-label-box,
html.dark-theme .highcharts-tooltip rect,
html.dark-theme .highcharts-tooltip path,
html.dark-theme .highcharts-tooltip-header rect,
html.dark-theme .highcharts-tooltip-header path,
html.dark-theme body.dark-theme .highcharts-tooltip-box,
html.dark-theme body.dark-theme .highcharts-label.highcharts-tooltip-box .highcharts-label-box {
  fill: #161b26 !important;
  stroke: #2d3748 !important;
}

/* Text inside SVG tooltips — every variant Highcharts spits out
   uses either a <text> with <tspan> children, or a standalone <tspan>.
   The `:not([style*="fill"])` below is important: the pointFormat series
   swatch is `<span style="color:{series.color}">●</span>` which Highcharts
   converts to `<tspan style="fill:{series.color}">…</tspan>`. We want to
   preserve that per-series bullet color while lifting every other tspan
   (series name, bold value, colons, etc.) to the neutral light color. */
html.dark-theme .highcharts-tooltip text,
html.dark-theme .highcharts-tooltip tspan:not([style*="fill"]),
html.dark-theme .highcharts-label.highcharts-tooltip-box text,
html.dark-theme .highcharts-label.highcharts-tooltip-box tspan:not([style*="fill"]),
html.dark-theme .highcharts-tooltip-header text,
html.dark-theme .highcharts-tooltip-header tspan:not([style*="fill"]),
html.dark-theme body.dark-theme .highcharts-tooltip text,
html.dark-theme body.dark-theme .highcharts-tooltip tspan:not([style*="fill"]) {
  fill: #e6e9f0 !important;
  color: #e6e9f0 !important;
}

/* In split stock tooltips each series-label is a <g class="highcharts-label
   highcharts-tooltip-box highcharts-color-N">. In non-styled mode Highcharts
   applies `fill={series.color}` to the inner `<text>` element so the whole
   line inherits the series color (that's what makes the `<span>{name}</span>`
   look muted/tinted in the screenshot). Force the text's own fill to neutral;
   the colored bullet `<tspan style="fill:...">` is excluded by
   `text:not([style*="fill"])` above and keeps its per-series color. */
html.dark-theme .highcharts-label.highcharts-tooltip-box > text,
html.dark-theme .highcharts-tooltip [class*="highcharts-color-"] > text,
html.dark-theme .highcharts-tooltip [class*="highcharts-color-"] text {
  fill: #e6e9f0 !important;
}

/* useHTML tooltips — the actual element is a <span class="highcharts-tooltip">
   (NOT a div) holding the pointFormat HTML. When `outside: true` it lives in
   a body-level div.highcharts-tooltip-container. Target both and override
   any inline `style="color: #333"` Highcharts applies from the JS theme. */
html.dark-theme span.highcharts-tooltip,
html.dark-theme div.highcharts-tooltip,
html.dark-theme .highcharts-tooltip-container,
html.dark-theme .highcharts-tooltip-container > .highcharts-tooltip,
html.dark-theme .highcharts-tooltip-container span,
html.dark-theme .highcharts-tooltip-container div {
  color: #e6e9f0 !important;
  background: #161b26 !important;
  border-color: #2d3748 !important;
}

/* HTML content rendered inside a useHTML tooltip — b/strong/em and plain
   spans that inherit `color` from a parent we couldn't style (e.g. an
   inline `style="color: #000"` that chart code applies to wrap values). */
html.dark-theme .highcharts-tooltip b,
html.dark-theme .highcharts-tooltip strong,
html.dark-theme .highcharts-tooltip em,
html.dark-theme .highcharts-tooltip-container b,
html.dark-theme .highcharts-tooltip-container strong,
html.dark-theme .highcharts-tooltip-container em {
  color: #ffffff !important;
}

/* Series-color spans inside pointFormat use `<span style="color:{series.color}">`.
   Those inline colors are the series palette (e.g. the bullet swatch) and
   we want to preserve them, so the `:not([style*="color"])` selector below
   excludes them and only lifts plain text / unstyled wrappers to the
   light neutral. */
html.dark-theme .highcharts-tooltip-container > *:not([style*="color"]),
html.dark-theme .highcharts-tooltip-container *:not([style*="color"]) {
  color: #e6e9f0 !important;
}

/* Range selector (Stock charts: 1M / 3M / YTD / 1Y / All buttons + date
   inputs). Default Highcharts styling is tuned for light backgrounds so in
   dark mode the input text and label colors need overriding. */
html.dark-theme .highcharts-range-selector-buttons text,
html.dark-theme .highcharts-range-label {
  fill: #cdd1dc !important;
}
html.dark-theme .highcharts-range-selector-buttons .highcharts-button-box {
  fill: #1a1f2b !important;
  stroke: #2d3748 !important;
}
html.dark-theme .highcharts-range-selector-buttons .highcharts-button-hover .highcharts-button-box {
  fill: #252d3d !important;
}
html.dark-theme .highcharts-range-selector-buttons .highcharts-button-pressed .highcharts-button-box {
  fill: #0964A0 !important;
  stroke: #0964A0 !important;
}
html.dark-theme .highcharts-range-selector-buttons .highcharts-button-pressed text {
  fill: #ffffff !important;
}
/* Stock chart date range inputs (above the chart) */
html.dark-theme input.highcharts-range-selector {
  background: #1a1f2b !important;
  color: #e6e9f0 !important;
  border-color: #2d3748 !important;
}

/* Navigator (mini-chart below Stock charts) */
html.dark-theme .highcharts-navigator-mask-inside {
  fill: rgba(13, 124, 196, 0.15) !important;
}
html.dark-theme .highcharts-navigator-outline {
  stroke: #2d3748 !important;
}
html.dark-theme .highcharts-navigator-handle {
  fill: #252d3d !important;
  stroke: #3a4559 !important;
}
html.dark-theme .highcharts-navigator-xaxis .highcharts-axis-line {
  stroke: #1e2433 !important;
}

/* Data labels baked into columns / bars */
html.dark-theme .highcharts-data-label text,
html.dark-theme .highcharts-data-label tspan {
  fill: #e6e9f0 !important;
}
html.dark-theme .highcharts-data-label-connector {
  stroke: #3a4559 !important;
}

/* Crosshair on hover */
html.dark-theme .highcharts-crosshair {
  stroke: #3a4559 !important;
}

/* Crosshair x-axis date label (Highcharts Stock — the pill that tracks the
   cursor and shows the current date under the plot). Default fill is a
   bright amber/yellow with near-black text which is unreadable in dark mode,
   so swap to the same treatment as the tooltip box. */
html.dark-theme .highcharts-crosshair-label rect,
html.dark-theme .highcharts-crosshair-label path,
html.dark-theme .highcharts-crosshair-label .highcharts-label-box {
  fill: #1a1f2b !important;
  stroke: #2d3748 !important;
}
html.dark-theme .highcharts-crosshair-label text,
html.dark-theme .highcharts-crosshair-label tspan {
  fill: #e6e9f0 !important;
  color: #e6e9f0 !important;
}

/* No-data label */
html.dark-theme .highcharts-no-data text {
  fill: #8b92a5 !important;
}

/* ============================================================================
   GLOBAL DARK MODE — FORMS & INPUTS
   ----------------------------------------------------------------------------
   Native HTML form controls (`<input>`, `<select>`, `<textarea>`) default to
   the OS light theme and leave white backgrounds / black text in dark mode
   unless each page overrides. These rules catch every unstyled input across
   the V2 app in one pass. Components that set explicit `background`/`color`
   via inline style or higher-specificity CSS still win (we only apply the
   dark palette to controls that are using defaults).
   ============================================================================ */

/* Native date/datetime/time inputs — covers model builder start-date,
   admin range filters, chart lab zoom picker, issuer HQ campaign wizard,
   stock distribution dates, etc. */
html.dark-theme input[type="date"],
html.dark-theme input[type="datetime-local"],
html.dark-theme input[type="time"],
html.dark-theme input[type="month"],
html.dark-theme input[type="week"] {
  background-color: #1a1f2b !important;
  color: #e6e9f0 !important;
  border-color: #2d3748 !important;
  color-scheme: dark;
}

/* Native picker-indicator button inside date inputs — the default black
   calendar glyph is invisible on a dark background. `color-scheme: dark`
   above already handles most browsers, this is the Chromium fallback. */
html.dark-theme input[type="date"]::-webkit-calendar-picker-indicator,
html.dark-theme input[type="datetime-local"]::-webkit-calendar-picker-indicator,
html.dark-theme input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(0.85) brightness(1.1);
  cursor: pointer;
}

/* Tell the UA to render the rest of the page's native widgets
   (scrollbars, dropdown menus) using a dark palette too. */
html.dark-theme {
  color-scheme: dark;
}

/* ============================================================================
   GLOBAL DARK MODE — WATCHLIST PANEL (13F, RIA, databases)
   ----------------------------------------------------------------------------
   The watchlist panel lives in `app-shell.css` with hard-coded light colors
   (white bg, #111827 text). Overlay dark mode here so every consumer picks
   it up without editing app-shell. Mirrors the existing .v2-sp card treatment.
   ============================================================================ */
html.dark-theme .v2-wl-panel__title,
html.dark-theme .v2-wl-detail__name,
html.dark-theme .v2-wl-card__name {
  color: #e6e9f0 !important;
}
html.dark-theme .v2-wl-panel__title i,
html.dark-theme .v2-wl-panel__close,
html.dark-theme .v2-wl-card__meta,
html.dark-theme .v2-wl-detail__status,
html.dark-theme .v2-wl-panel__empty,
html.dark-theme .v2-wl-sidebar__empty,
html.dark-theme .v2-wl-sidebar__empty p,
html.dark-theme .v2-wl-sidebar__empty span {
  color: #8b92a5 !important;
}
html.dark-theme .v2-wl-panel__header {
  background: #111520 !important;
  border-color: #1e2433 !important;
}
html.dark-theme .v2-wl-panel__sidebar {
  background: #0f131c !important;
  border-color: #1e2433 !important;
}
html.dark-theme .v2-wl-detail__header {
  border-color: #1e2433 !important;
}
html.dark-theme .v2-wl-card:hover {
  background: rgba(255, 255, 255, 0.04) !important;
}
html.dark-theme .v2-wl-card--active {
  background: rgba(9, 100, 160, 0.18) !important;
  border-color: rgba(9, 100, 160, 0.4) !important;
}
html.dark-theme .v2-wl-card--active:hover {
  background: rgba(9, 100, 160, 0.24) !important;
}
html.dark-theme .v2-wl-panel__close:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  color: #e6e9f0 !important;
}
html.dark-theme .v2-wl-card__btn {
  color: #8b92a5 !important;
}
html.dark-theme .v2-wl-card__btn:hover {
  background: rgba(255, 255, 255, 0.06) !important;
  color: #e6e9f0 !important;
}
html.dark-theme .v2-wl-panel__actions .v2-btn-sm {
  background: #1a1f2b !important;
  color: #cdd1dc !important;
  border-color: #2d3748 !important;
}
html.dark-theme .v2-wl-panel__actions .v2-btn-sm:hover {
  background: #252d3d !important;
  border-color: #3a4559 !important;
}

/* Watchlist import modal (v2-wl-import-modal) body contents — the modal
   outer chrome is handled by .v2-modal-overlay / .v2-modal-content which
   already use the --bg-elev / --text CSS vars, but the inner import form
   sets raw light colors inline that need lifting. */
html.dark-theme #v2-wl-import-modal .v2-modal-content,
html.dark-theme #v2-wl-import-modal textarea,
html.dark-theme #v2-wl-import-modal input[type="text"] {
  background: #111520 !important;
  color: #e6e9f0 !important;
  border-color: #2d3748 !important;
}

/* Quick Tickers upload modal (v2-qt-import-modal) — same shape as the
   watchlist import modal above, used by the Quick Tickers Upload button
   on the V2 ETF/MF/CEF databases. Inline light colors in explorerPageV2's
   modal markup get lifted here for dark mode. */
html.dark-theme #v2-qt-import-modal .v2-modal-content,
html.dark-theme #v2-qt-import-modal textarea,
html.dark-theme #v2-qt-import-modal input[type="text"] {
  background: #111520 !important;
  color: #e6e9f0 !important;
  border-color: #2d3748 !important;
}

/* ============================================================================
   GLOBAL DARK MODE — LOADING SCREENS
   ----------------------------------------------------------------------------
   Pages render loading spinners inline via `container.innerHTML = ...` with
   white backgrounds and dark text. Affects issuer-channel (all tabs),
   visualizer, and any page built off the same pattern.
   ============================================================================ */
html.dark-theme .v2-sp__loading,
html.dark-theme .v2-loading-screen,
html.dark-theme .ic-loading,
html.dark-theme .v2-dashboard-loading,
html.dark-theme [data-role="loading-screen"] {
  background: #0b0e13 !important;
  color: #8b92a5 !important;
}

/* Any inline spinner wrapper that uses the common flex pattern — matches
   the structures in securityProfilePageV2 / modelProfilePageV2 / issuer
   channel ("<div style='display:flex;...;color:#9CA3AF'>Loading…</div>"). */
html.dark-theme .v2-card__body > div[style*="Loading"],
html.dark-theme .v2-card__body > div[style*="loading"] {
  color: #8b92a5 !important;
}

/* ============================================================================
   GLOBAL DARK MODE — MISCELLANEOUS PAGE COMPONENTS
   ============================================================================ */

/* Model profile perf table — `.mp-perf-row--bench` and cell sticky columns
   hard-code a pale grey (#fafbfc) that bleeds through as bright white in
   dark mode. Swap the sticky backgrounds and bench-row highlight. */
html.dark-theme .mp-perf-row--bench,
html.dark-theme .mp-perf-row--bench .mp-perf-cell--name {
  background: #151a24 !important;
}
html.dark-theme .mp-perf-th--name,
html.dark-theme .mp-perf-cell--name {
  background: var(--v2-bg-surface, #111520) !important;
}
html.dark-theme .mp-perf-th {
  color: #8b92a5 !important;
  border-bottom-color: #1e2433 !important;
}
html.dark-theme .mp-perf-row {
  border-bottom-color: #161b26 !important;
}

/* ---------------------------------------------------------------------------
   Model profile — Performance tab "underlying holdings" & Fundamentals audit
   tables. Both are rendered with inline `<tr style="background:#fff">` /
   `#f8fafc` stripes and `<th style="color:#475569">` text in JS
   (modelProfilePageV2.js). Inline styles win over normal CSS, so we use
   !important overrides scoped to dark mode.
   - `.mp-perf-table tbody tr` covers the Performance > Underlying Holdings
     table (line ~1799, `<table class="mp-perf-table">`).
   - `#mp-fund-grid-content table` covers the Fundamentals audit table
     (line ~2863, `<div id="mp-fund-grid-content">`).
   --------------------------------------------------------------------------- */
html.dark-theme .mp-perf-table thead tr,
html.dark-theme .mp-perf-table tbody tr,
html.dark-theme #mp-fund-grid-content table thead tr,
html.dark-theme #mp-fund-grid-content table tbody tr {
  background: transparent !important;
}
html.dark-theme .mp-perf-table tbody tr:nth-child(even),
html.dark-theme #mp-fund-grid-content table tbody tr:nth-child(even) {
  background: #151a24 !important;
}
html.dark-theme .mp-perf-table thead tr,
html.dark-theme #mp-fund-grid-content table thead tr {
  background: #161b26 !important;
  border-bottom-color: #1e2433 !important;
}
html.dark-theme .mp-perf-table thead th,
html.dark-theme #mp-fund-grid-content table thead th {
  color: #8b92a5 !important;
  background: #161b26 !important;
  border-bottom-color: #1e2433 !important;
}
html.dark-theme .mp-perf-table tbody td,
html.dark-theme #mp-fund-grid-content table tbody td {
  color: #c4c9d4 !important;
  border-bottom-color: #252d3d !important;
}
/* Ticker links inside these rows pick up the dark-text default; keep them
   on the v2 primary so they remain visibly clickable. */
html.dark-theme .mp-perf-table tbody td a,
html.dark-theme #mp-fund-grid-content table tbody td a,
html.dark-theme .mp-fund-grid-link {
  color: var(--v2-primary, #8b9cff) !important;
}

/* Indicator picker row hover / active colours on the security profile
   technicals tab (inlined light blues that wash out in dark mode). */
html.dark-theme .v2-sp__ind-row:hover {
  background: rgba(255, 255, 255, 0.04) !important;
}
html.dark-theme .v2-sp__ind-row.is-active {
  background: rgba(9, 100, 160, 0.18) !important;
}

/* Compare tool top launch-in toolbar: the hover state uses hard-coded
   light indigo (#EEF2FF / #A5B4FC / #4338CA) which becomes neon against
   the dark panel. Tone it down to the accent palette. */
html.dark-theme .v2-ct__toolbar-btn:hover:not(:disabled) {
  background: rgba(13, 124, 196, 0.18) !important;
  border-color: #0d7cc4 !important;
  color: #e6e9f0 !important;
}
html.dark-theme .v2-ct__toolbar-btn i {
  color: #8b9cff !important;
}

/* Chart Lab team-item pickers in Save panel use inline light borders
   (#f1f5f9 / #f8fafc). Soften to the dark border. */
html.dark-theme .cb-scp__team-item {
  border-bottom-color: #1e2433 !important;
}
html.dark-theme .cb-scp__team-item:hover {
  background: rgba(255, 255, 255, 0.04) !important;
}

/* Share-save popover: close-btn hover is light red on white. Keep the red
   accent but swap the hover bg to a dark-mode-appropriate tint. */
html.dark-theme .cb-share-save-popover__close:hover {
  background: rgba(220, 38, 38, 0.16) !important;
  color: #fca5a5 !important;
}

/* Profile pages (access-sharing, account, branding, billing, notifications):
   the page-level `<h1>` tags don't inherit a colour and fall to the browser
   default black. These are plain headings with no classes beyond the icon,
   so we scope by the containing panel to avoid hitting global h1s. */
html.dark-theme #v2-access-sharing h1,
html.dark-theme #v2-account h1,
html.dark-theme #v2-branding h1,
html.dark-theme #v2-billing h1,
html.dark-theme #v2-notifications h1 {
  color: #e6e9f0 !important;
}
html.dark-theme .v2-profile-info-value,
html.dark-theme .v2-profile-mono {
  color: #e6e9f0 !important;
}
html.dark-theme .v2-sub-card-btn--outline {
  background: transparent !important;
  color: #e6e9f0 !important;
  border-color: #2d3748 !important;
}
html.dark-theme .v2-sub-card-btn--outline:hover {
  background: rgba(255, 255, 255, 0.05) !important;
}
html.dark-theme .v2-sub-card-btn[disabled],
html.dark-theme .v2-sub-card-btn[disabled]:hover {
  background: transparent !important;
  color: #8b92a5 !important;
  border-color: #2d3748 !important;
  opacity: 0.55 !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
}

/* HQ Manager issuer kits — `.v2-card__body` inside the kits tab has an
   inherited light background when it lives inside a white parent panel.
   This is covered by v2-card defaults, but the kit-specific wrapper
   occasionally gets nested inside a non-v2-card div. */
html.dark-theme #v2-hq-manager .v2-card__body,
html.dark-theme #v2-hq-manager .v2-card,
html.dark-theme #v2-hq-manager .v2-card-body {
  background: var(--v2-bg-surface, #111520) !important;
  color: #e6e9f0 !important;
}

/* ETF universe cards — explicit class-level overrides in case the cascade
   for --v2-bg-primary hasn't reached the card bg. Also covers the big
   AUM stat which currently reads in a muted-text colour against a white bg. */
html.dark-theme .eu-card {
  background: var(--v2-bg-surface, #111520) !important;
  border-color: #1e2433 !important;
}
html.dark-theme .eu-card-header {
  background: #151a24 !important;
  border-bottom-color: #1e2433 !important;
}
html.dark-theme .eu-stat-aum,
html.dark-theme .eu-card-title,
html.dark-theme .eu-page-title {
  color: #e6e9f0 !important;
}

/* ============================================================================
   GLOBAL DARK MODE — BUGBOT / AG-GRID CONTAINER BG
   ----------------------------------------------------------------------------
   Some AG-Grid parent wrappers use a raw `background: #fff` on the
   `.ag-center-cols-container` (pinned-left parent) which renders over the
   dark theme's row-level background and flashes white on scroll. Force the
   container to the theme bg so the row + cell colours show through.
   ============================================================================ */
html.dark-theme .ag-theme-balham .ag-center-cols-container,
html.dark-theme .ag-theme-balham .ag-pinned-left-cols-container,
html.dark-theme .ag-theme-balham .ag-pinned-right-cols-container,
html.dark-theme .ag-theme-alpine .ag-center-cols-container,
html.dark-theme .ag-theme-alpine .ag-pinned-left-cols-container,
html.dark-theme .ag-theme-alpine .ag-pinned-right-cols-container {
  background: var(--v2-bg-surface, #111520) !important;
}

/* Issuer channel "Choose a Screen" / "My Screens" dropdown menus. These
   are injected via inline HTML and the option rows only set padding /
   cursor — they inherit text colour from the (dark) menu background,
   leaving them invisible. Force the text colour explicitly and add a
   hover affordance that works in both themes. */
.ic-view-option {
  color: var(--v2-text-primary, #212529);
}
.ic-view-option:hover {
  background: var(--v2-bg-hover, #f1f3f4);
}
html.dark-theme .ic-view-option {
  color: #e6e9f0 !important;
  border-bottom-color: #1e2433 !important;
}
html.dark-theme .ic-view-option:hover {
  background: rgba(255, 255, 255, 0.05) !important;
}

/* Chart Lab "Choose a Team Channel" save-panel items follow the same
   pattern — inline padding/border/cursor only. Fix the same way. */
html.dark-theme .cb-scp__team-item {
  color: #e6e9f0 !important;
}

