:root {
  --pma-primary: var(--blue);
  --pma-primary-dark: #2455c8;
  --pma-primary-soft: var(--blue-soft);
  --pma-text: #0f172a;
  --pma-muted: #64748b;
  --pma-border: #e2e8f0;
  --pma-surface: #ffffff;
  --pma-canvas: #f6f8fb;
  --pma-success: #16a34a;
  --pma-danger: #dc2626;
  --pma-warning: #d97706;
}

.pma-app {
  min-height: 100vh;
  background: var(--pma-canvas);
  color: var(--pma-text);
}

.pma-page {
  min-width: 0;
  padding: 28px 32px 44px;
}

.pma-shell {
  width: min(100%, 1720px);
  margin: 0 auto;
}

.pma-heading,
.pma-heading-stats,
.pma-subnav,
.pma-filter-actions,
.pma-card-toolbar,
.pma-card-actions,
.pma-footer,
.pma-pagination,
.pma-modal-header,
.pma-modal-footer,
.pma-status-option,
.pma-value,
.pma-user-cell,
.pma-action-group,
.pma-balance-summary,
.pma-language-grid,
.pma-modal-tools {
  display: flex;
  align-items: center;
}

.pma-heading {
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.pma-heading h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.pma-heading p {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--pma-muted);
  font-size: 14px;
  line-height: 1.65;
}

.pma-heading-stats {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.pma-stat {
  min-width: 126px;
  padding: 10px 13px;
  border: 1px solid var(--pma-border);
  border-radius: 10px;
  background: var(--pma-surface);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.pma-stat span,
.pma-stat strong {
  display: block;
}

.pma-stat span {
  color: var(--pma-muted);
  font-size: 12px;
  font-weight: 750;
}

.pma-stat strong {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 900;
}

.pma-subnav {
  width: fit-content;
  max-width: 100%;
  gap: 4px;
  padding: 5px;
  margin-bottom: 18px;
  overflow-x: auto;
  border-radius: 10px;
  background: #edf1f7;
  scrollbar-width: none;
}

.pma-subnav::-webkit-scrollbar {
  display: none;
}

.pma-subnav a {
  min-width: 100px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border-radius: 7px;
  color: var(--pma-muted);
  font-size: 13px;
  font-weight: 850;
  text-decoration: none;
  white-space: nowrap;
}

.pma-subnav a:hover,
.pma-subnav a:focus-visible {
  color: var(--pma-primary);
}

.pma-subnav a.active {
  background: #fff;
  color: var(--pma-text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.pma-filter-card,
.pma-table-card,
.pma-info-card {
  border: 1px solid var(--pma-border);
  border-radius: 13px;
  background: var(--pma-surface);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.045);
}

.pma-filter-card {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 15px 18px;
  align-items: end;
  margin-bottom: 18px;
  padding: 18px 20px;
}

.pma-filter-card.compact {
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr) auto;
}

.pma-filter-card label,
.pma-field,
.pma-fieldset {
  min-width: 0;
}

.pma-filter-card label > span,
.pma-field > span,
.pma-fieldset legend {
  display: block;
  margin-bottom: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}

.pma-field.required > span::before,
.pma-fieldset.required legend::before {
  content: "*";
  margin-right: 4px;
  color: #ef4444;
}

.pma-filter-card input,
.pma-filter-card select,
.pma-field input,
.pma-field select,
.pma-field textarea {
  width: 100%;
  border: 1px solid #cfd8e5;
  border-radius: 8px;
  background: #fff;
  color: var(--pma-text);
  font: inherit;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.pma-filter-card input,
.pma-filter-card select,
.pma-field input,
.pma-field select {
  height: 40px;
  padding: 0 12px;
}

.pma-field textarea {
  min-height: 118px;
  padding: 11px 12px;
  line-height: 1.55;
  resize: vertical;
}

.pma-filter-card input:focus,
.pma-filter-card select:focus,
.pma-field input:focus,
.pma-field select:focus,
.pma-field textarea:focus {
  border-color: #7ba5ff;
  box-shadow: 0 0 0 3px rgba(var(--blue-rgb), 0.12);
}

.pma-date-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.pma-filter-actions {
  align-self: end;
  justify-content: flex-start;
  gap: 9px;
}

.pma-button,
.pma-icon-button,
.pma-link-button,
.pma-page-button {
  appearance: none;
  border: 0;
  font: inherit;
  cursor: pointer;
}

.pma-button {
  min-width: 82px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 850;
  white-space: nowrap;
}

.pma-button.primary {
  background: var(--pma-primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(var(--blue-rgb), 0.17);
}

.pma-button.primary:hover {
  background: var(--pma-primary-dark);
}

.pma-button.secondary {
  border-color: #bfdbfe;
  background: #fff;
  color: var(--pma-primary);
}

.pma-button.neutral {
  border-color: #d5dbe5;
  background: #fff;
  color: #334155;
}

.pma-button.danger {
  border-color: #fecaca;
  background: #fff;
  color: var(--pma-danger);
}

.pma-button:disabled,
.pma-page-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pma-table-card {
  overflow: hidden;
}

.pma-card-toolbar {
  justify-content: space-between;
  min-height: 62px;
  gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--pma-border);
}

.pma-card-toolbar h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
}

.pma-card-toolbar p {
  margin: 4px 0 0;
  color: var(--pma-muted);
  font-size: 12px;
}

.pma-card-actions {
  justify-content: flex-end;
  gap: 8px;
}

.pma-icon-button {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #d5dbe5;
  border-radius: 7px;
  background: #fff;
  color: #475569;
  font-size: 15px;
}

.pma-icon-button:hover {
  border-color: #9bb9ff;
  color: var(--pma-primary);
}

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

.pma-table {
  width: 100%;
  min-width: 1160px;
  border-collapse: collapse;
  table-layout: auto;
  color: #334155;
  font-size: 12.5px;
}

.pma-table.wide {
  min-width: 1450px;
}

.pma-table th,
.pma-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf1f6;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.pma-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6f9fd;
  color: #64748b;
  font-weight: 850;
}

.pma-table tbody tr:hover {
  background: #fbfdff;
}

.pma-table tbody tr:last-child td {
  border-bottom: 0;
}

.pma-table td.wrap,
.pma-table th.wrap {
  white-space: normal;
}

.pma-user-cell {
  align-items: flex-start;
  flex-direction: column;
  gap: 2px;
}

.pma-user-cell strong {
  color: var(--pma-text);
  font-weight: 850;
}

.pma-user-cell span,
.pma-user-cell small {
  color: var(--pma-muted);
  font-size: 11px;
}

.pma-value {
  gap: 5px;
  font-weight: 850;
}

.pma-value.positive {
  color: var(--pma-success);
}

.pma-value.negative {
  color: var(--pma-danger);
}

.pma-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 850;
}

.pma-status.blue {
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: var(--blue-ink);
}

.pma-status.green {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #15803d;
}

.pma-status.red {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #dc2626;
}

.pma-status.amber {
  border: 1px solid #fde68a;
  background: #fffbeb;
  color: #b45309;
}

.pma-status.slate {
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
}

.pma-action-group {
  gap: 10px;
}

.pma-link-button {
  padding: 0;
  background: transparent;
  color: var(--pma-primary);
  font-size: 12px;
  font-weight: 850;
}

.pma-link-button:hover {
  color: var(--pma-primary-dark);
  text-decoration: underline;
}

.pma-link-button.danger {
  color: var(--pma-danger);
}

.pma-empty {
  padding: 56px 20px;
  color: var(--pma-muted);
  text-align: center;
}

.pma-footer {
  justify-content: space-between;
  gap: 14px;
  min-height: 60px;
  padding: 10px 16px;
  border-top: 1px solid var(--pma-border);
  color: var(--pma-muted);
  font-size: 12px;
}

.pma-footer-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.pma-page-size {
  height: 32px;
  border: 1px solid #d5dbe5;
  border-radius: 6px;
  background: #fff;
  color: #475569;
}

.pma-pagination {
  justify-content: flex-end;
}

.pma-page-button {
  min-width: 34px;
  height: 34px;
  margin-left: -1px;
  border: 1px solid #dbe1ea;
  background: #fff;
  color: #475569;
  font-size: 12px;
}

.pma-page-button:first-child {
  margin-left: 0;
  border-radius: 6px 0 0 6px;
}

.pma-page-button:last-child {
  border-radius: 0 6px 6px 0;
}

.pma-page-button.active {
  position: relative;
  z-index: 1;
  border-color: var(--pma-primary);
  background: var(--pma-primary);
  color: #fff;
}

.pma-switch {
  position: relative;
  width: 36px;
  height: 20px;
  display: inline-block;
}

.pma-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.pma-switch i {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #dfe4eb;
  cursor: pointer;
  transition: 0.18s ease;
}

.pma-switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.28);
  transition: 0.18s ease;
}

.pma-switch input:checked + i {
  background: var(--pma-primary);
}

.pma-switch input:checked + i::after {
  transform: translateX(16px);
}

.pma-helper-banner {
  margin: -1px 0 14px;
  padding: 11px 14px;
  border: 1px solid #dbeafe;
  border-radius: 9px;
  background: #f5f9ff;
  color: #475569;
  font-size: 12px;
  line-height: 1.6;
}

.pma-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2600;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
}

.pma-modal-backdrop[hidden] {
  display: none;
}

.pma-modal {
  width: min(720px, 100%);
  max-height: min(820px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 26px 70px rgba(15, 23, 42, 0.25);
}

.pma-modal.large {
  width: min(860px, 100%);
}

.pma-modal-header {
  justify-content: space-between;
  min-height: 66px;
  padding: 0 22px;
  border-bottom: 1px solid var(--pma-border);
}

.pma-modal-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
}

.pma-modal-tools {
  gap: 6px;
}

.pma-modal-tools button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #475569;
  font-size: 18px;
  cursor: pointer;
}

.pma-modal-tools button:hover {
  background: #f1f5f9;
}

.pma-modal-body {
  min-height: 0;
  padding: 22px;
  overflow: auto;
}

.pma-modal-footer {
  justify-content: flex-end;
  gap: 10px;
  min-height: 72px;
  padding: 14px 22px;
  border-top: 1px solid var(--pma-border);
  background: #fff;
}

.pma-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 24px;
}

.pma-detail-item.full {
  grid-column: 1 / -1;
}

.pma-detail-item dt {
  margin-bottom: 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 850;
}

.pma-detail-item dd {
  margin: 0;
  color: #64748b;
  font-size: 14px;
  line-height: 1.55;
}

.pma-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 17px 18px;
}

.pma-field.full,
.pma-fieldset.full {
  grid-column: 1 / -1;
}

.pma-field small {
  display: block;
  margin-top: 6px;
  color: var(--pma-muted);
  font-size: 11px;
}

.pma-input-count {
  position: relative;
}

.pma-input-count input {
  padding-right: 54px;
}

.pma-input-count em {
  position: absolute;
  top: 50%;
  right: 12px;
  color: #94a3b8;
  font-size: 12px;
  font-style: normal;
  transform: translateY(-50%);
}

.pma-status-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pma-status-option {
  gap: 8px;
  min-width: 104px;
  height: 40px;
  justify-content: center;
  border: 1px solid #dbe1ea;
  border-radius: 8px;
  color: #475569;
  font-weight: 800;
  cursor: pointer;
}

.pma-status-option:has(input:checked) {
  border-color: #8ab0ff;
  background: var(--pma-primary-soft);
  color: var(--pma-primary);
}

.pma-balance-summary {
  align-items: stretch;
  gap: 10px;
  margin-bottom: 18px;
}

.pma-balance-summary article {
  flex: 1;
  padding: 13px;
  border: 1px solid var(--pma-border);
  border-radius: 9px;
  background: #f8fafc;
}

.pma-balance-summary span,
.pma-balance-summary strong {
  display: block;
}

.pma-balance-summary span {
  color: var(--pma-muted);
  font-size: 11px;
}

.pma-balance-summary strong {
  margin-top: 5px;
  font-size: 17px;
}

.pma-inline-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.pma-inline-table th,
.pma-inline-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--pma-border);
  text-align: left;
}

.pma-language-grid {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.pma-language-grid label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #475569;
  font-size: 13px;
  white-space: nowrap;
}

.pma-language-grid input {
  width: 16px;
  height: 16px;
  accent-color: var(--pma-primary);
}

.pma-stepper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
}

.pma-stepper span {
  height: 4px;
  border-radius: 99px;
  background: #e2e8f0;
}

.pma-stepper span.active {
  background: var(--pma-primary);
}

.pma-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--pma-danger);
  font-size: 12px;
}

.pma-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2900;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 16px;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.28);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.pma-toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1280px) {
  .pma-filter-card {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .pma-heading {
    flex-direction: column;
  }

  .pma-heading-stats {
    justify-content: flex-start;
  }
}

@media (max-width: 860px) {
  .pma-page {
    padding: 20px 16px 34px;
  }

  .pma-heading h1 {
    font-size: 25px;
  }

  .pma-filter-card,
  .pma-filter-card.compact {
    grid-template-columns: 1fr;
    padding: 15px;
  }

  .pma-filter-actions,
  .pma-filter-actions .pma-button {
    width: 100%;
  }

  .pma-card-toolbar,
  .pma-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .pma-card-actions,
  .pma-pagination {
    justify-content: flex-start;
  }

  .pma-modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .pma-modal,
  .pma-modal.large {
    width: 100%;
    max-height: 92vh;
    border-radius: 14px 14px 0 0;
  }

  .pma-detail-grid,
  .pma-form-grid {
    grid-template-columns: 1fr;
  }

  .pma-detail-item.full,
  .pma-field.full,
  .pma-fieldset.full {
    grid-column: auto;
  }

  .pma-balance-summary {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .pma-stat {
    min-width: calc(50% - 5px);
  }

  .pma-heading-stats {
    width: 100%;
  }

  .pma-date-range {
    grid-template-columns: 1fr;
  }

  .pma-modal-header,
  .pma-modal-footer {
    padding-inline: 16px;
  }

  .pma-modal-body {
    padding: 18px 16px;
  }
}
