:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #17181c;
  --muted: #6b7280;
  --line: #e4e6ea;
  --brand: #2f6bff;
  --brand-dark: #1e4fd6;
  --danger: #d13b3b;
  --ok: #16803c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 14px; }
code { background: #eef0f4; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); }
.ok { color: var(--ok); }
.inline { display: inline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; height: 56px; background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--ink); font-size: 16px; white-space: nowrap; }
.topbar nav { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.who { color: var(--muted); }

.wrap { max-width: 980px; margin: 0 auto; padding: 28px 20px 80px; }
.pagehead { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 16px; }
.back { font-size: 13px; display: inline-block; margin-bottom: 6px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 20px; margin-bottom: 18px;
}
.card.narrow { max-width: 420px; margin: 60px auto; }
.btn {
  display: inline-block; padding: 9px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: #c9d4ea; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 18px; }

.child { display: flex; gap: 14px; align-items: center; color: var(--ink); }
.child:hover { text-decoration: none; border-color: #c9d4ea; }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; background: #e7eeff;
  color: var(--brand); display: grid; place-items: center;
  font-size: 20px; font-weight: 700; flex: none;
}
.child-main { display: flex; flex-direction: column; gap: 2px; }
.child-main strong { font-size: 16px; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.bind { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--line); }

label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
select {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
select:focus { outline: 2px solid #cddcff; border-color: var(--brand); }

input, textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  min-width: 0;
}
input:focus, textarea:focus { outline: 2px solid #cddcff; border-color: var(--brand); }
textarea { width: 100%; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

button {
  font: inherit; cursor: pointer; border-radius: 8px; white-space: nowrap;
  border: 1px solid var(--line); background: #fff; padding: 9px 14px;
}
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--brand-dark); }
button.danger { color: var(--danger); border-color: #f0caca; }
button.small { padding: 4px 10px; font-size: 12px; }
button.link { border: none; background: none; color: var(--brand); padding: 0; }
.form-actions { display: flex; align-items: center; gap: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
td:first-child { white-space: nowrap; }
td:last-child { text-align: right; }
td.stem { max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-num { font-size: 36px; font-weight: 700; line-height: 1.1; }

.rank { list-style: none; padding: 0; margin: 0; }
.rank li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.rank li:last-child { border-bottom: none; }

.pill {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: #eef0f4; color: var(--muted); vertical-align: middle;
}
.pill.active { background: #e6f6ec; color: var(--ok); }
.pill.pending { background: #fff4e0; color: #a16207; }
.pill.revoked { background: #fdecec; color: var(--danger); }

.import { margin-bottom: 16px; }
.import summary { cursor: pointer; font-weight: 600; margin-bottom: 8px; }
.import textarea { margin: 10px 0; }

@media (max-width: 620px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .brand { font-size: 14px; }
  .who { display: none; }
  .wrap { padding: 20px 14px 60px; }
  .pagehead { flex-direction: column; }
  .card { padding: 16px; }
  .grid { grid-template-columns: 1fr; }
  td.stem { max-width: 180px; }
}
