/* ==========================================================================
   环球外贸获客云 · 设计令牌与主题层
   - 亮/暗双主题，通过 <html class="dark"> 切换
   - 语义工具类替代硬编码 hex，所有业务视图共享同一套视觉语言
   ========================================================================== */

/* ---------- 1. 设计令牌 ---------- */
:root {
  color-scheme: light;

  /* 层次：背景 → 卡片 → 悬浮 */
  --bg: #F5F6FA;
  --bg-soft: #EFF1F7;
  --surface: #FFFFFF;
  --surface-2: #F7F8FC;
  --surface-3: #F1F3F9;
  --surface-hover: #F2F4FA;
  --overlay: rgba(16, 18, 27, .38);

  /* 线条 */
  --line: #E6E8F0;
  --line-strong: #D2D7E4;

  /* 文字 */
  --fg: #15181F;
  --fg-strong: #000000;
  --fg-muted: #5C6272;
  --fg-subtle: #8A90A0;
  --fg-inverse: #FFFFFF;

  /* 品牌 */
  --brand: #5B5BD6;
  --brand-hover: #4F4FC4;
  --brand-ink: #3F3AA8;
  --brand-soft: #EEF0FF;
  --brand-line: #D9DCFB;

  /* 语义色 */
  --ok: #12864A;
  --ok-soft: #E6F6EC;
  --ok-line: #BFE6CE;
  --warn: #B25A09;
  --warn-soft: #FDF2E3;
  --warn-line: #F5DDBB;
  --danger: #D92D20;
  --danger-soft: #FDECEC;
  --danger-line: #F8CFCF;
  --info: #1D6BD6;
  --info-soft: #E8F1FE;
  --info-line: #C6DDFB;
  --neutral-soft: #F1F3F9;

  /* 效果 */
  --shadow-xs: 0 1px 2px rgba(16, 18, 27, .05);
  --shadow-sm: 0 1px 3px rgba(16, 18, 27, .07), 0 1px 2px rgba(16, 18, 27, .04);
  --shadow-md: 0 6px 20px -6px rgba(16, 18, 27, .12), 0 2px 6px -2px rgba(16, 18, 27, .06);
  --shadow-lg: 0 22px 48px -18px rgba(16, 18, 27, .26), 0 4px 12px -4px rgba(16, 18, 27, .1);
  --ring: rgba(91, 91, 214, .32);

  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 68px;
  --header-h: 58px;
}

html.dark {
  color-scheme: dark;

  --bg: #0C0E14;
  --bg-soft: #101319;
  --surface: #141821;
  --surface-2: #191E28;
  --surface-3: #1E2431;
  --surface-hover: #1D2331;
  --overlay: rgba(0, 0, 0, .6);

  --line: #252B37;
  --line-strong: #333B4A;

  --fg: #E7EAF1;
  --fg-strong: #FFFFFF;
  --fg-muted: #9BA3B4;
  --fg-subtle: #6E7789;
  --fg-inverse: #0C0E14;

  --brand: #7C85F2;
  --brand-hover: #8E96F7;
  --brand-ink: #A7AEFB;
  --brand-soft: rgba(124, 133, 242, .15);
  --brand-line: rgba(124, 133, 242, .34);

  --ok: #4ADE80;
  --ok-soft: rgba(74, 222, 128, .13);
  --ok-line: rgba(74, 222, 128, .3);
  --warn: #FBBF24;
  --warn-soft: rgba(251, 191, 36, .13);
  --warn-line: rgba(251, 191, 36, .3);
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, .13);
  --danger-line: rgba(248, 113, 113, .32);
  --info: #60A5FA;
  --info-soft: rgba(96, 165, 250, .13);
  --info-line: rgba(96, 165, 250, .3);
  --neutral-soft: rgba(255, 255, 255, .06);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .45);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 52px -20px rgba(0, 0, 0, .75);
  --ring: rgba(124, 133, 242, .42);
}

/* ---------- 2. 基础 ---------- */
* { -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .22s ease, color .22s ease;
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; letter-spacing: -.01em; color: var(--fg); }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
small { font-size: 12px; }

::selection { background: var(--brand-soft); color: var(--brand-ink); }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--fg-subtle); background-clip: content-box; }

/* ---------- 3. 语义工具类：文字 ---------- */
.text-fg { color: var(--fg); }
.text-fg-strong { color: var(--fg-strong); }
.text-muted { color: var(--fg-muted); }
.text-subtle { color: var(--fg-subtle); }
.text-inverse { color: #fff; }
.text-brand { color: var(--brand); }
.text-brand-ink { color: var(--brand-ink); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }
.text-neutral { color: var(--fg-muted); }

/* ---------- 4. 语义工具类：背景 ---------- */
.bg-app { background: var(--bg); }
.bg-app-soft { background: var(--bg-soft); }
.bg-surface { background: var(--surface); }
.bg-surface-2 { background: var(--surface-2); }
.bg-surface-3 { background: var(--surface-3); }
.bg-hover { background: var(--surface-hover); }
.bg-brand { background: var(--brand); }
.bg-brand-soft { background: var(--brand-soft); }
.bg-ok-soft { background: var(--ok-soft); }
.bg-warn-soft { background: var(--warn-soft); }
.bg-danger-soft { background: var(--danger-soft); }
.bg-info-soft { background: var(--info-soft); }
.bg-neutral-soft { background: var(--neutral-soft); }
.bg-line { background: var(--line); }
.bg-muted-soft { background: var(--neutral-soft); }
.bg-subtle-soft { background: var(--neutral-soft); }

/* ---------- 5. 语义工具类：边框 / 环 / 分隔 / 填充 ---------- */
.border-line { border-color: var(--line); }
.border-line-strong { border-color: var(--line-strong); }
.border-brand { border-color: var(--brand); }
.border-brand-line { border-color: var(--brand-line); }
.border-ok { border-color: var(--ok-line); }
.border-warn { border-color: var(--warn-line); }
.border-danger { border-color: var(--danger-line); }
.border-info { border-color: var(--info-line); }
.border-neutral { border-color: var(--line); }

.divide-line > * + * { border-color: var(--line); }
.ring-brand-ring { box-shadow: 0 0 0 3px var(--ring); }
.outline-line { outline-color: var(--line); }

.fill-brand { fill: var(--brand); }
.fill-muted { fill: var(--fg-muted); }
.fill-ok { fill: var(--ok); }
.fill-warn { fill: var(--warn); }
.fill-danger { fill: var(--danger); }
.stroke-brand { stroke: var(--brand); }
.stroke-muted { stroke: var(--fg-muted); }
.stroke-ok { stroke: var(--ok); }
.stroke-danger { stroke: var(--danger); }

.placeholder-subtle::placeholder { color: var(--fg-subtle); }
.decoration-brand { text-decoration-color: var(--brand); }

/* 渐变 */
.from-brand-grad { --tw-gradient-from: var(--brand); }
.to-brand-grad { --tw-gradient-to: var(--brand-ink); }
.from-brand { --tw-gradient-from: var(--brand); }
.via-brand { --tw-gradient-via: var(--brand); }
.to-brand { --tw-gradient-to: var(--brand); }

/* ---------- 6. 组件：卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: box-shadow .2s ease, border-color .2s ease, transform .2s ease, background-color .22s ease;
}
.card-hover:hover { box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.card-pad { padding: 18px; }
.card-title { font-size: 14px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--fg-subtle); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- 7. 组件：按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease, transform .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--brand-hover); }
.btn-soft { background: var(--brand-soft); color: var(--brand-ink); border-color: var(--brand-line); }
.btn-soft:hover { background: var(--brand-soft); border-color: var(--brand); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--fg-muted); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--fg); border-color: var(--fg-subtle); }
.btn-danger { background: var(--surface); border-color: var(--danger-line); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { filter: brightness(1.06); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }
.btn-icon { padding: 7px; width: 34px; height: 34px; }

/* ---------- 8. 组件：徽章 / 标签 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px; font-size: 12px; line-height: 18px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: var(--info-line); }
.badge-brand { background: var(--brand-soft); color: var(--brand-ink); border-color: var(--brand-line); }
.badge-neutral { background: var(--neutral-soft); color: var(--fg-muted); border-color: var(--line); }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: 8px; font-size: 12px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--fg-muted);
}

/* ---------- 9. 组件：表单 ---------- */
.input, select.input, textarea.input {
  width: 100%; padding: 7px 11px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); font-size: 13px; background: var(--surface); color: var(--fg);
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
.input::placeholder { color: var(--fg-subtle); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
select.input { cursor: pointer; }
textarea.input { resize: vertical; min-height: 84px; line-height: 1.6; }
.label { display: block; font-size: 12px; font-weight: 500; color: var(--fg-muted); margin-bottom: 5px; }
.hint { font-size: 12px; color: var(--fg-subtle); }

/* ---------- 10. 组件：表格 ---------- */
table.tbl { width: 100%; font-size: 13px; border-collapse: separate; border-spacing: 0; }
table.tbl thead th {
  /* 粘在顶栏下方；若表格处于 overflow:hidden 容器内则自动退化为静态表头 */
  position: sticky; top: var(--header-h); z-index: 5;
  text-align: left; font-size: 12px; font-weight: 500; color: var(--fg-muted);
  padding: 10px 12px; background: var(--surface-2);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl tbody td {
  padding: 11px 12px; border-bottom: 1px solid var(--line);
  vertical-align: middle; color: var(--fg);
}
table.tbl tbody tr { transition: background-color .14s ease; }
table.tbl tbody tr:hover td { background: var(--surface-hover); }
table.tbl tbody tr:last-child td { border-bottom: none; }
.tbl-wrap { overflow-x: auto; }

/* 卡片去掉 overflow-hidden 以启用吸顶表头时，由表格外缘单元格自行收角，保持圆角外观 */
table.tbl { border-radius: var(--radius); }
table.tbl thead th:first-child { border-top-left-radius: calc(var(--radius) - 1px); }
table.tbl thead th:last-child  { border-top-right-radius: calc(var(--radius) - 1px); }
table.tbl tbody tr:last-child td:first-child { border-bottom-left-radius: calc(var(--radius) - 1px); }
table.tbl tbody tr:last-child td:last-child  { border-bottom-right-radius: calc(var(--radius) - 1px); }

/* ---------- 11. 组件：提示条 ---------- */
.flash {
  display: flex; align-items: flex-start; gap: 8px;
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin-bottom: 14px;
  border: 1px solid var(--line);
}
.flash-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.flash-err { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.flash-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.flash-info { background: var(--info-soft); color: var(--info); border-color: var(--info-line); }

/* ---------- 12. 应用外壳 ---------- */
.app-shell { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  transition: width .22s ease, background-color .22s ease;
  z-index: 30;
}
html.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
html.sidebar-collapsed .sidebar .sb-label,
html.sidebar-collapsed .sidebar .sb-group-title,
html.sidebar-collapsed .sidebar .sb-foot,
html.sidebar-collapsed .sidebar .sb-badge { display: none; }
html.sidebar-collapsed .sidebar .sb-link { justify-content: center; padding-left: 0; padding-right: 0; }

.sb-brand {
  height: var(--header-h); display: flex; align-items: center; gap: 10px;
  padding: 0 14px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.sb-logo {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-ink));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
  box-shadow: 0 4px 12px -4px var(--brand);
}
/* 折叠/展开双 Logo：折叠显示方形小图标，展开显示独立横版 Logo 且不显示文字 */
.sb-when-collapsed { display: none; width: 100%; align-items: center; justify-content: center; }
.sb-when-expanded { display: flex; width: 100%; align-items: center; gap: 10px; min-width: 0; }
html.sidebar-collapsed .sidebar .sb-when-expanded { display: none; }
html.sidebar-collapsed .sidebar .sb-when-collapsed { display: flex; }
.sb-logo-wide { height: 30px; width: auto; max-width: 100%; object-fit: contain; flex-shrink: 0; }

/* 可视化编辑控件：开关 / 三态分段器 / 滑块 */
.switch { position: relative; display: inline-flex; width: 38px; height: 22px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px; cursor: pointer;
  background: var(--line-strong); transition: background-color .18s ease;
}
.switch i::before {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; top: 2px; left: 2px; transition: transform .18s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.28);
}
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::before { transform: translateX(16px); }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.seg label { cursor: pointer; }
.seg label input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg label span {
  display: block; padding: 3px 9px; font-size: 12px; line-height: 18px;
  color: var(--fg-muted); transition: background-color .15s ease, color .15s ease;
}
.seg label input:checked + span { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.seg label:has(input[value="on"]:checked) span { background: var(--ok-soft); color: var(--ok); }
.seg label:has(input[value="off"]:checked) span { background: var(--danger-soft); color: var(--danger); }
.seg-off label:has(input:checked) span { background: var(--danger-soft); color: var(--danger); }

.quota-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; }
.quota-row + .quota-row { margin-top: 4px; }
.quota-row.on { background: var(--surface-2); }
.quota-row input[type="range"] { height: 4px; accent-color: var(--brand); }

/* 预览模式提示条（代理商授权登录 / 平台管理员预览租户） */
.preview-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 20px; font-size: 12.5px;
  background: var(--warn-soft); color: var(--warn);
  border-bottom: 1px solid var(--warn-line);
  position: sticky; top: 0; z-index: 26;
}
.preview-dot {
  width: 7px; height: 7px; border-radius: 999px; flex-shrink: 0;
  background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 22%, transparent);
  animation: previewPulse 1.8s ease-in-out infinite;
}
@keyframes previewPulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.preview-exit {
  flex-shrink: 0;
  padding: 3px 10px; border-radius: 8px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--warn-line); background: var(--surface); color: var(--warn);
  transition: background-color .15s ease;
}
.preview-exit:hover { background: var(--warn); color: #fff; border-color: var(--warn); }

.sb-nav { flex: 1; overflow-y-auto; overflow-x: hidden; padding: 10px 8px 16px; }
.sb-group-title {
  padding: 12px 10px 5px; font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--fg-subtle);
}
.sb-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; font-size: 13px; color: var(--fg-muted);
  margin-bottom: 2px; transition: background-color .15s ease, color .15s ease;
  position: relative;
}
.sb-link:hover { background: var(--surface-hover); color: var(--fg); }
.sb-link.active {
  background: var(--brand-soft); color: var(--brand-ink); font-weight: 600;
}
.sb-link.active::before {
  content: ''; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.sb-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .9; }
.sb-link .sb-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-badge {
  font-size: 10px; padding: 0 6px; border-radius: 999px; line-height: 16px;
  background: var(--brand-soft); color: var(--brand-ink); border: 1px solid var(--brand-line);
}
/* 二级菜单（如 客户开发 → AI 开发 / 全球开发 / 海关数据） */
.sb-group { margin-bottom: 2px; }
.sb-link.sb-parent { font-weight: 600; }
.sb-link.sb-parent.open { color: var(--fg); }
.sb-caret { width: 14px; height: 14px; flex-shrink: 0; opacity: .6; transition: transform .18s ease; }
.sb-group.open > .sb-link.sb-parent .sb-caret { transform: rotate(180deg); }
.sb-sub {
  display: none;
  margin: 2px 0 4px 20px; padding-left: 10px;
  border-left: 1px solid var(--line);
}
.sb-sub.open { display: block; }
.sb-link.sb-sub-link { font-size: 12.5px; padding: 6px 10px; margin-bottom: 1px; }
.sb-link.sb-sub-link.active::before { left: -14px; height: 14px; }
html.sidebar-collapsed .sidebar .sb-sub { margin-left: 0; padding-left: 0; border-left: 0; }
html.sidebar-collapsed .sidebar .sb-caret { display: none; }
html.sidebar-collapsed .sidebar .sb-link.sb-sub-link { padding-left: 0; padding-right: 0; opacity: .85; }

.sb-foot { padding: 10px 14px; border-top: 1px solid var(--line); font-size: 11px; color: var(--fg-subtle); }

/* 顶栏 */
.topbar {
  height: var(--header-h); flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 25;
}
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  width: 300px; max-width: 40vw; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--fg-subtle);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.topbar-search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); background: var(--surface); }
.topbar-search input { border: 0; outline: 0; background: transparent; font-size: 13px; width: 100%; color: var(--fg); }
.topbar-search kbd {
  font-family: inherit; font-size: 11px; padding: 1px 5px; border-radius: 5px;
  border: 1px solid var(--line-strong); color: var(--fg-subtle); background: var(--surface);
}
.icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--fg-muted); cursor: pointer; transition: all .15s ease;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--fg); border-color: var(--line-strong); }
.avatar {
  width: 30px; height: 30px; border-radius: 999px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-ink));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
.user-menu-wrap { position: relative; }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 50;
  animation: pop .14s ease;
}
.user-menu.hidden { display: none; }
.user-menu a, .user-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border-radius: 8px; font-size: 13px; color: var(--fg-muted);
  background: none; border: 0; cursor: pointer; text-align: left;
}
.user-menu a:hover, .user-menu button:hover { background: var(--surface-hover); color: var(--fg); }
.user-menu .um-sep { height: 1px; background: var(--line); margin: 5px 4px; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* 内容区 */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content-body { flex: 1; padding: 22px 24px 40px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-title { font-size: 19px; font-weight: 650; }
.page-desc { font-size: 12.5px; color: var(--fg-subtle); margin-top: 3px; }

/* ---------- 13. 数据展示组件 ---------- */
.stat-card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.stat-card .stat-label { font-size: 12px; color: var(--fg-subtle); display: flex; align-items: center; gap: 6px; }
.stat-card .stat-value { font-size: 24px; font-weight: 680; letter-spacing: -.02em; margin-top: 6px; line-height: 1.15; }
.stat-card .stat-foot { font-size: 12px; color: var(--fg-subtle); margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.stat-icon {
  width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand-ink); flex-shrink: 0;
}
.stat-icon.ok { background: var(--ok-soft); color: var(--ok); }
.stat-icon.warn { background: var(--warn-soft); color: var(--warn); }
.stat-icon.danger { background: var(--danger-soft); color: var(--danger); }
.stat-icon.info { background: var(--info-soft); color: var(--info); }
.stat-card::after {
  content: ''; position: absolute; inset: 0 0 auto auto; width: 120px; height: 120px;
  background: radial-gradient(circle at top right, var(--brand-soft), transparent 70%);
  opacity: .7; pointer-events: none;
}

.progress { height: 6px; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); transition: width .5s ease; }
.progress.ok > span { background: var(--ok); }
.progress.warn > span { background: var(--warn); }
.progress.danger > span { background: var(--danger); }

.empty-state {
  padding: 46px 20px; text-align: center; color: var(--fg-subtle);
}
.empty-state .es-icon {
  width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--fg-subtle);
}

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a {
  padding: 8px 13px; font-size: 13px; color: var(--fg-muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; transition: color .15s ease, border-color .15s ease;
}
.tabs a:hover { color: var(--fg); }
.tabs a.active { color: var(--brand-ink); border-bottom-color: var(--brand); font-weight: 600; }

.section-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--fg-subtle); }
.kv dd { margin: 0; color: var(--fg); }

/* ---------- 14. 遗留硬编码 hex 兜底映射 ---------- */
/* 迁移脚本已替换绝大多数；此处兜底漏网之鱼，保证主题一致性 */
html [class*="bg-[#F7F7F5]"], html [class*="bg-[#F4F4F2]"], html [class*="bg-[#FAFAFC]"],
html [class*="bg-[#F6F5FA]"], html [class*="bg-[#F1F0EC]"], html [class*="bg-[#F1EFE8]"] { background-color: var(--surface-2); }
html [class*="bg-white"] { background-color: var(--surface); }
html [class*="border-[#E7E5F0]"], html [class*="border-[#D8D5E4]"],
html [class*="border-[#E8E6DF]"], html [class*="border-[#F1EFE8]"] { border-color: var(--line); }
html [class*="text-[#5F5E5A]"], html [class*="text-[#444441]"] { color: var(--fg-muted); }
html [class*="text-[#888780]"] { color: var(--fg-subtle); }
html [class*="text-[#2C2C2A]"] { color: var(--fg); }
html [class*="text-[#3B6D11]"], html [class*="text-[#2E7D32]"] { color: var(--ok); }
html [class*="bg-[#EAF3DE]"], html [class*="bg-[#E8F5E9]"] { background-color: var(--ok-soft); }
html [class*="text-[#A32D2D]"], html [class*="text-[#C62828]"] { color: var(--danger); }
html [class*="bg-[#FCEBEB]"], html [class*="bg-[#FDECEA]"] { background-color: var(--danger-soft); }
html [class*="text-[#854F0B]"] { color: var(--warn); }
html [class*="bg-[#FAEEDA]"] { background-color: var(--warn-soft); }
html [class*="text-[#3C3489]"], html [class*="text-[#534AB7]"], html [class*="text-[#7F77DD]"] { color: var(--brand-ink); }
html [class*="bg-[#EEEDFE]"] { background-color: var(--brand-soft); }
html [class*="bg-[#534AB7]"], html [class*="bg-[#7C6FF0]"] { background-color: var(--brand); }

/* ---------- 14b. 语义类完整矩阵（补齐迁移中产生的前缀组合） ---------- */
.bg-ok, .bg-warn, .bg-danger, .bg-info { background-color: var(--ok); }
.bg-warn { background-color: var(--warn); }
.bg-danger { background-color: var(--danger); }
.bg-info { background-color: var(--info); }
.bg-ok-line, .bg-warn-line { background-color: var(--ok-line); }
.bg-warn-line { background-color: var(--warn-line); }
.bg-danger-line { background-color: var(--danger-line); }
.bg-info-line { background-color: var(--info-line); }
.bg-brand-ink { background-color: var(--brand-ink); }
.bg-fg { background-color: var(--fg); }
.bg-muted { background-color: var(--fg-muted); }
.bg-subtle { background-color: var(--fg-subtle); }

.text-line { color: var(--line); }
.text-ok-line { color: var(--ok-line); }
.text-warn-line { color: var(--warn-line); }
.text-danger-line { color: var(--danger-line); }
.text-info-line { color: var(--info-line); }
.text-neutral-soft { color: var(--fg-muted); }

.border-surface, .border-surface-2, .border-surface-3 { border-color: var(--line); }
.border-surface-2 { border-color: var(--surface-2); }
.border-hover { border-color: var(--surface-hover); }
.border-brand-ink { border-color: var(--brand-ink); }
.border-ok-line { border-color: var(--ok-line); }
.border-danger-line { border-color: var(--danger-line); }
.border-warn-soft { border-color: var(--warn-line); }
.border-fg { border-color: var(--fg); }
.border-muted { border-color: var(--fg-muted); }
.border-subtle { border-color: var(--fg-subtle); }

.divide-line { border-color: var(--line); }

/* ---------- 14c. Tailwind brand 色阶在暗色下的重映射 ---------- */
/* 视图中仍保留少量 bg-brand-50 / text-brand-800 等色阶用法，
   暗色模式统一改为半透明品牌底 + 高亮文字，避免深底深字 */
html.dark .bg-brand-50,
html.dark .bg-brand-100,
html.dark .bg-brand-200 { background-color: var(--brand-soft); }
html.dark .bg-brand-400,
html.dark .bg-brand-600,
html.dark .bg-brand-700 { background-color: var(--brand); }
html.dark .text-brand-400 { color: var(--brand); }
html.dark .text-brand-600,
html.dark .text-brand-700,
html.dark .text-brand-800 { color: var(--brand-ink); }
html.dark .border-brand-200,
html.dark .border-brand-400,
html.dark .border-brand-600 { border-color: var(--brand-line); }
html.dark .ring-brand-400 { box-shadow: 0 0 0 3px var(--ring); }
html.dark .divide-brand-200 { border-color: var(--brand-line); }

/* ---------- 15. 主题切换按钮 ---------- */
.theme-toggle { position: relative; overflow: hidden; }
.theme-toggle svg { transition: transform .35s cubic-bezier(.4, 0, .2, 1), opacity .25s ease; }
html:not(.dark) .theme-toggle .icon-moon { display: block; }
html:not(.dark) .theme-toggle .icon-sun { display: none; }
html.dark .theme-toggle .icon-moon { display: none; }
html.dark .theme-toggle .icon-sun { display: block; }

/* 主题切换动画：圆形扩散 */
html.theme-transition * { transition: background-color .28s ease, border-color .28s ease, color .28s ease !important; }

/* ---------- 16. 工具类补充 ---------- */
.divider { height: 1px; background: var(--line); border: 0; margin: 14px 0; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; font-size: 12px; }
.truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.scroll-y { overflow-y: auto; }
.soft-scroll { scrollbar-width: thin; }

/* 移动端侧栏遮罩 */
.sb-backdrop {
  display: none; position: fixed; inset: 0; background: var(--overlay); z-index: 29;
}
@media (max-width: 1024px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .22s ease; }
  html.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  html.sidebar-open .sb-backdrop { display: block; }
  .topbar-search { width: 180px; }
}
@media (max-width: 640px) {
  .content-body { padding: 16px 14px 32px; }
  .topbar { padding: 0 12px; }
  .topbar-search { display: none; }
}
