/* ===== 币圈行情 · 全局样式 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #f5f6f8; color: #1f2329; font-size: 14px; line-height: 1.5;
}
a { color: #1f2329; text-decoration: none; }
a:hover { color: #3566f0; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 12px 40px; }

/* ===== 顶栏 ===== */
.topbar { background: #fff; border-bottom: 1px solid #e8eaed; position: sticky; top: 0; z-index: 50; }
.topbar-in { max-width: 1280px; margin: 0 auto; padding: 0 12px; height: 54px; display: flex; align-items: center; justify-content: space-between; }
.logo { font-size: 20px; font-weight: 700; color: #1f2329; }
.logo span { color: #3566f0; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.update-time { color: #8a919f; font-size: 12px; }
.btn { border: 1px solid #d5d9e0; background: #fff; border-radius: 6px; padding: 5px 12px; font-size: 13px; cursor: pointer; color: #1f2329; }
.btn:hover { border-color: #3566f0; color: #3566f0; }
.btn-fav { color: #b8860b; }
.btn-back { text-decoration: none; }

/* ===== 全球市场条 ===== */
.mkt-bar { display: flex; flex-wrap: wrap; gap: 12px 32px; background: #fff; border: 1px solid #e8eaed; border-radius: 8px; padding: 12px 16px; margin: 14px 0; }
.mkt-item { display: flex; align-items: baseline; gap: 6px; }
.mkt-label { color: #8a919f; font-size: 12px; }
.mkt-item b { font-size: 15px; font-weight: 600; }

/* ===== 面板 ===== */
.coin-panel, .kline-panel, .desc-panel, .market-panel { background: #fff; border: 1px solid #e8eaed; border-radius: 8px; margin-bottom: 14px; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #eef0f3; flex-wrap: wrap; }
.panel-head h1 { font-size: 16px; font-weight: 600; }
.panel-head h2 { font-size: 15px; font-weight: 600; }
.stale-tip { color: #d97706; font-size: 12px; }

/* ===== 表格 ===== */
.table-scroll { overflow-x: auto; }
.coin-table { width: 100%; border-collapse: collapse; min-width: 940px; }
.coin-table th {
  background: #fafbfc; color: #6b7280; font-weight: 500; font-size: 12px;
  padding: 10px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid #eef0f3;
  cursor: pointer; user-select: none;
}
.coin-table th:first-child, .coin-table th:nth-child(2) { text-align: left; }
.coin-table th.sorted { color: #3566f0; }
.coin-table th .sort-arrow { font-size: 10px; color: #3566f0; margin-left: 3px; }
.coin-table td { padding: 10px 10px; text-align: right; border-bottom: 1px solid #f2f4f7; white-space: nowrap; font-size: 13px; }
.coin-table td:nth-child(1) { text-align: left; }
.coin-table td:nth-child(2) { text-align: left; }
.coin-table tbody tr:hover { background: #f8faff; }
.col-rank { width: 64px; }
.col-coin { width: 210px; }
.col-chg { width: 100px; }
.col-spark { width: 120px; text-align: left !important; }
.col-fav { width: 44px; text-align: center !important; }
.rank { color: #8a919f; font-size: 12px; display: inline-block; width: 26px; text-align: center; }
.rank.r1, .rank.r2, .rank.r3 { color: #b8860b; font-weight: 700; }

.coin-cell { display: flex; align-items: center; gap: 8px; }
.coin-icon { width: 22px; height: 22px; border-radius: 50%; background: #f0f2f5; flex-shrink: 0; }
.coin-sym { font-weight: 600; color: #1f2329; }
.coin-name { color: #8a919f; font-size: 12px; }
.col-price .cny { font-weight: 600; }
.col-price .usd { color: #8a919f; font-size: 12px; }
.chg { font-weight: 600; }
.chg.up { color: #e03131; }
.chg.down { color: #0ca678; }
.chg.flat { color: #8a919f; }

.fav-star { border: none; background: none; cursor: pointer; font-size: 16px; color: #c3c8d1; }
.fav-star.active { color: #f5b50a; }

.spark-cell svg { display: block; }

/* ===== 分页 ===== */
.pager { display: flex; justify-content: center; gap: 6px; padding: 14px 0 10px; flex-wrap: wrap; }
.pager button { border: 1px solid #d5d9e0; background: #fff; border-radius: 6px; min-width: 32px; height: 30px; cursor: pointer; font-size: 13px; color: #1f2329; }
.pager button:hover { border-color: #3566f0; color: #3566f0; }
.pager button.active { background: #3566f0; border-color: #3566f0; color: #fff; }
.pager button:disabled { color: #c3c8d1; cursor: default; }

/* ===== 详情页 ===== */
.detail-head { background: #fff; border: 1px solid #e8eaed; border-radius: 8px; padding: 16px 20px; margin: 14px 0; display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; justify-content: space-between; }
.d-head-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.d-icon { width: 46px; height: 46px; border-radius: 50%; background: #f0f2f5; }
.d-title h1 { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.d-name-en { color: #8a919f; font-size: 15px; font-weight: 400; }
.d-name-cn { color: #6b7280; font-size: 14px; margin-top: 2px; }
.d-rank { display: inline-block; background: #f2f4f7; color: #6b7280; font-size: 12px; border-radius: 4px; padding: 1px 8px; margin-left: 6px; }
.d-price { text-align: right; }
.d-price-cny { font-size: 28px; font-weight: 700; }
.d-price-sub { color: #8a919f; font-size: 15px; margin-top: 2px; display: flex; gap: 10px; align-items: baseline; justify-content: flex-end; }
.d-price-sub .chg { font-size: 14px; }
.d-price-time { color: #a0a6b0; font-size: 12px; margin-top: 4px; }

.data-grid { background: #fff; border: 1px solid #e8eaed; border-radius: 8px; padding: 8px 16px; margin-bottom: 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; }
.dg-cell { padding: 10px 8px; border-bottom: 1px dashed #eef0f3; }
.dg-cell span { display: block; color: #8a919f; font-size: 12px; }
.dg-cell b { font-size: 14px; font-weight: 600; }
.dg-cell b em { display: block; color: #a0a6b0; font-size: 11px; font-weight: 400; font-style: normal; }

/* ===== K线 ===== */
.kline-panel { padding-bottom: 12px; }
.kline-ranges, .kline-periods { display: flex; gap: 6px; margin-left: auto; }
.kline-ranges button, .kline-periods button {
  border: 1px solid #d5d9e0; background: #fff; color: #6b7280; border-radius: 5px;
  padding: 3px 10px; font-size: 12px; cursor: pointer;
}
.kline-ranges button.active, .kline-periods button.active { background: #3566f0; border-color: #3566f0; color: #fff; }
.kline-chart { width: 100%; height: 420px; position: relative; }
.kline-chart svg { width: 100%; height: 100%; display: block; }
.kline-tip { color: #a0a6b0; font-size: 12px; padding: 6px 16px 0; }

/* ===== 简介 / 市场 ===== */
.desc-panel, .market-panel { padding: 14px 16px; }
.desc-panel h2, .market-panel h2 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.coin-desc { color: #4b5563; line-height: 1.9; font-size: 13px; }
.market-panel .coin-table { min-width: 640px; }
.market-panel td { text-align: left !important; }
.market-panel td:nth-child(3), .market-panel td:nth-child(4), .market-panel td:nth-child(5) { text-align: right !important; }

/* ===== 页脚 ===== */
.footer { text-align: center; color: #a0a6b0; font-size: 12px; padding: 18px 0 0; }

/* ===== 中屏（721-1100px 桌面窄窗）：紧凑表格，隐藏 USDT价/交易量/供应量，保留 排名/币种/价格/24小时%/市值/过去7天/收藏 ===== */
@media (max-width: 1100px) and (min-width: 721px) {
  #coinTable th:nth-child(4), #coinTable td:nth-child(4),
  #coinTable th:nth-child(7), #coinTable td:nth-child(7),
  #coinTable th:nth-child(8), #coinTable td:nth-child(8) { display: none; }
  #coinTable { min-width: 640px; }
  #coinTable th, #coinTable td { padding: 8px 6px; }
  #coinTable th { font-size: 11px; }
  #coinTable td { font-size: 12px; }
  #coinTable .col-rank { width: 46px; }
  #coinTable .col-coin { width: 170px; }
  #coinTable .coin-name { font-size: 11px; }
  #coinTable .col-chg { width: 84px; }
  #coinTable .col-spark { width: 88px; }
  #coinTable .spark-cell svg { width: 84px; height: 24px; }
  #coinTable .col-fav { width: 40px; }
}

/* ===== 移动端：卡片式行（币种+市值 | 价格$ | 涨跌+走势 | 收藏）===== */
@media (max-width: 720px) {
  .topbar-in { padding: 0 8px; }
  .d-price { text-align: left; }
  .d-price-sub { justify-content: flex-start; }
  .kline-chart { height: 340px; }
  .panel-head { gap: 8px; }
  .kline-ranges { margin-left: 0; }

  /* 列表页手机版：表格转卡片行，市值放名称下方 */
  #coinTable { min-width: 0; width: 100%; }
  #coinTable thead { display: none; }
  #coinTable tbody { display: block; }
  #coinTable tr {
    display: grid;
    grid-template-columns: 28px minmax(0,1fr) auto auto 34px;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 2px 10px;
    padding: 10px 8px;
    border-bottom: 1px solid #f2f4f7;
  }
  #coinTable td { padding: 0; border-bottom: none; white-space: normal; font-size: 12px; text-align: left; }
  #coinTable td:nth-child(1) { grid-column: 1; grid-row: 1 / 3; text-align: center; }          /* 排名 */
  #coinTable td:nth-child(2) { grid-column: 2; grid-row: 1; }                                 /* 币种 */
  #coinTable td:nth-child(6) { grid-column: 2; grid-row: 2; color: #6b7280; font-size: 11px; } /* 市值（名称下方） */
  #coinTable td:nth-child(4) { grid-column: 3; grid-row: 1 / 3; text-align: right; }           /* 价格($) */
  #coinTable td:nth-child(5) { grid-column: 4; grid-row: 1; text-align: right; }               /* 涨跌 */
  #coinTable td:nth-child(9) { grid-column: 4; grid-row: 2; text-align: right; }               /* 走势 */
  #coinTable td:nth-child(10) { grid-column: 5; grid-row: 1 / 3; text-align: center; }         /* 收藏 */
  #coinTable td:nth-child(3), #coinTable td:nth-child(7), #coinTable td:nth-child(8) { display: none; } /* 人民币价/交易量/供应量 */

  /* 行内细节 */
  #coinTable td:nth-child(4) .usd { color: #1f2329; font-size: 15px; font-weight: 700; }
  #coinTable .coin-cell { gap: 6px; }
  #coinTable .coin-icon { width: 20px; height: 20px; }
  #coinTable .coin-sym { font-size: 13px; }
  #coinTable .coin-name { color: #8a919f; font-size: 11px; }
  #coinTable .spark-cell svg { width: 78px; height: 26px; }
  #coinTable .fav-star { font-size: 15px; }

  /* 全局市场条 / 详情页紧凑化 */
  .mkt-bar { gap: 8px 16px; padding: 10px 12px; }
  .mkt-item b { font-size: 13px; }
  .detail-head { padding: 12px 14px; }
  .d-price-cny { font-size: 24px; }
  .d-icon { width: 38px; height: 38px; }
  .d-title h1 { font-size: 19px; }
  .data-grid { grid-template-columns: repeat(2, 1fr); padding: 6px 10px; }
  .dg-cell { padding: 8px 6px; }
}
