/* Native ERP views. Scoped additions on top of styles.css; amber marks unresolved
   states, and local records such as payments never take accepted (green) styling. */
.erp-page {
  max-width: 1180px;
}
.erp-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.erp-sections {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}
.erp-sections a {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.erp-sections a:hover {
  color: var(--ink);
}
.erp-sections a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--deep);
}
.erp-heading {
  align-items: flex-start;
  flex-wrap: wrap;
}
.erp-heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.erp-panel {
  padding: 24px 28px;
  max-width: none;
}
.erp-extension-toolbar summary {
  min-height: 44px;
  align-content: center;
  cursor: pointer;
  font-weight: 600;
}
.erp-extension-toolbar summary:focus-visible {
  outline: 2px solid var(--deep);
  outline-offset: 4px;
  border-radius: 4px;
}
.erp-extension-toolbar[open] summary {
  margin-bottom: 12px;
}
.erp-panel-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.erp-filters {
  margin: 8px 0 12px;
}
.erp-count {
  margin-top: 0;
}
.erp-count:empty {
  display: none;
}
.erp-records {
  margin: 8px 0 0;
}
.erp-records li:first-child {
  border-top: 0;
}
.erp-empty h3 {
  color: var(--ink);
  font-size: 1rem;
  margin-bottom: 4px;
}
.erp-empty .library-row-actions {
  margin-top: 14px;
}
.erp-more {
  justify-content: center;
  margin-top: 12px;
}
.erp-chip {
  margin-top: 6px;
  margin-right: 6px;
}
.erp-tone-warn {
  background: #fff0d7;
  border-color: #ecd3a4;
  color: #795312;
}
.erp-tone-text-danger {
  color: var(--danger);
}
.erp-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1px;
  margin-bottom: 24px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.erp-metrics > * {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 20px;
  background: #fff;
  min-width: 0;
  text-decoration: none;
}
.erp-metrics a:hover {
  background: #fbfcfa;
}
.erp-metrics span {
  font-size: 0.78rem;
  color: var(--muted);
}
.erp-metrics strong {
  font-family: inherit;
  font-size: 1.35rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.erp-metrics small {
  font-size: 0.75rem;
  color: var(--muted);
}
.erp-facts {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin: 8px 0;
}
.erp-facts dd {
  font-size: 1rem;
}
.erp-table-wrap {
  margin-top: 8px;
}
.erp-table th,
.erp-table td {
  padding: 12px 14px;
}
.erp-table th:first-child,
.erp-table td:first-child {
  padding-left: 0;
}
.erp-table th:last-child,
.erp-table td:last-child {
  padding-right: 0;
}
.erp-table td:last-child,
.erp-table th:last-child {
  text-align: left;
}
.erp-table th.erp-num,
.erp-table td.erp-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.erp-table small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}
.erp-table .text-btn {
  display: block;
  min-height: 32px;
  padding: 4px 0;
}
.erp-details {
  padding: 16px 28px;
}
.erp-details summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}
.erp-details summary:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 3px;
}
.erp-uncertain {
  margin-bottom: 24px;
}
.erp-uncertain ul {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}
.erp-uncertain li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
}

.erp-dialog-wide {
  width: min(860px, calc(100vw - 32px));
}
.erp-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.erp-fieldset:disabled {
  opacity: 0.7;
}
.erp-form-grid {
  gap: 0 20px;
}
.erp-field {
  min-width: 0;
  margin-bottom: 14px;
}
.erp-field[hidden] {
  display: none;
}
.library-dialog .erp-field .field {
  margin: 0;
}
.erp-field .field-help {
  display: block;
  margin-top: 6px;
}
.erp-field-error {
  display: block;
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 4px;
}
.erp-field-error:empty {
  display: none;
}
.erp-field [aria-invalid="true"] {
  border-color: var(--danger);
}
.erp-field .checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 44px;
  font-size: 0.875rem;
}
.erp-inline-action {
  display: flex;
  align-items: flex-end;
  padding-bottom: 14px;
}
.erp-preview {
  min-height: 1.4em;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}
.erp-preview:empty {
  margin: 0;
}
.erp-dialog-actions {
  flex-wrap: wrap;
  margin-top: 16px;
}
.erp-cart {
  border-block: 1px solid var(--border);
  margin: 8px 0 18px;
  padding: 16px 0;
}
.erp-cart h3 {
  font-size: 0.95rem;
  margin-bottom: 12px;
}
.erp-cart-add {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}
.erp-cart-add .field {
  flex: 1 1 260px;
}
.library-dialog .erp-cart .field {
  margin: 0;
}
.erp-lines {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}
.erp-lines li {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid #e6ebe5;
}
.erp-line-title small {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
}
.erp-line-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 12px;
}
.erp-journal-inputs {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr);
}
.erp-line-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.erp-cart-total {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 24px;
  margin: 12px 0 0;
}
.erp-cart-total dt {
  color: var(--muted);
  font-size: 0.75rem;
}
.erp-cart-total dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.erp-print-head {
  display: none;
}

@media screen and (max-width: 700px) {
  .erp-heading-actions,
  .erp-heading-actions .btn {
    width: 100%;
  }
  .erp-panel {
    padding: 20px 16px;
  }
  .erp-details {
    padding: 8px 16px;
  }
  .erp-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .erp-metrics > * {
    padding: 14px;
  }
  .erp-records .collection-amount {
    text-align: left;
  }
  .erp-records.collection-documents li,
  .erp-records.payment-history li {
    flex-direction: column;
    gap: 8px;
  }
  .erp-table,
  .erp-table tbody,
  .erp-table tr,
  .erp-table td {
    display: block;
    width: 100%;
  }
  .erp-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .erp-table tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
  }
  .erp-table tr:last-child {
    border-bottom: 0;
  }
  .erp-table td,
  .erp-table td:first-child,
  .erp-table td:last-child,
  .erp-table td.erp-num {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 16px;
    padding: 4px 0;
    border: 0;
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .erp-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.75rem;
    text-align: left;
  }
  .erp-table .text-btn {
    min-height: 44px;
    padding: 10px 0;
  }
  .erp-line-inputs,
  .erp-journal-inputs {
    grid-template-columns: minmax(0, 1fr);
  }
  .erp-inline-action {
    padding-bottom: 8px;
  }
  .erp-dialog-actions .btn {
    flex: 1 1 100%;
  }
}

@media print {
  body.erp-printing .settings-nav {
    display: none !important;
  }
  body.erp-printing .workspace,
  body.erp-printing .workspace-main,
  body.erp-printing .main-content {
    display: block;
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: none;
  }
  body.erp-printing .erp-page {
    max-width: none;
  }
  body.erp-printing .erp-page > :not(.erp-printable),
  body.erp-printing .erp-no-print {
    display: none !important;
  }
  body.erp-printing .erp-print-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 16px;
  }
  body.erp-printing .erp-panel {
    border: 0;
    padding: 0;
    margin-bottom: 16px;
  }
  body.erp-printing .erp-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  body.erp-printing .erp-metrics small,
  body.erp-printing .erp-printable .text-btn {
    display: none;
  }
  body.erp-printing .erp-table tr {
    break-inside: avoid;
  }
}
@media (max-width: 720px) {
  .erp-table { min-width: 0; max-width: 100%; table-layout: auto; }
  .erp-table td { min-width: 0; }
}

/* Credit review stays scannable on a phone; the original sale is still retained. */
.erp-facts.erp-credit-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.erp-credit-summary > div:nth-child(3) {
  grid-column: 1 / -1;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.erp-facts.erp-credit-summary dt { font-size: .82rem; }
.erp-facts.erp-credit-summary dd { font-size: 1rem; }
.erp-credit-history strong, .erp-credit-history small { display: block; }
.erp-credit-history small { margin-top: 6px; }
