/* =====================================================================
   业务管理系统 · 设计系统 (Premium Web UI)
   作者: Senior Developer · 高级开发工程师
   特性: 明/暗/跟随系统 三态主题 · 玻璃拟态 · 磁吸交互 · 流畅动效
   ===================================================================== */

/* ---------- 设计令牌 ---------- */
:root {
  --brand: #6366f1;
  --brand-2: #8b5cf6;
  --accent: #06b6d4;
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 40px -12px rgba(15, 23, 42, 0.18);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, 0.35);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* 浅色主题 */
:root,
html[data-theme="light"] {
  --bg: #eef2fb;
  --bg-grad-1: rgba(99, 102, 241, 0.18);
  --bg-grad-2: rgba(6, 182, 212, 0.16);
  --bg-grad-3: rgba(139, 92, 246, 0.14);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-2: rgba(255, 255, 255, 0.55);
  --surface-solid: #ffffff;
  --ink: #1e293b;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.14);
  --chip: #eef2ff;
  --chip-ink: #4338ca;
}

/* 深色主题 */
html[data-theme="dark"] {
  --bg: #070b18;
  --bg-grad-1: rgba(99, 102, 241, 0.22);
  --bg-grad-2: rgba(6, 182, 212, 0.16);
  --bg-grad-3: rgba(139, 92, 246, 0.20);
  --surface: rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.04);
  --surface-solid: #11182b;
  --ink: #e8edf7;
  --ink-soft: #cbd5e1;
  --muted: #94a3b8;
  --line: rgba(255, 255, 255, 0.10);
  --line-strong: rgba(255, 255, 255, 0.18);
  --chip: rgba(129, 140, 248, 0.16);
  --chip-ink: #c7d2fe;
  --shadow: 0 10px 40px -12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.65);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 0.4s var(--ease), color 0.3s var(--ease);
}

/* 背景流动光斑（氛围层） */
body::before {
  content: "";
  position: fixed;
  inset: -20% -20% -20% -20%;
  z-index: -1;
  background:
    radial-gradient(40% 40% at 18% 20%, var(--bg-grad-1), transparent 70%),
    radial-gradient(38% 38% at 82% 18%, var(--bg-grad-2), transparent 70%),
    radial-gradient(46% 46% at 60% 88%, var(--bg-grad-3), transparent 70%);
  filter: blur(10px);
  animation: drift 22s ease-in-out infinite alternate;
}
@keyframes drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(2%, -2%, 0) scale(1.06); }
}

/* ---------- 玻璃面板 ---------- */
.glass {
  background: var(--surface);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- 排版 ---------- */
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.gradient-text {
  background: linear-gradient(120deg, var(--brand), var(--brand-2) 55%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.muted { color: var(--muted); }
.soft { color: var(--ink-soft); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.2s;
  will-change: transform;
}
.btn-primary {
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 8px 24px -8px rgba(99, 102, 241, 0.6);
}
.btn-primary:hover { box-shadow: 0 12px 30px -8px rgba(99, 102, 241, 0.75); }
.btn-ghost {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost:hover { background: var(--surface); }
.lnk { color: var(--brand); cursor: pointer; text-decoration: underline; font-weight: 600; }
.lnk:hover { opacity: 0.8; }
input[type="file"] { display: block; width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px dashed var(--line); background: var(--surface-2); color: var(--ink); font-size: 13.5px; }
.btn-danger {
  background: var(--bad);
  color: #fff;
}
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.block { width: 100%; }

/* 磁吸交互：由 JS 注入 transform */
.magnetic { transition: transform 0.18s var(--ease), box-shadow 0.25s var(--ease); }

/* ---------- 表单 ---------- */
label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 5px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-solid);
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.16);
}

/* ---------- 徽标 / 状态 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.b-ok { background: rgba(16, 185, 129, 0.14); color: #059669; }
.b-do { background: rgba(245, 158, 11, 0.16); color: #d97706; }
.b-pen { background: var(--chip); color: var(--chip-ink); }
.b-proj { background: rgba(99, 102, 241, 0.16); color: var(--brand); }
.b-stage { background: var(--surface-2); color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.do { background: var(--warn); }
.dot.pen { background: var(--muted); }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
.topbar .logo { font-size: 17px; font-weight: 800; }
.topbar .top-logo { height: 30px; width: auto; object-fit: contain; flex-shrink: 0; margin-right: -4px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.08)); }
.topbar .spacer { flex: 1; }
.search {
  max-width: 320px;
  position: relative;
}
.search input { padding-left: 36px; border-radius: 999px; background: var(--surface-2); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.icon-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s var(--ease);
}
.icon-btn:hover { background: var(--surface); transform: translateY(-1px); }

/* 汉堡按钮（仅移动端显示） */
.hamburger {
  display: none;
  width: 38px; height: 38px; flex-shrink: 0;
  align-items: center; justify-content: center;
  border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); cursor: pointer;
  transition: background 0.2s, transform 0.2s var(--ease);
}
.hamburger:hover { background: var(--surface); }
/* 侧边栏遮罩：桌面隐藏，移动端由 .show 控制显示 */
.sidebar-overlay { display: none; }

/* 超级管理员「系统维护」控制台模式：隐藏左侧菜单栏与汉堡按钮（进入具体账套运营视图时自动恢复） */
#app.super-console .sidebar { display: none; }
#app.super-console .hamburger { display: none !important; }
#app.super-console .sidebar-overlay { display: none !important; }

.role-pill {
  padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  background: var(--chip); color: var(--chip-ink);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(120deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 700; font-size: 13px;
}

/* ---------- 布局 ---------- */
.shell { display: flex; min-height: calc(100vh - 60px); }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* 菜单区：超出视口高度时出现滚动条，版权信息固定在底部 */
.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  margin-right: -4px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
  transition: background .2s;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  font-weight: 600;
  position: relative;
  transition: background 0.2s, color 0.2s, transform 0.2s var(--ease);
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); transform: translateX(2px); }
.nav-item.active {
  color: var(--brand);
  background: var(--chip);
}
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 18%; bottom: 18%; width: 3px;
  border-radius: 999px; background: linear-gradient(var(--brand), var(--brand-2));
}
.side-foot { margin-top: auto; font-size: 11.5px; color: var(--muted); padding: 10px 14px; }
.side-foot .side-foot-sub { font-size: 10.5px; opacity: .75; }
.side-foot .icp-no { display: inline-block; margin-top: 6px; font-size: 10.5px; color: var(--muted); text-decoration: none; opacity: .8; transition: color .2s; }
.side-foot .icp-no:hover { color: var(--brand); opacity: 1; }

/* ---------- 侧边栏：一级菜单 + 可折叠分组 ---------- */
.nav-group {
  display: flex; flex-direction: column; gap: 1px;
  margin: 4px 0 2px;
}
/* 一级菜单：字体偏大且统一 */
.nav-item.lv1, .nav-group-title.lv1 {
  font-size: 15px; font-weight: 700; letter-spacing: 0.01em;
  color: var(--text);
}
.nav-item.lv1 { padding: 11px 14px; }
.nav-item.lv1 svg { width: 19px; height: 19px; }
.nav-group-title.lv1 {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; margin: 0;
  cursor: pointer; user-select: none; border-radius: 13px;
  transition: background .18s ease, color .18s ease;
}
.nav-group-title.lv1:hover { background: var(--surface-2); }
.nav-group-title.lv1:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.nav-group-title .chev { width: 15px; height: 15px; flex-shrink: 0; transition: transform .25s cubic-bezier(.4,0,.2,1); }
.nav-group.collapsed .nav-group-title .chev { transform: rotate(-90deg); }
/* 二级菜单：字体比一级小，缩进 */
.nav-group-items {
  display: flex; flex-direction: column; gap: 1px; overflow: hidden;
  padding-left: 16px;
  max-height: 700px; opacity: 1;
  transition: max-height .28s cubic-bezier(.4,0,.2,1), opacity .2s ease;
}
.nav-group.collapsed .nav-group-items { max-height: 0; opacity: 0; }
.nav-item.sub { padding: 8px 12px; font-size: 13px; font-weight: 500; }
.nav-item.sub svg { width: 16px; height: 16px; }
.nav-item.sub.active::before { left: -2px; }

.main { flex: 1; padding: 24px 28px 40px; min-width: 0; }

/* ---------- 卡片 / 面板 ---------- */
.panel { padding: 20px; margin-bottom: 20px; }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.panel-head h2 { font-size: 16px; }
.panel-head .spacer { flex: 1; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat {
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat .num { font-size: 30px; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat .glow {
  position: absolute; right: -20px; top: -20px; width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, var(--bg-grad-1), transparent 70%);
}
.stat.warn .num { color: var(--warn); }
.stat.ok .num { color: var(--ok); }
.stat.brand .num { color: var(--brand); }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 130px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 700; background: var(--surface-2); font-size: 12.5px; position: sticky; top: 0; }
tbody tr { transition: background 0.15s; }
tbody tr:hover td { background: var(--surface-2); }
.row-actions a { color: var(--brand); cursor: pointer; margin-right: 12px; font-weight: 600; }
.row-actions a:hover { text-decoration: underline; }

/* ---------- 模态 ---------- */
.modal-bg {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(8, 12, 26, 0.5);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-bg.show { display: flex; animation: fade 0.25s var(--ease); }
.modal {
  width: 560px; max-width: 100%; max-height: 88vh; overflow: auto;
  padding: 24px;
  animation: pop 0.3s var(--ease);
}
.modal h3 { font-size: 18px; margin-bottom: 14px; }
.modal .close { float: right; cursor: pointer; color: var(--muted); font-size: 24px; line-height: 1; }
.modal .close:hover { color: var(--ink); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1.6fr; gap: 12px; }

/* 通讯录卡片 */
.contact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.contact-card { padding: 18px; border-radius: var(--radius, 16px); display: flex; flex-direction: column; gap: 14px; }
.contact-top { display: flex; align-items: center; gap: 12px; }
.contact-avatar { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px; display: grid; place-items: center;
  font-size: 18px; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--brand, #6366f1), var(--brand-2, #8b5cf6)); }
.contact-id { flex: 1; min-width: 0; }
.contact-name { font-size: 16px; font-weight: 700; color: var(--ink); }
.contact-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.contact-gender { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; color: var(--brand);
  background: var(--chip-2, rgba(99,102,241,.12)); white-space: nowrap; }
.contact-rows { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--border, rgba(128,128,128,.16)); padding-top: 12px; }
.contact-row { display: flex; gap: 10px; font-size: 13px; }
.contact-row .k { flex: 0 0 64px; color: var(--muted); }
.contact-row .v { flex: 1; min-width: 0; word-break: break-all; color: var(--ink); }
.contact-actions { display: flex; gap: 14px; border-top: 1px solid var(--border, rgba(128,128,128,.16)); padding-top: 10px; }
.contact-actions a { color: var(--brand); cursor: pointer; font-weight: 600; font-size: 13px; }
.contact-actions a:last-child { color: var(--danger, #ef4444); }
.contact-actions a:hover { text-decoration: underline; }
@media (max-width: 560px) { .contact-grid { grid-template-columns: 1fr; } }
.po-row { align-items: end; display: grid; gap: 8px; grid-template-columns: 2fr 1.4fr 0.9fr 1fr 1.6fr 0.5fr; }
.po-row[data-type="mold"] { grid-template-columns: 2fr 1.4fr 1fr 1.4fr 0.5fr; }
.po-head { display: grid; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--muted); padding: 0 2px; }
.po-head span:nth-child(1) { grid-column: 1; }
.po-row[data-type="part"] ~ .po-head, .po-head { grid-template-columns: 2fr 1.4fr 0.9fr 1fr 1.6fr 0.5fr; }
.po-row[data-type="mold"] ~ .po-head, .po-head[data-mold] { grid-template-columns: 2fr 1.4fr 1fr 1.4fr 0.5fr; }
.po-name, .po-moq { background: var(--surface-2); color: var(--muted); }
.po-price-wrap { display: flex; flex-direction: column; gap: 2px; }
.po-hint { font-size: 11px; line-height: 1.2; }
.po-del { padding: 6px 10px; }
/* 分段切换控件（订单类型） */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg-btn { border: 0; background: transparent; color: var(--muted); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; transition: all 0.18s var(--ease); }
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.18); }
@media (max-width: 640px) { .grid3 { grid-template-columns: 1fr; } .po-row, .po-head { grid-template-columns: 1fr 1fr; } .po-row[data-type="mold"] { grid-template-columns: 1fr 1fr; } }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: #0f172a; color: #fff; padding: 11px 20px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity 0.3s, transform 0.3s var(--ease); z-index: 99;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 0.96; transform: translateX(-50%) translateY(0); }
html[data-theme="dark"] .toast { background: #1e293b; }

/* ---------- 同步动态时间线 ---------- */
.feed { max-height: 460px; overflow: auto; padding-right: 4px; }
.feed-item {
  border-left: 3px solid var(--brand);
  padding: 9px 14px; margin-bottom: 10px;
  background: var(--surface-2);
  border-radius: 0 12px 12px 0;
  animation: fade 0.3s var(--ease);
}
.feed-item small { color: var(--muted); }
.evt { font-weight: 700; color: var(--brand); }

/* ---------- 进度条 ---------- */
.progress-pill { display: inline-flex; gap: 4px; }
.pstep {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--line-strong);
}
.pstep.done { background: var(--ok); }
.pstep.do { background: var(--warn); }

/* ---------- 错误边界 ---------- */
.err-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #dc2626;
  padding: 14px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13.5px;
}
html[data-theme="dark"] .err-box { color: #fca5a5; }
.ver-tag {
  font-size: 11px; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line); padding: 2px 9px; border-radius: 999px; font-weight: 600;
}

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card { width: 400px; max-width: 100%; padding: 36px 34px; }
.login-card .brand-mark {
  width: 52px; height: 52px; border-radius: 15px; margin-bottom: 18px;
  display: flex; align-items: center; justify-content: center; color: #fff;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  box-shadow: 0 12px 30px -10px rgba(99, 102, 241, 0.7);
}
.demo-row { display: flex; gap: 8px; margin-top: 16px; }
.demo-row button {
  flex: 1; background: var(--chip); color: var(--chip-ink); border: 0;
  border-radius: var(--radius-sm); padding: 9px; font-size: 12.5px; font-weight: 700; cursor: pointer;
  transition: transform 0.2s var(--ease), filter 0.2s;
}
.demo-row button:hover { transform: translateY(-2px); filter: brightness(1.05); }

/* 登录页账套下拉式菜单（与账号/密码输入框同款样式） */
.set-select { position: relative; margin-bottom: 2px; text-align: left; }
.set-select-trigger {
  width: 100%; display: flex; align-items: center; gap: 8px;
  background: var(--surface-solid); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; font-family: inherit; font-weight: 500;
  cursor: pointer; text-align: left;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s;
}
.set-select-trigger:hover { border-color: var(--brand); }
.set-select-trigger:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--chip); }
.set-select-trigger.open { border-color: var(--brand); box-shadow: 0 0 0 3px var(--chip); }
.set-select-trigger #set_select_label { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-select-trigger .caret { transition: transform 0.25s var(--ease); color: var(--muted); flex: none; }
.set-select-trigger.open .caret { transform: rotate(180deg); }
.set-select-menu {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 40;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 6px; display: none; flex-direction: column; gap: 4px;
  max-height: 260px; overflow-y: auto; backdrop-filter: blur(20px) saturate(160%);
}
.set-select-menu.show { display: flex; animation: dropIn 0.22s var(--ease); }
@keyframes dropIn { from { opacity: 0; transform: translateY(-8px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.set-option {
  display: flex; flex-direction: column; gap: 2px; text-align: left; width: 100%;
  background: transparent; border: 0; border-radius: 8px; padding: 10px 12px; cursor: pointer;
  color: var(--fg); transition: background 0.15s var(--ease), transform 0.15s var(--ease);
}
.set-option:hover { background: var(--chip); transform: translateX(2px); }
.set-option.active { background: var(--chip-2, rgba(99,102,241,.14)); }
.set-option-name { font-size: 14px; font-weight: 700; }
.set-option-meta { font-size: 11.5px; color: var(--muted); }
/* 超级管理员「系统维护」伪账套入口 */
.set-option-sys { margin-top: 6px; border-top: 1px solid var(--line); border-radius: 8px; padding-top: 12px; }
.set-option-sys .set-option-name { color: var(--brand); }
.set-option-sys .set-option-meta { color: var(--brand-2, var(--muted)); }
.set-option-sys:hover { background: var(--chip-2, rgba(99,102,241,.14)); }
.set-option-sys.active { background: var(--chip-2, rgba(99,102,241,.2)); }

/* 主题切换浮钮（登录页） */
.theme-float {
  position: absolute; top: 20px; right: 20px;
}

/* ---------- 动画 ---------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.reveal { animation: reveal 0.5s var(--ease) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }

/* ---------- 响应式（抽屉式侧边栏） ---------- */
@media (max-width: 860px) {
  /* 顶栏精简，避免横向溢出 */
  .topbar { gap: 10px; padding: 0 14px; }
  .hamburger { display: inline-flex; }
  .topbar .search { display: none; }
  .topbar .ver-tag, #online_txt, #who, .role-pill { display: none; }
  .topbar .top-logo { height: 26px; }
  .topbar .logo { font-size: 15px; }

  /* 布局：侧边栏脱离文档流，主内容全宽 */
  .shell { flex-direction: row; }
  .main { padding: 16px 14px 28px; }

  /* 侧边栏 → 抽屉（默认收起在屏幕左侧外） */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 260px; max-width: 82vw; height: 100vh;
    flex-direction: column; gap: 6px;
    padding: 18px 14px;
    border-right: 1px solid var(--line);
    background: var(--surface-solid);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.35);
    transform: translateX(-105%);
    transition: transform 0.28s var(--ease);
    z-index: 60; overflow-y: auto; overflow-x: hidden;
  }
  .sidebar.open { transform: translateX(0); }
  /* 抽屉模式下由外层 .sidebar 统一滚动，避免内部再出现一层滚动条 */
  .sidebar-nav { flex: none; overflow: visible; min-height: 0; padding-right: 0; margin-right: 0; }

  /* 抽屉内恢复常规可折叠分组（不再强行平铺） */
  .nav-group { display: flex; }
  .nav-group-title { display: flex; }
  .nav-group-items { padding-left: 16px; }
  .nav-item { flex-direction: row; gap: 12px; padding: 11px 14px; font-size: 14px; transform: none; }
  .nav-item span.txt { font-size: 14px; }
  .nav-item.lv1 { font-size: 15px; padding: 11px 14px; }
  .nav-item.lv1 svg { width: 19px; height: 19px; }
  .nav-item.active::before { display: block; }
  .nav-item.sub { padding: 8px 12px; font-size: 13px; }
  .side-foot { display: block; margin-top: auto; }

  /* 遮罩：抽屉打开时出现 */
  .sidebar-overlay {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(8, 12, 26, 0.45);
    backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
    opacity: 0; visibility: hidden;
    transition: opacity 0.28s var(--ease), visibility 0.28s;
  }
  .sidebar-overlay.show { opacity: 1; visibility: visible; }

  /* 表格在窄屏横向滚动而非挤压变形 */
  .table-wrap { margin: 0 -2px; }
  .table-wrap table { min-width: 600px; }

  /* 表单网格与采购明细在手机上单列 */
  .grid2, .grid3,
  .po-row, .po-head,
  .po-row[data-type="mold"], .po-row[data-type="part"] ~ .po-head {
    grid-template-columns: 1fr;
  }

  /* 模态在手机上铺满、留边距 */
  .modal { padding: 18px 16px; border-radius: 16px; }
}

/* 超小屏（≤480px）进一步收紧 */
@media (max-width: 480px) {
  .main { padding: 14px 12px 24px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat .num { font-size: 24px; }
  .topbar .logo { display: none; }
}

/* ---------- BOM 树形管理 ---------- */
.bom-tree { display: flex; flex-direction: column; gap: 10px; }
.bom-tree-node { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); transition: box-shadow .18s ease, border-color .18s ease; }
.bom-tree-node:hover { border-color: var(--accent-soft, var(--accent)); }
.bom-tree-node.expanded { box-shadow: 0 6px 22px rgba(0,0,0,.06); }
.bom-tree-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; user-select: none; transition: background .15s ease; }
.bom-tree-head:hover { background: var(--surface-2); }
.bom-tree-head .chev { width: 16px; height: 16px; flex-shrink: 0; transition: transform .25s cubic-bezier(.4,0,.2,1); color: var(--muted); }
.bom-tree-node.expanded .chev { transform: rotate(90deg); }
.bt-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bt-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-meta { font-size: 12px; color: var(--muted); }
.bom-tree-body { display: none; flex-direction: column; border-top: 1px solid var(--line); }
.bom-tree-node.expanded .bom-tree-body { display: flex; }
.bom-leaf { display: flex; align-items: center; gap: 14px; padding: 10px 16px 10px 44px; font-size: 13.5px; border-bottom: 1px dashed var(--line); }
.bom-leaf:last-child { border-bottom: 0; }
.bl-no { font-weight: 600; white-space: nowrap; }
.bl-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bl-qty { color: var(--accent); font-weight: 700; white-space: nowrap; }
.bl-note { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bom-leaf .row-actions { flex-shrink: 0; }

@media (max-width: 860px) {
  .bom-tree-head { flex-wrap: wrap; gap: 8px; }
  .bom-tree-head .btn-sm { order: 3; }
  .bom-leaf { flex-wrap: wrap; gap: 8px; padding-left: 24px; }
  .bl-note { flex-basis: 100%; order: 4; }
}

/* ---------- 账套选择 & 超级管理后台 ---------- */
.set-list { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.set-row {
  appearance: none; -webkit-appearance: none;
  width: 100%; text-align: left; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--surface-solid);
  color: var(--ink); cursor: pointer; font-family: inherit; font-size: 14px;
  transition: transform 0.2s var(--ease), border-color 0.2s, box-shadow 0.2s;
}
.set-row:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow); }
.set-row.active { border-color: var(--brand); background: var(--chip); }
.set-name { font-weight: 700; font-size: 15px; }
.set-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* 财务对比条 */
.cmp-bar { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.cmp-bar > span { display: block; height: 100%; border-radius: 999px; transition: width 0.6s var(--ease); }

/* 新建账套表单：窄屏单列 */
@media (max-width: 640px) {
  .toolbar input { width: 100%; min-width: 0; }
}

/* ---------------- 权限管理矩阵 ---------------- */
.perms-wrap { padding: 4px; overflow-x: auto; border-radius: var(--radius-sm); max-height: calc(100vh - 160px); overflow-y: auto; }
.perms-table { min-width: 880px; }
.perms-table th, .perms-table td { padding: 10px 10px; text-align: center; vertical-align: middle; }
.perms-table th:first-child, .perms-table td:first-child,
.perms-table th:nth-child(2), .perms-table td:nth-child(2),
.perms-table th:nth-child(3), .perms-table td:nth-child(3) { text-align: left; }
.perms-table .perm-col { font-size: 12px; min-width: 64px; }
.perms-table .perm-emp { line-height: 1.35; font-weight: 600; }
.perms-table .perm-emp .muted { font-weight: 400; font-size: 11.5px; }
.perm-sel {
  appearance: none; -webkit-appearance: none;
  padding: 6px 8px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font-size: 12.5px; cursor: pointer;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.perm-sel:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.perm-sel[data-val="none"], .perm-sel:has(option[value="none"]:checked) { color: var(--muted); }
.perms-table td .btn.block { min-width: 56px; padding: 7px 10px; font-size: 12.5px; }


/* ---------------- 组织架构（部门树） ---------------- */
.org-wrap { display: flex; gap: 0; padding: 0; overflow: hidden; min-height: calc(100vh - 170px); }
.org-tree-panel { width: 40%; min-width: 300px; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.org-tree-meta { padding: 12px 16px; font-size: 12.5px; color: var(--muted); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.org-tree { padding: 8px 6px 16px; overflow-y: auto; flex: 1; }
.org-node { position: relative; }
.org-row {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px 9px 10px; border-radius: 12px;
  cursor: pointer; transition: background .18s var(--ease), transform .18s var(--ease);
  position: relative;
}
.org-row:hover { background: color-mix(in srgb, var(--brand) 9%, transparent); }
.org-row.sel { background: color-mix(in srgb, var(--brand) 16%, transparent); box-shadow: inset 3px 0 0 var(--brand); }
.org-toggle {
  flex: 0 0 auto; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--muted); transition: transform .2s var(--ease); border-radius: 6px;
}
.org-toggle:not(.ghost):hover { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
.org-toggle.open { transform: rotate(90deg); }
.org-toggle.ghost { visibility: hidden; }
.org-info { flex: 1; min-width: 0; }
.org-name { font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-fn { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.org-count { flex: 0 0 auto; font-size: 11px; color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); padding: 1px 7px; border-radius: 999px; }
.org-acts { flex: 0 0 auto; display: flex; gap: 2px; opacity: 0; transition: opacity .18s var(--ease); }
.org-row:hover .org-acts { opacity: 1; }
.org-acts a { width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 13px; color: var(--muted); cursor: pointer; transition: background .18s var(--ease), color .18s var(--ease); }
.org-acts a:hover { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }
.org-children { position: relative; }

/* 详情面板 */
.org-detail-panel { flex: 1; padding: 22px 24px; overflow-y: auto; }
.org-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); gap: 10px; }
.org-empty-ic { font-size: 42px; opacity: .6; }
.org-detail-card { padding: 22px; border-radius: var(--radius-sm); }
.org-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.org-detail-head h3 { margin: 0; font-size: 22px; color: var(--ink); }
.org-breadcrumb { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.org-detail-acts { display: flex; gap: 8px; }
.org-fn-detail { margin: 14px 0; color: var(--ink); line-height: 1.6; font-size: 14px; }
.org-stat-row { display: flex; gap: 14px; margin: 6px 0 18px; }
.org-stat { background: color-mix(in srgb, var(--surface-2) 70%, transparent); border: 1px solid var(--line); border-radius: 14px; padding: 12px 18px; min-width: 96px; }
.org-stat .num { font-size: 24px; font-weight: 700; color: var(--brand); }
.org-stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.org-emp-list { border-top: 1px solid var(--line); padding-top: 14px; }
.org-emp-title { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.org-emp-list ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.org-emp-list li { background: color-mix(in srgb, var(--surface-2) 60%, transparent); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 13.5px; }
.org-emp-name { font-weight: 600; color: var(--ink); }

/* ---------------- 社保申报（人事管理） ---------------- */
.social-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px 28px;
  padding: 16px 20px;
  margin-top: 14px;
}
.social-meta .k { display: block; font-size: 12px; color: var(--muted); letter-spacing: .02em; }
.social-meta .v { display: block; font-weight: 600; margin-top: 3px; color: var(--ink); }

.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; margin: 4px 0 12px; }
.badge.ok { background: rgba(46, 194, 126, .16); color: #2ec27e; }
.badge.warn { background: rgba(230, 170, 40, .16); color: #e0a020; }

.social-tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 1180px; }
.social-tbl th, .social-tbl td { border: 1px solid var(--line); padding: 7px 9px; text-align: center; white-space: nowrap; }
.social-tbl thead th { background: color-mix(in srgb, var(--surface-2) 70%, transparent); position: sticky; top: 0; z-index: 2; font-weight: 600; }
.social-tbl tbody td:first-child, .social-tbl tbody td:nth-child(2), .social-tbl tbody td:nth-child(3), .social-tbl tbody td:nth-child(4) { text-align: left; }
.social-tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.social-tbl .strong { font-weight: 700; }
.social-tbl tfoot td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.social-tbl tfoot .sub td { font-weight: 600; }
.social-tbl tfoot .total-row td { font-size: 14px; font-weight: 700; background: color-mix(in srgb, var(--accent, #4f7cff) 12%, transparent); }

@media (max-width: 860px) {
  .org-wrap { flex-direction: column; min-height: 0; }
  .org-tree-panel { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--line); max-height: 42vh; }
  .org-detail-panel { padding: 18px 16px; }
}

