:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e4e7ec;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #b45309;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 22px;
}
.brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; flex-wrap: wrap; }
.nav a {
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 500;
}
.nav a:hover { background: #f1f3f6; color: var(--text); text-decoration: none; }
.nav a.active { background: #eaf0fe; color: var(--accent); }

/* ---------- 布局 ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 26px 20px 64px; }
.narrow { max-width: 460px; }
.page-title { font-size: 21px; font-weight: 700; margin: 0 0 4px; }
.page-sub { color: var(--muted); margin: 0 0 22px; font-size: 13px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-title {
  font-size: 15px; font-weight: 700; margin: 0 0 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* ---------- 统计块 ---------- */
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .k { color: var(--muted); font-size: 12px; letter-spacing: .02em; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* ---------- 表单 ---------- */
.form-row { margin-bottom: 15px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 5px; }

input[type=text], input[type=password], input[type=date], input[type=number],
select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}
textarea { resize: vertical; min-height: 68px; }

.checks { display: flex; flex-wrap: wrap; gap: 10px; }
.check {
  display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 11px; background: #fafbfc; cursor: pointer; font-size: 13px;
}
.check input { width: auto; margin: 0; }
.check:hover { border-color: #cfd6e0; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: #f7f8fa; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger { color: var(--danger); border-color: #f0c4c4; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-row { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.btn-block { width: 100%; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap; background: #fafbfc; }
tbody tr:hover { background: #fafbfc; }
tbody tr:last-child td { border-bottom: none; }
td .btn { margin-right: 5px; }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }

/* ---------- 标签 ---------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.7;
}
.badge-admin { background: #eaf0fe; color: var(--accent); }
.badge-user { background: #f1f3f5; color: #4b5563; }
.badge-ok { background: #e7f7f1; color: var(--ok); }
.badge-off { background: #fdecec; color: var(--danger); }
.badge-warn { background: #fdf3e3; color: var(--warn); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  padding: 9px 16px; border: none; background: none; font-family: inherit;
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: #1f2430; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 13.5px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: opacity .22s, transform .22s; z-index: 100;
  max-width: 84vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #b91c1c; }
.toast.ok { background: #047857; }

.alert {
  padding: 11px 14px; border-radius: 9px; font-size: 13.5px;
  margin-bottom: 15px; display: none;
}
.alert.show { display: block; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fbd5d5; }
.alert-ok { background: #ecfdf5; color: #065f46; border: 1px solid #bbf7d0; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.spacer { height: 14px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }

/* ---------- 弹窗 ---------- */
dialog.modal {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: min(520px, 92vw);
  box-shadow: 0 20px 50px rgba(16, 24, 40, .22);
  color: var(--text);
  background: var(--panel);
}
dialog.modal::backdrop { background: rgba(15, 20, 30, .38); }
.modal-body { max-height: 62vh; overflow-y: auto; }

@media (max-width: 620px) {
  .topbar-inner { height: auto; padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
  .nav { margin-left: 0; width: 100%; }
  .container { padding: 18px 14px 50px; }
  .card { padding: 17px; }
}
