#purchasesStage { grid-column: 2; min-width: 0; background: #fff; border: 1px solid #d7dfe9; align-self: start; }
#purchasesStage h2 { font-size: 20px; margin: 0; }
#purchasesStage h3 { font-size: 16px; margin: 0; }
.piContent { padding: 0 16px 16px; }
#purchasesStage .piRecurringDialog { width: min(620px, calc(100vw - 24px)); max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); padding: 0; overflow-y: auto; }
#piRecurringForm { min-width: 0; padding: 20px; }
#piRecurringContext { overflow-wrap: anywhere; }
#piRecurringFields { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 14px; }
#piRecurringNew { margin: 0; gap: 14px; }
#piRecurringFields label { min-width: 0; }
#piRecurringFields input, #piRecurringFields select { min-width: 0; max-width: 100%; width: 100%; }
#piRecurringFields .piFull { grid-column: 1 / -1; }
#piRecurringNew[hidden] { display: none; }
@media (max-width: 600px) { #piRecurringNew { grid-template-columns: minmax(0, 1fr); } }
.piFilters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 16px 0; }
.piFilters label:first-child { flex: 1 1 280px; }
.piFilters label { min-width: 180px; }
.piTableScroll { overflow-x: auto; max-width: 100%; border: 1px solid #d7dfe9; }
.piTable { width: 100%; min-width: 1060px; border-collapse: collapse; font-size: 13px; table-layout: auto; }
.piTable th { background: #eff3f6; color: #344054; text-align: left; font-size: 12px; }
.piTable td, .piTable th { padding: 12px 10px; border-bottom: 1px solid #e5e9ef; vertical-align: top; }
.piTable td:nth-child(2) { min-width: 245px; max-width: 330px; overflow-wrap: anywhere; }
.piTable td:nth-child(4) { min-width: 190px; max-width: 300px; overflow-wrap: anywhere; }
.piTable tbody tr:hover { background: #f5faf9; }
.piTable small, #piHistory small { display: block; color: #596579; font-size: 11px; margin-top: 4px; overflow-wrap: anywhere; }
.piNumber { border: 0; padding: 0; background: none; color: #086252; font: inherit; font-weight: 700; text-align: left; cursor: pointer; min-height: 24px; }
.piNumber:hover { text-decoration: underline; }
.piAmount { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.piStatus { display: inline-block; border-radius: 4px; padding: 4px 7px; white-space: nowrap; font-weight: 700; font-size: 12px; }
.pi-unassigned { background: #fff4df; color: #783f0b; }
.pi-partial { background: #e8f0ff; color: #1e40af; }
.pi-assigned { background: #e5f5e9; color: #14582d; }
.piNotice { background: #fff8e8; border-left: 3px solid #c98000; padding: 10px 12px; color: #6c4110; font-size: 13px; }
.piPaging { display: flex; justify-content: end; align-items: center; gap: 12px; margin-top: 16px; }
.piDetail { width: min(1160px, calc(100vw - 24px)); max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); padding: 0; }
.piDetail .dialogBody { padding: 24px; }
.piDialogHead { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.piDialogHead > div { min-width: 0; }
#piDetailNumber { overflow-wrap: anywhere; }
.piFacts { display: grid; grid-template-columns: 140px minmax(0, 1fr) 140px minmax(0, 1fr); gap: 8px 12px; font-size: 13px; margin: 0; }
.piFacts dt { color: #596579; }
.piFacts dd { margin: 0; overflow-wrap: anywhere; font-weight: 600; }
.piExchangeRate { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 14px 16px; border-left: 3px solid #0b7770; background: #edf7f4; color: #183d35; }
.piExchangeRate[hidden] { display: none; }
.piExchangeRate > div { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.piExchangeRate p { margin: 6px 0; }
.piExchangeRate small { display: block; margin-top: 8px; color: #405c53; }
.piExchangeRate a { color: #075b56; text-decoration: underline; }
#piAllocationForm { border-top: 1px solid #d7dfe9; padding-top: 20px; }
.piAllocation { display: grid; grid-template-columns: minmax(180px, 2fr) minmax(130px, 1fr) 120px minmax(130px, 1fr) auto; align-items: end; gap: 10px; margin-bottom: 12px; }
.piAllocation label { min-width: 0; }
.piAllocation input, .piAllocation select { width: 100%; min-width: 0; }
.piAllocationSum { font-weight: 700; }
#piHistory { max-height: 220px; overflow: auto; }
@media (max-width: 1040px) {
  #purchasesStage { grid-column: 1; }
}
@media (max-width: 800px) {
  .piFacts { grid-template-columns: 110px minmax(0, 1fr); }
  .piAllocation { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .piAllocation label:first-child { grid-column: 1 / -1; }
  .piPaging { justify-content: space-between; }
  .piFilters label { flex: 1 1 100%; }
  #purchasesStage .panelHead { flex-wrap: wrap; }
  .piDetail .dialogBody { padding: 16px; }
}
