/* iokmax ERP · 浅色主题（白底黑字，护眼） */
:root {
  --bg: #f4f5f7;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #eef1f5;
  --border: #e2e5ea;
  --text: #1a1d21;
  --muted: #6b7280;
  --accent: #2f6fe4;
  --accent-soft: rgba(47, 111, 228, 0.10);
  --teal: #0e9384;
  --amber: #b45309;
  --up: #dc2626;      /* 涨/改善 = 红 */
  --down: #16a34a;    /* 跌 = 绿 */
  --radius: 12px;
  --shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c3c9d2; border-radius: 4px; }

/* ---------- 通用 ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  transition: 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-danger { color: var(--up); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; line-height: 18px; }
.badge-red    { background: rgba(248, 113, 113, 0.15); color: var(--up); }
.badge-green  { background: rgba(52, 211, 153, 0.15); color: var(--down); }
.badge-gray   { background: rgba(139, 152, 169, 0.15); color: var(--muted); }
.badge-blue   { background: var(--accent-soft); color: var(--accent); }
.badge-amber  { background: rgba(245, 185, 85, 0.15); color: var(--amber); }
.badge-purple { background: rgba(139, 92, 246, 0.15); color: #7c3aed; }

.up   { color: var(--up); }
.down { color: var(--down); }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 500px at 70% -10%, rgba(76, 141, 255, 0.12), transparent),
    radial-gradient(900px 400px at 10% 110%, rgba(45, 212, 191, 0.08), transparent),
    var(--bg);
  padding: 20px;
}
.login-card {
  width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px 24px;
  box-shadow: var(--shadow);
}
.login-logo { display: flex; gap: 14px; align-items: center; margin-bottom: 28px; }
.login-lang-toggle { margin-left: auto; }
.logo-mark {
  width: 46px; height: 46px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  border-radius: 12px;
  font-weight: 800; font-size: 22px; color: #fff;
  flex: none;
}
.login-logo h1 { font-size: 20px; }
.login-logo p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
}
.field input:focus { border-color: var(--accent); }
.login-error {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--up);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}
.login-btn-row { display: flex; gap: 10px; }
.demo-hint { margin-top: 22px; border-top: 1px dashed var(--border); padding-top: 16px; }
.demo-hint-title { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.demo-accounts { display: flex; flex-direction: column; gap: 8px; }
.demo-fill {
  text-align: left;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
}
.demo-fill b { color: var(--text); margin-right: 6px; }
.demo-fill:hover { border-color: var(--accent); color: var(--text); }
.login-foot { margin-top: 18px; font-size: 11px; color: var(--muted); text-align: center; }

/* ---------- 布局 ---------- */
.app { display: flex; flex-direction: column; height: 100vh; }
.sidebar {
  flex: none;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: 60px;
  min-height: 60px;
  position: relative;
  z-index: 100;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 0 0; flex: none; }
.brand .logo-mark { width: 34px; height: 34px; font-size: 16px; border-radius: 9px; }
.brand-text b { font-size: 14px; display: block; }
.brand-text i { font-size: 10px; color: var(--muted); font-style: normal; }
/* 顶部横排导航 */
#nav.topnav { flex: 1; display: flex; flex-direction: row; align-items: center; gap: 2px; overflow: visible; }
.topnav-item { position: relative; display: flex; align-items: center; }
.topnav-label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  font-size: 14px;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.topnav-item.has-menu:hover .topnav-label { background: var(--panel-2); }
.topnav-item.has-menu:hover .topnav-label::after { content: '▾'; font-size: 10px; color: var(--muted); margin-left: 2px; }
/* 下拉菜单 */
.topnav-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 230px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 0 0 12px 12px;
  box-shadow: 0 12px 30px rgba(20,30,60,.14);
  padding: 8px;
  display: none;
  flex-direction: column;
  gap: 2px;
}
.topnav-item.has-menu:hover .topnav-menu { display: flex; }
.topnav-item.nav-collapsed .topnav-menu { display: none !important; }
.topnav-sec {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1px;
  padding: 6px 10px 2px;
}
.topnav-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  position: relative;
  white-space: nowrap;
}
.nav-item span { font-size: 16px; width: 20px; text-align: center; }
.nav-item:hover { color: var(--text); background: var(--panel-2); }
.nav-item.on { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nav-tag {
  font-style: normal;
  font-size: 10px;
  background: var(--teal);
  color: #ffffff;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}
/* 顶部右侧用户区 */
.sidebar-foot { display: flex; align-items: center; gap: 12px; flex: none; margin-left: auto; }
.build-ver { font-size: 11px; color: var(--muted); letter-spacing: .2px; }
.build-ver b { color: var(--text); font-weight: 600; }
.user-chip { display: flex; gap: 10px; align-items: center; }
.avatar {
  width: 34px; height: 34px; flex: none;
  background: linear-gradient(135deg, var(--teal), var(--accent));
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: #ffffff;
}
.user-meta b { display: block; font-size: 13px; }
.user-meta i { font-size: 11px; color: var(--muted); font-style: normal; }
.user-actions { display: flex; gap: 8px; }
.user-actions .btn { padding: 6px 8px; font-size: 12px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px;
  flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-soft);
}
.topbar h2 { font-size: 17px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.lang-toggle {
  min-width: 64px;
  font-weight: 600;
  letter-spacing: .2px;
  cursor: pointer;
  white-space: nowrap;
}
.src-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
}
.src-badge.demo { background: rgba(245, 185, 85, 0.14); color: var(--amber); }
.sync-note {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(180, 83, 9, 0.10);
  color: var(--amber);
  white-space: nowrap;
  cursor: help;
}
.period-picker { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.period-picker button {
  background: transparent; border: none; color: var(--muted);
  padding: 6px 12px; font-size: 12px;
}
.period-picker button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- 时间周期条（日/月/年 + 预设 + 自定义） ---------- */
.period-bar { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.period-bar .select { height: 30px; padding: 0 8px; font-size: 12px; }
.gran-picker { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; height: 30px; }
.gran-picker button {
  background: transparent; border: none; color: var(--muted);
  padding: 0 11px; font-size: 12px; cursor: pointer; line-height: 30px;
}
.gran-picker button:hover { color: var(--text); }
.gran-picker button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.period-custom { display: inline-flex; align-items: center; gap: 5px; }
.period-custom em { color: var(--muted); font-style: normal; font-size: 12px; }
.date-input {
  height: 30px; padding: 0 8px; font-size: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); outline: none; color-scheme: light;
}
.date-input:focus { border-color: var(--accent); }
.period-label {
  font-size: 12px; color: var(--muted); white-space: nowrap;
  border-left: 1px solid var(--border); margin-left: 2px; padding-left: 10px;
}
.period-label b { color: var(--text); font-weight: 600; }
@media (max-width: 1360px) { .period-label { display: none; } }

.page { flex: 1; overflow-y: auto; padding: 20px 24px 40px; }

/* ---------- 卡片 / KPI ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card h3 { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.card-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-title-row h3 { margin: 0; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .k-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi .k-value { font-size: 22px; font-weight: 700; letter-spacing: 0.2px; }
.kpi .k-value small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.kpi .k-delta { font-size: 12px; margin-top: 6px; color: var(--muted); }
.kpi .k-delta b { font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.chart { width: 100%; height: 300px; }
.chart-sm { height: 240px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
th:hover { color: var(--text); }
td { padding: 9px 10px; border-bottom: 1px solid #eef0f3; white-space: nowrap; }
tr:hover td { background: rgba(76, 141, 255, 0.04); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* 合计行：吸附在表底部，和明细行区分开 */
tr.total-row td {
  background: rgba(76, 141, 255, 0.07);
  border-top: 1px solid var(--border);
  border-bottom: none;
  font-weight: 600;
  position: sticky;
  bottom: 0;
}
tr.total-row:hover td { background: rgba(76, 141, 255, 0.11); }
/* 构成类小表：有两行合计（公式合计 / 领星口径），若仍 sticky bottom 会互相压盖
 * （容器不可滚动时两行同时吸附到底部）→ 该表内取消吸附，按正常文档流排列 */
.comp-table tr.total-row td { position: static; }
.comp-table tr:last-child td { border-bottom: 1px solid #eef0f3; }
.mono { font-family: "SF Mono", Consolas, monospace; font-size: 12px; }
.sub { color: var(--muted); font-size: 12px; }
/* 数据完整度表：说明文字较长，这里允许换行并按比例固定列宽（其它表格仍是单行不换行） */
.q-table { table-layout: fixed; }
.q-table th, .q-table td { white-space: normal; }
.q-table th:nth-child(1), .q-table td:nth-child(1) { width: 36%; }
.q-table th:nth-child(2), .q-table td:nth-child(2) { width: 11%; }
.q-table th:nth-child(3), .q-table td:nth-child(3) { width: 53%; }
.pos { color: var(--up); }
.neg { color: var(--down); }

.progress { background: var(--bg-soft); border-radius: 4px; height: 6px; min-width: 80px; }
.progress i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }

.spark { vertical-align: middle; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.select {
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 7px 10px; font-size: 13px; outline: none;
}
/* 「自定义区间」的起止日期：跟在时间下拉后面，选到该项才出现 */
.kw-range { display: inline-flex; align-items: center; gap: 6px; }
.kw-range[hidden] { display: none; }
.kw-range-sep { color: var(--muted); font-size: 13px; }
.kw-range input[type="date"].select { width: 140px; }
.kw-range-hint { color: var(--muted); font-size: 12px; white-space: nowrap; }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; }

/* ---------- 可下拉选择器（combobox）：筛选栏里装几百个选项 ---------- */
.cbx { position: relative; display: inline-block; }
.cbx > input { width: 100%; padding-right: 24px; }
.cbx > input::placeholder { color: var(--muted); }
.cbx.open > input, .cbx > input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cbx::after {
  content: ''; position: absolute; right: 9px; top: 50%; margin-top: -2px;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid var(--muted); pointer-events: none;
}
.cbx-panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 60;
  min-width: 100%; max-width: 520px; max-height: 240px; overflow: hidden auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow); padding: 4px; display: none;
}
.cbx.open .cbx-panel { display: block; }
/* 筛选栏贴近屏幕底部时，面板改为向上弹出（app.js 里按可视空间自动加这个类） */
.cbx.cbx-up .cbx-panel { top: auto; bottom: calc(100% + 4px); }
.cbx-item {
  display: flex; align-items: baseline; gap: 8px; padding: 6px 9px; border-radius: 6px;
  cursor: pointer; white-space: nowrap; overflow: hidden;
}
.cbx-item:hover, .cbx-item.on { background: var(--accent-soft); }
.cbx-item .cbx-v {
  font-size: 12.5px; color: var(--text); flex: 0 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis;
}
.cbx-item .cbx-l { flex: 0 1 auto; min-width: 0; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.cbx-item .cbx-s { flex: none; margin-left: auto; font-size: 11.5px; color: var(--muted); }
.cbx-empty { padding: 10px; text-align: center; font-size: 12px; color: var(--muted); }
.cbx-more { margin-top: 4px; padding: 6px 9px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); }
/* 筛选栏里下拉别把屏幕占满：紧凑型面板再矮一档 */
.cbx.cbx-short .cbx-panel { max-height: 182px; }
/* AI 页的 ASIN 下拉是主选择器、候选可达 500 条，面板给高一点（一屏能多看几项）。
 * 实际高度仍由 app.js 按可用空间兜底压缩，保证整块留在视口内。 */
.cbx.cbx-tall .cbx-panel { max-height: 420px; }

/* 下拉面板底部的翻页条：1252 个活动名也不会变成一条无尽长列表。
 * 吸附在面板底部，滚动列表时它一直在，随时换页 / 改每页条数。 */
.cbx-pg {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; align-items: center; gap: 6px;
  margin: 4px -4px -4px; padding: 5px 6px 5px 9px;
  border-top: 1px solid var(--border); background: var(--panel);
  font-size: 11.5px; color: var(--muted);
}
.cbx-pg-info { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbx-pg-btn {
  flex: none; min-width: 24px; height: 22px; padding: 0 6px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; font-size: 12px; line-height: 1;
}
.cbx-pg-btn:hover:not(:disabled) { border-color: var(--accent); }
.cbx-pg-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.cbx-pg-size {
  flex: none; padding: 3px 4px; font-size: 11.5px; border-radius: 6px; outline: none;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
}
/* 面板自己的滚动条也做粗一点，别细得点不中 */
.cbx-panel::-webkit-scrollbar { width: 12px; height: 12px; }
.cbx-panel::-webkit-scrollbar-track { background: var(--bg-soft); }
.cbx-panel::-webkit-scrollbar-thumb {
  background: #b9c1cc; border-radius: 6px; border: 3px solid var(--panel); background-clip: content-box;
}
.cbx-panel::-webkit-scrollbar-thumb:hover { background: #98a2b0; background-clip: content-box; }

/* ---------- 固定高度表格区：横竖滚动条常驻，随时可拖 ----------
 * 之前表格跟着整个页面滚，横向滚动条要先把页面拉到最底才看得见。
 * 这里给表格自己的滚动容器定高，横竖两根滚动条都贴在容器边上，随时能拖。 */
.scroll-box {
  max-height: calc(100vh - 372px);
  min-height: 240px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}
.scroll-box table { min-width: 1360px; }
/* 广告活动明细：16 列很宽，横向滚动时把「广告活动」列钉在最左边，
 * 拖到右边看指标时也知道这一行是谁 */
#ads-camp-table table th:first-child,
#ads-camp-table table td:first-child {
  position: sticky; left: 0; z-index: 2;
  background: var(--panel);
  box-shadow: 1px 0 0 var(--border);
}
#ads-camp-table table thead th:first-child { z-index: 4; background: var(--panel-2); }
#ads-camp-table table tbody tr:hover td:first-child { background: #f4f7ff; }
/* 明细表高度跟着视口走：页面一进来横向滚动条就在容器底边，不用先把整页拖到底。
 * 实际高度由 app.js 的 fitBox() 按视口实时算，这里只是首帧兜底。 */
.scroll-box.ads-box {
  max-height: clamp(300px, calc(100vh - 620px), 720px);
  min-height: 280px;
}
/* 16 列 + 品名，别把列挤扁；窄屏下横向滚动才有意义 */
.scroll-box.ads-box table { min-width: 1560px; }
/* 库存管理：9 列，品名列用 ellip 截断；给个合理最小宽度，窄屏时横向滚动条才出现 */
.scroll-box.inv-box { max-height: clamp(300px, calc(100vh - 500px), 760px); min-height: 280px; }
.scroll-box.inv-box table { min-width: 1080px; }
.scroll-box.inv-box table td .ellip { max-width: 240px; }

/* ---------- 常驻横向滚动条 ----------
 * 「横向滚动条要滚到最底才够得着」的解法：在明细卡底部再挂一根，吸附在页面可视区底边，
 * 页面停在哪里都能左右拖（AG Grid 的 pinned horizontal scrollbar 做法），
 * 与表格容器的横向位置双向同步。表格没有横向溢出时自动隐藏。 */
.hsync {
  position: sticky; bottom: 0; z-index: 5;
  height: 16px; overflow-x: auto; overflow-y: hidden;
  margin-top: 8px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--border);
  box-shadow: 0 -2px 8px rgba(16, 24, 40, 0.06);
}
.hsync[hidden] { display: none; }
.hsync-inner { height: 1px; }
.hsync::-webkit-scrollbar { height: 14px; }
.hsync::-webkit-scrollbar-track { background: var(--bg-soft); border-radius: 8px; }
.hsync::-webkit-scrollbar-thumb {
  background: #b9c1cc; border-radius: 8px; border: 3px solid var(--bg-soft); background-clip: content-box;
}
.hsync::-webkit-scrollbar-thumb:hover { background: #98a2b0; background-clip: content-box; }
.scroll-box thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--panel-2);
  box-shadow: inset 0 -1px 0 var(--border);
}
.scroll-box tbody tr:last-child td { border-bottom: none; }
/* 滚动条本身做粗一点，便于拖动（Chrome/Edge/Safari） */
.scroll-box::-webkit-scrollbar { width: 13px; height: 13px; }
.scroll-box::-webkit-scrollbar-track { background: var(--bg-soft); border-radius: 7px; }
.scroll-box::-webkit-scrollbar-thumb {
  background: #b9c1cc; border-radius: 7px; border: 3px solid var(--bg-soft); background-clip: content-box;
}
.scroll-box::-webkit-scrollbar-thumb:hover { background: #98a2b0; background-clip: content-box; }
.scroll-box::-webkit-scrollbar-corner { background: var(--bg-soft); }
/* 品名可能很长（领星标题动辄上百字符），截断显示、悬停看全文，
 * 否则它会把「当前排名」这些关键列一路挤到最右边 */
.ellip {
  display: block; max-width: 280px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- 分页条 ---------- */
.pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.pager .pg-info { font-size: 12px; color: var(--muted); margin-right: auto; }
.pager .pg-info b { color: var(--text); font-weight: 600; }
.pager button {
  min-width: 30px; height: 30px; padding: 0 9px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; font-size: 12.5px; cursor: pointer; transition: 0.15s;
}
.pager button:hover:not(:disabled) { border-color: var(--accent); }
.pager button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }
.pager .pg-dots { color: var(--muted); padding: 0 2px; font-size: 12px; }
.pager .pg-side { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.pager .pg-side select { padding: 5px 8px; }
.pager .pg-jump input {
  width: 54px; text-align: center;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; padding: 5px 6px; font-size: 12.5px; outline: none;
}
.pager .pg-jump input:focus { border-color: var(--accent); }
.ai-pager { margin: 10px 0 4px; }

/* ---------- AI 广告分析：页签表格定高滚动 + 常驻横向滚动条 ----------
 * 十几张表行数从十几到几百，一次性铺开会把页面拉得极长、滚动条要拖到最底才够得着。
 * 这里统一成「表格自己滚 + 表格下面分页」，横竖滚动条都贴着容器边，随时能拖。 */
.scroll-box.ai-box {
  max-height: clamp(260px, 42vh, 560px);
  min-height: 200px;
}
/* 半宽卡片（grid-2）里的表再矮一点，两张并排不把版面撑开 */
.scroll-box.ai-box.ai-box-sm { max-height: clamp(200px, 30vh, 380px); }
/* 8~12 列的 AI 表：给个最小宽度，窄屏 / 半宽卡片里横向拖动才有意义 */
.scroll-box.ai-box table { min-width: 1020px; }
.scroll-box.ai-box.ai-box-sm table { min-width: 720px; }
/* 首列（对象名 / 关键词 / 广告组）横向拖动时钉在最左边，
 * 拖到右边看指标时也知道这一行是谁 */
#ai-tab-body .ai-box table th:first-child,
#ai-tab-body .ai-box table td:first-child {
  position: sticky; left: 0; z-index: 2;
  background: var(--panel);
  box-shadow: 1px 0 0 var(--border);
}
#ai-tab-body .ai-box table thead th:first-child { z-index: 4; background: var(--panel-2); }
#ai-tab-body .ai-box table tbody tr:hover td:first-child { background: #f4f7ff; }

/* ---------- AI 明细表：表头筛选 + 点列排序 ---------- */
/* 可排序列：常驻 ⇅ 按钮（灰色），悬停/激活高亮，让「可点排序」一眼可见 */
#ai-tab-body th.ai-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
#ai-tab-body th.ai-sortable:hover { color: var(--accent); }
#ai-tab-body th.ai-sortable:hover .ai-sort-ind { color: var(--accent); }
.ai-sort-ind {
  display: inline-block; font-size: 10px; margin-left: 3px;
  color: #b3bac4; vertical-align: 1px; transition: color .12s;
}
.ai-sort-ind.on { color: var(--accent); font-weight: 700; }
/* 库存管理表 / 广告投放活动明细表：数字列点表头排序（复用 ai-sort-ind 指示器） */
th.ai-inv-sort, th.ai-ads-sort { cursor: pointer; user-select: none; white-space: nowrap; }
th.ai-inv-sort:hover, th.ai-ads-sort:hover { color: var(--accent); }
th.ai-inv-sort:hover .ai-sort-ind, th.ai-ads-sort:hover .ai-sort-ind { color: var(--accent); }
/* 表头内嵌筛选控件：比正文小一号，不把表头撑得太高 */
.ai-tfilter { margin-top: 3px; }
.ai-tfilter .select {
  width: 100%; min-width: 0; height: 24px; padding: 1px 5px;
  font-size: 11px; font-weight: 400; cursor: pointer;
}
.ai-tfilter .ai-tf-sel { appearance: auto; }
.ai-tfilter .ai-tf-text { cursor: text; }
/* 「当前竞价」这类 num 列是右对齐的，筛选控件也跟着靠右 */
#ai-tab-body th.num .ai-tfilter .select { text-align: right; }

/* 常驻横向滚动条：整块吸附在可视区底边，页面停在哪里都能左右拖。
 * 鼠标移到哪张表上，它就驱动哪张（标签会写清楚当前是哪张表）。 */
.hsync-wrap {
  position: sticky; bottom: 0; z-index: 6;
  margin-top: 12px; padding: 4px 9px 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 -4px 12px rgba(16, 24, 40, 0.08);
}
.hsync-wrap[hidden] { display: none; }
.hsync-label { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
/* 吸附交给外层 .hsync-wrap，里面这根只负责滚动，避免两层都 sticky 打架 */
.hsync-wrap .hsync {
  position: static; bottom: auto; margin-top: 0; height: 16px;
  border: 0; background: transparent; box-shadow: none;
}
.filter-note { font-size: 12px; color: var(--muted); margin-left: auto; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(680px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 24px;
  box-shadow: var(--shadow);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h3 { font-size: 16px; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 20px; line-height: 1; }
.modal-close:hover { color: var(--text); }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- 单品详情 / 分析记录 ---------- */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px 16px; }
.kv { border-bottom: 1px dashed #e2e5ea; padding-bottom: 6px; }
.kv i { display: block; font-style: normal; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.kv b { font-size: 13px; font-weight: 600; }

.remind { border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 8px; line-height: 1.6; }
.remind.ok { background: rgba(52, 211, 153, 0.08); border: 1px solid rgba(52, 211, 153, 0.3); }
.remind.warn { background: rgba(245, 185, 85, 0.09); border: 1px solid rgba(245, 185, 85, 0.32); }
.remind.danger { background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248, 113, 113, 0.35); }

.ship-list { display: flex; flex-direction: column; gap: 10px; }
.ship-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.ship-item:hover { border-color: #c3c9d2; }
.ship-head b { font-size: 13px; }
.ship-note { display: flex; gap: 12px; align-items: flex-start; margin: 4px 0; }
.ship-note i {
  font-style: normal; font-size: 11px; color: var(--muted); flex: none;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px;
}
.ship-note span { font-size: 12px; color: var(--down); line-height: 1.6; }

.tag-chip {
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--muted);
  border-radius: 20px; padding: 4px 12px; font-size: 12px;
}
.tag-chip:hover { border-color: var(--accent); color: var(--text); }
.tag-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

a.link { color: var(--accent); cursor: pointer; text-decoration: none; border-bottom: 1px dashed rgba(76, 141, 255, 0.5); }
a.link:hover { border-bottom-style: solid; }

textarea.select { line-height: 1.6; font-family: inherit; }
input[type="date"].select { color-scheme: light; }

@media (max-width: 900px) {
  .grid-2, .grid-2-1 { grid-template-columns: 1fr; }
  /* 顶部横排导航：900px 以下隐藏品牌文字，保留图标与导航 */
  .sidebar { height: auto; min-height: 56px; flex-wrap: wrap; padding: 6px 12px; }
  .sidebar .brand-text { display: none; }
}

/* ================= AI 广告分析 ================= */
.ai-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.ai-bar .select { height: 32px; padding: 0 10px; font-size: 13px; }
.ai-bar .spacer { flex: 1; }

.ai-kpi .kpi { min-width: 148px; }
.ai-target { font-size: 11px; color: var(--muted); margin-top: 5px; }
.ai-target.ok { color: var(--teal); }
.ai-target.warn { color: var(--amber); }
.ai-target.bad { color: var(--up); }

.ai-panel {
  background: linear-gradient(135deg, rgba(76, 141, 255, 0.08), rgba(124, 92, 255, 0.06));
  border: 1px solid rgba(76, 141, 255, 0.3);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}
.ai-head { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.ai-score { font-size: 30px; font-weight: 700; line-height: 1; }
.ai-score small { font-size: 11px; color: var(--muted); font-weight: 400; display: block; margin-top: 5px; }
.ai-head h3 { font-size: 15px; margin: 0; }
.ai-diag { font-size: 13px; line-height: 1.85; color: var(--text); white-space: pre-wrap; }

.ai-sug { border: 1px solid var(--border); border-radius: 10px; background: var(--panel); padding: 13px 15px; margin-bottom: 10px; }
.ai-sug:hover { border-color: rgba(76, 141, 255, 0.45); }
.ai-sug-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.ai-sug-top b { font-size: 13px; }
.ai-sug-row { font-size: 12.5px; line-height: 1.75; color: var(--muted); }
.ai-sug-row b { color: var(--text); font-weight: 600; }
.ai-sug-actions { margin-top: 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ai-op {
  font-family: "SF Mono", Consolas, monospace; font-size: 11px;
  background: rgba(45, 212, 191, 0.12); color: var(--teal);
  border: 1px solid rgba(45, 212, 191, 0.3); border-radius: 6px; padding: 3px 8px;
}
.ai-op.manual { background: rgba(245, 185, 85, 0.12); color: var(--amber); border-color: rgba(245, 185, 85, 0.3); }
.pill { display: inline-block; border-radius: 20px; padding: 2px 9px; font-size: 11px; font-weight: 600; }
.pill-red { background: rgba(248, 113, 113, 0.14); color: var(--up); }
.pill-amber { background: rgba(245, 185, 85, 0.14); color: var(--amber); }
.pill-blue { background: rgba(76, 141, 255, 0.14); color: var(--accent); }
.pill-green { background: rgba(52, 211, 153, 0.14); color: var(--down); }
.pill-gray { background: rgba(139, 152, 169, 0.14); color: var(--muted); }
.pill-teal { background: rgba(14, 147, 132, 0.14); color: var(--teal); }
.pill-purple { background: rgba(124, 92, 255, 0.12); color: #7c3aed; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tabs button {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 8px 13px; font-size: 13px;
}
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs button:hover { color: var(--text); }

/* ---- AI 广告分析 · 横向分栏页签（一级 6 栏，激活=蓝底白字，可换行） ---- */
.ai-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.ai-tabs button {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--accent); color: var(--accent);
  padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.ai-tabs button .bdg {
  font-size: 11px; font-weight: 500; padding: 1px 7px; border-radius: 9px;
  background: rgba(76, 141, 255, 0.12); color: var(--accent);
}
.ai-tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.ai-tabs button.on .bdg { background: rgba(255, 255, 255, 0.22); color: #fff; }
.ai-tabs button:hover:not(.on) { box-shadow: 0 1px 6px rgba(76, 141, 255, 0.25); }

/* ---- 广告诊断 · 二级子页签（诊断清单 + 16 项明细，同一视觉语言更紧凑） ---- */
.ai-subtabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.ai-subtabs button {
  background: var(--panel); border: 1px solid var(--border); color: var(--accent);
  padding: 5px 11px; border-radius: 7px; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.ai-subtabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.ai-subtabs button:hover:not(.on) { border-color: var(--accent); }

.ai-job { display: flex; align-items: center; gap: 12px; padding: 14px 18px; }
.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(76, 141, 255, 0.25);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ticket { border: 1px solid var(--border); border-radius: 10px; background: var(--panel); padding: 13px 15px; margin-bottom: 10px; }
.ticket-top { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 6px; }
.ticket-top b { font-size: 13.5px; }
.ticket-meta { font-size: 12px; color: var(--muted); line-height: 1.7; }
.ticket-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.exec-row { font-size: 12px; padding: 3px 0; border-bottom: 1px dashed var(--border); }
.exec-row:last-child { border-bottom: none; }

/* 六大分析维度结论卡片 */
.dim-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.dim-card {
  border: 1px solid var(--border); border-radius: 10px; background: var(--panel);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 7px;
}
.dim-title { font-size: 13px; font-weight: 700; color: var(--text); }
.dim-sum { font-size: 12.5px; line-height: 1.75; color: var(--text); }
.dim-row { font-size: 12px; line-height: 1.7; color: var(--muted); }
.dim-row b { color: var(--text); font-weight: 600; }
.dim-row ul { margin: 4px 0 0 18px; padding: 0; }
.dim-row li { margin-bottom: 3px; }
/* 关联归因：事件时间线（圆点 + 日期 + 类型标签 + 内容） */
.attr-tl { display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--border); margin-left: 4px; padding-left: 12px; }
.attr-tl-row { display: flex; align-items: baseline; gap: 8px; font-size: 12px; line-height: 1.7; padding: 2px 0; }
.attr-tl-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 7px; margin-left: -16px; }
.attr-tl-date { color: var(--muted); flex: 0 0 78px; }
.attr-tl-tag { flex: 0 0 92px; font-weight: 600; }
.attr-tl-body { color: var(--muted); word-break: break-word; }
.warn-box {
  background: rgba(245, 185, 85, 0.09); border: 1px solid rgba(245, 185, 85, 0.35);
  border-radius: 10px; padding: 12px 15px; font-size: 12.5px; line-height: 1.8;
}
.warn-box b { color: var(--amber); }
.risk-box {
  background: rgba(248, 113, 113, 0.08); border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 10px; padding: 12px 15px; font-size: 12.5px; line-height: 1.8;
}

/* ===== 店铺分配多选控件（子账号管理 / 新建子账号） ===== */
.picker .picker-modes { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; }
/* nowrap 很关键：label 是 flex 容器，里面「文字 + <em>」会各自成为一个 flex item 被压窄，
 * 不加就会把「全部店铺（不受限）」竖着拆成好几行（新建弹窗里宽度更紧，一定会踩到） */
.picker .picker-modes label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; flex: 0 0 auto; cursor: pointer; }
.picker .picker-modes em { font-style: normal; }
.picker .picker-box { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--panel-2); }
.picker .store-list {
  max-height: 250px; overflow: auto; display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 10px;
  background: var(--panel); border-radius: 8px; padding: 6px;
}
.picker .store-opt {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: 8px; cursor: pointer; font-size: 12.5px; min-width: 0;
}
.picker .store-opt:hover { background: var(--accent-soft); }
.picker .store-opt input { margin: 0; flex: 0 0 auto; }
.picker .store-opt span { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker .store-opt em { font-style: normal; flex: 0 0 auto; }
.picker .store-list::-webkit-scrollbar { width: 10px; height: 10px; }
.picker .store-list::-webkit-scrollbar-thumb { background: #c3cad4; border-radius: 6px; border: 2px solid var(--panel); }
/* 子账号表里的店铺摘要：允许换行，但只在词边界断开（避免 "Home UK" 被拆成 "H / ome UK"） */
.scope-names { max-width: 230px; white-space: normal; line-height: 1.35; overflow-wrap: break-word; word-break: normal; }

/* ================= 移动端适配（手机浏览器） ================= */
/* 桌面是「左侧栏 + 右侧主区」横向布局；手机改为「顶部导航条 + 纵向主区」，
 * 让窗口比例贴合手机竖屏，避免横向挤压。 */
@media (max-width: 768px) {
  /* 布局改纵向（100dvh 兼容移动地址栏收缩） */
  .app { flex-direction: column; height: 100vh; height: 100dvh; }
  /* 兜底：任何内部横向溢出都不允许撑破文档宽度（否则 iOS Safari 缩小整页） */
  html, body { overflow-x: hidden; }

  /* ---- 顶部条 · 手机适配（20261114 汉堡抽屉版）----
   * 单行：汉堡按钮 + 品牌 + 用户区；导航收进抽屉，点汉堡展开。 */
  .sidebar {
    width: 100%; flex: none;
    flex-direction: row; flex-wrap: nowrap; align-items: center;
    gap: 8px;
    padding: 6px 10px;
    height: 52px; min-height: 52px;
    border-right: none; border-bottom: 1px solid var(--border);
    overflow: visible;
  }
  .brand { padding: 0; order: 1; gap: 8px; }
  .brand .logo-mark { width: 30px; height: 30px; font-size: 14px; border-radius: 8px; }
  .brand .brand-text { display: block; }   /* 覆盖 900px 断点，恢复品牌文字 */
  .brand .brand-text b { font-size: 13px; }
  .brand .brand-text i { display: none; }  /* 副标题收起，省空间 */
  /* 汉堡按钮：显示在品牌左侧 */
  .sidebar .menu-toggle { display: inline-flex; }
  /* topbar 里的汉堡按钮移动端不显示（入口在顶部条内即可） */
  .topbar .menu-toggle { display: none; }

  /* 用户区：与品牌同行、靠右（保留退出/改密入口） */
  .sidebar-foot {
    order: 2; margin-left: auto;
    border-top: none; padding: 0;
    display: flex; flex-direction: row; align-items: center; gap: 8px;
  }
  .user-chip { padding: 0; gap: 6px; }
  .user-chip .avatar { width: 30px; height: 30px; }
  .user-meta i { display: none; }
  .user-meta b { font-size: 12px; }
  .user-actions { display: flex; flex-direction: row; gap: 6px; }
  .user-actions .btn { white-space: nowrap; padding: 5px 7px; font-size: 12px; }
  /* 手机窄屏：按钮只留图标，文字隐藏（title 提示仍在），避免顶部条溢出 */
  .user-actions .btn-txt { display: none; }
  .build-ver { display: none; }

  /* 导航抽屉：默认收起（max-height 0），点汉堡后从顶部滑下展开。
   * ⚠️ 必须用 #nav.topnav 与桌面规则同特异性：桌面 `#nav.topnav{overflow:visible;flex:1}`
   * 会压过低特异性的 #nav 覆盖，导致抽屉不收起。 */
  #nav.topnav {
    order: 3;
    position: fixed;
    top: 52px; left: 0; right: 0;
    max-height: 0;
    overflow: hidden;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 16px 32px rgba(20, 30, 60, 0.18);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    z-index: 97;
    transition: max-height .28s ease;
  }
  .sidebar.nav-open #nav.topnav {
    max-height: calc(100dvh - 52px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* 抽屉内：部门纵向分组，每个子项整行可点 */
  .topnav-item { display: block; border-bottom: 1px solid var(--border); }
  .topnav-item:last-child { border-bottom: none; }
  .topnav-label {
    display: flex; align-items: center; width: 100%;
    padding: 13px 16px; font-size: 14px; font-weight: 700;
    color: var(--text); background: var(--panel-2);
    border: none; border-radius: 0;
    white-space: normal;
  }
  .topnav-menu {
    display: flex; flex-direction: column; gap: 0;
    position: static; min-width: 0; width: 100%;
    background: transparent; border: none; border-radius: 0;
    box-shadow: none; padding: 4px 0 8px;
  }
  .topnav-sec {
    display: block;
    padding: 10px 16px 4px; font-size: 11px; color: var(--muted);
    letter-spacing: 1px;
  }
  .topnav-empty {
    display: block;
    padding: 10px 16px 12px; font-size: 12px; color: var(--muted); font-style: italic;
    white-space: normal;
  }
  .nav-item {
    padding: 12px 16px 12px 20px; font-size: 14px; gap: 10px;
    white-space: normal;
  }
  .nav-item span { display: inline; width: 24px; flex: none; }   /* 覆盖 900px 断点 */

  /* 顶栏：自适应高度 + 允许换行 */
  .topbar {
    height: auto; min-height: 50px; flex: none;
    flex-wrap: wrap; gap: 6px 12px; padding: 8px 12px;
  }
  .topbar h2 { font-size: 15px; }
  .topbar-right { flex-wrap: wrap; gap: 6px 8px; width: 100%; }
  .sync-note { display: none !important; }   /* 长文案手机隐藏 */
  .period-label { display: none; }

  /* 页面内边距收紧 */
  .page { padding: 12px 12px 36px; }

  /* KPI 两列 + 紧凑卡片 */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 12px 12px; }
  .kpi .k-value { font-size: 18px; }
  .card { padding: 12px 13px; }
  .grid-2, .grid-2-1 { gap: 12px; }

  /* 图表高度收紧 */
  .chart { height: 240px; }

  /* 表单单列 */
  .form-grid { grid-template-columns: 1fr; }

  /* 店铺多选控件单列 */
  .picker .store-list { grid-template-columns: 1fr; }

  /* 登录卡自适应 */
  .login-card { width: 100%; max-width: 400px; padding: 26px 20px 20px; }

  /* 弹窗底部抽屉式，宽度贴边 */
  .modal-mask { padding: 12px; align-items: flex-end; }
  .modal { width: 100%; max-height: 92vh; padding: 18px 16px; border-radius: 14px 14px 8px 8px; }

  /* 汉堡抽屉遮罩：展开时显示 */
  .sidebar-mask.show { display: block; }
}


/* ================= 产品反馈（Review / Rating） ================= */
.fb-head { display: flex; align-items: center; gap: 16px; padding: 18px 20px; }
.fb-title { font-size: 18px; font-weight: 700; }
.fb-drill { display: grid; grid-template-columns: minmax(120px, 0.7fr) minmax(120px, 0.7fr) minmax(320px, 2.2fr); gap: 14px; margin-top: 14px; }
.fb-col { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.fb-col-h { font-size: 13px; font-weight: 600; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.fb-col-b { max-height: 340px; overflow-y: auto; }
.fb-item { padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.fb-item:last-child { border-bottom: none; }
.fb-item:hover { background: var(--panel-2); }
.fb-item.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.fb-t { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-col-main .fb-t { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: break-word; word-break: break-word; line-height: 1.4; }
.fb-name-miss { color: var(--muted); font-style: italic; }
.fb-d { font-size: 11px; color: var(--muted); margin-top: 2px; }

.fb-detail { display: grid; grid-template-columns: 320px 1fr; gap: 16px; }
.fb-left { min-width: 0; }
.fb-right { min-width: 0; }
#fb-score { background: linear-gradient(160deg, #2f6fe4, #5b4be0); color: #fff; border-radius: var(--radius); padding: 18px; }
.fb-score-top { display: flex; align-items: center; gap: 14px; }
.fb-avg { font-size: 42px; font-weight: 800; line-height: 1; }
.fb-stars { font-size: 18px; letter-spacing: 2px; color: #fbbf24; margin: 2px 0 4px; }
.fb-sub { font-size: 12px; opacity: .85; }
.fb-metrics { display: flex; gap: 20px; margin: 14px 0; font-size: 12px; opacity: .9; }
.fb-mv { font-size: 18px; font-weight: 700; margin-top: 2px; }
.fb-bar { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-top: 7px; }
.fb-bar span { width: 30px; opacity: .85; }
.fb-bar-track { flex: 1; height: 8px; background: rgba(255,255,255,.22); border-radius: 5px; overflow: hidden; }
.fb-bar-track i { display: block; height: 100%; background: #fbbf24; border-radius: 5px; }
.fb-bar b { width: 26px; text-align: right; font-weight: 600; }

#fb-topics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fb-topic-col { min-width: 0; }
.fb-topic-h { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.fb-topic-h.neg { color: var(--up); }
.fb-topic-h.pos { color: var(--down); }
.fb-topic { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: var(--panel-2); }
.fb-topic.neg { border-left: 3px solid var(--up); }
.fb-topic.pos { border-left: 3px solid var(--down); }
.fb-topic-t { font-weight: 600; font-size: 13px; }
.fb-topic-t small { font-weight: 500; color: var(--muted); }
.fb-topic-d { font-size: 12px; color: var(--muted); margin-top: 3px; }
.fb-topic-m { font-size: 11px; color: var(--muted); margin-top: 5px; }
.fb-topic-m b.up { color: var(--down); }
.fb-topic-m b.down { color: var(--up); }
.fb-topic-a { font-size: 12px; color: var(--amber); margin-top: 4px; }
.fb-topic-q { font-size: 11px; color: var(--muted); font-style: italic; margin-top: 4px; }

.fb-tbl-wrap { overflow-x: auto; }
.fb-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.fb-tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--panel-2); white-space: nowrap; }
.fb-tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.fb-tbl tbody tr:hover { background: var(--panel-2); }
.fb-star { color: var(--amber); letter-spacing: 1px; white-space: nowrap; }
.fb-rt { font-weight: 600; }
.fb-rb { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.fb-zh { color: #92400e; background: #fffbeb; border-radius: 4px; padding: 1px 6px; display: inline-block; margin-top: 4px; font-size: 12px; }
@media (max-width: 960px) {
  .fb-drill { grid-template-columns: 1fr; }
  .fb-detail { grid-template-columns: 1fr; }
  #fb-topics { grid-template-columns: 1fr; }
  /* 手机：反馈头部说明 + 按钮换行，避免文字与按钮挤在一起 */
  .fb-head { flex-direction: column; align-items: stretch; gap: 10px; padding: 14px 16px; }
  .fb-head .btn { align-self: flex-start; }
}

/* ===== Token 用量面板（AI 广告分析页）20261017 ===== */
.ai-usage-panel { margin-bottom: 16px; }
.ai-usage-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.ai-usage-title { font-size: 14px; font-weight: 700; }
.ai-usage-range { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.ai-usage-range input[type="date"] {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 4px 8px; font-size: 12px; height: 28px;
}
.ai-usage-total { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.ai-usage-kpi { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.ai-usage-kpi .k-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.ai-usage-kpi .k-value { font-size: 20px; font-weight: 700; }
.ai-usage-kpi .sub { font-size: 11px; color: var(--muted); margin-top: 4px; }
.ai-usage-models { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.ai-usage-model { flex: 1 1 200px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.ai-usage-model .m-name { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.ai-usage-model .m-tok { display: block; font-size: 15px; font-weight: 700; color: var(--accent); }
.ai-usage-model .m-sub { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }
.ai-usage-buckets { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-usage-bucket { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; min-width: 90px; text-align: center; }
.ai-usage-bucket .b-label { display: block; font-size: 11px; color: var(--muted); }
.ai-usage-bucket .b-tok { display: block; font-size: 14px; font-weight: 700; }
.ai-usage-bucket .b-sub { display: block; font-size: 10.5px; color: var(--muted); }
@media (max-width: 960px) {
  .ai-usage-total { grid-template-columns: repeat(2, 1fr); }
}

/* ============ 亚马逊广告位分析 ============ */
.adpos-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.adpos-card {
  position: relative; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.adpos-card:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
/* 词覆盖完整度：左边框色标 */
.adpos-card.cov-ok   { border-left: 3px solid #12a150; }
.adpos-card.cov-warn { border-left: 3px solid #b45309; }
.adpos-card.cov-bad  { border-left: 3px solid #d43a3a; }
/* 「强制」复选框：与筛选栏其他控件对齐 */
.adpos-force-chk { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text); cursor: pointer; user-select: none; white-space: nowrap; }
.adpos-force-chk input { width: 15px; height: 15px; margin: 0; cursor: pointer; accent-color: #3b82f6; }

.adpos-progress-bar {
  width: 100%; height: 8px; border-radius: 999px; overflow: hidden;
  background: var(--border, #e5e7eb);
}
.adpos-progress-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6, #06b6d4);
  transition: width .25s ease;
}

/* 关键词排位分析表：不确定进度条（反查 H10 阶段扫动） */
.kwrank-progress-fill {
  display: block; height: 100%; width: 35%; border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6, #06b6d4, #3b82f6);
  background-size: 200% 100%;
  animation: kwrank-scan 1.4s ease-in-out infinite;
}
@keyframes kwrank-scan {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(420%); }
}

/* 进度条完成/失败状态 */
.kwrank-progress-fill.kwrank-done {
  animation: none; width: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  transition: width .4s ease;
}
.kwrank-progress-fill.kwrank-error {
  animation: none; width: 100%;
  background: linear-gradient(90deg, #ef4444, #dc2626);
  transition: width .4s ease;
}
/* 广告位分析词表：紧凑列宽 + 数字对齐 + 建议列不重叠 */
.adpos-kw-table { font-size: 12.5px; width: 100%; }
.adpos-kw-table th, .adpos-kw-table td { padding: 7px 8px; white-space: normal; vertical-align: top; }
.adpos-kw-table th { font-size: 11.5px; }
/* 关键词列允许换行，避免撑宽 */
.adpos-kw-table th:nth-child(2), .adpos-kw-table td:nth-child(2) { white-space: normal; word-break: break-word; min-width: 120px; max-width: 220px; }
/* 投放活动（倒数第2列）与建议（最后一列）允许换行，避免重叠重影 */
.adpos-kw-table th:nth-last-child(2), .adpos-kw-table td:nth-last-child(2),
.adpos-kw-table th:last-child, .adpos-kw-table td:last-child { white-space: normal; word-break: break-word; }
/* 投放活动列限宽 */
.adpos-kw-table th:nth-last-child(2), .adpos-kw-table td:nth-last-child(2) { max-width: 180px; }
/* 数字列右对齐 + 等宽数字，保证整齐不歪 */
.adpos-kw-table td.num, .adpos-kw-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* 排名列（自然/广告）与搜索量列紧凑、数字不换行 */
.adpos-kw-table th:nth-child(3), .adpos-kw-table td:nth-child(3),
.adpos-kw-table th:nth-child(4), .adpos-kw-table td:nth-child(4) { white-space: nowrap; }
/* 建议列文字留白，避免行间拥挤重叠 */
.adpos-kw-table th:last-child, .adpos-kw-table td:last-child { line-height: 1.55; min-width: 150px; }
.adpos-kw-table .sub { line-height: 1.5; }
/* 表头「流量占比」旁的小字注释 */
.adpos-kw-table th .th-note { display: block; font-size: 10px; font-weight: 400; color: var(--muted); margin-top: 2px; line-height: 1.35; white-space: normal; }

/* 一键双采流水线弹窗 */
.adpos-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.adpos-pipe-modal {
  background: var(--panel, #fff); border-radius: 14px; padding: 22px 26px;
  width: 560px; max-width: 92vw; max-height: 86vh; overflow: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.adpos-pipe-modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 2px; }
.adpos-pipe-step { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border, #eef1f5); align-items: flex-start; }
.adpos-pipe-step:last-child { border-bottom: none; }
.adpos-pipe-step .num {
  flex: 0 0 26px; height: 26px; border-radius: 50%; background: #eef2ff; color: #4338ca;
  font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.adpos-pipe-step.done .num { background: #eaf6ef; color: #18794e; }
.adpos-pipe-step.running .num { background: #3b82f6; color: #fff; animation: adpos-pulse 1s infinite; }
@keyframes adpos-pulse { 50% { opacity: .55; } }
.adpos-pipe-step .body { flex: 1; }
.adpos-pipe-step .t { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.adpos-pipe-step .d { font-size: 12px; color: var(--sub, #8a94a6); line-height: 1.5; }
.adpos-pipe-step .bar { height: 5px; border-radius: 3px; background: var(--border, #eef1f5); margin-top: 8px; overflow: hidden; }
.adpos-pipe-step .bar i { display: block; height: 100%; background: linear-gradient(90deg, #3b82f6, #7c5cff); border-radius: 3px; width: 0; transition: width .3s; }
.adpos-pipe-result { margin-top: 14px; border: 1px solid #cbe9d4; background: #f0faf4; border-radius: 10px; padding: 14px 16px; }
.adpos-pipe-ok { font-weight: 700; color: #15803d; margin-bottom: 8px; }
.adpos-pipe-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.adpos-pipe-row span { color: var(--sub, #5a6678); }
.adpos-pipe-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
@media (max-width: 640px) {
  .adpos-cards { grid-template-columns: 1fr; }
}

/* ================= 移动端汉堡抽屉菜单（20261114） ================= */
/* 汉堡按钮：默认（桌面）隐藏，移动端断点里显示 */
.menu-toggle {
  display: none;
  flex: none;
  width: 40px; height: 40px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  -webkit-tap-highlight-color: transparent;
}
.menu-toggle span {
  display: block;
  width: 20px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}
/* 展开态：汉堡变 X */
.menu-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* 抽屉遮罩：默认隐藏 */
.sidebar-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 98;
}

/* ================= 关键词排位分析表（kwrank） ================= */
.kwrank-table { font-size: 12px; width: 100%; border-collapse: collapse; }
.kwrank-table th, .kwrank-table td { padding: 6px 7px; white-space: nowrap; vertical-align: middle; border: 1px solid var(--border, #eef1f5); }
.kwrank-table thead th { font-size: 11px; font-weight: 600; position: sticky; top: 0; z-index: 2; background: var(--bg-soft, #fff); }
/* 分组表头 */
.kwrank-table th.mine-head { background: #eef4ff; color: #1d4ed8; text-align: center; }
.kwrank-table th.comp-head { background: #fff3e0; color: #c2410c; text-align: center; }
/* 子表头我店区 / 竞对区 */
.kwrank-table th.mine { background: #f3f7ff; color: #334155; }
.kwrank-table th.comp { background: #fff7ed; color: #7c2d12; }
/* 数据单元格分组底色（弱化，避免刺眼） */
.kwrank-table td.mine { background: #fbfdff; }
.kwrank-table td.comp { background: #fffdf7; }
/* 行号列 */
.kwrank-table .rowhead { position: sticky; left: 0; z-index: 1; background: var(--bg-soft, #fff); color: var(--muted, #98a2b0); font-size: 11px; text-align: center; min-width: 34px; }
/* 关键词列允许换行 */
.kwrank-table td:first-of-type { white-space: normal; word-break: break-word; min-width: 140px; max-width: 220px; font-weight: 600; }
/* 数字列右对齐 + 等宽数字 */
.kwrank-table td { text-align: right; font-variant-numeric: tabular-nums; }
.kwrank-table td:first-of-type, .kwrank-table td:nth-child(11) { text-align: left; }
