:root {
    /* TradingView light theme */
    --bg: #ffffff;
    --bg-subtle: #f8f9fd;
    --bg-hover: #f0f3fa;
    --border: #e0e3eb;
    --border-strong: #d1d4dc;
    --text: #131722;
    --text-muted: #6a6d78;
    --blue: #2962ff;
    --blue-hover: #1e53e5;
    --blue-soft: #e3effd;
    --green: #089981;
    --green-soft: #e6f4f1;
    --red: #f23645;
    --red-soft: #fdecee;
    --orange: #ff9800;
    --orange-soft: #fff3e0;
    /* Pine script colors */
    --pine-buy: #4caf50;
    --pine-sell: #ff5252;

    --font-sans: -apple-system, BlinkMacSystemFont, 'Trebuchet MS', 'Inter', Roboto, Ubuntu, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;
    --radius: 4px;
    --radius-lg: 8px;
    --toolbar-h: 46px;
    --sidebar-w: clamp(280px, 22vw, 420px);
    --bottom-h: clamp(190px, 28vh, 330px);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --dur: 150ms;
    --ease: cubic-bezier(0.2, 0, 0, 1);
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(19, 23, 34, 0.14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: clamp(13px, 0.45vw + 7px, 16px);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
    line-height: 1.45;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.up { color: var(--green); }
.down { color: var(--red); }
.muted { color: var(--text-muted); }
.small { font-size: 11px; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; border-radius: var(--radius); }

/* ---------- toolbar ---------- */
.toolbar {
    height: var(--toolbar-h); flex-shrink: 0;
    display: flex; align-items: center; gap: 4px;
    padding: 0 8px; border-bottom: 1px solid var(--border); background: var(--bg);
    position: relative; z-index: 20;
    overflow: hidden; overflow-x: hidden; overflow-y: hidden; scrollbar-width: none;
}
.toolbar::-webkit-scrollbar { display: none; }
.divider { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.toolbar-spacer { flex: 1; }
.menu-anchor { position: relative; }

.symbol-btn, .tool-btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 34px; padding: 0 10px; border-radius: var(--radius);
    font-weight: 600; white-space: nowrap;
    transition: background var(--dur) var(--ease);
}
.symbol-btn { font-size: 15px; max-width: 280px; }
.symbol-btn span { overflow: hidden; text-overflow: ellipsis; }
.tool-btn { font-weight: 500; }
.symbol-btn:hover, .tool-btn:hover { background: var(--bg-hover); }
.tool-btn.is-on { color: var(--blue); }

.interval-group { display: flex; gap: 2px; }
.interval-group button {
    height: 30px; min-width: 32px; padding: 0 7px; border-radius: var(--radius);
    font-weight: 500; transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.interval-group button:hover { background: var(--bg-hover); }
.interval-group button[aria-pressed="true"] { color: var(--blue); background: var(--blue-soft); }

.badge {
    display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
    border-radius: 12px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-live { background: var(--green-soft); color: var(--green); }
.badge-sim { background: var(--orange-soft); color: #e65100; }
.badge-muted { background: var(--bg-hover); color: var(--text-muted); }
.badge-open { background: var(--blue-soft); color: var(--blue); }

.primary-btn, .ghost-btn {
    height: 32px; padding: 0 14px; border-radius: var(--radius); font-weight: 600; white-space: nowrap;
    transition: background var(--dur) var(--ease);
}
.primary-btn { background: var(--blue); color: #fff; }
.primary-btn:hover { background: var(--blue-hover); }
.ghost-btn { border: 1px solid var(--border-strong); }
.ghost-btn:hover { background: var(--bg-hover); }
.link-btn { color: var(--blue); font-size: 12px; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }
.icon-btn { width: 32px; height: 32px; border-radius: var(--radius); display: inline-grid; place-items: center; color: var(--text-muted); }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ---------- symbol search ---------- */
.popover { position: absolute; top: calc(100% + 4px); left: 0; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); z-index: 30; }
.symbol-menu { width: 360px; padding: 8px; }
.symbol-menu input { width: 100%; height: 36px; padding: 0 10px; margin-bottom: 6px; border: 1px solid var(--border-strong); border-radius: var(--radius); }
.symbol-menu input:focus { border-color: var(--blue); outline: none; }
.symbol-list { max-height: 400px; overflow-y: auto; }
.symbol-group { padding: 8px 8px 4px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.symbol-item { display: flex; justify-content: space-between; width: 100%; padding: 8px; border-radius: var(--radius); text-align: left; }
.symbol-item:hover, .symbol-item:focus-visible { background: var(--bg-hover); }
.symbol-item[aria-selected="true"] { background: var(--blue-soft); }
.symbol-item small { color: var(--text-muted); }

/* ---------- layout (desktop) ---------- */
.workspace {
    flex: 1; min-height: 0; display: grid;
    grid-template-columns: minmax(0, 1fr) var(--sidebar-w);
    grid-template-rows: minmax(0, 1fr) var(--bottom-h);
    grid-template-areas: "chart side" "bottom side";
}
.workspace.no-side { grid-template-columns: minmax(0, 1fr); grid-template-areas: "chart" "bottom"; }
.workspace.no-bottom { grid-template-rows: minmax(0, 1fr); grid-template-areas: "chart side"; }
.workspace.no-side.no-bottom { grid-template-areas: "chart"; }
.workspace.no-side .sidebar, .workspace.no-bottom .bottom { display: none; }

.chart-area { grid-area: chart; position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chart-body { flex: 1; min-height: 0; min-width: 0; display: flex; }

/* option strike strip: slim TradingView-style status line above the charts */
.option-live-hud {
    flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px;
    padding: 4px 12px; font-size: 12px; color: var(--text-muted);
    background: var(--bg-subtle); border-bottom: 1px solid var(--border);
}
.hud-group { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 14px; }
.hud-tag { background: var(--blue-soft); color: var(--blue); font-weight: 700; font-size: 11px; letter-spacing: 0.4px; padding: 2px 8px; border-radius: var(--radius); }
.hud-item strong { color: var(--text); font-family: var(--font-mono); font-weight: 600; margin-left: 2px; font-variant-numeric: tabular-nums; }
.hud-status { font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--text-muted); }
.hud-status.is-live { color: var(--green); }

.icon-btn[aria-pressed="false"] { color: var(--border-strong); }
.icon-btn[aria-pressed="true"] { color: var(--text); }
.tool-btn[aria-pressed="true"] { color: var(--blue); background: var(--blue-soft); }
.wide-btn { width: 100%; margin-top: 10px; }
.setup-state.is-clickable { width: 100%; text-align: left; cursor: pointer; transition: box-shadow var(--dur) var(--ease); }
.setup-state.is-clickable:hover { box-shadow: 0 0 0 2px var(--blue-soft); }

/* ---------- drawing tool bar ---------- */
.draw-bar {
    flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 2px;
    width: 46px; padding: 6px 4px; overflow-y: auto; scrollbar-width: none;
    border-right: 1px solid var(--border); background: var(--bg);
}
.workspace.no-draw .draw-bar { display: none; }
.draw-btn {
    flex: 0 0 auto; width: 36px; height: 36px; border-radius: var(--radius); display: grid; place-items: center;
    color: var(--text-muted); transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.draw-btn:hover { background: var(--bg-hover); color: var(--text); }
.draw-btn[aria-pressed="true"] { background: var(--blue-soft); color: var(--blue); }
.draw-btn.is-danger:hover { background: var(--red-soft); color: var(--red); }
.draw-sep { flex: 0 0 auto; width: 24px; height: 1px; background: var(--border); margin: 4px 0; }
.draw-color { flex: 0 0 auto; width: 32px; height: 28px; padding: 1px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); cursor: pointer; }
.draw-width { flex: 0 0 auto; width: 42px; height: 28px; margin-top: 2px; padding: 0 2px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); font-size: 11px; }
.draw-hint {
    position: absolute; bottom: 44px; left: 50%; transform: translateX(-50%); z-index: 12; max-width: calc(100% - 24px);
    background: var(--text); color: #fff; padding: 7px 14px; border-radius: 16px; font-size: 12px; font-weight: 500; text-align: center;
    box-shadow: var(--shadow); pointer-events: none;
}

/* ---------- chart panes (1, 2 or 4 charts) ---------- */
.panes { flex: 1; min-width: 0; min-height: 0; display: grid; gap: 2px; background: var(--border); }
.panes.layout-1 { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.panes.layout-2h { grid-template: minmax(0, 1fr) / repeat(2, minmax(0, 1fr)); }
.panes.layout-2v { grid-template: repeat(2, minmax(0, 1fr)) / minmax(0, 1fr); }
.panes.layout-4 { grid-template: repeat(2, minmax(0, 1fr)) / repeat(2, minmax(0, 1fr)); }

.panes.focus-split { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.panes.focus-split .chart-pane:not(.is-active) { display: none; }
.chart-pane { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); container: pane / size; }
.panes[data-multi="true"] .chart-pane.is-active::after {
    content: ""; position: absolute; inset: 0; border: 2px solid var(--blue); pointer-events: none; z-index: 8;
}

.pane-bar { display: none; flex: 0 0 auto; align-items: center; gap: 6px; height: 34px; padding: 0 6px 0 8px; border-bottom: 1px solid var(--border); background: var(--bg-subtle); }
.panes[data-multi="true"] .pane-bar { display: flex; }
.pane-symbol { font-weight: 700; padding: 4px 6px; border-radius: var(--radius); max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-symbol:hover { background: var(--bg-hover); }
.pane-interval { height: 26px; padding: 0 4px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); font-weight: 600; }
.pane-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex: 0 0 auto; }
.pane-dot.is-live { background: var(--green); }
.pane-dot.is-sim { background: var(--orange); }
.pane-opt { height: 24px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: 12px; font-size: 11px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.pane-opt:hover { background: var(--bg-hover); }
.pane-opt[aria-pressed="true"] { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }

/* the option chart opens beside (or under, when the pane is narrow) the index chart */
/* ---------- pane resizer & mode toggle ---------- */
.pane-split { flex: 1; min-height: 0; display: flex; overflow: hidden; position: relative; }
.pane-main, .pane-option { position: relative; flex: 1 1 0; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.pane-resizer {
    width: 6px;
    background: var(--border);
    cursor: col-resize;
    position: relative;
    z-index: 15;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
.pane-resizer:hover, .pane-resizer.is-dragging {
    background: var(--blue);
}
.pane-resizer::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 24px;
    background: var(--text-muted);
    border-radius: 1px;
}

.mode-toggle-btn {
    display: inline-flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 10px; border-radius: var(--radius);
    font-size: 11px; font-weight: 700; letter-spacing: 0.4px;
    text-transform: uppercase; transition: all var(--dur) var(--ease);
}
.mode-toggle-btn.is-manual {
    background: rgba(2, 132, 199, 0.12); color: #0284c7; border: 1px solid rgba(2, 132, 199, 0.4);
}
.mode-toggle-btn.is-auto {
    background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.5);
}
.mode-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.mode-dot.is-manual { background: #0284c7; }
.mode-dot.is-auto { background: #10b981; box-shadow: 0 0 6px #10b981; animation: pulseDot 1.5s infinite; }
@keyframes pulseDot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(0.85); } }
.pane-main { display: flex; flex-direction: column; }
.pane-spot-head[hidden] { display: none !important; }
.pane-option { border-left: 2px solid var(--border); }
.pane-body { position: relative; flex: 1; min-height: 0; }
.chart-host { position: absolute; inset: 0; }
.pane-head { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 6px 0 12px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.pane-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-note { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@container pane (max-width: 760px) {
    .pane-split { flex-direction: column; }
    .pane-option { border-left: 0; border-top: 2px solid var(--border); }
}

/* in multi-chart layouts the pane bar already names the chart, so the legend stays small */
.panes[data-multi="true"] .legend-title { display: none; }
.panes[data-multi="true"] .legend { font-size: 12px; background: rgba(255, 255, 255, 0.72); right: auto; max-width: calc(100% - 78px); border-radius: 4px; padding: 0 4px; }
@container pane (max-width: 560px) {
    .lg-detail, .legend-study { display: none; }
}

/* floating bar for the selected drawing */
.sel-bar {
    position: absolute; top: 34px; left: 50%; transform: translateX(-50%); z-index: 9;
    display: flex; align-items: center; gap: 4px; padding: 4px;
    background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.sel-bar input[type="color"] { width: 32px; height: 30px; padding: 1px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); cursor: pointer; }
.sel-bar select { height: 30px; padding: 0 4px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); }
.sel-btn { height: 30px; min-width: 30px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: var(--radius); font-weight: 700; color: var(--text); }
.sel-btn:hover { background: var(--bg-hover); }
.sel-btn.is-danger:hover { background: var(--red-soft); color: var(--red); }
.note-input { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 15px; }
.note-input:focus { border-color: var(--blue); outline: none; }

.strategy-menu { left: 0; right: auto; width: 310px; padding: 6px; }
.strategy-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; padding: 9px 12px; border-radius: var(--radius); text-align: left; }
.strategy-opt:hover { background: var(--bg-hover); }
.strategy-opt[aria-checked="true"] { background: var(--blue-soft); }
.strategy-opt[aria-checked="true"] .strat-title { color: var(--blue); font-weight: 700; }
.strat-title { font-size: 13px; font-weight: 600; color: var(--text); }
.strat-desc { font-size: 11px; color: var(--text-muted); line-height: 1.35; }

.layout-menu { left: auto; right: 0; width: 210px; padding: 6px; }
.layout-opt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border-radius: var(--radius); font-weight: 500; text-align: left; }
.layout-opt:hover { background: var(--bg-hover); }
.layout-opt[aria-checked="true"] { background: var(--blue-soft); color: var(--blue); }
.active-label { margin: -4px 0 8px; font-size: 12px; color: var(--text-muted); }
.active-label:empty { display: none; }
.mobile-nav { display: none; }
.nav-dot { position: absolute; top: 6px; right: calc(50% - 20px); width: 9px; height: 9px; border-radius: 50%; background: var(--red); border: 2px solid var(--bg); }

.legend { position: absolute; top: 6px; left: 10px; right: 80px; z-index: 5; pointer-events: none; font-size: 13px; line-height: 1.7; }
.legend-title { font-weight: 600; margin-right: 10px; }
.legend-item { margin-right: 8px; white-space: nowrap; }
.legend-item b { font-weight: 400; margin-right: 2px; }
.legend-study { color: var(--text); }

.sim-banner {
    position: absolute; bottom: 36px; left: 50%; transform: translateX(-50%); z-index: 6;
    background: var(--orange-soft); color: #e65100; border: 1px solid #ffcc80;
    padding: 5px 14px; border-radius: 16px; font-size: 12px; font-weight: 600; white-space: nowrap;
}


/* ---------- sidebar ---------- */
.sidebar { grid-area: side; border-left: 1px solid var(--border); overflow-y: auto; min-height: 0; background: var(--bg); }
.panel { padding: 12px 16px 16px; border-bottom: 1px solid var(--border); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.panel-head h2 { font-size: 13px; font-weight: 600; }
.chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--bg-hover); color: var(--text-muted); }
.chip-long { background: var(--green-soft); color: var(--green); }
.chip-short { background: var(--red-soft); color: var(--red); }

.setup-state { border-radius: var(--radius-lg); padding: 12px; margin-bottom: 10px; border: 1px solid var(--border); }
.setup-state.is-long { background: var(--green-soft); border-color: #b2dfdb; }
.setup-state.is-short { background: var(--red-soft); border-color: #f8bbd0; }
.setup-state.is-pending { background: var(--blue-soft); border-color: #bbdefb; }
.setup-title { font-size: 16px; font-weight: 700; }
.setup-title.is-long { color: var(--green); }
.setup-title.is-short { color: var(--red); }
.setup-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.kv { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0; font-size: 13px; }
.kv strong { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.kv + .kv { border-top: 1px dashed var(--border); }
.kv span:first-child { color: var(--text-muted); }
.kv strong { font-family: var(--font-mono); font-weight: 600; }
.big-pnl { font-size: 18px; }
.hint { color: var(--text-muted); font-size: 12px; }


.alert-log { list-style: none; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.alert-log li { padding: 8px 10px; border-radius: var(--radius); background: var(--bg-subtle); border-left: 3px solid var(--border-strong); font-size: 12px; }
.alert-log li.is-long { border-left-color: var(--green); }
.alert-log li.is-short { border-left-color: var(--red); }
.alert-log li.is-warn { border-left-color: var(--orange); }
.alert-log time { color: var(--text-muted); font-size: 11px; display: block; }

/* ---------- strategy tester ---------- */
.bottom { grid-area: bottom; display: flex; flex-direction: column; min-height: 0; border-top: 1px solid var(--border); }
.bottom-head { display: flex; align-items: center; gap: 24px; padding: 4px 8px 4px 16px; border-bottom: 1px solid var(--border); }
.bottom-head h2 { font-size: 13px; font-weight: 600; white-space: nowrap; }
.bottom-head .toolbar-spacer { display: none; }
.summary { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px 22px; font-size: 12px; }
.summary span b { font-weight: 400; color: var(--text-muted); margin-right: 6px; }
.summary span strong { font-family: var(--font-mono); font-weight: 600; }
.table-wrap { flex: 1; min-height: 0; overflow: auto; }
.trade-table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.trade-table th { position: sticky; top: 0; background: var(--bg); color: var(--text-muted); font-weight: 500; text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--border); z-index: 1; }
.trade-table td { padding: 6px 12px; border-bottom: 1px solid var(--bg-hover); font-variant-numeric: tabular-nums; }
.trade-table .num { text-align: right; font-family: var(--font-mono); }
.trade-table tbody tr { cursor: pointer; transition: background var(--dur) var(--ease); }
.trade-table tbody tr:hover { background: var(--bg-hover); }
.trade-table tbody tr.is-open { background: var(--blue-soft); }
.result-pill { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.result-TP { background: var(--green-soft); color: var(--green); }
.result-SL { background: var(--red-soft); color: var(--red); }
.result-EARLY_EXIT { background: var(--orange-soft); color: #e65100; }
.result-SESSION_END, .result-OPEN { background: var(--bg-hover); color: var(--text-muted); }
.result-OPEN { background: var(--blue-soft); color: var(--blue); }

/* ---------- bottom tabs & live bot dashboard ---------- */
.bottom-tabs { display: flex; align-items: center; gap: 6px; }
.bottom-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: transparent;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 5px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--dur) var(--ease);
}
.bottom-tab-btn:hover { color: var(--text); background: var(--bg-hover); }
.bottom-tab-btn.is-active {
    color: var(--blue);
    background: var(--blue-soft);
    border-color: rgba(41, 98, 255, 0.2);
    font-weight: 700;
}
.bot-pulse-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(8, 153, 129, 0.7);
    animation: botPulse 2s infinite;
}
@keyframes botPulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(8, 153, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(8, 153, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(8, 153, 129, 0); }
}
.bot-dashboard-view {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-subtle);
}
.bot-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}
.bot-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.bot-card-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.bot-card-val {
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.bot-meter-track {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}
.bot-meter-fill {
    height: 100%;
    background: var(--blue);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.bot-meter-fill.is-full {
    background: var(--orange);
}
.bot-spotlight {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.bot-spotlight.is-long {
    border-left: 4px solid var(--green);
    background: linear-gradient(90deg, rgba(8, 153, 129, 0.03) 0%, var(--bg) 40%);
}
.bot-spotlight.is-short {
    border-left: 4px solid var(--red);
    background: linear-gradient(90deg, rgba(242, 54, 69, 0.03) 0%, var(--bg) 40%);
}
.bot-spot-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.bot-spot-title {
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.bot-spot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}
.bot-spot-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}
.bot-stream-wrap {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.bot-stream-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-subtle);
}
.secondary-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    transition: all var(--dur) var(--ease);
}
.secondary-btn:hover {
    background: var(--bg-hover);
    border-color: var(--text);
}
.strat-select-bar {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
}
.strat-tab-pill {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--dur) var(--ease);
}
.strat-tab-pill:hover { color: var(--text); }
.strat-tab-pill.is-active {
    background: var(--blue);
    color: #ffffff;
    border-color: var(--blue);
}

/* ---------- alert pop-ups (TradingView style) ---------- */
.alert-stack { position: fixed; top: 56px; right: 16px; z-index: 60; display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 32px)); }
.alert-card { background: var(--bg); border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--border); padding: 14px 16px; border-top: 4px solid var(--blue); animation: slide-in 220ms var(--ease); }
.alert-card.is-long { border-top-color: var(--green); }
.alert-card.is-short { border-top-color: var(--red); }
.alert-card.is-warn { border-top-color: var(--orange); }
.alert-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.alert-card .alert-meta { color: var(--text-muted); font-size: 11px; margin-bottom: 6px; }
.alert-card p { font-size: 13px; margin-bottom: 10px; }
.alert-actions { display: flex; gap: 8px; justify-content: flex-end; }
.alert-actions button { height: 30px; padding: 0 12px; }
@keyframes slide-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- settings dialog ---------- */
.settings { margin: auto; border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow); width: min(440px, calc(100vw - 32px)); color: var(--text); }
.settings::backdrop { background: rgba(19, 23, 34, 0.35); }
.settings-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.settings-head h2 { font-size: 16px; font-weight: 600; }
.settings-tabs { display: flex; gap: 16px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.settings-tab { padding: 8px 0; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; }
.settings-tab.is-active { color: var(--text); border-bottom-color: var(--text); }
.settings-body { padding: 12px 16px; max-height: 60vh; overflow-y: auto; }
.settings-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin: 12px 0 6px; }
.settings-group:first-child { margin-top: 0; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 0; }
.setting-row input[type="number"], .setting-row input[type="time"] { width: 110px; height: 32px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--radius); }
.setting-row select { width: 130px; height: 32px; padding: 0 6px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); }
.setting-row input[type="color"] { width: 44px; height: 28px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--bg); cursor: pointer; }
.setting-row input:focus, .setting-row select:focus { border-color: var(--blue); outline: none; }
.setting-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--blue); }
.settings-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.settings-msg { padding: 8px 16px 0; font-size: 12px; color: var(--text-muted); }
.settings-msg:empty { display: none; }
.settings-msg.is-error { color: var(--red); }

/* ---------- responsive ---------- */
/* laptops: icons only in the toolbar */
@media (max-width: 1280px) {
    #market-badge, .tb-theme .btn-text, .tb-settings .btn-text, .tb-alerts .btn-text, .tb-replay .btn-text, .tb-draw .btn-text, .tb-layout .btn-text { display: none; }
    .toolbar .tool-btn { padding: 0 6px; }
}
@media (max-width: 860px) {
    .tb-strategy { max-width: 58vw; }
    .tb-strategy .btn-text { display: inline-block !important; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11.5px; }
    .tb-split .btn-text { display: inline-block !important; font-size: 11px; }
    .candle-timer-chip { padding: 2px 7px; font-size: 11px; }
    .candle-timer-chip strong { font-size: 11.5px; }
    .workspace {
        display: flex !important;
        flex-direction: column !important;
        position: relative !important;
        flex: 1 1 auto !important;
        height: calc(100dvh - 42px) !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }
    .main-tab-view {
        position: absolute !important;
        inset: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
    }
    #view-chart.is-active {
        display: flex !important;
        flex-direction: column !important;
    }
    #view-chart[hidden],
    #view-chart:not(.is-active),
    #view-chart[style*="display: none"] {
        display: none !important;
    }
    #view-dashboard[hidden],
    #view-dashboard:not(.is-active),
    #view-dashboard[style*="display: none"] {
        display: none !important;
    }
    #view-dashboard.is-active {
        display: block !important;
        z-index: 60 !important;
        background: var(--s2-bg, #f7f9fd) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* very large screens (4K, ultrawide): bigger chart text and side panels */
@media (min-width: 1900px) {
    :root { --toolbar-h: 52px; }
    .legend { font-size: 14px; }
    .draw-bar { width: 52px; }
    .draw-btn { width: 40px; height: 40px; }
}

/* ===== phone / small tablet: strict single-line priority toolbar ===== */
@media (max-width: 860px) {
    .toolbar {
        height: 40px !important;
        min-height: 40px !important;
        max-height: 40px !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        row-gap: 0 !important;
        gap: 5px !important;
        padding: 0 6px !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .divider, #market-badge, .desktop-only, .btn-text, .tb-settings svg:last-child, .toolbar > .toolbar-spacer { display: none; }
    .tb-symbol { flex: 1 1 0; min-width: 0; }
    .symbol-btn { max-width: 100%; }
    .tb-intervals { order: unset; flex: 0 0 auto; overflow-x: auto; scrollbar-width: none; }
    .tb-intervals::-webkit-scrollbar { display: none; }
    .interval-group button { flex: 0 0 auto; min-width: 38px; height: 30px; font-size: 11px; }
    .toolbar .tool-btn { width: 30px; height: 30px; padding: 0; justify-content: center; }
    #connect-btn { order: unset; flex: 0 0 auto; height: 30px; }
    #data-badge { font-size: 0; padding: 0 9px; }
    #data-badge::before { width: 10px; height: 10px; }

    .workspace { display: block; position: relative; flex: 1; min-height: 0; }
    .chart-area, .sidebar, .bottom { position: absolute; inset: 0; display: none; }
    .chart-body { flex-direction: column; }
    .workspace[data-view="chart"] .chart-area { display: flex; flex-direction: column; }
    .workspace[data-view="signals"] .sidebar { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; border-left: 0; }
    .workspace[data-view="trades"] .bottom { display: flex; border-top: 0; }
    .workspace.no-side .sidebar, .workspace.no-bottom .bottom { display: none; }
    .workspace[data-view="signals"].no-side .sidebar { display: block; }
    .workspace[data-view="trades"].no-bottom .bottom { display: flex; }
    .sidebar .panel { padding-left: calc(16px + var(--safe-left)); padding-right: calc(16px + var(--safe-right)); }

    /* drawing tools become a scrolling strip above the charts */
    .draw-bar { flex-direction: row; width: 100%; height: 46px; padding: 4px 8px; overflow-x: auto; overflow-y: hidden; border-right: 0; border-bottom: 1px solid var(--border); }
    .draw-sep { width: 1px; height: 24px; margin: 0 4px; }
    .draw-width { margin-top: 0; }
    .draw-hint { bottom: 16px; }
    .panes { flex: 1; }

    .mobile-nav {
        display: flex; flex: 0 0 auto; background: var(--bg); border-top: 1px solid var(--border);
        padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
    }
    .mobile-nav button {
        position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
        height: 54px; font-size: 11px; font-weight: 600; color: var(--text-muted);
    }
    .mobile-nav button[aria-pressed="true"] { color: var(--blue); }

    .bottom-head { flex-wrap: wrap; gap: 4px 16px; padding: 8px 16px; }
    .summary { flex: 1 1 100%; gap: 4px 16px; }
    .alert-stack { top: calc(var(--safe-top) + 56px); left: 8px; right: 8px; width: auto; }
    .symbol-menu { position: fixed; top: calc(var(--safe-top) + 8px); left: 8px; right: 8px; width: auto; }
    .symbol-list { max-height: calc(100dvh - 190px); }
    .layout-menu { position: fixed; top: calc(var(--safe-top) + 56px); right: 8px; left: auto; }
    .settings { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
    .settings-body { max-height: calc(100dvh - 190px); }
    .sel-bar { top: 6px; }
}

/* small phones: fewer columns, one or two stacked charts */
@media (max-width: 640px) {
    .hide-sm, .wide-only { display: none; }
    .trade-table { font-size: 12px; }
    .trade-table th, .trade-table td { padding: 9px 7px; }
    .pane-note { display: none; }
    .legend { font-size: 12px; right: 8px; }
    .legend-item { margin-right: 6px; }
}

/* landscape phones: keep the chart tall */
@media (max-height: 500px) and (max-width: 960px) {
    .tb-intervals { order: 0; flex: 1 1 0; }
    .toolbar { row-gap: 0; padding-top: calc(3px + var(--safe-top)); padding-bottom: 3px; }
    .mobile-nav button { height: 44px; flex-direction: row; gap: 8px; }
    .draw-bar { height: 40px; }
}

/* touch screens: bigger tap targets */
@media (pointer: coarse) {
    .interval-group button, .tool-btn, .symbol-btn, .layout-opt, .symbol-item { min-height: 40px; }
    .draw-btn { width: 40px; height: 40px; }
    .icon-btn { width: 40px; height: 40px; }
    .sel-btn, .sel-bar select, .sel-bar input[type="color"] { height: 38px; min-width: 38px; }
    .pane-interval, .pane-opt { height: 30px; }
    .alert-actions button { height: 38px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}


/* ---------- TradingView Strategy Tester Resizer, Controls, Overview & Matrix ---------- */
.bottom-resizer {
    height: 8px;
    background: transparent;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 20;
    margin-top: -4px;
    margin-bottom: -4px;
    user-select: none;
    transition: background var(--dur) var(--ease);
}
.bottom-resizer:hover, .bottom-resizer.is-dragging {
    background: var(--blue-soft);
}
.resizer-grip {
    width: 40px;
    height: 3px;
    border-radius: 2px;
    background: var(--border-strong);
    transition: background var(--dur) var(--ease), width var(--dur) var(--ease);
}
.bottom-resizer:hover .resizer-grip, .bottom-resizer.is-dragging .resizer-grip {
    background: var(--blue);
    width: 60px;
}

/* Maximized / Full-Scale Strategy Tester Drawer */
.workspace.bottom-maximized .bottom {
    position: fixed;
    top: var(--toolbar-h);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    background: var(--bg);
    box-shadow: 0 -8px 32px rgba(19, 23, 34, 0.2);
    border-top: 1px solid var(--border);
}

/* Bottom Controls */
.bottom-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}
.tv-ctrl-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--dur) var(--ease);
}
.tv-ctrl-btn:hover {
    color: var(--text);
    background: var(--bg-hover);
    border-color: var(--border-strong);
}
.tv-ctrl-btn.is-active {
    color: var(--blue);
    background: var(--blue-soft);
    border-color: rgba(41, 98, 255, 0.35);
}
.tv-ctrl-btn.icon-only {
    padding: 3px 7px;
    font-size: 13px;
}

/* Candle Bar Countdown Timer */
.candle-timer-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px 9px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1;
    color: var(--text);
    user-select: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.candle-pulse-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(8, 153, 129, 0.7);
    animation: candlePulse 1.5s infinite;
}
@keyframes candlePulse {
    0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(8, 153, 129, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 5px rgba(8, 153, 129, 0); }
    100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(8, 153, 129, 0); }
}
.timer-tf {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
}
.timer-divider {
    color: var(--border-strong);
}
.timer-countdown {
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text);
}

/* Overview Cards Grid */
.tv-view-pane {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.tv-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    padding: 14px 16px;
    background: var(--bg-subtle);
}
.tv-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tv-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}
.tv-card-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.tv-card-value {
    font-size: 17px;
    font-weight: 700;
    font-family: var(--font-mono);
}
.tv-card-sub {
    font-size: 11px;
    color: var(--text-muted);
}

/* Performance Summary Table */
.tv-perf-wrap {
    padding: 14px 16px;
    background: var(--bg-subtle);
}
.tv-perf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.tv-perf-table th {
    position: sticky;
    top: 0;
    background: var(--bg-hover);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    padding: 9px 14px;
    border-bottom: 2px solid var(--border);
    z-index: 1;
}
.tv-perf-table td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--bg-hover);
    font-variant-numeric: tabular-nums;
}
.tv-perf-table td.metric-name {
    font-weight: 600;
    color: var(--text);
}
.tv-perf-table tr:hover {
    background: var(--bg-subtle);
}
.tv-perf-table td.num {
    text-align: right;
    font-family: var(--font-mono);
}

/* Setup Analysis */
.tv-analysis-wrap {
    padding: 14px 16px;
    background: var(--bg-subtle);
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.tv-analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 12px;
}
.tv-analysis-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
.tv-analysis-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
}

/* Mode Selector Button & Dot */
.mode-toggle-btn {
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.mode-toggle-btn.is-manual {
    background: rgba(2, 132, 199, 0.08);
    border: 1px solid rgba(2, 132, 199, 0.35);
    color: #0284c7;
}
.mode-toggle-btn.is-manual:hover {
    background: rgba(2, 132, 199, 0.15);
}
.mode-toggle-btn.is-auto {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid #10b981;
    color: #047857;
}
.mode-toggle-btn.is-auto:hover {
    background: rgba(16, 185, 129, 0.20);
}
.mode-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}
.mode-dot.is-manual {
    background: #0284c7;
}
.mode-dot.is-auto {
    background: #10b981;
    box-shadow: 0 0 6px #10b981;
}

/* ---------- TradingView Bottom Dock Bar ---------- */
.bottom-dock-bar {
    height: 32px;
    flex-shrink: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    z-index: 25;
}
.dock-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--dur) var(--ease);
}
.dock-tab-btn:hover {
    color: var(--text);
    background: var(--bg-hover);
}
.dock-tab-btn.is-active {
    color: #0284c7;
    background: rgba(14, 165, 233, 0.12);
    border-color: rgba(14, 165, 233, 0.3);
    font-weight: 700;
}
.dock-pill {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 1px 6px;
    border-radius: 8px;
}
.dock-spacer { flex: 1; }
.dock-status {
    font-size: 11px;
    font-weight: 600;
    color: var(--green);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
@media (max-width: 860px) {
    .bottom-dock-bar { display: none; }
}

/* Toolbar overflow & responsiveness on standard laptop screens */
@media (max-width: 1440px) {
    #market-badge { display: none; }
    .toolbar-spacer { flex: 0 1 8px; }
}
@media (max-width: 1280px) {
    .tb-theme .btn-text, .tb-settings .btn-text, .tb-alerts .btn-text, .tb-replay .btn-text, .tb-draw .btn-text, .tb-layout .btn-text { display: none; }
    .toolbar .tool-btn { padding: 0 6px; }
}

/* ---------- TradingView Dark Mode (OLED / Fintech) ---------- */
:root[data-theme="dark"], body.dark-theme {
    --bg: #131722;
    --bg-subtle: #0c0e14;
    --bg-hover: #1e222d;
    --border: #2a2e39;
    --border-strong: #363c4e;
    --text: #d1d4dc;
    --text-muted: #787b86;
    --blue: #2962ff;
    --blue-hover: #1e53e5;
    --blue-soft: rgba(41, 98, 255, 0.18);
    --green: #089981;
    --green-soft: rgba(8, 153, 129, 0.18);
    --red: #f23645;
    --red-soft: rgba(242, 54, 69, 0.18);
    --orange: #f59e0b;
    --orange-soft: rgba(245, 158, 11, 0.18);
    --shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}
:root[data-theme="dark"] .trade-table th {
    background: #131722;
    color: #787b86;
    border-bottom: 1px solid #2a2e39;
}
:root[data-theme="dark"] .trade-table td {
    border-bottom: 1px solid #1e222d;
}
:root[data-theme="dark"] .popover {
    background: #1e222d;
    border: 1px solid #363c4e;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
:root[data-theme="dark"] .symbol-item:hover,
:root[data-theme="dark"] .strategy-opt:hover,
:root[data-theme="dark"] .layout-opt:hover {
    background: #2a2e39;
}
:root[data-theme="dark"] .settings {
    background: #1e222d;
    color: #d1d4dc;
    border-color: #363c4e;
}
:root[data-theme="dark"] .setting-row input,
:root[data-theme="dark"] .setting-row select {
    background: #131722;
    color: #d1d4dc;
    border-color: #363c4e;
}
:root[data-theme="dark"] .ts-subtabs button {
    background: #1e222d;
    color: #d1d4dc;
}
:root[data-theme="dark"] .ts-subtabs button:hover {
    background: #2a2e39;
}
:root[data-theme="dark"] .ts-subtabs button.is-active {
    background: #2962ff;
    color: #ffffff;
}
:root[data-theme="dark"] .bottom-dock-bar {
    background: #131722;
    border-top: 1px solid #2a2e39;
}

.tb-split {
    font-weight: 600;
    color: var(--blue);
    background: rgba(41, 98, 255, 0.08);
    border: 1px solid rgba(41, 98, 255, 0.2);
}
.tb-split:hover {
    background: rgba(41, 98, 255, 0.16);
}
.tb-split.is-active, .tb-split[aria-pressed="true"] {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}

/* Top Bar - Strategy Tester & Option Details tab buttons */
.tb-tester-btn, .tb-option-details-btn {
    font-weight: 600;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 11px;
    height: 32px;
    border-radius: var(--radius);
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--dur) var(--ease);
}
.tb-tester-btn:hover, .tb-option-details-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.tb-tester-btn[aria-pressed="true"], .tb-tester-btn.is-active,
.tb-option-details-btn[aria-pressed="true"], .tb-option-details-btn.is-active {
    background: var(--blue-soft, rgba(41, 98, 255, 0.12)) !important;
    color: var(--blue, #2962ff) !important;
    border-color: rgba(41, 98, 255, 0.28) !important;
    font-weight: 600;
}
.tb-tester-btn .btn-text, .tb-option-details-btn .btn-text {
    display: inline !important;
}

/* Settings modal tab pills styling */
.strat-select-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}
.strat-tab-pill {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-subtle, #f0f3fa);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.strat-tab-pill:hover {
    background: var(--bg-hover);
    color: var(--text);
}
.strat-tab-pill.is-active {
    background: var(--blue, #2962ff);
    color: #ffffff;
    border-color: var(--blue, #2962ff);
    box-shadow: 0 2px 6px rgba(41, 98, 255, 0.25);
}
:root[data-theme="dark"] .strat-tab-pill {
    background: #1e222d;
    border-color: #2a2e39;
    color: #94a3b8;
}
:root[data-theme="dark"] .strat-tab-pill:hover {
    background: #2a2e39;
    color: #e2e8f0;
}
:root[data-theme="dark"] .strat-tab-pill.is-active {
    background: #2962ff;
    border-color: #2962ff;
    color: #ffffff;
}


/* ==========================================================================
   2026 UI/UX PRO-MAX: SINGLE-LINE PRIORITY TOOLBAR & RECTANGULAR STATUS
   ========================================================================== */
.toolbar {
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    flex-wrap: nowrap !important;
    overflow: hidden !important;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
    white-space: nowrap !important;
    scrollbar-width: none !important;
    align-items: center !important;
    gap: 5px !important;
    padding: 0 8px !important;
    background: #ffffff !important;
    width: 100% !important;
    box-sizing: border-box !important;
}
.toolbar::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }

/* Bell icon removal */
#alerts-btn, .tb-alerts, #alert-stack {
    display: none !important;
}

/* Strategy button always prominent, compact and visible without scrolling */
.tb-strategy {
    flex: 0 0 auto !important;
    max-width: 155px !important;
    display: inline-flex !important;
}
#strategy-btn {
    height: 28px !important;
    padding: 0 7px !important;
    font-size: 11.5px !important;
    font-weight: 700 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    border: 1.5px solid #2563eb !important;
    border-radius: 6px !important;
    background: #ffffff !important;
    color: #0f172a !important;
    box-shadow: 0 1px 3px rgba(37,99,235,0.12) !important;
    max-width: 155px !important;
}
#strategy-btn svg {
    flex-shrink: 0 !important;
}
#strategy-btn .btn-text, #strategy-label {
    display: inline-block !important;
    visibility: visible !important;
    max-width: 110px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    color: #0f172a !important;
    font-weight: 700 !important;
    font-size: 11.5px !important;
}

/* SINGLE-LINE STATUS RECTANGLE (NO OVAL, NO DOUBLE LINE) */
.tb-live-trade {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    height: 30px !important;
    padding: 0 10px 0 6px !important;
    border: 1px solid #dce5ef !important;
    border-radius: 6px !important;
    background: #f8fafc !important;
    color: #0f172a !important;
    white-space: nowrap !important;
    flex: 0 1 auto !important;
    max-width: 440px !important;
}
.tb-live-trade .ls-main, .tb-live-trade .ls-pnl {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 5px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}
.tb-live-trade .ls-main b, .tb-live-trade .ls-pnl b {
    font-size: 12px !important;
    font-weight: 750 !important;
    white-space: nowrap !important;
}
.tb-live-trade small {
    font-size: 10.5px !important;
    color: #64748b !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    display: inline !important;
}

/* View tabs */
.view-tabs {
    flex: 0 0 auto !important;
    margin-left: auto !important;
    display: inline-flex !important;
    gap: 3px !important;
}
.view-tabs button {
    height: 28px !important;
    padding: 0 10px !important;
    font-size: 11px !important;
    font-weight: 750 !important;
    border-radius: 5px !important;
}

/* Mobile viewport adjustments */
@media (max-width: 768px) {
    .toolbar {
        height: 40px !important;
        padding: 0 6px !important;
        gap: 5px !important;
    }
    #strategy-btn {
        height: 30px !important;
        padding: 0 6px !important;
        max-width: 140px !important;
        font-size: 11px !important;
    }
    #strategy-btn .btn-text, #strategy-label {
        max-width: 105px !important;
        font-size: 11px !important;
    }
    .tb-live-trade {
        max-width: 130px !important;
        height: 26px !important;
        font-size: 10px !important;
    }
    .view-tabs button {
        height: 26px !important;
        padding: 0 6px !important;
        font-size: 10px !important;
    }
    .mobile-nav { display: none !important; }
}

/* ---------- MARKET STATUS & HOLIDAY BADGE (NO DUPLICATES) ---------- */
#data-badge {
    display: none !important;
}
#stream-badge[data-state="live"], #stream-badge:not([data-state="reconnecting"]) {
    display: none !important;
}
#market-badge {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    height: 28px !important;
    padding: 0 10px !important;
    border-radius: 6px !important;
    font-size: 11px !important;
    font-weight: 750 !important;
    white-space: nowrap !important;
    flex: 0 0 auto !important;
}
#market-badge.badge-holiday {
    background: #fef3c7 !important;
    color: #92400e !important;
    border: 1.5px solid #f59e0b !important;
    box-shadow: 0 1px 3px rgba(245, 158, 11, 0.18) !important;
}
#market-badge.badge-closed {
    background: #f1f5f9 !important;
    color: #475569 !important;
    border: 1px solid #cbd5e1 !important;
}
#market-badge.badge-open, #market-badge.badge-live {
    background: #ecfdf5 !important;
    color: #065f46 !important;
    border: 1px solid #10b981 !important;
}

/* ---------- CLEAR SPOT & OPTION CHART SPLIT LABELS ---------- */
.pane-split-tag {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.04em;
    white-space: nowrap;
    text-transform: uppercase;
    user-select: none;
}
.spot-tag {
    background: #eff6ff !important;
    color: #1d4ed8 !important;
    border: 1px solid #bfdbfe !important;
}
.opt-tag {
    background: #faf5ff !important;
    color: #7e22ce !important;
    border: 1px solid #e9d5ff !important;
}

/* ---------- STRATEGY SELECTOR POPOVER & PROMINENCE ---------- */
#strategy-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    cursor: pointer !important;
}
#strategy-btn .btn-text, #strategy-label {
    display: inline-block !important;
    font-weight: 750 !important;
    color: #0f172a !important;
}
@media (min-width: 861px) {
    #strategy-btn .btn-text, #strategy-label {
        max-width: 110px !important;
    }
}
.strategy-menu {
    position: fixed !important;
    z-index: 99999 !important;
    width: 310px !important;
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important;
    padding: 6px !important;
}

