/* =================================================================
   智能MES系统 - 专业级设计系统
   基于 Ant Design 5 设计语言 + 现代 B2B SaaS 范式
   ================================================================= */

/* ---------- 1. 设计令牌（Design Tokens）---------- */
:root {
  /* 品牌色 - 工业化深蓝，更专业 */
  --brand-50:  #eff5ff;
  --brand-100: #dbe7ff;
  --brand-200: #b8d1ff;
  --brand-300: #8eb3ff;
  --brand-400: #5b8aff;
  --brand-500: #2f6bff;   /* 主品牌色 */
  --brand-600: #1b4fd6;
  --brand-700: #143aa3;
  --brand-800: #102b78;
  --brand-900: #0a1d52;

  /* 中性色 - 更精致的灰阶 */
  --gray-25:  #fcfcfd;
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* 功能色 */
  --success-50:  #ecfdf5;
  --success-100: #d1fae5;
  --success-500: #10b981;
  --success-600: #059669;
  --success-700: #047857;

  --warning-50:  #fffbeb;
  --warning-100: #fef3c7;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #b45309;

  --danger-50:   #fef2f2;
  --danger-100:  #fee2e2;
  --danger-500:  #ef4444;
  --danger-600:  #dc2626;
  --danger-700:  #b91c1c;

  --info-50:  #ecfeff;
  --info-500: #06b6d4;
  --info-600: #0891b2;

  /* 语义令牌 */
  --bg:           #f5f7fa;
  --bg-soft:      #f9fafb;
  --bg-elevated:  #ffffff;
  --side-bg:      #0f172a;        /* 深色侧边栏 */
  --side-bg-2:    #1e293b;
  --side-text:    #94a3b8;
  --side-text-2:  #cbd5e1;
  --side-active:  #1e3a8a;
  --side-brand:   #1e6fff;

  --card:         #ffffff;
  --line:         #e5e7eb;
  --line-soft:    #f3f4f6;
  --line-strong:  #d1d5db;

  --txt:          #111827;
  --txt-2:        #4b5563;
  --sub:          #6b7280;
  --subtle:       #9ca3af;
  --link:         #1e6fff;
  --link-hover:   #143aa3;

  /* 阴影 - 4 级层次 */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.06), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --shadow-2xl: 0 25px 50px -12px rgba(15, 23, 42, 0.18);

  /* 圆角 */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 14px;
  --r-2xl: 18px;
  --r-full: 9999px;

  /* 字体 */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", Consolas, "Courier New", monospace;

  /* 动画 */
  --t-fast: 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  --t:      0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- 2. 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--txt);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea, button { font: inherit; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }
::selection { background: var(--brand-200); color: var(--brand-900); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
.hidden { display: none !important; }

/* ---------- 3. 登录页 - 品牌化分屏设计 ---------- */
.login-view {
  position: fixed; inset: 0; display: flex;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #1e6fff 100%);
  overflow: hidden;
  z-index: 9999;
}
.login-view::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    radial-gradient(at 20% 30%, rgba(30, 111, 255, 0.35) 0px, transparent 50%),
    radial-gradient(at 80% 70%, rgba(6, 182, 212, 0.25) 0px, transparent 50%);
  pointer-events: none;
}
.login-view::after {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  mask-image: linear-gradient(180deg, transparent 0%, black 30%, black 70%, transparent 100%);
}
.login-wrap {
  position: relative; z-index: 1;
  display: flex; width: 100%; min-height: 100vh;
  align-items: center; justify-content: center; padding: 32px;
}
.login-brand-side {
  flex: 1; max-width: 560px; padding: 0 48px; color: #fff;
}
.login-brand-side .lb-logo {
  display: flex; align-items: center; gap: 14px; margin-bottom: 32px;
}
.login-brand-side .lb-mark {
  width: 52px; height: 52px; border-radius: var(--r-lg);
  background: linear-gradient(135deg, var(--brand-500), #06b6d4);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; color: #fff;
  box-shadow: 0 8px 24px rgba(30, 111, 255, 0.5);
}
.login-brand-side .lb-name {
  font-size: 20px; font-weight: 700; letter-spacing: 0.5px;
}
.login-brand-side .lb-tag {
  font-size: 12px; color: rgba(255,255,255,0.6); margin-top: 2px;
}
.login-brand-side .lb-title {
  font-size: 38px; font-weight: 700; line-height: 1.25; margin: 24px 0 16px;
  background: linear-gradient(90deg, #fff, #93c5fd);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-brand-side .lb-desc {
  font-size: 15px; color: rgba(255,255,255,0.75); line-height: 1.7;
  margin-bottom: 36px;
}
.login-brand-side .lb-features {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
}
.login-brand-side .lb-feat {
  display: flex; gap: 10px; align-items: flex-start;
}
.login-brand-side .lb-feat .ic {
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.login-brand-side .lb-feat .tt { font-size: 13px; font-weight: 600; color: #fff; }
.login-brand-side .lb-feat .dd { font-size: 12px; color: rgba(255,255,255,0.6); margin-top: 2px; }

.login-card {
  width: 420px; flex-shrink: 0;
  background: #fff; border-radius: var(--r-xl);
  padding: 40px 36px; box-shadow: var(--shadow-2xl);
  position: relative; overflow: hidden;
}
.login-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--brand-500), #06b6d4, #10b981);
}
.login-card .lc-title {
  font-size: 22px; font-weight: 700; color: var(--gray-900);
  margin-bottom: 4px;
}
.login-card .lc-sub {
  color: var(--sub); font-size: 13px; margin-bottom: 28px;
}
.login-card .field { margin-bottom: 20px; }
.login-card label {
  display: block; font-size: 12px; color: var(--gray-700);
  margin-bottom: 10px; font-weight: 500;
}
.login-card input::placeholder {
  color: #b0b8c4;
  font-size: 13px;
  opacity: 1;
}
.login-card .input-wrap {
  position: relative;
}
.login-card .input-wrap .ic {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--subtle); font-size: 16px; pointer-events: none;
}
.login-card input {
  width: 100%; padding: 13px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--r-md);
  font-size: 14px; line-height: 1.4;
  outline: none; transition: all var(--t-fast);
  background: var(--gray-25);
}
.login-card input:hover { border-color: var(--gray-300); }
.login-card input:focus {
  border-color: var(--brand-500);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(30, 111, 255, 0.12);
}
.login-err {
  color: var(--danger-600); font-size: 12px; min-height: 18px; margin-top: 4px;
  display: flex; align-items: center; gap: 4px;
}
.login-err:empty { display: none; }
.login-card button[type=submit] {
  width: 100%; margin-top: 8px; padding: 12px;
  border: none; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  color: #fff; font-size: 15px; font-weight: 600;
  box-shadow: 0 4px 12px rgba(30, 111, 255, 0.3);
  transition: all var(--t-fast);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.login-card button[type=submit]:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(30, 111, 255, 0.4);
}
.login-card button[type=submit]:active:not(:disabled) { transform: translateY(0); }
.login-card button[type=submit]:disabled { opacity: 0.6; cursor: wait; }
.login-card .lc-tip {
  margin-top: 20px; padding-top: 18px;
  border-top: 1px dashed var(--gray-200);
  font-size: 12px; color: var(--sub); text-align: center;
  line-height: 1.6;
}
.login-card .lc-tip strong { color: var(--gray-700); font-weight: 600; }

/* 未登录时强制隐藏主框架，防止任何内容透出 */
body:not(.is-logged-in) .app-view,
body:not(.is-logged-in) .drawer,
body:not(.is-logged-in) .drawer-mask,
body:not(.is-logged-in) .toast { display: none !important; }

/* 小屏：卡片独占，顶部显示品牌徽标 */
.login-card .lc-brand-m {
  display: none;
  align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 22px;
}
.login-card .lc-brand-m .m-mark {
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--brand-500), #06b6d4);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; font-weight: 700;
}
.login-card .lc-brand-m .m-name {
  font-size: 17px; font-weight: 700; color: var(--gray-900);
}

@media (max-width: 1100px) {
  .login-brand-side { display: none; }
  .login-wrap { padding: 24px; }
  .login-card {
    width: 100%; max-width: 480px; padding: 36px 32px;
  }
  .login-card .lc-brand-m { display: flex; }
}

@media (max-width: 520px) {
  .login-wrap { padding: 16px; align-items: flex-start; padding-top: 8vh; }
  .login-card { padding: 28px 22px; border-radius: var(--r-lg); }
  .login-card .lc-title { font-size: 20px; }
}

/* ---------- 4. 主框架 ---------- */
.app-view { display: flex; height: 100%; }

/* 侧边栏 - 现代深色风格 */
.sidebar {
  width: 232px; background: var(--side-bg);
  display: flex; flex-direction: column;
  transition: width var(--t); overflow: hidden;
  position: relative; z-index: 10;
}
.app-view.collapsed .sidebar { width: 0; }
.sidebar::after {
  content: ''; position: absolute; top: 0; right: 0; bottom: 0;
  width: 1px; background: rgba(255,255,255,0.04);
}
.side-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  white-space: nowrap;
  background: linear-gradient(180deg, rgba(30,111,255,0.08), transparent);
}
.side-brand .logo {
  width: 36px; height: 36px; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--brand-500), #06b6d4);
  color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(30, 111, 255, 0.35);
}
.side-brand-txt .b1 {
  color: #fff; font-weight: 700; font-size: 15px; letter-spacing: 0.3px;
}
.side-brand-txt .b2 {
  font-size: 11px; color: var(--side-text);
  margin-top: 2px; letter-spacing: 0.5px;
}
.side-menu { flex: 1; overflow-y: auto; padding: 12px 0 24px; }
.side-menu::-webkit-scrollbar { width: 4px; }
.side-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); }

.menu-group { margin: 4px 0; }
.menu-group-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 22px;
  font-size: 13.5px; letter-spacing: 0.5px;
  color: #94a3b8; font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  border-radius: 0;
  margin: 0;
  transition: all var(--t-fast);
  user-select: none;
}
.menu-group-title:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
}
.menu-group-title .arrow {
  font-size: 11px;
  opacity: 0.6;
  transition: transform var(--t-fast);
}
.menu-group-title .gic {
  display: inline-block;
  width: 22px;
  text-align: center;
  margin-right: 9px;
  font-size: 16px;
  opacity: 0.9;
  flex-shrink: 0;
}
.menu-group-title .gtitle {
  display: flex;
  align-items: center;
}
.menu-group-items {
  overflow: hidden;
  max-height: 800px;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 1;
}
.menu-group.collapsed .menu-group-items {
  max-height: 0;
  opacity: 0;
}
.menu-group.collapsed .menu-group-title .arrow {
  transform: rotate(-90deg);
}
.menu-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 22px; font-size: 14px;
  color: var(--side-text-2); cursor: pointer;
  white-space: nowrap; border-left: 3px solid transparent;
  transition: all var(--t-fast); position: relative;
}
.menu-item:hover {
  background: rgba(255,255,255,0.04);
  color: #fff;
}
.menu-item.active {
  background: linear-gradient(90deg, rgba(30, 111, 255, 0.15), transparent);
  color: #fff;
  border-left-color: var(--side-brand);
  font-weight: 600;
}
.menu-item.active::after {
  content: ''; position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--brand-400);
  box-shadow: 0 0 8px var(--brand-400);
}
.menu-item .ic {
  width: 20px; text-align: center; font-size: 16px; flex-shrink: 0;
  opacity: 0.9;
}
.menu-group-title .gic,
.menu-item .ic,
.topnav-item .ic,
.top-act .ic,
.gs-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 主区 */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar {
  height: 52px; background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center;
  padding: 0 20px; gap: 14px;
  position: sticky; top: 0; z-index: 5;
  box-shadow: none;
}
.menu-toggle {
  background: none; border: none; font-size: 18px;
  color: var(--sub); padding: 6px; border-radius: var(--r-sm);
  transition: all var(--t-fast);
}
.menu-toggle:hover { background: var(--gray-100); color: var(--txt); }
.crumb {
  font-size: 16px; font-weight: 600; color: var(--gray-800);
  display: flex; align-items: center; gap: 6px;
}
.crumb::before {
  content: ''; display: inline-block;
  width: 3px; height: 14px; background: var(--brand-500);
  border-radius: 2px; margin-right: 6px;
}
.spacer { flex: 1; }
.top-user {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 3px;
  background: var(--gray-50); border: 1px solid var(--line);
  font-size: 13px; color: var(--txt-2);
}
.top-user .avatar {
  width: 22px; height: 22px; border-radius: 3px;
  background: var(--brand-600);
  color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.logout-btn {
  border: 1px solid var(--line); background: #fff;
  border-radius: var(--r-md); padding: 7px 14px;
  font-size: 13px; color: var(--sub);
  transition: all var(--t-fast);
}
.logout-btn:hover { border-color: var(--danger-500); color: var(--danger-600); background: var(--danger-50); }

/* ---------- 顶部全局搜索 ---------- */
.gs-wrap { position: relative; display: flex; align-items: center; }
.gs-ic { position: absolute; left: 11px; font-size: 13px; opacity: .6; pointer-events: none; }
.gs-input {
  width: 240px; height: 32px; padding: 0 12px 0 30px;
  border: 1px solid var(--line); border-radius: 3px;
  background: var(--gray-50); color: var(--txt);
  font-size: 13px; outline: none; transition: all var(--t-fast);
}
.gs-input:focus { border-color: var(--brand-500); background: #fff; box-shadow: none; width: 280px; }
.gs-panel {
  position: absolute; top: 44px; left: 0; right: 0; min-width: 280px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 30; max-height: 360px; overflow: auto;
}
.gs-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: var(--r-sm);
  cursor: pointer; font-size: 13px;
}
.gs-item:hover { background: var(--brand-50); }
.gs-g { font-size: 11px; color: var(--sub); background: var(--gray-100); padding: 2px 7px; border-radius: var(--r-full); }
.gs-l { color: var(--txt); font-weight: 500; }
.gs-empty { padding: 14px; text-align: center; color: var(--sub); font-size: 13px; }

/* ---------- 顶部「我的应用」横向滚动条 ---------- */
.top-myapps {
  display: flex; align-items: center; gap: 8px;
  flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; padding: 2px 4px;
  position: relative;
  mask-image: linear-gradient(90deg, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 10px, #000 calc(100% - 10px), transparent 100%);
}
.top-myapps::-webkit-scrollbar { display: none; }
.top-myapps.empty { display: none; }
.top-app-chip {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 5px 10px; border-radius: 3px;
  background: var(--gray-50); border: 1px solid var(--line);
  font-size: 13px; color: var(--txt-2); white-space: nowrap; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.top-app-chip:hover { background: var(--gray-100); border-color: var(--line-strong); color: var(--txt); }
.top-app-chip .ic { display: inline-flex; align-items: center; color: var(--sub); }
.top-app-chip:hover .ic { color: var(--brand-600); }
.top-app-more {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  min-width: 42px; height: 28px; padding: 0 8px; border-radius: 3px;
  background: var(--gray-50); border: 1px solid var(--line);
  color: var(--txt-2); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: background .12s; flex-shrink: 0;
}
.top-app-more:hover { background: var(--gray-100); border-color: var(--line-strong); }
.top-app-scroll {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 34px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: #fff; color: var(--sub);
  font-size: 16px; cursor: pointer; flex-shrink: 0; transition: all var(--t-fast);
}
.top-app-scroll:hover { background: var(--brand-50); color: var(--brand-600); border-color: var(--brand-300); }
.top-app-scroll.hidden { display: none; }
.top-app-popover {
  position: absolute; top: 46px; right: 0;
  min-width: 240px; max-width: 320px; max-height: 360px; overflow: auto;
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); z-index: 40; padding: 12px;
}
.top-app-popover-head {
  font-size: 13px; font-weight: 700; color: var(--gray-800);
  padding: 0 4px 10px; border-bottom: 1px solid var(--line-soft);
  margin-bottom: 10px;
}
.top-app-popover-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.top-app-popover-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px; border-radius: var(--r-md);
  cursor: pointer; transition: all var(--t-fast); text-align: center;
}
.top-app-popover-item:hover { background: var(--brand-50); }
.top-app-popover-item .ic { display: inline-flex; align-items: center; color: var(--sub); }
.top-app-popover-item .tt {
  font-size: 12px; color: var(--gray-700); max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

body.dark-theme .top-app-chip {
  background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.1); color: #cbd5e1;
}
body.dark-theme .top-app-chip:hover {
  background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.18); color: #e2e8f0;
}
body.dark-theme .top-app-more {
  background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.1); color: #cbd5e1;
}
body.dark-theme .top-app-popover {
  background: var(--card); border-color: var(--line);
}
body.dark-theme .top-app-popover-head { color: #e2e8f0; border-bottom-color: var(--line); }
body.dark-theme .top-app-popover-item:hover { background: rgba(255,255,255,0.05); }
body.dark-theme .top-app-popover-item .tt { color: #cbd5e1; }

/* ---------- 顶部动作按钮 ---------- */
.top-act {
  display: inline-flex; align-items: center; gap: 5px;
  height: 32px; padding: 0 12px; border-radius: 3px;
  border: 1px solid var(--line); background: #fff; color: var(--txt-2);
  font-size: 13px; cursor: pointer; transition: background .12s, border-color .12s; white-space: nowrap;
}
.top-act:hover { border-color: var(--line-strong); color: var(--txt); background: var(--gray-50); }
.top-act .ic { font-size: 15px; }
.top-act.ai {
  background: var(--brand-600); border-color: var(--brand-600); color: #fff; font-weight: 500;
}
.top-act.ai:hover { background: var(--brand-700); border-color: var(--brand-700); color: #fff; }

.content {
  flex: 1; overflow: auto; padding: 24px;
  position: relative;
}

/* ---------- 5. 卡片网格 - 现代化数据卡片 ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 20px;
  transition: all var(--t-fast); position: relative; overflow: hidden;
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  border-color: var(--brand-200);
}
.card .k {
  font-size: 13px; color: var(--sub); font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.card .v {
  font-size: 30px; font-weight: 700; margin-top: 8px;
  color: var(--gray-900); line-height: 1.2;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}
.card .d {
  font-size: 12px; margin-top: 8px; color: var(--subtle);
}
.card .ic {
  position: absolute; right: 16px; top: 16px;
  width: 36px; height: 36px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; opacity: 0.95;
}
.v.ok { color: var(--success-600); }
.v.warn { color: var(--warning-600); }
.v.bad { color: var(--danger-600); }

/* =================================================================
   应用市场 / 应用软件 — 参考飞书/钉钉/SaaS 应用市场设计
   ================================================================= */

/* ───── Hero 头部：标题 + 搜索 ───── */
.am-hero {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; margin-bottom: 22px; flex-wrap: wrap;
}
.am-hero-left h2 {
  font-size: 22px; font-weight: 700; color: var(--gray-900);
  margin: 0 0 6px 0;
}
.am-subtitle {
  font-size: 14px; color: var(--gray-500);
}
.am-search-box {
  position: relative; display: flex; align-items: center;
  min-width: 320px; max-width: 420px; flex: 1;
}
.am-search-ic {
  position: absolute; left: 12px; display: inline-flex; align-items: center;
  color: var(--gray-400); pointer-events: none;
}
.am-search-input {
  width: 100%; height: 34px; padding: 0 12px 0 34px;
  border: 1px solid var(--line); border-radius: 3px;
  background: #fff; color: var(--txt);
  font-size: 13px; outline: none; transition: border-color .12s;
}
.am-search-input:hover { border-color: var(--gray-400); }
.am-search-input:focus { border-color: var(--brand-500); }

/* ───── 我的应用面板 ───── */
.am-installed-panel {
  background: #fff; border: 1px solid var(--line); border-radius: 4px;
  padding: 16px 18px 18px; margin-bottom: 20px;
}
.am-section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.am-section-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 700; color: var(--gray-900);
}
.am-sec-icon { display: inline-flex; align-items: center; color: var(--gray-500); }
.am-sec-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 18px; padding: 0 6px;
  border-radius: 2px;
  background: var(--gray-100); color: var(--gray-600);
  font-size: 11px; font-weight: 600;
}
.am-text-btn {
  background: transparent; border: none; color: var(--brand-600);
  font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 8px;
  border-radius: var(--r-sm); transition: all var(--t-fast);
}
.am-text-btn:hover { background: var(--brand-50); }
.am-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}
.am-quick-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 13px 8px; border-radius: 3px;
  background: #fff; border: 1px solid var(--line);
  cursor: pointer; transition: border-color .12s, background .12s; text-align: center;
}
.am-quick-card:hover { background: var(--gray-25); border-color: var(--gray-400); }
.am-quick-icon {
  width: 38px; height: 38px; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; background: var(--gray-50); border: 1px solid var(--line-soft);
  color: var(--gray-700);
}
.am-quick-name {
  font-size: 13px; font-weight: 500; color: var(--gray-800);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.am-quick-cat {
  font-size: 11px; color: var(--gray-400); margin-top: -4px;
}

/* ───── 分类筛选栏 ───── */
.am-cat-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.am-tabs {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.am-tab {
  cursor: pointer; padding: 5px 12px; border-radius: 3px;
  font-size: 13px; user-select: none; transition: background .12s, color .12s, border-color .12s;
  background: #fff; color: var(--gray-600);
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line);
}
.am-tab:hover { background: var(--gray-50); color: var(--gray-800); border-color: var(--gray-400); }
.am-tab.active {
  background: var(--brand-50); color: var(--brand-700); font-weight: 600;
  border-color: var(--brand-300);
}
.am-tab-count {
  font-size: 11px; font-weight: 600; color: var(--gray-500);
  padding: 0; background: none;
}
.am-tab.active .am-tab-count { background: none; color: var(--brand-600); }
.am-result-count {
  font-size: 13px; color: var(--gray-500); white-space: nowrap;
}

/* ───── 应用卡片网格 ───── */
.am-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.am-card {
  background: #fff;
  border-radius: 4px;
  border: 1px solid var(--line);
  transition: border-color .12s ease, box-shadow .12s ease;
  display: flex; flex-direction: column;
  overflow: hidden; cursor: default;
}
.am-card:hover {
  border-color: var(--gray-400);
}
.am-card.am-installed {
  border-left: 2px solid var(--success-500);
}
.am-card.am-installed:hover { cursor: pointer; }
.am-card-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 16px 16px 12px;
}
.am-card-icon {
  width: 40px; height: 40px; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; background: var(--gray-50); border: 1px solid var(--line-soft);
  color: var(--gray-700);
}
.am-card-status {
  display: flex; align-items: center; justify-content: center;
}
.am-check {
  padding: 1px 6px; border-radius: 2px;
  background: #ecfdf5; color: var(--success-600);
  border: 1px solid #a7f3d0;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
}
.am-card-body {
  flex: 1; padding: 0 18px 16px;
}
.am-card-title {
  font-size: 15.5px; font-weight: 700; color: var(--gray-900);
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.am-card-badge {
  font-size: 10px; font-weight: 600;
  padding: 2px 6px; border-radius: 2px;
  background: #ecfdf5; color: var(--success-600); border: 1px solid #a7f3d0;
}
.am-card-desc {
  font-size: 13px; color: var(--gray-500); line-height: 1.65;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.am-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 13px 18px; border-top: 1px solid var(--line-soft);
  background: var(--gray-25);
}
.am-card-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.am-card-tags span,
.am-card-cat {
  font-size: 11px; font-weight: 500;
  padding: 2px 7px; border-radius: 2px;
  background: #f3f4f6; color: #6b7280; border: 1px solid var(--line-soft);
}
.am-card-cat.premium { background: #eff6ff; color: var(--brand-600); }
.am-card-cat.ext { background: #f5f3ff; color: #7c3aed; border-color: #ddd6fe; }
.am-card-badge.ext { background: #f5f3ff; color: #7c3aed; border-color: #ddd6fe; }
/* 外部专业软件卡片：左侧品牌色条 + 玻璃质感 */
.am-card.am-ext {
  border-left: 3px solid var(--ext-color, #7c3aed);
  background: linear-gradient(180deg, #fff 0%, #faf9ff 100%);
}
.am-card.am-ext .am-card-icon {
  background: #fff; border-color: var(--line-soft);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.am-card.am-ext:hover { box-shadow: 0 6px 20px rgba(124,58,237,.12); }
.am-ext-tag {
  padding: 1px 6px; border-radius: 2px;
  background: #f5f3ff; color: #7c3aed; border: 1px solid #ddd6fe;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
}
/* 品牌 logo（simple-icons 真实 SVG） */
.am-brand-svg { display: block; width: 24px; height: 24px; }
/* 无 logo 时用品牌色首字母占位 */
.am-brand-fallback {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 4px;
  color: #fff; font-weight: 700; font-size: 13px; line-height: 1;
}
.am-card-btn {
  font-size: 13px; font-weight: 500;
  padding: 5px 14px; border-radius: 3px;
  border: 1px solid transparent; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s; white-space: nowrap; flex-shrink: 0;
}
.am-card-btn.primary {
  background: var(--brand-600); color: #fff; border-color: var(--brand-600);
}
.am-card-btn.primary:hover { background: var(--brand-600); }
.am-card-btn.open {
  background: #fff; color: var(--gray-700);
  border-color: var(--line);
}
.am-card-btn.open:hover { background: var(--gray-50); border-color: var(--brand-300); color: var(--brand-600); }

/* ───── 分页 ───── */
.am-pager {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 26px 0 6px;
}
.am-pg-btn {
  min-width: 28px; height: 28px; padding: 0 8px;
  border-radius: 3px; border: 1px solid var(--line);
  background: #fff; color: var(--gray-600);
  font-size: 13px; cursor: pointer; transition: border-color .12s, background .12s;
}
.am-pg-btn:hover { border-color: var(--gray-400); color: var(--gray-800); background: var(--gray-50); }
.am-pg-btn.active {
  background: var(--brand-600); color: #fff; border-color: var(--brand-600);
  font-weight: 600;
}
.am-pg-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ───── 空状态 ───── */
.am-empty-state {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 20px; text-align: center;
}
.am-empty-icon { margin-bottom: 12px; color: var(--gray-300); display: flex; }

/* 线性图标统一表现（应用市场 / 侧栏 / 顶部） */
.am-quick-icon svg, .am-card-icon svg, .am-sec-icon svg, .am-search-ic svg { display: block; }
.am-card-icon svg { width: 22px; height: 22px; }
.am-quick-icon svg { width: 20px; height: 20px; }
.am-empty-title { font-size: 16px; font-weight: 600; color: var(--gray-800); margin-bottom: 6px; }
.am-empty-desc { font-size: 13px; color: var(--gray-500); }

/* ───── 抽屉内应用网格 ───── */
.am-drawer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px; padding: 4px;
}

/* ───── 深色主题覆盖 ───── */
body.dark-theme .am-hero-left h2 { color: #f1f5f9; }
body.dark-theme .am-subtitle { color: #94a3b8; }
body.dark-theme .am-search-box .am-search-input {
  background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.12);
  color: #f1f5f9; box-shadow: none;
}
body.dark-theme .am-search-box .am-search-input:hover { border-color: rgba(255,255,255,0.2); }
body.dark-theme .am-search-box .am-search-input:focus {
  border-color: var(--brand-400); background: rgba(255,255,255,0.08); box-shadow: none;
}
body.dark-theme .am-installed-panel {
  background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.1);
}
body.dark-theme .am-section-title { color: #f1f5f9; }
body.dark-theme .am-sec-count { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
body.dark-theme .am-text-btn { color: #93c5fd; }
body.dark-theme .am-text-btn:hover { background: rgba(59, 130, 246, 0.12); }
body.dark-theme .am-quick-card {
  background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.1);
}
body.dark-theme .am-quick-card:hover {
  background: rgba(255,255,255,0.08); border-color: rgba(59, 130, 246, 0.45);
}
body.dark-theme .am-quick-name { color: #e2e8f0; }
body.dark-theme .am-quick-cat { color: #94a3b8; }
body.dark-theme .am-tab {
  background: rgba(255,255,255,0.04); color: #cbd5e1; border-color: rgba(255,255,255,0.12);
}
body.dark-theme .am-tab:hover { background: rgba(255,255,255,0.09); color: #f1f5f9; border-color: rgba(255,255,255,0.22); }
body.dark-theme .am-tab.active { background: rgba(59,130,246,0.16); color: #bfdbfe; border-color: rgba(59,130,246,0.45); }
body.dark-theme .am-tab-count { color: #94a3b8; }
body.dark-theme .am-quick-icon,
body.dark-theme .am-card-icon { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.1); color: rgba(255,255,255,0.82); }
body.dark-theme .am-check { background: rgba(16,185,129,.12); color: #6ee7b7; border-color: rgba(16,185,129,.35); }
body.dark-theme .am-result-count { color: #94a3b8; }
body.dark-theme .am-card {
  background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.1);
}
body.dark-theme .am-card:hover {
  border-color: rgba(255,255,255,0.25); box-shadow: none;
}
body.dark-theme .am-card-title { color: #f1f5f9; }
body.dark-theme .am-card-badge { background: rgba(16, 185, 129, 0.12); color: #6ee7b7; }
body.dark-theme .am-card-desc { color: #94a3b8; }
body.dark-theme .am-card-foot {
  background: rgba(255,255,255,0.03);
  border-top-color: rgba(255,255,255,0.08);
}
body.dark-theme .am-card-tags span,
body.dark-theme .am-card-cat {
  background: rgba(255,255,255,0.08); color: #cbd5e1;
}
body.dark-theme .am-card-cat.premium { background: rgba(59, 130, 246, 0.12); color: #93c5fd; }
body.dark-theme .am-card-btn.open {
  background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.12); color: #cbd5e1;
}
body.dark-theme .am-card-btn.open:hover {
  background: rgba(59, 130, 246, 0.12); border-color: rgba(59, 130, 246, 0.35); color: #93c5fd;
}
body.dark-theme .am-pg-btn {
  background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.1); color: #cbd5e1;
}
body.dark-theme .am-pg-btn:hover { background: rgba(59, 130, 246, 0.12); border-color: rgba(59, 130, 246, 0.35); color: #93c5fd; }
body.dark-theme .am-pg-btn.active { background: var(--brand-500); color: #fff; border-color: var(--brand-500); }
body.dark-theme .am-empty-title { color: #e2e8f0; }
body.dark-theme .am-empty-desc { color: #94a3b8; }

/* ---------- 6. 面板/工具栏 - 现代化 ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 0;
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.panel-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.panel-title {
  font-size: 15px; font-weight: 600; color: var(--gray-800);
  display: flex; align-items: center; gap: 8px;
}
.panel-title::before {
  content: ''; display: inline-block;
  width: 3px; height: 14px; background: var(--brand-500);
  border-radius: 2px;
}
.panel-body { padding: 0; }

.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px; padding: 14px 16px;
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.toolbar input[type=text],
.toolbar input[type=search] {
  padding: 8px 12px 8px 34px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  font-size: 13px; min-width: 240px; outline: none;
  background: var(--gray-25) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/></svg>") no-repeat 12px center;
  transition: all var(--t-fast);
}
.toolbar input[type=text]:focus,
.toolbar input[type=search]:focus {
  border-color: var(--brand-500);
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(30, 111, 255, 0.1);
}
.toolbar input:hover { border-color: var(--line-strong); }
.toolbar .stat {
  margin-left: auto;
  color: var(--sub); font-size: 12px;
  display: flex; align-items: center; gap: 4px;
}
.toolbar .stat strong { color: var(--gray-800); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 7. 按钮 - 扁平化现代风格 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border: 1.5px solid var(--line);
  background: #fff; border-radius: var(--r-md);
  font-size: 13px; color: var(--gray-700); font-weight: 500;
  transition: all var(--t-fast);
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--brand-400);
  color: var(--brand-600);
  background: var(--brand-50);
}
.btn:active { transform: scale(0.98); }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: var(--r-sm); }
.btn.lg { padding: 10px 20px; font-size: 14px; }
.btn.primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  color: #fff; border-color: transparent;
  box-shadow: 0 2px 6px rgba(30, 111, 255, 0.25);
}
.btn.primary:hover {
  background: linear-gradient(135deg, var(--brand-400), var(--brand-500));
  color: #fff; box-shadow: 0 4px 10px rgba(30, 111, 255, 0.35);
  transform: translateY(-1px);
}
.btn.success { background: var(--success-500); color: #fff; border-color: transparent; }
.btn.success:hover { background: var(--success-600); color: #fff; }
.btn.warn { background: var(--warning-500); color: #fff; border-color: transparent; }
.btn.warn:hover { background: var(--warning-600); color: #fff; }
.btn.danger {
  border-color: var(--danger-200);
  color: var(--danger-600);
  background: #fff;
}
.btn.danger:hover {
  background: var(--danger-500);
  color: #fff; border-color: var(--danger-500);
}
.btn.ghost { background: transparent; border-color: rgba(255,255,255,0.18); color: rgba(255,255,255,0.85); }
.btn.ghost:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* 表格内操作按钮组 - 更精致 */
.tbl-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.tbl-actions .btn {
  padding: 3px 9px; font-size: 12px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--brand-600);
  border-radius: var(--r-sm);
}
.tbl-actions .btn:hover {
  background: var(--brand-50);
  border-color: var(--brand-200);
}
.tbl-actions .btn.danger { color: var(--danger-600); }
.tbl-actions .btn.danger:hover { background: var(--danger-50); border-color: var(--danger-200); }
.tbl-actions .btn.warn { color: var(--warning-600); }
.tbl-actions .btn.warn:hover { background: var(--warning-50); border-color: var(--warning-200); }
.tbl-actions .btn.success { color: var(--success-600); }
.tbl-actions .btn.success:hover { background: var(--success-50); border-color: var(--success-200); }

/* ---------- 8. 表格 - 现代化数据表 ---------- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 14px;
}
thead th {
  color: var(--gray-600); font-weight: 600; font-size: 13px;
  text-transform: none; letter-spacing: 0.2px;
  background: var(--gray-50);
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1;
  white-space: nowrap;
}
thead th:first-child { border-top-left-radius: 0; padding-left: 22px; }
thead th:last-child  { border-top-right-radius: 0; }
tbody td {
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--line-soft);
  color: var(--gray-700);
  white-space: nowrap;
  vertical-align: middle;
}
tbody td:first-child { padding-left: 22px; }
tbody td:last-child  { padding-right: 16px; }
tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: var(--brand-50); }
tbody tr:hover td { color: var(--gray-800); }
tbody tr:last-child td { border-bottom: none; }

/* 表格内文字颜色 */
tbody td.td-id { color: var(--gray-500); font-family: var(--font-mono); font-size: 12px; }
tbody td.td-amount,
tbody td.td-num { font-variant-numeric: tabular-nums; font-weight: 500; color: var(--gray-800); }
tbody td.td-amount { color: var(--gray-900); }

/* 状态标签 - 精致圆角徽标 */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--r-sm);
  font-size: 12px; font-weight: 500;
  background: var(--gray-100); color: var(--gray-600);
  white-space: nowrap;
}
.tag::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.7;
}
.tag.ok {
  background: var(--success-50); color: var(--success-700);
}
.tag.ok::before { background: var(--success-500); }
.tag.warn {
  background: var(--warning-50); color: var(--warning-700);
}
.tag.warn::before { background: var(--warning-500); }
.tag.bad {
  background: var(--danger-50); color: var(--danger-700);
}
.tag.bad::before { background: var(--danger-500); }
.tag.info {
  background: var(--info-50); color: var(--info-600);
}
.tag.info::before { background: var(--info-500); }
.tag.brand {
  background: var(--brand-50); color: var(--brand-700);
}
.tag.brand::before { background: var(--brand-500); }
.tag.plain { padding: 2px 8px; }
.tag.plain::before { display: none; }

/* 分页 */
.pager {
  display: flex; gap: 6px; align-items: center;
  padding: 14px 22px; font-size: 13px; color: var(--sub);
  border-top: 1px solid var(--line-soft);
  background: var(--gray-25);
}
.pager .pager-info { margin-right: auto; }
.pager input {
  width: 50px; padding: 5px 8px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  text-align: center; font-size: 12px;
  outline: none;
}
.pager input:focus { border-color: var(--brand-500); }

/* ---------- 9. 抽屉 - 现代化右滑面板 ---------- */
.drawer-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  z-index: 40;
  animation: fadeIn var(--t);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%;
  width: 520px; max-width: 92vw;
  background: #fff; z-index: 50;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-2xl);
  animation: slideInRight var(--t-slow);
}
.drawer-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--gray-25);
}
.drawer-head .dh-title {
  font-size: 15px; font-weight: 600; color: var(--gray-800);
  display: flex; align-items: center; gap: 8px;
}
.drawer-head .dh-title::before {
  content: ''; display: inline-block;
  width: 3px; height: 14px; background: var(--brand-500);
  border-radius: 2px;
}
.drawer-close {
  background: transparent; border: none;
  width: 28px; height: 28px; border-radius: var(--r-sm);
  color: var(--sub); font-size: 18px; line-height: 1;
  transition: all var(--t-fast);
}
.drawer-close:hover { background: var(--gray-100); color: var(--gray-800); }
.drawer-body { flex: 1; overflow: auto; padding: 22px 24px; }

/* ───── 统一表单样式（修复零代码/抽屉内表单元素裸奔）───── */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 16px;
}
.form-row label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 2px;
}
.inp,
.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="date"],
.form-row input[type="datetime-local"],
.form-row input[type="password"],
.form-row input[type="email"],
.form-row textarea,
.form-row select {
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--gray-900);
  background: #fff;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--r-md);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  box-sizing: border-box;
}
.inp:focus,
.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(30, 111, 255, 0.12);
}
.inp::placeholder,
.form-row input::placeholder,
.form-row textarea::placeholder {
  color: var(--gray-400);
  font-size: 13px;
}
.form-row textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}
.form-row select {
  appearance: auto;
  background-color: #fff;
}
.form-row input[type="checkbox"] {
  width: auto;
  min-height: auto;
  transform: scale(1.2);
  margin: 4px 0;
}

/* 兼容部分视图把 label 和 input 写在一行内的内联用法 */
label.form-row {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.drawer-foot {
  padding: 14px 24px; border-top: 1px solid var(--line);
  display: flex; gap: 10px; justify-content: flex-end;
  background: var(--gray-25);
}

/* 表单字段 */
.field { margin-bottom: 16px; }
.field > label {
  display: block; font-size: 12px; color: var(--gray-700);
  margin-bottom: 6px; font-weight: 500;
}
.field > label .req { color: var(--danger-500); margin-left: 2px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  font-size: 13px; outline: none;
  background: #fff; color: var(--gray-800);
  font-family: inherit; transition: all var(--t-fast);
}
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--line-strong); }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(30, 111, 255, 0.1);
}
.field textarea { min-height: 80px; resize: vertical; }
.field .hint { font-size: 11px; color: var(--subtle); margin-top: 4px; }

.kv {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 10px 0; border-bottom: 1px dashed var(--line-soft);
  font-size: 13px;
}
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--sub); flex-shrink: 0; }
.kv .v { text-align: right; word-break: break-all; max-width: 60%; color: var(--gray-800); font-weight: 500; }

/* ---------- 10. Toast 通知 - 现代化 ---------- */
.toast {
  position: fixed; bottom: 32px; left: 50%;
  transform: translateX(-50%);
  background: var(--gray-800); color: #fff;
  padding: 11px 22px; border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
  z-index: 99;
  box-shadow: var(--shadow-xl);
  display: flex; align-items: center; gap: 8px;
  animation: toastIn var(--t-slow);
  max-width: 90vw;
}
@keyframes toastIn { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.toast::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--gray-400);
}
.toast.ok { background: var(--success-700); }
.toast.ok::before { background: var(--success-500); box-shadow: 0 0 6px var(--success-500); }
.toast.bad { background: var(--danger-700); }
.toast.bad::before { background: var(--danger-500); box-shadow: 0 0 6px var(--danger-500); }
.toast.warn { background: var(--warning-700); }
.toast.warn::before { background: var(--warning-500); }

/* ---------- 11. 通用工具 ---------- */
.section-title {
  font-size: 16px; font-weight: 600; color: var(--gray-800);
  margin: 6px 0 14px; display: flex; align-items: center; gap: 8px;
}
.section-title::before {
  content: ''; display: inline-block;
  width: 3px; height: 16px; background: var(--brand-500);
  border-radius: 2px;
}
.section-sub { font-size: 12px; color: var(--sub); margin: -8px 0 14px 11px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.muted { color: var(--sub); } .dim { color: var(--subtle); }
.text-success { color: var(--success-600); } .text-warn { color: var(--warning-600); } .text-bad { color: var(--danger-600); } .text-brand { color: var(--brand-600); }
.text-right { text-align: right; } .text-center { text-align: center; }
.flex1 { flex: 1; }
.empty {
  padding: 60px 20px; text-align: center; color: var(--sub);
  font-size: 13px;
}
.empty .ic { font-size: 32px; opacity: 0.4; margin-bottom: 8px; display: block; }

/* 骨架屏 */
.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.4s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* 加载旋转 */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner.dark {
  border-color: rgba(30, 111, 255, 0.2);
  border-top-color: var(--brand-500);
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .two, .three { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
  .toolbar input { min-width: 180px; }
}

/* ---------- 12. 数据驾驶舱（深色模式）---------- */
.content.dark-dashboard {
  background:
    radial-gradient(at 10% 0%, rgba(30, 111, 255, 0.15) 0px, transparent 50%),
    radial-gradient(at 90% 100%, rgba(6, 182, 212, 0.12) 0px, transparent 50%),
    #141d2e;
  color: #e8ecf3;
  min-height: 100%;
}
.content.dark-dashboard::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}
.content.dark-dashboard .section-title { color: #fff; }
.content.dark-dashboard .section-sub { color: #94a3b8; }
.content.dark-dashboard .section-title::before { background: linear-gradient(180deg, var(--brand-400), #06b6d4); }
.content.dark-dashboard .cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  position: relative; z-index: 1;
}
.content.dark-dashboard .card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-xl);
  padding: 24px 22px;
  backdrop-filter: blur(12px);
  position: relative; overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  transition: all var(--t);
}
.content.dark-dashboard .card:hover {
  border-color: rgba(30, 111, 255, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
.content.dark-dashboard .card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--brand-400), #06b6d4);
}
.content.dark-dashboard .card:nth-child(2n)::before { background: linear-gradient(90deg, #06b6d4, #10b981); }
.content.dark-dashboard .card:nth-child(3n)::before { background: linear-gradient(90deg, #10b981, var(--brand-400)); }
.content.dark-dashboard .card:nth-child(4n)::before { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.content.dark-dashboard .card .k { color: #94a3b8; font-size: 12px; font-weight: 500; }
.content.dark-dashboard .card .v {
  font-size: 36px; font-weight: 700; margin-top: 10px;
  background: linear-gradient(90deg, #fff, #93c5fd);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
  line-height: 1.1;
}
.content.dark-dashboard .card .d { color: #64748b; font-size: 11px; margin-top: 8px; }
.content.dark-dashboard .card .ic { opacity: 0.6; }

.content.dark-dashboard .panel {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--r-xl);
  backdrop-filter: blur(10px);
  position: relative; z-index: 1;
}
.content.dark-dashboard .panel-head { background: rgba(255, 255, 255, 0.02); border-bottom-color: rgba(255, 255, 255, 0.06); }
.content.dark-dashboard .panel-title { color: #fff; }
.content.dark-dashboard .panel-title::before { background: var(--brand-400); }

.content.dark-dashboard .toolbar {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
}
.content.dark-dashboard .toolbar input { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.1); color: #fff; }
.content.dark-dashboard .toolbar input:focus { border-color: var(--brand-400); background: rgba(255, 255, 255, 0.08); }
.content.dark-dashboard .toolbar .stat { color: #94a3b8; }

.content.dark-dashboard table thead th {
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1; border-bottom-color: rgba(255, 255, 255, 0.06);
}
.content.dark-dashboard table tbody td {
  border-bottom-color: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
}
.content.dark-dashboard table tbody tr:hover { background: rgba(255, 255, 255, 0.04); }
.content.dark-dashboard .pager { background: rgba(255, 255, 255, 0.02); border-top-color: rgba(255, 255, 255, 0.06); color: #94a3b8; }
.content.dark-dashboard .pager input { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.1); color: #fff; }

@media (max-width: 1100px) {
  .content.dark-dashboard .cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .content.dark-dashboard .cards { grid-template-columns: 1fr; }
}

/* =================================================================
   APS 智能排产甘特图
   ================================================================= */
.sc-card { overflow: auto; padding: 16px; }
.sc-wrap { position: relative; min-width: 980px; }
.sc-corner {
  position: absolute; left: 0; top: 0; height: 44px;
  background: var(--gray-50); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 14px;
  font-size: 12px; font-weight: 600; color: var(--gray-500);
  border-top-left-radius: var(--r-lg);
}
.sc-tick {
  position: absolute; top: 0; height: 44px;
  font-size: 12px; font-weight: 600; color: var(--gray-500);
  border-left: 1px solid var(--line); padding: 0 8px;
  display: flex; align-items: center; background: var(--gray-50);
  transform: translateX(-1px);
}
.sc-row-label {
  position: absolute; left: 0; height: 52px;
  background: var(--gray-50); border-right: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 14px;
  font-size: 14px; font-weight: 600; color: var(--gray-800);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sc-row-line {
  position: absolute; right: 0; height: 52px;
  border-top: 1px solid var(--line-soft);
}
.sc-bar {
  position: absolute; height: 38px; border-radius: 6px;
  opacity: .92; cursor: pointer; padding: 0 8px;
  display: flex; align-items: center; overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
  transition: transform .1s, opacity .1s, box-shadow .1s;
}
.sc-bar:hover { opacity: 1; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,.2); z-index: 2; }
.sc-bar-text {
  font-size: 12px; font-weight: 600; color: #fff;
  white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.sc-legend {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px;
  margin: 10px 0; font-size: 13px; color: var(--sub);
}
.sc-legend-title { font-weight: 700; color: var(--txt); margin-right: 4px; }
.sc-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 8px; }
.sc-legend-stat { margin-left: auto; color: var(--subtle); }
.sc-empty { padding: 40px 24px; text-align: center; color: var(--sub); font-size: 14px; }

/* 深色主题 APS */
body.dark-theme .sc-corner { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1); color: #94a3b8; }
body.dark-theme .sc-tick { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1); color: #94a3b8; }
body.dark-theme .sc-row-label { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.1); color: #e2e8f0; }
body.dark-theme .sc-row-line { border-top-color: rgba(255,255,255,.06); }
body.dark-theme .sc-bar { box-shadow: 0 2px 8px rgba(0,0,0,.35); }
body.dark-theme .sc-bar:hover { box-shadow: 0 6px 18px rgba(0,0,0,.45); }
body.dark-theme .sc-legend-title { color: #f1f5f9; }
body.dark-theme .sc-empty { color: #94a3b8; }

@media (max-width: 900px) {
  .sc-legend-stat { width: 100%; margin-left: 0; margin-top: 4px; }
}

/* 业务动作弹窗（如下达计划选包装组） */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 14px; padding: 22px 22px 18px;
  width: 92%; max-width: 380px; box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  animation: modalIn .18s ease;
}
@keyframes modalIn { from { transform: translateY(12px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-title { font-size: 15px; font-weight: 600; color: #1e293b; margin-bottom: 14px; }
.modal-select {
  width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px;
  font-size: 14px; color: #1e293b; background: #f8fafc; outline: none; cursor: pointer;
}
.modal-select:focus { border-color: #2563eb; background: #fff; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* =================================================================
   13. 全局深色主题 — body.dark-theme（所有页面默认深色）
   覆盖 顶部栏 / 按钮 / 表单 / 抽屉 / 弹窗 / 标签 / 表格 / 分页 等
   ================================================================= */

/* --- 基础 --- */
body.dark-theme {
  background: #141d2e;
  color: #e2e8f0;            /* 深色主题默认文字提亮，避免未被具体类覆盖的文字在深底上不可见 */

  /* 重定义全部语义变量：深色模式下让所有使用 --gray-* / --txt / --sub 的组件自动可读 */
  --gray-25:  rgba(255, 255, 255, 0.03);
  --gray-50:  rgba(255, 255, 255, 0.06);
  --gray-100: rgba(255, 255, 255, 0.10);
  --gray-200: rgba(255, 255, 255, 0.14);
  --gray-300: rgba(255, 255, 255, 0.20);
  --gray-400: #94a3b8;
  --gray-500: #cbd5e1;
  --gray-600: #e2e8f0;
  --gray-700: #f1f5f9;
  --gray-800: #f8fafc;
  --gray-900: #ffffff;

  --bg:           #141d2e;
  --bg-soft:      #1a2436;
  --bg-elevated:  #1f2a3e;
  --card:         #1f2a3e;
  --line:         rgba(255, 255, 255, 0.12);
  --line-soft:    rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.18);

  --txt:          #f1f5f9;
  --txt-2:        #e2e8f0;
  --sub:          #cbd5e1;
  --subtle:       #94a3b8;
  --link:         #93c5fd;
  --link-hover:   #bfdbfe;
}
body.dark-theme .main {
  background: #141d2e;
}
body.dark-theme .content {
  background: #141d2e;
}

/* --- 顶部栏 --- */
body.dark-theme .topbar {
  background: rgba(15, 23, 42, 0.92);
  border-bottom-color: rgba(255, 255, 255, 0.06);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
}
body.dark-theme .menu-toggle {
  color: #64748b;
}
body.dark-theme .menu-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e8ecf3;
}
body.dark-theme .crumb {
  color: #e8ecf3;
}
body.dark-theme .crumb::before {
  background: var(--brand-400);
}
body.dark-theme .top-user {
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
}
body.dark-theme .logout-btn {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
}
body.dark-theme .logout-btn:hover {
  border-color: #ef4444;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.08);
}

/* --- 顶部栏（深色主题） --- */
body.dark-theme .gs-input { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.12); color: #f1f5f9; }
body.dark-theme .gs-input:focus { background: rgba(255, 255, 255, 0.1); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25); }
body.dark-theme .gs-panel { background: #0f172a; border-color: rgba(255, 255, 255, 0.1); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
body.dark-theme .gs-item:hover { background: rgba(255, 255, 255, 0.06); }
body.dark-theme .gs-g { background: rgba(255, 255, 255, 0.08); color: #94a3b8; }
body.dark-theme .gs-l { color: #e2e8f0; }
body.dark-theme .top-app-chip { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.12); color: #cbd5e1; }
body.dark-theme .top-app-chip:hover { background: rgba(59, 130, 246, 0.18); border-color: rgba(59, 130, 246, 0.5); color: #93c5fd; }
body.dark-theme .top-act { background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.12); color: #cbd5e1; }
body.dark-theme .top-act:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.18); color: #e2e8f0; }
body.dark-theme .top-act.ai { background: var(--brand-700); border-color: var(--brand-600); }

/* --- 按钮 --- */
body.dark-theme .btn {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
}
body.dark-theme .btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--brand-400);
  color: #93c5fd;
}
body.dark-theme .btn.primary {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  color: #fff;
  border-color: transparent;
}
body.dark-theme .btn.primary:hover {
  background: linear-gradient(135deg, var(--brand-400), var(--brand-500));
  color: #fff;
}
body.dark-theme .btn.success {
  background: var(--success-500);
  color: #fff;
  border-color: transparent;
}
body.dark-theme .btn.success:hover { background: var(--success-600); color: #fff; }
body.dark-theme .btn.warn {
  background: var(--warning-500);
  color: #fff;
  border-color: transparent;
}
body.dark-theme .btn.warn:hover { background: var(--warning-600); color: #fff; }
body.dark-theme .btn.danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
}
body.dark-theme .btn.danger:hover {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}
body.dark-theme .btn.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.85);
}
body.dark-theme .btn.ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* 表格内操作按钮 */
body.dark-theme .tbl-actions .btn {
  background: transparent;
  border-color: transparent;
  color: var(--brand-300);
}
body.dark-theme .tbl-actions .btn:hover {
  background: rgba(30, 111, 255, 0.1);
  border-color: rgba(30, 111, 255, 0.2);
  color: #93c5fd;
}
body.dark-theme .tbl-actions .btn.danger { color: #fca5a5; }
body.dark-theme .tbl-actions .btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
}
body.dark-theme .tbl-actions .btn.warn { color: #fcd34d; }
body.dark-theme .tbl-actions .btn.warn:hover {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.2);
}
body.dark-theme .tbl-actions .btn.success { color: #6ee7b7; }
body.dark-theme .tbl-actions .btn.success:hover {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.2);
}

/* --- 工具栏 --- */
body.dark-theme .toolbar {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
body.dark-theme .toolbar input[type=text],
body.dark-theme .toolbar input[type=search] {
  background: rgba(255, 255, 255, 0.05) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/></svg>") no-repeat 12px center;
  border-color: rgba(255, 255, 255, 0.1);
  color: #e8ecf3;
}
body.dark-theme .toolbar input[type=text]:focus,
body.dark-theme .toolbar input[type=search]:focus {
  border-color: var(--brand-400);
  background-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(30, 111, 255, 0.15);
}
body.dark-theme .toolbar input:hover {
  border-color: rgba(255, 255, 255, 0.18);
}
body.dark-theme .toolbar .stat {
  color: #94a3b8;
}
body.dark-theme .toolbar .stat strong {
  color: #e8ecf3;
}

/* --- 面板 --- */
body.dark-theme .panel {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
body.dark-theme .panel-head {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}
body.dark-theme .panel-title {
  color: #e8ecf3;
}
body.dark-theme .panel-title::before {
  background: var(--brand-400);
}

/* --- 表格 --- */
body.dark-theme table thead th {
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  border-bottom-color: rgba(255, 255, 255, 0.06);
}
body.dark-theme table tbody td {
  border-bottom-color: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
}
body.dark-theme table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}
body.dark-theme table tbody tr:hover td {
  color: #e8ecf3;
}
body.dark-theme tbody td.td-id {
  color: #94a3b8;
}
body.dark-theme tbody td.td-amount,
body.dark-theme tbody td.td-num {
  color: #e8ecf3;
}

/* --- 分页 --- */
body.dark-theme .pager {
  background: rgba(255, 255, 255, 0.02);
  border-top-color: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
}
body.dark-theme .pager input {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #e8ecf3;
}
body.dark-theme .pager input:focus {
  border-color: var(--brand-400);
}

/* --- 表单 --- */
body.dark-theme .field > label {
  color: #94a3b8;
}
body.dark-theme .field input,
body.dark-theme .field select,
body.dark-theme .field textarea {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #e8ecf3;
}
body.dark-theme .field input:focus,
body.dark-theme .field select:focus,
body.dark-theme .field textarea:focus {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(30, 111, 255, 0.15);
}
body.dark-theme .field input:hover,
body.dark-theme .field select:hover,
body.dark-theme .field textarea:hover {
  border-color: rgba(255, 255, 255, 0.18);
}
body.dark-theme .field .hint {
  color: #64748b;
}
body.dark-theme .field input::placeholder,
body.dark-theme .field textarea::placeholder {
  color: #64748b;
}

/* 抽屉/弹窗内统一表单（零代码新增记录等）在深色主题下的可读性 */
body.dark-theme .form-row label {
  color: #cbd5e1;
  font-weight: 500;
}
body.dark-theme .form-row label .required,
body.dark-theme .form-row label [required] {
  color: #fca5a5;
}
body.dark-theme .inp,
body.dark-theme .form-row input[type="text"],
body.dark-theme .form-row input[type="number"],
body.dark-theme .form-row input[type="date"],
body.dark-theme .form-row input[type="datetime-local"],
body.dark-theme .form-row input[type="password"],
body.dark-theme .form-row input[type="email"],
body.dark-theme .form-row textarea,
body.dark-theme .form-row select {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}
body.dark-theme .inp:hover,
body.dark-theme .form-row input:hover,
body.dark-theme .form-row textarea:hover,
body.dark-theme .form-row select:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.07);
}
body.dark-theme .inp:focus,
body.dark-theme .form-row input:focus,
body.dark-theme .form-row textarea:focus,
body.dark-theme .form-row select:focus {
  border-color: var(--brand-400);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 3px rgba(30, 111, 255, 0.18), inset 0 1px 2px rgba(0, 0, 0, 0.1);
}
body.dark-theme .inp::placeholder,
body.dark-theme .form-row input::placeholder,
body.dark-theme .form-row textarea::placeholder {
  color: #64748b;
}
body.dark-theme .form-row select {
  background-color: rgba(255, 255, 255, 0.05);
}
body.dark-theme .form-row select option {
  background: #1e293b;
  color: #e8ecf3;
}

/* --- 抽屉 --- */
body.dark-theme .drawer-mask {
  background: rgba(0, 0, 0, 0.6);
}
body.dark-theme .drawer {
  background: #111827;
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.55);
}
body.dark-theme .drawer-head {
  background: rgba(15, 23, 42, 0.9);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}
body.dark-theme .drawer-head .dh-title {
  color: #e8ecf3;
}
body.dark-theme .drawer-head .dh-title::before {
  background: var(--brand-400);
}
body.dark-theme .drawer-close {
  color: #94a3b8;
}
body.dark-theme .drawer-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e8ecf3;
}
body.dark-theme .drawer-body {
  color: #cbd5e1;
}
body.dark-theme .drawer-foot {
  background: rgba(15, 23, 42, 0.9);
  border-top-color: rgba(255, 255, 255, 0.08);
}

/* --- 弹窗 --- */
body.dark-theme .modal-overlay {
  background: rgba(0, 0, 0, 0.65);
}
body.dark-theme .modal {
  background: #1e293b;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
body.dark-theme .modal-title {
  color: #e8ecf3;
}
body.dark-theme .modal-select {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #e8ecf3;
}
body.dark-theme .modal-select:focus {
  border-color: var(--brand-400);
  background: rgba(255, 255, 255, 0.08);
}

/* --- 标签（Tag）--- */
body.dark-theme .tag {
  background: rgba(255, 255, 255, 0.06);
  color: #94a3b8;
}
body.dark-theme .tag.ok {
  background: rgba(16, 185, 129, 0.1);
  color: #6ee7b7;
}
body.dark-theme .tag.ok::before { background: var(--success-500); }
body.dark-theme .tag.warn {
  background: rgba(245, 158, 11, 0.1);
  color: #fcd34d;
}
body.dark-theme .tag.warn::before { background: var(--warning-500); }
body.dark-theme .tag.bad {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
}
body.dark-theme .tag.bad::before { background: var(--danger-500); }
body.dark-theme .tag.info {
  background: rgba(6, 182, 212, 0.1);
  color: #67e8f9;
}
body.dark-theme .tag.info::before { background: var(--info-500); }
body.dark-theme .tag.brand {
  background: rgba(30, 111, 255, 0.12);
  color: #93c5fd;
}
body.dark-theme .tag.brand::before { background: var(--brand-500); }

/* --- KV 展示 --- */
body.dark-theme .kv {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}
body.dark-theme .kv .k { color: #94a3b8; }
body.dark-theme .kv .v { color: #f1f5f9; font-weight: 500; }
body.dark-theme .kv .k {
  color: #94a3b8;
}
body.dark-theme .kv .v {
  color: #e8ecf3;
}

/* --- 章节标题 --- */
body.dark-theme .section-title {
  color: #e8ecf3;
}
body.dark-theme .section-title::before {
  background: var(--brand-400);
}
body.dark-theme .section-sub {
  color: #94a3b8;
}

/* --- 空状态 --- */
body.dark-theme .empty {
  color: #64748b;
}
body.dark-theme .empty .ic {
  opacity: 0.3;
}

/* --- 骨架屏 --- */
body.dark-theme .skeleton {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.04) 75%);
}

/* --- 滚动条 --- */
body.dark-theme::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
}
body.dark-theme::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}
body.dark-theme ::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
}
body.dark-theme ::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* --- 文本辅助 --- */
body.dark-theme .muted { color: #cbd5e1; }
body.dark-theme .dim { color: #94a3b8; }
body.dark-theme .text-success { color: #6ee7b7; }
body.dark-theme .text-warn { color: #fcd34d; }
body.dark-theme .text-bad { color: #fca5a5; }
body.dark-theme .text-brand { color: #93c5fd; }

/* --- 链接 --- */
body.dark-theme a { color: #93c5fd; }
body.dark-theme a:hover { color: #bfdbfe; }

/* --- 文本选中 --- */
body.dark-theme ::selection {
  background: rgba(30, 111, 255, 0.25);
  color: #bfdbfe;
}

/* --- 加载旋转 --- */
body.dark-theme .spinner.dark {
  border-color: rgba(147, 197, 253, 0.2);
  border-top-color: #93c5fd;
}

/* --- 深色主题可读性兜底：表格/卡片内所有文字强制可见 --- */
body.dark-theme table tbody td,
body.dark-theme table tbody td > *,
body.dark-theme table tbody td span,
body.dark-theme table tbody td div,
body.dark-theme table tbody td small,
body.dark-theme table tbody td em,
body.dark-theme table tbody td i,
body.dark-theme table tbody td strong,
body.dark-theme table tbody td b,
body.dark-theme table tbody td a {
  color: #e2e8f0;
}
body.dark-theme table tbody td .tag:not(.ok):not(.warn):not(.bad):not(.info):not(.brand) {
  color: #e2e8f0 !important;
  background: rgba(255, 255, 255, 0.08);
}
body.dark-theme table tbody td .tag.ok,
body.dark-theme table tbody td .tag.warn,
body.dark-theme table tbody td .tag.bad,
body.dark-theme table tbody td .tag.info,
body.dark-theme table tbody td .tag.brand {
  color: inherit !important;
}
body.dark-theme table tbody tr:hover td,
body.dark-theme table tbody tr:hover td > * {
  color: #f8fafc;
}

/* =================================================================
   全部应用 — 把应用市场卡片设计语言推广到系统菜单分组
   ================================================================= */
.ac-group { margin-bottom: 30px; }
.ac-group:last-child { margin-bottom: 6px; }
.ac-group .am-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.ac-card { cursor: pointer; }
body.dark-theme .ac-card:hover { border-color: rgba(59, 130, 246, 0.45); }

/* ---------- AI 助手面板 ---------- */
.ai-panel {
  position: fixed; right: 18px; bottom: 78px; width: 460px; max-width: 94vw;
  height: 600px; max-height: 86vh; background: #fff; color: var(--txt);
  border-radius: 16px; box-shadow: 0 18px 60px rgba(0,0,0,.28);
  z-index: 9999; display: none; flex-direction: column; overflow: hidden;
  font-size: 13px; border: 1px solid var(--line);
}
.ai-panel.open { display: flex; }
.ai-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #1e6fff, #5b8dff); color: #fff;
}
.ai-logo { font-size: 20px; }
.ai-head strong { font-size: 15px; }
.ai-sub { font-size: 11px; opacity: 0.85; margin-left: 4px; }
.ai-flex { flex: 1; }
.ai-select {
  border: none; border-radius: 6px; padding: 4px 8px; font-size: 12px;
  background: rgba(255,255,255,.2); color: #fff; outline: none;
}
.ai-select option { color: #222; }
.ai-close {
  background: rgba(255,255,255,.2); border: none; color: #fff;
  border-radius: 6px; width: 26px; height: 26px; cursor: pointer; font-size: 18px; line-height: 1;
}
.ai-tabs {
  display: flex; border-bottom: 1px solid var(--line); background: var(--gray-25);
}
.ai-tab {
  flex: 1; text-align: center; padding: 10px; cursor: pointer;
  font-size: 13px; color: var(--sub); transition: all .15s;
}
.ai-tab.active { color: var(--brand-600); font-weight: 700; box-shadow: inset 0 -2px 0 var(--brand-500); }
.ai-body { flex: 1; display: flex; overflow: hidden; }
.ai-sessions {
  width: 130px; border-right: 1px solid var(--line); overflow: auto; padding: 8px; background: var(--gray-25);
}
.ai-sess-hd { font-size: 11px; color: var(--sub); margin-bottom: 8px; font-weight: 600; }
.ai-sess-new {
  padding: 6px; border-radius: 6px; cursor: pointer; color: var(--brand-600);
  font-weight: 600; font-size: 12px; margin-bottom: 6px;
}
.ai-sess-new:hover { background: var(--brand-50); }
.ai-sess-item {
  padding: 6px; border-radius: 6px; cursor: pointer; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--txt-2);
}
.ai-sess-item:hover { background: var(--gray-100); }
.ai-sess-err { color: var(--danger-500); font-size: 12px; }
.ai-chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.ai-msgs { flex: 1; overflow: auto; padding: 12px; }
.ai-empty { padding: 40px 20px; text-align: center; color: var(--sub); font-size: 13px; }
.ai-err { color: var(--danger-600); }
.ai-bubble { display: flex; margin: 8px 0; }
.ai-bubble.left { justify-content: flex-start; }
.ai-bubble.right { justify-content: flex-end; }
.ai-bubble-inner {
  max-width: 82%; padding: 10px 12px; border-radius: 12px;
  white-space: pre-wrap; line-height: 1.55; font-size: 13px;
}
.ai-bubble.left .ai-bubble-inner { background: var(--gray-100); color: var(--txt); border-bottom-left-radius: 4px; }
.ai-bubble.right .ai-bubble-inner { background: var(--brand-500); color: #fff; border-bottom-right-radius: 4px; }
.ai-quick {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--line-soft);
}
.ai-chip {
  display: inline-flex; padding: 5px 10px; border-radius: 12px;
  background: var(--brand-50); color: var(--brand-700); font-size: 12px;
  border: 1px solid var(--brand-200); cursor: pointer; transition: all .12s;
}
.ai-chip:hover { background: var(--brand-100); border-color: var(--brand-300); }
.ai-inputbar {
  display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line);
}
.ai-input {
  flex: 1; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; outline: none; font-size: 13px; color: var(--txt);
}
.ai-input:focus { border-color: var(--brand-400); box-shadow: 0 0 0 3px var(--brand-100); }
.ai-send {
  padding: 9px 16px; border-radius: 10px; border: none; background: var(--brand-500); color: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: background .12s;
}
.ai-send:hover { background: var(--brand-600); }
.ai-send:disabled { opacity: 0.6; cursor: not-allowed; }
.ai-ask-hint { padding: 12px 14px 0; color: var(--sub); font-size: 12px; }
.ai-ask-bar { padding: 10px 14px; }
.ai-textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  outline: none; font-size: 13px; color: var(--txt); resize: none; margin-bottom: 8px;
}
.ai-textarea:focus { border-color: var(--brand-400); box-shadow: 0 0 0 3px var(--brand-100); }
.ai-qres { flex: 1; overflow: auto; padding: 0 14px 14px; }
.ai-loading { padding: 20px; text-align: center; color: var(--sub); }
.ai-summary { padding: 10px; background: var(--brand-50); border-radius: 8px; margin-bottom: 10px; color: var(--brand-800); }
.ai-sql-wrap { margin-bottom: 10px; }
.ai-sql-wrap summary { cursor: pointer; color: var(--brand-600); font-size: 12px; font-weight: 600; }
.ai-sql {
  background: var(--gray-100); padding: 10px; border-radius: 8px; overflow: auto;
  white-space: pre-wrap; font-size: 12px; color: var(--txt-2); margin-top: 6px;
}
.ai-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.ai-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ai-table th { background: var(--gray-50); padding: 8px 10px; text-align: left; font-weight: 600; border-bottom: 1px solid var(--line); }
.ai-table td { padding: 7px 10px; border-bottom: 1px solid var(--line-soft); }
.ai-table tr:last-child td { border-bottom: none; }
.ai-muted { color: var(--sub); font-size: 12px; padding: 4px 0; }

/* AI 浮窗按钮 */
.ai-fab {
  position: fixed; right: 18px; bottom: 18px; width: 54px; height: 54px;
  border-radius: 50%; border: none; background: linear-gradient(135deg, #1e6fff, #5b8dff);
  color: #fff; font-size: 24px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(30,111,255,.45); z-index: 9998;
}

/* 深色主题 AI 助手 */
body.dark-theme .ai-panel { background: #0f172a; border-color: rgba(255,255,255,.1); color: #e2e8f0; }
body.dark-theme .ai-tabs { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.1); }
body.dark-theme .ai-tab { color: #94a3b8; }
body.dark-theme .ai-tab.active { color: #93c5fd; box-shadow: inset 0 -2px 0 #1e6fff; }
body.dark-theme .ai-sessions { background: rgba(255,255,255,.03); border-color: rgba(255,255,255,.1); }
body.dark-theme .ai-sess-new:hover { background: rgba(30,111,255,.15); }
body.dark-theme .ai-sess-item { color: #cbd5e1; }
body.dark-theme .ai-sess-item:hover { background: rgba(255,255,255,.08); }
body.dark-theme .ai-bubble.left .ai-bubble-inner { background: rgba(255,255,255,.08); color: #e2e8f0; }
body.dark-theme .ai-input,
body.dark-theme .ai-textarea { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.12); color: #e2e8f0; }
body.dark-theme .ai-input:focus,
body.dark-theme .ai-textarea:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(30,111,255,.2); }
body.dark-theme .ai-chip { background: rgba(30,111,255,.12); border-color: rgba(30,111,255,.3); color: #93c5fd; }
body.dark-theme .ai-chip:hover { background: rgba(30,111,255,.2); }
body.dark-theme .ai-summary { background: rgba(30,111,255,.12); color: #bfdbfe; }
body.dark-theme .ai-sql { background: rgba(255,255,255,.05); color: #cbd5e1; }
body.dark-theme .ai-table th { background: rgba(255,255,255,.06); }
body.dark-theme .ai-table td,
body.dark-theme .ai-table th { border-color: rgba(255,255,255,.1); }
body.dark-theme .ai-table-wrap { border-color: rgba(255,255,255,.1); }
body.dark-theme .ai-quick,
body.dark-theme .ai-inputbar { border-color: rgba(255,255,255,.1); }

/* ---------- AI 配置页 ---------- */
.aic-wrap { display: flex; gap: 18px; margin-top: 16px; height: calc(100vh - 170px); min-height: 480px; }
.aic-list { width: 260px; min-width: 220px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: auto; padding: 10px; }
.aic-list-hd { font-size: 12px; font-weight: 700; color: var(--sub); padding: 8px 10px; letter-spacing: 0.5px; }
.aic-item { padding: 10px 12px; border-radius: var(--r-md); cursor: pointer; margin-bottom: 4px; transition: all .12s; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.aic-item:hover { background: var(--gray-50); }
.aic-item.active { background: var(--brand-50); border: 1px solid var(--brand-200); }
.aic-name { font-size: 13.5px; font-weight: 600; color: var(--txt); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aic-status { font-size: 11px; padding: 2px 8px; border-radius: 10px; flex-shrink: 0; white-space: nowrap; }
.aic-free { font-size: 10px; padding: 1px 5px; border-radius: 6px; background: var(--success-100); color: var(--success-700); flex-shrink: 0; white-space: nowrap; margin-left: auto; }
.aic-status.on { background: var(--success-100); color: var(--success-700); }
.aic-status.ready { background: var(--warn-100); color: var(--warn-700); }
.aic-status.off { background: var(--gray-100); color: var(--gray-500); }
.aic-detail { flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; overflow: auto; }
.aic-empty { color: var(--sub); text-align: center; padding-top: 80px; }
.aic-detail-hd { display: flex; align-items: center; justify-content: space-between; padding-bottom: 16px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.aic-detail-hd h3 { margin: 0; font-size: 18px; }
.aic-id { color: var(--sub); font-size: 12px; margin-left: 8px; }
.aic-toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 13px; }
.aic-toggle input { width: 38px; height: 20px; cursor: pointer; }
.aic-form { max-width: 600px; }
.aic-tip { font-size: 12px; color: var(--sub); margin-top: 6px; }
.aic-actions { display: flex; gap: 12px; margin: 20px 0; }
.aic-global { margin-top: 28px; padding-top: 22px; border-top: 1px dashed var(--line); }
.aic-global h4 { margin: 0 0 14px; font-size: 15px; }
.aic-global-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 560px; }
.aic-msg { margin-top: 12px; padding: 10px 14px; border-radius: var(--r-md); font-size: 13px; }
.aic-msg.ok { background: var(--success-50); color: var(--success-700); }
.aic-msg.err { background: var(--danger-50); color: var(--danger-700); }
.aic-plan { padding: 10px 12px; background: var(--gray-50); border-radius: var(--r-md); border: 1px dashed var(--line); line-height: 1.5; }
.aic-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0; align-items: center; }
.aic-form select#aic-model { width: 100%; max-width: 420px; }
.aic-form .aic-tip { margin-top: 6px; }
.aic-detail-hd .aic-toggle input { accent-color: var(--brand); }
.aic-alert { padding: 12px 16px; border-radius: var(--r-md); font-size: 13px; line-height: 1.6; margin: 0 0 16px; }
.aic-alert-warn { background: var(--warning-50); color: var(--warning-800); border: 1px solid var(--warning-200); }
body.dark-theme .aic-alert-warn { background: rgba(245,158,11,.12); color: #fbbf24; border-color: rgba(245,158,11,.35); }

/* ---------- AI 助手新版聊天 ---------- */
.ai-panel {
  position: fixed; right: 18px; bottom: 78px; width: 720px; max-width: 96vw;
  height: 640px; max-height: 88vh; background: var(--card); color: var(--txt);
  border-radius: 16px; box-shadow: 0 24px 80px rgba(0,0,0,.32);
  z-index: 9999; display: none; flex-direction: row; overflow: hidden;
  font-size: 13.5px; border: 1px solid var(--line);
}
.ai-panel.open { display: flex; }
.ai-sidebar { width: 200px; min-width: 180px; background: var(--gray-25); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.ai-side-hd { padding: 14px; border-bottom: 1px solid var(--line); }
.ai-new-btn { width: 100%; padding: 8px; border-radius: 10px; border: 1px dashed var(--brand-400); background: var(--brand-50); color: var(--brand-700); font-weight: 600; cursor: pointer; }
.ai-new-btn:hover { background: var(--brand-100); }
.ai-session-list { flex: 1; overflow: auto; padding: 8px; }
.ai-sess-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 12.5px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--txt-2); }
.ai-sess-item:hover { background: var(--gray-100); }
.ai-sess-item.active { background: var(--brand-100); color: var(--brand-800); font-weight: 600; }
.ai-sess-empty { color: var(--sub); font-size: 12px; padding: 20px 10px; text-align: center; }
.ai-side-ft { padding: 10px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.ai-side-ft .ai-select { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 12px; background: var(--card); color: var(--txt); }
.ai-config-btn { width: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); cursor: pointer; }
.ai-panel.ai-collapsed .ai-sidebar { display: none; }
.ai-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ai-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.ai-head-left { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; cursor: move; user-select: none; }
.ai-head-left:hover { opacity: .9; }
.ai-drag-dots { color: var(--subtle); font-size: 16px; letter-spacing: 2px; line-height: 1; opacity: .7; }
.ai-head-right { display: flex; gap: 6px; }
.ai-icon-btn { width: 30px; height: 30px; border-radius: 8px; border: none; background: transparent; color: var(--sub); cursor: pointer; font-size: 14px; }
.ai-icon-btn:hover { background: var(--gray-100); }
.ai-msgs { flex: 1; overflow: auto; padding: 16px; background: var(--bg); }
.ai-msg { display: flex; gap: 12px; margin-bottom: 18px; }
.ai-msg.user { flex-direction: row-reverse; }
.ai-avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--gray-100); font-size: 16px; flex-shrink: 0; }
.ai-msg.user .ai-avatar { background: var(--brand-500); }
.ai-content { max-width: 78%; min-width: 60px; }
.ai-role { font-size: 11px; color: var(--sub); margin-bottom: 4px; }
.ai-msg.user .ai-role { text-align: right; }
.ai-text { padding: 12px 14px; border-radius: 14px; line-height: 1.6; background: var(--card); border: 1px solid var(--line); color: var(--txt); }
.ai-msg.user .ai-text { background: var(--brand-500); color: #fff; border-color: var(--brand-500); }
.ai-text pre.ai-code { background: var(--gray-100); padding: 10px; border-radius: 8px; overflow: auto; font-size: 12px; margin: 8px 0; }
.ai-text code { background: var(--gray-100); padding: 2px 5px; border-radius: 4px; font-size: 12px; }
.ai-text ul { padding-left: 18px; margin: 6px 0; }
.ai-text strong { font-weight: 700; }
.ai-typing { color: var(--sub); }
.ai-welcome { text-align: center; padding: 50px 20px; color: var(--sub); }
.ai-welcome-logo { font-size: 48px; margin-bottom: 12px; }
.ai-welcome-title { font-size: 18px; font-weight: 700; color: var(--txt); margin-bottom: 8px; }
.ai-welcome-desc { font-size: 13.5px; margin-bottom: 12px; }
.ai-welcome-tip { font-size: 12.5px; background: var(--brand-50); color: var(--brand-700); display: inline-block; padding: 8px 14px; border-radius: 20px; }
.ai-quick { padding: 8px 16px; border-top: 1px solid var(--line); background: var(--card); display: flex; flex-wrap: wrap; gap: 8px; }
.ai-inputbar { display: flex; gap: 10px; padding: 12px 16px 16px; border-top: 1px solid var(--line); background: var(--card); align-items: flex-end; }
.ai-inputbar .ai-textarea { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; outline: none; font-size: 13.5px; color: var(--txt); resize: none; min-height: 24px; max-height: 120px; line-height: 1.5; }
.ai-inputbar .ai-textarea:focus { border-color: var(--brand-400); box-shadow: 0 0 0 3px var(--brand-100); }
.ai-send { width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--brand-500); color: #fff; font-size: 16px; cursor: pointer; transition: all .12s; display: flex; align-items: center; justify-content: center; }
.ai-send:hover { background: var(--brand-600); }
.ai-send:disabled { opacity: .5; cursor: not-allowed; }
.ai-card-btn { padding: 6px 14px; border-radius: 8px; border: 1px solid var(--brand-400); background: var(--brand-50); color: var(--brand-700); cursor: pointer; font-size: 12.5px; }
.ai-card-btn:hover { background: var(--brand-100); }

/* AI 浮窗按钮 */
.ai-fab {
  position: fixed; right: 18px; bottom: 18px; width: 54px; height: 54px;
  border-radius: 50%; border: none; background: linear-gradient(135deg, #1e6fff, #5b8dff);
  color: #fff; font-size: 24px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(30,111,255,.45); z-index: 9998;
}

/* AI 一句话建表 */
.am-ai-create { margin-top: 10px; padding: 5px 14px; border-radius: 3px; border: 1px solid var(--line); background: #fff; color: var(--gray-700); font-size: 13px; font-weight: 500; cursor: pointer; transition: background .12s, border-color .12s, color .12s; }
.am-ai-create:hover { background: var(--brand-50); border-color: var(--brand-300); color: var(--brand-700); }
.aitb-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; margin-top: 16px; max-width: 920px; }
.aitb-label { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.aitb-textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 14px; font-size: 14px; color: var(--txt); background: var(--bg); resize: vertical; min-height: 90px; }
.aitb-textarea:focus { border-color: var(--brand-400); box-shadow: 0 0 0 3px var(--brand-100); outline: none; }
.aitb-examples { margin-top: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.aitb-examples-label { color: var(--sub); font-size: 12px; }
.aitb-chip { padding: 5px 12px; border-radius: 14px; background: var(--brand-50); color: var(--brand-700); font-size: 12px; cursor: pointer; border: 1px solid var(--brand-200); }
.aitb-chip:hover { background: var(--brand-100); }
.aitb-actions { margin-top: 14px; }
.aitb-loading { margin-top: 18px; padding: 18px; background: var(--brand-50); border-radius: 10px; color: var(--brand-700); text-align: center; }
.aitb-err { margin-top: 18px; padding: 14px; background: var(--danger-50); color: var(--danger-700); border-radius: 10px; }
.aitb-design { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.aitb-design-hd { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; background: var(--gray-25); border-bottom: 1px solid var(--line); }
.aitb-title { font-size: 16px; font-weight: 700; }
.aitb-meta { font-size: 12px; color: var(--sub); margin-top: 4px; }
.aitb-desc { padding: 12px 18px; color: var(--txt-2); font-size: 13px; border-bottom: 1px solid var(--line); }
.aitb-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.aitb-tbl th { background: var(--gray-50); padding: 10px 12px; text-align: left; font-weight: 600; border-bottom: 1px solid var(--line); }
.aitb-tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.aitb-tbl tr:last-child td { border-bottom: none; }
.aitb-tag { display: inline-block; padding: 2px 8px; border-radius: 10px; background: var(--gray-100); color: var(--txt-2); font-size: 11px; margin-right: 6px; }
.aitb-formula { display: inline-block; padding: 2px 8px; border-radius: 10px; background: var(--brand-100); color: var(--brand-800); font-size: 11px; font-weight: 600; }
.aitb-placeholder { color: var(--sub); font-size: 11px; margin-top: 4px; }
.aitb-tpl { margin-top: 14px; }
.aitb-tpl-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.aitb-tpl-chip { background: var(--gray-100); color: var(--txt-2); border-color: var(--line); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aitb-tpl-chip:hover { background: var(--brand-50); color: var(--brand-700); }

/* Excel 公式速查面板 */
.aitb-funcs-panel { margin-top: 16px; max-width: 920px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; }
.aitb-funcs-hd { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.aitb-func-group { margin-bottom: 12px; }
.aitb-func-cat { font-size: 12px; font-weight: 700; color: var(--brand-700); margin-bottom: 6px; }
.aitb-func-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px 16px; }
.aitb-func { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; background: var(--gray-25); border: 1px solid var(--line-soft); border-radius: 10px; }
.aitb-func code { font-size: 12px; font-weight: 700; color: var(--brand-800); }
.aitb-func-desc { font-size: 12px; color: var(--txt-2); }
.aitb-func-eg { font-size: 11px; color: var(--sub); font-family: monospace; word-break: break-all; }

/* 零代码 formula 标记与只读 */
.nc-formula { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--brand-500); color: #fff; font-size: 10px; font-weight: 700; margin-left: 5px; vertical-align: middle; }

/* 深色主题 AI */
body.dark-theme .aic-list, body.dark-theme .aic-detail { background: #0f172a; border-color: rgba(255,255,255,.1); }
body.dark-theme .aic-item:hover { background: rgba(255,255,255,.06); }
body.dark-theme .aic-item.active { background: rgba(30,111,255,.18); border-color: rgba(30,111,255,.4); }
body.dark-theme .aic-sidebar { background: rgba(255,255,255,.03); border-color: rgba(255,255,255,.1); }
body.dark-theme .ai-sidebar { background: rgba(255,255,255,.03); border-color: rgba(255,255,255,.1); }
body.dark-theme .ai-msgs { background: rgba(0,0,0,.2); }
body.dark-theme .ai-text { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1); color: #e2e8f0; }
body.dark-theme .ai-msg.user .ai-text { background: var(--brand-600); border-color: var(--brand-600); }
body.dark-theme .ai-text pre.ai-code { background: rgba(0,0,0,.25); color: #e2e8f0; }
body.dark-theme .ai-text code { background: rgba(0,0,0,.25); }
body.dark-theme .ai-avatar { background: rgba(255,255,255,.08); }
body.dark-theme .ai-msg.user .ai-avatar { background: var(--brand-600); }
body.dark-theme .ai-inputbar .ai-textarea { background: rgba(255,255,255,.05); border-color: rgba(255,255,255,.12); color: #e2e8f0; }
body.dark-theme .ai-inputbar .ai-textarea:focus { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(30,111,255,.2); }
body.dark-theme .ai-icon-btn:hover { background: rgba(255,255,255,.08); }
body.dark-theme .ai-welcome-tip { background: rgba(30,111,255,.15); color: #93c5fd; }

