* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background:#f4f6fb; color:#1f2937; }
a { color:#2563eb; text-decoration:none; }
.container { max-width: 1200px; margin: 20px auto 70px; padding: 0 16px; }
.topbar { display:flex; justify-content:space-between; align-items:center; background:#111827; color:#fff; padding:10px 16px; }
.brand { font-weight:700; display:flex; align-items:center; gap:10px; min-width:0; color:#fff; text-decoration:none; }
.brand-logo { height:30px; width:auto; object-fit:contain; background:#fff; border-radius:6px; padding:2px; }
.brand-text { font-size:16px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.brand-version { font-size:11px; font-weight:500; opacity:.88; margin-left:6px; }
.userbox { display:flex; align-items:center; gap:8px; }
.avatar { width:30px; height:30px; border-radius:50%; object-fit:cover; }
.card { background:#fff; border-radius:12px; box-shadow:0 4px 18px rgba(0,0,0,.06); padding:16px; margin-bottom:16px; }
.grid-4 { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; margin-bottom:16px; }
.stat { display:flex; flex-direction:column; gap:8px; }
.stat span { font-size:26px; font-weight:700; }
.form-grid, .form-grid-3, .form-grid-4 { display:grid; gap:12px; margin:8px 0; }
.form-grid-3 { grid-template-columns:repeat(3,minmax(0,1fr)); }
.form-grid-4 { grid-template-columns:repeat(4,minmax(0,1fr)); }
label { display:flex; flex-direction:column; gap:6px; font-size:14px; }
input, select, button { font:inherit; }
input, select { padding:8px 10px; border:1px solid #d1d5db; border-radius:8px; }
.btn { background:#2563eb; color:#fff; border:none; border-radius:8px; padding:8px 14px; cursor:pointer; }
.btn-small { padding:6px 10px; font-size:13px; }
.btn.danger { background:#dc2626; }
.inline { display:inline-flex; gap:6px; align-items:center; margin-right:8px; }
.alert { border-radius:8px; padding:10px 12px; margin-bottom:12px; }
.alert.ok { background:#dcfce7; color:#166534; }
.alert.error { background:#fee2e2; color:#991b1b; }
table { width:100%; border-collapse:collapse; }
th, td { border-bottom:1px solid #e5e7eb; text-align:left; padding:10px 8px; font-size:14px; }
.muted { color:#6b7280; font-size:13px; }
.chips { display:flex; flex-wrap:wrap; gap:8px; }
.chip { background:#eef2ff; border-radius:999px; padding:4px 10px; }
.admin-tabs { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; margin-bottom:12px; }
.tab-btn { border:1px solid #cbd5e1; background:#fff; color:#0f172a; border-radius:10px; padding:10px 12px; cursor:pointer; font-weight:600; }
.tab-btn.active { background:#2563eb; color:#fff; border-color:#2563eb; box-shadow:0 4px 12px rgba(37,99,235,.2); }
.inline-check { display:inline-flex; align-items:center; gap:8px; font-size:14px; }
.inline-check input[type="checkbox"] { width:16px; height:16px; margin:0; }
.auth-wrap { max-width:420px; margin:80px auto; }
.auth-wrap-wide { max-width:980px; }
.login-methods-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.login-methods-row > .card { margin-bottom: 0; }
.beian { position:fixed; left:0; right:0; bottom:0; background:#fff; border-top:1px solid #e5e7eb; text-align:center; padding:8px; font-size:12px; }
.beian p { margin:2px 0; }
.copyright { color:#6b7280; font-size:12px; }
.btn[disabled], .btn:disabled { background:#9ca3af; cursor:not-allowed; opacity:.85; }
.frq-notice { background:#fff7ed; color:#9a3412; border:1px solid #fdba74; padding:10px; border-radius:8px; margin-bottom:10px; }
.frq-text-wrap { display:flex; flex-direction:column; min-height:52vh; }
.frq-text-wrap textarea {
  width:100%;
  border:1px solid #cbd5e1;
  border-radius:8px;
  padding:12px;
  resize:vertical;
  flex:1;
  min-height:46vh;
  font-size:17px;
  line-height:1.65;
}

.anomaly-live-list { margin:0; padding-left:18px; }
.anomaly-live-list li { margin:6px 0; }
.anomaly-new { animation: anomalyPulse 1.2s ease; background:#fef2f2; border-left:3px solid #dc2626; padding:6px 8px; border-radius:6px; }
@keyframes anomalyPulse {
  0% { transform: translateY(-6px); opacity:0; }
  40% { transform: translateY(0); opacity:1; }
  100% { transform: translateY(0); opacity:1; }
}

/* Student exam page */
.exam-shell { position:fixed; inset:0; background:#f8fafc; display:flex; flex-direction:column; }
.exam-top {
  display:grid;
  grid-template-columns:1fr auto 1fr;
  align-items:center;
  gap:10px;
  padding:14px 20px;
  background:#0f172a;
  color:#fff;
}
.exam-top-logo-wrap { display:flex; justify-content:center; align-items:center; }
.exam-top-logo {
  height:40px;
  width:auto;
  object-fit:contain;
  background:#fff;
  border-radius:8px;
  padding:3px 8px;
  box-shadow:0 2px 8px rgba(0,0,0,.28);
}
.clock { font-size:26px; font-weight:800; justify-self:start; }
.exam-top-right { justify-self:end; display:flex; flex-direction:column; align-items:flex-end; gap:6px; }
.battery-tip { font-size:20px; font-weight:700; text-align:right; }
.exam-net-status {
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 10px;
  border: 1px solid transparent;
}
.exam-net-status.online { background:#dcfce7; color:#166534; border-color:#86efac; }
.exam-net-status.offline { background:#fee2e2; color:#991b1b; border-color:#fca5a5; }
.remaining { text-align:center; font-weight:700; font-size:28px; padding:8px 12px 4px; background:#fff; border-bottom:1px solid #e5e7eb; display:flex; align-items:center; justify-content:center; gap:10px; }
.remaining.danger { color:#dc2626; }
.btn-time-toggle { padding:4px 10px; font-size:12px; line-height:1.2; }
.exam-main { flex:1; display:grid; grid-template-columns:3.2fr 1fr; min-height:0; margin-top:-4px; }
.paper-view { background:#fff; border-right:1px solid #e5e7eb; display:flex; flex-direction:column; min-height:0; }
.paper-toolbar { display:flex; align-items:center; gap:10px; padding:8px 12px; border-bottom:1px solid #e5e7eb; background:#fff; flex-wrap:wrap; }
.pdf-jump-inline { font-size:12px; color:#334155; }
.pdf-page-input { width:78px; padding:5px 8px; border:1px solid #cbd5e1; border-radius:8px; font-size:13px; }
.pdf-annot-toolbar { display:flex; align-items:center; gap:8px; padding:8px 12px; border-bottom:1px solid #e5e7eb; background:#f8fafc; flex-wrap:wrap; }
.pdf-annot-toolbar .btn.active { background:#1d4ed8; color:#fff; border-color:#1d4ed8; }
.pdf-stage { flex:1; overflow:auto; padding:12px; background:#f8fafc; display:flex; justify-content:center; align-items:flex-start; }
.pdf-canvas-wrap { position:relative; display:inline-block; }
#pdfCanvas { max-width:100%; height:auto; box-shadow:0 2px 12px rgba(0,0,0,.08); background:#fff; display:block; }
#annotCanvas { position:absolute; left:0; top:0; width:100%; height:100%; pointer-events:auto; }

.student-warn-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: #b30000;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.student-warn-inner { width:min(920px, 92vw); position:relative; display:flex; flex-direction:column; align-items:center; }
.student-warn-emoji { font-size:86px; line-height:1; margin-bottom:12px; }
.student-warn-title { font-size:54px; font-weight:900; margin-bottom:20px; letter-spacing:1px; }
.student-warn-message { font-size:38px; font-weight:700; line-height:1.5; }
.student-warn-ack { position:absolute; top:0; right:0; margin-top:0; font-size:24px; font-weight:800; padding:12px 20px; border-radius:12px; background:#fef08a; color:#7f1d1d; }

.hybrid-stop-flash {
  position:absolute;
  inset:0;
  z-index:4000;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  pointer-events:none;
}
.hybrid-stop-flash .hybrid-stop-text {
  font-size:46px;
  font-weight:900;
  line-height:1.28;
  width:min(1100px, 92%);
}
.hybrid-stop-flash.phase-red { background:#d43030; }
.hybrid-stop-flash.phase-red .hybrid-stop-text { color:#1f8f3a; }
.hybrid-stop-flash.phase-white { background:#fff; }
.hybrid-stop-flash.phase-white .hybrid-stop-text { color:#cf1717; }
.qa-panel { background:#f1f5f9; padding:12px; overflow:auto; }
.q-head { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.q-head-actions { display:flex; align-items:center; gap:8px; }
.options { display:grid; gap:8px; margin:12px 0; }
.option-btn { background:#fff; border:1px solid #cbd5e1; border-radius:8px; padding:8px 10px; cursor:pointer; }
.option-btn.active { border-color:#2563eb; color:#1d4ed8; font-weight:700; }
.qa-nav { display:flex; gap:8px; margin:10px 0; }
.exam-footer { display:flex; justify-content:space-between; align-items:center; padding:16px 20px; background:#fff; border-top:1px solid #e5e7eb; min-height:64px; }
.exam-footer-student { font-size:19px; font-weight:800; letter-spacing:.2px; }
.exam-footer-module { font-size:15px; font-weight:600; color:#0f172a; }
.review-panel { margin-top:8px; max-height:240px; overflow:auto; display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:8px; }
.hidden { display:none !important; }
.modal { position:fixed; inset:0; background:rgba(0,0,0,.4); display:flex; align-items:center; justify-content:center; }
.modal-content { width:520px; max-width:90vw; background:#fff; border-radius:10px; padding:16px; max-height:78vh; overflow:auto; }
#reviewList { max-height:56vh; overflow:auto; padding-right:6px; }
.desmos-panel { position:fixed; right:16px; top:90px; width:360px; height:560px; min-width:280px; min-height:320px; resize:both; background:#fff; border:1px solid #cbd5e1; border-radius:10px; box-shadow:0 12px 24px rgba(0,0,0,.22); z-index:10000; overflow:auto; }
.desmos-drag-bar { height:40px; background:#0f172a; color:#fff; display:flex; align-items:center; justify-content:space-between; padding:0 10px; cursor:move; user-select:none; }
.desmos-close { border:none; background:transparent; color:#fff; font-size:22px; cursor:pointer; line-height:1; }
.desmos-mount { width:100%; height:calc(100% - 40px); }

.congrats-wrap { min-height:calc(100vh - 120px); display:flex; align-items:center; justify-content:center; background:#dbeafe; position:relative; overflow:hidden; }
.congrats-ribbon { position:absolute; top:24px; left:-46px; transform:rotate(-12deg); background:linear-gradient(90deg,#f59e0b,#ef4444); color:#fff; font-weight:800; padding:10px 60px; box-shadow:0 6px 14px rgba(0,0,0,.22); letter-spacing:.5px; }
.congrats-card { text-align:center; background:#eff6ff; border:1px solid #bfdbfe; border-radius:16px; padding:36px 28px; max-width:760px; box-shadow:0 10px 30px rgba(37,99,235,.15); }
.congrats-emoji { font-size:110px; line-height:1; margin-bottom:14px; }
.congrats-card h1 { margin:0 0 20px; font-size:32px; color:#0f172a; }
.congrats-exit { background:#dc2626 !important; color:#22c55e !important; font-weight:800; }

@media (max-width: 860px) {
  .grid-4, .form-grid-3, .form-grid-4 { grid-template-columns:1fr; }
  .exam-main { grid-template-columns:1fr; }
  .exam-top { grid-template-columns:1fr; gap:8px; }
  .exam-top-logo-wrap { order:-1; }
  .clock { justify-self:center; text-align:center; }
  .exam-top-right { justify-self:center; align-items:center; }
  .battery-tip { text-align:center; }
}

.start-code-wrap {
  margin: 18px auto 8px;
  width: min(760px, 96%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 20px 18px;
  background: #f8fafc;
  border: 1px solid #dbeafe;
  border-radius: 14px;
}
.start-code-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(54px, 74px));
  gap: 12px;
}
.start-code-digit {
  height: 72px;
  text-align: center;
  font-size: 38px;
  font-weight: 800;
  border: 2px solid #93c5fd;
  border-radius: 12px;
  background: #fff;
}
.start-code-submit {
  font-size: 19px;
  font-weight: 800;
  padding: 12px 28px;
}


.unified-wait-box {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.resource-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 14px 0;
}

.login-main-title {
  text-align: center;
  font-size: 34px;
  margin: 0 0 14px;
  letter-spacing: .2px;
  white-space: nowrap;
  line-height: 1.2;
}

.hello-card { padding-top: 20px; padding-bottom: 18px; }
.hello-title { margin: 0; font-size: 34px; }
.hello-quote {
  margin: 10px 0 0;
  color: #374151;
  line-height: 1.75;
  font-size: 18px;
}
.hello-quote em { font-style: italic; }
.hello-author {
  display: inline-block;
  margin-top: 8px;
  font-size: 14px;
  color: #6b7280;
}

.proctor-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 6px;
}
.proctor-meta-item {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px 12px;
}
.proctor-meta-label { font-size: 12px; color: #6b7280; }
.proctor-meta-value { margin-top: 4px; font-size: 15px; font-weight: 700; color: #111827; }

@media (max-width: 860px) {
  .login-main-title { font-size: 26px; }
  .hello-title { font-size: 28px; }
  .hello-quote { font-size: 16px; }
  .proctor-meta-grid { grid-template-columns: 1fr; }
}
