*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html, body {
  background: var(--white);
  color: var(--gray-900);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: var(--font); cursor: pointer; border: none; }
a { color: inherit; text-decoration: none; }
input, select, textarea { font-family: var(--font); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

.app-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  line-height: 0;
}
.app-icon svg { width: 100%; height: 100%; display: block; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  line-height: 1;
  white-space: nowrap;
  transition: .15s;
}
.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-700); }
.btn-primary:disabled { background: var(--gray-200); color: var(--gray-500); cursor: not-allowed; }
.btn-white { background: #fff; color: var(--gray-900); border: 1px solid var(--gray-200); }
.btn-white:hover { background: var(--gray-50); }
.btn-light { background: var(--blue-50); color: var(--blue-700); }
.btn-light:hover { background: var(--blue-100); }
.btn-ghost { background: transparent; color: var(--gray-500); }
.btn-ghost:hover { color: var(--gray-900); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.05); }
.btn-danger { background: #FEECEC; color: var(--danger); }
.btn-danger:hover { background: #FDDDDD; }
.btn-sm { padding: 9px 16px; font-size: 14px; }
.btn-block { width: 100%; justify-content: center; padding-top: 14px; padding-bottom: 14px; }

.admin-app .btn { font-weight: 700; padding: 10px 16px; font-size: 13.5px; }
.admin-app .btn-sm { padding: 8px 13px; font-size: 12.5px; }
.admin-app .btn-block { padding: 13px; }
.admin-app .btn-white:hover { background: #fff; border-color: var(--blue-500); color: var(--blue-700); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  letter-spacing: .01em;
}
.badge-blue { background: var(--blue-50); color: var(--blue-700); }
.badge-gray { background: var(--gray-50); color: var(--gray-500); }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-amber { background: var(--warning-bg); color: #B45309; }

.pill { font-size: 11.5px; font-weight: 800; padding: 4px 10px; border-radius: 999px; display: inline-block; }
.pill.active { background: #ECFDF3; color: #05603A; }
.pill.disabled { background: var(--gray-100); color: var(--gray-500); }
.pill.role-admin { background: var(--blue-50); color: var(--blue-700); }
.pill.role-teacher { background: var(--warning-bg); color: #B45309; }
.pill.role-student { background: var(--gray-100); color: var(--gray-500); }

.field { display: flex; flex-direction: column; margin-bottom: 15px; }
.field.full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 7px; color: var(--gray-900); }
.field label .req { color: var(--danger); }
.field label .opt { color: var(--gray-500); font-weight: 400; }
.field input,
.field select {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  font-size: 15px;
  background: var(--gray-50);
  color: var(--gray-900);
}
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--blue-500);
  background: #fff;
  box-shadow: 0 0 0 3px var(--blue-50);
}
.field input.invalid { border-color: var(--danger); background: var(--danger-bg); }
.field .err { font-size: 12px; color: var(--danger); margin-top: 5px; font-weight: 600; display: none; }
.field.show-err .err { display: block; }

.field .err-shown { font-size: 12px; color: var(--danger); margin-top: 5px; font-weight: 600; }
.field .code-input { text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }

.admin-app .field input,
.admin-app .field select { padding: 12px 14px; border-radius: 11px; font-size: 14.5px; }

.err-line { color: var(--danger); font-size: 13px; font-weight: 600; margin-bottom: 12px; min-height: 18px; }

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: linear-gradient(135deg, #2563EB, #3B7BF6);
  color: #fff;
}
.brand-mark--round { border-radius: 50%; box-shadow: 0 10px 24px rgba(37, 99, 235, .32); }
.brand-mark--square { border-radius: 13px; }

.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #EEF4FF 0%, #F5F7FA 45%, #E6EEFF 100%);
}
.login-view .login-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 22px;
  box-shadow: 0 14px 44px rgba(16, 24, 40, .1);
  padding: 38px;
  width: 100%;
  max-width: 400px;
}
.login-view .login-card.wide { max-width: 470px; }
.login-view .login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-view .brand-name { font-weight: 800; font-size: 18px; line-height: 1.1; }
.login-view .brand-name span {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gray-500);
  margin-top: 3px;
}
.login-view h2 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.login-view .sub { font-size: 13.5px; color: var(--gray-500); margin-bottom: 22px; }
.login-view .field input { padding: 12px 14px; border-radius: 11px; font-size: 14.5px; }
.login-view .btn-block { padding: 13px; font-weight: 700; }
.login-view .login-hint {
  font-size: 12px;
  color: var(--gray-500);
  text-align: center;
  margin-top: 16px;
  line-height: 1.5;
}
.login-view .login-hint a { color: var(--blue-700); font-weight: 700; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .field { margin-bottom: 0; }
.pass-field { margin-top: 15px; }
@media (max-width: 520px) {
  .form-grid { grid-template-columns: 1fr; }
  .login-view .login-card { padding: 28px 22px; }
}

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(2px);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 18px;
  max-width: 420px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.modal.modal-lg { max-width: 560px; border-radius: 20px; padding: 26px; }
.modal.modal-center { text-align: center; }
.modal .m-ico {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--warning-bg); color: var(--warning);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 16px;
}
.modal h3 { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.modal .m-text { font-size: 14.5px; color: var(--gray-500); line-height: 1.6; margin-bottom: 22px; }
.modal .m-actions { display: flex; gap: 11px; justify-content: center; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; text-align: left; }
.modal-head h3 { font-size: 20px; font-weight: 800; margin: 0; }
.modal-head .m-sub { font-size: 13px; color: var(--gray-500); margin-top: 2px; }
.x-btn {
  background: var(--gray-50); border-radius: 9px; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center; color: var(--gray-500); flex: none;
}
.x-btn:hover { background: var(--gray-100); }
.m-actions-end { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

.table-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }
.table-card table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table-card thead th {
  background: var(--gray-50);
  text-align: left;
  font-weight: 800;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-500);
  padding: 13px 16px;
  white-space: nowrap;
  border-bottom: 1px solid var(--gray-200);
}
.table-card tbody td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.table-card tbody tr:last-child td { border-bottom: none; }
.table-card tbody tr:hover { background: var(--blue-50); }
.table-empty { text-align: center; padding: 26px; color: var(--gray-500); }

.p-name { font-weight: 700; }
.p-sub { font-size: 12px; color: var(--gray-500); }
.att { display: inline-flex; flex-direction: column; gap: 2px; }
.att .sc { font-weight: 800; font-size: 15px; }
.att .meta { font-size: 11.5px; color: var(--gray-500); }
.sc.g { color: var(--success); }
.sc.y { color: var(--warning); }
.sc.r { color: var(--danger); }
.att-empty { color: var(--gray-200); font-weight: 800; font-size: 15px; }
.best-badge { background: var(--blue-50); color: var(--blue-700); font-weight: 800; font-size: 13px; padding: 5px 11px; border-radius: 999px; }
.tok-code {
  font-family: var(--font-mono);
  font-weight: 800; font-size: 14px; letter-spacing: .03em;
  background: var(--gray-50); border: 1px solid var(--gray-200);
  padding: 4px 10px; border-radius: 8px; display: inline-block;
}
.use-badge { font-size: 12.5px; font-weight: 700; }
.cell-muted { color: var(--gray-500); font-size: 12.5px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.icon-btn {
  background: var(--gray-50); border: 1px solid var(--gray-200); color: var(--gray-900);
  border-radius: 9px; padding: 6px 9px; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 5px;
}
.icon-btn:hover { border-color: var(--blue-500); color: var(--blue-700); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

.rich p { margin-bottom: 13px; }
.rich p:last-child { margin-bottom: 0; }
.rich b { font-weight: 700; }

.gap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 24px;
  padding: 0 8px;
  margin: 0 3px;
  border-radius: 7px;
  background: var(--gray-200);
  color: var(--gray-900);
  font-weight: 800;
  font-size: 13px;
  vertical-align: middle;
}
.gap-active {
  background: var(--blue-600);
  color: #fff;
  box-shadow: 0 0 0 3px var(--blue-100);
  animation: gapPulse 1.5s ease-in-out infinite;
  scroll-margin: 120px;
}
@keyframes gapPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--blue-100); }
  50% { box-shadow: 0 0 0 7px rgba(37, 99, 235, .28); }
}

.pv-line em {
  font-style: normal;
  font-weight: 700;
  color: var(--blue-700);
  background: var(--blue-50);
  padding: 1px 6px;
  border-radius: 6px;
}

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast-stack { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--gray-900); color: #fff;
  padding: 11px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.toast-fade-enter, .toast-fade-leave-to { opacity: 0; transform: translateY(8px); }
.toast-fade-enter-active, .toast-fade-leave-active { transition: .2s ease; }


@media (max-width: 560px) {
  .modal { padding: 22px 18px; border-radius: 16px; }
  .modal.modal-lg { padding: 20px 18px; }
  .modal h3, .modal-head h3 { font-size: 18px; }
  .modal .m-actions, .m-actions-end { flex-direction: column-reverse; }
  .modal .m-actions .btn, .m-actions-end .btn { width: 100%; justify-content: center; }
  .login-view { padding: 16px; }
  .login-view .login-card { padding: 26px 20px; border-radius: 18px; }
  .btn { padding: 11px 18px; font-size: 14.5px; }
  .table-card thead th, .table-card tbody td { padding: 11px 12px; }
}
