/* Main query lists share the sales/inquiry table spacing. Keep this scoped to
   query shells: detail tables, pickers, import previews and settings are separate. */
:root {--query-list-gutter:16px;--query-list-section-gap:8px;}
@media screen and (max-width:768px) {
  :root {--query-list-gutter:10px;}
}

/* A single middle panel owns the space around the toolbar and results. */
:is(#page-inquiry-query .inquiry-query-shell,
    #page-comparison-query>.comparison-query-shell,
    #page-quotation-query>.comparison-query-shell,
    .huihuang-query-page>.huihuang-query-shell,
    .wuxi-m7-query-page>.huihuang-query-shell,
    .jn-sap-page>.jn-sap-shell,
    .jn-archive-query-page>.jn-archive-shell,
    .invoice-data-query:not(.invoice-data-query-embedded),
    :is(#page-order-procurement-requisitions,#page-order-procurement-applications)>.op-shell,
    .wcr-report>.wcr-shell,
    #mainWrap .sales-document-query-page>.sales-document-query-shell,
    .sales-business-panel:has(>.sales-business-table-wrap,>.invoice-data-query-embedded,>.sales-business-comparison-query),
    #page-supplier-import-records>.supplier-invoice-page,
    #workbenchContent .wbt-panel,
    #page-batches>.card) {
  box-sizing:border-box;
  padding:var(--query-list-gutter);
  background:#fff;
  gap:var(--query-list-section-gap);
  min-width:0;
  min-height:0;
}

:is(#page-inquiry-query .inquiry-query-shell,
    #page-comparison-query>.comparison-query-shell,
    #page-quotation-query>.comparison-query-shell,
    .huihuang-query-page>.huihuang-query-shell,
    .wuxi-m7-query-page>.huihuang-query-shell,
    .jn-sap-page>.jn-sap-shell,
    .jn-archive-query-page>.jn-archive-shell,
    .invoice-data-query:not(.invoice-data-query-embedded),
    .wcr-report>.wcr-shell,
    .sales-document-query-page>.sales-document-query-shell)>.quotation-toolbar,
.sales-business-panel>.sales-business-toolbar,
:is(.sales-business-panel>.invoice-data-query-embedded,.sales-business-comparison-query>.comparison-query-embedded)>.sales-business-toolbar,
#workbenchContent .wbt-panel>.wbt-toolbar,
:is(#page-order-procurement-requisitions,#page-order-procurement-applications)>.op-shell>.op-toolbar {
  margin:0;
  padding:0;
}

:is(#page-inquiry-query .inquiry-query-scroll,
    #page-comparison-query>.comparison-query-shell>.comparison-query-scroll,
    #page-quotation-query>.comparison-query-shell>.comparison-query-scroll,
    .huihuang-query-page>.huihuang-query-shell>.huihuang-query-scroll,
    .wuxi-m7-query-page>.huihuang-query-shell>.huihuang-query-scroll,
    .jn-sap-page .jn-sap-results,
    .jn-archive-query-page>.jn-archive-shell>.jn-archive-list-scroll,
    .invoice-data-query:not(.invoice-data-query-embedded)>.invoice-data-table-wrap,
    :is(#page-order-procurement-requisitions,#page-order-procurement-applications)>.op-shell>.op-content>.op-table-scroll) {
  flex:1 1 0;
  height:0;
  min-width:0;
  min-height:0;
  margin:0;
  overflow:auto;
  border:0;
  border-radius:0;
}
.jn-sap-page>.jn-sap-shell>.jn-sap-results-frame {
  border:0;
  border-radius:0;
}

/* Embedded workspaces use the outer panel once, including when the list is nested. */
.sales-business-panel>.sales-business-table-wrap,
:is(.sales-business-panel>.invoice-data-query-embedded,.sales-business-comparison-query>.comparison-query-embedded)>:is(.invoice-data-table-wrap,.comparison-query-scroll) {
  margin:0;
}
:is(.sales-business-panel>.invoice-data-query-embedded,.sales-business-comparison-query>.comparison-query-embedded) {gap:var(--query-list-section-gap);}

/* The import history and review queue have their own query panels. */
#page-supplier-import-records {height:100%;min-height:0;overflow:hidden;}
#page-supplier-import-records>.supplier-invoice-page {
  box-sizing:border-box;
  height:100%;
  min-height:0;
  display:flex;
  flex-direction:column;
  overflow:hidden!important;
}
#page-supplier-import-records .invoice-route-heading {padding:0;margin:0;flex:none;}
#page-supplier-import-records .supplier-invoice-panel {
  flex:1 1 0;
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:var(--query-list-section-gap);
  margin:0;
  padding:0;
  border:0;
  border-radius:0;
}
#page-supplier-import-records .supplier-invoice-panel>.supplier-invoice-controls {margin:0;padding:0;flex:none;}
#page-supplier-import-records .supplier-invoice-panel>.supplier-invoice-controls:last-child {min-height:50px;box-sizing:border-box;}
#page-supplier-import-records .supplier-invoice-panel>.supplier-invoice-table {
  flex:1 1 0;
  height:0;
  min-height:0;
  margin:0;
  overflow:auto;
}
#workbenchContent .wbt-table-wrap,
#workbenchContent .wbt-panel>.wbt-message:not(:empty),
#workbenchContent .wbt-panel>.wbt-results {margin:0;}
#workbenchContent .wbt-table-wrap {border:0;}
#workbenchContent .wbt-message:empty {display:none;}

/* Price-history queries use static cards rather than a document query shell. */
#page-batches :is(.preview-table,#historyQueryResult>div:has(>#historyPriceTable)) {border:0;border-radius:0;overflow:auto;}
#page-batches :is(#historyPriceTable,#batchDetailTable) {border-collapse:separate;border-spacing:0;border:1px solid #cbd7e5;border-radius:5px;white-space:nowrap;}
#page-batches :is(#historyPriceTable,#batchDetailTable)>:is(thead,tbody)>tr>:is(th,td) {box-sizing:border-box;height:40px;padding:6px 11px;border-right:1px solid #d7e0eb;border-bottom:1px solid #e2e8f0;}
#page-batches :is(#historyPriceTable,#batchDetailTable)>tbody>tr:not(:has(>[colspan]))>:is(th,td) {height:43px;}
#page-batches :is(#historyPriceTable,#batchDetailTable)>:is(thead,tbody)>tr>:last-child {border-right:0;}
#page-batches :is(#historyPriceTable,#batchDetailTable)>tbody>tr:last-child>:is(th,td) {border-bottom:0;}

/* Align footer text with the list without changing its paging controls. */
:is(#page-inquiry-query .inquiry-query-footer,
    #page-comparison-query>.comparison-query-shell>.comparison-query-footer,
    #page-quotation-query>.comparison-query-shell>.comparison-query-footer,
    .huihuang-query-page>.huihuang-query-shell>.huihuang-query-footer,
    .wuxi-m7-query-page>.huihuang-query-shell>.huihuang-query-footer,
    .jn-sap-page .jn-sap-result-actions,
    .jn-archive-query-page>.jn-archive-shell>.jn-archive-footer,
    .invoice-data-query:not(.invoice-data-query-embedded)>.invoice-data-footer,
    .sales-business-panel>.sales-business-footer,
    :is(.sales-business-panel>.invoice-data-query-embedded,.sales-business-comparison-query>.comparison-query-embedded)>:is(.invoice-data-footer,.comparison-query-footer),
    :is(#page-order-procurement-requisitions,#page-order-procurement-applications)>.op-shell>.op-footer) {
  padding-inline:0;
}

@media screen and (min-width:769px) {
  :is(#inquiryListContainer>.oa-inquiry-query-table,
      #page-comparison-query .comparison-query-scroll>.comparison-query-table,
      #page-quotation-query .comparison-query-scroll>.comparison-query-table,
      .huihuang-query-page>.huihuang-query-shell>.huihuang-query-scroll>.huihuang-query-table,
      .wuxi-m7-query-page>.huihuang-query-shell>.huihuang-query-scroll>.huihuang-query-table,
      .jn-sap-page .jn-sap-results>.jn-sap-table,
      .jn-archive-query-page .jn-archive-list-scroll>.jn-archive-table,
      .invoice-data-query:not(.invoice-data-query-embedded) .invoice-data-table,
      :is(#page-order-procurement-requisitions,#page-order-procurement-applications)>.op-shell>.op-content>.op-table-scroll>.op-table,
      #page-supplier-import-records .supplier-invoice-panel>.supplier-invoice-table>table,
      #workbenchContent .wbt-table-wrap>.wbt-table) {
    border-collapse:separate;
    border-spacing:0;
    border:1px solid #cbd7e5;
    border-radius:5px;
  }
  :is(#inquiryListContainer>.oa-inquiry-query-table,
      #page-comparison-query .comparison-query-scroll>.comparison-query-table,
      #page-quotation-query .comparison-query-scroll>.comparison-query-table,
      .huihuang-query-page>.huihuang-query-shell>.huihuang-query-scroll>.huihuang-query-table,
      .wuxi-m7-query-page>.huihuang-query-shell>.huihuang-query-scroll>.huihuang-query-table,
      .jn-sap-page .jn-sap-results>.jn-sap-table,
      .jn-archive-query-page .jn-archive-list-scroll>.jn-archive-table,
      .invoice-data-query:not(.invoice-data-query-embedded) .invoice-data-table,
      :is(#page-order-procurement-requisitions,#page-order-procurement-applications)>.op-shell>.op-content>.op-table-scroll>.op-table,
      #page-supplier-import-records .supplier-invoice-panel>.supplier-invoice-table>table,
      #workbenchContent .wbt-table-wrap>.wbt-table)>:is(thead,tbody)>tr>:is(th,td) {
    box-sizing:border-box;
    height:40px;
    padding:6px 11px;
    border-right:1px solid #d7e0eb;
    border-bottom:1px solid #e2e8f0;
  }
  :is(#inquiryListContainer>.oa-inquiry-query-table,
      #page-comparison-query .comparison-query-scroll>.comparison-query-table,
      #page-quotation-query .comparison-query-scroll>.comparison-query-table,
      .huihuang-query-page>.huihuang-query-shell>.huihuang-query-scroll>.huihuang-query-table,
      .wuxi-m7-query-page>.huihuang-query-shell>.huihuang-query-scroll>.huihuang-query-table,
      .jn-sap-page .jn-sap-results>.jn-sap-table,
      .jn-archive-query-page .jn-archive-list-scroll>.jn-archive-table,
      .invoice-data-query:not(.invoice-data-query-embedded) .invoice-data-table,
      :is(#page-order-procurement-requisitions,#page-order-procurement-applications)>.op-shell>.op-content>.op-table-scroll>.op-table,
      #page-supplier-import-records .supplier-invoice-panel>.supplier-invoice-table>table,
      #workbenchContent .wbt-table-wrap>.wbt-table)>tbody>tr:not(:has(>.oa-empty,>.huihuang-empty,>.op-empty,>.wbt-empty,>[colspan]))>:is(th,td) {
    height:43px;
  }
  :is(#inquiryListContainer>.oa-inquiry-query-table,
      #page-comparison-query .comparison-query-scroll>.comparison-query-table,
      #page-quotation-query .comparison-query-scroll>.comparison-query-table,
      .huihuang-query-page>.huihuang-query-shell>.huihuang-query-scroll>.huihuang-query-table,
      .wuxi-m7-query-page>.huihuang-query-shell>.huihuang-query-scroll>.huihuang-query-table,
      .jn-sap-page .jn-sap-results>.jn-sap-table,
      .jn-archive-query-page .jn-archive-list-scroll>.jn-archive-table,
      .invoice-data-query:not(.invoice-data-query-embedded) .invoice-data-table,
      :is(#page-order-procurement-requisitions,#page-order-procurement-applications)>.op-shell>.op-content>.op-table-scroll>.op-table,
      #page-supplier-import-records .supplier-invoice-panel>.supplier-invoice-table>table,
      #workbenchContent .wbt-table-wrap>.wbt-table)>:is(thead,tbody)>tr>:last-child {border-right:0;}
  :is(#inquiryListContainer>.oa-inquiry-query-table,
      #page-comparison-query .comparison-query-scroll>.comparison-query-table,
      #page-quotation-query .comparison-query-scroll>.comparison-query-table,
      .huihuang-query-page>.huihuang-query-shell>.huihuang-query-scroll>.huihuang-query-table,
      .wuxi-m7-query-page>.huihuang-query-shell>.huihuang-query-scroll>.huihuang-query-table,
      .jn-sap-page .jn-sap-results>.jn-sap-table,
      .jn-archive-query-page .jn-archive-list-scroll>.jn-archive-table,
      .invoice-data-query:not(.invoice-data-query-embedded) .invoice-data-table,
      :is(#page-order-procurement-requisitions,#page-order-procurement-applications)>.op-shell>.op-content>.op-table-scroll>.op-table,
      #page-supplier-import-records .supplier-invoice-panel>.supplier-invoice-table>table,
      #workbenchContent .wbt-table-wrap>.wbt-table)>tbody>tr:last-child>:is(th,td) {border-bottom:0;}
  /* Source badges keep their existing size, without making a 40px header taller. */
  :is(#page-inquiry-query,#page-comparison-query,#page-quotation-query) thead .inquiry-source-fixed-label {padding:2px 8px;}
  #page-supplier-import-records .supplier-invoice-panel>.supplier-invoice-table>table :is(th,td) {white-space:nowrap;}
  #page-supplier-import-records .supplier-invoice-table td:last-child>.btn {height:28px;min-height:28px;padding:2px 8px;line-height:20px;}
  #workbenchContent .wbt-table-wrap>.wbt-table :is(th,td).wbt-check-cell {padding:0;}
  /* Keep the native visual link between an original voucher and its reversal. */
  #mainWrap :is(.huihuang-query-page,.wuxi-m7-query-page)>.huihuang-query-shell>.huihuang-query-scroll>.huihuang-query-table>tbody>tr[data-reversal-role=original]>td {border-bottom-style:dashed;}
}

@media screen and (max-width:768px) {
  /* The three query cards already supply their own internal text spacing. */
  :is(#page-inquiry-query,#page-comparison-query,#page-quotation-query) :is(#inquiryListContainer,#comparisonListContainer,#quotationListContainer) {padding:0;}
  #mainWrap :is(.huihuang-query-page,.wuxi-m7-query-page)>.huihuang-query-shell>.huihuang-query-scroll {
    flex:none;
    height:auto;
    overflow:visible;
  }
  /* Lists without mobile cards keep their horizontally scrolling tables. */
  :is(.jn-sap-page .jn-sap-results>.jn-sap-table,
      :is(#page-order-procurement-requisitions,#page-order-procurement-applications)>.op-shell>.op-content>.op-table-scroll>.op-table) {
    border-collapse:separate;
    border-spacing:0;
    border:1px solid #cbd7e5;
    border-radius:5px;
  }
  :is(.jn-sap-page .jn-sap-results>.jn-sap-table,
      :is(#page-order-procurement-requisitions,#page-order-procurement-applications)>.op-shell>.op-content>.op-table-scroll>.op-table)>:is(thead,tbody)>tr>:is(th,td) {
    box-sizing:border-box;
    height:40px;
    padding:6px 11px;
    border-right:1px solid #d7e0eb;
    border-bottom:1px solid #e2e8f0;
  }
  :is(.jn-sap-page .jn-sap-results>.jn-sap-table,
      :is(#page-order-procurement-requisitions,#page-order-procurement-applications)>.op-shell>.op-content>.op-table-scroll>.op-table)>tbody>tr:not(:has(>[colspan]))>:is(th,td) {height:43px;}
  :is(.jn-sap-page .jn-sap-results>.jn-sap-table,
      :is(#page-order-procurement-requisitions,#page-order-procurement-applications)>.op-shell>.op-content>.op-table-scroll>.op-table)>:is(thead,tbody)>tr>:last-child {border-right:0;}
  :is(.jn-sap-page .jn-sap-results>.jn-sap-table,
      :is(#page-order-procurement-requisitions,#page-order-procurement-applications)>.op-shell>.op-content>.op-table-scroll>.op-table)>tbody>tr:last-child>:is(th,td) {border-bottom:0;}
}
