/* ============================================================
   TradeView Pro — Complete Unified Stylesheet
   All UI components consolidated (no runtime CSS injection)
   ============================================================ */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --tv-bg:        #131722;
    --tv-bg2:       #1c2030;
    --tv-bg3:       #2a2e39;
    --tv-bg4:       #363a45;
    --tv-border:    #2a2e39;
    --tv-text:      #d1d4dc;
    --tv-text2:     #787b86;
    --tv-text3:     #b2b5be;

    --tv-green:     #26a69a;
    --tv-green-dim: rgba(38,166,154,0.12);
    --tv-red:       #ef5350;
    --tv-red-dim:   rgba(239,83,80,0.12);
    --tv-blue:      #2962ff;
    --tv-blue-dim:  rgba(41,98,255,0.15);
    --tv-yellow:    #f2a900;

    --top-h:        38px;
    --left-w:       44px;
    --right-w:      0px;
    --bottom-h:     180px;
    --bottom-collapsed: 28px;
}

body {
    background: var(--tv-bg);
    color: var(--tv-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif;
    overflow: hidden;
    height: 100dvh;
    width: 100vw;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--tv-bg); }
::-webkit-scrollbar-thumb { background: var(--tv-bg3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--tv-bg4); }

/* ============================================================
   PLATFORM GRID LAYOUT
   ============================================================ */
.platform {
    display: grid;
    grid-template-rows: var(--top-h) 1fr var(--bottom-h);
    grid-template-columns: var(--left-w) 1fr var(--right-w);
    grid-template-areas:
        "top top top"
        "left chart right"
        "bottom bottom bottom";
    height: 100dvh;
}
.platform:has(#bottom-panel.collapsed) {
    grid-template-rows: var(--top-h) 1fr var(--bottom-collapsed);
}

/* ============================================================
   TOP BAR (Modern styles)
   ============================================================ */
#top-bar, .top-bar {
    grid-area: top;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    height: 44px;
    background: #0f1218;
    border-bottom: 1px solid #1e2230;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #d1d4dc;
    font-size: 13px;
    position: relative;
    z-index: 1000;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}
#top-bar::-webkit-scrollbar, .top-bar::-webkit-scrollbar { display: none; }

.tb-symbol {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    font-weight: 600;
    color: #e0e3eb;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.tb-symbol .exch {
    font-size: 10px;
    color: #6a7186;
    font-weight: 500;
    background: #1a1d29;
    padding: 3px 7px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tb-sep {
    width: 1px;
    height: 22px;
    background: #1e2230;
    margin: 0 6px;
    flex-shrink: 0;
}

.tf-wrap {
    display: flex;
    align-items: center;
    gap: 2px;
    background: #0a0d13;
    border-radius: 5px;
    padding: 2px;
    border: 1px solid #1a1d29;
}
.tf-b {
    background: transparent;
    border: none;
    color: #787b86;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 3px;
    min-width: 32px;
    font-family: inherit;
}
.tf-b:hover { background: #1a1d29; color: #d1d4dc; }
.tf-b.on { background: #2962ff; color: #fff; font-weight: 600; }

.replay-wrap { display: flex; align-items: center; }
.rp-btn {
    background: transparent;
    border: none;
    color: #b2b5be;
    padding: 7px 10px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
}
.rp-btn:hover { background: #1a1d29; color: #d1d4dc; }
.rp-btn.active {
    background: rgba(41, 98, 255, 0.15);
    color: #2962ff;
    box-shadow: inset 0 0 0 1px rgba(41, 98, 255, 0.35);
}
.rp-btn svg { width: 14px; height: 14px; }

.tb-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 4px;
}
.tb-price {
    font-size: 15px;
    font-weight: 600;
    color: #d1d4dc;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
}
.tb-price.up { color: #26a69a; }
.tb-price.down { color: #ef5350; }
.tb-change {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 3px;
    font-variant-numeric: tabular-nums;
}
.tb-change.up { color: #26a69a; background: rgba(38, 166, 154, 0.12); }
.tb-change.down { color: #ef5350; background: rgba(239, 83, 80, 0.12); }
.tb-status {
    font-size: 11px;
    color: #6a7186;
    font-weight: 500;
    padding: 4px 9px;
    background: #0a0d13;
    border-radius: 4px;
    border: 1px solid #1a1d29;
    font-variant-numeric: tabular-nums;
    min-width: 80px;
    text-align: center;
}

/* ============================================================
   REPLAY FLOATING PANEL
   ============================================================ */
.tv-replay-panel {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #181b25;
    border: 1px solid #2a2e39;
    border-radius: 8px;
    display: none;
    align-items: center;
    padding: 5px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #d1d4dc;
}
.tv-replay-panel.show { display: flex; }
.tv-r-sep { width: 1px; height: 22px; background: #2a2e39; margin: 0 4px; }
.tv-r-btn {
    background: transparent;
    border: none;
    color: #b2b5be;
    cursor: pointer;
    border-radius: 5px;
    padding: 7px 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    height: 32px;
    font-weight: 500;
    font-family: inherit;
}
.tv-r-btn:hover { background: #262a36; color: #fff; }
.tv-r-btn.active { color: #2962ff; background: rgba(41, 98, 255, 0.1); }
.tv-r-btn.primary { background: #2962ff; color: #fff; }
.tv-r-btn.primary:hover { background: #3670ff; }
.tv-r-text-btn { padding: 0 12px; min-width: 42px; }

.tv-r-select-group {
    display: flex;
    align-items: stretch;
    background: #262a36;
    border-radius: 5px;
    margin-right: 4px;
    color: #e0e3eb;
    overflow: hidden;
}
.tv-r-select-group:hover { background: #2f3341; }
.tv-r-select-group.idle { background: transparent; }
.tv-r-select-group.idle:hover { background: #262a36; }
.tv-r-select-main {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px 0 10px;
    height: 32px;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
}
.tv-r-select-caret {
    display: flex;
    align-items: center;
    padding: 0 8px;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    border-left: 1px solid rgba(0,0,0,0.35);
}
.tv-r-select-caret:hover { background: rgba(255,255,255,0.05); }

.tv-r-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    background: #1e2230;
    border: 1px solid #2a2e39;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.6);
    min-width: 240px;
    display: none;
    flex-direction: column;
    padding: 5px 0;
    z-index: 10000;
}
.tv-r-popup.show { display: flex; }
.tv-popup-header {
    font-size: 10px;
    color: #6a7186;
    padding: 6px 14px 8px;
    letter-spacing: 0.6px;
    font-weight: 600;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tv-popup-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    font-size: 13px;
    color: #d1d4dc;
    cursor: pointer;
    background: transparent;
    border: none;
    text-align: left;
    width: 100%;
    font-family: inherit;
}
.tv-popup-item:hover { background: #262a36; }
.tv-popup-item.selected {
    background: rgba(41, 98, 255, 0.15);
    color: #4f80ff;
    font-weight: 600;
}
.tv-popup-item .desc {
    color: #6a7186;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.tv-popup-item.selected .desc { color: #6b93ff; }

.tv-switch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-top: 1px solid #2a2e39;
    margin-top: 4px;
    font-size: 13px;
    color: #d1d4dc;
    cursor: pointer;
}
.tv-switch-row:hover { background: #262a36; }
.tv-switch {
    width: 32px;
    height: 18px;
    background: #4a5164;
    border-radius: 12px;
    position: relative;
    flex-shrink: 0;
}
.tv-switch.on { background: #2962ff; }
.tv-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    transition: left 0.15s;
}
.tv-switch.on::after { left: 16px; }

/* ============================================================
   🎨 DRAWING TOOLS SIDEBAR — TradingView Style Categorized
   ============================================================ */
.left-bar {
    grid-area: left;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--tv-bg2);
    border-right: 1px solid var(--tv-border);
    padding: 4px 0;
    gap: 1px;
    z-index: 90;
    overflow-y: auto;
    overflow-x: visible;
}
.left-bar::-webkit-scrollbar { width: 0; display: none; }

.lt-cat {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--tv-text2);
    padding: 7px;
    transition: background 0.12s, color 0.12s;
}
.lt-cat:hover { background: var(--tv-bg3); color: var(--tv-text); }
.lt-cat.on { background: var(--tv-bg3); color: var(--tv-blue); }
.lt-cat svg { width: 100%; height: 100%; }

/* Triangle indicator (has submenu) */
.lt-cat:not([data-cat="cursor"]):not([data-cat="cross"]):not([data-cat="trash"])::after {
    content: '';
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 4px 4px;
    border-color: transparent transparent var(--tv-text2) transparent;
    opacity: 0.7;
}
.lt-cat:hover::after,
.lt-cat.on::after {
    border-color: transparent transparent var(--tv-blue) transparent;
    opacity: 1;
}

/* Tooltip on hover */
.lt-cat[title]:hover::before {
    content: attr(title);
    position: absolute;
    left: 42px;
    top: 50%;
    transform: translateY(-50%);
    background: #363a45;
    color: var(--tv-text);
    padding: 4px 9px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    z-index: 9999;
    pointer-events: none;
    border: 1px solid var(--tv-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.lt-div {
    width: 24px;
    height: 1px;
    background: var(--tv-border);
    margin: 3px 0;
}

/* Trash button color */
.lt-cat[data-cat="trash"] { color: #ef5350; }
.lt-cat[data-cat="trash"]:hover { background: rgba(239,83,80,0.15); color: #ff1744; }

/* ============================================================
   FLYOUT SUBMENU (Category Popup)
   ============================================================ */
.lt-flyout {
    position: fixed;
    background: #1e222d;
    border: 1px solid #363a45;
    border-radius: 6px;
    padding: 4px;
    z-index: 99998;
    box-shadow: 0 8px 24px rgba(0,0,0,0.65);
    display: none;
    flex-direction: column;
    gap: 1px;
    min-width: 230px;
    animation: ltFlyIn 0.12s ease-out;
}
.lt-flyout.show { display: flex; }
@keyframes ltFlyIn {
    from { opacity: 0; transform: translateX(-4px); }
    to { opacity: 1; transform: translateX(0); }
}

.lt-flyout-header {
    font-size: 10px;
    color: var(--tv-text2);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 10px 4px;
    border-bottom: 1px solid var(--tv-border);
    margin-bottom: 2px;
}

.lt-flyout-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--tv-text);
    font-size: 12px;
    font-family: inherit;
    text-align: left;
    width: 100%;
    transition: background 0.1s;
}
.lt-flyout-item:hover { background: #2a2e39; }
.lt-flyout-item.on {
    background: rgba(41, 98, 255, 0.15);
    color: var(--tv-blue);
}
.lt-flyout-item .lt-fly-icon {
    width: 18px;
    height: 18px;
    color: var(--tv-text2);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lt-flyout-item:hover .lt-fly-icon,
.lt-flyout-item.on .lt-fly-icon { color: var(--tv-blue); }
.lt-flyout-item .lt-fly-icon svg { width: 100%; height: 100%; }
.lt-flyout-item .lt-fly-name { flex: 1; font-weight: 500; }
.lt-flyout-item .lt-fly-shortcut {
    font-size: 10px;
    color: var(--tv-text2);
    font-family: monospace;
    background: #0f1218;
    padding: 1px 5px;
    border-radius: 3px;
}

/* ============================================================
   DRAWING CONTEXT MENU (Right-click on drawing)
   ============================================================ */
.dw-ctx {
    position: fixed;
    z-index: 99999;
    background: #1e222d;
    border: 1px solid #363a45;
    border-radius: 6px;
    padding: 4px 0;
    min-width: 190px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.55);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
    animation: dwCtxIn 0.1s ease-out;
}
@keyframes dwCtxIn {
    from { opacity: 0; transform: scale(.96); }
    to { opacity: 1; transform: scale(1); }
}
.dw-ctx-i {
    padding: 7px 14px;
    color: var(--tv-text);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.1s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.dw-ctx-i:hover { background: #2a2e39; color: #fff; }
.dw-ctx-del { color: #ef5350; }
.dw-ctx-del:hover { background: rgba(239, 83, 80, 0.15) !important; color: #ff1744 !important; }
.dw-ctx-sep { height: 1px; background: #363a45; margin: 3px 0; }

/* ============================================================
   CANVAS / CHART AREA
   ============================================================ */
.chart-area {
    grid-area: chart;
    position: relative;
    background: var(--tv-bg);
    overflow: hidden;
}
#chart-container {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    contain: size layout paint;
    will-change: width, height;
}

.ohlc-overlay {
    position: absolute;
    top: 6px;
    left: 8px;
    z-index: 50;
    pointer-events: none;
    display: flex;
    gap: 10px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    background: rgba(19, 23, 34, 0.65);
    padding: 2px 6px;
    border-radius: 4px;
}
.ohlc-overlay .ol { color: var(--tv-text2); margin-right: 2px; }
.ohlc-overlay .ov { color: var(--tv-text3); }
.ohlc-overlay .ov.up { color: var(--tv-green); }
.ohlc-overlay .ov.down { color: var(--tv-red); }

/* ============================================================
   RIGHT SIDEBAR (Hidden — Floating Ticket Architecture)
   ============================================================ */
.right-bar { display: none !important; }

/* ============================================================
   FLOATING TRADE TICKET
   ============================================================ */
.trade-ticket {
    --up: #0ecb81;
    --dn: #f6465d;
    --bg: rgba(19, 23, 34, 0.95);
    --panel: #1e222d;
    --border: #2a2e39;
    --text: #ffffff;
    --muted: #707a8a;
    --font: 'Inter', sans-serif;
    --mono: 'JetBrains Mono', monospace;

    position: absolute;
    right: 16px;
    bottom: 60px;
    z-index: 1000;
    width: 300px;
    max-width: calc(100vw - 32px);
    background: var(--bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    font-family: var(--font);
    overflow: hidden;
    transition: width 0.2s ease, bottom 0.2s ease;
}
.trade-ticket.closed { width: max-content; }
.trade-ticket.closed .ticket-body { display: none; }
.trade-ticket.closed .t-chev { transform: rotate(0deg); }

.ticket-bar { display: flex; align-items: stretch; height: 44px; }
.t-btn-quick {
    border: none;
    padding: 0 18px;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: filter 0.15s;
}
.t-btn-quick.buy { background: var(--up); color: #000; border-radius: 0; }
.t-btn-quick.sell { background: var(--dn); color: #fff; border-radius: 0; }
.t-btn-quick:hover { filter: brightness(1.1); }
.t-btn-quick:active { filter: brightness(0.9); }

.ticket-mid {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    background: var(--panel);
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    padding: 0 16px;
    transition: background 0.15s;
}
.ticket-mid:hover { background: #2a2e39; }
.t-lev-label { color: var(--muted); font-size: 10px; }
.t-chev { color: var(--muted); font-size: 10px; transition: transform 0.2s; transform: rotate(180deg); }

.ticket-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-top: 1px solid var(--border);
}

.t-row { display: flex; gap: 6px; }
.t-side {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    background: #131722;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    border-radius: 6px;
    cursor: pointer;
}
.t-side.on.buy { background: var(--up); color: #000; border-color: var(--up); }
.t-side.on.sell { background: var(--dn); color: #fff; border-color: var(--dn); }

.t-field { display: flex; flex-direction: column; gap: 6px; }
.t-field label {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    font-weight: 600;
}
.t-field label b {
    color: var(--text);
    font-family: var(--mono);
    font-weight: 500;
    text-transform: none;
}
.t-row-half { display: flex; gap: 8px; }
.t-row-half .t-field { flex: 1; min-width: 0; }

.t-seg { display: flex; gap: 4px; }
.t-seg button {
    flex: 1;
    padding: 6px 0;
    border: 1px solid var(--border);
    background: #131722;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.15s;
}
.t-seg button:hover { color: var(--text); border-color: #4e5569; }
.t-seg button.on { background: #2a2e39; color: var(--text); border-color: #4e5569; }
.t-seg.tiny button { padding: 4px 0; font-size: 10px; }

.t-stepper {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}
.t-stepper button {
    width: 40px;
    border: none;
    background: var(--panel);
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}
.t-stepper button:hover { background: var(--border); }
.t-stepper input, .t-field > input {
    flex: 1;
    border: none;
    background: #131722;
    color: var(--text);
    text-align: center;
    font-family: var(--mono);
    font-size: 13px;
    padding: 8px 6px;
    outline: none;
    -moz-appearance: textfield;
    width: 100%;
}
.t-field > input { border: 1px solid var(--border); border-radius: 6px; text-align: left; }
.t-field > input:focus { border-color: #4e5569; }
.t-field > input::placeholder { color: #4e5569; }
.t-stepper input::-webkit-outer-spin-button,
.t-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

.t-summary {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--muted);
    padding-top: 4px;
}
.t-summary b { color: var(--text); font-family: var(--mono); font-weight: 600; }

.t-submit {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.5px;
    transition: 0.15s;
    margin-top: 4px;
}
.t-submit.buy { background: var(--up); color: #000; }
.t-submit.sell { background: var(--dn); color: #fff; }
.t-submit:hover { filter: brightness(1.1); }
.t-submit:active { transform: scale(0.98); }

/* ============================================================
   ON-CHART ORDER WIDGET (Draggable Pills)
   ============================================================ */
.ow-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
}
.ow-hit {
    position: absolute;
    left: 0; right: 0;
    height: 18px;
    margin-top: -9px;
    pointer-events: auto !important;
    cursor: ns-resize;
    z-index: 51;
}
.ow-hit.no-drag { cursor: default !important; }
.ow-hline {
    position: absolute;
    left: 0; right: 0;
    height: 0;
    pointer-events: none;
    z-index: 51;
}
.ow-hline.entry { border-top: 2px solid #2962ff; }
.ow-hline.entry.is-sell { border-top-color: #ef5350; }
.ow-hline.entry.draft,
.ow-hline.entry.pending { border-top-style: dashed; }
.ow-hline.tp { border-top: 1.5px dashed #26a69a; }
.ow-hline.sl { border-top: 1.5px dashed #ff9800; }

.ow-pill {
    position: absolute;
    display: inline-flex;
    align-items: stretch;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 11px;
    font-weight: 600;
    pointer-events: auto !important;
    user-select: none;
    white-space: nowrap;
    transform: translateY(-50%);
    cursor: ns-resize;
    z-index: 52;
    gap: 0;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
    border: 1px solid #363a45;
}
.ow-pill.no-drag { cursor: default !important; }

.ow-chip {
    margin: 0;
    padding: 0 8px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border: none;
    border-right: 1px solid #363a45;
    background: #1c2030;
    color: #d1d4dc;
    line-height: 1;
}
.ow-pill .ow-chip:last-child { border-right: none; }

.ow-pill .chip-label.buy { background: #2962ff; color: #fff; cursor: pointer; }
.ow-pill .chip-label.buy:hover { background: #1e53e5; }
.ow-pill .chip-label.sell { background: #ef5350; color: #fff; cursor: pointer; }
.ow-pill .chip-label.sell:hover { background: #d32f2f; }
.ow-pill .chip-label.tp { background: #26a69a; color: #fff; }
.ow-pill .chip-label.sl { background: #ff9800; color: #fff; }

.ow-pill .qty { cursor: default; font-family: monospace; background: #2a2e39; color: #d1d4dc; }
.ow-pill .val { cursor: default; background: #131722; color: #d1d4dc; }
.ow-pill .val.pnl-up { color: #26a69a !important; font-weight: 700; }
.ow-pill .val.pnl-down { color: #ef5350 !important; font-weight: 700; }
.ow-pill .val[data-act="toggle-mode"] { cursor: pointer; }
.ow-pill .val[data-act="toggle-mode"]:hover { background: #2a2e39; }
.ow-pill .close-btn { cursor: pointer; color: #787b86; background: #131722; }
.ow-pill .close-btn:hover { background: #ef5350; color: #fff; }
.ow-pill .tpsl-chip { cursor: ns-resize; background: #131722; font-weight: bold; }
.ow-pill .tpsl-chip.tp { color: #26a69a; }
.ow-pill .tpsl-chip.sl { color: #ef5350; }
.ow-pill .tpsl-chip:hover { background: #2a2e39; }
.ow-pill .tpsl-chip.dragging { opacity: 0.4; }

.ow-ghost {
    position: absolute;
    left: 0; right: 0;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 60;
}
.ow-ghost-line {
    position: absolute;
    left: 0; right: 0;
    top: 0;
    border-top: 1.5px dashed #26a69a;
}
.ow-ghost-text {
    position: absolute;
    right: 70px;
    top: 0;
    transform: translateY(-50%);
    padding: 4px 10px;
    background: #26a69a;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.ow-ghost.invalid .ow-ghost-line { border-top-color: #ef5350; }
.ow-ghost.invalid .ow-ghost-text { background: #ef5350; }

.ow-zone-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 40;
}
.ow-zone-box {
    position: absolute;
    left: 0; right: 0;
    opacity: 0.08;
}
.ow-zone-box.tp-zone { background: #26a69a; }
.ow-zone-box.sl-zone { background: #ff9800; }
.ow-zone-box.bad-zone { background: #ef5350; }

/* ============================================================
   BOTTOM PANEL
   ============================================================ */
.bottom-panel {
    grid-area: bottom;
    display: flex;
    flex-direction: column;
    background: var(--tv-bg2);
    border-top: 1px solid var(--tv-border);
    overflow: hidden;
    z-index: 101;
    height: 100%;
}
.bottom-panel__tabs {
    display: flex;
    align-items: center;
    background: var(--tv-bg2);
    border-bottom: 1px solid var(--tv-border);
    padding: 0 8px;
    height: 28px;
    flex-shrink: 0;
}
.bottom-tab {
    background: transparent;
    border: none;
    color: var(--tv-text2);
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}
.bottom-tab:hover { color: var(--tv-text); }
.bottom-tab.active { color: var(--tv-blue); border-bottom-color: var(--tv-blue); font-weight: 600; }

.badge {
    background: var(--tv-bg4);
    color: var(--tv-text);
    padding: 0 4px;
    font-size: 9px;
    border-radius: 4px;
    margin-left: 2px;
}
.badge.ok { background: rgba(38,166,154,0.15); color: var(--tv-green); }

.bottom-toggle {
    background: transparent;
    border: none;
    color: var(--tv-text2);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 10px;
}
.bottom-content {
    flex: 1;
    overflow-y: auto;
    background: var(--tv-bg);
}
.bottom-pane {
    display: none;
    padding: 8px;
    height: 100%;
}
.bottom-pane.active { display: block; }
.bottom-panel.collapsed .bottom-content { display: none; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    text-align: left;
}
.data-table th {
    color: var(--tv-text2);
    border-bottom: 1px solid var(--tv-border);
    padding: 6px 8px;
    font-weight: 600;
}
.data-table td {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-variant-numeric: tabular-nums;
}
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }

.cancel-btn {
    background: transparent;
    border: 1px solid var(--tv-border);
    border-radius: 3px;
    color: var(--tv-text2);
    padding: 2px 8px;
    cursor: pointer;
}
.cancel-btn:hover { border-color: var(--tv-red); color: var(--tv-red); }

.empty-state {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--tv-bg4);
}
.log-container {
    font-family: monospace;
    font-size: 11px;
    line-height: 1.6;
    color: var(--tv-text3);
    padding: 4px;
}
.up { color: var(--tv-green) !important; }
.down { color: var(--tv-red) !important; }

.pos-side {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 2px;
}
.pos-side.long, .pos-side.buy { background: rgba(38,166,154,0.15); color: var(--tv-green); }
.pos-side.short, .pos-side.sell { background: rgba(239,83,80,0.15); color: var(--tv-red); }

/* History summary text */
.history-summary-text {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: var(--tv-text2);
}

/* ============================================================
   GO-TO DATE MODAL
   ============================================================ */
.tv-goto-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 18, 0.85) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: tvFade 0.12s ease-out;
    will-change: opacity;
}
@keyframes tvFade { from { opacity: 0; } to { opacity: 1; } }

.tv-goto-modal {
    background: var(--tv-bg2) !important;
    border: 1px solid var(--tv-bg4) !important;
    border-radius: 8px !important;
    width: 320px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6) !important;
    display: flex;
    flex-direction: column;
    animation: tvPop 0.12s cubic-bezier(0.215, 0.610, 0.355, 1);
    overflow: hidden;
    will-change: transform, opacity;
}
@keyframes tvPop {
    from { opacity: 0; transform: scale(0.97) translateY(-6px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.tv-goto-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 12px;
}
.tv-goto-header h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: -0.02em;
}
.tv-goto-close {
    background: transparent;
    border: none;
    color: var(--tv-text2);
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    transition: all 0.15s ease;
}
.tv-goto-close:hover { color: #ffffff; background: var(--tv-bg3); }

.tv-goto-tabs {
    display: flex;
    gap: 16px;
    padding: 0 20px;
    border-bottom: 1px solid var(--tv-border);
}
.tv-goto-tab {
    padding: 8px 0;
    color: var(--tv-text2);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: color 0.15s ease;
}
.tv-goto-tab:hover { color: var(--tv-text); }
.tv-goto-tab.active { color: #ffffff; font-weight: 600; }
.tv-goto-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0; right: 0;
    height: 2px;
    background: var(--tv-blue);
    border-radius: 99px;
}

.tv-goto-body, .tv-range-body {
    padding: 16px 20px;
    min-height: 295px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.tv-goto-inputs { display: flex; gap: 8px; margin-bottom: 12px; }
.tv-input-wrap {
    position: relative;
    flex: 1;
    border: 1px solid var(--tv-border);
    display: inline-flex;
    align-items: center;
    border-radius: 6px;
    background: var(--tv-bg);
    transition: all 0.15s ease;
}
.tv-input-wrap.date { flex: 1.4; }
.tv-input-wrap.time { flex: 1; }
.tv-input-wrap:hover { border-color: var(--tv-bg4); }
.tv-input-wrap:focus-within { border-color: var(--tv-blue); background: var(--tv-bg2); }
.tv-goto-input {
    width: 100%;
    background: transparent;
    border: none;
    color: #ffffff;
    padding: 7px 28px 7px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-family: monospace;
    outline: none;
    box-sizing: border-box;
}
.tv-input-icon {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #4f525d;
    font-size: 11px;
}

.tv-time-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--tv-bg2);
    border: 1px solid var(--tv-bg4);
    border-radius: 6px;
    max-height: 180px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    display: none;
}
.tv-time-dropdown.show { display: block; }
.tv-time-dropdown::-webkit-scrollbar { width: 6px; }
.tv-time-dropdown::-webkit-scrollbar-thumb { background: #2a2e39; border-radius: 99px; }
.tv-time-option {
    padding: 6px 10px;
    font-size: 12px;
    color: var(--tv-text);
    cursor: pointer;
    font-family: monospace;
    transition: all 0.15s ease;
}
.tv-time-option:hover { background: #2a2e39; color: #ffffff; }
.tv-time-option.selected { background: var(--tv-blue); color: #ffffff; font-weight: 600; }

.calendar { width: 100%; user-select: none; }
.calendar .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.calendar .header button {
    background: transparent;
    border: none;
    color: var(--tv-text2);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.calendar .header button:hover:not(:disabled) { background: #2a2e39; color: #ffffff; }
.calendar .header button:disabled { opacity: 0.25; cursor: default; }
.calendar .header button.title { color: #ffffff; font-weight: 600; }
.calendar .header button.flip-horizontal svg { transform: rotate(180deg); }

.calendar .sub-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 4px;
}
.calendar .sub-header span {
    text-align: center;
    font-size: 10px;
    color: #4f525d;
    padding: 4px 0;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calendar .view-month { display: flex; flex-direction: column; }
.calendar .weeks { display: flex; flex-direction: column; gap: 2px; }
.calendar .week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }

.calendar .day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--tv-text);
    font-size: 11px;
    font-family: monospace;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}
.calendar .day:hover:not(:disabled):not([aria-selected="true"]) { background: #2a2e39; color: #ffffff; }
.calendar .day:disabled { color: #4f525d; opacity: 0.3; cursor: default; }
.calendar .day.today { border: 1px solid var(--tv-bg4); font-weight: 600; }
.calendar .day[aria-selected="true"] {
    background: var(--tv-blue) !important;
    color: #ffffff !important;
    font-weight: 700;
}

.tv-cal-grid-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.tv-cal-month {
    padding: 10px 0;
    text-align: center;
    font-size: 12px;
    color: var(--tv-text);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
}
.tv-cal-month:hover:not(.disabled):not(.selected) { background: #2a2e39; color: #ffffff; }
.tv-cal-month.selected { background: var(--tv-blue); color: #ffffff; font-weight: 600; }
.tv-cal-month.disabled { color: #4f525d; opacity: 0.3; cursor: default; }

.tv-cal-grid-years { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.tv-cal-year {
    padding: 8px 0;
    text-align: center;
    font-size: 11px;
    color: var(--tv-text);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s ease;
    font-family: monospace;
}
.tv-cal-year:hover:not(.disabled):not(.selected) { background: #2a2e39; color: #ffffff; }
.tv-cal-year.selected { background: var(--tv-blue); color: #ffffff; font-weight: 600; }
.tv-cal-year.disabled { color: #4f525d; opacity: 0.3; cursor: default; }

.tv-cal-sublabel {
    text-align: center;
    color: #4f525d;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 0;
    background: var(--tv-bg);
    border-radius: 4px;
    margin-bottom: 8px;
}

.tv-goto-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--tv-border);
}
.tv-btn-cancel {
    background: transparent;
    color: var(--tv-text);
    border: 1px solid var(--tv-border);
    border-radius: 6px;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}
.tv-btn-cancel:hover { background: #2a2e39; border-color: var(--tv-bg4); color: #ffffff; }
.tv-btn-goto {
    background: var(--tv-blue) !important;
    color: #ffffff !important;
    border: none;
    border-radius: 6px;
    padding: 5px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}
.tv-btn-goto:hover { background: #1e53e5 !important; }

.tv-range-label {
    font-size: 11px;
    color: #4f525d;
    margin-bottom: 4px;
    display: block;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.bottom-tab.goto-btn {
    background: transparent;
    color: var(--tv-text2);
    border: none !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    font-size: 11px;
    margin-left: auto;
    transition: color 0.15s ease;
    height: 100%;
}
.bottom-tab.goto-btn:hover { color: #ffffff; }

/* Tab Pane Visibility */
.tv-goto-tab-pane { display: none; }
.tv-goto-tab-pane.active { display: block; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast {
    position: fixed;
    top: 48px;
    right: 12px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    z-index: 9999;
    transform: translateX(120%);
    transition: transform 0.25s ease;
    max-width: 280px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.toast.show { transform: translateX(0); }
.toast.ok { background: rgba(38,166,154,0.95); color: #fff; }
.toast.err { background: rgba(239,83,80,0.95); color: #fff; }
.toast.info { background: var(--tv-bg3); color: var(--tv-text); border: 1px solid var(--tv-border); }

/* ============================================================
   LOADER PILL
   ============================================================ */
.loader-pill {
    position: fixed;
    bottom: 42px;
    right: 12px;
    background: var(--tv-bg3);
    border: 1px solid var(--tv-border);
    padding: 6px 12px;
    border-radius: 20px;
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    z-index: 999;
}
.loader-pill.show { display: flex; }
.loader-spin {
    width: 12px;
    height: 12px;
    border: 2px solid var(--tv-text2);
    border-top-color: var(--tv-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   MOBILE DRAWER & FLOATING FAB
   ============================================================ */
.drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
    opacity: 0;
}
.drawer-overlay.show { display: block; opacity: 1; }

.mobile-trade-fab {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 16px;
    width: 50px;
    height: 50px;
    background: var(--tv-blue);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    z-index: 150;
    box-shadow: 0 4px 16px rgba(41, 98, 255, 0.4);
}

/* ============================================================
   LOGIN OVERLAY
   ============================================================ */
.login-overlay {
    position: fixed;
    inset: 0;
    background: #0c0e15;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.login-modal {
    background: #181b25;
    border: 1px solid #2a2e39;
    border-radius: 12px;
    width: 340px;
    padding: 28px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.6);
}
.login-header h2 {
    font-size: 18px;
    color: #ffffff;
    text-align: center;
    margin-bottom: 4px;
}
.login-header p {
    font-size: 11px;
    color: #787b86;
    text-align: center;
    margin-bottom: 24px;
}
.login-tabs {
    display: flex;
    gap: 4px;
    background: #0f1218;
    padding: 2px;
    border-radius: 6px;
    margin-bottom: 18px;
}
.login-tab {
    flex: 1;
    border: none;
    background: transparent;
    color: #787b86;
    padding: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
}
.login-tab.active { background: #2962ff; color: #fff; }
.login-form-group { display: flex; flex-direction: column; gap: 10px; }
.login-form-group input {
    background: #0f1218;
    border: 1px solid #2a2e39;
    padding: 10px 12px;
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
    outline: none;
}
.login-form-group input:focus { border-color: #2962ff; }
.login-form-group button {
    background: #2962ff;
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    padding: 11px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 6px;
}
.login-form-group button:hover { background: #1e53e5; }
.login-form-group button:disabled { opacity: 0.5; }
.auth-error-label {
    color: #ef5350;
    font-size: 11px;
    text-align: center;
    margin-top: 6px;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.hidden { display: none !important; }

/* ============================================================
   📱 RESPONSIVE MOBILE
   ============================================================ */
@media (max-width: 768px) {
    :root {
        --left-w: 0px;
        --right-w: 0px;
        --bottom-h: 130px;
    }

    /* 🎨 Floating Drawing Bar (Left side se safe distance + scrollable) */
    .left-bar {
        position: fixed;
        bottom: calc(var(--bottom-h) + 12px);
        left: 10px;
        transform: none;
        flex-direction: row;
        padding: 4px 6px;
        gap: 3px;
        background: var(--tv-bg2);
        border: 1px solid var(--tv-border);
        border-radius: 30px;
        z-index: 110;
        width: auto;
        height: auto;
        box-shadow: 0 4px 16px rgba(0,0,0,0.5);
        max-width: calc(100vw - 75px); /* Right side par Blue button ke liye jagah chhori */
        overflow-x: auto;
        scrollbar-width: none;
    }
    .left-bar::-webkit-scrollbar { display: none; }

    .platform:has(#bottom-panel.collapsed) .left-bar {
        bottom: calc(var(--bottom-collapsed) + 12px);
    }

    .lt-cat { width: 32px; height: 32px; flex-shrink: 0; }
    .lt-div { width: 1px; height: 20px; margin: 0 2px; }
    .lt-cat[title]:hover::before { display: none; }
    .lt-cat:not([data-cat="cursor"]):not([data-cat="cross"]):not([data-cat="trash"])::after {
        right: 1px;
        bottom: 1px;
    }

    .lt-flyout {
        max-width: calc(100vw - 20px);
        max-height: 60vh;
        overflow-y: auto;
    }

    /* ⚡ Mobile Trade Floating Action Button (Position Fixed above bottom tabs) */
    .mobile-trade-fab {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: calc(var(--bottom-h) + 12px);
        right: 10px;
        width: 44px;
        height: 44px;
        background: var(--tv-blue);
        border: none;
        border-radius: 50%;
        color: #fff;
        font-size: 18px;
        cursor: pointer;
        z-index: 150;
        box-shadow: 0 4px 16px rgba(41, 98, 255, 0.45);
    }

    .platform:has(#bottom-panel.collapsed) .mobile-trade-fab {
        bottom: calc(var(--bottom-collapsed) + 12px);
    }

    .right-bar {
        position: fixed;
        bottom: 0;
        left: 0; right: 0;
        height: 65dvh;
        z-index: 210;
        border-left: none;
        border-top: 1px solid var(--tv-border);
        border-radius: 12px 12px 0 0;
        transform: translateY(100%);
    }
    .right-bar.open { transform: translateY(0); }

    .tv-replay-panel { bottom: 20px; padding: 4px; }
    .tv-r-popup { min-width: 220px; }
}
@media (max-width: 480px) {
    :root {
        --top-h: 36px;
        --bottom-h: 120px;
    }
    .tf-b { padding: 4px 6px; font-size: 11px; }
    .tb-symbol { font-size: 12px; }
    .tb-symbol .exch { display: none; }
    .tb-status { display: none; }
}