.pv2-page {
  --pv2-green: #315f4a;
  --pv2-soft: #faf8f5;
}

.pv2-page-heading { margin-bottom: 18px; }
.pv2-page-heading p { max-width: 760px; }

.pv2-metrics {
  gap: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 16px;
}

.pv2-metrics .metric-card,
.pv2-detail-metrics .metric-card {
  border-radius: 12px;
  box-shadow: none;
  min-height: 0;
  padding: 14px 15px;
}

.pv2-metrics .metric-label,
.pv2-detail-metrics .metric-label {
  font-size: 9px;
  letter-spacing: .08em;
}

.pv2-metrics .metric-value {
  font-size: clamp(18px, 1.55vw, 24px);
  line-height: 1.12;
  margin-top: 7px;
  white-space: nowrap;
}

.pv2-metrics .metric-note,
.pv2-detail-metrics .metric-note {
  font-size: 9.5px;
  line-height: 1.4;
  margin-top: 6px;
}

.pv2-balance-card {
  background: var(--ink) !important;
  border-color: var(--ink) !important;
}

.pv2-balance-card .metric-label,
.pv2-balance-card .metric-note { color: rgba(255, 255, 255, .66) !important; }
.pv2-balance-card .metric-value { color: #fff !important; }

.pv2-ledger {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(28, 29, 29, .035);
  overflow: hidden;
}

.pv2-ledger-head {
  align-items: center;
  background: var(--surface);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  min-height: 52px;
  padding: 8px 12px 7px 14px;
}

.pv2-tabs { margin: 0; }
.pv2-tab { letter-spacing: .015em; }

.pv2-ledger-caption {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  padding-right: 3px;
  white-space: nowrap;
}

.pv2-filterbar {
  background: var(--pv2-soft);
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  margin: 0;
  padding: 10px 13px;
}

.pv2-filterbar .searchbox > span {
  color: var(--muted);
  font-size: 19px;
  left: 12px;
  line-height: 1;
  position: absolute;
  top: 50%;
  transform: translateY(-54%);
}

.pv2-filterbar input,
.pv2-filterbar select {
  font-size: 10.5px;
  height: 36px;
}

.pv2-table-wrap {
  border: 0;
  max-width: 100%;
  overflow: auto;
  scrollbar-color: var(--line) transparent;
  scrollbar-width: thin;
}

.pv2-table {
  font-size: 10.5px;
  margin: 0;
  min-width: 940px;
}

.pv2-payments-table { min-width: 760px; }
.pv2-exceptions-table { min-width: 820px; }

.pv2-table thead th {
  background: #fff;
  color: var(--muted);
  font-size: 8.5px;
  letter-spacing: .065em;
  padding-bottom: 9px;
  padding-top: 9px;
  text-transform: uppercase;
  white-space: nowrap;
}

.pv2-table tbody td {
  padding-bottom: 10px;
  padding-top: 10px;
  vertical-align: middle;
}

.pv2-table tbody tr { transition: background .12s ease; }
.pv2-table tbody tr[data-pv2-purchase] { cursor: pointer; }
.pv2-table tbody tr[data-pv2-purchase]:hover { background: #fcfaf7; }
.pv2-table tbody tr[data-pv2-purchase]:focus { outline: 2px solid var(--ink); outline-offset: -2px; }

.pv2-table .cell-title { font-size: 10.5px; }
.pv2-table .cell-subtitle { font-size: 8.8px; margin-top: 3px; }
.pv2-money,
.pv2-balance { white-space: nowrap; }
.pv2-balance strong { color: var(--ink); font-size: 10.75px; }
.pv2-balance.negative strong { color: var(--danger); }
.pv2-due { white-space: nowrap; }
.pv2-due.overdue { color: var(--danger); font-weight: 800; }
.pv2-open-cell { text-align: right; width: 48px; }
.pv2-open {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink) !important;
  padding: 5px 8px !important;
}
.pv2-open:hover { background: var(--surface-2); }

.pv2-status,
.pv2-adjustment,
.pv2-fulfillment {
  font-size: 8px;
  letter-spacing: .025em;
  padding: 5px 7px;
  white-space: nowrap;
}

.pv2-status-stack { display: grid; gap: 3px; justify-items: start; }
.pv2-fulfillment-inline { color: var(--muted); font-size: 8px; font-weight: 700; white-space: nowrap; }
.pv2-heading-tags { align-items: center; display: flex; flex-wrap: wrap; gap: 5px; }
.pv2-fulfillment { background: #f4efe9; color: var(--ink-soft); }

.pv2-status.paid { background: var(--success-pale); color: var(--success); }
.pv2-status.partial { background: var(--blue-pale); color: #385c70; }
.pv2-status.unpaid { background: var(--surface-2); color: var(--ink-soft); }
.pv2-status.overdue { background: var(--danger-pale); color: var(--danger); }
.pv2-status.credit { background: var(--sage-pale); color: var(--pv2-green); }
.pv2-adjustment.refund { background: var(--danger-pale); color: var(--danger); }
.pv2-adjustment.supplier_credit { background: var(--sage-pale); color: var(--pv2-green); }
.pv2-adjustment.replacement { background: var(--blue-pale); color: #385c70; }

.pv2-boundary {
  align-items: baseline;
  background: transparent;
  border: 0;
  color: var(--muted);
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding: 0 2px;
}

.pv2-boundary strong {
  color: var(--ink-soft);
  flex: 0 0 auto;
  font-size: 8.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.pv2-boundary span {
  font-size: 8.8px;
  line-height: 1.45;
}

.pv2-modal { max-height: calc(100vh - 36px); }
.pv2-modal.wide { width: min(1080px, calc(100vw - 40px)); }
.pv2-modal .modal-body { overflow: auto; }
.pv2-modal textarea { min-height: 84px; resize: vertical; }

.pv2-detail-heading,
.pv2-section-heading,
.pv2-upload-row {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.pv2-detail-heading {
  background: var(--pv2-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
}

.pv2-detail-heading p,
.pv2-section-heading p,
.pv2-upload-row span {
  color: var(--muted);
  display: block;
  font-size: 9.5px;
  line-height: 1.45;
  margin: 5px 0 0;
}

.pv2-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.pv2-detail-heading .btn,
.pv2-section-heading .btn {
  min-height: 32px;
  padding: 7px 10px;
}

.pv2-detail-metrics {
  gap: 7px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 9px 0 0;
}

.pv2-detail-metrics .metric-card { padding: 11px 12px; }
.pv2-detail-metrics .metric-value {
  font-size: clamp(16px, 1.25vw, 20px);
  line-height: 1.12;
  margin-top: 5px;
  white-space: nowrap;
}

.pv2-detail-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 11px;
  overflow: hidden;
}

.pv2-section-heading {
  background: #fbf9f6;
  border-bottom: 1px solid var(--line);
  padding: 10px 13px;
}

.pv2-section-heading h3 {
  font-family: Raleway, sans-serif;
  font-size: 10.5px;
  letter-spacing: .01em;
  margin: 0;
}

.pv2-detail-section table { background: #fff; }
.pv2-detail-section table th { font-size: 8.5px; }
.pv2-detail-section table td { font-size: 10px; padding-bottom: 9px; padding-top: 9px; }
.pv2-line-state-table { min-width: 900px; }
.pv2-receive-table { min-width: 720px; }
.pv2-receive-table td small { color: var(--muted); display: block; font-size: 8.5px; margin-top: 2px; }
.pv2-receive-table input { min-width: 110px; }

.pv2-editor-lines { border: 1px solid var(--line); border-radius: 12px; margin-top: 14px; overflow: hidden; }
.pv2-purchase-line { align-items: end; border-top: 1px solid var(--line); display: grid; gap: 8px; grid-template-columns: minmax(220px, 2fr) minmax(90px, .7fr) minmax(110px, .8fr) minmax(130px, 1fr) auto; padding: 10px 12px; }
.pv2-purchase-line:first-child { border-top: 0; }
.pv2-purchase-line .field { margin: 0; }
.pv2-purchase-line .pv2-remove-line { margin-bottom: 5px; }

.pv2-purchase-mode {
  border: 0;
  margin: 2px 0 14px;
  padding: 0;
}
.pv2-purchase-mode legend {
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .09em;
  margin-bottom: 7px;
}
.pv2-purchase-mode-options {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.pv2-purchase-mode-option {
  cursor: pointer;
  margin: 0;
  position: relative;
}
.pv2-purchase-mode-option input {
  height: 1px;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  width: 1px;
}
.pv2-purchase-mode-option span {
  background: var(--surface, #fff);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 3px;
  min-height: 54px;
  padding: 10px 12px;
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}
.pv2-purchase-mode-option strong {
  color: var(--ink);
  font-size: 10px;
  letter-spacing: .035em;
}
.pv2-purchase-mode-option small {
  color: var(--muted);
  font-size: 8.8px;
  line-height: 1.35;
}
.pv2-purchase-mode-option input:checked + span {
  background: var(--surface-2, #f7f2ec);
  border-color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--ink);
}
.pv2-purchase-mode-option input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.pv2-purchase-mode:disabled .pv2-purchase-mode-option { cursor: default; opacity: .68; }

.pv2-event-list article,
.pv2-document-list article {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 9px 13px;
}

.pv2-event-list article:last-child,
.pv2-document-list article:last-child { border-bottom: 0; }
.pv2-event-list strong,
.pv2-event-list span,
.pv2-document-list strong,
.pv2-document-list span { display: block; }
.pv2-event-list strong,
.pv2-document-list strong { font-size: 10.5px; }
.pv2-event-list span,
.pv2-document-list span { color: var(--muted); font-size: 8.8px; margin-top: 3px; }

.pv2-empty-inline {
  color: var(--muted);
  font-size: 10px;
  padding: 18px 13px;
  text-align: center;
}

.pv2-notes {
  background: #faf7f3;
  border-radius: 10px;
  margin-top: 11px;
  padding: 11px 13px;
}
.pv2-notes strong { font-size: 10px; }
.pv2-notes p { color: var(--ink-soft); font-size: 10px; line-height: 1.55; margin: 5px 0 0; white-space: pre-wrap; }

.pv2-form-context {
  background: var(--surface-2);
  border-radius: 10px;
  display: grid;
  gap: 3px;
  margin-bottom: 15px;
  padding: 11px 13px;
}
.pv2-form-context strong { font-size: 11px; }
.pv2-form-context span { color: var(--muted); font-size: 9.5px; }

.pv2-adjustment-help {
  background: var(--blue-pale);
  border-radius: 9px;
  color: #385c70;
  font-size: 9.5px;
  line-height: 1.5;
  margin-bottom: 15px;
  padding: 10px 12px;
}
.pv2-adjustment-help.refund { background: var(--danger-pale); color: #7c2c2c; }
.pv2-adjustment-help.supplier_credit { background: var(--sage-pale); color: var(--pv2-green); }

.pv2-upload-row { border-bottom: 1px solid var(--line); padding-bottom: 13px; }
.pv2-upload-row label.disabled { opacity: .5; pointer-events: none; }
.pv2-document-list { border: 1px solid var(--line); border-radius: 10px; margin-top: 13px; overflow: hidden; }

.pv2-toast {
  background: var(--success);
  border-radius: 10px;
  bottom: 22px;
  box-shadow: var(--shadow);
  color: #fff;
  font-size: 11px;
  max-width: 390px;
  padding: 11px 13px;
  position: fixed;
  right: 22px;
  z-index: 220;
}
.pv2-toast.error { background: var(--danger); }

@media (max-width: 1180px) {
  .pv2-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pv2-detail-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .pv2-ledger-head { align-items: flex-start; flex-direction: column; gap: 4px; padding: 8px 10px; }
  .pv2-tabs { max-width: 100%; overflow-x: auto; padding-bottom: 1px; }
  .pv2-tab { white-space: nowrap; }
  .pv2-ledger-caption { padding: 0 2px 3px; }
  .pv2-filterbar { grid-template-columns: 1fr 1fr; }
  .pv2-filterbar .searchbox { grid-column: 1 / -1; }
  .pv2-detail-heading,
  .pv2-section-heading,
  .pv2-upload-row { align-items: flex-start; flex-direction: column; gap: 9px; }
  .pv2-detail-actions { justify-content: flex-start; }
  .pv2-purchase-line { grid-template-columns: 1fr 1fr; }
  .pv2-purchase-line .pv2-line-item { grid-column: 1 / -1; }
}


@media (max-width: 620px) {
  .pv2-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pv2-metrics .metric-card:last-child { grid-column: auto; }
  .pv2-metrics .metric-value { font-size: 18px; }
  .pv2-filterbar { grid-template-columns: 1fr; }
  .pv2-filterbar .searchbox { grid-column: auto; }
  .pv2-boundary { align-items: flex-start; flex-direction: column; gap: 3px; }
  .pv2-detail-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pv2-detail-metrics .metric-card:last-child { grid-column: auto; }
  .pv2-modal.wide { width: 100%; }
}

@media (max-width: 440px) {
  .pv2-metrics,
  .pv2-detail-metrics { grid-template-columns: 1fr; }
  .pv2-page-heading .page-actions { width: 100%; }
  .pv2-page-heading .page-actions .btn { flex: 1; }
  .pv2-toast { bottom: 12px; left: 12px; max-width: none; right: 12px; }
}

@media print {
  .pv2-tabs,
  .pv2-ledger-caption,
  .pv2-boundary { display: none !important; }
}