/* 收货管理专属样式 */
.receiving-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 12px;
}

.receiving-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.receiving-view-switch {
  flex: 0 0 auto;
  height: 39px;
  box-sizing: border-box;
}

.receiving-view-btn {
  height: 33px;
}

.receiving-date-nav {
  height: 39px;
  box-sizing: border-box;
  padding: 2px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow-xs);
}

.receiving-date-step {
  width: 33px;
  height: 33px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}

.receiving-date-step:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.receiving-date-step:disabled {
  color: var(--weak);
  cursor: not-allowed;
  opacity: .45;
  background: transparent;
}

.receiving-date-step svg,
.receiving-date-field svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.receiving-date-field {
  width: 120px;
  min-width: 120px;
  height: 33px;
}

.receiving-date-field input {
  width: 100%;
  height: 33px;
  padding: 0 28px 0 8px !important;
  border-radius: 7px !important;
  font-size: 12.5px;
  font-weight: 600;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.receiving-date-field input:focus,
.receiving-date-field input:hover {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.receiving-date-field .datetime-icon {
  right: 7px;
  color: var(--primary, #2563eb);
}

.receiving-today-btn {
  height: 33px;
  padding: 0 8px;
  font-size: 12.5px;
}

.receiving-date-nav .btn:disabled {
  cursor: not-allowed;
  opacity: .48;
  box-shadow: none;
}

.receiving-date-description {
  min-height: 20px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 20px;
}

/* 统计卡片网格 - 5列 */
.receiving-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.receiving-summary-card {
  min-width: 0;
  min-height: 104px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}

.receiving-summary-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.receiving-summary-val {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.receiving-summary-sub {
  font-size: 11.5px;
  color: var(--weak);
  margin-top: 4px;
}

.receiving-summary-unit {
  color: var(--weak);
  font-size: 12px;
  font-weight: 500;
}

.receiving-summary-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.receiving-summary-icon svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.receiving-summary-icon.blue { background: #edf4ff; color: #2563eb; }
.receiving-summary-icon.green { background: #eafbf5; color: #10a66a; }
.receiving-summary-icon.orange { background: #fff5e6; color: #de8600; }
.receiving-summary-icon.purple { background: #f2edff; color: #7658dd; }
.receiving-summary-icon.cyan { background: #e6f7ff; color: #08979c; }

/* 快速收货双栏布局 */
.receiving-quick-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: 16px;
  margin-bottom: 16px;
}

.receiving-panel {
  display: flex;
  flex-direction: column;
}

.receiving-panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.receiving-panel-title {
  font-size: 15px;
  font-weight: 750;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.receiving-panel-title svg {
  color: var(--text-2);
  flex: 0 0 auto;
}

.receiving-panel-body {
  padding: 16px 18px 18px;
}

/* 快速录入表单网格 */
.receiving-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 14px;
}

.receiving-form-grid .span-full {
  grid-column: 1 / -1;
}

.receiving-form-grid .span-2 {
  grid-column: span 2;
}

.receiving-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.receiving-field-label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
}

.receiving-field-label .required {
  color: #ef4444;
  margin-left: 2px;
}

.receiving-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.receiving-input-group input,
.receiving-input-group select {
  width: 100%;
}

.receiving-unit-addon {
  position: absolute;
  right: 12px;
  font-size: 12px;
  color: #94a3b8;
  pointer-events: none;
}

.receiving-net-badge {
  background: var(--green-soft);
  color: var(--green);
  font-weight: 750;
  font-size: 17px;
  padding: 0 14px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
}

.calc-switch-btn {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text-2);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.receiving-calc-switch-cell {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.calc-switch-btn:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.receiving-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: none;
}

.receiving-form-actions .btn {
  min-width: 96px;
}

/* 纸种汇总微型表格 */
.receiving-summary-table-wrap {
  overflow-x: auto;
  max-height: 380px;
  overflow-y: auto;
  padding-top: 0;
}

.receiving-summary-table {
  width: 100%;
  min-width: 440px;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}

/* 列宽分配：纸种20% 收货量18% 平均单价22% 总金额24% 车次16% */
.receiving-summary-table col.col-paper  { width: 20%; }
.receiving-summary-table col.col-net    { width: 18%; }
.receiving-summary-table col.col-price  { width: 22%; }
.receiving-summary-table col.col-amount { width: 24%; }
.receiving-summary-table col.col-count  { width: 16%; }

.receiving-summary-table th,
.receiving-summary-table td {
  padding: 9px 8px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.receiving-summary-table th {
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

.receiving-summary-table td.num,
.receiving-summary-table th.num {
  text-align: right;
}

.receiving-summary-table tfoot td {
  font-weight: 650;
  background: transparent;
  border-top: 1px solid var(--line);
  border-bottom: none;
}

.receiving-empty-row {
  padding: 28px 16px !important;
  text-align: center !important;
  color: var(--weak) !important;
}

/* 自动完成/记忆下拉列表 */
.receiving-datalist-pop {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  z-index: 50;
  max-height: 180px;
  overflow-y: auto;
  margin-top: 3px;
}

.receiving-datalist-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s;
}

.receiving-datalist-item:hover,
.receiving-datalist-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

/* 响应式适配 */
@media (max-width: 1280px) {
  .receiving-summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .receiving-quick-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 930px) {
  .receiving-head {
    display: block;
  }

  .receiving-head-actions {
    justify-content: flex-start;
    margin-top: 12px;
  }

  .receiving-summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .receiving-form-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .receiving-head-actions,
  .receiving-date-nav {
    width: 100%;
  }

  .receiving-date-nav,
  .receiving-view-switch {
    height: 50px;
  }

  .receiving-view-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .receiving-view-btn,
  .receiving-date-step,
  .receiving-today-btn {
    min-height: 44px;
  }

  .receiving-filter-label {
    display: none;
  }

  .receiving-date-field {
    height: 44px;
    min-width: 0;
    flex: 1 1 auto;
  }

  .receiving-date-field input {
    height: 44px;
    width: 100%;
    font-size: 16px;
  }

  .receiving-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .receiving-summary-card {
    min-height: 108px;
    padding: 12px;
  }

  .receiving-summary-card:last-child {
    grid-column: 1 / -1;
  }

  .receiving-summary-val {
    font-size: 18px;
  }

  .receiving-summary-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .receiving-summary-icon svg {
    width: 18px;
    height: 18px;
  }

  .receiving-form-grid {
    grid-template-columns: 1fr;
  }

  .receiving-form-grid .span-2 {
    grid-column: auto;
  }

  .receiving-calc-switch-cell {
    justify-content: flex-start;
  }

  .receiving-calc-switch-cell::before {
    content: "切换计算方向";
    margin-right: 10px;
    color: var(--muted);
    font-size: 12px;
  }

  .receiving-form-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .receiving-form-actions .btn {
    min-width: 0;
    min-height: 44px;
    padding: 0 10px;
  }

  #rcvSaveFinishBtn {
    grid-column: 1 / -1;
  }

  .rcv-attachment-cell {
    grid-column: auto !important;
    grid-row: auto !important;
  }
}

@media (max-width: 640px) {
  #page-receiving .data-table td {
    display: flex;
    position: static !important;
    left: auto !important;
    right: auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  #page-receiving .data-table td::before {
    content: attr(data-label);
  }

  #page-receiving .data-table td[data-label="操作"] {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-end;
    gap: 10px;
    border-bottom: 0 !important;
  }

  #page-receiving .data-table td[data-label="操作"]::before,
  #page-receiving .data-table td[colspan]::before {
    display: none;
    content: none;
  }

  #page-receiving .data-table td[colspan] {
    grid-column: 1 / -1;
    display: block;
    text-align: center;
  }
}

/* 暗色主题适配 */
html.dark-theme .receiving-view-switch {
  background: #0f172a;
}

html.dark-theme .receiving-view-btn.active {
  background: var(--panel);
  color: var(--primary);
}

html.dark-theme .receiving-date-field input {
  color-scheme: dark;
}

html.dark-theme .receiving-field-label,
html.dark-theme .receiving-unit-addon {
  color: var(--text-2);
}

html.dark-theme .receiving-net-badge {
  background: rgba(16, 166, 106, .14);
  color: #6ee7b7;
}

html.dark-theme .receiving-panel-title svg {
  color: var(--text-2);
}

html.dark-theme .receiving-summary-icon.blue,
html.dark-theme .receiving-summary-icon.cyan {
  background: rgba(59, 130, 246, .15);
  color: #93c5fd;
}

html.dark-theme .receiving-summary-icon.green {
  background: rgba(16, 166, 106, .15);
  color: #6ee7b7;
}

html.dark-theme .receiving-summary-icon.orange {
  background: rgba(239, 148, 0, .15);
  color: #fbbf24;
}

html.dark-theme .receiving-summary-icon.purple {
  background: rgba(121, 91, 220, .18);
  color: #c4b5fd;
}

/* 收货快速录入附件上传单元格 */
.rcv-attachment-cell {
  grid-column: 3;
  grid-row: 3 / 5;
  display: flex;
  flex-direction: column;
}

.rcv-attachment-dropzone {
  flex: 1;
  min-height: 84px;
  border: 0;
  border-radius: 12px;
  background: var(--surface, #f8fafc);
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  transition: all 0.2s ease;
  cursor: pointer;
}

.rcv-attachment-dropzone:hover,
.rcv-attachment-dropzone.dragover {
  background: var(--primary-soft, #eff6ff);
}

.rcv-attachment-empty-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 2px;
  padding: 4px;
}

.rcv-empty-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-soft, #edf4ff);
  color: var(--primary, #2563eb);
  display: grid;
  place-items: center;
  margin-bottom: 2px;
  transition: all 0.2s ease;
}

.rcv-attachment-dropzone:hover .rcv-empty-icon {
  transform: translateY(-2px);
  background: rgba(37, 99, 235, 0.15);
}

.rcv-empty-icon svg {
  width: 15px;
  height: 15px;
}

.rcv-empty-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2, #475569);
}

.rcv-empty-hint {
  font-size: 10px;
  color: var(--weak, #94a3b8);
}

.rcv-attachment-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
  width: 100%;
  max-height: 152px;
  overflow-y: auto;
}

.rcv-attachment-item {
  position: relative;
  min-width: 0;
  padding: 4px;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 8px;
  background: #ffffff;
  font-size: 10px;
  color: var(--text, #1e293b);
  overflow: hidden;
}

.rcv-attachment-thumb {
  height: 58px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: var(--surface, #f8fafc);
}

.rcv-attachment-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.rcv-pdf-thumb {
  display: grid;
  place-items: center;
  width: 34px;
  height: 40px;
  border-radius: 5px;
  background: #fee2e2;
  color: #dc2626;
  font-size: 10px;
  font-weight: 750;
}

.rcv-attachment-item .name {
  display: block;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rcv-attachment-item .remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(15, 23, 42, .68);
  color: #ffffff;
  cursor: pointer;
  padding: 0;
  font-size: 15px;
  font-weight: bold;
  line-height: 1;
}

.rcv-attachment-item .remove-btn:hover {
  background: #dc2626;
  color: #ffffff;
}

html.dark-theme .rcv-attachment-dropzone {
  background: rgba(15, 23, 42, 0.4);
}

html.dark-theme .rcv-attachment-item {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}

html.dark-theme .receiving-date-nav {
  background: #1e293b;
  border-color: #334155;
}

html.dark-theme .receiving-date-field input {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #e2e8f0;
}

html.dark-theme .receiving-date-field input:focus,
html.dark-theme .receiving-date-field input:hover {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

html.dark-theme .receiving-summary-table th {
  background: rgba(15, 23, 42, 0.35);
  color: var(--text-2, #a8b3c3);
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}
html.dark-theme .receiving-summary-table tfoot td {
  color: #cbd5e1;
  border-top-color: rgba(148, 163, 184, 0.15);
}

html.dark-theme .receiving-summary-table td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}

@media (min-width: 641px) {
  html.dark-theme #page-receiving .data-table th:last-child {
    background: #243042 !important;
  }

  html.dark-theme #page-receiving .data-table td:last-child {
    background: #1e293b !important;
  }
}

.icon-btn.attachment-btn {
  position: relative;
  color: var(--primary, #2563eb);
  background: var(--primary-soft, rgba(37, 99, 235, 0.1));
  margin-right: 4px;
}

.icon-btn.attachment-btn:hover {
  background: var(--primary);
  color: #ffffff;
}

.attachment-badge-num {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 9px;
  font-weight: 750;
  line-height: 14px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

html.dark-theme .receiving-datalist-item:hover {
  background: #334155;
  color: #60a5fa;
}

#receivingOverlay .receiving-readonly-input {
  background: var(--surface, #f8fafc);
  font-weight: 700;
}
