:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --line: #e5e7eb;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* 顶栏 */
.topbar {
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.nav { margin-left: 28px; display: flex; gap: 4px; }
.nav a {
  color: rgba(255,255,255,.82);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 500;
  transition: background .15s;
}
.nav a:hover { background: rgba(255,255,255,.16); color: #fff; }
.nav a.active { background: rgba(255,255,255,.22); color: #fff; }
.nav a.logout { margin-left: auto; }

.container { max-width: 1180px; margin: 24px auto; padding: 0 24px; }

/* 卡片 */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card h2, .card h3 { margin: 0 0 14px; font-weight: 600; }
.card h3 { font-size: 15px; }

/* 统计卡 row */
.stats-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px,1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-card .num { font-size: 28px; font-weight: 700; }
.stat-card .lbl { color: var(--muted); font-size: 13px; }
.stat-card.ok .num { color: var(--ok); }
.stat-card.warn .num { color: var(--warn); }
.stat-card.bad .num { color: var(--bad); }

/* 表格 */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { background: #fafbfc; color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
tr:hover td { background: #f8faff; }

/* 表单 */
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.grid-form .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=date], input[type=number], textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(37,99,235,.25); border-color: var(--brand); }
textarea { resize: vertical; min-height: 60px; }

/* 按钮 */
.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13.5px;
  cursor: pointer;
  font-weight: 600;
  transition: filter .12s, background .12s;
  text-decoration: none;
  color: var(--ink);
  background: #eef0f4;
}
.btn:hover { filter: brightness(.96); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.warn { background: var(--warn); color: #fff; }
.btn.bad { background: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* 徽标 */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.perm { background: #e0f2e9; color: var(--ok); }
.badge.timed { background: #fff4e0; color: var(--warn); }
.badge.revoked { background: #fee2e2; color: var(--bad); }
.badge.expired { background: #fee2e2; color: var(--bad); }

/* 列表 */
.kv { font-size: 13px; color: var(--muted); }
.mono { font-family: Consolas, "Courier New", monospace; word-break: break-all; }

/* 弹出提示 */
.toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%) translateY(-8px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 99;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 560px; max-width: 94vw; max-height: 90vh; overflow:auto; padding: 22px; }
.modal h3 { margin-top: 0; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#1d4ed8,#2563eb 55%,#3b82f6); }
.login-card { background: #fff; border-radius: 16px; padding: 34px 36px; width: 360px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.login-title { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login-error { color: var(--bad); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

.empty { color: var(--muted); text-align: center; padding: 28px 0; }

.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-name { width: 150px; text-align: right; font-size: 13px; white-space: nowrap; overflow:hidden; text-overflow:ellipsis; }
.bar-track { flex: 1; background: #eef1f6; border-radius: 6px; height: 22px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg,var(--brand),#3b82f6); border-radius: 6px; display:flex; align-items:center; justify-content:flex-end; padding-right:6px; color:#fff; font-size:12px; font-weight:600; min-width:30px; transition: width .3s; }
