/* ==========================================================================
   天罡平台 · 基础样式层
   职责：设计令牌（CSS 变量）、深浅色主题、全局布局（顶栏 / 侧边栏 / 面包屑 /
        标签页 / 内容区）、通用原子组件（按钮、卡片、标签、统计卡、提示等）。
   设计意图：所有颜色、间距、圆角、阴影都走变量，便于「客户化配置」页实时换主题色；
            layout 使用 flex 而非固定高度，保证 1024~1920 宽度下都不裁切。
   ========================================================================== */

/* ---------- 1. 设计令牌：浅色主题（默认） ---------- */
:root {
  color-scheme: light;
  --brand: #1e63d0;
  --brand-strong: #164ea8;
  --brand-weak: #e8f0fd;
  /* 选中高亮填充：由 brand 与 surface 混合校准，文字对比度 ≥8:1、与 brand 描边 ≥3:1 */
  --select-bg: #bcd0f1;
  --brand-2: #0aa2a2;
  /* 语义色按 WCAG 2.1 AA（正文 ≥ 4.5:1）校准，浅色底与白字两种用法均达标 */
  --danger: #c62828;
  --danger-weak: #fdecec;
  --warning: #a15c00;
  --warning-weak: #fff5e6;
  --success: #15803d;
  --success-weak: #e8f7ef;
  --info: #1d6fc4;
  --info-weak: #eaf3fd;
  --purple: #6d4fd0;

  /* 画布：浅色主题使用独立浅灰画布，白色卡片浮于其上，避免深色缝隙/边条 */
  --bg: #f2f5fa;
  --bg-deep: #e9eff7;
  --surface: #ffffff;

  /* 画布前景色：浅色画布配深色文字；深色主题由下方各主题或 store.js 自动推导为浅色文字 */
  --canvas-fg: #1c2b3f;
  --canvas-fg-2: rgba(28, 43, 63, .78);
  --canvas-fg-3: rgba(28, 43, 63, .68);
  --canvas-chip-bg: rgba(28, 43, 63, .07);
  --surface-2: #f8fafd;
  --surface-3: #eef3fa;

  /* 顶栏：浅色主题使用白色顶栏 + 深色文字（令牌化，深色主题保持原深底浅字） */
  --topbar-bg: #ffffff;
  --topbar-fg: #1c2b3f;
  --topbar-fg-2: #465a72;
  --topbar-fg-3: #5a6c82;
  --topbar-accent: #1e63d0;
  --topbar-logo-glow: transparent;
  --topbar-hover: #f1f5fc;
  --topbar-active-bg: #e8f0fd;
  --topbar-active-fg: #164ea8;
  --topbar-border: #dbe3ee;
  --topbar-shadow: 0 2px 10px rgba(16, 38, 68, .06);
  --topbar-input-bg: #f4f7fb;
  --topbar-input-border: #dbe3ee;
  --topbar-input-fg: #1c2b3f;
  --topbar-input-fg-2: #5a6c82;
  --topbar-icon-bg: #ffffff;
  --topbar-icon-border: #dbe3ee;
  --topbar-icon-fg: #40536b;

  /* 页签激活态：与内容卡片同色，形成「纸页」衔接 */
  --tab-active-bg: #ffffff;
  --tab-active-fg: #1c2b3f;

  /* 代码 / 日志面板（浅色主题下为浅底深字） */
  --code-bg: #f6f8fc;
  --code-fg: #24384f;
  --code-border: #dbe3ee;

  --sidebar-bg: #ffffff;
  --sidebar-active: #e8f0fd;
  --sidebar-hover: #f2f6fd;

  --text: #1c2b3f;
  --text-2: #4a5b70;
  --text-3: #5a6c82;
  --text-inverse: #ffffff;
  --border: #dbe3ee;
  --border-strong: #bcc9da;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 38, 68, .06);
  --shadow: 0 4px 16px rgba(16, 38, 68, .10);
  --shadow-lg: 0 16px 48px rgba(16, 38, 68, .18);

  /* 全局字号增量：所有 font-size: calc(Npx + var(--fs-bump)) 统一由该变量控制。
     --fs-bump 默认 4px（body 基准 = calc(14px + 4px) = 18px）。
     页面风格 → 字体调整 可全局调节 --fs-bump，范围对应 body 12px~24px。
     分区域字号：--fs-topnav-add / --fs-sidebar-add / --fs-body-add 叠加到对应容器的 --fs-bump 上。
     行内 style 字号由 components.css 末尾 [style*="font-size:Npx"] 属性选择器同步套用 var(--fs-bump)。 */
  --fs-bump: 4px;

  /* 类型阶梯：全部走 calc(基础 + var(--fs-bump))，随全局字号同步缩放 */
  --fs-xs: calc(12px + var(--fs-bump));
  --fs-sm: calc(13px + var(--fs-bump));
  --fs: calc(14px + var(--fs-bump));
  --fs-md: calc(15px + var(--fs-bump));
  --fs-lg: calc(18px + var(--fs-bump));
  --fs-xl: calc(22px + var(--fs-bump));
  --fs-xxl: calc(28px + var(--fs-bump));

  /* 分区域字号增量（页面风格 → 字体调整 中设置，默认 0） */
  --fs-topnav-add: 0px;
  --fs-sidebar-add: 0px;
  --fs-body-add: 0px;

  /* 左上角品牌标识（页面风格 → 品牌标识 中设置） */
  --brand-logo-size: 28px;
  --brand-text-size: 19px;
  --brand-sub-size: 10px;
  --brand-gap: 9px;

  /* 顶栏高度：原 56px，按要求增加 1/3（≈74.67px） */
  --topbar-h: calc(56px * 4 / 3);
  --sidebar-w: 244px;
  --tabbar-h: 38px;
  --crumb-h: 34px;

  --font: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", "Segoe UI", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
  --speed: .18s;
}

/* 分区域字号：在各区域容器上覆盖 --fs-bump，叠加区域增量。
   var(--fs-bump) 引用继承自 :root 的全局值，再加区域偏移，无循环引用。 */
.topnav { --fs-bump: calc(var(--fs-bump) + var(--fs-topnav-add)); }
.sidebar { --fs-bump: calc(var(--fs-bump) + var(--fs-sidebar-add)); }
main { --fs-bump: calc(var(--fs-bump) + var(--fs-body-add)); }

/* ---------- 2. 深色主题 ---------- */
html[data-theme="dark"] {
  --brand: #4f8ef0;
  --brand-strong: #2f6fd4;
  --brand-weak: #173257;
  --select-bg: #25426e;
  --brand-2: #2cc4c4;
  --danger: #ef5350;
  --danger-weak: #3a1c1f;
  --warning: #f0a23a;
  --warning-weak: #3a2a14;
  --success: #3ec98a;
  --success-weak: #123127;
  --info: #5aa2e8;
  --info-weak: #142c45;
  --purple: #a08cf0;

  --bg: var(--topbar-bg);
  --bg-deep: #08101b;
  --surface: #101d2e;
  --surface-2: #142337;
  --surface-3: #1a2c43;
  --topbar-bg: #081322;
  --topbar-fg: #e8f1ff;
  --sidebar-bg: #0e1a29;
  --sidebar-active: #173257;
  --sidebar-hover: #142337;

  --text: #e4edfa;
  --text-2: #a9b9ce;
  --text-3: #7386a0;
  --border: #24364e;
  --border-strong: #334a67;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow: 0 4px 16px rgba(0, 0, 0, .4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
}

/* ---------- 2b. 页面风格：青墨商务（浅色，新增） ---------- */
html[data-theme="ink-teal"] {
  /* 品牌与语义色按 WCAG 2.1 AA（正文 ≥ 4.5:1）校准：
     浅色画布 #f2f6f7、白色卡片、浅色底纹 #e7eff1 上均达标 */
  --brand: #0b7480;
  --brand-strong: #0a5f67;
  --brand-weak: #e2f4f5;
  --select-bg: #b7d8db;
  --brand-2: #2563eb;
  --danger: #c62828;
  --danger-weak: #fdecec;
  --warning: #995400;
  --warning-weak: #fff5e6;
  --success: #127536;
  --success-weak: #e8f7ef;
  --info: #0b7480;
  --info-weak: #e2f4f5;
  --purple: #6d4fd0;

  /* 内容画布：浅色模式的独立浅灰画布（此前误用顶栏深色，导致整屏深底深字不可读） */
  --bg: #f2f6f7;
  --bg-deep: #e7eff1;
  --surface: #ffffff;
  --surface-2: #f4f8f9;
  --surface-3: #e7eff1;
  /* 顶栏保持墨青深底浅字 */
  --topbar-bg: #0e343c;
  --topbar-fg: #e6f4f5;
  --sidebar-bg: #ffffff;
  --sidebar-active: #e2f4f5;
  --sidebar-hover: #f0f7f8;

  --text: #1b2b2e;
  --text-2: #45575b;
  /* 三级文字：原 #7a8c90 在浅色画布上仅 3.2:1，加深至 4.77:1 满足 AA */
  --text-3: #5b6b6f;
  --text-inverse: #ffffff;
  --border: #d9e4e6;
  --border-strong: #c0d2d5;

  --radius-sm: 5px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-sm: 0 1px 2px rgba(14, 52, 60, .06);
  --shadow: 0 4px 16px rgba(14, 52, 60, .10);
  --shadow-lg: 0 16px 48px rgba(14, 52, 60, .18);
}

/* ---------- 2c. 页面风格：石墨暗夜（深色，新增） ---------- */
html[data-theme="graphite"] {
  --brand: #5b9dff;
  --brand-strong: #3b82e8;
  --brand-weak: #14253d;
  --select-bg: #284167;
  --brand-2: #38c8b9;
  --danger: #f0635e;
  --danger-weak: #33171a;
  --warning: #f0a63c;
  --warning-weak: #32250f;
  --success: #41c78b;
  --success-weak: #0f2c20;
  --info: #5b9dff;
  --info-weak: #14253d;
  --purple: #9d8cf2;

  --bg: var(--topbar-bg);
  --bg-deep: #04070c;
  --surface: #0d1219;
  --surface-2: #111927;
  --surface-3: #172130;
  --topbar-bg: #060a12;
  --topbar-fg: #dce8fa;
  --sidebar-bg: #0a0f17;
  --sidebar-active: #14253d;
  --sidebar-hover: #111927;

  --text: #e6ebf2;
  --text-2: #a3b1c2;
  --text-3: #6d7d92;
  --border: #1e2a3c;
  --border-strong: #2b3c55;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
  --shadow: 0 4px 16px rgba(0, 0, 0, .5);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
}

/* 深色 / 石墨 / 深海风格使用深色系统控件（滚动条、原生下拉等） */
html[data-theme="dark"],
html[data-theme="graphite"],
html[data-theme="deep-ocean"] { color-scheme: dark; }

/* ---------- 2d. 深色系风格共用的顶栏 / 页签 / 代码面板令牌 ----------
   浅色主题在 :root 中定义为白底深字；深色、石墨、深海三种风格保持「深底浅字」，
   集中在此覆盖，避免各主题重复声明。青墨商务虽为深色顶栏，但内容区是浅色，
   其顶栏令牌与其余浅色风格一起在下方块中覆盖，页签/代码面板沿用 :root 浅色令牌。 */
html[data-theme="dark"],
html[data-theme="graphite"],
html[data-theme="deep-ocean"] {
  --canvas-chip-bg: rgba(255, 255, 255, .14);
  --topbar-fg-2: rgba(234, 242, 255, .78);
  --topbar-fg-3: rgba(234, 242, 255, .56);
  --topbar-accent: #6cc6ff;
  --topbar-logo-glow: rgba(80, 190, 255, .4);
  --topbar-hover: rgba(255, 255, 255, .10);
  --topbar-active-bg: rgba(88, 166, 255, .22);
  --topbar-active-fg: #ffffff;
  --topbar-border: transparent;
  --topbar-shadow: 0 2px 10px rgba(0, 0, 0, .18);
  --topbar-input-bg: rgba(255, 255, 255, .10);
  --topbar-input-border: rgba(255, 255, 255, .16);
  --topbar-input-fg: #eef6ff;
  --topbar-input-fg-2: #9db8d8;
  --topbar-icon-bg: rgba(255, 255, 255, .06);
  --topbar-icon-border: rgba(255, 255, 255, .16);
  --topbar-icon-fg: #dbe9fb;
  --tab-active-bg: var(--bg);
  --tab-active-fg: var(--canvas-fg);
  --code-bg: #0a1420;
  --code-fg: #cfe3f7;
  --code-border: transparent;
}

/* 主题切换过渡：仅在切换瞬间（约 220ms）启用颜色过渡，避免整屏突变闪烁，
   结束后立即移除该类，不干扰按钮/菜单日常的交互动效。 */
html.theme-switching,
html.theme-switching body,
html.theme-switching body * {
  transition: background-color .18s ease, color .18s ease, border-color .18s ease,
              box-shadow .18s ease, fill .18s ease, stroke .18s ease !important;
}
@media (prefers-reduced-motion: reduce) {
  html.theme-switching,
  html.theme-switching body,
  html.theme-switching body * { transition: none !important; }
}
/* ---------- 2e. 页面风格：雾霭蓝（浅色，低饱和护眼） ---------- */
html[data-theme="mist-blue"] {
  --brand: #4a7fb5;
  --brand-strong: #37648f;
  --brand-weak: #e8f0f8;
  --select-bg: #d2dfec;
  --brand-2: #5c9aa8;
  --danger: #c4555d;
  --danger-weak: #fbeeee;
  --warning: #b8792f;
  --warning-weak: #fbf3e8;
  --success: #3f8563;
  --success-weak: #eaf4ee;
  --info: #4a7fb5;
  --info-weak: #e8f0f8;
  --purple: #7266a8;

  --bg: #eef2f7;
  --bg-deep: #e4ebf3;
  --surface: #ffffff;
  --surface-2: #f6f9fc;
  --surface-3: #e9eff6;
  --topbar-bg: #33506b;
  --topbar-fg: #eaf1f9;
  --sidebar-bg: #fbfcfe;
  --sidebar-active: #e8f0f8;
  --sidebar-hover: #f2f6fb;

  --text: #2a3341;
  --text-2: #55606e;
  --text-3: #8a93a0;
  --text-inverse: #ffffff;
  --border: #e0e7ef;
  --border-strong: #cbd6e2;

  --radius-sm: 5px;
  --radius: 9px;
  --radius-lg: 13px;
  --radius-xl: 17px;
  --shadow-sm: 0 1px 2px rgba(38, 60, 84, .05);
  --shadow: 0 3px 12px rgba(38, 60, 84, .08);
  --shadow-lg: 0 14px 40px rgba(38, 60, 84, .14);
}

/* ---------- 2f. 页面风格：暖沙纸（浅色，暖调护眼） ---------- */
html[data-theme="warm-paper"] {
  --brand: #a8712c;
  --brand-strong: #85561f;
  --brand-weak: #f8efe0;
  --select-bg: #ebddca;
  --brand-2: #5f8f74;
  --danger: #bf5252;
  --danger-weak: #fbeeee;
  --warning: #b3761f;
  --warning-weak: #fbf2e2;
  --success: #5c8455;
  --success-weak: #eff5ea;
  --info: #8a7a5c;
  --info-weak: #f5f1e8;
  --purple: #8a6f9c;

  --bg: #f6f1e8;
  --bg-deep: #ede5d7;
  --surface: #fffdf9;
  --surface-2: #faf6ee;
  --surface-3: #f1e9db;
  --topbar-bg: #6b5540;
  --topbar-fg: #f7f1e8;
  --sidebar-bg: #fffdf9;
  --sidebar-active: #f8efe0;
  --sidebar-hover: #fbf6ec;

  --text: #3a3128;
  --text-2: #6b5f52;
  --text-3: #9b8f80;
  --text-inverse: #ffffff;
  --border: #e8dfd0;
  --border-strong: #d6c9b5;

  --radius-sm: 5px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-sm: 0 1px 2px rgba(90, 72, 48, .05);
  --shadow: 0 3px 12px rgba(90, 72, 48, .09);
  --shadow-lg: 0 14px 40px rgba(90, 72, 48, .15);
}

/* ---------- 2g. 页面风格：鼠尾草绿（浅色，灰绿镇静） ---------- */
html[data-theme="sage-green"] {
  --brand: #4e8a6b;
  --brand-strong: #3a6b51;
  --brand-weak: #e8f1ec;
  --select-bg: #d6e4dd;
  --brand-2: #6d8fa8;
  --danger: #c25a58;
  --danger-weak: #fbeeee;
  --warning: #b07f30;
  --warning-weak: #faf3e6;
  --success: #4e8a6b;
  --success-weak: #e8f1ec;
  --info: #5b8494;
  --info-weak: #ecf2f4;
  --purple: #7d6aa3;

  --bg: #f0f4f1;
  --bg-deep: #e6ece8;
  --surface: #ffffff;
  --surface-2: #f7faf8;
  --surface-3: #eaf0ec;
  --topbar-bg: #3f5b4b;
  --topbar-fg: #eaf2ed;
  --sidebar-bg: #fbfcfb;
  --sidebar-active: #e8f1ec;
  --sidebar-hover: #f3f7f4;

  --text: #2b3630;
  --text-2: #57645c;
  --text-3: #8b968f;
  --text-inverse: #ffffff;
  --border: #dfe7e2;
  --border-strong: #c9d5ce;

  --radius-sm: 5px;
  --radius: 9px;
  --radius-lg: 13px;
  --radius-xl: 17px;
  --shadow-sm: 0 1px 2px rgba(44, 66, 54, .05);
  --shadow: 0 3px 12px rgba(44, 66, 54, .08);
  --shadow-lg: 0 14px 40px rgba(44, 66, 54, .14);
}

/* ---------- 2h. 页面风格：暮云紫（浅色，柔紫低对比） ---------- */
html[data-theme="dusk-lilac"] {
  --brand: #6d5b9e;
  --brand-strong: #554680;
  --brand-weak: #ede9f6;
  --select-bg: #d3cee2;
  --brand-2: #5f8fa0;
  --danger: #bf5a6b;
  --danger-weak: #fbeeef;
  --warning: #b07d35;
  --warning-weak: #faf2e6;
  --success: #4f8a70;
  --success-weak: #eaf2ee;
  --info: #6d5b9e;
  --info-weak: #ede9f6;
  --purple: #6d5b9e;

  --bg: #f4f2f7;
  --bg-deep: #ebe8f0;
  --surface: #ffffff;
  --surface-2: #f9f8fb;
  --surface-3: #eeecf4;
  --topbar-bg: #4a4258;
  --topbar-fg: #f0edf6;
  --sidebar-bg: #fcfbfd;
  --sidebar-active: #ede9f6;
  --sidebar-hover: #f5f3f9;

  --text: #2f2b38;
  --text-2: #5d5769;
  --text-3: #918b9c;
  --text-inverse: #ffffff;
  --border: #e5e1ec;
  --border-strong: #d2ccdd;

  --radius-sm: 5px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-sm: 0 1px 2px rgba(56, 46, 74, .05);
  --shadow: 0 3px 12px rgba(56, 46, 74, .08);
  --shadow-lg: 0 14px 40px rgba(56, 46, 74, .14);
}

/* ---------- 2i. 页面风格：深海墨蓝（深色，低亮度护眼） ---------- */
html[data-theme="deep-ocean"] {
  --brand: #5a9bd4;
  --brand-strong: #4380b6;
  --brand-weak: #1c3145;
  --select-bg: #2f4a64;
  --brand-2: #4fb0a8;
  --danger: #e06a66;
  --danger-weak: #331c1e;
  --warning: #dda24f;
  --warning-weak: #302517;
  --success: #4fbf8f;
  --success-weak: #122b22;
  --info: #5a9bd4;
  --info-weak: #1c3145;
  --purple: #9184d8;

  --bg: #16212e;
  --bg-deep: #101923;
  --surface: #1f2c3a;
  --surface-2: #243243;
  --surface-3: #2b3b4e;
  --topbar-bg: #131d28;
  --topbar-fg: #dde7f2;
  --sidebar-bg: #1a2733;
  --sidebar-active: #1c3145;
  --sidebar-hover: #213040;

  --text: #dbe4ee;
  --text-2: #a4b2c2;
  --text-3: #74838f;
  --text-inverse: #16212e;
  --border: #2b3a4b;
  --border-strong: #3a4d63;

  --radius-sm: 5px;
  --radius: 9px;
  --radius-lg: 13px;
  --radius-xl: 17px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 3px 12px rgba(0, 0, 0, .35);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, .45);
}

/* 青墨商务 / 雾霭蓝 / 暖沙纸 / 鼠尾草绿 / 暮云紫：内容区为浅色（页签、代码面板沿用 :root 浅色令牌），
   但顶栏为深底浅字，仅覆盖顶栏作用域令牌，与 2d 的深色系集中覆盖保持一致的取值 */
html[data-theme="ink-teal"],
html[data-theme="mist-blue"],
html[data-theme="warm-paper"],
html[data-theme="sage-green"],
html[data-theme="dusk-lilac"] {
  --topbar-fg-2: rgba(234, 242, 255, .78);
  --topbar-fg-3: rgba(234, 242, 255, .56);
  --topbar-accent: #6cc6ff;
  --topbar-logo-glow: rgba(80, 190, 255, .4);
  --topbar-hover: rgba(255, 255, 255, .10);
  --topbar-active-bg: rgba(88, 166, 255, .22);
  --topbar-active-fg: #ffffff;
  --topbar-border: transparent;
  --topbar-shadow: 0 2px 10px rgba(0, 0, 0, .18);
  --topbar-input-bg: rgba(255, 255, 255, .10);
  --topbar-input-border: rgba(255, 255, 255, .16);
  --topbar-input-fg: #eef6ff;
  --topbar-input-fg-2: #9db8d8;
  --topbar-icon-bg: rgba(255, 255, 255, .06);
  --topbar-icon-border: rgba(255, 255, 255, .16);
  --topbar-icon-fg: #dbe9fb;
}

/* ---------- 3. 重置 ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5, p { margin: 0; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
table { border-collapse: collapse; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg { display: block; }
::selection { background: rgba(30, 99, 208, .22); }

/* 滚动条：细、克制，避免大屏与列表视觉噪音 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 4. 应用骨架 ---------- */
.app-shell { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.layout { flex: 1; display: flex; min-height: 0; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.view { flex: 1; overflow: auto; padding: 16px 18px 28px; position: relative; }

/* ---------- 5. 顶栏 ---------- */
.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  background: var(--topbar-bg);
  color: var(--topbar-fg);
  border-bottom: 1px solid var(--topbar-border);
  position: relative;
  z-index: 30;
  box-shadow: var(--topbar-shadow);
}
.brand { display: flex; align-items: center; gap: var(--brand-gap); flex: none; min-width: 172px; }
.brand-logo { color: var(--topbar-accent); display: grid; place-items: center; filter: drop-shadow(0 0 6px var(--topbar-logo-glow)); width: var(--brand-logo-size); height: var(--brand-logo-size); }
.brand-logo svg { width: 100%; height: 100%; display: block; }
.brand-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: var(--brand-text-size); letter-spacing: 3px; color: var(--topbar-fg); }
.brand-text small { font-size: var(--brand-sub-size); letter-spacing: .6px; color: var(--topbar-fg-2); margin-top: 3px; }

/* LOGO 布局模式（由「页面风格 → 品牌标识」切换，作用于顶栏与设置面板内的预览实例） */
/* 右置：文字在左、LOGO 在右，整组仍贴品牌区左缘（与左置模式视觉起点一致）。
   row-reverse 下主起点在右侧，用 flex-end 把整组压到左端，避免右侧留空导致顶栏错位 */
.brand-layout-right { flex-direction: row-reverse; justify-content: flex-end; }
/* 上置：LOGO 在上、文字在下；间距收窄且 LOGO 高度按顶栏剩余空间自适应，避免溢出顶栏 */
.brand-layout-top { flex-direction: column; justify-content: center; gap: min(var(--brand-gap), 6px); min-width: 0; }
.brand-layout-top .brand-text { align-items: center; }
.brand-layout-top .brand-logo {
  width: clamp(10px, calc(var(--topbar-h) - 6px - var(--brand-text-size) * 1.1 - 16px), var(--brand-logo-size));
  height: clamp(10px, calc(var(--topbar-h) - 6px - var(--brand-text-size) * 1.1 - 16px), var(--brand-logo-size));
}
/* 覆盖：LOGO 铺满整个品牌区并置于文字下方（半透明水印 + 文字投影保证可读性）
   用 .brand.brand-layout-cover 提升优先级：移动端 .brand{min-width:0} 会把品牌区宽度归零，
   而 ≤560px 时文字被隐藏、区内只剩绝对定位的 LOGO，容器塌陷会让 LOGO 消失并与导航重叠 */
.brand.brand-layout-cover { position: relative; isolation: isolate; min-width: var(--brand-logo-size); min-height: var(--brand-logo-size); }
.brand-layout-cover .brand-logo {
  position: absolute; left: 0; top: 0; width: 100%; height: 100%;
  min-width: var(--brand-logo-size); min-height: var(--brand-logo-size);
  opacity: .45; filter: none; pointer-events: none; z-index: 0;
}
.brand-layout-cover .brand-logo img { object-fit: contain; }
.brand-layout-cover .brand-text { position: relative; z-index: 1; text-shadow: 0 1px 4px rgba(3, 10, 20, .9); }

/* 一级导航：左右箭头参与布局，避免缩放/高 DPI 下遮住菜单文字；nav 自身承担横向滚动 */
.topnav-wrap { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; }
.topnav {
  display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0;
  overflow-x: auto; overflow-y: hidden;
  scroll-behavior: smooth;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.topnav-wrap.is-scrollable .topnav { cursor: grab; }
/* 隐藏原生滚动条，避免破坏顶栏视觉；滚动能力仍完整保留 */
.topnav::-webkit-scrollbar { width: 0; height: 0; display: none; }
.topnav.is-dragging { scroll-behavior: auto; cursor: grabbing; user-select: none; }
.topnav.is-dragging .topnav-item { pointer-events: none; }
/* 溢出方向的内容在边缘轻微淡出，作为滚动的视觉提示 */
.topnav-wrap.can-left .topnav {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 100%);
}
.topnav-wrap.can-right .topnav {
  -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 16px), transparent 100%);
  mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 16px), transparent 100%);
}
.topnav-wrap.can-left.can-right .topnav {
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
}
.topnav-item {
  position: relative;
  flex: none;
  padding: 8px 11px;
  border-radius: 6px;
  font-size: calc(16.5px + var(--fs-bump));
  color: var(--topbar-fg-2);
  white-space: nowrap;
  transition: background var(--speed), color var(--speed);
}
.topnav-item:hover { background: var(--topbar-hover); color: var(--topbar-fg); text-decoration: none; }
.topnav-item.active { background: var(--topbar-active-bg); color: var(--topbar-active-fg); font-weight: 600; }
.topnav-item.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px;
  background: var(--topbar-accent); border-radius: 2px;
}
/* 两端滚动指示器：独立占位按钮，只在溢出时占宽，绝不遮住导航文字 */
.topnav-arrow {
  flex: none; width: 0; height: 32px; margin: 0 1px; overflow: hidden;
  display: grid; place-items: center; padding: 0;
  border: 0; border-radius: 6px; background: none; color: var(--topbar-fg-2);
  font-size: calc(22px + var(--fs-bump)); line-height: 1; cursor: pointer;
  opacity: 0; pointer-events: none;
  transition: opacity var(--speed), color var(--speed), width var(--speed), background var(--speed);
}
.topnav-wrap.is-scrollable .topnav-arrow { width: 30px; }
.topnav-wrap.can-left .topnav-arrow-left,
.topnav-wrap.can-right .topnav-arrow-right { opacity: 1; pointer-events: auto; }
.topnav-arrow:hover { color: var(--topbar-fg); background: var(--topbar-hover); }
.topnav-arrow:focus-visible { outline: 2px solid var(--topbar-accent); outline-offset: -2px; }
.topnav-arrow:disabled { cursor: default; }

.topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }
.global-search { position: relative; display: flex; align-items: center; background: var(--topbar-input-bg); border: 1px solid var(--topbar-input-border); border-radius: 18px; padding: 0 10px; height: 32px; }
.global-search:focus-within { background: var(--topbar-bg); border-color: var(--topbar-accent); }
.gs-icon { color: var(--topbar-input-fg-2); font-size: calc(16px + var(--fs-bump)); margin-right: 4px; }
.global-search input { width: 212px; background: none; border: 0; outline: none; color: var(--topbar-input-fg); font-size: calc(12.5px + var(--fs-bump)); }
.global-search input::placeholder { color: var(--topbar-input-fg-2); }
.gs-panel {
  position: absolute; top: 38px; right: 0; width: 340px; max-height: 380px; overflow: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60;
}
.gs-group { font-size: calc(11px + var(--fs-bump)); color: var(--text-3); padding: 7px 10px 4px; }
.gs-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; color: var(--text); }
.gs-item:hover { background: var(--brand-weak); text-decoration: none; }
.gs-item small { color: var(--text-3); font-family: var(--mono); }
.gs-empty { padding: 16px; color: var(--text-3); text-align: center; }

.icon-btn {
  width: 30px; height: 30px; border-radius: 6px; border: 1px solid var(--topbar-icon-border);
  background: var(--topbar-icon-bg); color: var(--topbar-icon-fg); font-size: calc(15px + var(--fs-bump));
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--topbar-hover); color: var(--topbar-fg); }
/* 「系统管理」入口：仅保留图标，停靠右上角，悬浮显示模块名 */
.sys-entry { position: relative; }
.sys-entry.active { background: var(--topbar-active-bg); border-color: var(--topbar-accent); color: var(--topbar-active-fg); }
.sys-entry::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 8px); right: 0;
  padding: 5px 9px; border-radius: 6px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: calc(12px + var(--fs-bump)); white-space: nowrap;
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity var(--speed), transform var(--speed);
  z-index: 90;
}
.sys-entry:hover::after, .sys-entry:focus-visible::after { opacity: 1; transform: translateY(0); }
.userbox { display: flex; align-items: center; gap: 7px; padding-left: 6px; cursor: pointer; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(145deg, var(--brand), var(--brand-strong)); color: #fff; display: grid; place-items: center; font-size: calc(13px + var(--fs-bump)); font-weight: 700; }
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta b { font-size: calc(12.5px + var(--fs-bump)); color: var(--topbar-fg); font-weight: 600; }
.user-meta small { font-size: calc(10.5px + var(--fs-bump)); color: var(--topbar-fg-2); }

/* ---------- 6. 侧边栏（二级/三级/四级） ---------- */
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--sidebar-bg);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  transition: width var(--speed), margin var(--speed); position: relative; z-index: 20;
}
.sidebar.collapsed { width: 0; overflow: hidden; border-right: 0; }
.sidebar-head { padding: 13px 14px 10px; border-bottom: 1px solid var(--border); flex: none; }
.sidebar-head .sh-kicker { font-size: calc(10.5px + var(--fs-bump)); letter-spacing: 1px; color: var(--text-3); text-transform: uppercase; }
.sidebar-head .sh-title { font-size: calc(15px + var(--fs-bump)); font-weight: 700; color: var(--text); margin-top: 3px; display: flex; align-items: center; gap: 6px; }
.sidebar-head .sh-desc { font-size: calc(11px + var(--fs-bump)); color: var(--text-3); margin-top: 4px; line-height: 1.5; }
.menu-tree { flex: 1; overflow-y: auto; padding: 8px 7px 18px; }
.sidebar-foot {
  flex: none; border-top: 1px solid var(--border); padding: 9px 14px;
  font-size: calc(11px + var(--fs-bump)); color: var(--text-3); display: flex; align-items: center; gap: 6px;
}
.sidebar-foot .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-weak); }

.m-item {
  display: flex; align-items: center; gap: 7px; padding: 7px 9px; margin: 1px 0;
  border-radius: 6px; color: var(--text-2); font-size: calc(13px + var(--fs-bump)); cursor: pointer;
  user-select: none; position: relative; border: 0; background: none; width: 100%; text-align: left;
  transition: background var(--speed), color var(--speed);
}
.m-item:hover { background: var(--sidebar-hover); color: var(--text); text-decoration: none; }
.m-item.active { background: var(--sidebar-active); color: var(--brand); font-weight: 600; }
.m-item.active::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px;
  background: var(--brand); border-radius: 0 3px 3px 0;
}
.m-item .m-icon { width: 16px; flex: none; display: grid; place-items: center; color: var(--text-3); }
.m-item.active .m-icon, .m-item:hover .m-icon { color: currentColor; }
.m-item .m-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-item .m-arrow {
  width: 15px; flex: none; text-align: center; color: var(--text-3);
  font-size: calc(9px + var(--fs-bump)); transition: transform var(--speed);
}
.m-item .m-arrow.open { transform: rotate(90deg); }
.m-item .m-badge { font-size: calc(10px + var(--fs-bump)); background: var(--danger); color: #fff; border-radius: 8px; padding: 0 5px; line-height: 15px; }
.m-children { margin-left: 9px; padding-left: 8px; border-left: 1px dashed var(--border); }
.m-children.depth-2 { margin-left: 12px; }
.m-children.depth-3 { margin-left: 10px; }
.sidebar.collapsed .menu-tree { padding: 0; }

/* ---------- 7. 面包屑与标签页 ---------- */
.crumbbar {
  height: var(--crumb-h); flex: none; display: flex; align-items: center; gap: 6px;
  padding: 0 18px; font-size: calc(12px + var(--fs-bump)); color: var(--text-3);
  background: var(--surface); border-bottom: 1px solid var(--border);
  white-space: nowrap; overflow: hidden;
}
.crumbbar a { color: var(--text-3); }
.crumbbar a:hover { color: var(--brand); text-decoration: none; }
.crumbbar .cb-sep { color: var(--border-strong); }
.crumbbar .cb-now { color: var(--text); font-weight: 600; }
.crumbbar .cb-tag { margin-left: auto; display: inline-flex; gap: 6px; align-items: center; }

.tabbar {
  height: var(--tabbar-h); flex: none; display: flex; align-items: stretch; gap: 2px;
  padding: 0 10px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  overflow-x: auto; overflow-y: hidden;
}
.tab {
  display: flex; align-items: center; gap: 6px; padding: 0 10px; max-width: 210px;
  font-size: calc(12px + var(--fs-bump)); color: var(--text-2); border: 1px solid transparent; border-bottom: 0;
  border-radius: 6px 6px 0 0; cursor: pointer; white-space: nowrap; margin-top: 4px;
  position: relative;
}
.tab:hover { background: var(--surface-3); text-decoration: none; }
.tab.active { background: var(--tab-active-bg); color: var(--tab-active-fg); font-weight: 600; border-color: var(--border); }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--tab-active-bg); }
.tab .t-label { overflow: hidden; text-overflow: ellipsis; }
.tab .t-close { width: 15px; height: 15px; line-height: 13px; text-align: center; border-radius: 50%; color: var(--text-3); font-size: calc(12px + var(--fs-bump)); }
.tab .t-close:hover { background: var(--danger); color: #fff; }
.tab .t-home { color: var(--text-3); font-size: calc(11px + var(--fs-bump)); }
.tabbar-empty { font-size: calc(12px + var(--fs-bump)); color: var(--text-3); display: flex; align-items: center; }

/* ---------- 8. 页面骨架（所有视图复用） ---------- */
.page { animation: page-in var(--speed) ease-out; }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; flex-wrap: wrap;
}
.page-title { font-size: var(--fs-xl); font-weight: 700; color: var(--canvas-fg); display: flex; align-items: center; gap: 9px; line-height: 1.3; }
.page-title .pt-sub { font-size: calc(12px + var(--fs-bump)); font-weight: 400; color: var(--canvas-fg-3); }
.page-title .pt-count { font-size: calc(12px + var(--fs-bump)); font-weight: 500; color: var(--canvas-fg-2); background: var(--canvas-chip-bg); padding: 2px 8px; border-radius: 10px; }
.page-desc { font-size: calc(12px + var(--fs-bump)); color: var(--canvas-fg-3); margin-top: 5px; line-height: 1.6; max-width: 820px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-body { display: flex; flex-direction: column; gap: 14px; }

/* 列表页整页铺满：数据列表卡片填满剩余视口高度，表体内部上下滚动 */
.view:has(> .list-page) { display: flex; flex-direction: column; overflow: hidden; }
.list-page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.list-page > .page-body { flex: 1; min-height: 0; }
.list-page .table-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.list-page #lp-table { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.list-page #lp-table .table-wrap { flex: 1; min-height: 0; max-height: none; }

/* 自定义页整页铺满（.fill-page 标记页）：指定 .fill-card 卡片填满剩余高度，卡片主体内部滚动 */
.view:has(> .fill-page) { display: flex; flex-direction: column; overflow: hidden; }
.fill-page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.fill-page > .page-body { flex: 1; min-height: 0; }
.fill-page .fill-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.fill-page .fill-card .card-body { flex: 1; min-height: 0; overflow: auto; }
/* 通用：fill-page 内任意加 .fill-grow 的元素吸收剩余高度（配合自身 overflow:auto 内部滚动） */
.fill-page .fill-grow { flex: 1; min-height: 0; }
.fill-page .log-viewer { max-height: none; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-title { font-size: calc(14px + var(--fs-bump)); font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 3px; height: 14px; background: var(--brand); border-radius: 2px; }
.section-more { font-size: calc(12px + var(--fs-bump)); color: var(--text-3); cursor: pointer; }
.section-more:hover { color: var(--brand); }

/* ---------- 9. 卡片与栅格 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 14px 16px; min-width: 0;
}
.card.flat { box-shadow: none; }
.card.pad-0 { padding: 0; overflow: hidden; }
.card-hover { transition: box-shadow var(--speed), transform var(--speed), border-color var(--speed); }
.card-hover:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--border-strong); }
.grid { display: grid; gap: 14px; }
.grid-2, .grid-3, .grid-4, .grid-5, .grid-6, .grid-2-1, .grid-1-2 { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.flex-center { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; }
.muted { color: var(--text-3); }
.dict-missing { color: var(--text-3); border-bottom: 1px dashed var(--border-strong); cursor: help; }
.small { font-size: calc(12px + var(--fs-bump)); }
.xs { font-size: calc(11px + var(--fs-bump)); }
.strong { font-weight: 700; }
.mono { font-family: var(--mono); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

@media (max-width: 1440px) {
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
  .topnav-item { padding: 7px 8px; font-size: calc(15.5px + var(--fs-bump)); }
  .topnav-wrap.is-scrollable .topnav-arrow { width: 28px; }
  .global-search input { width: 150px; }
}
@media (max-width: 980px) {
  .grid-2, .grid-3, .grid-4, .grid-5, .grid-6 { grid-template-columns: 1fr; }
  .brand-text small { display: none; }
  .brand { min-width: 0; }
  .topbar { gap: 10px; padding: 0 10px; }
  .global-search { display: none; }
  .user-meta { display: none; }
  .sidebar { width: 210px; }
}
@media (max-width: 560px) {
  /* 小屏优先保证一级导航可操作：品牌只留 Logo，两端箭头收窄 */
  .brand-text { display: none; }
  .topbar-right { gap: 6px; }
  .topnav-wrap.is-scrollable .topnav-arrow { width: 24px; font-size: calc(20px + var(--fs-bump)); }
}
/* 手机端：侧边栏改为抽屉式浮层，默认收起，避免挤压正文导致内容换行错乱 */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0;
    width: min(80vw, 280px); z-index: 80; overflow-y: auto;
    transform: translateX(-100%);
    transition: transform var(--speed);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.collapsed { width: min(80vw, 280px); border-right: 1px solid var(--border); }
  .sidebar.open { transform: translateX(0); }
  .view { padding: 12px 12px 24px; }
  .page-head { flex-wrap: wrap; gap: 8px; }
}

/* ---------- 10. 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 30px; padding: 0 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font-size: calc(12.5px + var(--fs-bump)); white-space: nowrap;
  transition: background var(--speed), border-color var(--speed), color var(--speed);
}
.btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-weak); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b52a31; border-color: #b52a31; color: #fff; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn-sm { height: 26px; padding: 0 9px; font-size: calc(12px + var(--fs-bump)); }
.btn-xs { height: 22px; padding: 0 7px; font-size: calc(11px + var(--fs-bump)); border-radius: 4px; }
.btn-lg { height: 36px; padding: 0 18px; font-size: calc(14px + var(--fs-bump)); }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 6px 6px 0; }
.btn-group .btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- 11. 标签 / 徽标 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px;
  border-radius: 4px; font-size: calc(11px + var(--fs-bump)); line-height: 1; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2); border: 1px solid transparent;
}
.tag.soft { border-color: transparent; }
.tag.outline { background: transparent; border-color: var(--border-strong); }
.tag-dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.tag-lg { height: 24px; padding: 0 9px; font-size: calc(12px + var(--fs-bump)); }
.badge-num { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--brand); color: #fff; font-size: calc(10px + var(--fs-bump)); display: inline-grid; place-items: center; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 12px; background: var(--surface-3); font-size: calc(11.5px + var(--fs-bump)); color: var(--text-2); }
.dot-status { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ---------- 12. 统计卡（工作台/自定义页/大屏共用） ---------- */
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 13px 15px; position: relative; overflow: hidden; min-width: 0;
}
.stat::after {
  content: ""; position: absolute; right: -18px; top: -26px; width: 76px; height: 76px;
  border-radius: 50%; background: var(--brand-weak); opacity: .55; pointer-events: none;
}
.stat .st-label { font-size: calc(12px + var(--fs-bump)); color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.stat .st-value { font-size: calc(26px + var(--fs-bump)); font-weight: 700; color: var(--text); margin-top: 6px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .st-value small { font-size: calc(12px + var(--fs-bump)); font-weight: 500; color: var(--text-3); margin-left: 3px; }
.stat .st-foot { margin-top: 6px; font-size: calc(11px + var(--fs-bump)); color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.stat .st-trend.up { color: var(--danger); }
.stat .st-trend.down { color: var(--success); }
.stat.accent { border-top: 3px solid var(--brand); }
.stat.accent-danger { border-top: 3px solid var(--danger); }
.stat.accent-warn { border-top: 3px solid var(--warning); }
.stat.accent-success { border-top: 3px solid var(--success); }
.stat.accent-teal { border-top: 3px solid var(--brand-2); }
.stat.accent-purple { border-top: 3px solid var(--purple); }

/* ---------- 13. 进度条 / 迷你指标 ---------- */
.bar-track { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; background: var(--brand); transition: width .35s ease; }
.bar-fill.success { background: var(--success); }
.bar-fill.warn { background: var(--warning); }
.bar-fill.danger { background: var(--danger); }
.bar-fill.teal { background: var(--brand-2); }
.rank-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.rank-row:last-child { border-bottom: 0; }
.rank-no { width: 18px; height: 18px; border-radius: 4px; background: var(--surface-3); color: var(--text-3); font-size: calc(10px + var(--fs-bump)); display: grid; place-items: center; flex: none; }
.rank-no.top { background: var(--danger-weak); color: var(--danger); font-weight: 700; }
.rank-name { flex: 1; font-size: calc(12.5px + var(--fs-bump)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-val { font-size: calc(12px + var(--fs-bump)); font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------- 14. 空态 / 加载 / 错误 ---------- */
.empty-state { padding: 44px 20px; text-align: center; color: var(--text-3); }
.empty-state .es-icon { font-size: calc(32px + var(--fs-bump)); opacity: .45; margin-bottom: 8px; }
.empty-state .es-text { font-size: calc(13px + var(--fs-bump)); }
.empty-state .es-hint { font-size: calc(11.5px + var(--fs-bump)); color: var(--text-3); margin-top: 4px; }
.loading-mask { position: absolute; inset: 0; background: rgba(255,255,255,.55); backdrop-filter: blur(1px); display: grid; place-items: center; z-index: 20; border-radius: inherit; }
html[data-theme="dark"] .loading-mask { background: rgba(8, 16, 27, .55); }
html[data-theme="graphite"] .loading-mask { background: rgba(4, 7, 12, .6); }
html[data-theme="deep-ocean"] .loading-mask { background: rgba(16, 25, 35, .55); }
.spinner { width: 26px; height: 26px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: sk 1.2s ease infinite; border-radius: 5px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.sk-line { height: 12px; margin: 7px 0; }
.sk-line.w40 { width: 40%; } .sk-line.w60 { width: 60%; } .sk-line.w80 { width: 80%; }
.error-state { padding: 36px 20px; text-align: center; color: var(--danger); }
.error-state .error-cache { margin: 18px auto 0; max-width: 980px; text-align: left; max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: var(--surface); color: var(--text-2); }
.error-state .error-cache .table { margin-top: 8px; width: 100%; }
.error-state .es-title { font-size: calc(14px + var(--fs-bump)); font-weight: 700; margin-bottom: 6px; }
.error-state .es-msg { font-size: calc(12px + var(--fs-bump)); color: var(--text-2); white-space: pre-wrap; word-break: break-all; max-width: 640px; margin: 0 auto 12px; }

/* ---------- 15. 提示 / Toast ---------- */
/* 提示浮层本身不拦截鼠标：否则提示与弹窗/表格重叠时，下方按钮会点不动；
   仅文案与操作按钮可点击（可复制、可关闭） */
.toast-root { position: fixed; top: 68px; right: 18px; z-index: 9000; display: flex; flex-direction: column; gap: 8px; width: 380px; max-width: calc(100vw - 36px); pointer-events: none; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--info);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 10px 12px;
  display: flex; align-items: flex-start; gap: 9px; animation: toast-in .22s ease-out; pointer-events: none;
}
.toast .t-msg, .toast .t-copy, .toast .t-close { pointer-events: auto; }
@keyframes toast-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.error { border-left-color: var(--danger); }
.toast .t-icon { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: calc(12px + var(--fs-bump)); color: #fff; background: var(--info); margin-top: 1px; }
.toast.success .t-icon { background: var(--success); }
.toast.warning .t-icon { background: var(--warning); }
.toast.error .t-icon { background: var(--danger); }
.toast .t-body { flex: 1; min-width: 0; }
.toast .t-msg { font-size: calc(12.5px + var(--fs-bump)); color: var(--text); white-space: pre-wrap; word-break: break-word; line-height: 1.55; user-select: text; }
.toast .t-meta { margin-top: 5px; font-size: calc(10.5px + var(--fs-bump)); color: var(--text-3); display: flex; gap: 8px; align-items: center; }
.toast .t-actions { display: flex; gap: 4px; align-items: center; }
.toast .t-copy, .toast .t-close { border: 0; background: transparent; color: var(--text-3); font-size: calc(12px + var(--fs-bump)); padding: 2px 4px; border-radius: 3px; }
.toast .t-copy:hover, .toast .t-close:hover { background: var(--surface-3); color: var(--text); }
html[data-theme="dark"] .toast { box-shadow: 0 10px 32px rgba(0,0,0,.6); }
html[data-theme="graphite"] .toast { box-shadow: 0 10px 32px rgba(0,0,0,.7); }
html[data-theme="deep-ocean"] .toast { box-shadow: 0 10px 32px rgba(0,0,0,.55); }

/* ---------- 16. 工具条 / 分段控件 ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 6px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text-2); font-size: calc(12px + var(--fs-bump)); padding: 4px 10px; border-radius: 5px; }
.seg button.active { background: var(--surface); color: var(--brand); font-weight: 600; box-shadow: var(--shadow-sm); }
html[data-theme="dark"] .seg button.active { background: var(--surface-2); }
html[data-theme="graphite"] .seg button.active { background: var(--surface-2); }
html[data-theme="deep-ocean"] .seg button.active { background: var(--surface-2); }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 7px 0 9px;
  border-radius: 12px; background: var(--brand-weak); color: var(--brand); font-size: calc(11.5px + var(--fs-bump));
}
.chip .c-x { width: 15px; height: 15px; line-height: 13px; text-align: center; border-radius: 50%; cursor: pointer; color: var(--brand); }
.chip .c-x:hover { background: rgba(30,99,208,.2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- 17. 客户化主题覆盖 ---------- */
html[data-accent="teal"] { --brand: #0a8f8f; --brand-strong: #077272; --brand-weak: #e5f6f6; --select-bg: #bfe2e2; }
html[data-accent="green"] { --brand: #1a8f52; --brand-strong: #147243; --brand-weak: #e7f6ee; --select-bg: #c3e2d2; }
html[data-accent="purple"] { --brand: #6d4fd0; --brand-strong: #573cb0; --brand-weak: #efeafd; --select-bg: #d3caf1; }
html[data-accent="red"] { --brand: #c4362f; --brand-strong: #a02a24; --brand-weak: #fbe9e8; --select-bg: #edc3c1; }
html[data-theme="dark"][data-accent="teal"], html[data-theme="graphite"][data-accent="teal"], html[data-theme="deep-ocean"][data-accent="teal"] { --brand: #2fc2c2; --brand-strong: #1fa3a3; --brand-weak: #123a3a; --select-bg: #1b5560; }
html[data-theme="dark"][data-accent="green"], html[data-theme="graphite"][data-accent="green"], html[data-theme="deep-ocean"][data-accent="green"] { --brand: #3ec98a; --brand-strong: #2ba86f; --brand-weak: #123127; --select-bg: #20574d; }
html[data-theme="dark"][data-accent="purple"], html[data-theme="graphite"][data-accent="purple"], html[data-theme="deep-ocean"][data-accent="purple"] { --brand: #a08cf0; --brand-strong: #826fdc; --brand-weak: #291f45; --select-bg: #454676; }
html[data-theme="dark"][data-accent="red"], html[data-theme="graphite"][data-accent="red"], html[data-theme="deep-ocean"][data-accent="red"] { --brand: #ef6a63; --brand-strong: #d64a43; --brand-weak: #3a1c1f; --select-bg: #633942; }

.noscript { padding: 40px; text-align: center; font-size: calc(16px + var(--fs-bump)); }

/* ==========================================================================
   全局可搜索下拉（core/combo.js 自动升级原生 select）
   平台约定：所有下拉均支持手工填写 / 下拉选择 / 模糊查询 / 精确查询已有项
   ========================================================================== */
.tg-combo { position: relative; display: inline-block; vertical-align: middle; }
.tg-combo-input { width: 100%; }
.tg-combo-input::placeholder { color: var(--text-3); }
.tg-combo-list {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 1200;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); max-height: 260px; overflow: auto; padding: 2px;
}
.tg-combo-opt { padding: 6px 10px; font-size: calc(13px + var(--fs-bump)); line-height: 1.5; cursor: pointer; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-combo-opt:hover, .tg-combo-opt.hover { background: var(--brand-weak); }
.tg-combo-opt.active { color: var(--brand); font-weight: 600; }
.tg-combo-opt.disabled { color: var(--text-3); cursor: not-allowed; }
.tg-combo-empty { padding: 8px 10px; font-size: calc(12px + var(--fs-bump)); color: var(--text-3); }

/* ==========================================================================
   统一弹窗日期时间选择器（core/datetime-picker.js）
   所有日期/时间字段统一使用弹窗日历，禁止手动输入
   ========================================================================== */
.dtp-panel {
  position: fixed; z-index: 10000;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 12px; width: 280px;
  font-size: calc(13px + var(--fs-bump)); user-select: none;
}
.dtp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dtp-nav {
  background: none; border: none; color: var(--text-2); cursor: pointer;
  width: 28px; height: 28px; border-radius: var(--radius-sm); font-size: calc(14px + var(--fs-bump));
  display: flex; align-items: center; justify-content: center;
}
.dtp-nav:hover { background: var(--surface-3); color: var(--text); }
.dtp-title { font-weight: 600; font-size: calc(14px + var(--fs-bump)); color: var(--text); }
.dtp-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.dtp-week span { text-align: center; color: var(--text-3); font-size: calc(12px + var(--fs-bump)); padding: 4px 0; }
.dtp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dtp-cell {
  background: none; border: none; color: var(--text); cursor: pointer;
  height: 30px; border-radius: var(--radius-sm); font-size: calc(13px + var(--fs-bump));
  display: flex; align-items: center; justify-content: center;
}
.dtp-cell:hover { background: var(--brand-weak); }
.dtp-cell-other { color: var(--text-3); }
.dtp-cell-today { color: var(--brand); font-weight: 600; }
.dtp-cell-sel { background: var(--brand); color: #fff; }
.dtp-cell-sel:hover { background: var(--brand-strong); }
.dtp-time {
  display: flex; align-items: center; gap: 6px; margin-top: 10px;
  padding-top: 10px; border-top: 1px solid var(--border);
}
.dtp-time-label { color: var(--text-2); font-size: calc(12px + var(--fs-bump)); }
.dtp-time-sel {
  padding: 4px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: calc(13px + var(--fs-bump));
}
.dtp-foot { display: flex; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.dtp-btn {
  flex: 1; padding: 6px 0; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-2); cursor: pointer; font-size: calc(12px + var(--fs-bump));
}
.dtp-btn:hover { background: var(--surface-3); }
.dtp-btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.dtp-btn-primary:hover { background: var(--brand-strong); }

/* ---------- 流程详情弹窗：概览矩阵 / 自适应表格（随内容自动扩展，不截断） ---------- */
.bpm-detail-meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.bpm-detail-meta-item {
  display: flex; flex-direction: column; gap: 5px; min-width: 0;
  padding: 10px 14px; background: var(--surface-2);
}
.bpm-detail-meta-item .k { font-size: calc(11.5px + var(--fs-bump)); color: var(--text-3); letter-spacing: .3px; }
.bpm-detail-meta-item .v {
  font-size: calc(13.5px + var(--fs-bump)); font-weight: 600; color: var(--text);
  line-height: 1.4; overflow-wrap: anywhere;
}
.bpm-detail-meta-item .tag { align-self: flex-start; }
.bpm-detail-wrap {
  margin-top: 8px; border: 1px solid var(--border); border-radius: 10px;
  overflow: auto; background: var(--surface); box-shadow: var(--shadow-sm);
}
.bpm-detail-table {
  width: 100%; table-layout: auto; border-collapse: separate; border-spacing: 0;
  font-size: calc(13px + var(--fs-bump));
}
.bpm-detail-table.is-form { min-width: 420px; }
.bpm-detail-table.is-tasks { min-width: 760px; }
.bpm-detail-table thead th {
  position: sticky; top: 0; z-index: 1;
  padding: 10px 14px; text-align: left; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
  font-weight: 600; font-size: calc(12px + var(--fs-bump)); letter-spacing: .3px;
  border-bottom: 1px solid var(--border-strong);
}
.bpm-detail-table tbody td {
  padding: 10px 14px; color: var(--text); vertical-align: top; line-height: 1.6;
  border-bottom: 1px solid var(--border); overflow-wrap: anywhere;
}
.bpm-detail-table tbody tr:last-child td { border-bottom: 0; }
.bpm-detail-table tbody tr:nth-child(even) td { background: var(--surface-2); }
/* 表单内容表：首列字段名定宽浅底，内容列自适应扩展 */
.bpm-detail-table.is-form tbody td:first-child {
  width: 1%; white-space: nowrap;
  color: var(--text-3); font-weight: 500; background: var(--surface-3);
}
.bpm-detail-table tbody tr:hover td { background: var(--brand-weak); }
.bpm-detail-table .col-num { width: 46px; text-align: center; color: var(--text-3); }
.bpm-detail-empty {
  margin-top: 8px; padding: 18px; text-align: center;
  border: 1px dashed var(--border-strong); border-radius: 10px;
  color: var(--text-3); font-size: calc(12.5px + var(--fs-bump)); background: var(--surface-2);
}
