/* ============================================================
   行者骑行数据大屏 — 紧凑版 (1920×1080)
   ============================================================ */

:root {
  --bg-primary: #0b0f16;
  --bg-card: #141b2b;
  --bg-card-hover: #1a2340;
  --border: #1e2a45;
  --text-primary: #e2e8f0;
  --text-secondary: #7e8ea0;
  --green: #22c55e;
  --blue: #3b82f6;
  --orange: #f59e0b;
  --purple: #8b5cf6;
  --cyan: #06b6d4;
  --gradient-1: linear-gradient(135deg, #22c55e 0%, #06b6d4 100%);
  --gradient-2: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  --gradient-3: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  --gradient-4: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  user-select: none;
}

/* ── 顶部 ── */
.top-bar { height: 2px; background: var(--gradient-1); }

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 28px 4px;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-icon { font-size: 24px; line-height: 1; }

.header h1 {
  font-size: 18px;
  font-weight: 700;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right { display: flex; align-items: center; gap: 14px; }
.update-time { font-size: 11px; color: var(--text-secondary); }

/* ── 年份选择器 ── */
.year-tabs {
  padding: 2px 28px 6px;
  display: flex;
  gap: 6px;
}

.year-tab {
  padding: 3px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.year-tab:hover { border-color: var(--green); color: var(--text-primary); }

.year-tab.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 600;
}

/* ── 主体 ── */
.container {
  padding: 6px 28px 10px;
  height: calc(100vh - 68px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ── KPI 卡片行 (8 张一行) ── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  flex-shrink: 0;
  margin-bottom: 4px;
}

.kpi-card {
  background: var(--bg-card);
  border-radius: 10px;
  padding: 10px 6px 8px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: 86px;
  transition: all 0.25s ease;
  cursor: default;
}

.kpi-card:hover {
  border-color: var(--accent, var(--green));
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
  background: var(--bg-card-hover);
}

/* 顶部彩色横条 */
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent, var(--gradient-1));
}

/* 图标 + 数字行 */
.kpi-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 2px;
}

.kpi-icon-wrap {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  background: var(--accent-bg, rgba(34,197,94,0.12));
  color: var(--accent, #22c55e);
  flex-shrink: 0;
  transition: all 0.25s;
}

.kpi-card:hover .kpi-icon-wrap {
  transform: scale(1.12);
  background: var(--accent, #22c55e);
  color: #fff;
}

.kpi-main {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.kpi-unit {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 1px;
}

/* 下方标签 + 副标题合并在一行 */
.kpi-info {
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.3;
}

.kpi-info .accent {
  color: var(--accent, #22c55e);
  font-weight: 600;
}

/* ── 图表网格 ── */
.charts-main {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr 1fr;  /* 累计里程占 2 倍 */
  gap: 6px;
  flex: 1;
  min-height: 0;
}

.charts-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  flex: 1.2;
  min-height: 0;
}

.chart-card {
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chart-wide {
  /* 已经由 grid 的 2fr 控制宽度 */
}

.chart-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
}

.chart-body {
  flex: 1;
  min-height: 0;
  width: 100%;
}

/* ── 最近活动列表 ── */
.recent-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.recent-scroll::-webkit-scrollbar { width: 3px; }
.recent-scroll::-webkit-scrollbar-track { background: transparent; }
.recent-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.recent-item {
  display: grid;
  grid-template-columns: 68px 1fr auto;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(30, 42, 69, 0.4);
  align-items: center;
  font-size: 12px;
}

.recent-item:last-child { border-bottom: none; }

.recent-date { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
.recent-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.recent-stats { font-size: 11px; color: var(--green); white-space: nowrap; display: flex; gap: 8px; }

/* ── Loading / Error ── */
.loading, .error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 16px;
}

.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
.error-text { color: var(--text-secondary); font-size: 14px; }