* { box-sizing: border-box; }
body {
  margin: 0; background: #f4f6f9; color: #1f2937;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 15px; line-height: 1.6;
}
.wrap { max-width: 720px; margin: 0 auto; padding: 28px 16px 60px; }
.card { background: #fff; border-radius: 14px; padding: 26px; box-shadow: 0 6px 24px rgba(15,23,42,.07); }
.card.narrow { max-width: 380px; margin: 60px auto 0; }
h1 { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 0 0 12px; color: #334155; }
.muted { color: #64748b; font-size: 13px; }
.tip { color: #94a3b8; font-size: 12px; margin-top: 18px; }
label { display: block; font-size: 13px; color: #475569; margin: 14px 0 6px; }
input, textarea, button { font: inherit; }
input, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid #dbe2ea; border-radius: 9px;
  background: #fff; outline: none;
}
input:focus, textarea:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
button {
  margin-top: 16px; padding: 11px 20px; border: 0; border-radius: 9px;
  background: #2563eb; color: #fff; cursor: pointer;
}
button:disabled { opacity: .6; cursor: default; }
button.ghost { background: #eef2f7; color: #334155; }
button.mini { margin: 0; padding: 4px 9px; font-size: 12px; border-radius: 6px; background: #2563eb; }
button.mini.ghost { background: #eef2f7; color: #334155; }
button.mini.danger { background: #ef4444; }
.msg { margin-top: 14px; font-size: 14px; }
.msg.ok { color: #047857; } .msg.err { color: #b91c1c; }
.out { margin-top: 18px; padding: 16px; border-radius: 10px; background: #ecfdf5; border: 1px solid #a7f3d0; }
.out.hidden { display: none; }
.label { font-size: 12px; color: #047857; margin-bottom: 6px; }
.cid { font-family: ui-monospace, Consolas, monospace; font-size: 17px; letter-spacing: .5px; word-break: break-all; }
.btn-link { display: inline-block; margin-top: 20px; color: #2563eb; font-size: 13px; }

/* 后台 */
.admin { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.topbar { display: flex; align-items: center; gap: 20px; background: #0f172a; color: #fff; padding: 12px 18px; border-radius: 12px; flex-wrap: wrap; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a { color: #cbd5e1; text-decoration: none; padding: 6px 12px; border-radius: 7px; font-size: 14px; }
.topbar nav a.on, .topbar nav a:hover { background: #1e293b; color: #fff; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin: 18px 0; }
.stat { background: #fff; border-radius: 12px; padding: 14px; text-align: center; box-shadow: 0 2px 10px rgba(15,23,42,.05); }
.stat b { display: block; font-size: 22px; color: #2563eb; }
.stat.warn b { color: #d97706; } .stat.bad b { color: #dc2626; }
.stat span { font-size: 12px; color: #64748b; }
.panel { background: #fff; border-radius: 12px; padding: 18px; margin-bottom: 18px; box-shadow: 0 2px 10px rgba(15,23,42,.05); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.row input[type=checkbox] { width: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 6px; border-bottom: 1px solid #f1f5f9; text-align: left; vertical-align: middle; }
th { color: #64748b; font-weight: 600; background: #f8fafc; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.small { font-size: 12px; color: #64748b; }
.ops { display: flex; gap: 6px; flex-wrap: wrap; }
.ops form { margin: 0; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px; background: #eef2f7; color: #475569; }
.tag.ok { background: #ecfdf5; color: #047857; } .tag.warn { background: #fffbeb; color: #b45309; }
.tag.bad { background: #fef2f2; color: #b91c1c; } .tag.dim { background: #f1f5f9; color: #94a3b8; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
/* 密钥分类布局 */
.keys-layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; margin-top: 18px; align-items: start; }
.tree { background: #fff; border-radius: 12px; padding: 12px; box-shadow: 0 2px 10px rgba(15,23,42,.05); position: sticky; top: 12px; max-height: calc(100vh - 40px); overflow: auto; }
.tree a { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; border-radius: 7px; color: #334155; text-decoration: none; font-size: 13px; }
.tree a:hover { background: #f1f5f9; }
.tree a.on { background: #e0ecff; color: #1d4ed8; font-weight: 600; }
.tree .cnt { font-size: 11px; color: #94a3b8; background: #f1f5f9; border-radius: 9px; padding: 0 7px; }
.tree-fam { margin: 12px 0 4px; font-size: 12px; color: #64748b; font-weight: 700; letter-spacing: .5px; }
.tree-prod { padding-left: 10px; }
.tree-ed { padding-left: 26px; }
.tree-ed::before { content: "└ "; color: #cbd5e1; }
.tree-all { font-weight: 600; }

/* 折叠式目录树 */
.tgroup { margin: 2px 0; }
.tgroup > summary {
  list-style: none; cursor: pointer; padding: 6px 10px; border-radius: 7px;
  font-size: 13px; font-weight: 700; color: #475569; display: flex;
  justify-content: space-between; align-items: center;
}
.tgroup > summary::-webkit-details-marker { display: none; }
.tgroup > summary::before { content: "▸"; color: #64748b; font-size: 15px; line-height: 1; width: 15px; display: inline-block; text-align: center; margin-right: 6px; }
.tgroup[open] > summary::before { content: "▾"; color: #2563eb; }
.tgroup > summary:hover { background: #f1f5f9; }
.tgroup.prod > summary { font-weight: 600; color: #64748b; padding-left: 14px; font-size: 12.5px; }
.tgroup.prod .tree-ed { padding-left: 32px; }
.tgroup .tree-ed { display: flex; justify-content: space-between; padding: 4px 10px 4px 32px;
  border-radius: 6px; color: #475569; text-decoration: none; font-size: 12.5px; }
.tgroup .tree-ed:hover { background: #f1f5f9; }
.tgroup .tree-ed.on { background: #e0ecff; color: #1d4ed8; font-weight: 600; }
.crumb { font-size: 14px; }

.keys-main { min-width: 0; }
.keys-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; background: #fff; border-radius: 12px; padding: 12px 16px; box-shadow: 0 2px 10px rgba(15,23,42,.05); margin-bottom: 14px; }
.keys-head .search { display: flex; gap: 6px; }
.keys-head .search input { width: 220px; padding: 7px 10px; border: 1px solid #dbe2ea; border-radius: 7px; font-size: 13px; }
.keys-head .search button { margin: 0; }
.toolbtns { display: flex; gap: 10px; align-items: center; }
.toolbtns form { margin: 0; }
.toolbtns .btn-link { margin: 0; font-size: 13px; }

.keygrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.kcard { background: #fff; border: 1px solid #eef2f7; border-radius: 12px; padding: 12px; cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.kcard:hover { box-shadow: 0 6px 18px rgba(15,23,42,.08); border-color: #dbeafe; }
.kcard.off { opacity: .65; background: #fafbfc; }
.kcard.open { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.kcard-top { display: flex; justify-content: space-between; align-items: center; }
.ktail { font-family: ui-monospace, Consolas, monospace; font-size: 15px; font-weight: 700; color: #0f172a; letter-spacing: .5px; }
.copybtn { margin: 0; padding: 2px 9px; font-size: 11px; border-radius: 6px; background: #eef2f7; color: #2563eb; }
.copybtn:hover { background: #dbeafe; }
.ked { font-size: 12px; color: #475569; margin: 6px 0 8px; }
.kmeta { display: flex; align-items: center; gap: 6px; }
.kmeta .rem { margin-left: auto; font-size: 15px; color: #0f172a; }
.kdetail { display: none; margin-top: 10px; border-top: 1px dashed #e2e8f0; padding-top: 10px; }
.kcard.open .kdetail { display: block; }
.kdetail dl { display: grid; grid-template-columns: 70px 1fr; gap: 4px 8px; margin: 0 0 10px; font-size: 12px; }
.kdetail dt { color: #94a3b8; }
.kdetail dd { margin: 0; word-break: break-all; color: #334155; }
.kacts { display: flex; flex-wrap: wrap; gap: 6px; }
.kacts form { margin: 0; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 18px 0; font-size: 13px; }
.pager a { color: #2563eb; text-decoration: none; }
@media (max-width: 900px) {
  .keys-layout { grid-template-columns: 1fr; }
  .tree { position: static; max-height: none; }
}
@media (max-width: 640px) {
  .wrap { padding-top: 16px; }
  .card { padding: 18px; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
  .keys-head { flex-direction: column; align-items: stretch; }
  .keys-head .search input { width: 100%; }
}

