:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
}
.login-card {
  background: #fff;
  padding: 36px 40px;
  border-radius: 16px;
  width: 360px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card .field { margin-bottom: 16px; }
.login-card label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--muted); }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: #1f2937;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { padding: 20px 20px 16px; font-size: 16px; font-weight: 600; border-bottom: 1px solid #374151; }
.brand small { display: block; font-weight: 400; color: #9ca3af; font-size: 12px; margin-top: 2px; }
.nav { flex: 1; padding: 12px 8px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 2px 0;
  border-radius: 8px;
  color: #d1d5db;
  text-decoration: none;
  cursor: pointer;
}
.nav a:hover { background: #374151; color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav a svg { width: 16px; height: 16px; flex-shrink: 0; }
.side-foot { padding: 14px 20px; border-top: 1px solid #374151; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.side-foot .user { color: #9ca3af; }

.main { flex: 1; padding: 24px 28px; min-width: 0; }

/* ---------- 页面头部 ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-head h2 { font-size: 20px; }
.page-head .desc { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat .num { font-size: 26px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat.warn .num { color: var(--warn); }
.stat.danger .num { color: var(--danger); }
.stat.ok .num { color: var(--ok); }

/* ---------- 卡片 / 表格 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.toolbar .grow { flex: 1; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: #fafafa; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f9fafb; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.key-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 徽标 ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge.issued { background: #e0e7ff; color: #4338ca; }
.badge.activated { background: #dcfce7; color: #166534; }
.badge.expired { background: #fef3c7; color: #92400e; }
.badge.revoked { background: #fee2e2; color: #991b1b; }
.badge.permanent { background: #e5e7eb; color: #374151; }
.badge.limited { background: #f3e8ff; color: #6b21a8; }

/* ---------- 按钮 / 输入 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.12s;
}
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.input, .select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15); }
textarea.input { resize: vertical; min-height: 70px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--muted); }
.row-actions { display: flex; gap: 4px; }

/* ---------- 分页 / 空态 ---------- */
.pager { display: flex; align-items: center; gap: 10px; padding: 12px 16px; justify-content: flex-end; color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; width: 460px; max-width: 100%;
  max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.modal.wide { width: 620px; }
.modal-head { padding: 18px 22px 0; font-size: 17px; font-weight: 600; }
.modal-body { padding: 18px 22px; }
.modal-foot { padding: 0 22px 20px; display: flex; justify-content: flex-end; gap: 10px; }

/* 密钥结果 */
.key-result {
  background: #f3f4f6; border: 1px dashed #c7cbd1; border-radius: 8px;
  padding: 12px; margin: 8px 0; word-break: break-all;
}
.key-result .mono { font-size: 13px; }

/* ---------- 提示 ---------- */
#toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #111827; color: #fff; padding: 11px 16px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  animation: slidein 0.2s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--ok); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.muted { color: var(--muted); }
.mt { margin-top: 12px; }
.flex { display: flex; align-items: center; gap: 8px; }
.gap8 { gap: 8px; }
.grow { flex: 1; }
.wrap { flex-wrap: wrap; }
a.link { color: var(--primary); cursor: pointer; }
