:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e6e8ec;
  --text: #1b2430;
  --muted: #6b7480;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --gold: #c2872b;
  --danger: #d64545;
  --ok: #15803d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 32px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card p.sub { color: var(--muted); margin: 0 0 24px; font-size: 13px; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 208px; flex: 0 0 208px; background: #111827; color: #cbd5e1;
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 6px 10px 18px; }
.brand b { color: #fff; font-size: 15px; letter-spacing: -0.01em; display: block; }
.brand span { font-size: 12px; color: #7c8798; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  text-align: left; background: transparent; border: 0; color: #b6bfcd;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px;
}
.nav button:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav button.active { background: #fff; color: #111827; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 10px 10px 0; border-top: 1px solid rgba(255, 255, 255, 0.08); font-size: 12px; color: #7c8798; }
.sidebar-foot button { background: none; border: 0; color: #94a3b8; cursor: pointer; padding: 6px 0; font-size: 12px; }
.sidebar-foot button:hover { color: #fff; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 28px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar h2 { font-size: 17px; }
.topbar .hint { color: var(--muted); font-size: 12.5px; }
.content { padding: 22px 28px 60px; }

/* ---------- 组件 ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 14.5px; }
.card-body { padding: 16px 18px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer;
  font-size: 13.5px; white-space: nowrap;
}
.btn:hover { border-color: #cfd4dc; background: #fafbfc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: #f0c7c7; }
.btn.danger:hover { background: #fdf2f2; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn.link { border: 0; background: none; color: var(--primary); padding: 0 4px; height: auto; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; outline: none;
}
.textarea { height: auto; min-height: 80px; padding: 9px 10px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .spacer { flex: 1; }
.toolbar .input, .toolbar .select { width: auto; min-width: 130px; }

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { font-size: 12.5px; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 650; margin-top: 6px; letter-spacing: -0.02em; }
.stat .foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat.accent .value { color: var(--primary); }
.stat.warn .value { color: var(--gold); }
.stat.bad .value { color: var(--danger); }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbfcfd;
}
table.tbl td { padding: 11px 12px; border-bottom: 1px solid #f1f2f4; vertical-align: middle; }
table.tbl tbody tr:hover { background: #fafbfc; }
table.tbl tr:last-child td { border-bottom: 0; }
.tbl .actions { white-space: nowrap; text-align: right; }
.tbl .actions button { margin-left: 2px; }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 13px; }

.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; background: #eef1f5; color: #4b5563; }
.tag.ok { background: #e8f6ee; color: var(--ok); }
.tag.warn { background: #fdf3e3; color: #a16207; }
.tag.bad { background: #fdecec; color: var(--danger); }
.tag.blue { background: #eaf1fe; color: var(--primary); }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.42); display: grid; place-items: center;
  padding: 24px; z-index: 100; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 560px; background: #fff; border-radius: 14px; box-shadow: 0 24px 64px rgba(15, 23, 42, .3);
  max-height: calc(100vh - 48px); display: flex; flex-direction: column;
}
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 15px; }
.modal-head .x { background: none; border: 0; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }

.form { display: flex; flex-direction: column; gap: 14px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 4px 0 -2px; }

/* ---------- 提示 ---------- */
.toast-root { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  padding: 10px 16px; border-radius: 9px; background: #111827; color: #fff; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: toastIn .18s ease-out;
}
.toast.error { background: #b42323; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; align-items: center; }
.pw-box { background: #f5f7fa; border: 1px dashed #cfd4dc; border-radius: 9px; padding: 12px 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; letter-spacing: .06em; }

@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row; overflow-x: auto; align-items: center; padding: 10px; }
  .brand { display: none; }
  .nav { flex-direction: row; flex: 0 0 auto; }
  .nav button { white-space: nowrap; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; white-space: nowrap; }
  .content { padding: 16px; }
  .topbar { padding: 14px 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}
