/* === BOM智能匹配工具 - 样式 === */
:root {
  --primary: #1e6ffb;
  --primary-dark: #1656cf;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #3b82f6;
  --info-bg: #eff6ff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 10px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.05);
  --radius: 10px;
  --radius-sm: 6px;
  /* 结果行 hover / 当前选中（浮层打开）的加深底色 + 左侧强调条 */
  --row-hover: #e9eef6;
  --row-hover-bar: var(--primary);
}

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

/* hidden 属性必须是最高优先级：.stats 的 display:grid、.filters 的 display:flex
   会盖掉浏览器对 [hidden] 的默认处理，导致「隐藏」失效
   （症状：清空结果后统计卡仍以全零显示 / 首次打开就看到 0 行统计卡） */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--gray-800);
  line-height: 1.5;
  font-size: 14px;
}

/* === TopBar === */
.topbar {
  background: linear-gradient(135deg, #1e6ffb 0%, #1656cf 100%);
  color: white;
  padding: 18px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  font-size: 32px;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.18);
  border-radius: 12px;
}
.brand h1 { font-size: 20px; font-weight: 600; }
.sub { font-size: 12px; opacity: 0.9; margin-top: 2px; }
.topbar-right { display: flex; gap: 10px; }
.link-btn {
  color: white;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  background: rgba(255,255,255,0.15);
  transition: background 0.2s;
}
.link-btn:hover { background: rgba(255,255,255,0.25); }
.link-btn.primary { background: white; color: var(--primary); font-weight: 600; }
.link-btn.primary:hover { background: #f5f5f5; }
/* .topbar-flat（BOM匹配主页扁平顶栏）样式见 theme.css —— theme.css 最后加载，
   必须在那里覆盖 .topbar 的深色主题 */

/* === Container === */
.container { max-width: 1400px; margin: 24px auto; padding: 0 24px; }

/* === Steps === */
.steps {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--surface);
  padding: 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.step {
  flex: 1;
  text-align: center;
  padding: 10px;
  font-size: 13px;
  color: var(--gray-500);
  border-radius: var(--radius-sm);
  position: relative;
}
.step span {
  display: inline-block;
  width: 22px; height: 22px;
  line-height: 22px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-500);
  font-weight: 600;
  margin-right: 6px;
}
.step.active {
  color: var(--primary);
  background: var(--info-bg);
  font-weight: 600;
}
.step.active span {
  background: var(--primary);
  color: white;
}
.step.done {
  color: var(--success);
}
.step.done span {
  background: var(--success);
  color: white;
}

/* === Card === */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

/* === Tabs === */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--gray-100); margin-bottom: 18px; }
.tab-btn {
  border: none;
  background: none;
  padding: 10px 18px;
  font-size: 14px;
  cursor: pointer;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.tab-btn:hover { color: var(--gray-700); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* === Dropzone === */
.dropzone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--primary);
  background: var(--info-bg);
}
.dz-icon { font-size: 48px; margin-bottom: 8px; }
.dz-title { font-size: 16px; font-weight: 600; color: var(--gray-700); }
.dz-hint { font-size: 12px; color: var(--gray-500); margin: 6px 0 14px; }
.file-info { margin-top: 12px; color: var(--success); font-size: 13px; }

/* === Textarea === */
textarea {
  width: 100%;
  padding: 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}
textarea:focus { border-color: var(--primary); }
.hint { font-size: 12px; color: var(--gray-500); margin-top: 6px; }

/* === Buttons === */
.actions { display: flex; gap: 10px; margin-top: 18px; }
.btn {
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}
.btn.primary { background: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.primary.big { padding: 14px 28px; font-size: 15px; font-weight: 600; }
.btn.ghost { background: var(--gray-100); color: var(--gray-700); }
.btn.ghost:hover { background: var(--gray-200); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Loading === */
.loading {
  background: var(--surface);
  padding: 30px;
  border-radius: var(--radius);
  text-align: center;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
/* 刷新后恢复上次匹配结果的提示条 */
.restore-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--info-bg);
  border: 1px solid #bfdbfe;
  border-left: 3px solid var(--info);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--gray-700);
}
/* （全局 [hidden] 规则已统一处理，无需再单独声明） */
.restore-icon {
  flex: none;
  position: relative;
  width: 14px; height: 14px;
  border: 1.5px solid var(--info);
  border-radius: 50%;
}
.restore-icon::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 4px; height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: var(--info);
}
.restore-text { flex: 1; line-height: 1.5; }
.restore-clear {
  flex: none;
  padding: 5px 12px;
  font-family: inherit;
  font-size: 12px;
  color: var(--info);
  background: var(--surface);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.restore-clear:hover { background: var(--info); color: #fff; }
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--gray-100);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-bar {
  width: 60%;
  max-width: 400px;
  height: 6px;
  background: var(--gray-100);
  border-radius: 3px;
  margin: 12px auto 0;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #4d8afc);
  width: 0;
  transition: width 0.3s;
}

/* === Stats === */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  padding: 18px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--gray-300);
}
.stat-card.success { border-left-color: var(--success); }
.stat-card.info { border-left-color: #2563eb; }
.stat-card.purple { border-left-color: #8b5cf6; }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.amount { border-left-color: #8b5cf6; }
.stat-label { font-size: 13px; color: var(--gray-500); margin-bottom: 4px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--gray-800); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.info .stat-value { color: #2563eb; }
.stat-card.purple .stat-value { color: #8b5cf6; }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.amount .stat-value { color: #8b5cf6; font-size: 22px; }
.stat-extra { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* === Filters === */
.filters {
  background: var(--surface);
  padding: 14px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}
.filter-group { display: flex; gap: 6px; }
.chip {
  border: 1.5px solid var(--gray-200);
  background: white;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  color: var(--gray-600);
  transition: all 0.15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.filter-right { display: flex; gap: 10px; align-items: center; }
.filter-right input {
  padding: 7px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  width: 220px;
}
.filter-right input:focus { border-color: var(--primary); }

/* === Table === */
.result-area {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: auto;
  max-height: 70vh;
}
.result-table {
  width: 100%;
  min-width: 1420px;
  border-collapse: collapse;
  font-size: 13px;
}
.result-table thead {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--gray-50);
  box-shadow: 0 1px 0 var(--gray-200);
}
.result-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: var(--gray-700);
  border-bottom: 1.5px solid var(--gray-200);
  white-space: nowrap;
}
.result-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: top;
  transition: background-color 0.12s ease, box-shadow 0.12s ease;
}
/* 鼠标划过 / 当前选中（对比或候选浮层打开）时，整行底色加深 + 首列蓝色强调条 */
.result-table tbody tr:hover td,
.result-table tbody tr.row-active td { background: var(--row-hover); }
.result-table tbody tr:hover td:first-child,
.result-table tbody tr.row-active td:first-child {
  box-shadow: inset 3px 0 0 var(--row-hover-bar);
}
.result-table tbody tr:hover { cursor: pointer; }
.result-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* === Status Tags === */
.status-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.status-tag.EXACT, .status-tag.已有物料, .status-tag.完全匹配 {
  background: var(--success-bg);
  color: var(--success);
}
.status-tag.SPEC, .status-tag.规格一致 {
  background: #eff6ff;
  color: #2563eb;
}
.status-tag.SUB, .status-tag.疑似可替代 {
  background: #f5f3ff;
  color: #8b5cf6;
}
.status-tag.PENDING, .status-tag.WEAK, .status-tag.待确认 {
  background: var(--warning-bg);
  color: var(--warning);
}
.status-tag.NOMATCH, .status-tag.无法匹配 {
  background: var(--danger-bg);
  color: var(--danger);
}

.pn {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-weight: 600;
  color: var(--gray-900);
}
.brand-tag {
  display: inline-block;
  padding: 1px 8px;
  background: var(--info-bg);
  color: var(--info);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-right: 4px;
}
.note-cell { font-size: 12px; color: var(--gray-600); max-width: 240px; }
.note-cell .substitute { color: #8b5cf6; font-weight: 500; }

/* === 「原始需求」三列（原型号 / 原封装 / 原参数）：BOM 实际输入 === */
.ori-pn-cell, .ori-fp-cell, .ori-desc-cell {
  font-size: 12px;
  color: var(--gray-700);
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ori-pn-cell { font-family: "SF Mono", Menlo, Consolas, monospace; max-width: 170px; }
.ori-pn-cell .ori-pn-val { font-weight: 600; color: var(--gray-900); }
.ori-fp-cell { font-family: "SF Mono", Menlo, Consolas, monospace; max-width: 150px; }
.ori-desc-cell { color: var(--gray-600); max-width: 220px; }
.ori-empty { color: var(--gray-300); }

/* === 「匹配结果」列（点击弹出对比） === */
.match-result-cell { cursor: pointer; min-width: 100px; }
.match-result-cell:hover .status-tag { filter: brightness(0.96); }
.pn-cell { font-family: "SF Mono", Menlo, Consolas, monospace; font-weight: 500; }
.pn-cell .pn-val {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

/* === 原始需求 / 匹配结果 对比浮层 === */
.cmp-popover {
  position: fixed;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  max-width: 92vw;
  overflow: auto;
  max-height: 80vh;
  animation: modalFadeIn 0.15s ease-out;
}
.cmp-popover[hidden] { display: none !important; }
.cmp-close {
  position: absolute;
  top: 5px; right: 7px;
  width: 26px; height: 26px;
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: var(--gray-400);
  cursor: pointer;
  border-radius: 50%;
}
.cmp-close:hover { background: var(--gray-100); color: var(--gray-700); }
.cmp-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 540px;
  font-size: 13px;
  table-layout: fixed; /* 固定布局：让「原始需求」「匹配结果」两列严格等宽 */
}
.cmp-table th, .cmp-table td {
  border: 1px solid var(--gray-200);
  padding: 9px 14px;
  text-align: left;
  vertical-align: top;
  line-height: 1.55;
}
.cmp-table th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
}
.cmp-table .cmp-dim { width: 84px; white-space: nowrap; }
/* 原始需求 / 匹配结果 两列等宽（扣除维度列后各占一半） */
.cmp-table .cmp-ori,
.cmp-table .cmp-res { width: calc((100% - 84px) / 2); }
.cmp-table .cmp-ori { word-break: break-word; }
.cmp-table td.cmp-dim { color: var(--gray-500); }
.cmp-table td.cmp-ori { color: var(--gray-800); }
.cmp-table td.cmp-res { color: #e5342b; font-weight: 500; word-break: break-word; }
.cmp-hint { color: var(--gray-400); font-weight: 400; font-size: 11px; margin-left: 5px; }
/* 弹窗内的对比表：自适应宽度、紧凑一点 */
.cmp-table.cmp-in-modal { min-width: 0; font-size: 12.5px; }
.cmp-table.cmp-in-modal th, .cmp-table.cmp-in-modal td { padding: 7px 10px; }
.cmp-table.cmp-in-modal .cmp-dim { width: 72px; }
.cmp-table.cmp-in-modal .cmp-ori,
.cmp-table.cmp-in-modal .cmp-res { width: calc((100% - 72px) / 2); }

/* === 「更换型号」列 + 候选选择浮层 === */
.swap-cell { text-align: center; white-space: nowrap; }
.swap-cell .swap-link {
  border: none;
  background: none;
  padding: 2px 4px;
  font-size: 13px;
  font-family: inherit;
  color: #1a73e8;
  cursor: pointer;
  border-radius: 4px;
}
.swap-cell .swap-link:hover { color: #0b57d0; background: #eef3fe; text-decoration: underline; }
.swap-cell .swap-link.is-swapped { color: var(--success, #16a34a); font-weight: 600; }
.swap-cell .swap-none { color: var(--gray-300); }
.swapped-mark {
  display: inline-block;
  padding: 0 6px;
  border-radius: 4px;
  background: #f5f3ff;
  color: #8b5cf6;
  font-weight: 500;
  font-size: 11px;
  margin-right: 4px;
}

.swap-popover {
  position: fixed;
  z-index: 61;
  width: 430px;
  max-width: 92vw;
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: modalFadeIn 0.15s ease-out;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}
.swap-popover[hidden] { display: none !important; }
.swap-head {
  position: relative;
  padding: 12px 40px 6px 16px;
  border-bottom: 1px solid var(--gray-100);
}
.swap-title { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.swap-sub { padding: 6px 16px; font-size: 12px; color: var(--gray-500); border-bottom: 1px solid var(--gray-100); }
.swap-sub b { color: var(--gray-800); font-family: "SF Mono", Menlo, Consolas, monospace; }
.swap-list { overflow-y: auto; padding: 6px 0; }
.swap-item {
  padding: 9px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.12s;
}
.swap-item:hover { background: var(--gray-50); border-left-color: #1a73e8; }
.swap-item.is-current { background: #f0fdf4; border-left-color: var(--success, #16a34a); cursor: default; }
.swap-item.is-current:hover { background: #f0fdf4; }
.swap-item-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.swap-item-pn {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-weight: 600;
  font-size: 13px;
  color: var(--gray-900);
}
.swap-tier {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 600;
}
.swap-tier.tier-1 { background: var(--success-bg); color: var(--success); }
.swap-tier.tier-2 { background: #eff6ff; color: #2563eb; }
.swap-tier.tier-3 { background: #fef3c7; color: #b45309; }
.swap-tier.tier-4 { background: var(--gray-100); color: var(--gray-500); }
.swap-cur-pill {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-weight: 600;
}
.swap-pick {
  margin-left: auto;
  font-size: 11px;
  color: #1a73e8;
  font-weight: 600;
}
.swap-item-meta {
  margin-top: 4px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--gray-500);
  align-items: center;
}
.swap-item-codes {
  margin-top: 3px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--gray-600);
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
.swap-item-codes .code-key {
  font-style: normal;
  font-family: inherit;
  color: var(--gray-400);
  margin-right: 4px;
  font-size: 10.5px;
}
.swap-item-near {
  margin-top: 4px;
  padding: 3px 7px;
  border-radius: 4px;
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  line-height: 1.4;
  word-break: break-word;
}
.swap-item-desc {
  margin-top: 3px;
  font-size: 11px;
  color: var(--gray-400);
  word-break: break-word;
}

.price { font-weight: 600; color: #ea580c; }
.subtotal { font-weight: 700; color: var(--gray-900); }
.score-pill {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  border-radius: 4px;
  background: var(--gray-100);
  color: var(--gray-500);
  margin-left: 4px;
  font-weight: 600;
}

/* 匹配等级徽章（已有物料/规格一致/疑似可替代） */
.level-pill {
  display: inline-block;
  padding: 1px 8px;
  font-size: 10px;
  border-radius: 999px;
  margin-left: 4px;
  font-weight: 600;
}
.level-pill.level-exact { background: var(--success-bg); color: var(--success); }
.level-pill.level-spec { background: #eff6ff; color: #2563eb; }
.level-pill.level-sub { background: #f5f3ff; color: #8b5cf6; }

/* 内部编码 / 客户编码标签 */
.code-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  background: #eef2ff;
  color: #25477E;
  border: 1px solid #c7d2fe;
  border-radius: 4px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-weight: 500;
}
.code-tag.small {
  padding: 1px 5px;
  font-size: 11px;
}
.ic-pill {
  display: inline-block;
  padding: 2px 10px;
  font-size: 12px;
  background: #ecfdf5;
  color: #047857;
  border-radius: 999px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-weight: 600;
  margin-left: 6px;
}
.dim { color: var(--gray-500); font-size: 12px; }

/* 同物料高亮（在 TOP 候选中也是同 internal_code 的项） */
.candidate.same-material {
  border-left: 3px solid #8b5cf6;
  background: linear-gradient(90deg, rgba(139,92,246,0.06), transparent 60%);
}
.badge-ic {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  border-radius: 4px;
  background: #8b5cf6;
  color: #fff;
  font-weight: 600;
}

/* === Empty === */
.empty {
  background: var(--surface);
  padding: 60px 20px;
  text-align: center;
  border-radius: var(--radius);
  color: var(--gray-500);
  box-shadow: var(--shadow-sm);
}
.empty-icon { font-size: 64px; margin-bottom: 8px; }
.empty-hint { font-size: 13px; color: var(--gray-400); margin-top: 4px; }

/* === Modal === */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
  animation: modalFadeIn 0.18s ease-out;
}
.modal[hidden] { display: none !important; }
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  overflow: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  font-size: 22px;
  cursor: pointer;
  color: var(--gray-500);
}
.modal-close:hover { background: var(--gray-200); color: var(--gray-800); }
.modal-card h2 { font-size: 18px; margin-bottom: 16px; color: var(--gray-800); }

.detail-section { margin-bottom: 20px; }
.detail-section h3 {
  font-size: 13px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
  padding-bottom: 4px;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.detail-item {
  display: flex; flex-direction: column;
  font-size: 13px;
}
.detail-item .label { color: var(--gray-500); font-size: 11px; }
.detail-item .value { color: var(--gray-800); font-weight: 500; }

.candidate-list { display: flex; flex-direction: column; gap: 8px; }
.candidate {
  padding: 12px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--gray-300);
}
.candidate.best { border-left-color: var(--success); background: var(--success-bg); }
.candidate .pn { font-size: 14px; }
.candidate-meta { display: flex; gap: 12px; margin-top: 4px; font-size: 12px; color: var(--gray-600); flex-wrap: wrap; }
.candidate-meta .reasons { color: var(--info); font-style: italic; }
.candidate-meta.desc-line { display: block; padding: 6px 10px; margin-top: 4px; background: var(--gray-100); border-radius: 4px; color: var(--gray-700); font-size: 12px; line-height: 1.5; word-break: break-all; }

/* === Footer === */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--gray-400);
  font-size: 12px;
}

/* === Responsive === */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .filters { flex-direction: column; align-items: stretch; }
  .filter-right { justify-content: space-between; }
  .filter-right input { width: auto; flex: 1; }
  .topbar { flex-direction: column; gap: 12px; }
  .steps { font-size: 12px; }
  .step span { display: block; margin: 0 auto 4px; }
}

/* === 登录页 === */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e6ffb 0%, #1656cf 55%, #0f3fa0 100%);
}
.login-card {
  background: var(--surface);
  width: 380px;
  max-width: calc(100vw - 40px);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 36px 36px 28px;
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand .logo { font-size: 42px; }
.login-brand h1 { font-size: 20px; margin: 6px 0 4px; color: var(--gray-900); }
.login-brand .sub { color: var(--gray-500); font-size: 13px; }
.login-card .field { display: block; margin-bottom: 16px; }
.login-card .field span {
  display: block; font-size: 13px; color: var(--gray-600); margin-bottom: 6px;
}
.login-card .field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-card .field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(30 111 251 / 0.15);
}
.login-err {
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.login-btn {
  width: 100%;
  padding: 11px 0;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.login-btn:hover { background: var(--primary-dark); }
.login-btn:disabled { opacity: .6; cursor: default; }
.login-tip {
  margin-top: 18px;
  text-align: center;
  color: var(--gray-400);
  font-size: 12px;
}

/* === 顶栏当前用户徽章 / 退出按钮 === */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgb(255 255 255 / 0.16);
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
}
#logout-btn { cursor: pointer; }
