:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --muted: #9aa3b2;
  --accent: #4f8cff;
  --accent-2: #2f6fe4;
  --ok: #35c07f;
  --warn: #e2a53a;
  --err: #e2564d;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

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

body.center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

header.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

header.topbar h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 600;
  letter-spacing: 0.02em;
}

nav.links { display: flex; gap: 12px; margin-left: auto; align-items: center; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
}
.badge.admin { color: #ffd479; border-color: #5a4a1e; background: #2a2413; }
.badge.ok { color: var(--ok); border-color: #1d4c37; background: #12251c; }
.badge.warn { color: var(--warn); border-color: #5a4a1e; background: #2a2413; }
.badge.err { color: var(--err); border-color: #5a2320; background: #2a1614; }

main { max-width: 1180px; margin: 0 auto; padding: 20px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.card h1 { margin-top: 0; font-size: 20px; }

.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

.stat {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stat .value { font-size: 22px; font-weight: 600; }
.stat .label { color: var(--muted); font-size: 12px; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

input[type="text"], input[type="number"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.checkline { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.checkline label { margin: 0; color: var(--text); font-size: 13px; }
.checkline input { width: auto; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent-2);
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
}
.btn:hover { background: var(--accent-2); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { background: #8c2f2a; border-color: #a33b34; }
.btn.danger:hover { background: #a33b34; }
.btn.small { padding: 4px 10px; font-size: 12px; }

.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.table-wrap { overflow-x: auto; }

code, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.secret {
  background: #10141b;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  word-break: break-all;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.notice {
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.notice.ok { border-color: #1d4c37; background: #12251c; }
.notice.warn { border-color: #5a4a1e; background: #2a2413; }
.notice.err { border-color: #5a2320; background: #2a1614; }

.error { color: var(--err); }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }

dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  max-width: 640px;
  width: calc(100% - 32px);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog .dialog-body { padding: 18px 20px; }
dialog h3 { margin: 0 0 12px; font-size: 16px; }
dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; }

.login-card { max-width: 420px; text-align: center; }
.login-card p { color: var(--muted); }

.footnote { color: var(--muted); font-size: 12px; margin-top: 6px; }

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  main { padding: 12px; }
  .card { padding: 14px; }
}
