:root {
  --bg: #f5f6f8; --panel: #ffffff; --panel2: #f0f2f5; --text: #12151a; --muted: #6b7280; --faint: #9aa1ac; --line: #e3e6eb;
  --accent: #2563eb; --accent-soft: #e7efff;
  --good: #15803d; --good-soft: #e3f5e9; --bad: #c62828; --bad-soft: #fdeaea; --warn: #b45309; --warn-soft: #fdf2e1;
  --info: #4f46e5; --info-soft: #ecebfd;
  --green: #16a34a; --red: #dc2626; --up: var(--green); --down: var(--red);
  --radius: 14px; --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1014; --panel: #151a21; --panel2: #1c222b; --text: #e7eaef; --muted: #9aa3b0; --faint: #6b7480; --line: #262d37;
    --accent: #5b8def; --accent-soft: #1b2740;
    --good: #4ade80; --good-soft: #13281b; --bad: #f87171; --bad-soft: #2e1717; --warn: #fbbf24; --warn-soft: #2d2412;
    --info: #a5b4fc; --info-soft: #1e1f3a; --green: #22c55e; --red: #ef4444;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1014; --panel: #151a21; --panel2: #1c222b; --text: #e7eaef; --muted: #9aa3b0; --faint: #6b7480; --line: #262d37;
  --accent: #5b8def; --accent-soft: #1b2740;
  --good: #4ade80; --good-soft: #13281b; --bad: #f87171; --bad-soft: #2e1717; --warn: #fbbf24; --warn-soft: #2d2412;
  --info: #a5b4fc; --info-soft: #1e1f3a; --green: #22c55e; --red: #ef4444;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}
:root.redup { --up: var(--red); --down: var(--green); }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); } .down { color: var(--down); } .muted { color: var(--muted); } .faint { color: var(--faint); }
.small { font-size: 12px; } .tiny { font-size: 11px; }
.b { font-weight: 600; }

/* ---------- 顶栏 ---------- */
.top {
  position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--panel) 92%, transparent);
  backdrop-filter: saturate(1.6) blur(10px); border-bottom: 1px solid var(--line);
}
.top-in { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 54px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand .logo { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, #2563eb, #7c3aed); display: grid; place-items: center; color: #fff; font-size: 14px; }
.brand small { font-weight: 500; color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 7px 12px; border-radius: 9px; color: var(--muted); white-space: nowrap; font-weight: 500; }
.tabs a:hover { background: var(--panel2); color: var(--text); }
.tabs a.on { background: var(--accent-soft); color: var(--accent); }
.top-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.fresh { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.ok { background: var(--green); } .dot.stale { background: var(--warn); } .dot.err { background: var(--red); }

/* ---------- 底部导航 (手机) ---------- */
.bottom {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--panel); border-top: 1px solid var(--line);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
.bottom a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 0; color: var(--muted); font-size: 11px; }
.bottom a svg { width: 22px; height: 22px; }
.bottom a.on { color: var(--accent); }

/* ---------- 布局 ---------- */
main { max-width: 1240px; margin: 0 auto; padding: 18px 16px 40px; }
.page-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 2px 0 14px; }
.page-h h1 { font-size: 20px; margin: 0; }
.page-h .sub { color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.mrow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 8px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.mrow:last-child { border-bottom: 0; }
.mrow:hover { background: var(--panel2); }
.mrow .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 14px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h2 .act { font-size: 12px; font-weight: 500; }
.card h3 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); font-weight: 600; }
.stack > * + * { margin-top: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.kv > div:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }
.big { font-size: 26px; font-weight: 700; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.mid { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sep { height: 1px; background: var(--line); margin: 12px 0; }
.note { background: var(--panel2); border-radius: 10px; padding: 10px 12px; color: var(--muted); font-size: 13px; }
.note b { color: var(--text); }
ul.clean { list-style: none; padding: 0; margin: 0; }
ul.clean li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
ul.clean li:last-child { border-bottom: 0; }
ul.dots { margin: 6px 0; padding-left: 18px; } ul.dots li { margin: 3px 0; }

/* ---------- 组件 ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--panel2); color: var(--muted); }
.chip.bad { background: var(--bad-soft); color: var(--bad); } .chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.good { background: var(--good-soft); color: var(--good); } .chip.info { background: var(--info-soft); color: var(--info); }
.score { display: inline-grid; place-items: center; min-width: 40px; height: 26px; padding: 0 7px; border-radius: 8px; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; }
.s5 { background: #15803d; color: #fff; } .s4 { background: #22c55e; color: #fff; } .s3 { background: var(--panel2); color: var(--text); }
.s2 { background: #f59e0b; color: #fff; } .s1 { background: #dc2626; color: #fff; } .s0 { background: var(--panel2); color: var(--faint); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 7px 13px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--panel2); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.pri:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
input.in, select.in { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 11px; width: 100%; min-width: 0; outline: none; }
input.in:focus, select.in:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.fld { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
.seg { display: inline-flex; background: var(--panel2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 13px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.scr-ctrl { display: flex; gap: 8px; flex: 1; justify-content: flex-end; min-width: 240px; }
.scr-ctrl input.in { max-width: 200px; }
.scr-ctrl select.in { width: auto; }
.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; font-size: 13px; color: var(--muted); }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }
.bar { height: 8px; border-radius: 99px; background: var(--panel2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.alloc { display: flex; height: 30px; border-radius: 9px; overflow: hidden; font-size: 12px; font-weight: 600; color: #fff; }
.alloc > div { display: grid; place-items: center; white-space: nowrap; overflow: hidden; }
.spark { width: 100%; height: 44px; display: block; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 40px 0; }
.spin { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; z-index: 50; font-size: 13px; box-shadow: var(--shadow); max-width: calc(100% - 32px); }

/* ---------- 结论卡 ---------- */
.verdict { border-radius: var(--radius); padding: 16px 18px; border: 1px solid; }
.verdict .t { font-size: 22px; font-weight: 750; }
.verdict.buy { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.verdict.buy .t { color: var(--good); }
.verdict.buy_small { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.verdict.buy_small .t { color: var(--info); }
.verdict.wait { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.verdict.wait .t { color: var(--warn); }
.verdict.avoid { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.verdict.avoid .t { color: var(--bad); }
.mode-card { border-left: 5px solid var(--accent); }
.mode-进攻 { border-left-color: var(--green); } .mode-BTC为主 { border-left-color: var(--accent); }
.mode-谨慎 { border-left-color: #f59e0b; } .mode-防守 { border-left-color: var(--red); }
.plan-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.plan-grid > div { background: var(--panel2); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.plan-grid .l { font-size: 11px; color: var(--muted); }
.plan-grid .v { font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.gbar { display: grid; grid-template-columns: 92px 1fr 34px; gap: 8px; align-items: center; margin: 5px 0; font-size: 13px; }
.ring { width: 92px; height: 92px; flex: none; }

/* ---------- 列表 ---------- */
.list { display: flex; flex-direction: column; }
.lrow {
  display: grid; grid-template-columns: 28px minmax(130px, 1.4fr) 1fr .8fr .8fr 64px minmax(180px, 2.2fr) .9fr;
  gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.lrow:hover { background: var(--panel2); }
.lrow.head { cursor: default; color: var(--muted); font-size: 12px; font-weight: 600; background: transparent; position: sticky; top: 54px; background: var(--panel); z-index: 2; }
.lrow.head:hover { background: var(--panel); }
.lrow .c-coin { min-width: 0; }
.lrow .c-coin .s { font-weight: 650; }
.lrow .c-coin .n { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow .c-flags { display: flex; gap: 4px; flex-wrap: wrap; }
.lrow .r { text-align: right; font-variant-numeric: tabular-nums; }
.lrow .idx { color: var(--faint); font-size: 12px; }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 7px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.t td.r, table.t th.r { text-align: right; }
table.t tr.hl td { background: var(--accent-soft); }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--panel2); }
.pos-card .acts li { padding: 6px 10px; border-radius: 8px; margin-top: 6px; font-size: 13px; }
.acts .bad { background: var(--bad-soft); color: var(--bad); } .acts .warn { background: var(--warn-soft); color: var(--warn); }
.acts .good { background: var(--good-soft); color: var(--good); } .acts .info { background: var(--panel2); color: var(--muted); }
.chart { width: 100%; height: 380px; }
.chart.sm { height: 260px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.more-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.more-links a { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; color: var(--text); }
.more-links a b { display: block; margin-bottom: 2px; }
.more-links a span { color: var(--muted); font-size: 12px; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; }
.login .brand { justify-content: center; font-size: 20px; margin-bottom: 18px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* ---------- 响应式 ---------- */
@media (max-width: 1000px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .g12 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .tabs, .fresh .txt { display: none; }
  .bottom { display: flex; }
  main { padding: 14px 16px calc(84px + env(safe-area-inset-bottom)); }
  .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .lrow { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "coin price score" "flags flags flags"; padding: 11px 4px; gap: 6px 10px; }
  .lrow .c-coin { grid-area: coin; } .lrow .c-price { grid-area: price; } .lrow .c-score { grid-area: score; }
  .lrow .c-flags { grid-area: flags; }
  .lrow .idx, .lrow .c-7d, .lrow .c-vol, .lrow .c-24h { display: none; }
  .lrow .c-price .chg { display: block; }
  .lrow.head { display: none; }
  .scr-ctrl { min-width: 0; width: 100%; }
  .scr-ctrl input.in { max-width: none; flex: 1; }
  .plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart { height: 300px; }
  .big { font-size: 22px; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@media (min-width: 821px) { .lrow .c-price .chg { display: none; } }
@media (max-width: 420px) { .g4 { grid-template-columns: minmax(0, 1fr); } .more-links { grid-template-columns: minmax(0, 1fr); } }
