/* ============================================================
   Lead Workbench · 智能获客工作台（搜客平台）
   设计语言：墨绿工业感 + 沙金强调 · 无 emoji · SVG 图标
   ============================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --font-head: 'Noto Serif SC', 'Microsoft YaHei', 'SimSun', serif;
  --font-body: 'Noto Sans SC', 'Microsoft YaHei', 'PingFang SC', 'Segoe UI', sans-serif;
  --ink: #16201d;
  --ink-2: #5c6b66;
  --ink-3: #93a09b;
  --paper: #f6f4ef;
  --panel: #ffffff;
  --line: #e6e2d8;
  --pine: #12332b;          /* 主色：深墨绿 */
  --pine-soft: #e7efeb;
  --pine-mid: #2e6b5c;
  --gold: #b98a2f;          /* 强调：沙金 */
  --gold-soft: #f4ecd8;
  --high: #b3542a;          /* 高意向：砖红 */
  --high-soft: #f9e8df;
  --mid: #2f6ba3;           /* 中意向：蓝 */
  --mid-soft: #e5eef8;
  --low: #7d8a86;           /* 低意向：灰绿 */
  --low-soft: #edf0ee;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(22, 32, 29, .06);
}

html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; letter-spacing: .01em; }
a, button, [role=button] { cursor: pointer; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px; flex-shrink: 0;
  background: var(--pine);
  color: #e9f0ed;
  padding: 22px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; border-bottom: 1px solid rgba(233,240,237,.15); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--gold); display: grid; place-items: center; flex-shrink: 0;
}
.brand h1 { font-size: 15px; color: #fff; }
.brand p { font-size: 11px; color: rgba(233,240,237,.55); letter-spacing: .06em; }
.ver-badge {
  font-size: 11px; font-weight: 700; color: #16201d;
  background: var(--gold); border-radius: 6px; padding: 1px 7px; margin-left: 6px;
  cursor: pointer; vertical-align: middle; letter-spacing: .02em;
  transition: opacity .15s ease;
}
.ver-badge:hover { opacity: .82; }
.changelog-modal { width: 660px; max-width: 92vw; max-height: 82vh; }
.markdown-body { font-size: 13px; line-height: 1.7; color: var(--ink); }
.markdown-body h1 { font-size: 19px; margin: 4px 0 12px; color: var(--ink); }
.markdown-body h2 { font-size: 15px; margin: 18px 0 8px; color: var(--pine-mid); border-left: 3px solid var(--pine-mid); padding-left: 8px; }
.markdown-body h3 { font-size: 13.5px; margin: 14px 0 6px; color: var(--ink); }
.markdown-body p { margin: 6px 0; color: var(--ink-2); }
.markdown-body ul { margin: 6px 0; padding-left: 20px; }
.markdown-body li { margin: 3px 0; color: var(--ink-2); }
.markdown-body hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.markdown-body code { background: #f2f5f3; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.markdown-body a { color: var(--pine-mid); text-decoration: underline; }

.nav { margin-top: 16px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: rgba(233,240,237,.78); font-size: 13.5px;
  background: none; border: none; text-align: left; width: 100%;
  transition: background .15s;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(185,138,47,.22); color: #ffd98a; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

.sidebar-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(233,240,237,.15); font-size: 11.5px; color: rgba(233,240,237,.5); }
.sidebar-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #6fbf8f; margin-right: 6px; }

.main { flex: 1; min-width: 0; padding: 26px 32px 48px; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.topbar h2 { font-size: 20px; }
.topbar .sub { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }

/* ---------- 通用组件 ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 18px;
}
.panel h3 { font-size: 14.5px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; font-size: 13px;
  font-family: var(--font-body); font-weight: 500;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  transition: all .15s;
}
.btn:hover { border-color: var(--pine-mid); color: var(--pine-mid); }
.btn.primary { background: var(--pine); border-color: var(--pine); color: #fff; }
.btn.primary:hover { background: var(--pine-mid); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.gold:hover { background: #c99b3e; }
.btn.wechat { background: #07c160; border-color: #07c160; color: #fff; }
.btn.wechat:hover { background: #06ad56; }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.disabled { opacity: .45; background: var(--low-soft); color: var(--ink-3); cursor: not-allowed; border-color: var(--line); }
.btn.disabled:hover { border-color: var(--line); color: var(--ink-3); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500;
}
.chip.high { background: var(--high-soft); color: var(--high); }
.chip.mid { background: var(--mid-soft); color: var(--mid); }
.chip.low { background: var(--low-soft); color: var(--low); }
.chip.public { background: var(--pine-soft); color: var(--pine-mid); }
.chip.private { background: var(--gold-soft); color: #8a6a24; }
.chip.gray { background: var(--low-soft); color: var(--ink-2); }
.chip.gold { background: var(--gold-soft); color: #8a6a24; border: 1px solid rgba(138,106,36,.25); }

/* ---------- 顶栏账号栏 ---------- */
.account-bar { display: flex; align-items: center; gap: 10px; }

/* ---------- 指标卡 ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .label { font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.stat .value { font-family: var(--font-head); font-size: 27px; font-weight: 600; margin-top: 4px; }
.stat .value .unit { font-size: 13px; color: var(--ink-3); font-weight: 400; margin-left: 3px; }
.stat .trend { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.stat .accent-line { width: 26px; height: 3px; border-radius: 2px; background: var(--gold); margin-top: 10px; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* 分布条 */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.bar-row .lbl { width: 54px; font-size: 12.5px; color: var(--ink-2); flex-shrink: 0; }
.bar-track { flex: 1; height: 9px; background: var(--pine-soft); border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 5px; transition: width .5s ease; }
.bar-row .num { width: 30px; text-align: right; font-family: var(--font-head); font-weight: 600; font-size: 13px; }

/* ---------- 表格 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.search {
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--font-body); font-size: 13px; background: #fff; color: var(--ink);
  width: 220px; outline: none;
}
.search:focus { border-color: var(--pine-mid); }
select.filter {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--font-body); font-size: 13px; background: #fff; color: var(--ink); outline: none;
}

/* 周边找线索地址联想下拉 */
.geo-suggest {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
  margin-top: 4px; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.08);
  max-height: 260px; overflow-y: auto;
}
.geo-suggest-item {
  padding: 7px 12px; cursor: pointer; border-bottom: 1px dashed var(--line);
}
.geo-suggest-item:last-child { border-bottom: none; }
.geo-suggest-item:hover { background: #f3f7f5; }
.geo-suggest-item .cell-main { font-size: 12.5px; font-weight: 500; color: var(--ink); }
.geo-suggest-item .cell-sub { font-size: 11px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 10px 12px; font-weight: 500; font-size: 12px;
  color: var(--ink-2); border-bottom: 1px solid var(--line); white-space: nowrap;
  background: #fbfaf7;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #faf9f5; }
.cell-main { font-weight: 500; }
.cell-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.contact-list { display: flex; flex-wrap: wrap; gap: 4px; }

/* 分页 */
.pager { display: flex; align-items: center; gap: 10px; padding-top: 12px; margin-top: 6px; border-top: 1px solid var(--line); }

/* ---------- 空状态 / 提示 ---------- */
.empty { text-align: center; color: var(--ink-3); padding: 34px 0; font-size: 13px; }
.toast {
  position: fixed; top: 18px; left: 50%; z-index: 99;
  transform: translateX(-50%) translateY(-8px);
  background: var(--pine); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 4px 14px rgba(22,32,29,.25);
  white-space: nowrap;
  opacity: 0; transition: all .25s;
  pointer-events: none;   /* 提示条永不拦截点击 */
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--high); }

.loading { text-align: center; color: var(--ink-3); padding: 40px 0; font-size: 13px; }

/* 日志 */
.log-row { font-size: 12.5px; padding: 7px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 10px; }
.log-row:last-child { border-bottom: none; }
.log-row .time { color: var(--ink-3); flex-shrink: 0; font-family: var(--font-head); }
.log-row .src { color: var(--pine-mid); font-weight: 500; flex-shrink: 0; width: 70px; }
.log-row .status { margin-left: auto; flex-shrink: 0; }

/* ---------- 可点击表格行 ---------- */
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--pine-soft); }

/* 空号检测徽章 */
.phone-flag { font-size: 10px; padding: 0 4px; border-radius: 3px; margin-left: 2px; }
.phone-flag.valid { background: #dbeedd; color: #3b6d11; }
/* 复制按钮 */
.copy-btn {
  background: none; border: 1px solid transparent; color: var(--ink-3);
  width: 22px; height: 22px; border-radius: 5px; cursor: pointer;
  font-size: 13px; line-height: 1; display: inline-grid; place-items: center;
  flex-shrink: 0; padding: 0;
}
.copy-btn:hover { color: var(--pine-mid); border-color: var(--line); background: var(--pine-soft); }
.phone-flag.invalid { background: #f7c1c1; color: #a32d2d; }
.phone-flag.pending { background: #eceff1; color: #5f6b66; }

/* ---------- 数据源接入状态 ---------- */
.src-status-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.src-status {
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: #fbfaf7;
}
.src-status-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.src-name { font-weight: 500; font-size: 13.5px; }

/* ---------- 详情抽屉 ---------- */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(18, 51, 43, .35); z-index: 90;
  animation: fadein .2s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: -460px; width: 440px; height: 100vh;
  background: var(--panel); z-index: 95;
  box-shadow: -8px 0 30px rgba(22,32,29,.15);
  transition: right .28s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
}
.drawer.open { right: 0; }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 22px 14px; border-bottom: 1px solid var(--line);
}
.drawer-head h3 { font-size: 16px; }
.drawer-close {
  background: none; border: none; color: var(--ink-2); padding: 0;
  border-radius: 8px; line-height: 0; cursor: pointer;
  width: 34px; height: 34px; display: grid; place-items: center;
  flex-shrink: 0; margin-left: 12px;
}
.drawer-close:hover { color: var(--ink); background: var(--pine-soft); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px 28px; }
.detail-block { margin-bottom: 20px; }
.detail-block h4 {
  font-size: 13px; color: var(--ink-2); margin-bottom: 10px;
  display: flex; align-items: center; gap: 10px; font-weight: 500;
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.detail-grid > div { font-size: 13px; }
.d-label { display: block; font-size: 11px; color: var(--ink-3); margin-bottom: 2px; }
.detail-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px dashed var(--line); font-size: 13px;
}
.detail-row:last-child { border-bottom: none; }
.signal-row {
  display: flex; align-items: flex-start; gap: 10px; padding: 9px 0;
  border-bottom: 1px dashed var(--line); font-size: 13px;
}
.signal-row:last-child { border-bottom: none; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 6px; border-top: 1px solid var(--line); }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .src-status-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: 14px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { display: none; }
  .main { padding: 18px 14px; }
  .stats-grid { grid-template-columns: 1fr; }
  .search { width: 100%; }
  .src-status-grid { grid-template-columns: 1fr; }
  .drawer { width: 100%; right: -100%; }
  .detail-grid { grid-template-columns: 1fr; }
}

/* 采集关键词管理 */
.kw-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-size: 12px; color: var(--ink);
}
.kw-chip.off { background: #f5f5f5; }
.kw-chip.dim { background: #f7f8f8; color: var(--ink-3); }
.kw-chip em { font-style: normal; }
.kw-btn {
  border: none; background: transparent; cursor: pointer;
  color: var(--ink-3); font-size: 12px; padding: 0 2px; line-height: 1;
}
.kw-btn:hover { color: var(--pine-mid); }
.kw-btn.danger:hover { color: #c0392b; }

/* 关键词详细设置弹窗 */
.kw-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 640px; max-width: 92vw; max-height: 82vh;
  background: var(--panel); border-radius: 14px; z-index: 96;
  box-shadow: 0 20px 60px rgba(22,32,29,.25);
  display: flex; flex-direction: column; overflow: hidden;
  animation: fadein .2s ease;
}
.kw-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.kw-modal-body { flex: 1; overflow-y: auto; padding: 18px 20px 24px; }

/* 数据源接入 · 平台登录（合并模块） */
.src-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.src-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;  /* 小圆角矩形 */
  font-size: 12.5px; font-weight: 500; border: 1px solid var(--line);
}
.src-badge em { font-style: normal; font-size: 11px; font-weight: 400; }
.src-badge.on { background: var(--mid-soft); color: var(--mid); border-color: transparent; }
.src-badge.on em { color: var(--mid); opacity: .75; }
.src-badge.off { background: var(--low-soft); color: var(--ink-2); }
.src-badge.off em { color: var(--ink-3); }

/* 平台登录卡片：登录成功与未登录颜色区分 */
.src-status.logged {
  background: var(--pine-soft); border-color: var(--pine-mid);
}
.src-status.logged .src-name { color: var(--pine-mid); }

/* 数据源接入汇总条：点击高亮对应卡片 */
.src-badge { cursor: pointer; transition: all .15s ease; }
.src-badge:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.src-badge.active { outline: 2px solid var(--gold); outline-offset: 1px; box-shadow: 0 0 0 3px var(--gold-soft); }
.src-badge.on.active { background: var(--mid-soft); }
.src-badge.off.active { background: var(--gold-soft); }
.src-badge.off.active em { color: var(--gold); }

/* 平台登录卡片高亮（点击数据源后提示） */
.src-status { transition: all .15s ease; }
.src-status.lit {
  outline: 2px solid var(--gold); outline-offset: 1px;
  box-shadow: 0 0 0 3px var(--gold-soft);
  transform: translateY(-1px);
}

/* 接入指引 */
.badge-guide {
  border: none; background: transparent; cursor: pointer;
  font-size: 11px; color: var(--mid); text-decoration: underline; padding: 0; line-height: 1;
}
.badge-guide:hover { color: var(--gold); }
.guide-num {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
  background: var(--pine-soft); color: var(--pine-mid);
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}

/* 看板：近7天新增趋势 */
.trend-bar {
  width: 100%; max-width: 26px; border-radius: 5px 5px 2px 2px;
  background: linear-gradient(180deg, var(--pine-mid), var(--pine));
  min-height: 3px; transition: height .3s ease;
}

/* 访问鉴权登录框（配置 APP_AUTH_TOKEN 后显示） */
.login-box {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 360px; max-width: 90vw;
  background: var(--panel); border-radius: 14px; z-index: 4100;
  box-shadow: 0 20px 60px rgba(22,32,29,.3);
  padding: 26px 28px 30px; box-sizing: border-box;
  animation: fadein .2s ease;
}

/* noVNC 远程登录弹窗（无头服务器虚拟浏览器画面） */
.vnc-box {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(1080px, 94vw); height: min(720px, 92vh);
  background: var(--panel); border-radius: 14px; z-index: 3950;
  box-shadow: 0 20px 60px rgba(22,32,29,.35);
  display: flex; flex-direction: column; overflow: hidden;
  animation: fadein .2s ease;
}
.vnc-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.vnc-frame {
  flex: 1; width: 100%; border: 0; background: #000;
}
.vnc-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--line);
}
