:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --text: #1f2937;
  --text-2: #4b5563;
  --muted: #9ca3af;
  --primary: #4a6cf7;
  --primary-soft: #eef2ff;
  --primary-strong: #3b5bdb;
  --up: #059669;
  --up-soft: #ecfdf5;
  --down: #dc2626;
  --down-soft: #fef2f2;
  --new: #2563eb;
  --new-soft: #eff6ff;
  --gold: #b45309;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.04);
  --radius: 10px;
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.layout {
  width: min(1040px, calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: var(--shadow);
  background: var(--surface);
}
.brand h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 650;
}
.sub {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 0.82rem;
  box-shadow: var(--shadow);
}
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.dot.ok { background: var(--up); }
.dot.err { background: var(--down); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow-x: auto;
}
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 0.9rem;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.section-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
}
.hint {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.movers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 720px) {
  .movers-grid { grid-template-columns: 1fr; }
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 650;
  font-size: 0.95rem;
  margin-bottom: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.badge {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
}
.badge.up { background: var(--up-soft); color: var(--up); }
.badge.down { background: var(--down-soft); color: var(--down); }
.badge.new { background: var(--new-soft); color: var(--new); }

.mover-list {
  list-style: none;
  margin: 0;
  padding: 0;
  min-height: 48px;
}
.mover-list li {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  padding: 9px 2px;
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
}
.mover-list li:first-child { border-top: 0; }
.rank-chip {
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  text-align: right;
}
.mover-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.mover-delta {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 0.88rem;
}
.mover-delta.up { color: var(--up); }
.mover-delta.down { color: var(--down); }
.mover-delta.neutral { color: var(--text-2); }
.mover-meta {
  grid-column: 2 / -1;
  color: var(--muted);
  font-size: 0.75rem;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.search {
  width: min(260px, 100%);
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 8px;
  outline: none;
}
.day-input {
  width: auto;
  min-width: 150px;
}
.history-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-ghost {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--line);
}
.btn-ghost:hover {
  background: var(--line);
  color: var(--text);
}
.search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.btn {
  appearance: none;
  border: 0;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  color: #fff;
  background: var(--primary);
}
.btn:hover { background: var(--primary-strong); }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.board-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.board-table th,
.board-table td {
  padding: 9px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.board-table th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
}
.board-table td.num,
.board-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.board-table tbody tr:hover { background: #f8faff; }
.board-table tbody tr:last-child td { border-bottom: 0; }
.board-table .empty {
  text-align: center;
  color: var(--muted);
  padding: 28px;
}
.pos {
  color: var(--primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pos.top3 { color: var(--gold); }
.tag-amb {
  margin-left: 6px;
  font-size: 0.7rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 6px;
  vertical-align: middle;
  font-weight: 400;
}

.player-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.player-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

.chart-card { margin-bottom: 14px; }
#threshChart {
  display: block;
  width: 100%;
  max-width: 920px;
  height: auto;
}
.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 8px;
  color: var(--text-2);
  font-size: 0.8rem;
}
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: -1px;
}

.empty-state {
  color: var(--muted);
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
  background: var(--surface);
}
.amb-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 0.86rem;
  border: 1px solid #dbe4ff;
}
.series-block { margin-bottom: 12px; }
.series-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
  align-items: baseline;
}
.series-title { font-weight: 650; }
.series-stats {
  color: var(--text-2);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}
.series-canvas-wrap { overflow: auto; }
.series-canvas-wrap canvas {
  display: block;
  width: 100%;
  max-width: 920px;
  height: auto;
}

.site-footer {
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  line-height: 1.6;
}

.chart-tooltip {
  position: fixed;
  z-index: 80;
  pointer-events: none;
  max-width: 240px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
  font-variant-numeric: tabular-nums;
}

/* player modal */
.modal[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.modal-card {
  position: relative;
  width: min(960px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  padding: 16px 18px 20px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.modal-head h3 {
  margin: 0;
  font-size: 1.05rem;
}
.modal-close {
  appearance: none;
  border: 0;
  background: var(--surface-2);
  color: var(--text-2);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover {
  background: var(--line);
  color: var(--text);
}
