/* ============================================================
   生产单智能生成系统 — Apple HIG (简洁、商务、克制)
   - Generous whitespace, hairline borders, restrained palette
   - 14px base, weights 400/500/600/700
   - One centered column (max 840px)
   - Section cards animate in (fade + 8px translateY, 200ms cubic-bezier)
   ============================================================ */

:root {
  /* ---- 中性色阶（更深的文字、更干净的分隔线）---- */
  --bg: #f5f6fa;
  --bg-grad:
    radial-gradient(1100px 520px at 88% -10%, #e9f0ff 0%, rgba(233, 240, 255, 0) 60%),
    radial-gradient(820px 460px at 4% -4%, #f1eeff 0%, rgba(241, 238, 255, 0) 55%),
    #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --surface-hover: #f4f7fe;

  --text: #0e1526;
  --text-1: #0e1526;   /* 修：此前被 var(--text-1) 引用但从未定义 */
  --text-2: #58617a;
  --text-3: #939db3;

  /* ---- 品牌主色 ---- */
  --accent: #1d5cf0;
  --accent-strong: #1749c4;
  --accent-light: #eef3ff;
  --accent-soft: rgba(29, 92, 240, .10);
  --accent-grad: linear-gradient(135deg, #2f6bff 0%, #1749c4 100%);
  --violet: #6d4aff;

  --green: #12a150;
  --green-soft: rgba(18, 161, 80, .12);
  --red: #e5484d;
  --red-soft: rgba(229, 72, 77, .12);
  --amber: #d98200;
  --amber-soft: rgba(217, 130, 0, .13);

  --hairline: #dfe3ec;
  --hairline-soft: #eceff5;
  --border-strong: #cbd3e2;

  /* ---- 圆角 ---- */
  --radius-card: 16px;
  --radius-btn: 10px;
  --radius-chip: 10px;
  --radius-input: 10px;

  /* ---- 阴影：分层，制造"浮起来"的层次感 ---- */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 8px -2px rgba(16, 24, 40, .07);
  --shadow-md: 0 10px 28px -10px rgba(16, 24, 40, .16), 0 2px 8px -3px rgba(16, 24, 40, .07);
  --shadow-lg: 0 28px 56px -20px rgba(16, 24, 40, .24), 0 6px 16px -6px rgba(16, 24, 40, .10);
  --shadow-accent: 0 6px 16px -6px rgba(29, 92, 240, .48);

  --ring: 0 0 0 3px var(--accent-soft);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
          "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "JetBrains Mono", "Cascadia Mono", "Cascadia Code",
               Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { font-weight: 600; color: var(--text); letter-spacing: -0.01em; }

/* ============================================================
   顶部栏
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--hairline);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #00b4ff);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.brand-title { font-size: 15px; font-weight: 600; color: var(--text); }
.brand-sub { font-size: 11px; color: var(--text-3); font-weight: 500; }
.status-pills { display: flex; align-items: center; gap: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-2);
  background: var(--bg);
  border: 1px solid var(--hairline);
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 500;
}
.pill .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 0 rgba(255, 149, 0, .4);
  flex-shrink: 0;
}
.pill .health-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pill.ok .dot { background: var(--green); box-shadow: 0 0 0 0 rgba(52, 199, 89, .4); }

/* ============================================================
   主区域：单列居中
   ============================================================ */
/* 注意：宽度/居中由 .app-main + .page 负责（见文件末尾「Apple HIG 侧边栏 + 多页面 SPA 布局」）。
   这里不再给 main 设 max-width / margin，否则会和 .app-main 的 flex 布局打架。 */

/* ============================================================
   Section cards (Apple HIG)
   .section 与 .card 是同一套卡片外观的两个别名：
   - .section   早期单页布局使用
   - .card      Phase 5 多页面 HTML 使用
   两者必须共享样式，否则页面会退化成无背景、无内边距的纯文本流。
   ============================================================ */
.section,
.card {
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-card);
  padding: 28px 32px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease;
}
.section:hover,
.card:hover { box-shadow: var(--shadow-md); }

.section-head,
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}
.section-title,
.card-head h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.section-hint,
.card-hint {
  font-size: 13px;
  color: var(--text-2);
}

/* 进入动画：fade + 8px translateY */
.section.anim-in,
.card.anim-in {
  opacity: 0;
  transform: translateY(8px);
  animation: sectionIn 200ms cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}
@keyframes sectionIn {
  to { opacity: 1; transform: none; }
}

.hidden { display: none !important; }

/* ============================================================
   Dropzone
   ============================================================ */
.dropzone {
  border: 1.5px dashed var(--hairline);
  border-radius: var(--radius-card);
  padding: 48px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  transition: all .15s ease;
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.dropzone input { display: none; }
.dz-icon {
  font-size: 36px;
  color: var(--accent);
  margin-bottom: 12px;
  font-weight: 300;
}
.dz-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.dz-sub {
  font-size: 13px;
  color: var(--text-2);
}
.dz-link {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .12s;
}
.dz-link:hover { border-bottom-color: var(--accent); }

body.file-dragover::after {
  content: "松开鼠标，将文件添加到列表";
  position: fixed; inset: 0; z-index: 9998;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 113, 227, .06);
  backdrop-filter: blur(4px);
  color: var(--accent);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  pointer-events: none;
}

/* ============================================================
   文件 chips
   ============================================================ */
.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-chip);
  padding: 6px 12px 6px 14px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: all .12s ease;
  font-weight: 500;
}
.file-chip:hover {
  background: #fff5f5;
  border-color: #fbb;
  color: var(--red);
}
.file-chip .file-x {
  display: inline-flex;
  width: 16px; height: 16px;
  align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--hairline-soft);
  color: var(--text-2);
  font-size: 11px;
  line-height: 1;
  margin-left: 2px;
}
.file-chip:hover .file-x { background: var(--red); color: #fff; }

/* ============================================================
   Buttons (统一圆角、克制)
   ============================================================ */
.btn {
  height: 40px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-btn);
  padding: 0 18px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all .15s ease;
  letter-spacing: -0.005em;
}
.btn:hover { background: var(--bg); border-color: var(--text-3); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface); border-color: var(--hairline); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: #0077ed;
  border-color: #0077ed;
}
.btn-primary:disabled:hover { background: var(--accent); border-color: var(--accent); }

.btn-large {
  height: 52px;
  padding: 0 28px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-btn);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
}
.btn-ghost:hover { background: var(--accent-light); border-color: transparent; color: var(--accent); }

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
  font-size: 16px;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* ============================================================
   Inputs & form fields
   ============================================================ */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: -0.005em;
}
input[type="text"],
input[type="search"],
input[type="date"],
input[type="number"],
input[type="password"],
select {
  height: 40px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-input);
  padding: 0 14px;
  font-size: 14px;
  color: var(--text);
  font-family: var(--font);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-weight: 400;
}
input:hover { border-color: var(--text-3); }
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-light);
}
input::placeholder { color: var(--text-3); }

/* 客户主输入：32px 高 · 加大字号 · hairline */
input.input-big {
  height: 56px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  border-radius: 12px;
  padding: 0 18px;
}

/* ============================================================
   Section B 客户卡片（核心）
   ============================================================ */
.customer-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.customer-row .field-label {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.customer-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}
.customer-status .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-3);
}
.customer-status.is-existing { color: var(--green); }
.customer-status.is-existing .dot { background: var(--green); }
.customer-status.is-new { color: var(--accent); }
.customer-status.is-new .dot { background: var(--accent); }
.customer-status.is-local { color: #5856d6; }
.customer-status.is-local .dot { background: #5856d6; }
.customer-status.is-down { color: var(--amber); }
.customer-status.is-down .dot { background: var(--amber); }

.customer-card {
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-card);
  padding: 20px 22px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}
.customer-card.is-existing { border-left: 3px solid var(--green); }
.customer-card.is-new      { border-left: 3px solid var(--accent); }
.customer-card.is-local    { border-left: 3px solid #5856d6; }

.customer-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.customer-card-name {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.customer-card-display {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 2px;
}
.customer-card-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.01em;
}
.tag.is-vip { background: #fff5e0; color: #b45309; }
.tag.is-warn { background: #fff5f5; color: var(--red); }

.customer-card-meta {
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}
.customer-card-meta b { color: var(--text); font-weight: 600; }

.order-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 6px;
  scrollbar-width: thin;
}
.order-scroll::-webkit-scrollbar { height: 6px; }
.order-scroll::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 3px; }
.order-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-chip);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: all .15s ease;
  font-weight: 500;
}
.order-chip:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.order-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.order-chip.is-active .oc-meta { color: rgba(255,255,255,.8); }
.order-chip .oc-bill { font-weight: 600; }
.order-chip .oc-meta { color: var(--text-3); font-size: 11px; }

.order-chip.is-flash {
  animation: orderFlash 800ms ease;
}
@keyframes orderFlash {
  0%   { background: #fff7cc; border-color: #ffd60a; }
  100% { background: var(--surface); border-color: var(--hairline-soft); }
}

.candidate-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.candidate-row .candidate-label {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
}
.candidate-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
  font-weight: 500;
  transition: all .12s;
}
.candidate-pill:hover { border-color: var(--accent); color: var(--accent); }
.candidate-pill.is-active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.picker-link {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  font-family: var(--font);
}
.picker-link:hover { text-decoration: underline; }

/* ============================================================
   Section C 合同 & 款号
   ============================================================ */
.form-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 14px;
  align-items: end;
}
.main-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  background: rgba(52, 199, 89, .12);
  border: 1px solid rgba(52, 199, 89, .35);
  border-radius: var(--radius-chip);
  padding: 8px 14px;
  font-size: 13px;
  color: #1f7a3a;
  font-weight: 500;
}
.main-chip b { font-weight: 600; }
.main-chip.is-flash { animation: orderFlash 800ms ease; }

/* ============================================================
   Section D 提取
   ============================================================ */
.extract-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: flex-start;
}
.table-checks {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--hairline-soft);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-2);
  transition: all .15s ease;
  user-select: none;
}
.check-chip:hover { border-color: var(--accent); color: var(--text); }
.check-chip input { accent-color: var(--accent); margin: 0; }
.check-chip:has(input:checked) {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.progress-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 12px 0 6px;
}
.stage-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.005em;
}
.stage-pct {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.progress {
  height: 6px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
#progressBar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width .3s ease;
}

.log {
  font-family: "JetBrains Mono", "SF Mono", "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  background: var(--bg);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-chip);
  padding: 12px 16px;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 12px;
}
.log .line { display: flex; gap: 10px; align-items: baseline; padding: 1px 0; }
.log .ts { color: var(--text-3); flex-shrink: 0; font-size: 11px; font-variant-numeric: tabular-nums; }
.log .ic { flex-shrink: 0; }
.log .msg { color: var(--text-2); word-break: break-all; }
.log .msg.stage { color: var(--accent); }
.log .msg.ok { color: var(--green); }
.log .msg.err { color: var(--red); }
.log .msg.final { color: var(--amber); font-weight: 600; }

/* ============================================================
   Section E 提取结果
   ============================================================ */
#validationBox {
  font-size: 13px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#validationBox .err { color: var(--red); }
#validationBox .warn { color: var(--amber); }
#validationBox .pass { color: var(--green); }

.summary-strip {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.summary-row {
  border-radius: var(--radius-chip);
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.55;
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--hairline-soft);
  background: var(--bg);
}
.summary-row ul { margin: 4px 0 0 0; padding-left: 18px; }
.summary-row li { margin: 2px 0; white-space: normal; }
.summary-row.rule { background: var(--accent-light); border-color: rgba(0,113,227,.25); color: var(--accent); }
.summary-row.review { background: #fff8e6; border-color: rgba(255,149,0,.3); color: #b45309; }
.summary-row.empty { display: none; }
.summary-row .summary-title { font-weight: 600; }

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  background: var(--bg);
  border-radius: 10px;
  width: fit-content;
}
.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all .15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  font-family: var(--font);
}
.tab em {
  font-style: normal;
  font-size: 11px;
  background: rgba(0,0,0,.06);
  border-radius: 999px;
  padding: 1px 7px;
  color: var(--text-2);
  font-weight: 600;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.tab.active em { background: var(--accent-light); color: var(--accent); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-chip);
  background: var(--surface);
}
table {
  border-collapse: collapse;
  font-size: 13px;
  width: 100%;
  min-width: 660px;
}
th, td {
  border-bottom: 1px solid var(--hairline-soft);
  padding: 10px 12px;
  white-space: nowrap;
}
th {
  background: var(--bg);
  color: var(--text-2);
  font-weight: 600;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 2;
  font-size: 12px;
  letter-spacing: 0.01em;
}
td { color: var(--text); }
tbody tr { transition: background .1s; }
tbody tr:hover { background: rgba(0,113,227,.04); }
td input {
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  min-width: 70px;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  transition: all .12s;
}
td input:hover { border-color: var(--hairline); }
td input:focus {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(0,113,227,.12);
}

/* 类别徽章 */
.cat-badge {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.cat-badge.cat-main    { background: rgba(0,113,227,.12); color: var(--accent); border-color: rgba(0,113,227,.25); }
.cat-badge.cat-filling { background: rgba(255,149,0,.14); color: #b45309; border-color: rgba(255,149,0,.3); }
.cat-badge.cat-lining  { background: rgba(88,86,214,.14); color: #5856d6; border-color: rgba(88,86,214,.3); }
.cat-badge.cat-inter   { background: rgba(52,199,89,.14); color: #1f7a3a; border-color: rgba(52,199,89,.3); }
.cat-badge.cat-other   { background: var(--bg); color: var(--text-2); border-color: var(--hairline-soft); }
.cat-badge.is-empty    { background: transparent; color: var(--text-3); border-color: var(--hairline-soft); font-weight: 400; }

.weight-note {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 3px;
  line-height: 1.4;
  white-space: normal;
}
.rule-note {
  display: block;
  font-size: 11px;
  color: var(--amber);
  margin-top: 2px;
  line-height: 1.4;
  white-space: normal;
  max-width: 320px;
}
.rule-note::before { content: "⚠ "; }
.muted-line {
  display: block;
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
  white-space: normal;
}
.muted-sup {
  vertical-align: super;
  font-size: 10px;
  color: var(--text-3);
  margin-left: 3px;
  cursor: help;
}

.candidates {
  border: 1px solid var(--hairline-soft);
  background: var(--bg);
  border-radius: var(--radius-chip);
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-2);
}
.candidates .item {
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
}
.candidates .item:hover { background: var(--accent-light); }
.candidates .item.selected { background: var(--accent-light); font-weight: 600; color: var(--accent); }

.hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 8px;
  white-space: pre-wrap;
  line-height: 1.7;
}
.hint.success { color: var(--green); }
.hint.fail { color: var(--red); }
.hint.warn { color: var(--amber); }

/* 取材覆盖情况：告诉用户"这次到底喂了多少、有没有文件被落下"。
   以前这一步完全静默 —— 4 个文件只用了 2 个也照样显示"总结完成"，
   用户只会觉得"AI 分析得不对"。 */
.coverage-note {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-card);
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  border-left: 3px solid var(--amber);
  font-size: 12px;
  line-height: 1.75;
  color: var(--text-2);
  white-space: pre-wrap;
}
.coverage-note .cn-title { font-weight: 600; color: var(--text-1); }
.coverage-note.is-ok {
  background: color-mix(in srgb, var(--green) 10%, transparent);
  border-left-color: var(--green);
}

/* ============================================================
   Section F 粘性底栏
   ============================================================ */
.action-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 24px;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--hairline);
  animation: sectionIn 240ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.action-bar-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-right: auto;
  padding-left: 8px;
  font-weight: 500;
}
.action-bar-actions { display: inline-flex; gap: 10px; }

/* ============================================================
   Modal (LLM 设置 + 客户名册 Sheet)
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  backdrop-filter: blur(8px);
  animation: fadeIn .18s ease;
}
.modal-panel {
  position: relative;
  width: min(560px, calc(100vw - 40px));
  max-height: 85vh;
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalIn .22s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--hairline-soft);
  flex-shrink: 0;
}
.modal-head h3 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.modal-x {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--text-3);
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-x:hover { background: var(--bg); color: var(--text); }
.modal-body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  flex: 1;
}
.modal-body .field { gap: 6px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--hairline-soft);
  background: var(--bg);
  flex-shrink: 0;
}

/* 客户名册 Sheet：上滑抽屉 */
.modal-panel.is-sheet {
  width: 100%;
  max-width: 720px;
  height: 80vh;
  max-height: 80vh;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  animation: sheetIn .28s cubic-bezier(0.22, 0.61, 0.36, 1);
}
@keyframes sheetIn {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.sheet-search {
  position: relative;
}
.sheet-search input {
  width: 100%;
  height: 44px;
  border-radius: var(--radius-btn);
  font-size: 15px;
  padding: 0 14px 0 40px;
}
.sheet-search::before {
  content: "🔍";
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: .55;
}
.sheet-status {
  font-size: 12px;
  color: var(--text-3);
}
.sheet-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-chip);
  background: var(--surface);
}
.sheet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--hairline-soft);
  cursor: pointer;
  transition: background .12s;
}
.sheet-row:last-child { border-bottom: none; }
.sheet-row:hover { background: var(--bg); }
.sheet-row-name { font-weight: 600; font-size: 14px; }
.sheet-row-meta { font-size: 12px; color: var(--text-3); }
.sheet-row-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}
.sheet-row-tag {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  background: rgba(88,86,214,.14);
  color: #5856d6;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

.muted { font-style: normal; font-weight: 400; color: var(--text-3); font-size: 12px; }
.settings-note {
  font-size: 12px;
  color: var(--text-2);
  background: var(--bg);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-chip);
  padding: 8px 12px;
}
/* 无内容时不显示（否则设置页会多出一条空灰条） */
.settings-note:empty { display: none; }

/* ============================================================
   Toast
   ============================================================ */
#toastBox {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
}
.toast {
  min-width: 220px;
  max-width: 380px;
  padding: 10px 16px;
  border-radius: var(--radius-btn);
  font-size: 13px;
  line-height: 1.5;
  word-break: break-all;
  background: var(--surface);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-md);
  display: flex;
  gap: 8px;
  align-items: flex-start;
  animation: toastIn .2s ease;
  font-weight: 500;
}
.toast::before { font-size: 14px; flex-shrink: 0; }
.toast.success::before { content: "✓"; color: var(--green); }
.toast.error::before   { content: "✕"; color: var(--red); }
.toast.info::before    { content: "ⓘ"; color: var(--accent); }
.toast.warning::before { content: "⚠"; color: var(--amber); }
.toast.success { border-color: rgba(52,199,89,.3); }
.toast.error   { border-color: rgba(255,59,48,.3); }
.toast.info    { border-color: rgba(0,113,227,.3); }
.toast.warning { border-color: rgba(255,149,0,.3); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}
.toast.leaving { transition: all .2s; opacity: 0; }

.footer {
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  padding: 12px 0 32px;
  font-weight: 500;
}

/* ============================================================
   📜 历史记录 section（仍保留为单独可切换 section）
   ============================================================ */
.records-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.records-filters {
  display: grid;
  grid-template-columns: 1fr 1fr 0.7fr;
  gap: 12px;
  margin-bottom: 14px;
}
.records-filters .field-label { font-size: 12px; }
.records-filters input,
.records-filters select { height: 38px; font-size: 13px; }

.records-table-wrap { max-height: 420px; overflow: auto; }
.records-table-wrap table {
  table-layout: fixed;
  width: 100%;
  min-width: 940px;
}
.records-table-wrap tbody tr { cursor: pointer; }
.records-table-wrap tbody tr.is-active { background: var(--accent-light); }

/* 长文本列截断：历史（9 列）/规则（6 列）/批次（6 列）表的列数多，
   款号或规则摘要一长就把整表撑到 900px+，结果必须在卡片里横向滚动
   才能点到最右边的「操作」按钮。
   做法：表格改 table-layout: fixed 并显式分配列宽，普通单元格单行省略；
   操作列给足固定宽度并豁免省略（否则三个按钮会被裁掉）。
   ⚠️ 只给 td 设 max-width 是无效的 —— auto 布局下 nowrap 的 min-content
   宽度会赢过 max-width，所以必须配合 fixed 布局才能真正约束列宽。 */
.records-table-wrap th,
.records-table-wrap td,
.rules-table-wrap th,
.rules-table-wrap td,
.archive-table-wrap th,
.archive-table-wrap td {
  overflow: hidden;
  text-overflow: ellipsis;
}
.records-table-wrap th:last-child,
.records-table-wrap td:last-child,
.rules-table-wrap th:last-child,
.rules-table-wrap td:last-child,
.archive-table-wrap th:last-child,
.archive-table-wrap td:last-child {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

/* 历史记录表（9 列）列宽：ID / 创建时间 / 最后阶段 / 行数 / 状态 / 操作 用固定值，
   客户 / 款号 / 制单 三列在 fixed 布局下自动均分剩余宽度。
   固定列合计 688px，配 940px 的 min-width 时三个弹性列各得 ~84px，仍可读。 */
.records-table-wrap th:nth-child(1) { width: 72px; }
.records-table-wrap th:nth-child(5) { width: 142px; }
.records-table-wrap th:nth-child(6) { width: 100px; }
.records-table-wrap th:nth-child(7) { width: 64px; }
.records-table-wrap th:nth-child(8) { width: 110px; }
.records-table-wrap th:nth-child(9) { width: 200px; }

.records-empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}
.records-filter-summary { margin-bottom: 12px; color: var(--text-2); }
.records-empty p { margin: 0 0 12px; }
.records-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
#sectionRecords .records-tools { flex-wrap: wrap; }

.status-badge {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.status-badge.passed   { background: rgba(52,199,89,.14); color: #1f7a3a; border-color: rgba(52,199,89,.3); }
.status-badge.failed   { background: rgba(255,59,48,.12); color: var(--red); border-color: rgba(255,59,48,.3); }
.status-badge.partial  { background: rgba(255,149,0,.14); color: #b45309; border-color: rgba(255,149,0,.3); }
.status-badge.status-passed { background: rgba(52,199,89,.14); color: #1f7a3a; border-color: rgba(52,199,89,.3); }
.status-badge.status-failed { background: rgba(255,59,48,.12); color: var(--red); border-color: rgba(255,59,48,.3); }

.records-detail {
  margin-top: 16px;
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  background: var(--bg);
}
.records-detail-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
.records-detail-head h3 { font-size: 15px; font-weight: 600; }
.records-actions { display: inline-flex; gap: 6px; }

.stage-timeline {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-chip);
  margin-bottom: 12px;
}
.stage-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--hairline-soft);
  background: var(--bg);
  color: var(--text-3);
  cursor: default;
  user-select: none;
  transition: all .15s;
  font-weight: 500;
}
.stage-dot.clickable { cursor: pointer; }
.stage-dot.clickable:hover { border-color: var(--accent); color: var(--accent); }
.stage-dot.done {
  background: rgba(52,199,89,.14); color: #1f7a3a; border-color: rgba(52,199,89,.3);
}
.stage-dot .stage-dot-icon {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--hairline);
  flex-shrink: 0;
}
.stage-dot.done .stage-dot-icon { background: var(--green); }

.records-section {
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-chip);
  padding: 12px 16px;
}
.records-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.records-section ul { margin: 4px 0 0 18px; font-size: 12px; line-height: 1.6; }
.records-section li.err { color: var(--red); }
.records-section li.warn { color: var(--amber); }
.records-section .rule-list li { color: var(--text-2); white-space: pre-wrap; }
.records-section .file-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.records-section .file-list .file-chip {
  cursor: default;
  background: var(--bg);
  color: var(--text-2);
  border-color: var(--hairline-soft);
}
.records-section .file-list .file-chip:hover {
  background: var(--bg); border-color: var(--hairline-soft); color: var(--text-2);
}
.records-section .file-list .file-chip .file-x { display: none; }

.snapshot-pre {
  margin-top: 8px;
  background: #1d1d1f;
  color: #e8e8ed;
  border-radius: var(--radius-chip);
  padding: 12px 14px;
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 11px;
  line-height: 1.55;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.snapshot-loading { color: var(--text-3); font-size: 12px; padding: 6px 0; }

.records-row-preview {
  position: absolute;
  z-index: 50;
  max-width: 320px;
  background: var(--text);
  color: #fff;
  font-size: 11px;
  line-height: 1.6;
  padding: 8px 12px;
  border-radius: var(--radius-chip);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  white-space: pre-wrap;
  font-weight: 500;
}

.btn.is-resuming { opacity: .85; }
.records-op-btn {
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: 8px;
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 720px) {
  main { padding: 0 16px; gap: 20px; }
  .section { padding: 22px 18px; }
  .section-title { font-size: 18px; }
  input.input-big { font-size: 18px; height: 50px; }
  .form-row { grid-template-columns: 1fr; }
  .records-filters { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
  .brand-sub { display: none; }
  .action-bar { flex-wrap: wrap; padding: 12px 16px; }
  .action-bar-hint { display: none; }
}

/* ============================================================
   📚 客户规则库
   ============================================================ */
.rules-table-wrap { max-height: 420px; overflow: auto; }
.rules-table-wrap table {
  table-layout: fixed;
  width: 100%;
  min-width: 780px;
}
/* 规则库表（6 列）：简称/样例数/更新时间/操作用固定宽度，
   全称与规则摘要两列吃剩余宽度（摘要列保持换行，见 .rule-summary-cell）。 */
.rules-table-wrap th:nth-child(1) { width: 112px; }
.rules-table-wrap th:nth-child(4) { width: 72px; }
.rules-table-wrap th:nth-child(5) { width: 150px; }
.rules-table-wrap th:nth-child(6) { width: 168px; }
.rules-table-wrap tbody tr { cursor: pointer; }
.rule-summary-cell {
  max-width: 320px;
  white-space: normal !important;
  color: var(--text-2);
  font-size: 12px;
  line-height: 1.5;
}

/* 上传区（卡片内嵌的子面板） */
.rules-upload-section {
  margin: 4px 0 16px;
  padding: 16px 18px;
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-card);
  background: var(--bg);
}
.rules-upload-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.rules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.rules-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

/* 🧪 对照组构建器 —— 一组 = 多份原件 ↔ 多份业务员版（N:M），可加多组 */
.rule-groups-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 6px 0 8px;
}
.rule-groups { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.rule-group {
  border: 1px solid var(--hairline-soft);
  border-radius: 12px;
  background: var(--surface);
  padding: 12px 14px;
}
.rule-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.rule-group-title { font-size: 13px; font-weight: 600; }
.rule-group-body { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rule-group-side .field-label { display: block; margin-bottom: 6px; }
.rule-group-side input[type="file"] { width: 100%; font-size: 12px; }
.rule-group-count { font-size: 12px; color: var(--text-2); margin-top: 4px; min-height: 16px; }
@media (max-width: 880px) {
  .rule-group-body { grid-template-columns: 1fr; }
}

/* 规则详情里的「样例对照组」（可逐个删文件 / 追加文件） */
.rule-sample-group {
  border: 1px solid var(--hairline-soft);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px 12px;
  margin-bottom: 8px;
}
.rule-sample-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  font-size: 13px;
}
.rule-sample-file { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rule-sample-side { font-size: 12px; color: var(--text-2); flex-shrink: 0; }
.rule-sample-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* 「重新总结」结果条：贴在规则详情底部，让用户先过一眼再决定覆盖 */
.rule-resummary {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid var(--hairline-soft);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  background: var(--bg);
}
.rules-upload-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

/* AI 预览面板（编辑字段） */
.rules-preview {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px dashed rgba(0, 113, 227, .35);
  border-radius: var(--radius-chip);
  background: var(--accent-light);
}
.rules-preview-head h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--accent);
}
.rules-preview-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.rules-preview textarea {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-input);
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  line-height: 1.5;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.rules-preview textarea:hover { border-color: var(--text-3); }
.rules-preview textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, .15);
}
.rules-preview code {
  background: rgba(0, 0, 0, .06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-2);
}

/* 详情面板里的字段映射表 */
.rule-mapping-wrap { max-height: 320px; overflow: auto; }

/* 「基本翻译规则」列表 —— 规则库的核心产出，做成有序号、可扫读的清单 */
.rule-rules-list {
  margin: 0;
  padding-left: 22px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--text);
}
/* pre-wrap：模型常把「- 子项A / - 子项B」写在一条规则里，换行要保留可读性 */
.rule-rules-list li { margin-bottom: 7px; padding-left: 2px; white-space: pre-wrap; }
.rule-rules-list li::marker { color: var(--accent); font-weight: 600; }
.rule-rules-list b { color: var(--accent-strong, var(--accent)); }
.rule-summary-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-chip);
  padding: 10px 14px;
}

/* ---- 🏭 ERP 共性规则（事实统计，置顶区块） ---- */
.erp-rules {
  margin: 0;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Cascadia Mono", monospace;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-chip);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-height: 520px;
  overflow-y: auto;
}
.erp-banner {
  margin: 8px 0 12px;
  padding: 10px 14px;
  border-radius: var(--radius-chip);
  border: 1px solid var(--hairline-soft);
  background: var(--surface-2);
}
.erp-banner-warn {
  border-color: var(--amber);
  background: var(--amber-soft);
}
.erp-banner-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}
.erp-banner-head .muted { font-weight: 400; }
.erp-banner .erp-rules { margin-top: 6px; max-height: 360px; }
.erp-err { color: var(--red); font-size: 13px; }
.btn.btn-xs { padding: 3px 9px; font-size: 12px; border-radius: 7px; }

/* 匹配成功后的 banner（绿色调） */
.rules-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 12px;
  padding: 8px 12px;
  border-radius: var(--radius-chip);
  border: 1px solid rgba(52, 199, 89, .3);
  background: rgba(52, 199, 89, .1);
  color: #1f7a3a;
  font-size: 13px;
  animation: bannerIn .25s ease;
}
@keyframes bannerIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.rules-banner-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.rules-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.rules-banner-text b { font-weight: 600; }
.rules-banner-sub {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 400;
  white-space: normal;
  line-height: 1.45;
}
.rules-banner-link {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  color: var(--green);
  background: var(--surface);
  border: 1px solid rgba(52, 199, 89, .35);
  border-radius: 8px;
}
.rules-banner-link:hover {
  background: rgba(52, 199, 89, .14);
  color: #1f7a3a;
  border-color: rgba(52, 199, 89, .5);
}
.rules-banner-x {
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 16px;
  border-radius: 50%;
  color: var(--text-3);
  background: transparent;
  border: none;
}
.rules-banner-x:hover {
  background: rgba(0, 0, 0, .06);
  color: var(--text);
}

@media (max-width: 720px) {
  .rules-grid,
  .rules-upload-grid { grid-template-columns: 1fr; }
  .rules-banner { flex-wrap: wrap; }
}

/* ============================================================
   📦 已上传文件（sample archive + AI pairing）
   ============================================================ */
.archive-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.archive-mode {
  margin-top: 4px;
}

/* 上传 mode：两个 dragzone 横向 */
.archive-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 4px;
}

.archive-dz {
  border: 1.5px dashed var(--hairline);
  border-radius: var(--radius-card);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  transition: all .15s ease;
}
.archive-dz:hover,
.archive-dz.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.archive-dz .dz-icon {
  font-size: 28px;
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: 300;
}
.archive-dz .dz-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.archive-dz .dz-sub {
  font-size: 12px;
  color: var(--text-2);
}

/* ============ Mode 2: 配对 ============ */
.archive-batch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--bg);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-chip);
  padding: 10px 14px;
  margin-bottom: 14px;
}
.archive-batch-info {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-2);
}
.archive-batch-info b { font-weight: 600; color: var(--text); }
.archive-batch-id {
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--text-2);
}
.archive-batch-label {
  font-weight: 600;
  color: var(--text);
}
.archive-batch-time {
  color: var(--text-3);
  font-size: 11px;
}
.archive-batch-actions {
  display: inline-flex;
  gap: 8px;
}

.archive-pair-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 12px;
}
.archive-col {
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius-card);
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.archive-col-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--hairline-soft);
  background: var(--bg);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.archive-col-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  max-height: 460px;
  overflow-y: auto;
}

.archive-file-card {
  border: 1.5px solid var(--hairline-soft);
  border-radius: var(--radius-chip);
  padding: 10px 12px;
  background: var(--bg);
  cursor: pointer;
  transition: all .12s ease;
  position: relative;
}
.archive-file-card:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.archive-file-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 3px rgba(0,113,227,.15);
}
.archive-file-card .af-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.archive-file-card .af-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
  flex: 1;
  min-width: 0;
}
.archive-file-card .af-size {
  font-size: 11px;
  color: var(--text-3);
  flex-shrink: 0;
}
.archive-file-card .af-foot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
/* 文件卡片右上角的删除键：平时低调，悬浮才显形，避免误点 */
.archive-file-card .af-del {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
  opacity: .35;
  transition: opacity .12s ease, background .12s ease;
}
.archive-file-card:hover .af-del { opacity: 1; }
.archive-file-card .af-del:hover { background: rgba(255,59,48,.12); }
.archive-file-card .af-preview {
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-3);
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  border-radius: 6px;
  padding: 6px 8px;
  margin-top: 4px;
  max-height: 84px;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-all;
}
.archive-file-card .af-customer {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  background: rgba(88,86,214,.14);
  color: #5856d6;
  border: 1px solid rgba(88,86,214,.3);
  border-radius: 999px;
  padding: 2px 8px;
  margin-top: 4px;
  font-weight: 600;
}

/* 不同配对用不同颜色高亮 */
.archive-file-card.pair-c0 { border-color: rgba(0,113,227,.55); background: rgba(0,113,227,.06); }
.archive-file-card.pair-c1 { border-color: rgba(52,199,89,.55); background: rgba(52,199,89,.06); }
.archive-file-card.pair-c2 { border-color: rgba(255,149,0,.55); background: rgba(255,149,0,.06); }
.archive-file-card.pair-c3 { border-color: rgba(88,86,214,.55); background: rgba(88,86,214,.06); }
.archive-file-card.pair-c4 { border-color: rgba(255,59,48,.55); background: rgba(255,59,48,.06); }
.archive-file-card.pair-c5 { border-color: rgba(0,113,227,.7);  background: rgba(0,113,227,.08); }
.archive-file-card.pair-c6 { border-color: rgba(52,199,89,.7);  background: rgba(52,199,89,.08); }
.archive-file-card.pair-c7 { border-color: rgba(255,149,0,.7);  background: rgba(255,149,0,.08); }
.archive-file-card .af-pair-tag {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid currentColor;
}

.archive-pair-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 4px 12px;
  border-top: 1px dashed var(--hairline-soft);
  margin-top: 4px;
}

/* 当前配对列表 */
.archive-pairs-wrap {
  margin-top: 10px;
  border: 1px dashed rgba(0,113,227,.35);
  border-radius: var(--radius-chip);
  background: var(--accent-light);
  padding: 12px 14px;
}
.archive-pairs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.archive-pairs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}
.archive-pair-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--hairline-soft);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
}
.archive-pair-item .api-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0,113,227,.14);
  color: var(--accent);
}
.archive-pair-item .api-arrow {
  color: var(--text-3);
}
.archive-pair-item .api-name {
  font-weight: 500;
  color: var(--text);
  word-break: break-all;
  flex: 1;
  min-width: 0;
}
/* 一组里两侧都可以有多份（N:M）→ 每侧是一个可换行的名字列表 */
.archive-pair-item .api-side {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
}
.archive-pair-item .api-side .api-name {
  flex: 0 1 auto;
  background: var(--bg);
  border: 1px solid var(--hairline-soft);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 11.5px;
}
.archive-pair-item .api-remove {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.archive-pair-item .api-remove:hover { background: rgba(255,59,48,.14); color: var(--red); }
.archive-pairs-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.archive-summarize {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px dashed rgba(0,113,227,.35);
  border-radius: var(--radius-chip);
  background: var(--accent-light);
}
.archive-summarize h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--accent);
}

.archive-batch-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline-soft);
}

/* ============ Mode 3: 历史批次列表 ============ */
.archive-table-wrap {
  max-height: 460px;
  overflow: auto;
}
.archive-table-wrap table {
  table-layout: fixed;
  width: 100%;
  min-width: 780px;
}
/* 批次表（6 列）：批次/文件数/上传时间/状态/操作用固定宽度，标签列吃剩余宽度。 */
.archive-table-wrap th:nth-child(1) { width: 208px; }
.archive-table-wrap th:nth-child(3) { width: 76px; }
.archive-table-wrap th:nth-child(4) { width: 150px; }
.archive-table-wrap th:nth-child(5) { width: 96px; }
.archive-table-wrap th:nth-child(6) { width: 172px; }
.archive-table-wrap tbody tr { cursor: default; }
.archive-batch-id-cell {
  font-family: "JetBrains Mono", "SF Mono", Consolas, monospace;
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
}

@media (max-width: 720px) {
  .archive-upload-grid,
  .archive-pair-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Apple HIG 侧边栏 + 多页面 SPA 布局
   - 替换旧的顶部单页布局
   - sidebar: 240px, 固定左侧
   - app-main: 弹性扩展
   - .page: 单个 page 容器，整页切换
   ============================================================ */

.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-right: 1px solid var(--hairline-soft);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
}

.sidebar-head {
  padding: 18px 18px 16px 18px;
  border-bottom: 1px solid var(--hairline-soft);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-head .brand-logo {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0071e3, #5856d6);
  color: #fff; font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}

.sidebar-head .brand-text {
  display: flex; flex-direction: column; min-width: 0;
}

.sidebar-head .brand-title {
  font-size: 13px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-head .brand-sub {
  font-size: 10px; color: var(--text-3); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  position: relative;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.nav-item:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.nav-icon { font-size: 16px; width: 18px; text-align: center; flex-shrink: 0; }

.sidebar-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--hairline-soft);
}

.app-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 32px 36px 64px 36px;
}

.page {
  max-width: 840px;
  margin: 0 auto;
}

/* 表格密集的页面列多，840px 的正文宽度会被表格挤到横向滚动，
   单独放宽（只是上限，窗口小时仍会自适应收窄）。 */
.page[data-page="history"] { max-width: 1120px; }
.page[data-page="rules"] { max-width: 1040px; }
.page[data-page="archive"] { max-width: 1040px; }

.page.hidden { display: none; }

.page-head {
  margin-bottom: 28px;
}

.page-head h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  margin: 0 0 6px 0;
}

.page-hint {
  font-size: 13px;
  color: var(--text-3);
  margin: 0;
}

/* Override old .topbar / .main / .footer to be no-op (they're no longer used in HTML) */
.topbar { display: none; }
.main { display: none; }
.footer { display: none; }

/* ============================================================
   ★ Design Refresh v2 — 「精致商务」视觉层
   ------------------------------------------------------------
   为什么单独一层：整套样式全部靠 var(--*) 令牌驱动，
   顶部 :root 换成新令牌后，这里只需**覆盖需要额外雕琢的组件**，
   不动任何布局逻辑 —— app.js 依赖的 class / DOM 结构零改动。

   ⚠️ 本层必须放在响应式 @media 之前：CSS 同优先级下后者胜出，
      若放在媒体查询之后，会把窄屏规则全部盖掉。
   ============================================================ */

/* ---------- 1. 基础层 ---------- */
body {
  font-feature-settings: "cv05" 1, "ss01" 1;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.006em;
}

::selection { background: var(--accent-soft); color: var(--accent-strong); }

/* 细滚动条（默认那根灰条是"廉价感"的一大来源） */
* { scrollbar-width: thin; scrollbar-color: #ccd4e4 transparent; }
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: #ccd4e4;
  border: 3px solid transparent;
  border-radius: 99px;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: #aab5cb; background-clip: content-box; }
*::-webkit-scrollbar-corner { background: transparent; }

/* 键盘可达性：统一焦点环 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
}

/* ---------- 1.5 图标系统（SVG sprite，替代 emoji） ---------- */
svg.ic {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: block;
  fill: none;
  stroke: currentColor;
  vertical-align: -3px;
}
svg.ic-sm { width: 15px; height: 15px; }
svg.ic-lg { width: 22px; height: 22px; }
.btn svg.ic { margin-top: -1px; }
.nav-label { line-height: 1.2; }

/* ---------- 2. 布局底色 ---------- */
.app-shell { background: var(--bg-grad); background-attachment: fixed; }

.app-main { padding: 36px 44px 88px 44px; }

.page { max-width: 900px; }

/* ---------- 3. 侧边栏 ---------- */
.sidebar {
  width: 248px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-right: 1px solid var(--hairline-soft);
  box-shadow: 1px 0 0 rgba(255, 255, 255, .6) inset;
}

.sidebar-head {
  padding: 20px 18px;
  border-bottom: 1px solid var(--hairline-soft);
  gap: 13px;
}

.sidebar-head .brand-logo,
.brand-logo {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--accent-grad);
  font-size: 15px;
  letter-spacing: .02em;
  box-shadow: var(--shadow-accent), inset 0 1px 0 rgba(255, 255, 255, .32);
}

.sidebar-head .brand-title { font-size: 13.5px; font-weight: 700; letter-spacing: -.015em; }
.sidebar-head .brand-sub {
  font-size: 9.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
  margin-top: 3px;
}

.sidebar-nav { padding: 12px 12px; gap: 3px; }

.nav-item {
  padding: 10px 12px;
  border-radius: 10px;
  gap: 11px;
  font-size: 13.5px;
  color: var(--text-2);
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

/* 选中态：左侧强调条。
   ⚠️ 不能用 ::before + left:-12px —— .sidebar-nav 有 overflow-y:auto，
   会连带把 overflow-x 变成 auto，负偏移的伪元素被裁掉（实测完全不显示）。
   改用 inset box-shadow：贴着圆角内边缘，不会被裁。 */
.nav-item:hover { background: var(--surface-hover); color: var(--text); }

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
  box-shadow:
    inset 0 0 0 1px rgba(29, 92, 240, .10),
    inset 3px 0 0 0 var(--accent);
}

.nav-icon {
  width: 21px; height: 21px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: inherit;
  opacity: .82;
}
.nav-icon svg { width: 20px; height: 20px; display: block; }
.nav-icon svg [stroke] { stroke: currentColor; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-foot { padding: 16px 18px; }

/* ---------- 4. 页头 ---------- */
.page-head {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 28px;
}

.page-head-icon {
  width: 46px; height: 46px;
  flex-shrink: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: linear-gradient(160deg, #ffffff 0%, #eef3ff 100%);
  border: 1px solid #e2e9fb;
  box-shadow: var(--shadow-xs), inset 0 1px 0 #fff;
}
.page-head-icon svg { width: 23px; height: 23px; display: block; }
.page-head-icon svg [stroke] { stroke: currentColor; }

.page-head h1 {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -.032em;
  margin: 0 0 5px 0;
  line-height: 1.15;
}

.page-hint { font-size: 13.5px; color: var(--text-2); line-height: 1.5; }

/* 内联图标与文字的间距：这些容器是"图标 + 文本节点"的混排，
   没有 flex gap 可用，只能靠 margin-right 撑开（勿全局加，
   否则按钮里的 gap 会变成双重间距）。 */
.field-label > svg.ic,
.archive-col-head > svg.ic,
.rule-groups-head .field-label > svg.ic,
.archive-summarize h4 > svg.ic,
.page-hint > svg.ic { margin-right: 7px; vertical-align: -3px; }

.archive-col-head,
.archive-summarize h4,
.rule-groups-head .field-label {
  display: inline-flex;
  align-items: center;
}
.rule-groups-head .field-label { line-height: 1.4; }

/* ---------- 5. 卡片 ---------- */
.card,
.section {
  border-radius: var(--radius-card);
  border: 1px solid var(--hairline-soft);
  padding: 26px 30px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .22s ease, border-color .22s ease;
}
.card:hover,
.section:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--hairline);
}

.card-head,
.section-head { margin-bottom: 22px; gap: 10px; align-items: center; }

/* 卡片头里「标题 + 说明 + 工具栏」三件套：说明占满中段，
   工具栏永远贴右 —— 否则按钮一多，说明会被挤成两三行窄条。 */
.card-head > .card-hint,
.card-head > .section-hint {
  flex: 1 1 220px;
  margin-left: 4px;
}
.records-tools,
.archive-tools { margin-left: auto; flex-shrink: 0; }

/* 设置页卡片本身 max-width 720，居中比贴左好看 */
.page[data-page="settings"] > .card { margin: 0 auto; }

.card-head h2,
.section-title {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.022em;
  line-height: 1.3;
}

.card-hint,
.section-hint { font-size: 12.5px; color: var(--text-3); }

/* ---------- 6. 上传区 ---------- */
.dropzone {
  border: 1.5px dashed #cbd6ea;
  border-radius: 14px;
  padding: 44px 24px;
  background: linear-gradient(180deg, #fbfcff 0%, #f5f8fe 100%);
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s ease;
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: linear-gradient(180deg, #f7faff 0%, #ecf2ff 100%);
  box-shadow: 0 0 0 4px var(--accent-soft);
  transform: translateY(-1px);
}

.dz-icon {
  width: 58px; height: 58px;
  margin: 0 auto 15px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--accent);
  font-size: 24px;
  font-weight: 400;
  line-height: 1;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease;
}
.dz-icon svg { width: 26px; height: 26px; display: block; }
.dz-icon svg [stroke] { stroke: currentColor; }
.dropzone:hover .dz-icon,
.dropzone.dragover .dz-icon { transform: translateY(-2px) scale(1.04); box-shadow: var(--shadow-md); }

.dz-title { font-size: 16.5px; font-weight: 650; letter-spacing: -.018em; margin-bottom: 7px; }
.dz-sub { font-size: 13px; color: var(--text-2); }
.dz-link { font-weight: 600; }

/* ---------- 7. 按钮 ---------- */
.btn {
  height: 40px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--hairline);
  background: var(--surface);
  font-weight: 550;
  box-shadow: var(--shadow-xs);
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease,
              transform .12s ease, color .15s ease;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0) scale(.985); box-shadow: var(--shadow-xs); }
.btn:disabled,
.btn:disabled:hover {
  box-shadow: none;
  transform: none;
  opacity: .45;
}

.btn-primary {
  background: var(--accent-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-accent), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #3d76ff 0%, #1a52d6 100%);
  border-color: transparent;
  box-shadow: 0 9px 22px -7px rgba(29, 92, 240, .58), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn-primary:disabled,
.btn-primary:disabled:hover {
  background: var(--accent);
  box-shadow: none;
}

.btn-large { height: 48px; padding: 0 30px; font-size: 15.5px; border-radius: 12px; }

.btn-ghost {
  box-shadow: none;
  border-color: transparent;
  background: transparent;
  color: var(--accent);
}
.btn-ghost:hover { background: var(--accent-light); border-color: transparent; box-shadow: none; }

/* ---------- 8. 表单 ---------- */
input[type="text"],
input[type="search"],
input[type="date"],
input[type="number"],
input[type="password"],
select,
textarea {
  height: 42px;
  border-radius: var(--radius-input);
  border: 1px solid var(--hairline);
  background: var(--surface);
  box-shadow: inset 0 1px 1px rgba(16, 24, 40, .02);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
textarea { height: auto; padding: 10px 14px; line-height: 1.6; font-size: 13px; }

input:hover,
select:hover,
textarea:hover { border-color: var(--border-strong); }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
  background: #fff;
}

input[type="text"].input-big,
input.input-big {
  height: 58px;
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -.028em;
  border-radius: 14px;
  box-shadow: var(--shadow-xs), inset 0 1px 1px rgba(16, 24, 40, .02);
}

.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); letter-spacing: -.005em; }

/* ---------- 9. 标签 / chip / 状态 ---------- */
.tag { border-radius: 999px; font-weight: 600; letter-spacing: .005em; }
.tag.is-vip  { background: #fff4e2; color: #a35c00; }
.tag.is-warn { background: var(--red-soft); color: var(--red); }

.cat-badge { font-weight: 650; letter-spacing: .01em; }
.cat-badge.cat-main    { background: var(--accent-soft); color: var(--accent-strong); border-color: rgba(29, 92, 240, .22); }
.cat-badge.cat-filling { background: var(--amber-soft); color: #a35c00; border-color: rgba(217, 130, 0, .26); }
.cat-badge.cat-lining  { background: rgba(109, 74, 255, .12); color: #5636d6; border-color: rgba(109, 74, 255, .24); }
.cat-badge.cat-inter   { background: var(--green-soft); color: #0d7d3e; border-color: rgba(18, 161, 80, .26); }

.check-chip { border-radius: 11px; padding: 8px 15px; font-weight: 550; background: var(--surface); }
.check-chip:has(input:checked) {
  background: var(--accent-light);
  border-color: rgba(29, 92, 240, .45);
  color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.file-chip {
  border-radius: 10px;
  padding: 7px 12px 7px 14px;
  background: var(--surface);
  border-color: var(--hairline);
  box-shadow: var(--shadow-xs);
}
.file-chip:hover { background: var(--red-soft); border-color: rgba(229, 72, 77, .4); color: var(--red); }

.candidate-pill { border-radius: 999px; padding: 5px 13px; }
.candidate-pill.is-active { box-shadow: 0 0 0 3px var(--accent-soft); }

.order-chip { border-radius: 11px; box-shadow: var(--shadow-xs); }
.order-chip.is-active { box-shadow: var(--shadow-accent); }

.main-chip {
  background: var(--green-soft);
  border-color: rgba(18, 161, 80, .3);
  color: #0d7d3e;
  border-radius: var(--radius-chip);
}

.customer-card {
  border-radius: var(--radius-card);
  background: var(--surface-2);
  border-color: var(--hairline-soft);
  padding: 22px 24px;
}

/* 状态灯（客户识别 / 连接状态） */
.customer-status .dot { box-shadow: 0 0 0 3px rgba(147, 157, 179, .16); }
.customer-status.is-existing .dot { box-shadow: 0 0 0 3px var(--green-soft); }
.customer-status.is-new .dot      { box-shadow: 0 0 0 3px var(--accent-soft); }
.customer-status.is-local { color: #5636d6; }
.customer-status.is-local .dot { background: var(--violet); box-shadow: 0 0 0 3px rgba(109, 74, 255, .16); }
.customer-status.is-down .dot { box-shadow: 0 0 0 3px var(--amber-soft); }

.pill {
  background: var(--surface);
  border-color: var(--hairline-soft);
  box-shadow: var(--shadow-xs);
  padding: 6px 12px;
}
.pill .dot { box-shadow: 0 0 0 3px var(--amber-soft); }
.pill.ok .dot { box-shadow: 0 0 0 3px var(--green-soft); }

/* ---------- 10. 进度 / 日志 ---------- */
.progress { height: 7px; background: #e8ecf5; box-shadow: inset 0 1px 2px rgba(16, 24, 40, .05); }
#progressBar {
  background: var(--accent-grad);
  box-shadow: 0 0 12px -2px rgba(29, 92, 240, .55);
  transition: width .35s cubic-bezier(.4, 0, .2, 1);
}
.stage-pct { font-variant-numeric: tabular-nums; }

.log {
  font-family: var(--font-mono);
  font-size: 11.5px;
  border-radius: 12px;
  background: #f8fafd;
  border-color: var(--hairline-soft);
  padding: 13px 16px;
  line-height: 1.75;
}

/* ---------- 11. 结果区 ---------- */
.tabs {
  padding: 5px;
  background: #eaeef7;
  border-radius: 13px;
  gap: 3px;
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, .05);
}
.tab { border-radius: 10px; padding: 8px 15px; font-weight: 550; }
.tab:hover { color: var(--text); background: rgba(255, 255, 255, .55); }
.tab.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 2px 8px -3px rgba(16, 24, 40, .12);
}
.tab.active em { background: var(--accent-soft); color: var(--accent); }
.tab em { font-variant-numeric: tabular-nums; }

.table-wrap {
  border-radius: 13px;
  border-color: var(--hairline-soft);
  box-shadow: var(--shadow-xs);
}
th {
  background: #f7f9fd;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .03em;
  color: var(--text-2);
  padding: 11px 12px;
  border-bottom: 1px solid var(--hairline);
}
td { padding: 10px 12px; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #f6f9ff; }
tbody tr:last-child td { border-bottom: none; }
td input:focus { background: #fff; box-shadow: inset 0 0 0 1px var(--accent); }

/* 校验 / 摘要：从"裸文字行"升级为提示卡 */
#validationBox { gap: 6px; }
#validationBox > * { border-radius: 10px; }
.summary-row {
  border-radius: 12px;
  padding: 12px 15px;
  border-color: var(--hairline-soft);
  background: var(--surface-2);
}
.summary-row.rule {
  background: var(--accent-light);
  border-color: rgba(29, 92, 240, .22);
  color: var(--accent-strong);
  box-shadow: inset 3px 0 0 var(--accent);
}
.summary-row.review {
  background: #fffaf0;
  border-color: rgba(217, 130, 0, .28);
  color: #8a5200;
  box-shadow: inset 3px 0 0 var(--amber);
}

.coverage-note { border-radius: 12px; border-left-width: 3px; }

/* ---------- 12. 粘性底栏 ---------- */
.action-bar {
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: 1px solid var(--hairline-soft);
  box-shadow: 0 -8px 28px -12px rgba(16, 24, 40, .18);
  padding: 14px 32px;
}

/* ---------- 13. Toast ---------- */
.toast {
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  backdrop-filter: blur(12px);
  border-width: 1px;
}
.toast.success { border-color: rgba(18, 161, 80, .32);  background: #f3fdf6; }
.toast.error   { border-color: rgba(229, 72, 77, .32);  background: #fff6f6; }
.toast.info    { border-color: rgba(29, 92, 240, .28);  background: #f5f8ff; }
.toast.warning { border-color: rgba(217, 130, 0, .30);  background: #fffaf0; }

/* ---------- 14. Modal ---------- */
.modal-backdrop { background: rgba(14, 21, 38, .45); backdrop-filter: blur(10px); }
.modal-panel {
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--hairline-soft);
}
.modal-head { padding: 18px 24px; }
.modal-head h3 { font-size: 16.5px; font-weight: 650; letter-spacing: -.02em; }
.modal-foot { padding: 15px 24px; background: var(--surface-2); }
.modal-panel.is-sheet { border-radius: 20px 20px 0 0; }
.sheet-row { padding: 13px 18px; }
.sheet-row:hover { background: var(--surface-hover); }
.sheet-row-tag { background: rgba(109, 74, 255, .12); color: #5636d6; }
.settings-note { border-radius: 10px; background: var(--surface-2); }

/* ---------- 15. 其它零散组件 ---------- */
.candidates,
.archive-batch-bar,
.rules-upload-section,
.archive-summarize,
.records-detail {
  border-radius: var(--radius-card);
}
.candidates { background: var(--surface-2); border-color: var(--hairline-soft); }
.candidates .item { border-radius: 9px; }
.candidates .item:hover { background: var(--accent-light); }

.hint { line-height: 1.7; }
.hint.success { color: var(--green); }
.hint.fail    { color: var(--red); }
.hint.warn    { color: var(--amber); }

.picker-link { font-weight: 600; }

/* ---------- 16. 历史详情 / 阶段时间轴 / 状态徽章 ---------- */
.records-detail {
  background: var(--surface-2);
  border-radius: var(--radius-card);
  padding: 18px 20px;
}
.records-detail-head h3 { font-size: 15px; font-weight: 650; letter-spacing: -.015em; }
.records-detail-head h3 b { color: var(--accent); font-weight: 700; }

.records-section {
  border-radius: 12px;
  background: var(--surface);
  padding: 13px 16px;
}
.records-section-title {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .045em;
  text-transform: uppercase;
  color: var(--text-3);
}

.stage-timeline { border-radius: 12px; background: var(--surface); gap: 7px; }
.stage-dot { border-radius: 999px; font-weight: 550; }
.stage-dot.clickable:hover { background: var(--accent-light); }
.stage-dot.done {
  background: var(--green-soft);
  color: #0d7d3e;
  border-color: rgba(18, 161, 80, .28);
}

.status-badge { font-weight: 650; }
.status-badge.passed,
.status-badge.status-passed { background: var(--green-soft); color: #0d7d3e; border-color: rgba(18, 161, 80, .28); }
.status-badge.failed,
.status-badge.status-failed { background: var(--red-soft); color: var(--red); border-color: rgba(229, 72, 77, .28); }
.status-badge.partial  { background: var(--amber-soft); color: #a35c00; border-color: rgba(217, 130, 0, .28); }

/* 快照代码块：保留深色（有意为之的对比），只把圆角与配色收进新体系 */
.snapshot-pre {
  background: #111726;
  color: #dde4f2;
  border-radius: 12px;
  font-family: var(--font-mono);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}

@media (max-width: 880px) {
  .sidebar { width: 64px; }
  .sidebar-head .brand-text,
  .nav-label { display: none; }
  /* 窄屏只保留状态灯（隐藏文字）。
     注意：原来写的是 `.pill span:last-child`，而 .dot 是 pill 内唯一的元素子节点，
     所以 :last-child 命中的是圆点本身 —— 结果「灯被隐藏、文字溢出成一个圆」。
     正确做法是给文字单独加 .health-text 包裹层再隐藏它。 */
  .sidebar-foot { padding: 12px 0; display: flex; justify-content: center; }
  .sidebar-foot .pill { padding: 6px; gap: 0; }
  .sidebar-foot .health-text { display: none; }
  .sidebar-head { justify-content: center; padding: 16px 0; }
  .nav-item { justify-content: center; padding: 10px 0; }
  .app-main { padding: 20px 16px 40px 16px; }
}

@media (max-width: 640px) {
  .card,
  .section { padding: 20px 18px; }
  .page-head h1 { font-size: 22px; }
  .archive-pair-grid { grid-template-columns: 1fr; }
  .archive-upload-grid,
  .rules-upload-grid { grid-template-columns: 1fr; }
}


/* 历史记录在侧栏窄视口中以卡片完整显示，避免只能看到操作列。 */
@media (max-width: 760px) {
  #sectionRecords .card-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  #sectionRecords .records-tools { flex-wrap: wrap; }
  #recordsCount { white-space: normal; line-height: 1.6; }
  .records-table-wrap { max-height: none; overflow: visible; }
  .records-table-wrap table { display: block; min-width: 0; width: 100%; table-layout: auto; }
  .records-table-wrap thead { display: none; }
  .records-table-wrap tbody { display: grid; gap: 12px; }
  .records-table-wrap .record-row { display: block; border: 1px solid var(--border, #e5e7eb); border-radius: 12px; padding: 12px; }
  .records-table-wrap .record-row::before { content: attr(data-file); display: block; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; margin-bottom: 8px; }
  .records-table-wrap .record-row td { display: flex; gap: 8px; width: auto; padding: 4px 0; border: 0; white-space: normal; overflow: visible; overflow-wrap: anywhere; text-align: left; }
  .records-table-wrap .record-row td::before { content: attr(data-label); flex: 0 0 56px; color: var(--text-3, #777); font-size: 12px; }
  .records-table-wrap .record-row td:last-child { flex-wrap: wrap; padding-top: 10px; }
  .records-table-wrap .record-row td:last-child::before { flex-basis: 100%; }
  .records-table-wrap .records-op-btn { margin: 0; }
}


/* 历史详情始终显示在视口内，结果表优先展示。 */
dialog.records-detail { position: fixed; inset: 0; margin: auto; width: min(960px, calc(100vw - 28px)); max-width: calc(100vw - 28px); max-height: calc(100dvh - 28px); overflow-y: auto; padding: 20px; box-sizing: border-box; box-shadow: 0 18px 80px rgba(0,0,0,.2); }
dialog.records-detail::backdrop { background: rgba(15,23,42,.35); }
dialog.records-detail .records-section { margin-top: 10px; }
dialog.records-detail .file-chip { max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
.result-notes { margin-top: 16px; padding: 12px 14px; border: 1px solid var(--hairline-soft); border-radius: 12px; }
.result-notes summary, .records-section summary { cursor: pointer; font-weight: 600; }
.result-notes[open] summary { margin-bottom: 12px; }
.result-notes #validationBox { max-height: 320px; overflow-y: auto; margin: 0; }
#resultValidationSummary { margin-bottom: 12px; }
.history-result-notice { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 12px; background: var(--accent-light); border-radius: 10px; margin-bottom: 12px; }
#sectionResult { scroll-margin-top: 16px; }
#sectionResult #tabs { overflow-x: auto; flex-wrap: nowrap; }
#sectionResult #tabs .tab { flex-shrink: 0; }

a.records-op-btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
