/* ==========================================================================
   Full Scope Multi-Chart Desktop Styling ("Charts")
   ========================================================================== */

#page-charts.child-page {
    display: none;
    width: 100%;
    margin-top: 0.5rem;
    padding: 0;
    gap: 0;
}

#page-charts.child-page.active {
    display: flex;
    flex-direction: row;
    height: calc(100vh - 128px);
    width: 100%;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-color, #243046);
    border-radius: 8px;
    background: var(--bg-card, #0f172a);
}

.charts-workspace-wrapper {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* --------------------------------------------------------------------------
   LEFT: Multi-Chart Canvas Workspace
   -------------------------------------------------------------------------- */
.charts-workspace-left {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 320px;
    overflow: hidden;
    background: #090e17;
}

.charts-top-toolbar {
    height: 38px;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    background: #0b1120;
    border-bottom: 1px solid #1e293b;
    user-select: none;
    gap: 8px;
}

.charts-tb-left, .charts-tb-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.charts-tb-title {
    font-size: 12px;
    font-weight: 700;
    color: #e2e8f0;
    letter-spacing: -0.2px;
    margin-right: 4px;
}

.charts-tb-divider {
    width: 1px;
    height: 18px;
    background: #334155;
    margin: 0 4px;
}

.charts-tb-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 25px;
    padding: 0 8px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #f1f5f9;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.charts-tb-btn:hover {
    background: #2b394f;
    border-color: #38bdf8;
    color: #38bdf8;
}

.charts-tb-btn.btn-accent {
    background: rgba(56, 189, 248, 0.15);
    border-color: #38bdf8;
    color: #38bdf8;
}

.charts-tb-btn.btn-accent:hover {
    background: #38bdf8;
    color: #0b1120;
}

.charts-tb-btn.active {
    background: rgba(56, 189, 248, 0.15);
    border-color: #38bdf8;
    color: #38bdf8;
}

.charts-tb-layout-btn {
    height: 25px;
    padding: 0 7px;
    background: #182232;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #94a3b8;
    font-size: 10.5px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    transition: all 0.15s ease;
}

.charts-tb-layout-btn:hover {
    background: #243046;
    color: #f8fafc;
    border-color: #475569;
}

.charts-tb-layout-btn.active {
    background: #38bdf8;
    color: #0b1120;
    border-color: #38bdf8;
}

.charts-active-badge {
    font-size: 11px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    padding: 2px 7px;
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.4);
    border-radius: 4px;
    color: #38bdf8;
}

/* --------------------------------------------------------------------------
   CHARTS GRID TILES CONTAINER
   -------------------------------------------------------------------------- */
.charts-tiles-workspace {
    flex: 1 1 auto;
    height: calc(100% - 38px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px;
    display: grid;
    gap: 6px;
    background: #090e17;
    position: relative;
}

/* Layout Presets */
.charts-tiles-workspace.layout-1x1 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

.charts-tiles-workspace.layout-1x2 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}

.charts-tiles-workspace.layout-2x1 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
}

.charts-tiles-workspace.layout-2x2 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.charts-tiles-workspace.layout-2x3 {
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.charts-tiles-workspace.layout-auto {
    grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
    grid-auto-rows: minmax(320px, 1fr);
}

/* Custom Draggable Tiles Layout */
.charts-tiles-workspace.layout-custom {
    display: flex !important;
    flex-wrap: wrap !important;
    align-content: flex-start !important;
    gap: 6px !important;
    overflow-y: auto !important;
}

/* Individual Tile Resizing */
.chart-tile {
    position: relative;
    box-sizing: border-box;
}

.chart-tile.has-custom-size {
    flex: 0 0 auto !important;
}

/* Draggable Border Resize Handles */
.chart-tile-resize-handle {
    position: absolute;
    z-index: 25;
    user-select: none;
    transition: background 0.12s ease;
}

/* Right Border Handle */
.chart-tile-resize-handle.handle-e {
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: ew-resize;
}

/* Bottom Border Handle */
.chart-tile-resize-handle.handle-s {
    bottom: 0;
    left: 0;
    width: 100%;
    height: 6px;
    cursor: ns-resize;
}

/* Bottom-Right Corner Grip Handle */
.chart-tile-resize-handle.handle-se {
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    cursor: nwse-resize;
    z-index: 26;
    border-radius: 2px 0 5px 0;
}

/* Active & Hover Highlights */
.chart-tile-resize-handle.handle-e:hover,
.chart-tile-resize-handle.handle-e.is-dragging,
.chart-tile-resize-handle.handle-s:hover,
.chart-tile-resize-handle.handle-s.is-dragging {
    background: rgba(56, 189, 248, 0.6) !important;
}

.chart-tile-resize-handle.handle-se:hover,
.chart-tile-resize-handle.handle-se.is-dragging {
    background: #38bdf8 !important;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.8) !important;
}

/* Single Chart Tile Card */
.chart-tile {
    display: flex;
    flex-direction: column;
    background: #0d1424;
    border: 1px solid #1e293b;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    min-height: 220px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.chart-tile.active-chart {
    border: 1px solid #38bdf8 !important;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.25) !important;
}

.chart-tile.maximized-tile {
    position: absolute !important;
    top: 6px !important;
    left: 6px !important;
    right: 6px !important;
    bottom: 6px !important;
    z-index: 80 !important;
    width: calc(100% - 12px) !important;
    height: calc(100% - 12px) !important;
}

/* --------------------------------------------------------------------------
   NARROW CHART HEADER
   -------------------------------------------------------------------------- */
.chart-tile-header {
    height: 32px;
    min-height: 32px;
    background: #111a2e;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    user-select: none;
    font-size: 11px;
}

.chart-hdr-left {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    flex: 1 1 auto;
    min-width: 0;
}

.chart-active-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #475569;
    flex-shrink: 0;
    transition: background 0.15s;
}

.chart-tile.active-chart .chart-active-dot {
    background: #38bdf8;
    box-shadow: 0 0 6px #38bdf8;
}

.chart-sym-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 800;
    color: #38bdf8;
    cursor: pointer;
    flex-shrink: 0;
}

.chart-name-trunc {
    color: #94a3b8;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
    min-width: 0;
    flex-shrink: 1;
}

.chart-price-val {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: #f8fafc;
    font-size: 12px;
    flex-shrink: 0;
}

.chart-chg-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    flex-shrink: 0;
}

.chart-chg-badge.pos {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.chart-chg-badge.neg {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.chart-hdr-right {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    margin-left: auto;
}

.chart-hdr-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 22px;
    padding: 0 6px;
    background: #182232;
    border: 1px solid #334155;
    border-radius: 3px;
    color: #cbd5e1;
    font-size: 10.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.12s ease;
}

.chart-hdr-btn:hover {
    background: #243046;
    border-color: #38bdf8;
    color: #38bdf8;
}

.chart-hdr-btn.btn-formula {
    background: rgba(168, 85, 247, 0.12);
    border-color: rgba(168, 85, 247, 0.4);
    color: #c084fc;
}

.chart-hdr-btn.btn-formula:hover {
    background: #a855f7;
    color: #ffffff;
    border-color: #a855f7;
}

.chart-hdr-btn.btn-bear-ribbon {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fbbf24;
}

.chart-hdr-btn.btn-bear-ribbon:hover {
    background: rgba(245, 158, 11, 0.25);
    color: #fde68a;
    border-color: #f59e0b;
}

.chart-hdr-btn.btn-bear-ribbon-active {
    background: #d97706 !important;
    color: #ffffff !important;
    border-color: #fbbf24 !important;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5) !important;
}

.chart-formula-script-badge {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 7px;
    background: rgba(168, 85, 247, 0.14);
    border: 1px solid rgba(168, 85, 247, 0.45);
    border-radius: 4px;
    color: #e9d5ff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
}

.chart-hdr-btn.btn-formula-active {
    background: #a855f7 !important;
    color: #ffffff !important;
    border-color: #c084fc !important;
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.5) !important;
}

.chart-hdr-btn.btn-indicators {
    background: rgba(56, 189, 248, 0.1);
    border-color: rgba(56, 189, 248, 0.35);
    color: #38bdf8;
}

.chart-hdr-btn.btn-indicators:hover {
    background: #38bdf8;
    color: #0b1120;
}

.chart-ind-badge {
    font-size: 9px;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 8px;
    background: #38bdf8;
    color: #0b1120;
    margin-left: 2px;
}

.chart-tf-select {
    height: 22px;
    padding: 0 4px;
    background: #182232;
    border: 1px solid #334155;
    border-radius: 3px;
    color: #cbd5e1;
    font-size: 10px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    outline: none;
}

.chart-tf-select:hover, .chart-tf-select:focus {
    border-color: #38bdf8;
}

.chart-hdr-icon-btn {
    width: 26px;
    height: 24px;
    min-width: 26px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #182232;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #cbd5e1;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    padding: 0;
}

.chart-hdr-icon-btn:hover {
    background: #243046;
    color: #ffffff;
    border-color: #38bdf8;
}

.chart-hdr-icon-btn.btn-maximize-tile {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.45);
    color: #38bdf8;
}

.chart-hdr-icon-btn.btn-maximize-tile:hover {
    background: #38bdf8;
    color: #0b1120;
    border-color: #38bdf8;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

.chart-hdr-icon-btn.btn-maximize-tile.active {
    background: #0284c7 !important;
    color: #ffffff !important;
    border-color: #38bdf8 !important;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5) !important;
}

.chart-hdr-icon-btn.btn-close {
    background: #182232;
    border: 1px solid #334155;
    color: #94a3b8;
}

.chart-hdr-icon-btn.btn-close:hover {
    background: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
}

/* Canvas Area */
.chart-canvas-wrapper {
    flex: 1 1 0%;
    width: 100%;
    height: auto;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.chart-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(13, 20, 36, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #38bdf8;
    z-index: 10;
    gap: 6px;
    pointer-events: none;
}

/* Indicators Dropdown Menu */
.chart-indicators-menu {
    position: absolute;
    top: 34px;
    right: 65px;
    z-index: 120;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.65);
    padding: 8px;
    width: 240px;
    max-height: 320px;
    overflow-y: auto;
    display: none;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
}

.ind-group-label {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    padding: 3px 4px 1px 4px;
    border-bottom: 1px solid #1e293b;
    margin-top: 4px;
}

.ind-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.12s;
    user-select: none;
}

.ind-item:hover {
    background: #1e293b;
}

.ind-item label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: #e2e8f0;
    font-size: 11px;
}

.ind-item input[type="checkbox"] {
    accent-color: #38bdf8;
    cursor: pointer;
}

.ind-color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* --------------------------------------------------------------------------
   VERTICAL RESIZABLE SPLITTER
   -------------------------------------------------------------------------- */
.charts-v-splitter {
    width: 6px;
    height: 100%;
    background: #131d2e;
    border-left: 1px solid #1e293b;
    border-right: 1px solid #1e293b;
    cursor: col-resize;
    flex-shrink: 0;
    z-index: 30;
    transition: background 0.12s ease;
}

.charts-v-splitter:hover, .charts-v-splitter.dragging {
    background: #38bdf8 !important;
}

/* Floating Edge Dock Tab (Shown when Universe Pane is collapsed) */
.charts-collapsed-dock-tab {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 45;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 5px;
    background: #131d2e;
    color: #94a3b8;
    border: 1px solid #1e293b;
    border-right: none;
    border-radius: 6px 0 0 6px;
    cursor: pointer;
    box-shadow: -3px 0 12px rgba(0, 0, 0, 0.45);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    transition: all 0.15s ease;
    user-select: none;
}

.charts-collapsed-dock-tab:hover {
    background: #1e293b;
    color: #38bdf8;
    border-color: #38bdf8;
    box-shadow: -4px 0 14px rgba(56, 189, 248, 0.3);
}

.charts-collapsed-dock-tab .dock-tab-title {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
}

.charts-right-pane.collapsed {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.scope-collapse-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.scope-collapse-btn:hover {
    background: #1e293b;
    border-color: #334155;
    color: #38bdf8;
}

/* --------------------------------------------------------------------------
   RIGHT: Stock Universe Scope Explorer Pane (~20% width)
   -------------------------------------------------------------------------- */
.charts-right-pane {
    width: 290px;
    min-width: 220px;
    max-width: 55vw;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #0d1424;
    flex-shrink: 0;
    user-select: none;
    overflow: hidden;
}

.scope-header {
    height: 38px;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    background: #0b1120;
    border-bottom: 1px solid #1e293b;
}

.scope-title {
    font-size: 12px;
    font-weight: 700;
    color: #f1f5f9;
}

.scope-count-badge {
    font-size: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    background: #1e293b;
    color: #38bdf8;
    border: 1px solid #334155;
}

.scope-controls {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-bottom: 1px solid #1e293b;
    background: #0d1424;
}

.scope-lbl {
    font-size: 10px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.scope-select {
    width: 100%;
    height: 28px;
    padding: 0 6px;
    background: #182232;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #f1f5f9;
    font-size: 11.5px;
    font-weight: 600;
    outline: none;
    cursor: pointer;
}

.scope-select:hover, .scope-select:focus {
    border-color: #38bdf8;
}

.scope-search-box {
    position: relative;
    width: 100%;
}

.scope-input {
    width: 100%;
    height: 28px;
    padding: 0 8px 0 24px;
    background: #182232;
    border: 1px solid #334155;
    border-radius: 4px;
    color: #f1f5f9;
    font-size: 11px;
    outline: none;
}

.scope-input:focus {
    border-color: #38bdf8;
}

.scope-search-icon {
    position: absolute;
    left: 7px;
    top: 7px;
    color: #64748b;
    pointer-events: none;
}

/* Keyboard navigable stock list */
.scope-stock-list-container {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px;
    outline: none;
}

.scope-stock-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.scope-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.12s;
    font-size: 11.5px;
    border-left: 3px solid transparent;
}

.scope-row:hover {
    background: #1e293b;
}

.scope-row.selected {
    background: #1a2c42 !important;
    border-left-color: #38bdf8 !important;
}

.scope-row-left {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
}

.scope-sym {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 800;
    color: #38bdf8;
    font-size: 12px;
    min-width: 42px;
}

.scope-name {
    color: #cbd5e1;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.scope-sector-badge {
    font-size: 9.5px;
    color: #64748b;
    background: #182232;
    padding: 1px 4px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
    text-align: right;
}

.scope-footer-hint {
    padding: 6px 10px;
    font-size: 10px;
    color: #64748b;
    background: #090e17;
    border-top: 1px solid #1e293b;
    line-height: 1.4;
    text-align: center;
}

/* ==========================================================================
   Chart Tile Oscillator Sub-Pane
   ========================================================================== */
.chart-tile {
    display: flex !important;
    flex-direction: column !important;
}

.chart-canvas-wrapper {
    flex: 1 1 auto;
    min-height: 140px;
    position: relative;
    width: 100%;
}

/* Lower Sub-Pane for Oscillators (Stochastic, etc.) */
.chart-osc-wrapper {
    height: 115px;
    min-height: 85px;
    max-height: 160px;
    display: none;
    flex-direction: column;
    border-top: 1px solid #1e293b;
    background: #0b1120;
    position: relative;
    flex-shrink: 0;
}

.chart-osc-header {
    height: 20px;
    min-height: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    background: #090e17;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 10px;
    font-weight: 600;
    color: #94a3b8;
    user-select: none;
}

.chart-osc-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #cbd5e1;
    font-size: 10px;
    font-family: 'JetBrains Mono', monospace;
}

.chart-osc-close-btn {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 11px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    border-radius: 2px;
    transition: color 0.15s ease;
}

.chart-osc-close-btn:hover {
    color: #ef4444;
}

.chart-osc-canvas {
    flex: 1 1 auto;
    width: 100%;
    position: relative;
    overflow: hidden;
}

/* ==========================================================================
   Chart Tile Ribbon Bar (target=Ribbon)
   ========================================================================== */
.chart-ribbon-wrapper {
    height: 32px;
    min-height: 28px;
    max-height: 42px;
    display: none;
    flex-direction: column;
    border-top: 1px solid #1e293b;
    background: #090e17;
    position: relative;
    flex-shrink: 0;
}

.chart-ribbon-header {
    height: 15px;
    min-height: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    background: #070b12;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 9px;
    font-weight: 600;
    color: #94a3b8;
    user-select: none;
}

.chart-ribbon-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #cbd5e1;
    font-size: 9px;
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chart-ribbon-legend {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

.chart-ribbon-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 8.5px;
    color: #cbd5e1;
    font-family: 'JetBrains Mono', monospace;
}

.chart-ribbon-legend-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.chart-ribbon-close-btn {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 10px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    border-radius: 2px;
    transition: color 0.15s ease;
}

.chart-bear-ribbon-wrapper .chart-ribbon-header {
    position: relative;
    overflow: hidden;
}

.chart-bear-ribbon-wrapper .chart-ribbon-title {
    position: relative;
    z-index: 3;
    background: rgba(7, 11, 18, 0.92);
    padding-right: 6px;
    color: #94a3b8;
    font-size: 8.5px;
}

.chart-bear-ribbon-wrapper .chart-ribbon-close-btn {
    position: relative;
    z-index: 3;
    background: rgba(7, 11, 18, 0.92);
    padding-left: 4px;
}

.chart-bear-ribbon-wrapper .chart-ribbon-legend {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    margin-left: 0 !important;
    pointer-events: none;
    overflow: hidden;
    z-index: 2;
    display: block !important;
}

.bear-event-inline-label {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    color: #fbbf24;
    font-family: 'JetBrains Mono', monospace;
    font-size: 8.5px;
    font-weight: 700;
    white-space: nowrap;
    background: rgba(7, 11, 18, 0.88);
    padding: 0 3px;
    border-radius: 2px;
    line-height: 13px;
    pointer-events: auto;
    cursor: default;
}

.chart-ribbon-close-btn:hover {
    color: #ef4444;
}

.chart-ribbon-canvas {
    height: 17px;
    min-height: 15px;
    flex: 1 1 auto;
    width: 100%;
    position: relative;
    overflow: hidden;
}



/* ==========================================================================
   GROUPED BUTTON CONTROLS (Timeframe & Chart Type)
   ========================================================================== */
.chart-btn-group {
    display: inline-flex;
    align-items: center;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 1px;
    gap: 1px;
    flex-shrink: 0;
}

.chart-grp-btn {
    height: 22px;
    padding: 0 6px;
    background: transparent;
    border: none;
    border-radius: 3px;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
    transition: all 0.12s ease;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.chart-grp-btn:hover {
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.08);
}

.chart-grp-btn.active {
    background: #0284c7;
    color: #ffffff;
    font-weight: 800;
    box-shadow: 0 0 6px rgba(2, 132, 199, 0.4);
}

/* ==========================================================================
   LIGHT THEME OVERRIDES FOR CHARTS DESKTOP
   ========================================================================== */
[data-theme="light"] #page-charts.child-page.active,
body.light-theme #page-charts.child-page.active {
    background: #ffffff;
    border-color: #cbd5e1;
}

[data-theme="light"] .charts-workspace-left,
body.light-theme .charts-workspace-left {
    background: #f8fafc;
}

[data-theme="light"] .charts-top-toolbar,
body.light-theme .charts-top-toolbar {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
}

[data-theme="light"] .charts-tb-title,
body.light-theme .charts-tb-title {
    color: #0f172a;
}

[data-theme="light"] .charts-tb-btn,
body.light-theme .charts-tb-btn {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}

[data-theme="light"] .charts-tb-btn:hover,
body.light-theme .charts-tb-btn:hover {
    background: #e2e8f0;
    color: #0284c7;
    border-color: #0284c7;
}

[data-theme="light"] .charts-tb-layout-btn,
body.light-theme .charts-tb-layout-btn {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}

[data-theme="light"] .charts-tb-layout-btn.active,
body.light-theme .charts-tb-layout-btn.active {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
}

[data-theme="light"] .chart-tile,
body.light-theme .chart-tile {
    background: #ffffff;
    border-color: #cbd5e1;
}

[data-theme="light"] .chart-tile.active-chart,
body.light-theme .chart-tile.active-chart {
    border-color: #0284c7;
    box-shadow: 0 0 8px rgba(2, 132, 199, 0.25);
}

[data-theme="light"] .chart-tile-header,
body.light-theme .chart-tile-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

[data-theme="light"] .chart-sym-badge,
body.light-theme .chart-sym-badge {
    color: #0284c7;
}

[data-theme="light"] .chart-name-trunc,
body.light-theme .chart-name-trunc {
    color: #475569;
}

[data-theme="light"] .chart-price-val,
body.light-theme .chart-price-val {
    color: #0f172a;
}

[data-theme="light"] .chart-hdr-btn,
body.light-theme .chart-hdr-btn {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}

[data-theme="light"] .chart-hdr-btn:hover,
body.light-theme .chart-hdr-btn:hover {
    background: #e2e8f0;
    color: #0284c7;
    border-color: #0284c7;
}

[data-theme="light"] .chart-hdr-icon-btn,
body.light-theme .chart-hdr-icon-btn {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}

[data-theme="light"] .chart-btn-group,
body.light-theme .chart-btn-group {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

[data-theme="light"] .chart-grp-btn,
body.light-theme .chart-grp-btn {
    color: #475569;
}

[data-theme="light"] .chart-grp-btn:hover,
body.light-theme .chart-grp-btn:hover {
    color: #0f172a;
    background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .chart-grp-btn.active,
body.light-theme .chart-grp-btn.active {
    background: #0284c7;
    color: #ffffff;
}

[data-theme="light"] .charts-right-pane,
body.light-theme .charts-right-pane {
    background: #ffffff;
    border-left: 1px solid #cbd5e1;
}

[data-theme="light"] .scope-header,
body.light-theme .scope-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

[data-theme="light"] .scope-title,
body.light-theme .scope-title {
    color: #0f172a;
}

[data-theme="light"] .scope-select,
[data-theme="light"] .scope-input,
body.light-theme .scope-select,
body.light-theme .scope-input {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

[data-theme="light"] .scope-row,
body.light-theme .scope-row {
    color: #0f172a;
    border-bottom-color: #f1f5f9;
}

[data-theme="light"] .scope-row:hover,
body.light-theme .scope-row:hover {
    background: #f1f5f9;
}

[data-theme="light"] .scope-row.selected,
body.light-theme .scope-row.selected {
    background: #e0f2fe;
    color: #0369a1;
}

[data-theme="light"] .scope-sym,
body.light-theme .scope-sym {
    color: #0284c7;
}

[data-theme="light"] .scope-name,
body.light-theme .scope-name {
    color: #475569;
}

[data-theme="light"] .chart-osc-wrapper,
body.light-theme .chart-osc-wrapper {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

[data-theme="light"] .chart-osc-header,
body.light-theme .chart-osc-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

[data-theme="light"] .chart-osc-title,
body.light-theme .chart-osc-title {
    color: #334155;
}
