/* Desktop A-style organization for materials, purchases, company assets and later support pages. */
@media (min-width: 769px) {
  body.pc-ui-preview .a-operation-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
    gap: 16px;
    margin-top: 18px;
    padding: 18px;
    border: 1px solid #d7e3f4;
    border-radius: 12px;
    background: #fbfdff;
  }

  body.pc-ui-preview .a-operation-field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 7px;
    color: #405572;
    font-size: 12px;
    font-weight: 700;
  }

  body.pc-ui-preview .a-operation-field > input,
  body.pc-ui-preview .a-operation-field > select,
  body.pc-ui-preview .a-operation-field > textarea {
    width: 100%;
    min-width: 0;
    margin: 0;
    color: #172b4d;
    font-weight: 400;
  }

  body.pc-ui-preview .a-operation-field:has(> .hidden) {
    display: none;
  }

  body.pc-ui-preview .a-operation-form > .search-select,
  body.pc-ui-preview .a-operation-form > .purchase-voucher-field {
    min-width: 0;
  }

  body.pc-ui-preview .a-operation-form > .search-select input {
    width: 100%;
    min-width: 0;
  }

  body.pc-ui-preview .a-operation-caption {
    display: block;
    margin-bottom: 7px;
    color: #405572;
    font-size: 12px;
    font-weight: 700;
  }

  body.pc-ui-preview .material-return-summary,
  body.pc-ui-preview .a-operation-form > .form-static-field {
    grid-column: 1 / -1;
  }

  body.pc-ui-preview #materialEditForm.a-operation-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.pc-ui-preview .a-operation-submit {
    justify-self: end;
    grid-column: 1 / -1;
    min-width: 136px;
  }

  body.pc-ui-preview #material-stock-table-section,
  body.pc-ui-preview #purchaseTableAnchor,
  body.pc-ui-preview .a-asset-panel {
    border-color: #d8e3f1;
    box-shadow: 0 4px 18px rgba(27, 52, 87, 0.04);
  }

  body.pc-ui-preview .material-jump-nav .open-inventory-counts {
    width: auto;
    flex: 0 0 auto;
    padding: 5px 10px;
  }

  body.pc-ui-preview #material-stock-table-section .material-inventory-table {
    width: 100%;
    min-width: 780px;
    table-layout: fixed;
  }

  body.pc-ui-preview .material-a-table-scroll {
    max-width: 100%;
    overflow-x: auto;
  }

  body.pc-ui-preview .material-a-detail {
    max-width: 100%;
    margin-top: 14px;
    padding: 16px;
    border: 1px solid #c9dafa;
    border-radius: 12px;
    background: #f8fbff;
    overflow: hidden;
  }

  body.pc-ui-preview #material-stock-table-section .material-inventory-table th,
  body.pc-ui-preview #material-stock-table-section .material-inventory-table td {
    width: auto;
    vertical-align: middle;
  }

  body.pc-ui-preview #material-stock-table-section .material-inventory-table th:nth-child(1) { width: 24%; }
  body.pc-ui-preview #material-stock-table-section .material-inventory-table th:nth-child(2) { width: 16%; }
  body.pc-ui-preview #material-stock-table-section .material-inventory-table th:nth-child(3) { width: 15%; }
  body.pc-ui-preview #material-stock-table-section .material-inventory-table th:nth-child(4) { width: 13%; }
  body.pc-ui-preview #material-stock-table-section .material-inventory-table th:nth-child(5) { width: 17%; }
  body.pc-ui-preview #material-stock-table-section .material-inventory-table th:nth-child(6) { width: 15%; }
  body.pc-ui-preview #material-stock-table-section .material-action-group { flex-wrap: wrap; }

  body.pc-ui-preview .purchase-a-shell .purchase-overview-cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    border: 1px solid #d8e3f1;
    border-radius: 8px;
    background: #fff;
  }

  body.pc-ui-preview .purchase-a-shell .purchase-overview-cards > * {
    margin: 0;
    border: 0;
    border-right: 1px solid #d8e3f1;
    border-radius: 0;
    box-shadow: none;
  }

  body.pc-ui-preview .purchase-a-shell .purchase-overview-cards > *:last-child { border-right: 0; }

  body.pc-ui-preview .purchase-a-shell .purchase-list-table {
    width: 100%;
    min-width: 1060px;
    table-layout: fixed;
  }

  body.pc-ui-preview .purchase-a-shell .purchase-list-table th,
  body.pc-ui-preview .purchase-a-shell .purchase-list-table td {
    width: auto !important;
    min-width: 0;
    vertical-align: middle;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  body.pc-ui-preview .purchase-a-shell .purchase-list-table th:nth-child(1) { width: 18% !important; }
  body.pc-ui-preview .purchase-a-shell .purchase-list-table th:nth-child(2) { width: 15% !important; }
  body.pc-ui-preview .purchase-a-shell .purchase-list-table th:nth-child(3) { width: 11% !important; }
  body.pc-ui-preview .purchase-a-shell .purchase-list-table th:nth-child(4) { width: 11% !important; }
  body.pc-ui-preview .purchase-a-shell .purchase-list-table th:nth-child(5) { width: 11% !important; }
  body.pc-ui-preview .purchase-a-shell .purchase-list-table th:nth-child(6) { width: 15% !important; }
  body.pc-ui-preview .purchase-a-shell .purchase-list-table th:nth-child(7) { width: 8% !important; }
  body.pc-ui-preview .purchase-a-shell .purchase-list-table th:nth-child(8) { width: 11% !important; }
  body.pc-ui-preview .purchase-a-shell .purchase-table-action-group { flex-wrap: wrap; }
  body.pc-ui-preview .purchase-a-shell .purchase-a-amount { font-weight: 700; color: #17365c; }
  body.pc-ui-preview .purchase-a-shell .purchase-list-table th:last-child,
  body.pc-ui-preview .purchase-a-shell .purchase-list-table tbody tr[data-row-id] > td:last-child {
    position: sticky;
    right: 0;
    z-index: 1;
    background: #fff;
    box-shadow: -6px 0 12px rgba(27, 52, 87, 0.06);
  }

  body.pc-ui-preview .purchase-a-detail {
    margin-top: 14px;
    padding: 18px;
    border: 1px solid #c9dafa;
    border-radius: 12px;
    background: #f8fbff;
  }

  body.pc-ui-preview #purchaseCreatePanel .purchase-form-grid > .purchase-voucher-field,
  body.pc-ui-preview #purchaseCreatePanel #purchaseVoucherPreview {
    grid-column: 1 / -1;
  }

  body.pc-ui-preview #purchaseCreatePanel .purchase-form-grid > .purchase-voucher-field {
    padding: 10px 12px;
    border: 1px solid #d7e3f4;
    border-radius: 8px;
    background: #fff;
  }

  body.pc-ui-preview .a-asset-panel > h3 { display: inline-block; margin-right: 12px; }
  body.pc-ui-preview .a-asset-form-toggle { vertical-align: middle; }
  body.pc-ui-preview #fixedAssetEditModal { z-index: 110; }
  body.pc-ui-preview #purchaseActionModal,
  body.pc-ui-preview #purchaseVoucherModal { z-index: 110; }
  body.pc-ui-preview #purchaseActionModal .purchase-action-dialog-card {
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    box-sizing: border-box;
  }
  body.pc-ui-preview #purchaseForm > .payable-validation {
    grid-column: 1 / -1;
    margin: 0;
  }
  body.pc-ui-preview #fixedAssetEditModal .edit-modal-card { width: min(94vw, 960px); min-width: 0; }
}

/* 手机端：库存和采购表保持在独立滚动容器内，录入表单改为单列。 */
@media (max-width:768px) {
  .a-operation-form,
  #materialEditForm.a-operation-form,
  .purchase-form-grid,
  .purchase-a-shell,
  .purchase-a-shell > section,
  .a-asset-panel {
    min-width:0;
    max-width:100%;
    box-sizing:border-box;
  }

  .a-operation-form,
  #materialEditForm.a-operation-form,
  .purchase-form-grid { grid-template-columns:minmax(0,1fr)!important; }
  .a-operation-form > *,
  .purchase-form-grid > * { grid-column:1 / -1!important; min-width:0; max-width:100%; }
  .a-operation-form input,
  .a-operation-form select,
  .a-operation-form textarea,
  .purchase-form-grid input,
  .purchase-form-grid select,
  .purchase-form-grid textarea { width:100%; max-width:100%; box-sizing:border-box; }
  .a-operation-submit { width:100%; justify-self:stretch; }

  .material-filter-strip,
  .purchase-a-shell .purchase-filter-strip,
  .purchase-a-shell .purchase-a-advanced {
    grid-template-columns:minmax(0,1fr)!important;
    min-width:0;
  }
  .material-filter-strip > *,
  .purchase-a-shell .purchase-filter-strip > *,
  .purchase-a-shell .purchase-a-advanced > * { min-width:0; width:100%; max-width:100%; box-sizing:border-box; }
  .material-jump-nav,
  .material-action-group,
  .purchase-table-action-group,
  .purchase-detail-related-actions { display:flex; flex-wrap:wrap; gap:6px; min-width:0; }
  .material-jump-nav > button,
  .material-action-group > button,
  .purchase-table-action-group > button,
  .purchase-detail-related-actions > button { width:auto; max-width:100%; margin:0; }

  #material-stock-table-section,
  #material-usage-table-section,
  #material-return-table-section,
  .purchase-a-shell #purchaseTableAnchor { min-width:0; max-width:100%; overflow:hidden; }
  /* 领用和归还记录的旧模板没有额外 table-scroll，直接让区块承载横向滚动。 */
  #material-usage-table-section,
  #material-return-table-section { overflow-x:auto; overflow-y:hidden; }
  #material-stock-table-section .material-a-table-scroll,
  #material-stock-table-section .table-scroll,
  #material-flow-section .table-scroll,
  #material-usage-table-section .table-scroll,
  #material-return-table-section .table-scroll,
  .purchase-a-shell .purchase-table-scroll,
  .purchase-a-shell .table-scroll {
    display:block;
    width:100%;
    max-width:100%;
    overflow-x:auto;
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
  }
  #material-stock-table-section .material-inventory-table,
  #material-stock-table-section .material-a-table-scroll > table,
  #material-flow-section .material-flow-table,
  #material-usage-table-section table,
  #material-return-table-section table,
  .purchase-a-shell .purchase-list-table {
    width:760px;
    min-width:760px;
    table-layout:fixed;
  }
  #material-stock-table-section th,
  #material-stock-table-section td,
  #material-flow-section th,
  #material-flow-section td,
  #material-usage-table-section th,
  #material-usage-table-section td,
  #material-return-table-section th,
  #material-return-table-section td,
  .purchase-a-shell .purchase-list-table th,
  .purchase-a-shell .purchase-list-table td { white-space:normal; overflow-wrap:anywhere; }

  .purchase-a-shell .purchase-overview-cards { grid-template-columns:repeat(2,minmax(0,1fr)); min-width:0; }
  .purchase-a-shell .purchase-overview-cards > * { min-width:0; }
  .purchase-a-shell .purchase-action-card,
  .purchase-a-shell .purchase-a-detail,
  .material-a-detail { min-width:0; max-width:100%; overflow-wrap:anywhere; }
  #fixedAssetEditModal .edit-modal-card,
  #purchaseActionModal .purchase-action-dialog-card,
  #purchaseVoucherModal .purchase-voucher-dialog-card { width:calc(100vw - 24px); max-width:calc(100vw - 24px); min-width:0; box-sizing:border-box; }
}

@media (min-width: 769px) and (max-width: 1199px) {
  body.pc-ui-preview .a-operation-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.pc-ui-preview .purchase-a-shell .purchase-overview-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.pc-ui-preview .purchase-a-shell .purchase-filter-strip {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(138px, 0.5fr) auto auto;
    gap: 8px;
  }
  body.pc-ui-preview .purchase-a-shell .purchase-filter-strip > * { min-width: 0; width: 100%; }
  body.pc-ui-preview .purchase-a-shell .purchase-a-advanced:not(.is-open) { display: none; }
  body.pc-ui-preview .purchase-a-shell #purchaseAdvancedToggle { white-space: nowrap; }
}

@media (min-width: 1200px) {
  body.pc-ui-preview .purchase-a-shell #purchaseAdvancedToggle { display: none; }
}

@media (min-width: 1200px) and (max-width: 1499px) {
  body.pc-ui-preview .purchase-a-shell .purchase-filter-strip {
    grid-template-columns: minmax(200px, 1.4fr) repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 769px) and (max-width: 950px) {
  body.pc-ui-preview .purchase-a-shell .purchase-filter-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.pc-ui-preview .purchase-a-shell #purchaseTableKeyword { grid-column: 1 / -1; }
}
/* Procurement detail actions stay compact beside the business details. */
@media (min-width: 769px) {
  body.pc-ui-preview .purchase-detail-related-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
  body.pc-ui-preview .purchase-detail-related-actions > button { width: auto; margin: 0; }
}
