/**
 * Shared Sidebar Styles
 * Include this file in all pages that have a sidebar
 */

/* ===== Control Panel Menu Bar - High-Tech Ribbon ===== */
/* Ribbon is always visible at the top */
.control-panel-menubar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width, 314px);
    right: 0;
    background: #111113;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    /* Clip horizontal overflow (the sliding ribbon content) without
       creating a scroll container for vertical flyouts. Dropdowns
       re-anchor themselves with position:fixed via JS so they escape
       this clip entirely. */
    overflow: clip visible;
}

/* Ribbon Tabs Bar */
.ribbon-tabs {
    display: flex;
    align-items: center;
    height: 42px;
    padding: 0 12px;
    background: #0c0c0e;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    gap: 2px;
}

/* Spacer to push persistent buttons to the right */
.ribbon-tabs-spacer {
    flex: 1;
}

/* Persistent buttons in ribbon tabs */
.ribbon-persistent-btn {
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.ribbon-persistent-btn:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
}

.ribbon-persistent-btn.primary {
    color: #c9a962;
    border-color: rgba(201, 169, 98, 0.4);
    background: rgba(201, 169, 98, 0.1);
}

.ribbon-persistent-btn.primary:hover {
    background: rgba(201, 169, 98, 0.2);
    border-color: rgba(201, 169, 98, 0.6);
}

.ribbon-tab {
    padding: 8px 20px;
    background: transparent;
    border: none;
    border-radius: 3px 3px 0 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.4);
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
}

.ribbon-tab:hover {
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.03);
}

.ribbon-tab.active {
    color: #e2c87d;
    background: #111113;
    border: none;
    border-bottom: none;
    margin-bottom: -1px;
}

/* Crisp accent glow line under active tab */
.ribbon-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    right: 20%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #c9a962, transparent);
    border-radius: 1px;
    box-shadow: 0 0 8px rgba(201, 169, 98, 0.5);
}

/* Legal links — recessed, minimal */
.ribbon-legal-links {
    display: flex;
    gap: 4px;
    align-items: center;
}

.ribbon-legal-link {
    padding: 4px 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.65rem;
    letter-spacing: 0.03em;
    color: rgba(255, 255, 255, 0.2);
    transition: color 0.15s ease;
    white-space: nowrap;
}

.ribbon-legal-link:hover {
    color: rgba(255, 255, 255, 0.5);
}

/* Ribbon Panel */
.ribbon-panel {
    padding: 6px 12px;
    height: 80px;
    overflow: visible;
    scrollbar-width: none;
    -ms-overflow-style: none;
    position: relative;
    background: linear-gradient(180deg, #111113 0%, #0e0e10 100%);
    contain: layout;
}

.ribbon-panel::-webkit-scrollbar {
    display: none;
}

/* Viewport wrapper between the clipped menubar and the transformed
   ribbon-content. Lets dropdowns measure a clean anchor box while
   the translated content slides underneath. */
.ribbon-viewport {
    position: relative;
    height: 100%;
    overflow: visible;
}

/* Ribbon scroll arrows — chevrons pinned to the panel edges. Only
   rendered when the active tab's ribbon content is wider than the
   viewport; JS toggles .visible. */
.ribbon-scroll-arrow {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 56px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    background: rgba(17, 17, 19, 0.92);
    color: rgba(255, 255, 255, 0.55);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    user-select: none;
}

.ribbon-scroll-arrow.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ribbon-scroll-arrow:hover {
    color: #e2c87d;
    border-color: rgba(201, 169, 98, 0.5);
    background: rgba(17, 17, 19, 0.98);
}

.ribbon-scroll-arrow.left { left: 4px; }
.ribbon-scroll-arrow.right { right: 4px; }

/* Edge fade so users see there's more ribbon off-screen — only when
   the corresponding arrow is visible. */
.ribbon-panel::before,
.ribbon-panel::after {
    content: '';
    position: absolute;
    top: 6px;
    bottom: 6px;
    width: 36px;
    pointer-events: none;
    z-index: 40;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.ribbon-panel::before {
    left: 0;
    background: linear-gradient(90deg, #111113 0%, rgba(17,17,19,0) 100%);
}
.ribbon-panel::after {
    right: 0;
    background: linear-gradient(270deg, #111113 0%, rgba(17,17,19,0) 100%);
}
.ribbon-panel.fade-left::before { opacity: 1; }
.ribbon-panel.fade-right::after { opacity: 1; }

.ribbon-content {
    display: none;
    align-items: flex-start;
    gap: 4px;
    height: 100%;
    overflow: visible;
    width: max-content;
    transition: transform 0.25s ease;
    will-change: transform;
}

.ribbon-content.active {
    display: flex;
}

/* Ribbon Groups */
.ribbon-group {
    display: flex;
    flex-direction: column;
    padding: 0 4px;
    min-width: 0;
}

.ribbon-group-title {
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.35);
    text-align: center;
    padding-bottom: 3px;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    white-space: nowrap;
}

.ribbon-items {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.ribbon-separator {
    width: 1px;
    height: 60px;
    background: linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.08) 30%, rgba(255,255,255,0.08) 70%, transparent 100%);
    margin: 4px 10px;
    flex-shrink: 0;
}

/* Strategy Sections - Compact, no auto-expand */
.ribbon-strategy-section {
    flex: 0 0 auto;
    min-width: auto;
    max-width: none;
    display: flex;
    justify-content: flex-start;
}

/* Execution Tab - Compact sizing, no auto-expand */
#ribbon-execution .ribbon-group {
    flex: 0 0 auto;
    min-width: 80px;
}

/* Narrow groups - Indicator Trading, ML Trading, Portfolio */
.ribbon-group-narrow {
    flex: 0 0 auto !important;
    min-width: 80px !important;
    max-width: 100px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
}

/* Center the group title text in narrow groups */
.ribbon-group-narrow .ribbon-group-title {
    text-align: center !important;
    width: 100% !important;
}

/* Center the ribbon-items in narrow groups */
.ribbon-group-narrow .ribbon-items {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    height: 100% !important;
    width: 100% !important;
}

/* Center the ribbon-item itself */
.ribbon-group-narrow .ribbon-item {
    padding: 6px 8px;
    min-width: 60px;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
}

.ribbon-group-narrow .ribbon-item-icon {
    width: 24px;
    height: 24px;
}

.ribbon-group-narrow .ribbon-item-label {
    font-size: 0.6rem;
    text-align: center !important;
}

#ribbon-execution .ribbon-group-title {
    min-width: 60px;
    font-size: 0.55rem;
}

/* Trained Models group - wider title underline */
.ribbon-group-trained-models .ribbon-group-title {
    min-width: 180px;
}

/* ML Strategies tab - wider buttons for full text */
#ribbon-ml .ribbon-item {
    min-width: 80px;
    max-width: 110px;
}

#ribbon-ml .ribbon-item-label {
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
}

/* Dropdown Menu Component */
.ribbon-dropdown {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ribbon-dropdown-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    min-width: 54px;
    gap: 2px;
}

.ribbon-dropdown-btn span {
    font-size: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.ribbon-dropdown-btn .dropdown-arrow {
    width: 10px;
    height: 10px;
    color: var(--text-tertiary);
    transition: transform 0.2s ease;
}

.ribbon-dropdown-btn:hover {
    background: rgba(201, 169, 98, 0.1);
    border-color: rgba(201, 169, 98, 0.3);
}

.ribbon-dropdown-btn:hover span {
    color: var(--text-primary);
}

.ribbon-dropdown.disabled .ribbon-dropdown-btn {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Dropdown Content */
.ribbon-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    min-width: 120px;
    padding: 6px 0;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-top: 4px;
}

.ribbon-dropdown:hover .ribbon-dropdown-content {
    display: block;
}

.ribbon-dropdown:hover .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-section-title {
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    padding: 6px 12px 4px;
    border-top: 1px solid var(--border-primary);
    margin-top: 4px;
}

.dropdown-section-title:first-child {
    border-top: none;
    margin-top: 0;
}

.dropdown-item {
    display: block;
    padding: 6px 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.15s ease;
}

.dropdown-item:hover {
    background: rgba(201, 169, 98, 0.1);
    color: var(--text-primary);
}

/* Ribbon Items */
.ribbon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.18s ease;
    text-decoration: none;
    min-width: 72px;
    max-width: 96px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.ribbon-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.14);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.ribbon-item.active-module {
    background: rgba(63, 185, 80, 0.12);
    border-color: rgba(63, 185, 80, 0.5);
    box-shadow: 0 0 12px rgba(63, 185, 80, 0.35), 0 0 4px rgba(63, 185, 80, 0.2);
}

.ribbon-item.active-module .ribbon-item-label {
    color: #3fb950;
    font-weight: 600;
}

.ribbon-item.active-module .ribbon-item-icon {
    color: #3fb950;
}

.ribbon-item.featured {
    background: rgba(201, 169, 98, 0.06);
    border: 1px solid rgba(201, 169, 98, 0.12);
}

.ribbon-item.featured:hover {
    border-color: rgba(201, 169, 98, 0.35);
    background: rgba(201, 169, 98, 0.1);
    box-shadow: 0 2px 10px rgba(201, 169, 98, 0.12);
}

.ribbon-item-icon {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(201, 169, 98, 0.12);
    border-radius: 5px;
    color: #dbb864;
    margin-bottom: 2px;
    transition: all 0.18s ease;
}

.ribbon-item:hover .ribbon-item-icon {
    filter: brightness(1.2);
}

.ribbon-item-icon svg {
    width: 15px;
    height: 15px;
}

/* --- Crisp icon color palette --- */
.ribbon-item-icon.teal {
    background: rgba(34, 211, 238, 0.12);
    color: #22d3ee;
}

.ribbon-item-icon.purple {
    background: rgba(168, 85, 247, 0.14);
    color: #c084fc;
}

/* ML Strategy specific */
#ribbon-ml .ribbon-item-icon.purple {
    background: rgba(168, 85, 247, 0.16);
    color: #d4a0ff;
}

#ribbon-ml .ribbon-item-icon.purple-alt {
    background: rgba(236, 72, 153, 0.16);
    color: #f9a8d4;
}

.ribbon-item-icon.blue {
    background: rgba(96, 165, 250, 0.14);
    color: #93bbfd;
}

.ribbon-item-icon.green {
    background: rgba(74, 222, 128, 0.14);
    color: #4ade80;
}

.ribbon-item-icon.orange {
    background: rgba(251, 191, 36, 0.14);
    color: #fbbf24;
}

.ribbon-item-icon.red {
    background: rgba(248, 113, 113, 0.14);
    color: #f87171;
}

/* Compact ribbon group — 30% smaller items (Research Units etc.) */
.ribbon-group-compact .ribbon-items {
    gap: 3px;
}

.ribbon-group-compact .ribbon-item {
    min-width: 50px;
    max-width: 67px;
    padding: 2px 5px;
}

.ribbon-group-compact .ribbon-item-icon {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    margin-bottom: 1px;
}

.ribbon-group-compact .ribbon-item-icon svg {
    width: 10px;
    height: 10px;
}

.ribbon-group-compact .ribbon-item-label {
    font-size: 0.55rem;
}

/* Library items styling */
.library-items {
    flex-wrap: wrap;
    max-width: 200px;
}

/* Factor-config library row (FM099 Direct Portfolio + Asset Pool chips).
   Keep the chips on a SINGLE inline row so the ▼ overflow trigger
   remains next to them — wrapping onto a second row pushes the
   trigger down the page and the fixed-position menu anchors to the
   wrong spot. The chip labels were shortened to just the size
   (e.g. "(100)") so two fit comfortably in the ribbon width. */
#ribbon-fund-factor-configs {
    flex-wrap: nowrap;
    overflow: visible;
}
#ribbon-fund-factor-configs .saved-portfolios-container {
    flex-wrap: nowrap;
}
#ribbon-fund-factor-configs .saved-portfolios-items {
    flex-wrap: nowrap;
}

.library-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-primary);
}

.library-item:hover {
    border-color: var(--text-secondary);
}

.library-placeholder {
    opacity: 0.5;
    font-style: italic;
}

.ribbon-item-label {
    font-size: 0.63rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.75);
    text-align: center;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    transition: color 0.18s ease;
}

.ribbon-item:hover .ribbon-item-label {
    color: rgba(255, 255, 255, 0.95);
}

.ribbon-item-badge {
    font-size: 0.5rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 2px 5px;
    border-radius: 3px;
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    margin-top: 2px;
}

/* Text-only ribbon items (no icon) - compact style */
.ribbon-item.text-only {
    min-width: 36px;
    max-width: 60px;
    padding: 4px 5px;
    justify-content: center;
    height: 100%;
}

.ribbon-item.text-only .ribbon-item-label {
    font-size: 0.5rem;
}

/* Placeholder items (for empty states) */
.ribbon-item.ribbon-item-placeholder {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

.ribbon-item.ribbon-item-placeholder .ribbon-item-label {
    color: var(--text-tertiary);
    font-style: italic;
}

/* Disabled ribbon items (coming soon) */
.ribbon-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.ribbon-item.disabled:hover {
    background: transparent;
}

.ribbon-item-soon {
    font-size: 0.4rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    padding: 1px 4px;
    border-radius: 2px;
    background: rgba(139, 58, 58, 0.3);
    color: #b35858;
    margin-top: 2px;
}

/* ===== Ribbon Dropdown Menus (Scanner Region Dropdowns) ===== */
.ribbon-item-dropdown {
    position: relative;
    display: inline-block;
}

.ribbon-item-dropdown .ribbon-item.dropdown-trigger {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 6px;
    position: relative;
}

/* Top row: region icon + scanner button side by side */
.ribbon-item-dropdown .ribbon-icon-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
}

/* Smaller region icon in dropdown */
.ribbon-item-dropdown .ribbon-item-icon {
    width: 24px;
    height: 24px;
    min-width: 24px;
}

/* Scanner button with dropdown arrow */
.ribbon-item-dropdown .scanner-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 6px;
    background: var(--bg-hover);
    border-radius: 4px;
    border: 1px solid var(--border-primary);
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.ribbon-item-dropdown:hover .scanner-btn {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: #ffffff;
}

.ribbon-item-dropdown:hover .scanner-btn .dropdown-arrow {
    stroke: #ffffff;
}

/* Label below (Scanner text) */
.ribbon-item-dropdown .ribbon-item-label {
    font-size: 0.7rem;
}

.ribbon-item-dropdown .dropdown-arrow {
    opacity: 0.6;
    transition: transform 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
}

.ribbon-item-dropdown:hover .dropdown-arrow {
    opacity: 1;
}

.ribbon-item-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.ribbon-dropdown-menu {
    /* Left-anchored (rather than center-anchored) so a dropdown opening
       from a button near the menubar's left edge — e.g. the Screeners
       button on the Factor Models tab — never extends left past the
       menubar's `overflow: clip` boundary into the sidebar region. */
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 140px;
    background: #151518;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 4px 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 1px rgba(255, 255, 255, 0.05);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
    backdrop-filter: blur(12px);
}

.ribbon-item-dropdown:hover .ribbon-dropdown-menu,
.ribbon-item-dropdown.open .ribbon-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ribbon-dropdown-item {
    display: block;
    padding: 8px 16px;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.ribbon-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Knowledge Base Dropdown - Extended Style */
.ribbon-dropdown-menu.knowledge-dropdown {
    min-width: 180px;
    max-height: 400px;
    overflow-y: auto;
}

.ribbon-dropdown-divider {
    height: 1px;
    background: var(--border-primary);
    margin: 6px 12px;
}

/* Section label inside mega-dropdowns. Used in the consolidated KB ribbon
   to organize 10+-item dropdowns into scannable sections. Non-clickable;
   reads as a small uppercase header above each group of items. */
.ribbon-dropdown-section {
    display: block;
    padding: 10px 16px 4px 16px;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    pointer-events: none;
    border-top: 1px solid var(--border-primary);
    margin-top: 4px;
}

.ribbon-dropdown-section:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 8px;
}

.ribbon-dropdown-item.view-all {
    color: var(--accent-gold);
    font-weight: 500;
}

.ribbon-dropdown-item.view-all:hover {
    background: rgba(201, 169, 98, 0.1);
    color: var(--accent-gold);
}

/* ===== Market Scanner Consolidated Dropdown ===== */
.ribbon-dropdown-menu.market-scanner-menu {
    min-width: 160px;
}

.ribbon-dropdown-section {
    padding: 6px 16px 4px 16px;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-top: 1px solid var(--border-primary);
    margin-top: 4px;
}

.ribbon-dropdown-section:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 4px;
}

/* ===== Ribbon Trained Models - Compact Style ===== */
/* Layout: items on left, dropdown button on right */
.trained-models-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 6px;
    max-height: 65px;
    overflow: visible;
    position: relative;
    width: 100%;
}

/* Items wrapper for vertical stacking */
.trained-models-items {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}

/* Dropdown wrapper on the right side */
.trained-models-dropdown-wrapper {
    position: relative;
    display: flex;
    align-items: flex-start;
    padding-top: 2px;
}

.trained-model-line-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    cursor: default;
    transition: all 0.15s ease;
    white-space: nowrap;
    font-size: 0.6rem;
    height: 24px;
    min-width: 120px; /* Reduced by 40% from 200px */
}

.trained-model-line-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-secondary);
}

.model-ticker {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 42px;
    font-size: 0.6rem;
    cursor: pointer;
}

.model-algorithm {
    color: var(--text-secondary);
    font-size: 0.55rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
    cursor: pointer;
}

.model-performance {
    font-weight: 600;
    font-size: 0.6rem;
    min-width: 42px;
    text-align: right;
    cursor: pointer;
}

.model-performance.positive {
    color: #22c55e;
}

.model-performance.negative {
    color: #ef4444;
}

/* Dropdown trigger button - positioned on right side of items */
.dropdown-trigger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 50px;
    padding: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.dropdown-trigger-btn:hover {
    color: var(--text-secondary);
    border-color: var(--border-secondary);
    background: var(--bg-hover);
}

.dropdown-trigger-btn svg {
    width: 12px;
    height: 12px;
}

/* Trained Models Dropdown menu - opens DOWNWARD */
.trained-models-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 320px;
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    padding: 6px;
    margin-top: 2px;
}

.trained-model-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    color: var(--text-primary);
    border-radius: 4px;
    transition: background 0.15s ease;
    font-size: 0.65rem;
    cursor: default;
}

.trained-model-dropdown-item:hover {
    background: var(--bg-tertiary);
}

.trained-model-dropdown-item .model-ticker {
    min-width: 42px;
    font-size: 0.65rem;
    cursor: pointer;
}

.trained-model-dropdown-item .model-algorithm {
    flex: 1;
    font-size: 0.6rem;
    max-width: none;
    cursor: pointer;
    white-space: nowrap;
}

.trained-model-dropdown-item .model-performance {
    min-width: 50px;
    font-size: 0.65rem;
    cursor: pointer;
}

/* ===== Ribbon Trading Configs - Compact Style ===== */
/* Layout: items on left, dropdown button on right */
.trading-configs-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 6px;
    max-height: 65px;
    overflow: visible;
    position: relative;
    width: 100%;
}

/* Items wrapper for vertical stacking */
.trading-configs-items {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}

/* Dropdown wrapper on the right side */
.trading-configs-dropdown-wrapper {
    position: relative;
    display: flex;
    align-items: flex-start;
    padding-top: 2px;
}

.trading-config-line-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    cursor: default;
    transition: all 0.15s ease;
    white-space: nowrap;
    font-size: 0.6rem;
    height: 24px;
    min-width: 96px; /* Reduced by 40% from 160px */
}

.trading-config-line-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-secondary);
}

.config-ticker {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 42px;
    font-size: 0.6rem;
    cursor: pointer;
}

.config-strategy {
    font-size: 0.55rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 2px;
    text-transform: uppercase;
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    cursor: pointer;
}

.config-return {
    font-weight: 600;
    font-size: 0.6rem;
    min-width: 42px;
    text-align: right;
    cursor: pointer;
}

.config-return.positive {
    color: #22c55e;
}

.config-return.negative {
    color: #ef4444;
}

/* Trading Configs Dropdown menu - opens DOWNWARD */
.trading-configs-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 120px; /* Reduced by 40% from 200px */
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    padding: 4px;
    margin-top: 2px;
}

.trading-config-dropdown-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 8px;
    color: var(--text-primary);
    border-radius: 4px;
    transition: background 0.15s ease;
    font-size: 0.65rem;
    cursor: default;
}

.trading-config-dropdown-item:hover {
    background: var(--bg-tertiary);
}

.trading-config-dropdown-item .config-ticker {
    min-width: 42px;
    font-size: 0.65rem;
    cursor: pointer;
}

.trading-config-dropdown-item .config-strategy {
    font-size: 0.55rem;
    cursor: pointer;
}

.trading-config-dropdown-item .config-return {
    min-width: 50px;
    font-size: 0.65rem;
    cursor: pointer;
}

/* ===== Ribbon Saved Portfolios - Layout with dropdown on right ===== */
.saved-portfolios-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 6px;
    max-height: 65px;
    overflow: visible;
    position: relative;
    width: 100%;
}

/* Items wrapper for vertical stacking */
.saved-portfolios-items {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}

/* Dropdown wrapper on the right side */
.saved-portfolios-dropdown-wrapper {
    position: relative;
    display: flex;
    align-items: flex-start;
    padding-top: 2px;
}

.saved-portfolio-line-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    white-space: nowrap;
    font-size: 0.55rem;
    height: 24px;
    min-width: 132px; /* Reduced by 40% from 220px */
}

.portfolio-opt-type {
    font-weight: 700;
    font-size: 0.5rem;
    padding: 2px 4px;
    border-radius: 3px;
    text-transform: uppercase;
    min-width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.portfolio-opt-type.mvo {
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
}

.portfolio-opt-type.hrp {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.portfolio-opt-type.ivol {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

/* Multi-Factor Screener chips — green for Direct Factor Portfolio, blue
   for Asset Pool. Chips sit in the Screeners row (separate from the
   optimizer chips above), so sharing colour hues with HRP/IVOL is fine. */
.portfolio-opt-type.fmport {
    background: rgba(34, 197, 94, 0.22);
    color: #22c55e;
}

.portfolio-opt-type.pool {
    background: rgba(59, 130, 246, 0.22);
    color: #60a5fa;
}

/* Portfolio info (holdings count and sharpe ratio combined) */
.portfolio-info {
    color: var(--text-secondary);
    font-size: 0.55rem;
    white-space: nowrap;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Portfolio view button (green arrow to show holdings) */
.portfolio-view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    background: #22c55e;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.portfolio-view-btn:hover {
    background: #16a34a;
    transform: scale(1.1);
}

.portfolio-view-btn svg {
    width: 10px;
    height: 10px;
    color: white;
}

/* ===== Delete Button for Ribbon Items ===== */
.item-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    opacity: 0.5;
}

.item-delete-btn:hover {
    background: #ef4444;
    border-color: #ef4444;
    opacity: 1;
    transform: scale(1.1);
}

.item-delete-btn svg {
    width: 10px;
    height: 10px;
    color: var(--text-secondary);
}

.item-delete-btn:hover svg {
    color: white;
}

/* Saved Portfolios Dropdown menu - opens DOWNWARD */
.saved-portfolios-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 168px; /* Reduced by 40% from 280px */
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    padding: 4px;
    margin-top: 2px;
}

.saved-portfolio-dropdown-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 8px;
    color: var(--text-primary);
    border-radius: 4px;
    transition: background 0.15s ease;
    font-size: 0.55rem;
}

.saved-portfolio-dropdown-item:hover {
    background: var(--bg-tertiary);
}

.saved-portfolio-dropdown-item .portfolio-info {
    flex: 1;
}

.saved-portfolio-dropdown-item .portfolio-sharpe {
    min-width: 45px;
}

/* Trading Configs Dropdown menu - opens DOWNWARD */
.trading-configs-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 260px;
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    padding: 4px;
    margin-top: 2px;
}

.trading-config-dropdown-item .config-ticker {
    min-width: 42px;
    font-size: 0.65rem;
}

.trading-config-dropdown-item .config-info {
    flex: 1;
    font-size: 0.55rem;
}

.trading-config-dropdown-item .config-return {
    min-width: 45px;
    font-size: 0.65rem;
}

/* Adjust main container for ribbon height */
/* Ribbon height = 55px (tabs) + 80px (panel) = 135px */
.main-container {
    margin-top: 135px;
    padding-bottom: 60px;
    min-height: calc(100vh - 135px);
    box-sizing: border-box;
}

/* Ensure iframe content has proper scrolling */
.main-container iframe {
    height: calc(100vh - 135px);
    min-height: calc(100vh - 135px);
}

/* Strategy frame specific - full height without cutoff */
.main-container[style*="padding: 0"] {
    padding-bottom: 0 !important;
    height: calc(100vh - 135px);
}

.main-container[style*="padding: 0"] iframe {
    height: 100%;
    min-height: 100%;
}

/* ===== Sidebar Section Headers ===== */
.sidebar-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    padding: 0 6px;
}

.sidebar-section-header .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #22c55e;
}

.sidebar-section-header .title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* ===== Active Execution Cards ===== */
.execution-card {
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.execution-card:hover {
    border-color: var(--border-hover);
}

.execution-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
}

.execution-card-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.execution-card-title .icon {
    font-size: 0.9rem;
}

.execution-card-meta {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* ===== Status Badges ===== */
.status-badge {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 6px;
    border-radius: 3px;
}

.status-badge.running {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.status-badge.live {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.status-badge.idle {
    background: rgba(100, 100, 100, 0.2);
    color: #888888;
}

.status-badge.saved {
    background: rgba(147, 51, 234, 0.2);
    color: #9333ea;
}

.status-badge.long {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.status-badge.short {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* ===== Execution Card Glow States ===== */
.execution-card.has-running {
    border-color: #22c55e;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.4), 0 0 24px rgba(34, 197, 94, 0.2);
}

/* Blue glow for RSI Paper Trading when active */
.execution-card.has-rsi-active {
    border-color: #3b82f6;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.4), 0 0 24px rgba(59, 130, 246, 0.2);
}

.execution-card.has-rsi-active.in-position {
    border-color: #3b82f6;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5), 0 0 30px rgba(59, 130, 246, 0.3);
    animation: rsi-pulse 2s ease-in-out infinite;
}

@keyframes rsi-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(59, 130, 246, 0.4), 0 0 24px rgba(59, 130, 246, 0.2); }
    50% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.6), 0 0 40px rgba(59, 130, 246, 0.4); }
}

/* Purple glow for ML Trading when active */
.execution-card.has-ml-active {
    border-color: #a855f7;
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.4), 0 0 24px rgba(168, 85, 247, 0.2);
}

.execution-card.has-ml-active.in-position {
    border-color: #a855f7;
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.5), 0 0 30px rgba(168, 85, 247, 0.3);
    animation: ml-pulse 2s ease-in-out infinite;
}

@keyframes ml-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(168, 85, 247, 0.4), 0 0 24px rgba(168, 85, 247, 0.2); }
    50% { box-shadow: 0 0 20px rgba(168, 85, 247, 0.6), 0 0 40px rgba(168, 85, 247, 0.4); }
}

/* Green glow for Adv. Paper Trade when active */
.execution-card.has-adv-active {
    border-color: #22c55e;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.4), 0 0 24px rgba(34, 197, 94, 0.2);
}

.execution-card.has-adv-active.in-position {
    border-color: #22c55e;
    box-shadow: 0 0 15px rgba(34, 197, 94, 0.5), 0 0 30px rgba(34, 197, 94, 0.3);
    animation: adv-pulse 2s ease-in-out infinite;
}

@keyframes adv-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(34, 197, 94, 0.4), 0 0 24px rgba(34, 197, 94, 0.2); }
    50% { box-shadow: 0 0 20px rgba(34, 197, 94, 0.6), 0 0 40px rgba(34, 197, 94, 0.4); }
}

/* Purple glow for Stochastic Paper Trade (PT005STPT) when active.
   Mirrors .has-adv-active but in the stochastic accent colour (#a371f7). */
.execution-card.has-stoch-active {
    border-color: #a371f7;
    box-shadow: 0 0 12px rgba(163, 113, 247, 0.4), 0 0 24px rgba(163, 113, 247, 0.2);
}

.execution-card.has-stoch-active.in-position {
    border-color: #a371f7;
    box-shadow: 0 0 15px rgba(163, 113, 247, 0.5), 0 0 30px rgba(163, 113, 247, 0.3);
    animation: stoch-pulse 2s ease-in-out infinite;
}

@keyframes stoch-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(163, 113, 247, 0.4), 0 0 24px rgba(163, 113, 247, 0.2); }
    50% { box-shadow: 0 0 20px rgba(163, 113, 247, 0.6), 0 0 40px rgba(163, 113, 247, 0.4); }
}

/* Stochastic instance rows reuse the .ub-instance-item layout via an extra
   modifier class .stoch-instance-item that recolours the accent borders and
   signal text. Keeps the shared list shape without duplicating geometry. */
.ub-instance-item.stoch-instance-item.running {
    border-color: rgba(163, 113, 247, 0.4);
    background: rgba(163, 113, 247, 0.05);
}
.ub-instance-item.stoch-instance-item.running .ub-instance-ticker {
    color: #a371f7;
}
.ub-instance-item.stoch-instance-item .ub-instance-type {
    background: rgba(163, 113, 247, 0.15);
    color: #a371f7;
}

/* Orange/Amber glow for Portfolio Watch - ONLY when has positions */
.execution-card.has-portfolio-active.has-positions {
    border-color: #f59e0b;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.5), 0 0 30px rgba(245, 158, 11, 0.3);
    animation: portfolio-pulse 2s ease-in-out infinite;
}

@keyframes portfolio-pulse {
    0%, 100% { box-shadow: 0 0 12px rgba(245, 158, 11, 0.4), 0 0 24px rgba(245, 158, 11, 0.2); }
    50% { box-shadow: 0 0 20px rgba(245, 158, 11, 0.6), 0 0 40px rgba(245, 158, 11, 0.4); }
}

/* ===== Saved Configs Dropdown ===== */
.saved-configs-dropdown {
    border-top: 1px solid var(--border-primary);
    padding-top: 5px;
}

.saved-configs-dropdown .dropdown-header {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 2px 0;
}

.saved-configs-dropdown .dropdown-header:hover {
    opacity: 0.8;
}

.saved-configs-dropdown .dropdown-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.saved-configs-dropdown .dropdown-count {
    font-size: 0.6rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.saved-configs-dropdown .dropdown-arrow {
    font-size: 0.6rem;
    color: var(--text-tertiary);
    margin-left: auto;
    transition: transform 0.2s ease;
}

.saved-configs-dropdown .dropdown-arrow.open {
    transform: rotate(180deg);
}

.saved-configs-dropdown .dropdown-content {
    max-height: 150px;
    overflow-y: auto;
    margin-top: 4px;
}

.saved-configs-dropdown .config-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 4px;
    font-size: 0.7rem;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 2px;
}

.saved-configs-dropdown .config-item:hover {
    background: rgba(212, 175, 55, 0.1);
}

.saved-configs-dropdown .config-item .config-name {
    color: var(--text-primary);
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.saved-configs-dropdown .config-item .config-meta {
    color: var(--text-tertiary);
    font-size: 0.65rem;
}

.saved-configs-dropdown .config-item .config-return {
    font-weight: 600;
    margin-left: 8px;
}

.saved-configs-dropdown .config-item .config-return.positive {
    color: #22c55e;
}

.saved-configs-dropdown .config-item .config-return.negative {
    color: #ef4444;
}

/* ===== Research Library ===== */
.research-section {
    margin-bottom: 16px;
}

.research-category-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
    padding-left: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.research-category-header::before {
    content: '';
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-secondary);
}

.research-list {
    list-style: none;
}

.research-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.research-item:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.research-item .name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Flex row holding the strategy name + optional TT badge. The name
   truncates with an ellipsis when long, but the badge has flex-shrink:0
   so it never gets clipped — ensuring TT-saved reports remain visibly
   marked even when the strategy name is long. */
.research-item .name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
}

.research-item .name-row .name {
    flex: 0 1 auto;
}

.research-item .name-row .tt-badge {
    flex-shrink: 0;
    margin-left: 0;
}

.research-item .value {
    font-weight: 600;
    flex-shrink: 0;
    margin-left: 8px;
}

.research-item .value.positive {
    color: #16a34a;
}

.research-item .value.negative {
    color: #dc2626;
}

.research-item .action-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(100, 100, 100, 0.15);
    color: var(--text-secondary);
    font-weight: 500;
}

.research-item-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.research-item .meta {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    margin-top: 1px;
}

/* Time Travel badge — amber pill next to the name for TT-tagged items. */
.tt-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    color: #d29922;
    background: rgba(210, 153, 34, 0.16);
    border: 1px solid rgba(210, 153, 34, 0.7);
    border-radius: 3px;
    vertical-align: middle;
    white-space: nowrap;
}

/* Time Travel marker on report viewer pages — amber pill in the header
   showing the platform virtual date so the user can tell a TT-saved
   report apart from a live-mode report at a glance. */
.tt-marker {
    color: #d29922;
}
.tt-marker-pill {
    display: inline-block;
    padding: 2px 8px;
    margin-right: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #d29922;
    background: rgba(210, 153, 34, 0.12);
    border: 1px solid rgba(210, 153, 34, 0.55);
    border-radius: 3px;
    vertical-align: middle;
}

/* ===== Sidebar Divider ===== */
.sidebar-divider {
    height: 1px;
    background: var(--border-primary);
    margin: 16px 8px;
}

/* ===== Delete Button ===== */
.delete-btn-small {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0 4px;
    margin-left: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.delete-btn-small:hover {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

/* ===== ML Running Instances ===== */
.ml-running-instances {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid var(--border-primary);
}

.ml-running-instance {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 4px;
    margin-bottom: 3px;
    font-size: 0.7rem;
}

.ml-running-instance .instance-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.ml-running-instance .instance-ticker {
    font-weight: 600;
    color: var(--text-primary);
}

.ml-running-instance .instance-signal {
    font-size: 0.6rem;
    color: var(--text-secondary);
}

.ml-running-instance .instance-signal.signal-long {
    color: #22c55e;
}

.ml-running-instance .instance-signal.signal-short {
    color: #ef4444;
}

.ml-running-instance .instance-pnl {
    font-weight: 600;
}

.ml-running-instance .instance-pnl.positive {
    color: #22c55e;
}

.ml-running-instance .instance-pnl.negative {
    color: #ef4444;
}

/* ===== Portfolio Summary Stats ===== */
.portfolio-summary-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    padding: 6px 8px;
    background: rgba(245, 158, 11, 0.08);
    border-radius: 4px;
    border: 1px solid rgba(245, 158, 11, 0.15);
}

.portfolio-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
}

.portfolio-stat .stat-label {
    font-size: 0.55rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.portfolio-stat .stat-value {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-primary);
}

.portfolio-stat .stat-value.positive {
    color: #22c55e;
}

.portfolio-stat .stat-value.negative {
    color: #ef4444;
}

/* ===== Portfolio Running Positions ===== */
.portfolio-running-positions {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid var(--border-primary);
}

.portfolio-position-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 4px;
    margin-bottom: 3px;
    font-size: 0.7rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.portfolio-position-item:hover {
    background: rgba(245, 158, 11, 0.2);
}

.portfolio-position-item .position-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.portfolio-position-item .position-ticker {
    font-weight: 600;
    color: var(--text-primary);
}

.portfolio-position-item .position-direction {
    font-size: 0.6rem;
    color: var(--text-secondary);
}

.portfolio-position-item .position-direction.long {
    color: #22c55e;
    font-weight: 600;
}

.portfolio-position-item .position-direction.short {
    color: #ef4444;
    font-weight: 600;
}

.portfolio-position-item .position-values {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.2;
}

.portfolio-position-item .position-value {
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.portfolio-position-item .position-pnl {
    font-size: 0.65rem;
    font-weight: 600;
}

.portfolio-position-item .position-pnl.positive {
    color: #22c55e;
}

.portfolio-position-item .position-pnl.negative {
    color: #ef4444;
}

/* Portfolio summary items (multi-portfolio display) */
/* Default: inactive portfolio styling - muted/dimmed */
.portfolio-position-item.portfolio-summary-item {
    background: rgba(100, 100, 100, 0.08);
    border: 1px solid rgba(100, 100, 100, 0.15);
    opacity: 0.6;
}

.portfolio-position-item.portfolio-summary-item:hover {
    background: rgba(100, 100, 100, 0.12);
    border-color: rgba(100, 100, 100, 0.2);
    opacity: 0.8;
}

/* Active/Running portfolio styling - highlighted */
.portfolio-position-item.portfolio-summary-item.has-positions {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.35);
    opacity: 1;
}

.portfolio-position-item.portfolio-summary-item.has-positions:hover {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.45);
}

/* Inactive portfolio name styling - muted */
.portfolio-position-item .portfolio-name-label {
    color: var(--text-secondary);
    font-weight: 600;
}

/* Active portfolio name styling - highlighted */
.portfolio-position-item.has-positions .portfolio-name-label {
    color: #22c55e;
}

.portfolio-position-item .portfolio-count {
    font-size: 0.55rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* Running indicator dot for active portfolios */
.portfolio-position-item.portfolio-summary-item.has-positions::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.portfolio-position-item.portfolio-summary-item {
    position: relative;
    padding-left: 18px;
}

/* ===== Expand Buttons for Collapsed Lists ===== */
.positions-expand-btn,
.instances-expand-btn {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 4px 0;
    cursor: pointer;
    border-top: 1px dashed var(--border-primary);
    margin-top: 3px;
    transition: all 0.2s ease;
}

.positions-expand-btn:hover,
.instances-expand-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

/* ===== Paper Trading Instances Container ===== */
.paper-trading-instances {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid var(--border-primary);
}

.paper-trading-instance {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px 4px 18px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 4px;
    margin-bottom: 3px;
    font-size: 0.7rem;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    opacity: 0.6;
}

.paper-trading-instance:hover {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.25);
    opacity: 0.8;
}

.paper-trading-instance.active {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.35);
    opacity: 1;
}

.paper-trading-instance.active:hover {
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.45);
}

.paper-trading-instance.active::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #3b82f6;
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.5);
}

.paper-trading-instance.in-position {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.35);
    opacity: 1;
}

.paper-trading-instance.in-position:hover {
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.45);
}

.paper-trading-instance .instance-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.paper-trading-instance .instance-ticker {
    font-weight: 600;
    color: var(--text-primary);
}

.paper-trading-instance.active .instance-ticker {
    color: #60a5fa;
}

.paper-trading-instance .instance-type {
    font-size: 0.55rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.paper-trading-instance .instance-signal {
    font-size: 0.6rem;
    color: var(--text-secondary);
}

.paper-trading-instance .instance-signal.signal-long {
    color: #22c55e;
    font-weight: 600;
}

.paper-trading-instance .instance-signal.signal-short {
    color: #ef4444;
    font-weight: 600;
}

.paper-trading-instance .instance-pnl {
    font-weight: 600;
}

.paper-trading-instance .instance-pnl.positive {
    color: #22c55e;
}

.paper-trading-instance .instance-pnl.negative {
    color: #ef4444;
}

/* Project items in sidebar */
.paper-trading-instance.project-item {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-left: 2px solid rgba(59, 130, 246, 0.5);
}

.paper-trading-instance.project-item:hover {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.25);
    border-left-color: rgba(59, 130, 246, 0.6);
}

.paper-trading-instance.project-item.active {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-left: 2px solid rgba(59, 130, 246, 0.7);
    opacity: 1;
}

.paper-trading-instance.project-item.in-position {
    background: rgba(59, 130, 246, 0.12);
    border: 1px solid rgba(59, 130, 246, 0.35);
    border-left: 2px solid rgba(59, 130, 246, 0.7);
    opacity: 1;
}

.paper-trading-instance .project-name {
    color: #60a5fa;
}

.paper-trading-instance .project-type {
    font-size: 0.55rem;
    color: var(--text-tertiary);
    background: rgba(59, 130, 246, 0.2);
    padding: 1px 4px;
    border-radius: 2px;
}

/* ===== UB Paper Trading Instances ===== */
.ub-paper-trading-instances {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid var(--border-primary);
}

.ub-instance-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px 4px 18px;
    background: rgba(100, 100, 100, 0.08);
    border: 1px solid rgba(100, 100, 100, 0.15);
    border-radius: 4px;
    margin-bottom: 3px;
    font-size: 0.7rem;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    opacity: 0.6;
}

.ub-instance-item:hover {
    background: rgba(100, 100, 100, 0.12);
    border-color: rgba(100, 100, 100, 0.2);
    opacity: 0.8;
}

.ub-instance-item.running {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.35);
    opacity: 1;
}

.ub-instance-item.running:hover {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.45);
}

.ub-instance-item.running::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.ub-instance-item .ub-instance-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.ub-instance-item .ub-instance-ticker {
    font-weight: 600;
    color: var(--text-primary);
}

.ub-instance-item.running .ub-instance-ticker {
    color: #22c55e;
}

.ub-instance-item .ub-instance-type {
    font-size: 0.55rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.ub-instance-item .ub-instance-signal {
    font-size: 0.6rem;
    color: var(--text-secondary);
}

.ub-instance-item .ub-instance-signal.signal-long {
    color: #22c55e;
    font-weight: 600;
}

.ub-instance-item .ub-instance-signal.signal-short {
    color: #ef4444;
    font-weight: 600;
}

.ub-instance-item.has-position {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.35);
    opacity: 1;
}

.ub-instance-item.has-position:hover {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.45);
}

.ub-instance-item .ub-instance-pnl {
    font-size: 0.6rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.ub-instance-item .ub-instance-pnl.positive {
    color: #22c55e;
}

.ub-instance-item .ub-instance-pnl.negative {
    color: #ef4444;
}

/* ===== RSI Running Instances ===== */
.rsi-running-instances {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid var(--border-primary);
}

.rsi-running-instance {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 4px;
    margin-bottom: 3px;
    font-size: 0.7rem;
    transition: all 0.3s ease;
}

.rsi-running-instance.in-position {
    background: rgba(59, 130, 246, 0.15);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(59, 130, 246, 0.3); }
    50% { box-shadow: 0 0 15px rgba(59, 130, 246, 0.6); }
}

.rsi-running-instance .instance-info {
    display: flex;
    flex-direction: column;
}

.rsi-running-instance .instance-ticker {
    font-weight: 600;
    color: var(--text-primary);
}

.rsi-running-instance .instance-signal {
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.rsi-running-instance .instance-signal.signal-long {
    color: #3b82f6;
    font-weight: 600;
}

.rsi-running-instance .instance-signal.signal-short {
    color: #ef4444;
    font-weight: 600;
}

.rsi-running-instance .instance-pnl {
    font-weight: 600;
}

.rsi-running-instance .instance-pnl.positive {
    color: #22c55e;
}

.rsi-running-instance .instance-pnl.negative {
    color: #ef4444;
}

/* ===== Trading Config Items in Sidebar ===== */
.saved-configs-dropdown .trading-config-item {
    flex-wrap: wrap;
}

.saved-configs-dropdown .trading-config-item .config-main {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 6px;
    min-width: 0;
}

.saved-configs-dropdown .trading-config-item .config-type {
    font-size: 0.55rem;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 3px;
    text-transform: uppercase;
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.saved-configs-dropdown .trading-config-item .config-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 6px;
}

.saved-configs-dropdown .trading-config-item .download-btn {
    font-size: 0.8rem;
    font-weight: 700;
    color: #3b82f6;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: all 0.2s;
}

.saved-configs-dropdown .trading-config-item .download-btn:hover {
    background: rgba(59, 130, 246, 0.2);
}

/* ===== User Projects in Ribbon ===== */
.user-projects-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 6px;
    max-height: 55px;
    overflow: visible;
    position: relative;
    width: 100%;
}

.user-projects-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    max-height: 55px;
    overflow: hidden;
}

.user-project-line-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 3px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.55rem;
    transition: all 0.15s ease;
    cursor: pointer;
    white-space: nowrap;
    max-height: 24px;
}

.user-project-line-item:hover {
    border-color: var(--accent-gold);
    background: rgba(201, 169, 98, 0.1);
}

.project-color-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.project-name-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60px;
    font-weight: 500;
    font-size: 0.55rem;
}

.project-category-label {
    font-size: 0.45rem;
    padding: 1px 3px;
    background: rgba(201, 169, 98, 0.2);
    color: var(--accent-gold);
    border-radius: 2px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.project-item-count {
    font-size: 0.5rem;
    color: var(--text-secondary);
    min-width: 10px;
    text-align: center;
}

/* User Projects Dropdown Wrapper */
.user-projects-dropdown-wrapper {
    position: relative;
    display: flex;
    align-items: flex-start;
    padding-top: 2px;
}

/* User Projects Dropdown Menu */
.user-projects-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    padding: 4px;
    margin-top: 2px;
}

.dropdown-project-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    text-decoration: none;
    color: var(--text-primary);
    border-radius: 4px;
    transition: background 0.15s ease;
    font-size: 0.55rem;
}

.dropdown-project-item:hover {
    background: var(--bg-tertiary);
}

.dropdown-project-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-project-category {
    font-size: 0.45rem;
    padding: 1px 4px;
    background: rgba(201, 169, 98, 0.2);
    color: var(--accent-gold);
    border-radius: 3px;
    text-transform: uppercase;
}

.dropdown-project-count {
    font-size: 0.55rem;
    color: var(--text-secondary);
}

/* ============================================================================
   MOBILE RESPONSIVE — Hamburger Menu
   ============================================================================ */

/* Hamburger button — mobile-only. Hidden on desktop / tablet. Shown
   on portrait phones (≤768px wide) and landscape phones (short height
   in landscape orientation). On portrait it opens the accordion
   overlay menu; on landscape phones it toggles `body.chrome-collapsed`
   to hide the wrapper sidebar + top ribbon so the user can reclaim
   screen space without leaving the page. */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 10001;
    width: 44px;
    height: 44px;
    background: var(--bg-secondary, #0a0a0a);
    border: 1px solid var(--border-primary, #262626);
    border-radius: 8px;
    color: #c9a962;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}
@media (max-width: 768px), (orientation: landscape) and (max-height: 500px) {
    .mobile-menu-btn { display: flex; }
}

/* Hide the hamburger while the mobile menu overlay is open so it
   doesn't sit on top of the overlay's own logo header — the overlay's
   X button is the close affordance. */
body.mobile-menu-open .mobile-menu-btn { display: none !important; }

.mobile-menu-btn:active {
    background: rgba(201, 169, 98, 0.15);
}

/* Wrapper-chrome manual collapse state. Applied by JS on >768px
   viewports when the user clicks the hamburger. Below 768px the
   portrait media query at the bottom of this file already hides the
   chrome with display:none, so this transform is purely a visual
   nicety for landscape-phone / tablet / desktop. */
.sidebar,
.control-panel-menubar {
    transition: transform 0.25s ease;
}
body.chrome-collapsed .sidebar {
    transform: translateX(-100%);
}
body.chrome-collapsed .control-panel-menubar {
    transform: translateY(-100%);
}
body.chrome-collapsed .main-container {
    margin-left: 0 !important;
    /* Keep a 56px gap at the top — same as the portrait-phone rule —
       so the fixed hamburger button (top:10, height:44, z-index:10001)
       doesn't render on top of iframe content (e.g. a module's Symbol
       input or page header) when the chrome is collapsed. Without this
       gap, landscape-phone users couldn't tap the input cleanly because
       the hamburger sat over it. */
    margin-top: 56px !important;
}
body.chrome-collapsed .main-container iframe {
    /* 100vh on mobile = LARGEST possible viewport (address bar hidden),
       so the iframe extended below the actual visible area and any
       module's bottom controls (Run / Apply / etc.) ended up offscreen.
       100dvh tracks the live visible viewport; the 100vh declaration
       above is the fallback for older browsers that don't recognise
       dvh — the cascade picks the last valid one. */
    height: calc(100vh - 56px) !important;
    height: calc(100dvh - 56px) !important;
    min-height: calc(100vh - 56px) !important;
    min-height: calc(100dvh - 56px) !important;
}

/* Mobile overlay container — hidden by default */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary, #000);
    z-index: 10000;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-menu-overlay.open {
    display: block;
}

/* Mobile menu header */
.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-primary, #262626);
    position: sticky;
    top: 0;
    background: var(--bg-primary, #000);
    z-index: 1;
}

.mobile-menu-logo {
    height: 26px;
    width: auto;
}

/* The logo is wrapped in an <a href="/home"> so users on a strategy
   page can return to the home dashboard from inside the overlay. */
.mobile-menu-logo-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-close {
    width: 44px;
    height: 44px;
    background: none;
    border: 1px solid var(--border-primary, #262626);
    border-radius: 8px;
    color: var(--text-primary, #e5e5e5);
    font-size: 1.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    padding: 0;
    line-height: 1;
}

.mobile-menu-close:active {
    background: rgba(255, 255, 255, 0.05);
}

/* Accordion sections — one per ribbon tab */
.mobile-menu-section {
    border-bottom: 1px solid var(--border-primary, #262626);
}

.mobile-menu-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    color: #c9a962;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-section-header:active {
    background: rgba(201, 169, 98, 0.05);
}

.mobile-menu-section-header .chevron {
    transition: transform 0.2s ease;
    color: var(--text-tertiary, #737373);
    flex-shrink: 0;
}

.mobile-menu-section.open .mobile-menu-section-header .chevron {
    transform: rotate(180deg);
}

.mobile-menu-section-content {
    display: none;
    padding: 0 16px 16px;
}

.mobile-menu-section.open .mobile-menu-section-content {
    display: block;
}

/* Groups within a section */
.mobile-menu-group {
    margin-bottom: 14px;
}

.mobile-menu-group:last-child {
    margin-bottom: 0;
}

.mobile-menu-group-title {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary, #737373);
    margin-bottom: 6px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

/* Menu items — large touch targets */
.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 10px;
    color: var(--text-primary, #e5e5e5);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

.mobile-menu-item:active {
    background: rgba(201, 169, 98, 0.12);
}

.mobile-menu-item .mobile-icon {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.mobile-menu-item .mobile-icon.gold { background: rgba(201, 169, 98, 0.12); color: #c9a962; }
.mobile-menu-item .mobile-icon.teal { background: rgba(91, 164, 164, 0.12); color: #5ba4a4; }
.mobile-menu-item .mobile-icon.purple { background: rgba(168, 85, 247, 0.12); color: #a855f7; }
.mobile-menu-item .mobile-icon.blue { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.mobile-menu-item .mobile-icon.green { background: rgba(34, 197, 94, 0.12); color: #22c55e; }
.mobile-menu-item .mobile-icon.orange { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.mobile-menu-item .mobile-icon.red { background: rgba(179, 88, 88, 0.12); color: #b35858; }

/* Same .mobile-icon sizing/coloring inside expandable triggers — used
   by the Indicator Strategies "Scanners" tile and the Fundamental
   "Screeners" dropdown so their leading magnifying-glass icon shows
   instead of an unstyled invisible SVG. */
.mobile-menu-expandable-trigger .mobile-icon {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
}
.mobile-menu-expandable-trigger .mobile-icon svg {
    width: 18px;
    height: 18px;
}
.mobile-menu-expandable-trigger .mobile-icon.gold { background: rgba(201, 169, 98, 0.12); color: #c9a962; }
.mobile-menu-expandable-trigger .mobile-icon.teal { background: rgba(91, 164, 164, 0.12); color: #5ba4a4; }
.mobile-menu-expandable-trigger .mobile-icon.purple { background: rgba(168, 85, 247, 0.12); color: #a855f7; }
.mobile-menu-expandable-trigger .mobile-icon.blue { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.mobile-menu-expandable-trigger .mobile-icon.green { background: rgba(34, 197, 94, 0.12); color: #22c55e; }
.mobile-menu-expandable-trigger .mobile-icon.orange { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.mobile-menu-expandable-trigger .mobile-icon.red { background: rgba(179, 88, 88, 0.12); color: #b35858; }

.mobile-menu-item .featured-badge {
    font-size: 0.55rem;
    padding: 1px 5px;
    background: rgba(201, 169, 98, 0.2);
    color: #c9a962;
    border-radius: 3px;
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Expandable items (scanners with regions, KB articles) */
.mobile-menu-expandable {
    margin-bottom: 2px;
}

.mobile-menu-expandable-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 10px;
    color: var(--text-primary, #e5e5e5);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    min-height: 48px;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-expandable-trigger:active {
    background: rgba(201, 169, 98, 0.08);
}

.mobile-menu-expandable-trigger .trigger-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-menu-expandable-trigger .chevron {
    transition: transform 0.2s ease;
    color: var(--text-tertiary, #737373);
    flex-shrink: 0;
}

.mobile-menu-expandable.open .mobile-menu-expandable-trigger .chevron {
    transform: rotate(180deg);
}

.mobile-menu-expandable-content {
    display: none;
    padding-left: 16px;
}

.mobile-menu-expandable.open .mobile-menu-expandable-content {
    display: block;
}

.mobile-menu-sub-section {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-tertiary, #737373);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 10px 4px;
}

.mobile-menu-sub-item {
    display: flex;
    align-items: center;
    padding: 11px 10px;
    color: var(--text-secondary, #a3a3a3);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 6px;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

.mobile-menu-sub-item:active {
    background: rgba(201, 169, 98, 0.08);
    color: var(--text-primary, #e5e5e5);
}

/* Footer — legal links + pricing */
.mobile-menu-footer {
    padding: 20px 16px;
    border-top: 1px solid var(--border-primary, #262626);
    margin-top: 8px;
}

.mobile-menu-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.mobile-menu-footer-link {
    color: var(--text-tertiary, #737373);
    font-size: 0.8rem;
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px 0;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-footer-link:active {
    color: var(--text-primary, #e5e5e5);
}

.mobile-menu-pricing-btn {
    display: block;
    width: 100%;
    padding: 14px;
    background: rgba(201, 169, 98, 0.12);
    border: 1px solid rgba(201, 169, 98, 0.3);
    border-radius: 8px;
    color: #c9a962;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-pricing-btn:active {
    background: rgba(201, 169, 98, 0.2);
}

/* ===== MEDIA QUERY — Mobile Breakpoint ===== */
/* Portrait phone — the hamburger opens the accordion overlay menu;
   the chrome auto-hides regardless of the manual `chrome-collapsed`
   state because the desktop sidebar+ribbon don't fit a 375px screen. */
@media (max-width: 768px) {
    .control-panel-menubar {
        display: none !important;
    }
    .sidebar {
        display: none !important;
    }
    .main-container {
        margin-left: 0 !important;
        margin-top: 56px !important;
        min-height: calc(100vh - 56px) !important;
    }
    .main-container iframe {
        /* dvh tracks the visible viewport on mobile so the iframe
           doesn't extend below the address bar — keeps a module's
           bottom controls (Run / Apply / etc.) reachable. 100vh
           fallback for browsers that don't support dvh. */
        height: calc(100vh - 56px) !important;
        height: calc(100dvh - 56px) !important;
        min-height: calc(100vh - 56px) !important;
        min-height: calc(100dvh - 56px) !important;
    }
}

/* Home page on mobile — render the wrapper sidebar inline (logo
   banner + Active Execution + Research Library + Settings/Logout)
   instead of the empty desktop dashboard. The sidebar already has the
   logo at top (which is also a /home link), the running paper-trading
   instances and saved-report lists, and the action buttons at the
   bottom — exactly what a phone user wants to see at /home. */
@media (max-width: 768px), (orientation: landscape) and (max-height: 500px) {
    body.is-home-page .sidebar {
        display: flex !important;
        position: static !important;
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-primary, #262626);
        margin-top: 56px;  /* clear the fixed hamburger button */
    }
    body.is-home-page .main-container {
        display: none !important;
    }
}
