/* ==========================================================================
   usage-analytics.css · 用量页「分析」视图（2026-10-18）
   --------------------------------------------------------------------------
   结构由 usage-analytics.js 产出（.uca-*）。
   令牌全部复用 usage-chatgpt.css 的第 1 节（--uc-page / --uc-card / --uc-line /
   --uc-fg / --uc-fg-2 / --uc-pill / --uc-ease ...），所以深浅色自动跟随，
   这里不重新定义任何颜色。
   宽度断点用容器查询（查询对象是 .uc-wrap），与三档限额卡同一套口径。
   ========================================================================== */

/* ── 页签切换：概览 / 分析 ───────────────────────────────────────────────── */
.uc-page[data-tab="overview"] .uca { display: none; }
.uc-page[data-tab="analysis"] .uc-sec,
.uc-page[data-tab="analysis"] .qu-keys { display: none; }

.uca {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── 顶部：区间切换 + 时间范围 ───────────────────────────────────────────── */
.uca-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.uca-range {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--uc-pill);
}
.uca-rbtn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--uc-fg-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .18s ease, color .18s ease, transform .16s var(--uc-ease-press);
}
.uca-rbtn:hover { color: var(--uc-fg); }
.uca-rbtn:active { transform: scale(.96); }
.uca-rbtn.is-on {
  background: #ffffff;
  color: #0d0d0d;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}
[data-theme="dark"] .uca-rbtn.is-on {
  background: rgba(255, 255, 255, .14);
  color: var(--uc-fg);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), 0 1px 2px rgba(0, 0, 0, .28);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .uca-rbtn.is-on {
    background: rgba(255, 255, 255, .14);
    color: var(--uc-fg);
  }
}
.uca-meta {
  font-size: 12.5px;
  color: var(--uc-fg-2);
  font-variant-numeric: tabular-nums;
}

/* ── 卡片基座（和限额卡同款质感） ────────────────────────────────────────── */
.uca-card {
  background: var(--uc-card);
  border: 1px solid var(--uc-line);
  border-radius: 22px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
  transition: background-color .24s ease, border-color .24s ease, box-shadow .24s ease;
}
@supports (corner-shape: squircle) {
  .uca-card { corner-shape: squircle; }
}
[data-theme="dark"] .uca-card {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035), 0 1px 2px rgba(0, 0, 0, .22);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .uca-card {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .035), 0 1px 2px rgba(0, 0, 0, .22);
  }
}

/* ── KPI ────────────────────────────────────────────────────────────────── */
.uca-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}
@container (max-width: 359px) {
  .uca-kpis { grid-template-columns: minmax(0, 1fr); }
}
@container (min-width: 900px) {
  .uca-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.uca-kpi { padding: 16px 18px 18px; }
@container (max-width: 599px) {
  .uca-kpi { padding: 14px 15px 15px; }
  .uca-kpi-value { font-size: 23px; line-height: 29px; margin: 6px 0 4px; }
}
.uca-kpi-label {
  font-size: 12.5px;
  line-height: 18px;
  font-weight: 500;
  color: var(--uc-fg-2);
  letter-spacing: .01em;
}
.uca-kpi-value {
  margin: 8px 0 6px;
  font-size: 27px;
  line-height: 34px;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--uc-fg);
}
.uca-kpi-value .uca-num { font-variant-numeric: tabular-nums; }
.uca-kpi-sub {
  display: block;
  font-size: 12px;
  line-height: 17px;
  color: var(--uc-fg-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.uca-delta {
  display: inline-block;
  font-weight: 600;
  margin-right: 2px;
}
.uca-delta.is-up { color: #4cd97b; }
.uca-delta.is-down { color: #f06058; }
body:not(.adm-mode) [data-theme="light"] .uca-delta.is-up { color: #137333; }
body:not(.adm-mode) [data-theme="light"] .uca-delta.is-down { color: #c5221f; }
[data-theme="light"] .uca-delta.is-up { color: #137333; }
[data-theme="light"] .uca-delta.is-down { color: #c5221f; }

/* ── 卡片头 ─────────────────────────────────────────────────────────────── */
.uca-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.uca-card-title {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--uc-fg);
}
.uca-card-sub {
  margin: 3px 0 0;
  font-size: 12px;
  line-height: 17px;
  color: var(--uc-fg-2);
}
.uca-card-hint {
  flex: none;
  font-size: 11.5px;
  color: var(--uc-fg-2);
  opacity: .8;
}
.uca-legend {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--uc-fg-2);
}
.uca-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--uc-fg);
  opacity: .85;
  flex: none;
}
.uca-dot[data-k="chat"] { opacity: .38; }
.uca-dot[data-k="api"] { opacity: .9; }

/* ── 趋势图 ─────────────────────────────────────────────────────────────── */
.uca-trend { padding: 16px 18px 12px; }

.uca-chart {
  position: relative;
  height: 218px;
  margin-top: 12px;
}
.uca-plot {
  position: absolute;
  left: 46px;
  right: 0;
  /* 顶部留 26px：最高柱 + 悬停气泡都不再被裁/顶到卡边 */
  top: 26px;
  bottom: 22px;
}
.uca-grid {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--uc-line);
  opacity: .7;
}
.uca-grid-lab {
  position: absolute;
  left: -46px;
  width: 40px;
  text-align: right;
  transform: translateY(50%);
  font-size: 10.5px;
  line-height: 1;
  color: var(--uc-fg-2);
  opacity: .75;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.uca-cols {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 4px;
  height: 100%;
}
.uca-col {
  position: relative;
  flex: 1 1 0;
  max-width: 88px;
  min-width: 2px;
  height: 100%;
  display: flex;
  align-items: flex-end;
  cursor: default;
}
/* 柱子高度靠 scaleY，只动 transform，不触发重排 */
.uca-bar {
  width: 100%;
  height: 100%;
  border-radius: 3px 3px 2px 2px;
  background: var(--uc-fg);
  opacity: .92;
  transform-origin: center bottom;
  transform: scaleY(var(--h, 0));
  transition: opacity .16s ease, background-color .16s ease;
}
.uca-cols.is-hover .uca-col:not(.is-hot) .uca-bar { opacity: .32; }
.uca-cols.is-hover .uca-col.is-hot .uca-bar {
  opacity: 1;
  background: var(--uc-fg);
}
.uca-xaxis {
  position: absolute;
  left: 46px;
  right: 0;
  bottom: 0;
  height: 16px;
}
.uca-xlab {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 10.5px;
  line-height: 1;
  color: var(--uc-fg-2);
  opacity: .75;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 气泡：跟随鼠标，只动 transform / opacity */
.uca-tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  padding: 6px 9px;
  border-radius: 9px;
  background: var(--uc-fg);
  color: var(--uc-page);
  font-size: 11.5px;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(-999px, -999px, 0);
  transition: opacity .13s ease;
  font-variant-numeric: tabular-nums;
}
.uca-tip.is-on { opacity: 1; }

/* ── 两列区块 ───────────────────────────────────────────────────────────── */
.uca-grid2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
@container (min-width: 760px) {
  .uca-grid2 { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
}
/* 两张卡等高：让 grid 拉伸，内容各自内部滚动区不需要 —— 内容少的那张底部留白补齐 */
.uca-grid2 > .uca-card { align-self: stretch; }
.uca-models, .uca-sources { padding: 16px 18px 20px; display: flex; flex-direction: column; }

/* 分布行 */
/* 行间距 13px → 18px：原来每行挤在一起，模型名和进度条糊成一团 */
.uca-row + .uca-row { margin-top: 18px; }
.uca-row { padding-bottom: 2px; }
.uca-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  /* 文字与进度条之间 6px → 9px，不再贴在一起 */
  margin-bottom: 9px;
}
.uca-row-name {
  font-size: 13px;
  line-height: 18px;
  color: var(--uc-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.uca-row-val {
  flex: none;
  font-size: 12.5px;
  color: var(--uc-fg);
  font-variant-numeric: tabular-nums;
}
.uca-row-val em {
  font-style: normal;
  margin-left: 7px;
  color: var(--uc-fg-2);
}
.uca-row-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--uc-bar-track);
  overflow: hidden;
}
.uca-row-bar i {
  display: block;
  height: 100%;
  width: var(--w, 0%);
  border-radius: inherit;
  background: var(--uc-fg);
  opacity: .8;
  transform-origin: left center;
  transform: scaleX(1);
}

/* 来源：堆叠条 + 图例 */
.uca-split {
  display: flex;
  height: 8px;
  margin: 12px 0 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--uc-bar-track);
  transform-origin: left center;
  transform: scaleX(1);
}
.uca-seg {
  display: block;
  height: 100%;
  width: var(--w, 0%);
  background: var(--uc-fg);
  opacity: .85;
}
.uca-seg[data-k="chat"] { opacity: .35; }
.uca-seg + .uca-seg { box-shadow: 2px 0 0 var(--uc-card); }

.uca-leg {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--uc-line);
  font-size: 12.5px;
  color: var(--uc-fg-2);
}
.uca-leg:last-child { border-bottom: 0; }
.uca-leg-name { flex: 1; min-width: 0; color: var(--uc-fg); }
.uca-leg-val { flex: none; font-variant-numeric: tabular-nums; color: var(--uc-fg); }
.uca-leg-val em { font-style: normal; margin-left: 7px; color: var(--uc-fg-2); }

.uca-empty-inline {
  padding: 14px 0 18px;
  font-size: 12.5px;
  color: var(--uc-fg-2);
}

/* ── 空态 / 失败态 ──────────────────────────────────────────────────────── */
.uca-blank, .uca-fail {
  padding: 44px 24px 46px;
  text-align: center;
}
.uca-blank-ic { color: var(--uc-fg-2); opacity: .7; }
.uca-blank-ic svg { width: 30px; height: 30px; }
.uca-blank-t { margin-top: 12px; font-size: 14px; font-weight: 600; color: var(--uc-fg); }
.uca-blank-s { margin-top: 5px; font-size: 12.5px; color: var(--uc-fg-2); }
.uca-fail-t { font-size: 14px; font-weight: 600; color: var(--uc-fg); }
.uca-fail-s { margin: 6px 0 16px; font-size: 12.5px; color: var(--uc-fg-2); }

/* ── 骨架屏 ─────────────────────────────────────────────────────────────── */
.uca-sk {
  border-radius: 8px;
  background: linear-gradient(90deg,
    rgba(255, 255, 255, .04) 0%, rgba(255, 255, 255, .1) 40%,
    rgba(255, 255, 255, .04) 80%);
  background-size: 220% 100%;
  animation: uca-shimmer 1.15s linear infinite;
}
[data-theme="light"] .uca-sk {
  background: linear-gradient(90deg,
    rgba(0, 0, 0, .045) 0%, rgba(0, 0, 0, .09) 40%, rgba(0, 0, 0, .045) 80%);
  background-size: 220% 100%;
}
.uca-sk-label { width: 42%; height: 11px; opacity: .7; }
.uca-sk-value { width: 66%; height: 26px; margin: 12px 0 10px; }
.uca-sk-sub { width: 52%; height: 10px; opacity: .7; }
.uca-sk-chart { height: 190px; margin: 14px 0 8px; border-radius: 12px; }
@keyframes uca-shimmer {
  from { background-position: 120% 0; }
  to   { background-position: -120% 0; }
}

/* ──────────────────────────────────────────────────────────────────────────
   动效
   · 卡片进场：淡入 + 上浮 8px，420ms，按 40ms 交错
   · 柱状图：柱子从底部长到 --h，520ms，按 8ms/根 交错
   · 分布条：从左往右 520ms，按 30ms 交错
   全部只动 transform / opacity；fill-mode 用 backwards，播完交还元素自身样式。
   ────────────────────────────────────────────────────────────────────────── */
@keyframes uca-rise {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to   { opacity: 1; transform: none; }
}
@keyframes uca-grow {
  from { transform: scaleY(0); }
  to   { transform: scaleY(var(--h, 0)); }
}
@keyframes uca-sweep {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

.uca-kpis > .uca-card,
.uca > .uca-card,
.uca-grid2 > .uca-card {
  animation: uca-rise .42s var(--uc-ease) backwards;
}
.uca-kpis > .uca-card:nth-child(1) { animation-delay: 0ms; }
.uca-kpis > .uca-card:nth-child(2) { animation-delay: 40ms; }
.uca-kpis > .uca-card:nth-child(3) { animation-delay: 80ms; }
.uca-kpis > .uca-card:nth-child(4) { animation-delay: 120ms; }
.uca > .uca-trend { animation-delay: 120ms; }
.uca-grid2 > .uca-card:nth-child(1) { animation-delay: 170ms; }
.uca-grid2 > .uca-card:nth-child(2) { animation-delay: 210ms; }

.uca-chart.is-in .uca-col .uca-bar {
  animation: uca-grow .52s cubic-bezier(.23, 1, .32, 1) backwards;
  animation-delay: calc(140ms + var(--d, 0ms));
}
.uca-row-bar i {
  animation: uca-sweep .52s cubic-bezier(.23, 1, .32, 1) backwards;
  animation-delay: calc(220ms + var(--d, 0ms));
}
.uca-split {
  animation: uca-sweep .5s cubic-bezier(.23, 1, .32, 1) backwards;
  animation-delay: 200ms;
}
.uca-leg { animation: uca-rise .4s var(--uc-ease) backwards; animation-delay: calc(240ms + var(--d, 0ms)); }

/* ── 悬停只给能点的东西 ─────────────────────────────────────────────────── */
@media (hover: hover) and (pointer: fine) {
  .uca-col:hover .uca-bar { opacity: 1; }
}

/* ── 窄屏 ───────────────────────────────────────────────────────────────── */
@container (max-width: 599px) {
  .uca-chart { height: 176px; }
  .uca-plot { left: 38px; }
  .uca-grid-lab { left: -38px; width: 32px; }
  .uca-xaxis { left: 38px; }
  .uca-kpi-value { font-size: 24px; line-height: 30px; }
  .uca-cols { gap: 3px; }
  .uca-bar { border-radius: 2px 2px 1px 1px; }
}

/* ── 减少动态 ───────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .uca-kpis > .uca-card,
  .uca > .uca-card,
  .uca-grid2 > .uca-card,
  .uca-chart.is-in .uca-col .uca-bar,
  .uca-row-bar i,
  .uca-split,
  .uca-leg,
  .uca-sk {
    animation: none;
  }
  .uca-rbtn, .uca-tip, .uca-card { transition: none; }
}
