:root {
  --bg: #0f1115;
  --panel: #161a22;
  --border: #262b38;
  --text: #d1d4dc;
  --muted: #7d8494;
  --up: #26a69a;
  --down: #ef5350;
  --accent: #2962ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { display: flex; flex-direction: column; }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px;
  background: var(--panel); border-bottom: 1px solid var(--border); }
.search-wrap { position: relative; }
#search { width: 220px; padding: 7px 10px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font-size: 13px; text-transform: uppercase; }
#search::placeholder { text-transform: none; }
#search:focus { outline: none; border-color: var(--accent); }
.results { position: absolute; top: 36px; left: 0; z-index: 20; width: 340px; max-height: 420px;
  overflow-y: auto; margin: 0; padding: 4px 0; list-style: none; background: var(--panel);
  border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.5); }
.results li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 12px; cursor: pointer; }
.results li.active, .results li:hover { background: #1f2533; }
.results li .s { font-weight: 600; }
.results li .p { color: var(--muted); font-variant-numeric: tabular-nums; }
.results li.hdr { color: var(--muted); font-size: 11px; text-transform: uppercase; cursor: default; background: none; }
.hidden { display: none !important; }

.icon-btn { background: none; border: 1px solid var(--border); color: #f0b90b; border-radius: 6px;
  padding: 4px 9px; font-size: 15px; cursor: pointer; }
.intervals { display: flex; flex-wrap: wrap; gap: 2px; }
.intervals button { background: none; border: none; color: var(--muted); padding: 5px 7px;
  border-radius: 4px; cursor: pointer; font-size: 13px; }
.intervals button:hover { background: #1f2533; color: var(--text); }
.intervals button.active { color: #fff; background: var(--accent); }
body.inv-colors { --up: #ef5350; --down: #26a69a; }
.tool-btns { display: flex; gap: 4px; margin-left: auto; }
.tool-btn { background: none; border: 1px solid transparent; color: var(--text); padding: 5px 10px; border-radius: 6px;
  cursor: pointer; font-size: 13px; white-space: nowrap; }
.tool-btn i { font-style: italic; font-family: Georgia, serif; margin-right: 2px; }
.tool-btn:hover, .tool-btn.open { background: #1f2533; border-color: var(--border); }
.tool-btn.cog { font-size: 16px; padding: 3px 9px; }
.popup { position: fixed; z-index: 30; min-width: 280px; padding: 6px 0; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.55); }
.popup-title { padding: 6px 14px 8px; font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.popup .row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; cursor: pointer; }
.popup .row:hover { background: #1f2533; }
.popup .name { flex: 1; white-space: nowrap; }
.popup small { color: var(--muted); margin-left: 4px; }
.popup .swatch { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.popup .swatch.cross { width: 12px; height: auto; background: none; color: #FFEB3B; font-weight: 900; font-size: 16px; line-height: 1; text-align: center; }
.popup kbd { font-size: 11px; line-height: 1; font-family: inherit; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 3px 5px; }
.switch { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 32px; height: 18px; margin: 0;
  border-radius: 9px; background: #3a3f4d; cursor: pointer; transition: background .15s; }
.switch::before { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::before { transform: translateX(14px); }

.statsbar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 16px; padding: 6px 12px;
  border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.sym-name { font-size: 16px; font-weight: 700; }
.last-price { font-size: 16px; font-weight: 600; }
.stat em { color: var(--muted); font-style: normal; margin-right: 4px; }
.stat b { font-weight: 500; }
.up { color: var(--up); } .down { color: var(--down); }
.conn { margin-left: auto; color: var(--muted); font-size: 11px; }
.conn.live { color: #26a69a; }
.pos { color: #26a69a; } .neg { color: #ef5350; }

.chart-wrap { position: relative; flex: 1; min-height: 300px; }
.chart { position: absolute; inset: 0; }
.legend { position: absolute; top: 6px; left: 10px; z-index: 5; pointer-events: none;
  font-variant-numeric: tabular-nums; font-size: 12px; }
.legend span { margin-right: 8px; }
.legend .lbl { color: var(--muted); margin-right: 2px; }
.measure { position: absolute; top: 0; left: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.measure-label { position: absolute; z-index: 7; pointer-events: none; padding: 5px 9px; border-radius: 4px;
  color: #fff; font-size: 12px; line-height: 1.45; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.error { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); z-index: 10;
  max-width: 520px; padding: 16px 20px; background: #2a1517; border: 1px solid var(--down);
  border-radius: 8px; text-align: center; }
.loading { position: absolute; top: 10px; right: 80px; z-index: 6; color: var(--muted); }

@media (max-width: 700px) {
  #search { width: 160px; }
  .results { width: 280px; }
  .tool-btns { margin-left: 0; }
}
