:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e6e8ec;
  --border-strong: #d5d8de;
  --text: #1f2329;
  --text-2: #4b5563;
  --muted: #8b93a1;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --sidebar: #1b2333;
  --sidebar-2: #232c3f;
  --green: #15803d;
  --green-bg: #e8f5ec;
  --amber: #b45309;
  --amber-bg: #fdf3e3;
  --red: #b91c1c;
  --red-bg: #fdeaea;
  --blue: #1d4ed8;
  --blue-bg: #e8effd;
  --gray-bg: #f1f2f4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }

.app { display: flex; min-height: 100vh; }

/* ---------- 侧栏 ---------- */
.side {
  width: 220px;
  flex: 0 0 220px;
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 20px 20px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .3px;
}

.brand span { display: block; font-size: 11px; font-weight: 400; color: #7c879c; margin-top: 4px; letter-spacing: 0; }

.nav { padding: 8px 10px; flex: 1; }

.nav-label {
  font-size: 11px;
  color: #64708a;
  padding: 12px 10px 6px;
  letter-spacing: .5px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: 7px;
  color: #c3cbd9;
  font-size: 13.5px;
  transition: background .12s, color .12s;
}

.nav a:hover { background: var(--sidebar-2); color: #fff; }

.nav a.active { background: var(--primary); color: #fff; }

.nav a .dot { width: 6px; height: 6px; border-radius: 50%; background: #64708a; flex: 0 0 6px; }

.nav a.active .dot { background: #fff; }

.side-foot { padding: 14px 18px; font-size: 11px; color: #5d6880; border-top: 1px solid #2c3549; }

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.crumb { font-size: 14px; font-weight: 500; }

.crumb small { font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 12px; }

.topbar-right { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--text-2); }

.content { padding: 22px 24px 40px; flex: 1; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}

.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-head h3 { font-size: 14px; font-weight: 600; }

.card-head .sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 8px; }

.card-body { padding: 18px; }

.card-body.tight { padding: 0; }

/* ---------- 统计块 ---------- */
.grid { display: grid; gap: 14px; margin-bottom: 18px; }

.grid-5 { grid-template-columns: repeat(5, 1fr); }

.grid-4 { grid-template-columns: repeat(4, 1fr); }

.grid-2 { grid-template-columns: repeat(2, 1fr); }

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 16px 14px;
}

.stat .label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

.stat .value { font-size: 24px; font-weight: 600; letter-spacing: -.3px; line-height: 1.1; }

.stat .value small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }

.stat .foot { font-size: 11.5px; color: var(--muted); margin-top: 8px; }

.stat.accent .value { color: var(--primary); }

.stat.warn .value { color: var(--amber); }

.stat.danger .value { color: var(--red); }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  padding: 10px 16px;
  background: #fafbfc;
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td { padding: 12px 16px; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: #fafbfd; }

.t-main { font-weight: 500; color: var(--text); }

.t-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12.5px; letter-spacing: .3px; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.tag::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .8; }

.tag-green { color: var(--green); background: var(--green-bg); }
.tag-amber { color: var(--amber); background: var(--amber-bg); }
.tag-red { color: var(--red); background: var(--red-bg); }
.tag-blue { color: var(--blue); background: var(--blue-bg); }
.tag-gray { color: #5b6472; background: var(--gray-bg); }

.tag-plain { padding: 1px 7px; border: 1px solid var(--border); border-radius: 5px; font-size: 11.5px; color: var(--text-2); background: #fff; }
.tag-plain::before { display: none; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}

.btn:hover { background: #f7f8fa; border-color: #c3c8d2; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }

.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 6px; }

.btn-link { border: none; background: none; color: var(--primary); padding: 0 4px; height: auto; font-size: 12.5px; cursor: pointer; }

.btn-link:hover { text-decoration: underline; background: none; }

.btn-link.danger { color: var(--red); }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.input, .select {
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}

.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }

.input::placeholder { color: #a8afbb; }

textarea.input { height: auto; padding: 9px 11px; line-height: 1.6; resize: vertical; }

.field { margin-bottom: 14px; }

.field > label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }

.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }

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

.toolbar .spacer { flex: 1; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }

.pager-btns { display: flex; gap: 6px; }

/* ---------- 空状态 ---------- */
.empty { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 33, .45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px 20px;
  z-index: 100;
  overflow-y: auto;
}

.modal-mask.show { display: flex; }

.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 12px 40px rgba(16, 24, 40, .16);
  animation: pop .16s ease-out;
}

.modal.wide { max-width: 860px; }

@keyframes pop { from { transform: translateY(-6px); opacity: .6; } to { transform: none; opacity: 1; } }

.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }

.modal-head h3 { font-size: 15px; font-weight: 600; }

.modal-body { padding: 20px; max-height: 60vh; overflow-y: auto; }

.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.close { border: none; background: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; border-radius: 5px; }

.close:hover { background: var(--gray-bg); color: var(--text); }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #f2f4f8; }

.login-box { width: 360px; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 32px 30px 28px; box-shadow: 0 10px 30px rgba(16, 24, 40, .06); }

.login-box h1 { font-size: 19px; font-weight: 600; margin-bottom: 6px; }

.login-box p.sub { font-size: 12.5px; color: var(--muted); margin-bottom: 24px; }

.login-box .input { width: 100%; height: 38px; margin-bottom: 12px; }

.login-box .btn { width: 100%; height: 38px; margin-top: 6px; }

.login-err { color: var(--red); font-size: 12.5px; min-height: 18px; margin-top: 4px; }

.login-tip { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); line-height: 1.7; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 999;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(4px); }

.toast.err { background: #b91c1c; }

/* ---------- 进度条 ---------- */
.bar { height: 6px; background: #eef0f3; border-radius: 4px; overflow: hidden; width: 100px; }

.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }

.bar.done > i { background: var(--green); }

.bar.fail > i { background: var(--amber); }

/* ---------- 其他 ---------- */
.muted { color: var(--muted); }

.small { font-size: 12px; }

.row { display: flex; gap: 10px; align-items: center; }

.wrap-check { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; max-height: 220px; overflow-y: auto; padding: 4px; }

.check-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; cursor: pointer; font-size: 12.5px; }

.check-item:hover { border-color: var(--primary); background: #fafbff; }

.check-item input { accent-color: var(--primary); }

.divider { height: 1px; background: var(--border); margin: 16px 0; }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 13px; }

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

.kv dd { color: var(--text); }

@media (max-width: 1200px) {
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .side { display: none; }
  .grid-5, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
