:root {
  --ink: #1f2a37;
  --paper: #f4f1e9;
  --card: #ffffff;
  --accent: #0e7490;
  --accent-dark: #0b5f76;
  --accent2: #b45309;
  --line: #e2ddd2;
  --muted: #6b7280;
  --ok: #166534;
  --ok-bg: #dcfce7;
  --bad: #991b1b;
  --bad-bg: #fee2e2;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }

/* ===== 登录 ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 12%, rgba(14, 116, 144, .16), transparent 40%),
    radial-gradient(circle at 84% 82%, rgba(180, 83, 9, .12), transparent 42%),
    var(--paper);
}

.login-card {
  width: 368px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px 32px 28px;
  box-shadow: 0 18px 48px rgba(31, 42, 55, .12);
  text-align: center;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  flex: none;
}

.brand-mark.big {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  font-size: 26px;
  margin-bottom: 16px;
}

.login-card h1 { font-size: 20px; margin: 0 0 6px; letter-spacing: .06em; }
.login-card .sub { margin: 0 0 24px; color: var(--muted); font-size: 13px; }

.login-card label {
  display: block;
  text-align: left;
  font-size: 13px;
  color: #475569;
  margin-bottom: 14px;
}

.login-card input {
  width: 100%;
  height: 42px;
  margin-top: 6px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fcfbf7;
  outline: none;
}

.login-card input:focus { border-color: var(--accent); background: #fff; }

.form-msg { min-height: 20px; margin-top: 12px; font-size: 13px; color: var(--bad); }

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

.side {
  width: 232px;
  flex: none;
  background: var(--ink);
  color: #cbd5e1;
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
  margin-bottom: 16px;
}

.side-brand strong { display: block; color: #fff; font-size: 15px; letter-spacing: .08em; }
.side-brand small { display: block; color: #94a3b8; font-size: 11px; margin-top: 2px; letter-spacing: .12em; }

#nav { display: flex; flex-direction: column; gap: 4px; }

#nav button {
  text-align: left;
  border: 0;
  background: transparent;
  color: #cbd5e1;
  padding: 11px 14px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  letter-spacing: .04em;
}

#nav button:hover { background: rgba(255, 255, 255, .07); color: #fff; }
#nav button.active { background: var(--accent); color: #fff; font-weight: 600; }

.side-foot {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, .1);
  padding: 14px 8px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.link {
  border: 0;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px;
}
.link:hover { color: #fff; }

.side-user { display: flex; flex-direction: column; min-width: 0; line-height: 1.4; }
#adminName { color: #e2e8f0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 132px; }
#adminRole { color: #94a3b8; font-size: 11px; }
.side-links { display: flex; gap: 2px; flex: none; }
.td-note { color: var(--muted); font-size: 11.5px; }
td.acc-remark { white-space: normal; min-width: 120px; max-width: 200px; line-height: 1.5; }

main {
  flex: 1;
  min-width: 0;
  padding: 26px 32px 56px;
  max-width: 1500px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h2 { margin: 0; font-size: 22px; letter-spacing: .04em; }
.topbar p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }

/* ===== 卡片 ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(31, 42, 55, .05);
}

.card h3 { margin: 0 0 14px; font-size: 15px; letter-spacing: .04em; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
}

.stat span { display: block; color: var(--muted); font-size: 12.5px; }
.stat strong { display: block; font-size: 30px; line-height: 1.25; margin: 6px 0 2px; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat small { color: #94a3b8; font-size: 11.5px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid2 .card { margin-bottom: 0; }

.steps { margin: 0; padding-left: 20px; color: #475569; font-size: 13.5px; line-height: 2; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.copy-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 10px;
}

.copy-row code {
  flex: 1;
  min-width: 0;
  overflow: auto;
  background: #f8f6f0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  white-space: nowrap;
}

/* ===== 表单与按钮 ===== */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }

.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form.wrap { align-items: center; }

input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfbf7;
  color: var(--ink);
  outline: none;
}

input, select { height: 38px; padding: 0 10px; }
textarea { padding: 9px 10px; width: 100%; resize: vertical; }

input:focus, select:focus, textarea:focus { border-color: var(--accent); background: #fff; }

.toolbar input { width: 210px; }
.inline-form input { width: 200px; }
.inline-form input[type="file"] { width: 260px; padding: 6px 8px; height: auto; }

.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #475569; white-space: nowrap; }
.check input { width: 16px; height: 16px; margin: 0; }

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 15px;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  font-size: 13.5px;
  white-space: nowrap;
}

.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost { border-color: var(--line); color: #475569; }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn.danger { border-color: #fecaca; color: var(--bad); background: #fff; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; height: 42px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.icon-btn {
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
}
.icon-btn:hover { color: var(--ink); }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  padding: 10px 12px;
  background: #faf8f3;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1ede4;
  font-size: 13.5px;
  vertical-align: middle;
  white-space: nowrap;
}
td.wrap { white-space: normal; min-width: 220px; }

/* 内容表加了「补丁」列，两个 wrap 列按固定宽度收窄，避免整表在常见桌面宽度下横向溢出 */
#view-contents td.wrap { min-width: 0; max-width: 170px; }
#view-contents th:nth-child(5), #view-contents td:nth-child(5) { width: 170px; }
#view-contents th:nth-child(6), #view-contents td:nth-child(6) { width: 130px; white-space: normal; }
tbody tr:hover td { background: #fcfbf7; }
td.empty { text-align: center; color: var(--muted); padding: 28px 0; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.7;
  white-space: nowrap;
}
.badge.on { color: var(--ok); background: var(--ok-bg); }
.badge.off { color: var(--bad); background: var(--bad-bg); }
.badge.gray { color: #475569; background: #f1f5f9; }

select.mini { height: 30px; font-size: 12.5px; max-width: 170px; padding: 0 6px; }

/* ===== 学情弹窗 ===== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; margin-bottom: 8px; }
.stat { background: #faf8f3; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat .n { font-size: 20px; font-weight: 700; color: var(--accent); line-height: 1.3; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.modal-sub { font-size: 13px; color: var(--ink); margin: 16px 0 6px; }
.days { display: flex; gap: 8px; align-items: flex-end; margin: 8px 0 4px; }
.day { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; font-size: 11px; color: var(--muted); }
.day .bar { width: 100%; max-width: 34px; background: var(--accent); border-radius: 4px 4px 0 0; opacity: .82; }
.day b { font-weight: 600; color: #334155; font-size: 11px; }

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.pager select { height: 32px; font-size: 12.5px; }

/* ===== 操作日志 ===== */
.audit-toolbar input[type="datetime-local"] { width: 190px; }
.audit-note { margin: 0 0 12px; }
.audit-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 20px;
  margin: 2px 0 16px;
  padding: 12px 14px;
  background: #faf8f3;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.audit-meta > div { display: flex; gap: 8px; min-width: 0; font-size: 13px; }
.audit-meta span { flex: none; width: 64px; color: var(--muted); }
.audit-meta b { font-weight: 600; overflow-wrap: anywhere; }
.audit-meta .span2 { grid-column: span 2; }
.audit-meta .err-text { color: var(--bad); }
.audit-diff { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 4px; }
.audit-diff h4 { margin: 0 0 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.audit-diff pre {
  margin: 0;
  padding: 10px 12px;
  max-height: 340px;
  overflow: auto;
  background: #f8f6f1;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ===== 弹窗 ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-card {
  width: min(560px, 94vw);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  padding: 22px 24px 24px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, .28);
}

.modal-card.wide { width: min(920px, 94vw); }

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { margin: 0; font-size: 17px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: #475569; margin-bottom: 6px; }
.field input, .field textarea, .field select { width: 100%; }
.login-note { font-size: 12px; color: var(--muted); margin-top: 14px; line-height: 1.7; text-align: center; }
.kv-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.kv-line b { font-weight: 600; color: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ===== 权限点树 ===== */
.perm-tree { display: grid; gap: 10px; max-height: 52vh; overflow: auto; padding-right: 4px; }
.perm-group { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.perm-node { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #475569; padding: 4px 0; }
.perm-node input { width: 16px; height: 16px; margin: 0; flex: none; }
.perm-node code { font-size: 11.5px; color: var(--muted); background: #f1f5f9; padding: 1px 6px; border-radius: 5px; }
.perm-parent { border-bottom: 1px dashed var(--line); padding-bottom: 8px; margin-bottom: 4px; }
.perm-parent strong { color: var(--ink); }
.perm-children { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 16px; padding-left: 24px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .28);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all .22s ease;
  max-width: 70vw;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: #7f1d1d; }

@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .shell { display: block; }
  .side { width: auto; height: auto; position: static; padding: 14px 14px 10px; }
  .side-brand { padding-bottom: 12px; margin-bottom: 10px; }
  #nav { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  #nav button { white-space: nowrap; padding: 8px 12px; }
  .side-foot { margin-top: 10px; padding-top: 10px; }
  main { padding: 18px 14px 40px; }
  .toolbar input { width: 100%; }
  .audit-toolbar input[type="datetime-local"] { width: 100%; }
  .audit-meta { grid-template-columns: 1fr; }
  .audit-meta .span2 { grid-column: auto; }
  .audit-diff { grid-template-columns: 1fr; }
  .inline-form input { width: 100%; }
  .inline-form input[type="file"] { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat strong { font-size: 24px; }
}
