/* GEO 采集终端 · Dashboard —— 独立产品的完整界面。现代扁平 + 克制的靛蓝主色。 */
:root {
  --brand: #4f46e5; --brand-2: #7c3aed; --brand-soft: #eef2ff;
  --bg: #f6f7fb; --surface: #ffffff; --line: #e8eaf0;
  --ink: #1a1c2e; --sub: #6b7280; --muted: #9aa0ac;
  --green: #16a34a; --amber: #d97706; --rose: #e11d48;
  --shadow: 0 1px 3px rgba(20,22,46,.06), 0 8px 24px rgba(20,22,46,.05);
  --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; cursor: pointer; }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.01em; }

.app { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar { width: 232px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { font-size: 16px; font-weight: 700; margin: 4px 8px 22px; display: flex; align-items: center; gap: 8px; }
.brand .logo { background: linear-gradient(135deg, var(--brand), var(--brand-2)); -webkit-background-clip: text;
  background-clip: text; color: transparent; font-size: 18px; }
#nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: var(--sub);
  font-weight: 500; transition: background .12s, color .12s; }
.nav-item .ico { width: 18px; text-align: center; opacity: .8; }
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.foot { margin-top: auto; font-size: 11px; color: var(--muted); padding: 12px 10px 0; line-height: 1.5; }
.foot .muted { color: var(--muted); }

/* 内容区 */
.content { flex: 1; padding: 28px 34px 60px; max-width: 1080px; }
.view { display: none; animation: fade .18s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.view-head { margin-bottom: 20px; }
.view-head .sub { color: var(--sub); margin: 6px 0 0; font-size: 13px; }

/* 卡片 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card-h { font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-h .muted { font-weight: 400; font-size: 12px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } .sidebar { width: 64px; } .brand span:not(.logo), .nav-item span:not(.ico), .foot { display: none; } }

/* 统计块 */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .n { font-size: 28px; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; }
.stat .n.grad { background: linear-gradient(135deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat .l { color: var(--sub); font-size: 12px; margin-top: 2px; }
@media (max-width: 700px) { .stat-row { grid-template-columns: 1fr 1fr; } }

/* 表单控件 */
textarea, .input, .select { width: 100%; font: inherit; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; color: var(--ink); resize: vertical; }
textarea:focus, .input:focus, .select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
/* 采集历史筛选栏:紧凑横向排布,控件按 flex-basis 定宽、不撑满整行(覆盖 .input 的 width:100%),按需换行 */
.hf { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.hf > .input { width: auto; flex: 1 1 150px; min-width: 120px; }
.hf-dates { display: flex; align-items: center; gap: 6px; flex: 1 1 250px; }
.hf-dates .input { width: auto; flex: 1; min-width: 0; }
.hf-dates > span { flex: none; font-size: 12px; color: var(--muted, #9aa0ac); }
.hf-search { display: flex; align-items: center; gap: 8px; flex: 2 1 260px; }
.hf-search .input { width: auto; flex: 1; min-width: 0; }
.hf-search .btn { flex: none; }
.hf-bar { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.hf-bar .grow { flex: 1; font-size: 12px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12px; color: var(--sub); margin-bottom: 5px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--sub); }
.mins { width: 52px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; }
.select { width: auto; min-width: 180px; }

/* 按钮 */
button { font: inherit; cursor: pointer; border-radius: 10px; padding: 9px 16px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-weight: 500; transition: .12s; }
button:hover:not(:disabled) { border-color: #cfd3de; background: #fafbff; }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: none; font-weight: 600; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.btn-danger { color: var(--rose); border-color: #f3c6cf; }
.btn-danger:hover { background: #fff1f3; }
.btn-mini { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn-mini.right, .right { margin-left: auto; }
.status { font-size: 12px; color: var(--sub); }

/* 列表行(通用) */
.item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.item:last-child { border-bottom: none; }
.item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-num { width: 22px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { height: 7px; border-radius: 4px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.bar-track { flex: 1; height: 7px; border-radius: 4px; background: var(--bg); overflow: hidden; }
.cnt { width: 44px; text-align: right; font-variant-numeric: tabular-nums; color: var(--sub); }
.media-copy { font: inherit; font-size: 11px; color: var(--brand); background: var(--brand-soft); border: none; border-radius: 6px; padding: 3px 9px; margin: 0 8px; cursor: pointer; white-space: nowrap; transition: background .12s, color .12s; }
.media-copy:hover { background: var(--brand); color: #fff; }
.media-copy:disabled { opacity: .75; cursor: default; }

/* 徽章 */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.green { background: #e7f6ec; color: var(--green); }
.badge.gray { background: #f0f1f4; color: var(--muted); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.amber { background: #fef3e2; color: var(--amber); }
.badge.rose { background: #fde8ec; color: var(--rose); }

/* 平台列表 */
.platform-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.plat { display: flex; align-items: center; gap: 8px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; }
.plat .dot { width: 8px; height: 8px; border-radius: 50%; }
.plat .dot.on { background: var(--green); } .plat .dot.beta { background: var(--amber); }
.plat .pl-name { font-weight: 600; } .plat .pl-open { margin-left: auto; font-size: 12px; color: var(--brand); }
.plat .pl-mode { font-size: 11px; color: var(--muted); }

/* 品牌管理 chip */
.manage-box { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; font-size: 13px; }
.chip .x { color: var(--muted); cursor: pointer; font-weight: 700; }
.chip .x:hover { color: var(--rose); }

/* 历史条目 */
.hitem { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; box-shadow: var(--shadow); }
.hitem summary { list-style: none; padding: 13px 16px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.hitem summary::-webkit-details-marker { display: none; }
.hitem .q { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hitem .meta { font-size: 12px; color: var(--muted); }
.hitem .body { padding: 0 16px 15px; border-top: 1px solid var(--line); margin-top: 2px; }
/* 答案容器。内容由 md.js 渲染成真 DOM(排版/高亮样式都在 md.js 里,别在这重复定义) */
.hitem .ans { word-break: break-word; background: var(--bg); border-radius: 8px; padding: 10px 12px;
  max-height: 320px; overflow-y: auto; margin: 12px 0; }
.hitem .refs a { display: block; color: var(--brand); font-size: 12px; padding: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hitem .hdel { color: var(--muted); font-size: 12px; }
.hitem .hdel:hover { color: var(--rose); }

/* 监测项 */
.watch-row.on { background: var(--brand-soft); border-radius: 8px; margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
.qcov { padding: 10px 0; border-bottom: 1px solid var(--line); }
.qcov:last-child { border-bottom: none; }
.qcov-q { font-weight: 500; margin-bottom: 6px; }
.qcov-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* 媒体榜筛选条 */
.src-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.src-filters label { font-size: 12px; color: var(--sub); display: flex; align-items: center; gap: 6px; }
.src-filters .select { min-width: 130px; max-width: 260px; padding: 7px 10px; }
.src-filters .date { min-width: 130px; max-width: 150px; }
.src-quick { display: inline-flex; gap: 10px; font-size: 12px; }
.src-quick a { color: var(--brand); cursor: pointer; }
.src-quick a:hover { text-decoration: underline; }

/* 客户中心:客户/品牌 pill 选择器 + 可编辑客户名 + tab 栏 */
.cl-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.cl-pill { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--sub); font-size: 13px; font-weight: 500; cursor: pointer; }
.cl-pill:hover:not(:disabled) { border-color: #cfd3de; color: var(--ink); background: #fafbff; }
.cl-pill.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.cl-pill.add { border-style: dashed; color: var(--brand); }
.cl-pill .muted { font-size: 11px; }
.cl-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.cl-name-input { font-size: 20px; font-weight: 700; border: none; background: transparent; color: var(--ink); padding: 4px 8px; border-radius: 8px; flex: 1; min-width: 0; letter-spacing: -.01em; font-family: inherit; }
.cl-name-input:hover { background: var(--bg); }
.cl-name-input:focus { outline: none; background: var(--bg); box-shadow: 0 0 0 2px var(--brand-soft); }
.cl-tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.cl-tab { padding: 9px 16px; border: none; border-radius: 0; background: none; color: var(--sub); font-size: 14px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.cl-tab:hover:not(:disabled) { color: var(--ink); background: none; border-color: transparent; border-bottom-color: var(--line); }
.cl-tab.on { color: var(--brand); border-bottom-color: var(--brand); }

/* 检测记录 · 效果详情(仿对手 3 级下钻,原文里我方品牌/竞品双高亮) */
.eff-row { border-top: 1px solid var(--line); }
.eff-row:first-child { border-top: none; }
.eff-row > summary { list-style: none; padding: 9px 4px; display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.eff-row > summary::-webkit-details-marker { display: none; }
.effect { padding: 6px 4px 12px; display: flex; flex-direction: column; gap: 14px; }
.eff-metrics { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.eff-metrics .m { font-size: 12px; color: var(--sub); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; white-space: nowrap; }
.eff-metrics .m b { color: var(--ink); font-weight: 700; }
.eff-metrics .m.hit { background: #e8f8ee; border-color: #bfe9cf; color: var(--green); font-weight: 600; }
.eff-metrics .m.miss { color: var(--muted); }
.eff-metrics .m.ghost { border: none; background: transparent; color: var(--muted); margin-left: auto; }
.eff-orig { display: flex; flex-direction: column; gap: 8px; }
.q-bubble { align-self: flex-end; max-width: 82%; background: var(--brand-soft); color: var(--brand); border-radius: 12px 12px 3px 12px; padding: 8px 12px; font-size: 13px; }
/* 答案气泡只管容器。内部排版/品牌高亮/信源卡的样式都在 md.js 里,这里不重复定义 */
.a-bubble { background: var(--bg); border-radius: 3px 12px 12px 12px; padding: 12px 14px; word-break: break-word; max-height: 420px; overflow-y: auto; }
.src-filters .src-summary { margin-left: auto; font-size: 12px; }

.empty { color: var(--muted); text-align: center; padding: 28px 0; font-size: 13px; }
.log { margin: 12px 0 0; max-height: 160px; overflow-y: auto; background: #1a1c2e; color: #9be8b0;
  font-size: 12px; line-height: 1.55; padding: 10px 12px; border-radius: 10px; white-space: pre-wrap; word-break: break-all; }
.log:empty { display: none; }
.muted { color: var(--muted); }
