:root {
  --bg: #eef1f5;
  --panel: #ffffff;
  --ink: #1d2b3a;
  --muted: #67788c;
  --line: #dce3ec;
  --blue: #173f6e;
  --blue-soft: #e8eef6;
  --red: #b23a48;
  --red-soft: #f9ecee;
  --teal: #0f6f6b;
  --teal-soft: #e7f2f1;
  --radius: 8px;
  --shadow: 0 10px 30px rgba(23, 63, 110, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 36px 20px 56px;
}

.query-card {
  max-width: 520px;
  margin: 6vh auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 32px 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: var(--radius);
  background: var(--blue);
  color: #ffffff;
  font-size: 20px;
  font-weight: 700;
}

.brand h1 {
  margin: 0;
  font-size: 21px;
  line-height: 1.35;
}

.scope {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: #3a4a5d;
}

.field input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  color: var(--ink);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 63, 110, 0.12);
  background: #ffffff;
}

.primary {
  width: 100%;
  height: 46px;
  margin-top: 6px;
  border: 0;
  border-radius: var(--radius);
  background: var(--blue);
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

.primary:hover {
  background: #1e4f88;
}

.primary:active {
  transform: translateY(1px);
}

.primary:disabled {
  background: #8ba1ba;
  cursor: default;
}

.error {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
  line-height: 1.5;
}

#resultView {
  display: block;
}

#resultView[hidden] {
  display: none;
}

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 4px 2px 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
}

.result-head h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.25;
}

.res-id {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.res-class {
  max-width: 260px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: #3a4a5d;
  font-size: 14px;
  font-weight: 600;
  text-align: right;
  line-height: 1.5;
}

.rank-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.rank-card {
  display: grid;
  gap: 6px;
  min-height: 118px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--blue);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(23, 63, 110, 0.05);
}

.rank-card.accent {
  border-top-color: var(--red);
}

.rank-label {
  color: var(--muted);
  font-size: 13px;
}

.rank-card strong {
  font-size: 30px;
  line-height: 1.15;
  color: var(--blue);
}

.rank-card.accent strong {
  color: var(--red);
}

.rank-total {
  color: var(--muted);
  font-size: 12px;
}

.avg-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.avg-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.avg-item span {
  color: var(--muted);
  font-size: 12px;
}

.avg-item strong {
  font-size: 22px;
  color: var(--ink);
}

.avg-item.highlight {
  background: var(--teal-soft);
  border-color: #bfdcd8;
}

.avg-item.highlight strong {
  color: var(--teal);
}

.course-block {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.course-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px 13px;
  border-bottom: 1px solid var(--line);
}

.course-head h3 {
  margin: 0;
  font-size: 15px;
}

.course-note {
  color: var(--muted);
  font-size: 12px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 11px 18px;
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f6f8fb;
  color: #54657a;
  font-size: 12px;
  font-weight: 600;
}

td {
  border-top: 1px solid #edf1f6;
}

tbody tr:nth-child(even) td {
  background: #fafbfd;
}

td.score,
th.score,
td.credit,
th.credit {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.empty-row td {
  color: var(--muted);
  text-align: center;
  white-space: normal;
}

.back {
  display: block;
  margin: 18px auto 0;
  padding: 9px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.back:hover {
  background: var(--blue-soft);
}

.source-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 760px) {
  .shell {
    padding: 18px 14px 40px;
  }

  .query-card {
    margin-top: 4vh;
    padding: 24px 20px 22px;
  }

  .rank-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .avg-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .avg-item {
    padding: 12px;
  }

  .avg-item strong {
    font-size: 18px;
  }

  .result-head {
    flex-direction: column;
  }

  .res-class {
    max-width: none;
    width: 100%;
    text-align: left;
  }

  th,
  td {
    padding: 10px 14px;
  }
}

@media (max-width: 420px) {
  .rank-card {
    min-height: 104px;
    padding: 13px;
  }

  .rank-card strong {
    font-size: 26px;
  }

  .brand h1 {
    font-size: 18px;
  }
}
