/* ===== 基础变量 ===== */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --border: #e6e8ef;
  --text: #1c1f2a;
  --text-2: #5b6173;
  --text-3: #8c93a6;
  --primary: #2d6cdf;
  --primary-2: #4a86eb;
  --primary-soft: #e8efff;
  --accent: #e64545;
  --success: #28a745;
  --warning: #f59e0b;
  --shadow: 0 1px 2px rgba(20, 30, 60, .04), 0 4px 14px rgba(20, 30, 60, .06);
  --radius: 12px;
  --radius-sm: 8px;
  --side-w: 240px;
  --topbar-h: 72px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
}

/* ===== 侧栏 ===== */
.sidebar {
  width: var(--side-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}
.brand-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2d6cdf 0%, #5b8def 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
}
.brand-title { font-size: 15px; font-weight: 600; }
.brand-sub { font-size: 11px; color: var(--text-3); }

.nav { padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: none; border: 0; cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text-2);
  text-align: left;
  font-family: inherit;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-ico { width: 18px; text-align: center; opacity: .8; }

.legend {
  margin: auto 16px 16px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.legend-title { font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.legend-bar {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-3);
}
.legend-low, .legend-high { white-space: nowrap; }
.legend-gradient {
  flex: 1; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, #d9e8ff 0%, #ffe1e1 100%);
}
.legend-tip { font-size: 11px; color: var(--text-3); margin-top: 6px; }

/* ===== 主区 ===== */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 600; }
.topbar-sub { font-size: 12px; color: var(--text-3); margin: 2px 0 0; }

.year-switch {
  display: inline-flex;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid var(--border);
}
.year-btn {
  padding: 6px 16px;
  background: none; border: 0; cursor: pointer;
  font-size: 13px; color: var(--text-2);
  border-radius: 6px;
  font-family: inherit;
  font-weight: 500;
  transition: all .15s;
}
.year-btn:hover { color: var(--text); }
.year-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* ===== 视图 ===== */
.view { display: none; padding: 24px 28px 40px; }
.view.active { display: block; }

/* ===== 卡片 ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.card-head h3 { font-size: 15px; margin: 0; font-weight: 600; }
.card-tip { font-size: 11px; color: var(--text-3); }

.cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
@media (max-width: 1280px) { .cards { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 720px)  { .cards { grid-template-columns: repeat(2, 1fr); } }

.card.stat { padding: 16px 18px; }
.stat-label { font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-foot { font-size: 11px; color: var(--text-3); margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }

/* ===== 工具条 ===== */
.toolbar {
  display: flex; gap: 12px; align-items: center;
  background: var(--surface);
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-box { flex: 1; min-width: 240px; }
.search-box input {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface-2);
  outline: none;
  transition: border-color .15s, background .15s;
}
.search-box input:focus { border-color: var(--primary); background: #fff; }

.sort-box, .filter-box { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.sort-box select, .filter-box select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
}

.stat-line { font-size: 12px; color: var(--text-3); margin-left: auto; }

.table-info {
  font-size: 13px; color: var(--text-2);
  padding: 0 4px 10px;
}
.table-info b { color: var(--text); font-weight: 600; }

/* ===== 图表 ===== */
.chart { min-height: 320px; }
.chart-card .chart { min-height: 360px; }
.chart-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 12px; }
.chart-label { width: 80px; color: var(--text-2); flex-shrink: 0; }
.chart-bar-wrap { flex: 1; height: 18px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.chart-bar { height: 100%; border-radius: 4px; transition: width .3s; }
.chart-value { width: 60px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.chart-delta { font-size: 11px; padding: 1px 6px; border-radius: 4px; font-weight: 600; }
.delta-up   { background: #fff0f0; color: #d33; }
.delta-down { background: #f0f9f0; color: #28a745; }
.delta-flat { background: #f0f0f5; color: #888; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-2);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky; top: 0;
  cursor: pointer;
  user-select: none;
}
.data-table th:hover { background: #f0f3f8; }
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.data-table tr:hover td { background: var(--surface-2); }
.data-table.compact th, .data-table.compact td { padding: 7px 10px; font-size: 12px; }
.data-table .num { text-align: right; }

.score-cell { display: inline-block; min-width: 50px; padding: 2px 8px; border-radius: 4px; font-weight: 600; }

/* ===== 专业组网格 ===== */
.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.group-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  box-shadow: var(--shadow);
}
.group-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary-2);
  box-shadow: 0 6px 20px rgba(45, 108, 223, .12);
}
.group-name {
  font-size: 16px; font-weight: 600;
  margin-bottom: 4px;
  display: flex; align-items: center; justify-content: space-between;
}
.group-tag {
  font-size: 10px; padding: 1px 6px; border-radius: 4px;
  background: var(--primary-soft); color: var(--primary);
}
.group-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; margin-top: 12px;
  font-size: 12px; color: var(--text-2);
}
.group-stat-row { display: flex; justify-content: space-between; }
.group-stat-row b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.group-trend {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px;
}

/* ===== 院校网格 ===== */
.school-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}
.school-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.school-name {
  font-size: 15px; font-weight: 600;
  margin-bottom: 8px;
  display: flex; align-items: center; gap: 8px;
}
.school-id {
  font-size: 11px; color: var(--text-3);
  font-family: var(--mono);
  background: var(--bg);
  padding: 1px 6px; border-radius: 4px;
}
.school-meta {
  display: flex; gap: 14px;
  font-size: 12px; color: var(--text-2);
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}
.school-major-list {
  display: flex; flex-direction: column; gap: 5px;
  max-height: 220px; overflow-y: auto;
}
.major-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; padding: 4px 0;
}
.major-row .major-name { color: var(--text); }
.major-row .major-score { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ===== 对比控件 ===== */
.compare-controls {
  display: flex; gap: 20px; flex-wrap: wrap;
  align-items: center;
}
.control-group { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.control-group.hidden { display: none; }
.control-group label { color: var(--text-2); }
.control-group select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
}
.seg {
  display: inline-flex; background: var(--bg);
  border-radius: 6px; padding: 3px;
  border: 1px solid var(--border);
}
.seg-btn {
  padding: 5px 12px;
  background: none; border: 0; cursor: pointer;
  font-size: 12px; color: var(--text-2);
  border-radius: 4px; font-family: inherit;
  transition: all .15s;
}
.seg-btn.active { background: #fff; color: var(--primary); box-shadow: var(--shadow); }

/* ===== 分页 ===== */
.pagination {
  display: flex; gap: 4px; justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}
.pg-btn {
  min-width: 32px; height: 32px;
  padding: 0 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px; color: var(--text-2);
  font-family: inherit;
}
.pg-btn:hover { border-color: var(--primary); color: var(--primary); }
.pg-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pg-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===== 移动端 ===== */
@media (max-width: 720px) {
  body { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto;
    position: relative;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .legend { display: none; }
  .nav { flex-direction: row; overflow-x: auto; padding: 8px; }
  .nav-item { white-space: nowrap; }
  .topbar { padding: 0 16px; height: auto; flex-direction: column; align-items: flex-start; padding: 12px 16px; gap: 10px; }
  .view { padding: 16px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5e0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b0b6c5; }
