* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #f4f6f9;
  color: #1f2937;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #eef2f7;
}

.login-panel {
  width: 380px;
  max-width: 100%;
  background: #fff;
  border: 1px solid #e3e8ef;
  border-radius: 10px;
  padding: 32px 30px 24px;
  box-shadow: 0 8px 30px rgba(31, 41, 55, 0.06);
}

.login-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 1px;
}

.login-sub {
  color: #7b8794;
  font-size: 13px;
  margin: 8px 0 24px;
}

.login-hint {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #eff2f6;
  color: #8b95a1;
  font-size: 12px;
  line-height: 1.9;
}

/* ---------- 布局 ---------- */
.app-view { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: #fff;
  border-right: 1px solid #e5e9f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid #f0f3f7;
}

.brand-name { display: block; font-size: 16px; font-weight: 600; }
.brand-sub { display: block; color: #8b95a1; font-size: 12px; margin-top: 5px; }

.nav-list { flex: 1; overflow-y: auto; padding: 12px; }

.nav-group-label {
  padding: 12px 10px 6px;
  color: #9aa4b1;
  font-size: 12px;
  letter-spacing: 1px;
}

.nav-item {
  display: block;
  padding: 10px 12px;
  color: #4a5563;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 2px;
  font-size: 14px;
  border: 1px solid transparent;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: #f4f6fa; text-decoration: none; }
.nav-item.active { background: #eff4ff; color: #1d4ed8; border-color: #dbe6ff; }

.sidebar-foot {
  padding: 14px 16px 18px;
  border-top: 1px solid #f0f3f7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.side-user { font-size: 12px; color: #6b7280; line-height: 1.5; }
.side-user-name { display: block; color: #374151; font-size: 13px; font-weight: 500; }
.side-user-role { color: #98a2b3; font-size: 12px; margin-top: 2px; }
.side-user strong { display: block; color: #374151; font-size: 13px; font-weight: 500; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid #e5e9f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-extra { display: flex; align-items: center; gap: 8px; }

.page { padding: 20px 24px 40px; max-width: 1320px; width: 100%; }

/* ---------- 通用 ---------- */
.card {
  background: #fff;
  border: 1px solid #e5e9f0;
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 16px;
}

.card-title { font-size: 15px; font-weight: 600; margin: 0 0 14px; }
.card-sub { color: #7b8794; font-size: 12px; margin: -8px 0 14px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar .spacer { flex: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid #d5dbe5;
  background: #fff;
  color: #374151;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}

.btn:hover { background: #f7f9fc; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn-danger { color: #b42318; border-color: #f0c8c4; }
.btn-danger:hover { background: #fff5f4; }
.btn-ghost { border-color: transparent; background: transparent; color: #5f6b7a; }
.btn-ghost:hover { background: #f2f5f9; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; height: 40px; }
.btn-link {
  border: none; background: none; color: #2563eb; padding: 0; height: auto;
  cursor: pointer; font-size: 13px; font-family: inherit;
}
.btn-link:hover { text-decoration: underline; background: none; }
.btn-link.danger { color: #b42318; }

.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 13px; color: #4b5563; margin-bottom: 6px; }

input[type="text"], input[type="password"], input[type="number"], input[type="search"],
input[type="datetime-local"], input[type="file"], select, textarea {
  width: 100%;
  border: 1px solid #d5dbe5;
  border-radius: 6px;
  background: #fff;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: #1f2937;
  outline: none;
}

input:focus, select:focus, textarea:focus { border-color: #93b4ff; box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
textarea { min-height: 80px; resize: vertical; line-height: 1.6; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-error { color: #b42318; font-size: 13px; min-height: 18px; margin-bottom: 8px; }

.hint { color: #8b95a1; font-size: 12px; line-height: 1.7; }
.muted { color: #8b95a1; }

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

table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th, table.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #eef1f6;
  vertical-align: middle;
}
table.table th { background: #f8fafc; color: #5f6b7a; font-weight: 500; white-space: nowrap; }
table.table tbody tr:hover { background: #fbfcfe; }
table.table td .row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.empty { padding: 36px 10px; text-align: center; color: #98a2b3; font-size: 13px; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 18px;
  background: #f1f4f9;
  color: #5f6b7a;
  white-space: nowrap;
}
.tag.blue { background: #eaf1ff; color: #1d4ed8; }
.tag.green { background: #e9f7ef; color: #067647; }
.tag.orange { background: #fff4e6; color: #b54708; }
.tag.red { background: #feeeee; color: #b42318; }
.tag.gray { background: #f2f4f7; color: #667085; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: #fff;
  border: 1px solid #e5e9f0;
  border-radius: 8px;
  padding: 16px 18px;
}
.stat-label { color: #7b8794; font-size: 12px; }
.stat-value { font-size: 24px; font-weight: 600; margin-top: 6px; color: #1f2937; }
.stat-foot { color: #98a2b3; font-size: 12px; margin-top: 4px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid #e5e9f0; margin-bottom: 18px; flex-wrap: wrap; }
.tab {
  padding: 9px 14px;
  border: 1px solid transparent;
  border-bottom: none;
  background: none;
  cursor: pointer;
  color: #5f6b7a;
  font-size: 13px;
  font-family: inherit;
  border-radius: 6px 6px 0 0;
  margin-bottom: -1px;
}
.tab:hover { background: #f7f9fc; }
.tab.active { background: #fff; border-color: #e5e9f0; color: #1d4ed8; font-weight: 500; }

.section-title { font-size: 13px; font-weight: 600; color: #374151; margin: 18px 0 10px; }

.rule-row, .material-row {
  border: 1px solid #e8ecf2;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fafbfd;
}

.rule-grid { display: grid; grid-template-columns: 1.1fr 1.1fr .9fr .9fr .7fr .7fr auto; gap: 8px; align-items: end; }
.rule-grid .field { margin-bottom: 0; }
.material-grid { display: grid; grid-template-columns: 1.6fr 100px 90px auto; gap: 10px; align-items: end; }
.material-grid .field { margin-bottom: 0; }
.material-content { margin-top: 10px; }
.material-content .field { margin-bottom: 0; }

.checkbox-list { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.checkbox-item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #4b5563; cursor: pointer; }
.checkbox-item input { width: 14px; height: 14px; margin: 0; }

.permission-group { border: 1px solid #eef1f6; border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; }
.permission-group-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.permission-group-name { font-size: 13px; font-weight: 600; color: #374151; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .42);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px 24px;
  z-index: 50;
  overflow-y: auto;
}

.modal {
  background: #fff;
  border-radius: 10px;
  width: 560px;
  max-width: 100%;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 72px);
}
.modal.wide { width: 860px; }
.modal.narrow { width: 440px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eff2f6;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  border: none; background: none; font-size: 18px; line-height: 1;
  color: #8b95a1; cursor: pointer; padding: 2px 4px;
}
.modal-close:hover { color: #374151; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #eff2f6;
}

.toast-root { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast {
  background: #1f2937;
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .2);
  max-width: 360px;
}
.toast.error { background: #b42318; }

.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.split-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.course-card {
  border: 1px solid #e5e9f0;
  border-radius: 8px;
  background: #fff;
  padding: 16px 18px;
  margin-bottom: 12px;
}
.course-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.course-title { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
.course-meta { color: #8b95a1; font-size: 12px; line-height: 1.7; }
.course-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.question-stem { line-height: 1.7; max-width: 620px; }
.option-list { display: flex; flex-direction: column; gap: 8px; }
.option-item { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border: 1px solid #e8ecf2; border-radius: 6px; background: #fbfcfe; }
.option-item .opt-key { color: #8b95a1; font-size: 12px; width: 18px; flex: 0 0 18px; padding-top: 2px; }

.exam-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.exam-head h2 { font-size: 18px; margin: 0 0 6px; }
.countdown { font-size: 22px; font-weight: 600; color: #b54708; font-variant-numeric: tabular-nums; }
.countdown.low { color: #b42318; }

.answer-block { margin-bottom: 16px; }
.answer-block .stem { font-weight: 500; margin-bottom: 10px; line-height: 1.7; }
.answer-type { color: #8b95a1; font-size: 12px; margin-left: 8px; font-weight: normal; }

.ceiling { max-height: 300px; overflow-y: auto; border: 1px solid #e5e9f0; border-radius: 6px; padding: 10px; }

.import-area { width: 100%; min-height: 260px; font-family: Consolas, "Courier New", monospace; font-size: 12px; }

@media (max-width: 900px) {
  .sidebar { width: 176px; flex-basis: 176px; }
  .form-grid, .split-2, .split-3 { grid-template-columns: 1fr; }
  .rule-grid { grid-template-columns: 1fr 1fr; }
  .material-grid { grid-template-columns: 1fr 1fr; }
}
