/* ============================================================
   styles/components.css — UI component styles
   ============================================================ */

/* ── Layout ────────────────────────────────────────────────── */
#app        { display: flex; flex-direction: column; height: 100vh; width: 100vw; }
#toolbar    { display: flex; align-items: center; gap: 3px; height: var(--toolbar-h); padding: 0 10px; background: var(--bg-surface); border-bottom: 1px solid var(--border-subtle); flex-shrink: 0; z-index: 100; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; flex-wrap: nowrap; }
#toolbar::-webkit-scrollbar { display: none; }
#chart-area { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#main-canvas-wrap { flex: 1; position: relative; min-height: 0; }
#main-canvas    { display: block; }
#overlay-canvas { position: absolute; inset: 0; pointer-events: none; }
#indicator-panes { flex-shrink: 0; }
#statusbar  { height: var(--statusbar-h); background: rgba(7,13,24,.92); border-top: 1px solid var(--border-subtle); display: flex; align-items: center; padding: 0 16px; gap: 16px; font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); flex-shrink: 0; letter-spacing: .02em; }

/* ── Toolbar elements ──────────────────────────────────────── */
.tb-divider { width: 1px; height: 22px; background: var(--border-subtle); margin: 0 3px; flex-shrink: 0; }

/* ── range-bar removed — range buttons are now in the single toolbar ── */
/* #range-bar styles kept as no-op for any lingering references */
#range-bar { display: none; }
.tb-range-label {
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  flex-shrink: 0;
  padding: 0 2px 0 4px;
  opacity: 0.6;
  user-select: none;
}
.tb-group   { display: flex; align-items: center; gap: 1px; flex-shrink: 0; flex-wrap: nowrap; }
.tb-btn     { height: 27px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; color: var(--text-secondary); transition: all .12s; white-space: nowrap; display: flex; align-items: center; gap: 3px; flex-shrink: 0; letter-spacing: .01em; }
.tb-btn:hover  { background: rgba(58,108,255,.08); color: var(--text-primary); }
.tb-btn.active { background: rgba(58,108,255,.18); color: #fff; box-shadow: inset 0 0 0 1px rgba(58,108,255,.35); }

/* ── Ticker display ────────────────────────────────────────── */
#ticker-display { display: flex; align-items: center; gap: 8px; padding: 0 4px; flex-shrink: 0; min-width: 180px; }
#ticker-sym     { font-family: var(--font-mono); font-size: 14px; font-weight: 600; }
#ticker-co      { font-size: 10px; font-weight: 500; color: var(--sw-muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
#ticker-price   { font-family: var(--font-mono); font-size: 14px; font-weight: 500; }
#ticker-change  { font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; border-radius: 4px; }
#ticker-change.bull { background: var(--bull-dim); color: var(--bull); }
#ticker-change.bear { background: var(--bear-dim); color: var(--bear); }
.bull { color: var(--bull); }
.bear { color: var(--bear); }

/* ── Search ─────────────────────────────────────────────────
   KEY FIX: z-index:1000 on wrap + overflow:visible on toolbar
   so the dropdown renders ABOVE the chart canvas, not clipped
   ────────────────────────────────────────────────────────── */
#search-wrap       { position: relative; flex-shrink: 0; z-index: 1000; }
#search-input      { width: 180px; height: 32px; background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: 6px; padding: 0 10px 0 32px; font-size: 13px; font-weight: 500; color: var(--text-primary); transition: border-color .15s, width .2s; }
#search-input:focus { border-color: var(--accent); width: 240px; }
.search-icon       { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
#search-dropdown   { display: none; position: fixed; width: 380px; background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: 12px; z-index: 9999; box-shadow: 0 16px 48px rgba(0,0,0,.9), 0 0 0 1px rgba(58,108,255,.12); max-height: 380px; overflow-y: auto; overflow-x: hidden; }
#search-dropdown.open { display: block; }
.search-item       { display: flex; align-items: center; padding: 10px 14px; cursor: pointer; gap: 10px; transition: background .1s; border-bottom: 1px solid var(--border-subtle); }
.search-item:last-child { border-bottom: none; }
.search-item:hover,
.search-item.selected  { background: var(--bg-hover); }
.search-item .sym      { font-family: var(--font-mono); font-weight: 600; font-size: 13px; color: var(--text-primary); min-width: 72px; }
.search-item .name     { color: var(--text-secondary); font-size: 12px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-item .xbadge   { font-size: 10px; padding: 2px 6px; border-radius: 3px; background: var(--bg-active); color: var(--text-muted); font-family: var(--font-mono); text-transform: uppercase; border: 1px solid var(--border-default); flex-shrink: 0; }
.search-msg            { padding: 16px; text-align: center; color: var(--text-muted); font-size: 12px; }

/* ── Indicator panel ───────────────────────────────────────── */
#ind-panel   { position: absolute; top: 8px; right: 8px; background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: 8px; padding: 12px; z-index: 200; min-width: 195px; display: none; box-shadow: 0 8px 32px rgba(0,0,0,.6); }
#ind-panel.open { display: block; }
#ind-panel h3  { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 10px; font-family: var(--font-mono); }
.ind-item      { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border-subtle); gap: 10px; }
.ind-item:last-child { border-bottom: none; }
.ind-label     { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.ind-dot       { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ind-toggle    { width: 32px; height: 18px; border-radius: 9px; background: var(--bg-hover); border: 1px solid var(--border-default); position: relative; cursor: pointer; transition: all .2s; flex-shrink: 0; }
.ind-toggle.on { background: var(--accent); border-color: var(--accent); }
.ind-toggle::after { content: ''; position: absolute; width: 12px; height: 12px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: transform .2s; }
.ind-toggle.on::after { transform: translateX(14px); }

/* ── Sub panes ─────────────────────────────────────────────── */
.ind-pane    { position: relative; border-top: 1px solid var(--border-subtle); }
.ind-pane canvas { display: block; }
.pane-label  { position: absolute; top: 5px; left: 10px; font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); pointer-events: none; z-index: 5; }

/* ── Crosshair tooltip — compact two-line design ───────────── */
#crosshair-tooltip {
  position: absolute;
  background: rgba(10,12,18,0.92);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 5px 9px 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  pointer-events: none;
  z-index: 300;
  display: none;
  box-shadow: 0 4px 18px rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  min-width: 0;
  white-space: nowrap;
}
.tt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}
.tt-date  { color: var(--text-muted); font-size: 10px; }
.tt-chg   { font-size: 10.5px; font-weight: 600; }
.tt-ohlcv {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: var(--text-secondary);
}
.tt-ohlcv span { display: flex; gap: 2px; align-items: center; }
.tt-l { color: var(--text-muted); margin-right: 1px; }

/* ── Status bar ────────────────────────────────────────────── */
.sb-label { color: var(--text-muted); }

/* ── Loading / Error ───────────────────────────────────────── */
#loading    { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg-base); z-index: 400; flex-direction: column; gap: 12px; }
.spinner    { width: 28px; height: 28px; border: 2px solid var(--border-default); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.loading-sym { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
@keyframes spin { to { transform: rotate(360deg); } }

#error-msg  { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 10px; color: var(--text-muted); }
#error-msg.show { display: flex; }
#error-text { font-size: 12px; font-family: var(--font-mono); text-align: center; max-width: 360px; }
#retry-btn  { color: var(--accent); font-size: 12px; text-decoration: underline; cursor: pointer; background: none; border: none; }

/* ── Main layout (sidebar + chart) ─────────────────────────── */
#main-layout   { flex: 1; display: flex; min-height: 0; overflow: hidden; }
#chart-column  { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
#chart-area    { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ── Drawing tools sidebar ─────────────────────────────────── */
#drawing-sidebar {
  width: 48px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 4px;
  gap: 1px;
  flex-shrink: 0;
  overflow-y: auto;
  scrollbar-width: none;
}
#drawing-sidebar::-webkit-scrollbar { display: none; }
#drawing-tools { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; padding: 0 4px; }
/* Thin divider group inside drawing tools */
.tool-group-sep {
  width: 28px; height: 1px;
  background: var(--border-subtle);
  margin: 4px auto;
  flex-shrink: 0;
}
.tool-btn {
  width: 38px; height: 34px;
  border-radius: 7px;
  font-size: 14px;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  cursor: pointer;
  border: none; background: none;
}
.tool-btn:hover  { background: var(--bg-hover); color: var(--text-primary); }
.tool-btn.active { background: var(--accent-dim); color: var(--accent); }

/* ── Indicator panel (updated with groups + search) ─────────── */
#ind-panel {
  position: absolute; top: 8px; right: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 8px; z-index: 200;
  width: 230px; display: none;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  max-height: 70vh; overflow: hidden;
  display: none; flex-direction: column;
}
#ind-panel.open { display: flex; }
.ind-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px 6px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); font-family: var(--font-mono);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.ind-header button {
  font-size: 10px; color: var(--text-muted);
  padding: 2px 6px; border-radius: 4px;
  transition: all .15s;
}
.ind-header button:hover { background: var(--bear-dim); color: var(--bear); }
#ind-search {
  margin: 8px 10px 4px;
  background: var(--bg-hover);
  border: 1px solid var(--border-default);
  border-radius: 5px; padding: 5px 10px;
  font-size: 12px; color: var(--text-primary);
  flex-shrink: 0;
}
#ind-search:focus { border-color: var(--accent); }
#ind-list { overflow-y: auto; padding: 4px 0 8px; }
.ind-group { padding: 0 0 4px; }
.ind-group-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); padding: 6px 12px 3px;
  font-family: var(--font-mono);
}

/* ── Drawing Properties Panel ──────────────────────────────── */
#drawing-props {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 10px 14px;
  display: none;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  z-index: 400;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  white-space: nowrap;
}
.dp-row {
  display: flex;
  align-items: center;
  gap: 7px;
}
.dp-label {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
#dp-color {
  width: 30px;
  height: 24px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  padding: 1px 2px;
  cursor: pointer;
  background: none;
}
#dp-opacity, #dp-width {
  width: 80px;
  accent-color: var(--accent);
}
#dp-opacity-val, #dp-width-val {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  min-width: 30px;
}
.dp-actions { gap: 8px; }
.dp-btn {
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
  background: var(--bg-hover);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  transition: all .15s;
}
.dp-btn:hover { background: var(--bg-active); color: var(--text-primary); }
.dp-btn-danger { border-color: var(--bear-dim); color: var(--bear); }
.dp-btn-danger:hover { background: var(--bear-dim); }

/* ── Context Menu ──────────────────────────────────────────── */
#drawing-ctx-menu {
  position: fixed;
  display: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 4px 0;
  min-width: 160px;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0,0,0,.6);
}
.ctx-item {
  padding: 8px 14px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background .1s;
}
.ctx-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.ctx-danger     { color: var(--bear); }
.ctx-danger:hover { background: var(--bear-dim); }
.ctx-divider    { height: 1px; background: var(--border-subtle); margin: 3px 0; }

/* ══════════════════════════════════════════════════════════════
   ANALYZE BUTTON BAR
   ══════════════════════════════════════════════════════════════ */
#analyze-bar {
  height: 38px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#analyze-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 22px;
  height: 26px;
  background: linear-gradient(135deg, rgba(59,130,246,0.18), rgba(99,102,241,0.12));
  border: 1px solid rgba(59,130,246,0.45);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #60a5fa;
  transition: all .2s;
  letter-spacing: 0.4px;
  box-shadow: 0 0 12px rgba(59,130,246,0.15);
}
#analyze-btn:hover {
  background: linear-gradient(135deg, rgba(59,130,246,0.3), rgba(99,102,241,0.2));
  border-color: #60a5fa;
  box-shadow: 0 0 20px rgba(59,130,246,0.3);
  color: #93c5fd;
}
#analyze-btn.active {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-color: #3b82f6;
  color: #fff;
  box-shadow: 0 0 20px rgba(59,130,246,0.4);
}

/* ══════════════════════════════════════════════════════════════
   AI ANALYSIS DRAWER
   ══════════════════════════════════════════════════════════════ */
#analysis-drawer {
  height: 0;
  overflow: hidden;
  background: #080b0f;
  border-top: 1px solid rgba(59,130,246,0.4);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: 100%;
  transition: height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 1px 0 rgba(59,130,246,0.15);
}
#analysis-drawer.open      { height: 280px; }
#analysis-drawer.minimized { height: 38px; overflow: hidden; }

/* ── Header ────────────────────────────────────────────────── */
#analysis-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 38px;
  background: linear-gradient(90deg, rgba(59,130,246,0.08), transparent);
  border-bottom: 1px solid rgba(59,130,246,0.15);
  flex-shrink: 0;
}

#analysis-drawer-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 11px;
  font-weight: 700;
  color: #60a5fa;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Animated pulse dot */
.ai-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3b82f6;
  box-shadow: 0 0 6px #3b82f6;
  animation: ai-pulse 2s ease-in-out infinite;
}
@keyframes ai-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px #3b82f6; }
  50%       { opacity: 0.4; box-shadow: 0 0 2px #3b82f6; }
}

/* Confidence badge */
#analysis-confidence {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 2px 9px;
  border-radius: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
#analysis-confidence.conf-high { background: rgba(38,166,154,0.2); color: #26a69a; border: 1px solid rgba(38,166,154,0.4); }
#analysis-confidence.conf-mid  { background: rgba(245,158,11,0.15); color: #f59e0b; border: 1px solid rgba(245,158,11,0.35); }
#analysis-confidence.conf-low  { background: rgba(239,83,80,0.15);  color: #ef5350; border: 1px solid rgba(239,83,80,0.35); }

/* Controls */
#analysis-drawer-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}
.ai-ctrl-divider {
  width: 1px;
  height: 16px;
  background: var(--border-subtle);
  margin: 0 4px;
}
#analysis-scroll-left,
#analysis-scroll-right {
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  transition: all .15s;
}
#analysis-scroll-left:hover,
#analysis-scroll-right:hover { color: var(--accent); background: var(--accent-dim); }

#analysis-refresh-btn,
#analysis-minimize-btn,
#analysis-close-btn {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 9px;
  border-radius: 4px;
  transition: all .15s;
  font-family: var(--font-mono);
}
#analysis-refresh-btn:hover  { color: #60a5fa; background: var(--accent-dim); }
#analysis-minimize-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
#analysis-close-btn:hover    { color: #ef5350; background: var(--bear-dim); }

/* ── Scrollable body ───────────────────────────────────────── */
#analysis-body {
  flex: 1;
  overflow: hidden;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ── Loading ───────────────────────────────────────────────── */
#analysis-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #60a5fa;
  font-size: 12px;
  font-family: var(--font-mono);
  padding: 24px 24px;
  height: 100%;
}
.analysis-spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(59,130,246,0.2);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

/* ── Error ─────────────────────────────────────────────────── */
#analysis-error {
  display: none;
  align-items: center;
  gap: 8px;
  color: #ef5350;
  font-size: 12px;
  padding: 24px;
}
#analysis-error:not(:empty) { display: flex; }

/* ══════════════════════════════════════════════════════════════
   ANALYSIS CONTENT — horizontal scrolling card row
   ══════════════════════════════════════════════════════════════ */
#analysis-content {
  display: flex;
  flex-direction: row;
  gap: 1px;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
#analysis-content::-webkit-scrollbar { display: none; }

/* ── Individual section card ───────────────────────────────── */
.ai-section {
  flex-shrink: 0;
  width: 220px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  overflow: hidden;
  overflow-y: auto;
}
.ai-section:last-child { border-right: none; }

/* Trade Setup card is wider */
.ai-section.ai-trade { width: 260px; background: rgba(59,130,246,0.04); border-right-color: rgba(59,130,246,0.2); }

/* Confidence card */
.ai-section.ai-conf  { width: 160px; background: rgba(38,166,154,0.03); align-items: center; justify-content: center; }

/* ── Card header ───────────────────────────────────────────── */
.ai-h3 {
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: rgba(96,165,250,0.7);
  font-weight: 700;
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  background: rgba(59,130,246,0.04);
}

/* ── Card body ─────────────────────────────────────────────── */
.ai-body {
  padding: 8px 12px;
  font-size: 11.5px;
  line-height: 1.65;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  color: #9ab0c8;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border-default) transparent;
}

.ai-section strong { color: #dce6f0; font-weight: 600; }
.ai-section code   { font-family: var(--font-mono); font-size: 10.5px; background: rgba(59,130,246,0.1); color: #60a5fa; padding: 1px 4px; border-radius: 3px; }

/* ── Trade Setup special rows ──────────────────────────────── */
.ai-trade-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.ai-trade-row:last-child { border-bottom: none; }
.ai-trade-label {
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  min-width: 68px;
  flex-shrink: 0;
}
.ai-trade-val {
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: #dce6f0;
}
.ai-bias-bull { color: #26a69a !important; }
.ai-bias-bear { color: #ef5350 !important; }
.ai-bias-neut { color: #f59e0b !important; }
.ai-entry-val { color: #3b82f6 !important; }
.ai-target-val { color: #f97316 !important; }
.ai-stop-val   { color: #ef5350 !important; }

/* ── Confidence score card ─────────────────────────────────── */
.ai-score-num {
  font-size: 40px;
  font-family: var(--font-mono);
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}
.ai-score-label {
  font-size: 9px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.ai-score-rationale {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  padding: 0 12px;
  line-height: 1.5;
}
.score-high { color: #26a69a; }
.score-mid  { color: #f59e0b; }
.score-low  { color: #ef5350; }


/* ══ CHART LEGEND — clickable indicator chips on chart ═════════════════════ */
#chart-legend {
  position: absolute;
  top: 6px;
  left: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  z-index: 100;
  pointer-events: auto;
}

.legend-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px 3px 6px;
  background: rgba(10, 14, 22, 0.82);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-secondary);
  transition: border-color .15s, background .15s;
  user-select: none;
  backdrop-filter: blur(4px);
}
.legend-chip:hover {
  border-color: rgba(255,255,255,0.28);
  background: rgba(20, 26, 40, 0.92);
  color: var(--text-primary);
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-label {
  white-space: nowrap;
}
.legend-remove {
  font-size: 9px;
  color: var(--text-muted);
  padding: 0 0 0 2px;
  opacity: 0.5;
  transition: opacity .12s, color .12s;
  line-height: 1;
}
.legend-remove:hover {
  opacity: 1;
  color: #ef4444;
}

/* ══ INDICATOR SETTINGS POPOVER ════════════════════════════════════════════ */
#ind-settings-popover {
  position: absolute;
  z-index: 500;
  background: rgba(10, 14, 22, 0.97);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  padding: 0;
  min-width: 210px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
  backdrop-filter: blur(12px);
  font-family: var(--font-mono);
  overflow: hidden;
}
.isp-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.isp-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.isp-title {
  flex: 1;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.isp-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  opacity: 0.6;
}
.isp-close:hover { opacity: 1; color: #ef4444; }

.isp-params {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.isp-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.isp-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.isp-input {
  width: 70px;
  height: 28px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 5px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 0 8px;
  text-align: right;
  transition: border-color .15s;
}
.isp-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(59,130,246,0.08);
}
.isp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.isp-color {
  width: 36px;
  height: 24px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  background: none;
  cursor: pointer;
  padding: 2px;
}
.isp-footer {
  padding: 8px 12px;
}
.isp-remove-btn {
  width: 100%;
  padding: 6px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 5px;
  color: #f87171;
  font-family: var(--font-mono);
  font-size: 10.5px;
  cursor: pointer;
  transition: all .15s;
}
.isp-remove-btn:hover {
  background: rgba(239,68,68,0.18);
  border-color: rgba(239,68,68,0.5);
  color: #fff;
}

/* ══ SCANNER CONTROLS BAR (replaces scanner topbar) ══════════ */
.scanner-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.scanner-controls-left {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ══ CHART TOOLBAR — scanner theme overrides ═════════════════ */
#toolbar {
  background: var(--sw-panel);
  border-bottom: 1px solid var(--sw-border);
  height: var(--toolbar-h);
}
.tb-btn {
  color: var(--sw-muted);
  font-family: 'Inter', sans-serif;
}
.tb-btn:hover  { background: rgba(255,255,255,.05); color: var(--sw-text); }
.tb-btn.active { background: rgba(0,230,168,.12); color: var(--sw-green); }
.tb-divider    { background: var(--sw-border); }

/* ══ DRAWING SIDEBAR — scanner theme ════════════════════════ */
#drawing-sidebar {
  background: var(--sw-panel);
  border-right: 1px solid var(--sw-border);
}
.tool-btn:hover  { background: rgba(255,255,255,.05); color: var(--sw-text); }
.tool-btn.active { background: rgba(0,230,168,.12); color: var(--sw-green); }
.sidebar-action-btn {
  color: var(--text-muted);
  font-size: 15px;
  opacity: 0.7;
}
.sidebar-action-btn:hover {
  opacity: 1;
  color: var(--text-primary);
  background: rgba(255,255,255,.06);
}


/* ══ CHART NAV BAR — always-visible pan/zoom controls ══════ */
#chart-nav {
  height: 30px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
  user-select: none;
}

.chart-nav-group {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.chart-nav-btn {
  height: 22px;
  min-width: 26px;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chart-nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.chart-nav-btn:active {
  background: var(--accent-dim);
  color: var(--accent);
}
.nav-reset {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 0 8px;
  gap: 4px;
  color: var(--text-muted);
}

.chart-nav-divider {
  width: 1px;
  height: 14px;
  background: var(--border-subtle);
  margin: 0 4px;
}

.chart-nav-hint {
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.5;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Range buttons scrollable on small screens */
.range-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  flex-shrink: 1;
  min-width: 0;
}
.range-scroll::-webkit-scrollbar { display: none; }

/* ══ STATUS BAR ════════════════════════════════════════════ */
#statusbar {
  background: var(--sw-panel);
  border-top: 1px solid var(--sw-border);
}

/* ══ ANALYZE BUTTON — scanner green ════════════════════════ */
#analyze-btn {
  background: linear-gradient(135deg, rgba(0,230,168,.18), rgba(0,200,150,.12));
  border: 1px solid rgba(0,230,168,.4);
  color: var(--sw-green);
  box-shadow: 0 0 12px rgba(0,230,168,.15);
}
#analyze-btn:hover {
  background: linear-gradient(135deg, rgba(0,230,168,.28), rgba(0,200,150,.2));
  border-color: var(--sw-green);
  box-shadow: 0 0 20px rgba(0,230,168,.3);
  color: #fff;
}
#analyze-btn.active {
  background: linear-gradient(135deg, var(--sw-green), #00c48c);
  border-color: var(--sw-green);
  color: #050e0a;
  box-shadow: 0 0 20px rgba(0,230,168,.4);
}

/* ══ ANALYSIS DRAWER — scanner theme ════════════════════════ */
#analysis-drawer {
  background: var(--sw-bg);
  border-top: 1px solid rgba(0,230,168,.35);
}
#analysis-drawer-header {
  background: linear-gradient(90deg, rgba(0,230,168,.06), transparent);
  border-bottom: 1px solid rgba(0,230,168,.12);
}
#analysis-drawer-title {
  color: var(--sw-green);
}
.ai-pulse-dot {
  background: var(--sw-green);
  box-shadow: 0 0 6px var(--sw-green);
}
#analysis-confidence.conf-high { background: rgba(0,230,168,.15); color: var(--sw-green); border: 1px solid rgba(0,230,168,.35); }
#analysis-confidence.conf-mid  { background: rgba(248,191,59,.15); color: var(--sw-yellow); border: 1px solid rgba(248,191,59,.35); }
#analysis-confidence.conf-low  { background: rgba(255,77,109,.15); color: var(--sw-red); border: 1px solid rgba(255,77,109,.35); }
#analysis-refresh-btn:hover { color: var(--sw-green); background: rgba(0,230,168,.1); }
#analysis-close-btn:hover   { color: var(--sw-red);   background: rgba(255,77,109,.1); }

/* Analysis content cards — scanner palette */
.ai-h3 { color: rgba(0,230,168,.75); }
.ai-section { background: var(--sw-panel); border-right: 1px solid var(--sw-border); }
.ai-section.ai-trade { background: rgba(0,230,168,.03); border-right-color: rgba(0,230,168,.18); }
.ai-body { color: var(--sw-muted); }
.ai-section strong { color: var(--sw-text); }
.ai-trade-label { color: #4a5d7a; }
.ai-bias-bull  { color: var(--sw-green)  !important; }
.ai-bias-bear  { color: var(--sw-red)    !important; }
.ai-bias-neut  { color: var(--sw-yellow) !important; }
.ai-entry-val  { color: var(--sw-blue)   !important; }
.ai-target-val { color: var(--sw-yellow) !important; }
.ai-stop-val   { color: var(--sw-red)    !important; }
.score-high { color: var(--sw-green); }
.score-mid  { color: var(--sw-yellow); }
.score-low  { color: var(--sw-red); }
.ai-score-label { color: var(--sw-muted); }
.ai-score-rationale { color: var(--sw-muted); }

/* ══ SEARCH ═════════════════════════════════════════════════ */
#search-input { background: var(--sw-panel-2); border-color: var(--sw-border); }
#search-input:focus { border-color: var(--sw-green); }
#search-dropdown { background: var(--sw-panel); border-color: var(--sw-border); }
.search-item:hover, .search-item.selected { background: rgba(255,255,255,.04); }

/* ══ INDICATOR PANEL ════════════════════════════════════════ */
#ind-panel { background: var(--sw-panel); border-color: var(--sw-border); }
.ind-toggle.on { background: var(--sw-green); border-color: var(--sw-green); }

/* ── Apply Trading Plan to Chart ─────────────────────────── */
.ai-apply-wrap {
  padding: 6px 12px 10px;
  border-top: 1px solid rgba(59,130,246,0.15);
  margin-top: 4px;
}
.ai-apply-btn {
  width: 100%;
  padding: 7px 12px;
  border-radius: 7px;
  border: 1px solid rgba(59,130,246,0.35);
  background: rgba(59,130,246,0.1);
  color: #93c5fd;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.ai-apply-btn:hover {
  background: rgba(59,130,246,0.2);
  border-color: rgba(59,130,246,0.55);
  color: #fff;
}


/* ══ CROSSHAIR PRICE BADGE ══════════════════════════════════ */
/* Handled in renderer — uses --accent which now maps to sw-blue */

/* ══ TICKER DISPLAY ══════════════════════════════════════════ */
.bull { color: var(--sw-green); }
.bear { color: var(--sw-red); }
#ticker-change.bull { background: rgba(0,230,168,.12); color: var(--sw-green); }
#ticker-change.bear { background: rgba(255,77,109,.12); color: var(--sw-red); }

.ai-score-breakdown { display:flex; gap:6px; justify-content:center; flex-wrap:wrap; margin-top:5px; font-size:10px; font-family:var(--font-mono); color:var(--text-muted); }
.ai-score-breakdown span { background:var(--bg-hover); border-radius:4px; padding:1px 5px; border:1px solid var(--border-subtle); }

/* ═══════════════════════════════════════════════════════════
   MacroBull Premium Overrides — applied last
   ═══════════════════════════════════════════════════════════ */

/* Chart area subtle gradient background */
#main-canvas-wrap { background: linear-gradient(180deg, #07101f 0%, #050d18 100%); }

/* Ticker display — bolder, premium */
#ticker-sym    { font-size: 14px; font-weight: 800; letter-spacing: -.02em; color: var(--text-primary); }
#ticker-price  { font-size: 14px; font-weight: 700; font-family: var(--font-mono); color: var(--text-primary); }

/* Primary btn — blue gradient */
.primary-btn {
  background: linear-gradient(135deg, #3a6cff, #2255dd);
  color: #fff; border: none;
  font-weight: 700; border-radius: 8px;
  box-shadow: 0 2px 12px rgba(58,108,255,.35);
  transition: all .15s;
}
.primary-btn:hover { background: linear-gradient(135deg, #4d7dff, #3367ee); box-shadow: 0 4px 18px rgba(58,108,255,.45); transform: translateY(-1px); }

/* Secondary btn */
.secondary-btn {
  background: rgba(255,255,255,.04); color: var(--sw-muted, #7a8fae);
  border: 1px solid rgba(255,255,255,.08); font-weight: 600;
  border-radius: 8px; transition: all .15s;
}
.secondary-btn:hover { background: rgba(255,255,255,.07); color: var(--sw-text, #e8edf8); border-color: rgba(255,255,255,.14); }

/* Active tool in drawing sidebar — blue accent */
.tool-btn.active { background: rgba(58,108,255,.2); color: var(--sw-blue, #3a6cff); box-shadow: inset 0 0 0 1px rgba(58,108,255,.4); }
.tool-btn:hover  { background: rgba(255,255,255,.05); color: var(--sw-text, #e8edf8); }

/* Analysis confidence score colors */
.score-high  { color: #00e6a8; }
.score-mid   { color: #f8bf3b; }
.score-low   { color: #ff4d6d; }
.conf-high   { color: #00e6a8; }
.conf-mid    { color: #f8bf3b; }
.conf-low    { color: #ff4d6d; }

/* Analysis drawer — premium glass */
#analysis-drawer {
  background: linear-gradient(180deg, rgba(11,19,38,.98), rgba(7,13,24,.98));
  border-top: 1px solid var(--border-default);
  border-left: 1px solid var(--border-default);
}

/* Indicator panel — premium */
#indicator-panel {
  background: rgba(9,16,30,.97);
  border-left: 1px solid var(--border-default);
  backdrop-filter: blur(8px);
}

/* Scrollbar — subtle blue tint */
::-webkit-scrollbar-thumb { background: rgba(58,108,255,.2); }
::-webkit-scrollbar-thumb:hover { background: rgba(58,108,255,.35); }
