:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --border: #e6e9f0;
  --border-strong: #d6dbe5;
  --text: #1f2733;
  --text-2: #5b6472;
  --text-3: #8a93a2;
  --primary: #2f6bff;
  --primary-2: #1f56e0;
  --green: #3b6d11;
  --green-bg: #eaf3de;
  --amber: #854f0b;
  --amber-bg: #faeeda;
  --red: #a32d2d;
  --red-bg: #fcebeb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(20, 30, 55, 0.06), 0 4px 16px rgba(20, 30, 55, 0.05);
  /* v4.7.202 工种弹窗按钮专用色 */
  --cs-blue: #2f6bff;
  --cs-red: #d63031;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
html, body { height: 100%; overflow: hidden; margin: 0; }

.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url('/login-bg.jpg') center center / cover no-repeat fixed;
  padding: 20px;
}
.login-card {
  width: 380px;
  max-width: 100%;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 32px 32px;
  box-shadow: var(--shadow);
}
.login-logo { font-size: 22px; font-weight: 600; text-align: center; color: var(--text); }
.login-sub { text-align: center; color: var(--text-3); font-size: 13px; margin: 6px 0 28px; }
.field-label { display: block; font-size: 13px; color: var(--text-2); margin: 14px 0 6px; }
.login-error { color: var(--red); font-size: 13px; min-height: 20px; margin-top: 8px; }

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 180px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px; border-bottom: 1px solid var(--border); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
}
.brand-text { font-weight: 600; font-size: 14px; }
/* v4.7.581: 侧边栏菜单过高时菜单区自己滚动，「⚙ 账号设置/退出」永远钉在左下角可见
   （之前窗口矮的时候菜单把底部账号区顶出屏幕，缩小页面才看得见） */
.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; }
.brand, .sidebar-user-tags, .sidebar-user, .sidebar-user-actions { flex-shrink: 0;}
.nav-section {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.06em;
  padding: 14px 14px 6px 14px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  text-transform: uppercase;
}
.nav-section:first-of-type { border-top: none; margin-top: 0; padding-top: 4px; }
.nav-item {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: #f2f4f8; color: var(--text); }
.nav-item.active { background: #eaf0ff; color: var(--primary); font-weight: 500; }
/* v4.7.551: 左下角账号区——账号信息一行 + 按钮单独一行，避免窄侧边栏挤压/遮挡名字 */
.sidebar-user {
  border-top: 1px solid var(--border);
  padding: 12px 14px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user-actions {
  padding: 0 14px 12px;
  display: flex;
  gap: 8px;
}
.sidebar-user-actions .icon-btn { flex: 1; text-align: center; white-space: nowrap; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #eaf0ff; color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* v4.7.220 员工自己的工种标签（左下角头像区）；v4.7.221 移到头像上方；v4.7.223 独立成小格子 */
.user-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.user-tag { display: inline-block; padding: 1px 7px; border-radius: 10px; color: #fff; font-size: 10px; line-height: 1.5; font-weight: 500; white-space: nowrap; }
/* v4.7.223 标签独立小格子（带背景/小标题） */
.sidebar-user-tags { border-top: 1px solid var(--border); padding: 10px 14px; background: #f7f8fa; display: flex; flex-direction: column; gap: 6px; }
.user-tags-label { font-size: 11px; color: var(--text-3); font-weight: 500; }
.icon-btn {
  border: 1px solid var(--border); background: #fff; color: var(--text-2);
  border-radius: 8px; padding: 4px 8px; font-size: 11px; cursor: pointer;
  flex-shrink: 0;   /* v4.7.551: 按钮不参与压缩，空间不够时换行而不是挤名字 */
}
.icon-btn:hover { background: #f2f4f8; color: var(--red); border-color: #f0c4c4; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-y: auto; }
.topbar {
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.today { color: var(--text-3); font-size: 12px; }
.content { padding: 12px 16px; max-width: 100%; width: 100%; margin: 0 auto; }

/* ---------- 通用 ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 14px; }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.muted { color: var(--text-3); }
.hint { color: var(--text-3); font-size: 11px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  padding: 6px 14px; border-radius: 8px; font-size: 13px; cursor: pointer;
  transition: all .12s; text-decoration: none;
}
.btn:hover { background: #f2f4f8; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); }
.btn-danger { color: var(--red); border-color: #f0c4c4; }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text);
  background: #fff !important;
  font-family: inherit;
  pointer-events: auto !important;
  opacity: 1 !important;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,107,255,.12); }
.textarea { resize: vertical; min-height: 72px; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
/* 强制 modal 内的 input/select/textarea 显示可写状态 */
.modal .input, .modal .select, .modal .textarea {
  background: #fff !important;
  color: var(--text) !important;
  cursor: text !important;
  /* box-shadow inset 在 input 内部画白底，绕过任何外部 filter 染色 */
  box-shadow: inset 0 0 0 200px #fff !important;
  -webkit-box-shadow: inset 0 0 0 200px #fff !important;
  filter: none !important;
  -webkit-filter: none !important;
  mix-blend-mode: normal !important;
}
/* v4.7.376：下拉框右侧加自定义 ▼ 三角形
   ⚠️ 两个坑（都来自上面的 .modal .input/.select/.textarea 规则，特异性 0,2,0）：
   1. background:#fff !important 简写会把 background-image 重置成 none
   2. box-shadow:inset 0 0 0 200px #fff 是画在 background-image「之上」的，会把三角形整个盖住
   解法：本规则放在它「之后」+ 用 background-color 而非简写 + 关掉那个 inset 阴影 */
.select, .modal .select {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  padding-right: 32px !important;
  background-color: #fff !important;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3e%3cpath fill='%23666' d='M0 0h12L6 8z'/%3e%3c/svg%3e") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 10px 7px !important;
  cursor: pointer !important;
  filter: none !important;
  -webkit-filter: none !important;
  mix-blend-mode: normal !important;
  box-shadow: none !important;
  -webkit-box-shadow: none !important;
}
/* focus 光圈要单独补回来（上面的 box-shadow:none 特异性 0,2,0 会盖掉 178 行那条）*/
.select:focus, .modal .select:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(47,107,255,.12) !important;
  -webkit-box-shadow: 0 0 0 3px rgba(47,107,255,.12) !important;
}
.modal input:disabled, .modal select:disabled, .modal textarea:disabled,
.modal input[readonly], .modal select[readonly], .modal textarea[readonly],
.modal input:-webkit-autofill, .modal select:-webkit-autofill, .modal textarea:-webkit-autofill {
  background: #fff !important;
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text) !important;
  opacity: 1 !important;
  -webkit-box-shadow: inset 0 0 0 200px #fff !important;
  box-shadow: inset 0 0 0 200px #fff !important;
}
.modal .btn-primary { background: var(--primary) !important; color: #fff !important; }
.modal .btn { background: #fff !important; color: var(--text) !important; border: 1px solid var(--border-strong) !important; }
/* 强制整个 modal 容器内的 input/select/textarea/button 不被任何外层 filter 影响 */
.mask, .mask * { filter: none !important; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- 看板 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-label { font-size: 13px; color: var(--text-3); }
.stat-value { font-size: 26px; font-weight: 600; margin-top: 4px; }
.stat-value.primary { color: var(--primary); }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.amber { color: var(--amber); }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.dash-grid.single { grid-template-columns: 1fr; }

/* 阶段分布条 */
.stage-bars { display: flex; flex-direction: column; gap: 12px; }
.stage-bar-row { display: flex; align-items: center; gap: 12px; }
.stage-bar-label { width: 70px; text-align: right; font-size: 13px; color: var(--text-2); flex-shrink: 0; }
.stage-bar-track { flex: 1; height: 22px; background: #eef0f4; border-radius: 6px; overflow: hidden; }
.stage-bar-fill { height: 100%; border-radius: 6px; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; color: #fff; font-size: 12px; min-width: 22px; }
.stage-bar-num { width: 34px; font-size: 13px; color: var(--text); font-weight: 500; flex-shrink: 0; }

/* 来源分布 */
.source-list { display: flex; flex-direction: column; gap: 14px; }
.source-row { display: flex; align-items: center; gap: 12px; }
.source-name { width: 76px; font-size: 13px; color: var(--text-2); }
.source-track { flex: 1; height: 16px; background: #eef0f4; border-radius: 8px; overflow: hidden; }
.source-fill { height: 100%; border-radius: 8px; }
.source-num { width: 60px; font-size: 13px; color: var(--text); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; padding: 11px 12px; color: var(--text-3); font-weight: 500;
  border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 13px;
}
table.data td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:hover td { background: #fafbfd; }
table.data tr:last-child td { border-bottom: none; }
/* ERP 工单表紧凑排版 */
table.data.erp-table th { padding: 4px 5px; font-size: 12px; }
table.data.erp-table td { padding: 3px 5px; font-size: 12px; line-height: 1.4; }
.row-actions { display: flex; gap: 8px; white-space: nowrap; }
.link { color: var(--primary); cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* 徽章 */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; border: 1px solid transparent; white-space: nowrap;
}
.badge-s-新留资 { background: #eef2f7; color: #5b6472; border-color: #d9e0ea; }
.badge-s-已留资 { background: #e6f1fb; color: #185fa5; border-color: #b5d4f4; }
.badge-s-初步沟通 { background: #e1f5ee; color: #0f6e56; border-color: #9fe1cb; }
.badge-s-已报价 { background: var(--amber-bg); color: var(--amber); border-color: #fac775; }
.badge-s-深入洽谈 { background: #eeedfe; color: #534ab7; border-color: #cecbf6; }
.badge-s-已下单 { background: #fbeaf0; color: #993556; border-color: #f4c0d1; }
.badge-s-已成交 { background: var(--green-bg); color: var(--green); border-color: #c0dd97; }
.badge-s-已流失 { background: #f1efe8; color: #5f5e5a; border-color: #d3d1c7; }
.badge-src-淘宝 { background: #fff1ec; color: #d44a1f; border-color: #f6c4b0; }
.badge-src-阿里巴巴 { background: #fff3e6; color: #b3541e; border-color: #f6cfaa; }
.badge-src-抖音 { background: #eef2f7; color: #5b6472; border-color: #d9e0ea; }
.badge-src-拼多多 { background: #fcebeb; color: #a32d2d; border-color: #f7c1c1; }
.badge-src-小红书 { background: #fbeaf0; color: #993556; border-color: #f4c0d1; }
.badge-src-视频号 { background: #e1f5ee; color: #0f6e56; border-color: #9fe1cb; }
.badge-src-快手 { background: #faeeda; color: #854f0b; border-color: #fac775; }
.badge-src-线下 { background: #f1efe8; color: #5f5e5a; border-color: #d3d1c7; }
.badge-ct-新顾客, .badge-ct-新客户 { font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 14px; display: inline-block; background: #2f6bff; color: #fff; border: 1px solid #1f4ec9; }
.badge-ct-老顾客, .badge-ct-老客户 { font-size: 12px; font-weight: 600; padding: 4px 12px; border-radius: 14px; display: inline-block; background: #a32d2d; color: #fff; border: 1px solid #7a1f1f; }
.badge-ct-老顾客回单 { background: #eaf3de; color: #3b6d11; border-color: #c0dd97; }

/* 筛选栏 */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.filter-bar .input, .filter-bar .select { width: auto; min-width: 140px; }
.filter-bar .search { flex: 1; min-width: 200px; }
.count-line { color: var(--text-3); font-size: 13px; margin-left: auto; }

/* 空状态 */
.empty { text-align: center; color: var(--text-3); padding: 50px 20px; }
.empty .big { font-size: 15px; color: var(--text-2); margin-bottom: 6px; }

/* ---------- 弹窗 / 抽屉 ---------- */
.modal-mask, .mask {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(20, 30, 55, .45);
  z-index: 1000;
  overflow-y: auto;
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .15s;
}
.modal {
  background: #fff; border-radius: 16px; width: 880px; max-width: 96vw;
  max-height: calc(100vh - 40px); display: grid; grid-template-rows: auto 1fr auto;
  box-shadow: 0 20px 50px rgba(20,30,55,.25);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close { border: none; background: #f2f4f8; color: var(--text-2); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 16px; }
.modal-close:hover { background: #e8ebf1; }
.modal-body { padding: 22px; overflow: auto; flex: 1 1 auto; min-height: 0; }
/* v4.7.609: 滚动条常显可拖 */
.modal-body { scrollbar-width: auto; scrollbar-color: #c1c8d4 #f1f3f7; }
.modal-body::-webkit-scrollbar { width: 14px; }
.modal-body::-webkit-scrollbar-track { background: #f1f3f7; border-radius: 7px; }
.modal-body::-webkit-scrollbar-thumb { background: #c1c8d4; border-radius: 7px; border: 3px solid #f1f3f7; }
.modal-body::-webkit-scrollbar-thumb:hover { background: #a8b2c2; }
.modal-body, .modal-body * { box-sizing: border-box; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex: 0 0 auto; background: #fafbfd; border-radius: 0 0 16px 16px; }

.drawer-mask { position: fixed; inset: 0; background: rgba(20,30,55,.35); z-index: 100; animation: fadeIn .15s; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 96vw;
  background: #fff; box-shadow: -10px 0 40px rgba(20,30,55,.15); z-index: 101;
  display: flex; flex-direction: column; animation: slideIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--border); }

/* 详情信息 */
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.info-item .k { font-size: 12px; color: var(--text-3); }
.info-item .v { font-size: 14px; color: var(--text); margin-top: 2px; word-break: break-all; }

/* 时间线 */
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 18px 14px; }
.tl-dot { position: absolute; left: -20px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--primary); }
.tl-dot.done { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.tl-dot.lost { background: #8a93a2; box-shadow: 0 0 0 2px #8a93a2; }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-note { margin-top: 6px; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.tl-meta { font-size: 12px; color: var(--text-3); margin-top: 4px; }
/* v4.7.235：员工姓名完整显示 + 截断时不影响点击弹气泡（max-width 配合 text-overflow ellipsis） */
.tl-meta-name { display: inline-block; max-width: 100%; vertical-align: bottom; }
.tl-meta-name[data-tip] { color: #5b6472; }

.divider { height: 1px; background: var(--border); margin: 20px 0; }
.section-label { font-size: 15px; font-weight: 600; margin-bottom: 14px; }

/* 跟进表单 */
.follow-form { background: #f7f8fb; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

/* toast */
#toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: #1f2733; color: #fff; padding: 10px 20px; border-radius: 10px;
  z-index: 999; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2);
  animation: fadeIn .2s; max-width: 90vw;
}
#toast.ok { background: var(--green); }
#toast.err { background: var(--red); }

/* 员工管理 */
/* v4.7.561: 缩小角色标签 + white-space:nowrap，防止被权限列长文字挤压后「员工」竖着折行变形 */
.role-tag { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 12px; display: inline-block; border: 1px solid transparent; white-space: nowrap; line-height: 1.6; }
.role-tag.owner { background: #a32d2d; color: #fff; border-color: #7a1f1f; }
.role-tag.admin { background: #eaf0ff; color: var(--primary); border-color: #c5d4f7; }
.role-tag.finance { background: #e1f5ee; color: #0f6e56; border-color: #9fe1cb; }
.role-tag.staff { background: #1d9e75; color: #fff; border-color: #127456; }
/* v4.7.576: 序号、姓名拆成两列——序号列固定在最左原位，姓名独立成列右移 */
table.users-table th:nth-child(1), table.users-table td:nth-child(1) { width: 40px; min-width: 40px; text-align: right; white-space: nowrap; }
table.users-table th:nth-child(2), table.users-table td:nth-child(2) { min-width: 140px; padding-left: 20px; white-space: nowrap; }
/* 账号列留足位置显示账号名；角色/负责平台/不同工种继续右移并拉开间距 */
table.users-table th:nth-child(3), table.users-table td:nth-child(3) { min-width: 120px; padding-left: 26px; }
/* 负责平台列加宽容纳更多平台标签；不同工种右移并收窄，消除其右侧大片空白 */
table.users-table th:nth-child(4), table.users-table td:nth-child(4) { padding-left: 34px; }
table.users-table th:nth-child(5), table.users-table td:nth-child(5) { padding-left: 34px; padding-right: 16px; min-width: 230px; width: 240px; }
/* 不同工种、权限两列再整体右移 */
table.users-table th:nth-child(6), table.users-table td:nth-child(6) { padding-left: 44px; min-width: 110px; width: 120px; }
table.users-table th:nth-child(7), table.users-table td:nth-child(7) { padding-left: 44px; }
/* 状态/操作列不折行——前面列加宽后这两列被挤到贴边，「编辑/删除」竖排折行 */
table.users-table th:nth-child(8), table.users-table td:nth-child(8),
table.users-table th:nth-child(9), table.users-table td:nth-child(9) { white-space: nowrap; }
table.users-table th:nth-child(9), table.users-table td:nth-child(9) { min-width: 96px; padding-right: 16px; }
.state-on { color: var(--green); font-size: 13px; }
.state-off { color: var(--text-3); font-size: 13px; }

/* Switch 控件 */
.switch { display:inline-flex;align-items:center;cursor:pointer;user-select:none;position:relative }
.switch input { opacity:0;width:0;height:0;position:absolute }
.switch .slider { width:34px;height:18px;background:#d6dae1;border-radius:18px;position:relative;transition:background .2s }
.switch .slider::before { content:"";position:absolute;left:2px;top:2px;width:14px;height:14px;background:#fff;border-radius:50%;transition:transform .2s;box-shadow:0 1px 3px rgba(0,0,0,.2) }
.switch input:checked + .slider { background:#1d9e75 }
.switch input:checked + .slider::before { transform:translateX(16px) }

/* 标签页 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { padding: 10px 20px; cursor: pointer; color: var(--text-2); font-size: 14px; border-bottom: 2px solid transparent; user-select: none; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* 数据卡片 */
.stat-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.stat-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.metric-row { display: flex; align-items: baseline; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.metric-row:last-child { border-bottom: none; }
.metric-label { color: var(--text-2); font-size: 13px; width: 90px; flex-shrink: 0; }
.metric-value { font-size: 15px; font-weight: 600; color: var(--text); }
.metric-value.green { color: var(--green); }
.metric-value.amber { color: var(--amber); }
.meter { height: 8px; background: #eef0f4; border-radius: 5px; overflow: hidden; margin-top: 4px; }
.meter-fill { height: 100%; border-radius: 5px; transition: width .3s; }
.input-group { display: flex; align-items: center; gap: 6px; }
.input-group .prefix, .input-group .suffix { color: var(--text-3); font-size: 13px; flex-shrink: 0; }
.input-group input { flex: 1; min-width: 0; }

.daily-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.daily-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.daily-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.daily-card-title { font-weight: 600; font-size: 14px; }
.daily-field { margin-bottom: 10px; }
.daily-field label { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.daily-field input { width: 100%; }
.daily-saved { font-size: 12px; color: var(--green); }
.daily-acct {
  display: inline-block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  color: #1f4ec9;
  background: #eaf0ff;
  border: 1px solid #c5d4f7;
  border-radius: 10px;
  padding: 3px 10px;
  line-height: 1.5;
  margin-top: 2px;
}
@media (max-width: 900px) {
  .daily-acct { max-width: 120px; padding: 3px 8px; }
}

@media (max-width: 900px) {
  .stat-grid.cols-4, .stat-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .sidebar { width: 64px; }
  .brand-text, .user-meta, .nav-item { font-size: 0; }
  .nav-item { text-align: center; }
}

/* 生产工单详情弹窗：左右分栏 */
.wo-layout { display: grid; grid-template-columns: 200px 1fr; gap: 14px; min-height: 360px; }
.wo-side {
  position: sticky; top: 0; align-self: flex-start;
  background: #f7f9fc; border: 1px solid #e6e9f0; border-radius: 10px;
  padding: 12px; max-height: 78vh; overflow-y: auto;
}
.wo-side-title {
  font-size: 12px; font-weight: 600; color: #555;
  margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid #e6e9f0;
}
.wo-side-list { display: flex; flex-direction: column; gap: 4px; }
.wo-side-item {
  display: flex; align-items: center; gap: 6px; padding: 7px 8px;
  border-radius: 6px; background: #fff; border: 1px solid #e6e9f0;
  color: #1f2733; text-decoration: none; cursor: pointer;
  transition: all .15s ease;
}
.wo-side-item:hover { background: #eef3ff; border-color: #c5d4f7; }
.wo-side-item.active { background: #2f6bff; border-color: #2f6bff; color: #fff; }
.wo-side-dot {
  width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700;
}
.wo-side-name { flex: 1; font-size: 13px; font-weight: 500; }
.wo-side-item.active .wo-side-name { color: #fff; }
.wo-side-badge {
  font-size: 10px; padding: 1px 6px; border-radius: 10px;
  color: #fff; font-weight: 600; white-space: nowrap;
}
.wo-side-item.active .wo-side-badge { color: #fff; }
.wo-main { min-width: 0; }
.wo-step { padding: 10px 12px; margin: 6px 0; border: 1px solid #e6e9f0; border-radius: 8px; background: #fff; }
.wo-step:target, .wo-step.highlight { border-color: #2f6bff; box-shadow: 0 0 0 3px rgba(47,107,255,.12); }
.wo-step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.wo-step-dot {
  width: 24px; height: 24px; border-radius: 50%; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.wo-step-name { font-weight: 600; font-size: 14px; }
.wo-step-status { margin-left: auto; font-size: 12px; padding: 2px 10px; border-radius: 12px; font-weight: 600; }
.status-pending { background: #f1efe8; color: #5f5e5a; border: 1px solid #d3d1c7; }
.status-doing { background: #eaf0ff; color: #2f6bff; border: 1px solid #c5d4f7; }
.status-done { background: #e1f5ee; color: #0f6e56; border: 1px solid #9fe1cb; }
.wo-step-body { font-size: 13px; color: #333; }
.wo-step-actions { margin-top: 8px; display: flex; gap: 6px; }
/* v4.7.268 已回退 */
/* v4.7.609: 断点 700 会误伤 720px 弹窗（内容区 676px），降到 560 保住左侧工序导航 */
@media (max-width: 560px) {
  .wo-layout { grid-template-columns: 1fr; }
  .wo-side { position: relative; max-height: none; }
}
.wo-side-locked { opacity: 0.55; background: #f7f8fa !important; }
.wo-side-locked:hover { background: #f0f4f8 !important; opacity: 0.75; }

/* ---------- v4.7.202 工种创建弹窗按钮专用样式 ---------- */
/* 覆盖 .modal .btn { background:#fff !important; ... } 的强规则（class + !important 高于内联 style） */
.modal .cs-tag-add,
.modal .cs-tag-save.has-changes {
  background: var(--cs-blue) !important;
  color: #fff !important;
  border: 1px solid var(--cs-blue) !important;
  box-shadow: none !important;
  transition: background .15s;
}
.modal .cs-tag-add:hover,
.modal .cs-tag-save.has-changes:hover {
  background: #1f56e0 !important;
  border-color: #1f56e0 !important;
}
.modal .cs-tag-save {
  /* 默认未激活：cnt=0 时灰显 */
  background: #f0f4f8 !important;
  color: #888 !important;
  border: 1px solid #d6dae1 !important;
  cursor: default;
}
.modal .cs-tag-del {
  background: var(--cs-red) !important;
  color: #fff !important;
  border: 1px solid var(--cs-red) !important;
  box-shadow: none !important;
  transition: background .15s;
}
.modal .cs-tag-del:hover {
  background: #b52829 !important;
  border-color: #b52829 !important;
}

/* v4.7.617: 自定义弹窗序号框去掉浏览器自带的上下小箭头（容易被当成移动排序按钮），排序靠填数字自动跳位 */
.opt-sort::-webkit-outer-spin-button, .opt-sort::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.opt-sort { -moz-appearance: textfield; appearance: textfield; }
