:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e3e6ea;
  --text: #1f2329;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --green: #15803d;
  --green-soft: #ecfdf3;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --red: #b91c1c;
  --red-soft: #fef2f2;
  --gray-soft: #f3f4f6;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.55 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
  border-radius: 8px; padding: 6px 10px; letter-spacing: 1px;
}
.topbar h1 { font-size: 16px; margin: 0; }
.topbar .sub { margin: 0; font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); display: inline-block; }
.status-dot.busy { background: var(--amber); }
.job-count { font-size: 12px; color: var(--muted); }

/* ---------- 布局 ---------- */
.layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; padding: 16px 20px; max-width: 1280px; margin: 0 auto; }
.sidebar {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; align-self: start; position: sticky; top: 72px; max-height: calc(100vh - 96px); overflow: auto;
}
.sidebar h2 { font-size: 13px; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.history-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 7px;
  cursor: pointer; font-size: 13px;
}
.history-item:hover { background: var(--gray-soft); }
.history-item .k { font-family: var(--mono); font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.history-item .k.whois { background: var(--green-soft); color: var(--green); }
.history-item .k.ip, .history-item .k.prefix { background: var(--amber-soft); color: var(--amber); }
.history-item .key { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .fail { color: var(--red); }
.main { min-width: 0; }

/* ---------- 搜索 ---------- */
.search-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.search-row { display: flex; gap: 10px; }
.search-row input {
  flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  font-family: var(--mono);
}
.search-row input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.search-row select {
  padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; font-size: 13px;
}
.search-row button {
  padding: 10px 22px; border: none; border-radius: 8px; background: var(--accent); color: #fff;
  font-size: 14px; cursor: pointer;
}
.search-row button:hover { background: #1d4ed8; }
.search-row button:disabled { background: #93b4f5; cursor: not-allowed; }
.examples { margin-top: 10px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip {
  font-family: var(--mono); background: var(--gray-soft); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 20px; cursor: pointer; font-size: 12px;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.hint { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

/* ---------- 进度 ---------- */
.progress-card {
  margin-top: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; display: flex; align-items: center; gap: 14px;
}
.spinner {
  width: 22px; height: 22px; border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.9s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-card .muted { font-size: 12px; margin-top: 2px; }
.btn-ghost {
  margin-left: auto; padding: 6px 14px; border: 1px solid var(--border); border-radius: 7px;
  background: #fff; cursor: pointer; font-size: 13px;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- 结果卡片 ---------- */
.result { margin-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.card h3 { margin: 0 0 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.card h3 .tool { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card h3 .tool .btn-ghost { margin-left: 0; }
.verdict-card { border-left: 4px solid var(--green); }
.verdict-card.medium { border-left-color: var(--amber); }
.verdict-card.low { border-left-color: #9ca3af; }
.verdict-org { font-size: 20px; font-weight: 700; margin: 4px 0; }
.verdict-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.badge { font-size: 12px; padding: 2px 10px; border-radius: 20px; font-weight: 600; }
.badge.high { background: var(--green-soft); color: var(--green); }
.badge.medium { background: var(--amber-soft); color: var(--amber); }
.badge.low { background: var(--gray-soft); color: var(--muted); }
.src-chip { font-family: var(--mono); font-size: 11px; background: var(--gray-soft); padding: 2px 8px; border-radius: 4px; }

.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 18px; }
.kv { font-size: 13px; }
.kv .k { color: var(--muted); font-size: 12px; }
.kv .v { font-weight: 500; word-break: break-all; }
.kv .v.mono { font-family: var(--mono); }

.stat-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 4px; }
.stat {
  background: var(--gray-soft); border-radius: 8px; padding: 8px 14px; font-size: 12px; color: var(--muted);
  min-width: 96px;
}
.stat b { display: block; font-size: 17px; color: var(--text); }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
table.data th { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--gray-soft); position: sticky; top: 0; }
table.data tr:hover td { background: var(--accent-soft); }
table.data td.mono { font-family: var(--mono); }
.table-wrap { max-height: 420px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }

.reject { font-size: 13px; padding: 6px 0; border-bottom: 1px dashed var(--border); display: flex; gap: 8px; }
.reject:last-child { border-bottom: none; }
.reject .src { font-family: var(--mono); font-size: 11px; color: var(--muted); flex-shrink: 0; width: 150px; }
.reject .val { flex: 1; word-break: break-all; }
.reject .reason { color: var(--red); font-size: 12px; flex-shrink: 0; }

.warn-box {
  background: var(--amber-soft); border: 1px solid #fde68a; color: #92400e;
  border-radius: 8px; padding: 10px 12px; font-size: 13px;
}
.info-box { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.cache-banner {
  background: var(--accent-soft); border: 1px solid #c7dbfe; color: #1e40af;
  border-radius: 10px; padding: 10px 14px; font-size: 13px;
  display: flex; align-items: center; gap: 12px;
}
.cache-banner .btn-ghost { margin-left: auto; flex-shrink: 0; }
.error-card {
  margin-top: 16px; background: var(--red-soft); border: 1px solid #fecaca; color: var(--red);
  border-radius: 10px; padding: 14px 16px; font-size: 13px;
}
.muted { color: var(--muted); }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
details summary { cursor: pointer; color: var(--accent); font-size: 13px; user-select: none; }
details[open] summary { margin-bottom: 8px; }

/* ---------- JSON 弹窗 ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,18,25,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-box { background: #fff; border-radius: 10px; width: min(860px, 92vw); max-height: 86vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 14px; }
.modal-head > div { display: flex; gap: 8px; }
#json-body { margin: 0; padding: 16px; overflow: auto; font-size: 12px; background: #0f172a; color: #e2e8f0; border-radius: 0 0 10px 10px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: 200px; }
}

/* ---------- 名词解释页 ---------- */
.glossary-page { max-width: 880px; margin: 0 auto; padding: 20px; }
.plain-link { color: inherit; text-decoration: none; }
.plain-link:hover { color: var(--accent); }
.glossary-note { color: var(--muted); font-size: 12px; margin: 0 0 18px; }
.glossary-group {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px 20px; margin-bottom: 14px;
}
.glossary-group h2 {
  font-size: 15px; margin: 0 0 6px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border); color: var(--accent);
}
dl.glossary { margin: 0; }
dl.glossary dt {
  margin-top: 14px; font-weight: 600; font-size: 14px;
}
dl.glossary dt a { color: var(--accent); text-decoration: none; }
dl.glossary dt a:hover { text-decoration: underline; }
dl.glossary dt .zh {
  font-weight: 400; font-size: 12px; color: var(--muted); margin-left: 8px;
}
dl.glossary dd {
  margin: 4px 0 0; font-size: 13px; color: #374151; line-height: 1.7;
}
dl.glossary dd code {
  font-family: var(--mono); font-size: 12px; background: var(--gray-soft);
  padding: 1px 5px; border-radius: 4px;
}

/* ---------- 主页底部小字入口 ---------- */
.site-footer {
  max-width: 1280px; margin: 0 auto; padding: 6px 20px 28px;
  font-size: 12px; color: var(--muted); line-height: 1.9;
}
.site-footer a { color: var(--muted); text-decoration: none; border-bottom: 1px dotted #9ca3af; }
.site-footer a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.site-footer .footer-title { color: #374151; }
