/* === 基础重置 === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: #f0f2f5;
  color: #1d2129;
  line-height: 1.6;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
}

/* === Header === */
.app-header {
  text-align: center;
  margin-bottom: 32px;
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.header-actions {
  display: flex;
  gap: 8px;
}
.header-row h1 { margin-bottom: 0; }
.app-header h1 { font-size: 28px; }
.subtitle { color: #86909c; font-size: 14px; margin-top: 8px; }

.btn-icon {
  width: 40px;
  height: 40px;
  border: 1px solid #e5e6eb;
  border-radius: 8px;
  background: #fff;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-icon:hover { background: #f0f5ff; border-color: #3370ff; }

/* === 列筛选弹窗 === */
.column-filter-popup {
  position: fixed;
  inset: 0;
  z-index: 2000;
}
.column-filter-panel {
  position: absolute;
  width: 260px;
  max-height: 400px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.column-filter-search input {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-bottom: 1px solid #e5e6eb;
  font-size: 13px;
  outline: none;
}
.column-filter-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.column-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}
.column-filter-item:hover { background: #f7f8fa; }
.column-filter-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #3370ff;
  flex-shrink: 0;
}
.column-filter-item .item-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.column-filter-actions {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid #e5e6eb;
}
.col-filter-btn {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #c9cdd4;
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  text-align: center;
}
.col-filter-btn:hover { background: #f2f3f5; }
.col-filter-confirm {
  background: #3370ff !important;
  color: #fff;
  border-color: #3370ff !important;
}
.col-filter-confirm:hover { background: #2356db !important; }

/* === 历史任务弹窗 === */
.history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 1000;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  padding-top: 60px;
}
.history-panel {
  width: 380px;
  max-height: 70vh;
  background: #fff;
  border-radius: 12px 0 0 12px;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.history-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e6eb;
}
.history-panel-header h3 { font-size: 16px; margin: 0; }
.history-close-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: #f2f3f5;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #86909c;
  display: flex;
  align-items: center;
  justify-content: center;
}
.history-close-btn:hover { background: #e5e6eb; color: #1d2129; }

.history-filter {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
}
.history-filter-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #c9cdd4;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
}
.history-filter-input:focus {
  border-color: #3370ff;
  box-shadow: 0 0 0 2px rgba(51,112,255,0.1);
}
.history-filter-select {
  padding: 6px 8px;
  border: 1px solid #c9cdd4;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
  white-space: nowrap;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s;
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: #f7f8fa; }
.history-item-info {
  flex: 1;
  min-width: 0;
}
.history-item-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-part-number {
  display: inline-block;
  background: #f0f5ff;
  color: #3370ff;
  font-weight: 600;
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 6px;
  white-space: nowrap;
}
.history-item-meta {
  font-size: 11px;
  color: #86909c;
  margin-top: 2px;
}
.history-status {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.history-status.completed { background: #e8ffea; color: #00b42a; }
.history-status.failed { background: #ffece8; color: #f53f3f; }
.history-status.pending { background: #fff7e8; color: #ff7d00; }
.history-open-btn {
  font-size: 12px;
  padding: 3px 10px;
  border: 1px solid #3370ff;
  border-radius: 4px;
  background: #fff;
  color: #3370ff;
  cursor: pointer;
  white-space: nowrap;
}
.history-open-btn:hover { background: #f0f5ff; }
.history-del-btn {
  font-size: 11px;
  padding: 3px 6px;
  border: 1px solid #c9cdd4;
  border-radius: 4px;
  background: #fff;
  color: #86909c;
  cursor: pointer;
  white-space: nowrap;
}
.history-del-btn:hover { border-color: #f53f3f; color: #f53f3f; }

/* === 表格筛选栏 === */
.table-filter-bar {
  padding: 8px 0 12px;
}
.table-filter-input {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid #e5e6eb;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.table-filter-input:focus {
  border-color: #3370ff;
  box-shadow: 0 0 0 3px rgba(51,112,255,0.08);
}

/* === 上传区域 === */
.upload-area {
  border: 2px dashed #c9cdd4;
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
}
.upload-area:hover, .upload-area.dragover {
  border-color: #3370ff;
  background: #f0f5ff;
}
.upload-icon { font-size: 48px; margin-bottom: 12px; }
.upload-text { font-size: 16px; margin-bottom: 8px; }
.upload-hint { font-size: 13px; color: #86909c; }

/* === 文件预览 === */
.file-preview {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.file-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.file-name { font-weight: 500; font-size: 15px; }
.file-size { color: #86909c; font-size: 13px; }

/* 多文件列表 */
.file-list {
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 12px;
  border: 1px solid #e5e6eb;
  border-radius: 6px;
  padding: 4px 0;
}
.file-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  font-size: 13px;
  color: #4e5969;
}
.file-list-item:not(:last-child) { border-bottom: 1px solid #f0f0f0; }
.file-list-item span:first-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.preview-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.preview-actions select {
  padding: 8px 12px;
  border: 1px solid #c9cdd4;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}

/* 品番输入 */
.part-number-input {
  display: flex;
  align-items: center;
  border: 1px solid #c9cdd4;
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.part-number-input:focus-within {
  border-color: #3370ff;
  box-shadow: 0 0 0 2px rgba(51,112,255,0.1);
}
.part-prefix {
  padding: 8px 4px 8px 12px;
  font-size: 14px;
  font-weight: 600;
  color: #4e5969;
  background: #f7f8fa;
  user-select: none;
  white-space: nowrap;
}
#partNumberInput {
  width: 70px;
  padding: 8px 12px 8px 4px;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: 'SF Mono', 'Fira Code', monospace, inherit;
  background: transparent;
  color: #1d2129;
}
#partNumberInput::placeholder {
  color: #c9cdd4;
  font-weight: 400;
}

/* === 按钮 === */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #3370ff; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #2356db; }
.btn-success { background: #00b42a; color: #fff; }
.btn-success:hover:not(:disabled) { background: #009a29; }
.btn-secondary { background: #f2f3f5; color: #1d2129; }
.btn-secondary:hover:not(:disabled) { background: #e5e6eb; }
.btn-danger { background: #f53f3f; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #cb2634; }
.load-btn { font-size: 13px; padding: 8px 16px; }

/* === 进度 === */
.progress-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.progress-card h3 { margin-bottom: 16px; }
.progress-bar-container {
  height: 8px;
  background: #e5e6eb;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3370ff, #6aa1ff);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.progress-text { font-size: 14px; color: #4e5969; }
.progress-log {
  margin-top: 12px;
  padding: 12px;
  background: #f7f8fa;
  border-radius: 6px;
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 12px;
  color: #86909c;
  max-height: 120px;
  overflow-y: auto;
}
.progress-log p { margin: 4px 0; }

/* === 结果 === */
.result-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}
.result-card h3 { margin-bottom: 8px; }
.result-summary { color: #4e5969; margin-bottom: 16px; }
.result-actions { display: flex; gap: 12px; }

/* 紧凑结果卡片 */
.result-card-compact {
  padding: 12px 24px;
  margin-bottom: 8px;
}
.result-card-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.result-card-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}
.result-card-compact .result-summary {
  margin-bottom: 0;
  font-size: 13px;
  white-space: nowrap;
}
.result-actions-compact {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
  min-width: 120px;
  text-align: center;
}

/* === 表格 === */
/* 工具栏（在滚动容器外面，不随滚动消失） */
.table-toolbar {
  background: #fafbfc;
  border: 1px solid #e5e6eb;
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 表格包裹层 */
.table-wrapper {
  border: 1px solid #e5e6eb;
  border-top: none;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}

/* 顶部水平滚动条 */
.top-scroll {
  height: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  background: #f7f8fa;
  border-bottom: 1px solid #e5e6eb;
}
.top-scroll::-webkit-scrollbar {
  height: 10px;
}
.top-scroll::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.25);
  border-radius: 5px;
}
.top-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.table-container {
  background: #fff;
  border-radius: 0;
  box-shadow: none;
  overflow-x: auto;
  max-height: 75vh;
  overflow-y: auto;
  position: relative;
  margin-top: 0;
}
/* 工具栏（在滚动容器外面） */
.table-toolbar {
  background: #fafbfc;
  border: 1px solid #e5e6eb;
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.result-table {
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.result-table th {
  background: #f2f3f5;
  padding: 10px 28px 10px 12px;
  padding-right: 14px; /* 留空间给 resize 高亮 */
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 2px solid #e5e6eb;
  position: sticky;
  top: 0;
  z-index: 10;
  cursor: pointer;
  user-select: none;
}
/* 列名行冻结 */
.result-table thead tr th {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #f2f3f5;
}
.result-table th .filter-icon {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  opacity: 0.4;
  transition: opacity 0.15s;
}
.result-table th:hover .filter-icon { opacity: 0.7; }
.result-table th.filtered .filter-icon { opacity: 1; color: #3370ff; }

/* 列宽拖拽右边缘高亮 */
.result-table th.resize-hover {
  cursor: col-resize !important;
  border-right: 2px solid #3370ff;
}
/* 序号列默认窄 */
.result-table thead tr th:first-child {
  width: 50px;
  min-width: 40px;
  max-width: 80px;
  text-align: center;
}
.result-table tbody td:first-child {
  text-align: center;
}

/* 工具栏按钮 */
.toolbar-btn {
  padding: 4px 12px;
  border: 1px solid #c9cdd4;
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.toolbar-btn:hover { border-color: #3370ff; color: #3370ff; background: #f0f5ff; }
.toolbar-btn.danger:hover { border-color: #f53f3f; color: #f53f3f; background: #ffece8; }
.toolbar-divider {
  width: 1px;
  height: 16px;
  background: #e5e6eb;
}
.toolbar-hint {
  font-size: 11px;
  color: #86909c;
  margin-left: auto;
}

/* 行选中样式 */
.result-table tr.row-selected td {
  background: #e8f0fe;
}
.result-table tr:hover td { background: #f7f8fa; }
.result-table tr.row-selected:hover td { background: #d2e3fc; }

/* 底部提示行 */
.add-row-row td {
  padding: 8px;
  border-top: 2px dashed #e5e6eb;
  text-align: center;
}
.result-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
}
.result-table td .instrument-select {
  width: 100%;
  min-width: 120px;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 3px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  cursor: pointer;
}
.result-table td .instrument-select:hover {
  border-color: #c9cdd4;
  background: #fff;
}
.result-table td .instrument-select:focus {
  border-color: #3370ff;
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(51,112,255,0.1);
}
.result-table tr:hover td { background: #f7f8fa; }

/* === 一般公差设置 === */
.tolerance-section { margin-bottom: 24px; }
.tolerance-details {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid #e5e6eb;
  overflow: hidden;
}
.tolerance-summary {
  padding: 14px 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #4e5969;
  user-select: none;
  list-style: none;
}
.tolerance-summary::-webkit-details-marker { display: none; }
.tolerance-summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform 0.2s;
}
.tolerance-details[open] .tolerance-summary::before {
  transform: rotate(90deg);
}
.tolerance-details[open] .tolerance-summary {
  border-bottom: 1px solid #e5e6eb;
  color: #1d2129;
}
.tolerance-body { padding: 16px 20px; }
.tolerance-toggle { margin-bottom: 12px; }
.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #4e5969;
  cursor: pointer;
}
.toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #3370ff;
}
.tolerance-config {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}
.tolerance-group label.tolerance-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #1d2129;
  margin-bottom: 8px;
}
.tolerance-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.preset-btn {
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid #c9cdd4;
  border-radius: 4px;
  background: #fff;
  color: #4e5969;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.preset-btn:hover:not(:disabled) {
  border-color: #3370ff;
  color: #3370ff;
  background: #f0f5ff;
}
.preset-btn:disabled {
  background: #f2f3f5;
  color: #86909c;
  cursor: default;
  border-color: #e5e6eb;
}
.tolerance-input, .tier-input {
  width: 70px;
  padding: 6px 8px;
  border: 1px solid #c9cdd4;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
}
.tier-max-input {
  width: 60px;
  padding: 6px 4px;
  border: 1px solid #c9cdd4;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
  background: #fff;
}
.tier-max-input:disabled {
  background: #f7f8fa;
  color: #86909c;
  border-color: transparent;
}
.tier-min-input {
  width: 60px;
  padding: 6px 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
  background: #f7f8fa;
  color: #4e5969;
}
.tier-sep {
  font-size: 13px;
  color: #86909c;
  padding: 0 4px;
  user-select: none;
}
.tier-add-btn {
  margin-top: 6px;
  padding: 4px 12px;
  border: 1px dashed #c9cdd4;
  border-radius: 4px;
  background: transparent;
  color: #86909c;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.tier-add-btn:hover { border-color: #3370ff; color: #3370ff; background: #f0f5ff; }
.tier-del-btn {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: #c9cdd4;
  cursor: pointer;
  font-size: 12px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  margin-left: 4px;
}
.tier-del-btn:hover { background: #ffece8; color: #f53f3f; }
.tolerance-input:focus, .tier-input:focus {
  outline: none;
  border-color: #3370ff;
  box-shadow: 0 0 0 2px rgba(51,112,255,0.1);
}
.tier-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tier-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #4e5969;
}
.tier-range {
  min-width: 56px;
  font-weight: 500;
}

/* === 错误 === */
.error-card {
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.error-card h3 { color: #f53f3f; margin-bottom: 12px; }
.error-text { color: #4e5969; margin-bottom: 20px; max-width: 500px; margin-left: auto; margin-right: auto; }

/* === 配置弹窗 === */
.config-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.config-panel {
  width: 520px;
  max-height: 80vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.config-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e6eb;
}
.config-panel-header h3 { font-size: 16px; margin: 0; }
.config-close-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: #f2f3f5;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #86909c;
  display: flex;
  align-items: center;
  justify-content: center;
}
.config-close-btn:hover { background: #e5e6eb; color: #1d2129; }

.config-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e5e6eb;
  padding: 0 20px;
}
.config-tab {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: #86909c;
  cursor: pointer;
  position: relative;
  transition: color 0.15s;
  white-space: nowrap;
}
.config-tab:hover { color: #4e5969; }
.config-tab.active {
  color: #3370ff;
}
.config-tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: #3370ff;
  border-radius: 1px 1px 0 0;
}

.config-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.config-section { }
.config-section h4 {
  font-size: 14px;
  font-weight: 600;
  color: #1d2129;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f0f0f0;
}
.config-list {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid #e5e6eb;
  border-radius: 6px;
  padding: 4px 0;
}
.config-list-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 13px;
}
.config-list-item:not(:last-child) { border-bottom: 1px solid #f0f0f0; }
.config-list-item input {
  flex: 1;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 3px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  outline: none;
}
.config-list-item input:focus {
  border-color: #3370ff;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(51,112,255,0.1);
}
.config-list-item .config-del-btn {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: #c9cdd4;
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.config-list-item .config-del-btn:hover { background: #ffece8; color: #f53f3f; }

.config-add-btn {
  margin-top: 6px;
  padding: 4px 12px;
  border: 1px dashed #c9cdd4;
  border-radius: 4px;
  background: transparent;
  color: #86909c;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.config-add-btn:hover { border-color: #3370ff; color: #3370ff; background: #f0f5ff; }

.config-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid #e5e6eb;
}

/* 表格下拉/输入框通用样式 */
.result-table td select.dim-select {
  width: 100%;
  min-width: 80px;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 3px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  cursor: pointer;
}
.result-table td select.dim-select:hover {
  border-color: #c9cdd4;
  background: #fff;
}
.result-table td select.dim-select:focus {
  border-color: #3370ff;
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(51,112,255,0.1);
}
/* 可输入下拉框样式 */
.result-table td input.dim-input {
  width: 100%;
  min-width: 70px;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 3px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
}
.result-table td input.dim-input:hover {
  border-color: #c9cdd4;
  background: #fff;
}
.result-table td input.dim-input:focus {
  border-color: #3370ff;
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(51,112,255,0.1);
}
/* 自定义下拉选项 hover */
.dim-dropdown-item:hover {
  background: #f0f5ff !important;
}
/* 键盘导航高亮 */
.dim-dropdown-item.dd-active {
  background: #e8f0fe !important;
  color: #1d6dff;
}

/* === 响应式 === */
@media (max-width: 768px) {
  .preview-actions { flex-direction: column; align-items: stretch; }
  .result-actions { flex-direction: column; }
  .result-table { font-size: 12px; }
  .result-table th, .result-table td { padding: 6px 8px; }
  .tolerance-config { grid-template-columns: 1fr; }
  .history-panel { width: 100%; max-width: 100%; border-radius: 0; }
  .history-overlay { padding-top: 0; }
  .config-panel { width: 95%; max-height: 90vh; }
}

/* === 品番冲突弹窗 === */
.part-number-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.part-number-dialog {
  width: 420px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  padding: 24px 28px;
  text-align: center;
}
.part-number-dialog h3 {
  font-size: 18px;
  margin-bottom: 12px;
  color: #1d2129;
}
.part-number-conflict-msg {
  font-size: 14px;
  color: #4e5969;
  margin-bottom: 20px;
  line-height: 1.8;
}
.part-number-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.part-number-dialog-actions .btn {
  min-width: 120px;
}

/* === 登录页 === */
.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 400px;
  max-width: 90vw;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
  padding: 40px 32px;
  text-align: center;
}
.login-card h2 {
  font-size: 24px;
  color: #1d2129;
  margin-bottom: 8px;
}
.login-subtitle {
  font-size: 14px;
  color: #86909c;
  margin-bottom: 28px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #e5e6eb;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.login-input:focus {
  border-color: #3370ff;
  box-shadow: 0 0 0 3px rgba(51,112,255,0.1);
}
.login-error {
  padding: 10px 14px;
  background: #fff1f0;
  border: 1px solid #ffccc7;
  border-radius: 8px;
  color: #cf1322;
  font-size: 13px;
  text-align: left;
}
.login-btn {
  padding: 12px 24px;
  background: #3370ff;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.login-btn:hover {
  background: #2860e1;
}
.login-btn:active {
  background: #1d4ed8;
}
.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.login-footer {
  margin-top: 20px;
  font-size: 12px;
  color: #c0c4cc;
}

/* === 当前用户显示 === */
.current-user {
  font-size: 13px;
  color: #4e5969;
  padding: 6px 10px;
  background: #f7f8fa;
  border-radius: 6px;
  white-space: nowrap;
}

/* === 管理员面板 === */
.admin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 3000;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-top: 60px;
}
.admin-panel {
  width: 680px;
  max-width: 95vw;
  max-height: 85vh;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.admin-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #f0f0f0;
}
.admin-panel-header h3 {
  font-size: 18px;
  color: #1d2129;
}
.admin-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  border-radius: 6px;
  color: #86909c;
  display: flex;
  align-items: center;
  justify-content: center;
}
.admin-close-btn:hover {
  background: #f0f0f0;
  color: #1d2129;
}
.admin-toolbar {
  padding: 12px 24px;
  border-bottom: 1px solid #f0f0f0;
}
.admin-user-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 24px;
}
.admin-empty {
  text-align: center;
  color: #86909c;
  padding: 40px 0;
  font-size: 14px;
}

/* 用户列表表格 */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table th {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 2px solid #f0f0f0;
  color: #86909c;
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.admin-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #f7f8fa;
  vertical-align: middle;
}
.admin-table tr:hover {
  background: #f7f8fa;
}
.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.status-badge.active {
  background: #e8f8e8;
  color: #2d8f2d;
}
.status-badge.disabled {
  background: #fff1f0;
  color: #cf1322;
}
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: #f0f0f0;
  color: #4e5969;
}
.role-badge.admin {
  background: #fff3e0;
  color: #e65100;
}
.admin-action-btn {
  padding: 4px 10px;
  border: 1px solid #e5e6eb;
  border-radius: 4px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  margin-right: 4px;
  transition: all 0.15s;
}
.admin-action-btn:hover {
  border-color: #3370ff;
  color: #3370ff;
  background: #f0f5ff;
}
.admin-action-btn.danger:hover {
  border-color: #ff4d4f;
  color: #ff4d4f;
  background: #fff1f0;
}

/* === 添加用户弹窗 === */
.add-user-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.add-user-dialog {
  width: 420px;
  max-width: 90vw;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  padding: 24px 28px;
}
.add-user-dialog h3 {
  font-size: 18px;
  color: #1d2129;
  margin-bottom: 20px;
}
.add-user-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-group label {
  display: block;
  font-size: 13px;
  color: #4e5969;
  margin-bottom: 6px;
}
.form-input, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e5e6eb;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus {
  border-color: #3370ff;
  box-shadow: 0 0 0 3px rgba(51,112,255,0.1);
}
.add-user-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}
