:root {
  color-scheme: light;
  --bg: #f4f9fd;
  --panel: #ffffff;
  --ink: #17283b;
  --muted: #627386;
  --line: #d8e7f2;
  --line-strong: #b8cfdf;
  --primary: #2f78a8;
  --primary-soft: #e5f3fb;
  --coral: #d45f47;
  --coral-soft: #fde8e1;
  --gold: #a66c00;
  --gold-soft: #fff3ce;
  --indigo: #2f78a8;
  --indigo-soft: #e5f3fb;
  --good: #236f9f;
  --danger: #b42318;
  --shadow: 0 12px 30px rgba(32, 41, 59, 0.1);
  --radius: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bottom-nav-height: 72px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
textarea {
  font-size: 16px;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.icon-sprite {
  display: none;
}

.app-shell {
  min-height: 100%;
}

.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 14px calc(18px + var(--safe-bottom));
  background: var(--bg);
}

.auth-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.auth-brand {
  margin-bottom: 14px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  background: #e8f2fa;
}

.auth-form {
  display: grid;
  gap: 11px;
}

.auth-form label {
  color: var(--muted);
  font-size: 12px;
}

.auth-form input {
  width: 100%;
  margin-top: 5px;
}

.auth-submit {
  width: 100%;
  margin-top: 2px;
}

.auth-error {
  margin-top: 10px;
  border-radius: var(--radius);
  background: var(--coral-soft);
  color: var(--danger);
  padding: 9px 10px;
  font-size: 13px;
}

.student-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
}

.chat-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 14px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 249, 253, 0.96);
  backdrop-filter: blur(14px);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.profile-header-row {
  display: block;
}

.title-group {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 12px;
  font-size: 18px;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.identity-select {
  min-width: 104px;
  max-width: 42vw;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
}

.student-name {
  min-width: 0;
  max-width: 44vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-panel {
  min-width: 0;
  width: 100%;
  min-height: 118px;
  display: grid;
  grid-template-columns: clamp(70px, 18vw, 88px) minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  border: 1px solid rgba(215, 231, 242, 0.78);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 28px rgba(32, 67, 94, 0.08);
  padding: 16px;
}

.account-copy {
  min-width: 0;
  display: grid;
  justify-items: start;
  gap: 8px;
}

.account-name-button {
  max-width: 100%;
  overflow: hidden;
  border-radius: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  font-size: clamp(20px, 4.8vw, 24px);
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-name-button:focus-visible,
.account-name-button:hover {
  color: var(--primary);
  outline: none;
}

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

.account-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.account-side {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.account-badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid #a9d2ea;
  border-radius: 8px;
  padding: 0 9px;
  color: #2378b4;
  background: #f1f8fe;
  font-size: 13px;
  font-weight: 700;
}

.account-copy .account-badge {
  color: #2378b4;
  font-size: 13px;
}

.account-badge .icon {
  width: 14px;
  height: 14px;
}

.class-badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #c9dfed;
  border-radius: 8px;
  padding: 0 9px;
  color: #426278;
  background: #f7fbfe;
  font-size: 13px;
  font-weight: 700;
}

.account-logout {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  gap: 7px;
  border-radius: 0;
  padding: 0;
  color: #5f6f80;
  background: transparent;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}

.account-logout:focus-visible,
.account-logout:hover {
  color: var(--primary);
  outline: none;
}

.account-logout .icon {
  width: 19px;
  height: 19px;
  stroke-width: 2.2;
}

.account-password-link {
  min-height: 28px;
  padding: 0;
  color: var(--primary);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.account-password-link:focus-visible,
.account-password-link:hover {
  color: #145f92;
  outline: none;
}

.avatar-button {
  width: clamp(70px, 18vw, 88px);
  height: clamp(70px, 18vw, 88px);
  flex: 0 0 clamp(70px, 18vw, 88px);
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 4px solid #d9edf8;
  border-radius: 50%;
  color: var(--primary);
  background: radial-gradient(circle at 35% 30%, #f8fcff 0, #e2f1fb 62%, #cfe8f6 100%);
  box-shadow: 0 8px 18px rgba(47, 120, 168, 0.12);
}

.avatar-button img,
.message-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.avatar-button img {
  transform: scale(1.36);
  transform-origin: center;
}

.message-avatar img {
  transform: scale(1.14);
  transform-origin: center;
}

.avatar-button span {
  font-size: 30px;
  font-weight: 800;
}

.avatar-input {
  display: none;
}

.avatar-crop-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: end center;
  padding: 18px 14px calc(18px + var(--safe-bottom));
  background: rgba(18, 34, 50, 0.42);
}

.avatar-crop-sheet {
  width: min(380px, 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
  box-shadow: 0 18px 46px rgba(22, 38, 54, 0.24);
  padding: 16px;
}

.avatar-crop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.avatar-crop-title {
  font-size: 17px;
  font-weight: 800;
}

.avatar-crop-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--muted);
  background: #edf5fb;
  font-size: 22px;
  line-height: 1;
}

.avatar-crop-frame {
  width: min(260px, 72vw);
  height: min(260px, 72vw);
  position: relative;
  margin: 2px auto 12px;
  overflow: hidden;
  border: 3px solid #4da3d4;
  border-radius: 50%;
  background: #e5f3fb;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.85), 0 10px 24px rgba(47, 120, 168, 0.18);
  touch-action: none;
}

.avatar-crop-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px dashed rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  pointer-events: none;
}

.avatar-crop-image {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: none;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center;
}

.avatar-crop-hint {
  margin-bottom: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.avatar-crop-zoom {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

.avatar-crop-zoom input {
  width: 100%;
  accent-color: var(--primary);
}

.avatar-crop-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.avatar-crop-cancel,
.avatar-crop-confirm {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 800;
}

.avatar-crop-cancel {
  color: var(--muted);
  background: #edf5fb;
}

.avatar-crop-confirm {
  color: #fff;
  background: var(--primary);
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.mini-stat {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdff;
  padding: 8px;
}

.mini-stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.mini-stat strong {
  display: block;
  margin-top: 2px;
  font-size: 17px;
  line-height: 1;
}

.chat-list {
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px 98px;
  background: #eef6fc;
  scroll-behavior: smooth;
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 16px;
}

.message-row.mine {
  justify-content: flex-end;
}

.message-row.notice {
  justify-content: center;
  margin: 10px 0 16px;
}

.message-avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid #c8deee;
  background: #e2f1fb;
  color: #245f88;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  overflow: hidden;
}

.message-row.mine .message-avatar {
  border-color: #9fc9e6;
  background: #d4eafb;
  color: #174f78;
}

.message-avatar img {
  border-radius: 6px;
}

.message-stack {
  max-width: min(72vw, 620px);
  min-width: 0;
}

.message-row.mine .message-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.message {
  position: relative;
  width: fit-content;
  max-width: 100%;
  border: 1px solid #d7e5f0;
  border-radius: 4px;
  background: var(--panel);
  box-shadow: none;
}

.message::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 13px;
  width: 10px;
  height: 10px;
  border-left: 1px solid #d7e5f0;
  border-bottom: 1px solid #d7e5f0;
  background: inherit;
  transform: rotate(45deg);
}

.message-row.mine .message {
  border-color: #9ac8e8;
  background: #d9edfb;
}

.message-row.mine .message::before {
  left: auto;
  right: -6px;
  border: 0;
  border-top: 1px solid #9ac8e8;
  border-right: 1px solid #9ac8e8;
}

.message.revoked {
  color: var(--muted);
  background: #f1f3f7;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.message-row.mine .message-meta {
  flex-direction: row-reverse;
}

.message-meta strong {
  color: var(--ink);
  font-size: 13px;
}

.message-body {
  padding: 10px 12px;
  font-size: 17px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.recognition {
  border-top: 1px dashed #c4d9e8;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
}

.recognition.good {
  color: var(--good);
}

.recognition.warn {
  color: var(--gold);
  background: var(--gold-soft);
}

.message-withdraw {
  border-radius: 999px;
  padding: 4px 10px;
  color: #738496;
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.message-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 3px;
}

.icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
}

.icon-button:hover,
.icon-button:focus-visible {
  background: #e5f3fb;
  color: var(--ink);
  outline: none;
}

.icon-button.danger:hover,
.icon-button.danger:focus-visible {
  background: var(--coral-soft);
  color: var(--danger);
}

.icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  grid-template-areas:
    "tools tools"
    "input send";
  gap: 6px;
  align-items: end;
  padding: 6px 10px calc(6px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: rgba(248, 251, 254, 0.97);
  backdrop-filter: blur(16px);
}

.composer-tools {
  grid-area: tools;
  display: flex;
  align-items: center;
  gap: 8px;
}

.template-button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0 8px;
  color: #245f88;
  background: #eef7fd;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.template-button:focus-visible,
.template-button:hover {
  outline: none;
  border-color: var(--primary);
  background: #dff0fb;
}

.chat-composer textarea {
  grid-area: input;
  width: 100%;
  min-height: 40px;
  max-height: 112px;
  resize: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
  outline: none;
  line-height: 1.35;
}

.chat-composer textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.send-button {
  grid-area: send;
  width: 42px;
  min-height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  color: #fff;
  background: var(--primary);
}

.send-button .icon {
  width: 20px;
  height: 20px;
}

.send-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.admin-shell .chat-composer {
  bottom: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding-bottom: 6px;
}

.admin-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.admin-chat-shell {
  height: 100dvh;
  overflow: hidden;
}

.admin-data-shell,
.admin-manage-shell {
  height: 100dvh;
  overflow: hidden;
}

.admin-top {
  padding: calc(14px + env(safe-area-inset-top, 0px)) 14px 14px;
  background: rgba(244, 249, 253, 0.96);
  border-bottom: 1px solid var(--line);
}

.admin-class-switcher {
  min-width: 0;
  max-width: 520px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 10px auto 0;
  border: 1px solid rgba(183, 216, 238, 0.9);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  padding: 8px 10px;
}

.admin-class-switcher span {
  color: #4f6b80;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.admin-class-switcher select {
  width: 100%;
  min-height: 36px;
  border: 1px solid #b7d8ee;
  border-radius: 8px;
  background: #f5fbff;
  color: var(--primary);
  padding: 0 10px;
  font-weight: 800;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  border-radius: var(--radius);
  padding: 0 9px;
  color: var(--indigo);
  background: var(--indigo-soft);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  min-height: calc(var(--bottom-nav-height) + var(--safe-bottom));
  padding: 7px 18px calc(7px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 -8px 24px rgba(32, 41, 59, 0.08);
  backdrop-filter: blur(16px);
}

.tab-button {
  min-height: 56px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.15;
}

.tab-button .icon {
  width: 29px;
  height: 29px;
  stroke-width: 2.35;
}

.tab-button span {
  visibility: visible;
}

.tab-button.active {
  color: var(--primary);
  background: transparent;
  box-shadow: none;
}

.tab-button.active .icon {
  stroke-width: 2.85;
}

.view {
  min-width: 0;
  min-height: 0;
  padding: 14px;
  padding-bottom: calc(14px + var(--bottom-nav-height) + var(--safe-bottom));
}

.admin-data-shell > .view,
.admin-manage-shell > .view {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(20px + var(--bottom-nav-height) + var(--safe-bottom));
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.data-toolbar {
  align-items: stretch;
  gap: 12px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.data-toolbar .toolbar-group,
.data-toolbar .toolbar-actions {
  min-width: 0;
}

.desktop-send-field {
  display: none;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.desktop-send-field .field {
  width: 150px;
}

.field,
.select,
.date-input {
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
}

.field {
  width: 100%;
}

.search-field {
  position: relative;
  flex: 1 1 180px;
}

.search-field .icon {
  position: absolute;
  left: 10px;
  top: 10px;
  color: var(--muted);
}

.search-field input {
  width: 100%;
  padding-left: 36px;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--radius);
  padding: 0 12px;
  color: #245f88;
  background: #e8f2fa;
  font-weight: 700;
}

.button.primary {
  color: #fff;
  background: var(--primary);
}

.button.warn {
  color: #7a3a20;
  background: var(--coral-soft);
}

.button.danger {
  color: var(--danger);
  background: var(--coral-soft);
}

.button.outline {
  color: var(--primary);
  border: 1px solid #6aa8d1;
  background: #fff;
}

.button.ghost {
  color: var(--muted);
  background: transparent;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.summary-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px;
}

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

.summary-item strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
  line-height: 1;
}

.notice-band {
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  background: var(--gold-soft);
  padding: 10px 12px;
  margin-bottom: 12px;
  color: #634600;
  font-size: 13px;
  line-height: 1.5;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

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

.view .desktop-table table {
  min-width: 1080px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #eef6fc;
  font-weight: 700;
  white-space: nowrap;
}

td {
  color: var(--ink);
}

tr:last-child td {
  border-bottom: 0;
}

.student-data-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px;
  box-shadow: 0 10px 24px rgba(47, 120, 168, 0.06);
}

.student-data-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.student-data-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.2;
}

.student-data-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.student-table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.student-data-table {
  width: max-content;
  min-width: 860px;
  border-collapse: separate;
  border-spacing: 0;
}

.student-data-table th,
.student-data-table td {
  min-width: 78px;
  padding: 11px 12px;
  border-bottom: 1px solid #edf3f8;
  background: #fff;
  font-size: 13px;
  white-space: nowrap;
}

.student-data-table th {
  color: #5f6f83;
  background: #f7fbff;
}

.student-data-table tr:last-child td {
  border-bottom: 0;
}

.student-data-table .sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 76px;
  max-width: 94px;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

.student-data-table th.sticky-col {
  z-index: 3;
  background: #f7fbff;
}

.student-data-table .missing-row td,
.student-data-table .missing-row .sticky-col {
  color: var(--muted);
  background: #fff;
}

.student-data-table .table-edit {
  width: 32px;
  height: 32px;
}

.missing-row td {
  color: var(--muted);
  background: #fbfcfe;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: var(--radius);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.good {
  color: var(--good);
  background: #e2f1fb;
}

.status-pill.warn {
  color: var(--gold);
  background: var(--gold-soft);
}

.status-pill.submitted {
  color: #137a42;
  background: #e5f8ef;
}

.status-pill.unsubmitted {
  color: #bd1f2d;
  background: #fdecec;
}

.status-pill.muted {
  color: var(--muted);
  background: #eef1f6;
}

.status-pill.compact {
  min-height: 22px;
  padding: 0 7px;
  font-size: 11px;
}

.mobile-record-list,
.people-list {
  display: none;
}

.people-list.visible {
  display: grid;
  gap: 8px;
}

.record-card,
.person-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px;
}

.record-card {
  margin-bottom: 12px;
  box-shadow: 0 8px 18px rgba(47, 120, 168, 0.06);
}

.record-head,
.person-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.person-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
}

.person-content {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.person-avatar {
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid #e4f1fa;
  border-radius: 50%;
  color: var(--primary);
  background: #e2f1fb;
  font-size: 24px;
  font-weight: 800;
}

.person-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.record-head strong,
.person-main strong {
  display: block;
  font-size: 19px;
}

.person-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.person-controls {
  display: flex;
  justify-content: flex-end;
}

.person-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
}

.person-actions .button {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  white-space: nowrap;
}

.person-actions .button.danger {
  border: 1px solid #ef9aa5;
  background: #fff;
}

.table-actions {
  justify-content: flex-start;
}

.table-actions .button {
  min-height: 34px;
}

.record-meta,
.person-main span {
  color: var(--muted);
  font-size: 12px;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.record-grid strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 17px;
}

.admin-chat {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(92px + var(--bottom-nav-height) + var(--safe-bottom));
}

.admin-chat .chat-list {
  flex: 1;
  height: auto;
  padding-bottom: 16px;
}

.admin-chat-shell .admin-chat {
  min-height: 0;
  overflow: hidden;
  padding-bottom: 0;
}

.admin-chat-shell .admin-chat .toolbar {
  flex: 0 0 auto;
}

.admin-chat-shell .admin-chat .chat-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: calc(92px + var(--bottom-nav-height) + var(--safe-bottom));
}

.management-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.management-grid.management-grid-single {
  grid-template-columns: minmax(0, 1fr);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 12px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.roster-count {
  color: #245f88;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.roster-form {
  grid-template-columns: 1fr auto;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch-track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #cfd6e2;
  transition: background 0.2s ease;
}

.switch-track::after {
  content: "";
  width: 20px;
  height: 20px;
  position: absolute;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(32, 41, 59, 0.22);
  transition: transform 0.2s ease;
}

.switch input:checked + .switch-track {
  background: var(--primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  padding: 14px;
  background: rgba(30, 36, 48, 0.42);
}

.modal {
  width: min(560px, 100%);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

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

.modal-form label {
  color: var(--muted);
  font-size: 12px;
}

.modal-form input,
.modal-form select {
  width: 100%;
  margin-top: 4px;
}

.password-form {
  grid-template-columns: 1fr;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.export-modal {
  width: min(480px, 100%);
}

.export-modal .modal-head h2 {
  margin: 0;
}

.export-modal .modal-head p,
.export-description,
.sync-result p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.export-choice-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.export-choice {
  width: 100%;
  min-height: 48px;
}

.sync-result {
  border: 1px solid #a9dfc0;
  border-radius: var(--radius);
  padding: 12px;
  color: #23633f;
  background: #effaf3;
}

.sync-result.partial {
  border-color: #f0c38f;
  color: #7a4a16;
  background: #fff7ed;
}

.sync-result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.sync-result-grid span {
  border-radius: 8px;
  padding: 7px 4px;
  text-align: center;
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.sync-result-grid b {
  display: block;
  margin-top: 2px;
  font-size: 17px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 100;
  max-width: min(92vw, 420px);
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius);
  background: #1e2430;
  color: #fff;
  padding: 10px 12px;
  font-size: 13px;
  box-shadow: var(--shadow);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

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

.hidden {
  display: none !important;
}

@media (max-width: 720px) {
  .view {
    padding: 12px;
  }

  .admin-data-shell > .view,
  .admin-manage-shell > .view {
    padding: 12px 12px calc(18px + var(--bottom-nav-height) + var(--safe-bottom));
  }

  .data-toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .data-toolbar .toolbar-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }

  .data-toolbar .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .data-toolbar .toolbar-actions .button {
    width: 100%;
  }

  .desktop-send-field {
    display: none;
  }

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

  .summary-item {
    padding: 9px 8px;
  }

  .summary-item strong {
    font-size: 19px;
  }

  .student-data-panel {
    padding: 10px;
  }

  .student-data-head {
    margin-bottom: 9px;
  }

  .student-data-head span {
    font-size: 11px;
  }

  .student-data-table {
    min-width: 820px;
  }

  .student-data-table th,
  .student-data-table td {
    min-width: 72px;
    padding: 10px 11px;
    font-size: 12px;
  }

  .student-data-table .sticky-col {
    min-width: 72px;
    max-width: 86px;
  }

  .desktop-table {
    display: none;
  }

  .mobile-record-list,
  .people-list {
    display: block;
  }

  .management-grid {
    grid-template-columns: 1fr;
  }

  .person-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
  }

  .person-controls {
    justify-content: flex-end;
  }

  .person-actions {
    display: flex;
    grid-template-columns: none;
    gap: 6px;
  }

  .person-actions .button {
    min-height: 36px;
    padding: 0 8px;
    font-size: 12px;
  }

  .person-actions .button .icon {
    width: 16px;
    height: 16px;
  }

  .person-avatar {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
  }

  .person-content {
    gap: 10px;
  }

  .person-main strong {
    font-size: 18px;
  }

  .form-grid,
  .modal-form {
    grid-template-columns: 1fr;
  }

  .admin-chat .chat-list {
    height: auto;
  }
}

@media (min-width: 900px) {
  .student-shell,
  .admin-shell {
    max-width: 1080px;
    margin: 0 auto;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }

  .chat-composer {
    left: 50%;
    width: min(1080px, 100vw);
    transform: translateX(-50%);
  }

  .tabs {
    left: 50%;
    width: min(1080px, 100vw);
    transform: translateX(-50%);
  }
}
