:root {
  --primary: #2f7ff3;
  --primary-dark: #1f6ad9;
  --sidebar: #232c38;
  --sidebar-hover: #2c3746;
  --text: #2b3445;
  --text-2: #6b7787;
  --text-3: #9aa5b4;
  --border: #e6eaf0;
  --bg: #f2f4f7;
  --card: #ffffff;
  --red: #f0524f;
  --green: #22a06b;
  --orange: #f59f0a;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
a { color: var(--primary); text-decoration: none; }

/* ================== 登录 ================== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1f2a3a 0%, #2f4258 60%, #3b6ea5 100%);
}
.login-card {
  width: 380px;
  background: #fff;
  border-radius: 14px;
  padding: 36px 32px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
}
.login-logo {
  width: 56px; height: 56px; line-height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2f7ff3, #6b5cf6);
  color: #fff; font-size: 20px; font-weight: 700;
  text-align: center; margin-bottom: 18px;
}
.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-sub { color: var(--text-3); font-size: 13px; margin: 0 0 24px; }
.login-field { display: block; margin-bottom: 16px; }
.login-field span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.login-field input {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none; transition: border-color .2s;
}
.login-field input:focus { border-color: var(--primary); }
.login-tip { font-size: 12px; color: var(--text-3); text-align: center; margin: 16px 0 0; }

/* ================== 布局 ================== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 200px;
  background: var(--sidebar);
  color: #c9d2de;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #3d4a5c; border-radius: 3px; }

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.brand-logo {
  width: 30px; height: 30px; line-height: 30px; text-align: center;
  border-radius: 8px; font-size: 15px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #2f7ff3, #6b5cf6);
}
.brand-name { font-size: 14px; color: #eef3f9; font-weight: 600; letter-spacing: .5px; }

.menu { padding: 8px 0 24px; }
.menu-group > .menu-title {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; cursor: pointer; user-select: none;
  font-size: 14px; color: #cfd8e4;
}
.menu-group > .menu-title:hover { background: var(--sidebar-hover); }
.menu-group > .menu-title .arrow {
  margin-left: auto; font-size: 10px; color: #7b8798;
  transition: transform .2s;
}
.menu-group.open > .menu-title .arrow { transform: rotate(90deg); }
.menu-group .menu-icon { width: 16px; text-align: center; opacity: .9; }
.menu-children { display: none; padding: 2px 0 6px; }
.menu-group.open .menu-children { display: block; }
.menu-item {
  padding: 9px 16px 9px 42px;
  font-size: 13px; color: #a9b4c3; cursor: pointer;
  border-left: 3px solid transparent;
}
.menu-item:hover { color: #fff; background: var(--sidebar-hover); }
.menu-item.active {
  color: #fff; background: var(--primary); border-left-color: #8fc0ff;
}
.menu-badge {
  float: right; min-width: 18px; height: 18px; line-height: 18px;
  padding: 0 5px; border-radius: 9px; font-size: 11px; text-align: center;
  background: var(--red); color: #fff;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 52px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; position: sticky; top: 0; z-index: 20;
}
.crumb { font-size: 14px; color: var(--text-2); }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.admin-name { color: var(--text-2); }

.content { padding: 18px 20px 40px; }

/* ================== 按钮 / 表单 ================== */
.btn {
  height: 34px; padding: 0 16px; border-radius: 6px; border: 1px solid transparent;
  font-size: 13px; cursor: pointer; background: #fff; color: var(--text);
  transition: all .18s; white-space: nowrap;
}
.btn:hover { opacity: .9; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-default { border-color: var(--border); background: #fff; color: var(--text-2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-text { background: transparent; color: var(--text-2); padding: 0 8px; }
.btn-block { width: 100%; height: 42px; }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 4px; }
.btn + .btn { margin-left: 8px; }

input[type="text"], input[type="number"], input[type="password"], select, textarea {
  font-family: inherit; font-size: 13px; color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 0 10px; height: 34px; outline: none; background: #fff;
  transition: border-color .18s;
}
textarea { height: auto; padding: 8px 10px; line-height: 1.6; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }

/* ================== 卡片 ================== */
.card {
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--border); margin-bottom: 16px;
}
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 14px;
}
.card-body { padding: 18px; }

/* ================== 仪表盘 ================== */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-head { display: flex; align-items: center; justify-content: space-between; }
.stat-title { color: var(--text-2); font-size: 13px; }
.stat-pill {
  font-size: 12px; color: var(--primary); border: 1px solid #cfe0fb;
  background: #f2f7ff; border-radius: 4px; padding: 1px 7px;
}
.stat-value { font-size: 30px; font-weight: 700; margin: 10px 0 6px; letter-spacing: -.5px; }
.stat-desc { font-size: 12px; color: var(--text-3); display: flex; gap: 10px; }
.stat-desc .up { color: var(--red); }
.stat-desc .down { color: var(--green); }
.stat-foot {
  margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border);
  display: flex; justify-content: space-between; font-size: 12px; color: var(--text-3);
}
.stat-foot b { color: var(--text); font-weight: 600; }

.quick-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 12px; margin-bottom: 16px; }
.quick-item {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 8px; text-align: center; cursor: pointer; transition: all .18s;
}
.quick-item:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(31, 63, 116, .08); border-color: #cfdcf1; }
.quick-icon {
  width: 38px; height: 38px; line-height: 38px; margin: 0 auto 8px;
  border-radius: 50%; font-size: 17px; background: #eef3fb;
}
.quick-name { font-size: 12px; color: var(--text-2); }

.chart-legend { display: flex; gap: 18px; justify-content: center; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.chart-legend .line-dot { width: 12px; height: 2px; border-radius: 1px; vertical-align: 3px; }
#trendChart { width: 100%; height: 320px; display: block; }

/* ================== 工具栏 ================== */
.toolbar {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }
.toolbar input[type="text"] { width: 220px; }
.toolbar input.flt-input { width: 180px; }
.toolbar .flt-input::placeholder { color: #b6bec9; }
.toolbar select { width: 130px; }
.toolbar-label { font-size: 13px; color: var(--text-2); }

/* ================== 表格 ================== */
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: #fafbfd; color: var(--text-2); font-weight: 600;
  text-align: left; padding: 11px 12px; white-space: nowrap;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
tbody td {
  padding: 10px 12px; border-bottom: 1px solid #f3f5f8;
  color: var(--text); vertical-align: middle;
}
tbody tr:hover { background: #f8fafd; }
tbody tr:last-child td { border-bottom: none; }
.td-empty { text-align: center; color: var(--text-3); padding: 48px 0; }
.cell-img { width: 62px; height: 42px; border-radius: 4px; object-fit: cover; border: 1px solid var(--border); background: #f7f9fc; cursor: zoom-in; display: block; }
.cell-img:hover { border-color: #2f7ef3; }
.cell-empty-img { color: #b6bfcc; font-size: 12px; }

/* 图片放大预览 */
.img-viewer { position: fixed; inset: 0; z-index: 999; background: rgba(17,24,39,.78); display: flex; align-items: center; justify-content: center; padding: 40px; cursor: zoom-out; }
.img-viewer img { max-width: 92vw; max-height: 88vh; background: #fff; border-radius: 6px; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
.cell-empty-img { color: var(--text-3); font-size: 12px; }
.ellipsis { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 12px; line-height: 20px; }
.tag-blue { color: var(--primary); background: #eaf2ff; }
.tag-green { color: var(--green); background: #e8f7f0; }
.tag-red { color: var(--red); background: #fdeceb; }
.tag-orange { color: var(--orange); background: #fdf4e3; }
.tag-gray { color: var(--text-2); background: #f1f3f7; }

.ops { white-space: nowrap; }
.ops a { color: var(--primary); cursor: pointer; font-size: 13px; }
.ops a.danger { color: var(--red); }
.ops a + a { margin-left: 10px; }
.ops a:hover { text-decoration: underline; }

/* 操作列固定在右侧，宽表格横向滚动时也能点到 */
thead th:last-child, tbody td:last-child {
  position: sticky;
  right: 0;
  background: #fff;
  box-shadow: -6px 0 8px -6px rgba(15, 23, 42, .12);
  z-index: 1;
}
thead th:last-child { background: #fafbfd; z-index: 2; }
tbody tr:hover td:last-child { background: #f8fafd; }

.pager {
  display: flex; align-items: center; justify-content: flex-end; gap: 6px;
  padding: 12px 16px; background: #fff; border: 1px solid var(--border);
  border-top: none; border-radius: 0 0 var(--radius) var(--radius);
  font-size: 13px; color: var(--text-2);
}
.pager button {
  min-width: 30px; height: 30px; border: 1px solid var(--border);
  background: #fff; border-radius: 5px; cursor: pointer; color: var(--text-2);
}
.pager button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager button:disabled { opacity: .45; cursor: not-allowed; }
.pager .pager-info { margin-left: 10px; }

/* ================== 配置表单 ================== */
.cfg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 28px; }
.cfg-item.full { grid-column: 1 / -1; }
.cfg-label { font-size: 13px; color: var(--text-2); margin-bottom: 7px; }
.cfg-label .req { color: var(--red); margin-left: 3px; }
.cfg-input, .cfg-item select, .cfg-item textarea { width: 100%; }
.dep-wrap { width: 100%; }
.cfg-remark { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.5; word-break: break-word; }
.radio-row { display: flex; flex-wrap: wrap; gap: 18px; padding-top: 4px; }
.radio-row label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); cursor: pointer; }
.radio-row input { accent-color: var(--primary); }

.img-field { display: flex; align-items: center; gap: 10px; }
.img-box {
  width: 76px; height: 76px; border: 1px dashed #ccd6e3; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: #fafbfd; cursor: pointer; overflow: hidden; position: relative;
}
.img-box img { width: 100%; height: 100%; object-fit: cover; }
.img-box .plus { font-size: 22px; color: #b8c4d4; }
.img-box input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.img-clear { font-size: 12px; color: var(--red); cursor: pointer; }

/* 证书 / 普通文件（不是图片，只存服务器路径） */
.file-field { display: flex; align-items: center; gap: 12px; }
.file-pick {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
  cursor: pointer; position: relative; overflow: hidden; flex-shrink: 0;
  font-size: 13px; color: var(--text-2);
}
.file-pick:hover { border-color: var(--primary); color: var(--primary); }
.file-pick .file-ico {
  font-size: 10px; font-weight: 700; letter-spacing: .5px; color: #fff;
  background: #94a3b8; border-radius: 3px; padding: 2px 4px; line-height: 1.3;
}
.file-pick:hover .file-ico { background: var(--primary); }
.file-pick input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 13px; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-path { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.file-empty { font-size: 12px; color: var(--text-3); }
.file-clear { font-size: 12px; color: var(--red); cursor: pointer; flex-shrink: 0; }

.form-foot {
  display: flex; justify-content: center; gap: 12px;
  padding: 18px 0 8px; border-top: 1px solid var(--border); margin-top: 8px;
}
.form-foot .btn { min-width: 110px; height: 38px; }

.article-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 18px; }
.article-grid .full { grid-column: 1 / -1; }
.article-content { width: 100%; min-height: 380px; font-family: Consolas, Monaco, monospace; font-size: 13px; }

/* ================== 弹窗 ================== */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(18, 26, 38, .45); }
.modal-body {
  position: relative; background: #fff; border-radius: 10px; margin-top: 8vh;
  width: 620px; max-width: calc(100vw - 40px); max-height: 80vh;
  display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0, 0, 0, .22);
}
.modal-head {
  padding: 15px 20px; border-bottom: 1px solid var(--border);
  font-weight: 600; display: flex; align-items: center; justify-content: space-between;
}
.modal-x { border: none; background: none; font-size: 15px; color: var(--text-3); cursor: pointer; }
.modal-content { padding: 20px; overflow-y: auto; }
.modal-body.modal-wide { width: 1040px; max-height: 88vh; }
.modal-body.modal-wide .modal-content {
  padding: 18px 22px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
  align-content: start;
}
.modal-body.modal-wide .field-full { grid-column: 1 / -1; }
@media (max-width: 1120px) {
  .modal-body.modal-wide { width: calc(100vw - 40px); }
  .modal-body.modal-wide .modal-content { grid-template-columns: 1fr; }
}
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: center; }
.field { margin-bottom: 16px; }
.field > .cfg-label { margin-bottom: 6px; }
.field input[type="text"], .field input[type="number"], .field select, .field textarea { width: 100%; }

/* 分组表单：一行多列（添加题库那种） */
.form-row { display: grid; gap: 0 18px; grid-column: 1 / -1; }
.form-row .field { margin-bottom: 16px; min-width: 0; }
.field-box { background: #f7f9fc; border-radius: 8px; padding: 12px 14px; }
.field-box > .cfg-label { color: #333; font-weight: 600; }
.img-compact { align-items: center; }
.img-compact .img-clear { font-size: 12px; }

/* ================== 提示 ================== */
.toast {
  position: fixed; left: 50%; top: 24px; transform: translateX(-50%) translateY(-20px);
  background: #2b3445; color: #fff; padding: 9px 18px; border-radius: 6px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }

/* ================== 响应式 ================== */
@media (max-width: 1200px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .quick-row { grid-template-columns: repeat(4, 1fr); }
  .cfg-grid { grid-template-columns: 1fr; }
  .article-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { width: 150px; }
  .stat-row { grid-template-columns: 1fr; }
  .quick-row { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------- 开关 ---------------- */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cfd6e0; border-radius: 24px; transition: background .18s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.switch input:checked + span { background: #2f7ef3; }
.switch input:checked + span::after { transform: translateX(20px); }

/* 数字/颜色输入对齐 */
.cfg-item input[type="number"] { width: 100%; }
.cfg-item input[type="color"] { padding: 0; cursor: pointer; }
