.po-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin: 0 0 20px;
  padding: 22px 24px;
  border: 1px solid rgba(120, 130, 145, 0.22);
  border-radius: 18px;
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.98),
      rgba(244, 247, 251, 0.96)
    );
}

.po-page-header h2 {
  margin: 5px 0 7px;
  font-size: 25px;
}

.po-page-header p {
  max-width: 720px;
  margin: 0;
  color: #64748b;
}

.po-new-button {
  min-width: 190px;
  min-height: 44px;
}

.po-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.po-dashboard-card {
  min-height: 132px;
  padding: 19px;
  border: 1px solid rgba(120, 130, 145, 0.22);
  border-radius: 16px;
  background: var(--surface, #ffffff);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.po-dashboard-card-label {
  margin-bottom: 12px;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.po-dashboard-card-value {
  color: var(--text, #172033);
  font-size: 27px;
  font-weight: 850;
  line-height: 1.15;
}

.po-dashboard-card-caption {
  margin-top: 10px;
  color: #8290a4;
  font-size: 12px;
  line-height: 1.4;
}

.po-register-panel {
  padding: 0;
  overflow: hidden;
}

.po-register-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid rgba(120, 130, 145, 0.2);
}

.po-register-header h2 {
  margin: 0 0 5px;
}

.po-register-header p {
  margin: 0;
  color: #64748b;
}

.po-register-tools {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.po-register-tools input,
.po-register-tools select,
.po-register-tools button {
  width: auto;
  min-height: 42px;
  margin: 0;
}

.po-register-tools input {
  width: 300px;
}

.po-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.po-table {
  min-width: 1050px;
  margin: 0;
}

.po-table th {
  white-space: nowrap;
  background: rgba(240, 244, 248, 0.8);
}

.po-table td {
  vertical-align: middle;
}

.po-table td small {
  display: block;
  margin-top: 4px;
  color: #8290a4;
}

.po-number-cell {
  text-align: right;
  white-space: nowrap;
}

.po-total-cell {
  font-weight: 800;
}

.po-number-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: #1668ae;
  font-weight: 850;
  cursor: pointer;
}

.po-number-link:hover {
  text-decoration: underline;
}

.po-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 82px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e8edf3;
  color: #475569;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.po-status-draft {
  background: #e8edf3;
  color: #475569;
}

.po-status-submitted {
  background: #fff1bf;
  color: #795a00;
}

.po-status-approved {
  background: #dbeafe;
  color: #1d4ed8;
}

.po-status-ordered,
.po-status-partial {
  background: #ede9fe;
  color: #6d28d9;
}

.po-status-received,
.po-status-closed {
  background: #dcfce7;
  color: #166534;
}

.po-status-cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.po-table-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.po-action-button {
  min-height: 33px;
  padding: 6px 10px;
  font-size: 12px;
}

.po-primary-action {
  background: #1168ad;
  color: white;
  border-color: #1168ad;
}

.po-empty-state {
  padding: 48px 20px !important;
  text-align: center;
}

.po-empty-state strong,
.po-empty-state span {
  display: block;
}

.po-empty-state span {
  margin-top: 7px;
  color: #8290a4;
}

.po-loading-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  min-height: 260px;
  border: 1px solid rgba(120, 130, 145, 0.22);
  border-radius: 16px;
  background: var(--surface, #ffffff);
}

.po-loading-spinner {
  width: 25px;
  height: 25px;
  border: 3px solid rgba(17, 104, 173, 0.2);
  border-top-color: #1168ad;
  border-radius: 50%;
  animation: po-spin 0.8s linear infinite;
}

.po-error-panel {
  display: flex;
  align-items: flex-start;
  gap: 17px;
  padding: 25px;
}

.po-error-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 43px;
  height: 43px;
  flex: 0 0 43px;
  border-radius: 50%;
  background: #fee2e2;
  color: #991b1b;
  font-size: 24px;
  font-weight: 900;
}

@keyframes po-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1100px) {
  .po-dashboard-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .po-register-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .po-register-tools {
    width: 100%;
  }

  .po-register-tools input {
    flex: 1;
  }
}

@media (max-width: 700px) {
  .po-page-header {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .po-new-button {
    width: 100%;
  }

  .po-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .po-register-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .po-register-tools input,
  .po-register-tools select,
  .po-register-tools button {
    width: 100%;
  }
}
/* ABOTRIX Purchase Orders V12.3.1 — Entry Form */

body.po-modal-open {
  overflow: hidden;
}

.po-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.68);
  backdrop-filter: blur(5px);
}

.po-form-window,
.po-view-window {
  display: flex;
  flex-direction: column;
  width: min(1500px, 98vw);
  max-height: 96vh;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 20px;
  background: #f5f7fa;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35);
}

.po-view-window {
  width: min(1300px, 98vw);
}

.po-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
  background: #ffffff;
}

.po-form-header h2 {
  margin: 5px 0 4px;
}

.po-form-header p {
  margin: 0;
  color: #64748b;
}

.po-modal-close {
  width: 42px;
  height: 42px;
  min-width: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #eef2f6;
  color: #334155;
  font-size: 27px;
  line-height: 1;
}

.po-entry-form,
.po-view-content {
  overflow-y: auto;
  padding: 20px;
}

.po-form-section {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 16px;
  background: #ffffff;
}

.po-section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.po-section-heading h3 {
  margin: 0 0 4px;
}

.po-section-heading p {
  margin: 0;
  color: #64748b;
  font-size: 13px;
}

.po-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 15px;
}

.po-form-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.po-field-wide {
  grid-column: span 2;
}

.po-form-field span {
  color: #475569;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.po-form-field input,
.po-form-field select {
  width: 100%;
  min-height: 43px;
  margin: 0;
}

.po-item-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.po-item-entry-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
}

.po-item-entry-table th {
  padding: 11px 9px;
  border-bottom: 1px solid #dbe1e8;
  background: #f3f6f9;
  color: #475569;
  font-size: 11px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.po-item-entry-table td {
  padding: 8px;
  border-bottom: 1px solid #e7ebf0;
  vertical-align: middle;
}

.po-item-entry-table input,
.po-item-entry-table select {
  width: 100%;
  min-width: 105px;
  min-height: 39px;
  margin: 0;
}

.po-item-entry-table select {
  min-width: 260px;
}

.po-row-number {
  width: 45px;
  color: #64748b;
  font-weight: 800;
  text-align: center;
}

.po-unit-display {
  min-width: 75px !important;
  background: #f3f6f9 !important;
  color: #64748b;
}

.po-form-line-total {
  min-width: 125px;
  font-weight: 850;
  text-align: right;
  white-space: nowrap;
}

.po-remove-item {
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fee2e2;
  color: #991b1b;
  font-size: 22px;
}

.po-form-bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(330px, 0.7fr);
  gap: 18px;
}

.po-notes-section,
.po-summary-section {
  margin-bottom: 0;
}

.po-notes-section textarea {
  width: 100%;
  resize: vertical;
}

.po-summary-row,
.po-summary-input-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 9px 0;
  border-bottom: 1px solid #edf0f3;
}

.po-summary-input-row input {
  width: 150px;
  min-height: 38px;
  margin: 0;
  text-align: right;
}

.po-grand-total-row {
  margin-top: 7px;
  padding-top: 16px;
  border-top: 2px solid #cbd5e1;
  border-bottom: 0;
  font-size: 19px;
}

.po-grand-total-row strong {
  color: #1168ad;
  font-size: 24px;
}

.po-form-error {
  min-height: 22px;
  margin: 4px 0 10px;
}

.po-form-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  background: #ffffff;
}

.po-form-footer button {
  min-width: 130px;
}

.po-form-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  width: min(500px, 90vw);
  min-height: 180px;
  border-radius: 16px;
  background: #ffffff;
}

.po-view-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.po-view-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.po-view-details > div {
  padding: 15px;
  border: 1px solid #e1e6eb;
  border-radius: 12px;
  background: #ffffff;
}

.po-view-details span,
.po-view-notes span {
  display: block;
  margin-bottom: 7px;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.po-view-table {
  margin-bottom: 18px;
  border: 1px solid #e1e6eb;
  background: #ffffff;
}

.po-view-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
}

.po-view-notes,
.po-view-totals {
  padding: 18px;
  border: 1px solid #e1e6eb;
  border-radius: 14px;
  background: #ffffff;
}

.po-view-notes p {
  margin: 0;
  white-space: pre-wrap;
}

.po-view-totals > div {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
}

.po-view-grand-total {
  margin-top: 8px;
  padding-top: 14px !important;
  border-top: 2px solid #cbd5e1;
  font-size: 19px;
}

.po-view-grand-total strong {
  color: #1168ad;
}

@media (max-width: 1050px) {
  .po-form-grid {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }

  .po-form-bottom-grid {
    grid-template-columns: 1fr;
  }

  .po-view-details {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }

  .po-view-bottom {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 650px) {
  .po-modal-backdrop {
    padding: 0;
  }

  .po-form-window,
  .po-view-window {
    width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }

  .po-form-header {
    padding: 15px;
  }

  .po-entry-form,
  .po-view-content {
    padding: 12px;
  }

  .po-form-section {
    padding: 15px;
  }

  .po-form-grid,
  .po-view-details {
    grid-template-columns: 1fr;
  }

  .po-field-wide {
    grid-column: span 1;
  }

  .po-section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .po-form-footer {
    padding: 12px;
  }

  .po-form-footer button {
    min-width: 0;
    flex: 1;
  }
}

@media print {
  body * {
    visibility: hidden !important;
  }

  #purchaseOrderModal,
  #purchaseOrderModal * {
    visibility: visible !important;
  }

  #purchaseOrderModal {
    position: absolute;
    inset: 0;
    padding: 0;
    background: white;
  }

  .po-view-window {
    width: 100%;
    max-height: none;
    border: 0;
    box-shadow: none;
  }

  .po-modal-close,
  .po-form-footer {
    display: none !important;
  }

  .po-view-content {
    overflow: visible;
  }
}
