/* ==========================================================================
   配置驱动图表模板库 · 样式
   主题色通过 CSS 变量注入（由 charts.js 的 applyTheme 设置 --ct-*）
   ========================================================================== */

.ct-root {
  font-family: var(--ct-font, "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", Roboto, sans-serif);
  color: var(--ct-text, #e2e8f0);
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
}
.ct-root *,
.ct-root *::before,
.ct-root *::after { box-sizing: border-box; }

/* ---- card / header ------------------------------------------------------ */
.ct-card {
  background: var(--ct-panel, #111a2e);
  border: 1px solid var(--ct-border, #21304d);
  border-radius: 14px;
  padding: 16px 18px 18px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .28);
}
.ct-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.ct-title { font-size: 16px; font-weight: 700; letter-spacing: .2px; }
.ct-subtitle { font-size: 12px; color: var(--ct-muted, #94a3b8); margin-top: 3px; }
.ct-badges { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ct-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ct-muted, #94a3b8); }
.ct-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.ct-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ct-live {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ct-muted, #94a3b8);
  background: rgba(56, 189, 248, .08); border: 1px solid var(--ct-border, #21304d);
  padding: 4px 9px; border-radius: 999px;
}
.ct-live::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ct-accent, #38bdf8); box-shadow: 0 0 0 0 rgba(56, 189, 248, .55);
  animation: ct-pulse 1.8s infinite;
}
@keyframes ct-pulse {
  0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, .5); }
  70% { box-shadow: 0 0 0 7px rgba(56, 189, 248, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

.ct-empty { color: var(--ct-muted, #94a3b8); font-size: 13px; padding: 28px 10px; text-align: center; }

/* ---- tooltip ------------------------------------------------------------ */
.ct-tooltip {
  position: fixed; z-index: 9999; pointer-events: none;
  background: rgba(8, 13, 26, .96);
  border: 1px solid var(--ct-border, #21304d);
  border-radius: 9px; padding: 8px 11px;
  font-size: 12px; line-height: 1.65; color: #e2e8f0;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
  opacity: 0; transform: translateY(4px); transition: opacity .12s ease, transform .12s ease;
  max-width: 260px;
}
.ct-tooltip.show { opacity: 1; transform: translateY(0); }
.ct-tooltip b { color: #fff; font-weight: 600; }
.ct-tooltip .ct-tt-up { color: var(--ct-up, #ff4d4f); }
.ct-tooltip .ct-tt-down { color: var(--ct-down, #22c55e); }

/* ==========================================================================
   横向柱状图 (bar)
   ========================================================================== */
.ct-bar { position: relative; }
.ct-bar-row {
  position: absolute; left: 0; right: 0;
  display: flex; align-items: center; gap: 12px;
  transition: transform .72s cubic-bezier(.22, 1, .36, 1), opacity .4s;
  will-change: transform;
}
.ct-bar-row.is-dim { opacity: .38; }
.ct-bar-row.is-moved { animation: ct-row-flash .9s ease-out; }
@keyframes ct-row-flash {
  0% { filter: brightness(1.5); }
  100% { filter: brightness(1); }
}
.ct-bar-rank {
  width: 40px; flex: none; text-align: right;
  color: var(--ct-muted, #94a3b8); font-size: 13px; font-variant-numeric: tabular-nums;
}
.ct-bar-name {
  width: 104px; flex: none; font-size: 13px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.ct-bar-track {
  position: relative; flex: 1 1 auto; height: 22px; min-width: 60px;
  background: var(--ct-grid, #182338); border-radius: 6px; overflow: hidden;
}
.ct-bar-fill {
  position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 6px;
  transition: width .72s cubic-bezier(.22, 1, .36, 1), background .4s ease;
}
.ct-bar-value {
  min-width: 92px; flex: none; text-align: right; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.ct-bar-pct {
  min-width: 66px; flex: none; text-align: right; font-size: 12px;
  font-variant-numeric: tabular-nums; transition: color .4s ease;
}
.ct-bar-arrow { width: 14px; flex: none; text-align: center; font-size: 10px; opacity: 0; transition: opacity .3s; }
.ct-bar-arrow.on { opacity: 1; }

/* ==========================================================================
   表格 (table)
   ========================================================================== */
.ct-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ct-table th, .ct-table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--ct-grid, #182338); }
.ct-table th {
  color: var(--ct-muted, #94a3b8); font-weight: 600; font-size: 12px;
  text-transform: none; white-space: nowrap;
}
.ct-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.ct-table tbody tr { transition: background .25s ease; }
.ct-table tbody tr:hover { background: rgba(56, 189, 248, .07); }
.ct-table .ct-rank { color: var(--ct-muted, #94a3b8); width: 46px; }
.ct-table .ct-cell-bar { position: relative; }
.ct-table .ct-cell-bar > i {
  position: absolute; left: 0; top: 18%; height: 64%; border-radius: 4px; opacity: .22;
  transition: width .6s cubic-bezier(.22, 1, .36, 1);
}

/* ==========================================================================
   折线图 (line)
   ========================================================================== */
.ct-line svg { display: block; width: 100%; }
.ct-line .ct-line-grid { stroke: var(--ct-grid, #182338); stroke-width: 1; }
.ct-line .ct-line-axis { fill: var(--ct-muted, #94a3b8); font-size: 11px; }
.ct-line .ct-line-path { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ct-line .ct-line-area { opacity: .16; }
.ct-line .ct-line-dot { transition: r .2s ease; }

/* ==========================================================================
   横向树状图 (tree)
   ========================================================================== */
.ct-tree svg { display: block; width: 100%; }
.ct-tree .ct-tree-link {
  fill: none; stroke: var(--ct-link, #334155); stroke-width: 1.4;
  transition: stroke .25s ease, stroke-width .25s ease, opacity .25s ease;
}
.ct-tree .ct-tree-node circle {
  transition: r .5s cubic-bezier(.22, 1, .36, 1), fill .4s ease, opacity .25s ease;
}
.ct-tree .ct-tree-node text { font-size: 12px; dominant-baseline: middle; transition: fill .4s ease; }
.ct-tree .ct-tree-node .ct-tree-name { fill: var(--ct-text, #e2e8f0); }
.ct-tree .ct-tree-node .ct-tree-val { fill: var(--ct-muted, #94a3b8); font-size: 11px; }
.ct-tree .ct-tree-node .ct-tree-pct { font-size: 11px; }
.ct-tree .ct-tree-node.is-dim { opacity: .28; }
.ct-tree .ct-tree-node { cursor: default; }
.ct-tree .ct-tree-node.is-hover circle { stroke: #fff; stroke-width: 1.6; }
.ct-tree .ct-tree-focus { stroke: var(--ct-accent, #38bdf8); stroke-width: 1.8; }
.ct-tree .ct-tree-node.is-active circle { animation: ct-node-glow 2.4s ease-in-out infinite; }
@keyframes ct-node-glow {
  0%, 100% { stroke: transparent; stroke-width: 0; }
  50% { stroke: var(--ct-accent, #38bdf8); stroke-width: 2.2; }
}
.ct-tree .ct-tree-enter { animation: ct-node-enter .5s cubic-bezier(.22, 1, .36, 1) backwards; }
@keyframes ct-node-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---- resize ------------------------------------------------------------- */
@media (max-width: 720px) {
  .ct-bar-name { width: 72px; }
  .ct-bar-value { min-width: 74px; }
  .ct-bar-pct { display: none; }
}
