.sales-order-outstanding-root {
  position: fixed;
  inset: 0;
  z-index: 2600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.sales-order-outstanding-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.54);
}

.sales-order-outstanding-dialog {
  position: relative;
  width: min(1180px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  min-height: min(720px, calc(100vh - 36px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #d8e1ec;
  border-radius: 8px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
}

.sales-order-outstanding-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid #d8e1ec;
}

.sales-order-outstanding-header h2 {
  margin: 0;
  color: #102a43;
  font-size: 21px;
  line-height: 1.25;
}

.sales-order-outstanding-header p {
  margin: 5px 0 0;
  color: #62748a;
  font-size: 13px;
  font-weight: 600;
}

.sales-order-outstanding-close {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 1px solid #d8e1ec;
  border-radius: 6px;
  background: #ffffff;
  color: #26384c;
  cursor: pointer;
  font: inherit;
  font-size: 24px;
  line-height: 1;
}

.sales-order-outstanding-close:hover {
  background: #f4f7fa;
}

.sales-order-outstanding-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  border-bottom: 1px solid #d8e1ec;
  background: #f8fafc;
}

.sales-order-outstanding-metric {
  min-width: 0;
  padding: 12px 18px;
  border-right: 1px solid #d8e1ec;
}

.sales-order-outstanding-metric:last-child {
  border-right: 0;
}

.sales-order-outstanding-metric span {
  display: block;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.sales-order-outstanding-metric strong {
  display: block;
  margin-top: 3px;
  color: #102a43;
  font-size: 22px;
  line-height: 1.15;
}

.sales-order-outstanding-metric.is-money strong {
  font-size: 20px;
}

.sales-order-outstanding-breakdown {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 9px 18px;
  border-bottom: 1px solid #e5eaf0;
  color: #40566f;
  font-size: 13px;
}

.sales-order-outstanding-breakdown strong {
  color: #102a43;
}

.sales-order-outstanding-snapshot {
  margin-left: auto;
  color: #718096;
}

.sales-order-outstanding-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 480px) auto;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
}

.sales-order-outstanding-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.sales-order-outstanding-export-status {
  color: #047857;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.sales-order-outstanding-export-status.is-error {
  color: #b91c1c;
}

.sales-order-outstanding-table-wrap {
  flex: 1 1 auto;
  min-height: 260px;
  overflow: auto;
  margin: 0 18px;
  border: 1px solid #d8e1ec;
  border-radius: 6px;
}

.sales-order-outstanding-table,
.sales-order-outstanding-anomaly-wrap table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.sales-order-outstanding-table {
  min-width: 1100px;
}

.sales-order-outstanding-table th,
.sales-order-outstanding-anomaly-wrap th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 10px;
  background: #263d55;
  color: #ffffff;
  border-bottom: 1px solid #1e3348;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  white-space: nowrap;
}

.sales-order-outstanding-table td,
.sales-order-outstanding-anomaly-wrap td {
  padding: 7px 10px;
  border-bottom: 1px solid #e3e9f0;
  color: #172b3f;
  font-size: 13px;
  line-height: 1.25;
}

.sales-order-outstanding-table tbody tr:last-child td,
.sales-order-outstanding-anomaly-wrap tbody tr:last-child td {
  border-bottom: 0;
}

.sales-order-outstanding-table tbody tr:hover td {
  background: #f5f8fb;
}

.sales-order-outstanding-table .right,
.sales-order-outstanding-anomaly-wrap .right {
  text-align: right;
}

.sales-order-outstanding-total {
  color: #0b5fa5 !important;
  font-weight: 800;
}

.sales-order-outstanding-value {
  color: #047857 !important;
  font-weight: 800;
  white-space: nowrap;
}

.sales-order-outstanding-empty {
  padding: 26px !important;
  color: #64748b !important;
  text-align: center;
}

.sales-order-outstanding-empty.is-error {
  color: #b91c1c !important;
}

.sales-order-outstanding-warning {
  margin: 10px 18px 0;
  border: 1px solid #f1c98b;
  border-radius: 6px;
  background: #fff9ed;
  color: #8a4b08;
  font-size: 13px;
}

.sales-order-outstanding-warning summary {
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 700;
}

.sales-order-outstanding-anomaly-wrap {
  max-height: 180px;
  overflow: auto;
  border-top: 1px solid #f1c98b;
  background: #ffffff;
}

.sales-order-outstanding-anomaly-wrap table {
  min-width: 720px;
}

.sales-order-outstanding-anomaly-wrap th {
  background: #fff3d6;
  color: #70420b;
  border-bottom-color: #f1c98b;
}

.sales-order-outstanding-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid #d8e1ec;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
}

.sales-order-outstanding-footer > div {
  display: flex;
  gap: 8px;
}

@media (max-width: 720px) {
  .sales-order-outstanding-root {
    padding: 8px;
  }

  .sales-order-outstanding-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
    min-height: calc(100vh - 16px);
  }

  .sales-order-outstanding-summary {
    grid-template-columns: 1fr 1fr;
  }

  .sales-order-outstanding-metric:nth-child(2) {
    border-right: 0;
  }

  .sales-order-outstanding-metric:nth-child(-n + 2) {
    border-bottom: 1px solid #d8e1ec;
  }

  .sales-order-outstanding-breakdown {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .sales-order-outstanding-snapshot {
    margin-left: 0;
  }

  .sales-order-outstanding-toolbar {
    grid-template-columns: 1fr;
  }

  .sales-order-outstanding-toolbar-actions {
    flex-wrap: wrap;
  }

  .sales-order-outstanding-export-status {
    flex: 1 1 100%;
    text-align: right;
  }

  .sales-order-outstanding-table-wrap {
    margin-left: 10px;
    margin-right: 10px;
  }

  .sales-order-outstanding-warning {
    margin-left: 10px;
    margin-right: 10px;
  }

  .sales-order-outstanding-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .sales-order-outstanding-footer > div,
  .sales-order-outstanding-footer .btn {
    flex: 1 1 auto;
  }
}
