/* 订单台账：横向比较订单，按需展开应收，详情独立阅读。 */
.orders-ledger.panel,
.order-record.panel {
  min-width: 0;
  padding: 24px 28px;
  overflow: visible;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: none;
  font-size: 14px;
}

:is(.orders-ledger, .order-record) [hidden] {
  display: none !important;
}

.orders-ledger .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:is(.orders-ledger, .order-record) button {
  font-family: inherit;
}

:is(.orders-ledger, .order-record) :is(button, summary):focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.order-record-back:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

:is(.orders-ledger, .order-record) .button {
  box-shadow: none;
}

:is(.orders-ledger, .order-record) .button:disabled {
  cursor: not-allowed;
}

.orders-ledger-heading,
.order-record-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-bottom: 22px;
}

.orders-ledger-heading > div,
.order-record-head > div {
  min-width: 0;
}

.orders-ledger-heading h2,
.order-record-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.orders-ledger-heading p,
.order-record-head p,
.orders-ledger-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.orders-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-bottom: 18px;
}

.orders-filter-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.orders-filter-tabs button {
  min-height: 36px;
  border: 0;
  border-radius: 7px;
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

.orders-filter-tabs button.active,
.orders-filter-tabs button[aria-pressed="true"] {
  background: var(--green-soft);
  color: var(--green);
}

.orders-ledger .order-search-row {
  display: flex;
  align-items: center;
  flex: 1 1 240px;
  min-width: 220px;
  max-width: 320px;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.orders-ledger .order-search-row input {
  width: 100%;
  min-height: 38px;
  border-radius: 7px;
  background: var(--surface);
  font-size: 13px;
}

.orders-ledger .order-search-row .button {
  min-height: 38px;
  border-radius: 7px;
  padding: 8px 12px;
  font-size: 13px;
}

.orders-ledger .orders-sort-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}

.orders-ledger .orders-sort-label select {
  width: auto;
  min-width: 0;
  max-width: 100%;
  min-height: 38px;
  border-radius: 7px;
  padding: 8px 30px 8px 10px;
  background-color: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 400;
}

.orders-ledger-table,
.orders-ledger-table table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.orders-ledger-table th {
  border-bottom: 1px solid var(--line);
  padding: 11px 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  text-align: left;
}

.orders-ledger-table th:first-child {
  width: 35%;
}

.orders-ledger-table th:last-child {
  width: 104px;
}

.orders-ledger-table .order-ledger-row > td {
  padding: 16px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  line-height: 1.55;
}

.orders-ledger-table th:first-child,
.orders-ledger-table .order-ledger-row > td:first-child {
  padding-left: 0;
}

.orders-ledger-table th:last-child,
.orders-ledger-table .order-ledger-row > td:last-child {
  padding-right: 0;
}

.orders-ledger-table .num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}

.orders-ledger-table th.num button {
  justify-content: flex-end;
  color: inherit;
  font: inherit;
}

.order-identity {
  min-width: 0;
}

.order-name-link {
  display: block;
  max-width: 100%;
  border: 0;
  border-radius: 3px;
  padding: 3px 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
  text-align: left;
  overflow-wrap: anywhere;
}

.order-identity small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.order-outstanding {
  display: inline-grid;
  justify-items: end;
  gap: 3px;
  max-width: 100%;
  min-height: 32px;
  border: 0;
  border-radius: 4px;
  padding: 4px 0;
  background: transparent;
  color: var(--amber);
  font-size: 15px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  text-align: right;
}

.order-outstanding.is-zero,
.order-outstanding:disabled {
  color: var(--muted);
  font-weight: 400;
}

.order-outstanding strong {
  font: inherit;
}

.order-outstanding :is(small, span) {
  color: var(--green);
  font-size: 11px;
  font-weight: 500;
}

.order-collection-note {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
}

.order-collection-note.is-overdue {
  color: var(--amber);
}

.orders-ledger .order-row-actions {
  text-align: right;
}

.orders-ledger .order-row-actions :is(button, .text-button) {
  min-height: 34px;
  border: 0;
  border-radius: 4px;
  padding: 6px 0;
  background: transparent;
  color: var(--green);
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
}

.orders-ledger-table .order-ledger-row.is-expanded {
  background: var(--surface-soft);
}

.orders-ledger-table .order-expansion-row > td {
  padding: 0;
  border-bottom: 1px solid var(--line);
}

.order-inline-detail {
  min-width: 0;
  padding: 20px 24px 22px;
  background: var(--surface-soft);
}

.order-inline-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.order-inline-header h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.order-inline-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  min-height: 72px;
  padding: 20px 24px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.order-inline-state[role="alert"] {
  color: var(--red);
}

.orders-ledger .order-pagination {
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
  border-top: 0;
  padding: 18px 0 0;
  font-size: 12px;
}

.orders-ledger .order-pagination .button {
  min-height: 36px;
  border-color: var(--line);
  border-radius: 7px;
  padding: 7px 12px;
  background: var(--surface);
  font-size: 12px;
}

.order-record-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  margin: 0 0 18px;
  border: 0;
  border-radius: 4px;
  padding: 6px 0;
  background: transparent;
  color: var(--green);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
}

.order-record-head {
  margin-bottom: 8px;
}

.order-record-head > div:first-child {
  flex: 1 1 300px;
}

.order-record-summary {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 18px 40px;
  padding: 22px 0 24px;
}

.order-record-summary > div {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.order-record-summary span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.order-record-summary strong {
  color: var(--ink);
  font-size: 20px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.order-record-summary .outstanding strong {
  color: var(--amber);
}

.order-record-summary .outstanding.is-zero strong {
  color: var(--muted);
}

.order-record-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 26px;
  border-bottom: 1px solid var(--line);
}

.order-record-tabs button {
  min-height: 42px;
  margin-bottom: -1px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 2px 2px 0 0;
  padding: 10px 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.order-record-tabs button.active,
.order-record-tabs button[aria-selected="true"] {
  border-bottom-color: var(--green);
  color: var(--green);
}

.order-record-body {
  min-width: 0;
  padding-top: 24px;
}

:is(.orders-ledger, .order-record) .order-receivable-block {
  min-width: 0;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

:is(.orders-ledger, .order-record) .order-receivable-block:first-child {
  padding-top: 0;
}

.order-inline-header + .order-receivable-block,
.order-record .section-title + .order-receivable-block {
  padding-top: 0;
}

:is(.orders-ledger, .order-record) .order-receivable-main {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(200px, auto) auto;
  align-items: start;
  gap: 12px 24px;
}

:is(.orders-ledger, .order-record) .order-receivable-main > div {
  min-width: 0;
}

:is(.orders-ledger, .order-record) .order-receivable-main strong {
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

:is(.orders-ledger, .order-record) .order-receivable-main h3 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

:is(.orders-ledger, .order-record) .order-receivable-main p {
  margin-bottom: 0;
}

:is(.orders-ledger, .order-record) .order-receivable-main small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

:is(.orders-ledger, .order-record) .order-receivable-values {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px 24px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

:is(.orders-ledger, .order-record) .order-receivable-values > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

:is(.orders-ledger, .order-record) .order-receivable-values span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

:is(.orders-ledger, .order-record) .order-receivable-values .outstanding {
  color: var(--amber);
}

:is(.orders-ledger, .order-record) .order-receivable-actions {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px 14px;
}

:is(.orders-ledger, .order-record) .order-receivable-actions :is(.text-button, .button) {
  min-height: 34px;
  font-size: 12px;
}

:is(.orders-ledger, .order-record) .order-receivable-more {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

:is(.orders-ledger, .order-record) .order-receivable-more > summary {
  width: fit-content;
  max-width: 100%;
  min-height: 32px;
  border-radius: 3px;
  padding: 5px 0;
  color: var(--green);
  cursor: pointer;
}

:is(.orders-ledger, .order-record) .order-receivable-more[open] > summary {
  margin-bottom: 8px;
}

:is(.orders-ledger, .order-record) .order-linked-receipts {
  min-width: 0;
  margin-top: 10px;
}

:is(.orders-ledger, .order-record) .order-receipt-entry {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.6;
}

:is(.orders-ledger, .order-record) .order-receipt-entry > div {
  min-width: 0;
}

:is(.orders-ledger, .order-record) .order-receipt-entry strong {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  overflow-wrap: anywhere;
}

:is(.orders-ledger, .order-record) .order-receipt-entry small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.order-record .order-unlinked-receipts {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.order-record .order-settled-receivables {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.order-record .order-cash-link-detail {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 12px;
}

.order-record :is(.order-section, .order-timeline-section) {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.order-record .order-section + .order-section {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.order-record .section-title {
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}

.order-record .section-title h3,
.order-record .order-unlinked-receipts h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
}

.order-record .order-row {
  align-items: flex-start;
  min-height: 64px;
  gap: 16px 24px;
  padding: 16px 0;
}

.order-record .order-row strong {
  overflow: visible;
  font-size: 14px;
  white-space: normal;
  text-overflow: clip;
}

.order-record .order-row small {
  font-size: 12px;
  line-height: 1.6;
}

.order-record .order-row > div:last-child {
  flex: 0 1 auto;
}

.order-record .order-record-facts {
  margin: 0 0 28px;
}

.order-record-facts dl,
dl.order-record-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px 28px;
  margin: 0;
}

.order-record-facts dl > div,
dl.order-record-facts > div {
  min-width: 0;
}

.order-record-facts dt {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
}

.order-record-facts dd {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.orders-ledger-table .order-ledger-row.is-updated {
  animation: order-ledger-updated 2.2s ease-out;
}

@keyframes order-ledger-updated {
  from { background-color: var(--green-soft); }
  to { background-color: transparent; }
}

@media (hover: hover) and (pointer: fine) {
  .orders-filter-tabs button:not(.active):hover {
    background: var(--surface-soft);
    color: var(--ink);
  }

  .order-name-link:hover,
  .order-record-back:hover {
    color: var(--green);
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  .order-outstanding:not(:disabled):hover {
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

@media (max-width: 1180px) {
  .orders-ledger.panel,
  .order-record.panel {
    padding: 22px;
  }

  .orders-ledger-table th,
  .orders-ledger-table .order-ledger-row > td {
    padding-right: 10px;
    padding-left: 10px;
  }

  .orders-ledger-table th:first-child {
    width: 32%;
  }

  .orders-ledger-table th:last-child {
    width: 88px;
  }

  :is(.orders-ledger, .order-record) .order-receivable-main {
    grid-template-columns: minmax(0, 1fr) minmax(180px, auto);
    gap: 12px 20px;
  }

  :is(.orders-ledger, .order-record) .order-receivable-actions {
    grid-column: 1 / -1;
  }
}

@media (min-width: 841px) and (max-width: 1080px) {
  .orders-ledger-table .num,
  .order-outstanding {
    font-size: 12px;
  }

  .orders-ledger-table .order-ledger-row > td {
    padding-right: 8px;
    padding-left: 8px;
  }

  .orders-ledger .order-row-actions :is(button, .text-button) {
    font-size: 12px;
  }
}

/* 小屏，以及侧栏尚未收起的窄桌面，按订单重排而不是压缩金额。 */
@media (max-width: 680px), (min-width: 841px) and (max-width: 1040px) {
  .orders-ledger.panel,
  .order-record.panel {
    padding: 18px 16px;
    border-radius: 12px;
  }

  .orders-ledger-heading,
  .order-record-head {
    gap: 12px;
    margin-bottom: 18px;
  }

  .orders-ledger-heading h2,
  .order-record-head h2 {
    font-size: 20px;
  }

  .orders-toolbar {
    align-items: stretch;
    gap: 12px;
    margin-bottom: 12px;
  }

  .orders-filter-tabs {
    width: 100%;
  }

  .orders-filter-tabs button {
    padding-right: 10px;
    padding-left: 10px;
  }

  .orders-ledger .order-search-row {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
    max-width: none;
  }

  .orders-ledger .order-search-row input {
    font-size: 16px;
  }

  .orders-ledger .orders-sort-label {
    flex: 1 1 100%;
    justify-content: flex-end;
    margin-left: 0;
  }

  .orders-ledger .orders-sort-label select {
    max-width: calc(100% - 32px);
    font-size: 16px;
  }

  .orders-ledger-table,
  .orders-ledger-table :is(table, tbody) {
    display: block;
    width: 100%;
  }

  .orders-ledger-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .orders-ledger-table .order-ledger-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 16px;
    min-width: 0;
    padding: 18px 0;
    border-top: 1px solid var(--line);
  }

  .orders-ledger-table .order-ledger-row > td {
    display: block;
    min-width: 0;
    border: 0;
    padding: 0;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .orders-ledger-table .order-ledger-row > td:first-child,
  .orders-ledger-table .order-ledger-row > td:nth-child(2),
  .orders-ledger-table .order-ledger-row > td:last-child {
    grid-column: 1 / -1;
  }

  .orders-ledger-table .order-ledger-row > td[data-label]::before {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    content: attr(data-label);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
  }

  .orders-ledger-table .order-ledger-row > td:first-child::before,
  .orders-ledger-table .order-ledger-row > td:last-child::before {
    display: none;
  }

  .orders-ledger-table .order-ledger-row > td:nth-child(2) {
    color: var(--muted);
    font-size: 12px;
  }

  .orders-ledger-table .order-ledger-row > td:nth-child(2)::before {
    display: inline;
    margin-right: 8px;
  }

  .orders-ledger-table .order-ledger-row .num {
    font-size: 14px;
  }

  .order-outstanding {
    justify-items: start;
    font-size: 15px;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .orders-ledger .order-row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
  }

  .orders-ledger-table .order-expansion-row,
  .orders-ledger-table .order-expansion-row > td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .order-inline-detail,
  .order-inline-state {
    padding: 16px 12px;
  }

  .orders-ledger .order-pagination {
    justify-content: center;
    border-top: 1px solid var(--line);
  }

  .orders-ledger .order-pagination > span {
    flex-basis: 100%;
    order: -1;
    text-align: center;
  }

  .order-record-head > div:first-child {
    flex-basis: 100%;
  }

  .order-record-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 4px 0 22px;
  }

  .order-record-summary > .outstanding {
    grid-column: 1 / -1;
  }

  .order-record-summary strong {
    font-size: 18px;
  }

  .order-record-summary .outstanding strong {
    font-size: 24px;
  }

  .order-record-tabs {
    gap: 8px 22px;
  }

  .order-record-body {
    padding-top: 20px;
  }

  :is(.orders-ledger, .order-record) .order-receivable-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  :is(.orders-ledger, .order-record) .order-receivable-main > div {
    width: 100%;
  }

  :is(.orders-ledger, .order-record) .order-receivable-values {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    gap: 12px;
    text-align: left;
  }

  :is(.orders-ledger, .order-record) .order-receivable-actions {
    justify-content: flex-start;
  }

  .order-record .order-row {
    flex-wrap: wrap;
    gap: 10px;
  }

  .order-record .order-row > div:last-child {
    flex: 1 1 100%;
    max-width: 100%;
    justify-items: start;
    text-align: left;
  }

  .order-record-facts dl,
  dl.order-record-facts {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}

@media (pointer: coarse) {
  :is(.orders-ledger, .order-record) :is(.button, .text-button),
  .orders-filter-tabs button,
  .order-outstanding,
  .order-name-link,
  .order-record-back,
  .order-record-tabs button,
  :is(.orders-ledger, .order-record) .order-receivable-more > summary {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .orders-ledger-table .order-ledger-row.is-updated {
    animation: none;
    background: var(--green-soft);
  }
}
