:root {
  --green: #0f7d61;
  --green-dark: #09694f;
  --green-soft: #e8f4ef;
  --line: #d7e3de;
  --text: #10231d;
  --muted: #6d7a76;
  --bg: #f2f6f4;
  --white: #fff;
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  width: 100%;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  overscroll-behavior-x: none;
  touch-action: pan-y manipulation;
  -webkit-text-size-adjust: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 7px;
  background: var(--green);
  color: var(--white);
  font-weight: 800;
}

input,
select,
textarea {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
  color: var(--text);
  text-align: center;
  font-weight: 800;
}

@media (max-width: 720px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-view {
  display: grid;
  min-height: 100dvh;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  place-items: center;
}

.login-panel {
  width: min(100%, 360px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.login-panel h1 {
  margin: 0 0 16px;
  font-size: 26px;
  text-align: center;
}

.login-panel label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 700;
}

.login-panel input {
  height: 46px;
  padding: 0 10px;
  text-align: left;
}

.login-panel button {
  width: 100%;
  height: 46px;
  margin-top: 2px;
}

.form-error {
  min-height: 20px;
  margin: 10px 0 0;
  color: #b42318;
  text-align: center;
  font-weight: 700;
}

.login-hint {
  margin: 8px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.app-shell {
  display: flex;
  width: 100%;
  max-width: 640px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 7px max(8px, env(safe-area-inset-bottom));
  flex-direction: column;
  gap: 7px;
}

.top-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px;
  align-items: center;
  padding: 5px;
  border-radius: 7px;
  background: var(--green);
  color: var(--white);
}

.top-card > div:first-child {
  min-width: 72px;
}

.top-card strong {
  display: block;
  overflow: hidden;
  font-size: 18px;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-card span {
  display: none;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.92;
}

.top-actions {
  display: flex;
  min-width: 0;
  gap: 3px;
  align-items: center;
  justify-content: flex-end;
}

.top-actions button,
.tab,
.pager button,
.export-row button {
  height: 38px;
}

.top-actions button {
  height: 34px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

.top-actions .ghost-btn {
  width: 48px;
}

.top-actions .light-btn {
  width: 40px;
}

.top-actions .all-print-btn {
  width: 38px;
}

.top-actions .sync-pill {
  display: inline-flex;
  width: 72px;
  min-width: 72px;
  height: 30px;
  padding: 0 7px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: #6b7280;
  color: var(--white);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 2px 8px rgba(16, 35, 29, 0.18);
}

.sync-pill[data-status="synced"] {
  background: #12a46f;
}

.sync-pill[data-status="offline"] {
  background: #6b7280;
}

.sync-pill[data-status="pending"] {
  background: #dc2626;
}

.sync-pill[data-status="stale"] {
  background: #991b1b;
}

.sync-pill[data-status="saving"] {
  background: #2563eb;
}

.sync-pill[data-status="saved"] {
  background: #15803d;
}

.sync-pill[data-status="error"] {
  background: #b91c1c;
}

.mobile-more-btn {
  display: none;
  width: 48px;
  min-width: 48px;
  align-items: center;
  justify-content: center;
  border: 0;
  background: var(--white);
  color: var(--green);
  font-weight: 900;
}

.mobile-action-sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  align-items: end;
}

.mobile-action-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(15, 35, 29, 0.28);
}

.mobile-action-panel {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(430px, calc(100vw - 16px));
  margin: 0 auto max(8px, env(safe-area-inset-bottom));
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 18px 42px rgba(15, 35, 29, 0.22);
}

.mobile-action-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-action-panel header strong {
  color: var(--text);
  font-size: 17px;
}

.mobile-action-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.mobile-action-grid button {
  min-height: 42px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--green);
  color: var(--white);
  font-size: 14px;
  font-weight: 900;
}

.mobile-action-grid .logout-action {
  background: #dc3545;
  grid-column: span 2;
}

@media (min-width: 641px) {
  .mobile-action-sheet {
    display: none !important;
  }
}

.ghost-btn {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.12);
}

.light-btn {
  background: var(--white);
  color: var(--green);
}

.tab-bar {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--green-soft);
  overflow-x: auto;
}

.tab {
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
  background: var(--white);
  color: var(--green);
}

.tab.active {
  background: var(--green);
  color: var(--white);
}

.desktop-manage-tab {
  flex: 0 0 auto;
  padding: 0 12px;
}

.date-capsule {
  display: grid;
  width: 156px;
  min-width: 148px;
  height: 36px;
  grid-template-columns: 1.1fr 0.78fr 1fr;
  overflow: hidden;
  border: 1px solid var(--green);
  border-radius: 999px;
  background: var(--green);
}

.date-capsule.off-today {
  border-color: #8f1d1d;
  background: #8f1d1d;
}

.date-capsule .date-segment select,
.date-capsule.off-today .date-segment select {
  color: var(--white);
}

.date-segment {
  display: block;
  min-width: 0;
  margin: 0;
}

.date-segment + .date-segment {
  border-left: 1px solid rgba(255, 255, 255, 0.35);
}

.date-segment select {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  appearance: none;
  background: transparent;
  color: var(--white);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  text-align-last: center;
}

.date-segment select:focus {
  outline: 0;
  background: rgba(255, 255, 255, 0.14);
}

.date-segment option {
  color: var(--text);
  background: var(--white);
}

@media (max-width: 640px) {
  #main-export-btn,
  #print-page-btn,
  #print-all-btn {
    display: none !important;
  }

  .desktop-manage-tab {
    display: none !important;
  }

  .view-panel > .export-row,
  .export-menu-wrap {
    display: none !important;
  }

  .top-card {
    grid-template-columns: minmax(76px, 96px) minmax(0, 1fr);
  }

  .top-actions .sync-pill {
    width: 60px;
    min-width: 60px;
    padding: 0 5px;
    margin-left: auto;
  }

  .top-actions {
    gap: 5px;
  }

  .mobile-more-btn {
    display: inline-flex;
  }

  .date-capsule {
    width: clamp(146px, calc(100vw - 210px), 190px);
    min-width: 146px;
  }

  .tab-bar {
    gap: 6px;
  }

  .packing-table .table-row {
    padding-right: 42px;
  }

  .packing-table .table-row .swipe-delete-btn {
    top: 50%;
    right: 4px;
    width: 36px;
    height: 28px;
    border-radius: 6px;
    font-size: 11px;
    opacity: 0.92;
    pointer-events: auto;
    transform: translateY(-50%);
  }

  .packing-table .table-row.swipe-delete-open > input,
  .packing-table .table-row.swipe-delete-open > span {
    transform: none;
  }
}

@media (hover: none) and (pointer: coarse) {
  #main-export-btn,
  #print-page-btn,
  #print-all-btn {
    display: none !important;
  }

  .view-panel > .export-row,
  .export-menu-wrap {
    display: none !important;
  }

  .mobile-more-btn {
    display: inline-flex;
  }
}

.pager {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) 82px;
  gap: 8px;
  align-items: center;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--green-soft);
  text-align: center;
}

.pager button {
  background: var(--white);
  color: var(--green);
}

.pager button:last-child {
  background: var(--green);
  color: var(--white);
}

.pager strong {
  display: block;
  overflow: hidden;
  font-size: 18px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pager-title-btn {
  cursor: pointer;
}

.pager-title-btn:focus {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.pager-center {
  min-width: 0;
}

.group-pager-customer {
  display: grid;
  min-width: 0;
  min-height: 64px;
  align-content: center;
  gap: 2px;
  padding: 4px 8px;
  cursor: pointer;
}

.group-pager-customer #group-pager-title {
  color: var(--text);
  font-size: 18px;
}

.group-pager-customer #group-pager-subtitle {
  margin-top: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.pager span {
  display: block;
  overflow: hidden;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-panel {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#app-shell {
  height: 100dvh;
  overflow: hidden;
}

.batch-grid {
  display: grid;
  grid-template-columns: 36px minmax(58px, 0.85fr) 54px 68px minmax(92px, 1.15fr);
  gap: 5px;
  align-items: stretch;
}

.sequence-rail {
  position: relative;
}

.sequence-pill {
  display: grid;
  width: 100%;
  min-height: 44px;
  border-radius: 7px;
  background: var(--green);
  color: var(--white);
  font-size: 25px;
  font-weight: 900;
  place-items: center;
  transition: background 0.15s ease;
}

.sequence-pill.sell-stock-active {
  background: #8e2a1f;
}

.batch-jump-panel {
  position: absolute;
  left: 0;
  top: calc(100% + 5px);
  z-index: 7;
  display: grid;
  width: min(168px, calc(100vw - 22px));
  max-height: 310px;
  gap: 5px;
  padding: 7px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 12px 26px rgba(16, 35, 29, 0.18);
}

.batch-jump-panel button {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  min-height: 36px;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--green);
  text-align: left;
}

.batch-jump-panel button.active {
  background: var(--green);
  color: var(--white);
}

.batch-jump-panel span {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-field,
.batch-field,
.autocomplete-field {
  position: relative;
  display: block;
}

.product-field input,
.batch-field input {
  width: 100%;
  height: 44px;
  padding: 0 8px;
  font-size: 20px;
}

.product-field input {
  padding-left: 8px;
  text-align: left;
}

.batch-quantity-field input {
  padding-left: 8px;
  padding-right: 8px;
  font-size: 16px;
  text-align: left;
}

.batch-code-wrap {
  display: block;
}

.batch-field input {
  font-size: 16px;
  letter-spacing: 0;
  padding-left: 4px;
  padding-right: 4px;
  text-transform: uppercase;
}

.batch-code-lock.locked input {
  border-color: var(--green);
  border-radius: 999px;
  background: var(--green);
  color: var(--white);
}

.unit-price-field {
  display: flex;
  min-width: 0;
  height: 44px;
  align-items: center;
  gap: 3px;
  padding: 0 6px;
  border: 1px solid var(--green);
  border-radius: 7px;
  background: var(--green);
}

.unit-price-field input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--white);
  font-size: 17px;
  font-weight: 800;
  text-align: left;
}

.unit-price-field input::placeholder {
  color: rgba(255,255,255,0.64);
}

.unit-price-field input:-webkit-autofill,
.unit-price-field input:-webkit-autofill:hover,
.unit-price-field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--green) inset;
  -webkit-text-fill-color: var(--white);
  caret-color: var(--white);
}

.batch-quantity-field input:-webkit-autofill,
.batch-quantity-field input:-webkit-autofill:hover,
.batch-quantity-field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--white) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
}

.batch-summary-row {
  display: grid;
  grid-template-columns: minmax(74px, 1.2fr) minmax(58px, 0.9fr) minmax(58px, 0.9fr) 48px 48px;
  gap: 6px;
}

.batch-summary-row > * {
  box-sizing: border-box;
  height: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
}

.batch-summary-input,
.batch-summary-stat {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 3px;
  padding: 0 6px;
}

.batch-summary-input span,
.batch-summary-stat span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.batch-summary-input input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  font-weight: 800;
  text-align: right;
}

.batch-summary-stat strong {
  min-width: 0;
  color: var(--green);
  font-size: 16px;
  text-align: right;
  white-space: nowrap;
}

.price-lock.locked {
  border-color: var(--green);
  background: var(--green);
}

.price-lock.locked span {
  color: rgba(255,255,255,0.8);
}

.price-lock.locked input {
  color: var(--white);
  text-align: center;
}

.price-lock.locked input::placeholder {
  color: rgba(255,255,255,0.6);
}

.add-line-form {
  display: grid;
  grid-template-columns: minmax(84px, 1fr) 54px 66px minmax(64px, 0.72fr);
  gap: 6px;
}

.add-line-form input {
  width: 100%;
  height: 44px;
}

.add-line-form button {
  width: 100%;
  height: 44px;
  font-weight: 900;
}

.sort-lines-btn {
  border: 1px solid var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.batch-summary-row > .sort-lines-btn {
  padding: 0;
  border-radius: 7px;
  font-weight: 900;
}

.clear-current-batch-btn {
  border: 1px solid #d75c56;
  background: #fff4f2;
  color: #b93a34;
}

.batch-summary-row > .clear-current-batch-btn {
  padding: 0;
  border-radius: 7px;
  font-weight: 900;
}

.suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 8;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
  box-shadow: 0 10px 22px rgba(16, 35, 29, 0.12);
}

.suggestions button {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 34px;
  padding: 0 8px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--white);
  color: var(--text);
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestions button:last-child {
  border-bottom: 0;
}

.readonly input,
.readonly button,
.readonly select,
.readonly textarea,
input:disabled,
button:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.58;
}

.data-table {
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.packing-table {
  flex: 1;
  min-height: 220px;
  overflow-y: auto;
}

.table-row {
  display: grid;
  min-height: 40px;
  border-bottom: 1px solid var(--line);
}

.packing-table .table-row {
  position: relative;
  overflow: hidden;
  grid-template-columns: minmax(68px, 1fr) 46px 50px 38px 98px;
}

.packing-table .packing-delete-head {
  display: none;
}

.customer-table .table-row {
  grid-template-columns: 28px minmax(44px, 0.68fr) 40px 40px 46px 38px minmax(76px, 1fr) 48px 48px 34px;
}

.table-row:last-child {
  border-bottom: 0;
}

.table-row > span,
.table-row > input {
  display: grid;
  min-width: 0;
  padding: 0 3px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  align-items: center;
  justify-items: center;
  text-align: center;
  font-size: 14px;
  font-weight: 850;
}

.table-row > span:last-child,
.table-row > input:last-child {
  border-right: 0;
}

.packing-table input {
  display: block;
  width: 100%;
  height: 39px;
  padding: 0 3px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-size: 14px;
  line-height: 39px;
}

.customer-table input {
  width: 100%;
  height: 39px;
  padding: 0 3px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-size: 14px;
  font-weight: 850;
  text-align: center;
}

.customer-fill-cell {
  position: relative;
  min-width: 0;
  border-right: 1px solid var(--line);
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.customer-fill-cell > input {
  border-right: 0;
  width: 100%;
  height: auto;
  min-height: 39px;
}

/* 备注输入格预留右侧空间（首行右下角有填充圆圈），保证整列备注文本对齐；
   货位号格无填充按钮，无需预留，文本水平居中。 */
.customer-fill-cell-remark > input {
  padding-right: 18px;
}

.customer-bulk-fill-btn {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1.5px solid #8dbdaf;
  border-radius: 50%;
  background: #edf7f3;
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.customer-bulk-fill-btn:hover,
.customer-bulk-fill-btn:focus-visible {
  background: #dcefe8;
}

/* 批次号单元格：已分配多个批次时每个批次一行（两批两行、三批三行），高度由行数决定 */
.customer-table textarea[data-customer-edit="batchCode"] {
  width: 100%;
  min-height: 39px;
  padding: 9px 3px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-size: 14px;
  font-weight: 850;
  line-height: 20px;
  text-align: center;
  font-family: inherit;
  resize: none;
  overflow: hidden;
}

.customer-table textarea[data-customer-edit="batchCode"]:last-child {
  border-right: 0;
}

/* 多批次行（批次号单元格多行变高）时，普通输入格也拉伸到整行高度，
   内部竖线画满整行、不与底部边框截断；序号单元格保持整行垂直居中。 */
.customer-table .table-row > input {
  height: auto;
  min-height: 39px;
  align-self: stretch;
}

.customer-table .table-row > span,
.customer-table .table-row > .customer-fill-cell {
  align-self: stretch;
}

.customer-row-actions {
  padding: 0 !important;
  display: flex !important;
  flex-direction: column;
  align-items: stretch !important;
  justify-content: center !important;
}

.service-fee-row {
  background: #f8fbf9;
}

.logistics-row {
  background: #f7fafc;
  grid-template-columns: 1fr !important;
  padding: 0;
}

.logistics-compact-grid {
  display: grid;
  grid-template-columns: 42px 1fr minmax(56px, 72px);
  width: 100%;
  min-height: 40px;
}

.logistics-info-fields {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(96px, 1.15fr);
  align-items: center;
  min-width: 0;
}

.logistics-info-fields .logistics-name-cell {
  width: 100%;
  min-width: 0;
  text-align: left;
  padding-left: 4px;
  border-right: 0;
}

.logistics-info-fields .logistics-phone-cell {
  width: 100%;
  min-width: 0;
  text-align: left;
  border-right: 0;
  padding-left: 0;
}

.logistics-compact-label,
.logistics-compact-field {
  display: grid;
  min-width: 0;
  height: 40px;
  padding: 0 6px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  align-items: center;
  justify-items: center;
  text-align: center;
  font-size: 14px;
  font-weight: 850;
}

.logistics-compact-label {
  white-space: nowrap;
  font-size: 13px;
  color: #2f5d7c;
  background: #edf5f8;
}

.logistics-info-fields .logistics-compact-field {
  display: block;
  height: auto;
  padding: 8px 2px;
  font-size: 14px;
  font-weight: 850;
  background: transparent;
  border: 0;
}

.logistics-row input[data-logistics-picker],
.logistics-row .logistics-compact-field[data-logistics-picker] {
  color: #245b7a;
  cursor: pointer;
  font-weight: 800;
}

.service-fee-row input[readonly] {
  color: #314a43;
}

.auto-fee-badge {
  display: inline-grid;
  min-width: 28px;
  min-height: 20px;
  padding: 0 5px;
  border: 1px solid #b9d9ce;
  border-radius: 999px;
  align-items: center;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  margin: auto;
}

.logistics-badge {
  border-color: #c6d4e3;
  color: #2f5d7c;
}

.delete-line-btn {
  width: 100%;
  height: 100%;
  min-height: 39px;
  border-radius: 0;
  background: #b42318;
  color: var(--white);
  font-size: 12px;
}

.customer-row-actions .delete-line-btn,
.customer-row-actions .ack-duplicate-btn {
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  border-radius: 0;
  font-size: 11px;
}

.ack-duplicate-btn {
  background: var(--green);
  color: var(--white);
}

.swipe-delete-btn {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  width: 54px;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  transform: translateX(100%);
  transition: transform 0.16s ease, opacity 0.16s ease;
}

.packing-table .table-row > input,
.packing-table .table-row > span {
  transition: transform 0.16s ease;
}

.packing-table .table-row.swipe-delete-open > input,
.packing-table .table-row.swipe-delete-open > span {
  transform: translateX(-54px);
}

.packing-table .table-row.swipe-delete-open .swipe-delete-btn {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.customer-table .table-row.duplicate-warning {
  position: relative;
  background: #fff4e6;
  box-shadow: inset 3px 0 0 #d92d20;
}

.customer-table .table-row.duplicate-warning::after {
  content: "疑似重复";
  position: absolute;
  right: 34px;
  top: 2px;
  padding: 1px 4px;
  border-radius: 999px;
  background: #fee4e2;
  color: #b42318;
  font-size: 10px;
  font-weight: 900;
}

.customer-total-row {
  background: #fff5f5;
  border-top: 2px solid #dc3545;
  font-weight: bold;
}

.total-amount {
  color: #dc3545;
}

.table-head {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 36px;
  background: #edf5f2;
}

.table-head span {
  color: #314a43;
  font-size: 13px;
}

/* 采购表头单元格自带浅绿背景：个别浏览器里 sticky 表头背景绘制不完整，
   会露出白色底（备注/时间列），这里给每个单元格单独上色保证一致 */
.pending-table .table-head > span,
.purchased-table .table-head > span,
#procurement-inventory-panel .table-head > span {
  background: #edf5f2;
}

.name-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qty-cell {
  height: 39px;
  font-size: 15px !important;
}

.slot-cell {
  color: var(--green);
}

.empty-state {
  display: grid;
  min-height: 110px;
  color: var(--muted);
  font-weight: 850;
  place-items: center;
  text-align: center;
}

.export-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.export-row button {
  font-size: 14px;
}

.export-menu-wrap {
  display: grid;
  gap: 5px;
}

.export-menu-toggle {
  min-height: 34px;
  border-radius: 7px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

/* 电脑端菜单栏默认折叠：只显示第一行按钮，点击"展开菜单"显示全部 */
.export-row-collapsible.collapsed {
  max-height: 40px;
  overflow: hidden;
}

.customer-card {
  flex: 1 0 auto;
  min-height: 220px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.customer-add-panel,
.group-order-panel {
  display: grid;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--green-soft);
}

.inventory-panel,
.pending-panel,
.procurement-tabs {
  display: grid;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--green-soft);
}

.procurement-tabs {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 6px;
}

#procurement-pending-panel {
  display: flex;
  min-height: 0;
  flex: 1 0 auto;
  flex-direction: column;
  gap: 7px;
}

.pending-table {
  flex: 1 0 auto;
  min-height: 220px;
}

#procurement-purchased-panel,
#procurement-inbound-panel,
#procurement-inventory-panel,
#procurement-loss-panel {
  display: flex;
  min-height: 0;
  flex: 1 0 auto;
  flex-direction: column;
  gap: 7px;
}

#procurement-inbound-panel > .inventory-panel {
  display: flex;
  min-height: 0;
  flex: 1 0 auto;
  flex-direction: column;
  gap: 7px;
}

.purchased-table,
.inventory-table,
.loss-table,
.inventory-import-preview {
  flex: 1 0 auto;
  min-height: 220px;
}

.procurement-tabs button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--green);
}

.procurement-tabs button.active {
  background: var(--green);
  color: var(--white);
}

.inventory-category-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.inbound-mode-tabs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.purchase-category-tabs {
  margin-bottom: 6px;
}

.inventory-category-tabs button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--green);
  font-weight: 800;
}

.inventory-category-tabs button.active {
  background: var(--green);
  color: var(--white);
}

.inventory-bulk-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-top: 6px;
}

.inventory-bulk-actions button {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--green);
  color: var(--white);
  font-weight: 900;
}

.inventory-bulk-actions .danger-outline {
  border-color: #fecaca;
  background: #fff5f5;
  color: #b42318;
}

.inventory-add-grid {
  display: grid;
  grid-template-columns: minmax(58px, 1fr) minmax(82px, 1.08fr) 42px 50px 50px 50px 62px;
  gap: 5px;
}

.inventory-add-grid-two-row {
  grid-template-columns: minmax(0, 1.35fr) minmax(58px, 0.7fr) minmax(58px, 0.7fr) minmax(58px, 0.7fr) minmax(58px, 0.7fr);
  grid-template-areas:
    "product quantity cost sale member"
    "remark batch batch submit submit";
}

.inventory-add-grid-two-row .inventory-product-field { grid-area: product; }
.inventory-add-grid-two-row #inventory-batch { grid-area: batch; }
.inventory-add-grid-two-row #inventory-qty { grid-area: quantity; }
.inventory-add-grid-two-row #inventory-cost-price { grid-area: cost; }
.inventory-add-grid-two-row #inventory-sale-price { grid-area: sale; }
.inventory-add-grid-two-row #inventory-member-sale-price { grid-area: member; }
.inventory-add-grid-two-row #inventory-remark { grid-area: remark; }
.inventory-add-grid-two-row .inventory-inbound-actions {
  grid-area: submit;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.inventory-add-grid input,
.inventory-add-grid button,
.inventory-ai-panel textarea,
.inventory-ai-panel button,
.inventory-panel > button,
.pending-panel button {
  width: 100%;
  min-height: 38px;
}

#inventory-batch {
  text-transform: uppercase;
}

.inventory-ai-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px 92px;
  gap: 5px;
}

.inventory-ai-panel textarea {
  min-height: 42px;
  resize: vertical;
}

.inventory-import-preview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.inventory-import-head,
.inventory-import-row {
  display: grid;
  grid-template-columns: minmax(88px, 1.2fr) 56px 62px 62px 62px minmax(60px, 0.9fr) minmax(90px, 1.1fr) 52px;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.inventory-import-head {
  background: #edf5f2;
  color: #36524a;
}

.inventory-import-category-rose .inventory-import-head {
  background: #fdeef1;
  color: #8a3a44;
}

.inventory-import-category-grass .inventory-import-head {
  background: #edf5f2;
  color: #36524a;
}

.inventory-import-row:last-child {
  border-bottom: 0;
}

.inventory-import-row .inventory-import-input {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding: 2px 6px;
  border: 1px solid #d9e2de;
  border-radius: 6px;
  background: #fff;
  color: #22332e;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.inventory-import-row .inventory-import-input-name {
  text-align: left;
}

.inventory-import-row .inventory-import-input-remark,
.inventory-import-row .inventory-import-input-batch {
  text-align: left;
}

.inventory-import-category-rose .inventory-import-input:focus {
  border-color: #d98d9b;
  box-shadow: 0 0 0 2px rgba(217, 141, 155, 0.18);
}

.inventory-import-category-grass .inventory-import-input:focus {
  border-color: #7fb3a3;
  box-shadow: 0 0 0 2px rgba(127, 179, 163, 0.18);
}

.inventory-import-row .inventory-import-input:disabled {
  background: #f4f6f5;
  color: #8a9490;
}

.inventory-import-input-batch {
  text-transform: uppercase;
}

.inventory-import-unmatched {
  padding: 8px;
  color: #b42318;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.inventory-import-preview {
  overflow-x: auto;
}

.inventory-import-remark-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-import-remove {
  min-height: 30px;
  padding: 2px 6px;
  border: 1px solid #e3cdcd;
  background: #fff;
  color: #b42318;
  font-size: 12px;
  font-weight: 800;
}

.inventory-import-category-hint {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  background: #fff8e6;
  color: #8a6d1a;
  font-size: 12px;
  font-weight: 800;
}

.inventory-import-unresolved {
  display: grid;
  gap: 7px;
  padding: 8px;
  border-top: 1px solid var(--line);
  background: #fffdf7;
}

.inventory-import-unresolved-title {
  color: #a12828;
  font-size: 12px;
  font-weight: 800;
}

.inventory-import-review-item {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid #d94b4b;
  border-left-width: 4px;
  border-radius: 6px;
  background: #fff7f7;
}

.inventory-import-original-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.inventory-import-original {
  color: #a12828;
  font-size: 13px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-import-item-remove {
  min-height: 30px;
  padding: 2px 8px;
  border: 1px solid #d9c7c7;
  background: #fff;
  color: #a12828;
  font-size: 12px;
  font-weight: 800;
}

.inventory-import-candidates {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.inventory-import-candidates button {
  min-height: 30px;
  padding: 3px 9px;
  border: 1px solid #b9d8ce;
  background: #fff;
  color: #0f745b;
  font-size: 12px;
  font-weight: 800;
}

.inventory-import-no-candidate {
  color: #7b6767;
  font-size: 12px;
}

.inventory-import-manual-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 52px 52px 52px 52px minmax(64px, 0.9fr) 54px;
  gap: 5px;
}

.inventory-import-manual-row input,
.inventory-import-manual-row button {
  min-width: 0;
  min-height: 36px;
  font-size: 13px;
}

.inventory-import-manual-add {
  display: grid;
  grid-template-columns: auto repeat(7, minmax(0, 1fr)) 54px;
  gap: 5px;
  align-items: center;
  padding: 8px;
  border-top: 1px solid var(--line);
  background: #f4faf7;
}

.inventory-import-manual-label {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.inventory-import-manual-add input,
.inventory-import-manual-add button {
  min-width: 0;
  min-height: 36px;
  font-size: 13px;
}

@media (max-width: 720px) {
  .inventory-import-manual-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .inventory-import-manual-row button {
    grid-column: span 2;
  }

  .inventory-import-manual-add {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .inventory-import-manual-label {
    grid-column: 1 / -1;
  }

  .inventory-import-manual-add button {
    grid-column: span 2;
  }

  .inventory-import-head,
  .inventory-import-row {
    grid-template-columns: minmax(76px, 1.2fr) 48px 52px 52px 52px minmax(48px, 0.9fr) minmax(76px, 1fr) 46px;
    padding: 4px;
  }

  .inventory-import-row .inventory-import-input {
    padding: 2px 4px;
    font-size: 12px;
  }
}

.pending-panel {
  grid-template-columns: minmax(0, 1fr) 104px;
  align-items: center;
}

.pending-panel strong {
  overflow: hidden;
  color: var(--green);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-table .table-row {
  min-width: 760px;
  grid-template-columns: minmax(77px, 1.012fr) 70px 40px 40px 40px 40px 40px 40px 52px 104px 58px 54px minmax(52px, 0.7fr);
}

.inventory-table .inventory-grass-row {
  min-width: 760px;
  grid-template-columns: minmax(77px, 1.012fr) 70px 40px 40px 40px 40px 40px 40px 52px 104px 58px 54px minmax(52px, 0.7fr);
}

.inventory-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* 采购库存表头悬浮锁定：页面下滚时表头固定到视口顶部（left/width/transform 由 JS 同步） */
.inventory-table .table-head.inventory-head-fixed {
  position: fixed;
  top: 0;
  z-index: 40;
  margin: 0;
  box-shadow: 0 3px 8px rgba(15, 35, 29, 0.18);
}

.sale-price-table .table-row {
  grid-template-columns: minmax(52px, 1fr) 76px 42px 46px 46px 46px;
}

.loss-table .table-row {
  grid-template-columns: minmax(58px, 1fr) 119px 38px 42px 44px 73px 151px minmax(162px, 2.4fr);
}

.loss-table .table-row > strong {
  display: grid;
  min-width: 0;
  padding: 0 3px;
  place-items: center;
  border-right: 1px solid var(--line);
  text-align: center;
}

.inventory-table .table-row > *,
.loss-table .table-row > * {
  box-sizing: border-box;
  border-right: 1px solid #b9cec6;
  border-bottom: 1px solid #b9cec6;
}

.inventory-table .table-row > *:last-child,
.loss-table .table-row > *:last-child {
  border-right: 0;
}

.inventory-table .table-row,
.loss-table .table-row {
  border-bottom: 0;
}

.loss-remark-cell {
  display: grid;
  min-width: 0;
  padding: 0 6px;
  place-items: center;
  background: transparent;
  line-height: 1.35;
  overflow-wrap: anywhere;
  text-align: center;
}

.pending-table .table-row {
  grid-template-columns: minmax(58px, 1fr) 50px 58px minmax(78px, 1.1fr) 40px 106px minmax(52px, 0.8fr);
}

.pending-remark-cell,
.purchased-remark-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-actions {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
}

.purchased-table .table-row {
  grid-template-columns: minmax(64px, 1fr) 58px minmax(58px, 0.8fr) minmax(78px, 1fr) 72px;
}

.pending-qty,
.purchased-qty {
  display: inline-grid;
  min-width: 42px;
  min-height: 30px;
  padding: 0 6px;
  place-items: center;
  border-radius: 999px;
  font-weight: 900;
}

.pending-qty {
  background: #fee4e2;
  color: #b42318;
}

.pending-stock {
  display: inline-grid;
  min-height: 30px;
  place-items: center;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.pending-stock.muted {
  color: #8a9a93;
}

.purchased-qty {
  background: #dcfae6;
  color: var(--green);
}

.done-mini,
.reopen-mini,
.stock-mini {
  min-height: 34px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 12px;
}

.done-mini {
  background: #b42318;
}

.reopen-mini {
  background: var(--green);
}

.stock-mini {
  background: #0f7d61;
}

.inventory-table input {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 800;
}

.inventory-table input[data-inventory-edit="batchCode"] {
  font-size: 11px !important;
}

.inventory-name-cell {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 4px;
  min-width: 0;
  height: 100%;
}

.inventory-select-box {
  width: 16px !important;
  min-width: 16px;
  height: 16px !important;
  margin: 0;
  accent-color: var(--green);
}

.inventory-remaining-cell {
  display: inline-grid;
  min-height: 30px;
  place-items: center;
  color: #b42318;
  font-weight: 900;
}

.inventory-loss-cell,
.loss-qty {
  display: inline-grid;
  min-height: 30px;
  place-items: center;
  color: #b42318;
  font-weight: 900;
}

.inventory-time-cell {
  display: inline-grid;
  min-height: 30px;
  place-items: center;
  color: #38544b;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
  white-space: normal;
}

.inventory-row-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
  align-items: center;
}

.inventory-table .edit-mini,
.inventory-table .merge-mini,
.inventory-table .inbound-mini,
.inventory-table .loss-mini {
  min-height: 32px;
  padding: 0 2px;
  border-radius: 6px;
  color: #fff;
  font-size: 10px;
}

.inventory-table .edit-mini {
  background: var(--green);
}

.inventory-table .merge-mini {
  background: var(--green);
}

.inventory-table .inbound-mini {
  background: #dc2626;
}

.inventory-table .inbound-mini.inbound-done {
  background: var(--green);
}

.inventory-table .loss-mini {
  background: var(--green);
}

.inventory-table .inventory-allocation-btn {
  min-height: 26px;
  padding: 0 4px;
  border-radius: 6px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
}

.inventory-allocation-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.inventory-allocation-list .customer-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
}

.inventory-allocation-list .customer-name {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-allocation-list .customer-qty {
  flex: 0 0 auto;
  color: var(--green);
  font-weight: 900;
}

.customer-add-grid,
.group-add-grid {
  display: grid;
  grid-template-columns: minmax(54px, 0.8fr) minmax(42px, 0.55fr) minmax(42px, 0.55fr) minmax(82px, 1.15fr) 54px;
  gap: 5px;
}
.customer-add-grid {
  grid-template-columns: minmax(54px, 0.8fr) minmax(42px, 0.55fr) minmax(42px, 0.55fr) minmax(82px, 1.15fr) 54px;
}

.group-add-grid-auto {
  grid-template-columns: minmax(120px, 1.6fr) minmax(52px, 0.55fr) minmax(52px, 0.55fr) minmax(92px, 1fr) 54px;
}

.customer-new-name {
  grid-column: 1 / -1;
}

.customer-add-grid input,
.group-add-grid input,
.customer-add-grid select,
.group-add-grid select,
.customer-add-grid button,
.group-add-grid button {
  width: 100%;
  height: 38px;
}

.customer-add-grid select,
.group-add-grid select,
.smart-add-row select {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--white);
  color: var(--green);
  text-align: center;
  text-align-last: center;
  font-size: 14px;
  font-weight: 900;
}

#customer-add-batch,
#customer-ai-batch,
#group-add-batch {
  text-transform: uppercase;
}

.customer-add-grid button,
.group-add-grid button {
  min-height: 42px;
}

.group-customer-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 5px;
}

.group-customer-action-row .autocomplete-field {
  position: relative;
}

.group-customer-action-row input,
.group-customer-action-row button {
  width: 100%;
  height: 38px;
}

.group-customer-action-row button {
  min-height: 38px;
  padding: 0 3px;
  font-size: 12px;
  white-space: nowrap;
}

.group-customer-action-row .suggestions {
  top: calc(100% + 4px);
  text-align: left;
}

.smart-add-row {
  display: grid;
  gap: 5px;
}
#group-view .smart-add-row {
  grid-template-columns: minmax(0, 1fr) 48px 68px;
}
#customer-view .smart-add-row {
  grid-template-columns: minmax(0, 1fr) 68px 68px;
}

.smart-add-row input,
.smart-add-row select {
  width: 100%;
  height: 42px;
  text-transform: uppercase;
}

.smart-add-row textarea {
  width: 100%;
  min-height: 42px;
  max-height: 82px;
  padding: 7px;
  text-align: left;
  font-size: 13px;
  font-weight: 800;
  resize: vertical;
}

.smart-add-row textarea:focus {
  min-height: 92px;
}

.smart-add-row button {
  min-height: 42px;
  padding: 0 4px;
  font-size: 13px;
}

.smart-paste-review {
  display: grid;
  gap: 7px;
  margin-top: 7px;
}

.smart-paste-review-title {
  color: #a12828;
  font-size: 12px;
  font-weight: 800;
}

.smart-paste-review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.smart-paste-review-close {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-color: #d9c7c7;
  background: #fff;
  color: #8a3434;
  font-size: 22px;
  line-height: 1;
}

.smart-paste-review-item.unresolved {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid #d94b4b;
  border-left-width: 4px;
  border-radius: 6px;
  background: #fff7f7;
}

.smart-paste-original {
  color: #a12828;
  font-size: 13px;
  font-weight: 800;
}

.smart-paste-original-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.smart-paste-item-remove,
.smart-paste-review-reopen {
  min-height: 30px;
  border: 1px solid #d9c7c7;
  background: #fff;
  color: #a12828;
  font-weight: 800;
}

.smart-paste-review-reopen {
  width: 100%;
}

.smart-paste-candidates {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.smart-paste-candidates button {
  min-height: 30px;
  padding: 3px 9px;
  border-color: #b9d8ce;
  background: #fff;
  color: #0f745b;
  font-size: 12px;
}

.smart-paste-no-candidate {
  color: #7b6767;
  font-size: 12px;
}

.smart-paste-manual-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 58px 50px;
  gap: 5px;
}

.smart-paste-manual-row input,
.smart-paste-manual-row button {
  min-width: 0;
  min-height: 36px;
  font-size: 13px;
}

.customer-title {
  padding: 18px 8px 14px;
  background: #fbfdfc;
  text-align: center;
}

.customer-title-line {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.customer-title h2 {
  margin: 0;
  overflow: hidden;
  font-size: 24px;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-rename-btn {
  flex: 0 0 auto;
  min-height: 28px;
  border: 1px solid rgba(12, 126, 91, 0.22);
  border-radius: 999px;
  background: #eff8f4;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.customer-title p {
  margin: 7px 0 0;
  color: var(--green);
  font-size: 17px;
  font-weight: 900;
}

.status-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 4px 2px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.status-bar span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-bar button {
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--green);
  font-size: 11px;
}

.profit-panel,
.profit-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.profit-panel {
  padding: 8px;
}

.profit-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.profit-header strong,
.profit-card h2 {
  margin: 0;
  font-size: 16px;
}

.profit-header span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.profit-actions {
  display: flex;
  gap: 6px;
}

.profit-actions button {
  min-width: 48px;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--green);
  font-size: 13px;
}

.profit-actions button.active {
  background: var(--green);
  color: var(--white);
}

.profit-overview,
.profit-section {
  border: 1px solid var(--line);
  background: var(--white);
}

.profit-overview {
  padding: 10px;
  border-radius: 8px;
}

.profit-overview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.profit-overview-header strong {
  display: block;
  font-size: 18px;
}

.profit-overview-header span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.profit-period-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 190px);
}

.profit-period-actions button,
.profit-filter-row button,
.profit-customer-filter > button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.profit-period-actions button.active {
  border-color: var(--green);
  background: var(--green);
  color: var(--white);
}

.profit-filter-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(128px, 0.9fr) 54px;
  gap: 6px;
  margin-top: 9px;
}

.profit-filter-row select,
.profit-filter-row input,
.profit-customer-search-wrap input {
  width: 100%;
  height: 36px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--text);
  font-size: 16px;
}

.profit-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(108px, 0.85fr);
  gap: 6px;
  margin-top: 8px;
}

.profit-summary .empty-state {
  grid-column: 1 / -1;
}

.profit-hero-metric {
  min-height: 112px;
  padding: 15px 13px;
  border-left: 4px solid var(--green);
  background: #fff4f2;
}

.profit-hero-metric span,
.profit-hero-side span,
.profit-secondary-metrics span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.profit-hero-metric strong {
  display: block;
  margin: 5px 0 2px;
  color: var(--green);
  font-size: 28px;
  line-height: 1.1;
}

.profit-hero-metric small {
  color: #287d62;
  font-size: 11px;
  font-weight: 800;
}

.profit-hero-side {
  display: grid;
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.profit-hero-side > div {
  padding: 9px;
  background: #f7fbf9;
}

.profit-hero-side strong,
.profit-secondary-metrics strong {
  display: block;
  margin-top: 3px;
  font-size: 16px;
}

.profit-hero-side .profit-loss-summary {
  background: #f7fbf9;
}

.profit-hero-side .profit-loss-summary strong,
.profit-loss-table strong,
.profit-loss-summary-lines strong,
.negative {
  color: #b42318;
}

.profit-secondary-metrics {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.profit-secondary-metrics > div {
  min-width: 0;
  padding: 9px 7px;
  border-bottom: 3px solid #bfd7cd;
  background: #f7fbf9;
}

.profit-seller-summary {
  display: flex;
  grid-column: 1 / -1;
  flex-wrap: wrap;
  gap: 5px 10px;
  padding: 7px 9px;
  background: #edf5f2;
  color: #456057;
  font-size: 11px;
}

.profit-seller-summary b {
  color: var(--green);
}

.profit-section-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin: 8px 0;
  padding: 4px;
  border-radius: 7px;
  background: #dfeae6;
}

.profit-section-tabs button {
  height: 36px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #496159;
  font-size: 13px;
  font-weight: 900;
}

.profit-section-tabs button.active {
  background: var(--white);
  color: var(--green);
  box-shadow: 0 1px 4px rgba(16, 35, 29, 0.12);
}

.profit-section {
  overflow: visible;
  border-radius: 8px;
}

.profit-customer-filter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 6px;
  padding: 9px;
  border-bottom: 1px solid var(--line);
}

.profit-customer-search-wrap {
  position: relative;
  min-width: 0;
}

.profit-customer-search-wrap input {
  padding: 0 10px;
}

.profit-customer-suggestions {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  overflow: hidden;
  border: 1px solid #b6cbc3;
  border-radius: 6px;
  background: var(--white);
  box-shadow: 0 10px 24px rgba(16, 35, 29, 0.16);
}

.profit-customer-suggestions button {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border: 0;
  border-bottom: 1px solid #edf2f0;
  background: var(--white);
  color: var(--text);
  text-align: left;
}

.profit-customer-suggestions button:last-child {
  border-bottom: 0;
}

.profit-customer-suggestions small {
  color: var(--green);
  font-weight: 900;
}

.profit-suggestion-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

.profit-selected-customer-summary {
  border-bottom: 1px solid var(--line);
}

.profit-selected-customer-title,
.profit-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px;
}

.profit-selected-customer-title strong,
.profit-section-heading strong {
  font-size: 14px;
}

.profit-selected-customer-title span,
.profit-section-heading span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.profit-selected-customer-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.profit-selected-customer-grid > div {
  min-width: 0;
  padding: 8px 5px;
  background: #f9fbfa;
  text-align: center;
}

.profit-selected-customer-grid span,
.profit-selected-customer-grid strong {
  display: block;
}

.profit-selected-customer-grid span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.profit-selected-customer-grid strong {
  margin-top: 3px;
  font-size: 13px;
}

.profit-customer-table .table-row {
  grid-template-columns: minmax(98px, 1.2fr) repeat(4, minmax(58px, 0.8fr));
}

.profit-customer-row {
  appearance: none;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--white);
  color: var(--text);
  text-align: left;
}

.profit-customer-row:active {
  background: #edf6f2;
}

.profit-customer-row strong {
  color: var(--green);
  text-align: right;
}

.profit-document-table .table-row {
  grid-template-columns: 92px 64px minmax(112px, 1fr) 82px 86px;
}

.profit-batch-table .table-row {
  grid-template-columns: 92px minmax(120px, 1fr) minmax(104px, 0.9fr) 82px 86px;
}

.profit-document-row,
.profit-batch-row {
  appearance: none;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.profit-document-row:focus-visible,
.profit-batch-row:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: -2px;
}

.profit-document-row:active,
.profit-batch-row:active {
  background: #edf6f2;
}

.profit-document-row strong,
.profit-batch-row strong,
.profit-detail-table .table-row > strong,
.profit-batch-detail-table .table-row > strong {
  color: var(--green);
  text-align: right;
}

.profit-customer-row > strong,
.profit-document-row > strong,
.profit-batch-row > strong {
  display: grid;
  min-width: 0;
  align-items: center;
  justify-items: center;
  text-align: center;
}

.profit-document-source {
  display: grid;
  min-width: 0;
  align-items: center;
  justify-items: center;
  overflow: hidden;
}

.profit-document-source .profit-source-badge {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profit-document-customer,
.profit-batch-product,
.profit-batch-code,
.profit-detail-customer {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profit-source-badge {
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
}

.profit-mode-badge {
  color: #76521d;
  font-size: 11px;
  font-weight: 900;
}

.profit-section .not-applicable {
  color: #8a9893;
}

.profit-drilldown-header {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 58px;
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  background: #f4f8f6;
}

.profit-drilldown-header button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid #bdd1ca;
  border-radius: 6px;
  background: var(--white);
  color: var(--green);
  font-size: 22px;
  line-height: 1;
}

.profit-drilldown-header strong,
.profit-drilldown-header span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profit-drilldown-header strong {
  font-size: 15px;
}

.profit-drilldown-header span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.profit-drilldown-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  border-bottom: 8px solid #edf3f0;
  background: var(--line);
}

.profit-drilldown-summary > div {
  min-width: 0;
  padding: 8px 4px;
  background: var(--white);
  text-align: center;
}

.profit-drilldown-summary span,
.profit-drilldown-summary strong {
  display: block;
}

.profit-drilldown-summary span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.profit-drilldown-summary strong {
  overflow: hidden;
  margin-top: 3px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profit-drilldown .pending,
.profit-section .pending {
  color: #9a5d00;
  font-weight: 900;
}

.profit-customer-detail-block {
  border-top: 8px solid #edf3f0;
}

.profit-customer-detail-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px 68px;
  gap: 6px;
  align-items: center;
  min-height: 46px;
  padding: 7px 9px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  width: 100%;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  background: var(--white);
  color: var(--text);
  text-align: left;
}

.profit-customer-detail-line div,
.profit-detail-product,
.profit-loss-product {
  min-width: 0;
}

.profit-customer-detail-line div strong,
.profit-customer-detail-line div small,
.profit-detail-product b,
.profit-detail-product small,
.profit-loss-product b,
.profit-loss-product small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profit-customer-detail-line small,
.profit-detail-product small,
.profit-loss-product small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.profit-customer-detail-line > strong {
  color: var(--green);
  text-align: right;
}

.profit-detail-table .table-row {
  grid-template-columns: minmax(150px, 1.2fr) 72px 58px 78px 78px 86px 72px 82px;
}

.profit-batch-detail-table .table-row {
  grid-template-columns: minmax(110px, 1fr) 62px 72px 58px 78px 78px 86px 72px 82px;
}

.profit-batch-loss-block,
.profit-loss-group,
.profit-unmatched-block {
  border-top: 8px solid #edf3f0;
}

.profit-batch-loss-lines {
  border-top: 1px solid var(--line);
}

.profit-batch-loss-line {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 90px;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 6px 9px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.profit-batch-loss-line strong {
  text-align: right;
}

.profit-empty-row {
  min-height: 44px;
  color: var(--muted);
}

.profit-empty-cell {
  color: var(--muted);
  font-weight: 900;
}

.profit-loss-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--line);
}

.profit-loss-summary-grid > div {
  min-height: 54px;
  padding: 8px;
  border-left: 3px solid #d95c50;
  background: #fff7f5;
}

.profit-loss-summary-grid > div > strong {
  display: block;
  margin-bottom: 5px;
  color: #7a271a;
  font-size: 13px;
}

.profit-loss-summary-lines {
  display: grid;
  gap: 4px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.profit-loss-summary-lines > div:not(.empty-state) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.compact-empty {
  padding: 4px 0;
  font-size: 12px;
}

.profit-loss-table .table-row {
  grid-template-columns: minmax(90px, 1fr) minmax(120px, 1.2fr) 54px 74px 74px;
}

.profit-inventory-loss-table .table-row {
  grid-template-columns: 92px minmax(140px, 1.2fr) 60px 78px 86px;
}

.profit-unmatched-block {
  padding: 9px;
}

.profit-unmatched-block > strong {
  color: #7a271a;
  font-size: 13px;
}

.profit-unmatched {
  display: grid;
  gap: 6px;
  margin-top: 6px;
  color: #9b332b;
  font-size: 12px;
  font-weight: 800;
}

/* 利润页下半区按已确认的“客户总单式”草图展示。 */
.profit-sheet-view {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
}

.profit-sheet-bar {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px;
  background: var(--green);
  color: var(--white);
}

.profit-sheet-bar > strong {
  font-size: 15px;
  font-weight: 900;
}

.profit-sheet-bar .profit-sheet-bar-back {
  min-width: 72px;
  color: var(--white);
  font-size: 13px;
}

.profit-sheet-title {
  display: flex;
  min-height: 72px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 10px 9px;
}

.profit-sheet-title > div {
  min-width: 0;
}

.profit-sheet-title strong,
.profit-sheet-title small,
.profit-sheet-summary-line {
  display: block;
}

.profit-sheet-title > div > strong {
  overflow: hidden;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profit-sheet-title small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.profit-sheet-summary-line {
  margin-top: 4px;
  color: #425951;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.55;
}

.profit-sheet-summary-line b {
  color: var(--green);
}

.profit-sheet-back {
  width: auto;
  min-width: 70px;
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.profit-sheet-scroll {
  overflow-x: auto;
  border-top: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}

.profit-sheet-table {
  min-width: 720px;
}

.profit-customer-detail-table {
  min-width: 640px;
}

.profit-mode-detail-table {
  min-width: 820px;
}

.profit-sheet-row {
  display: grid;
  min-height: 42px;
  align-items: center;
  border-top: 1px solid #e5ece9;
  background: var(--white);
  color: var(--text);
  font-size: 11px;
}

.profit-customer-detail-table .profit-sheet-row {
  grid-template-columns: 34px 74px 58px 54px 78px 72px 82px 68px 82px;
}

.profit-mode-detail-table .profit-sheet-row {
  grid-template-columns: 34px 88px 128px 58px 54px 76px 72px 72px 66px 76px;
}

.profit-batch-cell {
  display: flex;
  min-width: 0;
  gap: 4px;
  align-items: center;
  overflow: hidden;
  padding: 6px 5px;
  white-space: nowrap;
}

.profit-batch-cell > .profit-batch-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.after-sale-btn {
  flex: 0 0 auto;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #f59e0b;
  color: var(--white);
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.after-sale-btn.has-after-sale {
  background: #b45309;
}

.after-sale-btn:active {
  filter: brightness(0.92);
}

.profit-sheet-row > span,
.profit-sheet-row > strong {
  overflow: hidden;
  padding: 6px 5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profit-sheet-row > strong {
  color: var(--green);
  text-align: right;
}

.profit-sheet-head {
  min-height: 34px;
  border-top: 0;
  background: #dfeae6;
  color: #40564e;
  font-size: 10px;
  font-weight: 900;
}

.profit-sheet-total {
  min-height: 38px;
  border-top: 2px solid #b9cec5;
  background: #f4f8f6;
  font-weight: 900;
}

.profit-sheet-action-row {
  appearance: none;
  width: 100%;
  padding: 0;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  border-radius: 0;
  text-align: left;
}

.profit-sheet-action-row:active {
  background: #edf6f2;
}

.profit-sheet-tip,
.profit-loss-note {
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  background: #fff9e9;
  color: #7e5d0a;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.55;
}

.profit-sheet-empty {
  width: 100%;
  min-width: 640px;
}

.profit-source-badge,
.profit-mode-badge {
  display: inline-block;
  width: max-content;
  padding: 3px 6px;
  border-radius: 4px;
  background: #e8f3ef;
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
}

.profit-mode-badge.margin {
  background: #fff1dc;
  color: #8a5e12;
}

.profit-source-badge.group {
  background: #fff1dc;
  color: #8a5e12;
}

.profit-loss-impact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 0 8px 8px;
}

.profit-loss-impact-grid > div {
  min-width: 0;
  padding: 9px 8px;
  border-bottom: 3px solid #d68b84;
  background: var(--white);
}

.profit-loss-impact-grid span,
.profit-loss-impact-grid strong {
  display: block;
}

.profit-loss-impact-grid span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.profit-loss-impact-grid strong {
  margin-top: 4px;
  color: #a42d25;
  font-size: 14px;
}

.profit-loss-block {
  margin-top: 8px;
  border: 1px solid var(--line);
  background: var(--white);
}

.profit-loss-block-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  background: #f0f5f3;
}

.profit-loss-block-title strong {
  font-size: 13px;
}

.profit-loss-block-title span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.profit-loss-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(100px, 0.9fr) 78px;
  gap: 8px;
  align-items: center;
  min-height: 46px;
  padding: 8px 10px;
  border-top: 1px solid #e5ece9;
  font-size: 11px;
}

.profit-loss-row span,
.profit-loss-row b,
.profit-loss-row small {
  display: block;
  min-width: 0;
}

.profit-loss-row small {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profit-loss-row > strong {
  color: #a42d25;
  text-align: right;
}

@media (max-width: 640px) {
  .profit-document-table .table-head,
  .profit-batch-table .table-head {
    display: grid;
  }

  .profit-document-table .table-row:not(.profit-empty-row),
  .profit-batch-table .table-row:not(.profit-empty-row) {
    min-height: 44px;
    gap: 3px;
    padding: 0 4px;
  }

  .profit-document-table .table-row {
    grid-template-columns: 58px 52px minmax(88px, 1fr) 48px 66px;
  }

  .profit-batch-table .table-row {
    grid-template-columns: 54px minmax(74px, 1fr) minmax(86px, 1.1fr) 44px 66px;
  }

  .profit-document-row > *,
  .profit-batch-row > *,
  .profit-document-row .profit-document-customer,
  .profit-batch-row .profit-batch-date,
  .profit-batch-row .profit-batch-product,
  .profit-batch-row .profit-batch-code,
  .profit-document-row > span:nth-child(4),
  .profit-batch-row > span:nth-child(4),
  .profit-document-row > strong,
  .profit-batch-row > strong {
    grid-column: auto;
    grid-row: auto;
  }

  .profit-document-row > strong,
  .profit-batch-row > strong,
  .profit-document-row > span:nth-child(4),
  .profit-batch-row > span:nth-child(4) {
    text-align: right;
  }

  .profit-document-table .table-row > *,
  .profit-batch-table .table-row > * {
    overflow: hidden;
    padding: 0 2px;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .profit-sheet-title {
    min-height: 68px;
  }

  .profit-loss-row {
    grid-template-columns: minmax(0, 1.25fr) minmax(96px, 0.9fr) 70px;
    gap: 5px;
    padding: 8px;
  }
}

@media (max-width: 640px) {
  .profit-overview-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .profit-period-actions {
    width: 100%;
  }

  .profit-filter-row {
    grid-template-columns: minmax(0, 1fr) minmax(122px, 0.9fr) 50px;
  }

  .profit-hero-metric {
    min-height: 104px;
    padding: 13px 10px;
  }

  .profit-hero-metric strong {
    font-size: 24px;
  }

  .profit-hero-side strong,
  .profit-secondary-metrics strong {
    font-size: 14px;
  }

  .profit-secondary-metrics > div {
    padding: 8px 5px;
  }

  .profit-customer-table .table-row {
    grid-template-columns: minmax(92px, 1.2fr) repeat(4, minmax(52px, 0.8fr));
  }

  .profit-customer-table .table-row > * {
    padding: 0 4px;
    font-size: 11px;
  }

  .profit-detail-table .table-head,
  .profit-batch-detail-table .table-head,
  .profit-loss-table .table-head,
  .profit-inventory-loss-table .table-head {
    display: none;
  }

  .profit-document-date {
    color: var(--muted);
  }

  .profit-drilldown-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .profit-detail-table .table-row:not(.profit-empty-row),
  .profit-batch-detail-table .table-row:not(.profit-empty-row) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px;
    min-height: 112px;
    padding: 9px;
  }

  .profit-detail-table .profit-detail-product {
    grid-column: 1 / -1;
  }

  .profit-batch-detail-table .profit-detail-customer {
    font-weight: 900;
  }

  .profit-detail-table .table-row:not(.profit-empty-row) > strong,
  .profit-batch-detail-table .table-row:not(.profit-empty-row) > strong,
  .profit-detail-table .table-row:not(.profit-empty-row) > span:nth-child(even),
  .profit-batch-detail-table .table-row:not(.profit-empty-row) > span:nth-child(even) {
    text-align: right;
  }

  .profit-detail-table [data-label]::before,
  .profit-batch-detail-table [data-label]::before,
  .profit-loss-table [data-label]::before,
  .profit-inventory-loss-table [data-label]::before {
    margin-right: 3px;
    color: var(--muted);
    content: attr(data-label) " ";
    font-size: 10px;
  }

  .profit-loss-table .table-row:not(.profit-empty-row) {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 8px;
    min-height: 78px;
    padding: 9px;
  }

  .profit-loss-table .table-row:not(.profit-empty-row) > span:nth-child(1) {
    font-weight: 900;
  }

  .profit-loss-table .profit-loss-product {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .profit-loss-table .table-row:not(.profit-empty-row) > span:nth-child(3),
  .profit-loss-table .table-row:not(.profit-empty-row) > span:nth-child(4) {
    grid-row: 3;
  }

  .profit-loss-table .table-row:not(.profit-empty-row) > span:nth-child(4),
  .profit-loss-table .table-row:not(.profit-empty-row) > strong {
    text-align: right;
  }

  .profit-inventory-loss-table .table-row:not(.profit-empty-row) {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 8px;
    min-height: 86px;
    padding: 9px;
  }

  .profit-inventory-loss-table .profit-loss-product {
    grid-column: 1 / -1;
  }

  .profit-inventory-loss-table .table-row:not(.profit-empty-row) > strong,
  .profit-inventory-loss-table .table-row:not(.profit-empty-row) > span:nth-child(even) {
    text-align: right;
  }
}

.safety-panel {
  border-color: #bddbd2;
}

.safety-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.safety-grid > div {
  min-height: 58px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbfa;
}

.safety-grid strong {
  display: block;
  margin-bottom: 5px;
  color: var(--green);
  font-size: 13px;
}

.safety-lines {
  display: grid;
  gap: 4px;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.safety-lines .ok {
  color: var(--green);
}

.safety-lines .warning {
  color: #b42318;
}

.audit-table .table-row {
  grid-template-columns: minmax(82px, 1fr) minmax(52px, .7fr) 76px 54px 48px 42px 42px;
}

.export-sheet {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 10px;
  background: rgba(8, 25, 20, 0.42);
}

.export-panel {
  display: grid;
  width: min(100%, 430px);
  max-height: calc(100dvh - 28px - env(safe-area-inset-top));
  gap: 8px;
  padding: 10px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.export-panel header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 66px;
  gap: 8px;
  align-items: center;
}

.export-panel header strong,
.export-panel header span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-panel header strong {
  font-size: 18px;
}

.export-panel header span,
.export-tip {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.export-preview-image {
  width: 100%;
  max-height: none;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
  touch-action: manipulation;
}

.export-tip {
  margin: 0;
  padding: 8px;
  border-radius: 7px;
  background: var(--green-soft);
  text-align: center;
}

.export-table-preview {
  max-height: 38dvh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.export-table-preview table {
  width: 100%;
  min-width: 390px;
  border-collapse: collapse;
}

.export-table-preview th,
.export-table-preview td {
  padding: 8px 6px;
  border: 1px solid var(--line);
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.export-table-preview th {
  background: var(--green-soft);
  color: var(--green);
}

.export-table-preview td[contenteditable="true"] {
  background: #fffaf0;
  box-shadow: inset 0 0 0 1px rgba(15, 125, 97, 0.2);
  cursor: text;
}

.export-table-preview td[contenteditable="true"]:focus {
  outline: 2px solid rgba(15, 125, 97, 0.35);
  outline-offset: -2px;
  background: #ffffff;
}

.export-table-preview .export-sheet-name {
  padding: 8px 6px 4px;
  font-size: 13px;
  font-weight: 800;
  color: var(--green);
  background: var(--green-soft);
  border-bottom: 1px solid var(--line);
  position: sticky;
  left: 0;
  top: 0;
  z-index: 1;
}

#export-copy-text {
  width: 100%;
  min-height: 86px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

.export-sheet-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.export-sheet-actions button {
  min-height: 42px;
}

.clear-day-sheet {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 10px;
  background: rgba(40, 10, 10, 0.42);
}

.clear-day-panel {
  display: grid;
  width: min(100%, 430px);
  gap: 10px;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border: 1px solid #f1b5b5;
  border-radius: 8px 8px 0 0;
  background: var(--white);
  box-shadow: 0 -12px 28px rgba(75, 18, 18, 0.18);
}

.clear-day-panel header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 8px;
  align-items: center;
}

.clear-day-panel header strong {
  color: #9f1d1d;
  font-size: 18px;
}

.clear-day-panel p {
  margin: 0;
  padding: 8px;
  border-radius: 7px;
  background: #fff1f1;
  color: #7a2424;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
}

.clear-scope-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.clear-scope-row button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 14px;
}

.clear-scope-row button.active {
  border-color: var(--green);
  background: var(--green);
  color: var(--white);
}

.clear-date-capsule {
  display: grid;
  height: 42px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--green-soft);
}

.clear-date-capsule .date-segment + .date-segment {
  border-left: 1px solid var(--line);
}

.clear-date-capsule select {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  appearance: none;
  background: transparent;
  color: var(--green);
  font-size: 15px;
  font-weight: 900;
  text-align: center;
  text-align-last: center;
}

.clear-date-capsule select:disabled {
  color: var(--muted);
  opacity: 0.55;
}

.clear-date-capsule option {
  color: var(--text);
  background: var(--white);
}

.clear-day-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.clear-day-panel input {
  height: 42px;
  letter-spacing: 0;
}

.danger-btn {
  min-height: 44px;
  background: #c62828;
  color: var(--white);
}

.group-clear-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.group-clear-actions button {
  min-height: 44px;
}

.wheel-picker {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 25, 20, 0.36);
  touch-action: pan-y;
}

.wheel-picker.anchored {
  align-items: center;
  justify-content: center;
  background: rgba(8, 25, 20, 0.36);
}

.wheel-picker-panel {
  width: min(100%, 430px);
  max-height: min(62dvh, 430px);
  padding: 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 12px 28px rgba(15, 35, 29, 0.22);
}

.wheel-picker.anchored .wheel-picker-panel {
  position: static;
  width: min(100%, 430px);
  max-height: min(62dvh, 430px);
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(15, 35, 29, 0.22);
}

.wheel-picker-panel header {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.wheel-picker-panel header strong {
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wheel-picker-panel header button {
  min-height: 38px;
  border-radius: 999px;
}

.wheel-picker-search-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.wheel-picker-search-row span {
  display: grid;
  min-height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--green);
  font-weight: 900;
}

.wheel-picker-search-row input {
  width: 100%;
  height: 38px;
  text-align: left;
}

.wheel-picker-options {
  max-height: min(48dvh, 320px);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(#fff, #f7fbf9);
  overscroll-behavior: contain;
  scroll-snap-type: y mandatory;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.wheel-picker.anchored .wheel-picker-options {
  max-height: min(34dvh, 260px);
}

/* 批次选择小浮窗（客户总单/群录单/草稿批次号选择） */
.batch-picker {
  position: fixed;
  z-index: 16;
  display: block;
}

.batch-picker.hidden {
  display: none;
}

.batch-picker-panel {
  width: 520px;
  max-width: calc(100vw - 16px);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  box-shadow: 0 10px 26px rgba(15, 35, 29, 0.25);
}

.batch-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.batch-picker-head strong {
  font-size: 15px;
  color: var(--green);
}

.batch-picker-close {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: #eef5f2;
  color: var(--green);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.batch-picker-demand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbf9;
  font-size: 13px;
  color: #333;
}

.batch-picker-demand-right {
  white-space: nowrap;
}

.batch-picker-demand b {
  color: var(--green);
}

.batch-picker-list {
  display: grid;
  max-height: min(38dvh, 240px);
  gap: 6px;
  padding: 2px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.batch-picker-option {
  display: grid;
  grid-template-columns: minmax(96px, 1fr) 82px minmax(132px, 1.35fr);
  min-height: 40px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--green);
  cursor: pointer;
}

.batch-picker-option strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 14px;
  letter-spacing: 0.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-picker-option-stock,
.batch-picker-option-prices {
  font-size: 12px;
  color: #555;
}

.batch-picker-option-stock {
  white-space: nowrap;
}

.batch-picker-option-prices {
  line-height: 1.35;
  text-align: left;
}

.batch-picker-option:hover,
.batch-picker-option:focus {
  border-color: var(--green);
  background: var(--green-soft);
  outline: 0;
}

/* 已配批次：标记"已配 X 扎"并锁定，不可再选同一批次 */
.batch-picker-option.batch-picker-option-allocated,
.batch-picker-option:disabled {
  opacity: 0.62;
  background: #f1f5f3;
  color: #6b7a75;
  cursor: not-allowed;
}

.batch-picker-option.batch-picker-option-allocated:hover,
.batch-picker-option.batch-picker-option-allocated:focus {
  border-color: var(--line);
  background: #f1f5f3;
}

.batch-picker-hint {
  min-height: 18px;
  margin: 8px 2px 0;
  font-size: 12px;
  color: #8a6d3b;
  text-align: center;
}

.wheel-option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  border-bottom: 1px solid var(--line);
}

.wheel-option-row:last-child {
  border-bottom: 0;
}

.wheel-option {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  font-weight: 900;
  text-align: center;
  scroll-snap-align: center;
}

.wheel-option-row .wheel-option {
  border-bottom: 0;
}

.wheel-option-action {
  min-height: 48px;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: #fef3c7;
  color: #92400e;
  font-size: 14px;
  font-weight: 900;
}

.wheel-option:last-child {
  border-bottom: 0;
}

.wheel-option.selected {
  background: var(--green);
  color: var(--white);
}

.wheel-option:disabled {
  color: var(--muted);
  background: var(--green-soft);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 10;
  max-width: min(330px, calc(100vw - 28px));
  padding: 10px 14px;
  border-radius: 7px;
  background: rgba(15, 35, 29, 0.9);
  color: var(--white);
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transform: translateX(-50%);
}

@media (max-width: 360px) {
  .app-shell {
    padding-left: 5px;
    padding-right: 5px;
  }

  .top-card {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px;
  }

  .top-card > div:first-child {
    min-width: 82px;
  }

  .top-card strong {
    font-size: 17px;
  }

  .top-actions {
    gap: 2px;
  }

  .date-capsule {
    width: 166px;
    min-width: 160px;
  }

  .top-actions .ghost-btn {
    width: 42px;
  }

  .top-actions .light-btn {
    width: 38px;
  }

  .top-actions .all-print-btn {
    width: 34px;
  }

  .sync-pill {
    width: 72px;
    min-width: 72px;
    height: 30px;
    font-size: 12px;
  }

  .top-actions button {
    padding: 0 4px;
    font-size: 12px;
  }

  .batch-grid {
    grid-template-columns: 32px minmax(60px, 1fr) 50px 60px 72px;
    gap: 4px;
  }

  .batch-summary-row {
    gap: 5px;
  }

  .customer-add-grid,
  .group-add-grid {
    grid-template-columns: minmax(48px, 0.65fr) 46px 46px minmax(88px, 1.1fr) 52px;
    gap: 4px;
  }

  .group-add-grid.group-add-grid-auto {
    grid-template-columns: minmax(120px, 1.6fr) minmax(52px, 0.55fr) minmax(52px, 0.55fr) minmax(92px, 1fr) 52px;
  }

  .inventory-add-grid {
    grid-template-columns: minmax(50px, 1fr) minmax(74px, 1.05fr) 38px 46px 46px 46px 54px;
    gap: 4px;
  }

  .inventory-ai-panel {
    grid-template-columns: minmax(0, 1fr) 54px 80px;
    gap: 4px;
  }

  #group-view .smart-add-row {
    grid-template-columns: minmax(0, 1fr) 42px 58px;
    gap: 4px;
  }
  #customer-view .smart-add-row {
    grid-template-columns: minmax(0, 1fr) 54px 58px;
  }

  .packing-table .table-row {
    grid-template-columns: minmax(56px, 1fr) 40px 44px 34px 82px;
  }

  .packing-table .table-row {
    padding-right: 42px;
  }

  .packing-table .table-row .swipe-delete-btn {
    top: 50%;
    right: 4px;
    width: 36px;
    height: 28px;
    border-radius: 6px;
    font-size: 11px;
    opacity: 0.92;
    pointer-events: auto;
    transform: translateY(-50%);
  }

  .packing-table .table-row.swipe-delete-open > input,
  .packing-table .table-row.swipe-delete-open > span {
    transform: none;
  }

  .customer-table .table-row {
    grid-template-columns: 24px minmax(38px, 0.62fr) 36px 36px 42px 34px minmax(68px, 1fr) 42px 44px 30px;
  }

  .inventory-table .table-row {
    min-width: 700px;
    grid-template-columns: minmax(44px, 1.012fr) 60px 34px 34px 34px 34px 34px 34px 48px 96px 46px 52px minmax(44px, 0.7fr);
  }

  .inventory-table .inventory-grass-row {
    min-width: 700px;
    grid-template-columns: minmax(44px, 1.012fr) 60px 34px 34px 34px 34px 34px 34px 48px 96px 46px 52px minmax(44px, 0.7fr);
  }

  .loss-table .table-row {
    grid-template-columns: minmax(48px, 1fr) 96px 34px 36px 38px 57px 130px minmax(132px, 2.4fr);
  }

  .sale-price-table .table-row {
    grid-template-columns: minmax(44px, 1fr) 66px 38px 42px 42px 42px;
  }

  .pending-table .table-row {
    grid-template-columns: minmax(48px, 1fr) 42px 48px minmax(60px, 1fr) 34px 92px minmax(44px, 0.8fr);
  }

  .purchased-table .table-row {
    grid-template-columns: minmax(54px, 1fr) 50px minmax(48px, 0.8fr) minmax(72px, 1fr) minmax(40px, 0.6fr) 64px;
  }
}

@media (min-width: 641px) and (max-width: 899px) {
  .app-shell {
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom));
  }
}

@media (min-width: 900px) {
  body {
    background: #edf4f1;
  }

  .app-shell {
    width: min(100%, 1440px);
    max-width: 1440px;
    min-height: 100dvh;
    padding: 16px;
    gap: 10px;
  }

  .top-card {
    grid-template-columns: minmax(160px, 1fr) auto;
    padding: 12px 14px;
  }

  .top-card strong {
    font-size: 24px;
  }

  .top-card span {
    display: block;
    font-size: 14px;
  }

  .top-actions {
    gap: 8px;
  }

  .group-customer-action-row {
    grid-template-columns: minmax(180px, 1fr) 72px 96px;
    gap: 8px;
  }

  .date-capsule {
    width: 206px;
    height: 42px;
  }

  .top-actions button,
  .tab,
  .pager button,
  .export-row button {
    height: 42px;
  }

  .top-actions .ghost-btn,
  .top-actions .light-btn {
    width: 76px;
  }

  .tab-bar {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
  }

  .pager {
    grid-template-columns: 132px minmax(0, 1fr) 132px;
    padding: 8px;
  }

  .pager strong {
    font-size: 20px;
  }

  .pager span {
    font-size: 13px;
  }

  .view-panel {
    gap: 10px;
  }

  .batch-grid {
    grid-template-columns: 58px minmax(180px, 1fr) 104px 130px 180px;
    gap: 10px;
  }

  .sequence-pill,
  .product-field input,
  .batch-field input,
  .unit-price-field {
    min-height: 50px;
    height: 50px;
  }

  .unit-price-field input {
    font-size: 20px;
  }

  .product-field input {
    font-size: 24px;
  }

  .batch-field input {
    font-size: 19px;
  }

  .batch-summary-row {
    grid-template-columns: 150px 120px 120px 80px 80px;
    gap: 8px;
  }

  .batch-summary-row > * {
    height: 46px;
    min-height: 46px;
  }

  .batch-summary-input span,
  .batch-summary-stat span {
    font-size: 13px;
  }

  .batch-summary-input input,
  .batch-summary-stat strong {
    font-size: 18px;
  }

  .add-line-form {
    grid-template-columns: minmax(320px, 1fr) 120px 116px 180px;
    gap: 8px;
  }

  .add-line-form input,
  .add-line-form button {
    height: 46px;
  }

  .packing-table {
    min-height: min(58vh, 640px);
  }

  .table-row {
    min-height: 44px;
  }

  .packing-table .table-row {
    grid-template-columns: minmax(220px, 1.35fr) 96px 110px 88px 180px 72px;
  }

  .customer-table .table-row {
    grid-template-columns: 58px minmax(170px, 1fr) 86px 86px 104px 86px 180px 100px 110px 70px;
  }

  .table-row > span,
  .table-row > input {
    font-size: 16px;
  }

  .customer-add-grid,
  .group-add-grid {
    grid-template-columns: minmax(220px, 0.85fr) 110px 110px 180px 120px;
    gap: 8px;
  }

  .group-add-grid.group-add-grid-auto {
    grid-template-columns: minmax(280px, 1.6fr) 120px 120px minmax(180px, 1fr) 120px;
  }

  .inventory-add-grid {
    grid-template-columns: minmax(240px, 1fr) 190px 100px 100px 100px 100px minmax(120px, 0.7fr) 120px;
    gap: 8px;
  }

  .inventory-table .table-row {
    min-width: 0;
    grid-template-columns: minmax(165px, 1.012fr) 120px 78px 86px 86px 86px 86px 86px 78px 136px 100px 128px minmax(120px, 0.7fr);
  }

  .inventory-table .inventory-grass-row {
    min-width: 0;
    grid-template-columns: minmax(165px, 1.012fr) 120px 78px 86px 86px 86px 86px 86px 78px 136px 100px 128px minmax(120px, 0.7fr);
  }

  .loss-table .table-row {
    grid-template-columns: minmax(170px, 1fr) 248px 90px 90px 100px 156px 338px minmax(450px, 2.4fr);
  }

  .sale-price-table .table-row {
    grid-template-columns: minmax(200px, 1fr) 170px 110px 110px 120px 120px;
  }

  .pending-table .table-row {
    grid-template-columns: minmax(180px, 1fr) 120px 120px minmax(220px, 1.2fr) 120px 150px minmax(140px, 0.8fr);
  }

  .purchased-table .table-row {
    grid-template-columns: minmax(180px, 1fr) 120px 160px minmax(180px, 1fr) minmax(120px, 0.8fr) 130px;
  }

  .profit-customer-table .table-row {
    grid-template-columns: minmax(220px, 1fr) 130px 130px 130px 140px;
  }

  .profit-document-table .table-row {
    grid-template-columns: 120px 90px minmax(220px, 1fr) 120px 130px;
  }

  .profit-batch-table .table-row {
    grid-template-columns: 120px minmax(220px, 1fr) 190px 120px 130px;
  }

  .profit-detail-table .table-row {
    grid-template-columns: minmax(220px, 1.2fr) 100px 90px 120px 120px 120px 110px 120px;
  }

  .profit-batch-detail-table .table-row {
    grid-template-columns: minmax(170px, 1fr) 90px 100px 90px 110px 110px 120px 100px 120px;
  }

  .profit-loss-table .table-row {
    grid-template-columns: minmax(150px, 1fr) minmax(220px, 1.2fr) 90px 110px 110px;
  }

  .profit-inventory-loss-table .table-row {
    grid-template-columns: 120px minmax(240px, 1.2fr) 90px 110px 120px;
  }

  #group-view .smart-add-row {
    grid-template-columns: minmax(0, 1fr) 90px 120px;
    gap: 8px;
  }
  #customer-view .smart-add-row {
    grid-template-columns: minmax(0, 1fr) 72px 120px;
  }

  .export-panel {
    width: min(100%, 760px);
  }
}

@media print {
  * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  html,
  body,
  #root {
    min-height: auto;
    overflow: visible;
    background: #fff;
  }

  .login-view,
  .top-card,
  .tab-bar,
  .pager,
  .add-line-form,
  .customer-add-panel,
  .group-order-panel,
  .status-bar,
  .toast,
  .clear-day-sheet,
  .wheel-picker,
  .export-sheet:not(.hidden) {
    display: none !important;
  }

  .app-shell {
    display: block;
    width: 100%;
    max-width: none;
    min-height: auto;
    padding: 0;
  }

  .view-panel {
    display: block;
  }

  .view-panel.hidden {
    display: none !important;
  }

  .data-table,
  .customer-card {
    border: 1px solid #9aa8a2;
    box-shadow: none;
  }

  .packing-table {
    max-height: none;
    overflow: visible;
  }

  .table-head {
    position: static;
  }
}

/* === 采购/核准弹窗 === */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 35, 29, 0.35);
}
.dialog-panel {
  width: min(380px, calc(100vw - 24px));
  max-height: 85vh;
  padding: 16px;
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 12px 40px rgba(15, 35, 29, 0.25);
  overflow-y: auto;
}
.dialog-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.dialog-panel header strong { font-size: 17px; color: var(--text); }
.close-btn {
  width: 32px; height: 32px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 18px; line-height: 1;
}
.dialog-body label {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  color: var(--muted);
  font-weight: 700;
}
.dialog-body label input {
  height: 40px;
  padding: 0 8px;
  text-align: center;
  font-weight: 800;
}
.dialog-panel footer {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.dialog-panel footer button {
  flex: 1;
  height: 42px;
  font-weight: 900;
}
.dialog-panel footer .ghost-btn {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid var(--green);
}

/* 采购弹窗 */
.purchase-product-name {
  font-size: 15px; font-weight: 900;
  color: var(--text);
  margin: 0 0 10px;
}
.purchase-pending-readonly {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  margin-bottom: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--green-soft);
  color: var(--text);
  font-weight: 800;
}
.inventory-use-dialog-rows {
  display: grid;
  gap: 8px;
}
.dialog-body .inventory-use-dialog-row {
  display: grid;
  grid-template-columns: 28px minmax(110px, 1fr) 90px;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.dialog-body .inventory-use-dialog-row > input[type="checkbox"] {
  width: 20px;
  height: 20px;
}
.inventory-use-batch {
  display: grid;
  gap: 2px;
}
.inventory-use-batch small {
  color: var(--muted);
}
.inventory-use-dialog-summary {
  margin: 10px 0 0;
  color: var(--green);
  font-weight: 900;
}
.batch-allocation-price {
  margin: 6px 0 0;
  color: var(--green);
  font-weight: 900;
  font-size: 14px;
}
.batch-allocation-panel {
  width: min(420px, calc(100vw - 24px));
}
.batch-allocation-panel .inventory-use-batch strong {
  white-space: normal;
  word-break: break-all;
}
.batch-insufficient-choices {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.batch-insufficient-choice {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 900;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.print-output-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.print-output-options button {
  display: grid;
  min-height: 92px;
  padding: 12px;
  place-items: center;
  border: 1px solid var(--green);
  background: var(--green-soft);
  color: var(--green);
}
.print-output-options button span {
  color: var(--muted);
  font-size: 12px;
}
.purchase-customer-list {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.purchase-customer-title { margin: 0 0 6px; font-weight: 700; color: var(--muted); }
#purchase-dialog-customer-rows > div {
  padding: 4px 0;
  border-bottom: 1px solid var(--green-soft);
  font-weight: 700;
}

/* 客户明细弹窗 */
.pending-customer-popup {
  position: fixed; inset: 0; z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pending-customer-popup .popup-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 35, 29, 0.3);
}
.pending-customer-popup .popup-panel {
  position: relative;
  width: min(320px, calc(100vw - 32px));
  max-height: 60vh;
  padding: 14px;
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 12px 36px rgba(15, 35, 29, 0.2);
  overflow-y: auto;
}
.pending-customer-popup .popup-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 10px;
}
.customer-detail-row {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}
.customer-detail-row .customer-qty { color: var(--green); }
.customer-detail-btn {
  background: none; border: none;
  color: var(--green); font-weight: 700;
  cursor: pointer; padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* 已采购表格扩列适配打印 */
.purchased-table .table-row {
  grid-template-columns: minmax(60px, 0.9fr) minmax(139px, 1fr) 42px 48px 48px 48px 48px 62px minmax(52px, 0.7fr) 120px minmax(56px, 0.8fr);
}

.purchased-table .purchased-batch-cell,
.purchased-table .purchased-time-cell {
  white-space: nowrap;
  overflow: hidden;
}

.purchased-table .purchased-batch-cell {
  font-size: 12px;
}

.purchased-table .purchased-name-cell {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.purchased-table .purchased-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchased-table .purchased-name-head,
.inventory-table .inventory-name-head {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.inventory-table .inventory-name-head .purchased-filter-trigger.active {
  background: var(--green);
  color: var(--white);
}

.inventory-filter-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 8px;
}

.purchased-filter-trigger {
  flex: 0 0 auto;
  display: inline-flex;
  width: 22px;
  height: 22px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  color: var(--green);
  cursor: pointer;
}

.purchased-filter-trigger:hover {
  background: var(--green-soft);
}

.purchased-filter-icon {
  display: block;
}

.purchased-filter-search {
  padding-bottom: 8px;
}

.purchased-filter-search input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  text-align: left;
}

.purchased-filter-products {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 10px;
}

.purchased-filter-product-btn {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.purchased-filter-product-btn.active {
  background: var(--green);
  color: var(--white);
}

.purchased-filter-record {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.purchased-filter-record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.purchased-filter-record-grid {
  display: grid;
  grid-template-columns: minmax(56px, auto) minmax(0, 1fr);
  gap: 4px 10px;
  font-size: 13px;
}

.purchased-filter-record-grid span {
  color: var(--muted);
  font-weight: 700;
}

.purchased-filter-record-grid strong {
  text-align: right;
  font-weight: 800;
}

.dialog-body select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
}

.form-hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.purchased-readonly {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.payment-status-btn {
  min-width: 0;
  min-height: 30px;
  padding: 0 4px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.payment-status-btn.payment-pending {
  border: 1px solid #9c1c1c;
  background: #b42318;
  color: #ffffff;
}

.payment-status-btn.payment-paid {
  border: 1px solid #bfe3d4;
  background: #e8f4ef;
  color: var(--green-dark);
}

.payment-status-btn[disabled] {
  opacity: 0.6;
}

.payment-status-btn.payment-offset {
  border: 1px solid #d9d9d9;
  background: #f5f5f5;
  color: #8c8c8c;
}

.purchased-row-actions {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  align-items: center;
}

.purchased-row-actions .reopen-mini,
.purchased-row-actions .danger-mini {
  min-width: 0;
  min-height: 32px;
  padding: 0 3px;
  border-radius: 6px;
  color: #fff;
  font-size: 11px;
}

.purchased-row-actions .danger-mini {
  background: #b3261e;
}

@media (max-width: 720px) {
  .inventory-add-grid.inventory-add-grid-two-row {
    grid-template-columns: minmax(0, 1.25fr) minmax(52px, 0.65fr) minmax(52px, 0.65fr) minmax(52px, 0.65fr) minmax(52px, 0.65fr);
  }
}

@media (min-width: 1100px) {
  .inventory-add-grid.inventory-add-grid-two-row {
    grid-template-columns: minmax(240px, 1.35fr) 100px 100px 100px 100px;
  }
  .purchased-table .table-row {
    grid-template-columns: minmax(180px, 1fr) 170px 90px 90px 90px 90px 90px 90px 90px 120px minmax(80px, 0.8fr);
  }
}

/* ── 通用管理页弹窗 ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay.hidden { display: none; }

.manage-confirm-message {
  margin: 0;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
}
.modal-panel {
  background: var(--bg-panel, #fff); border-radius: 8px;
  max-width: 380px; width: calc(100vw - 32px); max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.modal-panel header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border, #e0e0e0);
}
.modal-panel .close-btn {
  background: none; border: none; font-size: 1.3rem; cursor: pointer; padding: 0 4px; line-height: 1;
}
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal-body label { display: block; margin-bottom: 10px; font-size: 0.92rem; }
.modal-body input, .modal-body select {
  width: 100%; padding: 6px 8px; margin-top: 2px;
  border: 1px solid var(--border, #ccc); border-radius: 4px;
  font-size: 0.92rem;
}
.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 10px 16px; border-top: 1px solid var(--border, #e0e0e0);
}
.modal-footer button {
  padding: 6px 16px; border-radius: 4px; font-size: 0.92rem; cursor: pointer;
}
.modal-footer .light-btn { background: var(--bg-light, #f0f0f0); border: 1px solid var(--border, #ccc); }

/* ── 管理页表格操作按钮 ── */
.manage-action-btn {
  padding: 2px 8px; font-size: 0.82rem; border-radius: 3px;
  border: 1px solid var(--border, #ccc); background: var(--bg-panel, #fff); cursor: pointer;
  color: var(--green); font-weight: 700;
  margin-right: 4px;
}
.manage-action-btn:hover { background: var(--bg-hover, #e8f4fd); }
.manage-action-btn.danger { color: #c0392b; border-color: #e74c3c; }

/* ── 管理页卡片布局 ── */

.manage-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.manage-view.hidden { display: none; }

.manage-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  overflow: hidden;
}

.manage-card-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--green-soft);
}

.manage-card-bar strong {
  flex: 1;
  font-size: 16px;
  color: var(--green);
}

.manage-card-bar input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  font-size: 14px;
  text-align: left;
}

.manage-card-bar select {
  height: 34px;
  padding: 0 6px;
  font-size: 13px;
  font-weight: 800;
}

.manage-card-bar button {
  height: 34px;
  padding: 0 10px;
  white-space: nowrap;
  font-size: 13px;
}

.manage-card > .data-table {
  border: none;
  border-radius: 0;
}

.manage-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-top: 1px solid var(--line);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.customer-detail-summary {
  display: flex;
  gap: 14px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.customer-history-list {
  display: grid;
  max-height: min(48vh, 360px);
  overflow-y: auto;
  border-top: 1px solid var(--line);
}

.customer-history-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(90px, 1fr) auto;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
}

.customer-history-row span:last-child {
  white-space: nowrap;
  color: var(--muted);
}

/* 管理页表格列宽 */
#product-manage-view .data-table .table-row {
  grid-template-columns: minmax(54px, 0.8fr) minmax(46px, 0.9fr) minmax(42px, 0.8fr) 42px 62px;
}

/* H5 端隐藏来源列 */
@media (max-width: 640px) {
  #product-manage-view .data-table .table-row {
    grid-template-columns: minmax(56px, 1fr) 60px 80px 58px;
  }
  #product-manage-view .data-table .table-row > span:nth-child(4) {
    display: none;
  }
}
#logistics-manage-view .data-table .table-row {
  grid-template-columns: minmax(68px, 1fr) minmax(48px, 0.8fr) 38px 60px;
}
#customer-manage-view .data-table .table-row {
  grid-template-columns: minmax(112px, 1.2fr) 90px 78px minmax(118px, 1.1fr) 72px 64px;
}
#permission-manage-view .data-table .table-row {
  grid-template-columns: minmax(36px, 0.8fr) minmax(56px, 1fr) 38px 34px 38px 58px;
}

@media (min-width: 641px) {
  #product-manage-view .data-table .table-row {
    grid-template-columns: minmax(84px, 0.75fr) minmax(88px, 0.9fr) minmax(96px, 0.75fr) 88px 112px;
  }
  #logistics-manage-view .data-table .table-row {
    grid-template-columns: minmax(140px, 1fr) minmax(120px, 0.8fr) 68px 140px;
  }
  #customer-manage-view .data-table .table-row {
    grid-template-columns: minmax(148px, 1.2fr) 112px 110px minmax(180px, 1.5fr) 96px 72px;
  }
  #permission-manage-view .data-table .table-row {
    grid-template-columns: minmax(110px, 0.8fr) minmax(140px, 1fr) 76px 58px 70px 150px;
  }
}

/* 管理页表格通用：去掉多余边框 */
.manage-card .table-row {
  border-bottom: 1px solid var(--line);
}
.manage-card .table-row:last-child {
  border-bottom: 0;
}
.manage-card .table-head {
  background: #edf5f2;
}

/* 客户管理采用独立的紧凑资料列表，避免复用通用表格的粗重文字与窄列。 */
#customer-manage-view .manage-card {
  border-color: #d5e5de;
  box-shadow: 0 8px 20px rgba(21, 86, 65, 0.06);
}

#customer-manage-view .customer-manage-heading {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
}

#customer-manage-view .customer-manage-title {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

#customer-manage-view .manage-card-bar {
  padding: 10px 12px;
  background: #f6faf8;
}

#customer-manage-view .manage-card-bar select {
  width: 84px;
  color: var(--text);
  background: var(--white);
}

#customer-manage-view .manage-action-btn {
  min-width: 42px;
  margin-right: 0;
  white-space: nowrap;
}

#customer-manage-view .table-row {
  min-height: 48px;
}

#customer-manage-view .table-head {
  min-height: 38px;
}

#customer-manage-view .table-head > span {
  padding: 0 8px;
  color: #527568;
  font-size: 12px;
  font-weight: 800;
}

#customer-manage-lines .table-row > span {
  padding: 0 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

#customer-manage-lines .customer-name-cell {
  min-width: 0;
  color: #173d30;
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#customer-manage-lines .customer-phone-cell,
#customer-manage-lines .customer-code-cell,
#customer-manage-lines .customer-last-order-cell,
#customer-manage-lines .table-row > span:last-child {
  justify-content: center;
  text-align: center;
}

#customer-manage-lines .customer-code-cell,
#customer-manage-lines .customer-last-order-cell {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

#customer-manage-lines .customer-phone-cell {
  white-space: nowrap;
}

#customer-manage-lines .customer-address-cell {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#customer-manage-lines .customer-address-mobile {
  display: none;
}

/* ── 移动端表格列宽适配：压缩列宽，避免右侧列被裁剪成空白 ── */
@media (max-width: 640px) {
  .add-line-form {
    grid-template-columns: minmax(65px, 1fr) 46px 78px minmax(48px, 0.5fr);
    gap: 4px;
  }

  .customer-table .table-row {
    min-width: 620px;
    grid-template-columns: 24px minmax(34px, 0.62fr) 32px 34px 38px 54px minmax(48px, 1fr) 86px 90px 30px;
  }

  /* 客户订单列表移动端：列宽加大后超出屏宽时横向拖拽滚动 */
  .customer-table {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .customer-table::-webkit-scrollbar {
    height: 6px;
  }
  .customer-table::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.06);
  }
  .customer-table::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.28);
    border-radius: 3px;
  }

  /* 批次号字体比正文小一号（需 !important 压过 @media (max-width:720px) 的 16px !important） */
  .customer-table input[data-customer-edit="batchCode"],
  .customer-table textarea[data-customer-edit="batchCode"] {
    font-size: 12px !important;
  }

  .pending-table .table-row {
    grid-template-columns: minmax(48px, 1fr) 40px 46px minmax(56px, 1fr) 32px 84px minmax(40px, 0.6fr);
  }

  .purchased-table .table-row {
    min-width: 464px;
    grid-template-columns: minmax(54px, 1fr) minmax(83px, 0.9fr) 40px 40px 40px 40px 40px 50px 52px 100px minmax(40px, 0.6fr);
  }

  .loss-table .table-row {
    grid-template-columns: minmax(44px, 1fr) 83px 30px 32px 34px 52px 114px minmax(120px, 2.4fr);
  }

  /* 报损表移动端：超出宽度时支持横向拖拽滚动 */
  .loss-table {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .loss-table::-webkit-scrollbar {
    height: 6px;
  }
  .loss-table::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.06);
  }
  .loss-table::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.28);
    border-radius: 3px;
  }

  .pending-actions {
    gap: 2px;
  }

  .pending-actions .stock-mini,
  .pending-actions .done-mini {
    min-height: 30px;
    padding: 0 5px;
    font-size: 11px;
  }

  .group-add-grid.group-add-grid-auto {
    grid-template-columns: minmax(0, 1.6fr) minmax(46px, 0.55fr) minmax(46px, 0.55fr) minmax(78px, 1fr) 52px;
  }

  .group-customer-action-row {
    grid-template-columns: minmax(0, 1fr) 66px;
    gap: 4px;
  }

  #group-view .smart-add-row {
    grid-template-columns: minmax(0, 1fr) 40px 54px;
    gap: 4px;
  }

  .inventory-table .table-row,
  .inventory-table .inventory-grass-row {
    min-width: 620px;
  }

  /* 移动端隐藏库存“付款”列，电脑端显示；列宽同步去掉付款轨道，剩余空间留给品种列 */
  .inventory-table .inventory-payment-head,
  .inventory-table .inventory-payment-cell {
    display: none;
  }

  /* 备注列调宽 30%：min 57×1.3≈74px；fr 校准为 1.62 —— 620px 行宽下实测渲染约 102px（原 78.6px，加宽约 30%）。若仅按 0.91×1.3=1.18 缩放 fr，受固定列挤压只加宽约 14% */
  .inventory-table .table-row {
    grid-template-columns: minmax(44px, 1.012fr) 60px 34px 34px 34px 34px 34px 34px 96px 48px 46px minmax(74px, 1.62fr);
  }

  .inventory-table .inventory-grass-row {
    grid-template-columns: minmax(44px, 1.012fr) 60px 34px 34px 34px 34px 34px 34px 96px 48px 46px minmax(74px, 1.62fr);
  }
}

/* ── 手机/平板端：主内容区改为页面整体滚动，避免嵌套滚动容器划不到底部 ── */
@media (max-width: 899px) {
  #app-shell {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .view-panel {
    flex: none;
    min-height: 0;
    overflow: visible;
  }
}

@media (max-width: 640px) {
  #customer-manage-view .customer-manage-heading {
    min-height: 46px;
    padding: 0 10px;
  }

  #customer-manage-view .customer-manage-title {
    font-size: 16px;
  }

  #customer-manage-view .manage-card-bar {
    gap: 5px;
    padding: 8px;
  }

  #customer-manage-view .manage-card-bar select {
    width: 76px;
    padding: 0 4px;
    font-size: 12px;
  }

  #customer-manage-view .manage-card-bar button {
    padding: 0 8px;
  }

  #customer-manage-view .data-table .table-row {
    grid-template-columns: minmax(122px, 1.1fr) minmax(110px, 1fr) 64px;
  }

  #customer-manage-view .data-table .table-row > span:nth-child(2),
  #customer-manage-view .data-table .table-row > span:nth-child(3),
  #customer-manage-view .data-table .table-row > span:nth-child(5) {
    display: none;
  }

  #customer-manage-lines .table-row > span {
    padding: 0 6px;
  }

  #customer-manage-lines .customer-name-cell {
    font-size: 13px;
  }

  #customer-manage-lines .customer-address-desktop {
    display: none;
  }

  #customer-manage-lines .customer-address-mobile {
    display: block;
    color: var(--muted);
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (min-width: 641px) {
  .packing-table .table-row {
    grid-template-columns: minmax(120px, 1fr) minmax(60px, 96px) minmax(70px, 110px) minmax(60px, 88px) minmax(120px, 180px) 64px;
    padding-right: 0;
  }

  .packing-table .packing-delete-head {
    display: grid;
  }

  .packing-table .table-row .swipe-delete-btn {
    position: static;
    width: 100%;
    height: 100%;
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  body.spatial-keyboard-navigation :is(button, input, textarea, select):focus {
    outline: 3px solid #0f7d61;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px #fff;
  }
}

/* ───────── 客户预付款行（客户总单 / 群录单 总计下方） ───────── */

.customer-payment-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 7px 12px;
  background: #edf5f2;
  border-top: 1px solid #d3e2d9;
  font-size: 13px;
}

.customer-table .customer-payment-row > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  white-space: nowrap;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
}

.customer-payment-row .total-label,
.customer-payment-row .customer-payment-caption {
  color: #0f7d61;
}

.customer-table .customer-payment-row > input.customer-payment-input {
  width: 88px;
  height: auto;
  min-height: 0;
  align-self: auto;
  padding: 4px 8px;
  border: 1px solid #c5d8ca;
  border-radius: 5px;
  background: #fff;
  justify-items: stretch;
  text-align: right;
  font-size: 13px;
  font-weight: 700;
}

/* ───────── 财务管理 · 客户资金 ───────── */

.profit-funds-table .table-row {
  grid-template-columns: minmax(84px, 1fr) repeat(5, minmax(50px, 0.55fr)) 104px;
}

.profit-funds-table .table-row > span {
  font-size: 12px;
}

/* 欠款已结清（<=0）时金额显示为绿色 */
.ok-balance {
  color: #12a46f;
}

.profit-funds-actions {
  display: grid;
  gap: 3px;
  justify-items: stretch;
  padding: 4px 3px;
}

.profit-funds-detail-btn,
.profit-funds-collect-btn,
.profit-funds-waive-btn {
  min-height: 24px;
  padding: 0 4px;
  border: 1px solid #c8d9ee;
  border-radius: 5px;
  background: #fff;
  color: #2a5db0;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.profit-funds-collect-btn {
  border-color: #b9d8c8;
  background: #eef8f2;
  color: var(--green-dark);
}

.profit-funds-waive-btn {
  border-color: #e8c8b0;
  background: #fdf3ec;
  color: #b0632a;
}

/* 点回款弹框 */
.profit-funds-pay-popup {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 16px;
  background: rgba(15, 35, 29, 0.42);
}

.profit-funds-pay-popup-panel {
  display: grid;
  width: min(320px, 100%);
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  box-shadow: 0 18px 42px rgba(15, 35, 29, 0.26);
}

.profit-funds-pay-popup-panel > strong {
  font-size: 16px;
  text-align: center;
}

.profit-funds-pay-popup-panel input {
  height: 42px;
  padding: 0 10px;
  font-size: 18px;
  text-align: center;
}

.profit-funds-pay-popup-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
}

.profit-funds-pay-popup-actions button {
  height: 42px;
}

.profit-funds-pay-popup-actions .light-btn {
  border: 1px solid var(--line);
}

/* 历史订单表：日期/来源/数量/订单金额/欠款 */
.profit-funds-order-table .profit-sheet-row {
  grid-template-columns: minmax(88px, 1fr) 62px 46px 70px 74px;
}

/* 付款记录表：日期/类型/金额/收款人/方式/备注/操作 */
.profit-funds-payment-table .profit-sheet-row {
  grid-template-columns: 84px 50px 70px 80px 58px minmax(0, 1fr) 44px;
}

.payment-type-tag {
  display: inline-block;
  min-width: 34px;
  padding: 2px 4px;
  border-radius: 999px;
  background: #e8f4ef;
  color: var(--green-dark);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
}

.payment-type-tag.payment-type-collection {
  background: #eaf0ff;
  color: #2a5db0;
}

.payment-type-tag.payment-type-waive {
  background: #fdf3ec;
  color: #b0632a;
}

/* 统计卡片区：已抹零提示 */
.profit-waive-summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid #e8c8b0;
  border-radius: 8px;
  background: #fdf3ec;
  color: #8a5a2a;
  font-size: 12px;
}

.profit-waive-summary b {
  color: #b0632a;
}

.profit-funds-pay-form {
  display: grid;
  grid-template-columns: 92px repeat(3, minmax(0, 1fr)) auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 10px;
  padding: 9px;
  border: 1px dashed #c8d9ee;
  border-radius: 8px;
  background: #f8fbff;
}

.profit-funds-pay-form input,
.profit-funds-pay-form select {
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid #c8d9ee;
  border-radius: 5px;
  font-size: 13px;
}

.profit-funds-pay-form button {
  padding: 6px 12px;
  border: 0;
  border-radius: 5px;
  background: #2a5db0;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.profit-sheet-empty {
  grid-column: 1 / -1;
  color: #85938e;
  font-size: 12px;
  padding: 12px;
}

/* ───────── 仓库管理（纸箱型号 / 纸箱统计 / 物流公司） ───────── */

.manage-sub-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin: 8px 0;
  padding: 4px;
  border-radius: 7px;
  background: #dfeae6;
}

.manage-sub-tabs button {
  height: 36px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #496159;
  font-size: 13px;
  font-weight: 900;
}

.manage-sub-tabs button.active {
  background: var(--white);
  color: var(--green);
  box-shadow: 0 1px 4px rgba(16, 35, 29, 0.12);
}

.carton-model-edit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 60px 60px;
  gap: 6px;
  margin-bottom: 8px;
  padding: 8px;
  border: 1px dashed #b7d0c6;
  border-radius: 8px;
  background: #f4faf7;
}

.carton-model-edit-row input {
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid #b7d0c6;
  border-radius: 5px;
  font-size: 13px;
}

.carton-model-edit-row button {
  padding: 6px 8px;
  border: 0;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 700;
}

.carton-model-edit-row button:first-of-type {
  background: var(--green);
  color: #fff;
}

/* ───────── 纸箱统计 ───────── */

.carton-stats-mode {
  display: inline-flex;
  gap: 4px;
  margin: 8px 8px 12px;
  padding: 3px;
  border-radius: 9px;
  background: #eef1f4;
}

.carton-stats-mode button {
  padding: 6px 18px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #5b6670;
  font-size: 13px;
  font-weight: 700;
}

.carton-stats-mode button.active {
  background: #d8f0e3;
  color: var(--green);
  box-shadow: 0 1px 3px rgba(15, 90, 64, 0.18);
}

.carton-stats-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 0 8px 14px;
}

.carton-stats-stat {
  padding: 14px 12px;
  border: 1px solid #d6ecdf;
  border-radius: 12px;
  background: linear-gradient(160deg, #f2fbf7, #e7f5ef);
  text-align: center;
}

.carton-stats-stat span {
  display: block;
  color: #5a7a6e;
  font-size: 12px;
  font-weight: 700;
}

.carton-stats-stat strong {
  display: block;
  margin-top: 6px;
  color: #12875c;
  font-size: 20px;
  font-weight: 900;
}

/* 物流清单（待交货 / 已交货） */
#logistics-sheet-lines .logistics-sheet-row,
#logistics-sheet-lines .logistics-sheet-head {
  grid-template-columns: 64px 104px minmax(110px, 1fr) 92px 86px 78px 96px 96px minmax(80px, 0.8fr);
}
#logistics-sheet-lines .logistics-sheet-head {
  background: #e8f3ee;
  color: #0f7d61;
  font-size: 12px;
  font-weight: 850;
}
#logistics-sheet-lines .logistics-sheet-head > span {
  white-space: nowrap;
}
#logistics-sheet-lines .logistics-sheet-row > span {
  font-weight: 650;
}
#logistics-sheet-lines .logistics-sheet-row > span small {
  display: block;
  color: #8a97a0;
  font-size: 11px;
  font-weight: 600;
}
.logistics-carton-cell {
  cursor: pointer;
  width: 100%;
  min-height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 13px;
  font-weight: 650;
  text-align: left;
}
.logistics-carton-cell:empty::after {
  content: '点击选择';
  color: #aeb8bf;
  font-size: 12px;
  font-weight: 600;
}
.logistics-freight-text {
  cursor: pointer;
  width: 100%;
  min-height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}
.logistics-freight-text:empty::after {
  content: '点击输入';
  color: #aeb8bf;
  font-size: 12px;
  font-weight: 600;
}
.logistics-sheet-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: #eef6f2;
  border-bottom: 1px solid var(--line);
  color: #0f7d61;
  font-size: 13px;
  font-weight: 850;
}
.logistics-sheet-group-head + .logistics-sheet-group-head {
  border-top: 1px solid var(--line);
}
.logistics-freight-cell {
  gap: 4px;
}
.logistics-freight-input {
  width: 58px;
  height: 30px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
.logistics-freight-input:focus {
  outline: 2px solid #9fd8c4;
  border-color: #0f7d61;
}
.logistics-carton-btn,
.logistics-deliver-btn {
  padding: 4px 10px;
  border: 0;
  border-radius: 7px;
  background: #0f7d61;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.logistics-carton-btn {
  background: #eef6f2;
  color: #0f7d61;
}
.logistics-sheet-row.delivered {
  opacity: 0.72;
}
.logistics-sheet-row.delivered .logistics-deliver-btn,
.logistics-sheet-row.delivered .logistics-carton-btn {
  pointer-events: none;
}

.carton-stats-block {
  margin: 0 8px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.carton-stats-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
}

.carton-stats-block-head strong {
  font-size: 14px;
  color: #23303a;
}

.carton-stats-block-head span {
  font-size: 12px;
  color: #8a969f;
}

.carton-stats-block .data-table {
  border: 0;
  border-radius: 0;
}

/* ───────── 纸箱型号选择弹窗 ───────── */

.carton-picker-panel {
  width: 420px;
}

.carton-picker-customer {
  padding: 6px 8px;
  margin-bottom: 6px;
  border-radius: 6px;
  background: #f2f7ff;
  color: #2a5db0;
  font-size: 13px;
  font-weight: 900;
}

.carton-picker-list {
  display: grid;
  gap: 5px;
  max-height: 40vh;
  overflow-y: auto;
  margin-bottom: 8px;
}

.carton-picker-model-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  text-align: left;
}

.carton-picker-model-item.current {
  border-color: #2a5db0;
  background: #f2f7ff;
}

.carton-picker-model-item small {
  color: #85938e;
  font-size: 11px;
}

.carton-picker-new {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px auto;
  gap: 5px;
}

.carton-picker-new input {
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 13px;
}

.carton-picker-new button {
  padding: 6px 12px;
  border: 0;
  border-radius: 5px;
  background: var(--green);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.carton-picker-qty {
  padding: 8px 0;
  text-align: center;
}

.carton-picker-qty strong {
  display: block;
  font-size: 16px;
}

.carton-picker-qty > span {
  display: block;
  margin-top: 2px;
  color: #85938e;
  font-size: 12px;
}

.carton-picker-qty-control {
  display: grid;
  grid-template-columns: 44px 96px 44px;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-top: 12px;
}

.carton-picker-qty-control button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 18px;
  font-weight: 900;
}

.carton-picker-qty-control input {
  height: 40px;
  border: 1px solid #2a5db0;
  border-radius: 8px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
}

.carton-picker-qty-hint {
  margin-top: 8px;
  color: #85938e;
  font-size: 11px;
}

.carton-picker-qty-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.carton-picker-qty-actions button {
  padding: 9px 12px;
  border: 0;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
}

.carton-picker-qty-actions button:last-child {
  background: #2a5db0;
  color: #fff;
}

@media (max-width: 640px) {
  .profit-funds-pay-form {
    grid-template-columns: 1fr 1fr;
  }
  .carton-stats-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
