:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e5e8ec;
  --text: #1f2933;
  --muted: #8a94a6;
  --accent: #2563eb;
  --up: #dc2626;   /* 涨 = 红（国内习惯） */
  --down: #16a34a; /* 跌 = 绿 */
  --radius: 10px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }
.error { color: #dc2626; font-size: 12px; }
.muted { color: var(--muted); }

/* 登录 */
.login {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.login-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 320px;
  text-align: center;
}
.login-box h1 { font-size: 28px; margin-bottom: 4px; }
.login-box p { color: var(--muted); margin-bottom: 20px; }
.login-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 12px;
}
.login-box button {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

/* 顶栏 */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.brand { font-size: 20px; font-weight: 700; }
.brand .sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
#site-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  font-size: 13px;
}
.periods { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.periods button {
  padding: 7px 14px;
  border: none;
  background: var(--card);
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
}
.periods button + button { border-left: 1px solid var(--border); }
.periods button.active { background: var(--accent); color: #fff; }

.container { max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 30px; font-weight: 700; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.stat-delta { font-size: 12px; color: var(--muted); }
.stat-delta.up { color: var(--up); }
.stat-delta.down { color: var(--down); }

.chart-card { margin-top: 16px; }
.chart-card h2 { font-size: 15px; margin-bottom: 14px; }

/* TopN 网格 */
.grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.grid h2 { font-size: 15px; margin-bottom: 12px; }
.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.metric-row:first-of-type { border-top: none; }
.metric-key {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 65%;
}
.metric-nums { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.metric-empty { color: var(--muted); padding: 12px 0; }

/* TopN 占比条 */
.bar { height: 3px; background: #eef1f5; border-radius: 2px; overflow: hidden; margin-bottom: 6px; }
.bar i { display: block; height: 100%; background: var(--accent); opacity: .55; }

/* 演示模式提示条 */
.demo-banner {
  background: #fff7e6;
  border-bottom: 1px solid #f5d9a0;
  color: #8a6100;
  padding: 8px 24px;
  font-size: 13px;
  text-align: center;
}
.demo-banner code { background: #f7e7c6; padding: 1px 5px; border-radius: 3px; }

/* 表格 */
.table-card { margin-top: 16px; }
.table-card h2 { font-size: 15px; margin-bottom: 12px; }
.table-card h2 .hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 8px 10px; border-bottom: 1px solid #f0f2f5; }
td.nowrap { white-space: nowrap; color: var(--muted); }
.path-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tbody tr:hover { background: #fafbfc; }

.more-btn {
  margin-top: 12px;
  padding: 8px 18px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.more-btn:hover { background: #f7f8fa; }

.refresh-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.refresh-btn:hover { background: #f7f8fa; }

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .container { padding: 16px 12px 40px; }
}
