* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Trebuchet MS", Roboto, Ubuntu, sans-serif;
  background: #131722;
  color: #d1d4dc;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  direction: ltr;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
.hidden { display: none !important; }
.spacer { flex: 1; }

#topbar {
  height: 46px; min-height: 46px;
  background: #131722;
  border-bottom: 1px solid #2a2e39;
  display: flex; align-items: center;
  padding: 0 12px; gap: 10px;
  position: relative; z-index: 30;
}
.brand { font-weight: 800; color: #2962ff; font-size: 15px; letter-spacing: 0.2px; margin-right: 6px; }

#symbol-box { position: relative; }
#symbol-btn {
  display: flex; align-items: center; gap: 6px;
  background: #1e222d; border: 1px solid #2a2e39; border-radius: 6px;
  padding: 6px 10px; font-size: 12px;
}
#symbol-btn:hover { background: #2a2e39; }
.sym-icon { color: #2962ff; }
#sym-name { color: #fff; font-weight: 700; }
#sym-chg { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
#sym-chg.up { color: #089981; }
#sym-chg.down { color: #f23645; }
.caret { color: #868993; font-size: 10px; }

#symbol-dropdown {
  position: absolute; top: 42px; left: 0; width: 420px;
  background: #171b26; border: 1px solid #2a2e39; border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.55); z-index: 60; padding: 10px;
}
.coin-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
#coin-close { width: 30px; height: 32px; border-radius: 8px; background: #1e222d; border: 1px solid #2a2e39; color: #868993; flex-shrink: 0; }
#coin-close:hover { background: #2a2e39; color: #fff; }
#symbol-search {
  flex: 1; padding: 8px 10px; border-radius: 8px; border: 1px solid #2a2e39;
  background: #131722; color: #fff; outline: none; font-size: 12px;
}
#symbol-search::placeholder { color: #868993; }
.coin-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.coin-tabs button { flex: 1; padding: 7px; border-radius: 8px; background: #1e222d; border: 1px solid #2a2e39; font-size: 12px; font-weight: 700; color: #868993; position: relative; }
.coin-tabs button.active { background: #2962ff; color: #fff; border-color: #2962ff; }
.coin-tabs .badge { background: #f23645; color: #fff; font-size: 9px; padding: 1px 5px; border-radius: 99px; margin-left: 4px; }
.filter-row { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.filter-row button { padding: 5px 10px; border-radius: 99px; background: #1e222d; border: 1px solid #2a2e39; font-size: 11px; color: #d1d4dc; white-space: nowrap; }
.filter-row button.active { background: #2962ff; color: #fff; border-color: #2962ff; }
.sector-row { flex-wrap: nowrap; align-items: center; }
.sector-scroll { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; flex: 1; scrollbar-color: #2a2e39 transparent; }
.sector-scroll::-webkit-scrollbar { height: 4px; }
.sector-scroll::-webkit-scrollbar-thumb { background: #2a2e39; border-radius: 99px; }
.scroll-arrow { width: 26px; height: 26px; border-radius: 6px; background: #1e222d; border: 1px solid #2a2e39; color: #868993; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.scroll-arrow:hover { background: #2a2e39; color: #fff; }
.coin-list-head { display: flex; justify-content: space-between; font-size: 10px; color: #868993; padding: 6px 4px; border-bottom: 1px solid #1e222d; margin-bottom: 4px; }
#symbol-list { max-height: 320px; overflow: auto; }
.sym-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 6px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.sym-row:hover { background: #1e222d; }
.sym-row.active { background: rgba(41,98,255,0.12); }
.sym-row .fav { color: #868993; font-size: 12px; width: 18px; text-align: center; }
.sym-row .fav.on { color: #ff9800; }
.sym-row .info { flex: 1; display: flex; flex-direction: column; }
.sym-row .pair { font-weight: 700; color: #fff; }
.sym-row .pair small { color: #868993; font-weight: 400; margin-left: 4px; }
.sym-row .sub { font-size: 10px; color: #868993; }
.sym-row .price { text-align: right; min-width: 90px; }
.sym-row .price b { display: block; font-size: 11px; color: #fff; font-variant-numeric: tabular-nums; }
.chg.up { color: #089981; }
.chg.down { color: #f23645; }

#tf-group { display: flex; gap: 2px; align-items: center; }
#tf-group button { padding: 5px 9px; font-size: 12px; color: #868993; border-radius: 4px; }
#tf-group button:hover { background: #2a2e39; color: #fff; }
#tf-group button.active { background: #2962ff; color: #fff; }
#tf-more { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 6px; background: #1e222d; border: 1px solid #2a2e39; margin-left: 4px; }
#tf-more:hover { background: #2a2e39; }
#tf-dropdown {
  position: absolute; top: 42px; left: 260px; z-index: 55;
  background: #1e222d; border: 1px solid #2a2e39; border-radius: 8px;
  padding: 6px; display: flex; gap: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
#tf-dropdown button { padding: 6px 10px; border-radius: 6px; font-size: 12px; color: #d1d4dc; }
#tf-dropdown button:hover { background: #2a2e39; }
#tf-dropdown button.active { background: #2962ff; color: #fff; }

#reset-btn {
  background: #1e222d; border: 1px solid #2a2e39; padding: 6px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: #d1d4dc;
}
#reset-btn:hover { background: #2962ff; color: #fff; border-color: #2962ff; }

#workspace { flex: 1; display: flex; min-height: 0; background: #131722; position: relative; }
#draw-toolbar {
  width: 38px; min-width: 38px; background: #131722; border-right: 1px solid #2a2e39;
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; z-index: 5;
}
#draw-toolbar button {
  width: 28px; height: 28px; border-radius: 4px; display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: #868993; border: 1px solid transparent;
}
#draw-toolbar button:hover { background: #1e222d; color: #d1d4dc; border-color: #2a2e39; }
#draw-toolbar button.active { background: #2a2e39; color: #fff; border-color: #2962ff; }
.tb-sep { width: 20px; height: 1px; background: #2a2e39; margin: 4px 0; }
.tb-color-wrap { display: flex; align-items: center; justify-content: center; }
.tb-color-wrap input[type="color"] { width: 22px; height: 22px; border: 2px solid #2a2e39; border-radius: 4px; background: transparent; cursor: pointer; padding: 0; }
.tb-color-wrap input[type="color"]::-webkit-color-swatch-wrapper { padding: 1px; }
.tb-color-wrap input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }
.tb-width-wrap { display: flex; align-items: center; justify-content: center; }
.tb-width-wrap input[type="range"] { writing-mode: vertical-lr; direction: rtl; width: 20px; height: 60px; accent-color: #2962ff; }
#chart-area { flex: 1; position: relative; min-width: 0; overflow: hidden; }
#chart { position: absolute; inset: 0; }
#hl-settings {
  position: fixed; z-index: 95; width: 220px;
  background: #1e222d; border: 1px solid #2a2e39; border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
#hl-settings.hidden { display: none !important; }
#hl-settings input[type="color"] { width: 32px; height: 22px; border: none; border-radius: 4px; background: transparent; }
#hl-settings input[type="range"] { width: 100px; }
#ind-canvas { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
#ind-canvas.drawing { pointer-events: auto; }

#status-chip {
  position: absolute; top: 10px; left: 10px; z-index: 6;
  font-size: 11px; color: #868993;
  background: rgba(19,23,34,0.82); padding: 3px 9px; border-radius: 4px; border: 1px solid #2a2e39;
}

.hint { margin-top: 14px; font-size: 11px; color: #868993; line-height: 1.9; }

#ind-btn {
  background: #1e222d; border: 1px solid #2a2e39; padding: 6px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 600; color: #d1d4dc; white-space: nowrap;
}
#ind-btn:hover { background: #2962ff; color: #fff; border-color: #2962ff; }

#ind-menu {
  position: absolute; top: 42px; right: 60px; width: 240px;
  background: #171b26; border: 1px solid #2a2e39; border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.55); z-index: 60; padding: 10px;
}
#ind-menu.hidden { display: none !important; }
#ind-menu hr { border: none; border-top: 1px solid #2a2e39; margin: 8px 0; }
#ind-menu .ind-section { display: flex; flex-direction: column; gap: 2px; }
#ind-menu .ind-row {
  background: none; border: none; border-radius: 4px; padding: 6px 8px;
  margin-bottom: 0; font-size: 12px; color: #d1d4dc; cursor: pointer;
}
#ind-menu .ind-row:hover { background: #1e222d; }
#ind-menu .ind-child { padding-left: 24px; font-size: 11px; color: #868993; }
#ind-menu .ind-child:hover { color: #d1d4dc; }
#ind-menu input[type="checkbox"] { accent-color: #2962ff; margin-right: 6px; }
.ind-ict-head { justify-content: space-between !important; }
.ind-gear {
  width: 22px; height: 22px; border-radius: 4px; font-size: 12px;
  color: #868993; display: flex; align-items: center; justify-content: center;
}
.ind-gear:hover { background: #2a2e39; color: #fff; }

#ict-settings-panel {
  position: fixed; z-index: 95; width: 260px; max-height: 70vh;
  background: #1e222d; border: 1px solid #2a2e39; border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.55); overflow: hidden;
}
#ict-settings-panel.hidden { display: none !important; }
#ict-body { padding: 10px; overflow-y: auto; max-height: 55vh; }
.ict-section { margin-bottom: 10px; }
.ict-section h5 { font-size: 11px; font-weight: 700; color: #fff; margin-bottom: 6px; padding: 4px 0; border-bottom: 1px solid #2a2e39; display: flex; align-items: center; justify-content: space-between; }
.ict-section h5 small { color: #868993; font-weight: 400; }
.ict-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0; font-size: 11px; color: #d1d4dc;
}
.ict-row input[type="color"] { width: 32px; height: 22px; border: none; border-radius: 4px; background: transparent; cursor: pointer; }
.ict-row input[type="number"] { width: 60px; padding: 3px 6px; border-radius: 4px; border: 1px solid #2a2e39; background: #131722; color: #fff; font-size: 11px; text-align: center; }
.ict-row select { padding: 3px 6px; border-radius: 4px; border: 1px solid #2a2e39; background: #131722; color: #fff; font-size: 11px; }
.ict-row .ict-check { accent-color: #2962ff; }
.ict-reset {
  width: 100%; padding: 8px; margin-top: 8px; border-radius: 6px; font-size: 11px; font-weight: 700;
  background: #2a2e39; color: #d1d4dc; border: 1px solid #3a3e49;
}
.ict-reset:hover { background: #2962ff; color: #fff; }

#topbar-trade { display: flex; gap: 4px; }
.tb-trade {
  padding: 5px 14px; border-radius: 6px; font-size: 12px; font-weight: 700; color: #fff;
  border: 1px solid transparent; white-space: nowrap;
}
.tb-trade.buy { background: #089981; }
.tb-trade.buy:hover { background: #0ab09a; }
.tb-trade.sell { background: #f23645; }
.tb-trade.sell:hover { background: #ff4b5c; }

#bottombar {
  height: 28px; min-height: 28px;
  background: #131722; border-top: 1px solid #2a2e39;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; font-size: 11px; color: #868993;
}
#conn-dot { width: 8px; height: 8px; border-radius: 50%; background: #868993; flex-shrink: 0; }
#conn-dot.live { background: #089981; box-shadow: 0 0 6px rgba(8,152,129,0.6); }
#conn-dot.sim { background: #ff9800; }
#conn-dot.err { background: #f23645; }
#clock { color: #d1d4dc; font-variant-numeric: tabular-nums; }

#draw-menu {
  position: fixed; z-index: 90; min-width: 160px;
  background: #1e222d; border: 1px solid #2a2e39; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45); padding: 8px; display: flex; flex-direction: column; gap: 8px;
}
#draw-menu.hidden { display: none !important; }
#draw-menu button[data-action="delete"] { background: #f23645; color: #fff; padding: 6px; border-radius: 6px; font-size: 12px; font-weight: 700; }
#draw-menu button[data-action="delete"]:hover { background: #d32f37; }
#draw-menu label { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: #d1d4dc; gap: 8px; }
#draw-menu input[type="color"] { width: 32px; height: 22px; border: none; border-radius: 4px; background: transparent; }
#draw-menu input[type="range"] { width: 90px; }
#draw-menu input[type="text"] { width: 110px; padding: 4px 6px; border-radius: 4px; border: 1px solid #2a2e39; background: #131722; color: #fff; font-size: 11px; }
#order-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,0.52);
  display: flex; align-items: center; justify-content: center;
}
#order-backdrop.hidden { display: none !important; }
#order-popup {
  width: 380px; max-width: 92vw;
  background: #1e222d; border: 1px solid #2a2e39; border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.5); overflow: hidden;
}
.popup-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid #2a2e39; }
.popup-head b { font-size: 13px; color: #fff; }
#popup-close { font-size: 14px; color: #868993; padding: 4px 6px; border-radius: 4px; }
#popup-close:hover { background: #2a2e39; color: #fff; }
.popup-body { padding: 14px; display: grid; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; color: #868993; }
.field input { background: #131722; border: 1px solid #2a2e39; border-radius: 6px; color: #fff; padding: 8px 10px; font-size: 12px; outline: none; }
.field input:focus { border-color: #2962ff; }
.side-badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; color: #fff; width: fit-content; }
.side-badge.buy { background: #089981; }
.side-badge.sell { background: #f23645; }
.popup-foot { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid #2a2e39; justify-content: flex-end; }
.btn { padding: 7px 14px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.btn.ghost { background: #131722; border: 1px solid #2a2e39; color: #d1d4dc; }
.btn.ghost:hover { background: #2a2e39; }
.btn.primary { background: #2962ff; color: #fff; }
.btn.primary:hover { background: #1e53e5; }

.chart-search-panel {
  position: absolute; top: 4px; left: 6px; z-index: 50;
  width: 310px; max-height: 65vh;
  display: flex; flex-direction: column;
  background: #141820; border: 1px solid #2a2e39;
  border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,.6);
  direction: rtl; overflow: hidden;
}
.chart-search-panel[hidden] { display: none !important; }
.csp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-bottom: 1px solid #2a2e39;
}
.csp-title { font-size: 13px; font-weight: 600; color: #d1d4dc; }
.csp-close {
  background: none; border: none; color: #868993;
  font-size: 16px; cursor: pointer; padding: 2px 6px; border-radius: 4px;
}
.csp-close:hover { background: #2a2e39; color: #d1d4dc; }
.csp-input {
  width: 100%; box-sizing: border-box;
  background: #0d1117; border: none; border-bottom: 1px solid #2a2e39;
  color: #d1d4dc; font-size: 13px; padding: 8px 10px; outline: none;
}
.csp-input::placeholder { color: #555; }
.csp-input:focus { border-bottom-color: #2962ff; }
.csp-filters {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 6px 10px; border-bottom: 1px solid #2a2e39;
}
.csp-filter {
  background: #1e222d; border: 1px solid transparent; border-radius: 4px;
  color: #888; font-size: 11px; padding: 3px 8px; cursor: pointer;
}
.csp-filter:hover { color: #d1d4dc; border-color: #2a2e39; }
.csp-filter.is-active { background: #2962ff; color: #fff; border-color: #2962ff; }
.csp-action-hide { background: #3a1a1a; color: #ff6b6b; border-color: #ff6b6b44; }
.csp-action-hide:hover { background: #4a1a1a; color: #ff8888; border-color: #ff6b6b; }
.csp-action-show { background: #1a2a1a; color: #6bff6b; border-color: #6bff6b44; }
.csp-action-show:hover { background: #1a3a1a; color: #88ff88; border-color: #6bff6b; }
.csp-results { flex: 1; overflow-y: auto; padding: 2px 0; }
.csp-results::-webkit-scrollbar { width: 4px; }
.csp-results::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }
.csp-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; cursor: pointer; transition: background .1s;
}
.csp-item:hover { background: #1e222d; }
.csp-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.csp-name { flex: 1; font-size: 12px; color: #d1d4dc; }
.csp-price { font-size: 11px; color: #888; font-family: monospace; direction: ltr; }
.csp-badge { font-size: 9px; padding: 1px 5px; border-radius: 3px; background: #1e222d; color: #888; }
.csp-empty { text-align: center; padding: 20px; color: #666; font-size: 13px; }
