/* 钲鹏机床ERP - 表格样式 V3.0 */

/* 横向滚动外层：始终在视野内，水平滚动条固定可见 */
.table-hscroll {
  overflow-x: auto;
  overflow-y: visible;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* 纵向滚动内层：只负责纵向滚动，限制表格高度 */
.table-container {
  overflow-y: auto;
  overflow-x: visible;
  max-height: calc(100vh - 320px);
}

/* ===== V65 表格美化 ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table th {
  padding: 13px 16px;
  text-align: left;
  font-weight: 680;
  color: #334155;
  border-bottom: 2px solid #9DBFE0;
  white-space: nowrap;
  background: linear-gradient(180deg, #EDF4FC 0%, #D6E9F8 100%);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid #e8ecf3;
  color: var(--text);
  vertical-align: middle;
  line-height: 1.5;
}

/* 编码列等宽字体+品牌色 */
.data-table td:first-of-type {
  font-family: 'SF Mono','Consolas','Monaco',monospace;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--primary);
  letter-spacing: 0.3px;
}

/* --- 行底色 --- */
.data-table tbody tr {
  transition: background 0.18s ease, box-shadow 0.18s ease;
  position: relative;
}

/* 斑马纹 - 更明显的淡蓝间隔色 */
.data-table tbody tr:nth-child(even) {
  background: var(--primary-bg);
}

/* hover - 左蓝条 + 浅蓝底 */
.data-table tbody tr:hover {
  background: var(--primary-bg) !important;
  box-shadow: inset 3px 0 0 0 var(--primary);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* 禁用行灰色+删除线 */
.data-table tbody tr.row-disabled td {
  color: #94a3b8;
  font-style: italic;
}
.data-table tbody tr.row-disabled td:first-of-type {
  color: #94a3b8;
  text-decoration: line-through;
}

/* 草稿行暖色 */
.data-table tbody tr.row-draft td {
  color: #a16207;
}

.action-cell {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ===== 列配置面板 ===== */
.column-config-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  background: var(--primary-bg);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--primary);
  font-weight: 550;
  transition: var(--transition);
}
.column-config-trigger:hover {
  background: #D6E9F8;
  border-color: var(--primary);
  transform: translateY(-1px);
}

.column-config-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 440px;
  max-height: 70vh;
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  z-index: 10001;
  display: none;
  flex-direction: column;
}
.column-config-panel.active {
  display: flex;
}
.column-config-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 10000;
  display: none;
  backdrop-filter: blur(2px);
}
.column-config-overlay.active {
  display: block;
}
.column-config-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
}
.column-config-header button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.column-config-header button:hover {
  background: var(--danger-light);
  color: var(--danger);
}
.column-config-body {
  padding: 14px 22px;
  overflow-y: auto;
  flex: 1;
}
.column-config-body .config-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--warning-light);
  border-radius: var(--radius);
}
.column-config-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 4px 0;
  background: var(--bg);
  border-radius: var(--radius);
  cursor: grab;
  transition: background 0.15s, box-shadow 0.15s;
  user-select: none;
  border: 1px solid transparent;
}
.column-config-item:hover {
  background: var(--primary-bg);
  border-color: #c7d2fe;
}
.column-config-item.dragging {
  opacity: 0.5;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}
.column-config-item.drag-over {
  border: 2px dashed var(--primary);
  background: var(--primary-bg);
}
.column-config-item .drag-handle {
  color: var(--text-muted);
  font-size: 16px;
  cursor: grab;
  flex-shrink: 0;
}
.column-config-item .drag-handle:active { cursor: grabbing; }
.column-config-item input[type="checkbox"] {
  width: 16px; height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.column-config-item label {
  flex: 1;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
}
.column-config-item .col-width {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.column-config-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.column-config-footer button {
  padding: 8px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}
.column-config-footer .btn-reset {
  color: var(--danger);
  border-color: #fca5a5;
}
.column-config-footer .btn-reset:hover {
  background: var(--danger-light);
}
.column-config-footer .btn-save {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.column-config-footer .btn-save:hover {
  background: var(--primary-dark);
}
.column-config-footer .btn-cancel {
  color: var(--text-secondary);
}
.column-config-footer .btn-cancel:hover {
  background: var(--bg);
}

/* 隐藏列 */
.data-table th.col-hidden,
.data-table td.col-hidden {
  display: none;
}

/* ===== 表格可排序列 ===== */
.sortable-th {
  cursor: pointer;
  position: relative;
  transition: background 0.15s, color 0.15s;
}
.sortable-th:hover {
  background: linear-gradient(180deg, #e8ecf1, #dce1e8) !important;
  color: var(--primary);
}
.sortable-th .sort-indicator {
  display: inline-block;
  width: 12px;
  font-size: 10px;
  color: #c0c8d4;
  margin-left: 2px;
  transition: color 0.15s;
}
.sortable-th.sorted-asc .sort-indicator,
.sortable-th.sorted-desc .sort-indicator {
  color: var(--primary);
  font-weight: 700;
}
.sortable-th.sorted-asc,
.sortable-th.sorted-desc {
  background: linear-gradient(180deg, #e8edff, #dde3f5) !important;
  color: var(--primary);
}

/* ===== 在线感知栏（Presence Bar）===== */
#presence-bar {
  background: linear-gradient(135deg, var(--primary-bg), #D6E9F8);
  border: 1px solid #d0ddf5;
  border-radius: 8px;
  padding: 6px 14px;
  margin: 8px 0 4px;
  display: flex;
  align-items: center;
  font-size: 13px;
  color: #555;
  animation: presenceFadeIn 0.35s ease;
}
@keyframes presenceFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.presence-bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}
.presence-label {
  color: #888;
  font-size: 13px;
  margin-right: 2px;
}
.presence-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: default;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: transform 0.15s;
}
.presence-avatar:hover {
  transform: scale(1.15);
}
.presence-avatar.presence-editing {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #FF9500;
  animation: presencePulse 1.2s ease-in-out infinite;
}
@keyframes presencePulse {
  0%, 100% { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #FF9500; }
  50% { box-shadow: 0 0 0 2px #fff, 0 0 0 7px rgba(255,149,0,0.3); }
}
.presence-count {
  color: #aaa;
  font-size: 12px;
  margin-left: 4px;
}
.presence-editor-hint {
  color: #e67e22;
  font-size: 12px;
  margin-left: auto;
  padding: 2px 10px;
  background: #fff8e8;
  border-radius: 12px;
  white-space: nowrap;
}
.presence-editor-hint em {
  font-style: normal;
  color: #d35400;
  font-weight: 600;
}

/* ===== 字段模板编辑器（物料分类）===== */
.field-template-editor {
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.field-template-editor .fte-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.field-template-editor .fte-hint {
  color: #999;
  font-size: 12px;
  margin-left: auto;
}
.fte-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.fte-empty {
  text-align: center;
  color: #ccc;
  font-size: 13px;
  padding: 14px 0;
}
.fte-row {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 8px 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.fte-row:hover {
  border-color: var(--primary);
  box-shadow: 0 1px 4px rgba(74,144,217,0.12);
}
.fte-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.fte-idx {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #666;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.fte-name {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 13px;
  min-width: 80px;
}
.fte-name:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(74,144,217,0.15);
}
.fte-type {
  padding: 5px 6px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 12px;
  background: #fff;
  color: #333;
}
.fte-type:focus {
  border-color: var(--primary);
  outline: none;
}
.fte-del-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #ccc;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.fte-del-btn:hover {
  color: #e74c3c;
  background: #fef2f2;
  border-color: #fca5a5;
}
/* 拖拽手柄 */
.fte-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 24px;
  color: #c0c0c0;
  font-size: 10px;
  letter-spacing: 1px;
  cursor: grab;
  flex-shrink: 0;
  user-select: none;
  line-height: 1;
}
.fte-drag-handle:active {
  cursor: grabbing;
}
.fte-row:hover .fte-drag-handle {
  color: var(--primary);
}
/* 上移/下移按钮 */
.fte-move-btn {
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e5e7eb;
  border-radius: 3px;
  background: #fff;
  color: #999;
  font-size: 9px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.fte-move-btn:hover:not(:disabled) {
  color: var(--primary);
  border-color: var(--primary);
  background: #f0f7ff;
}
.fte-move-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
/* 拖拽状态 */
.fte-row.fte-dragging {
  opacity: 0.4;
  border-style: dashed;
}
.fte-row.fte-drag-over {
  border-color: var(--primary) !important;
  border-style: dashed;
  box-shadow: 0 0 0 2px rgba(74,144,217,0.25);
  background: #f0f7ff;
}
.fte-options {
  margin-top: 6px;
  padding-left: 28px;
}
.fte-options-input {
  width: 100%;
  min-height: 50px;
  max-height: 100px;
  padding: 6px 8px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 12px;
  resize: vertical;
  font-family: inherit;
  color: #666;
  background: #fafafa;
}
.fte-options-input:focus {
  border-color: var(--primary);
  outline: none;
  background: #fff;
}
.fte-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border: 1px dashed #b0c4de;
  border-radius: 6px;
  background: transparent;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.fte-add-btn:hover {
  border-color: var(--primary);
  background: #f0f7ff;
}

/* ===== 物料电子表格视图（类 XLSX 体验 · 工业风格美化）===== */
.spreadsheet-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: #f3f5f9;
  animation: spFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes spFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- 面包屑 ---- */
.spreadsheet-breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: #fff;
  border-bottom: 1px solid #e8ecf1;
  font-size: 13.5px;
}
.spreadsheet-breadcrumb .btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 1.5px solid #e0e5ec;
  border-radius: 8px;
  background: #fafbfd;
  color: #4a5568;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.2px;
}
.spreadsheet-breadcrumb .btn-back:hover {
  background: #eef4ff;
  border-color: var(--primary);
  color: var(--primary);
  transform: translateX(-2px);
  box-shadow: 0 2px 8px rgba(37,99,235,0.12);
}
.spreadsheet-breadcrumb .breadcrumb-sep {
  color: #c4c9d4;
  font-size: 14px;
  font-weight: 300;
}
.spreadsheet-breadcrumb .breadcrumb-current {
  font-weight: 650;
  color: #1e293b;
  font-size: 14px;
  letter-spacing: 0.1px;
}

/* ---- 工具栏 ---- */
.spreadsheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid #eef0f5;
}
.spreadsheet-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #64748b;
}
.spreadsheet-info strong {
  color: #0f172a;
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: 0.2px;
}
.spreadsheet-info .badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  background: #eff6ff;
  color: var(--primary);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.spreadsheet-actions {
  display: flex;
  gap: 8px;
}
.spreadsheet-actions .btn-sm {
  padding: 7px 16px;
  border: 1.5px solid #e0e5ec;
  border-radius: 8px;
  background: #fff;
  color: #475569;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.2s ease;
}
.spreadsheet-actions .btn-sm:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #1e293b;
}

/* ---- 电子表格主体 ---- */
.spreadsheet-table-wrap {
  flex: 1;
  overflow: auto;
  background: #fff;
  margin: 10px 14px 4px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.03);
  min-height: 260px;
  max-height: calc(100vh - 380px);
}
.spreadsheet-table-wrap table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  font-feature-settings: "tnum";
}
.spreadsheet-table-wrap thead {
  position: sticky;
  top: 0;
  z-index: 3;
}
.spreadsheet-table-wrap thead th {
  padding: 11px 12px;
  text-align: left;
  font-weight: 650;
  font-size: 11.5px;
  color: #334155;
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  border-right: 1px solid #eef0f5;
  white-space: nowrap;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.spreadsheet-table-wrap thead th:first-child {
  padding-left: 16px;
}
.spreadsheet-table-wrap thead th:last-child {
  border-right: none;
}
.spreadsheet-table-wrap tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f1f5f9;
  vertical-align: middle;
  font-size: 13px;
  color: #334155;
  transition: background 0.12s ease;
}
.spreadsheet-table-wrap tbody td:first-child {
  padding-left: 16px;
}
.spreadsheet-table-wrap tbody td:last-child {
  border-right: none;
}
.spreadsheet-table-wrap tbody tr {
  transition: background 0.12s ease;
}
.spreadsheet-table-wrap tbody tr:hover td {
  background: #F5F8FC;
  border-bottom-color: #e0e8f2;
}
.spreadsheet-table-wrap tbody tr:nth-child(even) td {
  background: #fbfcfe;
}
.spreadsheet-table-wrap tbody tr:nth-child(even):hover td {
  background: #f4f8fe;
}
/* 序号列 */
.spreadsheet-table-wrap .col-seq {
  width: 36px;
  text-align: center;
  color: #94a3b8;
  font-size: 11.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.spreadsheet-table-wrap thead .col-seq {
  text-align: center;
}
/* 编码列 */
.spreadsheet-table-wrap .col-code {
  font-family: "JetBrains Mono", "Cascadia Code", "Consolas", monospace;
  font-size: 12px;
  color: var(--primary);
  font-weight: 550;
  letter-spacing: 0.2px;
}
/* 名称列 */
.spreadsheet-table-wrap .col-name {
  font-weight: 580;
  color: #1e293b;
}
/* 数值列右对齐 */
.spreadsheet-table-wrap .col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---- 可编辑单元格 ---- */
.spreadsheet-cell-input {
  width: 100%;
  min-width: 80px;
  padding: 7px 10px;
  border: 1.5px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
  color: #1e293b;
  background: #fdfdfe;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  box-sizing: border-box;
}
.spreadsheet-cell-input:hover {
  border-color: #c4cde0;
}
.spreadsheet-cell-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1), 0 1px 3px rgba(0,0,0,0.06);
  outline: none;
  background: #fff;
}
.spreadsheet-cell-input.sheet-select {
  padding: 6px 8px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

/* ---- 编辑行高亮 ---- */
tr.spreadsheet-edit-row td {
  background: #fefce8 !important;
  border-bottom-color: #fde68a !important;
}
tr.spreadsheet-edit-row .spreadsheet-cell-input {
  background: #fffdf0;
  border-color: #d97706;
}
tr.spreadsheet-edit-row .spreadsheet-cell-input:focus {
  border-color: var(--primary);
}

/* ---- 新增行（底部常驻）---- */
tr.spreadsheet-add-placeholder {
  cursor: pointer;
  transition: background 0.2s;
}
tr.spreadsheet-add-placeholder td {
  padding: 12px 12px !important;
  color: #94a3b8;
  text-align: center;
  background: #fafbfd !important;
  border-top: 2px dashed #e2e8f0 !important;
  border-bottom: none !important;
  font-size: 13px;
}
tr.spreadsheet-add-placeholder:hover td {
  background: #eef4ff !important;
  color: var(--primary);
  border-top-color: var(--primary) !important;
}
tr.spreadsheet-add-placeholder .placeholder-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  margin-right: 8px;
  font-style: normal;
  line-height: 1;
}
tr.spreadsheet-add-placeholder:hover .placeholder-icon {
  background: #1d4ed8;
  transform: scale(1.1);
  transition: transform 0.2s ease;
}
tr.spreadsheet-add-placeholder .placeholder-hint {
  color: #94a3b8;
  font-size: 12px;
  margin-left: 10px;
}

/* ---- 行内操作按钮 ---- */
.spreadsheet-row-actions {
  display: flex;
  gap: 5px;
  white-space: nowrap;
}
.spreadsheet-row-actions .btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 6px;
  border: 1.5px solid transparent;
  cursor: pointer;
  font-weight: 550;
  transition: all 0.18s ease;
  letter-spacing: 0.1px;
}
.spreadsheet-row-actions .btn-save {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.spreadsheet-row-actions .btn-save:hover { background: #1d4ed8; box-shadow: 0 2px 6px rgba(37,99,235,0.3); }
.spreadsheet-row-actions .btn-cancel {
  background: #fff;
  color: #64748b;
  border-color: #e2e8f0;
}
.spreadsheet-row-actions .btn-cancel:hover { background: #f1f5f9; color: #475569; }
.spreadsheet-row-actions .btn-edit {
  background: #eff6ff;
  color: var(--primary);
  border-color: #bfdbfe;
}
.spreadsheet-row-actions .btn-edit:hover { background: #dbeafe; border-color: #93c5fd; }
.spreadsheet-row-actions .btn-del {
  background: #fef2f2;
  color: #dc5c3c;
  border-color: #fecaca;
}
.spreadsheet-row-actions .btn-del:hover { background: #fee2e2; border-color: #fca5a5; }

/* ---- 复制提示行 ---- */
tr.spreadsheet-copy-hint {
  background: #fffbeb !important;
  animation: hintPulse 2s ease-in-out;
}
@keyframes hintPulse {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0.65; }
}
tr.spreadsheet-copy-hint td {
  padding: 8px 12px !important;
  font-size: 12px;
  color: #92400e;
  text-align: left;
  border-bottom: 1px solid #fde68a !important;
  font-weight: 500;
}

/* ---- 分类切换标签 ---- */
.spreadsheet-cat-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 20px;
  flex-wrap: wrap;
  background: #fff;
  border-bottom: 1px solid #eef0f5;
}
.spreadsheet-cat-tab {
  padding: 6px 16px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  background: #fafbfd;
  color: #475569;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}
.spreadsheet-cat-tab:hover {
  border-color: #93c5fd;
  color: var(--primary);
  background: #eff6ff;
}
.spreadsheet-cat-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}
.spreadsheet-cat-tab .tab-count {
  font-size: 11px;
  opacity: 0.75;
  margin-left: 4px;
}

/* ---- 操作列固定在右侧 ---- */
#catSpreadsheetDataTable thead th:last-child {
  position: sticky;
  right: 0;
  background: #f8fafc;
  z-index: 5;
  box-shadow: -4px 0 10px rgba(0,0,0,0.06);
  min-width: 110px;
  text-align: center;
}
#catSpreadsheetDataTable tbody td:last-child {
  position: sticky;
  right: 0;
  background: #fff;
  z-index: 2;
  box-shadow: -3px 0 8px rgba(0,0,0,0.04);
  text-align: center;
}
#catSpreadsheetDataTable tbody tr:hover td:last-child {
  background: #F5F8FC;
}
#catSpreadsheetDataTable tbody tr:nth-child(even) td:last-child {
  background: #fbfcfe;
}
#catSpreadsheetDataTable tbody tr:nth-child(even):hover td:last-child {
  background: #f4f8fe;
}
#catSpreadsheetDataTable tbody tr.spreadsheet-add-row td:last-child {
  background: #f0f7ff;
}

/* ---- 浮动保存栏 ---- */
.spreadsheet-save-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 12px 20px;
  margin: 0 14px 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-top: 3px solid var(--primary);
  border-radius: 0 0 12px 12px;
  box-shadow: 0 -1px 4px rgba(0,0,0,0.04);
}
.spreadsheet-save-bar .btn-save-bar {
  padding: 9px 32px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 620;
  cursor: pointer;
  transition: all 0.22s ease;
  box-shadow: 0 2px 6px rgba(37,99,235,0.25);
  white-space: nowrap;
  letter-spacing: 0.4px;
}
.spreadsheet-save-bar .btn-save-bar:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37,99,235,0.32);
}
.spreadsheet-save-bar .save-bar-info {
  font-size: 12.5px;
  color: #64748b;
  flex: 1;
}

/* ---- 空状态 ---- */
.spreadsheet-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #94a3b8;
  font-size: 14px;
  gap: 8px;
}
.spreadsheet-empty .empty-icon {
  font-size: 40px;
  opacity: 0.5;
  margin-bottom: 4px;
}

/* ---- 列表拖拽图片上传 ---- */
.img-dropzone {
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s, background 0.15s;
}
.img-dropzone-empty {
  color: #94a3b8;
}
.img-dropzone-hover {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.18), 0 2px 8px rgba(37,99,235,0.15) !important;
  transform: scale(1.1);
  background: #eff6ff !important;
  z-index: 5;
}

/* 图片缩略图悬停显示删除按钮 */
.has-img:hover .img-del-btn {
  display: inline-flex !important;
}

/* ===== V66 分组折叠订单表格（基础行样式，表头/容器由 V3 接管） ===== */
/* 分组行 */
.group-header-row {
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  border-left: 3px solid transparent;
}
.group-header-row:hover {
  background: var(--primary-bg) !important;
}
.group-header-row.group-open {
  border-left-color: var(--primary);
  background: #f8faff !important;
}
.group-header-row td {
  padding: 10px 14px;
  border-bottom: 1px solid #e8ecf3;
  font-weight: 500;
  color: #1e293b;
}
.group-header-row:nth-child(even) td {
  background: var(--primary-bg);
}
.group-header-row .group-toggle-cell {
  text-align: center;
  vertical-align: middle;
  padding: 10px 6px;
}
.group-header-row .group-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  line-height: 22px;
  border-radius: 4px;
  text-align: center;
  font-size: 10px;
  color: #64748b;
  background: #f1f5f9;
  transition: background 0.2s, color 0.2s;
  font-weight: 700;
}
.group-header-row:hover .group-toggle-icon {
  background: #D6E9F8;
  color: var(--primary);
}
/* 明细行 */
.group-detail-row td {
  padding: 7px 14px;
  border-bottom: 1px solid #f0f3f7;
  font-size: 12px;
  color: #64748b;
  background: #fafbfd;
  vertical-align: middle;
}
.group-detail-row:first-of-type td {
  border-top: 2px solid #e2e8f0;
}
.group-detail-row .detail-seq {
  width: 32px;
  text-align: center;
  color: #94a3b8;
  font-size: 11px;
  padding-left: 44px;
}
.group-detail-row .detail-code {
  font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
  font-size: 11.5px;
  color: var(--primary);
  font-weight: 500;
}
.group-detail-row .detail-name {
  font-weight: 500;
  color: #334155;
}
.group-detail-row .detail-qty,
.group-detail-row .detail-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: #1e293b;
}
.group-detail-row:hover td {
  background: var(--primary-bg);
}
.group-detail-row .detail-actions {
  white-space: nowrap;
}
.group-detail-row .detail-actions button {
  padding: 2px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #fff;
  color: #64748b;
  font-size: 11px;
  cursor: pointer;
  margin: 0 2px;
  transition: all 0.12s;
}
.group-detail-row .detail-actions button:hover {
  background: #eff6ff;
  color: var(--primary);
  border-color: #93c5fd;
}
/* 分组操作下拉 */
.group-actions-cell {
  position: relative;
  white-space: nowrap;
}
.group-actions-cell .btn-action-menu {
  padding: 4px 12px;
  border: 1px solid #D6E9F8;
  border-radius: 6px;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.15s;
}
.group-actions-cell .btn-action-menu:hover {
  background: #D6E9F8;
  border-color: #9DBFE0;
}
.group-actions-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 100;
  min-width: 140px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  padding: 4px 0;
  margin-top: 2px;
}
.group-actions-menu.show {
  display: block;
}
.group-actions-menu button {
  display: block;
  width: 100%;
  padding: 7px 14px;
  border: none;
  background: none;
  text-align: left;
  font-size: 12.5px;
  color: #334155;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.group-actions-menu button:hover {
  background: var(--primary-bg);
  color: var(--primary);
}
.group-actions-menu button.btn-danger-text:hover {
  background: #fef2f2;
  color: #dc2626;
}
/* 分组统计栏 */
.group-summary-bar {
  padding: 10px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e8ecf3;
  font-size: 12.5px;
  color: #64748b;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
/* 快速筛选Pills */
.group-filter-pills {
  display: flex;
  gap: 6px;
  padding: 10px 0;
  flex-wrap: wrap;
  align-items: center;
}
.group-filter-pill {
  padding: 5px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  background: #fafbfd;
  color: #475569;
  font-weight: 500;
  transition: all 0.15s;
  user-select: none;
}
.group-filter-pill:hover {
  border-color: #93c5fd;
  color: var(--primary);
  background: #eff6ff;
}
.group-filter-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}
.group-filter-pill .pill-count {
  font-size: 10px;
  opacity: 0.75;
  margin-left: 4px;
}
.group-filter-pill.active .pill-count {
  opacity: 1;
}
/* 分组表格空状态 */
.grouped-empty {
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
  font-size: 14px;
}
.grouped-empty-icon {
  font-size: 40px;
  opacity: 0.4;
  margin-bottom: 8px;
  display: block;
}
/* 分组明细内嵌表格 */
.group-detail-cell {
  padding: 0 !important;
  background: #f8fafc;
}
.detail-inner-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 0;
}
.detail-inner-table thead th {
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 10.5px;
  color: #64748b;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  letter-spacing: 0.2px;
}
.detail-inner-table td {
  padding: 5px 10px;
  border-bottom: 1px solid #f0f3f7;
  color: #475569;
  vertical-align: middle;
}
.detail-inner-table tbody tr:hover td {
  background: #EDF4FC;
}
.detail-inner-table .col-seq {
  width: 30px;
  text-align: center;
  color: #94a3b8;
  font-size: 10px;
  padding: 5px 6px !important;
}

/* ========== V4 销售订单分组表格：表头固定 + 表体滚动 ========== */

/* 1) 外层容器 */
.so-table-container {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.03);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 2) 表头区：固定在滚动区上方，不参与滚动（无底部分隔线，与 body 浑然一体） */
.so-header-wrap {
  flex: 0 0 auto;
  background: #0a0f1a;
}

/* 3) 表体区：独立滚动 */
.so-body-wrap {
  flex: 1 1 auto;
  overflow: auto;
  max-height: calc(100vh - 260px);
  scrollbar-gutter: stable;
}

/* 4) 两个表格共用基础样式 */
.so-header-table,
.so-body-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

/* 5) 表头单元格：深黑蓝底白字，高对比度，底边贴合 body 不留缝 */
.so-header-table th {
  background: #080d18;
  background: linear-gradient(180deg, #0a1224 0%, #111d36 100%);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 13px 14px;
  border-bottom: 1px solid #0a1224;
  border-right: 1px solid #192644;
  text-align: left;
  white-space: nowrap;
}
.so-header-table th:last-child { border-right: none; }
.so-header-table th.col-toggle {
  width: 36px;
  text-align: center;
  padding: 12px 6px;
}

/* 6) 表体单元格 */
.so-body-table td {
  border: none;
  border-bottom: 1px solid #eef0f4;
  padding: 8px 14px;
  vertical-align: middle;
}

/* 7) 单头行：深色醒目，奇数偶数交替 */
.so-body-table tbody tr.group-header-row.order-group-odd td {
  background: #d9e0eb;
}
.so-body-table tbody tr.group-header-row.order-group-even td {
  background: #cdd5e3;
}
/* 展开状态下与明细行融为一体，无底部分隔 */
.so-body-table tbody tr.group-header-row.group-open td {
  border-bottom: 1px solid #c0c8d6;
}
/* 折叠状态下保留分隔区分不同订单 */
.so-body-table tbody tr.group-header-row:not(.group-open) td {
  border-bottom: 2px solid #b0b9c8;
}

/* 8) 明细行：更浅的同色系，紧跟单头行 */
.so-body-table tbody tr.group-detail-row.order-detail-odd td {
  background: #eef1f7;
}
.so-body-table tbody tr.group-detail-row.order-detail-even td {
  background: #e5e9f2;
}

/* 9) 左边界状态色条 */
.group-header-row td:first-child { border-left: 3px solid transparent; }
.group-header-row.status-row-pending td:first-child  { border-left: 3px solid #f59e0b; padding-left: 13px; }
.group-header-row.status-row-processing td:first-child { border-left: 3px solid #3b82f6; padding-left: 13px; }
.group-header-row.status-row-done td:first-child       { border-left: 3px solid #22c55e; padding-left: 13px; }
.group-header-row.status-row-danger td:first-child     { border-left: 3px solid #ef4444; padding-left: 13px; }
.group-header-row.status-row-default td:first-child    { border-left: 3px solid #cbd5e1; padding-left: 13px; }

/* 10) 单头行通用：内边距 + 过渡 */
.group-header-row td {
  padding-top: 10px;
  padding-bottom: 10px;
  transition: background 0.18s ease, border-color 0.18s ease;
}

/* 11) 明细行分隔：仅弱分隔 */
.group-detail-row td {
  border-bottom: 1px solid #d5dae3;
}
.group-detail-row:last-of-type td {
  border-bottom: 2px solid #b0b9c8;
}

/* 12) 悬停反馈：单头行更深，明细行微变 */
.so-body-table tbody tr.group-header-row.order-group-odd:hover td {
  background: #cdd5e3;
}
.so-body-table tbody tr.group-header-row.order-group-even:hover td {
  background: #c0c9d9;
}
.so-body-table tbody tr.group-detail-row:hover td {
  background: #dce2ed;
}

/* 13) 明细内表 */
.detail-inner-table th,
.detail-inner-table td {
  border: 1px solid #e2e8f0;
}
.detail-inner-table thead th {
  background: #f1f5f9;
  border-bottom: 2px solid #cbd5e1;
  font-weight: 600;
  font-size: 11px;
  color: #475569;
}

/* ═══════════════════════════════════════════════════════
   V81 销售订单展开卡片
   ═══════════════════════════════════════════════════════ */

/* 展开行 - 去掉默认 td padding，让卡片撑满 */
tr.so-expand-row > td.so-expand-cell,
tr.po-expand-row > td.po-expand-cell,
tr.os-expand-row > td.os-expand-cell {
  padding: 0 16px 12px 16px;
  background: #ffffff !important;
  border-bottom: 2px solid #e2e8f0;
  overflow: visible !important;
  white-space: normal !important;
  text-overflow: clip !important;
  color: #0f172a !important;
}

/* 卡片主体 */
.so-expand-card {
  animation: soExpandIn 0.25s ease;
}

@keyframes soExpandIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 物品明细行 hover */
.so-expand-item-row:hover {
  background: #f8fafc !important;
}

/* 响应式：小屏时隐藏备注列 */
@media (max-width: 768px) {
  .so-expand-card .so-expand-items th:nth-child(6),
  .so-expand-card .so-expand-items td:nth-child(6) {
    display: none;
  }
}
