/* ============================================================================
   骨架层（layout.css）
   ----------------------------------------------------------------------------
   范围：整页骨架（顶栏 / 三栏 / 页脚）、登录整屏、以及 shell 自己那几个区块
   （资产总览、搜索与涨跌榜、持仓表、交易记录）。

   硬约束（contract §4）：
   1. 颜色全部走 tokens.css 的变量，本文件不出现字面色值；
   2. 涨跌方向不可改：红涨绿跌；
   3. 数字统一 .num；
   4. 表格滚动用纯 CSS（max-height + sticky thead），不靠 JS 反复量算
      —— 那正是 V1「每 5 秒滚动条跳回顶部」的根因（测绘 R5）。

   另外补了 core 组件（toast / modal）的基础样式：core/*.js 会用这些类，
   但 base.css 没有覆盖，缺了会导致提示框与弹窗直接掉到页面流里。
   ========================================================================== */

/* ══════════════════════════════════════════════════════════════════════════
   0. core 组件：toast / modal
   ══════════════════════════════════════════════════════════════════════════ */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--s2);
  max-width: min(560px, 92vw);
  padding: 9px 14px;
  border-radius: var(--r-sm);
  background: var(--text);
  color: var(--surface);
  font-size: var(--fs-sm);
  line-height: 1.5;
  box-shadow: var(--shadow-lg);
  transition: opacity 160ms var(--ease), transform 160ms var(--ease);
}
.toast--success { background: var(--success); }
.toast--error { background: var(--danger); }
.toast--warn { background: var(--warn); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); }

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s4);
  background: var(--overlay);
}

.modal {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  width: 420px;
  max-width: 100%;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: var(--s5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.modal--narrow { width: 360px; }
.modal--wide { width: min(920px, 100%); }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.modal__title { font-size: var(--fs-lg); font-weight: 600; }
.modal__close {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  color: var(--text-3);
  font-size: var(--fs-md);
}
.modal__close:hover { background: var(--surface-3); color: var(--text); }
.modal__body { display: flex; flex-direction: column; gap: var(--s3); font-size: var(--fs-sm); }
.modal__foot { display: flex; gap: var(--s2); margin-top: var(--s1); }
.modal__foot .btn { flex: 1; }

/* ══════════════════════════════════════════════════════════════════════════
   1. 启动占位（main.js 决定去向后立刻移除，避免白屏闪烁）
   ══════════════════════════════════════════════════════════════════════════ */

.boot {
  position: fixed;
  inset: 0;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  background: var(--bg);
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.boot__logo { font-size: 34px; line-height: 1; opacity: 0.8; }

.app { min-height: 100vh; }

/* ══════════════════════════════════════════════════════════════════════════
   2. 顶栏
   --------------------------------------------------------------------------
   sticky + z-index，高度由 main.js 的 ResizeObserver 写进 --header-h，
   两栏的 sticky top 引用同一个变量 —— 这样改字号/换行都不会再把吸顶栏压住
   （测绘 R16 明确点出的硬耦合）。
   ══════════════════════════════════════════════════════════════════════════ */

.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s3);
  min-height: var(--header-h);
  padding: 12px var(--s6);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
}

/* ── 2.1 品牌 ─────────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: 0 0 auto;
}
.brand__logo { font-size: 26px; line-height: 1; }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; }
.brand__title { font-size: var(--fs-lg); letter-spacing: -0.01em; }
.brand__sub { font-size: var(--fs-xs); color: var(--text-3); }

/* ── 2.2 大奖横幅容器（内容与滚动由 boards/ticker.js 负责） ── */
.prize-ticker {
  flex: 1 1 320px;
  min-width: 0;
  max-width: 720px;
  margin: 0 var(--s3);
}
/* 没有数据时不要留一条空白胶囊 */
.prize-ticker:empty { display: none; }

/* ── 2.3 右侧控件 ─────────────────────────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--s3);
  margin-left: auto;
}

.mkt-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: color var(--dur-base) var(--ease), background var(--dur-base) var(--ease),
              border-color var(--dur-base) var(--ease);
}
.mkt-badge.is-open {
  color: var(--success);
  border-color: var(--success-border);
  background: var(--success-soft);
}
.mkt-badge.is-closed {
  color: var(--warn);
  border-color: var(--warn-border);
  background: var(--warn-soft);
}

.clock {
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}

/* 2.5 赛季倒计时胶囊 */
.season-next {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border: 1px solid var(--season-gold-border);
  border-radius: var(--r-pill);
  background: var(--season-gold-soft);
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}
.season-next .sn-label { color: var(--season-gold); font-weight: 600; }
.season-next .sn-cd { color: var(--season-gold); font-weight: 700; }
.season-next .sn-cd.is-due { color: var(--up); }

/* ── 顶栏文字按钮（V1 的 .btn.ghost.small 口径） ───────────── */
.header-btn {
  padding: 5px 12px;
  font-size: var(--fs-xs);
  font-weight: 500;
  white-space: nowrap;
}

/* ── 头像 chip + 下拉菜单（V1 的 .user-chip） ──────────────── */
.user-menu {
  position: relative;
  display: inline-flex;
  flex: 0 1 auto;
  min-width: 0;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  max-width: min(260px, 42vw);
  min-height: 30px;
  padding: 4px 12px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.user-chip:hover { background: var(--surface-3); }
.user-chip:focus-visible { outline: 2px solid var(--line-focus); outline-offset: 2px; }
.user-chip__avatar { flex: none; line-height: 1; }
/* 名字完整显示：不截字，只在过长时换行，hover 有完整 title */
.user-chip__name {
  min-width: 0;
  max-width: 15em;
  overflow-wrap: anywhere;
  text-align: left;
}
.user-chip__caret { flex: none; font-size: 10px; line-height: 1; opacity: 0.8; }

.user-menu__pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: var(--z-dropdown);
  display: flex;
  flex-direction: column;
  min-width: 148px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}
.user-menu__item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 7px 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-sm);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.user-menu__item:hover,
.user-menu__item:focus-visible { background: var(--surface-3); color: var(--text); }
.user-menu__item--danger { color: var(--danger); }
.user-menu__item--danger:hover,
.user-menu__item--danger:focus-visible { background: var(--danger-soft); color: var(--danger); }

/* ══════════════════════════════════════════════════════════════════════════
   3. 三栏骨架
   --------------------------------------------------------------------------
   DOM 顺序：col-season → col-main → col-side（与 V1 一致）
   视觉顺序：
     ≥1180        左 | 中 | 右
     960–1179     中 | 右，赛季栏落到中栏下方（＝V1 窄屏的真实顺序，见测绘 1.6/R7）
     ≤960         单栏：中 → 赛季 → 右
   ══════════════════════════════════════════════════════════════════════════ */

.layout {
  /* V1 的右栏宽度阶梯：1180–1499 360 / 1500–1779 400 / ≥1780 420。
     tokens.css 里的 --col-side 是只读共享文件，这里用局部变量覆盖，
     避免动到别人正在改的 token。 */
  --side-w: 360px;
  --season-w: 216px;
  display: grid;
  grid-template-columns: var(--season-w) minmax(0, 1fr) var(--side-w);
  grid-template-areas: "season main side";
  align-items: start;
  gap: var(--s5);
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s4) var(--s5) var(--s7);
}

@media (min-width: 1500px) {
  .layout {
    --side-w: 400px;
    --season-w: 228px;
  }
}

@media (min-width: 1780px) {
  .layout {
    --side-w: 420px;
    --season-w: 236px;
  }
}

.col-season { grid-area: season; }
.col-main { grid-area: main; }
.col-side { grid-area: side; }

.col-main {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  min-width: 0;
}
.col-side {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  min-width: 0;
}

/* 左栏本身就是一张卡（与 V1 的 aside.col-season.card 一致） */
.col-season {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  min-width: 0;
  padding: var(--s3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

/* 窄屏把左栏当普通容器，避免出现「卡片套卡片」的双层边框。
   960–1179px 按 V1 是单栏（中 → 赛季 → 右），不是「中 + 右」两栏。 */
@media (max-width: 1179px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "main"
      "season"
      "side";
    gap: var(--s4);
  }
}

@media (max-width: 960px) {
  .layout { gap: var(--s3); }
}

/* 吸顶两栏：top 与 max-height 都跟着 --header-h 走 */
@media (min-width: 1180px) {
  .layout { max-width: none; padding: 18px 28px 34px; }

  .col-season,
  .col-side {
    position: sticky;
    top: calc(var(--header-h) + var(--s3));
    max-height: calc(100vh - var(--header-h) - var(--s5));
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong) transparent;
  }
  .col-season::-webkit-scrollbar,
  .col-side::-webkit-scrollbar { width: 8px; }
  .col-season::-webkit-scrollbar-thumb,
  .col-side::-webkit-scrollbar-thumb {
    background: var(--line-strong);
    border-radius: var(--r-pill);
    border: 2px solid transparent;
    background-clip: padding-box;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   4. 右栏卡片（排行榜 / 死亡墙 / 留言板）
   --------------------------------------------------------------------------
   这三个容器里的内容是 boards 模块渲染的。为了不让「我铺卡 + 他再铺一张卡」
   叠出双层边框，这里统一把容器内的 .card 抹平（只保留内容）。
   ══════════════════════════════════════════════════════════════════════════ */

.side-boards {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.side-card { padding: var(--s3) var(--s4); }

.col-season > .card,
.side-card .card,
.leaderboard-slot > .card,
.msg-slot > .card {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.leaderboard-slot { min-height: 40px; }
.msg-slot { min-height: 40px; }

.death-card {
  border-color: var(--danger-border);
  background: linear-gradient(180deg, var(--danger-soft), var(--surface));
}
.death-note {
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--danger);
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════════════════
   5. 资产总览（blocks/summary.js）
   ══════════════════════════════════════════════════════════════════════════ */

.summary { padding: var(--s4) var(--s5); }
.sum-grid { display: flex; flex-direction: column; gap: var(--s2); }

.sum-row {
  display: grid;
  gap: var(--s2);
}
.sum-row--main {
  grid-template-columns: minmax(0, 1.15fr) repeat(3, minmax(0, 1fr));
}
/* 12 栏栅格：市值/现金各占半行，三个比率指标各占 1/3 行，博彩整行 */
.sum-row--metrics {
  grid-template-columns: repeat(12, minmax(0, 1fr));
}
.sum-row--metrics > .sum-item--mv,
.sum-row--metrics > .sum-item--cash { grid-column: span 6; }
.sum-row--metrics > .sum-item--day,
.sum-row--metrics > .sum-item--profit,
.sum-row--metrics > .sum-item--cost { grid-column: span 4; }
.sum-row--metrics > .sum-item--gamble { grid-column: 1 / -1; }

.sum-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  min-height: 68px;
  padding: 8px var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.sum-item--assets {
  background: linear-gradient(180deg, var(--accent-soft), var(--surface));
  border-color: var(--accent-border);
  position: relative;
  container-type: inline-size;
}

.sum-item__label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-xs);
  color: var(--text-3);
  white-space: nowrap;
}

.sum-item__value {
  font-size: var(--fs-xl);
  font-weight: 600;
  line-height: 1.25;
  /* 金额/时长绝不截断、绝不折行：以前这里有 overflow:hidden +
     text-overflow:ellipsis，1280 下四张卡挤到 ~200px 时「总资产」就变成
     ¥104,95…，「1 小时 46 分」也会折成两行。钱被截断比排版难看严重得多，
     所以这里一律 nowrap + 不裁剪，宁可让卡片内部换行（见 .sum-item__mainline
     的 flex-wrap）也不动数值本身。 */
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}
.sum-item__value--big { font-size: var(--fs-2xl); letter-spacing: -0.02em; }
.sum-item__rate { margin-left: 4px; font-size: var(--fs-xs); font-weight: 500; }
/* 卡车帝国入口（patch）：按钮只占「总资产」数字右侧的空白，不改数字的宽度和位置。
   .sum-item--assets 自己作为容器：卡片内容宽 <260px 时按钮改贴卡片右上角，
   不再跟数字挤同一行；数值本身 flex:0 0 auto 不参与收缩，所以按钮永远压不窄金额。 */
.sum-item__mainline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
/* 数值不参与收缩（0 1 auto → 0 0 auto）：按钮挤不下时由 flex-wrap 把按钮
   换到下一行，而不是把金额压窄后省略号截掉。 */
.sum-item__mainline > .sum-item__value { flex: 0 0 auto; }
.sum-truck-btn { flex: 0 0 auto; margin-left: auto; white-space: nowrap; }
@container (max-width: 260px) {
  .sum-truck-btn { position: absolute; top: 6px; right: 8px; margin-left: 0; }
}

.sum-item__sub {
  font-size: var(--fs-2xs);
  font-weight: 500;
  color: var(--text-3);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.sum-lev { color: var(--warn); }

/* `?` 气泡：长口径说明，hover / 键盘聚焦时展示 */
.q-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-3);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.q-tip:hover,
.q-tip:focus-visible {
  background: var(--accent);
  color: var(--surface);
  outline: none;
}
.q-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: var(--z-dropdown);
  width: 300px;
  max-width: 72vw;
  padding: var(--s2) var(--s3);
  transform: translateX(-50%) translateY(2px);
  background: var(--text);
  color: var(--surface);
  font-size: var(--fs-xs);
  font-weight: 400;
  line-height: 1.65;
  text-align: left;
  white-space: normal;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.q-tip:hover::after,
.q-tip:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
/* 靠边的气泡改为贴边对齐，避免超出卡片 */
.sum-row--main > .sum-item:first-child .q-tip::after { left: 0; transform: translateY(2px); }
.sum-row--main > .sum-item:first-child .q-tip:hover::after { transform: translateY(0); }
.sum-item--gamble .q-tip::after { left: auto; right: 0; transform: translateY(2px); }
.sum-item--gamble .q-tip:hover::after { transform: translateY(0); }

/* ══════════════════════════════════════════════════════════════════════════
   6. 搜索 + 今日涨跌榜（blocks/search.js）
   ══════════════════════════════════════════════════════════════════════════ */

.search-bar { padding: var(--s3) var(--s5); }
.search-block { display: flex; flex-direction: column; gap: var(--s3); }

.search-box { position: relative; }
.search-input {
  padding: 11px 14px;
  border-radius: var(--r-sm);
}
.search-input::-webkit-search-cancel-button { cursor: pointer; }

.dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: var(--z-dropdown);
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}
.dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  transition: background var(--dur-fast) var(--ease);
}
.dropdown__item:hover { background: var(--surface-2); }
.dropdown__name { font-weight: 600; }
.dropdown__code { font-size: var(--fs-xs); color: var(--text-3); }
.dropdown__hint {
  margin-left: auto;
  font-size: var(--fs-xs);
  color: var(--accent);
  white-space: nowrap;
}

.rank-panel {
  padding-top: var(--s3);
  border-top: 1px dashed var(--line);
}
.rank-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-bottom: var(--s2);
}
.rank-panel__title {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: var(--fs-sm);
  font-weight: 600;
}
.rank-tip {
  font-size: var(--fs-2xs);
  font-weight: 400;
  color: var(--text-4);
}
.rank-panel__filters { display: flex; gap: 6px; }

.mini-select {
  width: auto;
  min-width: 92px;
  padding: 4px 8px;
  font-size: var(--fs-xs);
  border-radius: var(--r-sm);
}

.rank-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s2);
}
.rank-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: var(--fs-xs);
  text-align: left;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
}
.rank-chip:hover { transform: translateY(-1px); }
.rank-chip__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.rank-chip__pct { flex: 0 0 auto; font-weight: 700; font-variant-numeric: tabular-nums; }

.rank-chip--up { background: var(--up-soft); border-color: var(--up-border); }
.rank-chip--up .rank-chip__pct { color: var(--up); }
.rank-chip--up:hover { background: var(--up-border); }
.rank-chip--down { background: var(--down-soft); border-color: var(--down-border); }
.rank-chip--down .rank-chip__pct { color: var(--down); }
.rank-chip--down:hover { background: var(--down-border); }
.rank-chip--flat { background: var(--flat-soft); }
.rank-chip--flat .rank-chip__pct { color: var(--flat); }

.rank-empty {
  grid-column: 1 / -1;
  padding: var(--s3) 0;
  color: var(--text-3);
  font-size: var(--fs-sm);
  text-align: center;
}

/* ── 6.1 我的收藏（blocks/favorites.js） ─────────────────────────────
   复用涨跌榜 pill（.rank-panel / .rank-grid / .rank-chip）；这里只去掉
   作为独立卡片的顶部虚线，并把空态改成左对齐的一行灰字。 */
.fav-panel {
  padding-top: 0;
  border-top: 0;
}
.fav-empty {
  padding: var(--s2) 0 var(--s1);
  text-align: left;
  line-height: var(--lh);
}
.fav-chip {
  min-height: 30px;
}

/* ── 6.2 交易弹窗的收藏星标（panels/trade.js 的 .tr-fav） ─────────────
   16×16 图标 + 24×24 点击热区；未收藏空心灰、已收藏实心金色。
   金色只用 tokens.css 的 --metal-*，白天/夜间两套主题自动跟随。 */
.tr-fav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-4);
  cursor: pointer;
  line-height: 1;
  transition: color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
}
.tr-fav svg {
  display: block;
  width: 16px;
  height: 16px;
}
.tr-fav svg path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}
.tr-fav:hover:not(:disabled) {
  color: var(--metal-lo);
  background: var(--metal-wash);
}
.tr-fav.is-on {
  color: var(--metal-deep);
}
/* 已收藏的填充必须始终是**实心金**：不要把 hover 的浅色 fill 写在更后面，
   否则 :hover 选择器权重更高，会把实心金覆盖成 35% 透明的淡金（实测过）。 */
.tr-fav.is-on svg path {
  fill: var(--metal-mid);
  stroke: var(--metal-deep);
}
.tr-fav.is-on:hover:not(:disabled) {
  background: var(--metal-wash);
}
.tr-fav:disabled {
  opacity: 0.5;
  cursor: default;
}
.tr-fav:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ══════════════════════════════════════════════════════════════════════════
   7. 区块头（持仓 / 交易记录共用）
   ══════════════════════════════════════════════════════════════════════════ */

.block { padding: var(--s4) var(--s5); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-bottom: var(--s3);
}

.head-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2);
}

.head-act { position: relative; font-weight: 600; }
.head-act--loan { color: var(--accent); }
.head-act--orders { color: var(--success); }
.head-act--lottery { color: var(--lottery); }
.head-act--scratch { color: var(--scratch); }
.head-act:hover:not(:disabled) { border-color: currentColor; }

.o-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--surface);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
}
.o-badge.hot { background: var(--up); }

/* ══════════════════════════════════════════════════════════════════════════
   8. 表格（持仓 / 交易记录）
   --------------------------------------------------------------------------
   滚动容器永远 overflow:auto，最大高度用 CSS 算「10 行 + 表头」。
   不再根据行数增删类名 —— 类名一变浏览器就会把 scrollTop 钳回 0（R5）。
   ══════════════════════════════════════════════════════════════════════════ */

.table-wrap--capped {
  --table-row-h: 38px;
  --table-head-h: 34px;
  max-height: calc(var(--table-row-h) * 10 + var(--table-head-h));
  overflow: auto;
  border-radius: var(--r-sm);
}

.table--sticky-hold th,
/* 方向列：文字 + 杠杆徽章必须同行。
   两个 span 都是内联元素，窄了就会断成两行——出现"有的在右、有的在下"的参差。
   统一 nowrap，并把徽章缩小一点，让「买入 10×」这类最长的组合也能挤进一列。 */
.table--sticky-trades td:nth-child(2) {
  white-space: nowrap;
}
.table--sticky-trades td:nth-child(2) .lev-tag {
  display: inline-block;
  margin-left: 4px;
  vertical-align: middle;
  font-size: 10px;
  line-height: 15px;
  padding: 0 5px;
  border-radius: 3px;
}
.table--sticky-trades th.num,
.table--sticky-trades td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.table--sticky-trades th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  /* 用内阴影画分隔线：border-collapse 下 sticky 元素的边框会随内容滚走 */
  box-shadow: inset 0 -1px 0 var(--line);
}

.table th[data-dir="desc"]::after { content: " ↓"; }
.table th[data-dir="asc"]::after { content: " ↑"; }

/* ── 交易记录分页条（blocks/trades.js） ──────────────────────────────
 * 表格下方一行：左「共 N 条」，右「上一页 · 第 N / M 页 · 下一页」。
 * 按钮复用 base.css 的 .btn.btn--ghost.btn--sm，这里只管排版，不另造视觉。 */
.trades-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  flex-wrap: wrap;
  margin-top: var(--s3);
}

.trades-count { font-size: var(--fs-xs); }

.trades-pager {
  display: flex;
  align-items: center;
  gap: var(--s2);
  margin-left: auto;
}

.trades-page {
  min-width: 92px;
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--text-2);
  white-space: nowrap;
}

/* ── 持仓表：表头与数值同一套对齐 + 金额不许折行 ──────────────────────
   holdings.js 给数值列的 th/td 都挂了 .num，这里把两边锁成同一规则：
   右对齐 + 等宽数字。以前 th 走 .table th 的默认左对齐、td 走 .num 的
   右对齐，窄窗口下就是「表头跟数字错位」。
   white-space: nowrap 是金额不折行的关键：`+¥1,690.00` 里 `+`(PR) 和
   `¥`(PR) 之间本来有换行机会，窄到一定程度浏览器就会在加号后断行；
   nowrap 把整段锁成一行。子行（强平/保证金）本来就 nowrap。 */
.table--sticky-hold th.num,
.table--sticky-hold td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* 操作列是按钮列：.right 打不过 .table th，这里显式让表头也右对齐 */
.table--sticky-hold th.right { text-align: right; }

/* ── 成本价 / 市值：双行列整列居中 ─────────────────────────────────────
   这两列是「上面数值 + 下面一行小字」（强平 xx · 距 xx% / 保证金 ¥xx），
   右对齐时两行右端对齐、左端长短不齐，比居中乱得多，所以专门给一个
   'center' 类。选择器权重 0,2,1 高于 .table .num(0,2,0) 与 .table th(0,1,1)，
   不会被 base.css 的左/右对齐盖回去。
   注意：这两列不再带 .num，所以等宽数字和 nowrap 必须在这里自己补，
   否则 `强平 7.96 · 距 +24.25%` 在窄窗口会被折断成两行。 */
.table--sticky-hold th.center,
.table--sticky-hold td.center {
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 数值列的宽度下限：列宽不足时宁可让 .table-wrap 内部横向滚动，
   也不要把 `¥1,724,004.00` 压到 30px 再折行。只约束数值列，
   股票/操作这类文本列仍由内容自然宽度决定。 */
.table--sticky-hold th:nth-child(2), .table--sticky-hold td:nth-child(2) { min-width: 62px; }  /* 现价 */
.table--sticky-hold th:nth-child(3), .table--sticky-hold td:nth-child(3) { min-width: 74px; }  /* 今日涨跌 */
.table--sticky-hold th:nth-child(4), .table--sticky-hold td:nth-child(4) { min-width: 84px; }  /* 成本价 */
.table--sticky-hold th:nth-child(5), .table--sticky-hold td:nth-child(5) { min-width: 96px; }  /* 持仓/可用 */
.table--sticky-hold th:nth-child(6), .table--sticky-hold td:nth-child(6) { min-width: 104px; } /* 市值 */
.table--sticky-hold th:nth-child(7), .table--sticky-hold td:nth-child(7) { min-width: 92px; }  /* 持仓盈亏 */
.table--sticky-hold th:nth-child(8), .table--sticky-hold td:nth-child(8) { min-width: 74px; }  /* 盈亏比例 */

/* 行内元素 */
.stock-name { font-weight: 600; }
.stock-code { margin-left: 6px; font-size: var(--fs-xs); color: var(--text-3); }

.hold-row { cursor: pointer; }

.lev-tag,
.short-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: var(--r-xs);
  color: var(--surface);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 15px;
  vertical-align: 1px;
}
.lev-tag { background: linear-gradient(180deg, var(--warn), var(--scratch)); }
.lev-tag.hot { background: linear-gradient(180deg, var(--up), var(--danger)); }
.short-tag { background: linear-gradient(180deg, var(--down), var(--success)); }
.short-tag.hot { background: linear-gradient(180deg, var(--up), var(--danger)); }

.liq-line {
  font-size: 10.5px;
  color: var(--text-3);
  white-space: nowrap;
}
.liq-line.near { color: var(--danger); font-weight: 700; }
.liq-line.safe { color: var(--down); }

.sub-line {
  font-size: 10.5px;
  color: var(--text-3);
  white-space: nowrap;
}

.t-liq { color: var(--danger); font-weight: 700; }
.t-short { color: var(--success); font-weight: 700; }

tr.tr-liq td { background: var(--up-soft); }
tr.lev-row--hot td { background: var(--up-soft); }
tr.short-row--hot td { background: var(--down-soft); }

.op-btn { padding: 3px 9px; }
td.right .op-btn + .op-btn { margin-left: 6px; }

.time-col { width: 116px; color: var(--text-3); }

/* 空态放在 td 里时不要被 .empty 的 flex 撑出奇怪高度 */
td.empty {
  display: table-cell;
  padding: 24px 0;
  color: var(--text-3);
  text-align: center;
}

/* ══════════════════════════════════════════════════════════════════════════
   9. 页脚风险说明
   ══════════════════════════════════════════════════════════════════════════ */

.footnote {
  padding: 0 var(--s1);
  color: var(--text-3);
  font-size: var(--fs-xs);
  line-height: var(--lh-loose);
}

/* ══════════════════════════════════════════════════════════════════════════
   10. 登录 / 注册整屏（auth.js）
   ══════════════════════════════════════════════════════════════════════════ */

.auth-view {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s4);
  overflow-y: auto;
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--bg) 55%, var(--down-soft) 100%);
}

.auth-mask {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: var(--s4) 0;
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  width: 380px;
  max-width: 100%;
  padding: 30px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.auth-logo { font-size: 40px; line-height: 1; }
.auth-title { font-size: 22px; }
.auth-sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
  line-height: 1.65;
}

.auth-tabs {
  display: flex;
  gap: var(--s1);
  padding: 3px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.auth-tabs .tab {
  flex: 1;
  padding: 9px 0;
  border-radius: var(--r-sm);
  color: var(--text-3);
  font-size: var(--fs-md);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.auth-tabs .tab.is-active {
  background: var(--accent);
  color: var(--surface);
  font-weight: 600;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  text-align: left;
}
.auth-fields { display: flex; flex-direction: column; gap: var(--s2); }
.auth-hint {
  margin-top: 2px;
  padding: 8px 10px;
  border: 1px solid var(--warn-border);
  border-radius: var(--r-sm);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: var(--fs-xs);
  line-height: 1.6;
}
.auth-error {
  padding: 2px 0;
  color: var(--danger);
  font-size: var(--fs-xs);
  line-height: 1.5;
}
.auth-form .btn--block { margin-top: var(--s1); }

/* ══════════════════════════════════════════════════════════════════════════
   11. 响应式
   ══════════════════════════════════════════════════════════════════════════ */

/* 大奖横幅在窄屏不占地方（V1 同样 ≤1179 隐藏） */
@media (max-width: 1179px) {
  .prize-ticker { display: none; }
}

/* 赛季倒计时胶囊在中等宽度让位给操作组 */
@media (max-width: 1060px) {
  .season-next { display: none; }
}

@media (max-width: 960px) {
  .app-header {
    gap: var(--s2);
    padding: 10px 14px;
  }
  .clock { display: none; }
  .header-right { gap: var(--s2); }
  /* 平板/手机（触摸设备）把按钮触控区抬到 36px */
  .header-btn,
  .user-chip { min-height: 36px; }

  .layout { padding: var(--s3) var(--s3) var(--s5); }

  /* V1 在 ≤960 收紧内边距 */
  .card { padding: var(--s3); }
  .summary { padding: var(--s3); }
  .search-bar { padding: var(--s3); }
  .block { padding: var(--s3); }
  .side-card { padding: var(--s3); }

  .sum-row--metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sum-row--metrics > .sum-item { grid-column: span 1; }
  .sum-row--metrics > .sum-item--gamble { grid-column: 1 / -1; }

  .table-wrap--capped { max-height: 46vh; }
}

/* 资产总览第一行（总资产 / 距离还款 / 下期还款金额 / 贷款 四张卡）的列数。
   ≥1400 维持四列；900–1399 两行两列；<900 单列。
   1280 是出问题的那档：三栏布局下主栏只有 608px，四列把每张卡压到
   130–150px，而「总资产」的 ¥100,263.84 需要 ~142px —— 于是被省略号截成
   ¥104,95…。改成两列后每张卡 ~300px，金额完整显示。
   放在 960 的媒体块之后，保证 900 以下被单列规则覆盖。 */
@media (max-width: 1399px) {
  .sum-row--main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 899px) {
  .sum-row--main { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .rank-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rank-tip { display: none; }
  .rank-panel__filters { width: 100%; }
  .rank-panel__filters .mini-select { flex: 1; min-width: 0; }
  .table-wrap--capped { max-height: none; }
}

@media (max-width: 560px) {
  .brand__sub { display: none; }

  /* 手机顶栏压回单行 56–64px：只留 V1 的高频操作（徽章 / 临时解锁 / 头像）。
     成交记录在「交易记录」卡内、退出在头像菜单里，都有等价入口。 */
  .app-header {
    flex-wrap: nowrap;
    gap: 6px;
    padding: 9px 10px;
    min-height: 56px;
  }
  .brand { gap: 6px; min-width: 0; }
  .brand__logo { font-size: 18px; }
  /* 手机只留 logo：把宽度让给「临时解锁 / 成交记录 / 头像」这些真操作 */
  .brand__title { display: none; }
  .header-right {
    flex-wrap: nowrap;
    gap: 4px;
    min-width: 0;
    margin-left: auto;
  }
  .mkt-badge {
    padding: 4px 7px;
    font-size: 10.5px;
    flex: 0 1 auto;
    min-width: 0;
  }
  .header-btn { min-height: 36px; padding: 0 8px; font-size: var(--fs-xs); }
  /* 退出在头像菜单里也有入口，手机顶栏不再重复占位 */
  #btn-logout { display: none; }

  .user-chip {
    max-width: 104px;
    min-height: 36px;
    padding: 3px 8px;
    font-size: 11px;
    gap: 3px;
  }
  .user-chip__name {
    max-width: 70px;
    line-height: 1.15;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .user-chip__caret { font-size: 9px; }

  .layout { padding: 10px 10px 20px; }
  .col-main { gap: var(--s3); }
  .col-side { gap: var(--s3); }
  .side-boards { gap: var(--s3); }

  /* 手机端表格允许横向滚动，别把 9 列压成一团 */
  .table--sticky-hold { min-width: 680px; }
  .table--sticky-trades { min-width: 600px; }

  /* 触控区加大 */
  .btn { padding: 9px 14px; }
  .btn--sm { padding: 7px 11px; }
  .op-btn { padding: 7px 12px; }
  .dropdown__item { padding: 12px 12px; }
  .rank-chip { padding: 8px 9px; }
  /* 触屏上把星标热区抬到 28px，仍远小于手机 44px 的可点区要求但不再局促 */
  .tr-fav { width: 28px; height: 28px; }
  .tr-fav svg { width: 18px; height: 18px; }

  .sum-item { min-height: 62px; }
  .sum-item__value { font-size: var(--fs-lg); }
  .sum-item__value--big { font-size: var(--fs-xl); }

  .section-head { align-items: flex-start; }
  .head-tools { gap: 6px; }
}

@media (max-width: 420px) {
  .auth-card { padding: 24px 20px; }
  .modal { padding: var(--s4); }
}

/* ══════════════════════════════════════════════════════════════════════════
   12. 动效降级（只关自己这几处的过渡，不动别人模块的动画）
   ══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .rank-chip,
  .toast,
  .q-tip::after {
    transition: none;
  }
  .rank-chip:hover {
    transform: none;
  }
}