.graph-front-wrap {
    max-width: 1360px;
    margin: 1.5rem auto 3rem auto;
    padding: 0 1.25rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.graph-terminal-card {
    background: var(--card-bg, var(--bg-secondary, #1e293b));
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.22));
    border-radius: 14px;
    padding: 1.15rem 1.3rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}
[data-theme="light"] .graph-terminal-card {
    background: #ffffff;
    border-color: #cbd5e1;
}

/* Top Panel: Row 1 = Coin Identity + Live WS + Sync | Row 2 = Controls & Indicators */
.graph-top-panel {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--border-color, rgba(148, 163, 184, 0.18));
}

.graph-coin-identity {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
}
.graph-coin-identity img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.graph-coin-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}
.graph-coin-sym {
    font-size: 1.28rem;
    font-weight: 800;
    color: var(--text-main, var(--text-primary, #f8fafc));
    letter-spacing: -0.01em;
}
[data-theme="light"] .graph-coin-sym {
    color: #0f172a;
}
.graph-coin-name {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    background: rgba(148, 163, 184, 0.12);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
}
.graph-ws-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
    padding: 0.24rem 0.65rem;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.14);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
    cursor: pointer;
    user-select: none;
    box-sizing: border-box;
}
.graph-ws-badge.paused {
    background: rgba(148, 163, 184, 0.14);
    color: #94a3b8;
    border-color: rgba(148, 163, 184, 0.28);
}
.graph-ws-badge.reconnecting {
    background: rgba(245, 158, 11, 0.14);
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.35);
}
.graph-ws-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}
.graph-ws-badge.paused .graph-ws-dot {
    background: #94a3b8;
    box-shadow: none;
}
.graph-ws-badge.reconnecting .graph-ws-dot {
    background: #f59e0b;
    box-shadow: 0 0 8px #f59e0b;
}

/* Controls: Symbol Select | Interval (5m, 15m, 1h, 1d) | Indicators & Tools */
.graph-controls-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    width: 100%;
}
.graph-ctrl-field {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.graph-filter-input {
    height: 40px;
    width: 110px;
    padding: 0 0.55rem;
    border-radius: 8px;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.3));
    background: var(--bg-color, var(--bg-primary, #0f172a));
    color: var(--text-main, var(--text-primary, #f8fafc));
    font-size: 0.8rem;
    font-weight: 600;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s ease, width 0.15s ease;
}
.graph-filter-input::placeholder {
    color: var(--text-secondary, #64748b);
    font-weight: 500;
}
[data-theme="light"] .graph-filter-input {
    background: #f8fafc;
    color: #0f172a;
    border-color: #cbd5e1;
}
.graph-filter-input:focus {
    border-color: #3b82f6;
}
.graph-select {
    height: 40px;
    width: 195px;
    min-width: 160px;
    max-width: 220px;
    padding: 0 0.55rem;
    border-radius: 8px;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.3));
    background: var(--bg-color, var(--bg-primary, #0f172a));
    color: var(--text-main, var(--text-primary, #f8fafc));
    font-size: 0.82rem;
    font-weight: 600;
    outline: none;
    text-overflow: ellipsis;
}
[data-theme="light"] .graph-select {
    background: #f8fafc;
    color: #0f172a;
    border-color: #cbd5e1;
}
.graph-select:focus {
    border-color: #3b82f6;
}

.graph-itv-group {
    display: inline-flex;
    background: var(--bg-color, var(--bg-primary, #0f172a));
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.28));
    border-radius: 8px;
    padding: 3px;
    gap: 3px;
    height: 40px;
    align-items: center;
    box-sizing: border-box;
}
[data-theme="light"] .graph-itv-group {
    background: #f1f5f9;
    border-color: #cbd5e1;
}
.graph-itv-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.36rem 0.62rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.graph-itv-btn:hover {
    color: var(--text-main, #f8fafc);
}
[data-theme="light"] .graph-itv-btn:hover {
    color: #0f172a;
}
.graph-itv-btn.active {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.4);
}

.graph-sync-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
    padding: 0.24rem 0.65rem;
    border-radius: 999px;
    cursor: pointer;
    border: 1px solid rgba(59, 130, 246, 0.4);
    background: #dbeafe;
    color: #1e40af;
    transition: all 0.18s ease;
    white-space: nowrap;
    user-select: none;
    box-sizing: border-box;
}
.graph-sync-btn:hover {
    background: #bfdbfe;
    border-color: rgba(37, 99, 235, 0.55);
}

.graph-predict-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.2;
    padding: 0.24rem 0.68rem;
    border-radius: 999px;
    cursor: pointer;
    border: 1px solid rgba(56, 189, 248, 0.42);
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    transition: all 0.18s ease;
    white-space: nowrap;
    user-select: none;
    box-sizing: border-box;
}
[data-theme="light"] .graph-predict-btn {
    background: #e0f2fe;
    color: #0369a1;
    border-color: rgba(2, 132, 199, 0.4);
}
.graph-predict-btn:hover {
    background: rgba(56, 189, 248, 0.22);
    border-color: #38bdf8;
}
[data-theme="light"] .graph-predict-btn:hover {
    background: #bae6fd;
    border-color: #0284c7;
}
.graph-predict-btn.active {
    background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
    color: #ffffff !important;
    border-color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.45);
}
.graph-predict-btn.no-data {
    opacity: 0.58;
}

/* Moving Averages (MA) Popover Menu — Idea 2 + Global SMA/EMA Switch */
.graph-ma-dropdown-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.graph-ma-trigger-btn {
    height: 40px;
    padding: 0 0.9rem;
    border-radius: 8px;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.3));
    background: var(--bg-color, var(--bg-primary, #0f172a));
    color: var(--text-main, var(--text-primary, #f8fafc));
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: all 0.16s ease;
    user-select: none;
}
[data-theme="light"] .graph-ma-trigger-btn {
    background: #f8fafc;
    color: #0f172a;
    border-color: #cbd5e1;
}
.graph-ma-trigger-btn:hover,
.graph-ma-trigger-btn.open {
    border-color: #3b82f6;
}
.graph-ma-count-badge {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 19px;
    height: 19px;
    padding: 0 5px;
    border-radius: 999px;
    background: #2563eb;
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 800;
}
.graph-ma-count-badge.visible {
    display: inline-flex;
}
.graph-ma-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    z-index: 60;
    background: var(--card-bg, #1e293b);
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.3));
    border-radius: 12px;
    padding: 0.9rem 1rem;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
    display: none;
}
[data-theme="light"] .graph-ma-popover {
    background: #ffffff;
    border-color: #cbd5e1;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}
.graph-ma-popover.open {
    display: block;
}
.graph-ma-type-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    background: var(--bg-color, #0f172a);
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.25));
    border-radius: 8px;
    padding: 3px;
    margin-bottom: 0.85rem;
}
[data-theme="light"] .graph-ma-type-switch {
    background: #f1f5f9;
    border-color: #cbd5e1;
}
.graph-ma-type-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.42rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.graph-ma-type-btn.active {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.35);
}
.graph-ma-group-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.48rem 0;
    border-top: 1px solid var(--border-color, rgba(148, 163, 184, 0.14));
}
.graph-ma-group-label {
    border: none;
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-main, #e2e8f0);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    padding: 0.32rem 0.55rem;
    border-radius: 6px;
    cursor: pointer;
    min-width: 88px;
    text-align: left;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.15s ease;
}
[data-theme="light"] .graph-ma-group-label {
    background: #f1f5f9;
    color: #1e293b;
}
.graph-ma-group-label:hover {
    background: rgba(59, 130, 246, 0.22);
}
.graph-ma-pills {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1;
    justify-content: flex-end;
}
.graph-ma-pill {
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.28));
    background: var(--bg-color, #0f172a);
    color: var(--text-secondary, #94a3b8);
    font-size: 0.8rem;
    font-weight: 700;
    min-width: 58px;
    height: 32px;
    padding: 0 0.55rem;
    border-radius: 7px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: all 0.15s ease;
}
[data-theme="light"] .graph-ma-pill {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #475569;
}
.graph-ma-pill:hover {
    border-color: #64748b;
    color: var(--text-main, #f8fafc);
}
[data-theme="light"] .graph-ma-pill:hover {
    color: #0f172a;
}
.graph-ma-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.graph-ma-pill.active {
    color: #ffffff !important;
    background: rgba(37, 99, 235, 0.22);
}
[data-theme="light"] .graph-ma-pill.active {
    color: #0f172a !important;
    background: rgba(37, 99, 235, 0.12);
}
.graph-ma-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.65rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border-color, rgba(148, 163, 184, 0.16));
}
.graph-ma-hint {
    font-size: 0.71rem;
    color: var(--text-secondary, #94a3b8);
}
.graph-ma-clear-btn {
    border: 1px solid rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    font-size: 0.74rem;
    font-weight: 700;
    padding: 0.28rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.graph-ma-clear-btn:hover {
    background: rgba(239, 68, 68, 0.22);
}
.graph-legend-ma-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin-top: 4px;
    pointer-events: auto;
}
.graph-legend-ma-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 1px 6px;
    border-radius: 5px;
    font-size: 0.73rem;
    font-weight: 700;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
}
[data-theme="light"] .graph-legend-ma-chip {
    background: rgba(241, 245, 249, 0.92);
    border-color: rgba(148, 163, 184, 0.35);
}
.graph-legend-ma-remove {
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 0.76rem;
    font-weight: 800;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
}
.graph-legend-ma-remove:hover {
    color: #ef4444;
}

/* Supertrend Top Bar Button + Buy/Sell Signals Toggle */
.graph-st-group {
    display: inline-flex;
    align-items: center;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.3));
    background: var(--bg-color, var(--bg-primary, #0f172a));
    padding: 3px;
    gap: 3px;
    box-sizing: border-box;
    transition: border-color 0.16s ease;
}
[data-theme="light"] .graph-st-group {
    background: #f8fafc;
    border-color: #cbd5e1;
}
.graph-st-group.active-up {
    border-color: rgba(8, 153, 129, 0.65);
}
.graph-st-group.active-dn {
    border-color: rgba(242, 54, 69, 0.65);
}
.graph-st-btn {
    border: none;
    background: transparent;
    color: var(--text-main, var(--text-primary, #f8fafc));
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
    height: 32px;
    padding: 0 0.72rem;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: all 0.15s ease;
    user-select: none;
}
.graph-st-btn > span {
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
[data-theme="light"] .graph-st-btn {
    color: #0f172a;
}
.graph-st-btn.active {
    background: rgba(148, 163, 184, 0.14);
}
.graph-st-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #64748b;
    flex-shrink: 0;
    position: relative;
    top: 1px;
    transition: all 0.15s ease;
}
.graph-st-group.active-up .graph-st-dot {
    background: #089981;
    box-shadow: 0 0 7px #089981;
}
.graph-st-group.active-dn .graph-st-dot {
    background: #f23645;
    box-shadow: 0 0 7px #f23645;
}
.graph-st-sig-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary, #94a3b8);
    font-size: 0.74rem;
    font-weight: 800;
    height: 32px;
    padding: 0 0.55rem;
    border-radius: 6px;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.15s ease;
}
.graph-st-sig-btn.visible {
    display: inline-flex;
}
.graph-st-sig-btn.active {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.35);
}

/* Visible Range Volume Profile (VRVP) & Volume Unit (USDT / COIN) Group */
.graph-vp-group {
    display: inline-flex;
    align-items: center;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.3));
    background: var(--bg-color, var(--bg-primary, #0f172a));
    padding: 3px;
    gap: 3px;
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}
[data-theme="light"] .graph-vp-group {
    background: #f8fafc;
    border-color: #cbd5e1;
}
.graph-vp-group.active {
    border-color: rgba(56, 189, 248, 0.65);
}
.graph-vp-btn {
    border: none;
    background: transparent;
    color: var(--text-main, var(--text-primary, #f8fafc));
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
    height: 32px;
    padding: 0 0.62rem;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.34rem;
    transition: all 0.15s ease;
    user-select: none;
}
[data-theme="light"] .graph-vp-btn {
    color: #0f172a;
}
.graph-vp-btn.active {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.25), rgba(245, 158, 11, 0.25));
    color: #38bdf8;
}
[data-theme="light"] .graph-vp-btn.active {
    color: #0284c7;
}
.graph-vol-unit-btn {
    border: none;
    background: rgba(37, 99, 235, 0.18);
    color: #60a5fa;
    font-size: 0.72rem;
    font-weight: 800;
    height: 32px;
    padding: 0 0.55rem;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0.02em;
    transition: all 0.15s ease;
    user-select: none;
}
.graph-vol-unit-btn.unit-coin {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
}
[data-theme="light"] .graph-vol-unit-btn {
    background: rgba(37, 99, 235, 0.12);
    color: #1d4ed8;
}
[data-theme="light"] .graph-vol-unit-btn.unit-coin {
    background: rgba(245, 158, 11, 0.16);
    color: #b45309;
}

/* Sub-Pane Oscillator Toggles (RSI 14 & MACD 12,26,9) — Top Row Right-Aligned */
.graph-osc-group {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    background: var(--bg-color, var(--bg-primary, #0f172a));
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.28));
    border-radius: 8px;
    padding: 3px;
    gap: 3px;
    height: 36px;
    box-sizing: border-box;
}
[data-theme="light"] .graph-osc-group {
    background: #f1f5f9;
    border-color: #cbd5e1;
}
.graph-osc-btn {
    border: none;
    background: transparent;
    color: var(--text-main, var(--text-primary, #f8fafc));
    font-size: 0.76rem;
    font-weight: 800;
    line-height: 1;
    height: 28px;
    padding: 0 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.28rem;
    transition: all 0.15s ease;
    user-select: none;
}
[data-theme="light"] .graph-osc-btn {
    color: #0f172a;
}
.graph-osc-btn:hover {
    background: rgba(148, 163, 184, 0.12);
}
.graph-osc-btn.active-rsi {
    background: rgba(168, 85, 247, 0.22);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.48);
}
[data-theme="light"] .graph-osc-btn.active-rsi {
    background: rgba(168, 85, 247, 0.15);
    color: #7e22ce;
}
.graph-osc-btn.active-macd {
    background: rgba(56, 189, 248, 0.22);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.48);
}
[data-theme="light"] .graph-osc-btn.active-macd {
    background: rgba(2, 132, 199, 0.15);
    color: #0369a1;
}
.graph-osc-btn.active-stoch {
    background: rgba(16, 185, 129, 0.22);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.48);
}
[data-theme="light"] .graph-osc-btn.active-stoch {
    background: rgba(5, 150, 105, 0.15);
    color: #047857;
}
.graph-osc-btn.active-obv {
    background: rgba(245, 158, 11, 0.22);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.48);
}
[data-theme="light"] .graph-osc-btn.active-obv {
    background: rgba(217, 119, 6, 0.15);
    color: #b45309;
}
.graph-osc-btn.active-mfi {
    background: rgba(236, 72, 153, 0.22);
    color: #f472b6;
    border: 1px solid rgba(236, 72, 153, 0.48);
}
[data-theme="light"] .graph-osc-btn.active-mfi {
    background: rgba(219, 39, 119, 0.14);
    color: #be185d;
}

/* Synchronized Oscillator Sub-Panes (RSI, MACD, Stochastic, OBV & MFI) */
.graph-subpane-wrap {
    position: relative;
    width: 100%;
    height: 155px;
    margin-top: 6px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.2));
    background: #131722;
    display: none;
}
.graph-subpane-wrap.visible {
    display: block;
}
.graph-subpane-canvas,
.graph-subpane-canvas .tv-lightweight-charts {
    width: 100% !important;
    height: 100% !important;
}
.graph-subpane-legend {
    position: absolute;
    top: 6px;
    left: 10px;
    z-index: 10;
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    background: rgba(19, 23, 34, 0.84);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 0.74rem;
    font-weight: 700;
    color: #d1d4dc;
}
[data-theme="light"] .graph-subpane-legend {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(148, 163, 184, 0.35);
    color: #1e293b;
}
.graph-subpane-close {
    border: none;
    background: rgba(239, 68, 68, 0.16);
    color: #f87171;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    font-size: 0.74rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-left: 2px;
}
.graph-subpane-close:hover {
    background: #ef4444;
    color: #ffffff;
}
.graph-vp-svg {
    position: absolute;
    top: 0;
    bottom: 26px;
    left: 0;
    right: 70px;
    width: calc(100% - 70px);
    height: calc(100% - 26px);
    z-index: 6;
    pointer-events: none;
    overflow: hidden;
}

/* Manual Trend Line & S/R Drawing Toolbar + Interactive SVG Overlay */
.graph-draw-group {
    display: inline-flex;
    align-items: center;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.3));
    background: var(--bg-color, var(--bg-primary, #0f172a));
    padding: 3px;
    gap: 3px;
    box-sizing: border-box;
}
[data-theme="light"] .graph-draw-group {
    background: #f8fafc;
    border-color: #cbd5e1;
}
.graph-draw-btn {
    border: none;
    background: transparent;
    color: var(--text-main, var(--text-primary, #f8fafc));
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    height: 32px;
    padding: 0 0.62rem;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.34rem;
    transition: all 0.15s ease;
    user-select: none;
    white-space: nowrap;
}
[data-theme="light"] .graph-draw-btn {
    color: #0f172a;
}
.graph-draw-btn:hover {
    background: rgba(148, 163, 184, 0.12);
}
.graph-draw-btn.active-tool {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #0f172a;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.35);
}
.graph-draw-btn.active-magnet {
    background: rgba(56, 189, 248, 0.18);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.45);
}
.graph-draw-clear-btn {
    color: #f87171 !important;
    padding: 0 0.5rem;
}
.graph-draw-clear-btn:hover {
    background: rgba(239, 68, 68, 0.16);
}
.graph-draw-count {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    background: rgba(239, 68, 68, 0.22);
    color: #fca5a5;
    font-size: 0.68rem;
    font-weight: 800;
}
.graph-draw-count.visible {
    display: inline-flex;
}

.graph-drawing-svg {
    position: absolute;
    top: 0;
    bottom: 26px;
    left: 0;
    right: 70px;
    width: calc(100% - 70px);
    height: calc(100% - 26px);
    z-index: 12;
    pointer-events: none;
    overflow: hidden;
    user-select: none;
}
.graph-drawing-svg.drawing-mode {
    pointer-events: all;
    cursor: crosshair;
}
.graph-drawing-svg.dragging-mode {
    pointer-events: all;
    cursor: grabbing;
}
.graph-draw-hit {
    pointer-events: stroke;
    stroke: transparent;
    stroke-width: 14px;
    fill: none;
    cursor: grab;
}
.graph-draw-handle {
    pointer-events: all;
    cursor: pointer;
    transition: r 0.12s ease;
}
.graph-draw-handle:hover {
    r: 7px;
}
.graph-draw-del-badge {
    pointer-events: all;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.12s ease, transform 0.12s ease;
}
.graph-draw-del-badge:hover {
    opacity: 1;
}

/* Far-Left MA Price Badges + Horizontal Dotted Line to Right Price Scale */
.graph-left-ma-layer {
    position: absolute;
    top: 0;
    bottom: 26px;
    left: 0;
    right: 70px;
    z-index: 8;
    pointer-events: none;
    overflow: hidden;
}
.graph-left-ma-row {
    position: absolute;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    pointer-events: none;
}
.graph-left-ma-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.32rem;
    padding: 2px 7px 2px 8px;
    border-radius: 0 5px 5px 0;
    font-size: 0.7rem;
    font-weight: 800;
    line-height: 1.25;
    color: #0f172a;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
}
.graph-left-ma-line {
    flex: 1;
    height: 0;
    border-top: 1.5px dotted currentColor;
    opacity: 0.85;
}

/* Chart Canvas */
.graph-canvas-wrap {
    position: relative;
    width: 100%;
    height: 600px;
    margin-top: 1rem;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.2));
    background: #131722;
}
#graph-lw-container,
#graph-lw-container .tv-lightweight-charts {
    width: 100% !important;
    height: 100% !important;
}
.graph-legend {
    position: absolute;
    top: 10px;
    left: 12px;
    z-index: 10;
    pointer-events: none;
    background: rgba(19, 23, 34, 0.82);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.78rem;
    line-height: 1.45;
    color: #d1d4dc;
    max-width: calc(100% - 90px);
}
.graph-loading {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(2px);
    color: #f8fafc;
    font-weight: 700;
    font-size: 0.92rem;
}

/* Bottom-Right Corner Scale & Viewport Bar (log · auto · reset · fullscreen) */
.graph-corner-bar {
    position: absolute;
    bottom: 32px;
    right: 78px;
    z-index: 15;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border-radius: 7px;
    background: rgba(19, 23, 34, 0.86);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(148, 163, 184, 0.24);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    user-select: none;
}
[data-theme="light"] .graph-corner-bar {
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(148, 163, 184, 0.45);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
}
.graph-corner-btn {
    border: none;
    background: transparent;
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    padding: 0.24rem 0.5rem;
    border-radius: 5px;
    cursor: pointer;
    line-height: 1.1;
    transition: all 0.14s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
[data-theme="light"] .graph-corner-btn {
    color: #475569;
}
.graph-corner-btn:hover {
    background: rgba(148, 163, 184, 0.16);
    color: #f8fafc;
}
[data-theme="light"] .graph-corner-btn:hover {
    background: rgba(15, 23, 42, 0.08);
    color: #0f172a;
}
.graph-corner-btn.active {
    background: rgba(37, 99, 235, 0.25);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.45);
}
[data-theme="light"] .graph-corner-btn.active {
    background: rgba(37, 99, 235, 0.15);
    color: #1d4ed8;
    border: 1px solid rgba(37, 99, 235, 0.4);
}
.graph-corner-sep {
    width: 1px;
    height: 14px;
    background: rgba(148, 163, 184, 0.22);
    margin: 0 1px;
}

/* Fullscreen Terminal Mode */
.graph-terminal-card.graph-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    z-index: 9999 !important;
    display: flex !important;
    flex-direction: column !important;
    padding: 0.85rem 1.15rem !important;
    box-sizing: border-box !important;
}
.graph-terminal-card.graph-fullscreen .graph-canvas-wrap {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin-top: 0.75rem !important;
}
.graph-terminal-card.graph-fullscreen .graph-subpane-wrap.visible {
    flex: 0 0 140px !important;
    height: 140px !important;
}

@media (max-width: 900px) {
    .graph-select {
        min-width: 190px;
    }
    .graph-canvas-wrap {
        height: 460px;
    }
}
