:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e3e6ea;
  --text: #1b1f24;
  --muted: #6b7480;
  --accent: #2f6df6;
  --accent-dim: #eaf0fe;
  --good: #17803d;
  --warn: #b45309;
  --bad: #c0392b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
}

.hidden { display: none !important; }

main { max-width: 1400px; margin: 0 auto; }

header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

header h1 { font-size: 20px; margin: 0; }

.badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--accent-dim);
  color: var(--accent);
}
.badge.warn { background: #fff4e5; color: var(--warn); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

/* ---------------------------------------------------------- 表单 */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; flex: 1; }
.field label { font-weight: 600; font-size: 13px; }
.hint { font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 12px; }

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row .field { min-width: 180px; }

textarea, input[type=text], input[type=password], input[type=number], select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

.check { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.check input { width: auto; }

.inline { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.inline input, .inline select { width: auto; padding: 5px 8px; }

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

button {
  font: inherit;
  font-weight: 600;
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover:not(:disabled) { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: not-allowed; }

button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.estimate { color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------- 进度 */

.progress-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.phase { font-weight: 700; }
.phase-msg { color: var(--muted); font-size: 13px; }
.phase.error { color: var(--bad); }
.phase.done { color: var(--good); }

.stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stat {
  flex: 1;
  min-width: 96px;
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}
.stat span { display: block; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat label { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.bar { height: 6px; background: var(--bg); border-radius: 99px; margin-top: 14px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }

/* ---------------------------------------------------------- 结果表 */

.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.spacer { flex: 1; }
.count { color: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; max-height: 62vh; overflow-y: auto; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--card);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  z-index: 1;
}
thead th[data-sort] { cursor: pointer; user-select: none; }
thead th[data-sort]:hover { color: var(--accent); }
thead th.sorted::after { content: " ↓"; }
thead th.sorted.asc::after { content: " ↑"; }

.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

td a { color: var(--accent); text-decoration: none; }
td a:hover { text-decoration: underline; }

.email { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.no-data { color: #c2c8d0; }

.src {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--bg);
  color: var(--muted);
  white-space: nowrap;
}
.src.api_region { background: var(--accent-dim); color: var(--accent); }

.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; background: var(--bg); padding: 1px 6px; border-radius: 4px; color: var(--muted); }

.sig {
  max-width: 320px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  font-size: 12px;
  max-height: 3em;
  overflow: hidden;
  cursor: pointer;
}
.sig.open { max-height: none; }

.verified { color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* ---------------------------------------------------------- 口令门 */

.gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.gate-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 30px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gate-box h1 { font-size: 17px; margin: 0 0 4px; }
.gate-error { color: var(--bad); font-size: 13px; margin: 0; min-height: 18px; }
