:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e5e7eb;
  --text: #1f2328;
  --muted: #6b7280;
  --brand: #2563eb;
  --brand-soft: #eff4ff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  display: flex;
  min-height: 100vh;
}

/* ---------- 侧栏 ---------- */
.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--line);
}
.brand .dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: var(--brand);
  flex: 0 0 auto;
}
.brand strong { display: block; font-size: 14px; }
.brand small { color: var(--muted); font-size: 11px; }

nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: #374151;
  text-decoration: none;
  font-size: 13.5px;
}
.nav-item:hover { background: #f3f4f6; }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.side-foot {
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
}
.tz-note small { color: #9ca3af; }
.logout {
  display: inline-block;
  margin-top: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
}
.logout:hover { color: var(--bad); border-color: #fecaca; }

/* ---------- 主区 ---------- */
main { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 26px 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 650; }
.topbar .sub { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.top-actions { display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--muted); }
.content { padding: 20px 26px 40px; }

/* ---------- 卡片 / 网格 ---------- */
.grid { display: grid; gap: 14px; }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1180px) { .g5, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  nav { flex-direction: row; flex-wrap: wrap; }
  .g5, .g4, .g3, .g2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.card h2 span.hint { font-weight: 400; color: var(--muted); font-size: 11.5px; }

.metric { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 15px; }
.metric .k { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 5px; }
.metric .v { font-size: 24px; font-weight: 650; margin-top: 5px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.metric .d { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.metric.accent { border-color: #dbeafe; background: linear-gradient(180deg,#fbfdff,#fff); }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #f1f3f5; vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: #fafbfc; position: sticky; top: 0; }
tbody tr:hover { background: #fafbff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { max-height: 620px; overflow: auto; border-radius: var(--radius); }

/* ---------- 徽标 ---------- */
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 18px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.tag.ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.tag.bad { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.tag.warn { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.tag.muted { background: #f3f4f6; color: #4b5563; border-color: #e5e7eb; }
.tag.blue { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

/* ---------- 条形 ---------- */
.bar-row { display: grid; grid-template-columns: 120px 1fr 64px; gap: 10px; align-items: center; margin-bottom: 7px; font-size: 12.5px; }
.bar-row .label { color: #374151; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #f1f3f5; border-radius: 5px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 5px; }
.bar-row .val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- 表单 ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
input, select, button { font: inherit; }
input[type=text], input[type=date], input[type=search], select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  background: #fff;
  color: var(--text);
}
button, .btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  color: #374151;
  text-decoration: none;
  display: inline-block;
}
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button:hover, .btn:hover { border-color: #c7cdd4; }

/* ---------- 登录页 ---------- */
.login-body { display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card {
  width: 340px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 24px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, .06);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 { margin: 0; font-size: 17px; }
.login-card .sub { margin: 0; color: var(--muted); font-size: 12.5px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: #374151; }
.login-card input { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.login-card button {
  margin-top: 4px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px;
  font-weight: 600;
  cursor: pointer;
}
.alert { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; }

/* ---------- 其它 ---------- */
.empty { color: var(--muted); font-size: 13px; padding: 22px 8px; text-align: center; }
.note { color: var(--muted); font-size: 11.5px; margin-top: 8px; line-height: 1.6; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.spark { display: block; width: 100%; height: 46px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.kv { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed #f1f3f5; font-size: 12.5px; }
.kv:last-child { border-bottom: none; }
.kv span:first-child { color: var(--muted); }
