/* 使用记录页：统计、分布图表与明细表复用账号页克制的分隔线与间距。 */
[data-account-panel='usage'] {
  --usage-slot-1: #2a78d6;
  --usage-slot-2: #eb6834;
  --usage-slot-3: #1baf7a;
  --usage-slot-4: #eda100;
  --usage-slot-5: #e87ba4;
  --usage-slot-6: #008300;
  --usage-slot-7: #4a3aa7;
  --usage-slot-8: #e34948;
  --usage-other: #a3a9a7;
  --usage-grid: #eceeed;
  --usage-axis: #c9cecd;
}
.usage-heading .key-actions {
  gap: 12px;
}
.usage-status {
  font-size: 12px;
}
.usage-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px 20px;
}
.usage-presets {
  grid-template-columns: repeat(4, auto);
  margin: 0;
}
.usage-presets button {
  min-height: 34px;
  padding: 6px 12px;
  white-space: nowrap;
}
.usage-presets button[aria-pressed='true'],
.usage-metric button[aria-pressed='true'] {
  background: #fff;
  box-shadow: 0 1px 3px #00000012;
  color: #117d68;
  font-weight: 600;
}
.usage-dates {
  display: flex;
  align-items: end;
  gap: 8px;
}
.usage-dates label,
.usage-granularity {
  gap: 5px;
  font-size: 12px;
  color: #73797c;
}
.usage-dates input {
  min-height: 36px;
  padding: 6px 10px;
  width: 152px;
}
.usage-granularity select {
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid #d8dddd;
  border-radius: 6px;
  background: #fff;
  color: #25282a;
  font: inherit;
}
.usage-charts-toggle {
  margin-left: auto;
  min-height: 36px;
  color: #73797c;
}
/* 加载时不遮盖已有内容，只在筛选条下方显示一条细进度线；轨道常驻，避免布局跳动。 */
.usage-progress {
  position: relative;
  height: 2px;
  margin-top: 10px;
  overflow: hidden;
  background: transparent;
}
.usage-progress[data-active='true'] {
  background: #e5f0ec;
}
.usage-progress span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 40%;
  background: #117d68;
  animation: usage-progress 1.1s ease-in-out infinite;
  visibility: hidden;
}
.usage-progress[data-active='true'] span {
  visibility: visible;
}
@keyframes usage-progress {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(250%);
  }
}
.usage-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 10px 0 20px;
  padding: 10px 0;
  border-block: 1px solid #e5e7e7;
}
.usage-summary > div {
  min-width: 0;
  padding: 0 16px;
  border-left: 1px solid #e5e7e7;
}
.usage-summary > div:first-child {
  padding-left: 0;
  border-left: 0;
}
.usage-summary dt {
  font-size: 11px;
  color: #73797c;
}
.usage-summary dd {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  margin: 2px 0 0;
  min-width: 0;
}
.usage-summary strong {
  font-size: 18px;
  font-weight: 600;
  white-space: nowrap;
}
.usage-summary small {
  color: #73797c;
  font-size: 11px;
  overflow-wrap: anywhere;
}
.usage-struck {
  text-decoration: line-through;
}
.usage-charts-heading,
.usage-chart-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.usage-charts-heading {
  margin-bottom: 12px;
}
.usage-charts-heading h3,
.usage-chart h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}
.usage-metric {
  grid-template-columns: repeat(3, auto);
  margin: 0;
}
.usage-metric button {
  min-height: 30px;
  padding: 4px 12px;
  font-size: 13px;
}
.usage-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.usage-chart {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid #e5e7e7;
  border-radius: 8px;
  background: #fafbfa;
}
.usage-trend-toggle {
  min-height: 28px;
  padding: 3px 10px;
  font-size: 12px;
  color: #73797c;
}
.usage-trend-toggle[aria-pressed='true'] {
  color: #117d68;
}
.usage-empty {
  margin: 0;
  padding: 36px 0;
  text-align: center;
  color: #73797c;
  font-size: 13px;
}
/* 环形图在左，明细表在右；紧凑卡片隐藏请求数与次要指标列。 */
.usage-donut {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.usage-donut-figure {
  flex-shrink: 0;
}
.usage-donut-chart {
  display: block;
  width: 108px;
  height: 108px;
  overflow: visible;
}
.usage-slice {
  transition:
    transform 0.15s,
    opacity 0.15s;
  transform-origin: 60px 60px;
  transform-box: view-box;
}
.usage-slice.is-active {
  transform: scale(1.05);
}
.usage-donut-total {
  fill: #25282a;
  font-size: 14px;
  font-weight: 600;
}
.usage-donut-label {
  fill: #73797c;
  font-size: 10px;
}
.usage-breakdown-scroll {
  flex: 1;
  min-width: 0;
  overflow: auto;
}
/* 固定表格布局：名称列吃掉剩余宽度并按省略号截断，数值列宽度固定，窄卡片里也不会被挤出。 */
.usage-breakdown {
  width: 100%;
  table-layout: fixed;
  white-space: nowrap;
}
.usage-breakdown th,
.usage-breakdown td {
  padding: 3px 8px 3px 0;
  font-size: 12px;
  text-align: right;
  border-bottom: 1px solid #eff1f0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.usage-breakdown th:not(:first-child) {
  width: 64px;
}
.usage-breakdown th:nth-child(2) {
  width: 52px;
}
.usage-breakdown th:last-child {
  width: 40px;
  padding-right: 0;
}
.usage-breakdown td:last-child {
  padding-right: 0;
}
.usage-breakdown th {
  padding-top: 0;
  font-weight: 500;
}
.usage-breakdown tr:last-child td {
  border-bottom: 0;
}
.usage-breakdown th:first-child,
.usage-breakdown td:first-child {
  text-align: left;
}
.usage-breakdown tbody tr {
  cursor: default;
}
.usage-breakdown tbody tr.is-active td,
.usage-breakdown tbody tr:focus-visible td {
  background: #eef3f1;
}
.usage-breakdown tbody tr:focus-visible {
  outline: none;
}
.usage-breakdown-name span {
  vertical-align: bottom;
}
.usage-breakdown-name i {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border-radius: 2px;
  vertical-align: 1px;
}
.usage-trend-body {
  min-width: 0;
}
.usage-trend-chart {
  display: block;
  max-width: 100%;
  overflow: visible;
}
.usage-grid {
  stroke: var(--usage-grid);
  stroke-width: 1;
}
.usage-axis {
  stroke: var(--usage-axis);
  stroke-width: 1;
}
.usage-axis-label {
  fill: #73797c;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.usage-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.usage-crosshair {
  stroke: #9aa3a0;
  stroke-width: 1;
  pointer-events: none;
}
.usage-marker {
  stroke: #fafbfa;
  stroke-width: 2;
  pointer-events: none;
}
.usage-plot-hit {
  fill: transparent;
  cursor: crosshair;
  outline: none;
}
.usage-plot-hit:focus-visible {
  stroke: #168f78;
  stroke-width: 2;
}
.usage-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: #52514e;
}
.usage-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.usage-legend i {
  width: 12px;
  height: 3px;
  border-radius: 2px;
}
.usage-trend-table {
  white-space: nowrap;
}
.usage-trend-table th,
.usage-trend-table td {
  padding: 8px 12px 8px 0;
  font-size: 12px;
  text-align: right;
}
.usage-trend-table th:first-child,
.usage-trend-table td:first-child {
  text-align: left;
}
/* 提示框：标签列按内容取宽、不换行；只有带色块的提示框才有色块列。 */
.usage-tooltip {
  position: absolute;
  z-index: 20;
  display: grid;
  gap: 4px;
  min-width: 150px;
  max-width: min(340px, calc(100vw - 16px));
  padding: 10px 12px;
  border-radius: 6px;
  background: #1f2a28;
  color: #fff;
  font-size: 12px;
  box-shadow: 0 10px 30px #0000002e;
  pointer-events: none;
}
.usage-tooltip strong {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.usage-tooltip hr {
  margin: 3px 0;
  border: 0;
  border-top: 1px solid #ffffff2b;
}
.usage-tooltip-row {
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) auto;
  align-items: center;
  gap: 8px 14px;
  color: #c8d1cf;
}
.usage-tooltip.has-keys .usage-tooltip-row {
  grid-template-columns: 10px minmax(max-content, 1fr) auto;
  gap: 8px;
}
.usage-tooltip-row span,
.usage-tooltip-row b {
  white-space: nowrap;
}
.usage-tooltip-row i {
  width: 10px;
  height: 3px;
  border-radius: 2px;
}
.usage-tooltip-row b {
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.usage-tooltip-row b[data-tone='input'] {
  color: #7dd3fc;
}
.usage-tooltip-row b[data-tone='output'] {
  color: #c4b5fd;
}
.usage-tooltip-row b[data-tone='tier'] {
  color: #67e8f9;
}
.usage-tooltip-row b[data-tone='rate'] {
  color: #60a5fa;
}
.usage-tooltip-row b[data-tone='good'] {
  color: #4ade80;
}
/* 十二列明细在 1120px 内尽量收紧：允许模型与端点换行，其余单元保持不换行。 */
.usage-table {
  white-space: normal;
}
.usage-table th {
  white-space: nowrap;
}
.usage-table td {
  vertical-align: top;
  padding-right: 14px;
}
.usage-table td:nth-child(2),
.usage-table td:nth-child(11) {
  overflow-wrap: break-word;
}
.usage-table .key-group-badge {
  white-space: nowrap;
}
.usage-time {
  display: grid;
  gap: 2px;
  white-space: nowrap;
}
.usage-time small {
  color: #73797c;
  font-size: 12px;
}
.usage-key-link {
  color: #117d68;
  font-weight: 600;
  text-decoration: underline dashed;
  text-underline-offset: 3px;
}
.usage-key-link:hover {
  color: #0c6756;
}
.usage-key-name {
  font-weight: 600;
}
.usage-ip {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}
.usage-badges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 96px;
}
.usage-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  background: #eef1f0;
  color: #52514e;
  font-size: 12px;
  white-space: nowrap;
}
.usage-badge[data-kind='stream'] {
  background: #e8f1fb;
  color: #2b5f9c;
}
.usage-badge[data-kind='ws_v2'] {
  background: #eeeafb;
  color: #5a48b0;
}
.usage-badge[data-kind='live'],
.usage-badge[data-kind='compaction'] {
  background: #e6f5ef;
  color: #17694f;
}
.usage-badge[data-kind='cyber'],
.usage-badge[data-kind='warn'] {
  background: #fff1e6;
  color: #9a5a17;
}
.usage-tokens {
  display: grid;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}
.usage-token-line {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.usage-token {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.usage-token .key-icon {
  width: 13px;
  height: 13px;
  color: #73797c;
}
.usage-token b {
  font-weight: 600;
}
.usage-token-cache {
  color: #73797c;
  font-size: 12px;
}
.usage-cost {
  display: grid;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}
.usage-cost b {
  color: #117d68;
  font-weight: 600;
}
.usage-cost b,
.usage-cost small,
.usage-tokens,
.usage-latency {
  white-space: nowrap;
}
.usage-cost-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
/* 原价划掉、倍率跟在后面；两者与实际扣费用同一列宽对齐。 */
.usage-cost-original {
  display: inline-flex;
  gap: 6px;
  color: #73797c;
  font-size: 11px;
}
.usage-cost-original s {
  text-decoration-color: #a3a9a7;
}
/* 费用明细按钮：悬停或点击（触屏）展开与 Sub2API 一致的费用弹层。 */
.usage-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #eef1f0;
  color: #8a9195;
  cursor: help;
}
.usage-info .key-icon {
  width: 12px;
  height: 12px;
  stroke-width: 2.2;
}
.usage-info:hover,
.usage-info:focus-visible {
  background: #e3eef9;
  color: #2b5f9c;
}
.usage-info:focus-visible {
  outline: 2px solid #117d68;
  outline-offset: 1px;
}
.usage-latency {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
/* 竖向色条上半段随首字分档、下半段随总耗时分档；文字保持中性色。 */
.usage-latency i {
  flex-shrink: 0;
  width: 3px;
  border-radius: 2px;
  --usage-first: var(--usage-total-color);
  background: linear-gradient(to bottom, var(--usage-first) 40%, var(--usage-total-color) 60%);
}
.usage-latency i[data-first='good'] {
  --usage-first: #0ca30c;
}
.usage-latency i[data-first='warn'] {
  --usage-first: #fab219;
}
.usage-latency i[data-first='slow'] {
  --usage-first: #ec835a;
}
.usage-latency i[data-first='critical'] {
  --usage-first: #d03b3b;
}
.usage-latency i[data-total='good'] {
  --usage-total-color: #0ca30c;
}
.usage-latency i[data-total='warn'] {
  --usage-total-color: #fab219;
}
.usage-latency i[data-total='slow'] {
  --usage-total-color: #ec835a;
}
.usage-latency i[data-total='critical'] {
  --usage-total-color: #d03b3b;
}
.usage-latency-grid {
  display: grid;
  grid-template-columns: max-content max-content;
  align-items: baseline;
  gap: 2px 8px;
  font-size: 12px;
}
.usage-latency-grid span {
  color: #73797c;
}
.usage-latency-grid b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.usage-empty-row {
  color: #73797c;
}
.usage-pagination {
  padding-top: 14px;
}
[data-account-panel='usage'][data-mode='local'] .usage-filters,
[data-account-panel='usage'][data-mode='local'] .usage-progress,
[data-account-panel='usage'][data-mode='local'] .usage-summary,
[data-account-panel='usage'][data-mode='local'] .usage-charts,
[data-account-panel='usage'][data-mode='local'] .usage-pagination .key-actions {
  display: none;
}
@media (max-width: 760px) {
  .usage-chart-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .usage-donut-chart {
    width: 100px;
    height: 100px;
  }
  .usage-breakdown-detail {
    display: none;
  }
}
@media (max-width: 700px) {
  .usage-heading {
    align-items: flex-start;
  }
  .usage-filters {
    gap: 12px;
  }
  .usage-presets {
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .usage-presets button {
    padding-inline: 6px;
    font-size: 13px;
  }
  .usage-dates {
    width: 100%;
  }
  .usage-dates label {
    flex: 1;
  }
  .usage-dates input {
    width: 100%;
  }
  .usage-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 12px;
  }
  .usage-summary > div:nth-child(odd) {
    padding-left: 0;
    border-left: 0;
  }
  .usage-charts-toggle {
    margin-left: 0;
  }
}
