:root {
  --bg: #080a12;
  --bg-soft: #0d101c;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-strong: rgba(255, 255, 255, 0.075);
  --border: rgba(255, 255, 255, 0.085);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eaf0fb;
  --text-dim: #a9b4c9;
  --text-faint: #6d7893;
  --yes: #22d3ee;
  --yes-soft: rgba(34, 211, 238, 0.12);
  --no: #f472b6;
  --no-soft: rgba(244, 114, 182, 0.12);
  --violet: #a78bfa;
  --green: #4ade80;
  --amber: #fbbf24;
  --red: #fb7185;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 24px 70px -30px rgba(0, 0, 0, 0.8);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.ambient {
  position: fixed;
  inset: -20vh -10vw auto -10vw;
  height: 80vh;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(45% 50% at 18% 22%, rgba(34, 211, 238, 0.14), transparent 70%),
    radial-gradient(45% 50% at 82% 10%, rgba(167, 139, 250, 0.13), transparent 70%),
    radial-gradient(35% 45% at 55% 45%, rgba(244, 114, 182, 0.07), transparent 70%);
  filter: blur(8px);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- top bar ---------- */

.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 74px;
  padding: 0 26px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 10, 18, 0.78);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid rgba(34, 211, 238, 0.35);
  background: linear-gradient(145deg, rgba(34, 211, 238, 0.22), rgba(167, 139, 250, 0.12));
  color: var(--yes);
  font-family: var(--mono);
  font-weight: 800;
  font-size: 18px;
  box-shadow: inset 0 0 24px rgba(34, 211, 238, 0.08);
}

.brand-copy { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--mono); font-weight: 700; letter-spacing: 0.1em; font-size: 15px; }
.brand-name span { color: var(--yes); }
.brand-sub { color: var(--text-faint); font-size: 10.5px; letter-spacing: 0.04em; margin-top: 3px; }

.top-stats {
  display: flex;
  align-items: center;
  gap: 28px;
  margin-left: auto;
}

.stat { display: flex; flex-direction: column; line-height: 1.15; min-width: 58px; }
.stat span { font-family: var(--mono); font-size: 15px; font-weight: 650; color: var(--text); }
.stat label { margin-top: 3px; color: var(--text-faint); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.11em; }
.stat.wide span { font-size: 12px; font-weight: 500; color: var(--text-dim); }

.top-actions { display: flex; align-items: center; gap: 13px; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 10.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5);
  animation: pulse 2.4s infinite;
}
.status.stale i { background: var(--amber); animation: none; }
.status.error i { background: var(--red); animation: none; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.35); }
  50% { box-shadow: 0 0 0 5px rgba(74, 222, 128, 0); }
}

.btn {
  border: 1px solid var(--border-strong);
  background: var(--panel-strong);
  border-radius: 9px;
  padding: 7px 13px;
  color: var(--text);
  font-size: 12px;
  font-weight: 550;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.26); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.ghost { background: transparent; color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); }

/* ---------- layout ---------- */

.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 372px minmax(0, 1fr);
  height: calc(100vh - 74px - 34px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: rgba(10, 13, 23, 0.5);
}

.sidebar-tools {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 16px 16px 10px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  transition: border-color 0.15s ease, background 0.15s ease;
}
.search:focus-within { border-color: rgba(34, 211, 238, 0.45); background: rgba(34, 211, 238, 0.04); }
.search svg { width: 15px; height: 15px; flex: none; fill: none; stroke: var(--text-faint); stroke-width: 2; stroke-linecap: round; }
.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
}
.search input::placeholder { color: var(--text-faint); }

.select-wrap { position: relative; }
.select-wrap select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  padding: 8px 30px 8px 10px;
  color: var(--text-dim);
  font-size: 12px;
  outline: 0;
}
.select-wrap::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-faint);
  border-bottom: 1.5px solid var(--text-faint);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.list-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 18px 9px;
  color: var(--text-faint);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.market-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 10px 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}
.market-list::-webkit-scrollbar { width: 8px; }
.market-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 999px; }

.market-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: start;
  width: 100%;
  padding: 10px 9px;
  margin-bottom: 3px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  text-align: left;
  transition: background 0.13s ease, border-color 0.13s ease;
}
.market-item:hover { background: rgba(255, 255, 255, 0.045); }
.market-item.active {
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.11), rgba(167, 139, 250, 0.055));
  border-color: rgba(34, 211, 238, 0.25);
}
.market-item.closed .market-title { color: var(--text-dim); }

.market-rank {
  display: grid;
  place-items: center;
  height: 22px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 10px;
}
.market-item.active .market-rank { color: var(--yes); background: var(--yes-soft); }
.market-rank.off { color: var(--text-faint); background: transparent; }

.load-more {
  display: flex;
  justify-content: space-between;
  width: calc(100% - 6px);
  margin: 6px 3px 0;
  padding: 9px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 550;
}
.load-more span { color: var(--text-faint); font-family: var(--mono); font-size: 10px; }
.load-more:hover { border-color: rgba(34, 211, 238, 0.4); color: var(--text); background: rgba(34, 211, 238, 0.04); }

.market-main { min-width: 0; }
.market-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text);
  font-size: 12.25px;
  line-height: 1.36;
  font-weight: 500;
}
.market-sub {
  margin-top: 4px;
  overflow: hidden;
  color: var(--text-faint);
  font-size: 10.25px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.market-nums { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; padding-top: 1px; }
.market-price { font-family: var(--mono); font-size: 12px; color: var(--yes); }
.market-volume { font-family: var(--mono); font-size: 9.75px; color: var(--text-faint); }

.content {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 26px 30px 46px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}
.content::-webkit-scrollbar { width: 10px; }
.content::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.13); border-radius: 999px; }

/* ---------- detail ---------- */

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: flex-start;
  margin-bottom: 20px;
}
.detail-copy { max-width: 920px; }
.eyebrow {
  margin-bottom: 6px;
  color: var(--yes);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.detail-copy h1 {
  margin: 0;
  font-size: clamp(22px, 2.3vw, 31px);
  font-weight: 650;
  line-height: 1.18;
  letter-spacing: -0.02em;
}
.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 14px;
  margin-top: 10px;
  color: var(--text-faint);
  font-size: 11px;
}
.meta b { color: var(--text-dim); font-weight: 550; }
.meta .dot { color: rgba(255, 255, 255, 0.18); }

.detail-side { display: flex; flex-direction: column; align-items: flex-end; gap: 9px; flex: none; }
.rank-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid rgba(34, 211, 238, 0.28);
  border-radius: 999px;
  background: var(--yes-soft);
  color: var(--yes);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.rank-pill.muted { border-color: var(--border); background: var(--panel); color: var(--text-faint); }
.end-date { color: var(--text-faint); font-size: 10.5px; text-align: right; }

.quote-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 14px;
}

.quote-card {
  position: relative;
  overflow: hidden;
  padding: 15px 17px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018));
}
.quote-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--yes);
  opacity: 0.85;
}
.quote-card.no::before { background: var(--no); }
.quote-card.yes { box-shadow: inset 0 0 80px -60px var(--yes); }
.quote-card.no { box-shadow: inset 0 0 80px -60px var(--no); }

.quote-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.quote-label { display: flex; align-items: center; gap: 7px; font-weight: 650; font-size: 12px; letter-spacing: 0.06em; }
.quote-label i { width: 7px; height: 7px; border-radius: 50%; background: var(--yes); }
.quote-card.no .quote-label i { background: var(--no); }
.quote-outcome { color: var(--text-faint); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }

.quote-prices { display: flex; align-items: baseline; gap: 22px; margin-top: 8px; }
.quote-price { display: flex; flex-direction: column; gap: 1px; }
.quote-price span { color: var(--text-faint); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; }
.quote-price strong { font-family: var(--mono); font-size: 27px; font-weight: 650; line-height: 1.1; letter-spacing: -0.03em; }
.quote-price.buy strong { color: var(--yes); }
.quote-card.no .quote-price.buy strong { color: var(--no); }
.quote-price.sell strong { color: var(--text); }

.quote-sub { margin-top: 8px; color: var(--text-faint); font-family: var(--mono); font-size: 10px; }

.chart-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  box-shadow: var(--shadow);
  padding: 16px 18px 13px;
}
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}
.chart-head h2 { margin: 0; font-size: 13.5px; font-weight: 600; }
.chart-head p { margin: 2px 0 0; color: var(--text-faint); font-size: 10.5px; }

.segmented { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--border); border-radius: 8px; background: rgba(0, 0, 0, 0.18); }
.segmented button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 4px 9px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.segmented button:hover { color: var(--text-dim); }
.segmented button.active { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.segmented button[data-series="YES"].active { color: var(--yes); background: var(--yes-soft); }
.segmented button[data-series="NO"].active { color: var(--no); background: var(--no-soft); }

.chart-box { position: relative; height: 318px; }
.chart-box.tall { height: 400px; }
.chart-box canvas { display: block; width: 100% !important; height: 100% !important; }
.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  font-size: 12px;
  pointer-events: none;
}

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.chart-grid .chart-box { height: 235px; }

/* ---------- table ---------- */

.table-card {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.022);
  overflow: hidden;
}
.table-card summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 17px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  list-style: none;
  user-select: none;
}
.table-card summary::-webkit-details-marker { display: none; }
.table-card summary::before {
  content: "▸";
  margin-right: 8px;
  color: var(--text-faint);
  transition: transform 0.15s ease;
}
.table-card[open] summary::before { transform: rotate(90deg); }
.summary-meta { margin-left: auto; color: var(--text-faint); font-family: var(--mono); font-size: 10.5px; font-weight: 400; }
.table-actions { display: flex; justify-content: flex-end; padding: 0 17px 10px; }

.table-wrap { max-height: 430px; overflow: auto; border-top: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 12px;
  background: #101422;
  border-bottom: 1px solid var(--border-strong);
  color: var(--text-faint);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
  color: var(--text-dim);
  font-family: var(--mono);
  white-space: nowrap;
}
tbody tr:hover { background: rgba(255, 255, 255, 0.035); }
tbody td.side-yes { color: var(--yes); }
tbody td.side-no { color: var(--no); }
.num { text-align: right; }
th.num { text-align: right; }

/* ---------- states ---------- */

.state {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  min-height: 50vh;
  text-align: center;
  color: var(--text-dim);
}
.state h2 { margin: 0; color: var(--text); font-size: 18px; }
.state p { margin: 0; color: var(--text-faint); font-size: 12.5px; }
.state code {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--yes);
  font-family: var(--mono);
  font-size: 11.5px;
}
.state.error h2 { color: var(--red); }
.spinner {
  width: 26px;
  height: 26px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--yes);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- footer ---------- */

.footer {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  height: 34px;
  padding: 0 24px;
  border-top: 1px solid var(--border);
  background: rgba(8, 10, 18, 0.9);
  color: var(--text-faint);
  font-size: 10px;
}
.footer-links { display: flex; gap: 14px; font-family: var(--mono); }
.footer-links a:hover { color: var(--yes); }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .top-stats { gap: 18px; }
  .stat.wide { display: none; }
  .layout { grid-template-columns: 330px minmax(0, 1fr); }
  .content { padding: 22px 22px 40px; }
}

@media (max-width: 860px) {
  body { overflow: auto; }
  .topbar { height: auto; padding: 12px 16px; flex-wrap: wrap; gap: 12px; }
  .brand { min-width: 0; }
  .top-stats { order: 3; width: 100%; margin-left: 0; justify-content: space-between; }
  .top-actions { margin-left: auto; }
  .layout { display: block; height: auto; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); max-height: 44vh; }
  .market-list { max-height: 31vh; }
  .content { overflow: visible; padding: 20px 16px 40px; }
  .detail-head { flex-direction: column; }
  .detail-side { align-items: flex-start; flex-direction: row; }
  .quote-grid, .chart-grid { grid-template-columns: 1fr; }
  .chart-box.tall { height: 320px; }
  .footer { height: auto; padding: 10px 16px; flex-wrap: wrap; }
}

@media (max-width: 520px) {
  .brand-sub { display: none; }
  .top-stats { gap: 10px; }
  .stat { min-width: 0; }
  .stat span { font-size: 13px; }
  .stat label { font-size: 8.5px; }
  .status { display: none; }
  .quote-prices { gap: 14px; }
  .quote-price strong { font-size: 23px; }
  .chart-card { padding: 13px 12px 9px; }
  .chart-head { flex-direction: column; }
  .chart-box.tall { height: 280px; }
  .chart-grid .chart-box { height: 210px; }
}
