:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #5f6b78;
  --line: #d8dee6;
  --accent: #166a65;
  --accent-strong: #0f514d;
  --warn: #9a5b00;
  --bad: #b42318;
  --good: #157347;
  --shadow: 0 14px 30px rgba(22, 33, 43, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
button, input, select, textarea { font: inherit; }
button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
}
button:hover { background: var(--accent-strong); }
.hidden { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eef3f4 0%, #f8faf9 50%, #edf1ee 100%);
}
.login-box {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-box h1 { margin: 0 0 8px; font-size: 26px; }
.login-box p { margin: 0 0 22px; color: var(--muted); line-height: 1.6; }
label { display: grid; gap: 7px; color: #304050; font-size: 14px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; line-height: 1.55; }
.error { margin-top: 12px; color: var(--bad); min-height: 20px; }

.app { min-height: 100vh; }
.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0 0 4px; font-size: 22px; }
.topbar p { margin: 0; color: var(--muted); }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.top-actions button, .actions button:nth-child(3), #closeDialog,
#closeTerminalBtn, #closeExamDialog, #closeResultDialog {
  background: #fff;
  color: var(--accent);
}
.top-actions button:hover, .actions button:nth-child(3):hover, #closeDialog:hover,
#closeTerminalBtn:hover, #closeExamDialog:hover, #closeResultDialog:hover { background: #eef7f6; }

.exam-btn {
  background: var(--bad) !important;
  color: #fff !important;
  border-color: var(--bad) !important;
  font-weight: 600;
}
.exam-btn:hover { background: #9a2016 !important; }

/* 考试模式顶部栏 */
.exam-bar {
  background: #fffbe6;
  border-bottom: 2px solid var(--warn);
  padding: 10px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.exam-info { display: flex; gap: 20px; align-items: center; }
.timer {
  font-size: 28px;
  font-weight: 700;
  color: var(--bad);
  letter-spacing: 2px;
}
.timer.warning { color: #c40000; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100%{ opacity:1; } 50%{ opacity:0.6; } }
.exam-actions { display: flex; gap: 10px; }
#examFinishBtn { background: var(--bad); border-color: var(--bad); color: #fff; }

/* 考试题目列表 */
.exam-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin: 16px 18px;
}
.exam-panel h3 { margin: 0 0 12px; font-size: 16px; }
.exam-lab-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.exam-lab-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.exam-lab-item:hover { background: #f4fbfa; border-color: var(--accent); }
.exam-lab-item.passed { border-color: var(--good); background: #e7f5ec; }
.exam-lab-item.failed { border-color: var(--bad); background: #fdebea; }
.exam-lab-item .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ccc;
}
.exam-lab-item.passed .dot { background: var(--good); }
.exam-lab-item.failed .dot { background: var(--bad); }

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}
.sidebar, .detail {
  min-height: calc(100vh - 112px);
}
.filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.stats div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
}
.stats b { display: block; font-size: 22px; }
.stats span { color: var(--muted); font-size: 13px; }
.lab-list { display: grid; gap: 9px; }
.lab-card {
  display: grid;
  gap: 7px;
  width: 100%;
  text-align: left;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
}
.lab-card:hover, .lab-card.active { border-color: var(--accent); background: #f4fbfa; }
.card-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lab-card strong { font-size: 15px; }
.lab-card span:last-child { color: var(--muted); font-size: 13px; }
.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  background: #edf0f2;
  color: #51606e;
  white-space: nowrap;
}
.status.passed { background: #e7f5ec; color: var(--good); }
.status.failed { background: #fdebea; color: var(--bad); }
.status.review { background: #fff3dd; color: var(--warn); }
.no-data, .empty-state {
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 26px;
  text-align: center;
}

.lab-detail { display: grid; gap: 14px; }
.detail-head {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.meta { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
h2 { margin: 0; font-size: 24px; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.panel h3 { margin: 0 0 10px; font-size: 16px; }
.panel p { margin: 0; line-height: 1.7; }
ul { margin: 0; padding-left: 20px; line-height: 1.8; }
.split { display: grid; grid-template-columns: 1.3fr .7fr; gap: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips span {
  border: 1px solid #cbd9d6;
  background: #f0f7f5;
  border-radius: 999px;
  padding: 5px 10px;
  color: #275c58;
  font-size: 13px;
}
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.panel label { margin-top: 10px; }
.form-actions { margin-top: 12px; display: flex; justify-content: flex-end; }
.result-panel pre, dialog pre {
  margin: 0;
  white-space: pre-wrap;
  overflow: auto;
  background: #101820;
  color: #e8eef2;
  border-radius: 6px;
  padding: 14px;
  line-height: 1.55;
  max-height: 420px;
}

/* 终端面板 */
.terminal-panel {
  position: fixed;
  right: 0;
  top: 76px;
  width: 50%;
  height: calc(100vh - 76px);
  background: #000;
  z-index: 10;
  display: flex;
  flex-direction: column;
}
.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: #1a1a2e;
  color: #e8eef2;
  font-size: 13px;
  border-bottom: 1px solid #333;
}
.terminal-header button {
  background: transparent;
  border: 1px solid #555;
  color: #e8eef2;
  padding: 5px 10px;
  font-size: 12px;
}
.ttyd-frame {
  width: 100%;
  height: calc(100% - 40px);
  border: none;
}

/* 考试对话框 */
.exam-dialog-body { padding: 16px; }
.exam-config { margin: 14px 0; }
.exam-rules { margin: 14px 0; background: #f8f9fa; padding: 12px; border-radius: 6px; }
.exam-rules h4 { margin: 0 0 8px; }
.exam-rules ul { padding-left: 20px; line-height: 1.8; }
.start-exam-btn {
  background: var(--bad) !important;
  border-color: var(--bad) !important;
  color: #fff !important;
  font-size: 16px;
  padding: 12px 24px;
  width: 100%;
}

/* 考试结果 */
.exam-result-body { padding: 16px; }
.exam-result-body h4 { margin: 0 0 12px; }
.exam-result-body .score-display {
  text-align: center;
  font-size: 48px;
  font-weight: 700;
  margin: 20px 0;
}
.exam-result-body .score-pass { color: var(--good); }
.exam-result-body .score-fail { color: var(--bad); }

dialog {
  width: min(900px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10, 20, 30, .42); }
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.dialog-head h3 { margin: 0; }
dialog pre { border-radius: 0 0 8px 8px; max-height: 70vh; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: 6px;
  color: #fff;
  box-shadow: var(--shadow);
}
.toast.ok { background: var(--accent); }
.toast.bad { background: var(--bad); }

@media (max-width: 920px) {
  .topbar, .detail-head { align-items: stretch; flex-direction: column; }
  .layout { grid-template-columns: 1fr; }
  .sidebar, .detail { min-height: auto; }
  .split, .review-grid { grid-template-columns: 1fr; }
  .terminal-panel { width: 100%; }
  .exam-lab-list { grid-template-columns: 1fr; }
}
