:root {
  --ink: #1f354a;
  --blue: #1f78bd;
  --blue-deep: #155d95;
  --line: #d9e1e8;
  --muted: #687886;
  --paper: #ffffff;
  --sky: #f5f7f9;
  --mint: #2fb798;
  --gold: #efb84b;
  --danger: #f2554b;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--sky);
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.admin-topbar,
.admin-shell {
  width: min(1180px, calc(100% - 48px));
  margin: auto;
}

.admin-topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 74px;
  border-bottom: 1px solid var(--line);
}

.brand img {
  display: block;
  width: 154px;
}

.admin-topbar nav {
  display: flex;
  gap: 20px;
  color: #506f8b;
  font-size: 13px;
  font-weight: 800;
}

.admin-topbar nav a:hover {
  color: var(--blue-deep);
}

#adminState {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.admin-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 0 20px;
}

.section-kicker,
.step-label {
  margin: 0 0 7px;
  color: var(--blue-deep);
  font-size: 12px;
  font-weight: 900;
}

.admin-heading h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.28;
}

.admin-heading p {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.admin-nav a {
  padding: 11px 18px;
  border-bottom: 2px solid transparent;
  color: #566b7a;
  font-size: 13px;
  font-weight: 800;
}

.admin-nav a[aria-current="page"],
.admin-nav a:hover {
  border-bottom-color: var(--blue);
  color: var(--blue-deep);
}

.permission-layout,
.student-admin-panel,
.class-admin-panel,
.student-data-panel {
  scroll-margin-top: 16px;
}

.admin-heading a,
.panel-heading button,
#savePermissions {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--blue);
  border-radius: 5px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 900;
}

.boundary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.boundary-grid article {
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 3px solid #72c2ef;
  border-radius: 7px;
  background: var(--paper);
}

.boundary-grid article:nth-child(2) {
  border-top-color: var(--mint);
}

.boundary-grid article:nth-child(3) {
  border-top-color: var(--gold);
}

.boundary-grid span {
  display: block;
  color: #5e7a94;
  font-size: 12px;
  font-weight: 800;
}

.boundary-grid strong {
  display: block;
  margin-top: 9px;
  font-size: 20px;
}

.boundary-grid p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.permission-layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.teacher-list,
.permission-editor {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
}

.teacher-list {
  align-self: start;
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 60px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  margin: 0;
  font-size: 18px;
}

.panel-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-heading button {
  min-height: 34px;
  border-color: #cfe3f4;
  background: #f5f9fc;
  color: #216da9;
}

.add-teacher-form {
  display: grid;
  gap: 10px;
  padding: 14px 18px 18px;
  border-bottom: 1px solid #e5eef5;
  background: #fbfdff;
}

.step-label {
  margin-bottom: 4px;
}

.field-tip,
.compact-editor p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.add-teacher-form button {
  min-height: 38px;
  border: 1px solid var(--blue);
  border-radius: 5px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
}

#savePermissions {
  min-width: 130px;
}

.teacher-row {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid #eef4f9;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 16px 18px;
  text-align: left;
}

.teacher-row:hover,
.teacher-row.is-active {
  background: #f0f8ff;
}

.teacher-row strong {
  display: block;
  font-size: 15px;
}

.teacher-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.teacher-row em {
  display: inline-flex;
  margin-top: 10px;
  border-radius: 999px;
  background: #edf7f4;
  color: #238b77;
  padding: 5px 9px;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.teacher-row[data-status="disabled"] em {
  background: #fff1ef;
  color: #d64a42;
}

.permission-editor {
  padding-bottom: 18px;
}

.editor-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 18px;
}

.compact-editor {
  grid-template-columns: minmax(180px, 260px) 1fr;
  align-items: end;
}

.field {
  display: grid;
  gap: 8px;
  color: #496783;
  font-size: 12px;
  font-weight: 900;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #d7e5f1;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-size: 14px;
}

.permission-section {
  margin: 0 18px 16px;
  padding: 18px;
  border: 1px solid #e2edf5;
  border-radius: 4px;
  background: #f8fafb;
}

.permission-section h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.check-grid,
.student-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

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

.check-item {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 10px;
  border: 1px solid #dbe8f2;
  border-radius: 4px;
  background: #fff;
  color: #294d6e;
  cursor: pointer;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 800;
}

.check-item input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.student-grid {
  grid-template-columns: repeat(4, 1fr);
}

.release-note {
  margin: 0 18px;
  padding: 18px;
  border: 1px solid #f2dfaa;
  border-radius: 4px;
  background: #f7fafc;
}

.release-note strong {
  color: var(--ink);
  font-size: 14px;
}

.release-note p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.teacher-account-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 18px 16px;
  padding: 14px 18px;
  border: 1px solid #e2edf5;
  border-radius: 4px;
  background: #f8fafb;
}

.teacher-account-tools button,
.student-admin-panel button,
.class-admin-panel button,
.account-row button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid #cfe3f4;
  border-radius: 5px;
  background: #f1f8ff;
  color: #216da9;
  cursor: pointer;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 900;
}

.student-admin-panel,
.class-admin-panel {
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
}

.student-admin-layout,
.class-admin-layout {
  display: grid;
  grid-template-columns: 342px minmax(0, 1fr);
}

.class-admin-layout {
  grid-template-columns: minmax(0, 1fr) 260px 260px;
  gap: 18px;
  padding: 18px;
}

.add-student-form,
.class-form,
.student-account-list-wrap {
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
  padding: 18px;
  border: 1px solid #e2edf5;
  border-radius: 4px;
  background: #f8fafb;
}

.add-student-form {
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  padding: 22px;
}

.student-account-list-wrap {
  border: 0;
  border-radius: 0;
  background: #fff;
  padding: 22px;
}

.student-heading-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.student-heading-actions a,
.account-actions a {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border: 1px solid #cfe3f4;
  border-radius: 5px;
  color: var(--blue-deep);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 800;
}

.student-heading-actions a:hover,
.account-actions a:hover {
  background: #f0f8ff;
}

.student-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f1f4f6;
}

.student-mode label { cursor: pointer; }
.student-mode input { position: absolute; opacity: 0; }
.student-mode span {
  display: flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: #536777;
  font-size: 13px;
  font-weight: 800;
}
.student-mode input:checked + span { background: #fff; color: var(--blue-deep); box-shadow: 0 1px 4px #173a601c; }
.student-mode input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: -2px; }

.english-student-fields { display: grid; gap: 12px; }
.english-student-fields[hidden] { display: none; }
.student-mode-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.add-student-form h3,
.class-form h3,
.student-account-list-wrap h3 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
}

.student-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.student-route-checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin: 0;
  border: 1px solid #dbe8f2;
  border-radius: 6px;
  padding: 12px;
}

.student-route-checks legend {
  color: #496783;
  font-size: 12px;
  font-weight: 900;
}

.student-route-checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #294d6e;
  font-size: 13px;
  font-weight: 800;
}

.student-route-checks input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.add-student-form button,
.class-form button {
  min-height: 40px;
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.student-account-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.student-list-heading span { color: var(--muted); font-size: 13px; font-weight: 500; }
.student-list-filters { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 10px; margin-bottom: 4px; }
.student-list-filters .field { gap: 5px; }
.student-list-filters input,
.student-list-filters select { min-height: 36px; }

.account-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.account-actions button,
.account-actions a { white-space: nowrap; }

.account-actions .danger-link { background: #fff; }

.account-actions a { background: #fff; }

.account-row .account-identity { min-width: 0; }

.account-row {
  display: grid;
  grid-template-columns: 38px minmax(140px, 1fr) 60px;
  gap: 12px;
  align-items: center;
  min-height: 72px;
  border-bottom: 1px solid #e8eef2;
  background: #fff;
  padding: 12px 0;
}

.account-row .account-actions { grid-column: 2 / 4; justify-content: flex-start; }
[hidden] { display: none !important; }
.checkin-access-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 20px; margin-bottom: 40px; align-items: start; }
.checkin-access-layout .permission-editor { border: 1px solid var(--line); border-radius: 4px; background: white; min-width: 0; }
.access-search { display: grid; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line); }
#accessStudents { max-height: 660px; overflow: auto; }
.access-form { padding: 22px; display: grid; gap: 22px; }
.access-toggle { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; }
.access-toggle input { width: 20px; height: 20px; accent-color: var(--blue); }
.access-content h3 { margin: 0; font-size: 16px; }
.access-content p { color: var(--muted); font-size: 13px; }
.access-content ol { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; list-style: none; padding: 0; margin: 0; }
.access-content li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; overflow-wrap: anywhere; }
.access-save { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.access-save button { background: var(--blue); color: white; border: 0; border-radius: 4px; padding: 12px 18px; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
#accessSaved { color: #23735e; line-height: 1.6; font-size: 13px; }
.access-error { color: #a32c29; background: #fff1ef; padding: 14px; border-left: 3px solid #d64a42; }
@media (max-width: 800px) { .checkin-access-layout { grid-template-columns: 1fr; } #accessStudents { max-height: 260px; } }
@media (max-width: 480px) { .access-content ol { grid-template-columns: 1fr; } .admin-nav a { padding: 11px 12px; } }

.account-avatar {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #eaf7f4;
  color: #207968;
  font-weight: 900;
}

.account-row div {
  min-width: 0;
}

.account-row strong,
.account-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-row strong {
  font-size: 14px;
}

.account-row small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  justify-self: start;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.status-pill.is-active {
  background: #edf7f4;
  color: #238b77;
}

.status-pill.is-disabled {
  background: #fff1ef;
  color: #d64a42;
}

button.danger-link,
.danger-link {
  border-color: #ffd5d0;
  background: #fff5f3;
  color: #d64a42;
}

.class-list {
  display: grid;
  gap: 10px;
  align-content: start;
}

.class-card {
  border: 1px solid #e2edf5;
  border-radius: 4px;
  background: #f8fafb;
  padding: 14px 16px;
}

.class-card strong,
.class-card span {
  display: block;
}

.class-card strong {
  font-size: 15px;
}

.class-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.class-card p {
  margin: 10px 0 0;
  color: #3a5b78;
  font-size: 13px;
  line-height: 1.6;
}

.empty-inline {
  margin: 0;
  padding: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.student-data-panel {
  margin-bottom: 48px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
}

.student-data-head,
.student-data-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.45fr) minmax(100px, 1fr) minmax(76px, .6fr) minmax(150px, 1fr) minmax(60px, .45fr) minmax(60px, .45fr);
  gap: 14px;
  align-items: center;
  padding: 13px 18px;
}

.student-data-head {
  border-bottom: 1px solid var(--line);
  background: #f6fbff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.student-data-row {
  border-bottom: 1px solid #edf4f8;
  color: #31516e;
  font-size: 13px;
}

.student-data-row:last-child { border-bottom: 0; }

.student-data-row strong { color: var(--ink); }

.student-data-row div { min-width: 0; }

.student-data-row div strong,
.student-data-row div span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.student-data-row div span { margin-top: 5px; color: var(--muted); font-size: 12px; }

.student-data-empty { margin: 0; padding: 24px 18px; color: var(--muted); font-size: 13px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 18px);
  padding: 11px 16px;
  border-radius: 6px;
  background: #173a60;
  color: #fff;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 980px) {
  .boundary-grid,
  .permission-layout,
  .editor-form,
  .two-col,
  .student-admin-layout,
  .class-admin-layout {
    grid-template-columns: 1fr;
  }

  .add-student-form { border-right: 0; border-bottom: 1px solid var(--line); }
  .account-row { grid-template-columns: 38px minmax(0, 1fr) 60px; }
  .account-actions { grid-column: 2 / 4; justify-content: flex-start; }

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

  .student-data-head { display: none; }

  .student-data-row {
    grid-template-columns: 1.4fr 1fr 64px;
    gap: 10px;
  }

  .student-data-row > :nth-child(4),
  .student-data-row > :nth-child(5) { display: none; }
}

@media (max-width: 680px) {
  .admin-topbar,
  .admin-shell {
    width: calc(100% - 28px);
  }

  .admin-topbar nav {
    display: none;
  }

  .brand img {
    width: 132px;
  }

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

  .admin-heading h1 {
    font-size: 25px;
  }

  .check-grid,
  .compact,
  .student-grid,
  .student-form-grid,
  .student-route-checks {
    grid-template-columns: 1fr;
  }

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

  .student-admin-panel > .panel-heading { align-items: flex-start; flex-direction: column; }
  .student-heading-actions { width: 100%; justify-content: space-between; }
  .student-list-filters { grid-template-columns: 1fr; }
  .student-admin-panel button,
  .account-actions a { font-size: 12px; }
}
