/* 首页专属样式：渠道卡片 / 指标与用量区 / 服务健康 */

.animate-pulse {
  animation: pulse-soft 1.4s ease-in-out infinite;
}

.top-layout .main-content.index-main-content {
  padding-top: calc(var(--topbar-offset) + 10px);
}

/* ===== 渠道卡片：.card 之上只加 padding 与抬升阴影 ===== */

.channel-card {
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
}

.channel-card:hover {
  transform: none;
  box-shadow: var(--shadow-lg);
  border-color: var(--surface-border-strong);
}

.channel-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--surface-border);
}

.channel-card-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--neutral-800);
}

.channel-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: var(--shadow-lift);
  flex-shrink: 0;
}

.channel-icon--anthropic {
  background: linear-gradient(135deg, #d97757, #c15f3c);
}

.channel-icon--openai {
  background: linear-gradient(135deg, #10a37f, #0d8a6a);
}

.channel-icon--codex {
  background: linear-gradient(135deg, #52525b, #27272a);
}

.channel-icon--api {
  background: linear-gradient(135deg, #6366f1, #4338ca);
}

.channel-cost {
  text-align: right;
  white-space: nowrap;
}

.channel-cost:has(.cost-value:empty) {
  display: none;
}

/* 零流量渠道卡收成单行 slim 形态：DOM 结构不动（id 契约保留，流量恢复即还原），
   只隐数据区、缩图标与留白，右侧给「暂无请求」提示。 */

.channel-empty-hint {
  display: none;
}

.channel-card--empty {
  padding: var(--space-3) var(--space-4);
  box-shadow: none;
}

.channel-card--empty:hover {
  box-shadow: var(--shadow-sm);
}

.channel-card--empty .channel-card-header {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.channel-card--empty .channel-card-title {
  font-size: var(--text-base);
}

.channel-card--empty .channel-icon {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-md);
  box-shadow: none;
}

.channel-card--empty .channel-icon svg {
  width: 14px;
  height: 14px;
}

.channel-card--empty .channel-cost,
.channel-card--empty .channel-metrics,
.channel-card--empty .token-stats {
  display: none;
}

.channel-card--empty .channel-empty-hint {
  display: inline;
  font-size: var(--text-xs);
  color: var(--neutral-500);
  white-space: nowrap;
}

.cost-label {
  display: block;
  font-size: var(--text-xs);
  color: var(--neutral-500);
  margin-bottom: 2px;
  font-weight: var(--font-medium);
}

.cost-value {
  display: block;
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  font-family: var(--font-family-mono);
}

.channel-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.metric-item {
  text-align: left;
}

.token-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--surface-border);
}

.token-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.token-label {
  font-size: var(--text-2xs);
  color: var(--neutral-500);
  font-weight: var(--font-medium);
}

.token-value {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--neutral-700);
  font-family: var(--font-family-mono);
}

/* ===== 用量概览：复用 channel-card 壳，内层配额条与令牌行 ===== */

.usage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-3);
}

.usage-quota-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.usage-quota-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.usage-quota-label {
  width: 3.5em;
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--neutral-500);
  font-weight: var(--font-medium);
}

.usage-quota-track {
  flex: 1;
  height: 6px;
  border-radius: var(--radius-2xs);
  background: var(--surface-border);
  overflow: hidden;
}

.usage-quota-fill {
  height: 100%;
  border-radius: var(--radius-2xs);
  transition: width 0.4s ease;
}

.usage-quota-val {
  width: 3em;
  text-align: right;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  font-family: var(--font-family-mono);
}

.usage-quota-sub {
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--neutral-500);
}

.usage-key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) 0;
}

.usage-key-row + .usage-key-row {
  border-top: 1px solid var(--surface-border);
}

.usage-key-name {
  font-family: var(--font-family-mono);
  color: var(--neutral-700);
  font-size: var(--text-sm);
}

.usage-key-req {
  font-weight: var(--font-semibold);
  color: var(--neutral-800);
  font-size: var(--text-sm);
}

.usage-key-tok {
  color: var(--neutral-500);
  font-size: var(--text-xs);
  font-family: var(--font-family-mono);
}

.service-health-card {
  padding: var(--space-6);
  overflow: hidden;
}

.service-health-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.service-health-title {
  margin: 0;
  color: var(--neutral-800);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  line-height: var(--leading-tight);
}

.service-health-summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.service-health-period,
.service-health-edge {
  color: var(--neutral-500);
  font-size: var(--text-sm);
  white-space: nowrap;
}

.service-health-rate {
  min-width: 4.5rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-base);
  background: var(--neutral-100);
  color: var(--neutral-600);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
}

.service-health-rate[data-state="healthy"] {
  background: color-mix(in srgb, var(--success-500) 14%, transparent);
  color: var(--success-600);
}

.service-health-rate[data-state="warning"] {
  background: color-mix(in srgb, var(--warning-500) 14%, transparent);
  color: var(--warning-600);
}

.service-health-rate[data-state="critical"] {
  background: color-mix(in srgb, var(--error-500) 14%, transparent);
  color: var(--error-600);
}

.service-health-plot {
  position: relative;
  width: 100%;
}

.service-health-grid {
  display: grid;
  grid-template-columns: repeat(96, minmax(0, 1fr));
  gap: 3px;
  width: 100%;
  min-width: 0;
  isolation: isolate;
}

.service-health-cell,
.service-health-swatch {
  background: var(--neutral-200);
}

.service-health-cell {
  aspect-ratio: 1;
  min-width: 0;
  border-radius: var(--radius-2xs);
  transition: transform 120ms ease-out, filter 120ms ease-out;
}

.service-health-cell.healthy,
.service-health-swatch.healthy {
  background: var(--success-500);
}

.service-health-cell.warning,
.service-health-swatch.warning {
  background: var(--warning-500);
}

.service-health-cell.critical,
.service-health-swatch.critical {
  background: var(--error-500);
}

.service-health-cell:hover {
  filter: brightness(1.08) saturate(1.12);
  transform: scale(1.24);
  z-index: var(--z-raised);
}

.service-health-tooltip {
  position: absolute;
  z-index: var(--z-tooltip);
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  background: var(--surface-bg-strong);
  box-shadow: var(--shadow-lg);
  color: var(--neutral-700);
  pointer-events: none;
  white-space: nowrap;
}

.service-health-tooltip::after {
  content: '';
  position: absolute;
  left: var(--service-health-tooltip-arrow-x);
  width: 10px;
  height: 10px;
  border-inline-end: 1px solid var(--surface-border);
  border-block-end: 1px solid var(--surface-border);
  background: var(--surface-bg-strong);
  transform: translateX(-50%) rotate(45deg);
}

.service-health-tooltip[data-placement="top"]::after {
  bottom: -6px;
}

.service-health-tooltip[data-placement="bottom"]::after {
  top: -6px;
  transform: translateX(-50%) rotate(225deg);
}

.service-health-tooltip-time {
  margin-bottom: 0.35rem;
  color: var(--neutral-600);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.service-health-tooltip-stats {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.service-health-tooltip-stats strong {
  font-weight: var(--font-semibold);
}

.service-health-tooltip-success {
  color: var(--success-600);
}

.service-health-tooltip-error {
  color: var(--error-600);
}

.service-health-tooltip-rate {
  color: var(--neutral-600);
}

.service-health-footer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.service-health-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  min-width: 0;
}

.service-health-legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--neutral-600);
  font-size: var(--text-xs);
  white-space: nowrap;
}

.service-health-swatch {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: var(--radius-2xs);
  flex: 0 0 auto;
}

.service-health-message {
  margin: var(--space-3) 0 0;
  color: var(--neutral-600);
  font-size: var(--text-sm);
  text-align: center;
}

@media (max-width: 768px) {
.service-health-grid {
    grid-template-columns: repeat(48, minmax(0, 1fr));
    gap: 2px;
  }
.service-health-legend {
    gap: var(--space-2);
  }
}

@media (max-width: 480px) {
.service-health-card {
    padding: var(--space-4);
  }
.service-health-header {
    align-items: flex-start;
    flex-direction: column;
    gap: var(--space-3);
  }
.service-health-summary {
    justify-content: space-between;
    width: 100%;
  }
.service-health-grid {
    grid-template-columns: repeat(32, minmax(0, 1fr));
  }
.service-health-footer {
    grid-template-columns: 1fr;
  }
.service-health-edge {
    display: none;
  }
.service-health-legend {
    flex-wrap: wrap;
  }
}

.metric-label {
  font-size: var(--text-sm);
  color: var(--neutral-600);
  font-weight: var(--font-medium);
}

/* 指标语义色统一走 styles.css 的 .tone-*（metric-value tone-primary/healthy/critical） */

/* ===== 网格系统 ===== */

.grid {
  display: grid;
  gap: var(--space-4);
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 768px) {
.grid-cols-2 {
    grid-template-columns: repeat(1, 1fr);
  }
.channel-card {
    padding: var(--space-4);
  }
.channel-metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
  }
.metric-item {
    display: flex;
    flex-direction: row-reverse;
    justify-content: space-between;
    align-items: center;
    text-align: left;
  }
.token-stats {
    grid-template-columns: repeat(2, 1fr);
  }
.token-item {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.gap-space-3 {
  gap: var(--space-3);
}

.animate-delay-1 {
  animation-delay: 0.1s;
}

.animate-delay-2 {
  animation-delay: 0.2s;
}

.animate-delay-3 {
  animation-delay: 0.3s;
}
