/* 后台样式：无 JS、无外部资源、无内联样式（CSP 只允许同源样式文件） */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fee2e2;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --side: #0f172a;
  --side-text: #cbd5e1;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary); }
h1 { font-size: 22px; margin: 0; line-height: 1.3; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 4px; }
p { margin: 0 0 10px; }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 14px; letter-spacing: .5px; word-break: break-all; }
ol { padding-left: 20px; }

/* ---------- 整体布局：左侧导航 + 右侧内容 ---------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side);
  color: var(--side-text);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.side .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: #fff; font-size: 16px; font-weight: 700; }
.side .logo {
  width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px; color: #fff; flex: none;
}
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side .group-title { margin: 14px 10px 4px; font-size: 12px; color: #64748b; letter-spacing: 1px; }
.side nav a {
  display: block; padding: 9px 12px; border-radius: 8px; color: var(--side-text); text-decoration: none;
  border-left: 3px solid transparent;
}
.side nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side nav a.active { background: rgba(99, 102, 241, .25); color: #fff; font-weight: 600; border-left-color: #818cf8; }
.side .me { margin-top: auto; padding: 12px; border-radius: 10px; background: rgba(255, 255, 255, .06); }
.side .me .name { color: #fff; font-weight: 600; word-break: break-all; }
.side .me .role { font-size: 12px; color: #94a3b8; margin-bottom: 8px; }
.side .me form { margin: 0; }
.side .me button { width: 100%; background: rgba(255, 255, 255, .12); color: #fff; padding: 6px 10px; }
.side .me button:hover { background: rgba(255, 255, 255, .22); }

.content { padding: 28px 32px 48px; max-width: 1320px; width: 100%; }
.page-head { margin-bottom: 20px; }
.page-head .muted { margin: 6px 0 0; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.right { margin-left: auto; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 0 0 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.card > h2 { padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2 { margin: 0; padding: 0; border: 0; }
.card-body { padding: 14px 20px; }
.card-head form { margin: 0 0 0 auto; }
.hint { background: var(--primary-soft); color: #3730a3; border-radius: 8px; padding: 10px 14px; margin: 0 0 16px; font-size: 13px; }

/* ---------- 表单 ---------- */
label { display: block; margin: 12px 0; font-weight: 600; font-size: 13px; }
label .muted { font-weight: 400; }
label.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; margin: 4px 14px 4px 0; font-size: 14px; }
input[type=text], input[type=password], input[type=search], select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px;
  font: inherit; font-weight: 400; background: #fff; color: var(--text);
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d2fe; border-color: var(--primary); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.row label { margin: 0; }
.row input[type=text], .row input[type=password], .row input[type=search], .row select { width: auto; min-width: 200px; }
.row .grow { flex: 1 1 220px; }
.row .grow input, .row .grow select { width: 100%; }
.stack > * { margin-bottom: 12px; }
.stack > *:last-child { margin-bottom: 0; }
.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0 6px 0 0; }
.inline select { width: auto; margin: 0; padding: 5px 8px; }
.checks { margin: 10px 0; max-height: 200px; overflow: auto; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #f9fafb; }

/* ---------- 按钮 ---------- */
button, .btn, label.as-btn {
  display: inline-block; padding: 8px 16px; border: 0; border-radius: 8px; background: var(--primary); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.4; margin: 0;
}
button:hover, .btn:hover, label.as-btn:hover { background: var(--primary-hover); }
button.secondary, .btn.secondary, label.as-btn.secondary { background: #e5e7eb; color: #1f2937; }
button.secondary:hover, .btn.secondary:hover, label.as-btn.secondary:hover { background: #d1d5db; }
button.danger, .btn.danger, label.as-btn.danger { background: var(--danger); }
button.danger:hover, .btn.danger:hover, label.as-btn.danger:hover { background: var(--danger-hover); }
button.small, .btn.small, label.as-btn.small { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
button.block { width: 100%; padding: 10px 16px; }
td.actions label.as-btn { margin: 0 6px 0 0; }
.card-head > label.as-btn { margin-left: auto; }

/* 弹层：勾选隐藏框后盖住整页，点遮罩或「关闭」收起。不占文档流，表格行不会被撑开。 */
input.modal-toggle {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0, 0, 0, 0); border: 0; white-space: nowrap;
}
.modals, .modal-slot { height: 0; }
.modal { display: none; }
input.modal-toggle:checked + .modal {
  display: block; position: fixed; inset: 0; z-index: 80;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .48); cursor: pointer; }
.modal-card {
  position: relative; z-index: 1; margin: 10vh auto 0; width: min(480px, calc(100% - 32px));
  max-height: 80vh; overflow: auto; background: #fff; border-radius: 12px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
}
.modal-card.wide { width: min(680px, calc(100% - 32px)); }
.modal-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: #fff;
}
.modal-head h2 { margin: 0; padding: 0; border: 0; font-size: 16px; }
label.modal-x {
  margin: 0 0 0 auto; padding: 4px 8px; border-radius: 6px; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer;
}
label.modal-x:hover { background: #f1f5f9; color: var(--text); }
.modal-form { padding: 16px 18px 18px; }
.modal-form > p { margin: 0 0 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
body:has(input.modal-toggle:checked) { overflow: hidden; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
th { background: #f8fafc; font-weight: 600; font-size: 12px; color: #475569; white-space: nowrap; letter-spacing: .3px; }
tbody tr:hover td { background: #fafbff; }
tr:last-child td { border-bottom: 0; }
td.wrap { word-break: break-all; max-width: 280px; }
td.preview { max-width: 360px; color: #374151; }
td.preview span { display: block; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.empty { text-align: center; color: var(--muted); padding: 28px 14px; }
td.actions { white-space: nowrap; }
tr.dim td { color: #9ca3af; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--border); }
.pager-links { display: inline-flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.pager .pg { min-width: 32px; padding: 5px 10px; text-align: center; border-radius: 6px; border: 1px solid var(--border); background: #fff; color: #1f2937; font-size: 13px; text-decoration: none; line-height: 1.2; }
.pager a.pg:hover { background: var(--primary-soft); border-color: var(--primary); }
.pager .pg.cur { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pager .pg.off { color: #9ca3af; background: #f8fafc; }
.pager .pg.gap { border-color: transparent; background: transparent; min-width: 0; padding: 5px 2px; }

.content-box { margin: 10px 0 0; padding: 12px 14px; background: #f9fafb; border: 1px solid var(--border); border-radius: 8px; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; font: inherit; }
.checks.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 2px 14px; max-height: none; margin: 0; }
.checks.grid label.check { margin: 4px 0; }
.send-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- 标签 / 提示 ---------- */
.tag { display: inline-block; padding: 1px 9px; border-radius: 999px; background: #e5e7eb; color: #374151; font-size: 12px; font-weight: 600; margin: 1px 2px 1px 0; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.err { background: var(--danger-soft); color: #991b1b; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.info { background: var(--primary-soft); color: #3730a3; }
.flash { padding: 11px 16px; border-radius: 8px; margin: 0 0 18px; word-break: break-all; border-left: 4px solid; font-weight: 500; }
.flash.ok { background: var(--ok-soft); color: #166534; border-color: #22c55e; }
.flash.err { background: var(--danger-soft); color: #991b1b; border-color: #ef4444; }
.content > .flash.toast {
  position: fixed; z-index: 70; top: 16px; right: 20px; left: auto; width: min(420px, calc(100vw - 32px));
  margin: 0; box-shadow: 0 12px 32px rgba(15, 23, 42, .16);
}

/* ---------- 首页统计 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; border-top: 3px solid var(--primary); }
.stat b { display: block; font-size: 28px; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.warn { border-top-color: #f59e0b; background: #fffbeb; }
.stat.warn b { color: var(--warn); }
.stat.good { border-top-color: #22c55e; }

/* ---------- 登录 / 绑定验证器（无侧边栏） ---------- */
body.plain { background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%); min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 420px; }
.auth-box .brand { text-align: center; color: #fff; margin-bottom: 18px; }
.auth-box .brand .logo {
  width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, #6366f1, #a78bfa);
  display: inline-flex; align-items: center; justify-content: center; font-size: 24px; margin-bottom: 8px;
}
.auth-box .brand div { font-size: 18px; font-weight: 700; }
.auth-box .card { padding: 26px 26px 22px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); border: 0; }
.auth-box .card h1 { font-size: 20px; margin-bottom: 14px; }
.auth-box.wide { max-width: 520px; }
.auth-foot { text-align: center; margin-top: 14px; }
.auth-foot form { display: inline; }
.auth-foot button { background: none; color: #c7d2fe; padding: 2px 6px; font-weight: 400; }
.auth-foot button:hover { background: none; color: #fff; text-decoration: underline; }
.narrow { max-width: 520px; }

/* ---------- 手机 / 窄屏 ---------- */
@media (max-width: 900px) {
  .shell { display: block; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px; }
  .side nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
  .side .group-title { display: none; }
  .side nav a { border-left: 0; padding: 6px 10px; }
  .side .me { margin: 0 0 0 auto; order: 2; padding: 6px 10px; display: flex; align-items: center; gap: 10px; }
  .side .me .role { display: none; }
  .side .me .name { margin: 0; }
  .side .me button { width: auto; }
  .content { padding: 18px 14px 36px; }
  .content > .flash.toast { top: auto; bottom: 16px; right: 16px; left: 16px; width: auto; }
  .row input[type=text], .row input[type=password], .row select { min-width: 140px; }
}
