* { box-sizing: border-box; margin: 0; padding: 0; }
:root{
  --bg:#f4f6fa; --panel:#ffffff; --line:#e5e9f0; --text:#1f2937; --muted:#6b7280;
  --primary:#2563eb; --primary-d:#1d4ed8; --ok:#059669; --warn:#d97706; --danger:#dc2626;
  --side:#111827; --side-t:#cbd5e1; --radius:10px; --shadow:0 2px 12px rgba(16,24,40,.06);
}
body{ font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei",sans-serif;
  background:var(--bg); color:var(--text); font-size:14px; line-height:1.5; }
.hidden{ display:none !important; }
button{ font-family:inherit; cursor:pointer; }
input,select,textarea{ font-family:inherit; font-size:14px; }

/* ---------- 登录 ---------- */
.login-page{ min-height:100vh; display:flex; align-items:center; justify-content:center;
  background:linear-gradient(135deg,#1e3a8a 0%,#2563eb 55%,#3b82f6 100%); }
.login-card{ width:400px; background:#fff; border-radius:16px; padding:38px 36px 28px;
  box-shadow:0 20px 60px rgba(0,0,0,.25); }
.login-brand{ display:flex; align-items:center; gap:14px; margin-bottom:30px; }
.login-brand h1{ font-size:22px; }
.login-brand p{ color:var(--muted); font-size:12px; margin-top:2px; }
.brand-mark{ width:48px; height:48px; border-radius:12px; background:var(--primary);
  color:#fff; font-size:26px; font-weight:800; display:flex; align-items:center; justify-content:center; }
.brand-mark.small{ width:34px; height:34px; font-size:18px; border-radius:9px; }
.login-card label{ display:block; font-size:13px; color:var(--muted); margin:14px 0 6px; }
.login-card input{ width:100%; height:42px; border:1px solid var(--line); border-radius:8px;
  padding:0 12px; outline:none; transition:.15s; }
.login-card input:focus{ border-color:var(--primary); box-shadow:0 0 0 3px rgba(37,99,235,.12); }
.login-foot{ text-align:center; color:var(--muted); font-size:11px; margin-top:22px; }
.err-msg{ color:var(--danger); font-size:13px; min-height:20px; margin-top:10px; }

.btn-primary{ background:var(--primary); color:#fff; border:none; border-radius:8px;
  padding:10px 18px; font-weight:600; transition:.15s; }
.btn-primary:hover{ background:var(--primary-d); }
.btn-primary:disabled{ opacity:.6; cursor:not-allowed; }
.btn-block{ width:100%; display:block; }
.btn-ghost{ background:transparent; color:var(--muted); border:1px solid var(--line);
  border-radius:8px; padding:9px 14px; }
.btn-ghost:hover{ background:#f3f4f6; color:var(--text); }
.btn-sm{ padding:5px 10px; font-size:12px; border-radius:6px; }
.btn-danger{ background:var(--danger); color:#fff; border:none; border-radius:6px; padding:5px 10px; font-size:12px; }
.btn-ok{ background:var(--ok); color:#fff; border:none; border-radius:6px; padding:5px 10px; font-size:12px; }

/* ---------- 布局 ---------- */
.app{ display:flex; min-height:100vh; }
.sidebar{ width:220px; flex-shrink:0; background:var(--side); color:var(--side-t);
  display:flex; flex-direction:column; position:fixed; top:0; bottom:0; left:0; }
.side-brand{ display:flex; align-items:center; gap:10px; padding:20px 18px; border-bottom:1px solid #1f2937; }
.side-brand strong{ display:block; color:#fff; font-size:15px; }
.side-brand span{ display:block; font-size:10px; color:#64748b; }
.sidebar nav{ flex:1; padding:12px 10px; }
.sidebar nav a{ display:flex; align-items:center; gap:12px; padding:11px 14px; border-radius:8px;
  color:var(--side-t); text-decoration:none; margin-bottom:4px; cursor:pointer; font-size:14px; }
.sidebar nav a:hover{ background:#1f2937; color:#fff; }
.sidebar nav a.active{ background:var(--primary); color:#fff; }
.sidebar nav a .ico{ width:20px; text-align:center; font-size:16px; }
.side-foot{ padding:14px; border-top:1px solid #1f2937; }
.side-user{ font-size:13px; color:#fff; margin-bottom:10px; padding:0 4px; }
.side-user small{ display:block; color:#64748b; font-size:11px; }
.side-foot .btn-ghost{ border-color:#374151; color:#9ca3af; }
.side-foot .btn-ghost:hover{ background:#1f2937; color:#fff; }

.main{ flex:1; margin-left:220px; min-width:0; display:flex; flex-direction:column; }
.topbar{ height:60px; background:#fff; border-bottom:1px solid var(--line); display:flex;
  align-items:center; justify-content:space-between; padding:0 26px; position:sticky; top:0; z-index:10; }
.page-title{ font-size:17px; font-weight:700; }
.top-right{ display:flex; align-items:center; gap:18px; }
.notify-btn{ background:none; border:none; font-size:20px; position:relative; }
.badge{ position:absolute; top:-4px; right:-8px; background:var(--danger); color:#fff;
  font-size:10px; border-radius:10px; min-width:16px; height:16px; line-height:16px; text-align:center; padding:0 4px; }
.top-user{ font-size:13px; color:var(--muted); }
.content{ padding:24px 26px; flex:1; }

/* ---------- 卡片/表格 ---------- */
.card{ background:var(--panel); border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:var(--shadow); padding:20px; margin-bottom:18px; }
.card h3{ font-size:15px; margin-bottom:16px; }
.stat-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:16px; margin-bottom:18px; }
.stat{ background:#fff; border:1px solid var(--line); border-radius:var(--radius); padding:18px 20px; box-shadow:var(--shadow); }
.stat .label{ color:var(--muted); font-size:12px; }
.stat .value{ font-size:26px; font-weight:700; margin-top:6px; }
.stat .sub{ font-size:11px; color:var(--muted); margin-top:4px; }
.stat.ok .value{ color:var(--ok); } .stat.warn .value{ color:var(--warn); }

table{ width:100%; border-collapse:collapse; font-size:13px; }
th,td{ text-align:left; padding:10px 12px; border-bottom:1px solid var(--line); }
th{ color:var(--muted); font-weight:600; background:#f9fafb; }
tr:hover td{ background:#fafbfc; }
.tbl-wrap{ overflow-x:auto; }
.tag{ display:inline-block; padding:2px 9px; border-radius:20px; font-size:11px; font-weight:600; }
.tag-valid{ background:#d1fae5; color:#065f46; }
.tag-expired,.tag-revoked,.tag-user_expired,.tag-agent_expired,.tag-not_found{ background:#fee2e2; color:#991b1b; }
.tag-pending{ background:#fef3c7; color:#92400e; }
.tag-role{ background:#e0e7ff; color:#3730a3; }
.mono{ font-family:ui-monospace,Consolas,monospace; font-size:12px; }

/* ---------- 表单 ---------- */
.form-grid{ display:grid; grid-template-columns:repeat(2,1fr); gap:16px; }
.form-grid .full{ grid-column:1/-1; }
.field label{ display:block; font-size:13px; color:var(--muted); margin-bottom:6px; }
.field input,.field select,.field textarea{ width:100%; border:1px solid var(--line); border-radius:8px;
  padding:9px 11px; outline:none; background:#fff; }
.field input:focus,.field select:focus,.field textarea:focus{ border-color:var(--primary); box-shadow:0 0 0 3px rgba(37,99,235,.1); }
.field textarea{ resize:vertical; min-height:90px; }
.field .hint{ font-size:11px; color:var(--muted); margin-top:4px; }
.form-actions{ display:flex; gap:10px; margin-top:20px; }

.toolbar{ display:flex; gap:10px; align-items:center; margin-bottom:16px; flex-wrap:wrap; }
.toolbar input,.toolbar select{ border:1px solid var(--line); border-radius:8px; padding:8px 10px; background:#fff; }
.toolbar .spacer{ flex:1; }

/* ---------- 签发结果 ---------- */
.result-box{ background:#f0fdf4; border:1px solid #bbf7d0; border-radius:10px; padding:18px; margin-top:18px; }
.result-box h4{ color:#065f46; margin-bottom:12px; }
.result-box textarea{ width:100%; height:110px; border:1px solid #bbf7d0; border-radius:8px; padding:10px;
  font-family:ui-monospace,Consolas,monospace; font-size:12px; background:#fff; }
.kv{ display:grid; grid-template-columns:120px 1fr; gap:8px 16px; font-size:13px; margin-bottom:14px; }
.kv .k{ color:var(--muted); }

/* ---------- 提醒抽屉 ---------- */
.drawer{ position:fixed; top:0; right:0; width:380px; height:100vh; background:#fff;
  box-shadow:-4px 0 24px rgba(0,0,0,.12); z-index:50; display:flex; flex-direction:column; }
.drawer-head{ display:flex; justify-content:space-between; align-items:center; padding:18px 20px; border-bottom:1px solid var(--line); }
.drawer-body{ flex:1; overflow-y:auto; padding:12px 20px; }
.drawer-foot{ padding:14px 20px; border-top:1px solid var(--line); }
.notify-item{ padding:12px 0; border-bottom:1px solid var(--line); }
.notify-item.unread{ border-left:3px solid var(--primary); padding-left:10px; }
.notify-item .nt{ font-weight:600; font-size:13px; }
.notify-item .nc{ color:var(--muted); font-size:12px; margin-top:4px; }
.notify-item .nd{ color:#9ca3af; font-size:11px; margin-top:4px; }
.icon-btn{ background:none; border:none; font-size:16px; color:var(--muted); }

/* ---------- 弹窗 ---------- */
.modal-mask{ position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:60; display:flex; align-items:center; justify-content:center; }
.modal{ width:560px; max-width:95vw; max-height:90vh; background:#fff; border-radius:12px; display:flex; flex-direction:column; box-shadow:0 20px 60px rgba(0,0,0,.3); }
.modal-head{ display:flex; justify-content:space-between; align-items:center; padding:16px 20px; border-bottom:1px solid var(--line); }
.modal-body{ padding:20px; overflow-y:auto; }
.modal-foot{ padding:14px 20px; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:10px; }

.toast{ position:fixed; bottom:30px; left:50%; transform:translateX(-50%); background:#111827; color:#fff;
  padding:12px 24px; border-radius:8px; z-index:100; font-size:14px; box-shadow:0 8px 24px rgba(0,0,0,.2); }
.toast.err{ background:var(--danger); }

.empty{ text-align:center; color:var(--muted); padding:40px; }
.pagination{ display:flex; gap:8px; align-items:center; justify-content:flex-end; margin-top:14px; font-size:13px; }
.tree-node{ padding-left:0; }
.tree-children{ padding-left:22px; border-left:1px dashed var(--line); margin-left:10px; }
.tree-row{ display:flex; align-items:center; gap:10px; padding:8px 0; }
.tree-row .tname{ font-weight:600; }
@media(max-width:800px){
  .sidebar{ width:64px; } .side-brand div:last-child,.sidebar nav a span:not(.ico),.side-user,.side-foot .btn-ghost{ display:none; }
  .sidebar nav a{ justify-content:center; } .main{ margin-left:64px; } .form-grid{ grid-template-columns:1fr; }
}
