:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --red: #dc2626;
  --green: #059669;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { max-width: 1260px; margin: 0 auto; padding: 22px 24px 60px; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 24px; background: #fff; border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; letter-spacing: 0; }
.topnav { display: flex; gap: 6px; margin-left: 18px; }
.topnav a {
  padding: 7px 12px; border-radius: 8px; color: #374151; font-size: 13px;
}
.topnav a.on { background: #eef2ff; color: var(--blue); font-weight: 600; }
.topnav a:hover { background: #f3f4f6; text-decoration: none; }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 13px; }

h1 { font-size: 26px; margin: 8px 0 4px; letter-spacing: -.3px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 18px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 4px; font-size: 17px; }
.card .code { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

.grid { display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: start; }
.stats { display: flex; gap: 26px; text-align: right; }
.stat b { display: block; font-size: 20px; color: var(--blue); line-height: 1.2; }
.stat span { font-size: 12px; color: var(--muted); }

.kv { display: flex; gap: 40px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.kv div { min-width: 220px; }
.kv label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.kv .val { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; word-break: break-all; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: #1f2937; font-size: 13px; cursor: pointer; text-decoration: none;
  font-family: inherit;
}
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }

input[type=text], input[type=password], input[type=number], select, textarea {
  height: 38px; padding: 0 12px; border: 1px solid #d1d5db; border-radius: 9px;
  background: #fff; font: inherit; color: var(--ink); outline: none; min-width: 0;
}
textarea { height: auto; padding: 10px 12px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: #fafafa; }
tr:hover td { background: #fcfdff; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; line-height: 1.7; }
.badge.ok { background: #dbeafe; color: #1d4ed8; }
.badge.unused { background: #dcfce7; color: #15803d; }
.badge.revoked { background: #fee2e2; color: #b91c1c; }
.badge.warn { background: #fef3c7; color: #b45309; }

.flash { padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; font-size: 13px; }
.flash.ok { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.flash.err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 470px; background: #fff; border-radius: 16px; padding: 40px; box-shadow: 0 14px 40px rgba(17,24,39,.07); }
.login-card h1 { font-size: 26px; margin: 0 0 26px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; color: #374151; margin-bottom: 6px; }
.field input { width: 100%; height: 44px; }
.login-card .btn { width: 100%; height: 46px; font-size: 15px; }

.pager { display: flex; gap: 8px; align-items: center; margin-top: 14px; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions form { display: inline; }

.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin: 0; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
/* ---------- 折叠卡片 ---------- */
.product { padding: 0; overflow: hidden; }
.product > summary {
  list-style: none; cursor: pointer; padding: 18px 20px;
  display: flex; align-items: center; gap: 16px;
}
.product > summary::-webkit-details-marker { display: none; }
.product > summary:hover { background: #fcfdff; }
.product .pname { flex: 1; min-width: 0; }
.product .pname h3 { margin: 0 0 2px; font-size: 17px; display: inline; }
.product .pname .code { color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 13px; margin-left: 8px; }
.product .chev { width: 18px; height: 18px; color: #9ca3af; transition: transform .15s; flex: none; }
.product[open] .chev { transform: rotate(90deg); }
.product .pbody { padding: 0 20px 18px; border-top: 1px solid var(--line); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17,24,39,.45);
  display: none; align-items: flex-start; justify-content: center;
  padding: 48px 20px; z-index: 50; overflow: auto;
}
.modal-mask.on { display: flex; }
body.modal-open { overflow: hidden; }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 1080px;
  box-shadow: 0 24px 60px rgba(17,24,39,.22);
}
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-title { font-size: 16px; flex: 1; }
.modal-x {
  border: 0; background: transparent; font-size: 22px; line-height: 1;
  color: #9ca3af; cursor: pointer; padding: 0 4px;
}
.modal-x:hover { color: #374151; }
.modal-body { padding: 20px; max-height: 70vh; overflow: auto; }
.modal-loading { color: var(--muted); padding: 30px; text-align: center; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.codes-out {
  width: 100%; font-family: ui-monospace, Menlo, monospace; font-size: 13px;
  border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fafafa;
}

.toast {
  position: fixed; left: 50%; bottom: 36px; transform: translate(-50%, 20px);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .18s; z-index: 80;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #b91c1c; }

.copy-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.copy-row .val { flex: 1; min-width: 0; }
.perm { color: var(--green); font-weight: 600; }
