:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e5e9f2;
  --text: #1c2333;
  --muted: #6b7590;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #eef2ff 0%, #f4f6fb 45%, #e0eaff 100%);
  padding: 24px;
}
.login-card {
  width: 400px; max-width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 36px 32px; box-shadow: 0 12px 40px rgba(37, 99, 235, .08);
}
.brand { text-align: center; margin-bottom: 26px; }
.brand-logo { font-size: 42px; }
.brand h1 { font-size: 21px; margin-top: 8px; }
.brand-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.login-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--muted); }
.field .req { color: var(--danger); font-style: normal; }
input[type="text"], input[type="password"], input[type="number"], input[type="email"], select {
  height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; background: #fff; color: var(--text); outline: none; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
#login-form .field { margin-bottom: 14px; }
.form-error {
  background: #fef2f2; border: 1px solid #fecaca; color: var(--danger);
  border-radius: 8px; padding: 9px 12px; font-size: 13px; margin: 12px 0;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 18px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; cursor: pointer; user-select: none; transition: all .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- 顶栏/布局 ---------- */
.topbar {
  background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 0 20px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar-brand { font-size: 15px; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.container { max-width: 1100px; margin: 24px auto; padding: 0 20px; display: grid; gap: 20px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px;
}
.card h2 { font-size: 17px; margin-bottom: 4px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-head h2 { margin-bottom: 0; }
.card > .muted { margin-bottom: 16px; }
.footer { text-align: center; padding: 24px 0 40px; }

/* ---------- 协议选择卡片 ---------- */
.profile-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.profile-item {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px;
  cursor: pointer; transition: all .15s; background: #fff;
}
.profile-item:hover { border-color: #b7c6f5; }
.profile-item.active {
  border-color: var(--primary); background: #f0f5ff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.10);
}
.profile-item b { display: block; font-size: 14px; }
.profile-item small { color: var(--muted); font-size: 12px; line-height: 1.45; display: block; margin-top: 3px; }

.form-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px; margin-bottom: 14px;
}
.profile-field-wide { grid-column: 1 / -1; }
.form-actions { margin-top: 6px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.cert-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.cert-table th, .cert-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.cert-table th { color: var(--muted); font-weight: 500; font-size: 12.5px; background: #fafbfe; }
.cert-table tbody tr:hover { background: #f8faff; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px;
}
.badge-ok { background: #ecfdf5; color: var(--ok); }
.badge-expired { background: #fff7ed; color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 28px 0; }

/* ---------- 弹窗 / Toast ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; width: 640px; max-width: 100%;
  max-height: 82vh; display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-body { padding: 18px 20px; overflow-y: auto; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 13.5px; margin-bottom: 14px; }
.kv .k { color: var(--muted); }
.pem-box {
  background: #0f172a; color: #a5f3fc; font-family: ui-monospace, Consolas, monospace;
  font-size: 11.5px; border-radius: 8px; padding: 12px; white-space: pre-wrap;
  word-break: break-all; max-height: 260px; overflow-y: auto;
}
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 14px; z-index: 99; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.toast.toast-err { background: var(--danger); }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr 1fr; }
}
