:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --text: #1d2329;
  --muted: #66717e;
  --line: #dfe4ea;
  --panel: #ffffff;
  --accent: #176b87;
  --accent-weak: #e5f2f5;
  --warm: #a8551d;
  --good: #176f4d;
  --bad: #a33a3a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 15px;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar,
.controls,
.stats,
.tableWrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

p {
  margin: 8px 0 0;
  color: var(--muted);
}

.rankBadge {
  min-width: 180px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  text-align: right;
}

.rankBadge span {
  display: block;
  color: var(--muted);
}

.rankBadge strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
  color: var(--accent);
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 96px auto;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 14px 16px;
}

.scoreControl {
  display: grid;
  grid-template-columns: 42px minmax(160px, 1fr);
  align-items: center;
  gap: 12px;
  color: var(--muted);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.scoreInput {
  width: 96px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

.segments {
  display: inline-grid;
  grid-template-columns: repeat(4, 64px);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f4f6;
}

.segment {
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.segment.active {
  background: var(--panel);
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(29, 35, 41, 0.12);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-top: 14px;
  overflow: hidden;
}

.stats div {
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.stats div:last-child {
  border-right: 0;
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stats strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.tableWrap {
  margin-top: 14px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  z-index: 1;
}

td.schoolName {
  font-weight: 650;
}

.sub {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.rank {
  color: var(--accent);
  font-weight: 650;
}

.margin {
  font-weight: 700;
}

.margin.good {
  color: var(--good);
}

.margin.bad {
  color: var(--bad);
}

.empty {
  padding: 26px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .rankBadge {
    width: 100%;
    text-align: left;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .scoreControl {
    grid-template-columns: 38px 1fr;
  }

  .segments {
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .stats div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}
