/* ============================================================
   Crypto Charting Pro — styles (dark + light themes)
   ============================================================ */
:root {
  --topbar-h: 44px;
  --green: #26a69a; --red: #ef5350;
}

/* ----- Dark themes ----- */
html[data-theme="dark-classic"] {
  --bg: #131722; --panel: #1e222d; --panel2: #2a2e39; --border: #2a2e39;
  --text: #d1d4dc; --muted: #787b86; --accent: #2962ff; --accent-strong: #1a44b8;
  --hover: #2a2e39;
}
html[data-theme="dark-midnight"] {
  --bg: #0c1a2b; --panel: #102338; --panel2: #173451; --border: #1d3a57;
  --text: #cdd9e5; --muted: #6f86a0; --accent: #3b82f6; --accent-strong: #1d5bcc;
  --hover: #173451;
}
html[data-theme="dark-matrix"] {
  --bg: #0a0f0a; --panel: #101a10; --panel2: #162615; --border: #1c361a;
  --text: #c8f7c5; --muted: #5e8a5b; --accent: #22c55e; --accent-strong: #15843c;
  --hover: #162615;
}
html[data-theme="dark-carbon"] {
  --bg: #16181d; --panel: #1d1f26; --panel2: #282b34; --border: #33373f;
  --text: #cfd2d8; --muted: #80858f; --accent: #a78bfa; --accent-strong: #6d4fd6;
  --hover: #282b34;
}

/* ----- Light themes ----- */
html[data-theme="light-classic"] {
  --bg: #f0f3fa; --panel: #ffffff; --panel2: #f0f3fa; --border: #e0e3eb;
  --text: #131722; --muted: #787b86; --accent: #2962ff; --accent-strong: #1a44b8;
  --hover: #eef0f4;
}
html[data-theme="light-warm"] {
  --bg: #fbf7f0; --panel: #fffdf8; --panel2: #f3ecdf; --border: #d9cab2;
  --text: #3b3022; --muted: #998a72; --accent: #c2761c; --accent-strong: #8f520e;
  --hover: #f1e7d6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 13px; overflow: hidden;
  display: flex; flex-direction: column;
}
button { font-family: inherit; cursor: pointer; color: var(--text); background: transparent; border: none; }
input, select { font-family: inherit; background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; outline: none; }
input:focus, select:focus { border-color: var(--accent); }
.muted { color: var(--muted); padding: 12px; text-align: center; font-size: 12px; }
.up { color: var(--green); } .down { color: var(--red); }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h); min-height: var(--topbar-h);
  background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 10px; gap: 10px;
}
.tb-group { display: flex; align-items: center; gap: 4px; }
.tb-group.right { margin-left: auto; }
.logo { font-size: 11px; margin-right: 8px; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.logo b { color: var(--accent); }
.logo-icon { width: 32px; height: 32px; border-radius: 6px; }
.tb-btn {
  padding: 6px 10px; border-radius: 5px; font-size: 13px; position: relative;
  border: 1px solid transparent;
}
.tb-btn:hover { background: var(--hover); }
.tb-btn:disabled { opacity: .6; cursor: default; }
#refreshAllBtn { font-size: 16px; line-height: 1; }
#refreshAllBtn.spinning { animation: tb-spin .7s linear infinite; }
@keyframes tb-spin { to { transform: rotate(360deg); } }
.layouts { background: var(--panel2); border-radius: 6px; padding: 2px; }
.layout-opt { padding: 5px 9px; border-radius: 4px; font-size: 11px; letter-spacing: -2px; }
.layout-opt.active { background: var(--accent); color: #fff; }
.badge {
  position: absolute; top: -2px; right: -2px; background: var(--red); color: #fff;
  font-size: 9px; min-width: 15px; height: 15px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
.ws-conn { display: inline-flex; align-items: center; gap: 5px; padding: 0 4px; }
.ws-exchange { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: 0.02em; }
.ws-status { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.ws-status.connected { background: var(--green); }
.ws-conn:has(.ws-status.connected) .ws-exchange { color: var(--text); }
.ws-status.error { background: var(--red); }

/* ---------- App layout ---------- */
.app-main { flex: 1; display: flex; min-height: 0; }
.panel-search { margin: 8px; width: calc(100% - 16px); }
.ind-list { flex: 1; overflow-y: auto; padding: 0 6px; }
.ind-item {
  display: grid; grid-template-columns: 20px auto 1fr; align-items: center; gap: 6px;
  width: 100%; text-align: left; padding: 6px 6px; border-radius: 5px;
}
.ind-item:hover { background: var(--hover); }
.ind-tag { width: 18px; height: 18px; border-radius: 4px; font-size: 10px; display: flex; align-items: center; justify-content: center; color: #fff; }
.ind-tag.overlay { background: var(--accent); }
.ind-tag.oscillator { background: #9c27b0; }
.ind-name { font-weight: 600; }
.ind-full { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Indicator hover tooltip (custom, floats over the chart area) */
.ind-tooltip {
  position: fixed; z-index: 1000; width: 250px; max-width: 80vw;
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  pointer-events: none; opacity: 0; transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}
.ind-tooltip.show { opacity: 1; transform: translateY(0); }
.ind-tt-title { font-weight: 700; font-size: 12px; margin-bottom: 4px; }
.ind-tt-desc { font-size: 11px; line-height: 1.45; color: var(--muted); }
/* ---------- Left panel: active indicators on the current chart ---------- */
.left-panel {
  width: 150px; min-width: 110px; max-width: 200px; flex: none;
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.left-panel.collapsed { width: 0; min-width: 0; border: none; }
.left-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 8px 10px; border-bottom: 1px solid var(--border); flex: none;
}
.left-panel-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ind-add-btn {
  width: 20px; height: 20px; border-radius: 5px; font-size: 15px; line-height: 1;
  display: flex; align-items: center; justify-content: center; color: var(--text);
}
.ind-add-btn:hover { background: var(--hover); }
.left-ind-chips {
  flex: 1; display: flex; flex-direction: column; gap: 6px;
  overflow-y: auto; overflow-x: hidden; padding: 8px;
  scrollbar-width: thin;
}
.left-ind-chips::-webkit-scrollbar { width: 5px; }
.left-ind-chips::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.left-ind-chips:empty::after { content: 'No indicators yet — tap + to add'; color: var(--muted); font-size: 11px; line-height: 1.4; }
.ind-chip { width: 100%; display: flex; align-items: center; gap: 5px; background: var(--panel2); border: 1px solid var(--border); border-radius: 14px; padding: 3px 6px 3px 8px; font-size: 11px; white-space: nowrap; }
.chip-dot { width: 8px; height: 8px; border-radius: 50%; cursor: pointer; flex: none; }
.chip-name { cursor: pointer; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.ind-chip.inactive { opacity: 0.45; }
.ind-chip.inactive .chip-name { text-decoration: line-through; }
.chip-x { color: var(--muted); font-size: 14px; line-height: 1; flex: none; }
.chip-x:hover { color: var(--red); }

/* ---------- Drawing toolbar ---------- */
.draw-toolbar {
  width: 55px; min-width: 55px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; overflow-y: auto;
}
.draw-toolbar #drawColor { width: 35px; height: 35px; padding: 0; border-radius: 6px; cursor: pointer; }
.draw-tool {
  width: 40px; height: 40px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.draw-tool svg { display: block; flex-shrink: 0; }
.draw-tool:hover { background: var(--hover); color: var(--text); }
.draw-tool.active { background: var(--accent); color: #fff; }
.draw-tool.clear { margin-top: auto; }

/* ---------- Charts area ---------- */
.charts-area { flex: 1; overflow: auto; display: grid; gap: 2px; background: var(--border); min-width: 0; }
.charts-area.layout-l1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.charts-area.layout-l2h { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.charts-area.layout-l2v { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
.charts-area.layout-l4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.charts-area.layout-l6 { grid-template-columns: 1fr 1fr 1fr; grid-template-rows: 1fr 1fr; }
.charts-area.layout-l8 { grid-template-columns: 1fr 1fr 1fr 1fr; grid-template-rows: 1fr 1fr; }

.chart-panel {
  background: var(--bg); display: flex; flex-direction: column; min-width: 320px; min-height: 300px;
  position: relative; border: 1px solid transparent;
}
.chart-panel.active { border-color: var(--accent); }
.chart-panel.panel-fullscreen { position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 90; }
.panel-bar {
  height: 36px; min-height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 8px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.sym-btn { font-weight: 700; font-size: 14px; padding: 4px 8px; border-radius: 5px; }
.sym-btn:hover { background: var(--hover); }
.sym-quote { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 2px; }
.panel-sym-price {
  font-weight: 800; font-size: 18px; line-height: 1; color: var(--text); letter-spacing: -0.2px;
  transition: color var(--duration-fast, 150ms) ease;
  /* Constant-width live readout: tabular digits + nowrap so a price tick can
     never change the element's width and reflow the rest of the panel bar. */
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.panel-sym-price:empty { display: none; }
.panel-sym-price.up { color: var(--green); }
.panel-sym-price.down { color: var(--red); }
.tf-group { display: flex; gap: 1px; }
.tf-btn { padding: 4px 7px; font-size: 11px; border-radius: 4px; color: var(--muted); }
.tf-btn:hover { background: var(--hover); color: var(--text); }
.tf-btn.active { background: var(--accent); color: #fff; }
.ohlc-info { font-size: 11px; margin-left: 6px; flex: 1; overflow: hidden; white-space: nowrap; }
.panel-act { width: 26px; height: 26px; border-radius: 5px; color: var(--muted); }
.panel-act:hover { background: var(--hover); color: var(--text); }
.panel-menu-btn { margin-left: auto; position: relative; }
.panel-menu-btn.has-active::after {
  content: ''; position: absolute; top: 2px; right: 2px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}

.panel-body { flex: 1; position: relative; display: flex; flex-direction: column; min-height: 0; }
.main-chart-div { flex: 1; min-height: 200px; position: relative; }
.main-osc-resize { height: 5px; cursor: row-resize; flex-shrink: 0; }
.main-osc-resize:hover { background: var(--accent); opacity: .5; }
.osc-wrap { height: 0; display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.osc-pane { flex: 1; min-height: 90px; position: relative; border-top: 1px solid var(--border); }
.osc-pane.dragging { opacity: 0.45; }
.osc-pane.drop-above { box-shadow: inset 0 2px 0 0 var(--accent); }
.osc-pane.drop-below { box-shadow: inset 0 -2px 0 0 var(--accent); }
.osc-label { position: absolute; top: 2px; left: 6px; z-index: 5; font-size: 10px; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: grab; }
.osc-label:active { cursor: grabbing; }
.osc-drag { color: transparent; font-size: 11px; line-height: 1; user-select: none; }
.osc-pane:hover .osc-drag { color: var(--muted); }
.osc-close { color: var(--muted); font-size: 12px; }
.osc-close:hover { color: var(--red); }
.osc-chart { width: 100%; height: 100%; }
.osc-resize { position: absolute; z-index: 6; top: -3px; left: 0; right: 0; height: 7px; cursor: row-resize; }
.osc-resize:hover { background: var(--accent); opacity: .5; }
.vol-profile-layer, .drawing-layer { position: absolute; inset: 0; pointer-events: none; }
.vol-profile-layer { z-index: 4; }
.drawing-layer { z-index: 8; }
.draw-canvas { position: absolute; left: 0; top: 0; touch-action: none; } /* P3-25: don't let the browser scroll/zoom while drawing with a finger */

.panel-error {
  position: absolute; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 20; text-align: center;
}
.retry-btn, .primary-btn { background: var(--accent); color: #fff; padding: 7px 14px; border-radius: 5px; margin-top: 8px; }
.primary-btn:hover, .retry-btn:hover { filter: brightness(1.1); }

/* ---------- Splitter ---------- */
.panel-splitter { width: 4px; cursor: col-resize; background: var(--border); }
.panel-splitter:hover, .panel-splitter.dragging { background: var(--accent); }

/* ---------- Right panel ---------- */
.right-panel {
  width: 310px; min-width: 200px; background: var(--panel); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
}
.right-panel.collapsed { width: 0; min-width: 0; border: none; }
.right-tabs { display: flex; border-bottom: 1px solid var(--border); }
.right-tab { flex: 1; padding: 9px 4px; font-size: 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.right-tab:hover { color: var(--text); }
.right-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.right-tab-content { display: none; flex: 1; flex-direction: column; overflow: hidden; min-height: 0; }
.right-tab-content.active { display: flex; }

.market-status { padding: 10px 10px 6px; border-bottom: 1px solid var(--border); flex: none; }
.market-status .muted { padding: 6px 0; }
.ms-row + .ms-row { margin-top: 8px; }
.ms-label { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--muted); }
.ms-value { font-size: 12px; font-weight: 600; color: var(--text); }
.ms-meter { height: 5px; border-radius: 3px; background: var(--panel2); margin-top: 4px; overflow: hidden; }
.ms-meter-fill { height: 100%; border-radius: 3px; transition: width .4s ease; }
.ms-sub { font-size: 10px; color: var(--muted); margin-top: 2px; }
.ms-stats { display: flex; gap: 6px; margin-top: 10px; }
.ms-stat { flex: 1; background: var(--panel2); border-radius: 6px; padding: 5px 6px; text-align: center; }
.ms-stat-label { display: block; font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.ms-stat-value { display: block; font-size: 11px; font-weight: 600; color: var(--text); margin-top: 2px; white-space: nowrap; }

.sym-search-wrap { position: relative; padding: 8px; }
.sym-search-wrap .panel-search { margin: 0; }
.sym-search-results {
  display: none; position: absolute; left: 8px; right: 8px; top: 44px; z-index: 30;
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px; max-height: 280px; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.search-res { padding: 8px 10px; cursor: pointer; font-weight: 600; }
.search-res span { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 3px; }
.search-res:hover { background: var(--hover); }

.wl-tabs { display: flex; gap: 4px; padding: 0 8px 8px; overflow-x: auto; }
.wl-tab { padding: 5px 10px; font-size: 12px; border-radius: 5px; color: var(--muted); white-space: nowrap; background: var(--panel2); }
.wl-tab.active { background: var(--accent); color: #fff; }
.wl-tab { cursor: grab; }
.wl-tab.dragging { opacity: 0.45; cursor: grabbing; }
.wl-tab.drop-before { box-shadow: inset 2px 0 0 0 var(--accent); }
.wl-tab.drop-after { box-shadow: inset -2px 0 0 0 var(--accent); }
.sym-list-head, .sym-row {
  display: grid; grid-template-columns: 16px 14px 1fr 44px 70px 52px 18px; align-items: center; gap: 4px; padding: 5px 8px;
}
.sym-list-head { font-size: 10px; color: var(--muted); text-transform: uppercase; border-bottom: 1px solid var(--border); }
.sym-list-head .col { cursor: pointer; }
.sym-list-head .col.num { text-align: right; }
.sym-list-head .col.sorted { color: var(--accent); }
/* Reserve a stable scrollbar gutter so the rows never shift left under the
   header when a vertical scrollbar appears. The header is padded to match the
   gutter width via --sb-w (measured in JS) so numeric columns stay right-aligned. */
.sym-list { flex: 1; overflow-y: auto; scrollbar-gutter: stable; }
.sym-list-head { padding-right: calc(8px + var(--sb-w, 0px)); }
.sym-row { font-size: 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.sym-row:hover { background: var(--hover); }
/* Symbol shown on the currently selected chart */
.sym-row.active { background: color-mix(in srgb, var(--accent) 16%, transparent); box-shadow: inset 3px 0 0 0 var(--accent); }
.sym-row.active:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.sym-drag { color: transparent; cursor: grab; font-size: 11px; line-height: 1; text-align: center; user-select: none; }
.sym-row:hover .sym-drag { color: var(--muted); }
.sym-row.dragging { opacity: 0.45; }
.sym-row.drop-above { box-shadow: inset 0 2px 0 0 var(--accent); }
.sym-row.drop-below { box-shadow: inset 0 -2px 0 0 var(--accent); }
.sym-dot { width: 8px; height: 8px; border-radius: 50%; }
.sym-name { font-weight: 600; }
.sym-quote-tag { font-weight: 400; font-size: 10px; color: var(--muted); margin-left: 2px; vertical-align: baseline; }
.sym-ex-tag { font-weight: 600; font-size: 8px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--hover); border: 1px solid var(--border); border-radius: 3px; padding: 0 3px; margin-left: 4px; vertical-align: middle; }
.sym-spark { display: flex; align-items: center; justify-content: center; }
.sym-price { text-align: right; }
.sym-chg { text-align: right; font-size: 11px; }
.sym-del { color: transparent; font-size: 14px; }
.sym-row:hover .sym-del { color: var(--muted); }
.sym-del:hover { color: var(--red); }

/* Watchlist performance heatmap (P2-16) */
.sym-heatmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; padding: 8px; overflow-y: auto; flex: 1; align-content: start; }
.heat-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 6px; padding: 10px 4px; cursor: pointer; text-align: center; }
.heat-tile:hover { outline: 1px solid var(--accent); }
.heat-sym { font-weight: 700; font-size: 12px; }
.heat-chg { font-size: 11px; font-weight: 600; }
.heat-vol { font-size: 9px; color: var(--muted); }
#heatmapToggleBtn.active { background: var(--accent); color: #fff; }
.wl-footer { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--border); }
.wl-footer button { flex: 1; padding: 7px; border-radius: 5px; background: var(--panel2); font-size: 12px; }
.wl-footer button:hover { background: var(--hover); }

/* Order book */
.ob-content { flex: 1; overflow-y: auto; padding: 6px; }
.ob-table { display: flex; flex-direction: column; }
.ob-row { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 2px 6px; font-size: 11px; }
.ob-bar { position: absolute; right: 0; top: 0; bottom: 0; }
.ob-price { position: relative; z-index: 1; }
.ob-price.bid { color: var(--green); } .ob-price.ask { color: var(--red); }
.ob-qty { position: relative; z-index: 1; text-align: right; color: var(--muted); }
.ob-spread { text-align: center; padding: 6px; font-size: 11px; color: var(--muted); border-block: 1px solid var(--border); margin: 4px 0; }

/* Order book sub-tabs: Book / Trades / Depth (P2-14) */
.ob-subtabs { display: flex; gap: 2px; padding: 6px 6px 0; }
.ob-subtab { flex: 1; padding: 5px 0; font-size: 11px; border-radius: 4px; color: var(--muted); background: var(--panel2); }
.ob-subtab:hover { color: var(--text); }
.ob-subtab.active { background: var(--accent); color: #fff; }

/* Time & sales tape */
.tape-head, .tape-row { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 3px 6px; font-size: 11px; }
.tape-head { color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); }
.tape-row .tape-price { text-align: center; }
.tape-row .tape-qty { text-align: right; color: var(--muted); }
.tape-row.buy .tape-price { color: var(--green); }
.tape-row.sell .tape-price { color: var(--red); }

/* Depth chart */
.depth-chart { padding: 6px; }
.depth-labels { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Paper trading & journal (P2-15) */
.paper-head { display: flex; align-items: center; justify-content: space-between; padding: 8px; }
.paper-sep { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px 2px; }
.paper-list { display: flex; flex-direction: column; gap: 6px; padding: 0 8px 8px; }
.paper-row { border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-size: 12px; }
.paper-row-main { display: flex; align-items: center; gap: 6px; }
.paper-side { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 3px; }
.paper-side.long { background: rgba(38,166,154,.18); color: var(--green); }
.paper-side.short { background: rgba(239,83,80,.18); color: var(--red); }
.paper-qty { color: var(--muted); margin-left: auto; }
.paper-row-sub { display: flex; justify-content: space-between; margin-top: 4px; font-size: 11px; color: var(--muted); }
.paper-row-actions { display: flex; gap: 6px; margin-top: 6px; }
.paper-row-actions button { flex: 1; padding: 4px; border-radius: 5px; background: var(--panel2); font-size: 11px; }
.paper-row-actions button:hover { background: var(--hover); }
/* Roadmap (2026-07-16): leveraged futures-style paper trades */
.paper-lev { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 3px; background: rgba(255,152,0,.18); color: #ff9800; }
.paper-row-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; font-size: 11px; color: var(--muted); }
.paper-row.liquidated { border-color: #ff9800; }
.paper-liq-warning { margin-top: 6px; padding: 4px 6px; border-radius: 5px; background: rgba(255,152,0,.15); color: #ff9800; font-size: 11px; font-weight: 600; }
.paper-liq-close-btn { background: #ff9800 !important; color: #1a1a1a !important; font-weight: 700; }
.paper-liq-close-btn:hover { background: #ffa726 !important; }
.pt-liq-preview { font-size: 11px; margin: -6px 0 8px; }
/* Roadmap (2026-07-16): edit position + show/hide-on-chart toggle */
.paper-chart-btn, .paper-edit-btn { flex: 0 0 auto !important; min-width: 30px; opacity: .6; }
.paper-chart-btn.active { opacity: 1; color: var(--accent); }
.paper-chart-btn:hover, .paper-edit-btn:hover { opacity: 1; }
.dc-log { margin-right: auto; }

/* Tech info */
.tech-content { padding: 12px; overflow-y: auto; flex: 1; }
.ti-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.ti-price { font-size: 24px; font-weight: 700; line-height: 1.1; }
.ti-chg { font-size: 13px; margin-top: 2px; }
.ti-perfs { display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.ti-perf-row { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.ti-perf-pill {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 1px 6px; border-radius: 10px;
}
.ti-perf-pill.up { background: rgba(38,166,154,.18); color: var(--green); }
.ti-perf-pill.down { background: rgba(239,83,80,.18); color: var(--red); }
.ti-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.ti-grid div { display: flex; flex-direction: column; }
.ti-grid span { color: var(--muted); font-size: 10px; }
.ti-grid b { font-size: 13px; }
.ti-divider { height: 1px; background: var(--border); margin: 10px 0; }
.ti-spacer { height: 6px; }
.ti-section-label { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 5px; }
/* Range gauge */
.ti-range-wrap { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.ti-range-lo, .ti-range-hi { font-size: 10px; color: var(--muted); white-space: nowrap; }
.ti-range-track { flex: 1; height: 6px; background: var(--panel2); border-radius: 3px; position: relative; }
.ti-range-fill { position: absolute; left: 0; top: 0; height: 100%; border-radius: 3px; transition: width .3s; }
.ti-range-thumb {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--panel);
  transition: left .3s;
}
/* RSI speedometer */
.ti-speedometer { text-align: center; }
.ti-speedometer-row { display: flex; align-items: center; justify-content: center; gap: 6px; }
.ti-speedometer-side { font-size: 10px; font-weight: 700; letter-spacing: .04em; flex-shrink: 0; }
.ti-speedometer-buy { color: #26a69a; }
.ti-speedometer-sell { color: #ef5350; }
.ti-speedometer-label { font-size: 14px; font-weight: 700; margin-top: 4px; letter-spacing: .01em; }
.ti-speedometer-rsi { font-size: 11px; color: var(--muted); margin-top: 1px; }
/* Seasonals */
.ti-seasonals { }
/* Footer */
.ti-footer { margin-top: 12px; }
.ti-alert-btn { width: 100%; padding: 8px; font-size: 12px; }

/* Scanner */
.scan-controls { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.scan-controls2 { padding-top: 0; flex-direction: row; align-items: center; gap: 6px; }
.scan-controls2 #scanSaved { flex: 1; min-width: 0; }
.scan-auto { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.scan-controls3 { padding-top: 0; flex-direction: row; align-items: center; gap: 6px; }
.scan-controls3 #scanAddWlSel { flex: 1; min-width: 0; }
.scan-select-all { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.scan-results { flex: 1; overflow-y: auto; }
.scan-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.scan-row:hover { background: var(--hover); }
.scan-row-check { flex: 0 0 auto; cursor: pointer; }
.scan-row-vals { flex: 1; display: flex; justify-content: space-between; align-items: center; }

/* ---------- Alerts overlay ---------- */
.alerts-overlay {
  position: fixed; top: var(--topbar-h); right: -340px; bottom: 0; width: 320px;
  background: var(--panel); border-left: 1px solid var(--border); z-index: 80; transition: right .2s;
  display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0,0,0,.3);
}
.alerts-overlay.open { right: 0; }
.alerts-head { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-bottom: 1px solid var(--border); }
.alerts-head > div { display: flex; gap: 6px; align-items: center; }
.alerts-list { flex: 1; overflow-y: auto; padding: 8px; }
.alert-item { display: flex; justify-content: space-between; align-items: flex-start; padding: 10px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; }
.alert-item.triggered { opacity: .55; }
.alert-note { color: var(--muted); font-size: 11px; margin-top: 3px; }
.alert-tag { display: inline-block; background: var(--accent); color: #fff; font-size: 9px; padding: 1px 5px; border-radius: 3px; margin-top: 4px; }
.alert-del { color: var(--muted); font-size: 16px; }
.alert-del:hover { color: var(--red); }

/* ---------- Modals ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 20px; width: 380px; max-width: 92vw; max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal h3 { margin-bottom: 14px; }

/* Command palette (P3-22) */
.modal.cmdk-modal { width: 560px; padding: 0; overflow: hidden; }
.cmdk-input { width: 100%; padding: 16px 18px; font-size: 15px; background: transparent; border: none; border-bottom: 1px solid var(--border); color: var(--text); }
.cmdk-input:focus { outline: none; }
.cmdk-list { max-height: 360px; overflow-y: auto; padding: 6px; }
.cmdk-item { display: flex; align-items: center; justify-content: space-between; padding: 9px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.cmdk-item.sel, .cmdk-item:hover { background: var(--hover); }
.cmdk-sym { font-weight: 600; }
.cmdk-hint { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.modal label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.modal label input, .modal label select { color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.modal-actions button { padding: 8px 14px; border-radius: 5px; background: var(--panel2); }
.modal-actions button:hover { background: var(--hover); }
.color-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.color-sw { width: 22px; height: 22px; border-radius: 5px; border: 2px solid transparent; }
.color-sw.sel { border-color: var(--text); }
.set-warn { color: var(--red); font-size: 11px; margin-bottom: 10px; min-height: 14px; }
.set-section-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 4px 0 6px; }
.set-ex-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 6px; padding: 4px; }
/* Each row is a <label>, so these MUST out-specify the global `.modal label`
   rule (0,1,1) which forces flex-direction:column. Scoping under
   `.modal-settings` (0,2,0) wins, keeping the checkbox + name + status on one
   horizontal row. */
.modal-settings .set-ex-row { display: flex; flex-direction: row; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 5px; cursor: pointer; margin: 0; }
.modal-settings .set-ex-row:hover { background: var(--hover); }
.modal-settings .set-ex-row input { flex: 0 0 auto; margin: 0; accent-color: var(--accent); cursor: pointer; }
.set-ex-name { font-size: 12px; font-weight: 600; white-space: nowrap; }
.set-ex-status { margin-left: auto; font-size: 10px; color: var(--muted); white-space: nowrap; }

/* Settings dialog: wider to fit the exchange rows, and user-resizable via the
   native bottom-right size handle (clamped by the modal's max-width/height).
   Flex column + a flexing list makes the list grow/shrink with the dialog. */
.modal.modal-settings { width: 480px; min-width: 360px; min-height: 300px; resize: both; overflow: auto; display: flex; flex-direction: column; }
.modal.modal-settings .set-ex-list { flex: 1 1 auto; min-height: 120px; max-height: none; }

/* Technical patterns guide (Roadmap) */
.modal.modal-patterns { width: 640px; min-width: 420px; min-height: 420px; }
.pat-intro { padding: 0; text-align: left; margin-bottom: 10px; }
.pat-filters { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.pat-filter { padding: 5px 12px; border-radius: 14px; background: var(--panel2); border: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.pat-filter:hover { background: var(--hover); }
.pat-filter.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pat-list { flex: 1 1 auto; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.pat-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--panel2); }
.pat-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.pat-name { font-weight: 600; font-size: 13px; }
.pat-kind { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.pat-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 2px 7px; border-radius: 10px; color: #fff; }
.pat-badge.pat-bullish { background: var(--green); }
.pat-badge.pat-bearish { background: var(--red); }
.pat-badge.pat-neutral { background: var(--muted); }
.pat-desc { font-size: 12px; line-height: 1.5; color: var(--text); margin-bottom: 6px; }
.pat-breakout { font-size: 12px; line-height: 1.5; color: var(--muted); }
.pat-breakout b { color: var(--text); }

/* Pattern example illustration (Roadmap: schematic price-path diagram per pattern) */
.pat-chart { width: 100%; height: 76px; display: block; margin-bottom: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
.pat-chart-price { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.pat-chart-line { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 4 3; opacity: .8; }

.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.tpl-card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 12px; border: 1px solid var(--border); border-radius: 8px; flex: 1; }
.tpl-card:hover { border-color: var(--accent); background: var(--hover); }
.tpl-card span { font-size: 10px; color: var(--muted); }
.tpl-sep { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 4px 0 8px; }
.tpl-user-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.tpl-user-row { display: flex; gap: 6px; align-items: stretch; }
.tpl-user-del { width: 30px; border-radius: 8px; color: var(--muted); }
.tpl-user-del:hover { background: var(--hover); color: var(--red); }

.layout-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.layout-item { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.layout-item-name { font-weight: 600; }
.layout-item-meta { font-size: 11px; color: var(--muted); }
.layout-item-actions { display: flex; gap: 6px; }
.layout-item-btn { padding: 5px 10px; border-radius: 5px; background: var(--panel2); font-size: 12px; }
.layout-item-btn.load { background: var(--accent); color: #fff; }

/* ---------- Drawing config popover ---------- */
.draw-cfg {
  position: fixed; z-index: 90; width: 232px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 12px 36px rgba(0,0,0,.45); font-size: 12px; overflow: hidden;
}
.draw-cfg .dc-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; background: var(--panel2); border-bottom: 1px solid var(--border); font-weight: 600; }
.draw-cfg .dc-head button { color: var(--muted); font-size: 13px; }
.draw-cfg .dc-head button:hover { color: var(--text); }
.draw-cfg .dc-body { padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.draw-cfg .dc-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); }
.draw-cfg .dc-row input, .draw-cfg .dc-row select { color: var(--text); background: var(--panel2); border: 1px solid var(--border); border-radius: 4px; padding: 3px 5px; }
.draw-cfg .dc-row input[type="color"] { padding: 0; width: 36px; height: 24px; border: none; background: none; cursor: pointer; }
.draw-cfg .dc-row input[type="number"], .draw-cfg .dc-row input[type="text"] { width: 110px; }
.draw-cfg .dc-coords { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding-top: 8px; }
.draw-cfg .dc-coord { display: grid; grid-template-columns: 1fr 64px 64px; align-items: center; gap: 5px; }
.draw-cfg .dc-coord span { color: var(--muted); }
.draw-cfg .dc-coord input { width: 100%; color: var(--text); background: var(--panel2); border: 1px solid var(--border); border-radius: 4px; padding: 3px 4px; }
.draw-cfg .dc-actions { padding: 8px 10px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 8px; }
.draw-cfg .dc-del { padding: 6px 12px; border-radius: 5px; background: var(--panel2); color: var(--red); }
.draw-cfg .dc-del:hover { background: var(--red); color: #fff; }
.draw-cfg .dc-del:disabled { opacity: .4; cursor: not-allowed; }
.draw-cfg .dc-del:disabled:hover { background: var(--panel2); color: var(--red); }
.draw-cfg .dc-lock { padding: 6px 12px; border-radius: 5px; background: var(--panel2); color: var(--text); }
.draw-cfg .dc-lock:hover { background: var(--border); }
.draw-cfg .dc-lock.active { color: #f0b90b; }

/* ---------- Context menu ---------- */
.ctx-menu { position: fixed; z-index: 200; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.4); min-width: 130px; }
.ctx-menu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 7px 10px; border-radius: 4px; font-size: 12px; }
.ctx-menu button:hover { background: var(--hover); }
.ctx-menu button.ctx-disabled { color: var(--muted); cursor: default; }
.ctx-menu button.ctx-disabled:hover { background: transparent; }
.ctx-dot { width: 12px; height: 12px; border-radius: 50%; }

/* ---------- Toasts ---------- */
#toastContainer { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--accent); color: var(--text); padding: 10px 16px; border-radius: 6px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.4); opacity: 0; transform: translateY(10px); transition: all .25s; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-warn { border-left-color: #ff9800; }
.toast-error { border-left-color: var(--red); }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--panel2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Darker Apply / primary buttons inside dialogs ---------- */
.modal-actions .primary-btn { background: var(--accent-strong); color: #fff; }
.modal-actions .primary-btn:hover { background: var(--accent-strong); filter: brightness(1.15); }

/* ---------- Compare / overlay legend ---------- */
.compare-legend { display: flex; align-items: center; gap: 5px; flex-wrap: nowrap; overflow: hidden; }
.cmp-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--panel2); border: 1px solid var(--border); border-radius: 12px; padding: 2px 6px; font-size: 11px; white-space: nowrap; }
.cmp-dot { width: 8px; height: 8px; border-radius: 50%; }
.cmp-x { color: var(--muted); font-size: 13px; line-height: 1; }
.cmp-x:hover { color: var(--red); }

/* ---------- Bottom timescale / range bar ---------- */
.panel-timescale {
  height: 28px; min-height: 28px; display: flex; align-items: center; gap: 2px;
  padding: 0 6px; background: var(--panel); border-top: 1px solid var(--border); overflow-x: auto;
}
.ts-btn { padding: 3px 9px; font-size: 11px; border-radius: 4px; color: var(--muted); white-space: nowrap; }
.ts-btn:hover { background: var(--hover); color: var(--text); }
.ts-btn.active { background: var(--accent); color: #fff; }

/* ---------- Bar replay bar (P2-10) ---------- */
.replay-bar {
  height: 30px; min-height: 30px; display: flex; align-items: center; gap: 8px;
  padding: 0 8px; background: var(--panel2); border-top: 1px solid var(--border);
}
.replay-act { width: 24px; height: 24px; border-radius: 4px; color: var(--text); font-size: 12px; }
.replay-act:hover { background: var(--hover); }
.replay-speed { font-size: 11px; background: var(--panel); border: 1px solid var(--border); border-radius: 4px; color: var(--text); padding: 2px 4px; }
.replay-scrub { flex: 1; accent-color: var(--accent); }
.replay-pos { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.replay-btn.active { background: var(--accent); color: #fff; }

/* ---------- Pane resize handles ---------- */
.panel-resize-r, .panel-resize-b { position: absolute; z-index: 12; display: none; }
.panel-resize-r { top: 0; bottom: 0; right: -3px; width: 7px; cursor: col-resize; }
.panel-resize-b { left: 0; right: 0; bottom: -3px; height: 7px; cursor: row-resize; }
.panel-resize-r:hover, .panel-resize-b:hover { background: var(--accent); opacity: .5; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing * { pointer-events: none; }
body.resizing-row { cursor: row-resize; user-select: none; }
body.resizing-row * { pointer-events: none; }

/* ---------- Theme picker ---------- */
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.theme-card { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; text-align: left; }
.theme-card:hover { border-color: var(--accent); background: var(--hover); }
.theme-card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.theme-swatch { display: flex; gap: 3px; width: 100%; height: 30px; border-radius: 5px; border: 1px solid; align-items: center; padding: 0 6px; }
.theme-swatch span { width: 14px; height: 14px; border-radius: 3px; }
.theme-name { font-weight: 600; font-size: 12px; }
.theme-mode { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* ---------- Symbol picker (add / overlay) ---------- */
.sp-stable-toggle { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; color: var(--muted); font-size: 12px; cursor: pointer; user-select: none; }
.sp-stable-toggle input { accent-color: var(--accent); cursor: pointer; }
.sp-ex-filter { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; }
.sp-ex-pill { padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.02em; cursor: pointer; transition: background 120ms, color 120ms, border-color 120ms; }
.sp-ex-pill:hover { background: var(--hover); color: var(--text); }
.sp-ex-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sp-quote-filter { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 8px; }
.sp-quote-pill { padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.02em; cursor: pointer; transition: background 120ms, color 120ms, border-color 120ms; }
.sp-quote-pill:hover { background: var(--hover); color: var(--text); }
.sp-quote-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sym-picker-list { max-height: 320px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 12px; }
.sym-picker-item { display: flex; align-items: baseline; gap: 4px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; text-align: left; }
.sym-picker-item:hover { background: var(--hover); border-color: var(--accent); }
.sym-picker-item span { color: var(--muted); font-size: 10px; }
.sym-picker-ex { margin-left: auto; font-weight: 600; font-size: 8px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--hover); border: 1px solid var(--border); border-radius: 3px; padding: 1px 4px; }
.search-res-ex { margin-left: auto; font-weight: 600; font-size: 8px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--hover); border: 1px solid var(--border); border-radius: 3px; padding: 1px 4px; }
.sym-picker-more { grid-column: 1 / -1; padding: 8px; border: 1px dashed var(--border); border-radius: 6px; color: var(--accent); font-size: 12px; font-weight: 600; }
.sym-picker-more:hover { background: var(--hover); }
.sym-picker-count { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 10px; padding: 2px 0; }
.cg-badge { display: inline-block; background: #6366f1; color: #fff; font-size: 9px; font-weight: 700; padding: 1px 4px; border-radius: 3px; letter-spacing: 0.04em; vertical-align: middle; margin-right: 4px; }
.search-sep { grid-column: 1 / -1; color: var(--muted); font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; padding: 6px 2px 2px; border-top: 1px solid var(--border); margin-top: 4px; }
.search-res-cg { background: var(--panel); }

/* Events pane */
.events-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 600; }
.events-head-actions { display: inline-flex; align-items: center; gap: 8px; }
.events-filter { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 400; color: var(--muted); cursor: pointer; }
.evt-refresh-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; line-height: 1; padding: 2px 4px; border-radius: 4px; }
.evt-refresh-btn:hover { background: var(--hover); color: var(--text); }
.evt-refresh-btn.spinning { animation: evt-spin 0.7s linear infinite; }
@keyframes evt-spin { to { transform: rotate(360deg); } }
.events-list { flex: 1; overflow-y: auto; padding: 4px; }
.evt-row { display: grid; grid-template-columns: 10px 1fr; align-items: start; gap: 8px; width: 100%; text-align: left; padding: 8px 8px; border-radius: 6px; border-bottom: 1px solid var(--border); }
.evt-row:hover { background: var(--hover); }
.evt-row.past { opacity: 0.55; }
.evt-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 3px; }
.evt-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.evt-title { font-size: 12px; font-weight: 600; }
.evt-meta { font-size: 10px; color: var(--muted); }
.evt-detail { margin: 4px 0 10px; }
.evt-detail-head { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.evt-detail-meta { font-size: 11px; color: var(--muted); margin: 4px 0; }
.evt-impact { margin-left: auto; font-size: 10px; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; }
.evt-impact.high { background: rgba(239,83,80,0.18); color: #ef5350; }
.evt-impact.medium { background: rgba(247,166,0,0.18); color: #f7a600; }
.evt-impact.low { background: var(--panel2); color: var(--muted); }

/* ---------- Order book controls ---------- */
.ob-controls { display: flex; align-items: center; gap: 8px; padding: 4px 6px 8px; }
.ob-controls label { font-size: 11px; color: var(--muted); }
.ob-controls select { flex: 1; padding: 4px 6px; font-size: 12px; }

/* ---------- Indicator picker dropdown (Roadmap 2) ---------- */
.ind-dropdown {
  position: fixed; z-index: 200; top: var(--topbar-h);
  width: 270px; max-height: 420px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.45);
  flex-direction: column; overflow: hidden;
}
.ind-drop-search {
  margin: 8px; width: calc(100% - 16px); flex-shrink: 0;
}
.ind-drop-list { flex: 1; overflow-y: auto; padding: 0 6px 6px; }
/* Reuse existing .ind-item styles — they still apply since the class name is the same */

/* ---------- Candle countdown timer (Roadmap 5) ---------- */
.candle-timer {
  font-size: 11px; font-variant-numeric: tabular-nums;
  color: var(--muted); letter-spacing: 0.02em; white-space: nowrap;
}

/* ---------- Event markers toggle button ---------- */
.evt-markers-btn { opacity: 0.45; }
.evt-markers-btn.active { opacity: 1; }

/* ---------- Layout dropdown (Roadmap 4) ---------- */
.layout-drop-wrap { position: relative; }
.layout-drop-btn {
  font-size: 12px; padding: 5px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--panel2);
  letter-spacing: 0.01em; white-space: nowrap;
}
.layout-drop-btn:hover { background: var(--hover); border-color: var(--accent); }
.layout-drop-menu {
  position: fixed; z-index: 250; min-width: 180px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.45);
  overflow: hidden; padding: 4px;
}
.ld-sep {
  font-size: 10px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); padding: 6px 10px 3px;
}
.ld-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  text-align: left; padding: 7px 10px; border-radius: 5px;
  font-size: 13px; color: var(--text);
}
.ld-item:hover { background: var(--hover); }
.ld-item.active { color: var(--accent); font-weight: 600; }
.ld-icon { font-size: 11px; letter-spacing: -2px; min-width: 20px; }

/* ---------- Per-chart hamburger menu (Roadmap: consolidate chart toggles) ---------- */
.panel-menu-dropdown {
  position: fixed; z-index: 250; min-width: 220px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.45);
  overflow: hidden; padding: 4px;
}
.pm-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  text-align: left; padding: 7px 10px; border-radius: 5px;
  font-size: 13px; color: var(--text); white-space: nowrap;
}
.pm-item:hover { background: var(--hover); }
.pm-item.active { color: var(--accent); font-weight: 600; }
.pm-item.danger:hover { background: rgba(239,83,80,.15); color: var(--red); }
.pm-sep { height: 1px; background: var(--border); margin: 4px 2px; }

/* ---------- Fancy buttons — Roadmap 1 ---------- */
/* Topbar buttons: subtle border + transition */
.tb-btn {
  border: 1px solid transparent; transition: background .12s, border-color .12s, color .12s;
}
.tb-btn:hover { border-color: var(--border); }
.tb-btn:active { background: var(--panel2); }

/* Panel bar symbol button */
.sym-btn {
  border: 1px solid transparent; border-radius: 6px;
  padding: 3px 9px; transition: background .12s, border-color .12s;
  background: var(--panel2);
}
.sym-btn:hover { border-color: var(--accent); }

/* Timeframe buttons pill-group */
.tf-group { background: var(--panel2); border-radius: 6px; padding: 2px; gap: 0; }
.tf-btn {
  border-radius: 4px; transition: background .12s, color .12s;
  padding: 3px 7px;
}
.tf-btn.active { background: var(--accent); color: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); }

/* Many timeframes (P1-8): let the pill-group scroll instead of overflowing */
.tf-group { overflow-x: auto; scrollbar-width: none; flex-shrink: 1; min-width: 0; }
.tf-group::-webkit-scrollbar { display: none; }
.tf-btn { flex-shrink: 0; }

/* Roadmap: favorite-timeframe dropdown (▾ next to the pinned TF pills) */
.tf-drop-btn {
  flex-shrink: 0; padding: 3px 5px; border-radius: 4px; font-size: 10px;
  color: var(--muted); transition: background .12s, color .12s;
}
.tf-drop-btn:hover { background: var(--hover); color: var(--text); }
.tf-dropdown {
  position: fixed; z-index: 250; min-width: 160px; max-height: 70vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.45);
  padding: 4px;
}
.tfd-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border-radius: 5px; cursor: pointer;
}
.tfd-item:hover { background: var(--hover); }
.tfd-item.active .tfd-label { color: var(--accent); font-weight: 600; }
.tfd-star {
  padding: 7px 4px 7px 10px; font-size: 13px; color: var(--muted); line-height: 1;
}
.tfd-star.on { color: #f7a600; }
.tfd-star:hover { color: #f7a600; }
.tfd-label { flex: 1; text-align: left; padding: 7px 10px 7px 0; font-size: 13px; color: var(--text); }

/* Per-chart symbol-switch dropdown (unfolds below the panel's symbol button) */
.sym-dropdown {
  position: fixed; z-index: 250; width: 260px; max-height: 70vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.45);
  padding: 8px;
}
.sym-dropdown .panel-search { margin: 0 0 6px; width: 100%; box-sizing: border-box; }
.sym-drop-list { max-height: 320px; overflow-y: auto; }
.sym-drop-list .search-res { border-radius: 5px; }

/* Chart type selector (P1-3) */
.ctype-sel {
  background: var(--panel2); color: var(--muted); border: 1px solid transparent;
  border-radius: 6px; font-size: 11px; padding: 3px 4px; cursor: pointer;
  transition: color .12s, border-color .12s;
}
.ctype-sel:hover { color: var(--text); border-color: var(--border); }
.ctype-sel:focus { outline: none; border-color: var(--accent); }

/* Server-side alert list extras (P1-6) */
.alert-type-tag {
  font-size: 10px; color: var(--muted); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px; margin-left: 6px; vertical-align: middle;
}
.alert-server-tag {
  font-size: 10px; color: var(--accent); border: 1px solid var(--accent);
  border-radius: 4px; padding: 1px 5px; font-weight: 500; vertical-align: middle;
}

/* Time-scale range buttons */
.panel-timescale { gap: 1px; }
.ts-btn { border-radius: 4px; transition: background .12s, color .12s; }
.ts-btn.active { background: var(--accent); color: #fff; }

/* Panel action buttons */
.panel-act {
  width: 28px; height: 28px; border-radius: 6px;
  transition: background .12s, color .12s;
}
.panel-act:hover { background: var(--hover); color: var(--text); }

/* Drawing toolbar */
.draw-tool { transition: background .12s, color .12s; }
.draw-tool.active { box-shadow: 0 1px 4px rgba(0,0,0,.3); }

/* Watchlist footer buttons */
.wl-footer button {
  border-radius: 6px; border: 1px solid var(--border);
  transition: background .12s, border-color .12s;
  font-weight: 500;
}
.wl-footer button:hover { border-color: var(--accent); color: var(--accent); background: var(--hover); }

/* Right panel tabs — animated underline */
.right-tab {
  position: relative; transition: color .15s;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.right-tab:after {
  content: ''; position: absolute; left: 20%; right: 20%; bottom: -2px;
  height: 2px; background: var(--accent);
  transform: scaleX(0); transition: transform .15s ease;
}
.right-tab:hover:after { transform: scaleX(1); }
.right-tab.active { border-bottom-color: var(--accent); }
.right-tab.active:after { transform: scaleX(0); }

/* Primary action buttons */
.primary-btn {
  border-radius: 6px; font-weight: 600;
  transition: filter .12s, transform .08s;
}
.primary-btn:hover { filter: brightness(1.15); }
.primary-btn:active { transform: scale(0.97); }

/* Indicator chips — remove button polish */
.chip-x { transition: color .1s; }

/* Watchlist tab pills */
.wl-tab { transition: background .12s, color .12s; }

/* Alerts bell */
#alertsBtn { border-radius: 6px; border: 1px solid transparent; transition: border-color .12s; }
#alertsBtn:hover { border-color: var(--border); }

/* ---------- Account / sign-in ---------- */
.acct-btn { display: inline-flex; align-items: center; gap: 6px; max-width: 160px; }
.acct-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-avatar { width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0; }
.acct-avatar-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
}
.auth-err { text-align: left; }
.modal-actions button:disabled { opacity: .6; cursor: default; }
.acct-card { display: flex; align-items: center; gap: 12px; margin: 12px 0; }
.acct-modal-avatar {
  width: 48px; height: 48px; border-radius: 50%; font-size: 20px;
}
.acct-card-name { font-weight: 700; font-size: 15px; }
.acct-card-email { font-size: 12px; }

/* Auth hardening (P3-19): security section + 2FA setup */
.acct-sec-sep { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 4px 0 8px; }
.acct-sec-row { justify-content: flex-start; margin-bottom: 14px; }
.totp-secret { font-family: monospace; font-size: 15px; letter-spacing: .08em; background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; padding: 10px; text-align: center; margin: 10px 0; word-break: break-all; }
.totp-qr { display: flex; justify-content: center; background: #fff; border-radius: 8px; padding: 12px; margin: 10px 0; }
.totp-qr img { display: block; width: 176px; height: 176px; }

/* ---------- Footer ---------- */
.app-footer {
  height: 30px; min-height: 30px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--panel); border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted); padding: 0 16px;
  white-space: nowrap; overflow: hidden;
}
.app-footer b { color: var(--text); }
.footer-logo { display: inline-flex; align-items: center; gap: 4px; color: var(--text); }
.footer-logo b { color: var(--accent); }
.footer-logo-icon { width: 32px; height: 32px; border-radius: 6px; vertical-align: middle; }
.footer-studio { display: inline-flex; align-items: center; gap: 4px; }
.footer-sep { color: var(--border); }
.footer-version { opacity: 0.5; font-size: 10px; letter-spacing: 0.04em; }
.footer-donate { color: #e0b45c; text-decoration: none; }
.footer-donate:hover { color: #f0c876; }
@media (max-width: 720px) {
  .footer-desc, .footer-sep:nth-child(3), .footer-sep:nth-child(4) { display: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .left-panel { width: 120px; }
  .right-panel { width: 260px; }
}

/* ---------- Mobile / tablet (P3-25) ----------
   Below 820px, any multi-chart layout becomes a horizontally swipeable
   single-chart-at-a-time view (scroll-snap) instead of squeezing several
   panels into an unusably small grid — "responsive single-chart mode" per
   the roadmap, without discarding whatever layout/panels the user has set
   up (they're still all there, one swipe away). The watchlist becomes a
   full-screen overlay toggled by the existing hamburger (☰) button instead
   of a fixed sidebar competing for width. */
@media (max-width: 820px) {
  .app-main { position: relative; }
  .right-panel {
    position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 80;
    width: 100% !important; max-width: 100%;
  }
  .right-panel.collapsed { display: none; }
  .panel-splitter { display: none; }

  .charts-area {
    display: flex !important; grid-template-columns: unset !important; grid-template-rows: unset !important;
    overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  }
  .chart-panel { flex: 0 0 100%; min-width: 100%; scroll-snap-align: start; }
  .panel-resize-r, .panel-resize-b { display: none !important; }

  .panel-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .panel-bar::-webkit-scrollbar { display: none; }
  .draw-toolbar { width: 44px; min-width: 44px; } /* the vertical tool column just needs to be narrower, not scrollable */
  .draw-tool { width: 32px; height: 32px; }

  .left-panel { display: none; } /* reclaim space; indicators are still editable via the ƒ button */
  #toggleLeft { display: none; } /* nothing to toggle on mobile — the panel is force-hidden above */
}
