:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e5e9f0;
  --border-strong: #d6dce8;
  --text: #1f2937;
  --text-soft: #4b5563;
  --muted: #8b95a5;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --green: #10b981;
  --green-dark: #047857;
  --green-light: #ecfdf5;
  --red: #ef4444;
  --red-dark: #b91c1c;
  --red-light: #fef2f2;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .1);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font-family: inherit; }
svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo {
  width: 40px; height: 40px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79,70,229,.28);
}
.brand-logo svg { width: 22px; height: 22px; }
.brand-text h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.3px; line-height: 1.3; }
.brand-text span { color: var(--muted); font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.sync-indicator { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(16,185,129,.15); }

/* ---------- 标签页 ---------- */
.tabs { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 65px; z-index: 40; }
.tabs-inner { max-width: 1280px; margin: 0 auto; padding: 0 24px; display: flex; gap: 4px; }
.tab {
  background: none; border: none; cursor: pointer;
  padding: 13px 18px 12px;
  color: var(--muted); font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
  position: relative;
}
.tab svg { width: 17px; height: 17px; }
.tab:hover { color: var(--text-soft); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-dot { width: 6px; height: 6px; background: var(--green); border-radius: 50%; }

/* ---------- 布局 ---------- */
.main { max-width: 1280px; margin: 0 auto; padding: 28px 24px 60px; }
.page { display: none; animation: fade .25s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h2 { margin: 0 0 3px; font-size: 23px; font-weight: 700; letter-spacing: -.4px; }
.page-sub { margin: 0; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 16px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: all .15s;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 7px 13px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(79,70,229,.2); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: var(--surface); border-color: var(--border-strong); color: var(--text-soft); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-success { background: var(--green); color: #fff; }
.btn-success { background: #059669; }
.btn-success:hover { background: #047857; }
.btn-danger-ghost { background: var(--red-light); color: var(--red-dark); border-color: #fecaca; }
.btn-danger-ghost:hover { background: #fee2e2; }
.btn-danger { background: var(--red); color: #fff; }

.input, .select {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: #aab2c0; }
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.input-lg { padding: 12px 14px; font-size: 14px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 34px; cursor: pointer; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.spacer-top { margin-top: 16px; }
.form-message { font-size: 12px; margin-top: 10px; min-height: 18px; }
.form-message.success { color: var(--green-dark); }
.form-message.error { color: var(--red-dark); }
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ---------- 统计卡 ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
  display: flex; align-items: center; gap: 15px;
}
.stat-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; }
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.indigo { background: #eef2ff; color: #4f46e5; }
.stat-icon.blue { background: #eff6ff; color: #3b82f6; }
.stat-icon.green { background: #ecfdf5; color: #059669; }
.stat-icon.red { background: #fef2f2; color: #ef4444; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.25; letter-spacing: -.5px; }

/* ---------- 作业卡内容 ---------- */
.card-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.assignment-select-wrap { min-width: 280px; flex: 1; max-width: 420px; }
.card-title { font-size: 15px; font-weight: 700; margin: 0 0 16px; display: flex; align-items: center; gap: 9px; }
.title-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.title-icon svg { width: 15px; height: 15px; }
.title-icon.indigo { background: #eef2ff; color: var(--primary); }
.title-icon.blue { background: #eff6ff; color: var(--blue); }
.title-icon.green { background: #ecfdf5; color: #059669; }
.title-icon.amber { background: #fffbeb; color: var(--amber); }
.view-switch { background: #f1f3f8; border-radius: 9px; padding: 3px; display: flex; gap: 2px; }
.view-btn { border: none; background: none; cursor: pointer; padding: 7px 14px; border-radius: 7px; font-size: 12px; font-weight: 600; color: var(--muted); }
.view-btn.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 4px rgba(16,24,40,.1); }

.progress-panel { background: #f9fafc; border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-bottom: 18px; }
.progress-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.progress-title { font-size: 16px; font-weight: 700; }
.progress-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.progress-number { text-align: right; display: flex; flex-direction: column; line-height: 1.2; }
.progress-number strong { font-size: 22px; color: var(--primary); }
.progress-number span { font-size: 12px; color: var(--muted); }
.progress-track { height: 9px; background: #e5e9f0; border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #6366f1, #4f46e5); border-radius: 99px; transition: width .5s ease; }
.legend { display: flex; align-items: center; gap: 20px; margin-top: 12px; font-size: 12px; color: var(--text-soft); flex-wrap: wrap; }
.legend b { color: var(--text); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.legend-dot.ok { background: var(--green); }
.legend-dot.no { background: var(--red); }
.legend-hint { color: var(--muted); margin-left: auto; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.search-input { max-width: 280px; }
.chip-group { display: flex; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--muted); padding: 6px 14px; border-radius: 99px; font-size: 12px; font-weight: 600; cursor: pointer; }
.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--primary-light); border-color: #c7d2fe; color: var(--primary); }

.student-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.student-card {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px 13px;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.student-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.student-card.submitted { background: var(--green-light); border-color: #c6f0dd; }
.student-avatar { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex-shrink: 0; background: #eef2ff; color: var(--primary); }
.student-card.submitted .student-avatar { background: #d1fae5; color: var(--green-dark); }
.student-info { min-width: 0; flex: 1; }
.student-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.student-id { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.status-badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.status-badge.ok { background: #d1fae5; color: var(--green-dark); }
.status-badge.no { background: var(--red-light); color: var(--red-dark); }

/* 矩阵 */
.matrix-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 11px; max-height: 620px; }
.matrix-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12px; }
.matrix-table th, .matrix-table td { padding: 9px 12px; text-align: center; border-bottom: 1px solid var(--border); white-space: nowrap; }
.matrix-table thead th { position: sticky; top: 0; background: #f9fafc; z-index: 3; font-weight: 700; color: var(--text-soft); }
.matrix-table th:first-child, .matrix-table td:first-child { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; }
.matrix-table thead th:first-child { z-index: 4; background: #f9fafc; }
.matrix-table tbody tr:hover td { background: #f9fafc; }
.matrix-table tbody tr:last-child td { border-bottom: none; }
.matrix-name { font-weight: 600; }
.matrix-id { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; display: block; }
.matrix-cell { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; font-weight: 700; }
.matrix-cell.ok { background: #d1fae5; color: var(--green-dark); }
.matrix-cell.no { background: var(--red-light); color: var(--red); }
.matrix-table th.hw-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }

/* 空状态 */
.empty-state { text-align: center; padding: 46px 20px 40px; }
.empty-illustration { width: 68px; height: 68px; margin: 0 auto 14px; border-radius: 18px; background: var(--primary-light); color: var(--primary); display: grid; place-items: center; }
.empty-illustration svg { width: 32px; height: 32px; }
.empty-state h3 { margin: 0 0 6px; font-size: 17px; }
.empty-state p { margin: 0 auto 18px; color: var(--muted); font-size: 13px; max-width: 380px; }

/* ---------- 学生登记 ---------- */
.register-layout { display: grid; grid-template-columns: 360px 1fr; gap: 18px; align-items: start; }
.register-identity, .register-records { position: relative; padding-top: 28px; }
.step-badge { position: absolute; top: -13px; left: 22px; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; box-shadow: 0 3px 8px rgba(79,70,229,.3); }
.register-identity h3, .register-records h3 { margin: 0 0 4px; font-size: 16px; }
.identity-result { margin-top: 16px; padding: 14px; border-radius: 11px; background: var(--green-light); border: 1px solid #c6f0dd; display: flex; align-items: center; gap: 12px; }
.identity-avatar { width: 42px; height: 42px; border-radius: 11px; background: #d1fae5; color: var(--green-dark); display: grid; place-items: center; font-weight: 700; }
.identity-name { font-size: 15px; font-weight: 700; }
.identity-id { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tip-box { display: flex; align-items: flex-start; gap: 8px; margin-top: 18px; padding: 12px; border-radius: 10px; background: #f9fafc; color: var(--muted); font-size: 12px; line-height: 1.5; }
.tip-box svg { width: 15px; height: 15px; margin-top: 2px; color: var(--primary); }
.register-list { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.register-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 48px 0; font-size: 13px; }
.register-placeholder svg { width: 34px; height: 34px; opacity: .5; }
.register-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 11px; }
.register-row-title { font-weight: 700; font-size: 13px; }
.register-row-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.register-row-actions { display: flex; gap: 7px; flex-shrink: 0; }
.status-btn { border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted); border-radius: 8px; padding: 7px 13px; font-size: 12px; font-weight: 700; cursor: pointer; transition: all .15s; }
.status-btn:hover.ok { background: #d1fae5; border-color: #a7f3d0; color: var(--green-dark); }
.status-btn:hover.no { background: var(--red-light); border-color: #fecaca; color: var(--red-dark); }
.status-btn.selected.ok { background: #059669; border-color: #059669; color: #fff; }
.status-btn.selected.no { background: #dc2626; border-color: #dc2626; color: #fff; }

/* ---------- 管理后台 ---------- */
.login-card { max-width: 400px; margin: 0 auto; text-align: center; padding: 36px 32px; }
.login-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-light); color: var(--primary); display: grid; place-items: center; margin: 0 auto 14px; }
.login-icon svg { width: 26px; height: 26px; }
.login-card h3 { margin: 0 0 4px; font-size: 18px; }
.login-card .field-label { text-align: left; margin-top: 22px; }
.admin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; align-items: start; }
.admin-assignment-list { display: flex; flex-direction: column; gap: 9px; max-height: 380px; overflow: auto; }
.admin-assignment-item { border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; }
.admin-assignment-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.admin-assignment-name { font-size: 13px; font-weight: 700; }
.admin-assignment-meta { font-size: 11px; color: var(--muted); }
.admin-assignment-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.mini-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); border-radius: 6px; padding: 4px 9px; font-size: 11px; cursor: pointer; }
.mini-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.mini-btn.danger:hover { border-color: var(--red); color: var(--red); background: var(--red-light); }
.admin-desc { margin: 0 0 18px; line-height: 1.6; }
.manual-actions { display: flex; gap: 8px; margin-top: 16px; }
.manual-actions .btn { flex: 1; }
.password-row { display: flex; gap: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 13px; box-shadow: var(--shadow-lg); z-index: 100;
  animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 响应式 ---------- */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .register-layout { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar-inner { padding: 10px 16px; }
  .tabs-inner { padding: 0 10px; overflow-x: auto; }
  .tab { padding: 12px 11px; font-size: 13px; white-space: nowrap; }
  .main { padding: 20px 14px 50px; }
  .sync-indicator { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; gap: 10px; }
  .stat-value { font-size: 21px; }
  .card { padding: 16px; }
  .card-head { align-items: stretch; flex-direction: column; }
  .assignment-select-wrap { max-width: none; }
  .page-head h2 { font-size: 20px; }
  .student-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .register-row { flex-direction: column; align-items: stretch; }
  .register-row-actions .status-btn { flex: 1; }
}
