:root {
  color-scheme: light;
  --paper: #f6f3ec;
  --ink: #1c2522;
  --muted: #66716c;
  --line: #d8d1c4;
  --field: #fffdf8;
  --accent: #b9312b;
  --accent-dark: #7b211d;
  --green: #23695b;
  --gold: #b78327;
  --shadow: 0 18px 45px rgba(64, 45, 29, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  background:
    linear-gradient(rgba(35, 105, 91, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(185, 49, 43, 0.07) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.top-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 24px;
  padding: 30px 0 22px;
  border-bottom: 3px double var(--ink);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-family: "SimSun", "STSong", serif;
  font-size: clamp(34px, 6vw, 76px);
  line-height: 0.98;
  letter-spacing: 0;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  border: 1px solid var(--ink);
  background: rgba(255, 253, 248, 0.82);
  box-shadow: var(--shadow);
}

.stats-strip div {
  min-width: 0;
  padding: 14px 16px;
  border-left: 1px solid var(--line);
}

.stats-strip div:first-child {
  border-left: 0;
}

.stats-strip span {
  display: block;
  color: var(--accent);
  font-size: 28px;
  font-weight: 900;
}

.stats-strip small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.search-panel {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--ink);
  background: rgba(255, 253, 248, 0.9);
  box-shadow: var(--shadow);
}

.query-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--field);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(35, 105, 91, 0.16);
}

.check-filter {
  align-content: end;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--field);
}

.check-line input {
  width: 16px;
  min-height: 16px;
  margin: 0;
}

.search-box input {
  min-height: 50px;
  font-size: 18px;
}

#search-button {
  align-self: end;
  min-height: 50px;
  border: 0;
  border-radius: 4px;
  color: #fffaf1;
  background: var(--accent);
  font-weight: 900;
}

#search-button:hover {
  background: var(--accent-dark);
}

.filters {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.result-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0 10px;
  color: var(--muted);
}

#result-summary {
  display: block;
  color: var(--ink);
  font-size: 16px;
}

#database-path {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  word-break: break-all;
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.pager button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  color: var(--ink);
  background: var(--field);
  font-size: 24px;
  line-height: 1;
}

.pager button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--ink);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: var(--shadow);
}

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

thead {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #fffaf1;
  background: var(--green);
}

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

th {
  font-size: 13px;
  letter-spacing: 0;
}

td {
  font-size: 14px;
}

tbody tr:hover {
  background: rgba(183, 131, 39, 0.1);
}

.school-code,
.subline {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.score {
  color: var(--accent);
  font-size: 18px;
  font-weight: 900;
}

.rank {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.subject-badge {
  display: inline-block;
  border: 1px solid rgba(35, 105, 91, 0.38);
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--green);
  background: rgba(35, 105, 91, 0.08);
  font-size: 12px;
  font-weight: 800;
}

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

@media (max-width: 1100px) {
  .top-band,
  .query-row {
    grid-template-columns: 1fr;
  }

  .stats-strip,
  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .top-band {
    gap: 16px;
    padding-top: 18px;
  }

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

  .result-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .pager {
    justify-content: space-between;
  }
}
