/* D16 · GEO 引用追踪仪表盘样式
 * 隐私友好的本地分析仪表盘 -- 纯 CSS + DOM，无第三方图表库
 * 配色：主蓝#1677FF / 良好绿#10B981 / 警告黄#F59E0B / 危险红#EF4444 / 中性灰#64748B/#E2E8F0
 * 复用 tokens.css 的 .container / .card / .btn 基础类与 CSS 变量
 */

:root {
  --dash-blue: #1677ff;
  --dash-green: #10b981;
  --dash-yellow: #f59e0b;
  --dash-red: #ef4444;
  --dash-gray: #64748b;
  --dash-gray-light: #e2e8f0;
}

/* ===== 页面骨架 ===== */
.dash-page {
  padding: 48px 0 96px;
  min-height: 60vh;
}
@media (max-width: 768px) {
  .dash-page {
    padding: 32px 0 64px;
  }
}

.dash-page__head {
  margin-bottom: 28px;
}
.dash-page__title {
  font-family: var(--f-serif);
  font-size: var(--fs-h1);
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  font-weight: 600;
  color: var(--c-text);
}
.dash-page__kicker {
  display: inline-block;
  font-family: var(--f-sans);
  font-size: var(--fs-tiny);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-accent-blue-fg);
  background: var(--c-accent-blue);
  padding: 4px 10px;
  border-radius: 9999px;
  margin-bottom: 12px;
}

/* ===== 1. 顶部说明条 ===== */
.dash-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  background: var(--c-accent-blue);
  border-radius: var(--r-md);
  margin-bottom: 36px;
  border: 1px solid color-mix(in srgb, var(--dash-blue) 18%, transparent);
}
.dash-notice__icon {
  font-size: 1.2rem;
  line-height: 1.4;
  flex-shrink: 0;
}
.dash-notice__text {
  font-size: var(--fs-small);
  line-height: var(--lh-normal);
  color: var(--c-text-2);
  margin: 0;
}

/* ===== 区块标题 ===== */
.dash-section {
  margin-bottom: 40px;
}
.dash-section__title {
  font-family: var(--f-serif);
  font-size: var(--fs-h3);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--c-text);
  margin-bottom: 18px;
}

/* ===== 2. 指标卡片网格 ===== */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}
.dash-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
/* 宽卡片跨两列（来源分布 / 落地页 / CLS） */
.dash-card--wide {
  grid-column: span 2;
}
@media (max-width: 768px) {
  .dash-card--wide {
    grid-column: span 1;
  }
}
.dash-card__label {
  font-family: var(--f-sans);
  font-size: var(--fs-small);
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--c-text-2);
  margin: 0;
}
.dash-card__value {
  font-family: var(--f-mono);
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 700;
  line-height: 1;
  color: var(--dash-blue);
  letter-spacing: -0.02em;
}
.dash-card__hint {
  font-size: var(--fs-tiny);
  color: var(--c-muted);
  margin: 0;
}

/* ===== 进度条 (M2) ===== */
.dash-progress {
  width: 100%;
  height: 10px;
  background: var(--dash-gray-light);
  border-radius: 9999px;
  overflow: hidden;
}
.dash-progress__bar {
  height: 100%;
  background: var(--dash-blue);
  border-radius: 9999px;
  transition: width 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ===== 条形图通用行 (M3 / M4) ===== */
.dash-bar-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dash-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dash-bar-row__label {
  flex-shrink: 0;
  width: 120px;
  font-size: var(--fs-small);
  color: var(--c-text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-bar-row__bar {
  flex-grow: 1;
  height: 8px;
  min-width: 40px;
  background: var(--dash-gray-light);
  border-radius: 9999px;
  overflow: hidden;
}
.dash-bar-row__fill {
  height: 100%;
  background: var(--dash-blue);
  border-radius: 9999px;
  transition: width 400ms cubic-bezier(0.16, 1, 0.3, 1);
}
.dash-bar-row__count {
  flex-shrink: 0;
  width: 40px;
  text-align: right;
  font-family: var(--f-mono);
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--c-text);
}

/* ===== 落地页列表 (M4) ===== */
.dash-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dash-list__item {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dash-list__path {
  flex-shrink: 0;
  width: 180px;
  font-family: var(--f-mono);
  font-size: var(--fs-small);
  color: var(--c-text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-list__count {
  flex-shrink: 0;
  width: 40px;
  text-align: right;
  font-family: var(--f-mono);
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--c-text);
}
.dash-list__item--empty {
  font-size: var(--fs-small);
  color: var(--c-muted);
  justify-content: center;
  padding: 10px 0;
}

/* ===== CLS 性能 (M5) ===== */
.dash-cls {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.dash-cls__avg {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.dash-cls__avg-label {
  font-size: var(--fs-small);
  color: var(--c-text-2);
}
.dash-cls__avg-value {
  font-family: var(--f-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--c-text);
  letter-spacing: -0.01em;
}
.dash-cls__tiers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 480px) {
  .dash-cls__tiers {
    grid-template-columns: 1fr;
  }
}
.dash-cls__tier {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
}
.dash-cls__tier-label {
  font-size: var(--fs-tiny);
  color: var(--c-muted);
  font-family: var(--f-mono);
}
.dash-cls__tier-count {
  font-family: var(--f-mono);
  font-size: 1.25rem;
  font-weight: 700;
}
.dash-cls__tier--good .dash-cls__tier-count {
  color: var(--dash-green);
}
.dash-cls__tier--good {
  border-color: color-mix(in srgb, var(--dash-green) 30%, transparent);
}
.dash-cls__tier--warn .dash-cls__tier-count {
  color: var(--dash-yellow);
}
.dash-cls__tier--warn {
  border-color: color-mix(in srgb, var(--dash-yellow) 30%, transparent);
}
.dash-cls__tier--bad .dash-cls__tier-count {
  color: var(--dash-red);
}
.dash-cls__tier--bad {
  border-color: color-mix(in srgb, var(--dash-red) 30%, transparent);
}

/* ===== 3. 操作区 ===== */
.dash-actions {
  margin-top: 8px;
  padding: 28px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
}
.dash-actions__btns {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
/* 清空按钮用危险色边框提示 */
.dash-actions__btns .btn--secondary#btn-clear {
  border-color: color-mix(in srgb, var(--dash-red) 40%, transparent);
  color: var(--dash-red);
}
.dash-actions__btns .btn--secondary#btn-clear:hover {
  background: color-mix(in srgb, var(--dash-red) 8%, transparent);
}

/* ===== 4. 空状态 ===== */
.dash-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 24px;
  text-align: center;
}
.dash-empty__icon {
  font-size: 3rem;
  line-height: 1;
}
.dash-empty__text {
  font-size: 1rem;
  color: var(--c-muted);
  max-width: 480px;
  line-height: var(--lh-loose);
}
.dash-empty__text code {
  font-family: var(--f-mono);
  font-size: 0.875em;
  padding: 2px 6px;
  background: var(--c-surface-2);
  border-radius: 4px;
  color: var(--dash-blue);
}

/* ===== 响应式：移动端紧凑 ===== */
@media (max-width: 640px) {
  .dash-bar-row__label {
    width: 90px;
  }
  .dash-list__path {
    width: 120px;
  }
  .dash-actions {
    padding: 20px;
  }
}

/* ===== 暗色模式适配 ===== */
[data-theme='dark'] .dash-progress,
[data-theme='dark'] .dash-bar-row__bar {
  background: rgba(255, 255, 255, 0.1);
}
[data-theme='dark'] .dash-cls__tier {
  background: var(--c-surface-2);
}
