:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #1d2433;
  --muted: #6b7280;
  --line: #e5e7eb;
  --shadow: 0 10px 30px rgba(20, 35, 80, .08);
  --radius: 16px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  background: linear-gradient(135deg, #101827, #263853);
  color: #fff;
}
.topbar h1 { margin: 0 0 6px; font-size: 24px; }
.topbar p { margin: 0; color: rgba(255,255,255,.78); font-size: 14px; line-height: 1.5; }
.panel {
  margin: 16px auto;
  width: min(1180px, calc(100% - 24px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.controls {
  display: grid;
  grid-template-columns: auto 1fr auto 150px auto auto;
  align-items: center;
  gap: 10px;
}
select, input, button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 14px;
  background: #fff;
}
button { cursor: pointer; font-weight: 700; }
button.primary {
  border: 0;
  background: #ffffff;
  color: #111827;
  padding: 0 16px;
}
.controls button, .primary, .period-btn { transition: transform .12s ease, opacity .12s ease; }
button:active { transform: scale(.98); }
.period-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.period-head h2 { margin-bottom: 4px; }
.period-list { display: flex; flex-wrap: wrap; gap: 8px; }
.period-btn { min-height: 34px; border-radius: 999px; background: #f9fafb; }
.period-btn span { color: var(--muted); font-size: 12px; margin-left: 4px; }
.cards {
  width: min(1180px, calc(100% - 24px));
  margin: 16px auto;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card.important { border-color: #111827; }
.card .num { font-size: 28px; font-weight: 900; word-break: break-all; }
.card .label { color: var(--muted); margin-top: 6px; font-size: 13px; }
.grid2 {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
h2 { margin: 0 0 14px; font-size: 18px; }
h3 { margin: 18px 0 10px; font-size: 15px; color: var(--muted); }
.hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.bars { display: grid; gap: 9px; }
.bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 88px;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.rank-name { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.bar-track {
  background: #eef2f7;
  border-radius: 999px;
  overflow: hidden;
  height: 11px;
}
.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #64748b, #111827);
}
.count { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}
.rank-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px;
  background: #fafafa;
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 3px 6px;
  align-items: center;
}
.rank-card strong { font-size: 18px; }
.rank-card span:last-of-type, .rank-card em { color: var(--muted); font-size: 12px; font-style: normal; grid-column: 2 / 3; }
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}
th { color: var(--muted); font-weight: 800; background: #fafafa; }
.pill, .tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  margin: 2px 3px 2px 0;
  border-radius: 999px;
  background: #f3f4f6;
  white-space: nowrap;
  font-size: 13px;
}
.tag { background: #eef2ff; color: #1e3a8a; }
.danger { background: #fee2e2 !important; color: #991b1b !important; }
.raw-text { max-width: 420px; line-height: 1.55; color: #374151; }
.logs { display: grid; gap: 8px; }
.log {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.log b { color: var(--text); }
.empty { color: var(--muted); padding: 10px 0; }
#toast {
  position: fixed;
  left: 50%; bottom: 22px;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  max-width: calc(100% - 24px);
  text-align: center;
  z-index: 9;
}
#toast.show { opacity: 1; }
@media (max-width: 1080px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
  .rank-list { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .topbar { display: block; padding: 18px 14px; }
  .topbar h1 { font-size: 20px; }
  .topbar button { margin-top: 12px; width: 100%; }
  .controls { grid-template-columns: 1fr; }
  .period-head { display: block; }
  .period-head button { width: 100%; margin: 10px 0; }
  .cards { grid-template-columns: repeat(2, 1fr); width: calc(100% - 16px); }
  .grid2 { grid-template-columns: 1fr; gap: 0; width: 100%; }
  .panel { width: calc(100% - 16px); margin: 10px auto; padding: 12px; }
  .rank-list { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .bar-row { grid-template-columns: 78px 1fr 74px; font-size: 13px; }
  .rank { min-width: 20px; height: 20px; font-size: 11px; }
  th, td { font-size: 13px; padding: 8px 6px; }
  table { min-width: 820px; }
}
@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr; }
  .rank-list { grid-template-columns: 1fr; }
}
