/* ── 主题变量 ───────────────────────────────────────────── */
:root,
[data-theme="dark"] {
  --bg: #0d1117;
  --panel: #161b22;
  --inset: #11151c;
  --text: #c9d1d9;
  --text-strong: #e6edf3;
  --muted: #7d8590;
  --line: #21262d;
  --line-2: #30363d;
  --accent: #4493f8;
  --accent-fg: #ffffff;
  --hover: #1b2330;
  --active: #143055;
  --active-bar: #4493f8;
  --btn: #21262d;
  --btn-hover: #2b323c;
  --low: #3fb950;   /* 低估 */
  --mid: #d29922;   /* 适中 */
  --high: #f85149;  /* 高估 */
  --low-bg: rgba(63,185,80,.16);
  --mid-bg: rgba(210,153,34,.16);
  --high-bg: rgba(248,81,73,.16);
  --track: #20262e;
  --shadow: none;
  --badge-broad-bg: #173052; --badge-broad-fg: #79c0ff;
  --badge-sector-bg: #3a2d12; --badge-sector-fg: #e3b341;
  --badge-etf-bg: #173052;   --badge-etf-fg: #79c0ff;
  --badge-lof-bg: #162a1e;   --badge-lof-fg: #3fb950;
  --badge-otc-bg: #2a1f38;   --badge-otc-fg: #c397f0;
}

[data-theme="light"] {
  --bg: #f6f8fa;
  --panel: #ffffff;
  --inset: #f6f8fa;
  --text: #1f2328;
  --text-strong: #0a0c10;
  --muted: #59636e;
  --line: #d1d9e0;
  --line-2: #d1d9e0;
  --accent: #0969da;
  --accent-fg: #ffffff;
  --hover: #f3f4f6;
  --active: #ddf4ff;
  --active-bar: #0969da;
  --btn: #f6f8fa;
  --btn-hover: #eef1f4;
  --low: #1a7f37;
  --mid: #9a6700;
  --high: #cf222e;
  --low-bg: rgba(26,127,55,.12);
  --mid-bg: rgba(154,103,0,.12);
  --high-bg: rgba(207,34,46,.12);
  --track: #eaeef2;
  --shadow: 0 1px 3px rgba(31,35,40,.08), 0 1px 0 rgba(31,35,40,.04);
  --badge-broad-bg: #ddf4ff; --badge-broad-fg: #0a5ec2;
  --badge-sector-bg: #fff1cc; --badge-sector-fg: #7d5a00;
  --badge-etf-bg: #ddf4ff;   --badge-etf-fg: #0a5ec2;
  --badge-lof-bg: #e6f4ea;   --badge-lof-fg: #1a7f37;
  --badge-otc-bg: #f3effe;   --badge-otc-fg: #7c3aed;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
  /* 顶栏等局部溢出时不把整页横向推出视口 */
  overflow-x: clip;
}

/* 数字一律等宽对齐——专业表格的基本素养 */
.num, td, .sm-val, .sm-bands { font-variant-numeric: tabular-nums; }

/* ── 顶栏 ───────────────────────────────────────────────── */
header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px 16px;
  flex-wrap: wrap;
  padding: 12px 22px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
  /* 防止顶栏链接把整页横向撑破 */
  min-width: 0;
  max-width: 100%;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  flex: 0 0 auto;
  min-width: 0;
}
.brand h1 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: .2px; color: var(--text-strong); }
.logo {
  width: 18px; height: 18px; border-radius: 5px;
  background: linear-gradient(135deg, var(--low), var(--accent) 55%, var(--high));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 auto;
  flex-wrap: wrap;
  margin-left: auto;
  min-width: 0;
  max-width: 100%;
}
.actions a.ghost,
.actions .nav-more > summary.ghost {
  background: var(--btn);
  border: 1px solid var(--line-2);
  color: var(--text);
  padding: 6px 11px;
  border-radius: 7px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  flex: 0 0 auto;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
}
.actions a.ghost:hover,
.actions .nav-more > summary.ghost:hover { background: var(--btn-hover); filter: none; }

/* 顶栏「阅读」折叠菜单：文章入口收进下拉，避免挤爆布局 */
.nav-more {
  position: relative;
  flex: 0 0 auto;
}
.nav-more > summary {
  list-style: none;
}
.nav-more > summary::-webkit-details-marker { display: none; }
.nav-more > summary::after {
  content: "";
  width: 0; height: 0;
  margin-left: 6px;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4.5px solid currentColor;
  opacity: .7;
}
.nav-more[open] > summary {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line-2));
  color: var(--text-strong);
}
.nav-more-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 168px;
  max-width: min(240px, calc(100vw - 24px));
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
  z-index: 40;
}
.nav-more-menu a {
  display: block;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
}
.nav-more-menu a:hover {
  background: var(--hover);
  color: var(--text-strong);
}

/* ── 按钮 ───────────────────────────────────────────────── */
button {
  font: inherit; font-size: 13px;
  background: var(--accent); border: 1px solid transparent; color: var(--accent-fg);
  padding: 6px 13px; border-radius: 7px; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, opacity .15s ease;
}
button:hover { filter: brightness(1.06); }
button.ghost { background: var(--btn); border-color: var(--line-2); color: var(--text); }
button.ghost:hover { background: var(--btn-hover); filter: none; }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; }

.icon-btn {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--btn); border: 1px solid var(--line-2); color: var(--text);
  border-radius: 8px;
}
.icon-btn:hover { background: var(--btn-hover); filter: none; }
.icon-btn svg { width: 16px; height: 16px; }
.field-label-row { display: inline-flex; align-items: center; gap: 6px; }
.metric-help-btn { width: 24px; height: 24px; border-radius: 999px; }
.metric-help-btn svg { width: 13px; height: 13px; }
.metric-help-inline {
  width: 20px;
  height: 20px;
  vertical-align: -4px;
  margin-left: 4px;
}
.metric-help-inline svg { width: 12px; height: 12px; }

/* ── 工具栏 ─────────────────────────────────────────────── */
.toolbar {
  display: flex; gap: 14px; align-items: center;
  padding: 12px 22px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.field { display: flex; align-items: center; gap: 7px; }
.field label { font-size: 12.5px; color: var(--muted); }
select, input[type="search"] {
  font: inherit; font-size: 13px;
  background: var(--panel); border: 1px solid var(--line-2); color: var(--text);
  padding: 6px 10px; border-radius: 7px; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
select:focus, input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent);
}
input[type="search"] { min-width: 220px; }

/* ── 首页数据状态条（单行减负） ─────────────────────────── */
.data-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin: 0 22px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}
.data-strip-main {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text);
}
.data-strip-link {
  flex: 0 0 auto;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
.data-strip-link:hover { text-decoration: underline; }
.data-strip-link.muted {
  color: var(--muted);
  font-weight: 500;
}
.data-strip .sync-health-dot {
  margin-left: 2px;
  flex: 0 0 auto;
}
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.brand-link h1 { margin: 0; }
.brand-link:hover h1 { color: var(--accent); }

/* ── 数据透明度提示（旧多行条，保留兼容） ─────────────── */
.data-transparency {
  display: flex;
  align-items: center;
  gap: 10px 14px;
  flex-wrap: wrap;
  padding: 9px 22px;
  font-size: 12px;
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 86%, var(--bg));
  border-bottom: 1px solid var(--line);
}
.dt-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.dt-label {
  flex: 0 0 auto;
  padding: 1px 7px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  color: var(--text-strong);
  background: var(--btn);
  font-weight: 600;
  line-height: 1.6;
}
.dt-current { color: var(--muted); }
#data-latest-date {
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

/* ── 盘中估算条 ─────────────────────────────────────────── */
.rt-banner {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 22px; font-size: 12px; color: var(--text);
  background: color-mix(in srgb, var(--accent) 8%, var(--panel));
  border-bottom: 1px solid var(--line);
}
.rt-banner.hidden { display: none; }
.rt-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--low);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--low) 60%, transparent);
  animation: rt-pulse 1.6s infinite;
}
@keyframes rt-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--low) 55%, transparent); }
  70% { box-shadow: 0 0 0 6px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.rt-note { color: var(--muted); }
/* 表格内盘中估算值 */
.rt-val { display: inline-flex; align-items: baseline; gap: 5px; }
.rt-val.up { color: var(--high); }
.rt-val.down { color: var(--low); }
.rt-val.flat { color: var(--text); }
.rt-chg { font-size: 11px; opacity: .85; font-variant-numeric: tabular-nums; }
.rt-chg.muted { color: var(--muted); opacity: .6; }
/* 盘中估算的点位/日期：正常文字色 + 小标，区别于纯收盘值 */
.rt-est { display: inline-flex; align-items: baseline; gap: 5px; }
.rt-tag {
  font-size: 10px; color: var(--muted); border: 1px solid var(--line-2);
  border-radius: 4px; padding: 0 4px; line-height: 1.5; white-space: nowrap;
}
/* 数据更新时的变化高亮：仅对相比上次真正变化的单元格做一次背景脉冲（涨红/跌绿） */
@keyframes cellFlashUp { 0%, 25% { background-color: var(--high-bg); } 100% { background-color: transparent; } }
@keyframes cellFlashDown { 0%, 25% { background-color: var(--low-bg); } 100% { background-color: transparent; } }
#tbody td.flash-up { animation: cellFlashUp 2.4s ease-out; }
#tbody td.flash-down { animation: cellFlashDown 2.4s ease-out; }
@media (prefers-reduced-motion: reduce) {
  #tbody td.flash-up, #tbody td.flash-down { animation: none; }
}

/* ── 布局 ───────────────────────────────────────────────── */
/* 仅首页双栏；勿用裸 main，否则数据说明/文章/自选等页会被拆栏 */
main.home-layout {
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(440px, 1.25fr);
  gap: 16px;
  padding: 16px 22px 24px;
}
@media (max-width: 980px) {
  main.home-layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
/* 列表：镜头栏固定，表格区独立滚动（高度约束打在 .table-scroll 上，避免 flex 塌缩） */
.table-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* 建立 BFC，避免子项 margin/高度把 panel 撑出视口外 */
  min-height: 0;
}
/* 长列表：跳过屏外行的布局/绘制，滚动更省 */
#tbl tbody tr {
  content-visibility: auto;
  contain-intrinsic-size: auto 48px;
}
.table-scroll {
  flex: 1 1 auto;
  min-height: 0; /* flex 子项默认为 auto，不设 0 时部分 WebKit 会按内容撑开、overflow 失效 */
  max-height: calc(80vh - 48px);
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* iOS 惯性滚动 */
  overscroll-behavior: contain;       /* 嵌套滚到边界不把整页卷走 */
  overscroll-behavior-y: contain;
  /* 交给浏览器原生 pan，保留动量；不要用 JS 写 scrollTop（会失去惯性） */
  touch-action: pan-x pan-y;
  position: relative;
  z-index: 0;
  /* 滚动合成层，减少花哨重绘 */
  will-change: scroll-position;
}

/* ── 市场估值温度 ───────────────────────────────────────── */
.overview {
  display: flex; align-items: stretch; gap: 8px;
  margin: 16px 22px 0; padding: 8px 8px 8px 4px;
}
.ov-gauge { flex: 0 0 220px; }
#gauge { width: 220px; height: 190px; }
.ov-trend { flex: 1; min-width: 0; display: flex; flex-direction: column;
  padding: 10px 14px 6px 4px; }
.ov-head { display: flex; align-items: baseline; gap: 10px; }
.ov-title { font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.ov-sub { font-size: 12px; color: var(--muted); }
#temp-trend { flex: 1; width: 100%; height: 110px; min-height: 110px; }
.ov-foot { font-size: 11px; color: var(--muted); padding-top: 4px; }

/* ── 估值雷达 ───────────────────────────────────────────── */
.radar {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin: 16px 22px 0;
}
.radar.hidden { display: none; }
.radar-foot { grid-column: 1 / -1; font-size: 11px; color: var(--muted); padding-top: 2px; }
.radar-col {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 10px 12px 6px;
}
.rc-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.rc-title { font-size: 13px; font-weight: 600; color: var(--text-strong); }
.rc-title.low { color: var(--low); }
.rc-title.high { color: var(--high); }
.rc-sub { font-size: 11.5px; color: var(--muted); }
.radar-list { display: flex; flex-direction: column; }
.rc-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 6px; border-radius: 7px; cursor: pointer;
  border-top: 1px solid var(--line);
  transition: background-color .12s ease;
}
.rc-item:first-child { border-top: none; }
.rc-item:hover { background: var(--hover); }
.rc-item.active { background: var(--active); }
.rc-code { font-size: 10.5px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.rc-name { flex: 1; min-width: 0; color: var(--text-strong); font-size: 12.5px;
  font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-pct { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rc-pct.low { color: var(--low); }
.rc-pct.mid { color: var(--mid); }
.rc-pct.high { color: var(--high); }
.rc-chg { font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums;
  min-width: 52px; text-align: right; }
.rc-chg.up { color: var(--high); }
.rc-chg.down { color: var(--low); }
.rc-empty { color: var(--muted); font-size: 12px; padding: 10px 6px; }

@media (max-width: 980px) {
  .radar { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .radar { margin: 12px 12px 0; }
}

/* ── 跟踪 ETF 面板 ──────────────────────────────────────── */
.etf-panel { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.etf-panel.hidden { display: none; }
.etf-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; padding: 0 16px; }
.etf-title { font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.etf-sub { font-size: 12px; color: var(--muted); }
.etf-foot { font-size: 11px; color: var(--muted); padding: 8px 16px 0; line-height: 1.5; }
#etf-body { overflow-x: auto; }
.etf-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.etf-table th { color: var(--muted); font-weight: 500; font-size: 11.5px;
  padding: 6px 10px; border-bottom: 1px solid var(--line); }
.etf-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
.etf-table tr:last-child td { border-bottom: none; }
.etf-table .etf-code { color: var(--muted); font-size: 12px; }
.etf-table .etf-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--text-strong); }
.etf-table th:nth-child(3), .etf-table td:nth-child(3) { text-align: left; }
.etf-table th:first-child, .etf-table td:first-child { padding-left: 16px; }
.etf-table th:last-child, .etf-table td:last-child { padding-right: 16px; }
.etf-table td.up { color: var(--high); }
.etf-table td.down { color: var(--low); }
.etf-table .etf-asof { display: block; color: var(--muted); font-size: 10px; font-weight: 400; }

/* 成分股下钻子表：与 ETF 面板同构 */
.cons-panel { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.cons-panel.hidden { display: none; }
.cons-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; padding: 0 16px; }
.cons-title { font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
.cons-sub { font-size: 12px; color: var(--muted); }
.cons-foot { font-size: 11px; color: var(--muted); padding: 8px 16px 0; line-height: 1.5; }
#cons-body { overflow-x: auto; }
.cons-table { width: 100%; min-width: 440px; border-collapse: collapse; font-size: 12.5px; table-layout: fixed; }
.cons-table th { color: var(--muted); font-weight: 500; font-size: 11.5px;
  padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.cons-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.cons-table tr:last-child td { border-bottom: none; }
.cons-table th:nth-child(1), .cons-table td:nth-child(1) { width: 44px; text-align: left; }
.cons-table th:nth-child(2), .cons-table td:nth-child(2) { width: 84px; text-align: left; }
.cons-table th:nth-child(3), .cons-table td:nth-child(3) { text-align: left; }
.cons-table th:nth-child(4), .cons-table td:nth-child(4) { width: 170px; text-align: right; }
.cons-table th:first-child, .cons-table td:first-child { padding-left: 16px; }
.cons-table th:last-child, .cons-table td:last-child { padding-right: 16px; }
.cons-table .cons-rank { color: var(--muted); font-size: 11.5px; white-space: nowrap;
  font-variant-numeric: tabular-nums; }
.cons-table .cons-code { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.cons-table .cons-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--text-strong); }
.cons-table .cons-wt { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.cons-table .cons-wnum { display: inline-block; min-width: 46px; text-align: right;
  font-variant-numeric: tabular-nums; color: var(--text); }
.cons-table .pctbar { display: inline-block; width: 56px; height: 5px; border-radius: 3px;
  background: var(--track); overflow: hidden; flex-shrink: 0; }
.cons-table .pctbar i.cons-bar { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
@media (max-width: 600px) {
  .cons-table { min-width: 100%; }
  .cons-table th:nth-child(4), .cons-table td:nth-child(4) { width: 135px; }
  .cons-table .pctbar { width: 36px; }
}
.cons-toggle { margin: 10px 16px 0; padding: 5px 12px; border: 1px solid var(--line-2);
  border-radius: 999px; background: var(--btn); color: var(--muted); font-size: 12px;
  cursor: pointer; transition: background .12s, color .12s; }
.cons-toggle:hover { background: var(--btn-hover); color: var(--text); }
.cons-toggle.hidden { display: none; }

.chart-ctrls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── 表格 ───────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
/*
 * 固定布局 + colgroup 定宽。
 * 否则超长名（MSCI中国A股国际通实时(人民币)）会按 min-content 撑开第一列，
 * 把「历史分位」挤出视口。
 */
#tbl {
  table-layout: fixed;
  width: 100%;
  border-collapse: collapse;
}
/*
 * 桌面七列：在左侧表约 540–640px 宽时仍要完整显示
 * 「行业主题」徽章与「YYYY-MM-DD」日期（勿再压成「行业主」「2026-07-」）。
 */
#tbl .col-name { width: 22%; }
#tbl .col-cat { width: 15%; }
#tbl .col-value { width: 11%; }
#tbl .col-pct { width: 15%; }
#tbl .col-point { width: 13%; }
#tbl .col-date { width: 14%; }
#tbl .col-compare { width: 48px; }
#tbl th,
#tbl td {
  vertical-align: middle;
}
/* 仅名称列强制裁切省略；分类/日期等允许完整显示 */
#tbl th:first-child,
#tbl td:first-child {
  overflow: hidden;
}
#tbl th:nth-child(2),
#tbl td:nth-child(2),
#tbl th:nth-child(6),
#tbl td:nth-child(6) {
  overflow: visible;
}
th, td { padding: 10px 14px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th:nth-child(2), td:nth-child(2) { text-align: left; }

thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--inset);
  font-size: 12px; font-weight: 600; color: var(--muted);
  cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--line);
  transition: color .15s ease;
}
thead th:hover { color: var(--text); }
.th-help {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}
thead th[data-sort]::after {
  content: ""; display: inline-block; width: 0; margin-left: 5px;
  border-left: 3.5px solid transparent; border-right: 3.5px solid transparent;
  opacity: 0; transition: opacity .15s ease;
}
thead th.sorted { color: var(--text-strong); }
thead th.sorted[data-dir="asc"]::after { border-bottom: 4px solid currentColor; opacity: .8; }
thead th.sorted[data-dir="desc"]::after { border-top: 4px solid currentColor; opacity: .8; }

tbody td { font-size: 13px; border-top: 1px solid var(--line); }
tbody tr { cursor: pointer; transition: background-color .12s ease; }
tbody tr:hover { background: var(--hover); }
tbody tr.active { background: var(--active); }
tbody tr.active td:first-child { box-shadow: inset 3px 0 0 var(--active-bar); }
tbody td:first-child { font-weight: 500; color: var(--text-strong); }
.idx-name {
  display: block;
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.idx-code {
  display: block;
  font-size: 11px; font-weight: 400; color: var(--muted); letter-spacing: .02em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500; line-height: 1.4;
}
.badge.宽基 { background: var(--badge-broad-bg); color: var(--badge-broad-fg); }
.badge.行业主题 { background: var(--badge-sector-bg); color: var(--badge-sector-fg); }
.badge.ETF { background: var(--badge-etf-bg); color: var(--badge-etf-fg); }
.badge.LOF { background: var(--badge-lof-bg); color: var(--badge-lof-fg); }
.badge.OTC { background: var(--badge-otc-bg); color: var(--badge-otc-fg); }

/* 历史分位：数字 + 细进度条，一眼看出贵贱 */
.pct { min-width: 0; }
.pct .pctnum { font-weight: 600; font-variant-numeric: tabular-nums; }
.pct .pctbar {
  display: block; width: 100%; max-width: 100%;
  height: 3px; margin-top: 4px; border-radius: 2px;
  background: var(--track); overflow: hidden;
}
.pct .pctbar i { display: block; height: 100%; border-radius: 2px; }
.pctnum.low, .pctbar i.low { color: var(--low); }
.pctnum.mid, .pctbar i.mid { color: var(--mid); }
.pctnum.high, .pctbar i.high { color: var(--high); }
.pctbar i.low { background: var(--low); }
.pctbar i.mid { background: var(--mid); }
.pctbar i.high { background: var(--high); }

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

/* ── 估值算法说明弹窗 ───────────────────────────────────── */
.metric-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
}
.metric-modal.hidden { display: none; }
.metric-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .48);
}
.metric-modal__panel {
  position: relative;
  width: min(720px, 100%);
  max-height: min(82vh, 760px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, .35);
  padding: 18px 18px 16px;
}
.metric-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.metric-modal__kicker {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 4px;
}
.metric-modal__head h2 {
  margin: 0;
  font-size: 17px;
  color: var(--text-strong);
}
.metric-modal__close { flex: 0 0 auto; }
.metric-modal__body {
  display: grid;
  gap: 14px;
  padding-top: 14px;
}
.metric-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 12px 10px;
  background: color-mix(in srgb, var(--panel) 88%, var(--inset));
}
.metric-block .metric-tags { margin-top: 8px; }
.metric-block h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--text-strong);
}
.metric-block p {
  margin: 0;
  color: var(--text);
  line-height: 1.72;
  font-size: 13px;
}
.metric-block ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.7;
  font-size: 13px;
}
.metric-source-badge {
  display: inline-flex;
  align-items: center;
  margin-right: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--badge-broad-fg);
  background: var(--badge-broad-bg);
  border: 1px solid color-mix(in srgb, var(--badge-broad-fg) 22%, transparent);
}
.metric-method-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.metric-method {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--inset);
}
.metric-method span {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-strong);
}
.metric-method p {
  font-size: 12px;
  color: var(--muted);
}
.metric-note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  padding-top: 2px;
}
.metric-note a {
  color: var(--accent);
  text-decoration: none;
  margin-left: 4px;
}
.metric-note a:hover { text-decoration: underline; }
.metric-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.metric-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--inset);
  color: var(--muted);
  border: 1px solid var(--line-2);
}

/* ── 图表区 ─────────────────────────────────────────────── */
#chart-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line);
}
#chart-title { font-size: 13.5px; font-weight: 600; color: var(--text-strong); }
#chart-title .ct-code { font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 4px; vertical-align: middle; }

/* 分段控件风格的区间切换 */
.segmented { display: inline-flex; gap: 2px; padding: 2px;
  background: var(--inset); border: 1px solid var(--line-2); border-radius: 9px; }
.rtab {
  background: transparent; border: none; color: var(--muted);
  padding: 4px 11px; border-radius: 7px; font-size: 12px; cursor: pointer;
  transition: color .12s ease, background-color .12s ease;
}
.rtab:hover { color: var(--text); filter: none; }
.rtab.on { background: var(--panel); color: var(--text-strong);
  box-shadow: 0 1px 2px rgba(0,0,0,.18); }

#chart-summary {
  display: flex; flex-direction: column;
  gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
#chart-summary.hidden, #chart-hint.hidden { display: none; }
.sm-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.sm-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  min-width: 0;
  flex: 1 1 auto;
}
.sm-val { font-size: 26px; font-weight: 700; color: var(--text-strong); letter-spacing: -.5px; line-height: 1.15; }
.sm-lbl {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.25;
  max-width: 6.5em;
}
.sm-help-btn {
  flex: 0 0 auto;
  margin-left: -2px;
}
/* 状态徽章 + 自选：成组换行，徽章本身不折行 */
.sm-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  margin-left: 4px;
}
.sm-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  flex: 0 0 auto;
}
.sm-status.low { background: var(--low-bg); color: var(--low); }
.sm-status.mid { background: var(--mid-bg); color: var(--mid); }
.sm-status.high { background: var(--high-bg); color: var(--high); }
#chart-summary .watch-btn {
  flex: 0 0 auto;
  align-self: center;
}
.sm-bands { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--muted); }
.sm-bands .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.dot.opp { background: var(--low); }
.dot.mid { background: var(--mid); }
.dot.danger { background: var(--high); }
.sm-explain { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.sm-radar { display: flex; gap: 8px; flex-wrap: wrap; }
.ctx-chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; line-height: 1.6;
}
.ctx-chip.low { background: var(--low-bg); color: var(--low); }
.ctx-chip.high { background: var(--high-bg); color: var(--high); }
.ctx-chip.mover { background: var(--badge-broad-bg); color: var(--badge-broad-fg); }

#chart { width: 100%; height: 440px; }
#chart-hint { padding: 60px 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* ── 移动端 ─────────────────────────────────────────────── */
@media (max-width: 980px) {
  .overview { flex-direction: column; gap: 0; }
  .ov-gauge { flex: none; align-self: center; }

  /*
   * 单列布局（含手机横屏，宽度常 >600）：列表要有明确高度才能嵌套滚。
   * 用原生 overflow 滚动（带惯性），overscroll-behavior 挡滚动链。
   * 不再 touch-action:none + JS 写 scrollTop（会失去丝滑惯性）。
   */
  .table-scroll {
    height: 55vh;
    max-height: 55vh;
    min-height: 240px;
    overflow-y: auto;
    overflow-x: auto;
    overscroll-behavior: contain;
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
  }
  @supports (height: 100dvh) {
    .table-scroll {
      height: 55dvh;
      max-height: 55dvh;
    }
  }
}

/*
 * 窄屏表格：grid 四列（与 index.html 内联一致）。
 * 实测 table-layout + col 百分比在 Chrome 手机宽度下会把「当前值」算成 0px。
 */
@media (max-width: 900px) {
  #tbl { display: block; width: 100%; }
  #tbl colgroup { display: none; }
  #tbl thead, #tbl tbody { display: block; width: 100%; }
  #tbl thead { position: sticky; top: 0; z-index: 2; }
  #tbl tbody tr {
    contain-intrinsic-size: auto 52px;
  }
  #tbl tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 4.75rem 5.75rem 2.75rem;
    width: 100%;
    align-items: center;
    box-sizing: border-box;
  }
  #tbl th, #tbl td {
    display: flex;
    align-items: center;
    width: auto !important;
    min-width: 0;
    box-sizing: border-box;
  }
  #tbl th:nth-child(1), #tbl td:nth-child(1) {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    overflow: hidden;
  }
  #tbl th:nth-child(3), #tbl td:nth-child(3),
  #tbl th:nth-child(4), #tbl td:nth-child(4) { justify-content: flex-end; }
  #tbl td.pct { flex-direction: column; align-items: flex-end; justify-content: center; width: 100%; }
  #tbl .pctbar { width: 100%; max-width: 100%; }
  #tbl th:nth-child(7), #tbl td:nth-child(7) { justify-content: center; }
  #tbl th:nth-child(2), #tbl td:nth-child(2),
  #tbl th:nth-child(5), #tbl td:nth-child(5),
  #tbl th:nth-child(6), #tbl td:nth-child(6) { display: none !important; }
}

@media (max-width: 600px) {
  header, .toolbar, .data-strip, .data-transparency { padding-left: 12px; padding-right: 12px; }
  header { gap: 8px 10px; padding-top: 10px; padding-bottom: 10px; }
  main.home-layout { padding: 12px; gap: 12px; }
  .overview { margin: 12px 12px 0; }
  .brand h1 { font-size: 15px; }
  .actions { gap: 5px; }
  .actions a.ghost,
  .actions .nav-more > summary.ghost {
    padding: 5px 9px;
    font-size: 12px;
  }
  .data-strip { margin: 0 12px; }
  .data-transparency { align-items: flex-start; }
  .dt-item { flex: 1 1 100%; }

  input[type="search"] { min-width: 0; flex: 1 1 100%; }

  th, td { padding: 8px 8px; }
  #tbl .compare-pick-btn { width: 28px; height: 28px; font-size: 16px; }
  #tbl th:first-child, #tbl td:first-child { padding-left: 12px; }
  /* 盘中估算：涨跌叠在数值下方，避免把当前值列撑破 */
  #tbl .rt-val {
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
    line-height: 1.15;
  }
  #tbl .rt-chg { font-size: 10px; }

  #chart-head { flex-wrap: wrap; }
  #chart { height: 240px; }
  .sm-val { font-size: 22px; }
  .sm-lbl { max-width: none; }
  /* 窄屏：数值一行，状态+自选整组换到下一行，避免徽章被挤断行 */
  .sm-actions { margin-left: 0; }
  .sm-bands { gap: 12px; }
  .metric-modal { padding: 10px; }
  .metric-modal__panel { padding: 14px 14px 12px; }
  .metric-modal__head h2 { font-size: 16px; }
  .metric-method-grid { grid-template-columns: 1fr; }
}

/* ── 骨架屏闪烁动画 ─────────────────────────────────────────── */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton-text,
.skeleton-badge,
.skeleton-bar {
  display: inline-block;
  background: linear-gradient(90deg, var(--line) 25%, var(--line-2) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: 4px;
  vertical-align: middle;
}

.skeleton-text {
  height: 13px;
}

.skeleton-badge {
  width: 56px;
  height: 18px;
  border-radius: 999px;
}

.skeleton-bar {
  display: block;
  height: 3px;
  width: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--line) 25%, var(--line-2) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
}


/* 镜头条：把主表投影成「低估/适中/高估」子表的操作入口 */
.lens-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 12px 0;
  flex-shrink: 0; /* 固定在列表上方，不参与纵向滚动 */
}
.lens-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--btn);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.lens-chip:hover { background: var(--btn-hover); color: var(--text); }
.lens-chip .lens-count {
  min-width: 18px;
  padding: 0 5px;
  text-align: center;
  border-radius: 999px;
  background: var(--track);
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.lens-chip.active { color: var(--text-strong); border-color: var(--accent); background: var(--active); }
.lens-chip.active .lens-count { background: var(--accent); color: var(--accent-fg); }
/* 桶色：低估绿 / 适中黄 / 高估红；自选用强调色 */
.lens-chip.lens-low.active  { border-color: var(--low);  background: var(--low-bg); }
.lens-chip.lens-mid.active  { border-color: var(--mid);  background: var(--mid-bg); }
.lens-chip.lens-high.active { border-color: var(--high); background: var(--high-bg); }
.lens-chip.lens-watch.active {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line-2));
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  color: var(--text-strong);
}
.lens-chip.lens-low.active  .lens-count { background: var(--low);  color: #fff; }
.lens-chip.lens-mid.active  .lens-count { background: var(--mid);  color: #fff; }
.lens-chip.lens-high.active .lens-count { background: var(--high); color: #fff; }
.lens-chip.lens-watch.active .lens-count {
  background: var(--accent);
  color: var(--accent-fg);
}

/* ── 跨指数对比 ─────────────────────────────────────────── */
header h1 .sep { color: var(--muted); font-weight: 400; }

.quick-compare-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, var(--bg));
}
.quick-compare-bar.hidden { display: none; }
.quick-compare-title {
  color: var(--text-strong);
  font-size: 12.5px;
  font-weight: 600;
}
.quick-compare-count {
  color: var(--muted);
  font-size: 12px;
  margin-left: 6px;
}
.quick-compare-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.compare-open-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 31px;
  padding: 5px 12px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-fg);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}
.compare-open-btn:hover { filter: brightness(1.06); }
.compare-action-th {
  width: 54px;
  text-align: center;
  cursor: default;
}
.compare-action-cell {
  width: 54px;
  text-align: center;
}
.compare-pick-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--btn);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
}
.compare-pick-btn:hover {
  background: var(--btn-hover);
  color: var(--text-strong);
  filter: none;
}
.compare-pick-btn.active {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line-2));
  background: var(--active);
  color: var(--accent);
  font-size: 15px;
}
.compare-pick-btn:disabled {
  opacity: .35;
}

.compare-main {
  display: block;
}

/* 搜索下拉 */
.search-dropdown-wrap { position: relative; }
.search-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  background: var(--panel); border: 1px solid var(--line-2); border-top: none;
  border-radius: 0 0 6px 6px; box-shadow: var(--shadow);
  max-height: 280px; overflow-y: auto;
}
.dd-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.dd-item:last-child { border-bottom: none; }
.dd-item:hover, .dd-item.focused { background: var(--hover); }
.dd-item.disabled { opacity: .4; cursor: default; background: transparent; }
.dd-name { flex: 1; color: var(--text-strong); font-weight: 600; }
.dd-code { color: var(--muted); font-size: 11px; }
.dd-cat { font-size: 10px; }
.dd-added { color: var(--low); font-size: 11px; flex-shrink: 0; }

/* Chip 栏 */
.compare-chip-bar {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 0 16px 4px; flex-wrap: wrap;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--btn); color: var(--text-strong); font-size: 13px;
}
.chip-rm {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border: none; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 14px; line-height: 1;
  cursor: pointer; padding: 0;
}
.chip-rm:hover { background: var(--high-bg); color: var(--high); }
.clear-btn {
  border: none; background: transparent; color: var(--high);
  font-size: 12px; cursor: pointer; padding: 4px 6px; white-space: nowrap;
}
.clear-btn:hover { text-decoration: underline; }

/* 对比表格 */
.compare-hint {
  padding: 48px 16px; text-align: center; color: var(--muted); font-size: 15px;
}
.compare-table-scroll {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.compare-loading { overflow-x: auto; }
.compare-table, .skeleton-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.compare-table th,
.compare-table td,
.skeleton-table th,
.skeleton-table td {
  padding: 10px 12px; text-align: right; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
.compare-table th {
  position: sticky; top: 0; background: var(--panel);
  color: var(--muted); font-weight: 600; font-size: 12px; z-index: 1;
}
.compare-table th:first-child,
.compare-table td:first-child {
  text-align: left; position: sticky; left: 0;
  background: var(--panel); z-index: 2;
}
.compare-table th:first-child { z-index: 3; }
.compare-table tbody tr:hover td { background: var(--hover); }
.compare-table tbody tr:hover td:first-child { background: var(--hover); }
.cmp-name-col { min-width: 130px; }
.cmp-metric-col { min-width: 80px; }
.cmp-date-col { min-width: 90px; }
.cmp-val { color: var(--text-strong); font-weight: 600; font-variant-numeric: tabular-nums; }
.cmp-pct { display: block; font-size: 11px; font-variant-numeric: tabular-nums; }
.cmp-pct.low  { color: var(--low); }
.cmp-pct.mid  { color: var(--mid); }
.cmp-pct.high { color: var(--high); }
.cmp-date { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.compare-table td.na { color: var(--muted); }
.stale-mark { color: var(--mid); font-weight: 600; cursor: help; }
.date-stale { color: var(--muted); }

/* 源端数据质量：估值停更 / 日期滞后 */
.dq-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.5;
  vertical-align: middle;
  white-space: nowrap;
  cursor: help;
}
.dq-tag.warn {
  background: rgba(210, 153, 34, 0.16);
  color: #d4a017;
  border: 1px solid rgba(210, 153, 34, 0.28);
}
.dq-tag.error {
  background: rgba(248, 81, 73, 0.14);
  color: #e77;
  border: 1px solid rgba(248, 81, 73, 0.28);
}
tr.dq-error td { opacity: 0.88; }
tr.dq-error .idx-name { color: var(--text); }
.sm-dq {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  margin: 8px 0 4px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.45;
}
.sm-dq.warn {
  background: rgba(210, 153, 34, 0.1);
  border: 1px solid rgba(210, 153, 34, 0.28);
  color: var(--text);
}
.sm-dq.error {
  background: rgba(248, 81, 73, 0.08);
  border: 1px solid rgba(248, 81, 73, 0.25);
  color: var(--text);
}
.sm-dq strong { font-weight: 600; }
.sm-dq a { color: var(--accent); text-decoration: none; white-space: nowrap; }
.sm-dq a:hover { text-decoration: underline; }

.compare-foot {
  padding: 12px 16px; color: var(--muted); font-size: 12px; text-align: center;
}

/* ── 历史分位分段可视化 ─────────────────────────────────── */
.pct-seg-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pct-seg-bar.hidden { display: none; }
.pct-seg-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pct-seg-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.pct-seg-track {
  position: relative;
  flex: 1;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  display: flex;
}
.pct-seg-s {
  height: 100%;
  transition: opacity .15s;
}
.pct-seg-s.s0 { background: var(--low); opacity: .38; }
.pct-seg-s.s1 { background: var(--low); opacity: .22; }
.pct-seg-s.s2 { background: var(--mid); opacity: .26; }
.pct-seg-s.s3 { background: var(--high); opacity: .22; }
.pct-seg-s.s4 { background: var(--high); opacity: .38; }
.pct-seg-s.hl {
  opacity: 1 !important;
}
/* 股息率方向反转 */
.pct-seg-bar.inv .pct-seg-s.s0 { background: var(--high); opacity: .38; }
.pct-seg-bar.inv .pct-seg-s.s1 { background: var(--high); opacity: .22; }
.pct-seg-bar.inv .pct-seg-s.s2 { background: var(--mid); opacity: .26; }
.pct-seg-bar.inv .pct-seg-s.s3 { background: var(--low); opacity: .22; }
.pct-seg-bar.inv .pct-seg-s.s4 { background: var(--low); opacity: .38; }
.pct-seg-bar.inv .pct-seg-s.hl {
  opacity: 1 !important;
}

.pct-seg-pointer {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--text-strong);
  border-radius: 1px;
  z-index: 2;
  transition: left .25s ease;
}
.pct-seg-pointer::after {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid var(--text-strong);
}
.pct-seg-ticks {
  display: flex;
  justify-content: space-between;
  padding: 0 2px;
  font-size: 10.5px;
  color: var(--muted);
}
.pct-seg-ticks span {
  text-align: center;
  min-width: 28px;
}

/* 表格内分位分段进度条 — 轨道显示分段渐变 + 当前位置覆盖固态条 */
.pctbar.pct-bar-seg {
  position: relative;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    color-mix(in srgb, var(--low) 32%, transparent) 0%,
    color-mix(in srgb, var(--low) 32%, transparent) 20%,
    color-mix(in srgb, var(--low) 14%, var(--mid) 14%) 20%,
    color-mix(in srgb, var(--low) 14%, var(--mid) 14%) 40%,
    color-mix(in srgb, var(--mid) 24%, transparent) 40%,
    color-mix(in srgb, var(--mid) 24%, transparent) 60%,
    color-mix(in srgb, var(--mid) 14%, var(--high) 14%) 60%,
    color-mix(in srgb, var(--mid) 14%, var(--high) 14%) 80%,
    color-mix(in srgb, var(--high) 32%, transparent) 80%,
    color-mix(in srgb, var(--high) 32%, transparent) 100%
  );
}
.pctbar.pct-bar-seg i {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 2px;
  transition: width .3s ease;
}

/* ── 账户 / 自选 ─────────────────────────────────────────── */
.auth-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.auth-nav form { display: inline; margin: 0; }
.watchlist-nav-link {
  position: relative;
  gap: 5px !important;
}
.watch-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0 5px;
  margin-left: 2px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--accent-fg);
  background: var(--accent);
  vertical-align: middle;
}
.tbl-watched,
.rc-watched {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line-2));
  white-space: nowrap;
  vertical-align: middle;
}
#radar .rc-item.watched .rc-name {
  font-weight: 600;
}
#tbody tr.watched .idx-name {
  font-weight: 600;
}
.wl-metric-link {
  text-decoration: none;
  color: inherit;
  border-radius: 6px;
  padding: 2px 4px;
  margin: -2px -4px;
}
.wl-metric-link:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  text-decoration: none;
}
.wl-metric-link .wl-pct {
  color: var(--accent);
}
.auth-nav .auth-email,
.actions .auth-email {
  font-size: 12px;
  color: var(--muted);
  max-width: 12em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 登录/自选/对比：单栏块级（首页用 main.home-layout 双栏） */
main.auth-shell,
main.watchlist-shell,
main.compare-main {
  display: block;
  grid-template-columns: none;
  gap: 0;
}
.auth-shell {
  max-width: 420px;
  margin: 40px auto 64px;
  padding: 0 16px;
}
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px 24px 22px;
  box-shadow: var(--shadow);
}
.auth-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
  color: var(--text-strong);
}
.auth-lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65;
}
.auth-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--high-bg);
  color: var(--high);
  font-size: 13px;
}
.auth-ok {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--low-bg);
  color: var(--low);
  font-size: 13px;
  line-height: 1.55;
}
.auth-inline-link {
  margin: -4px 0 0;
  text-align: right;
  font-size: 12.5px;
}
.auth-inline-link a {
  color: var(--accent);
  text-decoration: none;
}
.auth-inline-link a:hover { text-decoration: underline; }
.auth-form {
  display: grid;
  gap: 14px;
}
.auth-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.auth-form input {
  font: inherit;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--inset);
  color: var(--text-strong);
}
.auth-form input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-color: var(--accent);
}
.auth-form button.primary,
.auth-form button[type="submit"] {
  margin-top: 4px;
  width: 100%;
  padding: 10px 14px;
  font-weight: 600;
}
.auth-foot {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.auth-foot a { color: var(--accent); }

.watch-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--btn);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.watch-btn:hover { background: var(--btn-hover); filter: none; }
.watch-btn.on {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line-2));
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  color: var(--text-strong);
}
.watch-btn .star { font-size: 13px; line-height: 1; }
.watch-btn.sm { padding: 3px 8px; font-size: 12px; }
.etf-table th.watch-col,
.etf-table td.watch-col {
  width: 3.2rem;
  text-align: center;
}

/* 自选页：单栏全宽，标题在上、表格在下 */
main.watchlist-shell {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 22px 22px 48px;
  box-sizing: border-box;
}
.watchlist-head {
  margin-bottom: 14px;
}
.watchlist-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
  color: var(--text-strong);
}
.watchlist-lead {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
  max-width: 64ch;
}
.watchlist-meta {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}
.watchlist-status {
  color: var(--muted);
  font-size: 13.5px;
  padding: 12px 0;
}
.watchlist-table-wrap {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.watchlist-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.watchlist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.watchlist-table-rich {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}
/* 类型 · 名称 · PE · PB · 股息 · 观察区 · 操作 */
.watchlist-table-rich col.wl-c-type { width: 4.2rem; }
.watchlist-table-rich col.wl-c-name { width: auto; }
.watchlist-table-rich col.wl-c-metric { width: 5.6rem; }
.watchlist-table-rich col.wl-c-zone { width: 6.2rem; }
.watchlist-table-rich col.wl-c-act { width: 5.2rem; }
.watchlist-table th,
.watchlist-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.watchlist-table th {
  background: var(--inset);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}
.watchlist-table th.num,
.watchlist-table td.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.watchlist-table th.wl-act,
.watchlist-table td.wl-act {
  text-align: right;
  padding-right: 12px;
  white-space: nowrap;
}
.watchlist-table tr:last-child td { border-bottom: none; }
.watchlist-table tbody tr:hover td {
  background: color-mix(in srgb, var(--hover) 70%, transparent);
}
.watchlist-table a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.watchlist-table a:hover { text-decoration: underline; }
.wl-name {
  min-width: 0;
  overflow: hidden;
}
.wl-name > a {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wl-name .wl-sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wl-metric {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
}
.wl-pct {
  font-weight: 600;
  color: var(--text-strong);
}
.wl-delta {
  font-size: 11.5px;
  color: var(--muted);
}
.wl-delta.up { color: var(--high); }
.wl-delta.down { color: var(--low); }
.wl-zone {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line-2);
  white-space: nowrap;
}
.wl-zone.low {
  color: var(--low);
  background: var(--low-bg);
  border-color: color-mix(in srgb, var(--low) 35%, var(--line-2));
}
.wl-zone.high {
  color: var(--high);
  background: var(--high-bg);
  border-color: color-mix(in srgb, var(--high) 35%, var(--line-2));
}
.wl-zone.mid {
  color: var(--mid);
  background: var(--mid-bg);
  border-color: color-mix(in srgb, var(--mid) 30%, var(--line-2));
}
.watchlist-type {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  background: var(--inset);
  border: 1px solid var(--line-2);
  color: var(--muted);
}
.watchlist-footnote {
  margin: 10px 14px 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
}

/* 窄屏：卡片式行，避免横向滚动裁切「观察区 / 移出」 */
@media (max-width: 800px) {
  main.watchlist-shell { padding: 16px 12px 40px; }
  .watchlist-table-rich { table-layout: auto; min-width: 0; }
  .watchlist-table-rich colgroup { display: none; }
  .watchlist-table-rich thead { display: none; }
  .watchlist-table-rich,
  .watchlist-table-rich tbody,
  .watchlist-table-rich tr,
  .watchlist-table-rich td {
    display: block;
    width: 100%;
  }
  .watchlist-table-rich tr {
    position: relative;
    padding: 12px 12px 12px 14px;
    border-bottom: 1px solid var(--line);
    box-sizing: border-box;
  }
  .watchlist-table-rich tr:last-child { border-bottom: none; }
  .watchlist-table-rich td {
    padding: 0;
    border: none;
    text-align: left !important;
  }
  .watchlist-table-rich td.num { margin-top: 0; }
  .watchlist-table-rich td:nth-child(1) {
    position: absolute;
    top: 12px;
    left: 14px;
  }
  .watchlist-table-rich td.wl-name {
    padding: 0 5.5rem 0 3.4rem;
    min-height: 2.4rem;
  }
  .watchlist-table-rich td.wl-act {
    position: absolute;
    top: 10px;
    right: 10px;
    width: auto;
    padding: 0;
  }
  .watchlist-table-rich td.num {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    width: auto;
    margin: 10px 14px 0 0;
    vertical-align: top;
  }
  .watchlist-table-rich td.num::before {
    content: attr(data-label);
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 2px;
  }
  .watchlist-table-rich td.num .wl-metric { align-items: flex-start; }
  .watchlist-table-rich td.wl-zone-cell {
    display: inline-flex;
    margin: 10px 0 0;
    vertical-align: top;
  }
  .watchlist-table-rich td.wl-zone-cell::before {
    content: none;
  }
}
