:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --line: #e7ebf3;
  --text: #111827;
  --muted: #667085;
  --up: #e03131;      /* 涨 = 红 */
  --up-bg: #fef0f0;
  --up-deep: #d92d20;
  --down: #12964c;    /* 跌 = 绿 */
  --down-bg: #ecf9f1;
  --accent: #2563eb;
  --accent-2: #3b82f6;
  --navy-1: #0b1322;
  --navy-2: #14233f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .12);
  --shadow-hover: 0 2px 4px rgba(16, 24, 40, .05), 0 14px 34px -12px rgba(16, 24, 40, .18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* 确保 hidden 属性始终生效（避免 display:flex/grid 覆盖） */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(37, 99, 235, .06), transparent 60%),
    radial-gradient(900px 400px at 10% -5%, rgba(147, 51, 234, .05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== 顶栏（深色渐变） ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 14px 24px;
  background:
    radial-gradient(900px 300px at 15% 0%, rgba(59, 130, 246, .22), transparent 60%),
    radial-gradient(700px 260px at 90% 0%, rgba(124, 58, 237, .16), transparent 55%),
    linear-gradient(135deg, var(--navy-1), var(--navy-2));
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset, 0 8px 24px -12px rgba(6, 10, 24, .5);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  box-shadow: 0 4px 14px -4px rgba(59, 130, 246, .65), 0 0 0 1px rgba(255, 255, 255, .18) inset;
}
.brand h1 { font-size: 18px; font-weight: 700; letter-spacing: .2px; line-height: 1.25; }
.sub { font-size: 12px; color: rgba(255, 255, 255, .55); }

.status { display: flex; align-items: center; gap: 12px; font-size: 12px; color: rgba(255, 255, 255, .8); }
.live {
  display: inline-flex; align-items: center; gap: 6px;
  font-weight: 700; font-size: 11px; letter-spacing: 1.5px; color: #7ee2a8;
}
.live .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #34d399; box-shadow: 0 0 0 0 rgba(52, 211, 153, .6);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .55); }
  70% { box-shadow: 0 0 0 9px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.badge {
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .14);
  color: rgba(255, 255, 255, .9);
  padding: 3px 10px; border-radius: 999px; font-weight: 600;
  backdrop-filter: blur(4px);
}
.time { font-variant-numeric: tabular-nums; opacity: .85; }

.switch { position: relative; width: 40px; height: 22px; display: inline-block; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; border-radius: 999px;
  background: rgba(255, 255, 255, .22); transition: .25s; cursor: pointer;
}
.slider::before {
  content: ""; position: absolute; width: 16px; height: 16px;
  left: 3px; top: 3px; border-radius: 50%; background: #fff;
  transition: .25s; box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
.switch input:checked + .slider { background: linear-gradient(135deg, #3b82f6, #8b5cf6); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ===== 总览卡片（玻璃拟态） ===== */
.overview {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 12px; padding: 18px 24px 6px;
  max-width: 1420px; margin: 0 auto;
}
.ov-card {
  position: relative; overflow: hidden;
  background: rgba(255, 255, 255, .72);
  border: 1px solid rgba(255, 255, 255, .9);
  backdrop-filter: blur(14px);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 3px;
  box-shadow: 0 4px 18px -8px rgba(15, 23, 42, .14);
  transition: transform .18s ease, box-shadow .18s ease;
}
.ov-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 40%);
}
.ov-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.ov-top { display: flex; align-items: center; gap: 8px; position: relative; z-index: 1; }
.ov-icon {
  width: 28px; height: 28px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800; color: #fff;
  box-shadow: 0 3px 8px -2px rgba(0, 0, 0, .25);
}
.ov-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.ov-price { font-size: 20px; font-weight: 800; letter-spacing: -.3px; font-variant-numeric: tabular-nums; position: relative; z-index: 1; }
.ov-pct {
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; gap: 4px; position: relative; z-index: 1;
  padding: 1px 8px; border-radius: 999px; width: fit-content;
}
.up { color: var(--up-deep); }
.down { color: var(--down); }
.flat { color: var(--muted); }
.ov-pct.up { background: var(--up-bg); }
.ov-pct.down { background: var(--down-bg); }
.ov-pct.flat { background: #f2f4f8; }

.ov-skel {
  height: 52px; border-radius: 8px;
  background: linear-gradient(90deg, #edf1f7 25%, #f8fafc 50%, #edf1f7 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== Tab ===== */
.tabs {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px 0; max-width: 1420px; margin: 0 auto;
}
.tab-group {
  display: inline-flex; gap: 4px; padding: 4px;
  background: #e9edf4; border-radius: 12px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05) inset;
}
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  border: none; cursor: pointer;
  padding: 8px 18px; border-radius: 9px;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  background: transparent; transition: all .2s ease;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--card); color: var(--accent);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .1), 0 4px 12px -4px rgba(16, 24, 40, .14);
}
.tab-hint { margin-left: auto; font-size: 12px; color: var(--muted); }

/* ===== 面板与工具栏 ===== */
main { max-width: 1420px; margin: 0 auto; padding: 0 24px 24px; }
.panel {
  display: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel.active { display: block; animation: fadeUp .28s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}
.search-wrap {
  flex: 1; min-width: 230px; position: relative;
  display: flex; align-items: center;
}
.search-wrap svg { position: absolute; left: 12px; color: #98a2b3; pointer-events: none; }
.search {
  width: 100%; padding: 9px 12px 9px 36px;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 13px; outline: none;
  background: var(--card); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.search::placeholder { color: #98a2b3; }
.search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--card); cursor: pointer;
  padding: 5px 13px; border-radius: 999px; font-size: 12px; font-weight: 500; color: var(--muted);
  transition: all .15s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 3px 10px -3px rgba(37, 99, 235, .55);
}
.count { font-size: 12px; color: var(--muted); }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; scrollbar-width: thin; }
.grid { width: 100%; border-collapse: collapse; white-space: nowrap; }
.grid thead th {
  background: #f7f9fc;
  padding: 11px 14px; font-size: 11.5px; color: #98a2b3; font-weight: 700;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--line); text-align: left; user-select: none;
  text-transform: uppercase;
}
.grid thead th.num, .grid tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sortable { cursor: pointer; transition: color .15s; }
.sortable:hover { color: var(--accent); }
.sortable .arrow { margin-left: 4px; font-size: 9px; opacity: .85; }
.grid tbody td {
  padding: 10px 14px; border-bottom: 1px solid #f0f3f8; font-size: 13px;
  transition: background .12s;
}
.grid tbody tr { transition: background .12s; }
.grid tbody tr:hover { background: #f6f9fe; }
.grid tbody tr:last-child td { border-bottom: none; }
.cell-sym { font-weight: 700; letter-spacing: .2px; }
.cell-name { color: var(--muted); }
.coin { display: flex; align-items: center; gap: 9px; }
.coin img, .coin .cr { width: 22px; height: 22px; border-radius: 50%; }
.coin .cr {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; flex: none;
  box-shadow: 0 2px 5px -1px rgba(0, 0, 0, .28);
}
.coin .sym { font-weight: 700; }
.coin .nm { color: var(--muted); font-size: 12px; }
.price-cell { font-weight: 700; font-variant-numeric: tabular-nums; }
.change-chip {
  display: inline-block; min-width: 78px; text-align: center;
  padding: 3px 9px; border-radius: 7px;
  font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.up .change-chip { background: var(--up-bg); color: var(--up-deep); }
.down .change-chip { background: var(--down-bg); color: var(--down); }
.flat .change-chip { background: #f2f4f8; color: var(--muted); }
.badge-state { font-size: 10px; padding: 1px 7px; border-radius: 999px; background: #eef1f6; color: var(--muted); margin-left: 6px; }
.spark { display: inline-block; vertical-align: middle; }

/* 价格变化闪烁 */
@keyframes flashUp { 0% { background: rgba(224, 49, 49, .16); } 100% { background: transparent; } }
@keyframes flashDown { 0% { background: rgba(18, 150, 76, .14); } 100% { background: transparent; } }
.f-up { animation: flashUp 1.1s ease-out; }
.f-down { animation: flashDown 1.1s ease-out; }

.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ===== 页脚 ===== */
footer { max-width: 1420px; margin: 0 auto; padding: 6px 24px 26px; text-align: center; }
footer p { font-size: 12px; color: var(--muted); }
.src-line { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; }
.src-chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line); color: #667085;
  font-weight: 600;
}
.sep { opacity: .5; margin: 0 4px; }
.err { color: var(--up-deep); margin-top: 8px; font-weight: 600; }

/* ===== K 线弹窗 ===== */
.kline-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(9, 15, 30, .55);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.kline-modal {
  width: min(1080px, 100%);
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 24px 64px -16px rgba(6, 12, 32, .5);
  overflow: hidden;
  animation: popIn .22s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.kline-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 13px 18px;
  background: linear-gradient(135deg, var(--navy-1), var(--navy-2));
  color: #fff;
}
.kline-title { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.kl-sym { font-size: 19px; font-weight: 800; letter-spacing: .3px; }
.kl-name { font-size: 13px; color: rgba(255, 255, 255, .6); }
.kl-price { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; margin-left: 6px; }
.kl-pct { font-size: 13px; font-weight: 700; padding: 1px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.kl-pct.up { background: rgba(224, 49, 49, .85); color: #fff; }
.kl-pct.down { background: rgba(18, 150, 76, .9); color: #fff; }
.kl-pct.flat { background: rgba(255, 255, 255, .16); color: #fff; }
.kline-periods {
  margin-left: auto; display: inline-flex; gap: 3px; padding: 3px;
  background: rgba(255, 255, 255, .1); border-radius: 9px;
}
.kline-periods button {
  border: none; cursor: pointer; background: transparent; color: rgba(255, 255, 255, .7);
  font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: 7px;
  transition: all .15s;
}
.kline-periods button:hover { color: #fff; }
.kline-periods button.active { background: #fff; color: var(--navy-1); }
.kline-close {
  border: none; cursor: pointer;
  width: 30px; height: 30px; border-radius: 9px;
  background: rgba(255, 255, 255, .1); color: rgba(255, 255, 255, .85);
  font-size: 14px; display: grid; place-items: center;
  transition: background .15s;
}
.kline-close:hover { background: rgba(255, 255, 255, .24); }
.kline-chart-wrap { position: relative; aspect-ratio: 1000 / 460; background: #fff; }
.kline-chart { width: 100%; height: 100%; display: block; cursor: crosshair; }
.kline-loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(255, 255, 255, .75); color: var(--muted); font-size: 14px;
  z-index: 2; backdrop-filter: blur(2px);
}
.kline-tip {
  position: absolute; z-index: 3; pointer-events: none;
  background: rgba(17, 24, 39, .92); color: #fff;
  font-size: 12px; line-height: 1.7; padding: 8px 11px; border-radius: 9px;
  box-shadow: 0 8px 20px -6px rgba(0, 0, 0, .4);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.kline-tip .tip-t { color: rgba(255, 255, 255, .65); font-size: 11px; margin-bottom: 2px; }
.kline-tip b.up { color: #ff8a8a; }
.kline-tip b.down { color: #5fd68b; }
.kline-foot {
  padding: 8px 18px 10px; font-size: 11.5px; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
  background: #fbfcfe; border-top: 1px solid var(--line);
}

/* ===== 响应式 ===== */
@media (max-width: 980px) {
  .overview { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 12px 16px; }
  .tabs, main, footer { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 560px) {
  .overview { grid-template-columns: 1fr; }
  .status { width: 100%; justify-content: space-between; }
}
