:root {
  --ink: #101820;
  --ink-2: #1c2934;
  --paper: #f4f2eb;
  --card: #fffef9;
  --line: #d8d5cb;
  --muted: #6b746f;
  --signal: #c8f135;
  --blue: #1d5eff;
  --danger: #d23c3c;
  --green: #1a9e6b;
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background:
    linear-gradient(rgba(16,24,32,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16,24,32,.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}
.rank-app { max-width: 1560px; margin: 0 auto; padding: 24px 30px 56px; }

/* topbar */
.topbar { position: relative; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 28px; min-height: 188px; padding: 34px 38px; overflow: hidden; color: #fff; background: var(--ink); border: 1px solid #263642; border-radius: 4px; box-shadow: 0 18px 45px rgba(16,24,32,.16); animation: reveal .35s ease both; }
.topbar::after { content: ""; position: absolute; right: -58px; bottom: -158px; width: 330px; height: 330px; border: 55px solid var(--signal); border-radius: 50%; pointer-events: none; }
.hero-copy,.hero-actions { position: relative; z-index: 1; }
.eyebrow,.section-kicker { color: var(--signal); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
.topbar h1 { margin: 10px 0 8px; font-family: "Songti SC","STSong",serif; font-size: clamp(32px,4vw,52px); line-height: 1.05; letter-spacing: -.04em; }
.topbar p { max-width: 660px; margin: 0; color: #b8c2c8; font-size: 13px; line-height: 1.8; }
.hero-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 18px; }
.search-entry { display: inline-flex; gap: 18px; align-items: center; padding: 11px 15px; color: var(--ink); background: var(--signal); border-radius: 99px; font-size: 12px; font-weight: 800; text-decoration: none; }
.search-entry span { font-size: 17px; line-height: 1; }
.search-entry.alt2 { background: #2a3946; color: #fff; }
.status { display: inline-flex; align-items: center; gap: 8px; color: #dce3e6; font-size: 12px; }
.status::before { content: ""; width: 7px; height: 7px; background: var(--signal); border-radius: 50%; box-shadow: 0 0 0 4px rgba(200,241,53,.12); }
.status.subtle { color: var(--muted); }
.status.subtle::before { background: var(--blue); box-shadow: 0 0 0 4px rgba(29,94,255,.1); }
.status.ok::before { background: var(--green); box-shadow: 0 0 0 4px rgba(26,158,107,.12); }
.status.bad::before { background: var(--danger); box-shadow: 0 0 0 4px rgba(210,60,60,.12); }

/* workflow */
.workflow { display: flex; align-items: center; padding: 16px 22px; margin: 14px 0; background: rgba(255,254,249,.94); border: 1px solid var(--line); box-shadow: 0 8px 28px rgba(16,24,32,.05); }
.workflow-item { display: flex; align-items: center; gap: 10px; min-width: 150px; color: var(--muted); }
.workflow-item b { font-family: "Avenir Next Condensed",sans-serif; font-size: 24px; color: #adb2ac; }
.workflow-item span { display: flex; flex-direction: column; font-size: 12px; font-weight: 800; }
.workflow-item small { margin-top: 2px; color: #989f9b; font-size: 10px; font-weight: 500; }
.workflow-item.active b { color: var(--blue); }
.workflow-item.active span { color: var(--ink); }
.workflow-line { flex: 1; height: 1px; margin: 0 18px; background: var(--line); }

/* cards */
.card { padding: 24px; margin-bottom: 16px; background: rgba(255,254,249,.97); border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 8px 28px rgba(16,24,32,.06); animation: reveal .4s .05s ease both; }
.pool-card { border-top: 4px solid var(--blue); }
.hot-card { border-top: 4px solid var(--signal); }
.index-card { border-top: 4px solid var(--green); }
.tree-card { border-top: 4px solid #8a6dff; }
.expand-card { border-top: 4px solid #ff9f1c; }
.select-card { border-top: 4px solid var(--blue); }
.section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; margin-bottom: 18px; }
.section-title h2 { margin: 4px 0 3px; font-family: "Songti SC","STSong",serif; font-size: 22px; line-height: 1.25; }
.section-title p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.section-kicker { color: var(--blue); }
.hot-card .section-kicker { color: #a9b32a; }
.index-card .section-kicker { color: var(--green); }
.tree-card .section-kicker { color: #8a6dff; }
.expand-card .section-kicker { color: #d68312; }
.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-weight: 700; }

/* form */
.grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .03em; }
select,input,textarea { width: 100%; min-height: 42px; padding: 9px 12px; color: var(--ink); background: #fff; border: 1px solid #c9c6bb; border-radius: 3px; outline: none; font: inherit; font-size: 13px; transition: border-color .18s, box-shadow .18s; }
textarea { resize: vertical; line-height: 1.6; }
select:focus,input:focus,textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29,94,255,.12); }
input[type="checkbox"] { width: auto; min-height: 0; padding: 0; box-shadow: none; transition: none; }
select:disabled { color: #8f9692; background: #f0eee7; }
.prompt-label { margin-top: 8px; }

button { min-height: 39px; padding: 8px 15px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 3px; cursor: pointer; font: inherit; font-size: 12px; font-weight: 800; transition: transform .18s,box-shadow .18s,background .18s; }
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 5px 13px rgba(16,24,32,.11); }
button.primary { color: #fff; background: var(--blue); border-color: var(--blue); }
button.signal { color: var(--ink); background: var(--signal); border-color: var(--signal); }
button:disabled { opacity: .42; cursor: not-allowed; }
.actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.count-pill { padding: 7px 11px; color: var(--ink); background: #eef0e9; border-radius: 99px; font-size: 11px; font-weight: 800; }

/* toolbar */
.toolbar { display: grid; grid-template-columns: minmax(180px,2fr) 1.2fr 1fr 1fr auto auto; gap: 10px; align-items: end; margin-bottom: 14px; }
.toolbar button { min-height: 42px; }
.empty { padding: 40px; color: #929994; text-align: center; }

/* table */
.table-wrap { max-height: 560px; overflow: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: var(--card); font-size: 12px; }
th,td { padding: 11px 10px; border-bottom: 1px solid #e8e5dc; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; color: #dfe7ea; background: var(--ink-2); border-bottom: 0; font-size: 10px; letter-spacing: .06em; }
tbody tr:hover { background: #f3f8de; }
.kw-name { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 700; }
.src-badge { padding: 3px 7px; border-radius: 99px; font-size: 10px; font-weight: 800; background: #eef0e9; color: var(--muted); white-space: nowrap; }
.src-badge.douyin_hot { background: #fff3c4; color: #8a6d00; }
.src-badge.榜单拆词 { background: #e3edff; color: #1749c6; }
.src-badge.AI推荐 { background: #f5fbdc; color: #5c7a00; }
.src-badge.下钻 { background: #ffe9d6; color: #b5560a; }
.src-badge.相关词 { background: #ece6ff; color: #5b3fb0; }
.st-badge { padding: 3px 8px; border-radius: 99px; font-size: 10px; font-weight: 800; }
.st-badge.候选 { background: #eef0e9; color: var(--muted); }
.st-badge.已勾选 { background: var(--signal); color: var(--ink); }
.st-badge.已淘汰 { background: #f3dede; color: var(--danger); }
.verify-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.vbadge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 7px; border-radius: 99px; font-size: 10px; font-weight: 800; }
.vbadge.hot { background: #fff3c4; color: #8a6d00; }
.vbadge.idx { background: #dff5ea; color: #0d6b48; }
.vbadge.none { background: #f0eee7; color: #a7aca7; }
.row-actions { display: flex; gap: 6px; }
.row-actions button { min-height: 30px; padding: 5px 9px; font-size: 11px; }
.link-btn { color: var(--blue); background: transparent; border: 1px solid #cdd8f5; }
.trend-btn { color: var(--green); background: transparent; border: 1px solid #c7e8d8; }

/* 统一词库整改（12.7）：日期来源徽章——生参=抓取日，流量解析=统计日 */
.date-src { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.date-src b { padding: 1px 6px; border-radius: 99px; font-size: 9px; font-weight: 800; }
.date-src.sycm b { background: #e3edff; color: #1749c6; }
.date-src.metric b { background: #dff5ea; color: #0d6b48; }

/* tree */
.tree-view { margin-top: 14px; }
.tree-root { margin-bottom: 14px; padding: 14px; background: #f8f7ff; border: 1px solid #e0dbff; border-radius: 4px; }
.tree-root > .tree-root-name { font-size: 15px; font-weight: 800; color: #5b3fb0; }
.tree-leaves { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.leaf { padding: 5px 9px; background: #fff; border: 1px solid #e0dbff; border-radius: 99px; font-size: 11px; }

/* expand / dedup */
.checks { display: flex; gap: 18px; margin: 4px 0 2px; color: var(--muted); font-size: 12px; font-weight: 700; }
.checks label { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); }
.expand-result { margin-top: 12px; }
.exp-seed { margin: 8px 0; padding: 12px; background: #fff8ef; border: 1px solid #ffe2c2; border-radius: 4px; }
.exp-seed b { color: #b5560a; }
.exp-words { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.exp-word { padding: 4px 8px; background: #fff; border: 1px solid #ffe2c2; border-radius: 99px; font-size: 11px; }
.dedup-row { display: flex; align-items: center; gap: 14px; margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.dedup-result { margin-top: 12px; }
.dedup-pair { display: inline-flex; gap: 6px; align-items: center; padding: 6px 10px; margin: 4px 6px 0 0; background: #f7f7f2; border: 1px solid var(--line); border-radius: 3px; font-size: 11px; }

/* chips (selection) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sel-chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; background: #eef6ff; border: 1px solid #cdd8f5; border-radius: 99px; font-size: 12px; font-weight: 700; color: #1749c6; }
.sel-chip button { min-height: 22px; width: 22px; padding: 0; font-size: 14px; line-height: 1; color: var(--danger); background: transparent; border: 0; }

/* dialog / trend */
.keyword-index-dialog { width: min(860px,92vw); max-height: 88vh; padding: 24px; color: var(--ink); background: var(--paper); border: 0; border-radius: 5px; box-shadow: 0 22px 80px rgba(0,0,0,.4); overflow: auto; }
.keyword-index-dialog::backdrop { background: rgba(10,18,24,.72); }
.dialog-close { position: absolute; top: 12px; right: 12px; min-height: 30px; width: 30px; padding: 0; color: #fff; background: var(--danger); border: 0; border-radius: 50%; font-size: 20px; }

/* §69.28.29.7：SYCM 预检状态弹窗 */
.sycm-preflight-dialog { width: min(420px,92vw); padding: 22px 24px; color: var(--ink); background: var(--paper); border: 0; border-radius: 6px; box-shadow: 0 22px 80px rgba(0,0,0,.4); }
.sycm-preflight-dialog::backdrop { background: rgba(10,18,24,.72); }
.sycm-preflight-head { position: relative; padding-right: 40px; font-size: 16px; }
.sycm-preflight-body { margin: 14px 0 18px; color: var(--ink); font-size: 14px; line-height: 1.6; }
.sycm-preflight-actions { display: flex; gap: 10px; justify-content: flex-end; }
.sycm-preflight-actions button { min-height: 34px; padding: 0 16px; }
.trend-title { display: flex; align-items: center; gap: 10px; padding-right: 36px; }
.trend-title h2 { margin: 0; font-family: "Songti SC","STSong",serif; font-size: 26px; }
.trend-svg { display: block; width: 100%; height: auto; padding: 8px; background: #fff; border: 1px solid var(--line); }
.trend-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 12px; }
.trend-table th { position: static; background: var(--ink-2); color: #dfe7ea; padding: 8px 10px; }
.trend-table td { padding: 8px 10px; border-bottom: 1px solid #e8e5dc; }
.legend { display: flex; gap: 18px; margin: 8px 0; color: var(--muted); font-size: 11px; }
.legend i { display: inline-block; width: 18px; height: 3px; margin-right: 5px; vertical-align: middle; }
.trend-metrics { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.trend-metrics span { padding: 4px 8px; background: #fff; border: 1px solid var(--line); border-radius: 3px; font-size: 11px; }
.trend-controls { display: flex; flex-wrap: wrap; gap: 14px; margin: 10px 0 4px; }
.trend-controls label { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.trend-controls select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; background: #fff; font-size: 12px; color: var(--ink); }
#trendChart { margin-top: 4px; }

@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 920px) {
  .toolbar, .grid { grid-template-columns: 1fr 1fr; }
  .topbar { grid-template-columns: 1fr; }
  .hero-actions { align-items: flex-start; }
}

/* ===== 阿里妈妈流量趋势 ===== */
.alimama-metrics-toggle { display:flex; flex-wrap:wrap; gap:10px 18px; margin:8px 0; font-size:13px; color:#cbd5e1; }
.alimama-metrics-toggle label { display:inline-flex; align-items:center; gap:6px; cursor:pointer; }
.alimama-chart-wrap { position:relative; height:340px; margin-top:8px; }
#alimamaChart { width:100% !important; height:100% !important; }

/* ===== 多租户用户管理弹窗 ===== */
.auth-modal-mask { position:fixed; inset:0; background:rgba(2,6,17,.66); display:flex; align-items:center; justify-content:center; z-index:2000; }
.auth-modal { background:#0f172a; border:1px solid #1e293b; border-radius:12px; padding:18px 20px; width:min(720px,92vw); max-height:80vh; overflow:auto; box-shadow:0 12px 40px rgba(0,0,0,.5); }
.auth-modal table th, .auth-modal table td { border-bottom:1px solid #1e293b; padding:6px 8px; text-align:left; }
.auth-modal table th { color:#94a3b8; font-weight:600; }
.auth-modal .auth-role-select { background:#0b1220; color:#e2e8f0; border:1px solid #334155; border-radius:6px; padding:2px 6px; }
.auth-modal .st-badge { font-size:12px; padding:1px 8px; border-radius:999px; }
.auth-modal .st-badge.候选 { background:rgba(34,197,94,.15); color:#4ade80; }
.auth-modal .st-badge.已淘汰 { background:rgba(239,68,68,.15); color:#f87171; }

/* ===== 列配置弹窗（深色，对齐 auth-modal）===== */
.colcfg-modal {
  width: 380px; max-width: 92vw; max-height: 80vh; overflow: hidden;
  background: #0f172a; border: 1px solid #1e293b; border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5); display: flex; flex-direction: column;
}
.colcfg-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid #1e293b; }
.colcfg-head h3 { margin: 0; font-size: 15px; color: #e2e8f0; }
.colcfg-hint { font-size: 11px; color: #64748b; flex: 1; }
.colcfg-x { border: none; background: transparent; font-size: 22px; line-height: 1; color: #64748b; cursor: pointer; padding: 0 4px; }
.colcfg-x:hover { color: #e2e8f0; }
.colcfg-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.colcfg-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; margin: 4px 0;
  background: #1e293b; border: 1px solid #334155; border-radius: 9px; cursor: grab;
  transition: background .15s, opacity .15s;
}
.colcfg-item:hover { background: #243044; }
.colcfg-item.dragging { opacity: .4; }
.colcfg-item.off { opacity: .5; }
.colcfg-grip { color: #475569; font-size: 14px; cursor: grab; user-select: none; }
.colcfg-name { flex: 1; font-size: 13px; color: #cbd5e1; }
.colcfg-visible { accent-color: #667eea; width: 16px; height: 16px; }
.colcfg-move { display: flex; gap: 4px; }
.colcfg-move button {
  border: 1px solid #334155; background: #0f172a; border-radius: 6px; width: 26px; height: 24px;
  cursor: pointer; color: #94a3b8; font-size: 13px; line-height: 1;
}
.colcfg-move button:hover { border-color: #667eea; color: #a5b4fc; }
.colcfg-move button[data-act="top"] { border-color: #4f46e5; color: #c7d2fe; font-weight: 600; width: 30px; }
.colcfg-move button[data-act="top"]:hover { background: #4f46e5; color: #fff; }
.colcfg-foot { display: flex; justify-content: space-between; gap: 10px; padding: 14px 18px; border-top: 1px solid #1e293b; }
.colcfg-foot .btn-primary, .colcfg-foot .btn-default { padding: 8px 18px; border-radius: 8px; font-size: 13px; }
