@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300..800;1,300..800&display=swap');

/* ── 全局变量 ── */
:root {
  --bg: #f5f7fa;
  --bg2: #ffffff;
  --bg3: #eef1f6;
  --border: #d0d7de;
  --text: #1f2328;
  --text-muted: #656d76;
  --accent: #0969da;
  --accent2: #1a7f37;
  --danger: #cf222e;
  --warning: #9a6700;
  --header-h: 64px;
  --rank1: #b8860b;
  --rank2: #6e7681;
  --rank3: #953800;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Plus Jakarta Sans', 'Segoe UI', 'PingFang SC', sans-serif; background: var(--bg); color: var(--text); font-size: 16px; color-scheme: light; }

/* ── 顶栏 ── */
.top-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  gap: 12px;
  box-shadow: 0 1px 0 var(--border);
}
.top-bar-left { display: flex; align-items: center; gap: 20px; }
.top-bar-right { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 18px; font-weight: 800; color: var(--accent); white-space: nowrap; }
.subtitle { font-size: 13px; color: var(--text-muted); }
.badge {
  padding: 4px 12px; border-radius: 20px;
  background: var(--bg3); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-muted); white-space: nowrap;
}

/* ── 按钮 ── */
button { cursor: pointer; border: none; border-radius: var(--radius); transition: all .15s; }
.btn-refresh {
  display: flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff; padding: 8px 18px; font-weight: 600; font-size: 14.5px;
  border-radius: 8px;
}
.btn-refresh:hover { background: #0860ca; }
.btn-refresh.loading { opacity: .6; pointer-events: none; }



/* ── 主布局 ── */
.app-container { min-height: 100vh; display: flex; flex-direction: column; }
.main-content {
  margin-top: var(--header-h);
  flex: 1;
  padding: 24px 32px;
  max-width: 1500px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  margin-top: calc(var(--header-h) + 24px);
}

/* ── 排行榜工具栏 ── */
.rank-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.rank-title { font-size: 24px; font-weight: 800; }
.rank-toolbar-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.search-input {
  background: var(--bg2); border: 1px solid var(--border);
  color: var(--text); padding: 8px 16px; border-radius: 8px; font-size: 14px;
  outline: none; width: 260px;
  transition: all 0.2s ease;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(9,105,218,.1); }
.auto-refresh-label { color: var(--text-muted); font-size: 14px; display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.auto-refresh-label input { cursor: pointer; accent-color: var(--accent); width: 15px; height: 15px; }

/* ── 表格容器 ── */
.table-wrapper {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,.04);
}
#rankTable { width: 100%; border-collapse: collapse; }
#rankTable thead { position: sticky; top: 0; z-index: 10; }
#rankTable thead tr { background: var(--bg3); border-bottom: 2px solid var(--border); }
#rankTable th, #rankTable td {
  padding: 16px 20px; text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
#rankTable th { font-weight: 700; font-size: 14px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
#rankTable tbody tr { transition: background-color 0.2s ease, opacity 0.2s ease; }
#rankTable tbody tr:last-child td { border-bottom: none; }
#rankTable tbody tr:hover { background: rgba(9,105,218,.06); cursor: pointer; }
#rankTable tbody tr.active-row { background: rgba(9,105,218,.16) !important; }

.rank-num { font-weight: 800; font-size: 18px; }
.rank-1 { color: var(--rank1); }
.rank-2 { color: var(--rank2); }
.rank-3 { color: var(--rank3); }

.team-name { color: var(--accent); font-weight: 700; }
.team-link { color: var(--accent); font-weight: 700; text-decoration: none; font-size: 16px; }
.team-link:hover { text-decoration: underline; }
.score-total { font-weight: 800; color: var(--accent2); font-size: 18px; }
.score-sub { color: var(--text-muted); font-size: 15px; }
.badge-up { color: var(--accent2); font-size: 12px; margin-left: 3px; }
.badge-down { color: var(--danger); font-size: 12px; margin-left: 3px; }
.badge-new { background: var(--accent2); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 4px; font-weight: 700; margin-left: 4px; }
.loading-cell { text-align: center; color: var(--text-muted); padding: 40px !important; font-size: 16px; }


/* ── 活跃提交行（最近1小时内有提交）：非常淡的绿色背景 ── */
#rankTable tbody tr.row-active-submit { background: rgba(45, 164, 78, 0.08); }
#rankTable tbody tr.row-active-submit:hover { background: rgba(45, 164, 78, 0.14); }

/* ── 已除名队伍行（暂时不在了）：非常淡的灰色背景且半透明 ── */
#rankTable tbody tr.team-inactive { background: rgba(110, 118, 129, 0.08) !important; opacity: .65; }
#rankTable tbody tr.team-inactive:hover { background: rgba(110, 118, 129, 0.15) !important; opacity: .9; }
#rankTable tbody tr.team-inactive .team-link { color: var(--text-muted); }

/* ── 弹窗遮罩（默认隐藏） ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(31,35,40,.45);
  display: none; align-items: center; justify-content: center;
  z-index: 200;
  padding: 16px;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal-overlay.open .team-modal { animation: modal-pop .18s ease-out; }
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1);   }
}

/* ── 队伍详情弹窗 ── */
.team-modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: min(1300px, 95vw);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  overflow: hidden;
}

/* 弹窗头部 */
.modal-head {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-head-info { flex: 1; min-width: 0; }
.modal-head-info h2 { font-size: 24px; font-weight: 800; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-school { font-size: 14px; color: var(--text-muted); margin-top: 5px; display: block; }
.modal-head-scores {
  display: flex; gap: 20px; align-items: center; flex-shrink: 0;
}
.head-score-item { text-align: center; }
.head-score-label { font-size: 12px; color: var(--text-muted); }
.head-score-value { font-size: 22px; font-weight: 800; color: var(--accent2); }
.head-score-value.rank-val { color: var(--accent); }
.btn-modal-close {
  background: var(--bg3); color: var(--text-muted); font-size: 16px;
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  flex-shrink: 0; align-self: flex-start;
}
.btn-modal-close:hover { background: var(--border); color: var(--text); }

/* Tab */
.modal-tabs {
  display: flex; gap: 8px; padding: 16px 22px 0;
  flex-shrink: 0;
}
.tab-btn {
  background: var(--bg3); color: var(--text-muted); padding: 6px 16px; font-size: 13.5px;
  border: 1px solid var(--border); border-radius: 20px;
}
.tab-btn:hover { border-color: var(--accent); color: var(--accent); }
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }

/* 图表区 */
.modal-chart-wrap {
  padding: 14px 22px 0;
  position: relative;
  flex-shrink: 0;
  height: 380px;
}
.modal-chart-wrap canvas { width: 100% !important; height: 100% !important; }
.chart-empty {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 14px;
}

/* 统计卡片 */
.modal-stats {
  display: flex; gap: 12px; padding: 16px 22px;
  flex-shrink: 0; flex-wrap: wrap;
}

/* 历史记录区（可滚动） */
.modal-history {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden;
  border-top: 1px solid var(--border);
}
.modal-history-title {
  font-size: 13.5px; font-weight: 700; color: var(--text-muted);
  padding: 10px 22px 8px; flex-shrink: 0;
  text-transform: uppercase; letter-spacing: .06em;
}
.modal-history-scroll { flex: 1; overflow-y: auto; }
.history-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.history-table th, .history-table td { padding: 12px 18px; border-bottom: 1px solid var(--border); white-space: nowrap; text-align: left; }
.history-table th { background: var(--bg3); color: var(--text-muted); font-weight: 600; position: sticky; top: 0; z-index: 1; }
.history-table tbody tr:last-child td { border-bottom: none; }
.history-table tbody tr:hover { background: rgba(9,105,218,.05); }
.history-table .score-col { color: var(--accent2); font-weight: 700; }

/* ── 返回按鈕 / 顶栏分隔 ── */
.back-btn {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-muted); font-size: 14px; text-decoration: none; font-weight: 600;
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg3);
}
.back-btn:hover { background: var(--border); color: var(--text); }
.top-divider { color: var(--border); font-size: 18px; margin: 0 4px; }

/* ── 详情页布局 ── */
.main-content.team-page { display: flex; flex-direction: column; gap: 20px; }

.team-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 32px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.team-page-name { font-size: 28px; font-weight: 800; color: var(--accent); }
.team-page-school { font-size: 14px; color: var(--text-muted); margin-top: 5px; }
.team-header-scores { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.hs-item { text-align: center; }
.hs-label { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.hs-value { font-size: 26px; font-weight: 800; }
.hs-value.green { color: var(--accent2); }
.hs-value.blue  { color: var(--accent); }

/* ── 卡片容器 ── */
.card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,.04); overflow: hidden;
}
.card-tabs { display: flex; gap: 8px; padding: 16px 20px 0; flex-wrap: wrap; }
.card-title { font-size: 14px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; padding: 16px 20px 8px; }

/* ── 图表区 ── */
.chart-wrap {
  position: relative; height: 360px; padding: 16px 20px 20px;
}
.chart-wrap canvas { width: 100% !important; height: 100% !important; }
.chart-empty {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 15px;
}

/* ── 统计卡片行 ── */
.stats-row { display: flex; gap: 14px; flex-wrap: wrap; }
/* ── 统一的 stat-card 基础 ── */
.stat-card {
  border: 1px solid var(--border); border-radius: var(--radius); flex: 1;
}
.stat-label { font-size: 13px; color: var(--text-muted); }
.stat-value { font-weight: 800; }

/* modal 内嵌 */
.modal-stats .stat-card {
  background: var(--bg3); padding: 12px 20px; min-width: 130px;
}
.modal-stats .stat-label { margin-bottom: 6px; }
.modal-stats .stat-value { font-size: 20px; }

/* 详情页 stats-row */
.stats-row .stat-card {
  background: var(--bg2); padding: 16px 22px; min-width: 140px;
  box-shadow: 0 4px 20px rgba(0,0,0,.04);
}
.stats-row .stat-label { margin-bottom: 6px; }
.stats-row .stat-value { font-size: 24px; font-weight: 800; }

/* 色值变体 */
.stat-value.up, .stat-value.green { color: var(--accent2); }
.stat-value.down, .stat-value.red  { color: var(--danger); }
.stat-value.neutral { color: var(--accent); }
.stat-value.blue    { color: var(--accent); }

/* table-wrapper 内嵌时去除外层边框 */
.table-wrapper.no-border { border: none; box-shadow: none; border-radius: 0; }

/* ── 滚动条 ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg3); }
::-webkit-scrollbar-thumb { background: #c8d0da; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #adb5bd; }

/* ── 响应式 ── */
@media (max-width: 768px) {
  .main-content { padding: 14px 12px; }
  .top-bar { padding: 0 14px; }
  .subtitle { display: none; }
  .modal-head-scores { display: none; }
  .modal-chart-wrap { height: 180px; }
}
