/* CSS custom properties and theme tokens live in theme.css */

body {
    margin: 0;
    padding: 0;
    background-color: var(--ui-bg);
    color: var(--ui-fg);
    font-family: Arial, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    transition: background-color 120ms ease, color 120ms ease;
}

    /* TOP BAR */
    #topbar {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 50px;
        background: var(--ui-panel);
        display: flex;
        align-items: center;
        padding: 0 12px;
        z-index: 10;
        overflow: visible;  /* allow dropdowns to overflow */
    }

    .header-title-section {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        flex: 1;
        min-width: 0;
        overflow: visible;
    }

    .topbar-group {
        display: flex;
        align-items: center;
        gap: 6px;
        min-width: 0;
    }

    .topbar-group-primary {
        flex: 1;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        white-space: nowrap;
        min-width: 0;
    }

    .topbar-group-primary::-webkit-scrollbar {
        display: none;
    }

    .topbar-group-secondary {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        gap: 4px;
        position: relative;
    }

    /* Drawing-toolbar toggle button — hidden on large desktop, shown on tablet + mobile */
    .dt-mobile-toggle-btn {
        display: none;
        flex-shrink: 0;
    }
    @media (max-width: 1023px) {
        .dt-mobile-toggle-btn { display: inline-flex; }
    }

    /* Mobile row-break: invisible on desktop/tablet, active on mobile */
    .topbar-row-break {
        display: none;
    }

    /* Mobile overlay backdrop — hidden by default, managed by JS class on body */
    #dt-mobile-overlay {
        display: none;
    }

    @media (max-width: 1200px) {
        /* clocks are now fixed-positioned — no need to hide them */
        .status { display: none; }
    }

    @media (max-width: 920px) {
        .topbar-group-secondary .theme-select { display: none; }
        /* Market Watch stays visible even on tablet */
    }

    .topbar-divider {
        width: 1px;
        height: 22px;
        background: var(--ui-panel-border);
        opacity: 0.9;
        flex-shrink: 0;
    }

    .symbol-nav {
        position: relative;
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }

    /* ── Topbar live price ticker ── */
    .topbar-price-info {
        display: inline-flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        height: 38px;
        padding: 0 4px;
        flex-shrink: 0;
        gap: 1px;
    }

    .topbar-price-val {
        font-size: 14px;
        font-weight: 700;
        color: var(--ui-fg);
        letter-spacing: 0.01em;
        font-variant-numeric: tabular-nums;
        transition: color 0.25s;
        line-height: 1;
    }

    .topbar-price-val.price-up   { color: #26a69a; }
    .topbar-price-val.price-down { color: #ef5350; }

    .topbar-price-chg {
        font-size: 11px;
        font-weight: 500;
        color: #8892a4;
        letter-spacing: 0.01em;
        font-variant-numeric: tabular-nums;
        line-height: 1;
        transition: color 0.25s;
    }

    .topbar-price-chg.price-up   { color: #26a69a; }
    .topbar-price-chg.price-down { color: #ef5350; }

    @keyframes priceFlash {
        0%   { opacity: 1; }
        30%  { opacity: 0.35; }
        100% { opacity: 1; }
    }
    .topbar-price-val.flash { animation: priceFlash 0.32s ease; }

    .symbol-display-btn,
    .icon-action-btn,
    .tf-btn,
    .topbar-btn,
    .chart-type-btn {
        border: 1px solid transparent;
        color: var(--ui-fg);
        cursor: pointer;
        transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
        font-family: inherit;
    }

    .symbol-display-btn {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        height: 34px;
        padding: 0 14px;
        background: transparent;
        border-radius: 18px;
        font-size: 13px;
        font-weight: 700;
        letter-spacing: 0.02em;
        white-space: nowrap;
    }

    .symbol-display-btn:hover,
    .icon-action-btn:hover,
    .tf-btn:hover,
    .topbar-btn:hover,
    .chart-type-btn:hover {
        background: rgba(15, 23, 42, 0.06);
        border-color: var(--ui-panel-border);
    }

    .symbol-caret {
        opacity: 0.7;
        flex-shrink: 0;
    }

    .icon-action-btn {
        width: 32px;
        height: 32px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        background: transparent;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .symbol-search-modal.hidden {
        display: none;
    }

    .symbol-search-modal {
        position: fixed;
        inset: 0;
        z-index: 10000;
        display: flex;
        align-items: flex-start;
        justify-content: center;
        padding: 20px 16px;
    }

    .symbol-search-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(2, 6, 23, 0.4);
        backdrop-filter: blur(2px);
    }

    .symbol-search-dialog {
        position: relative;
        width: min(860px, calc(100vw - 32px));
        max-height: min(620px, calc(100vh - 40px));
        display: flex;
        flex-direction: column;
        background: #ffffff;
        border: 1px solid #d9dce3;
        border-radius: 12px;
        box-shadow: 0 18px 44px rgba(15, 23, 42, 0.2);
        overflow: hidden;
    }

    .symbol-search-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 16px 16px 12px;
    }

    .symbol-search-title {
        margin: 0;
        font-size: 16px;
        font-weight: 700;
        color: #111827;
    }

    .symbol-search-close-btn {
        width: 34px;
        height: 34px;
        border: none;
        background: transparent;
        color: #4b5563;
        border-radius: 10px;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .symbol-search-close-btn:hover {
        background: #f3f4f6;
        color: #111827;
    }

    .symbol-search-input-wrap {
        padding: 0 16px 12px;
    }

    .symbol-search-input-shell {
        display: flex;
        align-items: center;
        gap: 10px;
        min-height: 44px;
        border: 1px solid #d5dae3;
        border-radius: 12px;
        background: #ffffff;
        padding: 0 12px;
    }

    .symbol-search-input-shell:focus-within {
        border-color: rgba(38,166,154,0.65);
        box-shadow: 0 0 0 3px rgba(38,166,154,0.12);
    }

    .symbol-search-icon {
        color: #6b7280;
        flex-shrink: 0;
    }

    .symbol-search-input {
        flex: 1;
        min-width: 0;
        border: none;
        background: transparent;
        color: #111827;
        outline: none;
        font: inherit;
        font-size: 16px;
        line-height: 1.1;
        padding: 0;
    }

    .symbol-search-clear-btn {
        width: 30px;
        height: 30px;
        border: none;
        background: transparent;
        color: #6b7280;
        border-radius: 999px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
    }

    .symbol-search-clear-btn:hover {
        color: #111827;
        background: #f3f4f6;
    }

    .symbol-search-tabs {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 0 16px 10px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .symbol-search-tabs::-webkit-scrollbar {
        display: none;
    }

    .symbol-search-tab {
        border: none;
        background: #f3f4f6;
        color: #111827;
        height: 32px;
        padding: 0 12px;
        border-radius: 999px;
        font: inherit;
        font-size: 12px;
        font-weight: 600;
        cursor: pointer;
        white-space: nowrap;
    }

    .symbol-search-tab.active {
        background: #2f2f33;
        color: #ffffff;
    }

    .symbol-search-filters {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 0 16px 10px;
        border-bottom: 1px solid #eceef3;
    }


    .symbol-filter-btn {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        height: 32px;
        padding: 0 8px;
        border: none;
        background: transparent;
        color: #111827;
        font: inherit;
        font-size: 12px;
        font-weight: 500;
        cursor: pointer;
    }

    .symbol-filter-dropdown {
        position: relative;
    }

    .symbol-filter-menu.hidden {
        display: none;
    }

    .symbol-filter-menu {
        position: absolute;
        top: calc(100% + 8px);
        left: 0;
        min-width: 158px;
        max-height: 300px;
        overflow-y: auto;
        padding: 5px;
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
        z-index: 4;
    }

    .symbol-filter-menu-item {
        width: 100%;
        border: none;
        background: transparent;
        color: #111827;
        text-align: left;
        padding: 9px 11px;
        border-radius: 10px;
        font: inherit;
        font-size: 12px;
        font-weight: 500;
        cursor: pointer;
    }

    .symbol-filter-menu-item:hover {
        background: #f3f4f6;
    }

    .symbol-filter-menu-item.active {
        background: #2f2f33;
        color: #ffffff;
        font-weight: 600;
    }

    .symbol-search-body {
        min-height: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        flex: 1;
    }

    .symbol-dropdown-list {
        display: flex;
        flex-direction: column;
        gap: 4px;
        max-height: 280px;
        overflow-y: auto;
    }

    .symbol-search-results {
        gap: 0;
        max-height: none;
        min-height: 180px;
        padding: 0;
    }

    .symbol-dropdown-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 11px 16px;
        border: none;
        border-radius: 0;
        border-bottom: 1px solid #eceef3;
        background: transparent;
        color: #111827;
        cursor: pointer;
        font: inherit;
        font-weight: 600;
        text-align: left;
        width: 100%;
    }

    .symbol-dropdown-item:hover {
        background: #f8fafc;
    }

    .symbol-dropdown-item.keyboard-active {
        background: #f3f4f6;
    }

    .symbol-dropdown-item.selected {
        background: #f3f4f6;
        color: #111827;
    }

    .symbol-result-left {
        display: flex;
        align-items: center;
        gap: 12px;
        min-width: 0;
    }

    .symbol-result-icon {
        width: 24px;
        height: 24px;
        border-radius: 999px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: #edf2ff;
        color: #2563eb;
        font-size: 10px;
        font-weight: 700;
        flex-shrink: 0;
    }

    .symbol-dropdown-main {
        display: flex;
        align-items: center;
        gap: 18px;
        min-width: 0;
    }

    .symbol-dropdown-symbol {
        min-width: 96px;
        font-size: 14px;
        font-weight: 500;
        letter-spacing: 0.02em;
    }

    .symbol-dropdown-description {
        color: #111827;
        font-size: 13px;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 360px;
    }

    .symbol-result-right {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-left: auto;
        padding-left: 12px;
    }

    .symbol-dropdown-meta {
        color: #6b7280;
        font-size: 12px;
        font-weight: 500;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .symbol-result-exchange {
        color: #111827;
        font-size: 12px;
        font-weight: 600;
        white-space: nowrap;
    }

    .symbol-dropdown-empty {
        padding: 40px 10px 10px;
        text-align: center;
    }

    .symbol-dropdown-empty-title {
        font-size: 13px;
        font-weight: 700;
        color: #111827;
    }

    .symbol-dropdown-empty-subtitle {
        margin-top: 4px;
        font-size: 11px;
        color: #6b7280;
    }

    .symbol-dropdown-item mark {
        background: rgba(38,166,154,0.18);
        color: inherit;
        padding: 0 1px;
        border-radius: 3px;
    }

    body.symbol-search-open {
        overflow: hidden;
    }

    .symbol-search-footer {
        border-top: 1px solid #eceef3;
        padding: 10px 16px 12px;
        text-align: center;
        color: #6b7280;
        font-size: 12px;
        background: #fafafa;
    }

    /* ── Category chip grid ───────────────────────────── */
    .symbol-category-grid {
        padding: 6px 16px 12px;
    }

    /* Flat "All" grid — no section gaps, chips just wrap continuously */
    .symbol-category-grid-flat {
        padding: 10px 16px 14px;
    }
    .symbol-category-grid-flat .symbol-cat-chips {
        gap: 7px;
    }

    .symbol-cat-section {
        margin-bottom: 16px;
    }

    .symbol-cat-header {
        display: flex;
        align-items: baseline;
        gap: 6px;
        margin-bottom: 8px;
    }

    .symbol-cat-label {
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.06em;
        color: #9ea8b3;
        text-transform: uppercase;
    }

    .symbol-cat-count {
        font-size: 10px;
        color: #6b7280;
        letter-spacing: 0.03em;
    }

    .symbol-cat-chips {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .symbol-chip {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        padding: 4px 10px 4px 8px;
        border-radius: 4px;
        border: 1px solid #2a3140;
        background: transparent;
        color: #d1d4dc;
        font-size: 12px;
        font-weight: 500;
        font-family: inherit;
        cursor: pointer;
        white-space: nowrap;
        transition: border-color 0.13s, background 0.13s, color 0.13s;
    }

    .symbol-chip:hover {
        border-color: #26a69a;
        color: #fff;
        background: rgba(38,166,154,0.07);
    }

    .symbol-chip.symbol-chip-current {
        border-color: #26a69a;
        color: #26a69a;
        background: rgba(38,166,154,0.1);
    }

    .symbol-chip-dot {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .symbol-chip-dot.dot-active {
        background: #26a69a;
        box-shadow: 0 0 4px rgba(38,166,154,0.55);
    }

    .symbol-chip-dot.dot-inactive {
        background: #ef5350;
        box-shadow: 0 0 4px rgba(239,83,80,0.45);
    }

    .tv-alert-modal.hidden {
        display: none;
    }

    .tv-alert-modal {
        position: fixed;
        inset: 0;
        z-index: 10020;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 20px 16px;
    }

    .tv-alert-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(15, 23, 42, 0.22);
        backdrop-filter: blur(2px);
    }

    .tv-alert-dialog {
        position: relative;
        width: min(650px, calc(100vw - 32px));
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 14px;
        box-shadow: 0 20px 48px rgba(15, 23, 42, 0.16);
        overflow: hidden;
        color: #111827;
    }

    .tv-alert-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 18px 20px;
        border-bottom: 1px solid #eceef3;
    }

    .tv-alert-title-wrap {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
    }

    .tv-alert-title {
        margin: 0;
        font-size: 24px;
        line-height: 1.1;
        font-weight: 700;
        letter-spacing: -0.02em;
    }

    .tv-alert-symbol-btn,
    .tv-alert-icon-btn,
    .tv-alert-menu-btn,
    .tv-alert-inline-btn,
    .tv-alert-add-link,
    .tv-alert-footer-btn {
        font: inherit;
    }

    .tv-alert-symbol-btn {
        border: none;
        background: transparent;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 4px 0;
        color: #111827;
        font-size: 16px;
        font-weight: 600;
        cursor: pointer;
    }

    .tv-alert-symbol-badge {
        width: 24px;
        height: 24px;
        border-radius: 999px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: #2b7de9;
        color: #ffffff;
        font-size: 11px;
        font-weight: 700;
        flex-shrink: 0;
    }

    .tv-alert-header-actions {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .tv-alert-icon-btn {
        width: 36px;
        height: 36px;
        border: none;
        background: transparent;
        color: #4b5563;
        border-radius: 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    .tv-alert-icon-btn:hover {
        background: #f3f4f6;
        color: #111827;
    }

    .tv-alert-body {
        padding: 20px;
    }

    .tv-alert-section {
        padding-bottom: 18px;
        border-bottom: 1px solid #eceef3;
    }

    .tv-alert-row,
    .tv-alert-summary-row {
        display: grid;
        grid-template-columns: 146px minmax(0, 1fr);
        align-items: start;
        gap: 18px;
    }

    .tv-alert-label {
        color: #6b7280;
        font-size: 14px;
        font-weight: 600;
        line-height: 42px;
    }

    .tv-alert-condition-stack {
        display: grid;
        gap: 10px;
    }

    .tv-alert-static-field,
    .tv-alert-value-input,
    .tv-alert-datetime-input,
    .tv-alert-text-input {
        width: 100%;
        min-height: 42px;
        box-sizing: border-box;
        border: 1px solid #d7dce5;
        border-radius: 8px;
        background: #f7f7f8;
        color: #111827;
        padding: 0 14px;
        font-size: 14px;
    }

    .tv-alert-static-field {
        display: flex;
        align-items: center;
        font-weight: 500;
    }

    .tv-alert-menu-wrap {
        position: relative;
    }

    .tv-alert-menu-btn {
        width: 100%;
        min-height: 42px;
        border: 1px solid #8d949f;
        border-radius: 8px;
        background: #ffffff;
        color: #111827;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 0 14px;
        cursor: pointer;
    }

    .tv-alert-menu-btn-main {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
    }

    .tv-alert-condition-icon {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        color: #2f2f33;
        flex-shrink: 0;
    }

    .tv-alert-value-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .tv-alert-input-wrap {
        position: relative;
    }

    .tv-alert-value-input:focus,
    .tv-alert-datetime-input:focus,
    .tv-alert-text-input:focus {
        outline: none;
        border-color: #2962ff;
        box-shadow: 0 0 0 1px #2962ff inset;
        background: #ffffff;
    }

    .tv-alert-add-link {
        border: none;
        background: transparent;
        color: #2962ff;
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 4px 2px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        width: fit-content;
    }

    .tv-alert-summary {
        padding-top: 18px;
        display: grid;
        gap: 12px;
    }

    .tv-alert-summary-row {
        align-items: center;
    }

    .tv-alert-summary-row .tv-alert-label {
        line-height: 1.4;
    }

    .tv-alert-summary-control {
        min-width: 0;
    }

    .tv-alert-inline-btn {
        width: 100%;
        min-height: 32px;
        border: none;
        background: transparent;
        display: inline-flex;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        padding: 0;
        color: #111827;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
    }

    .tv-alert-menu.hidden {
        display: none;
    }

    .tv-alert-menu {
        position: absolute;
        left: 0;
        top: calc(100% + 8px);
        width: 100%;
        min-width: 260px;
        padding: 8px;
        background: #ffffff;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        box-shadow: 0 18px 36px rgba(15, 23, 42, 0.16);
        z-index: 4;
    }

    .tv-alert-menu-compact {
        width: min(360px, calc(100vw - 64px));
    }

    .tv-alert-menu-item {
        width: 100%;
        border: none;
        background: transparent;
        border-radius: 10px;
        padding: 10px 12px;
        display: flex;
        align-items: flex-start;
        gap: 10px;
        color: #111827;
        text-align: left;
        cursor: pointer;
    }

    .tv-alert-menu-item:hover {
        background: #f3f4f6;
    }

    .tv-alert-menu-item.active {
        background: #2f2f33;
        color: #ffffff;
    }

    .tv-alert-menu-icon {
        width: 22px;
        height: 22px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .tv-alert-menu-copy {
        display: grid;
        gap: 2px;
        min-width: 0;
    }

    .tv-alert-menu-title {
        font-size: 14px;
        font-weight: 600;
        line-height: 1.25;
    }

    .tv-alert-menu-subtitle {
        font-size: 12px;
        line-height: 1.35;
        color: #6b7280;
    }

    .tv-alert-menu-item.active .tv-alert-menu-subtitle {
        color: rgba(255, 255, 255, 0.8);
    }

    .tv-alert-footer {
        display: flex;
        justify-content: flex-end;
        gap: 12px;
        padding: 18px 20px;
        border-top: 1px solid #eceef3;
        background: #ffffff;
    }

    .tv-alert-footer-btn {
        min-width: 92px;
        height: 42px;
        border-radius: 8px;
        padding: 0 18px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
    }

    .tv-alert-footer-btn-secondary {
        border: 1px solid #e5e7eb;
        background: #ffffff;
        color: #111827;
    }

    .tv-alert-footer-btn-primary {
        border: 1px solid #111111;
        background: #111111;
        color: #ffffff;
    }

    .tv-alert-toast {
        position: fixed;
        right: 24px;
        bottom: 24px;
        z-index: 10030;
        min-width: 260px;
        max-width: min(420px, calc(100vw - 32px));
        padding: 14px 16px;
        border-radius: 12px;
        background: #111827;
        color: #ffffff;
        font-size: 13px;
        line-height: 1.45;
        box-shadow: 0 18px 38px rgba(15, 23, 42, 0.24);
        opacity: 0;
        pointer-events: none;
        transform: translateY(10px);
        transition: opacity 0.16s ease, transform 0.16s ease;
    }

    .tv-alert-toast.show {
        opacity: 1;
        transform: translateY(0);
    }

    @media (max-width: 760px) {
        .tv-alert-dialog {
            width: min(100vw - 20px, 560px);
        }

        .tv-alert-row,
        .tv-alert-summary-row {
            grid-template-columns: 1fr;
            gap: 8px;
        }

        .tv-alert-label {
            line-height: 1.2;
        }

        .tv-alert-value-row {
            grid-template-columns: 1fr;
        }
    }

    .title {
        font-size: 16px;
        font-weight: 600;
    }

    /* Market status dot (replaces "MARKET OPEN/CLOSED" text) */
    .status {
        width: 9px;
        height: 9px;
        border-radius: 999px;
        /* open */
        background: radial-gradient(circle at 28% 28%, rgba(255,255,255,0.95), rgba(255,255,255,0) 40%),
                    linear-gradient(180deg, #4fffe4, #00c2a8);
        margin-left: 0;
        flex-shrink: 0;
        box-shadow:
            0 0 0 1px rgba(255,255,255,0.14) inset,
            0 0 0 2px rgba(0, 194, 168, 0.18),
            0 2px 12px rgba(0, 194, 168, 0.55),
            0 0 18px rgba(79, 255, 228, 0.35);
    }

    .status.closed {
        /* closed */
        background: radial-gradient(circle at 28% 28%, rgba(255,255,255,0.95), rgba(255,255,255,0) 40%),
                    linear-gradient(180deg, #ff8f86, #ff2d55);
        box-shadow:
            0 0 0 1px rgba(255,255,255,0.14) inset,
            0 0 0 2px rgba(255, 45, 85, 0.18),
            0 2px 12px rgba(255, 45, 85, 0.50),
            0 0 18px rgba(255, 143, 134, 0.28);
    }

    /* ══════════════════════════════════════════
       DRAWING TOOLBAR  (left ribbon, TV-style)
       ══════════════════════════════════════════ */
    /* ── Range bar — lives inside #bottomBar .bottom-left, right of the calendar btn ── */
    #range-bar {
        display: flex;
        align-items: center;
        gap: 0;
        height: 100%;
        background: transparent;
        border: none;
        padding: 0;
        overflow: visible;
    }
    #range-bar .range-btn {
        background: transparent;
        border: none;
        color: var(--ui-fg);
        padding: 0 7px;
        height: 100%;
        cursor: pointer;
        border-radius: 3px;
        font-size: 12px;
        font-weight: 500;
        transition: color 0.12s, background 0.12s;
        white-space: nowrap;
        flex-shrink: 0;
        opacity: 0.65;
    }
    #range-bar .range-btn:hover {
        opacity: 1;
        background: var(--ui-button);
    }
    #range-bar .range-btn.active {
        color: #2962ff;
        font-weight: 600;
        opacity: 1;
    }
    .bottom-divider {
        width: 1px;
        height: 14px;
        background: var(--ui-panel-border);
        margin: 0 4px;
        flex-shrink: 0;
    }

    #drawing-toolbar {
        position: absolute;
        top: 50px;
        left: 0;
        width: 44px;
        bottom: 30px;
        background: var(--toolbar-bg, #1a1d2e);
        border-right: 1px solid var(--toolbar-border, #2e3347);
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 6px 0 6px;
        gap: 0;
        z-index: 20;
        overflow: visible;
        transition: background 0.15s;
    }

    /* Individual tool button */
    .dt-btn {
        position: relative;
        width: 32px;
        height: 32px;
        background: transparent;
        border: none;
        border-radius: 6px;
        color: var(--toolbar-icon, #ffffff);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        padding: 0;
        margin: 1px 0;
        transition: background 0.12s, color 0.12s;
        flex-shrink: 0;
    }
    .dt-btn svg {
        width: 18px;
        height: 18px;
        pointer-events: none;
    }
    .dt-btn:hover {
        background: var(--toolbar-hover, rgba(255,255,255,0.1));
        color: var(--toolbar-icon, #ffffff);
    }
    .dt-btn.active {
        background: var(--toolbar-hover, rgba(255,255,255,0.1));
        color: var(--toolbar-icon, #ffffff);
    }
    /* Toggle-on state (magnet, lock-all, visibility) */
    .dt-btn.toggle-on {
        background: #2962ff;
        color: #ffffff;
        border-radius: 6px;
    }
    .dt-btn.toggle-on:hover {
        background: #1e4fd4;
    }

    /* Hover tooltip (matches chart hover box vibe) */
    .dt-tooltip {
        position: fixed;
        z-index: 4000000;
        display: none;
        pointer-events: none;
        padding: 7px 10px;
        border-radius: 7px;
        background: rgba(30, 33, 48, 0.92);
        border: 1px solid rgba(58, 63, 85, 0.95);
        box-shadow: 0 6px 18px rgba(0,0,0,0.55);
        color: #d1d4dc;
        font: 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
        letter-spacing: 0.1px;
        white-space: nowrap;
        transform: translateY(-50%);
        opacity: 0;
        transition: opacity 0.08s ease;
        backdrop-filter: blur(4px);
    }
    .dt-tooltip.visible {
        display: block;
        opacity: 1;
    }

    /* Small triangle flyout indicator */
    .dt-arrow {
        position: absolute;
        bottom: 3px;
        right: 3px;
        width: 0;
        height: 0;
        border-style: solid;
        border-width: 0 0 4px 4px;
        border-color: transparent transparent currentColor transparent;
        opacity: 0.55;
        pointer-events: none;
    }

    /* Separator line */
    .dt-sep {
        width: 24px;
        height: 1px;
        background: var(--ui-panel-border);
        margin: 4px 0;
        flex-shrink: 0;
    }

    /* ── Flyout submenu ── */
    .dt-flyout {
        position: fixed;
        left: 44px;
        min-width: 248px;
        max-height: calc(100vh - 90px);
        overflow-y: auto;
        overflow-x: hidden;
        background: var(--ui-panel, #1e222d);
        color: var(--ui-fg, #e5e7eb);
        border: 1px solid var(--ui-panel-border, #333);
        border-radius: 4px;
        box-shadow: 0 4px 20px rgba(0,0,0,0.35);
        padding: 4px 0;
        z-index: 2000000;
        display: none;
        pointer-events: none;
        opacity: 0;
        transform: translateX(-6px);
        transition: opacity 0.1s ease, transform 0.1s ease;
        scrollbar-width: thin;
        scrollbar-color: var(--ui-button-hover) transparent;
    }
    .dt-flyout::-webkit-scrollbar { width: 4px; }
    .dt-flyout::-webkit-scrollbar-thumb { background: var(--ui-button-hover); border-radius: 2px; }
    .dt-flyout.visible {
        display: block;
        pointer-events: all;
        opacity: 1;
        transform: translateX(0);
    }

/* ── Drawing floating toolbar ── */
/* ═══════════════════════════════════════════
   DRAWING FLOATING TOOLBAR
═══════════════════════════════════════════ */
#drawing-popup {
    display: none;
    position: fixed;
    z-index: 3000000;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.16), 0 1px 4px rgba(0,0,0,0.08);
    padding: 5px 8px;
    font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    user-select: none;
    align-items: center;
    gap: 1px;
    flex-direction: row;
    min-height: 44px;
}
.dp-drag {
    color: #c4c8d0;
    cursor: grab;
    padding: 2px 4px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.dp-drag:active { cursor: grabbing; }
.dp-div {
    width: 1px;
    height: 22px;
    background: #e5e7eb;
    margin: 0 4px;
    flex-shrink: 0;
}
.dp-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #374151;
    padding: 5px 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.1s, color 0.1s;
    position: relative;
    flex-shrink: 0;
    min-width: 28px;
    justify-content: center;
}
.dp-btn:hover { background: #f0f2f5; color: #111827; }
.dp-btn.active { background: #eff6ff; color: #2962ff; }
.dp-btn.snap-on { color: #2962ff; background: #eff6ff; }
.dp-caret { opacity: 0.45; flex-shrink: 0; }
/* color swatch circle */
#dp-color-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #2196F3;
    border: 1.5px solid rgba(0,0,0,0.18);
    display: inline-block;
    flex-shrink: 0;
}
/* delete button hover red */
.dp-del-btn:hover { background: #fef2f2 !important; color: #ef5350 !important; }
/* lock active amber */
#dp-lock-btn.locked { color: #f59e0b; background: #fffbeb; }
/* width label */
#dp-width-label { font-size: 11px; color: #6b7280; margin: 0 1px; }
/* ── Dropdowns ── */
.dp-dropdown {
    display: none;
    position: fixed;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: 5px;
    z-index: 3100000;
    min-width: 130px;
}
.dp-dropdown.open { display: block; }
.dp-drop-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 10px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    color: #374151;
    font-size: 12px;
    font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    transition: background 0.1s;
    white-space: nowrap;
}
.dp-drop-item:hover { background: #f0f2f5; }
.dp-drop-item.active { background: #eff6ff; color: #2962ff; }
.dp-drop-sep {
    height: 1px;
    background: #e5e7eb;
    margin: 4px 0;
}
/* more dropdown wider */
.dp-more-drop { min-width: 150px; }
/* tooltip on hover via title (native) is enough; add CSS tooltip as fallback */
.dp-btn[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: #fff;
    font-size: 11px;
    padding: 3px 7px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.92;
}

/* ── Chart text/note input popup ── */
#chart-text-input-wrap {
    display: none;
    position: fixed;
    z-index: 3100000;
    background: #1e2130;
    border: 1px solid #3a3f55;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.65);
    padding: 10px;
    min-width: 210px;
    font-family: -apple-system, 'Segoe UI', sans-serif;
}
#chart-text-input-label {
    font-size: 11px;
    font-weight: 600;
    color: #9598a1;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    margin-bottom: 6px;
    display: block;
}
#chart-text-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    background: #131722;
    border: 1px solid #3a3f55;
    border-radius: 4px;
    color: #d1d4dc;
    font-size: 13px;
    line-height: 1.4;
    padding: 6px 8px;
    resize: vertical;
    outline: none;
    min-height: 56px;
    font-family: inherit;
}
#chart-text-input:focus { border-color: #2962ff; }
.cti-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 7px;
}
.cti-btn {
    padding: 5px 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
}
#chart-text-ok     { background: #2962ff; color: #fff; }
#chart-text-ok:hover { background: #1e4fc2; }
#chart-text-cancel { background: #2a2e39; color: #9598a1; }
#chart-text-cancel:hover { background: #363b4d; }

/* ── Emoji picker ── */
#chart-emoji-picker {
    display: none;
    position: fixed;
    z-index: 3100000;
    background: #1e2130;
    border: 1px solid #3a3f55;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.65);
    padding: 8px;
    width: 218px;
    font-family: -apple-system, 'Segoe UI', sans-serif;
}
#chart-emoji-picker .cep-title {
    font-size: 11px;
    font-weight: 600;
    color: #9598a1;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    margin-bottom: 6px;
}
#cep-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 2px;
}
.cep-emoji {
    font-size: 20px;
    padding: 5px 2px;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 4px;
    text-align: center;
    transition: background 0.1s;
    line-height: 1;
}
.cep-emoji:hover { background: rgba(255,255,255,0.1); }
    .dt-fly-item {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
        padding: 7px 14px;
        background: transparent;
        border: none;
        color: var(--ui-fg, #e5e7eb);
        cursor: pointer;
        font-size: 13px;
        font-family: inherit;
        text-align: left;
        transition: background 0.1s;
        white-space: nowrap;
    }
    .dt-fly-item:hover,
    .dt-fly-item.active {
        background: #3875d7;
        color: #ffffff;
    }
    .dt-fly-icon {
        width: 20px;
        height: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        color: inherit;
    }
    .dt-fly-icon svg {
        width: 16px;
        height: 16px;
    }
    .dt-fly-label {
        flex: 1;
    }
    /* Section group header */
    .dt-fly-section {
        padding: 10px 14px 4px;
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: #888;
        pointer-events: none;
        user-select: none;
    }
    .dt-fly-section:not(:first-child) {
        border-top: 1px solid #e5e7eb;
        margin-top: 4px;
    }
    /* Keyboard shortcut hint on the right */
    .dt-fly-shortcut {
        margin-left: 16px;
        font-size: 11px;
        color: #999;
        opacity: 0.55;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .dt-fly-item:hover .dt-fly-shortcut,
    .dt-fly-item.active .dt-fly-shortcut {
        opacity: 0.75;
    }

    /* Light theme adjustments */
    html[data-theme="light"] .dt-flyout {
        box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    }

    /* Hide OHLC tooltip and crosshairs while a tool flyout is open */
    body:has(.dt-flyout.visible) #chart-ohlc-float,
    body:has(.dt-flyout.visible) #crosshair-x,
    body:has(.dt-flyout.visible) #crosshair-y,
    body:has(.dt-flyout.visible) #axis-label-x,
    body:has(.dt-flyout.visible) #axis-label-y { display: none !important; }

    /* Legacy .tool kept for any older references */
    .tool {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        border-radius: 4px;
    }

    /* RIGHT PANEL (Hidden for now, but kept for structure) */
    #rightPanel {
        display: none;
        position: absolute;
        top: 50px;
        right: 0;
        width: 120px;
        bottom: 30px;
        background: var(--ui-panel);
        border-left: 1px solid var(--ui-panel-border);
        overflow-y: auto;
        z-index: 10;
    }

    .priceRow {
        padding: 4px 8px;
        font-size: 12px;
        border-bottom: 1px solid var(--ui-panel-border);
    }

    /* CHART AREA — position is now managed by #chart-layout-area grid */
    .chart-container {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--chart-bg);
        cursor: crosshair;
    }

    /* .topbar-feature-hidden and #market-status rules live in theme.css */

    /* ── UTC / IST clocks — fixed bottom-right, aligned with bottom bar ── */
    #topbar-clocks {
        position: fixed;
        bottom: 0;
        right: 46px;          /* sits beside the right sidebar */
        height: 30px;
        z-index: 500;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        font-family: monospace;
        font-size: 11px;
        color: var(--ui-muted);
        padding: 0 14px;
        pointer-events: none;
        user-select: none;
        white-space: nowrap;
    }

    .clock-row {
        display: flex;
        align-items: center;
        gap: 5px;
        line-height: 1.3;
    }

    .clock-label {
        color: var(--ui-muted);
        opacity: 0.7;
    }

    .clock-value {
        min-width: 58px;
    }

    #ohlc {
        position: static;
        display: flex;
        align-items: center;
        gap: 16px;
        color: var(--ui-fg);
        font-size: 12px;
        font-family: monospace;
        font-weight: 500;
        white-space: nowrap;
    }

    canvas {
        display: block;
        width: 100%;
        height: 100%;
    }

    /* BOTTOM BAR */
    #bottomBar {
        position: absolute;
        left: 0;
        right: 46px;          /* don't go under the right sidebar */
        bottom: 0;
        height: 30px;
        background: var(--ui-panel);
        border-top: 1px solid var(--ui-panel-border);
        display: flex;
        align-items: center;
        padding-left: 10px;
        z-index: 10;
    }

    .bottom-left {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .floating-chart-nav {
        position: absolute;
        bottom: 24px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        gap: 6px;
        z-index: 100;
        padding: 4px;
        opacity: 0.55;
        visibility: visible;
        pointer-events: auto;
        transition: opacity 0.2s ease;
    }

    .chart-container:hover .floating-chart-nav,
    .floating-chart-nav:focus-within {
        opacity: 1;
    }

    @media (hover: none) {
        .floating-chart-nav {
            opacity: 0.7;
            visibility: visible;
            pointer-events: auto;
        }
        .floating-chart-nav:active {
            opacity: 1;
        }
    }

    .floating-btn-group {
        display: flex;
        align-items: center;
        background: var(--ui-panel);
        border: 1px solid var(--ui-panel-border);
        border-radius: 8px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.08);
        overflow: hidden;
    }

    .floating-btn-group .divider {
        width: 1px;
        height: 16px;
        background: var(--ui-panel-border);
        opacity: 0.6;
    }

    .floating-chart-nav button {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        border: none;
        background: transparent;
        color: var(--ui-fg);
        cursor: pointer;
        transition: background 0.15s, color 0.15s, transform 0.1s;
        margin: 0;
        padding: 0;
    }

    .floating-chart-nav button.standalone-btn {
        background: var(--ui-panel);
        border: 1px solid var(--ui-panel-border);
        border-radius: 8px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.08);
    }

    .floating-chart-nav button:hover {
        background: var(--ui-button-hover);
        color: var(--chart-axis-fg);
    }

    .floating-chart-nav button.standalone-btn:active {
        transform: scale(0.95);
    }

    .floating-chart-nav button svg {
        pointer-events: none;
        color: inherit;
    }

    .bottom-right {
        margin-left: auto;
        padding-right: 12px;
        display: flex;
        align-items: center;
    }

    #bottomBar button,
    #bottomBar .range-btn {
        margin-right: 2px;
        background: transparent;
        border: none;
        color: var(--ui-muted);
        padding: 3px 7px;
        cursor: pointer;
        border-radius: 3px;
        font-size: 12px;
        font-weight: 500;
        transition: color 0.1s, background 0.1s;
        display: inline-flex;
        align-items: center;
        gap: 3px;
    }

    #bottomBar button:hover,
    #bottomBar .range-btn:hover {
        color: var(--ui-fg);
        background: var(--ui-button);
    }

    #bottomBar .range-btn.active {
        color: #2962ff;
        font-weight: 600;
    }

    .range-cal-btn {
        padding: 3px 6px !important;
    }

    /* Range buttons in the topbar (#rangeSelectorWrap) */
    #rangeSelectorWrap .range-btn {
        background: transparent;
        border: none;
        color: var(--ui-muted);
        padding: 3px 6px;
        cursor: pointer;
        border-radius: 3px;
        font-size: 12px;
        font-weight: 500;
        transition: color 0.1s, background 0.1s;
        display: inline-flex;
        align-items: center;
        white-space: nowrap;
    }
    #rangeSelectorWrap .range-btn:hover {
        color: var(--ui-fg);
        background: var(--ui-button);
    }
    #rangeSelectorWrap .range-btn.active {
        color: #2962ff;
        font-weight: 600;
    }

    /* Original overlays */
    .crosshair-x {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 30px;
        width: 0;
        pointer-events: none;
        display: none;
        border-right: 1px dashed var(--chart-crosshair);
        opacity: 0.75;
    }

    .crosshair-y {
        position: absolute;
        left: 0;
        right: 60px;
        top: 0;
        height: 0;
        pointer-events: none;
        display: none;
        border-bottom: 1px dashed var(--chart-crosshair);
        opacity: 0.75;
    }

    .axis-label-x,
    .axis-label-y {
        position: absolute;
        background: var(--chart-axis-bg);
        color: var(--chart-axis-fg);
        padding: 3px 7px;
        font-size: 11px;
        font-weight: 600;
        border-radius: 3px;
        pointer-events: none;
        display: none;
        z-index: 5;
        white-space: nowrap;
        box-shadow: 0 1px 6px rgba(33,150,243,0.35);
        letter-spacing: 0.01em;
    }

/* Theme button, panel, and swatch styles live in theme.css */

/* Symbols dropdown */
.symbols-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.symbols-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.symbols-btn::after {
    content: "▾";
    font-size: 11px;
    opacity: 0.85;
}

.symbols-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 260px;
    max-width: calc(100vw - 24px);
    background: var(--ui-panel);
    border: 1px solid var(--ui-panel-border);
    border-radius: 8px;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.25);
    padding: 10px;
    display: none;
    z-index: 50;
}

.symbols-dropdown.open .symbols-menu {
    display: block;
}

.symbols-search {
    padding-bottom: 8px;
    border-bottom: 1px solid var(--ui-panel-border);
    margin-bottom: 8px;
}

.symbols-search input {
    width: 100%;
    box-sizing: border-box;
    background: var(--ui-button);
    color: var(--ui-fg);
    border: 1px solid var(--ui-panel-border);
    border-radius: 6px;
    padding: 8px 10px;
    outline: none;
}

.symbols-search input:focus {
    border-color: rgba(38, 166, 154, 0.7);
}

.symbols-list {
    max-height: 320px;
    overflow: auto;
    display: flex;
    flex-direction: column;
        gap: 2px;
    }


.symbol-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    color: var(--ui-fg);
    background: transparent;
    font-weight: 700;
}

.symbol-item:hover {
    background: var(--ui-button-hover);
}

.symbol-item.selected {
    background: rgba(38, 166, 154, 0.15);
    outline: 1px solid rgba(38, 166, 154, 0.35);
}

.symbol-item .muted {
    font-weight: 600;
    color: var(--ui-muted);
    font-size: 11px;
}

/* ─── TradingView-style Topbar Elements ───────────────────── */

/* Timeframe button group */
.tf-group {
    display: flex;
    gap: 2px;
    align-items: center;
}

/* ── Chart-type selector (Bar / Candle / Line) ── */
.chart-type-group {
    display: flex;
    align-items: center;
    gap: 2px;
    background: transparent;
    border: none;
    border-radius: 10px;
    padding: 0;
}
.chart-type-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 34px;
    background: transparent;
    border-radius: 10px;
    color: var(--ui-muted);
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
    padding: 0;
}
.chart-type-btn:hover  { color: var(--ui-fg); }
.chart-type-btn.active { background: transparent; color: var(--ui-fg); }

/* Layout picker button — same style as chart-type-btn */
.layout-picker-btn { border-radius: 10px; }
.layout-picker-btn:hover { background: var(--ui-button-hover); color: var(--ui-fg); }
.layout-picker-wrap { position: relative; display: flex; align-items: center; }

/* ── Layout picker dropdown ── */
.layout-picker-dropdown {
    position: fixed;
    background: var(--ui-panel);
    border: 1px solid var(--ui-panel-border, rgba(128,128,128,.2));
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.28);
    z-index: 9999;
    width: 290px;
    overflow: hidden;
    user-select: none;
}
.layout-picker-dropdown.hidden { display: none; }

/* Equal sizes button */
.lp-equal-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: calc(100% - 24px);
    margin: 12px 12px 8px;
    padding: 8px 14px;
    border: 1.5px solid var(--ui-panel-border, rgba(128,128,128,.25));
    border-radius: 8px;
    background: transparent;
    color: var(--ui-fg);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s, border-color 0.12s;
    box-sizing: border-box;
}
.lp-equal-btn:hover {
    background: rgba(128,128,128,.09);
    border-color: var(--ui-fg);
}
.lp-equal-btn svg { flex-shrink: 0; }

/* Hover grid */
.lp-hover-grid {
    padding: 4px 14px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
}
.lp-hover-row {
    display: flex;
    gap: 4px;
}
.lp-hover-cell {
    width: 46px;
    height: 38px;
    border: 1.5px solid rgba(128,128,128,.22);
    border-radius: 7px;
    background: transparent;
    flex-shrink: 0;
    transition: background 0.08s, border-color 0.08s;
}
.lp-hover-cell-on {
    background: rgba(56, 189, 177, 0.20);
    border-color: rgba(56, 189, 177, 0.70);
}
.lp-hover-cell:hover {
    border-color: rgba(56, 189, 177, 0.90);
}

/* Dimension label */
.lp-dim-label {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--ui-fg);
    padding: 8px 0 6px;
    min-height: 30px;
    letter-spacing: 0.3px;
}

/* Divider */
.lp-divider {
    height: 1px;
    background: var(--ui-panel-border, rgba(128,128,128,.2));
    margin: 0;
}

/* ── Sync in Layout section ── */
.lp-sync {
    padding: 10px 14px 14px;
}
.lp-sync-hdr {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .7px;
    color: var(--ui-muted, #888);
    text-transform: uppercase;
    margin-bottom: 8px;
}
.lp-sync-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 13px;
    color: var(--ui-fg);
}
.lp-sync-lbl {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ── SYNC info icon ── */
.lp-sync-info {
    display: inline-flex;
    align-items: center;
    color: var(--ui-muted, #8a8a8a);
    cursor: default;
}
.lp-sync-info svg { display: block; }

/* Toggle switch */
.lp-tog {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
}
.lp-tog input { opacity: 0; width: 0; height: 0; position: absolute; }
.lp-tog-rail {
    position: absolute;
    inset: 0;
    background: rgba(128,128,128,.3);
    border-radius: 11px;
    transition: background 0.2s;
    cursor: pointer;
}
.lp-tog-rail::before {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.lp-tog input:checked + .lp-tog-rail { background: var(--accent, #2962ff); }
.lp-tog input:checked + .lp-tog-rail::before { transform: translateX(16px); }

/* ── Chart tab bar (MT4 style) ── */
#pane-tabbar {
    position: absolute;
    left: 44px;
    right: 46px;
    bottom: 30px;
    height: 26px;
    z-index: 6;
    display: flex;
    align-items: stretch;
    background: var(--ui-panel);
    border-top: 1px solid var(--ui-panel-border);
    overflow: hidden;
    z-index: 5;
    user-select: none;
}
#pane-tab-list {
    display: flex;
    align-items: stretch;
    flex: 1;
    overflow: hidden;
    gap: 0;
}
.pane-tab {
    display: flex;
    align-items: center;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--ui-muted);
    border-right: 1px solid var(--ui-panel-border);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
    position: relative;
    min-width: 80px;
}
.pane-tab:hover { background: rgba(120,123,134,0.1); color: var(--ui-fg); }
.pane-tab.pane-tab-active {
    background: var(--ui-bg, #131722);
    color: var(--ui-fg);
    font-weight: 700;
    border-top: 2px solid #2196F3;
}
/* Drag-over highlight */
.pane-tab.tab-drag-over {
    background: rgba(33,150,243,0.15);
    border-left: 2px solid #2196F3;
}
.tab-nav-btns {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    border-left: 1px solid var(--ui-panel-border);
}
.tab-nav-btn {
    width: 22px;
    height: 26px;
    border: none;
    background: transparent;
    color: var(--ui-muted);
    cursor: pointer;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s;
    padding: 0;
}
.tab-nav-btn:hover { background: rgba(120,123,134,0.15); color: var(--ui-fg); }

/* ── Multi-chart layout area ── */
#chart-layout-area {
    position: absolute;
    top: 50px;
    left: 44px;
    right: 46px;    /* leave room for right sidebar icon strip */
    bottom: 56px;   /* 30px status bar + 26px tab bar */
    display: flex;
    flex-direction: column;
    background: #e8e8e8;
    transition: right 0.2s ease;
}

/* Each horizontal row of charts */
.chart-row {
    display: flex;
    flex-direction: row;
    flex: 1 1 0%;
    min-height: 0;
}
.chart-row > .chart-pane,
.chart-row > .chart-pane-main {
    min-width: 0;
    min-height: 0;
    flex: 1 1 0%;
}

/* ── Drag-resize handles ── */
.grid-rsz-hdl {
    z-index: 50;
    position: relative;
    background: rgba(255,255,255,0.06);
    transition: background 0.12s;
}
.grid-rsz-hdl:hover,
.grid-rsz-hdl:active { background: rgba(41,98,255,0.28); }

/* Visible drag icon in the center of each handle */
.grid-rsz-hdl::after {
    content: '';
    position: absolute;
    border-radius: 3px;
    background: rgba(180,180,200,0.0);
    transition: background 0.12s, opacity 0.12s;
    opacity: 0;
}
.grid-rsz-hdl:hover::after,
.grid-rsz-hdl:active::after { opacity: 1; background: rgba(41,98,255,0.7); }

/* Vertical handle (between columns) — show ⟺ grab pill */
.grid-rsz-v {
    cursor: col-resize;
    width: 8px;
    flex-shrink: 0;
}
.grid-rsz-v::after {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 36px;
}

/* Horizontal handle (between rows) — show ⟺ grab pill rotated */
.grid-rsz-h {
    cursor: row-resize;
    height: 8px;
    flex-shrink: 0;
    width: 100%;
}
.grid-rsz-h::after {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 4px;
}

/* Arrow icon overlaid on the handle — ◁▷ */
.grid-rsz-v .rsz-icon,
.grid-rsz-h .rsz-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    line-height: 1;
    color: rgba(160,170,200,0.0);
    pointer-events: none;
    user-select: none;
    transition: color 0.12s;
    white-space: nowrap;
}
.grid-rsz-hdl:hover .rsz-icon,
.grid-rsz-hdl:active .rsz-icon { color: #fff; }

/* Equal-sizes reset button — kept for backwards compat but unused */
.lp-equal-btn {
    display: block;
    width: 100%;
    margin-bottom: 8px;
    padding: 5px 8px;
    background: var(--ui-button);
    border: 1px solid var(--ui-panel-border);
    border-radius: 4px;
    color: var(--ui-fg);
    font-size: 11px;
    cursor: pointer;
    text-align: center;
    letter-spacing: 0.3px;
}
.lp-equal-btn:hover { background: rgba(38,166,154,0.25); border-color: #26a69a; }

/* ── Chart-type dropdown ── */
.ct-dropdown {
    background: var(--ui-panel-bg);
    border: 1px solid var(--ui-panel-border);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    padding: 4px 0;
    min-width: 200px;
    font-size: 12px;
    color: var(--ui-fg);
    user-select: none;
    max-height: 80vh;
    overflow-y: auto;
}
.ct-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    cursor: pointer;
    transition: background 0.1s;
    border-radius: 3px;
    margin: 1px 4px;
}
.ct-row:hover    { background: var(--ui-button-hover); }
.ct-row.ct-active { background: rgba(41,98,255,0.15); color: #2962ff; }
.ct-icon { display:flex; align-items:center; flex-shrink:0; opacity:0.85; }
.ct-row.ct-active .ct-icon { opacity:1; }
.ct-label { flex:1; white-space:nowrap; }
.ct-sep {
    height: 1px;
    background: var(--ui-panel-border);
    margin: 4px 10px;
}

/* ── Pane drag-to-reposition ── */
.pane-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 100%;
    font-size: 14px;
    color: rgba(150,155,175,0.4);
    cursor: grab;
    flex-shrink: 0;
    user-select: none;
    transition: color 0.12s;
    margin-right: 2px;
}
.pane-drag-handle:hover { color: rgba(150,155,175,0.9); }
.pane-drag-handle:active { cursor: grabbing; }

.pane-dragging { opacity: 0.45; }
.pane-drag-over { outline: 2px solid #2962ff; outline-offset: -2px; }

/* When market watch panel is open, shrink chart area to make room */
#chart-layout-area.mw-open {
    right: 328px;   /* 282px panel + 46px icon strip */
}

/* Pane-0 wrapper — must fill its grid cell exactly */
.chart-pane-main {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* ── Chart loading overlay ─────────────────────────────────── */
.chart-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: var(--chart-bg, #131722);
    transition: opacity 0.3s ease;
    pointer-events: none; /* never block chart interaction — crosshair/drag work through the overlay */
}

.clo-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255,255,255,0.08);
    border-top-color: #2196F3;
    border-radius: 50%;
    animation: clo-spin 0.75s linear infinite;
}

@keyframes clo-spin {
    to { transform: rotate(360deg); }
}

.clo-text {
    font-size: 12px;
    color: rgba(255,255,255,0.35);
    letter-spacing: 0.03em;
}

html[data-theme="light"] .chart-loading-overlay {
    background: #f0f3fa;
}

html[data-theme="light"] .clo-spinner {
    border-color: rgba(0,0,0,0.08);
    border-top-color: #2196F3;
}

html[data-theme="light"] .clo-text {
    color: rgba(0,0,0,0.35);
}

/* chart-container fills pane-0 below the header */
.chart-pane-main > .chart-container {
    position: absolute !important;
    top: 28px !important;   /* 28px pane-header */
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
}

/* Minimized state for pane-0 */
.chart-pane-main.pane-minimized {
    height: 28px !important;
    min-height: 28px !important;
    overflow: hidden;
}
.chart-pane-main.pane-minimized > .chart-container { display: none; }
.chart-pane-main.pane-minimized > .tv-bs-wrap        { display: none; }

/* Extra panes */
.chart-pane {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--ui-panel);
    border: 1px solid var(--ui-panel-border);
    border-radius: 2px;
}
/* Allow the buy/sell panel to escape the pane boundary when open */
.chart-pane:has(.tv-bs-panel.open),
.chart-pane-main:has(.tv-bs-panel.open) { overflow: visible; }

/* Pane title bar */
.pane-header {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 6px 0 10px;
    background: var(--ui-panel);
    border-bottom: 1px solid var(--ui-panel-border);
    flex-shrink: 0;
    user-select: none;
}
.pane-icon   { color: #26a69a; font-size: 13px; letter-spacing: -1px; }
.pane-symbol { font-size: 13px; font-weight: 700; color: var(--ui-fg); }
.pane-tf     { font-size: 11px; color: var(--ui-muted); }

/* ── Pane timeframe current-TF button ── */
.pane-tf-cur {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    color: var(--ui-fg);
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    cursor: pointer;
    line-height: 16px;
    margin-left: 6px;
    transition: background 0.1s, border-color 0.1s;
    white-space: nowrap;
}
.pane-tf-cur:hover,
.pane-tf-cur.dd-open {
    background: var(--ui-button);
    border-color: var(--ui-panel-border);
    color: #2962ff;
}

/* ── TF Dropdown panel (appended to body, fixed-positioned) ── */
.pane-tf-dd {
    position: fixed;
    z-index: 9999;
    background: var(--ui-panel, #1e222d);
    border: 1px solid var(--ui-panel-border, #2a2e39);
    border-radius: 5px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.45);
    min-width: 170px;
    max-height: 340px;
    overflow-y: auto;
    padding: 4px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
}

/* Group header */
.tf-dd-grp-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px 5px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.7px;
    color: var(--ui-muted, #787b86);
    cursor: pointer;
    user-select: none;
}
.tf-dd-grp-hdr:hover { color: var(--ui-fg, #d1d4dc); }
.tf-dd-arrow { font-size: 9px; }

/* TF item row */
.tf-dd-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    font-size: 12.5px;
    color: var(--ui-fg, #d1d4dc);
    cursor: pointer;
    transition: background 0.08s;
}
.tf-dd-item:hover { background: var(--ui-button, #2a2e39); }
.tf-dd-item.tf-active {
    background: #2962ff;
    color: #fff;
}
.tf-dd-item.tf-active:hover { background: #1e53e5; }

/* Star button */
.tf-dd-star {
    background: transparent;
    border: none;
    color: var(--ui-muted, #787b86);
    font-size: 15px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.1s;
    flex-shrink: 0;
}
.tf-dd-star:hover   { color: #f59e0b; }
.tf-dd-star.tf-starred { color: #f59e0b; }
.tf-dd-item.tf-active .tf-dd-star         { color: rgba(255,255,255,0.6); }
.tf-dd-item.tf-active .tf-dd-star.tf-starred { color: #fff; }

/* Light theme */
[data-theme="light"] .pane-tf-dd {
    background: #ffffff;
    border-color: #d1d5db;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}
[data-theme="light"] .tf-dd-grp-hdr { color: #6b7280; }
[data-theme="light"] .tf-dd-item    { color: #111827; }
[data-theme="light"] .tf-dd-item:hover { background: #f0f3fa; }
[data-theme="light"] .tf-dd-star    { color: #9ca3af; }

/* Window control buttons */
.pane-controls {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1px;
    flex-shrink: 0;
}
.pane-ctrl {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    color: var(--ui-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    font-size: 12px;
    line-height: 1;
    padding: 0;
    transition: background 0.12s, color 0.12s;
    flex-shrink: 0;
}
.pane-ctrl:hover            { background: rgba(120,123,134,0.18); color: var(--ui-fg); }
.pane-ctrl-close:hover      { background: #ef5350 !important; color: #fff !important; }
.pane-ctrl-ind:hover        { background: rgba(33,150,243,0.15) !important; color: #2196F3 !important; }
.pane-ctrl svg              { pointer-events: none; }

/* Minimized pane — show header only */
.chart-pane.pane-minimized .pane-canvas { display: none; }
.chart-pane.pane-minimized {
    min-height: 0 !important;
    height: 28px !important;
    overflow: hidden;
}

/* Maximized pane — fills entire layout area */
.chart-pane.pane-maximized {
    position: absolute !important;
    inset: 0 !important;
    z-index: 10;
    width: 100% !important;
    height: 100% !important;
}

/* Buy/Sell widget inside extra panes — offset below 28px header */
.chart-pane .tv-bs-wrap {
    top: 38px;
    left: 0;
    z-index: 20;
    flex-direction: column;
    align-items: flex-start;
}
.chart-pane.pane-minimized .tv-bs-wrap { display: none; }

/* Pane canvas fills remaining space */
.pane-canvas {
    display: block;
    flex: 1;
    width: 100%;
    min-height: 0;
    cursor: crosshair;
    user-select: none;
}

/* ════════════════════════════════════════════
   MARKET WATCH PANEL
════════════════════════════════════════════ */
.mw-panel {
    position: fixed;
    top: 50px;
    right: 0;
    width: 280px;
    bottom: 30px;
    background: var(--ui-panel);
    border-left: 1px solid var(--ui-panel-border);
    display: flex;
    flex-direction: column;
    z-index: 50;
    box-shadow: -4px 0 16px rgba(0,0,0,0.2);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-size: 12px;
    transform: translateX(0);
    transition: transform 0.2s ease;
}
.mw-panel.hidden {
    transform: translateX(100%);
    pointer-events: none;
    visibility: hidden;
}

/* Header */
.mw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    height: 36px;
    background: var(--ui-button);
    border-bottom: 1px solid var(--ui-panel-border);
    flex-shrink: 0;
}
.mw-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--ui-fg);
    letter-spacing: 0.3px;
}
.mw-close-btn {
    background: transparent;
    border: none;
    color: var(--ui-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
}
.mw-close-btn:hover { background: rgba(239,83,80,0.15); color: #ef5350; }

/* Hint bar */
.mw-hint {
    font-size: 10px;
    color: var(--ui-muted);
    padding: 4px 12px;
    border-bottom: 1px solid var(--ui-panel-border);
    background: var(--ui-panel);
    flex-shrink: 0;
}

/* Table wrapper — scrollable */
.mw-table-wrap {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}
.mw-table-wrap::-webkit-scrollbar { width: 4px; }
.mw-table-wrap::-webkit-scrollbar-thumb { background: var(--ui-panel-border); border-radius: 2px; }

/* Table */
.mw-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}
.mw-table thead th {
    position: sticky;
    top: 0;
    background: var(--ui-button);
    color: var(--ui-muted);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 5px 6px;
    border-bottom: 1px solid var(--ui-panel-border);
    text-align: right;
}
.mw-th-sym { text-align: left !important; width: 38%; }
.mw-th-num { width: 20%; }

/* Group header row */
.mw-group-row td {
    padding: 8px 10px 3px;
    font-size: 10px;
    font-weight: 700;
    color: var(--ui-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    background: var(--ui-panel);
    border-top: 1px solid var(--ui-panel-border);
}

/* Symbol rows */
.mw-row {
    cursor: pointer;
    transition: background 0.1s;
}
.mw-row:hover { background: rgba(38,166,154,0.07); }
.mw-row.mw-selected { background: rgba(38,166,154,0.15); }

.mw-row td {
    padding: 5px 6px;
    border-bottom: 1px solid rgba(128,128,128,0.07);
    color: var(--ui-fg);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mw-sym-cell {
    text-align: left !important;
    display: flex;
    align-items: center;
    gap: 5px;
}
.mw-dir {
    font-size: 9px;
    flex-shrink: 0;
    color: var(--ui-muted);
    min-width: 10px;
}
.mw-sym-name {
    font-weight: 600;
    font-size: 12px;
    color: var(--ui-fg);
}
.mw-num  { font-size: 11px; font-variant-numeric: tabular-nums; color: var(--ui-fg); }
.mw-pct  { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }

.mw-up .mw-sym-name { color: #26a69a; }
.mw-dn .mw-sym-name { color: #ef5350; }

/* Footer */
.mw-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 12px;
    border-top: 1px solid var(--ui-panel-border);
    background: var(--ui-button);
    flex-shrink: 0;
    font-size: 10px;
    color: var(--ui-muted);
}
.mw-live-dot { color: #26a69a; font-size: 10px; }

/* ── Pane active border ── */
.pane-active { outline: 2px solid #26a69a !important; outline-offset: -2px; }

/* Market Watch — no-grid mode */
.mw-no-grid .mw-row td { border-bottom: none; }

/* Popup Prices floating widget */
.mw-popup-price {
    position: fixed;
    bottom: 60px;
    right: 290px;
    background: var(--ui-panel);
    border: 1px solid var(--ui-panel-border);
    border-radius: 6px;
    padding: 12px 16px 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 600;
    min-width: 160px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
}
.mw-popup-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--ui-fg);
    margin-bottom: 8px;
    border-bottom: 1px solid var(--ui-panel-border);
    padding-bottom: 6px;
}
.mw-popup-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    font-size: 13px;
    color: var(--ui-muted);
    padding: 3px 0;
}
.mw-dn-val { color: #ef5350; font-weight: 700; font-variant-numeric: tabular-nums; }
.mw-up-val { color: #26a69a; font-weight: 700; font-variant-numeric: tabular-nums; }
.mw-popup-close {
    position: absolute;
    top: 6px; right: 8px;
    background: transparent;
    border: none;
    color: var(--ui-muted);
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}
.mw-popup-close:hover { color: #ef5350; }

/* ─── Toast notification ─── */
.mw-toast {
    position: fixed;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #26a69a;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    white-space: nowrap;
}
.mw-toast.mw-toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ─── Specification & Tick-Chart modal overlay ─── */
.mw-spec-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 800;
}
.mw-spec-box {
    background: var(--ui-panel);
    border: 1px solid var(--ui-panel-border);
    border-radius: 6px;
    width: 340px;
    max-width: calc(100vw - 32px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    overflow: hidden;
}
.mw-spec-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 10px;
    border-bottom: 1px solid var(--ui-panel-border);
    background: var(--ui-button);
}
.mw-spec-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--ui-fg);
}
.mw-spec-close {
    background: transparent;
    border: none;
    color: var(--ui-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 3px;
    line-height: 1;
}
.mw-spec-close:hover { background: rgba(239,83,80,0.15); color: #ef5350; }

/* Specification table */
.mw-spec-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}
.mw-spec-table tr:nth-child(even) { background: rgba(128,128,128,0.04); }
.mw-spec-key {
    padding: 7px 16px 7px 16px;
    font-size: 12px;
    color: var(--ui-muted);
    font-weight: 500;
    width: 40%;
    white-space: nowrap;
}
.mw-spec-val {
    padding: 7px 16px;
    font-size: 13px;
    color: var(--ui-fg);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Specification / Tick footer */
.mw-spec-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--ui-panel-border);
    background: var(--ui-button);
}
.mw-spec-btn {
    padding: 6px 16px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border: 1px solid var(--ui-panel-border);
    background: var(--ui-button);
    color: var(--ui-fg);
    transition: background 0.1s;
}
.mw-spec-btn:hover { background: var(--ui-button-hover); }
.mw-spec-chart-btn {
    background: #2962ff;
    border-color: #2962ff;
    color: #fff;
}
.mw-spec-chart-btn:hover { background: #1a4fd8; border-color: #1a4fd8; }

/* Tick chart popup */
.mw-tick-body {
    padding: 14px 16px 10px;
}
.mw-tick-prices {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 8px;
}
.mw-tick-bid, .mw-tick-ask, .mw-tick-spread {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.mw-tick-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--ui-muted);
    text-transform: uppercase;
}
.mw-tick-val {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.mw-tick-spread span:last-child {
    font-size: 16px;
    font-weight: 600;
    color: var(--ui-fg);
}
.mw-tick-canvas {
    display: block;
    width: 100%;
    height: 140px;
    border-radius: 4px;
    border: 1px solid var(--ui-panel-border);
}
.mw-tick-status {
    font-size: 10px;
    color: var(--ui-muted);
    text-align: center;
    margin-top: 6px;
}

/* ════════════════════════════════════════════
   MARKET WATCH RIGHT-CLICK CONTEXT MENU
   Fully standalone — no dependency on tv-context-menu
════════════════════════════════════════════ */
.mw-ctx-menu {
    position: fixed;
    z-index: 99999;
    min-width: 240px;
    max-width: 280px;
    background: #ffffff;
    border: 1px solid #c8cdd6;
    border-radius: 3px;
    padding: 4px 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.22);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-size: 13px;
    color: #131722;
    user-select: none;
}

/* Dark theme override */
html:not([data-theme="light"]) .mw-ctx-menu {
    background: #1e222d;
    border-color: #363a45;
    color: #d1d4dc;
    box-shadow: 0 4px 20px rgba(0,0,0,0.45);
}

/* Menu item row */
.mw-ctx-item {
    display: flex;
    align-items: center;
    padding: 5px 12px 5px 2px;
    cursor: pointer;
    min-height: 26px;
    gap: 0;
}
.mw-ctx-item:hover:not(.mw-ctx-disabled) {
    background: #2962ff;
    color: #fff;
}
.mw-ctx-item:hover:not(.mw-ctx-disabled) .mw-ctx-label { color: #fff !important; }
.mw-ctx-item:hover:not(.mw-ctx-disabled) .mw-ctx-right { color: rgba(255,255,255,0.8) !important; }
.mw-ctx-item:hover:not(.mw-ctx-disabled) .mw-ctx-svg   { color: #fff; }
.mw-ctx-item:hover:not(.mw-ctx-disabled) .mw-ctx-check { color: #fff; }

/* Icon column — 28px fixed */
.mw-ctx-icon-col {
    width: 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mw-ctx-svg {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mw-ctx-svg svg { display: block; }
.mw-ctx-check {
    font-size: 11px;
    font-weight: 700;
    color: #131722;
    min-width: 12px;
    text-align: center;
}
html:not([data-theme="light"]) .mw-ctx-check { color: #d1d4dc; }

/* Label */
.mw-ctx-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

/* Right: shortcut text or submenu arrow */
.mw-ctx-right {
    font-size: 11px;
    color: #787b86;
    margin-left: 14px;
    flex-shrink: 0;
    white-space: nowrap;
}
.mw-ctx-arrow { font-size: 8px; }

/* States */
.mw-ctx-disabled { cursor: default; opacity: 0.4; }
.mw-ctx-muted .mw-ctx-label { color: #9598a1; }

/* Divider */
.mw-ctx-divider {
    height: 1px;
    background: #e0e3eb;
    margin: 3px 0;
}
html:not([data-theme="light"]) .mw-ctx-divider { background: #363a45; }

/* ── Pane price & status labels ── */
.pane-live-price {
    margin-left: auto;
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #26a69a;
}
.pane-status {
    font-size: 10px;
    color: var(--ui-muted);
    margin-left: 6px;
}
.pane-icon-svg { flex-shrink: 0; }

.tf-btn {
    background: transparent;
    border-radius: 10px;
    color: var(--ui-fg);
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    transition: background 0.1s, color 0.1s;
    line-height: 1;
    height: 34px;
    white-space: nowrap;
}
.tf-btn:hover {
    color: var(--ui-fg);
}
.tf-btn.active {
    background: transparent;
    color: var(--ui-fg);
    outline: none;
}

/* TF Dropdown Menu */
.tf-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--ui-panel, #ffffff);
    border: 1px solid var(--ui-panel-border, #e2e8f0);
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.13);
    z-index: 2000;
    min-width: 190px;
    padding: 6px 0;
    animation: tfDropIn 0.12s ease;
}
@keyframes tfDropIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.tf-section-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--ui-muted, #94a3b8);
    letter-spacing: 0.08em;
    padding: 8px 14px 4px;
    text-transform: uppercase;
    pointer-events: none;
    user-select: none;
}
.tf-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    color: var(--ui-fg, #0f172a);
    transition: background 0.1s;
    border-radius: 0;
}
.tf-item:hover {
    background: var(--ui-button-hover, rgba(15,23,42,0.06));
}
.tf-item.active {
    background: #2962ff;
    color: #fff;
    border-radius: 6px;
    margin: 0 6px;
    padding: 8px 8px;
}
.tf-item.active .tf-star { color: rgba(255,255,255,0.8); }
.tf-star {
    font-size: 12px;
    color: var(--ui-muted, #94a3b8);
    margin-left: 8px;
    flex-shrink: 0;
}

/* Generic topbar action button */
.topbar-btn {
    background: transparent;
    border-radius: 10px;
    color: var(--ui-fg);
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.1s, border-color 0.1s;
    height: 34px;
}

.nav-label-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Indicators button — highlights when panel is open */
.ind-topbar-btn.ind-btn-active {
    background: var(--ui-button-hover);
    border-color: var(--ui-panel-border);
    color: var(--ui-fg);
}

    .live-price-label {
        position: absolute;
        right: 0;
        background: #26a69a;
        color: #fff;
        padding: 4px 8px;
        font-size: 12px;
        font-weight: 700;
        border-radius: 3px;
        pointer-events: none;
        transform: translateY(-50%);
        z-index: 6;
        display: flex;
        flex-direction: column;
        align-items: center;
        line-height: 1.25;
        min-width: 66px;
        font-variant-numeric: tabular-nums;
        box-shadow: 0 1px 6px rgba(0,0,0,.35);
    }

    .live-price-label.down {
        background: #ef5350;
    }

    .live-price-timer {
        font-size: 9px;
        font-weight: 400;
        opacity: 0.8;
        letter-spacing: 0.04em;
    }

    .live-line {
        position: absolute;
        left: 0;
        right: 60px;
        height: 1px;
        pointer-events: none;
        z-index: 5;
        border-bottom: 1px dashed #26a69a;
    }

/* ── Chart info bar (TradingView-style top-left overlay) ── */
.chart-info-bar {
    display: flex;
    position: absolute;
    top: 6px;
    left: 8px;
    z-index: 10;
    pointer-events: none;
    user-select: none;
    flex-direction: column;
    gap: 2px;
}

.chart-info-row1 {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: #d1d4dc;
    line-height: 1;
}

.chart-info-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #26a69a;
    box-shadow: 0 0 5px rgba(38,166,154,0.7);
    flex-shrink: 0;
}

.chart-info-dot.inactive {
    background: #ef5350;
    box-shadow: 0 0 5px rgba(239,83,80,0.6);
}

.chart-info-sep {
    color: #4b5563;
    font-weight: 400;
}

.chart-info-row2 {
    font-size: 12px;
    font-weight: 500;
    color: #d1d4dc;
    letter-spacing: 0.01em;
    line-height: 1;
}

.chart-info-row2 .ci-o { color: #d1d4dc; }
.chart-info-row2 .ci-h { color: #26a69a; }
.chart-info-row2 .ci-l { color: #ef5350; }
.chart-info-row2 .ci-c { color: #d1d4dc; }
.chart-info-row2 .ci-chg-pos { color: #26a69a; }
.chart-info-row2 .ci-chg-neg { color: #ef5350; }

    .live-line.down {
        border-bottom-color: #ef5350;
    }

/* Hub connection status badge */
.hub-status-badge {
    position: absolute;
    top: 6px;
    left: 8px;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    pointer-events: none;
    opacity: 0.82;
}
.hub-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: hub-blink 1.4s ease-in-out infinite;
}
.hub-status-live { background: rgba(38,166,154,0.18); color: #26a69a; }
.hub-status-live .hub-status-dot { background: #26a69a; }
.hub-status-demo { background: rgba(120,123,134,0.15); color: #787b86; }
.hub-status-demo .hub-status-dot { background: #787b86; animation: none; }
@keyframes hub-blink {
    0%,100% { opacity: 1; } 50% { opacity: 0.3; }
}

/* ═══════════════════════════════════════════════
   BUY / SELL WIDGET  —  collapsible › style
═══════════════════════════════════════════════ */
/* ── NEW compact buy/sell widget ── */
/* Old buy/sell replaced by tv-bs-wrap — keep for safety */
#buysell-widget {
    position: absolute;
    top: 10px;
    left: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    user-select: none;
}
.bs-symbol-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 2px;
}
#bs-symbol-name {
    font-size: 11px;
    font-weight: 700;
    color: var(--ui-fg, #e5e7eb);
    letter-spacing: 0.5px;
}
.bs-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ui-muted, #9ca3af);
    font-size: 10px;
    padding: 0;
    line-height: 1;
}
.bs-close-btn:hover { color: var(--ui-fg, #e5e7eb); }
.bs-buttons-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
/* SELL button */
.bs-sell-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 5px 10px;
    border: 1.5px solid #ef5350;
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
    gap: 1px;
    transition: background 0.12s;
}
.bs-sell-btn:hover { background: rgba(239,83,80,0.10); }
/* BUY button */
.bs-buy-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    padding: 5px 10px;
    border: 1.5px solid #2962ff;
    border-radius: 5px;
    background: rgba(41,98,255,0.08);
    cursor: pointer;
    gap: 1px;
    transition: background 0.12s;
}
.bs-buy-btn:hover { background: rgba(41,98,255,0.18); }
/* Price text */
.bs-price {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}
.bs-sell-btn .bs-price { color: #ef5350; }
.bs-buy-btn  .bs-price { color: #2962ff; }
/* Label */
.bs-lbl {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.8px;
}
.bs-lbl-sell { color: #ef5350; }
.bs-lbl-buy  { color: #2962ff; }
/* Lot size */
.bs-lot-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}
.bs-lot-val {
    font-size: 11px;
    font-weight: 600;
    color: var(--ui-fg, #e5e7eb);
    min-width: 24px;
    text-align: center;
}
.bs-arr {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ui-muted, #9ca3af);
    font-size: 12px;
    padding: 0;
    line-height: 1;
    width: 16px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.bs-arr:hover { color: var(--ui-fg, #e5e7eb); }

.tv-bs-wrap {
    position: absolute;
    top: 38px;
    left: 0;
    z-index: 200;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    font-family: -apple-system, BlinkMacSystemFont, "Trebuchet MS", sans-serif;
    user-select: none;
}

/* Main pane-0 widget: direct child of pane-0 (not inside chart-container).
   Base position: below the 28px pane header + 10px gap = 38px */
#buysell-widget.tv-bs-wrap { top: 38px; }

/* Single chart mode: pane header is hidden → move widget to top */
body.single-chart #buysell-widget.tv-bs-wrap,
#chart-layout-area:not(:has(.chart-pane)) #buysell-widget.tv-bs-wrap { top: 10px; }

/* Single chart mode: no pane header, so chart-container fills from top */
body.single-chart .chart-pane-main > .chart-container,
#chart-layout-area:not(:has(.chart-pane)) .chart-pane-main > .chart-container { top: 0 !important; }

/* Symbol pill above the widget */
.tv-bs-sym-pill {
    position: absolute;
    top: -17px;
    left: 14px;
    right: 0;
    text-align: center;
    font-size: 9px;
    font-weight: 700;
    color: #666;
    background: rgba(240,242,245,0.9);
    border-radius: 3px 3px 0 0;
    padding: 1px 6px;
    letter-spacing: 0.5px;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    display: none;
}
/* Show symbol pill when panel is open */
.tv-bs-panel.open ~ .tv-bs-sym-pill { display: block; }

/* ── Toggle arrow button ── */
.tv-bs-toggle {
    width: 14px;
    min-height: 44px;
    background: rgba(30,34,50,0.75);
    border: 1px solid #3a3d4a;
    border-right: none;
    border-radius: 4px 0 0 4px;
    color: #aaa;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: color 0.12s, background 0.12s;
    line-height: 1;
    flex-shrink: 0;
}
.tv-bs-toggle:hover { color: #222; background: #ddd; }
.tv-bs-toggle.open  { background: #d8d8d8; }

/* ── Outer panel — single flat border, rounded right side ── */
.tv-bs-panel {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    overflow: hidden;
    max-width: 0;
    transition: max-width 0.22s ease;
    background: #ffffff;
    border: 1px solid #bfc3c7;
    border-left: none;
    border-radius: 0 6px 6px 0;
    box-shadow: 2px 4px 12px rgba(0,0,0,0.13);
    position: relative;
}
.tv-bs-panel.open { max-width: 360px; }

/* ── SELL column — light rose background ── */
.tv-bs-sell {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: #fce8ea;
    border: none;
    border-right: 1px solid #d6d9dc;
    cursor: pointer;
    padding: 0;
    transition: background 0.12s;
    min-width: 72px;
}
.tv-bs-sell:hover  { background: #f9d5d8; }
.tv-bs-sell:active { filter: brightness(0.97); }

/* SELL label bar */
.tv-bs-sell .tv-bs-lbl {
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #e8c4c8;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: #d84a4a;
    background: rgba(216,74,74,0.06);
}
/* SELL price area */
.tv-bs-sell .tv-bs-price {
    padding: 4px 7px;
    font-size: 11px;
    font-weight: 600;
    color: #c0192a;
    line-height: 1.1;
    white-space: nowrap;
    display: flex;
    align-items: baseline;
    justify-content: center;
}

/* ── BUY column — light mint background ── */
.tv-bs-buy {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: #daf0ea;
    border: none;
    border-left: 1px solid #d6d9dc;
    cursor: pointer;
    padding: 0;
    transition: background 0.12s;
    min-width: 72px;
}
.tv-bs-buy:hover  { background: #c8e8de; }
.tv-bs-buy:active { filter: brightness(0.97); }

/* BUY label bar */
.tv-bs-buy .tv-bs-lbl {
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #a8d8c0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    color: #2ca24c;
    background: rgba(44,162,76,0.06);
}
/* BUY price area */
.tv-bs-buy .tv-bs-price {
    padding: 4px 7px;
    font-size: 11px;
    font-weight: 600;
    color: #0a6e5a;
    line-height: 1.1;
    white-space: nowrap;
    display: flex;
    align-items: baseline;
    justify-content: center;
}

/* ── Split price: base (small) + pip (large bold) + pipette (superscript) ── */
.bsp-base { font-size: 10px; font-weight: 500; }
.bsp-pip  { font-size: 13px; font-weight: 700; line-height: 1; }
.bsp-sup  { font-size: 8px;  font-weight: 700; vertical-align: super; margin-left: 1px; }

/* ── Middle LOT column — compact horizontal ── */
.tv-bs-mid {
    width: 72px;
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: #eef1f4;
    border-left: 1px solid #d6d9dc;
    border-right: 1px solid #d6d9dc;
    padding: 0 4px;
}
.tv-bs-arr {
    width: 20px;
    height: 100%;
    background: transparent;
    border: none;
    font-size: 11px;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.1s;
    flex-shrink: 0;
    padding: 0;
}
.tv-bs-arr:hover { color: #111; }
.tv-bs-lot-val {
    font-size: 11px;
    font-weight: 700;
    color: #333;
    line-height: 1;
    text-align: center;
    flex: 1;
}

/* ══════════════════════════════════════════
   BUY/SELL WIDGET — Redesigned dropdown UI
   ══════════════════════════════════════════ */

/* ── Toggle tab: compact, clearly visible ‹ › arrow button ── */
.tv-bs-sym-btn {
    width: 16px;
    align-self: stretch;
    padding: 0;
    border: 1.5px solid rgba(33,150,243,0.65);
    border-right: none;
    border-radius: 5px 0 0 5px;
    background: rgba(33,150,243,0.15);
    color: #90caf9;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.14s, color 0.14s;
    flex-shrink: 0;
}
html[data-theme="light"] .tv-bs-sym-btn {
    border-color: rgba(33,150,243,0.55);
    background: rgba(33,150,243,0.08);
    color: #1976d2;
}
.tv-bs-sym-btn:hover {
    background: rgba(33,150,243,0.32);
    color: #ffffff;
}
html[data-theme="light"] .tv-bs-sym-btn:hover {
    background: rgba(33,150,243,0.16);
    color: #0d47a1;
}
.tv-bs-arrow { font-size: 13px; line-height: 1; }

/* ── Panel — hidden until .open is added ── */
.tv-bs-panel {
    display: none !important;
    flex-direction: row;
    align-items: stretch;
    overflow: visible;
    max-width: none;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    transition: none;
}
/* Show when toggled — works for every pane */
.tv-bs-panel.open {
    display: flex !important;
    max-width: none;
}

/* ── SELL column ── */
.tv-bs-col-sell {
    display: flex;
    flex-direction: column;
    width: 72px;
    border: 1px solid rgba(220, 38, 38, 0.6);
    border-radius: 6px 0 0 6px;
    overflow: hidden;
    cursor: pointer;
    background: #ef4444;
    transition: background 0.12s;
}
.tv-bs-col-sell:hover { background: #dc2626; }
.tv-bs-col-sell:active { filter: brightness(0.94); }
html[data-theme="light"] .tv-bs-col-sell { background: #fee2e2; border-color: #dc2626; }
html[data-theme="light"] .tv-bs-col-sell:hover { background: #fecaca; }

/* ── BUY column ── */
.tv-bs-col-buy {
    display: flex;
    flex-direction: column;
    width: 72px;
    border: 1px solid rgba(21, 128, 61, 0.6);
    border-radius: 0 6px 6px 0;
    overflow: hidden;
    cursor: pointer;
    background: #22c55e;
    transition: background 0.12s;
}
.tv-bs-col-buy:hover { background: #16a34a; }
.tv-bs-col-buy:active { filter: brightness(0.94); }
html[data-theme="light"] .tv-bs-col-buy { background: #dcfce7; border-color: #16a34a; }
html[data-theme="light"] .tv-bs-col-buy:hover { background: #bbf7d0; }

/* ── Lot control column ── */
.tv-bs-col-lot {
    display: flex;
    flex-direction: row;
    align-items: center;
    border-top: 1px solid rgba(100,120,180,0.3);
    border-bottom: 1px solid rgba(100,120,180,0.3);
    background: rgba(30, 41, 59, 0.85);
}
html[data-theme="light"] .tv-bs-col-lot {
    background: #f1f5f9;
    border-color: rgba(100,120,180,0.2);
}

/* SELL label */
.tv-bs-lbl-sell {
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.9);
    background: rgba(0,0,0,0.15);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
html[data-theme="light"] .tv-bs-lbl-sell { color: #991b1b; background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.08); }

.tv-bs-lbl-buy {
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: rgba(255,255,255,0.9);
    background: rgba(0,0,0,0.15);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
html[data-theme="light"] .tv-bs-lbl-buy { color: #14532d; background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.08); }

/* Lot arrows + input */
.tv-bs-lot-arr {
    width: 22px;
    height: 100%;
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(148,163,184,0.9);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: color 0.12s;
}
.tv-bs-lot-arr:hover { color: #ffffff; }
html[data-theme="light"] .tv-bs-lot-arr { color: rgba(71,85,105,0.9); }
html[data-theme="light"] .tv-bs-lot-arr:hover { color: #1e293b; }

.tv-bs-lot-input {
    width: 42px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    outline: none;
    border: none;
    background: transparent;
    color: #e2e8f0;
    appearance: none;
    -moz-appearance: textfield;
}
.tv-bs-lot-input::-webkit-outer-spin-button,
.tv-bs-lot-input::-webkit-inner-spin-button { -webkit-appearance: none; }
html[data-theme="light"] .tv-bs-lot-input { color: #1e293b; }

/* SELL price button */
.tv-bs-sell-btn {
    flex: 1;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    transition: background 0.12s;
}

/* BUY price button */
.tv-bs-buy-btn {
    flex: 1;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    transition: background 0.12s;
}

/* ── Single chart mode: hide ALL pane headers (symbol name + min/max/close) ──
   Two selectors for belt-and-suspenders reliability:
   1. JS-toggled body class (kept for browsers without :has support)
   2. Pure CSS :has() — fires immediately when DOM changes, no JS timing required */
body.single-chart .pane-header { display: none !important; }

/* When no .chart-pane element exists anywhere in the layout area, only the
   main pane (chart-pane-main) is present = single chart mode */
#chart-layout-area:not(:has(.chart-pane)) .pane-header { display: none !important; }

/* When any pane is maximized (fills full screen), hide its header too */
.pane-maximized .pane-header { display: none !important; }
/* Shift the buy/sell widget up when the 28px header is hidden */
.chart-pane.pane-maximized .tv-bs-wrap  { top: 10px !important; }
/* Same fix for pane-0 (class is chart-pane-main, not chart-pane) */
.chart-pane-main.pane-maximized .tv-bs-wrap { top: 10px !important; }
/* When pane-0 is maximized, header is hidden so chart-container can fill from top:0.
   This prevents the 28px dead-zone from partially overlapping the buy/sell toggle. */
.chart-pane-main.pane-maximized > .chart-container { top: 0 !important; }
/* Ensure widget is always clickable above the canvas */
.tv-bs-wrap { z-index: 300 !important; pointer-events: all !important; }
.tv-bs-wrap * { pointer-events: auto; }

/* Price inner display */
.tv-bs-price-inner {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: #ffffff;
    padding: 3px 4px;
}
/* SELL price — white on dark red */
.tv-bs-col-sell .tv-bs-price-inner { color: #fff; font-weight: 700; }
html[data-theme="light"] .tv-bs-col-sell .tv-bs-price-inner { color: #7f1d1d; }
.tv-bs-col-buy  .tv-bs-price-inner { color: #fff; font-weight: 700; }
html[data-theme="light"] .tv-bs-col-buy  .tv-bs-price-inner { color: #14532d; }

/* Pip display sizes (set by JS innerHTML) */
.bsp-base   { font-size: 11px; font-weight: 600; letter-spacing: 0.5px; opacity: 0.9; }
.bsp-dot    { font-size: 11px; font-weight: 500; }
.bsp-small  { font-size: 11px; font-weight: 500; }
.bsp-pip    { font-size: 14px; font-weight: 700; line-height: 1; margin-bottom: -1px; }
.bsp-pipette{ font-size: 9px;  font-weight: 600; position: relative; bottom: 4px; margin-left: 1px; }

/* ── Toast notification ── */
.bs-toast {
    position: absolute;
    top: 62px;
    left: 10px;
    z-index: 300;
    padding: 7px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.bs-toast.show {
    opacity: 1;
    transform: translateY(0);
}
.bs-toast.toast-sell { background: #c0392b; }
.bs-toast.toast-buy  { background: #2962ff; }

/* ═══════════════════════════════════════════════
   MT5-STYLE RIGHT-CLICK CONTEXT MENU
   All colors forced explicitly — dark theme must NOT bleed in
═══════════════════════════════════════════════ */
#chart-ctx-menu,
.ctx-menu {
    position: fixed !important;
    z-index: 999999 !important;
    background-color: #ffffff !important;
    border: 1px solid #b0b0b0 !important;
    border-radius: 3px !important;
    box-shadow: 2px 4px 16px rgba(0,0,0,0.45) !important;
    padding: 2px 0 !important;
    min-width: 240px !important;
    max-height: calc(100vh - 20px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    font-family: Arial, Tahoma, "Segoe UI", sans-serif !important;
    font-size: 13px !important;
    color: #1a1a1a !important;
    user-select: none !important;
    line-height: 1.3 !important;
}
#chart-ctx-menu::-webkit-scrollbar,
.ctx-menu::-webkit-scrollbar { width: 6px !important; }
#chart-ctx-menu::-webkit-scrollbar-track,
.ctx-menu::-webkit-scrollbar-track { background: #f0f0f0 !important; }
#chart-ctx-menu::-webkit-scrollbar-thumb,
.ctx-menu::-webkit-scrollbar-thumb { background: #b0b0b0 !important; border-radius: 3px !important; }
#chart-ctx-menu .ctx-row,
.ctx-menu .ctx-row {
    display: flex !important;
    align-items: center !important;
    padding: 4px 14px 4px 4px !important;
    cursor: pointer !important;
    white-space: nowrap !important;
    min-height: 24px !important;
    color: #1a1a1a !important;
    background-color: transparent !important;
}
#chart-ctx-menu .ctx-row:hover:not(.ctx-disabled),
.ctx-menu .ctx-row:hover:not(.ctx-disabled) {
    background-color: #3875d7 !important;
    color: #ffffff !important;
}
#chart-ctx-menu .ctx-row:hover:not(.ctx-disabled) *,
.ctx-menu .ctx-row:hover:not(.ctx-disabled) * {
    color: #ffffff !important;
}
#chart-ctx-menu .ctx-row:hover:not(.ctx-disabled) svg line,
#chart-ctx-menu .ctx-row:hover:not(.ctx-disabled) svg polyline,
#chart-ctx-menu .ctx-row:hover:not(.ctx-disabled) svg path,
#chart-ctx-menu .ctx-row:hover:not(.ctx-disabled) svg rect,
#chart-ctx-menu .ctx-row:hover:not(.ctx-disabled) svg circle,
#chart-ctx-menu .ctx-row:hover:not(.ctx-disabled) svg polygon,
.ctx-menu .ctx-row:hover:not(.ctx-disabled) svg line,
.ctx-menu .ctx-row:hover:not(.ctx-disabled) svg polyline,
.ctx-menu .ctx-row:hover:not(.ctx-disabled) svg path,
.ctx-menu .ctx-row:hover:not(.ctx-disabled) svg rect,
.ctx-menu .ctx-row:hover:not(.ctx-disabled) svg circle,
.ctx-menu .ctx-row:hover:not(.ctx-disabled) svg polygon {
    stroke: #ffffff !important;
    fill: #ffffff !important;
}
.ctx-disabled {
    color: #aaaaaa !important;
    cursor: default !important;
}
.ctx-disabled .ctx-icon {
    opacity: 0.45 !important;
}
.ctx-check-col {
    width: 14px !important;
    min-width: 14px !important;
    flex-shrink: 0 !important;
    text-align: center !important;
    font-size: 10px !important;
    color: #3875d7 !important;
    margin-right: 2px !important;
}
.ctx-icon {
    width: 20px !important;
    height: 20px !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin-right: 6px !important;
}
.ctx-icon svg {
    width: 16px !important;
    height: 16px !important;
    display: block !important;
}
.ctx-label {
    flex: 1 !important;
    padding-right: 16px !important;
    color: inherit !important;
}
.ctx-sc {
    font-size: 11.5px !important;
    color: #666666 !important;
    flex-shrink: 0 !important;
    font-family: Arial, sans-serif !important;
}
.ctx-sep {
    height: 1px !important;
    background-color: #d0d0d0 !important;
    margin: 2px 0 !important;
}
.ctx-has-sub > .ctx-sc {
    font-size: 9px !important;
    color: #555555 !important;
}
/* Timeframe submenu group header */
.ctx-tf-hdr {
    padding: 5px 10px 3px 34px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    color: #888888 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.06em !important;
    cursor: default !important;
    background-color: #f5f5f5 !important;
}
/* Submenu panel */
.ctx-submenu {
    min-width: 170px !important;
}
.ctx-sub2 {
    min-width: 160px !important;
}

/* ── Oscillator sub-pane (RSI / MACD / STOCH / ADX etc.) ── */
#osc-pane {
    position: absolute;
    left: 44px;
    right: 46px;
    bottom: 56px;
    display: none;
    flex-direction: column;
    background: #0d0d0d;
    border-top: 2px solid #2a2a2a;
    z-index: 10;
    overflow-x: hidden;
    overflow-y: auto;           /* scrollable when many oscillator sections are stacked */
    scroll-behavior: smooth;
}
/* Thin, unobtrusive scrollbar for the oscillator pane */
#osc-pane::-webkit-scrollbar        { width: 4px; }
#osc-pane::-webkit-scrollbar-track  { background: transparent; }
#osc-pane::-webkit-scrollbar-thumb  { background: #333; border-radius: 2px; }
#osc-pane::-webkit-scrollbar-thumb:hover { background: #555; }
#osc-pane.visible {
    display: flex;
}
#osc-pane #osc-canvas {
    width: 100%;
    display: block;
}
.osc-resize-handle {
    height: 5px;
    cursor: ns-resize;
    background: transparent;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
}
.osc-resize-handle:hover {
    background: rgba(255,255,255,0.08);
}
.osc-label {
    position: absolute;
    top: 4px;
    left: 8px;
    font-size: 10px;
    color: #888;
    pointer-events: none;
    z-index: 5;
}
/* Shrink main chart area when oscillator pane is open.
   --osc-h is the VISIBLE pane height set by JS (never exceeds window - MIN_CHART_H).
   No extra gap pixel — the border-top on #osc-pane provides visual separation. */
#chart-layout-area.osc-open {
    bottom: calc(56px + var(--osc-h, 110px));
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   Laptop L  ≥ 1024px  — default styles apply
   Laptop S  1024–1399px — minor condensing
   Tablet    768–1023px  — compact topbar, narrower panels
   Mobile    < 768px     — stacked charts, scrollable topbar
   Mobile S  < 480px     — minimal sizing
══════════════════════════════════════════════════════ */

/* ── Laptop S (1024 – 1399px): condense spacing slightly ── */
@media (max-width: 1399px) {
    .tf-btn {
        padding: 5px 9px;
    }
    .symbol-display-btn {
        padding: 0 11px;
    }
}

/* ── Tablet (768px – 1023px) ── */
@media (max-width: 1023px) {
    /* Topbar: compact height, smaller buttons, scrollable so nothing clips */
    #topbar {
        padding: 0 8px;
        gap: 4px;
        height: 46px;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
    }
    #topbar::-webkit-scrollbar { display: none; }
    .tf-btn {
        padding: 4px 8px;
        font-size: 12px;
        height: 30px;
    }
    .topbar-btn {
        padding: 4px 8px;
        font-size: 12px;
        height: 30px;
    }
    .symbol-display-btn {
        padding: 0 10px;
        font-size: 12px;
        height: 30px;
    }
    .icon-action-btn {
        width: 30px;
        height: 30px;
    }
    .chart-type-btn {
        width: 30px;
        height: 30px;
        min-width: 30px;
        padding: 0 5px !important;
    }
    /* Hide low-priority items to make room */
    /* #topbar-clocks is now fixed-positioned — always visible */
    .status { display: none; }
    /* Alert and Replay text labels hidden, icons only */
    #alertBtn  span,
    #replayBtn span { display: none; }
    #undoBtn, #redoBtn { display: none; }
    /* Adjust chart area for slightly shorter topbar.
       Drawing toolbar is always visible on tablet, chart leaves 44px gap. */
    #chart-layout-area {
        top: 46px;
        left: 44px;
    }
    #drawing-toolbar {
        top: 46px;
    }
    /* osc-pane: adjust top for shorter topbar */
    #osc-pane {
        top: 46px;
        left: 44px;
    }
    /* Chart rows: single column layout for readability */
    .chart-row {
        min-height: 240px;
    }
    /* Y-axis price labels always visible */
    .live-price-label {
        font-size: 10px;
        padding: 3px 5px;
    }
    /* Tab bar aligned with drawing toolbar */
    #pane-tabbar { left: 44px; }
    /* Market watch narrower on tablet */
    .mw-panel { width: 220px !important; min-width: 220px !important; }
    #chart-layout-area.mw-open { right: 266px; }  /* 220px panel + 46px icon strip */
}


/* ── Mobile (< 768px) ── */
@media (max-width: 767px) {
    body { overflow: hidden; }

    /* ── Topbar: 2-row layout ──
       Row 1 (44px): [EURUSD ▾] [+]  [1m]  [chart-type]
       Row 2 (40px): [Indicators ▾]  [Layout]  [Alert]  [Replay]   */
    #topbar {
        height: auto;          /* expands to fit 2 rows */
        padding: 0;
        overflow: visible;
        align-items: stretch;
    }

    /* header section fills topbar width */
    .header-title-section {
        flex: 1;
        min-width: 0;
        overflow: visible;
        gap: 0;
    }

    /* Primary group: wrapping flex — row-break div creates the 2nd row */
    .topbar-group-primary {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        width: 100%;
        overflow: visible;
        padding: 0 8px;
        gap: 6px;
        row-gap: 0;
    }

    /* Row-break div: zero-height, full-width → forces next items to new row */
    .topbar-row-break {
        display: block;
        flex-basis: 100%;
        height: 1px;
        background: var(--ui-panel-border, rgba(255,255,255,0.08));
        margin: 0 -8px;
        width: calc(100% + 16px);
    }

    /* Row 1 items (before row-break): 44px row */
    .topbar-group-primary .symbol-nav,
    .topbar-group-primary #tf-main-btn,
    .topbar-group-primary .chart-type-group {
        flex-shrink: 0;
        height: 44px;
        display: flex;
        align-items: center;
    }

    /* Row 2 items (after row-break): 40px row */
    .topbar-group-primary #indicatorBtn,
    .topbar-group-primary #layout-picker-wrap,
    .topbar-group-primary #alertBtn,
    .topbar-group-primary #replayBtn {
        flex-shrink: 0;
        height: 40px;
        display: flex;
        align-items: center;
    }

    /* Secondary group: hidden (all its items are low-priority) */
    .topbar-group-secondary { display: none; }
    .topbar-divider { display: none; }
    .dt-mobile-toggle-btn { display: none !important; }

    /* Hide low-priority items */
    /* #topbar-clocks is now fixed-positioned — always visible */
    .status,
    #undoBtn,
    #redoBtn { display: none; }

    /* Show text labels on row 2 */
    #alertBtn span,
    #replayBtn span { display: inline; }

    /* Button sizing */
    .tf-btn         { padding: 3px 8px; font-size: 12px; height: 30px; flex-shrink: 0; }
    .topbar-btn     { padding: 3px 8px; font-size: 12px; height: 30px; flex-shrink: 0; }
    .symbol-display-btn {
        padding: 0 10px;
        font-size: 13px;
        font-weight: 700;
        height: 30px;
        border-radius: 15px;
        flex-shrink: 0;
    }
    .icon-action-btn    { width: 30px; height: 30px; flex-shrink: 0; }
    .chart-type-btn     { width: 30px; height: 30px; min-width: 30px; padding: 0 5px !important; flex-shrink: 0; }

    /* ── Drawing toolbar: always visible compact sidebar (40px) ── */
    #drawing-toolbar {
        position: fixed !important;
        top: 85px !important;
        left: 0 !important;
        width: 40px !important;
        bottom: 70px !important;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        overflow-y: auto;
        overflow-x: hidden;
        visibility: visible !important;
        opacity: 1 !important;
        transform: none !important;
        pointer-events: auto !important;
        z-index: 100 !important;
        box-shadow: none;
        transition: none !important;
    }
    /* Compact toolbar buttons to fit 40px sidebar */
    #drawing-toolbar .dt-btn {
        width: 32px !important;
        height: 30px !important;
        min-height: 30px !important;
        padding: 0 !important;
        margin: 1px 0 !important;
    }

    /* Overlay backdrop: hidden (toolbar always visible, no toggle needed) */
    #dt-mobile-overlay { display: none !important; }

    /* Chart area: starts right of the 40px toolbar, below the 2-row topbar (85px)
       bottom = 44px (bottomBar) + 26px (pane-tabbar) = 70px */
    #chart-layout-area {
        top: 85px;
        left: 40px;
        bottom: 70px;
        right: 0;
    }
    #osc-pane {
        left: 40px;
        bottom: 70px;
        right: 0;
    }
    #chart-layout-area.osc-open {
        bottom: calc(70px + var(--osc-h, 110px));
    }

    /* Stack all panes vertically */
    .chart-row {
        flex-direction: column !important;
        min-height: 0;
    }
    .chart-row > .chart-pane,
    .chart-row > .chart-pane-main {
        min-height: 260px;
        flex: 1 1 260px !important;
    }
    /* Resize handles hidden */
    .grid-rsz-v,
    .grid-rsz-h { display: none; }

    /* Bottom bar: 44px tall, scrollable */
    #bottomBar {
        height: 44px;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
        flex-wrap: nowrap;
        padding-left: 4px;
    }
    #bottomBar::-webkit-scrollbar { display: none; }
    .bottom-right { display: none; }
    .bottom-left { flex-wrap: nowrap; white-space: nowrap; }

    /* Pane header */
    .pane-header { padding: 0 4px; gap: 4px; }
    .pane-symbol { font-size: 12px; }
    .pane-ctrl-min,
    .pane-ctrl-max,
    .pane-ctrl-close { display: none; }

    /* Price labels */
    .live-price-label { font-size: 10px; padding: 3px 4px; right: 0; }
    .live-line { right: 52px; }

    /* Buy/sell panel — keep visible on small screens */
    .tv-bs-wrap { display: flex; }

    /* Indicators panel: full width */
    #indicators-panel {
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-height: 60vh;
        overflow-y: auto;
    }

    /* Tab bar: aligned with chart (left: 40px), above bottomBar */
    #pane-tabbar {
        left: 40px;
        bottom: 44px;
    }

    /* Market watch: hidden on mobile */
    .mw-panel { display: none !important; }
    #chart-layout-area.mw-open { right: 0; }
}

/* ── Small mobile (< 480px) ── */
@media (max-width: 479px) {
    /* Slightly smaller buttons on row 1 */
    .tf-btn         { padding: 2px 6px; font-size: 11px; height: 26px; }
    .topbar-btn     { padding: 2px 6px; font-size: 11px; height: 26px; }
    .symbol-display-btn { font-size: 11px; padding: 0 7px; height: 26px; }
    .icon-action-btn    { width: 26px; height: 26px; }
    /* Row 1 items shorter */
    .topbar-group-primary .symbol-nav,
    .topbar-group-primary #tf-main-btn,
    .topbar-group-primary .chart-type-group { height: 40px; }
    /* Row 2 items shorter */
    .topbar-group-primary #indicatorBtn,
    .topbar-group-primary #layout-picker-wrap,
    .topbar-group-primary #alertBtn,
    .topbar-group-primary #replayBtn { height: 36px; }

    /* Topbar is 40+36+1 = 77px tall on small mobile */
    #chart-layout-area {
        top: 77px;
        left: 40px;
        bottom: 68px;
    }
    #osc-pane {
        left: 40px;
        bottom: 68px;
    }
    #drawing-toolbar {
        top: 77px !important;
        bottom: 68px !important;
    }
    #chart-layout-area.osc-open {
        bottom: calc(68px + var(--osc-h, 110px));
    }
    #bottomBar { height: 42px; }
    #pane-tabbar { left: 40px; bottom: 42px; }
    .chart-row > .chart-pane,
    .chart-row > .chart-pane-main {
        min-height: 200px;
        flex: 1 1 200px !important;
    }
    .live-price-label { font-size: 9px; padding: 2px 3px; }
    #bottomBar button,
    #bottomBar .range-btn { padding: 2px 5px; font-size: 11px; }
}

/* ═══════════════════════════════════════════════
   INDICATOR LINE POPUP
═══════════════════════════════════════════════ */

.ilp-wrap {
    position: fixed;
    z-index: 9500;
    display: none;
    align-items: center;
    gap: 2px;
    height: 38px;
    padding: 0 8px;
    background: var(--ui-panel);
    border: 1px solid var(--ui-panel-border);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.35), 0 1px 4px rgba(0,0,0,0.2);
    user-select: none;
    white-space: nowrap;
    animation: ilp-pop 0.14s cubic-bezier(0.34,1.56,0.64,1);
}

html[data-theme="light"] .ilp-wrap {
    box-shadow: 0 4px 20px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.08);
}

@keyframes ilp-pop {
    from { opacity: 0; transform: scale(0.92) translateY(4px); }
    to   { opacity: 1; transform: scale(1)    translateY(0);   }
}

/* Color swatch dot */
.ilp-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #2196F3;
    margin-right: 2px;
}

/* Indicator name */
.ilp-name {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ui-fg);
    letter-spacing: 0.01em;
    margin-right: 4px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Vertical separator */
.ilp-sep {
    width: 1px;
    height: 20px;
    background: var(--ui-panel-border);
    flex-shrink: 0;
    margin: 0 4px;
}

/* Generic icon button */
.ilp-btn {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--ui-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
    padding: 0;
    font-family: inherit;
}

.ilp-btn:hover {
    background: var(--ui-button-hover);
    color: var(--ui-fg);
    border-color: var(--ui-panel-border);
}

.ilp-btn:active {
    transform: scale(0.93);
}

/* Delete button — red accent on hover */
.ilp-del-btn:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

/* Code/formula button */
.ilp-code-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.3);
}

/* Arrow pointer */
.ilp-wrap::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    background: var(--ui-panel);
    border-right: 1px solid var(--ui-panel-border);
    border-bottom: 1px solid var(--ui-panel-border);
    transform: translateX(-50%) rotate(45deg);
    border-radius: 0 0 2px 0;
}

/* ═══════════════════════════════════════════════
   ACCOUNT ICON + LOGIN DROPDOWN PANEL
═══════════════════════════════════════════════ */

.account-dropdown-wrap {
    position: relative;
    flex-shrink: 0;
}

/* Account icon button */
.account-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid var(--ui-panel-border);
    background: var(--ui-button);
    color: var(--ui-fg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    flex-shrink: 0;
}

.account-icon-btn:hover {
    background: var(--ui-button-hover);
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.18);
}

.account-icon-btn.active {
    background: #1d4ed8;
    border-color: #3b82f6;
    color: #fff;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.22);
}

/* Panel container */
.account-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 320px;
    background: var(--ui-panel);
    border: 1px solid var(--ui-panel-border);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.3);
    z-index: 9999;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

html[data-theme="light"] .account-panel {
    box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.1);
}

.account-panel.ap-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Tabs */
.ap-tabs {
    display: flex;
    border-bottom: 1px solid var(--ui-panel-border);
    background: var(--ui-bg);
}

.ap-tab {
    flex: 1;
    padding: 12px 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ui-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.14s ease, background 0.14s ease;
    font-family: inherit;
    letter-spacing: 0.01em;
}

.ap-tab:hover {
    color: var(--ui-fg);
    background: var(--ui-button-hover);
}

.ap-tab-active {
    color: var(--ui-fg);
    font-weight: 700;
    position: relative;
}

.ap-tab-active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 16px;
    right: 16px;
    height: 2px;
    background: #3b82f6;
    border-radius: 2px 2px 0 0;
}

/* Body */
.ap-body {
    padding: 24px 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ap-body-hidden {
    display: none;
}

/* Branding */
.ap-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 2px;
}

.ap-brand-name {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ap-subtitle {
    text-align: center;
    font-size: 12.5px;
    color: var(--ui-muted);
    margin: 0;
    line-height: 1.4;
}

/* Input fields */
.ap-field-wrap {
    position: relative;
}

.ap-input {
    width: 100%;
    height: 42px;
    background: var(--ui-button);
    border: 1.5px solid var(--ui-panel-border);
    border-radius: 8px;
    color: var(--ui-fg);
    font-size: 13.5px;
    font-family: inherit;
    padding: 0 40px 0 14px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ap-input::placeholder {
    color: var(--ui-muted);
}

.ap-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
    background: var(--ui-button-hover);
}

/* Password toggle */
.ap-field-pw .ap-input {
    padding-right: 42px;
}

.ap-pw-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--ui-muted);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    transition: color 0.12s ease;
}

.ap-pw-toggle:hover {
    color: var(--ui-fg);
}

/* Forgot link */
.ap-forgot {
    font-size: 12px;
    color: #3b82f6;
    text-align: center;
    text-decoration: none;
    display: block;
    margin-top: -4px;
    transition: color 0.12s ease;
}

.ap-forgot:hover {
    color: #60a5fa;
    text-decoration: underline;
}

/* Submit button */
.ap-submit-btn {
    width: 100%;
    height: 42px;
    background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: opacity 0.14s ease, box-shadow 0.14s ease, transform 0.1s ease;
    box-shadow: 0 4px 14px rgba(34,197,94,0.35);
}

.ap-submit-btn:hover {
    opacity: 0.92;
    box-shadow: 0 6px 20px rgba(34,197,94,0.45);
    transform: translateY(-1px);
}

.ap-submit-btn:active {
    transform: translateY(0);
    opacity: 1;
}

/* Terms text */
.ap-terms {
    font-size: 11px;
    color: var(--ui-muted);
    text-align: center;
    margin: -4px 0 0;
    line-height: 1.5;
}

.ap-terms a {
    color: #3b82f6;
    text-decoration: none;
}

.ap-terms a:hover {
    text-decoration: underline;
}

/* Arrow pointer on panel */
.account-panel::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 14px;
    width: 12px;
    height: 12px;
    background: var(--ui-bg);
    border-left: 1px solid var(--ui-panel-border);
    border-top: 1px solid var(--ui-panel-border);
    transform: rotate(45deg);
    border-radius: 2px 0 0 0;
}

/* Responsive: make panel full-width on small screens */
@media (max-width: 400px) {
    .account-panel {
        right: -8px;
        width: calc(100vw - 16px);
    }
}

/* ═══════════════════════════════════════════════
   UNDO / REDO BUTTONS
═══════════════════════════════════════════════ */

#undoBtn,
#redoBtn {
    transition: opacity 0.15s ease, background 0.12s ease;
}

#undoBtn:disabled,
#redoBtn:disabled {
    cursor: not-allowed;
    pointer-events: none;
}

/* ═══════════════════════════════════════════════
   REPLAY CONTROL BAR
═══════════════════════════════════════════════ */

.replay-bar {
    position: absolute;
    bottom: 42px;          /* sits just above the bottom OHLC bar */
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: none;
    align-items: center;
    gap: 6px;
    background: var(--ui-panel);
    border: 1px solid #2563eb;
    border-radius: 10px;
    padding: 5px 10px;
    box-shadow: 0 4px 24px rgba(37,99,235,0.28), 0 2px 8px rgba(0,0,0,0.35);
    user-select: none;
    white-space: nowrap;
}

.replay-bar.rb-visible {
    display: flex;
    animation: rb-slide-up 0.2s ease;
}

@keyframes rb-slide-up {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Generic replay button */
.rb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 28px;
    min-width: 28px;
    padding: 0 6px;
    background: var(--ui-button);
    border: 1px solid var(--ui-panel-border);
    border-radius: 6px;
    color: var(--ui-fg);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
    flex-shrink: 0;
}

.rb-btn:hover {
    background: var(--ui-button-hover);
    border-color: #3b82f6;
}

/* Play button – accent color */
.rb-play {
    background: #1d4ed8;
    border-color: #3b82f6;
    color: #fff;
    min-width: 34px;
}

.rb-play:hover {
    background: #2563eb;
    border-color: #60a5fa;
}

/* Exit button */
.rb-exit {
    border-color: rgba(239,68,68,0.5);
    color: #ef4444;
}

.rb-exit:hover {
    background: rgba(239,68,68,0.12);
    border-color: #ef4444;
}

/* Speed button */
.rb-speed {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 8px;
    background: var(--ui-button);
    border: 1px solid var(--ui-panel-border);
    border-radius: 6px;
    color: #3b82f6;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.12s ease;
    flex-shrink: 0;
}

.rb-speed:hover {
    background: var(--ui-button-hover);
}

/* Progress bar */
.rb-progress {
    width: 120px;
    height: 4px;
    background: var(--ui-button-hover);
    border-radius: 2px;
    overflow: hidden;
    flex-shrink: 0;
}

.rb-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #1d4ed8, #3b82f6);
    border-radius: 2px;
    transition: width 0.15s linear;
}

/* Candle counter label */
.rb-label {
    font-size: 11px;
    color: var(--ui-muted);
    min-width: 60px;
    text-align: center;
    flex-shrink: 0;
}

/* Hide replay bar on mobile */
@media (max-width: 768px) {
    .replay-bar {
        bottom: 52px;
        gap: 4px;
        padding: 4px 8px;
    }
    .rb-progress { width: 60px; }
    .rb-label    { display: none; }
}
