/* v0.74.2: workbook selection, reliable record scrolling and compact commercial records. */
.stage-invoice-selector {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 3px 5px !important;
  color: #17324d;
  font-size: 10px;
  font-weight: 800;
  background: #f2faf5;
  border-bottom: 1px solid #cfe3d7;
  cursor: pointer;
}
.stage-invoice-selector input {
  width: 15px !important;
  min-width: 15px !important;
  height: 15px !important;
  margin: 0;
}
.stage-status-cell:has(.stage-invoice-selector) textarea {
  min-height: 25px !important;
}
.stage-create-selected {
  margin-left: auto;
  white-space: nowrap;
}
.stage-create-selected span {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  margin-left: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
}
.stage-create-selected:disabled {
  opacity: 0.45;
}

.sales-project-line-picker {
  margin: 0 0 10px;
  border: 1px solid #bad8c5;
  border-radius: 9px;
  background: #f4faf6;
}
.sales-project-line-picker > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  cursor: pointer;
}
.sales-project-line-picker > summary span:first-child {
  display: grid;
}
.sales-project-line-picker > summary small {
  color: #60727b;
  font-weight: 400;
}
#salesProjectLinePickerRows {
  display: grid;
  max-height: 230px;
  overflow: auto;
  border-top: 1px solid #d7e6dc;
}
.sales-project-line-option {
  display: grid !important;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 11px !important;
  border-bottom: 1px solid #e2ebe5;
  cursor: pointer;
}
.sales-project-line-option:hover {
  background: #fff;
}
.sales-project-line-option input {
  width: 16px !important;
  min-width: 16px !important;
  height: 16px !important;
  margin: 0;
}
.sales-project-line-option span {
  display: grid;
  min-width: 0;
}
.sales-project-line-option small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #62747b;
}
.sales-project-line-option b {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.sales-project-line-picker-actions {
  display: flex;
  justify-content: flex-end;
  padding: 8px 10px;
}

.project-dialog {
  display: none !important;
  width: min(1180px, calc(100vw - 24px)) !important;
  height: min(790px, calc(100vh - 18px)) !important;
  max-height: calc(100vh - 18px) !important;
  padding: 0 !important;
  overflow: hidden !important;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: #fff;
}
.project-dialog[open] {
  display: grid !important;
}
.project-dialog > .dialog-heading {
  margin: 0 !important;
  padding: 14px 16px 12px !important;
  background: linear-gradient(135deg, #f1f8f4, #fff);
  border-bottom: 1px solid #d8e2df;
}
.project-dialog-tabs {
  display: flex;
  gap: 6px;
  margin: 0 !important;
  padding: 8px 14px !important;
  overflow-x: auto;
  border-bottom: 1px solid #d8e2df;
  background: #fff;
}
.project-dialog-tabs button {
  flex: 0 0 auto;
  white-space: nowrap;
}
.project-dialog-body {
  box-sizing: border-box !important;
  height: auto !important;
  min-height: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  padding: 10px 14px 86px !important;
  overscroll-behavior: contain;
}
.project-dialog-body .project-record-setup {
  min-height: 100%;
}
.project-dialog-body .project-record-setup .dialog-actions,
.project-dialog-body .project-record-setup .form-actions,
.project-dialog-body .project-record-setup .row-actions {
  position: sticky;
  bottom: 0;
  z-index: 8;
  margin: 12px -2px -10px;
  padding: 10px 2px 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -1px 0 #d8e2df;
}
.project-metrics {
  grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
  gap: 7px !important;
}
.project-metric {
  min-width: 0;
  padding: 0 !important;
  border-radius: 9px !important;
  background: #f7faf9;
}
.project-metric button {
  box-sizing: border-box;
  width: 100%;
  min-height: 74px;
  padding: 10px 11px !important;
}
.project-metric small {
  display: block;
  min-height: 0;
  color: #60727b;
  line-height: 1.25;
  overflow-wrap: normal;
}
.project-metric strong {
  display: block;
  margin-top: 5px;
  font-size: 1rem;
  line-height: 1.1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.project-metric.danger {
  border-color: #e3b5b7;
  background: #fff5f5;
}
.project-metric.danger strong {
  color: #a62d33;
}
.project-drilldown {
  max-height: none !important;
  overflow: visible !important;
  margin-top: 10px !important;
}
.project-commercial-summary {
  padding: 12px;
  border: 1px solid #d8e2df;
  border-radius: 10px;
  background: #fff;
}
.project-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.project-summary-grid button {
  display: grid;
  text-align: left;
  padding: 12px;
  border: 1px solid #d7e1e4;
  border-radius: 9px;
  background: #f7faf9;
  color: #17324d;
}
.project-summary-grid small {
  color: #60727b;
}
.project-summary-grid strong {
  margin-top: 4px;
  font-size: 1rem;
  white-space: nowrap;
}
.project-stage-drilldown {
  display: grid;
  gap: 12px;
}
.project-stage-section {
  min-width: 0;
  border: 1px solid #d8e2df;
  border-radius: 10px;
  overflow: hidden;
}
.project-stage-section > h3 {
  margin: 0;
  padding: 9px 11px;
  background: #f3f7f6;
  font-size: 1rem;
}
.project-stage-section .project-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
}
.project-stage-table {
  width: 100%;
  min-width: 760px;
  table-layout: fixed;
}
.project-stage-table th,
.project-stage-table td {
  padding: 9px 10px !important;
  vertical-align: top;
  text-align: left;
}
.project-stage-table th:nth-child(1) {
  width: 13%;
}
.project-stage-table th:nth-child(2) {
  width: 36%;
}
.project-stage-table th:nth-child(3) {
  width: 14%;
}
.project-stage-table th:nth-child(4),
.project-stage-table th:nth-child(5) {
  width: 18.5%;
}
.project-stage-table td.description {
  white-space: normal;
  overflow-wrap: anywhere;
}
.project-stage-table .number {
  text-align: right !important;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.purchase-order-record-dialog {
  display: none !important;
  width: min(1000px, calc(100vw - 20px)) !important;
  height: min(900px, calc(100vh - 14px)) !important;
  max-height: calc(100vh - 14px) !important;
  padding: 0 !important;
  overflow: hidden !important;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
.purchase-order-record-dialog[open] {
  display: grid !important;
}
.purchase-order-record-dialog > .dialog-heading {
  margin: 0 !important;
  padding: 13px 18px !important;
}
.purchase-order-record-dialog > #purchaseOrderRecordBody {
  box-sizing: border-box;
  display: block !important;
  min-height: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  padding: 12px 18px 30px !important;
  overscroll-behavior: contain;
}
.purchase-order-record-dialog > .po-record-action-panel {
  position: relative;
  z-index: 20;
  margin: 0 !important;
  padding: 9px 18px 11px !important;
  border: 0 !important;
  border-top: 1px solid #d6e0de !important;
  border-radius: 0 !important;
  background: rgba(255, 255, 255, 0.98) !important;
  box-shadow: 0 -6px 14px rgba(23, 50, 77, 0.07);
}
.purchase-order-record-dialog > .po-record-action-panel h3 {
  display: none;
}
.po-record-dialog-actions {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}
.po-record-dialog-actions > * {
  flex: 0 0 auto;
}
.po-record-summary {
  margin-bottom: 10px;
}
.po-record-information,
.po-record-lines,
.po-rate-workflow,
.po-linked-documents {
  margin-bottom: 10px;
}
.po-record-lines {
  padding: 11px 13px !important;
}
.po-record-lines .dashboard-table-wrap {
  overflow-x: auto;
  overflow-y: visible !important;
  border-color: #d6e0e3;
}
.po-record-lines table {
  width: 100%;
  min-width: 680px !important;
  table-layout: fixed;
}
.po-record-lines th,
.po-record-lines td {
  padding: 8px 9px !important;
  line-height: 1.3;
}
.po-record-lines thead th {
  color: #17324d !important;
  background: #e9f1f4 !important;
  border-bottom: 2px solid #aac4cf !important;
}
.po-record-lines th:nth-child(1) {
  width: 9%;
}
.po-record-lines th:nth-child(2) {
  width: 12%;
}
.po-record-lines th:nth-child(3) {
  width: 49%;
}
.po-record-lines th:nth-child(4),
.po-record-lines th:nth-child(5) {
  width: 15%;
}
.po-record-lines td:nth-child(1),
.po-record-lines td:nth-child(2) {
  text-align: center;
}
.po-record-lines td:nth-child(3) {
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}
.po-record-lines td.number {
  text-align: right !important;
  white-space: nowrap;
}
.po-record-lines tfoot th,
.po-record-lines tfoot td {
  padding: 6px 9px !important;
  background: #f8faf9 !important;
}
.po-record-lines tfoot th {
  text-align: right;
}
.po-record-lines tfoot tr:last-child th,
.po-record-lines tfoot tr:last-child td {
  color: #17324d !important;
  border-top: 2px solid #5f9a75 !important;
  background: #edf6f0 !important;
}
.po-rate-workflow {
  padding: 12px 14px;
  border: 1px solid #cdded3;
  border-radius: 11px;
  background: #f7faf8;
}
.po-rate-workflow-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(0, 1.2fr);
  gap: 9px;
  align-items: end;
  margin: 9px 0;
}
.po-rate-workflow-controls label {
  font-size: 0.75rem;
}
.po-rate-workflow-controls input,
.po-rate-workflow-controls select {
  width: 100%;
  min-height: 38px;
}
.po-rate-workflow-controls p {
  margin: 0;
  padding: 8px;
  border-radius: 8px;
  background: #fff;
}
.rate-return-details {
  margin: 8px 0;
}
.rate-return-details summary {
  cursor: pointer;
  font-weight: 700;
}
.rate-return-rows {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}
.rate-return-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(130px, 0.65fr) minmax(
      135px,
      0.65fr
    ) minmax(180px, 1fr);
  gap: 7px;
  align-items: end;
  padding: 8px;
  border: 1px solid #dce7df;
  border-radius: 8px;
  background: #fff;
}
.rate-return-row > span {
  display: grid;
}
.rate-return-row small {
  color: #60727b;
}
.rate-return-row label {
  font-size: 0.7rem;
}
.rate-return-row input {
  width: 100%;
  min-height: 36px;
}
.final-rate-invoice {
  grid-column: 1/-1;
  margin-top: 6px !important;
  padding: 8px 10px !important;
  border-radius: 8px;
  background: #eef7f1;
}

@media (max-width: 900px) {
  .project-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .project-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .po-rate-workflow-controls {
    grid-template-columns: 1fr 1fr;
  }
  .po-rate-workflow-controls p {
    grid-column: 1/-1;
  }
  .rate-return-row {
    grid-template-columns: 1fr 1fr;
  }
  .rate-return-row > span,
  .rate-return-row label:last-child {
    grid-column: 1/-1;
  }
}
@media (max-width: 600px) {
  .project-dialog,
  .purchase-order-record-dialog {
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
  }
  .project-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  .project-summary-grid {
    grid-template-columns: 1fr;
  }
  .project-dialog-body {
    padding: 8px 9px 82px !important;
  }
  .purchase-order-record-dialog > #purchaseOrderRecordBody {
    padding: 9px 10px 24px !important;
  }
  .po-record-information {
    grid-template-columns: 1fr !important;
  }
  .po-rate-workflow-controls,
  .rate-return-row {
    grid-template-columns: 1fr;
  }
  .rate-return-row > * {
    grid-column: 1 !important;
  }
  .stage-create-selected {
    order: 4;
    margin-left: 0;
  }
  .stage-toolbar .autosave-status {
    order: 5;
  }
  .sales-project-line-option {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .sales-project-line-option b {
    grid-column: 2;
  }
}
