:root {
  --bg: #f3f4ff;
  --panel: #ffffff;
  --panel-2: #f7f4ff;
  --line: #e5ddfa;
  --text: #191839;
  --muted: #6b6a8c;
  --gold: #7027d9;
  --gold-soft: rgba(112, 39, 217, .08);
  --grad: linear-gradient(110deg, #009cff, #4936ff 55%, #a014f8);
  --grad-dot: linear-gradient(120deg, #8933ff, #5500e8);
  --up: #16a34a;
  --up-soft: rgba(22, 163, 74, .10);
  --down: #e11d48;
  --down-soft: rgba(225, 29, 72, .09);
  --radius: 20px;
  --shadow: 0 0 0 1px #ece6fb, 0 3px 12px rgba(118, 47, 242, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

/* 顶栏 */
.top { position: sticky; top: 0; z-index: 10; background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 3px 8px rgba(112, 39, 217, .28)); }
.brand-t { display: grid; line-height: 1.15; }
.brand-t b { font-size: 16px; letter-spacing: .5px; }
.brand-t small { font-size: 11px; font-weight: 500; color: var(--gold); letter-spacing: 1px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tabs a { color: var(--muted); padding: 7px 14px; border-radius: 999px; white-space: nowrap; font-size: 14px; }
.tabs a:hover { color: var(--text); text-decoration: none; background: var(--panel-2); }
.tabs a.on { color: #fff; background: var(--grad-dot); font-weight: 600; }

/* 区块 */
h1 { font-size: 22px; margin: 28px 0 4px; }
h2 { font-size: 17px; margin: 0; }
.sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .muted { font-size: 13px; }

/* 指标 */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; min-width: 0; box-shadow: var(--shadow); }
.kpi .k { color: var(--muted); font-size: 13px; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.kpi .d { font-size: 13px; color: var(--muted); margin-top: 2px; }
.kpi.hero { border-color: var(--gold); background: linear-gradient(180deg, var(--gold-soft), var(--panel) 70%); }
.kpi.hero.in { border-color: var(--up); background: linear-gradient(180deg, var(--up-soft), var(--panel) 70%); }
.kpi.hero.out { border-color: var(--down); background: linear-gradient(180deg, var(--down-soft), var(--panel) 70%); }

/* 表格 */
.tbl-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr:hover td { background: var(--panel-2); }
td.l, th.l { text-align: left; }

/* 图表 */
.chart { width: 100%; height: 260px; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.tip { position: fixed; pointer-events: none; background: #fff; box-shadow: var(--shadow); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.5; z-index: 20; display: none; max-width: 260px; }

/* 表单 */
.search { display: flex; gap: 8px; margin-bottom: 16px; }
.search input { flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 14px; padding: 12px 16px; font: 14px ui-monospace, SFMono-Regular, Menlo, monospace; }
.search input:focus { outline: none; border-color: var(--gold); }
button, .btn { background: var(--grad); color: #fff; border: 0; border-radius: 15px; box-shadow: 0 3px 12px rgba(118, 47, 242, .18); padding: 0 20px; font: 600 14px inherit; cursor: pointer; white-space: nowrap; }
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button.ghost { background: var(--panel); color: #5920ad; border: 1px solid var(--gold); border-radius: 9px; box-shadow: none; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: -6px 0 16px; }
.chip { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chip:hover { color: var(--text); }
.chip .x { opacity: .6; }

/* 等级徽章 */
.lv { display: inline-block; min-width: 34px; text-align: center; border-radius: 6px; padding: 1px 6px; font-size: 12px; font-weight: 700; background: var(--panel-2); color: var(--muted); }
.lv.p1, .lv.p2 { background: var(--gold-soft); color: var(--gold); }
.lv.p3, .lv.p4, .lv.p5, .lv.p6, .lv.p7 { background: var(--gold); color: #fff; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.zones { display: grid; gap: 10px; }
.zone .bar { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.zone .bar i { display: block; height: 100%; background: var(--gold); }
.zone .bar i.ok { background: var(--up); }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.empty, .loading, .err { text-align: center; color: var(--muted); padding: 32px 12px; }
.err { color: var(--down); }
.loading::before { content: ""; display: inline-block; width: 14px; height: 14px; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; margin-right: 8px; vertical-align: -2px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.note { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; margin-bottom: 12px; }
.crumbs a { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.foot { color: var(--muted); font-size: 12px; padding-top: 24px; padding-bottom: 40px; border-top: 1px solid var(--line); margin-top: 32px; }
.foot p { margin: 4px 0; }

/* 会员与结构图 */
.steps { margin: 0 0 16px; padding-left: 20px; display: grid; gap: 12px; }
.copy { display: flex; gap: 8px; align-items: center; margin: 8px 0 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 8px 8px 12px; }
.copy .mono { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.copy button { padding: 6px 12px; }
button:disabled { opacity: .5; cursor: default; }
.tree-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.tree-bar button { padding: 7px 14px; }
.tree-box { position: relative; height: 70vh; min-height: 420px; overflow: hidden; background: #faf9fd; background-image: radial-gradient(#e2dcf0 1px, transparent 1px); background-size: 18px 18px; border: 1px solid var(--line); border-radius: var(--radius); touch-action: none; cursor: grab; }
.tree-box:active { cursor: grabbing; }
.tree-inner { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.tree-inner svg { display: block; }
.node:hover rect:first-of-type { filter: brightness(1.25); }
.flow { display: grid; gap: 10px; margin-bottom: 16px; }
.flow-step { display: flex; gap: 12px; align-items: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.flow-step > b { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--grad-dot); color: #fff; font-size: 13px; box-shadow: 0 0 0 4px #f8f4ff; }
.flow-step.ok { border-color: var(--up); }
.flow-step.ok > b { background: var(--up); color: #fff; }
.flow-step .muted { font-size: 13px; }
.flow-t { font-weight: 600; margin-bottom: 2px; }
details.manual summary { cursor: pointer; color: var(--muted); }
details.manual[open] summary { color: var(--text); }
.demo-cta { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: linear-gradient(90deg, var(--gold-soft), var(--panel)); border: 1px solid var(--gold); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 14px; }
.demo-cta div { display: grid; }
.demo-cta .muted { font-size: 13px; }
.demo-cta .btn { padding: 10px 20px; flex: none; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-bottom: 18px; }
.feature { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 12px 14px; display: grid; gap: 2px; }
.feature .muted { font-size: 13px; }
.demo-tag { display: inline-block; font-size: 12px; color: var(--gold); background: var(--gold-soft); border-radius: 6px; padding: 2px 8px; margin-bottom: 8px; }

@media (max-width: 600px) {
  .top-in { height: auto; padding: 10px 16px; flex-direction: column; align-items: stretch; gap: 8px; }
  .tabs a { flex: 1; text-align: center; padding: 6px 2px; font-size: 13px; }
  h1 { font-size: 19px; margin-top: 20px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .v { font-size: 19px; }
  .card { padding: 14px; }
  .tbl-wrap { margin: 0 -14px; padding: 0 14px; }
  .chart { height: 200px; }
  .grid2 { grid-template-columns: 1fr; }
  .demo-cta { flex-direction: column; align-items: stretch; text-align: center; }
  .tree-box { height: 62vh; }
}

/* OTC */
.trust { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 16px; }
.trust > div { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: grid; gap: 2px; box-shadow: var(--shadow); }
.trust span { color: var(--muted); font-size: 13px; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.seg button { background: transparent; color: var(--muted); box-shadow: none; padding: 8px 16px; border-radius: 9px; }
.seg button.on { background: var(--grad-dot); color: #fff; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.form-grid label, label.full { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.form-grid input, .form-grid select, label.full input { background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 11px 14px; font: 15px inherit; min-width: 0; }
.form-grid input:focus, label.full input:focus { outline: none; border-color: var(--gold); }
label.full .row { display: flex; gap: 8px; }
label.full .row input { flex: 1; }
.modal { position: fixed; inset: 0; background: rgba(25, 24, 57, .35); display: grid; place-items: center; padding: 16px; z-index: 30; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border-radius: var(--radius); padding: 22px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(25, 24, 57, .25); display: grid; gap: 14px; }
.quote { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.7; }
.kpi .bal { display: grid; gap: 2px; margin: 4px 0 2px; font-size: 15px; }
.kpi .bal b { font-size: 20px; font-variant-numeric: tabular-nums; }

/* 手机：订单表变卡片，导航可横滑，表单单列，弹窗贴底 */
@media (max-width: 600px) {
  .tabs { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 -16px; padding: 0 16px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { flex: none; padding: 7px 13px; font-size: 14px; }
  .trust { grid-template-columns: 1fr 1fr; gap: 8px; }
  .trust > div { padding: 10px 12px; }
  .trust span { font-size: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid input, .form-grid select, label.full input { font-size: 16px; padding: 13px 14px; }
  .seg { display: flex; }
  .seg button { flex: 1; padding: 10px 8px; }
  #otc-create { width: 100%; padding: 14px 22px !important; font-size: 16px; }
  .tbl-wrap:has(table.cards) { margin: 0; padding: 0; overflow: visible; }
  table.cards thead { display: none; }
  table.cards, table.cards tbody { display: block; }
  table.cards tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  table.cards td { display: flex; flex-direction: column; padding: 0; border: 0; text-align: left !important; white-space: normal; font-size: 14px; }
  table.cards td::before { content: attr(data-l); font-size: 11px; color: var(--muted); }
  table.cards td.price b { font-size: 18px; }
  table.cards td.act { grid-column: 1 / -1; }
  table.cards td.act::before { content: none; }
  table.cards td.act button { width: 100%; padding: 11px 14px !important; font-size: 15px; }
  tbody tr:hover td { background: none; }
  .modal { place-items: end center; padding: 0; }
  .modal-box { max-width: none; border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; }
  label.full .row button { padding: 0 16px !important; }
  .kpi .bal b { font-size: 18px; }
}

/* 钱包选择 */
.wlist { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wbtn { display: flex; align-items: center; gap: 10px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: none; font-weight: 600; font-size: 14px; text-align: left; }
.wbtn:hover { border-color: var(--gold); text-decoration: none; filter: none; }
.wbtn img, .wbtn .wicon { width: 30px; height: 30px; border-radius: 9px; flex: none; }
.wicon { display: grid; place-items: center; background: var(--grad-dot); color: #fff; font-size: 14px; }

/* 订单簿的买入 / 卖出按钮：放最前面，颜色区分 */
table.book td.act { width: 1%; padding-right: 14px; }
.act-btn { padding: 9px 22px; font-size: 15px; font-weight: 700; min-width: 86px; }
.btn-buy { background: linear-gradient(110deg, #16a34a, #22c55e); box-shadow: 0 3px 12px rgba(22, 163, 74, .28); }
.btn-sell { background: linear-gradient(110deg, #e11d48, #f43f5e); box-shadow: 0 3px 12px rgba(225, 29, 72, .25); }
@media (max-width: 600px) {
  table.book td.act { width: auto; padding: 0; margin-bottom: 4px; }
  table.book td.act .act-btn { padding: 13px 14px !important; font-size: 17px; }
}
