:root {
  --green-950: #073b2a;
  --green-900: #0b4b35;
  --green-800: #126044;
  --green-700: #177a54;
  --green-600: #209363;
  --green-100: #dcf3e7;
  --green-50: #f1faf5;
  --gold: #c8a45b;
  --ink: #17372d;
  --muted: #647b73;
  --line: #dce8e2;
  --surface: #ffffff;
  --danger: #b33b3b;
  --warning: #9b6a15;
  --shadow: 0 24px 70px rgba(8, 72, 50, 0.13);
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: #edf7f1; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 15%, rgba(32, 147, 99, 0.16), transparent 28rem),
    radial-gradient(circle at 88% 85%, rgba(200, 164, 91, 0.12), transparent 30rem),
    linear-gradient(145deg, #f8fcf9, #e8f5ee);
}

button, input, select { font: inherit; }
a { color: var(--green-700); }

.page-shell { display: flex; flex-direction: column; }
.center-panel { width: min(100% - 32px, 680px); margin: auto; padding: 40px 0; }

.card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(220, 232, 226, 0.9);
  border-radius: 26px;
  box-shadow: var(--shadow);
}

.brand-block { text-align: center; margin-bottom: 28px; }
.brand-logo { width: 88px; height: 88px; object-fit: contain; }
.brand-block h1 { margin: 5px 0 8px; font-size: clamp(26px, 4vw, 34px); }

.eyebrow {
  margin: 8px 0 4px;
  color: var(--green-700);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.muted { color: var(--muted); line-height: 1.75; }
.install-card, .admin-login-card { padding: clamp(28px, 6vw, 52px); }
.admin-login-card { max-width: 500px; margin: auto; }

.form-stack { display: grid; gap: 18px; }
.form-stack label, .credential-form label {
  display: grid;
  gap: 8px;
  color: #284b3e;
  font-size: 14px;
  font-weight: 700;
}

input, select {
  width: 100%;
  border: 1px solid #c9dbd2;
  border-radius: 12px;
  background: #fbfefc;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

input { min-height: 50px; padding: 0 15px; }
select { min-height: 42px; padding: 0 36px 0 12px; }
input:focus, select:focus { border-color: var(--green-600); box-shadow: 0 0 0 4px rgba(32, 147, 99, 0.12); background: #fff; }
label small { color: var(--muted); font-weight: 400; }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 800;
  transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
}
.button:hover { transform: translateY(-1px); }
.button-wide { width: 100%; min-height: 54px; font-size: 16px; }
.button-primary { color: #fff; background: linear-gradient(135deg, var(--green-800), var(--green-600)); box-shadow: 0 10px 24px rgba(23, 122, 84, 0.2); }
.button-primary:hover { box-shadow: 0 13px 30px rgba(23, 122, 84, 0.28); }
.button-secondary { color: var(--green-800); background: var(--green-50); border-color: #bcd9ca; }
.button-warning { color: #80530a; background: #fff8e9; border-color: #ead49c; }
.button-danger { color: #a13333; background: #fff4f3; border-color: #edc5c1; }
.button-small { min-height: 40px; padding: 0 15px; }

.alert { margin: 0 0 22px; padding: 13px 15px; border-radius: 12px; line-height: 1.6; font-size: 14px; }
.alert-error { color: #8e2d2d; background: #fff2f1; border: 1px solid #f1c7c2; }
.alert-success { color: #126044; background: #eaf8f0; border: 1px solid #b9dfca; }
.text-link { display: block; margin-top: 22px; text-align: center; font-size: 14px; }

.query-panel { width: min(100% - 32px, 620px); padding: 34px 0 28px; }
.query-card { overflow: hidden; }
.welcome-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: clamp(25px, 5vw, 36px) clamp(22px, 6vw, 44px);
  color: #fff;
  background:
    linear-gradient(120deg, rgba(7, 59, 42, 0.96), rgba(23, 122, 84, 0.9)),
    radial-gradient(circle at right top, rgba(255,255,255,.18), transparent 40%);
}
.query-brand-logo { flex: none; width: clamp(62px, 13vw, 82px); height: clamp(62px, 13vw, 82px); object-fit: contain; }
.welcome-copy h1 { margin: 0; font-size: clamp(20px, 4.2vw, 28px); line-height: 1.45; }
.query-form { padding: clamp(25px, 6vw, 46px) clamp(24px, 7vw, 54px) clamp(30px, 7vw, 52px); }
.query-card > .alert { margin: 28px 54px 0; }
.closed-state { margin: 44px; padding: 32px; border-radius: 18px; text-align: center; background: var(--green-50); border: 1px solid var(--line); }
.closed-state strong { display: block; margin: 10px 0 5px; font-size: 22px; }
.closed-state p { margin: 0; color: var(--muted); }
.status-dot { display: inline-block; width: 13px; height: 13px; border-radius: 50%; background: #8da49a; box-shadow: 0 0 0 8px rgba(141,164,154,.13); }
.site-footer { margin-top: auto; padding: 10px 20px 28px; color: #6f857c; text-align: center; font-size: 12px; }

.result-page { background: linear-gradient(150deg, #e4f4eb, #fbfaf5); }
.result-card { position: relative; overflow: hidden; padding: clamp(36px, 8vw, 68px) clamp(24px, 7vw, 58px); text-align: center; }
.result-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 8px; background: linear-gradient(90deg, var(--green-800), var(--gold), var(--green-600)); }
.result-logo { width: 100px; height: 100px; object-fit: contain; }
.result-logo-wrap { display: inline-grid; place-items: center; width: 130px; height: 130px; border-radius: 50%; background: var(--green-50); box-shadow: inset 0 0 0 1px #cfe5d9; }
.result-card h1 { margin: 26px 0 0; font-size: clamp(24px, 5vw, 34px); line-height: 1.5; }
.class-result { margin: 30px 0 22px; padding: 26px 18px; border-radius: 20px; background: linear-gradient(140deg, var(--green-950), var(--green-700)); color: #fff; box-shadow: 0 18px 40px rgba(7,59,42,.22); }
.class-result span { display: block; margin-bottom: 8px; color: #cbe8d9; font-size: 18px; font-weight: 700; }
.class-result strong { display: block; font-size: clamp(32px, 8vw, 48px); letter-spacing: .05em; }
.admin-body { background: #f2f7f4; }
.admin-header { position: sticky; z-index: 10; top: 0; display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding: 10px clamp(18px, 4vw, 54px); color: #fff; background: rgba(7, 59, 42, .96); box-shadow: 0 8px 26px rgba(7,59,42,.15); backdrop-filter: blur(12px); }
.admin-brand { display: flex; align-items: center; gap: 12px; }
.admin-brand img { width: 46px; height: 46px; object-fit: contain; }
.admin-brand strong, .admin-brand span { display: block; }
.admin-brand span { margin-top: 3px; color: #bcd9ca; font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 18px; }
.header-actions a, .link-button { padding: 0; color: #e9f7ef; background: none; border: 0; text-decoration: none; cursor: pointer; font-size: 14px; }
.admin-main { width: min(100% - 36px, 1360px); margin: 0 auto; padding: 36px 0 70px; }
.admin-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.admin-title-row h1 { margin: 3px 0 6px; font-size: clamp(26px, 4vw, 38px); }
.admin-title-row .muted { margin: 0; }
.query-switch-status { flex: none; margin-top: 12px; padding: 9px 14px; border-radius: 999px; font-size: 13px; font-weight: 800; }
.query-switch-status.is-open { color: #11613f; background: #dff5e8; }
.query-switch-status.is-closed { color: #6b716e; background: #e7ece9; }
.admin-alert { margin-bottom: 24px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { min-height: 150px; padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 10px 30px rgba(17, 77, 55, .06); }
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 700; }
.stat-card strong { display: block; margin: 14px 0 8px; color: var(--green-900); font-size: 34px; line-height: 1; }
.stat-card .stat-time { font-size: 18px; line-height: 1.2; }
.stat-card small { color: #809188; }

.admin-grid { display: grid; gap: 20px; margin-bottom: 20px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { margin-bottom: 20px; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 10px 30px rgba(17,77,55,.05); }
.admin-grid .panel { margin-bottom: 0; }
.panel-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.panel-heading h2 { margin: 0 0 6px; font-size: 20px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.compact-form { gap: 14px; }
.file-picker { position: relative; padding: 18px; border: 1px dashed #99c2ae; border-radius: 14px; background: var(--green-50); cursor: pointer; }
.file-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-picker span { color: var(--green-700); font-weight: 500; overflow-wrap: anywhere; }
.privacy-note { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.action-stack { display: flex; flex-wrap: wrap; gap: 12px; }
.action-stack form { flex: 1 1 185px; }
.action-stack .button { width: 100%; }

.table-scroll { width: 100%; overflow-x: auto; border: 1px solid #edf2ef; border-radius: 13px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; font-size: 13px; }
th { padding: 13px 15px; color: #547067; background: #f3f8f5; text-align: left; font-size: 12px; }
td { padding: 14px 15px; border-top: 1px solid #edf2ef; color: #365349; }
tbody tr:hover { background: #fbfdfc; }
.empty-cell { padding: 34px; color: #8b9993; text-align: center; }
.class-link { color: var(--green-700); font-weight: 800; text-decoration: none; }
.tag { display: inline-block; min-width: 52px; padding: 4px 8px; border-radius: 999px; color: #68756f; background: #edf1ef; text-align: center; font-size: 11px; font-weight: 800; }
.tag-success { color: #126044; background: #dff4e8; }
.roster-heading { align-items: flex-end; }
.filter-form { display: flex; gap: 9px; align-items: center; }
.filter-form select { width: auto; min-width: 130px; }
.credential-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 12px; align-items: end; }
.credential-form input { min-height: 44px; }

@media (max-width: 980px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-columns { grid-template-columns: 1fr; }
  .credential-form { grid-template-columns: 1fr 1fr; }
  .credential-form .button { min-height: 44px; }
}

@media (max-width: 680px) {
  .center-panel { width: min(100% - 22px, 680px); padding: 22px 0; }
  .query-panel { width: calc(100% - 22px); }
  .welcome-copy { gap: 12px; }
  .card { border-radius: 20px; }
  .query-card > .alert { margin: 22px 22px 0; }
  .closed-state { margin: 24px 20px; padding: 25px 18px; }
  .admin-header { position: static; padding: 10px 14px; }
  .admin-brand span { display: none; }
  .header-actions { gap: 10px; }
  .admin-main { width: calc(100% - 22px); padding-top: 22px; }
  .admin-title-row { display: block; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { min-height: 126px; padding: 17px; }
  .stat-card strong { font-size: 28px; }
  .stat-card .stat-time { font-size: 15px; }
  .panel { padding: 18px; }
  .roster-heading { display: block; }
  .filter-form { display: grid; grid-template-columns: 1fr 1fr; margin-top: 16px; }
  .filter-form select { width: 100%; min-width: 0; }
  .filter-form .button { grid-column: 1 / -1; }
  .credential-form { grid-template-columns: 1fr; }
  .class-result strong { font-size: 36px; }
}

@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: auto; }
  .admin-brand strong { font-size: 14px; }
  .header-actions a { display: none; }
}
