﻿/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", "Segoe UI", Roboto, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== 顶部标题区 ========== */
.app-header {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  color: #fff;
  padding: 20px 24px 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}
.title-row h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
.scope-tag {
  font-size: 13px;
  opacity: 0.85;
  background: rgba(255,255,255,0.15);
  padding: 3px 10px;
  border-radius: 12px;
}
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.meta-pill {
  font-size: 12px;
  background: rgba(255,255,255,0.18);
  padding: 4px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.meta-pill.warning {
  background: rgba(245, 158, 11, 0.25);
  border: 1px solid rgba(245, 158, 11, 0.5);
}

/* ========== 筛选器 ========== */
.filter-bar {
  background: #fff;
  padding: 16px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: flex-start;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.filter-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.filter-label {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  white-space: nowrap;
}
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 14px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}
.chip:hover { background: #e5e7eb; }
.chip.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.chip input { display: none; }
.filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}
#search-input {
  padding: 7px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  min-width: 200px;
  outline: none;
}
#search-input:focus { border-color: #2563eb; }
.btn-secondary {
  padding: 7px 14px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.btn-secondary:hover { background: #f9fafb; border-color: #9ca3af; }

/* ========== 主内容区 ========== */
main {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}
.section {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.section-title {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 700;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-hint {
  margin: -8px 0 16px;
  font-size: 12px;
  color: #6b7280;
}

/* ========== KPI 卡 ========== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.kpi-card {
  background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.kpi-card.accent-gold {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: #f59e0b;
}
.kpi-card.accent-blue {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  border-color: #3b82f6;
}
.kpi-label {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
  font-weight: 500;
}
.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: #111827;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.kpi-unit {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 2px;
}

/* ========== 完成度 ========== */
.completion-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.completion-row {
  display: grid;
  grid-template-columns: 80px 1fr 100px 80px;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.completion-name {
  font-weight: 600;
  font-size: 13px;
}
.completion-bar-track {
  height: 12px;
  background: #f3f4f6;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.completion-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.3s ease;
}
.completion-bar-fill.excellent { background: linear-gradient(90deg, #10b981, #059669); }
.completion-bar-fill.watch { background: linear-gradient(90deg, #f59e0b, #d97706); }
.completion-bar-fill.review { background: linear-gradient(90deg, #ef4444, #dc2626); }
.completion-bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #fff;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.completion-detail {
  font-size: 12px;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}
.completion-status {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
  text-align: center;
}
.completion-status.excellent { background: #d1fae5; color: #065f46; }
.completion-status.watch { background: #fef3c7; color: #92400e; }
.completion-status.review { background: #fee2e2; color: #991b1b; }

/* ========== 图表 ========== */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.chart-card {
  background: #f9fafb;
  border-radius: 8px;
  padding: 14px;
}
.chart-card h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}
.chart-area {
  width: 100%;
  min-height: 280px;
}
.chart-area-tall {
  min-height: 320px;
}
.chart-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}
.tab-btn {
  padding: 5px 10px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: #6b7280;
}
.tab-btn:hover { background: #f3f4f6; }
.tab-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* ========== SVG 图表样式 ========== */
svg text { font-family: inherit; }
.bar-rect { transition: opacity 0.2s; cursor: pointer; }
.bar-rect:hover { opacity: 0.7; }
.line-path { fill: none; stroke-width: 2; }
.dot { cursor: pointer; }
.dot:hover { r: 5; }

/* ========== 表格 ========== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
  white-space: nowrap;
}
.data-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
}
.data-table th:hover { background: #f3f4f6; }
.data-table th .sort-ind {
  display: inline-block;
  width: 10px;
  margin-left: 4px;
  opacity: 0.4;
}
.data-table th.sort-asc .sort-ind,
.data-table th.sort-desc .sort-ind { opacity: 1; color: #2563eb; }
.data-table tbody tr:hover { background: #f9fafb; }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.id-cell { font-family: ui-monospace, monospace; font-size: 12px; color: #6b7280; }
.table-meta {
  margin-top: 12px;
  font-size: 12px;
  color: #6b7280;
}

/* ========== Footer 数据限制 ========== */
.data-limitations {
  max-width: 1400px;
  margin: 0 auto 24px;
  padding: 0 24px;
}
.data-limitations details {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 12px 16px;
}
.data-limitations summary {
  cursor: pointer;
  font-weight: 600;
  color: #92400e;
  font-size: 14px;
  list-style: none;
}
.data-limitations summary::-webkit-details-marker { display: none; }
.data-limitations summary::before { content: "▶ "; display: inline-block; transition: transform 0.2s; }
.data-limitations details[open] summary::before { transform: rotate(90deg); }
.data-limitations ol {
  margin: 12px 0 0;
  padding-left: 24px;
  font-size: 13px;
  color: #78350f;
  line-height: 1.8;
}
.footer-note {
  margin: 8px 0 0;
  font-size: 12px;
  color: #92400e;
  opacity: 0.8;
}

/* ========== 空状态 ========== */
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: #9ca3af;
  font-size: 14px;
  text-align: center;
}
.empty-state::before { content: "📭"; font-size: 32px; margin-right: 12px; }

/* ========== 响应式：手机端 ========== */
@media (max-width: 768px) {
  .app-header { padding: 16px; }
  .title-row h1 { font-size: 18px; }
  .meta-row { gap: 6px; }
  .meta-pill { font-size: 11px; padding: 3px 8px; }
  .filter-bar { padding: 12px; gap: 12px; }
  .filter-block { width: 100%; }
  .filter-actions { margin-left: 0; width: 100%; }
  #search-input { flex: 1; min-width: 0; }
  main { padding: 12px; }
  .section { padding: 14px; }
  .section-title { font-size: 15px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi-card { padding: 10px 12px; }
  .kpi-value { font-size: 18px; }
  .chart-row { grid-template-columns: 1fr; }
  .chart-area { min-height: 220px; }
  .completion-row {
    grid-template-columns: 70px 1fr 70px;
    gap: 8px;
  }
  .completion-detail { display: none; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 6px; }
}

/* ========== 中等屏幕（平板） ========== */
@media (min-width: 769px) and (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .chart-row { grid-template-columns: 1fr; }
}

/* ========== 打印 ========== */
@media print {
  .filter-bar, .data-limitations { display: none; }
  .section { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
}