/* ============================================================================
   基础层：重置 + 排版 + 通用组件
   ----------------------------------------------------------------------------
   这一层是全站共享的"词汇表"。业务代码只使用这里定义的类，
   不要各自发明新的按钮/卡片/表格样式 —— 那是 V1 里"同一种红出现四种值"的来源。
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: var(--lh-tight); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  padding: 0;
}
button:disabled { cursor: not-allowed; }

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

table { border-collapse: collapse; width: 100%; }

/* 数字一律等宽对齐：金额、倒计时、赔率对不齐比什么都难看 */
.num, .money, .pct, .mono, td.num, td.money, td.pct {
  font-variant-numeric: tabular-nums;
}
.mono { font-family: var(--font-mono); }

/* ── 焦点可见：键盘可用性的底线 ─────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--line-focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ── 工具类 ─────────────────────────────────────────────────── */
.hidden { display: none !important; }
.row { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.row-gap { display: flex; align-items: center; gap: var(--s2); }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.right { text-align: right; }
.center { text-align: center; }
.strong { font-weight: 600; }
.muted { color: var(--text-3); }
.tiny { font-size: var(--fs-xs); }
.small { font-size: var(--fs-sm); }
.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--flat); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── 卡片 ───────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: var(--s4) var(--s5);
}
.card--tight { padding: var(--s3) var(--s4); }
.card--flush { padding: 0; }
.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s3);
}
.card__title {
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card__sub {
  font-size: var(--fs-xs);
  color: var(--text-3);
  font-weight: 400;
}

/* ── 按钮 ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.3;
  transition: background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
  white-space: nowrap;
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; }

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn--primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }

.btn--buy { background: var(--up); color: #fff; border-color: var(--up); }
.btn--buy:hover:not(:disabled) { filter: brightness(0.94); }

.btn--sell { background: var(--down); color: #fff; border-color: var(--down); }
.btn--sell:hover:not(:disabled) { filter: brightness(0.94); }

.btn--danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn--danger:hover:not(:disabled) { filter: brightness(0.94); }

.btn--ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--text-2);
}
.btn--ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }

.btn--bare { background: none; border-color: transparent; color: var(--text-3); }
.btn--bare:hover:not(:disabled) { color: var(--text); background: var(--surface-3); }

.btn--sm { padding: 4px 10px; font-size: var(--fs-xs); }
.btn--lg { padding: 10px 20px; font-size: var(--fs-md); }
.btn--block { width: 100%; }

/* ── 表单 ───────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field__label { font-size: var(--fs-xs); color: var(--text-3); font-weight: 500; }
.field__hint { font-size: var(--fs-2xs); color: var(--text-3); line-height: 1.5; }
.field__error { font-size: var(--fs-xs); color: var(--danger); }

.input {
  width: 100%;
  padding: 8px 11px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input::placeholder { color: var(--text-4); }
.input:hover:not(:disabled) { border-color: var(--text-4); }
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.input:disabled { background: var(--surface-3); color: var(--text-3); }
.input--sm { padding: 5px 9px; font-size: var(--fs-sm); }

/* 分段选择器（买入/卖出、涨到/跌到、榜单切换） */
.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-3);
  border-radius: var(--r-sm);
}
.segmented__item {
  padding: 5px 14px;
  border-radius: var(--r-xs);
  font-size: var(--fs-sm);
  color: var(--text-2);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.segmented__item:hover { color: var(--text); }
.segmented__item[data-active="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* ── 表格 ───────────────────────────────────────────────────── */
.table {
  width: 100%;
  font-size: var(--fs-sm);
}
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px var(--s3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
.table td {
  padding: 9px var(--s3);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr[data-selected="true"] { background: var(--accent-soft); }
.table .num, .table .money, .table .pct { text-align: right; }
.table--compact td { padding: 6px var(--s2); }
/* 表头点击排序 */
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]:hover { color: var(--text); }
.table th[data-sort][data-dir] { color: var(--accent); }

/* 表格滚动容器：内部滚动，表头吸顶 */
.table-wrap {
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.table-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
.table-wrap::-webkit-scrollbar-track { background: transparent; }

/* ── 徽标 / 胶囊 ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: var(--r-xs);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: var(--fs-2xs);
  font-weight: 500;
  line-height: 1.7;
  white-space: nowrap;
}
.badge--up { background: var(--up-soft); color: var(--up); }
.badge--down { background: var(--down-soft); color: var(--down); }
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--lottery { background: var(--lottery-soft); color: var(--lottery); }
.badge--scratch { background: var(--scratch-soft); color: var(--scratch); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: var(--fs-xs);
  color: var(--text-2);
  white-space: nowrap;
}

/* ── 提示块（替代 V1 里散落的彩色 div） ─────────────────────── */
.hint {
  display: block;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  line-height: var(--lh);
}
.hint--info { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-strong); }
.hint--warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn); }
.hint--danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.hint--success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }

/* ── 空状态 ─────────────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s7) var(--s4);
  color: var(--text-3);
  font-size: var(--fs-sm);
  text-align: center;
}
.empty__icon { font-size: 22px; opacity: 0.5; line-height: 1; }
.empty__hint { font-size: var(--fs-xs); color: var(--text-4); }

/* ── 加载态 ─────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: skeleton 1.4s ease infinite;
  border-radius: var(--r-xs);
  color: transparent !important;
}
@keyframes skeleton {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ── 滚动条（细，避免抢注意力） ─────────────────────────────── */
.scroll-y {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  /* 不要在这里写 overscroll-behavior: contain：
     它会把滚轮"吃掉"，内层滚到底后页面纹丝不动。默认的滚动链才是用户预期。 */
}
.scroll-y::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-y::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
.scroll-y::-webkit-scrollbar-track { background: transparent; }

/* ── 自绘悬停提示气泡（js/core/tooltip.js 驱动的唯一浮层） ──────
   替代原生 title：0 延迟、样式可控、能换行、键盘 focus 也出。
   节点固定挂 body 末尾 + position: fixed —— 不参与布局流，
   所以列表/表格的行高、列宽不会因为加了提示而变。

   两种形态共用同一个浮层节点：
     · 纯字符串（默认）—— 一行短语，按内容收窄，观感与改造前一致；
     · 结构化信息卡（.dsh-tip--card）—— 标题 / 键值行 / 脚注三段式，
       左对齐、加宽到 340px，标题与脚注各压一条细分隔线。

   配色只用变量，深浅两套主题各自给一套：
     亮色 = 近黑底 + 白字（V1 的深色汽泡手感）
     夜间 = 比卡片稍亮一档的深灰 + 正文色（否则纯黑贴在深色卡上看不出边界）
   箭头是旋转 45° 的方块，颜色跟气泡一致，靠 --arrow-x 对准目标中心。 */
.dsh-tip {
  --tip-bg: color-mix(in srgb, var(--text) 94%, var(--accent));
  --tip-fg: var(--surface);
  /* 气泡上的三级文字层次：值用 --tip-fg 全亮，标签/脚注用同一前景色压透明度，
     不新增硬编码色值，深浅主题都能自动跟随 */
  --tip-muted: color-mix(in srgb, var(--tip-fg) 64%, transparent);
  --tip-faint: color-mix(in srgb, var(--tip-fg) 46%, transparent);
  --tip-line: color-mix(in srgb, var(--tip-fg) 18%, transparent);
  position: fixed;
  left: 0;
  top: 0;
  z-index: calc(var(--z-modal) + 10);
  max-width: min(340px, calc(100vw - 24px));
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: var(--tip-bg);
  color: var(--tip-fg);
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0.2px;
  /* 长文案换行而不是撑破视口；纯字符串里的 \n 保留换行 */
  white-space: pre-line;
  overflow-wrap: anywhere;
  /* 左对齐：单行纯文本气泡按内容收窄，观感不变；信息卡则靠这条保证成列 */
  text-align: left;
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px) scale(0.97);
  transition: opacity 90ms ease-out, transform 90ms ease-out;
  box-shadow: 0 6px 20px var(--overlay), 0 1px 2px var(--overlay);
}
.dsh-tip.show { opacity: 1; transform: translateY(0) scale(1); }
.dsh-tip::after {
  content: '';
  position: absolute;
  left: var(--arrow-x, 50%);
  bottom: -4px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  border-radius: 1px;
  background: var(--tip-bg);
  transform: rotate(45deg);
}
/* 翻到目标下方时，箭头改到气泡顶部 */
.dsh-tip[data-tip-pos="below"]::after { bottom: auto; top: -4px; }

/* ── 结构化信息卡（标题 / 键值 / 脚注） ───────────────────────
   宽度取 340px（窄屏收到视口内），保证最长那行键值不折行。 */
.dsh-tip--card {
  min-width: min(340px, calc(100vw - 24px));
  max-width: min(340px, calc(100vw - 24px));
  padding: 9px 13px 8px;
  border-radius: var(--r-md);
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0;
  white-space: normal;
}
.dsh-tip__title {
  padding-bottom: 7px;
  border-bottom: 1px solid var(--tip-line);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: 0.2px;
}
.dsh-tip__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px 0;
}
.dsh-tip__row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.dsh-tip__k {
  flex: 0 0 auto;
  min-width: 4.5em;              /* 结算时间 / 开赛时间 / 触发条件 / 结算规则 同宽 */
  font-size: var(--fs-2xs);
  font-weight: 500;
  color: var(--tip-muted);
}
.dsh-tip__v {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--tip-fg);
  overflow-wrap: anywhere;       /* 只有小屏放不下时才在值列内换行 */
}
.dsh-tip__note {
  padding-top: 7px;
  border-top: 1px solid var(--tip-line);
  font-size: var(--fs-2xs);
  font-weight: 500;
  line-height: 1.4;
  color: var(--tip-faint);
}

/* 夜间：气泡要比卡片亮一档，否则深压深看不出浮层边界 */
[data-theme="night"] .dsh-tip {
  --tip-bg: color-mix(in srgb, var(--surface-3) 72%, var(--bg-deep));
  --tip-fg: var(--text);
}

@media (prefers-reduced-motion: reduce) {
  .dsh-tip { transition: none; }
}

/* ── 数字/金额的语义色（沿用红涨绿跌） ─────────────────────── */
.tone-up { color: var(--up); }
.tone-down { color: var(--down); }
.tone-flat { color: var(--flat); }
/* ── 移动端横向溢出兜底 ────────────────────────────────────────
   持仓/成交表格在手机上保持 min-width 并靠 .table-wrap 内部横向滚动。
   个别装饰元素（徽标、吸顶表头阴影）会以 1~2px 的量探出视口，
   叠加后让整页出现 20px 左右的横向滚动条 —— 手机上非常难看。
   这里关掉页面级横向滚动；真正的宽内容都在各自的滚动容器里，不受影响。
   ──────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  html, body { overflow-x: hidden; }
}
.sum-item--assets{position:relative}
.sum-entries{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end;margin-left:auto}
.sum-entries .sum-truck-btn{position:static !important;margin-left:0}
