:root {
  --bg: #131722;
  --panel: #1E222D;
  --panel2: #2A2E39;
  --border: #2A2E39;
  --text: #D1D4DC;
  --muted: #787B86;
  --accent: #3B82F6;
  --accent-h: #2563EB;
  --up: #089981;
  --down: #F23645;
  --hover: #2A2E39;
  --font: -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); overflow: hidden; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
[hidden] { display: none !important; }
a { color: var(--accent); }

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- top bar ---------- */
#topbar { height: 46px; flex: none; display: flex; align-items: center; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; margin-right: 6px; }
.brand img { display: block; border-radius: 7px; }
.sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; flex: none; }
.spacer { flex: 1; }
.tb-btn { height: 34px; padding: 0 9px; border-radius: 4px; display: inline-flex; align-items: center; gap: 4px; color: var(--text); white-space: nowrap; }
.tb-btn:hover { background: var(--hover); }
.tb-btn.icon { width: 34px; padding: 0; justify-content: center; }
.tb-btn.active { color: var(--accent); }
.tb-btn:disabled { opacity: .35; cursor: default; background: none; }
.symbol-btn { font-weight: 700; font-size: 14px; padding: 0 10px 0 6px; }
.symbol-btn .ic svg { width: 20px; height: 20px; }
.ic { display: inline-flex; }
.ic svg { width: 28px; height: 28px; }
.fx { font-style: italic; font-weight: 700; font-size: 15px; margin-right: 2px; font-family: Georgia, serif; }
.tf-group { display: flex; gap: 1px; }
.tf-btn { height: 34px; min-width: 32px; padding: 0 7px; border-radius: 4px; color: var(--text); display: inline-flex; align-items: center; gap: 3px; font-weight: 500; }
.tf-btn:hover { background: var(--hover); }
.tf-btn.active { color: var(--accent); background: rgba(59,130,246,.12); }
.tf-btn .lock { color: var(--muted); display: inline-flex; }
.btn-primary { white-space: nowrap; height: 32px; padding: 0 14px; border-radius: 6px; background: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-ghost { height: 32px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--hover); }
#userArea { margin-left: 6px; position: relative; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* dropdown menus */
.dd { position: relative; }
.menu { position: absolute; top: 40px; left: 0; z-index: 50; min-width: 200px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 6px 0; box-shadow: 0 8px 24px rgba(0,0,0,.45); display: none; }
.menu.open { display: block; }
.menu.right { left: auto; right: 0; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 14px; text-align: left; color: var(--text); white-space: nowrap; }
.menu-item:hover { background: var(--hover); }
.menu-item.active { color: var(--accent); }
.menu-item .ic svg { width: 24px; height: 24px; }
.menu-sep { height: 1px; margin: 6px 0; background: var(--border); }
.menu-item:disabled { opacity: .4; cursor: default; background: none; }
#tfPhoneDD { display: none; }
.menu-note { padding: 6px 14px 8px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

/* ---------- main layout ---------- */
#main { flex: 1; display: flex; min-height: 0; }
#center { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#chartWrap { flex: 1; position: relative; min-height: 0; }
#chart { position: absolute; inset: 0; }
#drawCanvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
#chartWrap.tool-active #chart canvas { cursor: crosshair !important; }
#chartWrap.over-drawing:not(.tool-active) #chart canvas { cursor: pointer !important; }
#chartWrap.arrow-cursor #chart canvas { cursor: default; }
#chartWrap.dot-cursor #chart canvas { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Ccircle cx='6' cy='6' r='3' fill='%23787B86' stroke='white' stroke-width='1'/%3E%3C/svg%3E") 6 6, crosshair; }
#chartWrap.eraser-cursor #chart canvas { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20'%3E%3Cpath d='M3 13l8-8 6 6-6 6H6z' fill='white' stroke='%23131722' stroke-width='1.3'/%3E%3C/svg%3E") 4 16, pointer !important; }

/* ---------- drawing toolbar ---------- */
#drawbar { width: 52px; flex: none; border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 6px 0; gap: 2px; z-index: 20; }
.dt-group { position: relative; }
.dt-btn { width: 40px; height: 36px; border-radius: 4px; display: flex; align-items: center; justify-content: center; color: var(--text); position: relative; }
.dt-btn:hover { background: var(--hover); }
.dt-btn.active { color: var(--accent); background: rgba(59,130,246,.12); }
.dt-btn .corner { position: absolute; right: 3px; bottom: 3px; color: var(--muted); display: flex; }
.dt-sep { width: 32px; height: 1px; background: var(--border); margin: 5px 0; }
.flyout { position: absolute; left: 44px; top: -6px; z-index: 60; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 6px 0; min-width: 250px; box-shadow: 0 8px 24px rgba(0,0,0,.45); display: none; }
.dt-group:hover .flyout, .flyout.open { display: block; }
.flyout::before { content: ""; position: absolute; left: -10px; top: 0; bottom: 0; width: 10px; }
.flyout-title { padding: 4px 14px 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.flyout .menu-item .key { margin-left: auto; color: var(--muted); font-size: 11px; padding-left: 16px; }

/* ---------- legend ---------- */
#legend { position: absolute; left: 10px; top: 6px; z-index: 5; pointer-events: none; max-width: calc(100% - 120px); }
.lg-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 13px; }
.lg-title { font-weight: 600; color: var(--text); font-size: 14px; }
.lg-ohlc span { margin-right: 6px; color: var(--muted); }
.lg-ohlc b { font-weight: 500; }
.lg-row { display: flex; align-items: center; gap: 6px; height: 22px; font-size: 12px; pointer-events: auto; width: max-content; padding-right: 4px; border-radius: 3px; }
.lg-row .nm { color: var(--text); }
.lg-row .vals b { font-weight: 500; margin-right: 6px; }
.lg-row .btns { display: none; gap: 0; }
.lg-row:hover { background: rgba(30,34,45,.85); }
.lg-row:hover .btns { display: inline-flex; }
.lg-row .btns button { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; color: var(--muted); border-radius: 3px; }
.lg-row .btns button:hover { color: var(--text); background: var(--hover); }
.lg-row .btns svg { width: 18px; height: 18px; }
.lg-row.off .nm, .lg-row.off .vals { opacity: .45; }
#paneLegends { position: absolute; left: 10px; top: 0; z-index: 5; pointer-events: none; }
#paneLegends .lg-row { position: absolute; left: 0; }

/* replay cursor */
#replayCursor { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
#replayCursor .line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); }
#replayCursor .shade { position: absolute; top: 0; bottom: 0; right: 0; background: rgba(19,23,34,.55); }
#replayCursor .tip { position: absolute; top: 40px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; padding: 6px 12px; border-radius: 6px; font-weight: 600; }

/* selected drawing properties */
#drawProps { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 8; display: flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
#drawProps .sw { width: 20px; height: 20px; border-radius: 4px; border: 2px solid transparent; }
#drawProps .sw.on { border-color: #fff; }
#drawProps select { background: var(--panel2); border: 1px solid var(--border); border-radius: 4px; height: 26px; }
#drawProps button.ib { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 4px; color: var(--text); }
#drawProps button.ib:hover { background: var(--hover); }
#drawProps button.ib svg { width: 22px; height: 22px; }
#drawProps .nm { color: var(--muted); padding: 0 6px; font-size: 12px; }

#loading { position: absolute; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center; background: rgba(19,23,34,.35); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--panel2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- replay bar ---------- */
#replayBar { height: 46px; flex: none; display: flex; align-items: center; gap: 4px; padding: 0 8px; border-top: 1px solid var(--border); background: var(--panel); }
.rb-btn { height: 32px; padding: 0 10px; border-radius: 4px; display: inline-flex; align-items: center; gap: 4px; color: var(--text); white-space: nowrap; }
.rb-btn:hover { background: var(--hover); }
.rb-btn.icon { width: 34px; padding: 0; justify-content: center; }
.rb-btn .ic svg { width: 24px; height: 24px; }
#rbSpeed { height: 30px; background: var(--panel2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.rb-date { color: var(--muted); padding: 0 8px; white-space: nowrap; }
.rb-trade { height: 30px; padding: 0 16px; border-radius: 4px; font-weight: 700; color: #fff; }
.rb-trade.buy { background: var(--up); }
.rb-trade.sell { background: var(--down); }
.rb-trade:hover { filter: brightness(1.12); }
#rbStats { color: var(--muted); padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#rbStats b { color: var(--text); font-weight: 600; }
.pos { color: var(--up) !important; }
.neg { color: var(--down) !important; }

/* ---------- bottom bar ---------- */
#bottombar { height: 34px; flex: none; display: flex; align-items: center; gap: 2px; padding: 0 8px; border-top: 1px solid var(--border); }
.bb-btn { height: 26px; padding: 0 8px; border-radius: 4px; color: var(--text); font-size: 12px; }
.bb-btn:hover { background: var(--hover); }
.bb-btn.active { color: var(--accent); }
#clock { color: var(--text); font-size: 12px; padding: 0 6px; font-variant-numeric: tabular-nums; }

/* ---------- watchlist ---------- */
.sb-head { height: 46px; display: flex; align-items: center; padding: 0 14px; font-weight: 600; font-size: 14px; border-bottom: 1px solid var(--border); flex: none; }
.wl-cols, .wl-row { display: grid; grid-template-columns: 1fr 90px 66px; align-items: center; padding: 0 12px; }
.wl-cols { height: 28px; color: var(--muted); font-size: 11px; flex: none; }
.wl-cols span:not(:first-child), .wl-row span:not(:first-child) { text-align: right; }
#watchlist { overflow-y: auto; flex: 1; }
.wl-sec { padding: 10px 12px 4px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.wl-row { height: 32px; cursor: pointer; font-variant-numeric: tabular-nums; }
.wl-row:hover { background: var(--hover); }
.wl-row.active { background: rgba(59,130,246,.15); }
.wl-row .sym { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rightstrip { width: 46px; flex: none; border-left: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding-top: 6px; }
.rs-btn { width: 36px; height: 36px; border-radius: 4px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.rs-btn:hover { background: var(--hover); color: var(--text); }
.rs-btn.active { color: var(--accent); }

/* ---------- modals ---------- */
.modal-ov { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.55); display: flex; align-items: flex-start; justify-content: center; padding-top: 9vh; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 16px 48px rgba(0,0,0,.6); max-width: calc(100vw - 24px); max-height: 80vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 600; flex: 1; }
.modal-head .x { width: 30px; height: 30px; border-radius: 4px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.modal-head .x:hover { background: var(--hover); color: var(--text); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { color: var(--muted); font-size: 12px; }
.input { height: 38px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); outline: none; width: 100%; }
.input:focus { border-color: var(--accent); }
.err { color: var(--down); min-height: 18px; margin-bottom: 8px; font-size: 13px; }
.ok { color: var(--up); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.search-top { padding: 12px 18px 0; }
.search-input { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.search-input input { flex: 1; background: none; border: 0; outline: none; font-size: 17px; text-transform: uppercase; }
.search-input input::placeholder { text-transform: none; color: var(--muted); }
.tabs { display: flex; gap: 6px; padding: 10px 0; flex-wrap: wrap; }
.tab { height: 30px; padding: 0 14px; border-radius: 15px; background: var(--panel2); color: var(--text); }
.tab.active { background: var(--text); color: var(--bg); }
.sym-list { overflow-y: auto; border-top: 1px solid var(--border); }
.sym-row { display: grid; grid-template-columns: 28px 110px 1fr auto; align-items: center; gap: 10px; padding: 8px 18px; cursor: pointer; }
.sym-row:hover, .sym-row.kb { background: var(--hover); }
.sym-row .badge { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: #fff; }
.sym-row .s { font-weight: 700; }
.sym-row .n { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sym-row .e { color: var(--muted); font-size: 12px; text-align: right; }
.ind-row { display: flex; align-items: center; padding: 9px 18px; cursor: pointer; }
.ind-row:hover { background: var(--hover); }
.ind-row .t { color: var(--muted); font-size: 12px; margin-left: auto; }
table.trades { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.trades th, table.trades td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.trades th:first-child, table.trades td:first-child { text-align: left; }
table.trades th { color: var(--muted); font-weight: 500; font-size: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px; }
.stat .k { color: var(--muted); font-size: 11px; }
.stat .v { font-size: 16px; font-weight: 600; margin-top: 2px; }

/* toasts */
#toasts { position: fixed; bottom: 54px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--panel2); color: var(--text); padding: 10px 16px; border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.5); border-left: 3px solid var(--accent); max-width: 520px; }
.toast.error { border-left-color: var(--down); }

/* ---------- light mode ---------- */
body.light {
  --bg: #FFFFFF; --panel: #FFFFFF; --panel2: #F0F3FA; --border: #E0E3EB;
  --text: #131722; --muted: #6A6D78; --hover: #F0F3FA;
}
body.light .menu, body.light .flyout, body.light .modal, body.light #drawProps, body.light #favBar { box-shadow: 0 8px 24px rgba(0,0,0,.14); }
body.light .modal-ov { background: rgba(0,0,0,.3); }
body.light #loading { background: rgba(255,255,255,.4); }
body.light .lg-row:hover { background: rgba(240,243,250,.9); }
body.light #replayCursor .shade { background: rgba(255,255,255,.55); }
body.light .toast { background: #FFFFFF; box-shadow: 0 6px 20px rgba(0,0,0,.15); }
body.light .login-page { background: radial-gradient(1200px 600px at 50% -10%, #E3ECFF 0%, var(--bg) 60%); }

/* ---------- new top bar buttons ---------- */
.premium-btn { color: #10B981; font-weight: 700; }
.premium-btn .ic svg { width: 24px; height: 24px; }
.trade-btn { margin-left: 4px; height: 32px; padding: 0 12px 0 8px; border-radius: 16px; background: var(--accent); color: #fff; font-weight: 600; }
.trade-btn:hover, .trade-btn.active { background: var(--accent-h); color: #fff; }
.trade-btn .ic svg { width: 22px; height: 22px; }
.menu-item.premium { color: #10B981; font-weight: 700; }

/* ---------- forms in windows ---------- */
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }
.input.color { padding: 2px 4px; height: 38px; cursor: pointer; }
select.input { padding: 0 8px; }
.candle-grid { display: grid; grid-template-columns: 70px 1fr 1fr; gap: 6px 10px; align-items: center; margin-bottom: 12px; }
.candle-grid .input.color { height: 32px; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.list-title { margin: 16px 0 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.lr-del { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 4px; color: var(--muted); flex: none; }
.lr-del:hover { background: var(--hover); color: var(--down); }
.lr-del svg { width: 22px; height: 22px; }
button.link { color: var(--accent); padding: 0; }

/* layouts */
.layout-save { display: flex; gap: 8px; }
.layout-save .btn-primary { height: 38px; flex: none; }
.layout-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.lr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lr-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* alerts */
.alert-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 1px solid var(--border); }

/* Premium */
.premium { text-align: left; }
.pm-badge { width: 56px; height: 56px; margin: 0 auto 10px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(16,185,129,.14); color: #10B981; }
.pm-badge svg { width: 32px; height: 32px; }
.premium h4 { margin: 0 0 10px; text-align: center; font-size: 17px; }
.premium ul { margin: 0 0 18px; padding-left: 20px; line-height: 1.9; }
.pm-cta { display: flex; align-items: center; justify-content: center; height: 42px; font-size: 15px; text-decoration: none; background: #10B981; }
.pm-cta:hover { background: #059669; }

/* favorite drawing tools (floating bar over the chart) */
.menu-item .fav { margin-left: auto; padding-left: 12px; display: inline-flex; color: var(--muted); opacity: .55; }
.menu-item .key + .fav { margin-left: 0; }
.menu-item:hover .fav, .menu-item .fav.on { opacity: 1; }
.menu-item .fav svg { width: 18px; height: 18px; }
#favBar { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 7; display: flex; align-items: center; gap: 1px; padding: 3px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
#favBar .dt-btn { width: 34px; height: 32px; }
#favBar .dt-btn svg { width: 24px; height: 24px; }
.fav-grip { width: 10px; height: 26px; cursor: grab; touch-action: none; background: radial-gradient(circle, var(--muted) 1px, transparent 1.5px) 0 0 / 5px 5px; opacity: .6; }

/* paper trading panel */
#tpBody { overflow-y: auto; flex: 1; padding: 12px 14px 20px; }
.tp-sec { margin-bottom: 6px; }
.tp-note { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.tp-sym { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; font-size: 15px; }
.tp-sym span { font-variant-numeric: tabular-nums; font-weight: 600; }
.tp-order .field { margin-bottom: 10px; }
.tp-pcts { display: flex; gap: 4px; margin: -4px 0 10px; }
.tp-pcts button { flex: 1; height: 26px; border-radius: 4px; background: var(--panel2); font-size: 12px; }
.tp-pcts button:hover { filter: brightness(1.15); }
.tp-btns { display: flex; gap: 8px; margin: 4px 0 8px; }
.tp-btns .rb-trade { flex: 1; height: 40px; font-size: 15px; }
.tp-wide { width: 100%; margin-bottom: 8px; }
.tp-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0 4px; }
.tp-stats div { background: var(--panel2); border-radius: 6px; padding: 6px 8px; display: flex; flex-direction: column; }
.tp-stats span { color: var(--muted); font-size: 11px; }
.tp-stats b { font-size: 14px; font-variant-numeric: tabular-nums; }
.tp-pos { padding: 8px 0; }
.tp-row { padding: 8px 0; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.tp-r1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-r2 { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.tp-r2 .small { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-close-pos { height: 26px; padding: 0 10px; font-size: 12px; }
.tp-hist { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; font-size: 12px; border-top: 1px solid var(--border); }

/* tool lists: long ones scroll */
.flyout { left: 40px; max-height: calc(100vh - 16px); overflow-y: auto; }
.flyout::before { display: none; }
.emoji-ic { font-size: 20px; line-height: 1; }
.emoji-fly { min-width: 240px; }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; padding: 4px 8px 6px; }
.emoji-grid button { height: 36px; font-size: 21px; border-radius: 6px; line-height: 1; }
.emoji-grid button:hover { background: var(--hover); }
.emoji-grid button.on { background: rgba(59,130,246,.18); }

/* zoom and scroll buttons over the chart */
#zoomNav { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 7; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; pointer-events: none; }
#chartWrap:hover #zoomNav { opacity: 1; pointer-events: auto; }
#zoomNav button { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--panel2); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
#zoomNav button:hover { background: var(--accent); color: #fff; }
#zoomNav svg { width: 22px; height: 22px; }

/* favourites bar: top right of the chart, away from the zoom buttons */
#favBar { left: auto; right: 80px; top: 8px; bottom: auto; transform: none; }

/* timezone button */
#clock { height: 26px; padding: 0 8px; border-radius: 4px; cursor: pointer; }
#clock:hover { background: var(--hover); }
.menu.up { top: auto; bottom: 32px; max-height: 70vh; overflow-y: auto; }

/* drawing edit window */
.de-colors { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.de-colors .sw { width: 26px; height: 26px; border-radius: 5px; border: 2px solid transparent; }
.de-colors .sw.on { border-color: var(--text); }
.de-colors input[type=color] { width: 34px; height: 28px; border: 1px solid var(--border); border-radius: 5px; background: none; padding: 1px; cursor: pointer; }
.draw-edit textarea.input { height: auto; padding: 8px 12px; resize: vertical; font: inherit; }
.de-foot { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
.de-del { display: inline-flex; align-items: center; gap: 4px; color: var(--down); padding: 0 10px 0 6px; }
.de-del svg { width: 20px; height: 20px; }

/* object tree */
.tree-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.tree-clear { height: 28px; font-size: 12px; color: var(--down); }
.tree-list { max-height: 40vh; overflow-y: auto; }
.tree-row { display: flex; align-items: center; gap: 4px; padding: 3px 4px; border-radius: 4px; cursor: pointer; }
.tree-row:hover { background: var(--hover); }
.tree-row.sel { background: rgba(59,130,246,.15); }
.tree-row.off .tr-name, .tree-row.off .tr-ic { opacity: .45; }
.tr-ic svg { width: 22px; height: 22px; }
.tr-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row button { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; color: var(--muted); border-radius: 4px; flex: none; }
.tree-row button:hover { color: var(--text); background: var(--panel2); }
.tree-row button svg { width: 20px; height: 20px; }

/* compare */
.cmp-row { display: flex; align-items: center; gap: 6px; padding: 2px 18px; }
.cmp-row .lr-del { margin-left: auto; }
.lg-row.cmp .nm { font-weight: 600; }

/* ---------- right side: icon column + docked panel ---------- */
#rpanel { width: 310px; flex: none; border-left: 1px solid var(--border); display: flex; min-height: 0; background: var(--bg); }
.rp-view { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.rp-body { flex: 1; overflow-y: auto; padding: 10px 12px 20px; }
.rp-close, .rp-head-btn { width: 30px; height: 30px; border-radius: 4px; display: flex; align-items: center; justify-content: center; color: var(--muted); flex: none; }
.rp-close { margin-left: auto; }
.rp-head-btn { margin-left: auto; }
.rp-head-btn + .rp-close { margin-left: 2px; }
.rp-close:hover, .rp-head-btn:hover { background: var(--hover); color: var(--text); }
.rp-close svg, .rp-head-btn svg { width: 22px; height: 22px; }
#rightstrip { width: 46px; flex: none; border-left: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 8px; background: var(--bg); }
.rs-btn { width: 38px; height: 38px; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: var(--muted); position: relative; }
.rs-btn:hover { background: var(--hover); color: var(--text); }
.rs-btn.active { color: var(--accent); background: rgba(59,130,246,.12); }
.rs-btn.active::before { content: ""; position: absolute; right: -4px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--accent); }
.rs-btn svg { width: 26px; height: 26px; }
.rs-sep { width: 28px; height: 1px; background: var(--border); margin: 4px 0; }
#rpBackdrop { position: fixed; inset: 0; z-index: 89; background: rgba(0,0,0,.45); }

/* alerts panel */
.ap-new { width: 100%; height: 36px; margin-bottom: 4px; }
.ap-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.ap-row.log { justify-content: space-between; font-size: 12px; }
.ap-main { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: pointer; }

/* data window */
.dw-sec { padding: 6px 0 8px; border-bottom: 1px solid var(--border); }
.dw-title { font-weight: 600; margin-bottom: 4px; }
.dw-row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; font-variant-numeric: tabular-nums; }
.dw-row span { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.dw-row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.dw-row b { font-weight: 500; }

/* ---------- bottom panel ---------- */
#bpanel { flex: none; display: flex; flex-direction: column; border-top: 1px solid var(--border); background: var(--bg); position: relative; min-height: 0; }
#bpanel.collapsed { height: 34px; }
#bpanel.collapsed .bp-body, #bpanel.collapsed #bpResize { display: none; }
#bpResize { position: absolute; left: 0; right: 0; top: -4px; height: 8px; cursor: ns-resize; z-index: 5; touch-action: none; }
.bp-tabs { height: 33px; flex: none; display: flex; align-items: center; gap: 2px; padding: 0 6px; }
.bp-tab { height: 26px; padding: 0 12px; border-radius: 4px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.bp-tab:hover { background: var(--hover); color: var(--text); }
.bp-tab.active { color: var(--text); background: var(--panel2); }
.bp-icon { width: 30px; height: 28px; border-radius: 4px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.bp-icon:hover { background: var(--hover); color: var(--text); }
.bp-icon svg { width: 22px; height: 22px; transition: transform .15s; }
.bp-icon.flip svg { transform: rotate(180deg); }
.bp-body { flex: 1; min-height: 0; overflow: hidden; border-top: 1px solid var(--border); }
.bp-view { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.bp-view[hidden] { display: none !important; }
.bp-bar { flex: none; display: flex; align-items: center; gap: 12px; padding: 6px 12px; }
.bp-bar select { background: var(--panel2); border: 1px solid var(--border); border-radius: 4px; height: 26px; margin-left: 6px; }
.bp-scroll { flex: 1; overflow: auto; padding: 0 12px 10px; }
.bp-scroll table.trades th { position: sticky; top: 0; background: var(--bg); }
.bp-empty { padding: 4px 12px; }
.bp-report { flex: 1; min-height: 0; display: flex; gap: 12px; padding: 0 12px 10px; overflow: auto; }
.bp-stats { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; align-content: start; }
.bp-curve { width: 38%; min-width: 220px; display: flex; flex-direction: column; background: var(--panel2); border-radius: 6px; padding: 6px 8px; }
.bp-curve canvas { flex: 1; width: 100%; min-height: 90px; }
#notesBox { flex: 1; margin: 8px 12px 12px; resize: none; background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; font: inherit; outline: none; }
#notesBox:focus { border-color: var(--accent); }

/* ---------- top bar on medium screens: the less used buttons move into "More" ---------- */
/* these live in the right icon column */
#layoutsBtn, #treeBtn, #settingsBtn { display: none !important; }
.tb-btn.icon { flex: none; }
@media (max-width: 1300px) {
  #tfButtons { display: none; }
  #tfPhoneDD { display: block; }
  #tfPhoneBtn { font-weight: 600; color: var(--accent); gap: 0; }
  #tfPhoneBtn .caret svg { width: 18px; height: 18px; }
  #tfPhoneMenu .lock { margin-left: auto; color: var(--muted); display: inline-flex; }
}
@media (max-width: 1500px) {
  #indicatorsBtn, #replayBtn { font-size: 0; gap: 0; }
  #indicatorsBtn .fx { font-size: 15px; }
  .premium-btn .lbl { display: none; }
}

/* ---------- small screens ---------- */
@media (max-width: 1100px) {
  #back1mBtn, #layoutsBtn, #treeBtn, #snapshotBtn, #themeBtn, #settingsBtn, #fullscreenBtn { display: none; }
  /* timeframes as one dropdown */
  #tfButtons { display: none; }
  #tfPhoneDD { display: block; }
  #tfPhoneBtn { font-weight: 600; color: var(--accent); gap: 0; }
  #tfPhoneBtn .caret svg { width: 18px; height: 18px; }
  #tfPhoneMenu .lock { margin-left: auto; color: var(--muted); display: inline-flex; }
  .tb-btn.icon { flex: none; }
  /* the right panel slides over the chart */
  #rpanel { position: fixed; top: 0; right: 46px; bottom: 0; width: min(330px, calc(100vw - 60px)); z-index: 90; box-shadow: -12px 0 32px rgba(0,0,0,.5); }
  .bp-curve { display: none; }
  /* paper trading opens as a panel from the right */
  #indicatorsBtn, #replayBtn { font-size: 0; gap: 0; }
  #indicatorsBtn .fx { font-size: 15px; }
}
@media (max-width: 760px) {
  #drawbar { width: 44px; }
  .dt-btn { width: 36px; }
  .tf-btn { min-width: 26px; padding: 0 4px; }
  #snapshotBtn, #fullscreenBtn, #undoBtn, #redoBtn, #rightstrip { display: none; }
  #topbar { overflow-x: auto; }
  #replayBar { overflow-x: auto; }
  /* the hidden top bar buttons are reachable from "More" */
  #gotoDateBtn, #alertBtn, #premiumBtn, #compareBtn { display: none !important; }
  #rpanel { right: 0; width: min(330px, 92vw); }
  .wl-row { height: 44px; }
  /* bottom panel: hidden on phones; opens from "More" as a sheet */
  #bpanel.collapsed { display: none; }
  #bpanel:not(.collapsed) { position: fixed; left: 0; right: 0; bottom: 0; height: 62vh !important; z-index: 95; box-shadow: 0 -12px 32px rgba(0,0,0,.5); border-radius: 12px 12px 0 0; }
  #bpResize { display: none; }
  .bp-tab { padding: 0 8px; }
  #favBar, #zoomNav { display: none !important; }
  .flyout { left: 36px; min-width: 220px; max-width: calc(100vw - 50px); }
  #moreMenu { min-width: 220px; position: fixed; top: 48px; right: 6px; left: auto; }
  /* watchlist opens as a panel from the right (from "More") */
}

/* ---------- phones and small tablets: a clean screen for backtesting ---------- */
@media (max-width: 760px) {
  /* top bar: logo · pair · timeframe · chart type · indicators · replay · more · account. Everything fits, no sideways scrolling */
  #topbar { overflow: visible; gap: 0; padding: 0 4px; }
  #topbar > .sep { display: none; }
  .brand { margin-right: 2px; }
  .brand img { width: 26px; height: 26px; }
  .tb-btn { padding: 0 5px; height: 38px; }
  .tb-btn.icon { width: 34px; }
  .symbol-btn { padding: 0 6px 0 4px; font-size: 13px; }
  .symbol-btn .ic { display: none; }
  #tfButtons { display: none; }
  #tfPhoneDD { display: block; }
  #tfPhoneBtn { font-weight: 600; color: var(--accent); gap: 0; }
  #tfPhoneBtn .caret svg { width: 18px; height: 18px; }
  #tfPhoneMenu { min-width: 160px; }
  #tfPhoneMenu .lock { margin-left: auto; color: var(--muted); display: inline-flex; }
  .trade-btn { width: 34px; padding: 0; justify-content: center; margin-left: 2px; }
  .trade-btn .lbl { display: none; }
  #userArea { margin-left: 2px; }
  #userArea .btn-primary { height: 32px; padding: 0 10px; }
  .menu { top: 42px; }
  .menu-item { padding: 0 16px; height: 44px; font-size: 15px; }

  /* chart name on one short line, smaller prices */
  #legend { left: 6px; max-width: calc(100% - 70px); }
  .lg-title { font-size: 13px; }
  .lg-main { font-size: 11px; gap: 0 8px; }
  .lg-ohlc span { margin-right: 4px; }

  /* bottom bar on one line */
  #bottombar { padding: 0 4px; }
  #bottombar #clock, #bottombar .sep { display: none; }
  .bb-btn { padding: 0 6px; }

  /* replay bar in two rows: playback controls, then trading */
  #replayBar { height: auto; flex-wrap: wrap; row-gap: 4px; gap: 4px 2px; padding: 5px 6px; overflow: visible; }
  #replayBar > * { order: 1; }
  #rbSelect { font-size: 0; gap: 0; width: 34px; padding: 0; justify-content: center; }
  .rb-date { flex: 1; min-width: 0; padding: 0 4px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
  #rbRealtime { order: 2; font-size: 0; padding: 0 8px; }
  #rbRealtime::after { content: "Live"; font-size: 13px; }
  #rbClose { order: 3; }
  #replayBar > .sep { order: 4; flex-basis: 100%; height: 0; margin: 0; }
  #replayBar > .spacer { display: none; }
  #rbBuy, #rbSell, #rbFlat, #rbStats, #rbTrades { order: 5; }
  .rb-trade { height: 34px; padding: 0 18px; }
  #rbStats { flex: 1; padding: 0 4px; font-size: 12px; }

  #replayCursor .tip { top: 12px; width: max-content; max-width: 88vw; text-align: center; font-size: 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-body { overflow-x: auto; }
  .modal-ov { padding-top: 5vh; }
}

/* ---------- login page ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; overflow: auto; background: radial-gradient(1200px 600px at 50% -10%, #1E2A44 0%, var(--bg) 60%); }
.login-card { width: 380px; max-width: calc(100vw - 32px); background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 32px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.login-card .logo { display: block; margin: 0 auto 22px; height: 48px; }
.login-card h1 { font-size: 20px; margin: 0 0 6px; text-align: center; }
.login-card p.sub { color: var(--muted); text-align: center; margin: 0 0 22px; }
.login-card .btn-primary { width: 100%; height: 40px; font-size: 14px; }
.login-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 12px; }
.login-links a, .login-links button { color: var(--accent); text-decoration: none; padding: 0; }
.login-foot { margin-top: 20px; text-align: center; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); padding-top: 16px; }


/* =====================================================================
   Toolbar look (left tools + top bar), matched to TradingView's style:
   grey page, white panels with 4px gaps, soft rounded hover highlight,
   grey background for the chosen tool, blue for switched-on toggles.
   ===================================================================== */
:root { --page: #0C0E15; --tb-hover: #2A2E39; --tb-active: #2A2E39; --pill: #2A2E39; --pill-hover: #363A45; --divider: #2A2E39; --toggle-on: #2962FF; }
body.light { --page: #EBEBEB; --bg: #FFFFFF; --panel: #FFFFFF; --text: #000000; --hover: #F2F2F2; --border: #EBEBEB; --accent: #2962FF; --accent-h: #1E53E5;
  --tb-hover: #F2F2F2; --tb-active: #EBEBEB; --pill: #EBEBEB; --pill-hover: #DBDBDB; --divider: #EBEBEB; }

/* panels with gaps */
#app { background: var(--page); }
#topbar { height: 38px; background: var(--bg); border-bottom: 0; margin-bottom: 4px; padding: 0 4px; gap: 0; }
#main { gap: 4px; background: var(--page); }
#drawbar, #center, #rpanel, #rightstrip { background: var(--bg); border: 0; }
#center { min-width: 0; }

/* every toolbar button: a rounded highlight drawn inside the button */
.tb-btn, .dt-btn, .rs-btn { position: relative; background: none !important; border-radius: 0; color: var(--text); isolation: isolate; }
.tb-btn::before, .dt-btn::before, .rs-btn::before { content: ""; position: absolute; inset: 2px; border-radius: 6px; background: transparent; z-index: -1; transition: background-color .2s; }
.tb-btn:hover::before, .dt-btn:hover::before, .rs-btn:hover::before { background: var(--tb-hover); }
.tb-btn:disabled::before { background: transparent !important; }

/* top bar */
.tb-btn { height: 38px; padding: 0 10px; font-size: 14px; gap: 2px; }
.tb-btn.icon { width: 38px; padding: 0 5px; }
.tb-btn .ic svg { width: 28px; height: 28px; }
.tb-btn.active { color: var(--accent); }
#indicatorsBtn, #replayBtn { padding: 0 10px 0 5px; }
#topbar > .sep { width: 1px; height: 22px; background: var(--divider); margin: 0 4px; }
.brand { margin: 0 4px 0 2px; }

/* the pair: a grey pill with a round search button inside */
.sym-wrap { height: 38px; display: flex; align-items: center; padding: 0 4px; }
.sym-pill { position: relative; height: 28px; min-width: 96px; max-width: 170px; border-radius: 14px; background: var(--pill); color: var(--text); padding: 0 36px 0 12px; display: flex; align-items: center; font-size: 14px; font-weight: 600; white-space: nowrap; transition: background-color .2s; }
.sym-pill:hover { background: var(--pill-hover); }
#symbolLabel { overflow: hidden; text-overflow: ellipsis; }
.sym-act { position: absolute; right: 2px; top: 2px; width: 28px; height: 24px; border-radius: 999px; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.sym-act .ic svg { width: 18px; height: 18px; }
.sym-pill:hover .sym-act { background: var(--pill); }

/* the timeframe: one button ("1h") that opens a grouped list */
#tfButtons { display: none !important; }
#tfPhoneDD { display: block !important; }
#tfPhoneBtn { color: var(--text) !important; font-weight: 400 !important; min-width: 37px; justify-content: center; }
#tfPhoneMenu { min-width: 190px; padding: 6px 0; }
.menu-sec { padding: 8px 14px 4px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.menu-sec:not(:first-child) { border-top: 1px solid var(--divider); margin-top: 4px; }

/* menus */
.menu, .flyout { border-radius: 6px; border-color: var(--divider); }
.menu-item { min-height: 32px; padding: 0 14px; font-size: 14px; }
.menu-item:hover { background: var(--tb-hover); }
.menu-item.active { color: var(--accent); }
body.light .menu, body.light .flyout { box-shadow: 0 2px 4px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.12); border: 0; }

/* left tool bar: 52px wide, 52x38 buttons, black icons */
#drawbar { width: 52px; padding: 6px 0; gap: 0; }
.dt-group { width: 52px; }
.dt-btn { width: 52px; height: 38px; }
.dt-btn::before { inset: 2px 9px; }
.dt-btn svg { width: 28px; height: 28px; }
.dt-btn.active { color: var(--text); }
.dt-btn.active::before { background: var(--tb-active); }
.dt-group .dt-btn.active::before { background: var(--tb-active); }
/* switched-on toggles (magnet, keep drawing, lock, hide): blue with a white icon */
#drawbar > .dt-btn.toggle.active { color: #fff; }
#drawbar > .dt-btn.toggle.active::before { background: var(--toggle-on); }
#drawbar > .dt-btn.toggle.active:hover::before { background: var(--accent-h); }
/* the small arrow that opens a tool group appears on hover, on the right edge */
.dt-btn .corner { right: 2px; bottom: auto; top: 50%; transform: translateY(-50%); width: 9px; height: 18px; align-items: center; justify-content: center; opacity: 0; color: var(--text); transition: opacity .15s; }
.dt-btn .corner svg { width: 5px; height: 5px; transform: rotate(-45deg); }
.dt-group:hover .dt-btn .corner { opacity: .8; }
@media (hover: none) { .dt-btn .corner { opacity: .5; } }
/* sections of the tool bar separated like separate panels */
.dt-sep { width: 100%; height: 4px; margin: 6px 0; background: var(--page); }
.flyout { left: 52px; top: -6px; }
.flyout .menu-item { min-height: 34px; }

/* right icon column */
.rs-btn { width: 44px; height: 40px; color: var(--text); }
.rs-btn::before { inset: 2px 4px; }
.rs-btn.active { color: var(--accent); }
.rs-btn.active::before { background: var(--tb-active); }
.rs-btn.active::after { display: none; }
#rightstrip { width: 46px; gap: 2px; }
.rs-sep { width: 100%; height: 4px; background: var(--page); margin: 4px 0; }
#rpanel { border-radius: 0; }

/* bottom bar and panel as white panels */
#bottombar { border-top: 1px solid var(--divider); }
#bpanel { border-top: 0; margin-top: 4px; box-shadow: 0 -4px 0 var(--page); }
.bp-tab.active { background: var(--tb-active); }

/* trade button stays blue, round */
.trade-btn { background: var(--accent) !important; color: #fff !important; border-radius: 16px; height: 30px; margin: 0 4px; }
.trade-btn::before { display: none; }
.trade-btn:hover { background: var(--accent-h) !important; }
.premium-btn { color: #10B981; }

/* ---- responsive versions of the rules above ---- */
@media (max-width: 1500px) {
  #indicatorsBtn, #replayBtn { font-size: 0; padding: 0 5px; width: 38px; justify-content: center; }
}
@media (max-width: 760px) {
  #topbar { padding: 0 2px; margin-bottom: 0; }
  #main { gap: 0; }
  .sym-wrap { padding: 0 2px; }
  .sym-pill { min-width: 0; max-width: 112px; padding: 0 30px 0 10px; font-size: 13px; }
  .sym-act { width: 24px; }
  .tb-btn { padding: 0 4px; }
  .tb-btn.icon { width: 34px; padding: 0; }
  #indicatorsBtn, #replayBtn { width: 34px; padding: 0; }
  .brand { display: none; }
  #drawbar { width: 44px; }
  .dt-group, .dt-btn { width: 44px; }
  .dt-btn::before { inset: 2px 5px; }
  .flyout { left: 44px; }
  .trade-btn { width: 32px; padding: 0; margin: 0 2px; justify-content: center; }
  #bpanel { margin-top: 0; box-shadow: 0 -12px 32px rgba(0,0,0,.5); }
}

/* =====================================================================
   Windows, lists, tooltips, legend and bottom bar, matched to TradingView
   ===================================================================== */
:root { --tip-bg: #222; --tip-fg: #F2F2F2; --row-hover: #2A2E39; --row-sel: rgba(41,98,255,.2); --backdrop: rgba(0,0,0,.55); }
body.light { --row-hover: #F2F2F2; --row-sel: #BBD9FB; --backdrop: rgba(209,209,209,.3); --muted: #707070; }

/* windows */
.modal-ov { background: var(--backdrop); }
.modal { border: 0; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.12), 0 16px 48px rgba(0,0,0,.18); }
body.light .modal { box-shadow: 0 2px 4px rgba(0,0,0,.08), 0 8px 32px rgba(0,0,0,.16); }
.modal-head { padding: 14px 12px 14px 20px; border-bottom: 0; }
.modal-head h3 { font-size: 20px; font-weight: 600; }
.modal-head .x { width: 34px; height: 34px; border-radius: 8px; color: var(--text); }
.modal-head .x:hover { background: var(--row-hover); }
.modal-head .x svg { width: 22px; height: 22px; }
.modal-body { padding: 4px 20px 20px; }
.input { border-radius: 8px; height: 40px; }
.btn-primary { border-radius: 8px; height: 36px; padding: 0 16px; font-weight: 600; }
.btn-ghost { border-radius: 8px; height: 36px; border-color: var(--divider); }
.btn-ghost:hover { background: var(--row-hover); }

/* search box inside windows: a 40px rounded box with a thin border */
.search-top { padding: 0 20px; }
.search-input { height: 40px; border: 1px solid var(--divider); border-radius: 8px; padding: 0 10px; margin-bottom: 4px; }
.search-input:focus-within { border-color: var(--accent); }
.search-input input { font-size: 16px; text-transform: none; }
.search-input .ic svg { width: 22px; height: 22px; color: var(--muted); }
.tabs { padding: 10px 0 8px; gap: 6px; }
.tab { height: 30px; padding: 0 14px; border-radius: 15px; background: transparent; border: 1px solid var(--divider); font-size: 14px; }
.tab:hover { background: var(--row-hover); }
.tab.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* list rows: 32px, rounded, grey on hover */
.sym-list { border-top: 1px solid var(--divider); padding: 6px 8px 8px; }
.sym-row, .ind-row { min-height: 32px; padding: 6px 12px; border-radius: 8px; font-size: 14px; }
.sym-row:hover, .sym-row.kb, .ind-row:hover { background: var(--row-hover); }
.sym-row .badge { width: 22px; height: 22px; }
.wl-row:hover { background: var(--row-hover); }
.wl-row.active { background: var(--row-sel); }
.tree-row:hover, .layout-row:hover { background: var(--row-hover); }
.tree-row { border-radius: 6px; }

/* menus */
.menu, .flyout { background: var(--bg); padding: 6px 0; }
.menu-item { gap: 10px; }
.menu-item:disabled { opacity: .4; }
.menu-sep { background: var(--divider); }
.ctx-menu { position: fixed; z-index: 120; min-width: 240px; }

/* dark tooltips */
#tip { position: fixed; z-index: 400; max-width: 260px; padding: 6px 8px; border-radius: 4px; background: var(--tip-bg); color: var(--tip-fg); font-size: 13px; line-height: 1.35; pointer-events: none; white-space: normal; box-shadow: 0 2px 8px rgba(0,0,0,.2); }

/* legend: 16px title with dots between the parts, round badge, 13px prices */
#legend { top: 6px; left: 8px; }
.lg-main { gap: 2px 12px; font-size: 13px; }
.lg-title { display: inline-flex; align-items: center; gap: 0; font-size: 16px; font-weight: 400; color: var(--text); padding: 2px 6px 2px 2px; border-radius: 4px; background: color-mix(in srgb, var(--bg) 50%, transparent); }
.lg-badge { width: 18px; height: 18px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; margin-right: 6px; flex: none; }
.lg-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--text); opacity: .5; margin: 0 8px; flex: none; }
.lg-ohlc { font-size: 13px; }
.lg-ohlc span { color: var(--text); margin-right: 8px; }
.lg-ohlc b { font-weight: 400; margin-left: 1px; }
.lg-row { font-size: 13px; }

/* bottom bar: 38px with 14px buttons */
#bottombar { height: 38px; padding: 0 4px; }
.bb-btn { height: 38px; padding: 0 6px; font-size: 14px; color: var(--text); position: relative; background: none !important; isolation: isolate; }
.bb-btn::before { content: ""; position: absolute; inset: 4px 0; border-radius: 6px; z-index: -1; transition: background-color .2s; }
.bb-btn:hover::before { background: var(--tb-hover); }
.bb-btn.active { color: var(--accent); }
#clock { height: 30px; font-size: 14px; }

/* =====================================================================
   Drawing tools: floating toolbar, colour picker and settings window (TradingView style)
   ===================================================================== */
#drawProps { top: 8px; left: 50%; transform: translateX(-50%); height: 38px; padding: 0; gap: 0; display: flex; align-items: center; background: var(--bg); border: 0; border-radius: 6px; box-shadow: 0 0 2px rgba(0,0,0,.25), 0 3px 9px rgba(0,0,0,.18); z-index: 9; }
body.light #drawProps { box-shadow: 0 0 2px #DBDBDB, 0 3px 9px #EBEBEB; }
.ft-grip { width: 24px; height: 38px; cursor: grab; touch-action: none; background: radial-gradient(circle, var(--muted) 1px, transparent 1.4px) 7px 12px / 5px 5px; background-repeat: repeat; opacity: .7; clip-path: inset(10px 6px 10px 6px); }
.ft-btn { position: relative; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; flex-direction: column; color: var(--text); isolation: isolate; }
.ft-btn::before { content: ""; position: absolute; inset: 3px; border-radius: 6px; z-index: -1; transition: background-color .15s; }
.ft-btn:hover::before { background: var(--tb-hover); }
.ft-btn.on { color: var(--accent); }
.ft-btn svg { width: 28px; height: 28px; }
.ft-btn .ft-ic svg { width: 22px; height: 22px; }
.ft-bar { display: block; width: 18px; height: 3px; border-radius: 1px; margin-top: -2px; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.ft-t { font-size: 17px; font-weight: 600; line-height: 20px; margin-top: 2px; }
.ft-wide { width: 68px; flex-direction: row; gap: 6px; }
.ft-line { display: block; width: 18px; background: currentColor; border-radius: 1px; }
.ft-wide span { font-size: 13px; }

/* popups under the toolbar buttons */
.ft-pop { position: fixed; z-index: 130; background: var(--bg); border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,.12), 0 8px 24px rgba(0,0,0,.18); padding: 6px 0; }
.ft-menu { min-width: 170px; }
.ft-menu .menu-item { gap: 10px; min-height: 34px; }
.ft-menu .menu-item svg { flex: none; }
.ft-menu .menu-item .key { margin-left: auto; padding-left: 18px; color: var(--muted); font-size: 12px; }

/* colour picker: 10 columns of swatches, custom colour, opacity */
.cp { padding: 6px 10px 8px; width: 252px; }
.cp-row { display: grid; grid-template-columns: repeat(10, 20px); gap: 3px; margin-bottom: 3px; }
.cp-grey { margin-bottom: 8px; }
.cp-sw { width: 20px; height: 20px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); position: relative; }
.cp-sw:hover { transform: scale(1.12); }
.cp-sw.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--accent); }
.cp-sep { height: 1px; background: var(--divider); margin: 8px 0; }
.cp-custom { display: flex; gap: 4px; }
.cp-plus { position: relative; width: 20px; height: 20px; border-radius: 3px; border: 1px dashed var(--muted); display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 15px; cursor: pointer; overflow: hidden; }
.cp-plus input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.cp-opacity { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.cp-opacity input { flex: 1; accent-color: var(--accent); }
.cp-pct { width: 38px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }

/* settings window of a drawing */
.dset { margin: -4px -20px -20px; display: flex; flex-direction: column; }
.dset-tabs { display: flex; gap: 20px; padding: 0 20px; border-bottom: 1px solid var(--divider); }
.dset-tab { height: 40px; font-size: 16px; font-weight: 600; color: var(--muted); position: relative; }
.dset-tab:hover { color: var(--text); }
.dset-tab.on { color: var(--text); }
.dset-tab.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--text); border-radius: 2px; }
.dset-body { padding: 14px 20px; min-height: 260px; max-height: 56vh; overflow-y: auto; }
.dset-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.dset-l { width: 120px; flex: none; }
.dset-c { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
.dset-sel { width: auto; min-width: 96px; height: 34px; }
.dset-sw { width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--divider); background: linear-gradient(var(--c), var(--c)) center / 22px 22px no-repeat; flex: none; }
.dset-sw:hover { background-color: var(--row-hover); }
.dset-sec { margin: 14px 0 4px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.dset-textrow { gap: 8px; margin-bottom: 8px; }
.dset-tog { width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--divider); font-size: 15px; }
.dset-tog.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.dset-text { height: auto; padding: 10px 12px; font: inherit; resize: vertical; }
.dset-num { width: 120px; height: 34px; }
.dset-time { width: 190px; height: 34px; }
.dset-emoji { margin-bottom: 10px; }
.dset-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--divider); }
.dset-tpl { display: inline-flex; align-items: center; gap: 6px; }
.dset-tpl .ic svg { width: 6px; height: 6px; transform: rotate(45deg); }
.dset-cancel { height: 34px; border: 1px solid var(--text); background: transparent; color: var(--text); padding: 0 14px; }
.dset-ok { height: 34px; background: #222; color: #fff; padding: 0 16px; }
.dset-ok:hover { background: #000; }
body:not(.light) .dset-ok { background: #F2F2F2; color: #000; }

/* =====================================================================
   Top bar: timeframe menu, replay bar, chart settings, countdown (TradingView style)
   ===================================================================== */
/* timeframe menu */
#tfPhoneMenu { width: 230px; max-height: calc(100vh - 60px); overflow-y: auto; padding: 4px 0 6px; }
.tf-add { color: var(--muted); }
.tf-add .ic svg { width: 22px; height: 22px; }
.tf-sec { width: 100%; height: 30px; display: flex; align-items: center; justify-content: space-between; padding: 0 10px 0 14px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; border-top: 1px solid var(--divider); margin-top: 4px; }
.tf-sec:hover { color: var(--text); }
.tf-chev { display: inline-flex; transition: transform .15s; }
.tf-chev svg { width: 18px; height: 18px; }
.tf-sec.closed .tf-chev { transform: rotate(180deg); }
.tf-item { cursor: pointer; padding: 0 6px 0 14px; }
.tf-item .tf-name { flex: 1; }
.tf-item.active { background: var(--row-sel); color: var(--text); }
.tf-star, .tf-x { width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; color: var(--muted); opacity: 0; flex: none; }
.tf-star svg, .tf-x svg { width: 18px; height: 18px; }
.tf-item:hover .tf-star, .tf-item:hover .tf-x, .tf-star.on { opacity: 1; }
.tf-star:hover, .tf-x:hover { background: var(--tb-hover); color: var(--text); }
#tfButtons { display: none !important; }
@media (min-width: 1500px) { #tfButtons { display: flex !important; gap: 0; } }
.tf-btn { height: 38px; padding: 0 8px; border-radius: 0; position: relative; isolation: isolate; background: none !important; font-size: 14px; color: var(--text); }
.tf-btn::before { content: ""; position: absolute; inset: 2px 0; border-radius: 6px; z-index: -1; }
.tf-btn:hover::before { background: var(--tb-hover); }
.tf-btn.active { color: var(--accent); }

/* bar replay controls: one 48px bar, playback centred */
#replayBar { position: relative; height: 48px; padding: 0 8px; gap: 4px; background: var(--bg); border-top: 1px solid var(--divider); overflow: visible; }
.rb-side { display: flex; align-items: center; gap: 4px; min-width: 0; }
.rb-left { flex: 1; }
.rb-right { flex: 1; justify-content: flex-end; }
.rb-center { display: flex; align-items: center; gap: 0; flex: none; }
.rb-btn { position: relative; height: 38px; padding: 0 8px; border-radius: 0; background: none !important; color: var(--text); font-size: 14px; isolation: isolate; gap: 4px; }
.rb-btn::before { content: ""; position: absolute; inset: 2px 0; border-radius: 6px; z-index: -1; transition: background-color .15s; }
.rb-btn:hover::before { background: var(--tb-hover); }
.rb-btn.icon { width: 38px; padding: 0; }
.rb-btn .ic svg { width: 28px; height: 28px; }
.rb-txt { min-width: 38px; justify-content: center; }
.rb-split { display: flex; align-items: center; }
.rb-caret { width: 22px; padding: 0; justify-content: center; }
.rb-caret .ic svg { width: 18px; height: 18px; }
.rb-div { width: 1px; height: 22px; background: var(--divider); margin: 0 6px; }
.rb-date { color: var(--muted); font-size: 13px; padding: 0 6px; white-space: nowrap; }
.rb-trade { height: 30px; padding: 0 14px; border-radius: 6px; font-size: 14px; }
#rbStats { font-size: 13px; }
.rb-tf-pop { max-height: 60vh; overflow-y: auto; }

/* chart settings window: tabs on the left */
.modal:has(.cset) .modal-body { padding: 0; }
.cset { display: flex; height: min(564px, calc(80vh - 64px)); } /* 626px with the title, like TradingView's */
.cset-side { width: 206px; flex: none; padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--divider); overflow-y: auto; }
.cset-tab { height: 40px; display: flex; align-items: center; gap: 10px; padding: 0 16px 0 10px; border-radius: 8px; font-size: 15px; color: var(--text); text-align: left; }
.cset-tab .ic svg { width: 26px; height: 26px; }
.cset-tab:hover { background: var(--row-hover); }
.cset-tab.on { background: #222; color: #fff; }
body:not(.light) .cset-tab.on { background: #F2F2F2; color: #000; }
.cset-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cset-body { flex: 1; overflow-y: auto; padding: 4px 22px 16px; }
.cset-sec { margin: 16px 0 6px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.cset-sec:first-child { margin-top: 6px; }
.cset-row { display: flex; align-items: center; gap: 12px; min-height: 40px; }
.cset-l { flex: 1; min-width: 0; margin: 0; }
.cset-c { display: flex; align-items: center; gap: 8px; flex: none; }
.cset-num { width: 74px; height: 34px; }
.cset .dset-foot { padding: 12px 22px 16px; }

/* countdown to bar close, under the last price label */
#countdown { position: absolute; z-index: 4; height: 16px; line-height: 16px; font-size: 11px; color: #fff; text-align: center; pointer-events: none; font-variant-numeric: tabular-nums; }
#legend.no-bg .lg-title { background: none; }
.lg-vol b { color: var(--text); margin-left: 3px; font-weight: 400; }
/* navigation buttons: always / never */
#chartWrap.nav-always #zoomNav { opacity: 1; pointer-events: auto; }
#chartWrap.nav-hidden #zoomNav { display: none; }

@media (max-width: 760px) {
  /* replay bar on phones: playback on top, trading below */
  #replayBar { height: auto; flex-wrap: wrap; padding: 4px 6px; row-gap: 2px; }
  #replayBar > .rb-center { order: 1; flex: 1; justify-content: flex-start; }
  #replayBar > .rb-right { order: 2; flex: none; }
  #replayBar > .rb-left { order: 3; flex-basis: 100%; }
  #rbRealtime::after { content: none !important; }
  #rbRealtime { font-size: 14px; padding: 0; width: 38px; justify-content: center; }
  #rbSelect .lbl, #rbRealtime .lbl, .rb-date { display: none; }
  .rb-btn { padding: 0 5px; }
  .rb-div { margin: 0 3px; }
  /* settings window on phones: tabs on top */
  .cset { flex-direction: column; height: calc(80vh - 56px); }
  .cset-side { width: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--divider); padding: 4px 8px 8px; }
  .cset-tab { flex: none; height: 34px; font-size: 13px; padding: 0 10px 0 6px; }
  .cset-tab .ic svg { width: 20px; height: 20px; }
  .cset-body { padding: 4px 14px 12px; }
  .cset-row { gap: 8px; }
  .cset .dset-foot { padding: 10px 14px 12px; }
}

@media (max-width: 760px) {
  /* the drawing toolbar fits a phone screen: the less used buttons are in Settings */
  #drawProps { max-width: calc(100% - 8px); }
  #drawProps [data-a="tpl"], #drawProps [data-a="tcolor"], #drawProps [data-a="alert"], #drawProps [data-a="style"] { display: none; }
  .ft-grip { width: 16px; }
  .ft-btn { width: 34px; }
  .ft-wide { width: 56px; }
  .lg-title { font-size: 13px; }
  .lg-badge { width: 16px; height: 16px; font-size: 10px; margin-right: 4px; }
  .lg-dot { margin: 0 5px; }
  #bottombar { height: 34px; }
  .bb-btn { height: 34px; padding: 0 5px; font-size: 12px; }
  .modal-head { padding: 12px 8px 12px 16px; }
  .modal-head h3 { font-size: 17px; }
  .modal-body { padding: 4px 14px 16px; }
  .search-top { padding: 0 14px; }
}

/* ---------- left toolbar as TradingView-style cards ---------- */
#drawbar { background: var(--page) !important; padding: 0; gap: 4px; justify-content: flex-start; overflow: visible; }
.dt-card { width: 100%; background: var(--bg); border-radius: 0; padding: 6px 0; display: flex; flex-direction: column; align-items: center; flex: none; }
#drawbar .dt-btn.toggle.active { color: #fff; }
#drawbar .dt-btn.toggle.active::before { background: var(--toggle-on); }
#drawbar .dt-btn.toggle.active:hover::before { background: var(--accent-h); }
#drawbar .dt-btn.toggle.active .corner { color: #fff; }
.dt-btn .corner.opt { cursor: pointer; }
.dt-btn .corner:hover { opacity: 1 !important; }
.dt-btn .corner:hover::after { content: ""; position: absolute; inset: 0; border-radius: 3px; background: var(--tb-hover); z-index: -1; }
#drawbar .dt-btn.toggle.active .corner:hover::after { background: rgba(255,255,255,.2); }
.flyout-title:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--divider); padding-top: 10px; }
#chartWrap.zoom-mode, #chartWrap.zoom-mode * { cursor: zoom-in !important; }
#zoomBox { position: absolute; top: 0; bottom: 0; background: rgba(41,98,255,.12); border-left: 1px solid #2962FF; border-right: 1px solid #2962FF; pointer-events: none; z-index: 15; }

/* ---------- features from the old Backtesting Pro site ---------- */
/* type-a-timeframe box */
#intervalBox { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); z-index: 40; width: 260px; background: var(--bg); border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.16); padding: 14px 16px 12px; }
#intervalBox[hidden] { display: none; }
.ib-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 10px; }
#ibInput { width: 100%; height: 34px; border: 1px solid var(--divider); border-radius: 6px; padding: 0 10px; font-size: 16px; background: var(--bg); color: var(--text); outline: none; box-sizing: border-box; }
#ibInput:focus { border-color: #2962FF; }
.ib-hint { min-height: 18px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.ib-hint.error { color: #F23645; }
/* quick Buy / Sell under the legend */
#quickTrade { display: flex; align-items: stretch; gap: 0; margin: 6px 0 4px; pointer-events: auto; width: max-content; }
.qt-btn { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; min-width: 78px; height: 38px; padding: 0 8px; border: 1px solid; border-radius: 4px; background: var(--bg); font-size: 10px; line-height: 1.15; cursor: pointer; }
.qt-btn b { font-size: 13px; font-weight: 500; }
.qt-btn.sell { color: #F23645; border-color: #F23645; }
.qt-btn.buy { color: #2962FF; border-color: #2962FF; align-items: flex-end; }
.qt-btn.sell:hover { background: #F23645; color: #fff; }
.qt-btn.buy:hover { background: #2962FF; color: #fff; }
.qt-mid { width: 6px; }
@media (max-width: 760px) { #quickTrade { display: none; } }
/* "+" at the crosshair price */
#plusBtn { position: absolute; z-index: 25; display: flex; align-items: center; justify-content: center; width: 18px; height: 18px; padding: 0; border: 1px solid #2962FF; border-radius: 50%; background: var(--bg); color: #2962FF; cursor: pointer; }
#plusBtn[hidden] { display: none; }
#plusBtn:hover { background: #2962FF; color: #fff; }
/* session breaks */
#breaksCanvas { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 2; }
/* replay: back one bar */
.ic.flip svg { transform: scaleX(-1); }

/* ---------- profile menu (like backtestingpro.com) ---------- */
#topbar .brand { display: none; }
.profile-btn { flex: none; width: 28px; height: 28px; margin: 0 10px 0 6px; padding: 0; border: 0; border-radius: 50%; background: #F57C00; color: #fff; font: 600 14px/28px -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, sans-serif; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.profile-btn.guest { background: var(--tb-hover); color: var(--muted); }
.profile-btn:hover, .profile-btn[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--divider); }
#profileMenu { position: fixed; z-index: 3000; width: 290px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 70px); overflow-y: auto; padding: 6px 0; border-radius: 6px; background: #fff; color: #131722; box-shadow: 0 2px 4px rgba(0,0,0,.2), 0 8px 24px rgba(0,0,0,.15); font-size: 16px; }
body:not(.light) #profileMenu { background: #1E1E1E; color: #B8B8B8; box-shadow: 0 2px 4px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.5); }
.pm-head { display: flex; align-items: center; gap: 12px; padding: 8px 12px 12px; margin-bottom: 6px; border-bottom: 1px solid #E0E3EB; }
.pm-face { flex: none; width: 28px; height: 28px; border-radius: 50%; background: #F57C00; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 600; }
.pm-face.guest { background: #F0F3FA; color: #787B86; }
.pm-words { min-width: 0; display: flex; flex-direction: column; }
.pm-words b, .pm-words small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-words b { font-size: 16px; font-weight: 600; }
.pm-words small { color: #787B86; font-size: 13px; }
.pm-row { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; height: 44px; padding: 0 12px; box-sizing: border-box; border: 0; background: none; color: inherit; font: inherit; font-size: 16px; text-align: left; cursor: pointer; }
.pm-row:hover { background: #F0F3FA; }
.pm-row svg { flex: none; }
.pm-row > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-row small { color: #787B86; font-size: 14px; }
.pm-line { margin: 6px 0; border-top: 1px solid #E0E3EB; }
.pm-row input { position: absolute; opacity: 0; pointer-events: none; }
.pm-switch { position: relative; flex: none; width: 34px; height: 20px; border-radius: 10px; background: #B2B5BE; transition: background .15s; }
.pm-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.pm-row input:checked + .pm-switch { background: #131722; }
.pm-row input:checked + .pm-switch::after { transform: translateX(14px); }
body:not(.light) .pm-head, body:not(.light) .pm-line { border-color: #3D3D3D; }
body:not(.light) .pm-row:hover { background: #2E2E2E; }
body:not(.light) .pm-face.guest { background: #2E2E2E; }
body:not(.light) .pm-switch { background: #5C5C5C; }
body:not(.light) .pm-row input:checked + .pm-switch { background: #B8B8B8; }
body:not(.light) .pm-row input:checked + .pm-switch::after { background: #000; }
@media (max-width: 520px) { .pm-draw { display: none; } }
body.no-drawbar #drawbar { display: none; }
/* keyboard shortcuts window */
.keys-list { max-height: min(60vh, 520px); overflow-y: auto; margin: 0 -4px; }
.keys-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--divider); font-size: 14px; }
.keys-row:last-child { border-bottom: 0; }
.keys-row kbd { flex: none; padding: 2px 8px; border: 1px solid var(--divider); border-radius: 4px; background: var(--tb-hover); font-family: inherit; font-size: 12px; line-height: 18px; color: var(--text); }

/* ---------- dark theme: black, like backtestingpro.com / TradingView dark ---------- */
body:not(.light) { --page: #2E2E2E; --bg: #0F0F0F; --panel: #1E1E1E; --panel2: #1E1E1E; --text: #DBDBDB; --muted: #8C8C8C; --hover: #2E2E2E; --border: #2E2E2E; --divider: #2E2E2E;
  --tb-hover: #2E2E2E; --tb-active: #3D3D3D; --pill: #2E2E2E; --pill-hover: #3D3D3D; --row-hover: #2E2E2E; }

/* ---------- left toolbar: one continuous panel like TradingView (thin lines between the groups) ---------- */
#drawbar { background: var(--bg) !important; gap: 0; }
.dt-card { padding: 0 0 6px; }
.dt-card:first-child { padding: 6px 0; }
.dt-card + .dt-card::before { content: ""; display: block; width: 36px; height: 1px; margin: 0 8px 6px; background: var(--divider); flex: none; }
/* the menu arrow: 11 × 34 on the right edge, shown on hover; hovering it highlights only the arrow */
.dt-btn .corner { right: 0; top: 2px; bottom: 2px; height: auto; width: 11px; transform: none; border-radius: 4px 0 0 4px; color: var(--muted); opacity: 0; transition: none; }
.dt-btn .corner svg { width: 4px; height: 7px; transform: none; }
.dt-group:hover .dt-btn .corner { opacity: 1; }
.dt-btn .corner:hover { background: var(--tb-hover); opacity: 1 !important; }
.dt-btn .corner:hover::after { display: none; }
.dt-btn:has(.corner:hover)::before { background: transparent !important; }
#drawbar .dt-btn.toggle.active:has(.corner:hover)::before { background: var(--toggle-on) !important; }
#drawbar .dt-btn.toggle.active .corner:hover { background: rgba(255,255,255,.2); }
@media (hover: none) { .dt-btn .corner { opacity: .6; } }

/* ---------- drawing settings window: TradingView layout ---------- */
.dset-linebox { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px 0 6px; border: 1px solid var(--divider); border-radius: 6px; background: var(--bg); color: var(--text); cursor: pointer; }
.dset-linebox:hover { border-color: var(--muted); }
.dset-lb-sw { width: 22px; height: 22px; border-radius: 4px; display: block; }
.dset-lb-line { display: flex; color: var(--text); }
.dset-end { width: 34px; height: 34px; margin-left: 6px; border: 1px solid var(--divider); border-radius: 6px; background: var(--bg); color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.dset-end.left svg { transform: scaleX(-1); }
.dset-end:hover { border-color: var(--muted); }
.dset-stats { text-align: left; min-width: 150px; cursor: pointer; }
.dset-statsmenu .menu-item { gap: 10px; cursor: pointer; }
.dset-more { min-width: 44px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--divider); border-radius: 6px; }
.dset-row .dset-l .check { margin: 0; }
.dset-range { width: 150px; accent-color: #2962FF; }
.fib-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; margin: 4px 0 12px; }
.fib-lv { display: flex; align-items: center; gap: 8px; }
.fib-lv input[type=number] { width: 0; flex: 1; min-width: 60px; height: 34px; }
.fib-lv input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--text); }
.fib-lv:has(input[type=checkbox]:not(:checked)) input[type=number] { opacity: .5; }
.dset-visrow .dset-c { display: flex; align-items: center; gap: 8px; }
.dset-visrow input[type=number] { width: 64px; height: 30px; }
.dset-vis-bar { flex: 1; min-width: 40px; height: 4px; border-radius: 2px; background: #2962FF; }
.cp-line { padding: 4px 2px 2px; }
.cp-sub { font-size: 12px; color: var(--muted); margin: 6px 0 4px; }
.cp-seg { display: flex; border: 1px solid var(--divider); border-radius: 6px; overflow: hidden; }
.cp-seg button { flex: 1; height: 32px; display: flex; align-items: center; justify-content: center; background: var(--bg); color: var(--text); border: 0; border-right: 1px solid var(--divider); cursor: pointer; }
.cp-seg button:last-child { border-right: 0; }
.cp-seg button:hover { background: var(--tb-hover); }
.cp-seg button.on { background: var(--tb-active); }

/* ---------- Remove objects menu and replay menus (TradingView) ---------- */
.rm-menu { min-width: 277px; }
.rm-menu .menu-item { min-height: 32px; font-size: 14px; }
.rm-switch { display: flex; align-items: center; gap: 12px; cursor: pointer; position: relative; }
.rm-switch span { flex: 1; }
.rm-switch input { position: absolute; opacity: 0; pointer-events: none; }
.rm-switch input:checked + .pm-switch { background: var(--text); }
.rm-switch input:checked + .pm-switch::after { transform: translateX(14px); background: var(--bg); }
.rb-pop .menu-item { min-width: 220px; }
.rb-pop .menu-item .key { margin-left: auto; padding-left: 24px; color: var(--muted); font-size: 12px; }
@media (max-width: 760px) {
  /* replay bar on phones: keep playback, interval, real-time and exit on one row */
  #replayBar > .rb-center { flex-wrap: nowrap; min-width: 0; gap: 0; }
  #replayBar .rb-center .rb-div { display: none; }
  #replayBar .rb-center .rb-btn.icon, #replayBar #rbRealtime, #replayBar #rbClose { width: 32px; min-width: 32px; padding: 0; }
  #replayBar .rb-center .rb-txt { padding: 0 6px; min-width: 0; }
}

/* ---------- Cross cursor: a crosshair pointer over the chart, like TradingView (not over the price / time scales) ---------- */
#chartWrap:not(.arrow-cursor):not(.dot-cursor):not(.eraser-cursor):not(.zoom-mode) #chart tr:not(:last-child) > td:nth-child(2) canvas { cursor: crosshair; }

/* ---------- left toolbar scrolls when it does not fit (TradingView: wheel / touch, strips at top and bottom) ---------- */
#drawbar { position: relative; overflow: hidden; display: block; padding: 0; }
.dt-scroll { height: 100%; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; display: flex; flex-direction: column; align-items: center; overscroll-behavior: contain; }
.dt-scroll::-webkit-scrollbar { display: none; }
.dt-sc { position: absolute; left: 0; width: 100%; height: 24px; z-index: 3; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; background: rgba(112,112,112,.6); color: #fff; cursor: pointer; transition: transform .15s ease; }
.dt-sc.up { top: 0; transform: translateY(-24px); }
.dt-sc.up svg { transform: rotate(180deg); }
.dt-sc.down { bottom: 0; transform: translateY(24px); }
#drawbar:hover .dt-sc.can { transform: none; }
@media (hover: none) { #drawbar .dt-sc.can { transform: none; } }
/* tool menus open beside the bar, outside the scrolling area */
#drawbar .flyout { position: fixed; left: 52px; }

/* dragging the chart: closed hand (TradingView) */
#chartWrap.grabbing #chart canvas, #chartWrap.grabbing #drawCanvas { cursor: grabbing !important; }

/* ---------- Bar replay bar: TradingView's one centred row (49px, thin top border), × at the right ---------- */
#replayBar { position: relative; display: flex; align-items: center; justify-content: center; height: 49px !important; padding: 0 8px !important; border-top: 1px solid var(--divider); background: var(--bg); flex-wrap: nowrap !important; overflow: hidden; }
#replayBar .rb-row { display: flex; align-items: center; height: 38px; min-width: 0; }
#replayBar .rb-btn { height: 38px; font-size: 14px; color: var(--text); }
#replayBar .rb-btn::before { inset: 2px 2px; }
#replayBar .rb-btn.icon { width: 38px; }
#replayBar #rbSelect { padding: 0 8px 0 5px; gap: 4px; }
#replayBar #rbSelect .ic svg { width: 28px; height: 28px; }
#replayBar .rb-caret { width: 24px; padding: 0; }
#replayBar .rb-caret svg { width: 8px; height: 4px; }
#replayBar .rb-sep { width: 41px; height: 38px; display: flex; align-items: center; justify-content: center; flex: none; }
#replayBar .rb-sep::after { content: ""; width: 1px; height: 22px; background: var(--divider); }
#replayBar #rbStep { margin-right: 0; }
#replayBar #rbSpeedBtn { margin-left: 0; }
#replayBar #rbClose { margin-left: 16px; }
#replayBar #rbClose .ic svg { width: 18px; height: 18px; }
/* wide screens: the × sits at the right end, the controls stay centred */
@media (min-width: 900px) { #replayBar #rbClose { position: absolute; right: 8px; top: 5px; margin: 0; } }
/* while cutting: Select bar is pressed, play / forward wait for the cut */
#replayBar.rb-selecting #rbSelect::before { background: var(--tb-active); }
#replayBar.rb-selecting #rbBack, #replayBar.rb-selecting #rbPlay, #replayBar.rb-selecting #rbStep { opacity: .35; pointer-events: none; }

/* ---------- cutting the market: no mouse pointer, scissors on a thin blue line (TradingView) ---------- */
#chartWrap.cutting #chart canvas, #chartWrap.cutting #drawCanvas { cursor: none !important; }
#replayCursor .line, #replayCursor .tip { display: none !important; }
#replayCursor .scissors { position: absolute; width: 20px; height: 20px; transform: translate(-50%, -50%); pointer-events: none; }
#replayCursor .scissors svg { display: block; }

/* ---------- Replay trading tab in the bottom panel ---------- */
.bp-replay-tab { display: none; }
body.replaying .bp-replay-tab { display: inline-flex; }
#bpanel.bp-auto .bp-body { height: auto; }
.bp-view[data-tab="replay"] { padding: 10px 14px 12px; }
.rt-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rt-row .rb-trade { height: 34px; min-width: 84px; padding: 0 18px; border-radius: 6px; font-size: 14px; font-weight: 600; color: #fff; }
.rt-row .rb-btn { height: 34px; padding: 0 12px; border: 1px solid var(--divider); border-radius: 6px; }
.rt-row .rb-btn::before { inset: 0; }
.rt-row .rb-date { margin-left: auto; color: var(--muted); font-size: 13px; }
.rt-stats { margin-top: 8px; font-size: 13px; color: var(--muted); }
.rt-stats b { color: var(--text); font-weight: 600; }
.rt-stats b.pos { color: var(--up); } .rt-stats b.neg { color: var(--down); }
@media (max-width: 760px) {
  #replayBar { justify-content: flex-start; }
  #replayBar .rb-row { width: 100%; justify-content: space-between; }
  #replayBar .rb-sep { width: 9px; }
  #replayBar .lbl { display: none; }
  #replayBar .rb-btn.icon { width: 34px; min-width: 34px; }
  #replayBar #rbClose { margin-left: 0; }
  .rt-row .rb-trade { flex: 1; }
}
/* the Replay trading tab is a slim strip under the chart (also on phones, so the replay bar stays visible) */
#bpanel.bp-auto .bp-body { flex: none; }
@media (max-width: 760px) {
  #bpanel.bp-auto:not(.collapsed) { position: relative; height: auto !important; box-shadow: none; border-radius: 0; z-index: auto; top: auto; }
  #bpanel.bp-auto .bp-tabs { overflow-x: auto; }
  .bp-view[data-tab="replay"] { padding: 6px 8px 8px; }
  .rt-row { gap: 6px; }
  .rt-row .rb-date { display: none; }
  .rt-stats { margin-top: 6px; font-size: 12px; }
}
@media (max-width: 760px) {
  .rt-row { flex-wrap: nowrap; }
  .rt-row .rb-trade { min-width: 0; padding: 0 10px; }
  .rt-row .rb-btn { padding: 0 8px; font-size: 13px; }
}

/* Premium window: which feature is Premium, what Premium unlocks, the member's status */
.prem-need { text-align: center; margin: 0 0 10px; }
.prem-list { list-style: none; margin: 0 auto 12px; padding: 0; width: max-content; max-width: 100%; }
.prem-list li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.prem-st { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.prem-st.ok { color: var(--up); font-weight: 600; }
#profileMenu .pm-row svg { width: 28px; height: 28px; flex: none; }

/* ---------- price scale gear (corner under the price scale) and scroll-to-latest button ---------- */
#scaleGear { position: absolute; z-index: 6; display: flex; align-items: center; justify-content: center; padding: 0; color: var(--muted); background: transparent; border-radius: 4px; }
#scaleGear:hover { color: var(--text); background: var(--tb-hover); }
#goLive { position: absolute; z-index: 6; width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; padding: 0; background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.2), 0 0 0 1px var(--divider); }
#goLive[hidden] { display: none; }
#goLive:hover { background: var(--tb-hover); }
.scale-pop .menu-item { min-height: 32px; }

/* ---------- Quick search (Ctrl + K), like TradingView's "Search tool or function" ---------- */
#qsBg { position: fixed; inset: 0; z-index: 200; background: var(--backdrop, rgba(0,0,0,.4)); display: flex; justify-content: center; align-items: flex-start; padding-top: 60px; }
#qsBox { width: 480px; max-width: calc(100vw - 24px); height: min(680px, calc(100vh - 80px)); background: var(--bg); color: var(--text); border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,.2), 0 8px 24px rgba(0,0,0,.25); display: flex; flex-direction: column; overflow: hidden; }
.qs-h { display: flex; align-items: center; padding: 16px 16px 10px 20px; font-size: 18px; }
.qs-h b { flex: 1; font-weight: 600; }
.qs-x { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 6px; color: var(--muted); }
.qs-x:hover { background: var(--tb-hover); color: var(--text); }
.qs-x svg { width: 20px; height: 20px; }
.qs-in { display: flex; align-items: center; gap: 8px; margin: 0 20px 8px; height: 40px; padding: 0 10px; border: 1px solid var(--divider); border-radius: 8px; }
.qs-in:focus-within { border-color: #2962FF; }
.qs-in svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.qs-in input { flex: 1; border: 0; outline: none; background: transparent; color: var(--text); font-size: 15px; }
.qs-list { flex: 1; overflow-y: auto; padding: 0 0 10px; }
.qs-empty { text-align: center; color: var(--muted); margin: 120px 24px 0; }
.qs-sec { padding: 12px 20px 4px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.qs-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 36px; padding: 0 20px; text-align: left; font-size: 14px; color: var(--text); background: none; }
.qs-row:hover, .qs-row.cur { background: var(--tb-hover); }
.qs-ic { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; flex: none; color: var(--text); }
.qs-ic svg { width: 28px; height: 28px; }
.qs-l { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qs-k { color: var(--muted); font-size: 12px; white-space: nowrap; }
.qs-on { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; background: var(--tb-hover); color: var(--muted); }
.qs-on.yes { background: rgba(41,98,255,.14); color: #2962FF; }

/* ---------- chart page rebuilt to TradingView's measurements (1280px wide) ---------- */
/* bottom panel: closed = gone (TradingView), opened from the right strip; the chart gets the space */
#bpanel.collapsed { display: none; }
/* top bar: Indicators / Alert / Replay show their names on wide screens, like TradingView */
#alertBtn .lbl, #indicatorsBtn .lbl, #replayBtn .lbl { display: none; }
@media (min-width: 1200px) {
  #indicatorsBtn, #replayBtn, #alertBtn { font-size: 14px !important; width: auto !important; padding: 0 10px 0 5px !important; gap: 4px !important; }
  #alertBtn .lbl, #indicatorsBtn .lbl, #replayBtn .lbl { display: inline; }
  #indicatorsBtn .fx { margin: 0 2px 0 4px; }
}
/* right strip: 45px wide, 44 x 44 buttons */
#rightstrip { width: 45px; }
#rightstrip .rs-btn { width: 44px; height: 44px; }
#ranges { padding-left: 4px; }
/* legend 4px from the chart corner, 24px row (TradingView) */
@media (min-width: 761px) { #legend { left: 4px; top: 4px; } #legend .lg-main { min-height: 24px; } }
/* licence credit for the charting library (replaces the logo on the chart) */
.pm-credit { display: block; padding: 8px 12px 4px; font-size: 11px; color: #787b86; text-decoration: none; }
.pm-credit:hover { text-decoration: underline; }

/* Demonstration cursor: an arrow with a soft halo that follows the mouse; Magic: a fading laser trail */
#chartWrap.demo-cursor #chart canvas, #chartWrap.magic-cursor #chart canvas { cursor: default !important; }
#demoHalo { position: absolute; z-index: 7; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; pointer-events: none; background: rgba(255, 193, 7, .28); box-shadow: 0 0 0 2px rgba(255, 193, 7, .55); transition: transform .12s; }
#demoHalo.down { transform: scale(.75); background: rgba(255, 152, 0, .4); }
#magicCanvas { position: absolute; inset: 0; z-index: 7; pointer-events: none; }

/* ---------- top bar like TradingView's ---------- */
#themeBtn, #premiumBtn, #userArea { display: none !important; }   /* theme and sign in live in the profile menu */
@media (min-width: 761px) { #moreDD { display: none !important; } }
.tb-split { display: flex; align-items: center; }
.tb-caret { width: 24px !important; min-width: 24px; padding: 0 !important; justify-content: center; }
.tb-caret svg { width: 18px; height: 18px; }
#indicatorsBtn .ic svg, #alertBtn .ic svg, #replayBtn .ic svg { width: 28px; height: 28px; }
.layout-name { flex-direction: column; align-items: flex-start !important; justify-content: center; gap: 0 !important; padding: 0 6px !important; line-height: 1.1; height: 38px; }
.layout-name .ln-name { font-size: 14px; color: var(--text); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layout-name .ln-sub { font-size: 11px; color: #2962FF; }
.trade-btn { height: 30px !important; padding: 0 14px !important; margin: 0 4px 0 6px; border: 1px solid var(--divider) !important; border-radius: 15px !important; background: transparent !important; color: var(--text) !important; font-weight: 500; }
.trade-btn::before { display: none; }
.trade-btn:hover { background: var(--tb-hover) !important; }
#bottombar #gotoDateBtn, #bottombar #back1mBtn { width: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
#bottombar #gotoDateBtn .ic svg, #bottombar #back1mBtn .ic svg { width: 22px; height: 22px; }
@media (max-width: 1200px) { #layoutSplit, #layoutSetupBtn { display: none; } }
@media (max-width: 760px) { .tb-caret, #layoutSplit, #layoutSetupBtn, #settingsBtn { display: none !important; } .trade-btn { padding: 0 10px !important; } }
@media (min-width: 1101px) { #settingsBtn { display: inline-flex !important; } }
@media (max-width: 760px) { #tradeBtn { display: none !important; } }

/* ---------- multi-chart layouts (Layout setup) ---------- */
#chartGrid { flex: 1; position: relative; min-height: 0; background: var(--divider); }
#chartGrid > #chartWrap, #chartGrid > .gcell { position: absolute; }
#chartGrid.single > #chartWrap { inset: 0 !important; }
.gcell { overflow: hidden; background: var(--bg); }
.gcell .gc-chart { position: absolute; inset: 0; }
.gc-legend { position: absolute; left: 8px; top: 6px; z-index: 3; display: flex; align-items: center; gap: 2px; font-size: 13px; color: var(--text); pointer-events: none; max-width: calc(100% - 70px); white-space: nowrap; overflow: hidden; }
.gc-legend button { pointer-events: auto; background: transparent; border: 1px solid transparent; color: var(--text); font: inherit; padding: 2px 6px; border-radius: 4px; cursor: pointer; }
.gc-legend button:hover { border-color: var(--divider); background: var(--tb-hover); }
.gc-legend .gc-sym { font-weight: 600; }
.gc-legend .gc-ohlc { margin-left: 6px; font-size: 12px; color: var(--muted, #787B86); }
.gc-legend .gc-ohlc b { font-weight: 400; margin-right: 6px; }
.gc-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted, #787B86); font-size: 13px; z-index: 2; pointer-events: none; }
/* the menu */
.ls-menu { padding: 6px 0; min-width: 300px; }
.ls-row { display: flex; align-items: center; padding: 2px 12px; }
.ls-n { width: 26px; flex: none; font-size: 13px; color: var(--text); }
.ls-icons { display: flex; flex-wrap: nowrap; gap: 0; }
.ls-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--text); border-radius: 6px; cursor: pointer; padding: 0; }
.ls-btn:hover { background: var(--tb-hover); }
.ls-btn.on { background: #FFFFFF; color: #131722; }
body.light .ls-btn.on { background: #131722; color: #FFFFFF; }
.ls-btn svg { width: 26px; height: 26px; }
.ls-sep { height: 1px; background: var(--divider); margin: 6px 0; }
.ls-sec { padding: 6px 12px 4px; font-size: 11px; letter-spacing: .4px; color: var(--muted, #787B86); text-transform: uppercase; }
.ls-sync { display: flex; align-items: center; justify-content: space-between; padding: 7px 12px; font-size: 14px; color: var(--text); cursor: pointer; }
.ls-sync:hover { background: var(--tb-hover); }
.ls-sw { width: 34px; height: 18px; border-radius: 9px; background: #4A4A4A; position: relative; flex: none; transition: background .15s; }
.ls-sw::after { content: ''; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #FFFFFF; transition: left .15s; }
.ls-sync.on .ls-sw { background: #2962FF; }
.ls-sync.on .ls-sw::after { left: 18px; }
/* phones show one chart, like TradingView's app */
@media (max-width: 760px) { #chartGrid > .gcell { display: none !important; } #chartGrid > #chartWrap { inset: 0 !important; } }

/* selected drawing tool: blue icon on a dark blue square, like TradingView */
#drawbar .dt-group .dt-btn.active:not(.toggle) { color: #2962FF; }
#drawbar .dt-group .dt-btn.active:not(.toggle)::before { background: rgba(41,98,255,.15); }
body.light #drawbar .dt-group .dt-btn.active:not(.toggle)::before { background: rgba(41,98,255,.12); }

/* ---------- dark theme: pure black top, left, right and bottom bars with #222222 gaps (backtestingpro.com) ---------- */
body:not(.light) { --page: #222222; --bg: #000000; }
body:not(.light) #bottombar { border-top-color: #222222; }

/* ---------- top bar like the backtestingpro.com screenshot ---------- */
#compareBtn, #indFavBtn, #indicatorsBtn .lbl, #alertBtn .lbl, #replayBtn .lbl, .layout-name .ln-sub { display: none !important; }
#indicatorsBtn, #alertBtn, #replayBtn { width: 38px; padding: 0 !important; justify-content: center; }
.layout-name .ln-name { font-size: 15px; max-width: 150px; }
#layoutMenuBtn svg { width: 22px; height: 22px; stroke-width: 1.6; }
.trade-btn { border: 0 !important; border-radius: 0 !important; padding: 0 8px !important; margin: 0 2px; font-size: 15px; }
#premiumBtn:not([hidden]) { display: inline-flex !important; align-items: center; height: 30px !important; padding: 0 14px !important; margin: 0 2px 0 4px; border-radius: 15px !important; background: #FFFFFF !important; color: #000000 !important; font-size: 15px; font-weight: 500; }
#premiumBtn::before { display: none; }
#premiumBtn:hover { background: #E6E6E6 !important; }
body.light #premiumBtn:not([hidden]) { background: #000000 !important; color: #FFFFFF !important; }
.tf-caret { display: none; color: #787B86; }
@media (min-width: 1101px) {
  #tfButtons { display: flex !important; gap: 0; }
  #tfPhoneBtn { min-width: 0; padding: 0 6px; gap: 6px; }
  #tfPhoneBtn.is-fav .tf-val { display: none; }
  .tf-caret { display: inline-flex; }
}
.tf-btn { padding: 0 11px; font-size: 15px; }
.tf-btn.active { color: #2962FF; }
.tf-btn.active::before { inset: 0; border-radius: 0; background: #2E2E2E; }
body.light .tf-btn.active::before { background: var(--tb-active); }
#indicatorsBtn, #alertBtn, #replayBtn { width: 38px !important; min-width: 38px; }
#premiumBtn:not([hidden]) { flex: none; width: auto !important; min-width: 0; white-space: nowrap; } #premiumBtn .lbl { display: inline !important; } #tradeBtn { flex: none; }
@media (max-width: 760px) { #premiumBtn, #premiumBtn:not([hidden]) { display: none !important; } }
.keys-sec { padding: 12px 4px 4px; font-size: 11px; letter-spacing: .4px; text-transform: uppercase; color: var(--muted, #787B86); }

/* ---------- watchlist like TradingView's ---------- */
.wl-head { gap: 2px; padding: 0 6px 0 8px; }
.wl-name { display: flex; align-items: center; gap: 2px; height: 30px; padding: 0 6px; border-radius: 4px; font-weight: 600; font-size: 15px; color: var(--text); background: none; max-width: 170px; }
.wl-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wl-name:hover { background: var(--hover); }
.wl-head #wlAdd { margin-left: auto; }
.wl-head .wl-more { margin-left: 2px; }
#sidebar .wl-cols, #sidebar .wl-row { grid-template-columns: var(--wl-cols, minmax(0,1fr) 84px 64px 64px); }
.wl-cols { padding: 0 12px 0 14px; border-bottom: 1px solid var(--divider); }
.wl-cols button { background: none; color: var(--muted); font-size: 12px; text-align: right; padding: 0; height: 28px; cursor: pointer; }
.wl-cols button:first-child { text-align: left; }
.wl-cols button:hover, .wl-cols button.on { color: var(--text); }
#watchlist { outline: none; }
.wl-row { position: relative; padding: 0 12px 0 14px; font-size: 13px; }
.wl-row > span:not(.wl-symcell):not(.wl-flag) { text-align: right; white-space: nowrap; }
.wl-symcell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wl-logo { width: 18px; height: 18px; border-radius: 50%; color: #fff; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.wl-logo.big { width: 34px; height: 34px; font-size: 16px; }
.wl-flag { position: absolute; left: 0; top: 0; bottom: 0; width: 6px; cursor: pointer; }
.wl-flag[style]::before { content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 0 2px 2px 0; background: var(--flag); }
.wl-row:hover .wl-flag:not([style])::before { content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: 0 2px 2px 0; background: var(--muted); opacity: .45; }
.wl-x { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; display: none; align-items: center; justify-content: center; border-radius: 4px; color: var(--muted); background: var(--row-hover, var(--hover)); }
.wl-x svg { width: 16px; height: 16px; }
.wl-row:hover .wl-x { display: flex; }
.wl-x:hover { color: var(--text); }
.wl-row.dragging { opacity: .4; }
.wl-drop { box-shadow: inset 0 2px 0 #2962FF; }
.wl-last.wl-up { animation: wlUp 1s; }
.wl-last.wl-down { animation: wlDown 1s; }
@keyframes wlUp { from { color: #089981; } }
@keyframes wlDown { from { color: #F23645; } }
.wl-sec { display: flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; padding: 10px 12px 4px 8px; font-weight: 600; }
.wl-sec:hover { color: var(--text); }
.wl-chev { display: inline-flex; transition: transform .15s; }
.wl-chev svg { width: 16px; height: 16px; }
.wl-sec.closed .wl-chev { transform: rotate(-90deg); }
.wl-empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.6; }
.wl-flag-dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 8px; }
#wlSplit { height: 5px; flex: none; cursor: row-resize; border-top: 1px solid var(--divider); }
#wlSplit:hover { background: rgba(41,98,255,.3); }
#wlDetails { height: 300px; flex: none; overflow-y: auto; padding: 10px 14px 14px; }
#wlDetails[hidden], #wlSplit[hidden] { display: none; }
.wd-top { display: flex; align-items: center; gap: 10px; }
.wd-sym { font-weight: 600; font-size: 15px; }
.wd-name { font-size: 12px; color: var(--muted); }
.wd-price { margin: 10px 0 12px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.wd-price b { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.wd-price span { font-size: 14px; }
.wd-range { margin: 0 0 12px; }
.wd-rl { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; font-variant-numeric: tabular-nums; }
.wd-bar { position: relative; height: 4px; border-radius: 2px; background: var(--divider); }
.wd-bar i { position: absolute; top: -3px; width: 2px; height: 10px; margin-left: -1px; background: var(--text); border-radius: 1px; }
.wd-sec { font-size: 12px; color: var(--muted); margin: 4px 0 6px; }
.wd-perf { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.wd-perf div { border-radius: 4px; padding: 7px 4px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.wd-perf b { font-size: 13px; font-weight: 600; }
.wd-perf span { font-size: 11px; opacity: .8; }
.wd-perf .up { background: rgba(8,153,129,.15); color: #089981; }
.wd-perf .down { background: rgba(242,54,69,.15); color: #F23645; }

/* ---------- layout name: "Save" while there are unsaved changes (TradingView) ---------- */
#layoutNameBtn.dirty .ln-sub { display: block !important; }
#layoutNameBtn.dirty .ln-name { font-size: 14px; }

/* ---------- Premium badge and billing ---------- */
.prem-badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px 0 8px; border-radius: 12px; font-size: 12px; font-weight: 700; letter-spacing: .06em; color: #FFFFFF; background: linear-gradient(135deg, #F7B500 0%, #E8840C 100%); box-shadow: 0 1px 6px rgba(232,132,12,.35); white-space: nowrap; flex: none; }
.prem-badge.off { color: #F7B500; background: transparent; box-shadow: inset 0 0 0 1.5px #F7B500; }
.pm-plan { gap: 10px; }
.pm-plan small { margin-left: auto; }
.inv-plan { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 10px; background: var(--hover); margin-bottom: 18px; }
.inv-plan.on { background: linear-gradient(135deg, rgba(247,181,0,.16), rgba(232,132,12,.08)); box-shadow: inset 0 0 0 1px rgba(247,181,0,.35); }
.inv-plan-t { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.inv-plan-t b { font-size: 15px; }
.inv-plan-t span { font-size: 13px; color: var(--muted); }
.inv-h { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 8px; }
.inv-list { display: flex; flex-direction: column; }
.inv-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--divider); }
.inv-row:last-child { border-bottom: 0; }
.inv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.inv-main span { font-size: 12px; color: var(--muted); }
.inv-amt { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.inv-paid { font-size: 11px; font-weight: 700; color: #089981; text-transform: uppercase; letter-spacing: .05em; }
.inv-empty { color: var(--muted); font-size: 13px; padding: 12px 0; }

/* ---------- Premium badge: light grey tag, slanted right edge, bold black text ---------- */
.prem-badge { display: inline-flex; align-items: center; height: 16px; padding: 0 9px 0 6px; border-radius: 3px; background: #DBDBDB; color: #000000; font: 700 10.5px/16px "Segoe UI", Tahoma, Arial, sans-serif; letter-spacing: 0; text-transform: uppercase; white-space: nowrap; flex: none; box-shadow: none; clip-path: polygon(0 0, 100% 0, calc(100% - 4px) 100%, 0 100%); }
.prem-badge.off { background: #DBDBDB; color: #000000; box-shadow: none; }
.pm-plan .prem-badge { transform: scale(1.15); transform-origin: left center; margin-right: 8px; }
.inv-plan .prem-badge { transform: scale(1.3); transform-origin: left center; margin-right: 18px; }

/* ---------- Indicators window and settings (TradingView) ---------- */
.indw { display: flex; height: min(62vh, 540px); margin: -16px -18px; }
.indw-side { width: 190px; flex: none; border-right: 1px solid var(--divider); padding: 8px 0; overflow-y: auto; }
.indw-cat { display: flex; align-items: center; gap: 6px; width: 100%; height: 34px; padding: 0 16px; background: none; border: 0; color: var(--text); font-size: 14px; text-align: left; cursor: pointer; }
.indw-cat .ic svg { width: 18px; height: 18px; color: #F7B500; }
.indw-cat:hover { background: var(--hover); }
.indw-cat.on { background: var(--row-sel, rgba(41,98,255,.2)); }
.indw-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.indw-search { margin: 10px 12px; }
.indw-list { flex: 1; overflow-y: auto; }
.indw-row { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px 0 6px; cursor: pointer; font-size: 14px; }
.indw-row:hover { background: var(--hover); }
.indw-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.indw-t { font-size: 12px; color: var(--muted); }
.indw-star { width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 0; color: var(--muted); cursor: pointer; opacity: 0; }
.indw-row:hover .indw-star, .indw-star.on { opacity: 1; }
.indw-star.on { color: #F7B500; }
.indw-star svg { width: 18px; height: 18px; }
.indw-empty { color: var(--muted); padding: 20px 16px; font-size: 13px; }
.ind-set .dset-tabs { margin: -6px 0 12px; }
.ind-pane { min-height: 120px; max-height: 55vh; overflow-y: auto; }
.ind-foot { display: flex; gap: 8px; margin-top: 14px; }
.ind-col { width: 34px; height: 26px; padding: 0; border: 1px solid var(--divider); border-radius: 4px; background: none; cursor: pointer; }
.ind-w { width: 70px; height: 28px; margin-left: 6px; }
@media (max-width: 760px) { .indw { flex-direction: column; height: 70vh; } .indw-side { width: auto; display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--divider); padding: 0; } .indw-cat { width: auto; white-space: nowrap; } }

/* ---------- pane buttons, scale buttons, symbol info ---------- */
#paneCtrls { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.pane-ctrl { position: absolute; display: flex; gap: 2px; opacity: 0; transition: opacity .15s; pointer-events: auto; }
#chartWrap:hover .pane-ctrl { opacity: 1; }
.pane-ctrl button { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; background: var(--bg); color: var(--text); border: 1px solid var(--divider); cursor: pointer; }
.pane-ctrl button:hover { background: var(--tb-hover); }
#scaleBtns { display: flex; gap: 0; margin-right: 6px; }
#scaleBtns .bb-btn { min-width: 30px; padding: 0 6px; font-size: 13px; }
#scaleBtns .bb-btn.on { color: #2962FF; }
.sym-info { width: 300px; padding: 12px 14px; }
.si-head { display: flex; flex-direction: column; margin-bottom: 8px; }
.si-head b { font-size: 16px; }
.si-head span { color: var(--muted); font-size: 13px; }
.si-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 13px; border-top: 1px solid var(--divider); }
.si-row span { color: var(--muted); }
.si-row b { font-weight: 500; text-align: right; }
@media (max-width: 760px) { #scaleBtns { display: none; } }

#lockLine { position: absolute; top: 0; width: 0; border-left: 1px dashed var(--muted, #787B86); pointer-events: none; z-index: 4; }
.indw-save { color: #2962FF; padding-left: 12px; }
.indw-save .ic svg { width: 20px; height: 20px; }
.indw-row .indw-t { max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.indw-del { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 0; color: var(--muted); cursor: pointer; opacity: 0; }
.indw-row:hover .indw-del { opacity: 1; }
.indw-del svg { width: 16px; height: 16px; }

/* ---------- Create alert (TradingView's fields) ---------- */
.al2 .al-sym { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.al2 .al-sym b { font-size: 16px; }
.al2 .field[hidden] { display: none; }
.al2 textarea.input { height: auto; min-height: 54px; padding-top: 6px; resize: vertical; font: inherit; }
.al2 .al-open { display: block; margin: -4px 0 10px; font-size: 13px; }
.al-notif { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin: 4px 0 12px; font-size: 13px; }
.al-notif .muted { width: 100%; }

/* ---------- Settings: pane buttons, replay background, last day change ---------- */
#chartWrap.pane-btns-always .pane-ctrl { opacity: 1; }
#chartWrap.pane-btns-hidden .pane-ctrl { display: none; }
body.replaying #chartWrap.replay-bg #chart::after { content: ''; position: absolute; inset: 0; background: rgba(41,98,255,.05); pointer-events: none; z-index: 1; }
.lg-day { margin-left: 6px; }
.lg-day b { margin-left: 4px; font-weight: 500; }
