:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --topbar: #111827;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

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

code {
  font-family: Consolas, "SFMono-Regular", monospace;
  background: #f3f4f6;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12.5px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--topbar);
  color: #e5e7eb;
  padding: 0 20px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 16px; color: #fff; white-space: nowrap; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topbar nav a {
  color: #d1d5db;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13.5px;
}
.topbar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.topbar nav a.active { background: var(--brand); color: #fff; }
.topbar .user { display: flex; align-items: center; gap: 10px; color: #9ca3af; font-size: 13px; white-space: nowrap; }

.container { max-width: 1200px; margin: 22px auto 60px; padding: 0 18px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.page-head h1 { font-size: 22px; margin: 0; }
.muted { color: var(--muted); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card .label { color: var(--muted); font-size: 12.5px; }
.card .value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.card .value.small { font-size: 18px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.panel h2 { font-size: 16px; margin: 0 0 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.warn-panel { border-color: #fcd34d; background: #fffbeb; }
.token-panel { border-color: #86efac; background: #f0fdf4; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 .panel { margin-bottom: 0; }
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 .panel { margin-bottom: 16px; }
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: #fafafa; }
tr:last-child td { border-bottom: none; }
table.wide { font-size: 13px; }
td.detail { max-width: 360px; word-break: break-all; }
td.actions { white-space: nowrap; }
td.actions form { margin-right: 4px; }

form.inline { display: inline; }
form.stack { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; min-width: 220px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 14px;
  align-items: end;
}
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form-grid label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.form-grid button { justify-self: start; }

input, select, button {
  font: inherit;
  border-radius: 7px;
}
input, select {
  border: 1px solid #d1d5db;
  padding: 7px 9px;
  background: #fff;
  color: var(--text);
  min-width: 0;
}
input:focus, select:focus { outline: 2px solid #bfdbfe; border-color: var(--brand); }
button {
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 7px 12px;
  cursor: pointer;
  color: var(--text);
}
button:hover { background: #f9fafb; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-dark); }
button.danger { color: var(--bad); border-color: #fecaca; background: #fef2f2; }
button.danger:hover { background: #fee2e2; }
button.link { border: none; background: none; color: #93c5fd; padding: 0; }
button.copy { margin-left: 6px; padding: 2px 8px; font-size: 12px; }
a.button {
  display: inline-block;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  padding: 7px 12px;
  background: #fff;
  color: var(--text);
}
a.button:hover { background: #f9fafb; text-decoration: none; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #f3f4f6;
  color: #4b5563;
  border: 1px solid #e5e7eb;
}
.badge.ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.badge.warn { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.badge.bad { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

.flash, .error {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 13.5px;
}
.flash { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

.seg { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg a { padding: 6px 12px; color: var(--muted); background: #fff; font-size: 13px; }
.seg a:hover { text-decoration: none; background: #f9fafb; }
.seg a.on { background: var(--brand); color: #fff; }

#chart { width: 100%; height: 260px; display: block; }

.kv th { width: 160px; background: transparent; }
.kv td { font-family: Consolas, monospace; }

.pager { display: flex; gap: 14px; align-items: center; margin-top: 12px; }

details summary { cursor: pointer; color: var(--brand); }
details[open] summary { margin-bottom: 4px; }

.trace {
  background: #0b1220;
  color: #d1d5db;
  border-radius: 8px;
  padding: 12px;
  height: 420px;
  overflow: auto;
  font-family: Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre;
}

.login-wrap { min-height: 70vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}
.login-card h1 { font-size: 22px; margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card button { padding: 10px; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
