/* ==========================================================================
   外贸单证工作台 —— Tabler 风格皮肤
   --------------------------------------------------------------------------
   这是工作台自己的样式表，加载在 vendor/tabler.min.css **之后**：
   Tabler 提供基础（reboot / 表单 / 表格 / 徽章 / 按钮的骨架与设计变量），
   这里把工作台的布局和业务组件（单据卡、告警条、来源清单、产物行…）
   统一到同一套 Tabler 语言上。

   设计基调（Tabler 1.0）
     底色    页面 #f6f8fb 冷灰；卡片纯白，靠 1px 描边 + 极浅阴影分层
     主色    #066fd1（Tabler blue），只用于主操作、选中态、链接
     文字    #182433 主 / #667382 次 / #8a94a6 弱
     圆角    控件与标签 4px，卡片 6px —— 后台系统的"方正感"，不用大圆角
     密度    正文 14px、辅助 12px、表头 11px；一行信息量比"官网风"高，
             业务表格与表单才不会占掉整屏
     层级    顶栏（面包屑 + 页标题 + 操作）→ 内容区两列栅格 → 卡片（卡头/卡体）

   字号规范（只这 6 档，不新增）
     H1 页标题 21px/600 · H2 卡片标题 15px/600 · H3 区块小标题 14px/600
     H4 次级标题 14px/600 · Body 正文 14px/400 · Caption 辅助 12px/400
     另有一档 Micro 11px，仅用于表头大写字母与角标 —— 不再新增其它字号。

   改样式时只改这个文件；页面的 class 约定见 docs/界面设计.md。
   ========================================================================== */

:root {
  /* ---- 背景与表面 ---- */
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-inset: #f1f4f8;
  --surface-raised: #ffffff;

  /* ---- 文字 ---- */
  --ink-1: #182433;
  --ink-2: #3f4c5c;
  --ink-3: #667382;
  --ink-4: #8a94a6;
  --ink-on-brand: #ffffff;

  /* ---- 主色：Tabler blue ---- */
  --brand: #066fd1;
  --brand-2: #0359ad;
  --brand-grad: linear-gradient(180deg, #0b7ce0 0%, #066fd1 100%);
  --brand-soft: rgba(6, 111, 209, .07);
  --brand-soft-2: rgba(6, 111, 209, .12);
  --brand-line: rgba(6, 111, 209, .30);

  /* ---- 业务功能色 + 浅底 ---- */
  --teal: #0ca678;
  --violet: #7c3aed;
  --orange: #c47f17;
  --red: #d63939;
  --green: #2fb344;

  --teal-soft: #e7f7f1;
  --violet-soft: #f3edff;
  --orange-soft: #fdf4e4;
  --red-soft: #fdecec;
  --green-soft: #eaf7ec;

  /* ---- 描边 / 阴影 ---- */
  --hair: #e6e9ee;
  --hair-2: #dce1e7;
  --hair-dark: #cfd6df;

  --shadow-1: 0 1px 2px rgba(24, 36, 51, .05);
  --shadow-2: 0 2px 6px rgba(24, 36, 51, .07);
  --shadow-3: 0 10px 28px rgba(24, 36, 51, .14);
  --shadow-brand: 0 1px 2px rgba(6, 111, 209, .30);

  /* ---- 字号（6 档 + Micro） ---- */
  --fs-h1: 21px;
  --fs-h2: 15px;
  --fs-h3: 14px;
  --fs-h4: 14px;
  --fs-body: 14px;
  --fs-caption: 12px;
  --fs-micro: 11px;

  /* ---- 行高 ---- */
  --lh-h1: 1.3;
  --lh-h2: 1.4;
  --lh-h3: 1.45;
  --lh-h4: 1.45;
  --lh-body: 1.5;
  --lh-caption: 1.5;

  /* ---- 字重：只有两档 ---- */
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;

  /* ---- 间距：4px 网格 ---- */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px; --sp-9: 56px;

  /* 栅格：块与块之间只从这里取 */
  --gap-card: 16px;    /* 卡片与卡片 */
  --gap-inner: 12px;   /* 卡片内部网格 */
  --pad-card: 16px;    /* 卡片内边距（卡体） */
  --pad-page: 24px;    /* 主区左右留白（顶栏与内容共用） */

  /* ---- 圆角：后台系统的方正感 ---- */
  --r-xs: 3px;
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-pill: 9999px;

  /* ---- 骨架尺寸 ---- */
  --sidebar-w: 248px;
  --content-max: 1480px;
  --read-max: 720px;
  --topbar-h: 60px;

  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Microsoft YaHei", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;

  /* Tabler 表层变量跟着走：以后直接写 Tabler 组件（modal/tabs/dropdown）也不跑色 */
  --tblr-font-sans-serif: var(--sans);
  --tblr-body-font-size: var(--fs-body);
  --tblr-body-color: var(--ink-1);
  --tblr-body-bg: var(--bg);
  --tblr-primary: var(--brand);
  --tblr-border-radius: var(--r-sm);
  --tblr-border-radius-lg: var(--r-md);
  --tblr-border-color: var(--hair-2);
}

/* ---------------- 基础 ---------------- */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: var(--fw-regular) var(--fs-body)/var(--lh-body) var(--sans);
  color: var(--ink-1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Bootstrap reboot 会给标题/段落/列表加默认边距，这里统一归零：
   排版靠组件自己的 margin，不靠浏览器的默认值。 */
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: var(--fw-semibold); color: var(--ink-1); }
p { margin: 0; }
ul, ol { margin: 0; }
label { margin: 0; }
hr { border: 0; border-top: 1px solid var(--hair); }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-2); text-decoration: none; }

::selection { background: var(--brand-soft-2); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-radius: var(--r-sm);
}

/* 图标：内联 SVG（见 icons.js），尺寸跟着字号走 */
.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1em; height: 1em;
  vertical-align: -0.125em;
}
.icon svg { width: 100%; height: 100%; display: block; }
.icon-emoji { display: inline-flex; width: 1em; line-height: 1; justify-content: center; }

/* 正文文本块最大阅读宽度，落在 680~760px；表格/网格不受影响 */
.card-body > p, .content > p { max-width: var(--read-max); }

/* ---------------- 布局 ---------------- */
.app { display: flex; min-height: 100vh; align-items: stretch; }

/* 左侧导航（Tabler navbar-vertical 观感） */
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--hair-2);
}

.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--hair);
  flex: 0 0 auto;
}
.sidebar-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 12px 10px 16px;
  display: flex; flex-direction: column;
}

/* 品牌区（左上角 logo + 名称） */
.brand {
  display: flex; gap: 10px; align-items: center;
  padding: 6px 6px;
  border-radius: var(--r-md);
  color: var(--ink-1);
}
.brand:hover { background: var(--surface-2); color: var(--ink-1); text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: var(--r-md);
  background: var(--brand-grad);
  color: var(--ink-on-brand);
  display: grid; place-items: center;
  font-size: var(--fs-h3); font-weight: var(--fw-semibold); letter-spacing: .2px;
  overflow: hidden;
  box-shadow: var(--shadow-brand);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-text { min-width: 0; flex: 1; }
.brand-title {
  font-size: var(--fs-h3); font-weight: var(--fw-semibold);
  line-height: 1.3; letter-spacing: -.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub {
  color: var(--ink-4); font-size: var(--fs-micro);
  line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 导航分组标题（Tabler 的 .nav-section-title） */
.nav-section-title {
  padding: 8px 10px 4px;
  font-size: var(--fs-micro); font-weight: var(--fw-semibold);
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-4);
}

.nav { display: flex; flex-direction: column; gap: 1px; }

.nav-item {
  display: flex; gap: 10px; align-items: center;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-body); line-height: 1.4;
  color: var(--ink-3); text-decoration: none;
  border: 1px solid transparent;
  transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink-1); text-decoration: none; }
.nav-item:active { background: var(--surface-inset); }
.nav-item.active {
  background: var(--brand-soft-2);
  color: var(--brand);
  font-weight: var(--fw-medium);
}
.nav-icon { width: 18px; height: 18px; flex: 0 0 18px; font-size: 18px; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item.is-settings { color: var(--ink-3); }
.nav-item.is-settings.active { color: var(--violet); background: var(--violet-soft); }
.nav-item .badge { flex: 0 0 auto; }

/* 侧栏底部：设置组 + 版本号 */
.sidebar-foot {
  margin-top: auto; padding-top: 10px;
  display: flex; flex-direction: column; gap: 1px;
  border-top: 1px solid var(--hair);
}
.sidebar-foot .nav-section-title { padding-top: 0; }
.side-sep { height: 1px; margin: 8px 2px; background: var(--hair); }
.sidebar-version {
  margin-top: 10px; padding: 0 10px;
  font-size: var(--fs-micro); color: var(--ink-4);
}

/* ---------------- 主区 ---------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* 顶栏：面包屑 + 页标题 + 右侧操作。吸顶，滚动时始终能看到"我在哪一页" */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
  min-height: var(--topbar-h);
  padding: 10px var(--pad-page);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(6px);
  border-bottom: 1px solid var(--hair-2);
}
.topbar-left { min-width: 0; }
.topbar-heading { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
/* 全站唯一的 H1（每页顶栏一个） */
.topbar-left h1 {
  margin: 0; font-size: var(--fs-h1); font-weight: var(--fw-semibold);
  line-height: var(--lh-h1); letter-spacing: -.01em;
}
.topbar-sub { margin: 0; color: var(--ink-3); font-size: var(--fs-caption); }
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  margin: 0 0 3px; font-size: var(--fs-caption); color: var(--ink-4);
}
.breadcrumb-item { color: var(--ink-4); }
a.breadcrumb-item:hover { color: var(--brand); }
.breadcrumb-item.is-current { color: var(--ink-3); }
.breadcrumb-sep { color: var(--hair-dark); }
.topbar-right { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.topbar-actions { display: flex; gap: 6px; align-items: center; }

.content {
  padding: var(--sp-4) var(--pad-page) var(--sp-8);
  display: flex; flex-direction: column; gap: var(--gap-card);
  max-width: var(--content-max); width: 100%;
}

/* 首屏占位 */
.app-loading {
  display: flex; align-items: center; gap: 8px;
  padding: 18px 0; color: var(--ink-3); font-size: var(--fs-caption);
}

/* ---------------- 卡片（Tabler card） ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--hair-2);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  min-width: 0;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; gap: 8px;
  min-height: 40px;
  padding: 9px var(--pad-card);
  border-bottom: 1px solid var(--hair);
  background: var(--surface);
}
.card-body { padding: var(--pad-card); }
/* 卡体内块的纵向节奏：相邻块之间留 12px，字段自带 margin-bottom 不重复加。 */
.card-body > * + * { margin-top: var(--sp-3); }
.card-body > .field { margin-top: 0; max-width: 640px; }
.card-body > :last-child { margin-bottom: 0; }
.card-error { border-color: rgba(214, 57, 57, .35); }
.card-error .card-header { background: var(--red-soft); border-bottom-color: rgba(214, 57, 57, .2); }
.card-error .card-title { color: var(--red); }
.card-soft { box-shadow: none; }

/* 兼容老写法：卡片标题直接挂在 .card 下面（没有 card-header 包裹） */
.card > .card-title {
  margin: 0; padding: 9px var(--pad-card);
  border-bottom: 1px solid var(--hair);
  font-size: var(--fs-h2); font-weight: var(--fw-semibold);
}
.card > .card-title:last-child { border-bottom: 0; }

/* 卡片标题 = H2（15px/600）。业务卡片标题常带序号（① / ②），序号用主色 */
.card-title {
  margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: var(--fs-h2); font-weight: var(--fw-semibold);
  line-height: var(--lh-h2); letter-spacing: -.005em; color: var(--ink-1);
}
.card-title .icon { color: var(--ink-3); }

/* ---------------- 栅格 ---------------- */
.grid-2 {
  display: grid; gap: var(--gap-inner);
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
}
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

/* 便当盒栅格（工作台两列布局） */
.bento {
  display: grid; gap: var(--gap-card);
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
}
.bento > * { grid-column: span 12; min-width: 0; }
.bento > .bento-8 { grid-column: span 8; }
.bento > .bento-4 { grid-column: span 4; }
.bento > .bento-6 { grid-column: span 6; }
.bento-stack { display: grid; gap: var(--gap-card); align-content: start; }
@media (max-width: 1280px) {
  .bento > .bento-8, .bento > .bento-4 { grid-column: span 12; }
}
@media (max-width: 1100px) {
  .bento > .bento-6 { grid-column: span 12; }
}

/* ---------------- 表单 ---------------- */
.field { margin-bottom: var(--sp-3); min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: block; margin-bottom: 5px;
  font-size: var(--fs-caption); font-weight: var(--fw-medium);
  line-height: var(--lh-caption); color: var(--ink-2);
}
.field-help {
  margin: 5px 0 0; font-size: var(--fs-caption);
  line-height: var(--lh-caption); color: var(--ink-4); max-width: var(--read-max);
}
.field-inline { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
/* flex 子项默认可收缩，会把中文标签压成"一列竖排字"——禁止收缩 */
.field-inline > .field-label { flex: 0 0 auto; margin-bottom: 0; white-space: nowrap; }
.field-inline > input[type="number"] { width: auto; flex: 0 1 120px; }
.field-inline > input[type="text"] { width: auto; flex: 1 1 240px; }
.field-check { margin-bottom: 6px; }
.field-half { display: inline-block; width: calc(50% - 8px); margin-right: var(--sp-4); }
.field-third { display: inline-block; width: calc(33.33% - 11px); margin-right: var(--sp-4); }

/* 输入控件：Tabler form-control 的尺寸（高 32px / 13~14px / 4px 圆角）。
   页面模块里也有直接 new input 的地方，所以裸元素选择器也要覆盖。 */
input[type="text"], input[type="number"], input[type="password"],
input[type="search"], input[type="email"], input[type="url"], select, textarea,
.form-control, .form-select {
  width: 100%; max-width: 100%;
  min-height: 32px;
  padding: 5px 10px;
  font: var(--fw-regular) var(--fs-body)/1.45 var(--sans);
  color: var(--ink-1);
  background-color: var(--surface);
  border: 1px solid var(--hair-2);
  border-radius: var(--r-sm);
  transition: border-color .12s ease, box-shadow .12s ease;
  appearance: none;
}
select, .form-select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 30px;
}
textarea { resize: vertical; min-height: 84px; font-family: var(--sans); line-height: 1.55; }
input:hover, select:hover, textarea:hover { border-color: var(--hair-dark); }
input:focus, select:focus, textarea:focus, .form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(6, 111, 209, .12);
}
input::placeholder, textarea::placeholder { color: var(--ink-4); }
input:disabled, select:disabled, textarea:disabled {
  background: var(--surface-inset); color: var(--ink-3); cursor: not-allowed;
}
input[type="checkbox"], input[type="radio"] {
  width: 15px; height: 15px; min-height: 0; padding: 0; flex: 0 0 15px;
  accent-color: var(--brand); cursor: pointer; border-radius: var(--r-xs);
}
input[type="file"] {
  padding: 5px 8px; font-size: var(--fs-caption); cursor: pointer;
}
input[type="file"]::file-selector-button {
  margin: -5px 8px -5px -8px; padding: 5px 10px; cursor: pointer;
  font: var(--fw-medium) var(--fs-caption) var(--sans);
  color: var(--ink-2);
  background: var(--surface-2); border: 0; border-right: 1px solid var(--hair-2);
  border-radius: var(--r-sm) 0 0 var(--r-sm);
}
input[type="file"]::file-selector-button:hover { background: var(--surface-inset); }

.check-inline {
  display: inline-flex; align-items: center; gap: 6px;
  margin-right: var(--sp-4); margin-bottom: 6px;
  font-size: var(--fs-body); line-height: var(--lh-body);
  color: var(--ink-2); cursor: pointer;
}
.check-row { display: flex; flex-wrap: wrap; gap: 0; }
.row-actions {
  display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap;
  margin-top: var(--sp-4);
}
.card-body > .row-actions:first-child { margin-top: 0; }

/* logo 选择器 */
.logo-field { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.logo-preview {
  width: 48px; height: 48px; flex: 0 0 48px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--surface-inset);
  border: 1px solid var(--hair-2);
  overflow: hidden;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-placeholder { font-size: var(--fs-micro); color: var(--ink-4); }
.logo-field input[type="file"] { flex: 1 1 220px; width: auto; max-width: 320px; }

/* ---------------- 按钮（Tabler btn） ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px;
  padding: 5px 12px;
  font: var(--fw-medium) var(--fs-body)/1.4 var(--sans);
  color: var(--ink-1);
  background-color: var(--surface);
  border: 1px solid var(--hair-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--hair-dark); color: var(--ink-1); text-decoration: none; }
.btn:active { background: var(--surface-inset); }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn .icon { font-size: 15px; }

.btn-primary {
  color: var(--ink-on-brand);
  background: var(--brand);
  border-color: var(--brand);
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); color: var(--ink-on-brand); }
.btn-primary:active { background: #023f7d; border-color: #023f7d; }
.btn-small, .btn.btn-sm { min-height: 26px; padding: 2px 9px; font-size: var(--fs-caption); }
.btn-ghost {
  min-height: 26px; padding: 2px 8px;
  font: var(--fw-medium) var(--fs-caption)/1.4 var(--sans);
  color: var(--ink-3); background: transparent; border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--ink-1); }
.btn-danger { color: var(--red); border-color: rgba(214, 57, 57, .35); }
.btn-danger:hover { background: var(--red-soft); border-color: rgba(214, 57, 57, .5); color: var(--red); }

/* ---------------- 表格（Tabler table） ---------------- */
.table-wrap {
  border: 1px solid var(--hair-2);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: auto;
  max-height: 78vh;
}
.table {
  width: 100%; margin: 0;
  border-collapse: separate; border-spacing: 0;
  font-size: var(--fs-body); line-height: 1.45;
  color: var(--ink-1);
}
.table thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-weight: var(--fw-medium);
  font-size: var(--fs-micro); line-height: 1.4;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-4);
  padding: 7px var(--sp-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--hair-2);
  white-space: nowrap;
}
.table tbody td {
  padding: 8px var(--sp-3);
  border-bottom: 1px solid var(--hair);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tbody tr.is-selected td, .table tbody tr.is-selected:hover td { background: var(--brand-soft); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table code { font-size: var(--fs-caption); }
.table tbody td input.form-control,
.table tbody td input[type="number"] { min-height: 28px; padding: 3px 8px; }
.qty-input { width: 104px; text-align: right; font-variant-numeric: tabular-nums; }
.cell-hot { background: var(--brand-soft); border-radius: var(--r-xs); }

/* 明细价格预览（报价阶段的小表） */
.lines-table {
  width: 100%; border-collapse: collapse; margin: 0;
  font-size: var(--fs-caption);
}
.lines-table th {
  text-align: left; font-weight: var(--fw-medium); color: var(--ink-4);
  padding: 5px 8px; border-bottom: 1px solid var(--hair-2);
}
.lines-table td {
  padding: 4px 8px; border-bottom: 1px solid var(--hair);
  font-variant-numeric: tabular-nums;
}
.lines-table tbody tr:last-child td { border-bottom: none; }
.lines-table .num, .lines-table th:nth-child(n+2) { text-align: right; }

/* ---------------- 标签 / 徽章 / 胶囊 ---------------- */
.badge, .chip, .tag, .sev {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--fs-caption); line-height: 1.4;
  padding: 1px 7px; border-radius: var(--r-sm);
  white-space: nowrap; font-weight: var(--fw-regular);
  border: 1px solid transparent;
}
.badge { background: var(--surface-inset); color: var(--ink-3); font-size: var(--fs-micro); }
.badge-planned { background: var(--orange-soft); color: #8a5a00; }
.badge-ai { background: var(--violet-soft); color: var(--violet); }
.badge-rule { background: var(--teal-soft); color: #067a56; }
.badge-lock { background: var(--violet-soft); color: var(--violet); }

/* 顶栏信息胶囊：路径可能很长，必须允许省略，否则撑破顶栏 */
.chip {
  background: var(--surface); color: var(--ink-3);
  border-color: var(--hair-2);
  font-size: var(--fs-caption);
  padding: 3px 9px;
  max-width: 300px;
  overflow: hidden;
}
.chip-icon { font-size: 14px; color: var(--ink-4); flex: 0 0 auto; }
.chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-warn { background: var(--orange-soft); color: #8a5a00; border-color: transparent; }
.tag { background: var(--surface-inset); color: var(--ink-3); font-size: var(--fs-micro); padding: 1px 6px; }

.sev { font-weight: var(--fw-medium); font-size: var(--fs-micro); padding: 1px 6px; }
.sev-error { background: var(--red-soft); color: var(--red); }
.sev-warn { background: var(--orange-soft); color: #8a5a00; }
.sev-notice { background: var(--violet-soft); color: var(--violet); }
.sev-info { background: var(--brand-soft); color: var(--brand); }
.sev-row {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  margin: 0 0 var(--sp-3);
}

/* ---------------- 告警清单 ---------------- */
.warnings { display: flex; flex-direction: column; gap: 6px; }
.warning {
  display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-left: 3px solid var(--ink-4);
  font-size: var(--fs-caption); line-height: 1.55;
}
.warning-error { border-left-color: var(--red); background: #fffafa; }
.warning-warn { border-left-color: var(--orange); background: #fffdf8; }
.warning-notice { border-left-color: var(--violet); background: #fdfbff; }
.warning-info { border-left-color: var(--brand); background: #fafdff; }
.warning-msg { flex: 1 1 320px; max-width: var(--read-max); color: var(--ink-1); }
.warning-hint { color: var(--ink-3); }
.warning-evidence {
  flex-basis: 100%; color: var(--ink-4);
  font-family: var(--mono); font-size: var(--fs-micro);
}
.warning-code {
  font: var(--fw-regular) var(--fs-micro) var(--mono);
  color: var(--ink-4);
  background: var(--surface-inset); padding: 1px 5px;
  border-radius: var(--r-xs);
}

/* ---------------- 产物卡片 ---------------- */
.artifacts { display: flex; flex-direction: column; gap: 6px; }
.artifact {
  display: flex; justify-content: space-between; gap: var(--sp-3);
  align-items: center; flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--hair-2);
  transition: border-color .12s ease, background .12s ease;
}
.artifact:hover { background: var(--surface-2); border-color: var(--hair-dark); }
.artifact-main { display: flex; gap: 8px; align-items: center; min-width: 0; flex-wrap: wrap; }
.artifact-doc {
  font-size: var(--fs-micro); font-weight: var(--fw-medium); color: var(--brand);
  background: var(--brand-soft); padding: 1px 6px;
  border-radius: var(--r-sm);
}
.artifact-name { font-family: var(--mono); font-size: var(--fs-caption); color: var(--ink-1); word-break: break-all; }
.artifact-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------------- 键值 / 代码 / 折叠 ---------------- */
.kv {
  display: grid; grid-template-columns: minmax(150px, auto) 1fr;
  gap: 4px var(--sp-3); padding: 5px 0;
  border-bottom: 1px solid var(--hair);
  font-size: var(--fs-caption);
}
.kv:last-child { border-bottom: none; }
.kv-key { color: var(--ink-4); }
.kv-val { font-family: var(--mono); color: var(--ink-2); word-break: break-all; }

.path-code, code {
  font-family: var(--mono); font-size: var(--fs-caption);
  background: var(--surface-inset);
  padding: 1px 5px; border-radius: var(--r-xs);
  color: var(--ink-2); word-break: break-all;
}
.pre-wrap {
  white-space: pre-wrap; word-break: break-word;
  font: var(--fw-regular) var(--fs-caption)/1.55 var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-radius: var(--r-sm);
  padding: var(--sp-3); margin: var(--sp-2) 0 0;
  color: var(--ink-2);
  max-height: 360px; overflow: auto;
}
.details { margin-top: var(--sp-3); }
.details > summary {
  cursor: pointer;
  font-size: var(--fs-caption);
  font-weight: var(--fw-medium); color: var(--ink-3);
  padding: 4px 9px; border-radius: var(--r-sm);
  background: var(--surface-inset);
  display: inline-block;
  list-style: none;
  transition: background .12s ease, color .12s ease;
}
.details > summary::-webkit-details-marker { display: none; }
.details > summary:hover { background: var(--brand-soft); color: var(--brand); }
.details[open] > summary { margin-bottom: var(--sp-2); }

/* ---------------- 提示文字 ---------------- */
.muted { color: var(--ink-3); }
.small { font-size: var(--fs-caption); line-height: var(--lh-caption); }
.ok-text { color: #067a56; font-weight: var(--fw-medium); }
.warn-text { color: #8a5a00; font-weight: var(--fw-medium); }
.danger-text { color: var(--red); font-weight: var(--fw-medium); }

/* ---------------- 提示条（Tabler alert 观感） ---------------- */
.notice-bar {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  background: #f2f8fe;
  border: 1px solid #cfe3f7;
  border-left: 3px solid var(--brand);
  font-size: var(--fs-caption); line-height: 1.55; color: var(--ink-2);
}
.notice-bar.is-warn { background: #fef8ec; border-color: #f3e2c0; border-left-color: var(--orange); }
.notice-bar.is-ok { background: #eefaf0; border-color: #cdeed4; border-left-color: var(--green); }
.notice-icon { flex: 0 0 auto; font-size: 14px; line-height: 1.4; color: var(--ink-3); }
.notice-bar.is-warn .notice-icon { color: var(--orange); }
.notice-bar.is-ok .notice-icon { color: var(--green); }
.notice-bar strong { color: var(--ink-1); }

/* ---------------- 规划中的页面 ---------------- */
.planned-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: var(--sp-2); }
/* 规划页副标题 = H3 区块小标题 */
.planned-sub {
  font-size: var(--fs-h3); font-weight: var(--fw-semibold);
  line-height: var(--lh-h3); letter-spacing: -.005em;
  margin: var(--sp-4) 0 var(--sp-2);
}
.planned-needs { margin: 0; padding: 0; list-style: none; counter-reset: n; max-width: 920px; }
.planned-needs li {
  position: relative; margin: 6px 0; padding: 8px 12px 8px 38px;
  background: var(--surface-2); border-radius: var(--r-sm);
  border: 1px solid var(--hair);
  font-size: var(--fs-caption); line-height: 1.55;
}
.planned-needs li::before {
  content: counter(n);
  position: absolute; left: 10px; top: 7px;
  width: 18px; height: 18px; border-radius: var(--r-pill);
  background: var(--violet-soft); color: var(--violet);
  font: var(--fw-semibold) var(--fs-micro)/18px var(--sans);
  text-align: center;
  counter-increment: n;
}
.planned-alt { margin: 0; padding-left: 18px; font-size: var(--fs-caption); }
.planned-alt li { margin: 4px 0; }

/* ---------------- 后台登录门 ---------------- */
.gate { display: flex; justify-content: center; padding: var(--sp-8) var(--sp-5) var(--sp-9); }
.gate-inner { width: 100%; max-width: 400px; }
.gate-card {
  background: var(--surface);
  border: 1px solid var(--hair-2);
  border-radius: var(--r-md);
  padding: var(--sp-6);
  box-shadow: var(--shadow-2);
  text-align: center;
}
.gate-icon {
  width: 44px; height: 44px; margin: 0 auto var(--sp-3);
  border-radius: var(--r-md);
  background: var(--brand-grad);
  color: #fff; font-size: 20px; line-height: 1;
  display: grid; place-items: center;
  box-shadow: var(--shadow-brand);
}
.gate-card h2 {
  margin: 0 0 4px;
  font-size: var(--fs-h2); font-weight: var(--fw-semibold);
  line-height: var(--lh-h2); letter-spacing: -.005em;
}
.gate-card > p { margin: 0 0 var(--sp-4); color: var(--ink-3); font-size: var(--fs-caption); }
.gate-card .field { text-align: left; }
.gate-actions { margin-top: var(--sp-4); display: flex; gap: var(--sp-2); justify-content: center; }
.gate-note {
  margin-top: var(--sp-3); padding-top: var(--sp-3);
  font-size: var(--fs-caption); line-height: 1.55;
  color: var(--ink-4); border-top: 1px solid var(--hair);
}

/* ---------------- 分区小标题 ---------------- */
.section-head { display: flex; align-items: center; gap: 8px; margin: var(--sp-3) 0 var(--sp-2); }
.section-head h3 {
  margin: 0; font-size: var(--fs-h3); font-weight: var(--fw-semibold);
  line-height: var(--lh-h3); letter-spacing: -.005em;
}
.dot { width: 6px; height: 6px; border-radius: var(--r-pill); flex: 0 0 6px; }
.dot-teal { background: var(--teal); }
.dot-violet { background: var(--violet); }
.dot-orange { background: var(--orange); }
.dot-brand { background: var(--brand); }
.dot-red { background: var(--red); }

/* 来源标记 */
.src {
  font-family: var(--mono); font-size: var(--fs-micro);
  padding: 1px 5px; border-radius: var(--r-xs);
  line-height: 1.5;
}
.src-env { background: var(--teal-soft); color: #067a56; }
.src-admin { background: var(--violet-soft); color: var(--violet); }
.src-default { background: var(--surface-inset); color: var(--ink-4); }

/* ---------------- 生成单据页：两列 ---------------- */
.shell-grid {
  display: grid; gap: var(--gap-card);
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: start;
}
.shell-grid.bento { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.shell-left, .shell-right { display: grid; gap: var(--gap-card); align-content: start; min-width: 0; }
.shell-right { position: sticky; top: calc(var(--topbar-h) + var(--sp-2)); }
@media (max-width: 1280px) {
  .shell-grid { grid-template-columns: 1fr; }
  .shell-right { position: static; }
}

/* ---------------- ① 选表（单据卡） ---------------- */
.doc-picker .flow-group { margin-bottom: var(--sp-4); }
.doc-picker .flow-group:last-child { margin-bottom: 0; }
.doc-picker .flow-group.is-blocked { opacity: .55; }
.doc-picker .flow-group.is-blocked .doc-card { filter: grayscale(.6); }

.flow-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
/* 分组标题 = H3 区块小标题（低于卡片标题，高于正文） */
.flow-title { font-size: var(--fs-h3); font-weight: var(--fw-semibold); line-height: var(--lh-h3); color: var(--ink-1); }
.flow-note { color: #8a5a00; font-size: var(--fs-caption); background: var(--orange-soft); padding: 1px 6px; border-radius: var(--r-sm); }
.flow-desc {
  margin: 0 0 var(--sp-2); max-width: var(--read-max);
  font-size: var(--fs-caption); line-height: 1.55; color: var(--ink-4);
}

.doc-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.doc-card {
  display: block; cursor: pointer; margin: 0;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--hair-2);
  transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.doc-card:hover { border-color: var(--brand-line); box-shadow: var(--shadow-1); }
.doc-card.is-on { border-color: var(--brand); background: #f7fbff; box-shadow: 0 0 0 1px var(--brand) inset; }
.doc-card.is-warn { border-color: rgba(196, 127, 23, .45); }
.doc-card-top { display: flex; gap: 8px; align-items: center; }
.doc-card-top input { flex: 0 0 auto; }
/* 产品名 = H4 次级标题 */
.doc-card-name {
  flex: 1; min-width: 0;
  font-size: var(--fs-h4); font-weight: var(--fw-medium);
  line-height: var(--lh-h4); color: var(--ink-1);
}
.doc-card-code {
  font: var(--fw-semibold) var(--fs-micro) var(--mono);
  color: var(--ink-3); background: var(--surface-inset);
  padding: 1px 5px; border-radius: var(--r-xs);
}
.doc-card-desc {
  margin: 4px 0 0; font-size: var(--fs-caption);
  line-height: 1.5; color: var(--ink-4);
}
.doc-card-warn {
  margin: 4px 0 0; font-size: var(--fs-caption);
  line-height: 1.5; color: #8a5a00; font-weight: var(--fw-medium);
}

/* ---------------- ② 数据来源 ---------------- */
.source-card {
  padding: 10px 12px; margin-bottom: 8px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--hair-2);
}
.source-card:last-child { margin-bottom: 0; }
.source-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.source-icon { font-size: 15px; line-height: 1; color: var(--ink-3); }
/* 来源标题 = H4 */
.source-title { font-size: var(--fs-h4); font-weight: var(--fw-medium); line-height: var(--lh-h4); color: var(--ink-1); }
.source-desc {
  margin: 2px 0 0; max-width: var(--read-max);
  font-size: var(--fs-caption); line-height: 1.55; color: var(--ink-4);
}
.source-items { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.source-item {
  padding: 6px 8px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--hair);
}
.source-item.is-bad { border-color: rgba(214, 57, 57, .35); background: var(--red-soft); }
.source-item-main { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.source-item-name { font-family: var(--mono); font-size: var(--fs-caption); word-break: break-all; }
.source-item-roles { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.source-missing { margin-top: 8px; }

.source-inline {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 8px 10px; margin-bottom: var(--sp-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--hair);
}
.source-inline-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.source-inline-label { font-size: var(--fs-micro); line-height: 1.5; color: var(--ink-4); }
.source-inline-value { font-family: var(--mono); font-size: var(--fs-caption); word-break: break-all; }

/* 两张主库的一致性核对：数据健康度卡片 */
.source-sync-card { margin-top: 6px; }
.source-sync { display: grid; gap: 2px; }
.source-sync .kv { margin: 0; }

/* ---------------- 报价区块 ---------------- */
.quote-grid {
  display: grid; gap: var(--gap-inner);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.quote-grid > .field { min-width: 0; }
.quote-lines-preview { margin-top: 8px; }
.quote-lines-preview > .notice-bar { margin-bottom: 6px; }
.quote-customers:empty { display: none; }

/* ---------------- 吐司 ---------------- */
.toasts, .toast-host {
  position: fixed; right: var(--sp-5); bottom: var(--sp-5); z-index: 999;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--hair-2);
  border-left: 3px solid var(--brand);
  box-shadow: var(--shadow-3);
  font-size: var(--fs-caption); line-height: 1.55;
  max-width: 420px;
  pointer-events: auto;
  animation: toast-in .18s ease-out;
}
.toast-icon { font-size: 15px; color: var(--brand); margin-top: 1px; }
.toast-msg { color: var(--ink-1); }
.toast-ok { border-left-color: var(--green); }
.toast-ok .toast-icon { color: var(--green); }
.toast-warn { border-left-color: var(--orange); }
.toast-warn .toast-icon { color: var(--orange); }
.toast-error { border-left-color: var(--red); }
.toast-error .toast-icon { color: var(--red); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------------- 令牌门（401 时的页内对话框） ---------------- */
.token-gate {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center;
  padding: var(--sp-5);
  background: rgba(24, 36, 51, .42);
  backdrop-filter: blur(2px);
}
.token-gate-card {
  width: min(420px, 100%);
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--hair-2);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
}
.token-gate-title {
  margin: 0 0 6px;
  font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: var(--fw-semibold);
}
.token-gate-hint {
  margin: 0 0 var(--sp-3);
  max-width: var(--read-max);
  font-size: var(--fs-caption); line-height: 1.55; color: var(--ink-3);
}
.token-gate-input {
  width: 100%;
  min-height: 32px; padding: 5px 10px;
  font: var(--fw-regular) var(--fs-body)/1.45 var(--sans);
  color: var(--ink-1);
  background: var(--surface-2);
  border: 1px solid var(--hair-2);
  border-radius: var(--r-sm);
}
.token-gate-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(6, 111, 209, .12); }

/* ---------------- 载入 ---------------- */
.loading { display: flex; align-items: center; gap: 8px; color: var(--ink-3); }
.spinner {
  width: 14px; height: 14px; border-radius: var(--r-pill); flex: 0 0 14px;
  border: 2px solid var(--hair-2);
  border-top-color: var(--brand);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 装柜图（父页面里的 iframe 与摘要） ---------------- */
/* 编辑器内部是「总览｜方案图｜右侧面板」三栏；总览是 1:5 的长条，三栏本身
   就有 ~1400px 高。iframe 给矮了（原来 680px）用户在 iframe 里滚来滚去，
   方案图和右侧指标看不到一起 —— 所以给足高度，让页面整体滚动。 */
.container-editor-frame {
  display: block; width: 100%;
  height: max(880px, calc(100vh - 180px));
  border: 1px solid var(--hair-2); border-radius: var(--r-md);
  background: var(--surface);
}
/* 窄屏编辑器退化成单列（总览压成缩略图）后更高，父页 iframe 相应加高。 */
@media (max-width: 900px) {
  .container-editor-frame { height: max(980px, calc(100vh - 140px)); }
}
.container-warns { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.container-warns summary {
  cursor: pointer; color: var(--ink-4);
  font-size: var(--fs-caption); line-height: 1.5;
}
.container-warns p { margin: 0; }
.container-assumptions { margin-top: 8px; }
.container-assumptions summary {
  cursor: pointer; color: var(--ink-4); font-size: var(--fs-caption); line-height: 1.5;
}
.container-assumptions p { margin: 2px 0 0; }
/* 编辑器 8 秒没 ready 时的兜底提示 */
.editor-hint {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 8px; padding: 7px 10px;
  border-radius: var(--r-sm);
  background: var(--orange-soft); border: 1px solid rgba(196, 127, 23, .3);
  font-size: var(--fs-caption); line-height: 1.5; color: #8a5a00;
}
.editor-hint[hidden] { display: none; }
/* 父页摘要区里的"编辑器实时统计" */
.editor-live-stats {
  margin-top: 8px; padding: 5px 9px;
  border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--hair-2);
  font-size: var(--fs-caption); line-height: 1.5; color: var(--ink-2);
}
.editor-live-stats.is-bad { color: #8a0000; background: var(--red-soft); border-color: rgba(214, 57, 57, .25); }

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    border-right: 0; border-bottom: 1px solid var(--hair-2);
  }
  .sidebar-header { padding: 8px 12px; }
  .sidebar-scroll { flex-direction: row; align-items: center; gap: 8px; overflow-x: auto; padding: 8px 12px; }
  .nav-section-title { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin: 0; border-top: 0; padding: 0; flex-direction: row; align-items: center; }
  .side-sep { display: none; }
  .sidebar-version { display: none; }
  .nav-item { padding: 5px 9px; font-size: var(--fs-caption); }
  .nav-icon { width: 15px; height: 15px; flex: 0 0 15px; font-size: 15px; }
  .topbar { position: static; padding: 10px var(--sp-4); }
  .topbar-left h1 { font-size: 18px; }
  .content { padding: var(--sp-3) var(--sp-3) var(--sp-6); }
  /* 小屏顶栏按钮只留图标：文字节点是 <span>，但图标本身也是 <span class="icon">，
     所以必须排除 .icon，否则按钮会变成三个空盒子。 */
  .topbar-actions .btn > span:not(.icon) { display: none; }
}

/* ---------------- 可访问性 ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* 系统要求更高对比度：投影收掉、描边加重，保证可读性 */
@media (prefers-contrast: more) {
  :root {
    --ink-2: #2b3542;
    --ink-3: #45505d;
    --ink-4: #5a6470;
    --hair: rgba(0, 0, 0, .22);
    --hair-2: rgba(0, 0, 0, .30);
    --hair-dark: rgba(0, 0, 0, .40);
    --shadow-1: 0 0 0 1px rgba(0, 0, 0, .10);
    --shadow-2: 0 0 0 1px rgba(0, 0, 0, .14);
    --shadow-3: 0 2px 8px rgba(0, 0, 0, .22);
  }
  .card, .warning, .artifact, .table-wrap, .doc-card, .source-item { border-width: 1.5px; }
}

/* ---------------- 配件中心（2026-11 新版页面，只在这里追加） ---------------- */
/* 结果卡顶部指标：Total / Deduct / Final、型号数之类的一排等宽小块。
   颜色只表状态（primary=最终要看的数，is-warn=要处理），不拿来装饰。 */
.metric-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.metric {
  flex: 1 1 150px; min-width: 0;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--hair-2);
  border-radius: var(--r-sm);
}
.metric.is-primary { background: var(--brand-soft); border-color: var(--brand-line); }
.metric-label { font-size: var(--fs-micro); line-height: 1.5; color: var(--ink-4); }
.metric-value {
  font-size: var(--fs-h2); font-weight: var(--fw-semibold);
  line-height: var(--lh-h2); color: var(--ink-1);
  font-variant-numeric: tabular-nums; word-break: break-word;
}
.metric-value.is-warn { color: #8a5a00; }
.metric-note { font-size: var(--fs-micro); line-height: 1.5; color: var(--ink-4); }

/* 预览区（选合同后的型号匹配摘要 + 表格）与订单口径判定说明 */
.spare-preview { display: flex; flex-direction: column; gap: var(--sp-2); }
.spare-uploaded > .notice-bar { margin-top: 0; }
.order-mode-hint {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  margin-top: 5px;
  font-size: var(--fs-caption); line-height: 1.5;
}

/* 顶卡「价格与口径」：成本表 / 对照表压成两行，规则收进 details */
.spare-meta { display: flex; flex-direction: column; }
.spare-meta-row {
  display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
  padding: 4px 0;
  border-bottom: 1px solid var(--hair);
  font-size: var(--fs-caption); line-height: 1.5;
}
.spare-meta-row:last-child { border-bottom: none; }
.spare-meta-name { font-weight: var(--fw-medium); color: var(--ink-2); }

/* 窄屏：指标块一行一个，别把 Total/Final 挤成两行数字 */
@media (max-width: 900px) {
  .metric { flex-basis: 100%; }
}

/* Customer delivery: clear workflow hierarchy */
:root { --fht-accent: #174ea6; }
.card > .card-header { background: #174ea6; color: #fff; border-bottom: 0; padding: 16px 20px; }
.card > .card-header h2, .card > .card-header h3, .card > .card-header .card-title { color: #fff; }
.card > .card-header .icon { color: #dbeafe; }
.card { border: 1px solid #d5deec; box-shadow: 0 3px 12px #17345d0a; }
.card-body { background: #fff; }
.source-head, .section-head { background: #eaf1fc; color: #174ea6; padding: 10px 12px; border-radius: 7px; }
.btn-primary { background: #174ea6; border-color: #174ea6; }

.contract-input { margin-bottom:24px; min-width:0; container-type:inline-size; }
.contract-input > .field-label { margin-bottom:8px; }
.contract-choice { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:12px; align-items:stretch; }
.contract-choice .form-select { width:100%; min-width:0; height:40px; margin:0; }
.contract-choice .btn { height:40px; margin:0; padding:8px 18px; }
.contract-input > .field-help:empty { display:none; }
.contract-input > .field-help:not(:empty) { margin:10px 0 0; }
.contract-manager { margin-top:18px; border:1px solid #d5deec; border-radius:8px; padding:0; overflow:hidden; }
.contract-manager > summary { cursor:pointer; color:#174ea6; font-weight:600; padding:14px 16px; margin:0; line-height:1.5; background:#f6f9fe; }
.contract-manager[open] > summary { border-bottom:1px solid #d5deec; }
.contract-manager-body { padding:16px; min-width:0; }
.contract-manager-body > input { min-height:38px; margin:0 0 16px; }
.contract-manager .table-wrap { margin:0; max-height:360px; overflow:auto; }
.contract-manager .table { width:100%; table-layout:fixed; margin:0; }
.contract-manager .table th, .contract-manager .table td { vertical-align:middle; padding:12px; }
.contract-manager .table th:nth-child(2), .contract-manager .table td:nth-child(2) { width:88px; white-space:nowrap; }
.contract-manager .table th:nth-child(3), .contract-manager .table td:nth-child(3) { width:156px; }
.contract-manager .table td:first-child { white-space:normal; overflow-wrap:anywhere; }
.contract-actions { display:flex; justify-content:flex-start; align-items:center; flex-wrap:nowrap; gap:10px; margin:0; padding:0; }
.contract-actions .btn { min-width:54px; min-height:32px; margin:0; padding:5px 10px; }
@container (max-width:520px) {
 .contract-manager .table th:nth-child(2), .contract-manager .table td:nth-child(2) { display:none; }
 .contract-manager .table th:nth-child(3), .contract-manager .table td:nth-child(3) { width:140px; }
 .contract-manager-body { padding:12px; }
 .contract-manager .table th, .contract-manager .table td { padding:10px; }
}
@container (max-width:380px) {
 .contract-choice { grid-template-columns:minmax(0,1fr); gap:10px; }
 .contract-choice .btn { width:100%; }
 .contract-manager .table th:nth-child(3), .contract-manager .table td:nth-child(3) { width:116px; }
 .contract-actions { gap:6px; }
 .contract-actions .btn { min-width:44px; padding:5px 7px; }
}
/* Administrator AI source forms. */
.ai-source { padding: 18px 0; border-bottom: 1px solid var(--border, #dce2e9); }
.ai-source .row-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
/* Read-only document review workspace. */
.review-workspace { display:grid; grid-template-columns:minmax(0,1.6fr) minmax(320px,1fr); gap:18px; align-items:start; margin-top:18px; }
.review-workspace > * { min-width:0; }
.review-toolbar { display:flex; gap:16px; align-items:flex-end; }
.review-toolbar .field { flex:1; margin:0; min-width:0; }
.review-toolbar > .btn { flex:none; min-height:40px; }
.review-doc-options, .review-choices { display:flex; flex-wrap:wrap; align-items:center; gap:12px 18px; margin:16px 0; }
.review-choice { display:inline-flex; align-items:center; gap:7px; font-size:13px; cursor:pointer; }
.review-choice input { accent-color:#2054a0; width:16px; height:16px; }
.review-scope-label { color:#1b4d8d; font-weight:600; font-size:13px; }
.review-projects { margin:12px 0; }
.review-projects summary, .review-chat summary, .review-skipped summary { cursor:pointer; font-weight:600; padding:8px 0; }
.review-preview, .review-issues { background:#fff; border:1px solid #dce3ed; border-radius:10px; overflow:hidden; }
.review-preview { position:sticky; top:84px; }
.review-preview-toolbar { display:flex; gap:8px; align-items:center; padding:14px; background:#edf3fc; flex-wrap:wrap; }
.review-preview-toolbar select { min-width:100px; flex:1; max-width:250px; }
.review-preview-toolbar .btn { flex:none; }
.review-file-caption { padding:8px 14px; font-size:12px; color:#66758a; overflow-wrap:anywhere; border-bottom:1px solid #e2e8f0; }
.review-table-scroll { overflow:auto; height:65vh; min-height:320px; background:#f8fafc; }
.review-grid { border-collapse:separate; border-spacing:0; font-size:12px; width:max-content; min-width:100%; table-layout:fixed; }
.review-grid th, .review-grid td { border-right:1px solid #dce3ed; border-bottom:1px solid #dce3ed; padding:9px 10px; vertical-align:middle; }
.review-grid td { min-width:105px; max-width:240px; white-space:pre-wrap; overflow-wrap:anywhere; background:#fff; }
.review-grid th { background:#edf2f8; color:#50617a; text-align:center; min-width:45px; font-weight:600; }
.review-grid thead th { position:sticky; top:0; z-index:3; }
.review-grid tr > th:first-child { position:sticky; left:0; z-index:2; }
.review-grid thead tr > th:first-child { z-index:4; }
.review-grid .review-data-header td { background:#e6eefb; color:#183f79; font-weight:700; }
.review-grid td.review-highlight.review-error { background:#ffe0df; box-shadow:inset 0 0 0 2px #c83e3e; }
.review-grid td.review-highlight.review-confirm, .review-grid td.review-highlight.review-missing { background:#fff0cc; box-shadow:inset 0 0 0 2px #bc7c16; }
.review-grid .review-formula-pending { color:#926215; font-style:italic; }
.review-pager { display:flex; align-items:center; justify-content:center; gap:12px; padding:12px; border-top:1px solid #e2e8f0; flex-wrap:wrap; font-size:12px; }
.review-issue-header { padding:15px 16px; background:#2052a0; color:white; display:flex; justify-content:space-between; align-items:center; gap:8px; flex-wrap:wrap; }
.review-issue-header h2 { margin:0; color:white; font-size:17px; }
.review-issue-header .muted { color:#d9e5fa !important; }
.review-filters { display:flex; flex-wrap:wrap; gap:7px; padding:14px; border-bottom:1px solid #e2e8f0; }
.review-issue-list { padding:12px; max-height:40vh; overflow:auto; display:grid; gap:10px; }
.review-issue { display:grid; gap:7px; width:100%; text-align:left; background:#fff; padding:13px; border:1px solid #dce3ed; border-left:4px solid #bc7c16; border-radius:7px; cursor:pointer; color:#29364a; font:inherit; font-size:13px; }
.review-issue.review-error { border-left-color:#c83e3e; }
.review-issue:hover, .review-issue.is-selected { border-color:#2052a0; box-shadow:0 0 0 1px #2052a0; background:#f5f8ff; }
.review-category { font-size:11px; font-weight:700; color:#926215; }
.review-error .review-category { color:#b52f35; }
.review-place { font-size:11px; color:#697b92; }
.review-empty { padding:10px; color:#65758b; font-size:13px; }
.review-detail, .review-chat, .review-skipped { margin:0 14px; padding:14px 0; border-top:1px solid #e2e8f0; }
.review-detail h3 { font-size:15px; margin:0 0 12px; }
.review-detail h4 { font-size:12px; color:#65758b; margin:12px 0 5px; }
.review-detail p { font-size:13px; line-height:1.65; overflow-wrap:anywhere; }
.review-detail .row-actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.review-evidence { background:#f2f6fc; padding:11px; border-radius:6px; }
.review-chat-history { max-height:300px; overflow:auto; display:grid; gap:10px; margin-bottom:10px; }
.review-chat-message { padding:10px; background:#f1f5fb; border-radius:7px; font-size:13px; }
.review-chat-message.is-user { background:#e8f0fe; }
.review-chat-message strong { font-size:11px; color:#526781; }
.review-chat-message p { margin:5px 0 0; white-space:pre-wrap; line-height:1.65; }
.review-chat > .btn { margin-top:10px; }
.review-skipped p { font-size:12px; color:#65758b; }
@media (max-width:1100px) { .review-workspace { grid-template-columns:minmax(0,1fr); } .review-preview { position:static; } .review-table-scroll { height:50vh; } .review-issue-list { max-height:45vh; } }
@media (max-width:600px) { .review-toolbar { flex-wrap:wrap; } .review-toolbar .field { flex-basis:100%; } .review-toolbar > .btn { width:100%; } .review-preview-toolbar select { max-width:none; } }
.admin-maintenance { margin:18px 0; border:1px solid #dce3ed; border-radius:8px; padding:12px 16px; background:white; }
.admin-maintenance > summary { cursor:pointer; font-weight:600; color:#204b87; }
.admin-maintenance > div { margin-top:16px; }
