:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2129;
  --border: #2a313c;
  --text: #e6edf3;
  --muted: #8b949e;
  --green: #3fb950;
  --red: #f85149;
  --blue: #58a6ff;
  --amber: #d29922;
  --purple: #bc8cff;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff; --panel: #f6f8fa; --panel-2: #eef1f4;
    --border: #d0d7de; --text: #1f2328; --muted: #656d76;
    --green: #1a7f37; --red: #cf222e; --blue: #0969da;
    --amber: #9a6700; --purple: #8250df;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--panel); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--red);
  transition: background .3s;
}
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.muted { color: var(--muted); font-size: 12px; }

.badge {
  padding: 3px 9px; border-radius: 4px; font-size: 11px;
  font-weight: 700; letter-spacing: .5px;
}
.badge.paper { background: rgba(88,166,255,.15); color: var(--blue);
  border: 1px solid var(--blue); }
.badge.live { background: rgba(248,81,73,.15); color: var(--red);
  border: 1px solid var(--red); }
.badge.hidden { display: none; }
#halt-badge { background: var(--red); color: #fff; }

button {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 5px; cursor: pointer; font: inherit;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
button.danger { background: transparent; color: var(--red); border-color: var(--red); }
button.danger:hover { background: var(--red); color: #fff; }
button.small { padding: 3px 8px; font-size: 11px; }

input, select {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  padding: 6px 9px; border-radius: 5px; font: inherit;
}

.tabs { display: flex; gap: 2px; padding: 0 16px; border-bottom: 1px solid var(--border);
  background: var(--panel); overflow-x: auto; }
.tab { background: none; border: none; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 9px 14px; color: var(--muted); white-space: nowrap; }
.tab.active { color: var(--text); border-bottom-color: var(--blue); }

main { padding: 14px 16px 40px; }
.panel { display: none; }
.panel.active { display: block; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px;
  flex-wrap: wrap; }

.market-layout { display: grid; grid-template-columns: 260px 1fr; gap: 14px; }
@media (max-width: 900px) { .market-layout { grid-template-columns: 1fr; } }

.symbol-list {
  background: var(--panel); border: 1px solid var(--border); border-radius: 7px;
  max-height: 620px; overflow-y: auto;
}
.sym {
  padding: 7px 11px; cursor: pointer; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: 8px;
}
.sym:hover { background: var(--panel-2); }
.sym.sel { background: rgba(88,166,255,.12); border-left: 2px solid var(--blue); }
.sym .v { color: var(--muted); font-size: 11px; }

.chart-area { background: var(--panel); border: 1px solid var(--border);
  border-radius: 7px; padding: 12px; min-width: 0; }
.chart-header { display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.chart-header h2 { margin: 0; font-size: 16px; }
.quote-strip { display: flex; gap: 14px; font-size: 12px; flex-wrap: wrap; }
.quote-strip b { font-weight: 600; }
canvas { width: 100%; display: block; border-radius: 5px; }

.book-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 12px; }
.book { font-size: 11px; }
.book .row { display: flex; justify-content: space-between; padding: 1px 5px;
  position: relative; }
.book .row span { position: relative; z-index: 1; }
.book .bar { position: absolute; top: 0; bottom: 0; right: 0; opacity: .16; }
.book.bids .bar { background: var(--green); }
.book.asks .bar { background: var(--red); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 12px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--border);
  border-radius: 7px; padding: 12px; }
.card h4 { margin: 0 0 6px; font-size: 13px; display: flex;
  justify-content: space-between; align-items: center; gap: 8px; }
.card .kv { display: flex; justify-content: space-between; padding: 2px 0;
  font-size: 12px; }
.card .kv span:first-child { color: var(--muted); }

table.data { width: 100%; border-collapse: collapse; font-size: 12px;
  margin-bottom: 20px; }
table.data th { text-align: left; color: var(--muted); font-weight: 500;
  padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 5px 8px; border-bottom: 1px solid var(--border);
  vertical-align: top; }
table.data tr:hover td { background: var(--panel); }

.notice { padding: 9px 12px; border-radius: 6px; margin-bottom: 12px;
  border: 1px solid var(--border); background: var(--panel); font-size: 12px; }
.notice.info { border-color: var(--blue); background: rgba(88,166,255,.08); }
.notice.warn { border-color: var(--amber); background: rgba(210,153,34,.1); }
.notice.error { border-color: var(--red); background: rgba(248,81,73,.1); }
.notice.hidden { display: none; }

.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--border);
  border-radius: 7px; padding: 9px 14px; min-width: 110px; }
.stat .n { font-size: 19px; font-weight: 600; }
.stat .l { color: var(--muted); font-size: 11px; }

.up { color: var(--green); }
.down { color: var(--red); }
.dim { color: var(--muted); }
.pill { padding: 1px 7px; border-radius: 10px; font-size: 10px;
  border: 1px solid var(--border); }
.pill.pass { color: var(--green); border-color: var(--green); }
.pill.fail { color: var(--muted); }
.pill.ai { color: var(--purple); border-color: var(--purple); }

.news-item { background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; padding: 9px 12px; margin-bottom: 8px; }
.news-item a { color: var(--text); text-decoration: none; }
.news-item a:hover { color: var(--blue); }
.news-meta { color: var(--muted); font-size: 11px; margin-top: 3px; }

pre.json { background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; padding: 11px; overflow-x: auto; font-size: 11px;
  max-height: 480px; }

/* ---------- live ticker tape in the header ---------- */
.ticker-tape {
  flex: 1; display: flex; gap: 16px; overflow: hidden; margin: 0 18px;
  white-space: nowrap; font-size: 11px; mask-image: linear-gradient(
    to right, transparent, #000 24px, #000 calc(100% - 24px), transparent);
}
.ticker-tape .ti { display: flex; gap: 5px; align-items: baseline; }
.ticker-tape .ti b { font-weight: 600; }
@media (max-width: 1100px) { .ticker-tape { display: none; } }

.live-pill {
  font-size: 10px; color: var(--green); border: 1px solid var(--green);
  border-radius: 10px; padding: 1px 8px; opacity: .45;
  transition: opacity .18s;
}
.live-pill.pulse { opacity: 1; }

.sub-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  margin-top: 12px; }
@media (max-width: 760px) { .sub-grid { grid-template-columns: 1fr; } }
.sub-h { margin: 0 0 5px; font-size: 11px; color: var(--muted);
  font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }

.tape { font-size: 11px; max-height: 210px; overflow-y: auto; }
.tape .row { display: flex; justify-content: space-between; padding: 1px 5px;
  border-bottom: 1px solid var(--border); }
.tape .row.buy span:nth-child(2) { color: var(--green); }
.tape .row.sell span:nth-child(2) { color: var(--red); }
.tape .row.fresh { animation: flash .5s ease-out; }
@keyframes flash { from { background: rgba(88,166,255,.28); } to { background: transparent; } }

.tv-container { height: 640px; border: 1px solid var(--border);
  border-radius: 7px; overflow: hidden; background: var(--panel); }
.tv-container iframe { width: 100%; height: 100%; border: 0; display: block; }
.tv-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tv-presets button { font-size: 11px; padding: 3px 9px; }

table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.flash-up td { animation: flashg .6s ease-out; }
tr.flash-down td { animation: flashr .6s ease-out; }
@keyframes flashg { from { background: rgba(63,185,80,.22); } to { background: transparent; } }
@keyframes flashr { from { background: rgba(248,81,73,.22); } to { background: transparent; } }

.delay-tag { font-size: 9px; color: var(--amber); border: 1px solid var(--amber);
  border-radius: 3px; padding: 0 4px; margin-left: 5px; }

.progress { height: 5px; background: var(--panel-2); border-radius: 3px;
  overflow: hidden; margin-top: 3px; }
.progress > div { height: 100%; background: var(--blue); transition: width .4s; }
