/* ══════════════════════════════════════════════════════════════
   深色模式（2026-11-04 v3 · 保守方案）
   
   【前两版为什么失败】
   v1 逐条覆盖颜色 → 写了 67 条，实测仍 6 处白底浅字看不清
   v2 整页滤镜反色 → body 加 filter 后 position:fixed 失效，页面渲染空白
   
   【v3 思路：只改「底色」和「文字色」两个维度，不动布局、不用滤镜】
   · 只选页面里 4 个最大的容器统一改背景
   · 文字色统一改成浅色
   · 深色下所有"白底"组件用一条通配规则压掉
   · 宁可某些地方不够黑，也不能出现"看不见"
   
   原则：**能看清 > 好看**
   ══════════════════════════════════════════════════════════════ */

/* ── 设置页样式（两种主题共用）── */
.settings-page { max-width: 900px; }
.settings-title { margin-bottom: 20px; }
.settings-title h2 { font-size: 20px; color: #1e293b; margin: 0 0 5px; font-weight: 700; }
.settings-sub { font-size: 12.5px; color: #94a3b8; }

.settings-card {
  background: #fff; border: 1px solid #eef2f7; border-radius: 12px;
  padding: 18px 20px; margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.03);
}
.settings-card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.settings-card-icon { font-size: 20px; line-height: 1.3; }
.settings-card-name { font-size: 14.5px; font-weight: 700; color: #1e293b; margin-bottom: 3px; }
.settings-card-desc { font-size: 12px; color: #64748b; line-height: 1.65; }

.theme-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 560px; }
.theme-opt {
  position: relative; border: 2px solid #eef2f7; border-radius: 11px;
  padding: 12px; cursor: pointer; transition: .16s; background: #fff;
}
.theme-opt:hover { border-color: #c4b5fd; transform: translateY(-1px); }
.theme-opt.on { border-color: #7c3aed; box-shadow: 0 0 0 3px rgba(124,58,237,.09); }
.theme-opt-check {
  position: absolute; top: 9px; right: 10px; width: 19px; height: 19px;
  border-radius: 50%; background: #7c3aed; color: #fff;
  display: none; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.theme-opt.on .theme-opt-check { display: flex; }
.theme-opt-name { font-size: 13.5px; font-weight: 700; color: #1e293b; margin-top: 10px; }
.theme-opt-desc { font-size: 11.5px; color: #94a3b8; margin-top: 2px; }

.theme-preview { border-radius: 7px; padding: 9px 10px; height: 74px;
  display: flex; flex-direction: column; gap: 5px; }
.theme-preview-light { background: #f8fafc; border: 1px solid #e2e8f0; }
.theme-preview-dark { background: #1e293b; border: 1px solid #334155; }
.tp-bar { height: 9px; border-radius: 3px; }
.theme-preview-light .tp-bar { background: #cbd5e1; }
.theme-preview-dark .tp-bar { background: #475569; }
.tp-line { height: 7px; border-radius: 3px; }
.tp-line.short { width: 62%; }
.theme-preview-light .tp-line { background: #e2e8f0; }
.theme-preview-dark .tp-line { background: #334155; }

/* ══════════════════════════════════════════════════════════════
   深色模式 v3
   ══════════════════════════════════════════════════════════════ */

/* ① 页面底色 */
html[data-theme="dark"] body {
  background: #0f172a !important;
  color: #e5e9f0 !important;
}

/* ② 主内容区 + 所有面板容器：统一深色底 */
html[data-theme="dark"] .main,
html[data-theme="dark"] #main-content,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .panel-body,
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .mtabs,
html[data-theme="dark"] .toolbar,
html[data-theme="dark"] .search-box {
  background: #1a2438 !important;
  color: #e5e9f0 !important;
  border-color: #2c3a52 !important;
}

/* ②b 概览页统计卡 / 模块导航 / 各种卡片（2026-11-04：v3 漏了这些类定义的白底）
       这些卡片原本在 CSS 类里写 background:#fff，不是内联，通配选不中 */
html[data-theme="dark"] .stat-card,
html[data-theme="dark"] .stat-info,
html[data-theme="dark"] .stat-icon,
html[data-theme="dark"] .dash-mod,
html[data-theme="dark"] .module-item,
html[data-theme="dark"] .module-card,
html[data-theme="dark"] .info-card,
html[data-theme="dark"] .sum-card,
html[data-theme="dark"] .today-card,
html[data-theme="dark"] .note-card,
html[data-theme="dark"] .panel-header,
html[data-theme="dark"] .card-body,
html[data-theme="dark"] .card-head {
  background: #1a2438 !important;
  color: #e5e9f0 !important;
  border-color: #2c3a52 !important;
}
html[data-theme="dark"] .stat-card h3,
html[data-theme="dark"] .stat-info h3,
html[data-theme="dark"] .stat-card .num,
html[data-theme="dark"] .stat-info .num {
  color: #f1f5f9 !important;
}
html[data-theme="dark"] .stat-card .label,
html[data-theme="dark"] .stat-info .label,
html[data-theme="dark"] .stat-card small {
  color: #a8b3c4 !important;
}
/* 统计卡图标底色也压深 */
html[data-theme="dark"] .stat-icon.blue { background: #1e3a5f !important; }
html[data-theme="dark"] .stat-icon.green { background: #134e3a !important; }
html[data-theme="dark"] .stat-icon.orange { background: #5c3a13 !important; }
html[data-theme="dark"] .stat-icon.purple { background: #3b2a5c !important; }
html[data-theme="dark"] .stat-icon.red { background: #5c1f1f !important; }

/* ③ 表格 */
html[data-theme="dark"] .data-table,
html[data-theme="dark"] .data-table thead,
html[data-theme="dark"] .data-table tbody,
html[data-theme="dark"] .data-table tr {
  background: #1a2438 !important;
  color: #e5e9f0 !important;
}
html[data-theme="dark"] .data-table th {
  background: #24314a !important;
  color: #cbd5e1 !important;
  border-color: #2c3a52 !important;
}
html[data-theme="dark"] .data-table td {
  background: transparent !important;
  color: #e5e9f0 !important;
  border-bottom-color: #2c3a52 !important;
}
html[data-theme="dark"] .data-table tbody tr:hover,
html[data-theme="dark"] .data-table tbody tr:hover td {
  background: #22304a !important;
}

/* ③b 彩色小标签（2026-11-04）：原本是浅底+同色字，深色下必须换成深底+亮字
       涉及 .tag-* 系列和表格里的小徽章 */
html[data-theme="dark"] .tag-blue   { background: #1e3a5f !important; color: #7cb3f5 !important; }
html[data-theme="dark"] .tag-purple { background: #3b2a5c !important; color: #c4b5fd !important; }
html[data-theme="dark"] .tag-green  { background: #134e3a !important; color: #6ee7b7 !important; }
html[data-theme="dark"] .tag-orange { background: #5c3a13 !important; color: #fbbf24 !important; }
html[data-theme="dark"] .tag-red    { background: #5c1f1f !important; color: #fca5a5 !important; }
html[data-theme="dark"] .tag-gray   { background: #2c3a52 !important; color: #cbd5e1 !important; }
html[data-theme="dark"] .tag        { background: #2c3a52 !important; color: #cbd5e1 !important; }

/* ③c 返回栏里的链接、排序箭头 */
html[data-theme="dark"] .sub-back-bar a,
html[data-theme="dark"] .sub-back-bar span,
html[data-theme="dark"] a { color: #93c5fd !important; }
html[data-theme="dark"] .sort-arrow { color: #93c5fd !important; }

/* ③d 返回栏箭头（2026-11-04）：v3 显示对比度 1.8，太暗看不见 */
html[data-theme="dark"] .sub-back-ico,
html[data-theme="dark"] .sub-back-bar .sub-back-ico,
html[data-theme="dark"] .sub-back-bar button {
  color: #93c5fd !important;
}
/* 表格里的业务员名字等次要文字 */
html[data-theme="dark"] .data-table td span:not([class]) {
  color: #cbd5e1 !important;
}

/* ④ 通配兜底：深色下凡是"白/浅底"的块状元素一律压成深色
      这是 v1 缺失的关键 —— 不管有多少组件都能覆盖到。
      ⚠️ 2026-11-04：v3 初版只匹配了 div，概览页模块卡是 span/table 就漏了，
         这里去掉标签限制，改成 [style*=...] 通配所有标签。 */
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background:#ffffff"],
html[data-theme="dark"] [style*="background: #ffffff"],
html[data-theme="dark"] [style*="background:#f8fafc"],
html[data-theme="dark"] [style*="background: #f8fafc"],
html[data-theme="dark"] [style*="background:#f0fdfa"],
html[data-theme="dark"] [style*="background:#faf5ff"],
html[data-theme="dark"] [style*="background:#f5f3ff"],
html[data-theme="dark"] [style*="background:#fffbeb"],
html[data-theme="dark"] [style*="background:#fef2f2"],
html[data-theme="dark"] [style*="background:#eff6ff"],
html[data-theme="dark"] [style*="background:#f0f9ff"],
html[data-theme="dark"] [style*="background:#f1f5f9"] {
  background: #1a2438 !important;
  color: #e5e9f0 !important;
}
/* 深色下「白色小卡片」内部的次要说明文字也要变浅 */
html[data-theme="dark"] [style*="color:#94a3b8"],
html[data-theme="dark"] [style*="color: #94a3b8"],
html[data-theme="dark"] [style*="color:#64748b"],
html[data-theme="dark"] [style*="color: #64748b"] {
  color: #a8b3c4 !important;
}
/* ⚠️ 2026-11-04：概览页模块卡文字是 #334155（深蓝灰），在深底上看不见。
      凡是深色系内联文字，深色模式一律提亮。 */
html[data-theme="dark"] [style*="color:#334155"],
html[data-theme="dark"] [style*="color: #334155"],
html[data-theme="dark"] [style*="color:#1e3a5f"],
html[data-theme="dark"] [style*="color: #1e3a5f"],
html[data-theme="dark"] [style*="color:#1a1a2e"],
html[data-theme="dark"] [style*="color: #1a1a2e"],
html[data-theme="dark"] [style*="color:#111827"],
html[data-theme="dark"] [style*="color: #111827"],
html[data-theme="dark"] [style*="color:#1f2937"],
html[data-theme="dark"] [style*="color:#374151"],
html[data-theme="dark"] [style*="color:#0f172a"] {
  color: #e5e9f0 !important;
}
/* 积分列在深色下太暗，提亮 */
/* 积分列在深色下提亮（2026-11-04：0 分原用 #6b7a90 对比度仅 2.2，看不清）*/
html[data-theme="dark"] .pt-mid { color: #c4b5fd !important; }
html[data-theme="dark"] .pt-high { color: #fcd34d !important; }
html[data-theme="dark"] .pt-zero { color: #94a3b8 !important; }

/* ⑤ 文字：主文字浅、次要文字中灰 */
html[data-theme="dark"] h1, html[data-theme="dark"] h2, html[data-theme="dark"] h3,
html[data-theme="dark"] h4, html[data-theme="dark"] b, html[data-theme="dark"] strong,
html[data-theme="dark"] .settings-card-name,
html[data-theme="dark"] .settings-title h2,
html[data-theme="dark"] .theme-opt-name {
  color: #f1f5f9 !important;
}
html[data-theme="dark"] p, html[data-theme="dark"] label, html[data-theme="dark"] small,
html[data-theme="dark"] .settings-card-desc, html[data-theme="dark"] .settings-sub,
html[data-theme="dark"] .theme-opt-desc {
  color: #a8b3c4 !important;
}
/* 深色下所有残留的深色字（比如 #333 #1a1a2e）也被压成浅色 */
html[data-theme="dark"] span[style*="color:#333"],
html[data-theme="dark"] span[style*="color:#1a1a2e"],
html[data-theme="dark"] span[style*="color:#1e293b"],
html[data-theme="dark"] span[style*="color:#475569"],
html[data-theme="dark"] div[style*="color:#333"],
html[data-theme="dark"] div[style*="color:#1e293b"],
html[data-theme="dark"] div[style*="color:#475569"] {
  color: #e5e9f0 !important;
}

/* ⑥ 输入框 / 下拉 / 文本域 */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #24314a !important;
  color: #e5e9f0 !important;
  border-color: #2c3a52 !important;
}
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #6b7a90 !important;
}

/* ⑦ 按钮：保留彩色边框，但底色压深 */
html[data-theme="dark"] .btn-outline,
html[data-theme="dark"] button.btn-outline {
  background: #24314a !important;
  color: #dbe3ee !important;
  border-color: #3a4a66 !important;
}
html[data-theme="dark"] .btn-outline:hover {
  background: #2c3a52 !important;
}
/* 主按钮保持原色（紫/蓝），只确保文字够白 */
html[data-theme="dark"] .btn-primary {
  color: #fff !important;
}

/* ⑧ 弹窗 */
html[data-theme="dark"] .modal,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-body,
html[data-theme="dark"] .modal-footer {
  background: #1a2438 !important;
  color: #e5e9f0 !important;
  border-color: #2c3a52 !important;
}
html[data-theme="dark"] .modal-close {
  color: #cbd5e1 !important;
}
html[data-theme="dark"] .modal-overlay {
  background: rgba(0,0,0,.75) !important;
}

/* ⑨ 分类标签条 / 微信标签条（v1 漏的重点）*/
html[data-theme="dark"] .mtabs,
html[data-theme="dark"] .mtabs .mtab,
html[data-theme="dark"] .wx-tag-bar,
html[data-theme="dark"] .wx-tag-bar * {
  background: #1a2438 !important;
  color: #cbd5e1 !important;
  border-color: #2c3a52 !important;
}
html[data-theme="dark"] .mtabs .mtab.on,
html[data-theme="dark"] .mtab.on {
  background: #7c3aed !important;
  color: #fff !important;
}

/* ⑩ 侧边栏（本来就是深色，微调）*/
html[data-theme="dark"] .sidebar {
  background: #0b1220 !important;
  border-right-color: #2c3a52 !important;
}

/* ⑪ 返回栏 */
html[data-theme="dark"] .sub-back-bar {
  background: #24314a !important;
  color: #cbd5e1 !important;
  border-color: #2c3a52 !important;
}
html[data-theme="dark"] .sub-back-bar .sub-back-ico,
html[data-theme="dark"] .sub-back-bar a,
html[data-theme="dark"] .sub-back-bar span {
  color: #cbd5e1 !important;
}

/* ⑫ 滚动条 */
html[data-theme="dark"] ::-webkit-scrollbar { width: 10px; height: 10px; }
html[data-theme="dark"] ::-webkit-scrollbar-track { background: #0f172a; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #3a4a66; border-radius: 5px; }
html[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #4d6182; }

/* ══════════════════════════════════════════════════════════════
   浅色模式：显式还原（因为深色用了 !important）
   ══════════════════════════════════════════════════════════════ */
html[data-theme="light"] body { background: #f0f2f5 !important; color: #333 !important; }

/* ── 手机端 ── */
@media (max-width: 700px) {
  .theme-picker { grid-template-columns: 1fr; }
  .settings-page { padding: 0 2px; }
}
