/* Swiss Data Terminal — 纸白 / 黑线结构 / 直角 / 单强调色 */
:root {
  --bg: #FFFFFF;
  --ink: #0A0A0A;
  --ink-2: #525252;
  --ink-3: #8A8A8A;
  --rule: #0A0A0A;
  --rule-2: #E4E4E4;
  --hover: #FAFAFA;
  --accent: #4C6EF5;       /* 系列1 + 全局唯一强调 */
  --series-api: #E8590C;   /* 系列2:仅图表数据编码 */
  --good: #16A34A;
  --bad: #DC2626;
}
* { box-sizing: border-box; border-radius: 0 !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 400 13px/1.45 "Inter", system-ui, sans-serif;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: "Fira Code", monospace; font-variant-numeric: tabular-nums; }
button { cursor: pointer; }

/* ── masthead ─────────────────────────────────────────── */
.masthead {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1440px; margin: 0 auto; padding: 14px 24px 12px;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-title { font-size: 15px; font-weight: 800; letter-spacing: -0.01em; }
.brand-sub { font-size: 10.5px; color: var(--ink-3); font-family: "Fira Code"; }
.live-pill { display: flex; align-items: center; gap: 8px; font: 500 11px "Fira Code"; color: var(--ink-2); text-transform: uppercase; }
.live-dot { width: 7px; height: 7px; background: var(--ink-3); }
.live-dot.ok { background: var(--good); }
.live-dot.stale { background: var(--bad); }
.page-rule { border: 0; border-top: 2px solid var(--rule); margin: 0; }

/* ── 响应式网格:4档流式,模块只重排不消失 ──────────────── */
.masthead, .grid, .foot { max-width: 1800px; margin: 0 auto; }
.grid {
  display: grid;
  grid-template-columns: 164px minmax(430px, 1fr) 362px 348px;
  grid-template-areas: "kpi main venues pairs";
  min-height: calc(100vh - 120px);
}
.rail-l { grid-area: kpi; border-right: 1px solid var(--rule-2); padding: 16px 16px 24px 24px; }
.main { grid-area: main; padding: 16px 20px 24px; min-width: 0; min-height: 0; display: flex; flex-direction: column; height: calc(100vh - 108px); }
.m-chart { flex: none; }
.m-feed { flex: 1; min-height: 0; display: flex; flex-direction: column; container-type: inline-size; }
.rail-v { grid-area: venues; }
.rail-r { grid-area: pairs; }
.rail-v, .rail-r {
  border-left: 1px solid var(--rule-2); padding: 16px 18px 20px 16px;
  display: flex; flex-direction: column; height: calc(100vh - 108px);
  min-width: 0; min-height: 0;
}
.panel-scroll { flex: 1; overflow-y: auto; min-height: 0; }

/* 3列:Venues 和 Pairs 在右列上下对分 */
@media (max-width: 1500px) {
  .grid {
    grid-template-columns: 175px minmax(380px, 1fr) 362px;
    grid-template-rows: auto auto;
    grid-template-areas: "kpi main venues" "kpi main pairs";
  }
  /* 定高而非 fr:容器高度不定时 fr 会退化为 max-content(经典陷阱) */
  .rail-v, .rail-r { height: calc(50vh - 54px); min-height: 300px; }
  .rail-r { border-top: 2px solid var(--rule); }
}

/* 2列:KPI 变横向仪表条,主区与侧列并排 */
@media (max-width: 1150px) {
  .grid {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-rows: auto minmax(300px, 45vh) minmax(300px, 45vh);
    grid-template-areas: "kpi kpi" "main venues" "main pairs";
    min-height: 0;
  }
  .rail-l {
    display: flex; border-right: 0; border-bottom: 2px solid var(--rule);
    padding: 8px 24px 10px;
  }
  .rail-l .rule-thin { display: none; }
  .kpi { flex: 1; border-bottom: 0; border-right: 1px solid var(--rule-2); padding: 2px 14px 2px 0; margin-right: 14px; }
  .kpi:last-of-type { border-right: 0; margin-right: 0; }
  .kpi .v { font-size: 19px; }
  .main { height: auto; min-height: 0; }
  .feed-viewport { min-height: 200px; }
}

/* 单列:KPI → 图表 → Venues → Pairs → 实时流 */
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; grid-template-rows: none; grid-template-areas: none; }
  .rail-l, .rail-v, .rail-r, .m-chart, .m-feed { grid-area: auto; }
  .main { display: contents; }
  .rail-l { order: 1; flex-wrap: wrap; }
  .m-chart { order: 2; }
  .rail-v { order: 3; }
  .rail-r { order: 4; }
  .m-feed { order: 5; display: flex; flex-direction: column; }
  .kpi { flex: 1 1 40%; margin: 4px 0; }
  .rail-v, .rail-r, .m-chart, .m-feed { border-left: 0; border-top: 2px solid var(--rule); height: auto; padding: 14px 16px 18px; }
  .m-feed .feed-rule { display: none; }
  .feed-viewport { height: 60vh; min-height: 320px; }
  .panel-scroll { max-height: 380px; }
}



.sec-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink); margin: 0 0 10px;
}
.rule-thin { border: 0; border-top: 1px solid var(--rule-2); margin: 16px 0 14px; }

/* ── KPI rail ─────────────────────────────────────────── */
.kpi { padding: 10px 0 12px; border-bottom: 1px solid var(--rule-2); }
.kpi:first-of-type { padding-top: 2px; }
.kpi .lb { font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3); }
.kpi .v { font-family: "Fira Code"; font-size: 23px; font-weight: 600; margin-top: 4px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 10.5px; margin-top: 2px; color: var(--ink-2); }

/* ── filter bar (Live Trades 标题下方,横向) ───────────── */
.filter-bar { display: flex; gap: 10px; align-items: center; margin: 2px 0 10px; flex-wrap: wrap; }
.filter-box { position: relative; flex: 1; min-width: 240px; max-width: 420px; }
.filter-input {
  width: 100%; border: 1px solid var(--ink); padding: 7px 10px;
  font: 400 11.5px "Fira Code"; color: var(--ink); background: var(--bg); outline: none;
}
.filter-input::placeholder { color: var(--ink-3); font-family: "Inter"; }
.filter-input:focus { box-shadow: 2px 2px 0 var(--rule-2); }
.suggest {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  background: var(--bg); border: 1px solid var(--ink); border-top: 0;
  max-height: 220px; overflow-y: auto;
}
.suggest-item { padding: 7px 10px; font-size: 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.suggest-item:hover, .suggest-item.sel { background: var(--hover); }
.suggest-item .s-sym { font-weight: 600; }
.suggest-item .s-name { color: var(--ink-3); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 有样式的下拉:黑边直角 + 自绘箭头 */
.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; right: 10px; top: 50%; margin-top: -2px;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid var(--ink); pointer-events: none;
}
.venue-select {
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--ink); padding: 7px 28px 7px 10px;
  font: 600 10.5px "Inter"; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink); background: var(--bg); outline: none; cursor: pointer; min-width: 150px;
}
.venue-select:focus { box-shadow: 2px 2px 0 var(--rule-2); }

.ftags { display: flex; gap: 6px; flex-wrap: wrap; }
.ftag {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--ink); color: #fff; padding: 5px 9px; font: 500 10.5px "Fira Code";
}
.ftag .x { cursor: pointer; opacity: 0.7; font-weight: 700; padding: 0 2px; }
.ftag .x:hover { opacity: 1; }
.fhint { font-size: 10px; color: var(--ink-3); margin-top: 8px; line-height: 1.5; }

.flow-row { margin: 2px 0 8px; }
.pair-search { margin: 0 0 8px; }
.pair-search input {
  width: 100%; border: 1px solid var(--rule); background: var(--bg);
  font-family: "Fira Code"; font-size: 11px; color: var(--ink);
  padding: 5px 8px; border-radius: 0; outline: none;
}
.pair-search input:focus { border-color: var(--ink); }
.pair-search input::placeholder { color: var(--ink-3); }
.seg-sm button { padding: 3px 10px; font-size: 9.5px; }

.vtag { font-style: normal; font-size: 8px; font-weight: 700; letter-spacing: .06em; padding: 0 4px; vertical-align: 1px; }
.vtag.prop { background: var(--ink); color: #fff; }

/* ── 可排序表头 ─────────────────────────────────────────── */
.sortable { cursor: pointer; user-select: none; }
.sortable:hover { color: var(--ink); }
.sortable.on { color: var(--ink); }
.sortable.on::after { content: " ▼"; font-size: 8px; }

/* ── segmented (Swiss: 黑边直角) ──────────────────────── */
.seg { display: inline-flex; border: 1px solid var(--ink); }
.seg button {
  appearance: none; border: 0; background: var(--bg); color: var(--ink-2);
  font: 500 10.5px "Inter"; letter-spacing: 0.06em; padding: 5px 12px; text-transform: uppercase;
}
.seg button:hover { background: var(--hover); }
.seg button.on { background: var(--ink); color: #fff; font-weight: 600; }

/* ── chart ────────────────────────────────────────────── */
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.chart-controls { display: flex; gap: 10px; align-items: center; }
.legend { display: flex; gap: 14px; font-size: 10px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.legend i { width: 8px; height: 8px; display: inline-block; margin-right: 5px; }
.chart-wrap { position: relative; }
#vol-chart { width: 100%; height: 252px; display: block; }
.csv-btn {
  border: 1px solid var(--ink); background: var(--bg); color: var(--ink);
  font: 600 10px "Inter", sans-serif; letter-spacing: 0.06em; padding: 4px 10px;
  cursor: pointer; border-radius: 0;
}
.csv-btn:hover { background: var(--ink); color: #fff; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--ink); color: #fff; padding: 9px 11px; min-width: 168px;
  font-size: 11px; line-height: 17px;
}
.tooltip .tt-title { font-weight: 700; margin-bottom: 3px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 16px; color: #C9C9C9; }
.tooltip .tt-row b { color: #fff; font-family: "Fira Code"; font-weight: 600; }
.tooltip i { width: 7px; height: 7px; display: inline-block; margin-right: 5px; }

/* ── live trades ──────────────────────────────────────── */
.feed-rule { border: 0; border-top: 2px solid var(--rule); margin: 14px 0 0; }
.feed-head { display: flex; align-items: center; justify-content: space-between; margin: 10px 0 6px; }
.feed-meta { font: 400 10.5px "Fira Code"; color: var(--ink-3); }
.feed-cols, .trade-row {
  display: grid;
  grid-template-columns: 56px minmax(180px, 1fr) 88px 132px 68px 68px 88px 30px;
  gap: 8px; align-items: center; padding: 0 2px;
}
.t-order { overflow: hidden; white-space: nowrap; }
.t-order button {
  font-family: "Fira Code"; font-size: 10.5px; color: var(--ink-2);
  background: none; border: 0; padding: 0; cursor: pointer;
}
.t-order button:hover { color: var(--accent); text-decoration: underline; }
.feed-cols {
  color: var(--ink-3); font-size: 9.5px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; padding-bottom: 5px; border-bottom: 1px solid var(--rule);
}
.feed-cols .num { text-align: right; }
.feed-viewport { flex: 1; min-height: 260px; overflow-y: auto; overscroll-behavior: contain; }
.feed-spacer { position: relative; }
.feed-window { position: absolute; left: 0; right: 0; }
.trade-row { height: 38px; border-bottom: 1px solid var(--rule-2); font-size: 12px; }
.trade-row:hover { background: var(--hover); }
.trade-row.fresh { animation: flash 1.1s ease-out; }
@keyframes flash { from { background: #EEF2FF; } to { background: transparent; } }
.t-time { font-family: "Fira Code"; font-size: 10.5px; color: var(--ink-3); }
.t-swap { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-swap .amt { font-family: "Fira Code"; font-weight: 500; }
.t-swap .sym { color: var(--ink-2); }
.t-swap .arrow { color: var(--ink-3); padding: 0 5px; }
.t-usd { text-align: right; font-family: "Fira Code"; font-weight: 600; }
.t-usd.unpriced { color: var(--ink-3); font-weight: 400; }
.t-venues { display: flex; gap: 5px; overflow: hidden; }
.t-hash, .t-addr { font-family: "Fira Code"; font-size: 10.5px; }
.t-addr button {
  appearance: none; border: 0; background: none; padding: 0;
  font: inherit; color: var(--ink-2); cursor: pointer;
}
.t-addr button:hover { color: var(--accent); }
.tag {
  display: inline-block; padding: 1px 6px; font-size: 9.5px; font-weight: 600;
  letter-spacing: 0.04em; line-height: 14px;
}
.tag.if { background: var(--ink); color: #fff; }
.tag.api { border: 1px solid var(--ink-3); color: var(--ink-2); }
.tag.venue {
  color: var(--ink-3); border: 1px solid var(--rule-2); font-weight: 500;
  white-space: nowrap; cursor: pointer; background: none;
}
.tag.venue:hover { border-color: var(--ink); color: var(--ink); }
.jump-latest[hidden] { display: none; }
.jump-latest {
  position: sticky; bottom: 10px; margin: -40px auto 0; display: block;
  background: var(--ink); color: #fff; border: 0; padding: 7px 16px;
  font: 600 11px "Inter"; letter-spacing: 0.05em;
}
.empty { color: var(--ink-3); padding: 18px 2px; font-size: 12px; }

/* ── pairs rail ───────────────────────────────────────── */
.pairs-head-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.pairs-cols, .pairs-row {
  display: grid; grid-template-columns: 20px minmax(0, 1fr) 68px 50px 44px;
  gap: 8px; align-items: center;
}
.pairs-cols {
  color: var(--ink-3); font-size: 9.5px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; padding-bottom: 5px; border-bottom: 1px solid var(--rule);
}
.pairs-cols .num, .pairs-row .num { text-align: right; font-family: "Fira Code"; font-size: 10.5px; }
.pairs-row { padding: 6px 0; border-bottom: 1px solid var(--rule-2); font-size: 12px; }
.pairs-row:hover { background: var(--hover); }
.pairs-row .rank { color: var(--ink-3); font-family: "Fira Code"; font-size: 10px; }
.pair-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.pair-share { height: 2px; background: var(--accent); margin-top: 3px; }

.foot {
  max-width: 1440px; margin: 0 auto; color: var(--ink-3); font-size: 10.5px;
  line-height: 1.6; padding: 10px 24px 28px; border-top: 1px solid var(--rule-2);
}
.foot a { color: var(--ink-2); }

/* feed 自适应:按自身实际宽度(而非视口)决定显示哪些列。
   宽度不足时先收 Venues,再收 Addr+Order —— 列要么完整显示要么不显示,永不裁半 */
@container (max-width: 765px) {
  .feed-cols, .trade-row { grid-template-columns: 56px minmax(160px, 1fr) 88px 68px 68px 88px 30px; }
  .feed-cols .col-venues, .trade-row .t-venues { display: none; }
}
@container (max-width: 619px) {
  .feed-cols, .trade-row { grid-template-columns: 56px minmax(140px, 1fr) 84px 74px 34px; }
  .feed-cols .col-addr, .trade-row .t-addr,
  .feed-cols .col-order, .trade-row .t-order { display: none; }
}
