﻿/* ============================================================
 * 开单自动取价 + 财务价格审核
 * 依赖 app.css 中的 --card / --line / --muted / --brand / --text 变量
 * -----------------------------------------------------------------------------
 * 2026-11-16 UI 走查修订（只改样式，不动 DOM / JS）：
 *   1) 算价卡片：金额最大最显眼，判定次之，单价与口径降为辅助行；金额改用
 *      主题安全的强调文字色（--ds-accent-text），深色下不再用填充蓝当文字色。
 *   2) 联系人输入框补齐 100% 宽（此前是浏览器默认 169px），下拉项最小高度
 *      40px 以满足触控，下拉层提高 z-index 并限制高度。
 *   3) 发货人 / 收货人两块在 13 个字段中间自成一组（用 :has 加容器，不改 DOM）。
 *   4) 审价弹窗：两列只读信息对齐、去掉满屏虚线、窄屏改一列；三选一改为
 *      等宽 40px 大按钮。
 *   5) 客户档案工具栏右侧的统计文案单独成行，不再和按钮抢位置。
 * ============================================================ */

/* ------------------------------------------------------------
 * 1. 开单：自动算价卡片
 *    信息层级：金额（唯一大号）> 重泡判定 > 计费重量/单价（辅助）
 * ---------------------------------------------------------- */
.quote-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  padding: 12px 14px;
  min-height: 46px;
  width: 100%;
  box-sizing: border-box;
  /* 左侧 3px 竖条：这是系统算的，不是人填的（用 inset 阴影，不占布局） */
  box-shadow: inset 3px 0 0 var(--brand);
  border-left-color: var(--brand);
}
.quote-hint { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.quote-hint.is-warn { color: var(--orange); }
/* 首屏是空盒子（还没填客户/重量，JS 不会写提示），用 :empty 补一句引导语 */
.quote-box:empty::before {
  content: '填写客户、发到站、重量、体积后自动出价';
  font-size: 12.5px; color: var(--muted);
}

.quote-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.quote-amount {
  font-size: 26px; font-weight: 700; line-height: 1.1; letter-spacing: -.4px;
  /* 深色主题下用「强调文字色」，不要用填充蓝：填充蓝当文字只有约 3:1 */
  color: var(--ds-accent-text, var(--brand));
  font-variant-numeric: tabular-nums;
}
/* 判定标签跟在金额右侧，但不再抢字号 */
.quote-head .tag { margin-top: 3px; }
.quote-src { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }

.quote-meta {
  margin-top: 8px; padding-left: 10px;
  border-left: 2px solid var(--line);
  font-size: 12px; line-height: 1.6; color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.quote-bd { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 4px; }
.quote-bd-row {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 12.5px; padding: 3px 0;
  font-variant-numeric: tabular-nums;
}
.quote-bd-row > span:first-child { color: var(--muted); }
.quote-bd-row > span:last-child { color: var(--text); font-weight: 600; text-align: right; }

.quote-warn { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.quote-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.quote-label .field-label { font-weight: 600; color: var(--text); }

/* ------------------------------------------------------------
 * 2. 历史联系人自动匹配（输入即匹配）
 * ---------------------------------------------------------- */
.pick-wrap { position: relative; }
/* 之前输入框是浏览器默认 169px，比它自己的下拉层窄得多 */
.pick-wrap > .input { width: 100%; box-sizing: border-box; }

.pick-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 60;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--ds-shadow-3, 0 8px 24px rgba(16, 26, 43, .18));
  /* 弹窗内是可滚动区域，太高会被裁切；限制高度并内部滚动 */
  max-height: min(280px, 42vh); overflow: auto;
  display: none; padding: 4px;
}
.pick-list.on { display: block; }
.pick-item {
  display: flex; flex-direction: column; justify-content: center;
  min-height: 40px;                  /* 触控最小点击区（手机宽度下也够） */
  padding: 8px 10px; border-radius: 6px;
  cursor: pointer; border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.pick-item:last-child { border-bottom: 0; }
.pick-item:hover, .pick-item.hl { background: var(--ds-accent-subtle, rgba(45, 114, 210, .14)); }
.pick-title { font-weight: 600; color: var(--text); font-size: 13px; }
.pick-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; line-height: 1.45; }
.pick-empty { padding: 12px 10px; color: var(--muted); font-size: 12.5px; }

/* ------------------------------------------------------------
 * 3. 表单分组：发货人 / 收货人自成一块（不改 DOM，用 :has 找父级）
 * ---------------------------------------------------------- */
.form-grid > .form-item:has(> .contact-block) {
  position: relative; z-index: 1;   /* 栅格项会各自成层：抬起来，下拉才能盖住后面的字段 */
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px 12px;
  gap: 8px;
}
/* 正在输入的这一块再抬一层：否则后一块联系人的面板会盖住前一块的下拉 */
.form-grid > .form-item:has(.pick-wrap:focus-within) { z-index: 20; }   /* 高于吸顶报价条(6)，下拉才不会被它盖住 */
.form-grid > .form-item:has(> .contact-block) > .contact-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin: 0 0 2px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.contact-block { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.contact-block .cb-full { grid-column: 1 / -1; }
.contact-title { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; grid-column: 1 / -1; }

/* ------------------------------------------------------------
 * 4. 审价弹窗
 * ---------------------------------------------------------- */
.audit-info {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 24px; margin-bottom: 12px;
  padding: 4px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.audit-info .ai-row {
  display: flex; align-items: baseline; gap: 10px;
  font-size: 12.5px; padding: 7px 0;
  border-bottom: 1px solid var(--line); min-width: 0;
}
/* 最后一行的两格去掉下边线，收口干净 */
.audit-info .ai-row:nth-last-child(-n+2) { border-bottom: 0; }
.audit-info .ai-k { flex: 0 0 auto; min-width: 68px; color: var(--muted); white-space: nowrap; }
.audit-info .ai-row > span:last-child {
  flex: 1 1 auto; min-width: 0; text-align: right;
  color: var(--text); font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* 三选一：等宽大按钮，40px 点击区，选中态明确 */
.audit-choice { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0 4px; }
.audit-choice label {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 12px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--text);
  font-size: 13px; line-height: 1.2;
  transition: background-color 120ms cubic-bezier(.4, 0, .2, 1), border-color 120ms;
}
.audit-choice label:hover { border-color: var(--brand); }
.audit-choice label.on {
  border-color: var(--brand);
  /* 选中态文字也不能用填充蓝：深色下只有 3:1，改用强调文字色 */
  color: var(--ds-accent-text, var(--brand));
  font-weight: 600;
  background: var(--ds-accent-subtle, rgba(45, 114, 210, .14));
}
.audit-choice input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }

.audit-field { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.audit-field > span { font-size: 12.5px; color: var(--muted); }
.audit-field .input { width: 100%; box-sizing: border-box; }

.audit-breakdown { margin-top: 10px; font-size: 12.5px; }
.audit-breakdown .field-label { margin-bottom: 4px; }
.audit-breakdown .ab-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 6px 0; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.audit-breakdown .ab-row span:first-child { color: var(--muted); }
.audit-breakdown .ab-row span:last-child { color: var(--text); font-weight: 600; }
.audit-breakdown .ab-row:last-child { border-bottom: 0; }

.audit-audits { margin-top: 14px; }
.audit-audits .field-label { margin-bottom: 6px; }

/* ------------------------------------------------------------
 * 5. 客户档案工具栏：右侧统计文案单独成行，不再和按钮挤在一起
 * ---------------------------------------------------------- */
.toolbar > .hint {
  font-size: 12px; line-height: 1.6; color: var(--muted);
  font-variant-numeric: tabular-nums; text-align: right;
}
/* 换行后不要把「筛选 N / 共 N 条」甩到左边，始终贴着右端 */
.toolbar > .hint:last-child { margin-left: auto; }
.toolbar > .hint + .hint { white-space: nowrap; }

/* ------------------------------------------------------------
 * 6. 窄屏（手机宽度）
 * ---------------------------------------------------------- */
@media (max-width: 720px) {
  .audit-info { grid-template-columns: 1fr; padding: 4px 10px; }
  .audit-info .ai-row:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); }
  .audit-info .ai-row:last-child { border-bottom: 0; }
  .audit-info .ai-k { min-width: 76px; }
}
@media (max-width: 640px) {
  /* 开单表单在手机上改单列：两列输入框各只剩 150px 左右，写不下中文地址 */
  .modal-bd .form-grid:has(.contact-block) { grid-template-columns: 1fr; }
  .modal-bd .form-grid:has(.contact-block) .form-item.span-2 { grid-column: auto; }
  .contact-block { grid-template-columns: 1fr; }
  .quote-amount { font-size: 24px; }
  .quote-src { margin-left: 0; }
  .pick-list { max-height: 46vh; }
  .toolbar > .spacer { display: none; }
  .toolbar > .hint { flex: 1 1 100%; text-align: left; }
}
@media (max-width: 480px) {
  .audit-choice { grid-template-columns: 1fr; }
}

/* 紧凑模式：这两块也跟着收紧，但点击区不小于 36px */
[data-density="compact"] .pick-item { min-height: 36px; padding: 6px 10px; }
[data-density="compact"] .audit-info .ai-row { padding: 5px 0; }
[data-density="compact"] .audit-choice label { min-height: 36px; }

/* ============================================================
 * 补充（2026-11-16，Chief 补）：审价弹窗里把「系统报价」这一行抬出来，
 * 其余 11 项是核对信息，只有它是要和财务改价对照的那个数。
 * ============================================================ */
.audit-info .ai-row.audit-amount { border-bottom: 1px solid var(--line); padding: 8px 0; }
.audit-info .ai-row.audit-amount .ai-k { color: var(--text); font-weight: 600; }
.audit-info .ai-row.audit-amount > span:last-child {
  font-size: 18px; font-weight: 700; color: var(--brand);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
 * 开单表单：分区 + 收发货人并排 + 金额吸顶（2026-11-16）
 * ============================================================ */
.order-form { display: flex; flex-direction: column; }

/* 开单弹窗体去掉顶部内边距：吸顶报价条要以滚动视口为界贴住弹窗头，
   否则滚动时上一屏内容会从那条 16px 的留白里露出来（sticky 的 top 只能
   顶到内容区上沿，负 margin 会被包含块夹住，实测无效）。 */
.modal-bd:has(.order-form) { padding-top: 0; }
.order-form { display: flex; flex-direction: column; }

/* 吸顶报价条：填重量体积时不用滚到底才看到钱 */
.quote-bar {
  position: sticky; top: 0; z-index: 6;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin: 0 calc(-1 * var(--ds-space-6)) var(--ds-space-5);
  padding: 10px var(--ds-space-6);
  background: var(--card); border-bottom: 1px solid var(--line);
  box-shadow: var(--ds-shadow-2, 0 4px 12px -8px rgba(16, 26, 43, .35));
}
.qb-amount { font-size: 21px; font-weight: 700; color: var(--ds-accent-text, var(--brand)); font-variant-numeric: tabular-nums; }
.qb-tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.qb-tag-blue { color: var(--ds-accent-text, var(--brand)); background: var(--ds-accent-subtle, rgba(45, 114, 210, .14)); }
.qb-tag-cyan { color: var(--ds-info-text, var(--cyan)); background: var(--ds-info-subtle, rgba(76, 144, 240, .14)); }
.qb-tag-red { color: var(--ds-danger-text, var(--red)); background: var(--ds-danger-subtle, rgba(250, 153, 156, .14)); }
.qb-meta { font-size: 12px; color: var(--muted); }
.qb-src { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }

/* 分区标题 */
.form-section {
  grid-column: 1 / -1;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin: 14px 0 2px; padding-top: 12px;
  border-top: 1px solid var(--line);
}
.form-section:first-child { margin-top: 4px; padding-top: 0; border-top: 0; }
.form-section-t { font-size: 13px; font-weight: 700; color: var(--text); position: relative; padding-left: 9px; }
.form-section-t::before {
  content: ''; position: absolute; left: 0; top: 2px; bottom: 2px; width: 3px;
  border-radius: 2px; background: var(--brand);
}
.form-section-h { font-size: 11.5px; color: var(--muted); }

/* 收发货人并排：各占一列，内部紧凑 */
.contact-panel {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; background: var(--bg);
}
.contact-panel .contact-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 8px;
}
.contact-tag { font-size: 11px; font-weight: 400; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; }
.contact-block { display: block; }
.contact-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.contact-block .cb-full { width: 100%; }

@media (max-width: 860px) {
  .contact-row { grid-template-columns: 1fr; }
}

/* 窄屏：报价条只留「金额 + 判定 + 来源」，计费口径留在底部明细卡里，否则吸顶条会占掉 1/5 屏 */
@media (max-width: 640px) {
  .quote-bar { padding: 8px var(--ds-space-6); gap: 8px; }
  .qb-amount { font-size: 19px; }
  .qb-meta { display: none; }
  .qb-src { margin-left: auto; }
}
/* ============================================================
 * 订单列表：蓝桥写入状态的行级区分（2026-11-16）
 * 未写=琥珀左边条；已写=绿色左边条；已写待核=橙色
 * ============================================================ */
.table tbody tr.row-unbridged > td:first-child {
  box-shadow: inset 3px 0 0 var(--orange);
}
.table tbody tr.row-unbridged { background: rgba(217, 119, 6, .05); }
.table tbody tr.row-bridged > td:first-child {
  box-shadow: inset 3px 0 0 var(--green);
}
.table tbody tr.row-bridge-warn > td:first-child {
  box-shadow: inset 3px 0 0 var(--red);
}
.table tbody tr.row-bridge-warn { background: rgba(220, 38, 38, .05); }
.table tbody tr:hover.row-unbridged { background: rgba(217, 119, 6, .1); }
.table tbody tr:hover.row-bridge-warn { background: rgba(220, 38, 38, .1); }

.bridge-legend { display: inline-flex; align-items: center; gap: 14px; font-size: 12px; color: var(--muted); margin-left: 6px; }
.bridge-legend i { display: inline-block; width: 3px; height: 13px; border-radius: 2px; margin-right: 5px; vertical-align: -2px; }
.bridge-legend .lg-none i { background: var(--orange); }
.bridge-legend .lg-done i { background: var(--green); }
.bridge-legend .lg-warn i { background: var(--red); }

/* ============================================================
 * 开单表单：已填 / 未填字段的视觉区分（2026-11-16）
 * 只作用于文本/数字输入框——下拉框永远有值，上色只会变成噪音。
 * 已填 = 淡蓝底 + 实线；未填 = 素底 + 虚线边框
 * ============================================================ */
.order-form .form-grid input.input,
.order-form .form-grid textarea.input {
  transition: background .12s ease, border-color .12s ease;
}
.order-form .form-grid input.input:not(.is-filled),
.order-form .form-grid textarea.input:not(.is-filled) {
  border-style: dashed;
  border-color: var(--line);
  background: transparent;
}
.order-form .form-grid input.input.is-filled,
.order-form .form-grid textarea.input.is-filled {
  border-style: solid;
  border-color: rgba(31, 111, 235, .62);
  background: rgba(31, 111, 235, .06);
  color: var(--text);
}
.order-form .form-grid input.input.is-filled:focus,
.order-form .form-grid textarea.input.is-filled:focus {
  border-color: var(--brand);
  background: rgba(31, 111, 235, .09);
}

/* 联系人面板：名称+手机都填了，边框转绿、右上角标签跟着变 */
.contact-panel.all-filled { border-color: rgba(22, 163, 74, .5); }
.contact-panel.all-filled .contact-tag { color: var(--green); border-color: rgba(22, 163, 74, .45); }
/* 附加费编辑器 */
.fee-box { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.fee-row { display: grid; grid-template-columns: 1fr 140px 40px; gap: 8px; align-items: center; }
.fee-row:last-child { grid-template-columns: 1fr; }
.fee-row .btn { padding: 4px 0; }

/* ============================================================
 * 新建订单：全屏三栏（2026-11-16）
 * 目标：所有内容同屏可见，不用拖进度条
 * ============================================================ */
.modal.modal-full {
  width: 97vw; max-width: none; height: 93vh;
  display: flex; flex-direction: column;
}
.modal.modal-full .modal-bd { flex: 1 1 auto; overflow: auto; }
.modal.modal-full .modal-hd { flex: none; }
.modal.modal-full .modal-ft { flex: none; }

.modal-full .order-form .form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 14px;
  align-items: start;
}
.modal-full .order-form .quote-panel {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; background: var(--card);
  min-height: 100%;
}
.modal-full .order-form .quote-panel .quote-box { border: 0; background: transparent; padding: 0; margin-top: 8px; }

@media (max-width: 1180px) {
  .modal-full .order-form .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .modal.modal-full { width: 100vw; height: 100vh; border-radius: 0; }
  .modal-full .order-form .form-grid { grid-template-columns: 1fr; }
}

/* ============================================================
 * 报价卡重做：金额可编辑、层级清晰（2026-11-16）
 * ============================================================ */
.quote-amount-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 2px 0 6px; }
.quote-cur { font-size: 18px; font-weight: 700; color: var(--brand); }
.quote-amount-in {
  width: 150px; font-size: 26px; font-weight: 700; color: var(--brand);
  background: transparent; border: 0; border-bottom: 2px solid rgba(31, 111, 235, .35);
  padding: 0 2px 1px; outline: none; font-variant-numeric: tabular-nums; font-family: inherit;
}
.quote-amount-in:focus { border-bottom-color: var(--brand); background: rgba(31, 111, 235, .06); }
.quote-amount-in::-webkit-outer-spin-button,
.quote-amount-in::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.quote-note {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12px; color: var(--orange);
  background: rgba(217, 119, 6, .08); border-radius: 6px; padding: 5px 8px; margin-bottom: 6px;
}
.quote-panel .quote-head { display: none; }

/* 加深「已填」底纹：原来 .06 太淡，夹在白底里看不出边界 */
.order-form .form-grid input.input.is-filled,
.order-form .form-grid textarea.input.is-filled {
  border-color: rgba(31, 111, 235, .62);
  background: rgba(31, 111, 235, .13);
}
.order-form .form-grid input.input.is-filled:focus,
.order-form .form-grid textarea.input.is-filled:focus {
  border-color: var(--brand);
  background: rgba(31, 111, 235, .2);
}

/* 报价卡去掉左侧那条竖条/括号装饰，改成干净的卡片；金额输入框宽度贴合数字 */
.modal-full .order-form .quote-panel .quote-box {
  border: 0 !important;
  box-shadow: none !important;
  background: transparent;
  padding: 0;
  border-radius: 0;
  margin-top: 10px;
}
.quote-amount-in {
  width: 8.5ch;
  min-width: 96px;
  border-bottom-width: 1px;
  text-align: left;
}
.quote-amount-row { gap: 8px; padding-bottom: 2px; }
.quote-panel .quote-label { padding-bottom: 2px; }

/* 收发货人下拉：顶部说明这一批是「谁的收货人」 */
.pick-head {
  padding: 5px 10px; font-size: 11.5px; color: var(--brand);
  background: rgba(31, 111, 235, .07); border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
}

/* 固定值显示（发站固定宁波：不用下拉，直接显示） */
.form-item .fixed-value {
  display: flex; align-items: center; height: 34px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 6px;
  background: rgba(31, 111, 235, .08); color: var(--text);
  font-weight: 600; letter-spacing: .5px;
}


/* 配载：挂单列表 */
.lp-head, .lp-row { display: grid; grid-template-columns: 30px 1.2fr 1fr .7fr .6fr .8fr .9fr; gap: 8px; align-items: center; }
.lp-head { font-size: 11.5px; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 2; }
.lp-list { max-height: 52vh; overflow: auto; }
.lp-row { padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.lp-row.on { background: rgba(31,111,235,.07); }
.lp-no { font-variant-numeric: tabular-nums; }
.lp-c { text-align: center; }
.lp-r { text-align: right; }
