﻿/* ============ Nebula ERP · 2026 现代设计 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --surface-3: #e7ebf4;
  --border: rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.14);
  --text: #1c2333;
  --text-2: #5b6478;
  --text-3: #98a1b3;

  --accent-1: #4f6ef7;
  --accent-2: #7c5cf6;
  --accent-3: #0891b2;
  --gradient: linear-gradient(135deg, #4f6ef7 0%, #7c5cf6 50%, #0891b2 100%);

  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #2563eb;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow: 0 12px 40px rgba(30,41,82,0.12);
  --shadow-sm: 0 4px 16px rgba(30,41,82,0.08);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 18px; height: 18px; }
[hidden] { display: none !important; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .18s ease; font-family: var(--font); color: var(--text);
  white-space: nowrap; line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--gradient); color: #fff;
  box-shadow: 0 6px 20px rgba(99,102,241,0.35);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 8px 26px rgba(139,92,246,0.45); }
.btn-ghost {
  background: var(--surface-2); border-color: var(--border); color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.btn-danger { background: rgba(239,68,68,0.12); color: #dc2626; border-color: rgba(239,68,68,0.25); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px 8px; }

/* ============ 输入 ============ */
.input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px; color: var(--text);
  font-size: 14px; font-family: var(--font); transition: border-color .18s ease, box-shadow .18s ease;
}
.input:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(139,92,246,0.18); }
.input::placeholder { color: var(--text-3); }
textarea.input { resize: vertical; }
.input-search { min-width: 200px; }
.input-select { width: auto; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }

/* ============ 登录页 ============ */
.auth-view {
  position: relative; min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; overflow: hidden;
}
.auth-aurora {
  position: absolute; inset: 0; background: #eef1fb; z-index: 0;
}
.auth-aurora::before, .auth-aurora::after {
  content: ""; position: absolute; width: 60vw; height: 60vw; border-radius: 50%;
  filter: blur(90px); opacity: 0.55; animation: float 14s ease-in-out infinite;
}
.auth-aurora::before { background: #c7d2fe; top: -20%; left: -10%; }
.auth-aurora::after { background: #a5f3fc; bottom: -25%; right: -10%; animation-delay: -7s; }
@keyframes float { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(30px,40px) scale(1.08); } }

.auth-card {
  position: relative; z-index: 1; width: 100%; max-width: 420px;
  background: rgba(255,255,255,0.9); backdrop-filter: blur(24px);
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  padding: 40px 36px; box-shadow: var(--shadow);
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.logo-mark {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px;
  background: var(--gradient); color: #fff; font-size: 26px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 24px rgba(139,92,246,0.4);
}
.auth-brand h1 { font-size: 24px; letter-spacing: -0.5px; }
.auth-sub { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.auth-form h2 { font-size: 19px; margin-bottom: 4px; }
.form-hint { color: var(--text-3); font-size: 13px; margin-bottom: 20px; }
.auth-form label { margin-bottom: 14px; }
.auth-form .btn { margin-top: 8px; }
.auth-switch { text-align: center; margin-top: 18px; color: var(--text-3); font-size: 13px; }

/* ============ 应用布局 ============ */
.app-view { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; padding: 6px 14px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; font-weight: 700; font-size: 16px; margin-top: -4px; }
.sidebar-brand .logo-mark { width: 34px; height: 34px; margin: 0; border-radius: 9px; font-size: 17px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding-right: 4px; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #d0d5e0; border-radius: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: #b0b6c4; }
.sidebar-nav { scrollbar-width: thin; scrollbar-color: #d0d5e0 transparent; }
.nav-item {
  display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: transparent; border: none; color: var(--text-2); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all .16s ease; font-family: var(--font); text-align: left; flex-shrink: 0;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(6,182,212,0.14));
  color: var(--text); font-weight: 600;
}
.nav-item.active svg { color: var(--accent-2); }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--gradient);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: var(--text-3); }

.main { flex: 1; min-width: 0; padding: 24px 28px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px;
}
.topbar h2 { font-size: 22px; letter-spacing: -0.3px; }
.tenant-badge {
  background: var(--surface-2); border: 1px solid var(--border); padding: 6px 14px;
  border-radius: 999px; font-size: 13px; color: var(--text-2);
}

/* ============ 统计卡片 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat-card {
  display: flex; align-items: center; gap: 16px; padding: 22px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  transition: all .2s ease;
}
.stat-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.i-indigo { background: rgba(99,102,241,0.16); color: #4f6ef7; }
.i-violet { background: rgba(139,92,246,0.16); color: #7c5cf6; }
.i-cyan { background: rgba(6,182,212,0.16); color: #0891b2; }
.i-green { background: rgba(16,185,129,0.16); color: #059669; }
.i-orange { background: rgba(245,158,11,0.16); color: #d97706; }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.stat-label { color: var(--text-3); font-size: 13px; margin-top: 2px; }

/* ============ 仪表盘看板 ============ */
.dash-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 1000px) { .dash-cols { grid-template-columns: 1fr; } }
.dash-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.dash-bar-pair { display: flex; gap: 6px; align-items: flex-end; height: 160px; }
.dash-bar { width: 22px; border-radius: 4px 4px 0 0; transition: height .3s ease; }
.dash-bar-label { font-size: 11px; color: #98a1b3; white-space: nowrap; }
.dash-legend { display: flex; gap: 18px; font-size: 12px; color: #64748b; margin-top: 10px; }
.dash-legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; background: var(--c, #4f6ef7); }

/* ============ 面板 & 表格 ============ */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.panel-head h3 { font-size: 16px; }
.panel-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 12px 22px; font-size: 12px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: 0.4px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 14px 22px; border-bottom: 1px solid var(--border); font-size: 14px; white-space: nowrap; }
.dash-recent th { padding: 8px 10px; font-size: 11px; }
.dash-recent td { padding: 7px 10px; font-size: 12px; white-space: normal; word-break: break-all; }
.dash-recent .pill { font-size: 10px; padding: 2px 7px; }
.table tbody tr { transition: background .14s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.cell-muted { color: var(--text-3); }
.cell-strong { font-weight: 600; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* 折叠操作菜单（浮层下拉，不撑开行） */
.row-fold { display: inline-block; position: relative; }
.row-fold-menu {
  position: fixed; z-index: 999;
  min-width: 170px; max-height: 70vh; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 12px 32px rgba(15, 23, 42, .18);
  padding: 6px; display: flex; flex-direction: column; gap: 3px;
}
.row-fold-menu .btn {
  width: 100%; justify-content: flex-start;
  background: transparent; border-color: transparent; color: var(--text-2); box-shadow: none;
}
.row-fold-menu .btn:hover { background: var(--accent, #4f6ef7); color: #fff; }
.row-fold-menu .btn.btn-danger:hover { background: #ef4444; color: #fff; }
.row-fold-menu .pill { margin: 4px 0; }
.split-cell { max-width: 280px; }
.split-line { margin: 3px 0; }
.split-line label { display: flex; align-items: center; gap: 6px; font-size: 12px; flex-wrap: nowrap; }

/* 订单流程进度条（状态列内嵌） */
.order-progress { display: block; margin-top: 6px; min-width: 120px; }
.op-bar { position: relative; height: 22px; background: #eef1f6; border-radius: 6px; overflow: hidden; }
.op-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px 0 0 6px; transition: width .3s ease; }
.op-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4); white-space: nowrap; }

/* 状态徽章 */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-DRAFT { background: rgba(148,163,184,0.14); color: #64748b; }
.pill-PENDING { background: rgba(245,158,11,0.14); color: #d97706; }
.pill-REVIEWING { background: rgba(245,158,11,0.14); color: #d97706; }
.pill-APPROVED { background: rgba(59,130,246,0.14); color: #2563eb; }
.pill-PARTIAL { background: rgba(139,92,246,0.14); color: #7c3aed; }
.pill-COMPLETED { background: rgba(34,197,94,0.14); color: #16a34a; }
.pill-CANCELLED { background: rgba(239,68,68,0.14); color: #dc2626; }
.pill-on { background: rgba(34,197,94,0.14); color: #16a34a; }
.pill-off { background: rgba(148,163,184,0.14); color: #64748b; }
.pill-NORMAL { background: rgba(148,163,184,0.14); color: #64748b; }
.pill-IMPORTANT { background: rgba(59,130,246,0.14); color: #2563eb; }
.pill-STRATEGIC { background: rgba(139,92,246,0.14); color: #7c3aed; }

/* 空状态 / 加载 */
.empty { text-align: center; padding: 50px 20px; color: var(--text-3); }
.empty svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: 0.4; }
.skeleton { height: 16px; border-radius: 6px; background: var(--surface-3); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ============ 模态框 ============ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 100;
}
.modal {
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); animation: modalIn .22s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; }
.modal-close { background: none; border: none; color: var(--text-3); font-size: 24px; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 22px 24px; display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* 全屏弹窗（销售订单表单等） */
.modal-fullscreen { max-width: 96vw; width: 96vw; height: 92vh; max-height: 92vh; }
.modal-fullscreen .modal-body { height: calc(92vh - 66px); overflow-y: auto; }

/* 入库单基础信息左右两栏 */
.inbound-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.inbound-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
@media (max-width: 900px) { .inbound-info-grid { grid-template-columns: 1fr; } }

/* 入库单商品明细表格：横向滚动 + 不换行，保证清晰可见 */
#ib-table { min-width: 1200px; width: 100%; table-layout: auto; }
#ib-table th, #ib-table td { white-space: nowrap; padding: 6px 8px; font-size: 12.5px; }
#ib-table .input { min-width: 70px; width: 100%; padding: 5px 6px; font-size: 12.5px; }
#ib-table input[data-f="product"] { min-width: 170px; }

/* 客户模糊检索建议框 */
.suggest-wrap { position: relative; min-width: 0; }
.suggest-box { position: absolute; z-index: 50; left: 0; right: 0; top: 100%; margin-top: 2px; background: #fff; border: 1px solid var(--border-strong); border-radius: 8px; box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; }
.suggest-item { padding: 8px 12px; cursor: pointer; font-size: 13px; }
.suggest-item:hover { background: var(--surface-1, #f4f6fb); }
.suggest-item.muted { color: var(--text-3); cursor: default; }

/* 通用输入/确认弹窗：置于其它弹窗之上 */
#prompt-modal, #confirm-modal {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 20; max-width: 420px; max-height: 80vh; margin: 0; animation: none;
}

/* 订单明细行 */
.order-items { display: flex; flex-direction: column; gap: 10px; }
.order-items-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text-3); }
.order-line {
  display: flex; gap: 8px; align-items: center;
  background: var(--surface-3); padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.order-line input { min-width: 0; }
.order-line input[data-f="name"] { flex: 1.6; }
.order-line input[data-f="qty"], .order-line input[data-f="price"] { flex: 1; }
.order-line .line-name { flex: 1; min-width: 0; }
.order-line .line-info { flex-shrink: 0; white-space: nowrap; }
.order-line .line-qty { width: 96px; flex-shrink: 0; }
.order-line .rm { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: 18px; flex-shrink: 0; }
.order-line .rm:hover { color: var(--danger); }

/* ============ Toast ============ */
.toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  padding: 13px 18px; border-radius: var(--radius-sm); background: var(--surface-2);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm); font-size: 14px;
  display: flex; align-items: center; gap: 10px; animation: toastIn .25s ease; max-width: 320px;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--info); }

/* ============ 响应式 ============ */
@media (max-width: 820px) {
  .sidebar { width: 68px; padding: 16px 8px; }
  .sidebar-brand span, .nav-item span, .user-meta, .sidebar-footer .btn span { display: none; }
  .nav-item { justify-content: center; }
  .sidebar-footer .btn { justify-content: center; }
  .main { padding: 18px; }
  .form-row { grid-template-columns: 1fr; }
}

/* ============ 导航分组（可折叠下拉） ============ */
.nav-section {
  margin: 12px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
  color: var(--text-3); text-transform: uppercase;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  cursor: pointer; user-select: none; padding: 5px 4px; border-radius: 6px;
  transition: color .15s ease;
}
.nav-section:hover { color: var(--text-2); }
.nav-section::after {
  content: ''; width: 7px; height: 7px; flex-shrink: 0;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px); transition: transform .2s ease;
}
.nav-section.collapsed::after { transform: rotate(-45deg) translateY(1px); }
.nav-section.collapsed { margin-bottom: 2px; }
.nav-section.nav-static { cursor: default; }
.nav-section.nav-static::after { display: none; }
a.nav-item { text-decoration: none; }
a.nav-item:hover { text-decoration: none; }

/* ============ 状态徽章（新增模块） ============ */
.pill-REJECTED { background: rgba(239,68,68,0.14); color: #dc2626; }
.pill-RETURNED { background: rgba(6,182,212,0.14); color: #0891b2; }
.pill-TODO { background: rgba(148,163,184,0.14); color: #64748b; }
.pill-DOING { background: rgba(59,130,246,0.14); color: #2563eb; }
.pill-DONE { background: rgba(34,197,94,0.14); color: #16a34a; }
.pill-LOW { background: rgba(148,163,184,0.14); color: #64748b; }
.pill-HIGH { background: rgba(245,158,11,0.14); color: #d97706; }
.pill-URGENT { background: rgba(239,68,68,0.14); color: #dc2626; }
.pill-LEAD { background: rgba(148,163,184,0.14); color: #64748b; }
.pill-PROSPECT { background: rgba(59,130,246,0.14); color: #2563eb; }
.pill-QUOTE { background: rgba(139,92,246,0.14); color: #7c3aed; }
.pill-NEGOTIATION { background: rgba(245,158,11,0.14); color: #d97706; }
.pill-WON { background: rgba(34,197,94,0.14); color: #16a34a; }
.pill-LOST { background: rgba(148,163,184,0.14); color: #64748b; }
.pill-SENT { background: rgba(59,130,246,0.14); color: #2563eb; }
.pill-ACCEPTED { background: rgba(34,197,94,0.14); color: #16a34a; }
.pill-SHIPPED { background: rgba(139,92,246,0.14); color: #7c3aed; }
.pill-ANNUAL { background: rgba(34,197,94,0.14); color: #16a34a; }
.pill-SICK { background: rgba(245,158,11,0.14); color: #d97706; }
.pill-PERSONAL { background: rgba(59,130,246,0.14); color: #2563eb; }
.pill-OTHER { background: rgba(148,163,184,0.14); color: #64748b; }
.pill-PHONE { background: rgba(59,130,246,0.14); color: #2563eb; }
.pill-VISIT { background: rgba(139,92,246,0.14); color: #7c3aed; }
.pill-EMAIL { background: rgba(6,182,212,0.14); color: #0891b2; }
.pill-WECHAT { background: rgba(34,197,94,0.14); color: #16a34a; }
.pill-MANUAL { background: rgba(148,163,184,0.14); color: #64748b; }
.pill-SHOP { background: rgba(6,182,212,0.14); color: #0891b2; }

/* ============ 简易柱状图（销售统计） ============ */
.bars { display: flex; gap: 14px; align-items: flex-end; height: 190px; padding: 12px 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.bar { width: 100%; max-width: 60px; border-radius: 8px 8px 0 0; background: linear-gradient(180deg, #7c5cf6, #4f6ef7); min-height: 4px; transition: height .3s ease; }
.bar-label { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.bar-val { font-size: 12px; color: var(--text-2); font-weight: 600; }

/* ============ 内联筛选行 ============ */
.filter-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.badge-pinned { color: #d97706; font-size: 12px; }

/* ============ 顶栏 & 通知中心 ============ */
.topbar-right { display: flex; align-items: center; gap: 14px; position: relative; }
.notif-bell {
  position: relative; width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  display: flex; align-items: center; justify-content: center; transition: all .16s ease;
}
.notif-bell:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.notif-bell svg { width: 18px; height: 18px; }
.notif-badge {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(239,68,68,0.5);
}
.notif-panel {
  position: absolute; top: 56px; right: 0; width: 360px; max-width: 90vw; z-index: 90;
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 18px;
  border-bottom: 1px solid var(--border); font-weight: 700; font-size: 14px;
}
.notif-list { max-height: 420px; overflow-y: auto; }
.notif-item { padding: 13px 18px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .14s; }
.notif-item:hover { background: var(--surface-3); }
.notif-item.unread { background: rgba(99,102,241,0.06); }
.notif-item.unread .notif-item-title::before { content: "● "; color: var(--accent-2); font-size: 10px; }
.notif-item-title { font-weight: 600; font-size: 13px; }
.notif-item-content { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.notif-item-time { color: var(--text-3); font-size: 11px; margin-top: 4px; }
.notif-empty { padding: 30px; text-align: center; color: var(--text-3); }

/* ============ IM 消息 ============ */
.nav-badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
/* ============ IM 即时通讯（微信PC/QQ 风格，企业蓝主题） ============ */
.chat-layout { display: grid; grid-template-columns: 60px 280px 1fr; height: calc(100vh - 120px); background: #f5f5f5; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.chat-nav { display: flex; flex-direction: column; align-items: center; padding: 14px 0; background: #1f2329; gap: 8px; }
.chat-nav-item { width: 40px; height: 40px; border-radius: 10px; border: none; background: transparent; cursor: pointer; font-size: 20px; display: flex; align-items: center; justify-content: center; transition: all .2s; color: #8b929a; position: relative; }
.chat-nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.chat-nav-item.active { background: rgba(22,119,255,.22); color: #fff; }
.chat-nav-item.active::before { content: ''; position: absolute; left: -11px; top: 50%; transform: translateY(-50%); width: 3px; height: 20px; background: #1677ff; border-radius: 2px; }
.chat-nav-spacer { flex: 1; }
.chat-side { border-right: 1px solid #e8e8e8; display: flex; flex-direction: column; min-height: 0; background: #fff; }
.chat-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 16px 10px; }
.chat-side-head h3 { font-size: 16px; font-weight: 700; color: #1f2329; }
.presence-select { width: 116px; margin: 0; padding: 6px 8px; border: 1px solid #e8e8e8; border-radius: 8px; font-size: 12px; background: #fff; color: #4b5563; }
.presence-select:focus { outline: none; border-color: #1677ff; }
.conversation-list { flex: 1; overflow-y: auto; }
.chat-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.friend-list { flex: 1; overflow-y: auto; padding: 8px 12px; }
.moments-list { flex: 1; overflow-y: auto; padding: 4px 12px; }
.friend-requests-box { padding: 8px 14px; border-bottom: 1px solid #e8e8e8; background: #fff8ec; }
.perm-checks { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; }
/* 权限平铺网格（模块卡片 + 子功能 + 操作） */
#member-form { display: flex; flex-direction: column; height: calc(96vh - 10px); }
#member-form .form-row { margin-bottom: 6px; }
#member-form > label { margin-bottom: 6px; }
.mb-perms { flex: 1 1 auto; min-height: 0; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: var(--bg-soft); }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.perm-mod-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: #fff; }
.perm-views { margin-top: 6px; }
.perm-view-block { margin: 5px 0; padding: 6px 8px; background: var(--bg-soft); border-radius: 6px; }
.perm-ops { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 4px; }
.perm-op-row { margin: 0; font-size: 12px; }
/* 对账待选明细最大化 */
.rc-pending-max { position: fixed; inset: 0; z-index: 2000; background: #fff; padding: 20px 24px; max-height: none !important; min-height: 0 !important; overflow-y: auto; }
/* 对账管理表格（固定列宽，备注自动换行，避免横向滚动） */
.recon-table { table-layout: fixed; width: 100%; }
.recon-table th, .recon-table td { word-break: break-all; overflow-wrap: anywhere; }
.cp-tab.active { background: #1677ff; color: #fff; border-color: #1677ff; }
.cp-tab-panel { padding: 0; }
.conversation-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; transition: background .2s; }
.conversation-item:hover { background: #f5f6f7; }
.conversation-item.active { background: #e8f1fd; }
.conversation-item.active:hover { background: #e8f1fd; }
.chat-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 16px; font-weight: 600; object-fit: cover; }
@keyframes avatar-bounce { 0% { transform: translateY(0); } 30% { transform: translateY(-8px); } 60% { transform: translateY(0); } 80% { transform: translateY(-4px); } 100% { transform: translateY(0); } }
.avatar-bounce { animation: avatar-bounce 0.6s ease; }

/* 新消息浮窗提醒 */
.msg-notify-wrap { position: fixed; top: 16px; right: 16px; z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.msg-notify { display: flex; align-items: center; gap: 10px; width: 320px; background: #fff; border: 1px solid #e8e8e8; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 10px 12px; cursor: pointer; animation: notify-in .25s ease; }
@keyframes notify-in { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.mn-main { flex: 1; min-width: 0; }
.mn-title { font-weight: 600; font-size: 13px; color: #1f2329; }
.mn-tip { font-weight: 400; color: #9ca3af; font-size: 12px; }
.mn-content { color: #6b7280; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.mn-close { border: none; background: none; color: #9ca3af; font-size: 16px; cursor: pointer; padding: 0 2px; }
.chat-avatar-sm { width: 32px; height: 32px; font-size: 14px; }
.ci-main { flex: 1; min-width: 0; }
.ci-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ci-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #1f2329; }
.ci-time { color: #9ca3af; font-size: 11px; flex-shrink: 0; }
.ci-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 3px; }
.ci-last { color: #9ca3af; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.ci-unread { background: #ff4d4f; color: #fff; border-radius: 999px; min-width: 18px; height: 18px; padding: 0 5px; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.presence-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.presence-dot.on { background: #52c41a; box-shadow: 0 0 6px rgba(82,196,26,0.6); }
.presence-dot.off { background: #bfbfbf; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #f5f5f5; }
.chat-main-head { padding: 14px 20px; border-bottom: 1px solid #e8e8e8; font-weight: 700; font-size: 15px; background: #fff; color: #1f2329; display: flex; align-items: center; justify-content: space-between; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.chat-msg { max-width: 72%; display: flex; gap: 10px; align-items: flex-start; }
.chat-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg.other { align-self: flex-start; }
.chat-msg .chat-avatar { margin-top: 18px; }
.chat-msg-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.chat-msg.mine .chat-msg-main { align-items: flex-end; }
.chat-msg.other .chat-msg-main { align-items: flex-start; }
.chat-msg-meta { font-size: 11px; color: #9ca3af; }
.chat-bubble { padding: 10px 14px; border-radius: 10px; background: #fff; border: 1px solid #e8e8e8; font-size: 14px; line-height: 1.55; word-break: break-word; box-shadow: 0 1px 2px rgba(0,0,0,.04); color: #1f2329; }
.chat-msg.mine .chat-bubble { background: #1677ff; border-color: #1677ff; color: #fff; }
.chat-file { color: #1677ff; font-size: 14px; }
.chat-msg.mine .chat-file { color: #fff; }
.chat-input { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid #e8e8e8; align-items: flex-end; background: #fff; }
.chat-textarea { flex: 1; resize: none; min-height: 42px; max-height: 140px; padding: 10px 14px; border: 1px solid #e8e8e8; border-radius: 8px; font-size: 14px; font-family: inherit; line-height: 1.5; transition: border-color .2s; }
.chat-textarea:focus { outline: none; border-color: #1677ff; box-shadow: 0 0 0 2px rgba(22,119,255,.12); }
.chat-input .btn { height: 42px; }
.member-checkboxes { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.chat-empty { padding: 40px 16px; text-align: center; color: #9ca3af; }
.ci-avatar-wrap { position: relative; flex-shrink: 0; }
.ci-avatar-wrap .presence-dot { position: absolute; right: 0; bottom: 0; width: 10px; height: 10px; border: 2px solid #fff; }
.conversation-item .ci-pin { position: absolute; right: 10px; top: 6px; display: none; border: none; background: transparent; cursor: pointer; font-size: 13px; opacity: .6; padding: 2px 4px; border-radius: 6px; }
.conversation-item:hover .ci-pin { display: block; }
.conversation-item .ci-pin.on { display: block; opacity: 1; }
.conversation-item .ci-pin:hover { background: #e8e8e8; opacity: 1; }
.conversation-item { position: relative; }
.conversation-item.pinned { background: #fafafa; }
.friend-group-head { display: flex; align-items: center; gap: 6px; padding: 8px 14px; cursor: pointer; user-select: none; color: #4b5563; }
.friend-group-head:hover { background: #f5f6f7; }
.fg-arrow { font-size: 11px; color: #9ca3af; transition: transform .15s; display: inline-block; }
.fg-arrow.open { transform: rotate(90deg); }
.fg-name { font-weight: 600; font-size: 13px; flex: 1; }
.fg-count { font-size: 11px; color: #9ca3af; background: #f0f0f0; border-radius: 999px; padding: 0 7px; }
.friend-group-body { border-top: 1px solid #f5f5f5; }
.friend-item { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 26px; }
.friend-item:hover { background: #f5f6f7; }
.friend-item .fi-avatar-wrap { position: relative; flex-shrink: 0; }
.friend-item .fi-avatar-wrap .presence-dot { position: absolute; right: 0; bottom: 0; width: 10px; height: 10px; border: 2px solid #fff; }
.fi-main { flex: 1; min-width: 0; cursor: pointer; }
.fi-name { font-size: 14px; font-weight: 500; color: #1f2329; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fi-meta { font-size: 11px; color: #9ca3af; }
.friend-item .row-actions .row-fold > .btn { opacity: 0; }
.friend-item:hover .row-actions .row-fold > .btn { opacity: 1; }

/* 勾选行（批量选择商品等）：勾选框与文字对齐 */
.check-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; transition: border-color .15s, background .15s; }
.check-row:hover { background: var(--surface-hover, #f6f7fb); border-color: var(--border-strong, #d0d5e0); }
.check-row input[type="checkbox"] { width: 16px; height: 16px; flex-shrink: 0; margin: 0; cursor: pointer; accent-color: #4f6ef7; }
.pp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-meta { flex-shrink: 0; font-size: 12px; }

/* 滚动条美化 */
.chat-messages::-webkit-scrollbar, .conversation-list::-webkit-scrollbar, .friend-list::-webkit-scrollbar, .moments-list::-webkit-scrollbar, .member-checkboxes::-webkit-scrollbar { width: 6px; height: 6px; }
.chat-messages::-webkit-scrollbar-thumb, .conversation-list::-webkit-scrollbar-thumb, .friend-list::-webkit-scrollbar-thumb, .moments-list::-webkit-scrollbar-thumb, .member-checkboxes::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 3px; }
.chat-messages::-webkit-scrollbar-thumb:hover, .conversation-list::-webkit-scrollbar-thumb:hover, .friend-list::-webkit-scrollbar-thumb:hover, .moments-list::-webkit-scrollbar-thumb:hover { background: #b0b0b0; }

@media (max-width: 1000px) {
  .chat-layout { grid-template-columns: 60px 1fr; }
  .chat-side { display: none; }
}
@media (max-width: 700px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-nav { display: none; }
}

/* ============ 单据讨论 ============ */
.doc-chat-body { padding: 0; gap: 0; }
.doc-chat-messages { height: 46vh; border-bottom: 1px solid var(--border); }
.doc-chat-body .chat-input { border-top: 1px solid var(--border); }

/* ============ 邮件详情 ============ */
.email-detail-body { white-space: pre-wrap; word-break: break-word; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; margin: 10px 0; }

/* ============ 竞价大厅 ============ */
.bidding-bids { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; }
.bid-item { display: flex; align-items: center; gap: 12px; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }
.bid-supplier { font-weight: 600; flex: 1; min-width: 0; }
.bid-price { color: var(--accent-2); font-size: 16px; font-weight: 800; }
.bid-meta { color: var(--text-3); font-size: 12px; }

/* ============ 采购订单文档 ============ */
.po-doc { position: relative; background: #fff; border: 1px solid #b9c0d4; padding: 26px 28px; font-size: 13px; line-height: 1.8; color: #1c2333; }
.po-title { text-align: center; font-size: 22px; font-weight: 800; letter-spacing: 8px; margin-bottom: 2px; }
.po-sub { text-align: center; color: #6b7280; margin-bottom: 14px; letter-spacing: 2px; }
.po-info { text-align: center; }
.po-info div { margin: 1px 0; }
.po-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.po-table th, .po-table td { border: 1px solid #4b5563; padding: 6px 7px; font-size: 12px; text-align: center; }
.po-table th { background: #f3f5fa; font-weight: 600; }
.po-table td.num { text-align: center; font-variant-numeric: tabular-nums; }
.po-total { text-align: right; margin-top: 8px; }
.po-remark { margin-top: 8px; }
.po-terms { border: 1px dashed #9ca3af; padding: 8px 12px; margin-top: 10px; white-space: pre-wrap; min-height: 56px; }
.po-foot { margin-top: 12px; }
.po-sign { display: flex; justify-content: space-between; margin-top: 28px; }
.doc-sign { display: flex; justify-content: flex-start; gap: 56px; margin-top: 24px; padding-right: 40px; }
.doc-sign > span { min-width: 120px; white-space: nowrap; }
.po-sign-left { display: flex; align-items: center; gap: 18px; }
.po-approver-line { margin-top: 10px; font-size: 13px; color: var(--text-2); }
.po-signature { font-family: 'KaiTi', 'STKaiti', '楷体', 'FangSong', '仿宋', serif; font-size: 18px; color: #b91c1c; font-weight: 700; margin: 0 6px; letter-spacing: 2px; }
.po-sign-row { display: flex; justify-content: space-between; gap: 24px; margin-top: 18px; }
.po-sign-item { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 140px; }
.po-sign-label { font-size: 12px; color: var(--text-3); }
.po-sign-img { width: 140px; height: 70px; object-fit: contain; border-bottom: 1px dashed #cbd5e1; }
.po-sign-img-empty { display: block; width: 140px; height: 70px; border-bottom: 1px dashed #cbd5e1; }
.po-sign-name { font-size: 13px; font-weight: 600; color: var(--text-2); }
.po-seal-wrap { position: static; display: inline-block; }
.po-seal-overlay { position: absolute; left: 36px; bottom: 22px; height: 112px; width: 112px; object-fit: contain; opacity: .9; pointer-events: none; }
/* 查看单据弹窗用的打印容器：相对定位，供印章叠加定位，避免印章悬浮 */
.print-doc { position: relative; }

@media print {
  body * { visibility: hidden; }
  .po-doc, .po-doc *, .print-doc, .print-doc * { visibility: visible; }
  .po-doc, .print-doc { position: absolute; left: 0; top: 0; width: 100%; border: none; padding: 0; }
  /* 打印时缩小字体/内边距，避免宽表（对账单 14 列等）超出可打印区域 */
  .print-doc { font-size: 11px; line-height: 1.4; }
  .print-doc .po-title { font-size: 18px; }
  .print-doc .po-info { font-size: 11px; }
  .print-doc .table { font-size: 9px; width: 100%; table-layout: fixed; }
  .print-doc .table th, .print-doc .table td { padding: 2px 3px; word-break: break-all; overflow-wrap: anywhere; }
}

/* ============ 采购订单表单（表格明细） ============ */
#order-items-table .input { width: 100%; padding: 6px 8px; font-size: 13px; }
#order-items-table td { padding: 4px 5px; vertical-align: middle; }
.order-total { text-align: right; margin-top: 10px; font-size: 13px; color: var(--text); }
.order-total strong { color: var(--accent-2); font-size: 15px; }

/* 供应商模糊选择 */
.supplier-pick { position: relative; }
.supplier-suggest { position: absolute; top: 100%; left: 0; right: 0; z-index: 30; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 220px; overflow-y: auto; box-shadow: var(--shadow); }
.supplier-suggest-item { padding: 8px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.supplier-suggest-item:hover { background: var(--surface-2); }
.supplier-info { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface-3); }
.supplier-info-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px 12px; font-size: 12px; }

/* ============ 印章管理 ============ */
.seal-list { display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow-y: auto; }
.seal-item { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.seal-thumb { width: 48px; height: 48px; object-fit: contain; border-radius: 50%; }
.seal-info { flex: 1; min-width: 0; }

/* ============ IM 好友 / 动态 ============ */
.friend-groups-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 12px; border-radius: 999px; border: 1px solid #e5e7eb; background: #f3f4f6; cursor: pointer; font-size: 12px; color: #374151; }
.chip-active { background: #2563eb; color: #fff; border-color: #2563eb; }
.moment-item { border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.moment-img { max-width: 100%; max-height: 180px; object-fit: contain; border-radius: 6px; margin-top: 6px; }
.card-rows > div { padding: 4px 0; border-bottom: 1px dashed #e5e7eb; }
.presence-select { width: 100%; margin-top: 6px; padding: 5px 8px; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 12px; background: #fff; }

/* 打印标签：仅打印标签区域 */
@media print {
  body * { visibility: hidden; }
  #label-print-area, #label-print-area * { visibility: visible; }
  #label-print-area { position: absolute; left: 0; top: 0; width: 100%; border: none; }
}

/* 图片放大灯箱 */
.lightbox { position: fixed; inset: 0; z-index: 400; background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center; cursor: zoom-out; }
.lightbox img { max-width: 90vw; max-height: 90vh; object-fit: contain; }
.lightbox-close { position: absolute; top: 16px; right: 24px; font-size: 44px; line-height: 1; color: #fff; background: none; border: none; cursor: pointer; }

/* 图片删除按钮 */
.img-del { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: #ef4444; color: #fff; border: none; cursor: pointer; font-size: 14px; line-height: 1; display: flex; align-items: center; justify-content: center; z-index: 5; }

/* 产品大市场：淘宝式卡片网格 */
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; padding: 16px 0; }
.market-card { border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; background: #fff; transition: box-shadow .2s, transform .2s; }
.market-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.10); transform: translateY(-2px); }
.market-card-img-wrap { width: 100%; height: 220px; background: #fafafa; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.market-card-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.market-card-noimg { color: #9ca3af; font-size: 13px; }
.market-card-body { padding: 10px 12px 12px; }
.market-card-title { font-size: 14px; line-height: 1.45; height: 40px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; color: #111827; }
.market-card-price-row { margin-top: 8px; display: flex; align-items: baseline; justify-content: space-between; }
.market-card-price { color: #f97316; font-size: 18px; font-weight: 700; }
.market-card-stock { color: #9ca3af; font-size: 12px; }
.market-card-meta { margin-top: 6px; font-size: 12px; color: #6b7280; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.market-card-actions { margin-top: 10px; display: flex; gap: 8px; }
.market-card-actions .btn { flex: 1; }

/* 全局安全水印（登录人 IM 号 + 姓名） */
#global-watermark {
  position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  display: flex; flex-wrap: wrap; align-content: flex-start;
  overflow: hidden; opacity: 0.07; user-select: none;
}
#global-watermark span {
  font-size: 15px; color: #000; transform: rotate(-22deg);
  margin: 60px 80px; white-space: nowrap;
}

/* ===== 出库/入库 明细表格紧凑化（16 列，避免左右滚动） ===== */
#outbound-modal .table th,
#outbound-modal .table td,
#inbound-modal .table th,
#inbound-modal .table td { padding: 4px 5px; font-size: 12px; }
#outbound-modal .table input.input,
#outbound-modal .table select.input,
#inbound-modal .table input.input,
#inbound-modal .table select.input { padding: 2px 4px; font-size: 12px; height: 26px; }
#outbound-modal .table .split-cell,
#inbound-modal .table .split-cell { max-width: 180px; white-space: normal; padding: 3px 4px; }
#outbound-modal .split-line label { font-size: 11px; gap: 4px; flex-wrap: wrap; }
#outbound-modal .split-qty { width: 54px !important; }
#outbound-modal .table,
#inbound-modal .table { table-layout: auto; }
#outbound-modal .order-items-head,
#inbound-modal .order-items-head { flex-wrap: wrap; gap: 8px; }

/* ===== 打印：对账单/入库单等宽表列宽修正（避免文字重叠） ===== */
@media print {
  .print-doc .table { table-layout: fixed !important; font-size: 8.5px !important; width: 100% !important; }
  .print-doc .table th, .print-doc .table td {
    padding: 2px 2px !important; word-break: break-all !important; overflow-wrap: anywhere !important;
    overflow: hidden !important; white-space: normal !important; line-height: 1.25 !important;
    vertical-align: middle !important; font-size: 8.5px !important;
  }
  .print-doc .table th { font-size: 8px !important; }
  .print-doc .table th:nth-child(1)  { width: 4% !important; }
  .print-doc .table th:nth-child(2)  { width: 17% !important; }
  .print-doc .table th:nth-child(3)  { width: 11% !important; }
  .print-doc .table th:nth-child(4)  { width: 10% !important; }
  .print-doc .table th:nth-child(5)  { width: 7% !important; }
  .print-doc .table th:nth-child(6)  { width: 7% !important; }
  .print-doc .table th:nth-child(7)  { width: 4% !important; }
  .print-doc .table th:nth-child(8)  { width: 7% !important; }
  .print-doc .table th:nth-child(9)  { width: 7% !important; }
  .print-doc .table th:nth-child(10) { width: 5% !important; }
  .print-doc .table th:nth-child(11) { width: 4% !important; }
  .print-doc .table th:nth-child(12) { width: 7% !important; }
  .print-doc .table th:nth-child(13) { width: 6% !important; }
  .print-doc .table th:nth-child(14) { width: 4% !important; }
}

/* ===== 对账管理：备注列（来源单号标签）不重叠 ===== */
#reconciliations-body td:nth-child(6) { white-space: nowrap; }
#reconciliations-body td:nth-child(7) {
  white-space: normal !important;
  min-width: 230px;
  max-width: 300px;
  word-break: break-all;
}
#reconciliations-body td:nth-child(7) > div { max-width: 290px; }
#reconciliations-body td:nth-child(7) span {
  display: inline-block;
  margin: 1px 2px 1px 0;
}

/* ===== 对账管理：状态列与备注列拉开距离，避免内容堆叠 ===== */
#reconciliations-body td:nth-child(6),
#reconciliations-body th:nth-child(6) { min-width: 160px; padding-right: 60px !important; white-space: nowrap; }
#reconciliations-body td:nth-child(7),
#reconciliations-body th:nth-child(7) { min-width: 320px; padding-left: 60px !important; white-space: normal !important; }

/* ===== 公司资料：子功能左侧竖排 ===== */
.cp-layout { display: flex; gap: 16px; align-items: flex-start; }
.cp-sidebar { width: 168px; flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; }
.cp-sidebar .cp-tab { width: 100%; text-align: left; padding: 9px 12px; font-size: 13px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; }
.cp-sidebar .cp-tab.active { background: var(--accent-1); color: #fff; border-color: var(--accent-1); }
.cp-sidebar .cp-tab:hover:not(.active) { background: var(--surface-2); }
.cp-content { flex: 1; min-width: 0; }

/* ===== 公司账户信息：表格自适应宽度，避免横向溢出 ===== */
#page-finance-bank .table-wrap { overflow-x: auto; }
#page-finance-bank .table { table-layout: fixed; width: 100%; }
#page-finance-bank .table th,
#page-finance-bank .table td { padding: 8px 5px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#page-finance-bank .table th:nth-child(1)  { width: 14%; }  /* 开户银行 */
#page-finance-bank .table th:nth-child(2)  { width: 15%; }  /* 账户名称 */
#page-finance-bank .table th:nth-child(3)  { width: 17%; }  /* 银行账号 */
#page-finance-bank .table th:nth-child(4)  { width: 5%; }   /* 币种 */
#page-finance-bank .table th:nth-child(5)  { width: 8%; }   /* 初期金额 */
#page-finance-bank .table th:nth-child(6)  { width: 8%; }   /* 本月收款资金 */
#page-finance-bank .table th:nth-child(7)  { width: 8%; }   /* 本月付款资金 */
#page-finance-bank .table th:nth-child(8)  { width: 8%; }   /* 实时金额 */
#page-finance-bank .table th:nth-child(9)  { width: 5%; }   /* 默认 */
#page-finance-bank .table th:nth-child(10) { width: 6%; }   /* 备注 */
#page-finance-bank .table th:nth-child(11) { width: 7%; }   /* 操作 */
#page-finance-bank .table td:nth-child(11) { overflow: visible; }

/* ===== 物料清单（BOM）：表单紧凑 + 子件明细放大 ===== */
#bom-modal .modal-body { padding: 12px 16px; gap: 8px; }
#bom-modal .form-row {
  display: flex !important;
  flex-wrap: wrap;
  gap: 8px 12px !important;
  grid-template-columns: none !important;
}
#bom-modal .form-row > label {
  flex: 0 1 200px;
  min-width: 140px;
  gap: 3px;
  font-size: 12px;
  font-weight: 500;
}
#bom-modal .form-row > label:nth-child(1) { flex-basis: 190px; }
#bom-modal .form-row > label:nth-child(2) { flex-basis: 240px; }
#bom-modal .form-row > label:nth-child(3) { flex-basis: 110px; }
#bom-modal .form-row input,
#bom-modal .form-row select { padding: 4px 7px !important; font-size: 12px !important; height: 30px; }
#bom-modal .panel-head h4 { font-size: 13px; margin: 0; }
#bom-modal #bom-items td { padding: 4px 4px; }
#bom-modal #bom-items .input { padding: 4px 6px !important; font-size: 12px !important; height: 30px; }
#bom-modal .table-wrap { max-height: 46vh; min-height: 260px; overflow-y: auto; }
#bom-modal #bom-cost-summary { padding: 8px 12px; font-size: 12px; gap: 16px !important; }
#bom-modal #bom-cost-price { padding: 4px 7px !important; font-size: 12px !important; height: 30px; }

/* ============================================================
   移动端 H5 适配（<= 768px）
   目标：查看数据/报表、审批、扫码出入库 在手机上好用
   ============================================================ */
@media (max-width: 768px) {
  /* ---------- 整体 ---------- */
  html, body { font-size: 14px; }
  .main { padding: 12px 10px 84px; }
  .panel { padding: 12px !important; border-radius: 10px; }
  .panel-head { flex-wrap: wrap; gap: 8px; align-items: center; }
  .panel-head h3 { font-size: 15px; }
  .panel-actions { flex-wrap: wrap; gap: 6px; width: 100%; }

  /* ---------- 侧边栏 → 抽屉 ---------- */
  .sidebar {
    position: fixed !important;
    left: 0; top: 0; bottom: 0;
    width: 232px !important;
    z-index: 3000;
    transform: translateX(-102%);
    transition: transform .25s ease;
    padding: 16px 12px !important;
    overflow-y: auto;
  }
  body.m-nav-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 18px rgba(0,0,0,.22);
  }
  /* 抽屉里恢复文字显示 */
  .sidebar-brand span, .nav-item span, .user-meta,
  .sidebar-footer .btn span { display: inline !important; }
  .nav-item { justify-content: flex-start !important; }
  .sidebar-footer .btn { justify-content: flex-start !important; }

  /* 遮罩 */
  .m-nav-mask {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.42);
    z-index: 2999;
  }
  body.m-nav-open .m-nav-mask { display: block; }

  /* 汉堡按钮 */
  .m-nav-btn {
    display: inline-flex;
    align-items: center; justify-content: center;
    width: 38px; height: 38px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
  }

  /* ---------- 顶部栏 ---------- */
  .topbar { padding: 8px 10px !important; gap: 8px; }
  .expand-toggle { display: none !important; }

  /* ---------- 表格：紧凑 + 横滑 ---------- */
  .table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
  }
  .table th, .table td {
    padding: 6px 8px !important;
    font-size: 12px !important;
    white-space: nowrap;
  }
  .table th:first-child, .table td:first-child {
    position: sticky; left: 0;
    background: var(--surface);
    z-index: 1;
  }
  .table td.cell-strong { font-size: 12.5px; }

  /* ---------- 弹窗：全屏 ---------- */
  .modal {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
  }
  .modal-fullscreen {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
  }
  .modal-body { padding: 12px 14px !important; gap: 10px !important; }
  .modal-head { padding: 10px 14px !important; }
  .modal-head h3 { font-size: 15px; }

  /* ---------- 表单 ---------- */
  .form-row { grid-template-columns: 1fr !important; gap: 10px !important; }
  .form-row > label { width: 100% !important; min-width: 0 !important; flex-basis: auto !important; }
  /* 16px 防止 iOS 聚焦时自动放大页面 */
  .input, input, select, textarea { font-size: 16px !important; }
  .input, input, select { min-height: 42px; }
  textarea { min-height: 70px; }

  /* ---------- 按钮：加大触摸区 ---------- */
  .btn { min-height: 42px; padding: 9px 15px !important; font-size: 14px !important; }
  .btn-sm { min-height: 36px; padding: 7px 12px !important; font-size: 13px !important; }
  .btn-block { min-height: 46px; }

  /* ---------- 指标卡 2 列 ---------- */
  .stat-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  .stat-value { font-size: 18px !important; }
  .stat-card { padding: 12px !important; }

  /* ---------- 操作列 ---------- */
  .row-actions { flex-wrap: wrap !important; gap: 6px !important; }

  /* ---------- 分页 ---------- */
  .pager-bar { flex-wrap: wrap !important; gap: 8px !important; font-size: 12px; }

  /* ---------- 图表 ---------- */
  .bars { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* ---------- 折叠菜单：贴右侧显示完整 ---------- */
  .row-fold-menu { max-width: 78vw; }

  /* ---------- 聊天 ---------- */
  .chat-layout { grid-template-columns: 1fr !important; grid-template-rows: 1fr; }
  .chat-side, .chat-nav { display: none !important; }

  /* ---------- 仓库扫码入库/出库：大按钮 ---------- */
  #page-inbound .btn, #page-outbound .btn { min-height: 46px; }
}

/* 超小屏（<= 420px）进一步压缩 */
@media (max-width: 420px) {
  .main { padding: 10px 8px 84px; }
  .stat-grid { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .stat-value { font-size: 16px !important; }
  .stat-label { font-size: 11px !important; }
  .table th, .table td { padding: 5px 6px !important; font-size: 11.5px !important; }
  .btn { min-height: 40px; font-size: 13px !important; }
}

/* ---------- 移动端补充修正 ---------- */
@media (max-width: 768px) {
  /* 隐藏「展开明细」等次要按钮（实际 id 是 btn-toggle-expand） */
  #btn-toggle-expand { display: none !important; }

  /* 顶部右侧紧凑 */
  .topbar-right { gap: 6px !important; flex-wrap: nowrap; }
  .tenant-badge { display: none !important; }
  .notif-bell { width: 34px !important; height: 34px !important; }

  /* 页面标题缩小 */
  #page-title { font-size: 16px !important; flex: 1; min-width: 0;
                overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* 筛选条件（输入框/下拉）铺满一行 */
  .panel-actions > .input,
  .panel-actions > select,
  .panel-actions > .input-search,
  .panel-actions > .input-select { width: 100% !important; flex: 1 1 100%; }

  /* 复选按钮组不挤压 */
  .check-row { font-size: 13px; }
}

/* ============================================================
   消息/聊天界面 · 全新视觉（对齐系统设计变量）
   修复：侧栏过深、灰底不协调、圆角生硬
   ============================================================ */

/* 整体容器 */
.chat-layout {
  background: var(--bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-sm) !important;
  overflow: hidden;
}

/* ---------- 左侧图标导航：深色 → 浅色 ---------- */
.chat-nav {
  background: var(--surface) !important;
  border-right: 1px solid var(--border) !important;
  padding: 16px 0 !important;
  gap: 10px !important;
}
.chat-nav-item {
  width: 42px !important;
  height: 42px !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text-3) !important;
  font-size: 19px !important;
  transition: all .18s ease !important;
}
.chat-nav-item:hover {
  background: var(--surface-2) !important;
  color: var(--text-2) !important;
  transform: translateY(-1px);
}
.chat-nav-item.active {
  background: var(--gradient) !important;
  color: #fff !important;
  box-shadow: 0 6px 16px rgba(79,110,247,.28) !important;
}
.chat-nav-item.active::before {
  display: none !important;
}
.chat-nav-spacer { flex: 1; }

/* ---------- 会话列表 ---------- */
.chat-side {
  background: var(--surface) !important;
  border-right: 1px solid var(--border) !important;
}
.chat-side-head {
  padding: 18px 16px 12px !important;
}
.chat-side-head h3 {
  font-size: 15px !important;
  font-weight: 700 !important;
  color: var(--text) !important;
  letter-spacing: .2px;
}
.chat-search input,
.chat-side input[type="search"] {
  border-radius: var(--radius-sm) !important;
  background: var(--surface-2) !important;
  border: 1px solid transparent !important;
  transition: all .18s;
}
.chat-search input:focus,
.chat-side input[type="search"]:focus {
  background: var(--surface) !important;
  border-color: var(--accent-1) !important;
  box-shadow: 0 0 0 3px rgba(79,110,247,.12) !important;
}

/* 会话项 */
.chat-item,
.chat-conv,
.chat-side .list-item {
  border-radius: var(--radius-sm) !important;
  margin: 2px 8px !important;
  padding: 10px 10px !important;
  transition: background .16s ease, transform .16s ease;
}
.chat-item:hover,
.chat-conv:hover,
.chat-side .list-item:hover {
  background: var(--surface-2) !important;
}
.chat-item.active,
.chat-conv.active,
.chat-side .list-item.active {
  background: rgba(79,110,247,.10) !important;
  box-shadow: inset 3px 0 0 var(--accent-1);
}

/* 头像 */
.chat-avatar,
.chat-side .avatar {
  border-radius: 50% !important;
  box-shadow: 0 2px 8px rgba(30,41,82,.10);
  flex-shrink: 0;
}

/* ---------- 主聊天区 ---------- */
.chat-main {
  background: var(--bg) !important;
}
.chat-main-head {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 14px 22px !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  color: var(--text) !important;
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}

/* 消息列表 */
.chat-messages,
.chat-msg-list {
  padding: 20px 22px !important;
  gap: 14px !important;
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(79,110,247,.05), transparent 60%),
    radial-gradient(900px 400px at 100% 0%, rgba(124,92,246,.05), transparent 60%);
}

/* 气泡 */
.chat-bubble {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 14px !important;
  border-top-left-radius: 6px !important;
  padding: 10px 14px !important;
  color: var(--text) !important;
  font-size: 13.5px !important;
  line-height: 1.65 !important;
  box-shadow: 0 2px 10px rgba(30,41,82,.05) !important;
  word-break: break-word;
}
.chat-msg.mine .chat-bubble {
  background: var(--gradient) !important;
  border-color: transparent !important;
  color: #fff !important;
  border-top-left-radius: 14px !important;
  border-top-right-radius: 6px !important;
  box-shadow: 0 6px 18px rgba(79,110,247,.26) !important;
}
.chat-msg.other .chat-bubble {
  border-top-left-radius: 6px !important;
}

/* 消息元信息 */
.chat-msg-meta {
  font-size: 11.5px !important;
  color: var(--text-3) !important;
  padding: 0 4px;
}

/* 文件消息 */
.chat-file {
  border-radius: var(--radius-sm) !important;
  background: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-2) !important;
}
.chat-msg.mine .chat-file {
  background: rgba(255,255,255,.16) !important;
  border-color: rgba(255,255,255,.24) !important;
  color: #fff !important;
}

/* 日期分隔 */
.chat-date-sep,
.chat-day {
  align-self: center;
  font-size: 11.5px !important;
  color: var(--text-3) !important;
  background: rgba(255,255,255,.8) !important;
  padding: 3px 12px !important;
  border-radius: 99px !important;
  border: 1px solid var(--border) !important;
  backdrop-filter: blur(4px);
}

/* ---------- 输入区 ---------- */
.chat-input {
  background: var(--surface) !important;
  border-top: 1px solid var(--border) !important;
  padding: 14px 18px !important;
  gap: 10px !important;
}
.chat-input textarea,
.chat-input input[type="text"] {
  border-radius: var(--radius-sm) !important;
  background: var(--surface-2) !important;
  border: 1px solid transparent !important;
  padding: 10px 14px !important;
  transition: all .18s;
  resize: none;
  font-size: 13.5px;
}
.chat-input textarea:focus,
.chat-input input[type="text"]:focus {
  background: var(--surface) !important;
  border-color: var(--accent-1) !important;
  box-shadow: 0 0 0 3px rgba(79,110,247,.12) !important;
  outline: none;
}
.chat-input .btn {
  border-radius: var(--radius-sm) !important;
}

/* 工具条图标按钮 */
.chat-tool,
.chat-input .icon-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm) !important;
  color: var(--text-3) !important;
  transition: all .16s;
}
.chat-tool:hover,
.chat-input .icon-btn:hover {
  background: var(--surface-2) !important;
  color: var(--accent-1) !important;
}

/* ---------- 右侧资料栏 ---------- */
.chat-info,
.chat-detail {
  background: var(--surface) !important;
  border-left: 1px solid var(--border) !important;
}

/* ---------- 消息通知弹窗 ---------- */
.msg-notify {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !important;
  padding: 12px 14px !important;
}
.msg-notify:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 40px rgba(30,41,82,.16) !important;
}

/* ---------- 文档内聊天 ---------- */
.doc-chat-messages {
  background: var(--surface-2) !important;
  border-bottom: 1px solid var(--border) !important;
}
.doc-chat-body .chat-input {
  border-top: 1px solid var(--border) !important;
  background: var(--surface) !important;
}

/* ---------- 小屏 ---------- */
@media (max-width: 768px) {
  .chat-layout { border-radius: var(--radius-sm) !important; }
  .chat-messages, .chat-msg-list { padding: 14px 12px !important; gap: 10px !important; }
  .chat-bubble { max-width: 84% !important; font-size: 14px !important; }
  .chat-main-head { padding: 12px 14px !important; }
  .chat-input { padding: 10px 12px !important; }
}

/* 聊天侧栏标题不换行 */
.chat-side-head h3 { white-space: nowrap !important; }
.chat-side-head { flex-wrap: nowrap !important; }

/* 空状态居中 */
.chat-empty,
.chat-messages:empty::after {
  color: var(--text-3) !important;
}

/* 让聊天区高度利用更充分 */
.chat-layout { height: calc(100vh - 132px) !important; min-height: 520px; }

/* ============ 订单表头紧凑布局（4 列） ============ */
.order-head-row {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 8px 14px !important;
  margin-bottom: 8px;
}
.order-head-row > label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 11.5px; color: var(--text-2);
}
.order-head-row > label > input,
.order-head-row > label > select {
  height: 30px; font-size: 12.5px; padding: 3px 8px;
  border-radius: 6px;
}
.order-head-row .suggest-wrap { min-width: 0; }
@media (max-width: 900px) {
  .order-head-row { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
@media (max-width: 560px) {
  .order-head-row { grid-template-columns: 1fr !important; }
}

/* ============ 订单表头：极致紧凑（参照竞品布局） ============ */
.order-head-row {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 6px 12px !important;
  margin-bottom: 6px !important;
}
.order-head-row > label {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 5px !important;
  font-size: 11.5px !important;
  color: var(--text-2) !important;
  white-space: nowrap !important;
  min-width: 0;
}
.order-head-row > label > input,
.order-head-row > label > select {
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: 0 !important;
  height: 26px !important;
  line-height: 24px !important;
  font-size: 12.5px !important;
  padding: 1px 7px !important;
  border-radius: 5px !important;
  margin: 0 !important;
}
.order-head-row > label > select { padding: 1px 4px !important; }
.order-head-row .suggest-wrap { min-width: 0 !important; }
.order-head-row .suggest-wrap > label {
  display: flex !important; flex-direction: row !important;
  align-items: center !important; gap: 5px !important;
  font-size: 11.5px !important; color: var(--text-2) !important;
  white-space: nowrap !important; min-width: 0;
}
.order-head-row .suggest-wrap > label > input {
  flex: 1 1 auto !important; min-width: 0 !important;
  height: 26px !important; font-size: 12.5px !important;
  padding: 1px 7px !important; border-radius: 5px !important;
}

/* 小屏降级 */
@media (max-width: 1100px) {
  .order-head-row { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}
@media (max-width: 820px) {
  .order-head-row { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
@media (max-width: 560px) {
  .order-head-row { grid-template-columns: 1fr !important; }
  .order-head-row > label,
  .order-head-row .suggest-wrap > label { flex-wrap: wrap; white-space: normal; }
}

/* ============ 单据模板管理 ============ */
.tpl-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px; align-items: start; }
.tpl-left { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.tpl-left-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tpl-left-head h3 { font-size: 14px; font-weight: 700; }
.tpl-right { display: flex; flex-direction: column; gap: 12px; }
.tpl-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tpl-block-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.tpl-toolbar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; padding: 4px; background: var(--surface-2); border-radius: 6px; }
.tpl-toolbar .btn { padding: 2px 8px !important; min-height: 26px !important; font-size: 12px !important; }
.tpl-editor {
  min-height: 110px; max-height: 260px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  background: #fff; font-size: 13px; line-height: 1.7; outline: none;
}
.tpl-editor:focus { border-color: var(--accent-1); box-shadow: 0 0 0 3px rgba(79,110,247,.12); }
.tpl-editor img { max-width: 100%; }
.tpl-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; }
.tpl-field-row { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 2px 0; }
.tpl-field-name { width: 92px; color: var(--text-2); flex-shrink: 0; }
.tpl-field-row label { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.tpl-field-row input[type="checkbox"] { width: auto; height: auto; margin: 0; }
.tpl-field-row input[type="number"] { height: 24px; font-size: 12px; padding: 0 6px; border-radius: 5px; }
.tpl-actions { display: flex; gap: 8px; padding: 4px 0 16px; }
tr.row-active { background: rgba(79,110,247,.08) !important; }
@media (max-width: 1000px) {
  .tpl-layout { grid-template-columns: 1fr; }
  .tpl-fields { grid-template-columns: 1fr; }
}
.tpl-field-row { align-items: center !important; }
.tpl-field-row label { flex-direction: row !important; }
.tpl-field-row > label:nth-of-type(1) { width: 46px; }
@media (max-width: 1199px) {
  .tpl-layout { grid-template-columns: 1fr !important; }
  .tpl-left { max-height: 320px; overflow: auto; }
  .tpl-right { margin-top: 4px; }
}
/* 宽屏时字段表用 3 列（减少纵向高度） */
@media (min-width: 1400px) {
  .tpl-fields { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}
@media (min-width: 1800px) {
  .tpl-fields { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
}
/* 模板列表列宽压缩，避免横向滚动 */
.tpl-left .table th, .tpl-left .table td {
  padding: 7px 5px !important; font-size: 12px !important;
}
.tpl-left .table th:nth-child(1), .tpl-left .table td:nth-child(1) { width: 40px; text-align: center; }
.tpl-left .table th:nth-child(2), .tpl-left .table td:nth-child(2) { width: 38px; text-align: center; }
.tpl-left .table th:nth-child(3), .tpl-left .table td:nth-child(3) { min-width: 90px; }
.tpl-left .table th:nth-child(4), .tpl-left .table td:nth-child(4) { min-width: 80px; }
.tpl-left .table td:nth-child(3), .tpl-left .table td:nth-child(4) {
  white-space: normal; word-break: break-all;
}
/* ============ 模板编辑器：可自由缩放的图片 ============ */
.tpl-img-wrap {
  display: inline-block;
  position: relative;
  resize: both;
  overflow: hidden;
  max-width: 100%;
  min-width: 40px;
  min-height: 20px;
  vertical-align: middle;
  border: 1px dashed transparent;
  border-radius: 4px;
  line-height: 0;
  margin: 2px 4px;
  cursor: move;
}
.tpl-img-wrap:hover,
.tpl-img-wrap.sel {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 2px rgba(79,110,247,.15);
}
.tpl-img-wrap img {
  width: 100%; height: 100%;
  display: block; object-fit: contain;
  pointer-events: none;
  user-select: none;
}
.tpl-editor img { max-width: 100%; }

/* 嵌入（随文字排版，会影响布局） */
.tpl-img-wrap.m-inline { display: inline-block; vertical-align: middle; }
/* 居中独立成行 */
.tpl-img-wrap.m-center { display: block; margin: 8px auto; float: none; }

/* ===== 浮于文字上方 / 嵌入文字下方：绝对定位，完全不影响文字排版 ===== */
.tpl-editor { position: relative; }
.tpl-editor::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff;
  border-radius: 8px;
  z-index: -2;
  pointer-events: none;
}
.tpl-img-wrap.m-front,
.tpl-img-wrap.m-back {
  position: absolute !important;
  margin: 0 !important;
  float: none !important;
  display: block !important;
  cursor: move;
  resize: both;
}
.tpl-img-wrap.m-front { z-index: 10; }   /* 浮于文字上方 */
.tpl-img-wrap.m-back  { z-index: -1; opacity: .85; }  /* 嵌入文字下方 */

/* 绝对定位模式下，文字不受影响，可正常编辑 */

/* 右上角删除按钮 */
.tpl-img-wrap .tpl-img-del {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #dc2626; color: #fff;
  font-size: 12px; line-height: 18px; text-align: center;
  cursor: pointer; z-index: 3; display: none;
  font-family: sans-serif;
}
.tpl-img-wrap:hover .tpl-img-del { display: block; }

/* ============ 单据模板打印渲染 ============ */
.pt-doc {
  background: #fff; padding: 24px 28px; margin: 0 auto; max-width: 900px;
  font-family: "Microsoft YaHei", var(--font); font-size: 12.5px; color: #1c2333;
  border-radius: 8px; box-shadow: 0 2px 12px rgba(30,41,82,.08);
}
.pt-head { margin-bottom: 14px; }
.pt-head img { max-width: 100%; }
.pt-head h1, .pt-head h2, .pt-head h3 { margin: 6px 0; }
.pt-head-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.pt-head-table td { padding: 3px 6px; font-size: 12px; border-bottom: 1px dotted #e5e7eb; }
.pt-head-table .pt-lbl { color: #6b7280; width: 82px; white-space: nowrap; }
.pt-head-table .pt-val { color: #1c2333; font-weight: 600; }
.pt-items { width: 100%; border-collapse: collapse; table-layout: fixed; }
.pt-items th, .pt-items td {
  border: 1px solid #cbd5e1; padding: 5px 6px; font-size: 12px;
  word-break: break-all; vertical-align: middle;
}
.pt-items th { background: #f1f5f9; font-weight: 700; text-align: center; }
.pt-items td.pt-c { text-align: center; }
.pt-total {
  margin-top: 10px; padding: 8px 10px; border: 1px solid #cbd5e1;
  border-radius: 6px; font-size: 12.5px; background: #f8fafc;
}
.pt-foot { margin-top: 16px; font-size: 12px; color: #4b5563; }
.pt-foot img { max-width: 100%; }

@media print {
  .pt-doc { box-shadow: none; max-width: none; padding: 0; }
  .modal-head, .sidebar, .topbar { display: none !important; }
}
/* 打印渲染中的图片容器（不依赖编辑器样式） */
.pt-doc .tpl-img-wrap {
  display: inline-block;
  position: static;
  max-width: 100%;
  line-height: 0;
  vertical-align: middle;
  border: none !important;
  box-shadow: none !important;
  resize: none;
  margin: 2px 4px;
}
.pt-doc .tpl-img-wrap.m-center { display: block; margin: 8px auto; }
.pt-doc .tpl-img-wrap img {
  width: 100%; height: auto; display: block; object-fit: contain;
}
.pt-doc .tpl-img-del { display: none !important; }
.pt-doc .pt-head, .pt-doc .pt-foot { position: relative; overflow: hidden; }

/* ============ 操作菜单：自适应上下拉动 ============ */
.row-fold-menu {
  max-height: none;          /* 由 JS 按可用空间动态设置 */
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  transition: opacity .12s ease;
}
.row-fold-menu::-webkit-scrollbar { width: 6px; }
.row-fold-menu::-webkit-scrollbar-track { background: transparent; }
.row-fold-menu::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.18); border-radius: 3px;
}
.row-fold-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,.3);
}
.row-fold-menu.fold-open {
  animation: foldIn .12s ease;
}
@keyframes foldIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* 菜单内的按钮更紧凑，一屏能显示更多 */
.row-fold-menu .btn {
  justify-content: flex-start !important;
  width: 100%;
  text-align: left;
  min-height: 30px !important;
  padding: 5px 10px !important;
  font-size: 12.5px !important;
  white-space: nowrap;
}

/* ============ 表格固定布局（避免横向滚动） ============ */
.table-fixed { table-layout: fixed; width: 100%; }
.table-fixed th, .table-fixed td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 地址列可悬停查看完整内容 */
.table-fixed td.cell-addr { cursor: default; }

/* 表格容器始终允许横向滚动兜底（内容确实过长时） */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* 面板操作区自动换行 */
.panel-actions { flex-wrap: wrap; row-gap: 6px; }

/* ============ 订单表头：规整 4 列网格 ============ */
.order-head-grid {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 10px 16px !important;
  margin-bottom: 14px;
  padding: 14px 16px;
  background: var(--surface-2, #f8fafc);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.order-head-grid > label,
.order-head-grid > .suggest-wrap {
  display: flex !important;
  flex-direction: column !important;
  gap: 4px !important;
  min-width: 0;
  font-size: 11.5px;
  color: var(--text-2);
  font-weight: 500;
}
.order-head-grid > label > input,
.order-head-grid > label > select,
.order-head-grid .suggest-wrap > label > input {
  width: 100% !important;
  height: 32px !important;
  font-size: 12.5px !important;
  padding: 4px 9px !important;
  border-radius: 6px !important;
  box-sizing: border-box;
}
.order-head-grid .suggest-wrap > label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11.5px; color: var(--text-2);
}
.order-head-grid > .span-2 { grid-column: span 2; }

@media (max-width: 1100px) {
  .order-head-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}
@media (max-width: 860px) {
  .order-head-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .order-head-grid > .span-2 { grid-column: span 2; }
}
@media (max-width: 560px) {
  .order-head-grid { grid-template-columns: 1fr !important; }
  .order-head-grid > .span-2 { grid-column: span 1; }
}

/* ============ 单据弹窗：不再横向溢出 ============ */
.modal-fullscreen {
  width: 94vw !important;
  max-width: 94vw !important;
  box-sizing: border-box !important;
  overflow-x: hidden !important;
}
.modal-fullscreen .modal-body {
  min-width: 0 !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}
.modal-fullscreen .modal-body > * { min-width: 0 !important; max-width: 100% !important; }

/* 表头网格：永远不超出容器 */
.order-head-grid {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}
.order-head-grid > label,
.order-head-grid > div {
  min-width: 0 !important;
}
/* 关键：suggest-wrap 必须 overflow:visible，否则下拉候选框会被裁掉看不见 */
.order-head-grid > .suggest-wrap {
  min-width: 0 !important;
  overflow: visible !important;
  position: relative;
}
.order-head-grid input,
.order-head-grid select {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* 明细行：允许换行，避免撑破弹窗 */
.order-line {
  flex-wrap: wrap !important;
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}
.order-line > .input { min-width: 0 !important; }

/* 明细表头也允许换行 */
.order-items-head,
.order-col-head { flex-wrap: wrap !important; min-width: 0 !important; }

/* 小屏时弹窗更宽 */
@media (max-width: 1400px) {
  .modal-fullscreen { width: 96vw !important; max-width: 96vw !important; }
}

/* ============ 模具检索列表 ============ */
.mold-row {
  display: grid;
  grid-template-columns: 130px minmax(160px, 1fr) 90px 90px 130px 90px 100px 110px;
  gap: 8px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 12.5px;
}
.mold-row-head {
  background: transparent;
  border: none;
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.3px;
}
.mold-row:not(.mold-row-head):hover { background: var(--surface-1, #f4f6fb); }
@media (max-width: 1200px) {
  .mold-row { grid-template-columns: 110px minmax(120px, 1fr) 70px 70px 100px 70px 80px 90px; gap: 6px; padding: 8px 10px; }
}

/* ============ 任务中心 / 跟进记录 检索栏 ============ */
#task-search,
#followup-search {
  width: 260px !important;
  min-width: 200px !important;
  flex: 0 0 auto;
}
#page-oa-tasks .panel-actions,
#page-crm-followups .panel-actions {
  flex-wrap: nowrap;
  justify-content: flex-end;
}
@media (max-width: 1100px) {
  #task-search,
  #followup-search { width: 200px !important; min-width: 150px !important; }
}
@media (max-width: 860px) {
  #page-oa-tasks .panel-actions,
  #page-crm-followups .panel-actions { flex-wrap: wrap; }
  #task-search,
  #followup-search { width: 100% !important; }
}

/* ============ 商品列表：列宽固定 + 操作列右侧吸附 ============ */
.prod-table-wrap {
  overflow-x: auto;
  position: relative;
}
.prod-table {
  table-layout: fixed !important;
  width: 100% !important;
  min-width: 1000px;
}
.prod-table th,
.prod-table td {
  padding: 11px 12px !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.prod-table td:nth-child(3) {
  white-space: normal;
  word-break: break-word;
  line-height: 1.45;
}
/* 操作列吸附在右侧，横向滚动时始终可见 */
.prod-table th.sticky-col,
.prod-table td.row-actions {
  position: sticky !important;
  right: 0;
  background: var(--surface);
  box-shadow: -6px 0 8px -6px rgba(16, 24, 40, 0.18);
  z-index: 2;
}
.prod-table thead th.sticky-col {
  background: var(--surface);
  z-index: 3;
}
.prod-table tbody tr:hover td.row-actions { background: var(--surface-1, #f8fafc); }

/* 窄屏时 SKU / 分类 收窄，名称仍占主空间 */
@media (max-width: 1400px) {
  .prod-table { min-width: 940px; }
  .prod-table th, .prod-table td { padding: 10px 8px !important; font-size: 12.5px; }
}

/* ============ 销售单合计金额 ============ */
.so-total-box {
  margin: 14px 0 4px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary, #4f6ef7);
  border-radius: 8px;
  background: var(--surface-1, #f8fafc);
}
.so-total-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 14px;
}
.so-total-label { color: var(--text-2); font-weight: 600; }
.so-total-cur { color: var(--text-2); font-weight: 600; }
.so-total-num {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary, #4f6ef7);
  letter-spacing: 0.5px;
}
.so-total-cn {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
}
.so-total-sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-3);
}
