:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --border: #e3e2de;
  --ink: #1b1b1a;
  --ink-2: #55544f;
  --muted: #706e68;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #0b7a0b;
  --good-bg: #e4f4e4;
  --bad: #b42b2b;
  --bad-bg: #fbe6e6;
  --warn: #8a5a00;
  --warn-bg: #fdf0d2;
  --gray-bg: #ececea;
  --grid: #ecebe7;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
.boot { padding: 40px; color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }

/* 布局 */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 200px; flex: none; background: var(--surface); border-right: 1px solid var(--border);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh;
}
.brand { font-weight: 600; padding: 4px 10px 14px; line-height: 1.4; }
.brand span { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.side a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--ink-2); }
.side a:hover { background: var(--bg); text-decoration: none; }
.side a.on { background: #e8f0fb; color: var(--accent-ink); font-weight: 600; }
.side .spacer { flex: 1; }
.main { flex: 1; min-width: 0; padding: 24px 28px 60px; max-width: 1280px; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head .grow { flex: 1; }
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .side { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { width: 100%; padding-bottom: 4px; }
  .side .spacer { display: none; }
  .main { padding: 16px; }
}

/* 卡片 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
.grid.two > .card { margin-bottom: 0; }
.grid.two { margin-bottom: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.tile .k { font-size: 12px; color: var(--ink-2); }
.tile .v { font-size: 24px; font-weight: 600; line-height: 1.3; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 12px; color: var(--muted); }
a.tile { color: inherit; display: block; }
a.tile:hover { border-color: var(--accent); text-decoration: none; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.link:hover { background: #fafaf8; cursor: pointer; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* 表单 */
label.f { display: block; margin-bottom: 14px; }
label.f > span, .flabel { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; color: inherit; background: #fff; border: 1px solid #cfcdc7; border-radius: 6px; padding: 7px 10px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b7d3f6; border-color: var(--accent); }
input:disabled { background: var(--bg); color: var(--muted); }
input.short { width: 110px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.row > .grow { flex: 1; min-width: 160px; }
.check { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 20px; }
.plain-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.cohort-filter { max-width: 180px; }
.student-notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.change-preview { padding: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.audit-diff { display: grid; grid-template-columns: repeat(2, minmax(160px, 1fr)); gap: 16px; min-width: 340px; padding: 12px 0; }
.audit-kv { margin: 6px 0; font-size: 12px; }
.audit-kv div { margin-bottom: 6px; }
.audit-kv dt { color: var(--ink-2); }
.audit-kv dd { margin: 0; overflow-wrap: anywhere; }
.audit-pagination { margin-top: 12px; }
.advanced { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.advanced summary, details > summary { cursor: pointer; }
.advanced .row { margin-bottom: 8px; }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.warn button { display: block; margin-top: 10px; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 760px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: 90px minmax(0, 1fr); }
  .cohort-filter { max-width: 100%; }
  button, .btn, input[type=text], input[type=search], select { min-height: 44px; }
  .modal .foot { flex-wrap: wrap; }
  .codebig { font-size: 16px; overflow-wrap: anywhere; }
}

button, .btn {
  font: inherit; cursor: pointer; border: 1px solid #cfcdc7; background: #fff; color: var(--ink); border-radius: 6px; padding: 7px 14px;
  display: inline-block; white-space: nowrap;
}
button:hover, .btn:hover { background: var(--bg); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--accent-ink); }
button.danger { color: var(--bad); border-color: #e4b4b4; }
button.sm { padding: 3px 9px; font-size: 12px; }
button.linklike { border: 0; background: none; padding: 0; color: var(--accent-ink); }
button:disabled { opacity: 0.55; cursor: default; }

/* 状态 */
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.active { background: var(--good-bg); color: var(--good); }
.badge.expired { background: var(--bad-bg); color: var(--bad); }
.badge.unactivated { background: #e8f0fb; color: var(--accent-ink); }
.badge.disabled { background: var(--gray-bg); color: var(--ink-2); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.alert.err { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--good-bg); color: var(--good); }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #222; color: #fff; padding: 9px 18px; border-radius: 8px; z-index: 50; max-width: 90vw; }
.toast.err { background: var(--bad); }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; min-width: 0; }
.codebig { font-size: 22px; font-weight: 600; letter-spacing: 1px; }
.codes-out { font-size: 16px; line-height: 2; background: var(--bg); border-radius: 8px; padding: 10px 16px; max-height: 320px; overflow: auto; }

/* 弹窗 */
.mask { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 40; padding: 16px; }
.modal { background: #fff; border-radius: 12px; padding: 22px; width: 460px; max-width: 100%; max-height: 90vh; overflow: auto; }
.modal h2 { font-size: 17px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* 登录 */
.login { max-width: 340px; margin: 14vh auto 0; padding: 0 16px; }
.login h1 { margin-bottom: 4px; }
.modal .login { margin: 0; padding: 0; max-width: none; }

/* 独立管理入口：复用现有页面，仅收口登录、启用与本人复核。 */
.login.auth-card { width: calc(100% - 32px); max-width: 460px; margin: 8vh auto 32px; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 8px 28px #1b1b1a05; }
.auth-card h1 { font-size: 26px; line-height: 1.4; margin: 0 0 10px; }
.auth-card p { overflow-wrap: anywhere; }
.auth-card .auth-eyebrow { margin: 0 0 10px; color: var(--accent-ink); font-size: 13px; font-weight: 600; }
.auth-card input:not([type=checkbox]), .auth-card textarea { min-height: 46px; font-size: 16px; }
.auth-card .f { margin-top: 18px; }
.auth-card button { min-height: 44px; }
.auth-card .auth-submit { width: 100%; margin-top: 14px; }
.auth-card .auth-secondary { width: 100%; margin-top: 10px; }
.auth-card .auth-switch { display: block; margin: 8px 0 0; text-align: left; }
.auth-card .auth-remember { display: flex; align-items: flex-start; gap: 9px; white-space: normal; margin: 18px 0 8px; }
.auth-card .auth-remember input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; }
.auth-card .auth-help { margin: 22px 0 0; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.auth-card .auth-otp { letter-spacing: .2em; font-variant-numeric: tabular-nums; }
.auth-card .auth-recovery { width: 100%; min-height: 240px; resize: vertical; font-size: 13px; white-space: pre; }
.auth-card .auth-secret { font-size: 14px!important; }
.modal .login.auth-card { width: auto; padding: 0; border: 0; margin: 0; box-shadow: none; }
.auth-card :is(button,input,textarea):focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media(max-width:480px) {
  .login.auth-card { margin-top: 24px; padding: 22px; }
  .auth-card h1 { font-size: 23px; }
  .auth-card .auth-recovery { font-size: 12px; }
}

/* 图表 */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .hit.on { fill: rgba(0,0,0,.045); }
.tip {
  position: absolute; pointer-events: none; background: #1f1f1e; color: #fff; padding: 7px 10px; border-radius: 6px; font-size: 12px;
  line-height: 1.5; white-space: nowrap; z-index: 5; transform: translate(-50%, -100%);
}
.tip i, .legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
details.data { margin-top: 8px; font-size: 12px; }
details.data summary { cursor: pointer; color: var(--muted); }
details.data .table-wrap { max-height: 260px; overflow: auto; margin-top: 6px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 180px) 1fr auto; gap: 6px 10px; align-items: center; }
.hbar .track { background: var(--grid); border-radius: 4px; height: 10px; overflow: hidden; }
.hbar .fill { background: var(--series-1); height: 100%; border-radius: 4px; }
.meter { background: var(--grid); border-radius: 4px; height: 8px; width: 120px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px; }
.meter b { display: block; height: 100%; background: var(--series-1); }
.meter.full b { background: var(--bad); }
.gap { margin-left: 10px; }
