/* ═══════════════════════════════════════════════════════════════════════
   远欧科技 ERP · Google 彩色风格主题（Material Design 3 + 经典四色）
   支持：白底（light，默认）/ 黑底（dark）用户自选切换
   适配：Windows + 中国大陆（纯系统字体，零境外 CDN/字体外链）
   ═══════════════════════════════════════════════════════════════════════ */

:root,
html[data-ui-theme="light"] {
  --g-blue: #1a73e8;
  --g-blue-h: #1557b0;
  --g-blue-soft: #e8f0fe;
  --g-red: #ea4335;
  --g-red-soft: #fce8e6;
  --g-yellow: #fbbc04;
  --g-yellow-txt: #b06000;
  --g-yellow-soft: #fef7e0;
  --g-green: #34a853;
  --g-green-txt: #137333;
  --g-green-soft: #e6f4ea;

  /* 覆盖系统旧变量，使全部既有组件自动跟随 */
  --purple: #1a73e8;
  --purple2: #4285f4;
  --purple-d: #1557b0;
  --blue: #1a73e8;
  --green: #1e8e3e;
  --red: #d93025;
  --gold: #e37400;
  --soft: #e8f0fe;

  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-2: #f1f3f4;
  --card: #ffffff;
  --side-bg: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.94);
  --txt: #202124;
  --ink: #202124;
  --ink2: #3c4043;
  --ink3: #5f6368;
  --mut: #5f6368;
  --line: #dadce0;
  --line2: #e8eaed;
  --hover: #f1f3f4;
  --tr-hover: #f8faff;
  --input-bg: #ffffff;
  --shadow-1: 0 1px 2px rgba(60, 64, 67, 0.08), 0 1px 3px 1px rgba(60, 64, 67, 0.06);
  --shadow-2: 0 4px 12px rgba(60, 64, 67, 0.14);
}

html[data-ui-theme="dark"] {
  --g-blue: #8ab4f8;
  --g-blue-h: #aecbfa;
  --g-blue-soft: rgba(138, 180, 248, 0.16);
  --g-red: #f28b82;
  --g-red-soft: rgba(242, 139, 130, 0.15);
  --g-yellow: #fdd663;
  --g-yellow-txt: #fdd663;
  --g-yellow-soft: rgba(253, 214, 99, 0.14);
  --g-green: #81c995;
  --g-green-txt: #81c995;
  --g-green-soft: rgba(129, 201, 149, 0.15);

  --purple: #8ab4f8;
  --purple2: #aecbfa;
  --purple-d: #aecbfa;
  --blue: #8ab4f8;
  --green: #81c995;
  --red: #f28b82;
  --gold: #fdd663;
  --soft: rgba(138, 180, 248, 0.14);

  --bg: #121316;
  --surface: #1e1f24;
  --surface-2: #282a31;
  --card: #1e1f24;
  --side-bg: #18191e;
  --header-bg: rgba(24, 25, 30, 0.94);
  --txt: #e8eaed;
  --ink: #e8eaed;
  --ink2: #dadce0;
  --ink3: #9aa0a6;
  --mut: #9aa0a6;
  --line: #343740;
  --line2: #2b2d35;
  --hover: #2a2c34;
  --tr-hover: rgba(138, 180, 248, 0.08);
  --input-bg: #25272f;
  --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.52);
  color-scheme: dark;
}

/* ── 基础排版（Windows 清晰锐利中文字体栈，零境外字体外链）── */
html, body {
  background: var(--bg) !important;
  color: var(--txt) !important;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, -apple-system, sans-serif !important;
  -webkit-font-smoothing: antialiased;
}

/* 顶部 Google 四色彩条（3px 极细识别条） */
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 9999;
  background: linear-gradient(90deg,
    #4285f4 0%, #4285f4 25%,
    #ea4335 25%, #ea4335 50%,
    #fbbc04 50%, #fbbc04 75%,
    #34a853 75%, #34a853 100%);
  pointer-events: none;
}

/* ── 侧栏（Google Workspace 胶囊风）── */
.side {
  width: 214px !important;
  flex: 0 0 214px !important;
  background: var(--side-bg) !important;
  color: var(--txt) !important;
  border-right: 1px solid var(--line2) !important;
  padding-top: 3px;
}
html[data-ui-theme] .side .brand {
  padding: 16px 16px 14px !important;
  border-bottom: 1px solid var(--line2) !important;
  color: var(--txt) !important;
  background: transparent !important;
  gap: 10px !important;
}
html[data-ui-theme] .side .brand .blogo {
  width: 28px !important;
  height: 28px !important;
  flex: 0 0 28px !important;
  border-radius: 8px !important;
  background: transparent !important;
  box-shadow: none !important;
}
html[data-ui-theme] .side .brand span,
html[data-ui-theme] .side .brand b,
html[data-ui-theme] .side .brand > div {
  font-weight: 700 !important;
  font-size: 15.5px !important;
  color: var(--txt) !important;
  -webkit-text-fill-color: var(--txt) !important;
  background: none !important;
  opacity: 1 !important;
}
html[data-ui-theme] .side .brand small {
  color: var(--mut) !important;
  -webkit-text-fill-color: var(--mut) !important;
  font-size: 10.5px !important;
  letter-spacing: 0.4px !important;
  opacity: 1 !important;
}

.side nav { padding: 8px 10px 10px 0 !important; }
html[data-ui-theme] .side .ngrp {
  padding: 10px 16px 4px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  color: var(--mut) !important;
  opacity: 1 !important;
  letter-spacing: 0.3px;
}
.nb {
  color: var(--ink2) !important;
  border-radius: 0 999px 999px 0 !important;
  padding: 8.5px 14px 8.5px 16px !important;
  margin-bottom: 2px !important;
  font-size: 13.5px !important;
  font-weight: 500 !important;
  transition: background 0.14s ease, color 0.14s ease;
}
html[data-ui-theme] .side .nb {
  background: transparent !important;
  color: var(--ink2) !important;
  border: 0 !important;
  box-shadow: none !important;
  opacity: 1 !important;
}
html[data-ui-theme] .side .nb i { opacity: 0.9 !important; }
html[data-ui-theme] .side .nb:hover {
  background: var(--hover) !important;
  color: var(--txt) !important;
}
html[data-ui-theme="light"] .side .nb.on {
  background: #e8f0fe !important;
  color: #174ea6 !important;
  font-weight: 700 !important;
}
html[data-ui-theme="dark"] .side .nb.on {
  background: rgba(138, 180, 248, 0.18) !important;
  color: #8ab4f8 !important;
  font-weight: 700 !important;
}
html[data-ui-theme] .side .nb.on::before,
html[data-ui-theme] .side .nb::before {
  display: none !important;
  content: none !important;
}
.nb i { font-size: 15px !important; width: 20px !important; }

.side .foot {
  padding: 12px 14px !important;
  font-size: 11.5px !important;
  opacity: 1 !important;
  color: var(--mut) !important;
  border-top: 1px solid var(--line2) !important;
  background: var(--side-bg) !important;
}
.side .foot b { color: var(--txt) !important; }
.side .foot .glink {
  color: var(--g-blue) !important;
  cursor: pointer;
  font-weight: 600;
}
.side .foot .foot-ops {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.side .foot .foot-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--txt);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
}
.side .foot .foot-btn:hover {
  border-color: var(--g-blue);
  background: var(--g-blue-soft);
  color: var(--g-blue);
}

/* ── 顶栏 ── */
main { background: var(--bg) !important; }
main > header {
  background: var(--header-bg) !important;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line2) !important;
  padding: 12px 24px !important;
  margin-top: 3px;
}
main > header h1 {
  color: var(--txt) !important;
  font-size: 17px !important;
  font-weight: 700 !important;
  letter-spacing: -0.2px;
}
main > header .hint { color: var(--mut) !important; }
main > header .st { color: var(--mut) !important; gap: 10px !important; }
.dot { background: var(--g-green) !important; }

.g-theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--txt);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.14s, background 0.14s;
}
.g-theme-btn:hover {
  border-color: var(--g-blue);
  background: var(--g-blue-soft);
  color: var(--g-blue);
}

/* ── 卡片 & 区块标题 ── */
.pg { padding: 20px 24px 44px !important; }
.card {
  background: var(--card) !important;
  border: 1px solid var(--line2) !important;
  border-radius: 16px !important;
  padding: 18px 20px !important;
  margin-bottom: 16px !important;
  box-shadow: var(--shadow-1) !important;
  color: var(--txt) !important;
}
.sec {
  color: var(--txt) !important;
  font-size: 14.5px !important;
  font-weight: 700 !important;
  padding-left: 0 !important;
}
.sec::before { display: none !important; }
.sec .bar {
  display: inline-block !important;
  width: 4px !important;
  height: 16px !important;
  border-radius: 4px !important;
  background: linear-gradient(180deg, #4285f4 0%, #34a853 100%) !important;
  flex-shrink: 0;
}

/* ── KPI 卡片：Google 四色循环顶边（彻底压过旧主题暗蓝渐变与角标）── */
html[data-ui-theme] .kpi {
  background: var(--card) !important;
  border: 1px solid var(--line2) !important;
  border-radius: 14px !important;
  border-top: 3.5px solid var(--g-blue) !important;
  box-shadow: var(--shadow-1) !important;
  padding: 15px 16px !important;
}
html[data-ui-theme] .kpi::after,
html[data-ui-theme] .kpi::before { display: none !important; content: none !important; }
html[data-ui-theme] .kpi:hover {
  background: var(--card) !important;
  box-shadow: var(--shadow-2) !important;
}
html[data-ui-theme] .grid .kpi:nth-child(4n+1) { border-top-color: #4285f4 !important; }
html[data-ui-theme] .grid .kpi:nth-child(4n+2) { border-top-color: #ea4335 !important; }
html[data-ui-theme] .grid .kpi:nth-child(4n+3) { border-top-color: #fbbc04 !important; }
html[data-ui-theme] .grid .kpi:nth-child(4n+4) { border-top-color: #34a853 !important; }
html[data-ui-theme] .kpi b,
html[data-ui-theme] .kpi .v,
html[data-ui-theme] .kpi .num {
  color: var(--txt) !important;
  background: none !important;
  -webkit-background-clip: border-box !important;
  -webkit-text-fill-color: currentColor !important;
  font-weight: 800 !important;
}
html[data-ui-theme] .kpi.good { border-top-color: var(--g-green) !important; }
html[data-ui-theme] .kpi.good .v,
html[data-ui-theme] .kpi.good b { color: var(--g-green-txt) !important; }
html[data-ui-theme] .kpi.warn { border-top-color: var(--g-yellow) !important; }
html[data-ui-theme] .kpi.warn .v,
html[data-ui-theme] .kpi.warn b { color: var(--g-yellow-txt) !important; }
html[data-ui-theme] .kpi.na { border-top-color: var(--g-red) !important; }
html[data-ui-theme] .kpi.na .v,
html[data-ui-theme] .kpi.na b { color: var(--g-red) !important; }
html[data-ui-theme] .kpi .sub,
html[data-ui-theme] .kpi .s,
html[data-ui-theme] .kpi .src,
html[data-ui-theme] .kpi .muted { color: var(--mut) !important; border-top-color: var(--line2) !important; }

/* ── 按钮 / 芯片 / 表单控件（Google Material 3）── */
.chip {
  background: var(--surface) !important;
  color: var(--txt) !important;
  border: 1px solid var(--line) !important;
  border-radius: 999px !important;
  padding: 5px 13px !important;
  font-weight: 500;
  transition: background 0.14s, border-color 0.14s, box-shadow 0.14s;
}
.chip:hover {
  border-color: var(--g-blue) !important;
  background: var(--g-blue-soft) !important;
  color: var(--g-blue) !important;
}
.chip.on {
  background: var(--g-blue) !important;
  color: #ffffff !important;
  border-color: var(--g-blue) !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 3px rgba(26, 115, 232, 0.28);
}
html[data-ui-theme="dark"] .chip.on {
  color: #121316 !important;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  background: var(--input-bg) !important;
  color: var(--txt) !important;
  border: 1px solid var(--line) !important;
  border-radius: 10px !important;
  font-family: inherit;
}
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  outline: none !important;
  border-color: var(--g-blue) !important;
  box-shadow: 0 0 0 3px var(--g-blue-soft) !important;
}

/* ── 表格 ── */
table { color: var(--txt) !important; }
th {
  background: var(--surface-2) !important;
  color: var(--ink3) !important;
  border-bottom: 1px solid var(--line) !important;
  font-weight: 600 !important;
}
td {
  border-bottom: 1px solid var(--line2) !important;
  color: var(--txt) !important;
}
tr:hover td { background: var(--tr-hover) !important; }
.wrap { border-color: var(--line2) !important; border-radius: 12px !important; }

/* ── 提示条 / 筛选栏 / 空态 ── */
.note {
  background: var(--g-blue-soft) !important;
  color: var(--txt) !important;
  border-left: 4px solid var(--g-blue) !important;
  border-radius: 10px !important;
}
.note.warn, .warn {
  background: var(--g-red-soft) !important;
  border-left-color: var(--g-red) !important;
}
.fbar, .empty {
  background: var(--surface-2) !important;
  border-color: var(--line) !important;
  color: var(--mut) !important;
  border-radius: 12px !important;
}

/* ── 扩展模块（健康预警 / 利润异常 / 评价问答 / AI 员工）适配白/黑双主题 ── */
.ext-pill { background: var(--surface-2) !important; color: var(--ink2) !important; }
.ext-pill.ok { background: var(--g-green-soft) !important; color: var(--g-green-txt) !important; }
.ext-pill.warn { background: var(--g-yellow-soft) !important; color: var(--g-yellow-txt) !important; }
.ext-pill.danger { background: var(--g-red-soft) !important; color: var(--g-red) !important; }

.ext-pipe, .rep-card, .agent {
  background: var(--surface) !important;
  border-color: var(--line2) !important;
  border-radius: 14px !important;
  color: var(--txt) !important;
}
.ext-pipe.ok { border-left-color: var(--g-green) !important; }
.ext-pipe.warn { border-left-color: var(--g-yellow) !important; background: var(--g-yellow-soft) !important; }
.ext-pipe.danger { border-left-color: var(--g-red) !important; background: var(--g-red-soft) !important; }
.rep-card.bad { border-left-color: var(--g-red) !important; background: var(--g-red-soft) !important; }
.rep-buyer { background: var(--surface-2) !important; color: var(--txt) !important; }
.rep-cn { background: var(--g-blue-soft) !important; color: var(--g-blue) !important; }
.agent { border-left: 4px solid var(--g-blue) !important; }
.agent .tag { background: var(--g-green-soft) !important; color: var(--g-green-txt) !important; border: none !important; }

/* ── 黑底模式深度兜底（覆盖原代码中硬编码的浅色内联背景）── */
html[data-ui-theme="dark"] #ordAlertBar {
  background: rgba(242, 139, 130, 0.14) !important;
  border-color: rgba(242, 139, 130, 0.35) !important;
  border-left-color: #f28b82 !important;
  color: #e8eaed !important;
}
html[data-ui-theme="dark"] #ordAlertBar b { color: #f28b82 !important; }
html[data-ui-theme="dark"] #ceoBody > div,
html[data-ui-theme="dark"] #ceoStatus > div > div,
html[data-ui-theme="dark"] #ceoPlan > div {
  background: var(--surface-2) !important;
  color: var(--txt) !important;
  border-color: var(--line) !important;
}
html[data-ui-theme="dark"] select#ordShop_sel.ordShopSel,
html[data-ui-theme="dark"] .ordShopSel {
  background: #25272f !important;
  color: #e8eaed !important;
  border: 1px solid #4c5262 !important;
  box-shadow: none !important;
}
html[data-ui-theme="dark"] [style*="background:#e0f2fe"],
html[data-ui-theme="dark"] [style*="background:#eff6ff"],
html[data-ui-theme="dark"] [style*="background:#dbeafe"],
html[data-ui-theme="dark"] [style*="background:#eef2ff"] {
  background: rgba(138, 180, 248, 0.16) !important;
  color: #8ab4f8 !important;
  border-color: rgba(138, 180, 248, 0.35) !important;
}
html[data-ui-theme="dark"] [style*="background:#ede9fe"] {
  background: rgba(197, 138, 249, 0.18) !important;
  color: #d7aefb !important;
}
html[data-ui-theme="dark"] [style*="background:#f1f5f9"],
html[data-ui-theme="dark"] [style*="background:#e2e8f0"] {
  background: #2d3039 !important;
  color: #dadce0 !important;
}
html[data-ui-theme="dark"] [style*="background:#fff"],
html[data-ui-theme="dark"] [style*="background: #fff"],
html[data-ui-theme="dark"] [style*="background:#fafafa"],
html[data-ui-theme="dark"] [style*="background:#f8fafc"],
html[data-ui-theme="dark"] [style*="background:#f4f9ff"],
html[data-ui-theme="dark"] [style*="background:#f6f5f4"],
html[data-ui-theme="dark"] [style*="background:#fffdf5"],
html[data-ui-theme="dark"] [style*="background:#fbfffc"] {
  background: var(--surface-2) !important;
  color: var(--txt) !important;
}
html[data-ui-theme="dark"] [style*="color:#0c4a6e"],
html[data-ui-theme="dark"] [style*="color:#0369a1"] {
  color: #8ab4f8 !important;
}
html[data-ui-theme="dark"] [style*="color:#b91c1c"] {
  color: #f28b82 !important;
}
html[data-ui-theme="dark"] a { color: #8ab4f8; }
html[data-ui-theme="dark"] #gate {
  background: #121316 !important;
  color: #e8eaed !important;
}
html[data-ui-theme="dark"] #gate .gbox,
html[data-ui-theme="dark"] #gate .gcard {
  background: #1e1f24 !important;
  border-color: #343740 !important;
  color: #e8eaed !important;
}

/* 当用户全局选了白底，非 AI 托管页保持白底；选了黑底，全站统一深色 */
html[data-ui-theme="dark"] body.dark-theme,
html[data-ui-theme="dark"] body.dark-theme .app {
  background: var(--bg) !important;
}

/* ── 用户设置弹窗（Google Material 3 Dialog）── */
#userSetMask {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(3px);
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#userSetMask.open { display: flex; }
.uset-dlg {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  color: var(--txt);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.uset-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line2);
}
.uset-hd h3 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.uset-dots {
  display: inline-flex;
  gap: 4px;
}
.uset-dots i {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.uset-bd { padding: 18px 22px 22px; }
.uset-lbl {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--txt);
}
.uset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.uset-opt {
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  background: var(--surface-2);
  transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
  text-align: left;
  font-family: inherit;
  color: var(--txt);
}
.uset-opt:hover { border-color: var(--g-blue); }
.uset-opt.active {
  border-color: var(--g-blue);
  box-shadow: 0 0 0 3px var(--g-blue-soft);
}
.uset-prev {
  height: 68px;
  border-radius: 9px;
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid rgba(128,128,128,.22);
  display: flex;
  flex-direction: column;
}
.uset-prev-bar {
  height: 4px;
  background: linear-gradient(90deg, #4285f4 0 25%, #ea4335 25% 50%, #fbbc04 50% 75%, #34a853 75% 100%);
}
.uset-prev-body {
  flex: 1;
  display: flex;
  gap: 6px;
  padding: 7px;
}
.uset-prev.light .uset-prev-body { background: #f8f9fa; }
.uset-prev.light .p-side { width: 28%; background: #ffffff; border-radius: 4px; border: 1px solid #e0e3e7; }
.uset-prev.light .p-main { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.uset-prev.light .p-card { flex: 1; background: #ffffff; border-radius: 5px; border: 1px solid #e0e3e7; border-top: 2px solid #4285f4; }
.uset-prev.dark .uset-prev-body { background: #121316; }
.uset-prev.dark .p-side { width: 28%; background: #18191e; border-radius: 4px; border: 1px solid #343740; }
.uset-prev.dark .p-main { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.uset-prev.dark .p-card { flex: 1; background: #1e1f24; border-radius: 5px; border: 1px solid #343740; border-top: 2px solid #8ab4f8; }
.uset-opt-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 700;
}
.uset-opt-sub {
  font-size: 11.5px;
  color: var(--mut);
  margin-top: 3px;
}
.uset-ft {
  padding: 12px 22px;
  border-top: 1px solid var(--line2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--mut);
}
