/* ==========================================================================
   还款信用分 · 客户门户组件样式（credit-badge.js 配套）
   - 3D 徽章舞台（three.js canvas / 2D SVG 兜底共存）
   - 火花前进进度条（纯 CSS 动画，无额外 canvas）
   - 台账、等级阶梯、顶栏 chip
   命名前缀统一 cb-，只作用于门户，不影响后台。
   ========================================================================== */

.cb-chip,
.cb-card,
.cb-detail {
  --cb-c: #8896ab;
  --cb-a: #d3dbe8;
}

/* --------------------------------------------------------------------------
   0. 占位骨架（数据不可用时整块被 JS 移除，不会留下空框）
   -------------------------------------------------------------------------- */
.cb-skeleton {
  display: block;
  border-radius: var(--radius-lg, 10px);
  background: linear-gradient(90deg, #f1f5f9 25%, #e7edf5 37%, #f1f5f9 63%);
  background-size: 400% 100%;
  animation: cbSkel 1.4s ease infinite;
  margin-bottom: 18px;
}
.cb-skeleton--chip {
  width: 118px; height: 28px; border-radius: 999px; margin: 0;
}
@keyframes cbSkel {
  0%   { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* --------------------------------------------------------------------------
   1. 顶栏 chip（小号 2D，省 WebGL context）
   -------------------------------------------------------------------------- */
.cp-topbar__credit { display: flex; align-items: center; }
.cb-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 9px 3px 3px; border-radius: 999px;
  border: 1px solid var(--border-light, #e2e8f0);
  background: linear-gradient(180deg, #fff, #f8fafc);
  cursor: pointer; user-select: none;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.cb-chip:hover { border-color: var(--cb-c); box-shadow: 0 2px 10px rgba(15, 23, 42, .08); transform: translateY(-1px); }
.cb-chip:focus-visible { outline: 2px solid var(--c-primary-400, #38bdf8); outline-offset: 2px; }
.cb-chip__stage { display: block; }
.cb-chip__score {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 14px; font-weight: 700; color: var(--cb-c); line-height: 1;
}
.cb-chip__score i { font-style: normal; font-size: 10px; color: var(--text-tertiary, #94a3b8); margin-left: 2px; }
.cb-chip__grade { font-size: 11px; color: var(--text-tertiary, #94a3b8); white-space: nowrap; }

/* --------------------------------------------------------------------------
   2. 3D / 2D 徽章舞台
   -------------------------------------------------------------------------- */
.cb-stage {
  position: relative;
  display: block;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #fff 0%, #eef2f7 52%, #dbe3ee 100%);
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, .07), 0 2px 10px rgba(15, 23, 42, .05);
  overflow: hidden;
}
.cb-stage--chip { width: 28px; height: 28px; box-shadow: none; background: transparent; }
.cb-stage--md   { width: 132px; height: 132px; }
.cb-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.cb-svg { display: block; width: 86%; height: 86%; }
.cb-stage.is-3d .cb-fallback { display: none; }
.cb-canvas {
  position: absolute; inset: 0;
  display: block; width: 100% !important; height: 100% !important;
  border-radius: 50%;
  cursor: grab;
  touch-action: pan-y;          /* 横滑归徽章（拖动旋转），竖向仍交给页面滚动 */
}
.cb-canvas.is-drag { cursor: grabbing; }
.cb-glow {
  position: absolute; left: 50%; top: 50%;
  width: 76%; height: 76%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, var(--cb-a) 0%, transparent 68%);
  opacity: .38; pointer-events: none;
  animation: cbHalo 3.4s ease-in-out infinite;
}
.cb-stage--chip .cb-glow { display: none; }
@keyframes cbHalo {
  0%, 100% { opacity: .26; transform: translate(-50%, -50%) scale(.94); }
  50%      { opacity: .5;  transform: translate(-50%, -50%) scale(1.06); }
}
.cb-card__index {
  margin-top: 8px; text-align: center;
  font-size: 11px; color: var(--text-tertiary, #94a3b8);
  font-family: var(--font-mono, ui-monospace, monospace);
}
/* 拖动提示：紧跟舞台，只有真挂上 WebGL（is-3d）才显示；2D 兜底时不提示做不到的事 */
.cb-hint {
  display: none; margin-top: 6px; text-align: center;
  font-size: 10px; color: var(--text-tertiary, #94a3b8);
}
.cb-stage.is-3d + .cb-hint { display: block; }

/* --------------------------------------------------------------------------
   3. 首页信用分卡片
   -------------------------------------------------------------------------- */
.cb-card__body {
  display: flex; align-items: center; gap: 22px;
}
.cb-card__left { flex: 0 0 auto; width: 148px; }
.cb-card__main { flex: 1 1 auto; min-width: 0; }

.cb-score { display: flex; align-items: baseline; gap: 6px; line-height: 1; margin-bottom: 2px; }
.cb-score b {
  font-size: 38px; font-weight: 700; color: var(--cb-c);
  font-family: var(--font-mono, ui-monospace, monospace);
  letter-spacing: -.5px;
}
.cb-score i { font-style: normal; font-size: 13px; color: var(--text-tertiary, #94a3b8); }
.cb-score__bounds {
  margin-left: auto; font-size: 11px; color: var(--text-tertiary, #94a3b8);
  font-family: var(--font-mono, ui-monospace, monospace);
}
.cb-raw { font-size: 11px; color: var(--text-tertiary, #94a3b8); margin-bottom: 12px; }

.cb-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  font-size: 12px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, var(--cb-a), var(--cb-c) 70%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35);
}
.cb-tag__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 6px rgba(255, 255, 255, .9);
}

.cb-stats {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-tertiary, #94a3b8); margin-top: 12px;
}
.cb-stats em { font-style: normal; opacity: .5; }
.cb-nextplan {
  margin-top: 6px; font-size: 11px; color: var(--text-tertiary, #94a3b8);
  background: #f8fafc; border: 1px dashed var(--border-light, #e2e8f0);
  border-radius: var(--radius-md, 6px); padding: 6px 8px;
}
.cb-bad { color: var(--c-danger, #ef4444); }

/* --------------------------------------------------------------------------
   4. 火花前进进度条
   -------------------------------------------------------------------------- */
.cb-prog { margin-top: 10px; }
.cb-prog--main .cb-prog__head span:first-child { color: var(--c-gray-700, #334155); font-weight: 600; }
.cb-prog__head {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 11px; color: var(--text-tertiary, #94a3b8); margin-bottom: 5px;
}
.cb-prog__val {
  font-family: var(--font-mono, ui-monospace, monospace);
  color: var(--c-gray-700, #334155); white-space: nowrap;
}
.cb-track {
  position: relative; height: 10px; border-radius: 999px;
  background: #eaeff6;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, .08);
  overflow: hidden;               /* 火花跑到轨道外自然裁掉 */
}
.cb-track--main { height: 12px; }
.cb-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: calc(var(--cb-p, 0) * 1%);
  min-width: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cb-a) 0%, var(--cb-c) 55%, var(--cb-c) 100%);
  overflow: hidden;
  transition: width .45s cubic-bezier(.22, .61, .36, 1);
}
/* 填充内的流光：向「前进方向」跑 */
.cb-sheen {
  position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 18%, rgba(255, 255, 255, .7) 46%, transparent 74%);
  background-size: 220% 100%;
  animation: cbSheen 1.8s linear infinite;
}
@keyframes cbSheen {
  0%   { background-position: -130% 0; }
  100% { background-position: 130% 0; }
}
/* 填充右缘的高亮头（火花从这里喷出去） */
.cb-head {
  position: absolute; top: 50%; left: calc(var(--cb-p, 0) * 1%);
  width: 12px; height: 12px; margin-left: -6px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, var(--cb-a) 42%, transparent 72%);
  animation: cbHead 1.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes cbHead {
  0%, 100% { opacity: .75; transform: translateY(-50%) scale(.9); }
  50%      { opacity: 1;   transform: translateY(-50%) scale(1.15); }
}
/* 火花粒子：沿前进方向位移并淡出，错开 delay 形成连续火星 */
.cb-spark {
  position: absolute; top: 50%;
  left: calc(var(--cb-p, 0) * 1%);
  width: var(--cb-s, 6px); height: var(--cb-s, 6px);
  margin-left: calc(var(--cb-s, 6px) / -2);
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, var(--cb-a) 45%, var(--cb-c) 72%, transparent 74%);
  box-shadow: 0 0 6px rgba(255, 255, 255, .85);
  opacity: 0;
  pointer-events: none;
  animation: cbSpark 1.5s linear infinite;
}
.cb-spark--2 { --cb-s: 5px; animation-delay: .38s; }
.cb-spark--3 { --cb-s: 4px; animation-delay: .76s; }
.cb-spark--4 { --cb-s: 3px; animation-delay: 1.14s; }
@keyframes cbSpark {
  0%   { transform: translate3d(-2px, -50%, 0) scale(.4); opacity: 0; }
  14%  { opacity: .95; }
  100% { transform: translate3d(var(--cb-run, 26px), -50%, 0) scale(.12); opacity: 0; }
}
.cb-spark--1 { --cb-run: 26px; }
.cb-spark--2 { --cb-run: 22px; }
.cb-spark--3 { --cb-run: 30px; }
.cb-spark--4 { --cb-run: 18px; }

/* --------------------------------------------------------------------------
   5. 个人详情：等级阶梯 + 台账
   -------------------------------------------------------------------------- */
.cb-detail {
  margin-top: 16px; padding: 14px 16px;
  border: 1px solid var(--border-light, #e2e8f0);
  border-radius: var(--radius-lg, 10px);
  background: linear-gradient(180deg, #fff, #f8fafc);
}
.cb-detail__head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-bottom: 10px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border-light, #e2e8f0);
}
.cb-detail__title { font-size: 14px; font-weight: 600; }
.cb-detail__updated {
  margin-left: auto; font-size: 11px; color: var(--text-tertiary, #94a3b8);
  font-family: var(--font-mono, ui-monospace, monospace);
}
.cb-detail__body { display: flex; align-items: center; gap: 20px; padding: 12px 0; }
.cb-detail__left { flex: 0 0 auto; }
.cb-detail__main { flex: 1 1 auto; min-width: 0; }

.cb-ladder {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  margin-top: 12px; font-size: 11px; color: var(--text-tertiary, #94a3b8);
}
.cb-ladder__item {
  padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--border-light, #e2e8f0); background: #fff;
}
.cb-ladder__item.is-now {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, var(--cb-a), var(--cb-c) 70%);
  font-weight: 600;
}
.cb-ladder__sep { font-style: normal; opacity: .35; }

.cb-ledger { margin-top: 6px; }
.cb-ledger__table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cb-ledger__table th {
  text-align: left; padding: 8px 10px;
  background: #f8fafc; border-bottom: 1px solid var(--border-light, #e2e8f0);
  font-size: 11px; font-weight: 600; color: var(--text-tertiary, #94a3b8);
}
.cb-ledger__table td {
  padding: 8px 10px; border-bottom: 1px solid #f1f5f9;
  color: var(--c-gray-700, #334155); vertical-align: middle;
}
.cb-ledger__table tr:last-child td { border-bottom: none; }
.cb-ledger__row:hover td { background: var(--bg-hover, #f8fafc); }
.cb-ledger__type { font-weight: 500; }
.cb-ledger__ref,
.cb-ledger__date,
.cb-ledger__after {
  font-family: var(--font-mono, ui-monospace, monospace);
  color: var(--text-tertiary, #94a3b8); white-space: nowrap;
}
.cb-ledger__delta {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: 700; text-align: right; white-space: nowrap;
}
.cb-ledger__after { text-align: right; }
.cb-ledger__foot { margin-top: 8px; font-size: 11px; color: var(--text-tertiary, #94a3b8); }
.cb-ledger__empty { margin-top: 10px; padding: 14px; text-align: center; font-size: 12px; color: var(--text-tertiary, #94a3b8); }
.cb-virtual {
  font-style: normal; margin-left: 6px; padding: 1px 5px; border-radius: 999px;
  background: #eef2ff; color: #4f46e5; font-size: 10px;
}
.cb-up   { color: var(--c-success, #10b981); }
.cb-down { color: var(--c-danger, #ef4444); }
.cb-flat { color: var(--text-tertiary, #94a3b8); }
/* 台账里的正负色：必须比 .cb-ledger__table td 更具体，否则被单元格默认色吃掉 */
.cb-ledger__table td.cb-up   { color: var(--c-success, #10b981); }
.cb-ledger__table td.cb-down { color: var(--c-danger, #ef4444); }
.cb-ledger__table td.cb-flat { color: var(--text-tertiary, #94a3b8); }

/* --------------------------------------------------------------------------
   6. 响应式（门户移动端）
   -------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .cb-card__body { flex-direction: column; align-items: stretch; gap: 14px; }
  .cb-card__left { width: auto; }
  .cb-stage--md { width: 108px; height: 108px; }
  .cb-score b { font-size: 30px; }
  .cb-detail__body { flex-direction: column; align-items: stretch; }
  .cb-detail__left { align-self: center; }
  .cb-chip__grade { display: none; }
  .cb-ledger__table { font-size: 11px; }
  .cb-ledger__table th, .cb-ledger__table td { padding: 6px 7px; }
}

/* --------------------------------------------------------------------------
   7. 减少动效偏好：徽章只出一帧静态图，火花与流光全部停掉
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .cb-sheen, .cb-head, .cb-spark, .cb-glow, .cb-skeleton { animation: none !important; }
  .cb-spark { display: none; }
  .cb-sheen { opacity: .25; }
  .cb-fill { transition: none !important; }
}
