:root {
  --bg: #f6f6f3;
  --card: #ffffff;
  --line: #e5e4dd;
  --line-strong: #d3d1c7;
  --text: #1c1c19;
  --muted: #6d6c66;
  --faint: #96958d;
  --accent: #185fa5;
  --accent-soft: #e6f1fb;
  --accent-deep: #0c447c;
  --warm: #854f0b;
  --warm-soft: #faeeda;
  --ok: #0f6e56;
  --ok-soft: #e1f5ee;
  --danger: #a32d2d;
  --radius: 12px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 500; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--accent-deep);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 500; letter-spacing: 0.5px;
}
.brand h1 { font-size: 16px; }
.brand p { margin: 1px 0 0; font-size: 12px; color: var(--faint); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.provider-tag {
  font-size: 12px; color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 4px 10px; border-radius: 20px;
}
.provider-tag.warn { color: var(--warm); background: var(--warm-soft); border-color: #f0dcbc; }

/* ---------- 布局 ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 20px 24px 40px; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ---------- 搜索 ---------- */
.search-panel { padding: 16px; margin-bottom: 14px; }
.search-row { display: flex; gap: 10px; }
.kw-input {
  flex: 1;
  height: 46px;
  padding: 0 16px;
  font-size: 15px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.kw-input::placeholder { color: var(--faint); }
.kw-input:focus { border-color: var(--accent); background: #fff; }

.region-select, .mini-select {
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
  cursor: pointer;
}

.btn {
  height: 46px;
  padding: 0 20px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { background: #fafaf8; border-color: var(--line-strong); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}
.btn.primary:hover { background: var(--accent-deep); }
.btn.primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.ghost { height: 34px; padding: 0 14px; font-size: 13px; border-radius: 8px; }

.chips-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.chips-label { font-size: 12px; color: var(--faint); margin-right: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  background: var(--bg);
}
.chip input { margin: 0; accent-color: var(--accent); }
.chip:has(input:checked) { color: var(--accent-deep); background: var(--accent-soft); border-color: #b5d4f4; }
.spacer { flex: 1; }

/* ---------- 状态 ---------- */
.status-strip { margin-bottom: 14px; }
.progress {
  height: 3px; background: #e9e8e2; border-radius: 3px; overflow: hidden;
}
.progress .bar {
  height: 100%; width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.status-line {
  display: flex; gap: 8px; align-items: center;
  margin-top: 7px; font-size: 12px; color: var(--muted);
}
.dot { color: var(--line-strong); }

/* ---------- 统计 ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
.stat b { display: block; font-size: 22px; font-weight: 500; letter-spacing: -0.5px; }
.stat span { font-size: 12px; color: var(--faint); }

/* ---------- 表格 ---------- */
.table-panel { overflow: hidden; }
.table-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.filters { display: flex; gap: 6px; }
.fbtn {
  height: 30px; padding: 0 12px;
  border: 1px solid transparent; border-radius: 7px;
  background: transparent; color: var(--muted);
  font-size: 13px; font-family: inherit; cursor: pointer;
}
.fbtn:hover { background: var(--bg); }
.fbtn.active { background: var(--accent-soft); color: var(--accent-deep); border-color: #cfe3f7; }

.table-actions { display: flex; gap: 8px; align-items: center; }
.mini-input {
  height: 34px; padding: 0 12px; width: 200px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--bg); font-size: 13px; font-family: inherit; color: var(--text);
  outline: none;
}
.mini-input:focus { border-color: var(--accent); background: #fff; }
.mini-select { height: 34px; font-size: 13px; border-radius: 8px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 500;
  font-size: 12px;
  color: var(--faint);
  background: #fbfbf9;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid #f0efe9;
  vertical-align: top;
}
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fbfbf9; }
.col-idx { width: 40px; color: var(--faint); }
tbody td:nth-child(2), thead th:nth-child(2) { min-width: 216px; }
.col-loc { width: 100px; white-space: nowrap; }
.col-plat { width: 104px; }
.plat { white-space: nowrap; }
.col-phone { width: 138px; white-space: nowrap; }
.col-tags { width: 150px; }
.col-score { width: 62px; text-align: right; }

.cname { font-weight: 500; color: var(--text); }
.csub { font-size: 12px; color: var(--faint); margin-top: 2px; }

.plat {
  display: inline-block; padding: 2px 7px; border-radius: 5px;
  font-size: 11px; background: var(--bg); color: var(--muted); border: 1px solid var(--line);
}
.plat.b2b { background: var(--accent-soft); color: var(--accent-deep); border-color: #cfe3f7; }
.plat.content { background: #fdf1f1; color: #8a3b3b; border-color: #f2dada; }

.phone { color: var(--ok); font-family: ui-monospace, "Consolas", monospace; font-size: 12.5px; }
.phone.none { color: var(--faint); font-family: inherit; }

.tag {
  display: inline-block; padding: 1px 7px; margin: 0 4px 4px 0;
  border-radius: 5px; font-size: 11px;
  background: var(--warm-soft); color: var(--warm); border: 1px solid #f0dcbc;
}
.tag.cyan { background: var(--ok-soft); color: var(--ok); border-color: #c3e6db; }

.summary { color: var(--muted); font-size: 12.5px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.score { font-weight: 500; font-family: ui-monospace, Consolas, monospace; }
.score.hi { color: var(--danger); }
.score.mid { color: var(--warm); }
.score.low { color: var(--faint); }

.empty { padding: 56px 20px; text-align: center; }
.empty h3 { font-size: 15px; margin-bottom: 6px; }
.empty p { color: var(--faint); font-size: 13px; margin: 0 0 16px; }

.foot { margin-top: 18px; }
.foot p { font-size: 12px; color: var(--faint); margin: 0; line-height: 1.7; }

/* ---------- 抽屉 ---------- */
.drawer-mask, .modal-mask {
  position: fixed; inset: 0; background: rgba(28, 28, 25, 0.28);
  z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(520px, 94vw);
  background: var(--card);
  border-left: 1px solid var(--line);
  z-index: 50;
  display: flex; flex-direction: column;
  animation: slideIn 0.18s ease;
}
@keyframes slideIn { from { transform: translateX(24px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 16px; line-height: 1.4; }
.close {
  border: none; background: transparent; color: var(--faint);
  font-size: 13px; font-family: inherit; cursor: pointer; padding: 2px 4px;
}
.close:hover { color: var(--text); }
.drawer-body { padding: 18px 22px; overflow-y: auto; }
.kv { display: grid; grid-template-columns: 88px 1fr; gap: 10px 12px; margin-bottom: 20px; }
.kv dt { font-size: 12px; color: var(--faint); }
.kv dd { margin: 0; font-size: 13px; word-break: break-all; }
.drawer-body h4 { font-size: 12px; color: var(--faint); font-weight: 400; margin: 18px 0 8px; }
.snippet {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px; font-size: 13px; color: var(--muted); line-height: 1.7;
}
.link-line { font-size: 12px; color: var(--accent); word-break: break-all; }

/* ---------- 弹窗 ---------- */
.modal-mask { display: flex; align-items: center; justify-content: center; z-index: 60; }
.modal {
  width: min(480px, 92vw);
  background: var(--card);
  border-radius: 14px;
  padding: 22px;
  border: 1px solid var(--line);
}
.modal h2 { font-size: 16px; margin-bottom: 6px; }
.hint { font-size: 12.5px; color: var(--faint); margin: 0 0 18px; line-height: 1.7; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--bg); font-size: 13px; font-family: inherit; color: var(--text);
  outline: none;
}
.field input, .field select { height: 40px; }
.field textarea {
  padding: 9px 12px;
  height: auto;
  min-height: 78px;
  resize: vertical;
  line-height: 1.6;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); background: #fff; }
.provider-note { font-size: 12px; color: var(--warm); margin: -8px 0 14px; line-height: 1.6; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 20px; }

@media (max-width: 860px) {
  .topbar { padding: 14px 16px; }
  main { padding: 14px; }
  .search-row { flex-wrap: wrap; }
  .kw-input { flex: 1 1 100%; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .col-loc, .col-tags { display: none; }
}

.import-area {
  width: 100%;
  height: 200px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  resize: vertical;
  outline: none;
}
.import-area:focus { border-color: var(--accent); background: #fff; }

/* ---------- 社媒 ---------- */
.col-social { width: 106px; white-space: nowrap; }
.plat.soc { background: #fbeaf0; color: #993556; border-color: #f4c0d1; }
.wechat {
  margin-top: 3px; font-size: 12px; color: #993556;
  font-family: ui-monospace, Consolas, monospace;
}
.soc-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: var(--bg);
}
.soc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.soc-top b { font-weight: 500; font-size: 13px; }
.soc-meta { font-size: 12px; color: var(--faint); margin-top: 4px; }

/* 列宽修正 */
.col-plat { width: 92px; }
.col-social { width: 92px; }
.col-phone { width: 126px; }
.col-tags { width: 128px; min-width: 108px; }
.col-score { width: 54px; }
.tag { white-space: nowrap; }
thead th, tbody td { padding-left: 10px; padding-right: 10px; }
.summary { min-width: 180px; }

thead th:nth-child(2), tbody td:nth-child(2) { min-width: 178px; }
.col-loc { width: 86px; }
.summary { min-width: 0; }

table { table-layout: fixed; width: 100%; }
tbody td { overflow: hidden; }
.cname { word-break: break-all; }

/* ---------- 平台采集：判定结果 ---------- */
.cap-result {
  margin: -4px 0 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfbf9;
  max-height: 360px;
  overflow-y: auto;
}
.cap-head {
  position: sticky;
  top: 0;
  background: #fbfbf9;
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
}
.cap-head b { color: var(--accent-deep); font-weight: 600; }
.cap-list { padding: 4px 0; }
.cap-item { padding: 8px 12px; border-bottom: 1px dashed var(--line); }
.cap-item:last-child { border-bottom: none; }
.cap-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cap-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cap-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  word-break: break-all;
}
.cap-why { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; }
.cap-why i {
  font-style: normal;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 20px;
  line-height: 1.7;
}
.cap-why i.ok { background: var(--ok-soft); color: var(--ok); }
.cap-why i.no { background: #fbeaea; color: var(--danger); }
.judge {
  flex: none;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 20px;
  font-weight: 500;
  white-space: nowrap;
}
.judge.lv1 { background: var(--ok-soft); color: var(--ok); }
.judge.lv2 { background: var(--accent-soft); color: var(--accent-deep); }
.judge.lv3 { background: var(--warm-soft); color: var(--warm); }

.btn[disabled] { opacity: .5; cursor: default; }
#capSave { flex: 1 0 100%; }

/* ---------- 登录状态 ---------- */
.login-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--faint);
  margin: -6px 0 14px;
}
.linkbtn {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}
.login-line b { font-weight: 500; margin-right: 12px; }
.login-line b.in { color: var(--ok); }
.login-line b.off { color: var(--muted); }

/* 在线只读版提示条 */
.cloud-note {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  font-size: 13px;
  line-height: 1.6;
}
.readonly-mode .btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* 采集弹窗里的开关行 */
.check-line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 10px;
  font-size: 13px;
  color: #475569;
  cursor: pointer;
}
.check-line input {
  margin-top: 3px;
  accent-color: #2563eb;
}

/* 顶部公网地址条 */
.tunnel-note {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 12px;
  padding: 9px 14px;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 13px;
}
.tunnel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.tunnel-note a {
  color: #1d4ed8;
  text-decoration: underline;
  word-break: break-all;
}
