/*
 * 客户填单页。**只支持 PC**（2026-10-15 定）：按内容区 1120px 设计，
 * 不做手机断点、不按触屏最小点区排版。窄屏靠横向滚动兜底。
 */

body {
  padding-bottom: 88px; /* 给吸底的提交条让位 */
}

.topbar {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 20px 14px;
}
.topbar h1 {
  margin-bottom: 2px;
}
.topbar p {
  margin: 0;
  font-size: 13px;
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

.narrow {
  max-width: 520px;
  margin: 8vh auto 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: var(--gap);
  box-shadow: var(--shadow);
}

.card > h2,
.card-head {
  margin: 0 0 14px;
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap);
  flex-wrap: wrap;
}
.card-head h2 {
  margin: 0;
  font-size: 16px;
}
.card-head .faint {
  font-size: 12px;
}

.center {
  text-align: center;
}

/* ---------- 栅格 ---------- */

.grid {
  display: grid;
  gap: 0 var(--gap);
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.span-3 {
  grid-column: span 3;
}

/* ---------- 固定预填 ---------- */

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px var(--gap);
  margin: 0;
}
.kv dt {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}
.kv dd {
  margin: 0;
  word-break: break-all;
}
.kv-inline {
  grid-template-columns: auto 1fr auto 1fr;
  align-items: baseline;
}

/* ---------- 表单 ---------- */

.field {
  display: block;
  margin: 0 0 14px;
  border: 0;
  padding: 0;
  min-width: 0;
}
.field > span,
.field > legend {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 5px;
  padding: 0;
}

.req,
.opt {
  font-style: normal;
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 3px;
  vertical-align: 1px;
}
.req {
  background: var(--danger-soft);
  color: var(--danger);
}
.opt {
  background: var(--surface-2);
  color: var(--text-faint);
}

.input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.input[aria-invalid='true'] {
  border-color: var(--danger);
  background: var(--danger-soft);
}
textarea.input {
  resize: vertical;
  font-size: 13px;
  line-height: 1.7;
}

select.input {
  cursor: pointer;
}

.choices {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  flex-wrap: wrap;
}
.choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  background: var(--surface);
  font-size: 14px;
  white-space: nowrap;
}
.choice:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.choice input {
  accent-color: var(--accent);
}
.choices .grow {
  flex: 1;
  min-width: 190px;
  width: auto;
}

/* ---------- 批量粘贴 ---------- */

.paste {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  margin-bottom: 14px;
}
.paste > summary {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  user-select: none;
}
.paste[open] > summary {
  border-bottom: 1px solid var(--border);
}
.paste-body {
  padding: 12px 14px;
}
.paste .hint {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}
.paste .hint b {
  color: var(--text);
}
.paste-actions {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  margin-top: 10px;
}
.paste-errors {
  margin: 10px 0 0;
  padding-left: 20px;
  font-size: 13px;
  color: var(--danger);
}
.paste-errors:empty {
  display: none;
}

/* ---------- 粘贴回显（确认后才填入） ---------- */

.paste-preview {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.pp-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--gap-sm);
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.pp-mode {
  font-size: 13px;
}
.pp-mode.ok {
  color: var(--ok);
}
.pp-mode.warn {
  color: var(--warn);
}

/* 哪一列对到哪个字段 —— 错位就是在这里一眼看出来的 */
.pp-map {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 16px;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  line-height: 1.9;
  margin-bottom: 10px;
}
.pp-map:empty {
  display: none;
}
.pp-pair {
  display: inline-flex;
  gap: 4px;
}
.pp-k {
  color: var(--text-muted);
}
.pp-pair.missing .pp-v {
  color: var(--danger);
  font-weight: 600;
}

.pp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.pp-table th,
.pp-table td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pp-table th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
}
.pp-table td:first-child {
  width: 34px;
  color: var(--text-faint);
}
.pp-table td:nth-child(6) {
  text-align: right;
}
/* 超出上限、这次不会填入的行 */
.pp-table tr.over {
  opacity: 0.45;
}

.pp-notes {
  margin: 10px 0 0;
  padding-left: 20px;
  font-size: 12px;
  color: var(--text-muted);
}
.pp-notes:empty {
  display: none;
}
.pp-notes .over {
  color: var(--warn);
}

.pp-fill {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.pp-fill .faint {
  font-size: 12px;
}

/* ---------- 明细表 ---------- */

.items {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}
.items th,
.items td {
  padding: 0 4px 6px 0;
  text-align: left;
  vertical-align: top;
}
.items th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding-bottom: 6px;
  white-space: nowrap;
}
.items tbody tr td {
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.items th:last-child,
.items td:last-child {
  padding-right: 0;
}
.items .col-seq {
  width: 34px;
}
.items .col-part {
  width: 130px;
}
.items .col-unit {
  width: 90px;
}
.items .col-qty {
  width: 84px;
}
.items .col-del {
  width: 36px;
}
.items td.col-seq {
  padding-top: 15px;
  color: var(--text-faint);
  font-size: 12px;
}
.items input[type='number'] {
  text-align: right;
}

.btn-icon {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.btn-icon:hover:not(:disabled) {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger-soft);
}
.btn-icon:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.empty-items {
  margin: 14px 0 0;
  padding: 22px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.items-actions {
  display: flex;
  align-items: center;
  gap: var(--gap);
  margin-top: 14px;
}
.items-actions .faint {
  font-size: 12px;
}

/* ---------- 授权声明 ---------- */

.statement {
  margin: 0 0 12px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-muted);
}

.ack {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
}
.ack:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.ack input {
  margin-top: 3px;
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex: none;
}

/* ---------- 按钮 ---------- */

.btn {
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.btn:hover:not(:disabled) {
  background: var(--surface-2);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  padding: 10px 34px;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn-ghost {
  background: transparent;
}

.row-actions {
  display: flex;
  gap: var(--gap-sm);
  justify-content: center;
  margin-top: 18px;
}

/* ---------- 吸底提交条 ---------- */

.form-msg {
  max-width: 1120px;
  margin: 0 auto 10px;
  padding: 0 20px;
  color: var(--danger);
  font-size: 14px;
  min-height: 20px;
}
.form-msg:empty {
  min-height: 0;
}

.submit-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--gap);
  padding: 12px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgb(16 24 40 / 6%);
}

/* ---------- 结果页 / 进度 ---------- */

.tick {
  width: 52px;
  height: 52px;
  line-height: 52px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 26px;
  font-weight: 700;
}
.order-no {
  font-size: 20px;
  font-weight: 700;
  margin: 4px 0 10px;
  letter-spacing: 0.5px;
}

.field-row {
  display: flex;
  gap: var(--gap-sm);
  margin-bottom: 10px;
}

.timeline {
  margin: 16px 0 0;
  padding-left: 20px;
}
.timeline li {
  margin-bottom: 10px;
}
.timeline .at {
  display: block;
  font-size: 12px;
  color: var(--text-faint);
}
.timeline .note {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
}
