:root {
  --bg:       #0d1117;
  --bg-alt:   #161b22;
  --bg-hi:    #21262d;
  --border:   #30363d;
  --text:     #c9d1d9;
  --text-dim: #8b949e;
  --text-mut: #6e7681;
  --green:    #3fb950;
  --green-d:  #1e6d2f;
  --red:      #f85149;
  --red-d:    #6e2323;
  --blue:     #58a6ff;
  --yellow:   #d29922;
  --orange:   #ff8c42;
  --purple:   #bc8cff;
  --mono:     ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ──────────────────────────────────────────────────── */
header {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
  background: var(--bg-alt);
  flex-shrink: 0;
}
.brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.6px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .tag {
  font-size: 10px;
  font-weight: 500;
  background: var(--border);
  color: var(--text-dim);
  padding: 3px 8px;
  border-radius: 10px;
  letter-spacing: 1px;
}

.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.ctrl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}
.ctrl input, .ctrl select {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
  width: 60px;
  text-align: right;
  color-scheme: dark;   /* makes browser spin arrows visible on dark bg */
}
.ctrl select { width: auto; cursor: pointer; }
.btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  transition: all 0.15s;
}
.btn:hover { background: var(--bg-hi); }
.btn.paused {
  background: var(--orange);
  color: var(--bg);
  border-color: var(--orange);
}
.btn-toggle.on {
  background: var(--blue);
  color: var(--bg);
  border-color: var(--blue);
}

/* Error banner */
.err-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  background: #8b1d1d;
  color: white;
  font-family: var(--mono);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.err-banner.hidden { display: none; }
.err-banner .banner-close {
  margin-left: auto;
  background: rgba(0,0,0,0.25);
  border: none;
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}
.ws-badge {
  font-size: 10px;
  font-weight: 700;
  font-family: var(--mono);
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--red-d);
  color: var(--red);
  margin-right: 4px;
}
.ws-badge.ws-on {
  background: var(--green-d);
  color: var(--green);
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 6px currentColor;
  transition: all 0.3s;
}
.dot.alive {
  background: var(--green);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* ─── Whale banner ────────────────────────────────────────────── */
.whale-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: linear-gradient(90deg, var(--blue) 0%, var(--purple) 100%);
  color: white;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  animation: whaleIn 0.4s ease-out;
  flex-shrink: 0;
}
.whale-banner.hidden { display: none; }
.whale-banner .emoji { font-size: 18px; }
.whale-banner .banner-close {
  margin-left: auto;
  background: rgba(0,0,0,0.2);
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.whale-banner .banner-close:hover { background: rgba(0,0,0,0.4); }
@keyframes whaleIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── KPI strip ───────────────────────────────────────────────── */
.kpis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: var(--border);
  flex-shrink: 0;
}
.kpi {
  background: var(--bg);
  padding: 10px 16px;
}
.kpi .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.kpi .sublabel {
  text-transform: none;
  letter-spacing: 0;
  font-size: 9px;
  opacity: 0.6;
  margin-left: 4px;
}
.kpi-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.kpi .val {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.spark {
  height: 24px;
  width: 100px;
  overflow: visible;
  flex-shrink: 0;
}
.spark polyline {
  fill: none;
  stroke: var(--blue);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.spark .spark-area {
  fill: var(--blue);
  opacity: 0.1;
  stroke: none;
}

/* ─── Watchlist ───────────────────────────────────────────────── */
.watchlist {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-alt);
  padding: 10px 20px 14px;
}
.watchlist.hidden { display: none; }
.watchlist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.watchlist-head h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}
.watchlist-head h2 .small {
  font-size: 10px;
  color: var(--text-mut);
  font-weight: normal;
  margin-left: 6px;
}
.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.wl-card {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s;
  overflow: hidden;
}
.wl-card:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
}
.wl-card .wl-close {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 3px;
  background: transparent;
  border: none;
  color: var(--text-mut);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.wl-card:hover .wl-close { opacity: 1; }
.wl-card .wl-close:hover { background: var(--border); color: var(--red); }
.wl-title {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 16px;
}
.wl-price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.wl-price {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.wl-change {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
}
.wl-change.up   { color: var(--green); }
.wl-change.down { color: var(--red); }
.wl-change.flat { color: var(--text-mut); }
.wl-spark {
  width: 100%;
  height: 32px;
  display: block;
  margin: 4px 0;
}
.wl-spark polyline {
  fill: none;
  stroke: var(--blue);
  stroke-width: 1.4;
  stroke-linejoin: round;
}
.wl-spark.up   polyline { stroke: var(--green); }
.wl-spark.down polyline { stroke: var(--red); }
.wl-spark .wl-spark-area { fill-opacity: 0.15; stroke: none; }
.wl-spark.up   .wl-spark-area { fill: var(--green); }
.wl-spark.down .wl-spark-area { fill: var(--red); }
.wl-stats {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
}
.wl-stats .buydot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.wl-stats .buydot.bull { background: var(--green); box-shadow: 0 0 4px var(--green); }
.wl-stats .buydot.bear { background: var(--red);   box-shadow: 0 0 4px var(--red); }
.wl-stats .buydot.neut { background: var(--yellow); }

.wl-empty {
  grid-column: 1 / -1;
  padding: 24px;
  text-align: center;
  color: var(--text-mut);
  font-size: 12px;
  border: 1px dashed var(--border);
  border-radius: 6px;
}

/* Drawer footer (watch button) */
.drawer-foot {
  border-top: 1px solid var(--border);
  padding: 10px 20px;
  background: var(--bg);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.drawer-foot .btn { flex: 1; padding: 8px; }
.drawer-foot .btn.watched {
  background: var(--blue);
  color: var(--bg);
  border-color: var(--blue);
}

/* Highlight watched markets in tables */
tr.is-watched td:last-child::before {
  content: "👁 ";
  margin-right: 2px;
  opacity: 0.6;
}

/* ─── Hero: Live Trades ───────────────────────────────────────── */
.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-top: 1px solid var(--border);
}
.hero-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px 8px;
  flex-shrink: 0;
}
.hero-head h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}
.hero-head h2 .small {
  font-size: 10px;
  color: var(--text-mut);
  font-weight: normal;
  margin-left: 8px;
  letter-spacing: 0.5px;
  text-transform: none;
}
.hero-tools {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 10px;
}
.hero-tools .hint {
  color: var(--text-mut);
  font-family: var(--mono);
}
.btn-light {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: inherit;
}
.btn-light:hover { background: var(--bg-alt); color: var(--text); }

.feed {
  flex: 1;
  overflow: auto;
  padding: 0 20px 10px;
  min-height: 0;
}

.feed-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13px;
}
.feed-table colgroup .c-time    { width: 92px;  }
.feed-table colgroup .c-trader  { width: 130px; }
.feed-table colgroup .c-side    { width: 52px;  }
.feed-table colgroup .c-prob    { width: 170px; }
.feed-table colgroup .c-money   { width: 96px;  }
.feed-table colgroup .c-vol-all { width: 90px;  }
.feed-table colgroup .c-vol     { width: 84px;  }
.feed-table colgroup .c-hot     { width: 52px;  }
.feed-table colgroup .c-ends    { width: 60px;  }
.feed-table colgroup .c-market  { width: auto;  }

/* Give left columns more breathing room */
.feed-table thead th,
.feed-table tbody td { padding-left: 6px; padding-right: 14px; }
.feed-table thead th:first-child,
.feed-table tbody td:first-child { padding-left: 4px; }
.feed-table thead th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 500;
  padding: 6px 10px 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 2;
}
.feed-table thead th.num { text-align: right; padding-right: 12px; }
.feed-table tbody td {
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid rgba(48, 54, 61, 0.3);
  vertical-align: middle;
  white-space: nowrap;
}
.feed-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}
.feed-table tbody tr:hover td { background: var(--bg-alt); }
.feed-table tbody tr.fresh td {
  animation: flash 1.8s;
}
@keyframes flash {
  0%   { background: rgba(88, 166, 255, 0.18); }
  100% { background: transparent; }
}
.feed-table tbody tr.pinned {
  background: rgba(188, 140, 255, 0.08);
  border-left: 2px solid var(--purple);
}
.feed-table tbody tr.pinned td:first-child::before {
  content: "📌 ";
  margin-right: 2px;
}
.feed-table tbody tr.selected td {
  background: rgba(88, 166, 255, 0.12) !important;
}
.feed-table tbody tr.placeholder td {
  color: var(--text-mut);
  text-align: center;
  padding: 20px;
}

.time-cell   { color: var(--text-dim); }
.side-cell   { font-weight: 600; }
.side-cell.buy   { color: var(--green); }
.side-cell.sell  { color: var(--red); }
.money-cell      { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; padding-right: 12px !important; }
.money-cell.tier1 { color: var(--text); }
.money-cell.tier2 { color: var(--yellow); font-weight: 600; }
.money-cell.tier3 { color: var(--orange); font-weight: 700; }
.money-cell.tier4 { color: var(--purple); font-weight: 700; }
.money-cell .whale { margin-right: 4px; }

/* Trader cell */
.trader-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text);
}
.trader-cell.named       { color: var(--blue);   font-weight: 600; }
.trader-cell.pseudo      { color: var(--text);   }
.trader-cell.anon        { color: var(--text-mut); font-style: italic; font-size: 11px; }
.trader-cell.waiting     { color: var(--text-mut); font-style: italic; opacity: 0.6; }
.trader-cell:hover       { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }

/* Extra contextual columns */
.mkt-vol-cell { text-align: right; padding-right: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.mkt-vol-cell.big  { color: var(--text); }
.mkt-vol-cell.huge { color: var(--blue); font-weight: 600; }
.hot-cell { text-align: right; padding-right: 12px; color: var(--text-mut); font-variant-numeric: tabular-nums; }
.hot-cell.warm  { color: var(--yellow); }
.hot-cell.hot   { color: var(--orange); font-weight: 600; }
.hot-cell.blaze { color: var(--red);    font-weight: 700; }
.ends-cell { text-align: right; padding-right: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ends-cell.soon   { color: var(--yellow); font-weight: 600; }
.ends-cell.urgent { color: var(--red);    font-weight: 700; }
.ends-cell.done   { color: var(--text-mut); }
.market-cell {
  max-width: 0;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Probability bar ─────────────────────────────────────────────── */
.prob {
  position: relative;
  width: 160px;
  height: 16px;
  background: var(--bg-alt);
  border-radius: 3px;
  overflow: hidden;
}
.prob-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, var(--red-d), var(--yellow), var(--green-d));
  opacity: 0.55;
}
.prob-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #fff;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-shadow:
    0 0 2px rgba(0,0,0,0.9),
    0 0 4px rgba(0,0,0,0.8);
  letter-spacing: 0.3px;
}
.prob.side-sell .prob-fill {
  /* inverse: for SELL of a Yes token, the "direction" reads opposite */
}

/* ─── Secondary tabs ──────────────────────────────────────────── */
.secondary {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  height: 270px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}
.tabs {
  display: flex;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tab {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 10px 20px;
  cursor: pointer;
  border-right: 1px solid var(--border);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); background: var(--bg); }
.tab.active {
  color: var(--text);
  background: var(--bg);
  border-bottom-color: var(--blue);
}
.tab-right {
  margin-left: auto;
  padding: 8px 16px;
  font-size: 11px;
  color: var(--text-mut);
  font-family: var(--mono);
  align-self: center;
}
.tab-body {
  flex: 1;
  overflow: auto;
  padding: 0 20px;
}
.tab-body.hidden { display: none; }
.sec-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
}
.sec-table thead th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 500;
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
  background: var(--bg);
  position: sticky;
  top: 0;
}
.sec-table thead th.num { text-align: right; padding-right: 12px; }
.sec-table tbody td {
  padding: 6px 10px 6px 0;
  border-bottom: 1px solid rgba(48, 54, 61, 0.25);
  white-space: nowrap;
}
.sec-table tbody td.num { text-align: right; padding-right: 12px; }
.sec-table tbody tr { cursor: pointer; }
.sec-table tbody tr:hover td { background: var(--bg-alt); }

/* ─── Drawer ──────────────────────────────────────────────────── */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 100vw;
  background: var(--bg-alt);
  border-left: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(0,0,0,0.4);
  animation: drawerIn 0.2s ease-out;
}
.drawer.hidden { display: none; }
@keyframes drawerIn {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.drawer-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}
.drawer-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}
.drawer-body {
  flex: 1;
  overflow: auto;
  padding: 16px 20px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}
.drawer-stat {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(48, 54, 61, 0.3);
}
.drawer-stat .k { color: var(--text-mut); }
.drawer-stat .v { color: var(--text); font-weight: 500; }
.drawer-section-title {
  margin: 18px 0 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-mut);
}
.drawer-trade {
  display: grid;
  grid-template-columns: 64px 48px 60px 1fr;
  gap: 8px;
  padding: 4px 0;
  font-size: 11px;
  border-bottom: 1px solid rgba(48, 54, 61, 0.2);
}
.drawer-trade .s-buy  { color: var(--green); font-weight: 600; }
.drawer-trade .s-sell { color: var(--red);   font-weight: 600; }

/* ─── Footer ──────────────────────────────────────────────────── */
footer {
  padding: 7px 20px;
  border-top: 1px solid var(--border);
  color: var(--text-mut);
  font-size: 11px;
  font-family: var(--mono);
  background: var(--bg-alt);
  text-align: center;
  flex-shrink: 0;
}
.sep { margin: 0 10px; }

/* ─── Scrollbars ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ─── Utility ─────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 780px) {
  body { overflow: auto; height: auto; }
  header { grid-template-columns: 1fr; gap: 8px; }
  .controls { justify-content: flex-start; flex-wrap: wrap; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi .val { font-size: 16px; }
  .spark { width: 60px; }
  .hero { min-height: 50vh; }
  .secondary { height: 300px; }
  .feed-table colgroup .c-prob { width: 120px; }
  .prob { width: 100px; }
  .drawer { width: 100%; }
}
