:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #dde3ea;
  --blue: #2563eb;
  --green: #168a55;
  --red: #dc2626;
  --amber: #b7791f;
  --dark: #111827;
  --shadow: 0 12px 30px rgba(18, 27, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px 1fr;
}

.sidebar {
  background: var(--dark);
  color: #d1d5db;
  padding: 20px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #ffffff;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--blue);
  font-weight: 800;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
}

.brand-subtitle {
  margin-top: 2px;
  color: #9ca3af;
  font-size: 12px;
}

.nav-group-title {
  margin: 26px 12px 8px;
  color: #9ca3af;
  font-size: 12px;
}

.nav-item {
  height: 40px;
  width: 100%;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #d1d5db;
  font-size: 14px;
  margin-bottom: 4px;
  cursor: pointer;
  text-align: left;
}

.nav-item.active {
  background: #1f2937;
  color: #ffffff;
}

.nav-item:hover {
  background: #182233;
  color: #ffffff;
}

.main {
  min-width: 0;
}

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

.page-title {
  font-size: 20px;
  font-weight: 800;
}

.page-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  text-decoration: none;
}

.btn.primary {
  background: var(--blue);
  color: #ffffff;
}

.btn.secondary {
  background: #eef2f7;
  color: #243044;
}

.btn.ghost {
  border: 1px solid var(--line);
  background: #ffffff;
  color: #243044;
}

.btn.full {
  width: 100%;
  height: 42px;
}

.content {
  padding: 24px 28px 36px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

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

.metric-value {
  margin-top: 8px;
  font-size: 32px;
  font-weight: 800;
}

.metric-note {
  margin-top: 6px;
}

.green {
  color: var(--green);
}

.blue {
  color: var(--blue);
}

.red {
  color: var(--red);
}

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.device-panel {
  grid-column: 1 / -1;
}

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

.panel-head.compact {
  min-height: 56px;
}

.panel-title {
  font-weight: 800;
}

.panel-desc {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-input,
.select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  padding: 0 10px;
  color: #344054;
}

.search-input.compact {
  width: 140px;
}

.select.school-select {
  min-width: 240px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
}

th {
  height: 42px;
  padding: 0 10px;
  text-align: left;
  color: var(--muted);
  background: var(--panel-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  height: 54px;
  padding: 0 10px;
  border-bottom: 1px solid #edf1f5;
  white-space: nowrap;
}

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

.mono {
  font-family: Consolas, "Courier New", monospace;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.green {
  color: var(--green);
  background: #e8f7ef;
}

.badge.red {
  color: var(--red);
  background: #feecec;
}

.badge.amber {
  color: var(--amber);
  background: #fff7df;
}

.badge.blue {
  color: var(--blue);
  background: #eaf1ff;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.mini-btn,
.mini-link {
  height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: #243044;
  padding: 0 8px;
  cursor: pointer;
  text-decoration: none;
}

.mini-btn.danger {
  color: var(--red);
  border-color: #f6caca;
  background: #fff7f7;
}

.mini-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.mini-btn.active {
  color: var(--blue);
  border-color: #bcd0ff;
  background: #eaf1ff;
}

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

.chart-box {
  height: 230px;
  padding: 16px;
}

.chart-grid {
  height: 100%;
  position: relative;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(to top, rgba(221, 227, 234, 0.7) 1px, transparent 1px) 0 0 / 100% 25%,
    linear-gradient(to right, rgba(221, 227, 234, 0.45) 1px, transparent 1px) 0 0 / 16.66% 100%;
}

.chart-fill {
  position: absolute;
  inset: 0;
  clip-path: polygon(0 72%, 10% 64%, 20% 66%, 30% 48%, 40% 44%, 50% 36%, 60% 42%, 70% 26%, 80% 30%, 90% 22%, 100% 28%, 100% 100%, 0 100%);
  background: rgba(37, 99, 235, 0.14);
}

.rank-list,
.system-list {
  padding: 12px 16px 16px;
}

.rank-row,
.system-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  height: 44px;
}

.system-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.rank-index {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #eef2f7;
  color: #344054;
  font-weight: 700;
  font-size: 12px;
}

.rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-status,
.system-row span {
  color: var(--muted);
  font-size: 13px;
}

.muted-text {
  color: var(--muted);
}

.empty {
  height: 80px;
  text-align: center;
  color: var(--muted);
}

.empty.small {
  height: auto;
  padding: 24px 0;
}

.placeholder-panel {
  min-height: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 44px 24px;
  text-align: center;
}

.placeholder-panel[hidden] {
  display: none;
}

.module-panel[hidden] {
  display: none;
}

.placeholder-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 14px;
  background: #eaf1ff;
  color: var(--blue);
  font-size: 24px;
  font-weight: 800;
}

.placeholder-panel h2 {
  margin: 0 0 10px;
  font-size: 24px;
}

.placeholder-panel p {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.placeholder-actions {
  margin-top: 22px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.35);
  z-index: 20;
}

.modal.show {
  display: flex;
}

.modal-card {
  width: min(420px, 100%);
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
  padding: 18px;
}

.modal-card.wide {
  width: min(980px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.modal-card.form-modal-card {
  width: min(680px, 100%);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  font-weight: 800;
}

.modal-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
}

.qr-wrap {
  display: grid;
  place-items: center;
  padding: 18px 0 12px;
}

.qr-wrap img {
  width: 240px;
  height: 240px;
}

.payload {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: #344054;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

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

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

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

.summary-value {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 800;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.9fr);
  gap: 14px;
}

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

.split-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(0, 1.3fr);
  gap: 14px;
  margin-bottom: 8px;
}

.topic-list {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.topic-list code {
  display: block;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: #243044;
  white-space: normal;
  word-break: break-all;
}

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

.settings-list {
  padding: 8px 14px 12px;
}

.setting-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 40px;
  border-bottom: 1px solid #edf1f5;
}

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

.setting-row span {
  color: var(--muted);
}

.setting-row strong {
  min-width: 0;
  font-weight: 700;
  word-break: break-all;
}

.text-list p {
  margin: 10px 0;
  color: #344054;
  line-height: 1.6;
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.section-title {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
  background: var(--panel-soft);
}

.mini-table-wrap {
  max-height: 320px;
  overflow: auto;
}

.mini-table {
  font-size: 13px;
}

.mini-table th,
.mini-table td {
  height: 40px;
}

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  background: var(--dark);
}

.login-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  overflow: hidden;
}

.login-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.28), transparent 42%),
    radial-gradient(circle at 70% 30%, rgba(22, 138, 85, 0.22), transparent 28%),
    linear-gradient(180deg, rgba(17, 24, 39, 0), rgba(17, 24, 39, 0.7));
}

.login-visual > * {
  position: relative;
}

.login-copy {
  max-width: 720px;
  color: #ffffff;
}

.login-copy h1 {
  margin: 0 0 16px;
  font-size: 42px;
  line-height: 1.15;
}

.login-copy p {
  margin: 0;
  color: #cbd5e1;
  line-height: 1.8;
}

.login-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  max-width: 720px;
}

.login-stat {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 16px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.login-stat strong {
  display: block;
  margin-bottom: 6px;
  font-size: 24px;
}

.login-stat span {
  color: #cbd5e1;
  font-size: 13px;
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 28px;
}

.login-card {
  width: 100%;
  max-width: 340px;
}

.login-card h2 {
  margin: 0 0 8px;
  font-size: 26px;
}

.hint {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.form-field {
  margin-bottom: 16px;
}

.device-form .form-field {
  margin-bottom: 0;
}

.form-field.span-two {
  grid-column: span 2;
}

.form-field label {
  display: block;
  margin-bottom: 8px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.form-field input,
.form-field select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #ffffff;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.account-submit-field {
  display: flex;
  align-items: flex-end;
}

.account-submit-field .btn {
  width: 100%;
  height: 42px;
}

.account-table-wrap {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.login-error {
  display: none;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 6px;
  color: #b42318;
  background: #fef3f2;
  border: 1px solid #fecdca;
  font-size: 13px;
}

.teacher-entry-link {
  margin-top: 14px;
  display: block;
  color: var(--blue);
  font-size: 13px;
  text-align: center;
  text-decoration: none;
}

.teacher-entry-link:hover {
  text-decoration: underline;
}

.login-error.show {
  display: block;
}

.login-meta {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1100px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .device-panel {
    grid-row: auto;
    grid-column: auto;
  }
}

@media (max-width: 920px) {
  .app-shell,
  .login-view {
    grid-template-columns: 1fr;
  }

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

  .form-field.span-two {
    grid-column: auto;
  }

  .sidebar {
    display: none;
  }

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

  .login-visual {
    min-height: 360px;
  }

  .detail-summary,
  .detail-grid,
  .status-grid,
  .split-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .content {
    padding: 16px;
  }

  .metrics,
  .login-stats {
    grid-template-columns: 1fr;
  }

  .login-visual {
    padding: 28px 20px;
  }

  .login-copy h1 {
    font-size: 30px;
  }
}
