*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #131722;
  --bg2:      #1e222d;
  --bg3:      #2a2e39;
  --border:   #2a2e39;
  --text:     #d1d4dc;
  --text-dim: #787b86;
  --accent:   #2962ff;
  --green:    #26a69a;
  --red:      #ef5350;
  --orange:   #ffa726;
  --toolbar-h: 44px;
  --draw-h:    36px;
  --osc-h:     200px;
}

html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px; display: flex; flex-direction: column;
}

/* ── Toolbar ── */
#toolbar {
  height: var(--toolbar-h); min-height: var(--toolbar-h);
  background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  z-index: 10; flex-shrink: 0;
}

#symbol-input {
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); padding: 5px 10px; font-size: 13px; width: 140px;
  outline: none;
}
#symbol-input:focus { border-color: var(--accent); }

#search-dropdown {
  position: absolute; top: var(--toolbar-h); left: 12px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 4px;
  width: 280px; max-height: 280px; overflow-y: auto;
  z-index: 100; display: none;
}
#search-dropdown.open { display: block; }
.dd-item {
  padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.dd-item:hover { background: var(--bg3); }
.dd-item:last-child { border-bottom: none; }
.dd-epic  { font-weight: 600; }
.dd-name  { color: var(--text-dim); font-size: 11px; }

.sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

/* TF buttons */
.tf-btn {
  background: transparent; border: 1px solid transparent;
  border-radius: 3px; color: var(--text-dim); padding: 3px 8px;
  cursor: pointer; font-size: 12px; font-weight: 600; transition: all .1s;
}
.tf-btn:hover { color: var(--text); background: var(--bg3); }
.tf-btn.active {
  color: var(--accent); background: rgba(41,98,255,.15);
  border-color: rgba(41,98,255,.3);
}

/* Price display */
#price-display {
  margin-left: auto; font-size: 14px; font-weight: 700;
  display: flex; gap: 12px; align-items: center;
}
#price-val  { color: var(--text); }
#price-chg  { font-size: 12px; }
#price-chg.up   { color: var(--green); }
#price-chg.down { color: var(--red); }

/* Status / save */
#conn-status {
  width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim);
  margin-left: 4px;
}
#conn-status.connected { background: var(--green); }
#conn-status.error     { background: var(--red); }

#save-btn {
  padding: 5px 14px; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); cursor: pointer; font-size: 12px;
  transition: all .15s;
}
#save-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Drawing toolbar ── */
#draw-toolbar {
  height: var(--draw-h); min-height: var(--draw-h);
  background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 4px; padding: 0 12px;
  flex-shrink: 0;
}
.draw-btn {
  background: transparent; border: 1px solid transparent;
  border-radius: 3px; color: var(--text-dim); padding: 3px 10px;
  cursor: pointer; font-size: 12px; display: flex; align-items: center; gap: 5px;
  transition: all .1s;
}
.draw-btn:hover { color: var(--text); background: var(--bg3); }
.draw-btn.active {
  color: var(--orange); background: rgba(255,167,38,.1);
  border-color: rgba(255,167,38,.3);
}
#draw-hint {
  margin-left: auto; color: var(--text-dim); font-size: 11px;
  font-style: italic;
}

/* ── Chart area ── */
#charts-area {
  flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative;
}
#price-chart-wrap {
  flex: 1; min-height: 0; position: relative;
}
#price-chart { width: 100%; height: 100%; }

#osc-wrap {
  height: var(--osc-h); min-height: var(--osc-h); flex-shrink: 0;
  border-top: 2px solid var(--border); position: relative;
}
#osc-label {
  position: absolute; top: 4px; left: 10px; z-index: 2;
  font-size: 11px; color: var(--text-dim); pointer-events: none;
}
#osc-chart { width: 100%; height: 100%; }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; padding: 10px 18px; font-size: 13px;
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none; z-index: 1000;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.ok   { border-color: var(--green); color: var(--green); }
#toast.err  { border-color: var(--red);   color: var(--red);   }
#toast.warn { border-color: var(--orange); color: var(--orange); }

/* ── Crossing alert badge ── */
.crossing-badge {
  position: fixed; top: 60px; right: 16px;
  background: #1e222d; border: 1px solid var(--orange);
  border-radius: 6px; padding: 10px 14px; font-size: 12px;
  z-index: 500; max-width: 280px;
  animation: slideIn .2s ease;
}
.crossing-badge .cb-title { font-weight: 700; color: var(--orange); margin-bottom: 4px; }
.crossing-badge .cb-body  { color: var(--text); line-height: 1.5; }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Scrollbars ── */
::-webkit-scrollbar            { width: 6px; height: 6px; }
::-webkit-scrollbar-track      { background: var(--bg); }
::-webkit-scrollbar-thumb      { background: var(--bg3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover{ background: #3a3f4f; }
