.pay-card {
  max-width: 820px;
}

.pay-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 0.35rem;
}

.pay-page-head h1 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.pay-page-head #btn-pay-cancel {
  flex: 0 0 auto;
  margin-top: 0.15rem;
}

.pay-form {
  gap: 18px;
}

.pay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pay-admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #eff6ff;
}

.pay-admin-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #2563eb;
}

.pay-admin-hint {
  margin: 0;
  flex: 1 1 220px;
  font-size: 0.82rem;
  color: var(--text-muted, #6b7280);
}

.pay-form.pay-admin-edit-mode .pay-admin-field[readonly] {
  background: #fff;
  border-color: #93c5fd;
}

.pay-form.pay-admin-edit-mode .pay-admin-field:not([readonly]) {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.12);
}

.pay-picker {
  display: grid;
  gap: 6px;
}

.pay-picker label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.pay-picker select {
  width: 100%;
  min-height: 42px;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  font-size: 0.95rem;
  line-height: 1.35;
  background: var(--bg, #fff);
  color: var(--text, #1f2937);
  cursor: pointer;
  appearance: auto;
  -webkit-appearance: menulist;
}

.pay-picker select:disabled,
.pay-fieldset select:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.pay-fieldset select {
  width: 100%;
  min-height: 42px;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 10px;
  font-size: 0.95rem;
  line-height: 1.35;
  background: var(--bg, #fff);
  color: var(--text, #1f2937);
  cursor: pointer;
}

.pay-fieldset input[readonly]:not([type="number"]) {
  background: #f9fafb;
  color: var(--text, #1f2937);
  font-weight: 600;
}

#agent-amount {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #2563eb;
}

.pay-ms-disbursement {
  margin-top: 14px;
  padding: 14px 14px 10px;
  border: 1px dashed var(--border, #e5e7eb);
  border-radius: 10px;
  background: #fffaf5;
}

.pay-ms-disbursement legend {
  padding: 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #c2410c;
}

.pay-summary-column {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  max-width: 420px;
}

.pay-summary-column label {
  width: 100%;
}

.pay-other-referral {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 12px 14px;
  border: 1px dashed var(--border, #e5e7eb);
  border-radius: 10px;
  background: #f9fafb;
}

@media (max-width: 640px) {
  .pay-other-referral {
    grid-template-columns: 1fr;
  }
}

.pay-summary-detail {
  opacity: 0.92;
}

.pay-summary-line + .pay-summary-line {
  padding-top: 4px;
}

.pay-summary-column > .pay-summary-line:first-of-type {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 2px solid var(--border, #e5e7eb);
}

.pay-breakdown-column {
  max-width: 420px;
}

.pay-breakdown-column .pay-ytd-stat {
  width: 100%;
}

#expense-fmls,
#expense-referral,
#expense-outside-referral,
#expense-brokerage {
  background: #fff;
}

.pay-total-ms-field input {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #c2410c;
  font-size: 1.05rem;
  font-weight: 700;
}

.pay-summary-agent input,
.pay-summary-agent strong {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #2563eb;
  font-size: 1.1rem;
  font-weight: 700;
}

.pay-ytd-payee {
  font-size: 0.68rem;
  color: var(--text-muted, #6b7280);
  line-height: 1.3;
}

.pay-refresh-btn {
  justify-self: start;
  margin-top: 2px;
}

.pay-empty-note,
.pay-auth-hint {
  margin: 0;
  color: var(--muted, #6b7280);
  font-size: 0.9rem;
}

.pay-fieldset {
  margin: 0;
  padding: 16px 16px 12px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.55);
}

.pay-fieldset:disabled {
  opacity: 0.65;
}

.pay-fieldset legend {
  padding: 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #6b7280);
}

.pay-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.pay-span-2 {
  grid-column: span 2;
}

.pay-hint {
  display: block;
  margin-top: 4px;
  color: var(--text-muted, #6b7280);
  font-size: 0.8rem;
  line-height: 1.4;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
}

.pay-cap-notice {
  margin: 0 0 18px;
  padding: 16px 18px;
  border-radius: 14px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.pay-cap-notice strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.pay-cap-agent {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.88;
  margin-bottom: 8px;
}

.pay-cap-headline {
  font-size: clamp(1.2rem, 2.4vw, 1.55rem);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.pay-cap-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.pay-cap-sub {
  margin: 8px 0 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.pay-cap-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 4px;
}

.pay-cap-stat {
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.pay-cap-stat-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.82;
  margin-bottom: 4px;
}

.pay-cap-stat-value {
  display: block;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  line-height: 1.15;
}

.pay-cap-loading-label {
  font-weight: 600;
}

.pay-cap-notice--loading {
  border: 1px dashed #d1d5db;
  background: #f9fafb;
  color: #6b7280;
}

.pay-cap-notice--active {
  border: 1px solid #93c5fd;
  background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
  color: #1e3a5f;
}

.pay-cap-notice--active .pay-cap-title,
.pay-cap-notice--active .pay-cap-stat-value {
  color: #2563eb;
}

.pay-cap-notice--capped {
  border: 2px solid #34d399;
  background: linear-gradient(180deg, #ecfdf5 0%, #d1fae5 100%);
  color: #065f46;
  padding: 20px 18px;
  box-shadow: 0 10px 24px rgba(16, 185, 129, 0.12);
}

.pay-cap-notice--capped .pay-cap-headline {
  color: #047857;
}

.pay-commission-report-panel {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  background: linear-gradient(180deg, #f9fafb 0%, #f3f4f6 100%);
  overflow: hidden;
}

.pay-commission-report-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

.pay-commission-report-summary::-webkit-details-marker {
  display: none;
}

.pay-commission-report-summary::before {
  content: "▸";
  margin-right: 8px;
  color: var(--text-muted, #6b7280);
  transition: transform 0.15s ease;
}

.pay-commission-report-panel[open] .pay-commission-report-summary::before {
  transform: rotate(90deg);
}

.pay-commission-report-heading {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #6b7280);
}

.pay-commission-report-teaser {
  font-size: 0.82rem;
  color: var(--text-muted, #6b7280);
}

.pay-commission-report-body {
  padding: 0 16px 14px;
}

.pay-ytd-title {
  margin: 0 0 12px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #6b7280);
}

.pay-ytd-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.pay-ytd-stat {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
}

.pay-ytd-stat strong {
  font-size: 1.05rem;
  color: var(--text, #1f2937);
}

.pay-ytd-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted, #6b7280);
}

.pay-commission-panel {
  padding: 14px 16px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  background: linear-gradient(180deg, #fffaf5 0%, #fff7ed 100%);
}

.pay-commission-ms {
  background: #fff7ed;
  border-color: #fed7aa;
}

.pay-commission-ms strong {
  color: #c2410c;
}

.pay-commission-agent {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.pay-commission-agent strong {
  color: #2563eb;
}

.pay-ytd-highlight {
  grid-column: span 2;
  background: #ecfdf3;
  border-color: #bbf7d0;
}

.pay-ytd-highlight strong {
  font-size: 1.35rem;
  color: #166534;
}

.pay-report-card {
  margin-top: 18px;
  padding: 0;
  overflow: hidden;
}

.pay-report-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.pay-report-toolbar h2 {
  margin: 0;
  font-size: 1.05rem;
}

.pay-report-frame {
  width: 100%;
  min-height: 720px;
  border: 0;
  background: #f4f7fb;
}

@media (max-width: 640px) {
  .pay-grid,
  .pay-ytd-grid {
    grid-template-columns: 1fr;
  }

  .pay-span-2,
  .pay-ytd-highlight {
    grid-column: span 1;
  }
}