/* 千川 SOP 中控台 通用样式补充 */

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* 表格紧凑 */
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.data-table th {
  text-align: left; padding: 0.6rem 0.75rem;
  background: #1e293b; color: #94a3b8; font-weight: 500;
  border-bottom: 1px solid #334155; white-space: nowrap;
}
table.data-table td {
  padding: 0.6rem 0.75rem; border-bottom: 1px solid #1e293b;
  vertical-align: top;
}
table.data-table tr:hover td { background: rgba(30, 41, 59, 0.5); }

/* 卡片 */
.kpi-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid #1e293b;
  border-radius: 1rem;
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  opacity: 0.6;
}

/* 按钮 */
.btn { padding: 0.5rem 1rem; border-radius: 0.5rem; font-size: 0.875rem; font-weight: 500; transition: all 0.15s; cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem; }
.btn-primary { background: linear-gradient(135deg, #fbbf24, #f97316); color: #0f172a; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary { background: #1e293b; color: #e2e8f0; border: 1px solid #334155; }
.btn-secondary:hover { background: #334155; }
.btn-danger { background: #7f1d1d; color: #fecaca; }
.btn-danger:hover { background: #991b1b; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.75rem; }
.btn-xs { padding: 0.1rem 0.45rem; font-size: 0.7rem; }

/* 数据中心：左侧子栏目 / 页签 */
.sub-active { background: #1e293b; color: #fbbf24; border: 1px solid #334155; }
.tabc { background: transparent; color: #94a3b8; }
.tabc:hover { background: #1e293b; }
.tab-active { background: #1e293b; color: #fbbf24; }

/* 数据中心：下拉限宽（分组/运营人/投放方式 ≤120px；账户下拉 ≤200px）
   注意：select 会被下方 select.input 的 width:100% 覆盖，必须用 max-width 限宽 */
.dw { width: 112px; max-width: 112px; min-width: 80px; }
.dwa { width: 200px; max-width: 200px; min-width: 140px; }
/* 盈亏配色（利润 = 有效佣金 - 消耗）—— **A 股习惯：赚钱红、亏钱绿**（红涨绿跌）。
   · .gain = 赚钱 / 好（红）
   · .loss = 亏钱 / 差（绿）
   ⚠ 全站凡是「赚/亏」语义的数字一律用这两个类，别再按直觉写死 emerald/red。
   注意：这只管盈亏；状态类（失败/错误/告警）仍用红色、成功仍用绿色，别混用。 */
.gain { color: #f87171; }
.loss { color: #34d399; }
/* 页面工具栏：搜索 / 下拉 / 筛选并列成行
   注意 select.input 与 input.input 的 width:100% 会让每个控件独占一行，须在容器内覆盖 */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bar > select.input,
.bar > input.input { width: auto; min-width: 110px; max-width: 200px; flex: 0 0 auto; }
.bar > input.input.grow { flex: 1 1 260px; min-width: 200px; max-width: 380px; }
.bar > .btn, .bar > label, .bar > span, .bar > .seg { flex: 0 0 auto; }
.tabbar { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 4px; }
.tabbar .tabc { flex: 1 1 0; text-align: center; }

/* 输入框 */
.input, select.input, textarea.input {
  width: 100%; padding: 0.5rem 0.75rem;
  background: #0f172a; border: 1px solid #1e293b; border-radius: 0.5rem;
  color: #e2e8f0; font-size: 0.875rem;
  outline: none; transition: border-color 0.15s;
}
.input:focus { border-color: #fbbf24; }

/* 标签 */
.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 9999px; font-size: 0.7rem; font-weight: 500; }
.badge-pending { background: #1e3a8a; color: #bfdbfe; }
.badge-processing { background: #713f12; color: #fef08a; }
.badge-done, .badge-approved { background: #14532d; color: #bbf7d0; }
.badge-failed, .badge-rejected { background: #7f1d1d; color: #fecaca; }
.badge-queued { background: #3730a3; color: #ddd6fe; }
.badge-default { background: #1e293b; color: #94a3b8; }

/* 加载态 */
.loading { display: inline-block; width: 1rem; height: 1rem; border: 2px solid #475569; border-top-color: #fbbf24; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
#toast { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; align-items: center; pointer-events: none; }
.toast-item { padding: 0.875rem 1.5rem; border-radius: 0.5rem; background: #1e293b; border: 1px solid #334155; color: #e2e8f0; font-size: 0.9rem; font-weight: 500; box-shadow: 0 10px 30px rgba(0,0,0,0.5); max-width: 90vw; transition: opacity 0.3s, transform 0.3s; pointer-events: auto; white-space: pre-wrap; text-align: center; }
.toast-success { background: #14532d; border-color: #22c55e; color: #bbf7d0; }
.toast-error { background: #7f1d1d; border-color: #ef4444; color: #fecaca; }
.toast-info { background: #1e3a5f; border-color: #3b82f6; color: #bfdbfe; }

/* 移动端表格溢出滚动 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===== 侧边栏：折叠式子菜单 ===== */
.nav-caret { display: inline-flex; color: #64748b; transition: transform 0.15s; }
.nav-caret.open { transform: rotate(90deg); }
.nav-children { display: flex; flex-direction: column; gap: 1px; }

/* ===== 数据中心：两行紧凑工具栏（并列不换行，窄屏横向滚动） ===== */
.dc-bar {
  display: flex; align-items: center; gap: 0.5rem;
  background: #0f172a; border: 1px solid #1e293b; border-radius: 0.75rem;
  padding: 0.4rem 0.6rem; overflow-x: auto; white-space: nowrap;
}
.dc-bar > * { flex: none; }
.bar-sep { width: 1px; height: 1.25rem; background: #334155; }

/* 分段控件（视图切换） */
.seg { display: inline-flex; align-items: center; gap: 2px; background: #1e293b; border-radius: 0.5rem; padding: 2px; }
.segc { padding: 0.25rem 0.6rem; border-radius: 0.375rem; font-size: 0.8rem; color: #94a3b8; background: transparent; }
.segc:hover { color: #e2e8f0; }
.seg-active { background: #0f172a; color: #fbbf24; font-weight: 500; }

/* 数值右对齐 / 等宽 */
table.data-table th.num, table.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ===== 计划明细表：分组表头 + 紧凑行 ===== */
table.plan-table th, table.plan-table td { padding: 0.45rem 0.6rem; }
table.plan-table thead tr.grp th {
  text-align: center; background: #0b1220; color: #64748b;
  font-size: 0.7rem; letter-spacing: 0.05em; border-bottom: 1px solid #334155;
}
table.plan-table th.sortable { cursor: pointer; user-select: none; }
table.plan-table th.sortable:hover, table.plan-table th.sorted { color: #fbbf24; }
/* 两行单元格：主行（名称/账户）+ 副行（ID/分组·运营） */
table.plan-table td.cell2 { white-space: nowrap; }
table.plan-table td.cell2 .l1 { max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
table.plan-table td.cell2 .l2 { max-width: 300px; overflow: hidden; text-overflow: ellipsis; font-size: 0.7rem; color: #64748b; margin-top: 1px; }
/* 两行单元格：商品库等 data-table 复用（主行 + 副行） */
table.data-table td.cell2 { white-space: nowrap; }
table.data-table td.cell2 .l1 { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
table.data-table td.cell2 .l2 { max-width: 220px; overflow: hidden; text-overflow: ellipsis; font-size: 0.7rem; color: #64748b; margin-top: 1px; }
/* 第三行：线上素材ID（比 l2 再淡一档，等宽字体便于核对数字） */
table.data-table td.cell2 .l3 { max-width: 220px; overflow: hidden; text-overflow: ellipsis; font-size: 0.7rem; color: #94a3b8; margin-top: 1px; font-family: ui-monospace, "SF Mono", Consolas, monospace; }

/* 计划汇总条 */
.plan-sum { display: flex; flex-wrap: wrap; background: #0f172a; border-bottom: 1px solid #1e293b; }
.plan-sum .ps-item { display: flex; align-items: baseline; gap: 0.4rem; padding: 0.5rem 1rem; border-right: 1px solid #1e293b; }
.plan-sum .ps-item span { font-size: 0.7rem; color: #94a3b8; }
.plan-sum .ps-item b { font-size: 0.9rem; color: #e2e8f0; }

/* 计划分页 */
.plan-page { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; background: #0f172a; border-top: 1px solid #1e293b; font-size: 0.75rem; color: #94a3b8; }
.plan-page .input { padding: 0.15rem 0.4rem; }
.plan-page .btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* ===== 系统配置页 · 分类标签栏 =====
   设计意图：这批标签必须**一眼看出是可点的按钮**（旧版灰底淡边框跟 .badge 长得一样，
   用户反馈「快不知道是按钮了」）。所以改用分段控件：
   ① 整条轨道有凹陷质感（深底 + 内阴影），把按钮「框」出来；
   ② 未选中项：透明底 + 亮一档的文字 + 悬停整块变色 + 按下位移，明确可点；
   ③ 选中项：琥珀实心 + 外投影，像一颗被按下的实体键浮起来；
   ④ 计数做成独立胶囊，未选中也有底色，进一步强化「这块能点」。
   注意：类名沿用 .tab-btn / .tab-btn-on / .tab-n，settings.js 无需大改。 */
.cfg-tabs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem;
  padding: 0.3rem; border-radius: 0.85rem;
  background: #0b1220; border: 1px solid #1e293b;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
}
.tab-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.48rem 0.95rem; border-radius: 0.6rem;
  background: transparent; border: 1px solid transparent;
  color: #cbd5e1; font-size: 0.8125rem; font-weight: 500;
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .15s, color .15s, border-color .15s,
              box-shadow .15s, transform .12s;
}
.tab-btn:hover { background: #1e293b; border-color: #334155; color: #f1f5f9; }
.tab-btn:active { transform: translateY(1px); }
.tab-btn:focus-visible { outline: 2px solid #fbbf24; outline-offset: 2px; }
/* 计数胶囊 */
.tab-btn .tab-n {
  min-width: 1.4rem; padding: 0.05rem 0.4rem; border-radius: 9999px;
  font-size: 0.7rem; font-weight: 600; text-align: center;
  font-variant-numeric: tabular-nums;
  background: #1e293b; color: #94a3b8; transition: background .15s, color .15s;
}
.tab-btn:hover .tab-n { background: #334155; color: #e2e8f0; }
/* 选中态：琥珀实心 + 投影浮起 */
.tab-btn-on,
.tab-btn-on:hover {
  background: linear-gradient(135deg, #fbbf24, #f97316);
  border-color: transparent; color: #0f172a; font-weight: 600;
  box-shadow: 0 4px 14px -4px rgba(251, 146, 60, 0.7);
}
.tab-btn-on .tab-n,
.tab-btn-on:hover .tab-n { background: rgba(15, 23, 42, 0.2); color: #0f172a; }
/* 「全部配置」是另一类动作（查看全部），靠右放，跟分类区分开 */
.tab-btn-all { margin-left: auto; }
/* 窄屏标签会换行，靠右会把「全部配置」顶到最后一行的最右边（像掉队），所以小屏改回正常流式 */
@media (max-width: 640px) { .tab-btn-all { margin-left: 0; } }

/* 定时计划任务页 · 任务说明（比表格副行宽，允许折行） */
.sch-desc { max-width: 520px; }

/* 通用列表分页条（各列表页复用，与计划页同款观感） */
.table-pager { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; background: #0f172a; border-top: 1px solid #1e293b; font-size: 0.75rem; color: #94a3b8; }
.table-pager .input { padding: 0.15rem 0.4rem; width: 6.5rem; }
.table-pager .btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* 通用可排序表头（点表头排序） */
table.data-table th.sortable { cursor: pointer; user-select: none; }
table.data-table th.sortable:hover, table.data-table th.sortable.sorted { color: #fbbf24; }

/* ===== 帮助中心：markdown 正文排版 =====
   Tailwind 的 preflight 把标题/列表/表格的默认样式清掉了，这里按暗色主题补回来 */
.md-body { color: #cbd5e1; font-size: 0.875rem; line-height: 1.8; word-break: break-word; }
.md-body > *:first-child { margin-top: 0; }
.md-body h1 { font-size: 1.4rem; font-weight: 700; color: #f1f5f9; margin: 0 0 0.9rem; }
.md-body h2 { font-size: 1.1rem; font-weight: 600; color: #fbbf24; margin: 1.7rem 0 0.6rem; padding-bottom: 0.35rem; border-bottom: 1px solid #1e293b; }
.md-body h3 { font-size: 1rem; font-weight: 600; color: #e2e8f0; margin: 1.2rem 0 0.45rem; }
.md-body h4 { font-size: 0.9rem; font-weight: 600; color: #e2e8f0; margin: 0.9rem 0 0.35rem; }
.md-body p { margin: 0.6rem 0; }
.md-body ul, .md-body ol { margin: 0.6rem 0 0.6rem 1.2rem; }
.md-body ul { list-style: disc; }
.md-body ol { list-style: decimal; }
.md-body li { margin: 0.25rem 0; }
.md-body li > ul, .md-body li > ol { margin: 0.25rem 0 0.25rem 1.1rem; }
.md-body a { color: #60a5fa; text-decoration: underline; }
.md-body strong { color: #f1f5f9; font-weight: 600; }
.md-body em { color: #e2e8f0; }
.md-body code {
  background: #0b1220; border: 1px solid #1e293b; border-radius: 0.25rem;
  padding: 0.05rem 0.32rem; color: #fbbf24;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem;
}
.md-body pre { background: #0b1220; border: 1px solid #1e293b; border-radius: 0.5rem; padding: 0.8rem; overflow-x: auto; margin: 0.8rem 0; }
.md-body pre code { background: transparent; border: 0; padding: 0; color: #cbd5e1; }
.md-body blockquote {
  border-left: 3px solid #fbbf24; background: rgba(251, 191, 36, 0.06);
  padding: 0.55rem 0.9rem; margin: 0.8rem 0; border-radius: 0 0.375rem 0.375rem 0;
}
.md-body table { border-collapse: collapse; margin: 0.8rem 0; font-size: 0.82rem; display: block; overflow-x: auto; width: 100%; }
.md-body th { background: #1e293b; color: #94a3b8; font-weight: 500; text-align: left; padding: 0.45rem 0.6rem; border: 1px solid #334155; white-space: nowrap; }
.md-body td { padding: 0.45rem 0.6rem; border: 1px solid #1e293b; vertical-align: top; }
.md-body hr { border: 0; border-top: 1px solid #1e293b; margin: 1.3rem 0; }
.md-body img { max-width: 100%; }
