/* Shared dialogs grow with their content while remaining inside the viewport.
   Account management and order details retain their dedicated layouts. */
#modal {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

#modal .modal-card:not(:has(.account-management)) {
  min-width: 0;
  max-width: 100%;
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  overscroll-behavior: contain;
}

#modal:not(.order-details-modal) .modal-card:not(:has(.account-management)) {
  width: min(600px, 100%);
}

#modal:not(.order-details-modal) .modal-card:has(.table-scroll):not(:has(.account-management)) {
  width: fit-content;
  min-width: min(840px, 100%);
  max-width: min(1160px, 100%);
}

#modal-content:not(:has(.account-management)) {
  min-width: 0;
  max-width: none;
  overflow-wrap: anywhere;
}

#modal-content:not(:has(.account-management)) :is(.form-grid, .member-form-grid) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#modal-content:not(:has(.account-management)) :is(form, label, fieldset, input, select, textarea) {
  min-width: 0;
}

#modal-content:not(:has(.account-management)) .table-scroll {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

#modal-content:not(:has(.account-management)) .table-scroll table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  line-height: 1.6;
  text-align: left;
}

#modal-content:not(:has(.account-management)) .table-scroll :is(th, td) {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
  overflow-wrap: anywhere;
}

#modal-content:not(:has(.account-management)) .table-scroll th {
  background: #f5f9f8;
  color: #687e84;
  font-size: 12px;
  font-weight: 600;
}

#modal-content:not(:has(.account-management)) .table-scroll tr:last-child td {
  border-bottom: 0;
}

#modal-content:not(:has(.account-management)) .table-scroll .member-money-cell {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#modal-content:not(:has(.account-management)) .table-scroll :is(.status, .btn) {
  white-space: nowrap;
}

#modal-content:not(:has(.account-management)) .table-scroll .empty-state {
  padding: 28px 14px;
  text-align: center;
}

#modal .modal-actions {
  flex-wrap: wrap;
}

@media (max-width: 650px) {
  #modal-content:not(:has(.account-management)) :is(.form-grid, .member-form-grid) {
    grid-template-columns: minmax(0, 1fr);
  }

  #modal-content:not(:has(.account-management)) .table-scroll :is(th, td) {
    padding: 10px 8px;
    font-size: 12px;
  }

  #modal .modal-actions .btn {
    max-width: 100%;
    white-space: normal;
  }
}
