/* ============================================================================
   QRE-SAAS-CARD-CLASS — 小数据卡统一样式（2026-10-29）
   ----------------------------------------------------------------------------
   「一类卡」的定义：回测详情 / 个股详情里所有**单值小卡**，一律由 `.metric-card`
   渲染，分布在以下位置——

     回测结果页（job.html）
       · #metric-strip            主指标条（总收益率/年化/夏普/回撤/胜率/平均持股周期）
       · #ra-strip                风险调整收益条（α / β / 信息比率）
       · #range-strip             区间信息条（区间策略收益/暴露度/持仓年化…）
       · #replay-metrics          重播指标条
       · #fees-body > .wear-cards 交易磨损（佣金/印花税/过户费/总磨损/磨损比率）
       · #risk-body  > .risk-cards 风险分析（VaR/ES）
     个股回测详情（symbol.html）
       · #sum-strip               个股简介条（股票/区间收益/笔数/胜率/平均持股周期…）
       · #ra-strip                风险调整收益条（α / β / 信息比率）
       · #range-strip             区间信息条
       · #kreplay-info            重播指标条
       · #wear-body > .wear-cards 交易磨损
       · #risk-body               风险分析（.metric-strip 直接包 .metric-card）

   统一规则（用户 2026-10-29 定稿）：
     · 卡片     白底 + 紫框（--lav）
     · 中性数值 紫字（--lav-deep）——日期、暴露度、笔数、持股周期、β、磨损金额…
     · 盈亏数值 红 / 绿（--pos 红涨 / --neg 绿跌，A 股口径）——由 .pos / .neg 类驱动
     · 布局     flex-wrap + flex-grow，每行必然填满（末行拉宽），窄屏自然换行

   **为什么单独一个文件**：这类卡原先的规则散在三处——base.html 内联（白底）、
   lab-theme.css（`.metric-strip .metric-card` 白底 + `.risk-cards .metric-card`
   粉底粉框）、以及各模板的 ID 覆盖，于是出现白/紫/粉混搭。
   本文件在 lab-theme.css 与 night-mode.css **之后**加载，同特异性后者让位，
   因此这一处就是这类卡的唯一权威。**未来改这类卡的风格只改本文件**，
   不要去模板或 lab-theme 里补零散规则；新增小卡条时只需把新容器 ID 加进
   下面的 flex 规则（背景/边框/数值色由基类自动继承，无需再写）。
   ============================================================================ */

/* ---- 基类：白底磨砂玻璃（与 .card / .chart-box 同一套玻璃 token）----
   规格（用户 2026-10-29 定稿，与 .card 家族逐项一致）：
     · 半透明白色磨砂  backdrop-filter:blur(28px) saturate(140%)
                         背景 rgba(255,255,255,.48)（45%–60% 区间偏下沿）
     · 1px 半透明白描边 --glass-line
     · 顶部内侧细高光   inset 0 1px 0 --glass-hi
     · 圆角 24px        --card-radius
     · 大而柔的紫投影   --glass-shadow
   用容器类选择器把特异性提到与 lab-theme 同级，靠"后加载"胜出；
   裸 .metric-card 作为其它容器的兜底。
   注意：background 必须拆成 background-color + background-image——简写会重置
   background-image，把 --glass-sheen（顶部受光的玻璃厚度）抹掉（CR-2026-10-28 踩过）。 */
.metric-strip .metric-card,
.wear-cards .metric-card,
.risk-cards .metric-card,
.metric-card {
  background-color: var(--glass-bg);
  background-image: var(--glass-sheen);
  border: 1px solid var(--glass-line);
  border-radius: var(--card-radius);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--glass-shadow);
  padding: 20px 22px;
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  backdrop-filter: blur(28px) saturate(140%);
}

/* ---- 数值色：中性默认紫；盈亏走 .pos(红) / .neg(绿) ---- */
.metric-card .m-value {
  color: var(--lav-deep);
  font-size: 21px;
}
/* .pos/.neg 在 base.html 是 0,1,0，会被上面的 0,2,0 压住，这里显式提级 */
.metric-card .m-value.pos {
  color: var(--pos);
}
.metric-card .m-value.neg {
  color: var(--neg);
}

/* ---- 布局：六条小卡条 flex 自适应均分整行 ---- */
#metric-strip,
#sum-strip,
#range-strip,
#ra-strip,
#replay-metrics,
#kreplay-info,
#tier-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}
/* 密集条（7 卡左右）：min 150px。容器拓宽到 1920 后 7 卡一行余量充足；
   窄屏（≤960px）仍走 45% 两列，不会孤行。 */
#metric-strip .metric-card,
#range-strip .metric-card,
#replay-metrics .metric-card,
#kreplay-info .metric-card {
  flex: 1 1 150px;
}
/* 简介条与风险调整收益条（卡少、字号大）：min 280px → 3 卡撑满整行。
   简介条在本文件后段再按 9 卡覆盖为 5 列 / 21px，与 job 主指标条对齐。 */
#sum-strip .metric-card,
#ra-strip .metric-card {
  flex: 1 1 280px;
  padding: 20px 22px;
}
#tier-strip .metric-card {
  flex: 1 1 200px;
}
#sum-strip .metric-card .m-value,
#ra-strip .metric-card .m-value {
  font-size: 19.5px;
}
/* T1（2026-11-04）：个股顶部 9 卡与 job 主指标条同字号/同内边距；
   桌面固定 5 列（9 → 5+4），不出现末行孤卡。 */
#sum-strip .metric-card {
  flex: 1 1 calc(20% - 15px);
}
#sum-strip .metric-card .m-value {
  font-size: 21px;
}

/* ---- 磨损条毛/净收益值：盈亏红/绿 ----
   lab-theme 的 `.wb-val{color:var(--ink)}` 与 base 的 `.pos{color:var(--pos)}` 同为
   0,1,0 且 lab-theme 后加载会赢；这里用 0,2,0 显式提级。 */
.wb-val.pos {
  color: var(--pos);
}
.wb-val.neg {
  color: var(--neg);
}

/* ---- 磨损/风险条：lab-theme 的 `.risk-cards .metric-card` 是粉底粉框
       （#FFFBFB / #F0CACA），这里统一收回磨砂玻璃 ---- */
.wear-cards .metric-card,
.risk-cards .metric-card {
  background-color: var(--glass-bg);
  background-image: var(--glass-sheen);
  border-color: var(--glass-line);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--glass-shadow);
}

/* ---- 个股 FRM 六卡（VaR/ES 那组，`#risk-body .metric-strip`）：flex 自适应 ----
   与顶部指标条同一套 .metric-card 框架；桌面 4 列（6 → 4+2），≤960px 单列。
   夏普已上提到 #sum-strip，这里只留风险类指标。 */
#risk-body .metric-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}
#risk-body .metric-strip .metric-card {
  flex: 1 1 calc(25% - 14px);
}

@media (max-width: 960px) {
  #risk-body .metric-strip .metric-card {
    flex: 1 1 100%;
  }
  #metric-strip .metric-card,
  #range-strip .metric-card,
  #replay-metrics .metric-card,
  #kreplay-info .metric-card {
    flex: 1 1 100%;
  }
  #sum-strip .metric-card,
  #ra-strip .metric-card {
    flex: 1 1 100%;
  }
  #tier-strip .metric-card {
    flex: 1 1 100%;
  }
}
/* ---- 波动率状态标尺（R4-2.5） ----
   一个人字形/标尺：轨道上按阈值切低/中/高三段底色，EWMA 与 GARCH 各一根
   竖线打在轴上，上下错开贴标签。只用既有 token（--tint / --lav / --text），
   不设字体族/字重/行高，只有字号。 */
.vol-gauge {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 240px;
}

.vol-track {
  position: relative;
  height: 12px;
  margin: 44px 20px;
  border-radius: 6px;
  background: var(--tint);
}

.vol-seg {
  position: absolute;
  top: 0;
  height: 100%;
  background: var(--lav);
}

.vol-seg-low {
  opacity: 0.22;
}

.vol-seg-mid {
  opacity: 0.45;
}

.vol-seg-high {
  opacity: 0.72;
}

.vol-mark {
  position: absolute;
  top: 0;
}

.vol-mark-line {
  position: absolute;
  left: -1px;
  top: -6px;
  width: 2px;
  height: 24px;
  background: var(--text);
  border-radius: 1px;
}

.vol-mark-lab {
  position: absolute;
  left: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 13px;
  color: var(--text);
}

.vol-mark-above .vol-mark-lab {
  bottom: 22px;
}

.vol-mark-below .vol-mark-lab {
  top: 22px;
}

.vol-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  color: var(--text);
  font-size: 14px;
}

.vol-key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.vol-sw {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--lav);
}

.vol-sw-low {
  opacity: 0.22;
}

.vol-sw-mid {
  opacity: 0.45;
}

.vol-sw-high {
  opacity: 0.72;
}

.vol-gauge-rel {
  gap: 18px;
}

.vol-rel-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 12px;
}

.vol-rel-lab {
  color: var(--text);
}

.vol-rel-track {
  height: 10px;
  border-radius: 5px;
  background: var(--tint);
  overflow: hidden;
}

.vol-rel-fill {
  display: block;
  height: 100%;
  background: var(--lav);
  opacity: 0.72;
}

.vol-rel-val {
  color: var(--text);
}

@media (max-width: 960px) {
  .vol-rel-row {
    grid-template-columns: 56px 1fr auto;
  }
  .vol-track {
    margin: 40px 12px;
  }
  .vol-mark-lab {
    font-size: 12px;
  }
}

/* ---- QRE-UNSLOP-QUIET-CHROME：数据卡退回白底细边，色彩只留给数值 ---- */
.metric-strip .metric-card,
.wear-cards .metric-card,
.risk-cards .metric-card,
.metric-card {
  background-color: #FFFFFF;
  background-image: none;
  border-color: var(--line);
  box-shadow: 0 1px 2px rgba(36,31,46,.07);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
