:root {
  --navy: #111827;
  --navy-2: #1f2937;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 4px 18px rgba(17, 24, 39, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 14px; }

/* 登录 */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #111827 0%, #1e3a8a 55%, #2563eb 100%);
  padding: 20px;
}
.login-box {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 38px 36px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
}
.login-box h1 { margin: 0 0 6px; font-size: 24px; }
.login-box .sub { color: var(--muted); margin-bottom: 26px; }
.login-box .logo-dot {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  display: grid; place-items: center; color: #fff; font-weight: 800;
  margin-bottom: 18px;
}
.login-tip { margin-top: 18px; padding: 12px; background: var(--blue-soft); border-radius: 8px; color: #1e40af; font-size: 12px; }
.portal-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 18px; }
.portal-card { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); text-decoration: none; transition: .18s; }
.portal-card:hover { border-color: var(--blue); background: var(--blue-soft); transform: translateY(-2px); }
.portal-card span { font-size: 12px; color: var(--muted); }
.perm-matrix input[type=checkbox] { width: auto; }
.quota-bar { height: 8px; border-radius: 8px; background: #e5e7eb; overflow: hidden; margin-top: 6px; }
.quota-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--green)); }

/* 布局 */
.app { display: flex; min-height: 100vh; align-items: stretch; }
.sidebar {
  width: 224px; flex: 0 0 224px;
  background: var(--navy);
  color: #d1d5db;
  display: flex; flex-direction: column;
  min-height: 100vh;
}
.sidebar .brand {
  height: 64px; display: flex; align-items: center; gap: 10px;
  padding: 0 20px; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand i {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  display: grid; place-items: center; font-style: normal; font-size: 15px;
}
.nav { flex: 1; overflow: visible; padding: 14px 10px; }
.nav-group { color: #6b7280; font-size: 11px; letter-spacing: 1px; padding: 14px 12px 6px; text-transform: uppercase; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin: 2px 0; border-radius: 8px;
  color: #d1d5db; cursor: pointer; font-size: 14px;
}
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: var(--blue); color: #fff; }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar .foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #9ca3af; }

.main { flex: 1; min-width: 0; overflow-x: hidden; }
.topbar {
  height: 64px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 18px; }
.topbar .user { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--blue-soft);
  color: var(--blue); display: grid; place-items: center; font-weight: 700;
}
.content { padding: 24px 26px 60px; width: 100%; max-width: none; min-width: 0; }
.grid > * { min-width: 0; }
.card { min-width: 0; }
.card svg { display: block; width: 100%; max-width: 100%; height: auto; }
.card .row, .card .checks { max-width: 100%; }

/* 通用组件 */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h3 { margin: 0 0 4px; font-size: 20px; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h4 { margin: 0 0 14px; font-size: 15px; }
.stat { padding: 18px 20px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat .value.blue { color: var(--blue); }
.stat .value.green { color: var(--green); }
.stat .value.red { color: var(--red); }
.stat .value.amber { color: var(--amber); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--border); background: #fff;
  border-radius: 8px; cursor: pointer; color: var(--text); font-weight: 500;
  transition: .18s;
}
.btn:hover { border-color: #cbd5e1; background: #f9fafb; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input[type=text], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #d1d5db;
  border-radius: 8px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
textarea { min-height: 90px; resize: vertical; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; margin-bottom: 5px; color: #374151; font-weight: 500; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 4px 0; }
.checks label { display: inline-flex; gap: 6px; align-items: center; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: #f9fafb; color: #374151; font-size: 12px; font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: #fafbff; }
.table-wrap { overflow-x: auto; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; background: #f3f4f6; color: #374151; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.amber { background: #fef3c7; color: #92400e; }
.badge.blue { background: var(--blue-soft); color: #1e40af; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filter-bar input, .filter-bar select { width: auto; min-width: 150px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs button { border: none; background: none; padding: 9px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* 弹窗 */
.mask { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: min(640px, 100%); max-height: 88vh; overflow-y: auto; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.modal.wide { width: min(880px, 100%); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h4 { margin: 0; font-size: 17px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.x { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }

/* Toast */
#toast-root { position: fixed; top: 18px; right: 18px; z-index: 300; }
.toast { background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; margin-bottom: 8px; box-shadow: var(--shadow); animation: slide .25s; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes slide { from { transform: translateX(20px); opacity: 0; } }

/* 考试全屏 */
.exam-screen { position: fixed; inset: 0; background: #f4f6fb; z-index: 200; display: flex; flex-direction: column; }
.exam-top { background: #111827; color: #fff; padding: 12px 26px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.exam-top .title { font-weight: 600; font-size: 16px; }
.exam-top .timer { font-size: 20px; font-weight: 700; color: #fca5a5; font-variant-numeric: tabular-nums; }
.exam-top .timer.safe { color: #93c5fd; }
.exam-body { flex: 1; overflow-y: auto; padding: 30px 20px; }
.exam-q { max-width: 820px; margin: 0 auto; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.exam-q .qno { color: var(--blue); font-weight: 600; margin-bottom: 10px; }
.exam-q .qtitle { font-size: 18px; font-weight: 600; line-height: 1.7; margin-bottom: 22px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px;
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; cursor: pointer;
  transition: .15s;
}
.opt:hover { border-color: #93c5fd; background: #f8fbff; }
.opt.selected { border-color: var(--blue); background: var(--blue-soft); }
.opt .key { width: 24px; height: 24px; flex: 0 0 24px; border-radius: 50%; background: #f3f4f6; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.opt.selected .key { background: var(--blue); color: #fff; }
.exam-foot { background: #fff; border-top: 1px solid var(--border); padding: 14px 26px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; }
.dots span { width: 28px; height: 28px; border-radius: 6px; background: #f3f4f6; display: grid; place-items: center; font-size: 12px; cursor: pointer; }
.dots span.done { background: var(--blue); color: #fff; }
.dots span.cur { outline: 2px solid var(--blue); outline-offset: 2px; }
.warn-box { background: #fef3c7; color: #92400e; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; }

/* 富文本编辑器 */
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; border: 1px solid #d1d5db; border-bottom: none; border-radius: 8px 8px 0 0; background: #f9fafb; }
.editor-toolbar button { border: 1px solid transparent; background: #fff; border-radius: 6px; padding: 4px 9px; cursor: pointer; font-size: 13px; color: #374151; }
.editor-toolbar button:hover { border-color: #cbd5e1; background: var(--blue-soft); color: var(--blue); }
.editor-toolbar select { width: auto; padding: 4px 6px; font-size: 13px; }
.editor-area { min-height: 260px; max-height: 520px; overflow-y: auto; padding: 14px 16px; border: 1px solid #d1d5db; border-radius: 0 0 8px 8px; background: #fff; outline: none; line-height: 1.8; }
.editor-area:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.editor-area h2 { font-size: 20px; margin: 12px 0 8px; }
.editor-area h3 { font-size: 17px; margin: 10px 0 6px; }
.editor-area img { max-width: 100%; height: auto; border-radius: 8px; }
.editor-source { width: 100%; min-height: 260px; font-family: Consolas, Monaco, monospace; font-size: 12px; border-radius: 0 0 8px 8px; }
.editor-hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.setting-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.setting-grid .field.wide { grid-column: 1 / -1; }
.setting-note { color: var(--muted); font-size: 12px; word-break: break-all; }
.full-form { max-width: 920px; margin: 0 auto; }
.full-form .card { padding: 26px 30px; }
.avatar-preview { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; background: var(--blue-soft); border: 1px solid var(--border); display: inline-block; vertical-align: middle; }
.avatar-preview.placeholder { display: grid; place-items: center; color: var(--blue); font-size: 26px; font-weight: 700; }
.quota-warn { background: #fef3c7; color: #92400e; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.news-content { line-height: 1.9; word-break: break-word; }
.news-content img { max-width: 100%; height: auto; }

@media (max-width: 980px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .sidebar { width: 64px; flex-basis: 64px; }
  .sidebar .brand span, .nav a span:not(.ico), .nav-group, .sidebar .foot { display: none; }
  .sidebar .brand { padding: 0 17px; }
  .nav a { justify-content: center; }
  .content { padding: 18px; }
  .setting-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; }
}
