:root {
  color-scheme: dark;
  --bg: #12140f;
  --panel: #1c1f17;
  --ink: #f4f1e6;
  --muted: #a7ab96;
  --line: #33382b;
  --gold: #d7b15e;
  --up: #ff5c5c;
  --down: #3ecf8e;
  --ask: rgba(62, 207, 142, 0.8);
  --bid: rgba(255, 92, 92, 0.85);
  font-family: "Avenir Next", "PingFang TC", "Noto Sans TC", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(215, 177, 94, 0.08), transparent 50%),
    var(--bg);
  color: var(--ink);
}

.top, main, footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  min-width: 0;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  padding: 28px 0 12px;
}

h1, h2, p { margin: 0; }

h1 { font-size: 32px; font-weight: 650; letter-spacing: 0.01em; }
h2 { font-size: 18px; font-weight: 650; }

.kicker {
  color: var(--gold);
  letter-spacing: 0.16em;
  font-size: 12px;
  margin-bottom: 4px;
}

.status-wrap { text-align: right; }
.status-wrap a { color: var(--muted); font-size: 13px; }
#status { font-variant-numeric: tabular-nums; }
#status.ok { color: var(--down); }
#status.bad { color: var(--up); }

.market-nav {
  width: min(1180px, calc(100% - 32px));
  margin: 8px auto 0;
  display: flex;
  gap: 8px;
}

.market-tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  min-width: 88px;
}

.market-tab.active {
  background: var(--gold);
  color: #1b160c;
  border-color: transparent;
}

.banner {
  width: min(1180px, calc(100% - 32px));
  margin: 8px auto 0;
  padding: 10px 12px;
  background: rgba(255, 92, 92, 0.12);
  color: #ffd0d0;
  border-radius: 8px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.hero { margin: 16px 0; cursor: pointer; }
.hero.selected { border-color: var(--gold); }
.hero-row { display: flex; align-items: baseline; gap: 16px; margin-top: 6px; }
.hero-row strong { font-size: 42px; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.hero-row span { font-size: 18px; font-variant-numeric: tabular-nums; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr);
  gap: 16px;
  align-items: start;
}

.layout > .panel,
.table-wrap { min-width: 0; }

.panel-head, form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel-head { justify-content: space-between; margin-bottom: 8px; }

input, select, button {
  font: inherit;
  color: var(--ink);
  background: #12140f;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

button {
  background: var(--gold);
  color: #1b160c;
  border-color: transparent;
  font-weight: 700;
  cursor: pointer;
}

button.ghost, button.text {
  background: transparent;
  color: var(--ink);
  border-color: transparent;
  font-weight: 550;
  padding: 4px 0;
}

button.ghost {
  color: var(--muted);
  border-color: var(--line);
  padding: 4px 8px;
}

input { width: min(148px, 100%); }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin-top: 6px; }
.error { min-height: 1.2em; color: #ffb4b4; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 550; text-align: left; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
tbody tr { cursor: pointer; }
tbody tr:hover, tr.selected { background: rgba(215, 177, 94, 0.08); }

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--ink); }

.detail h2 { margin-bottom: 8px; }
.detail-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.detail-head .last { font-size: 36px; font-variant-numeric: tabular-nums; }
.sub { color: var(--muted); margin-top: 4px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}
.stat {
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}
.stat span { display: block; color: var(--muted); font-size: 12px; }
.stat strong { font-variant-numeric: tabular-nums; font-weight: 600; }

.book { margin: 8px 0 14px; }
.book-row, .spread, .meter { display: grid; align-items: center; }
.book-row {
  grid-template-columns: 42px 1fr 72px 1.2fr;
  gap: 8px;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  padding: 3px 0;
}
.book-row .px, .book-row .vol { text-align: right; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ask .lv, .ask .px { color: var(--down); }
.bid .lv, .bid .px { color: var(--up); }
.bar { height: 8px; background: #2a2e24; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; }
.ask .bar i { background: var(--ask); }
.bid .bar i { background: var(--bid); }
.spread { justify-content: center; color: var(--gold); padding: 6px 0; font-size: 13px; }
.meter { grid-template-columns: auto; height: 8px; display: flex; overflow: hidden; border-radius: 99px; margin-top: 8px; }
.meter .bid { background: var(--bid); height: 100%; }
.meter .ask { background: var(--ask); height: 100%; }

canvas {
  width: 100%;
  height: 150px;
  margin: 4px 0 12px;
  background: #14170f;
  border-radius: 10px;
}

.notes { margin: 8px 0 0; padding-left: 18px; }
.notes li { margin: 4px 0; }

footer { color: var(--muted); font-size: 12px; padding: 18px 0 28px; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .hero-row strong { font-size: 32px; }
  h1 { font-size: 26px; }
  th, td { padding: 8px 6px; }
}

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
