

#beneficiary-host {
  display: contents;
}

#search-beneficiary.beneficiary-active-fallback {
  display: block;
}

body:has(#search-beneficiary.beneficiary-active-fallback) .dashboard {
  display: none;
}

#search-beneficiary.screen {
  box-sizing: border-box;
  width: min(100%, 1060px);
  max-width: 1060px;
  min-width: 0;
  padding: 0 24px;
}

#search-beneficiary .screen-title {
  margin-bottom: 10px;
}

#search-beneficiary .screen-header {
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 6px 0 8px;
  padding-right: 168px;
}

#search-beneficiary .screen-header > div:not(.search-beneficiary-actions) {
  width: 100%;
  min-width: 0;
}

#search-beneficiary .search-fields {
  width: 100%;
  min-width: 0;
}

#search-beneficiary .grid-wrap {
  width: 100%;
  min-width: 0;
  scrollbar-gutter: stable;
}

#search-beneficiary .grid-wrap table {
  width: 100%;
  min-width: 1220px;
  table-layout: fixed;
}


#search-beneficiary .grid-wrap th,
#search-beneficiary .grid-wrap td {
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#search-beneficiary .grid-wrap th:nth-child(1),
#search-beneficiary .grid-wrap td:nth-child(1) {
  width: 72px;
}

#search-beneficiary .grid-wrap th:nth-child(2),
#search-beneficiary .grid-wrap td:nth-child(2) {
  width: 48px;
  text-align: center;
}

#search-beneficiary .grid-wrap th:nth-child(3),
#search-beneficiary .grid-wrap td:nth-child(3) {
  width: 110px;
}

#search-beneficiary .grid-wrap th:nth-child(4),
#search-beneficiary .grid-wrap td:nth-child(4) {
  width: 220px;
}

#search-beneficiary .grid-wrap th:nth-child(5),
#search-beneficiary .grid-wrap td:nth-child(5) {
  width: 135px;
}

#search-beneficiary .grid-wrap th:nth-child(6),
#search-beneficiary .grid-wrap td:nth-child(6) {
  width: 150px;
}

#search-beneficiary .grid-wrap th:nth-child(7),
#search-beneficiary .grid-wrap td:nth-child(7) {
  width: 190px;
}

#search-beneficiary .grid-wrap th:nth-child(8),
#search-beneficiary .grid-wrap td:nth-child(8) {
  width: 90px;
}

#search-beneficiary .grid-wrap th:nth-child(9),
#search-beneficiary .grid-wrap td:nth-child(9) {
  width: 110px;
}

#search-beneficiary .grid-wrap th:nth-child(10),
#search-beneficiary .grid-wrap td:nth-child(10) {
  width: 125px;
}

#search-beneficiary .import-status:empty {
  min-height: 0;
  margin-top: 0;
}

#search-beneficiary .screen-header > .search-beneficiary-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: auto;
  min-width: 0;
  height: auto;
  margin: 0;
  padding: 0;
  overflow: visible;
}

#search-beneficiary .search-beneficiary-actions .exit-button {
  position: relative;
  top: auto;
  right: auto;
}

#search-beneficiary .beneficiary-mobile-action {
  display: none;
}

@media (max-width: 640px) {
  #search-beneficiary.screen {
    padding: 0 10px;
  }

  #search-beneficiary .screen-header {
    padding: 14px;
  }

  #search-beneficiary .screen-header > .search-beneficiary-actions {
    position: static;
    width: 100%;
    margin-bottom: 8px;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  #search-beneficiary .beneficiary-mobile-action {
    display: inline-flex;
    align-items: center;
    width: auto;
  }

  #search-beneficiary #importBeneficiaryButton {
    display: none;
  }

  #search-beneficiary .search-beneficiary-actions .exit-button {
    margin-left: auto;
  }
}

#beneficiaryMergeModal .import-panel {
  width: min(960px, 96vw);
}

#beneficiaryMergeModal .po-add-beneficiary-grid table {
  min-width: 1080px;
  table-layout: fixed;
}

#beneficiaryMergeModal .po-add-beneficiary-grid {
  overflow: auto;
}

#beneficiaryMergeModal .po-add-beneficiary-grid th,
#beneficiaryMergeModal .po-add-beneficiary-grid td {
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#beneficiaryMergeModal .po-add-beneficiary-grid th:nth-child(1),
#beneficiaryMergeModal .po-add-beneficiary-grid td:nth-child(1) {
  width: 44px;
}

#beneficiaryMergeModal .po-add-beneficiary-grid th:nth-child(2),
#beneficiaryMergeModal .po-add-beneficiary-grid td:nth-child(2) {
  width: 90px;
}

#beneficiaryMergeModal .po-add-beneficiary-grid th:nth-child(3),
#beneficiaryMergeModal .po-add-beneficiary-grid td:nth-child(3) {
  width: 90px;
}

#beneficiaryMergeModal .po-add-beneficiary-grid th:nth-child(4),
#beneficiaryMergeModal .po-add-beneficiary-grid td:nth-child(4) {
  width: 260px;
}

#beneficiaryMergeModal .po-add-beneficiary-grid th:nth-child(5),
#beneficiaryMergeModal .po-add-beneficiary-grid td:nth-child(5) {
  width: 150px;
}

#beneficiaryMergeModal .po-add-beneficiary-grid th:nth-child(6),
#beneficiaryMergeModal .po-add-beneficiary-grid td:nth-child(6) {
  width: 90px;
}

#beneficiaryMergeModal .po-add-beneficiary-grid th:nth-child(7),
#beneficiaryMergeModal .po-add-beneficiary-grid td:nth-child(7) {
  width: 270px;
}

#beneficiaryMergeModal .po-add-beneficiary-grid th:nth-child(8),
#beneficiaryMergeModal .po-add-beneficiary-grid td:nth-child(8) {
  width: 86px;
}

#beneficiaryMergeModal .merge-group-row td {
  background: #f3f7f9;
  color: var(--brand);
  font-weight: 700;
}


.profile-top {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 6px 10px;
  background: #eeeeee;
  border-bottom: 1px solid #c8c8c8;
}

.profile-id {
  color: #ff1730;
  font-size: 14px;
  padding-top: 8px;
}

.profile-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 400;
}

.profile-meta {
  display: grid;
  grid-template-columns: auto 130px 188px auto 188px;
  gap: 4px;
  align-items: center;
  font-size: 13px;
}

.profile-meta input {
  width: 100%;
}

.profile-actions {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 70px;
  justify-content: end;
  gap: 4px;
}

#beneficiaryCleanupButton {
  padding-inline: 4px;
  font-size: 12px;
  white-space: nowrap;
}

.profile-body {
  padding: 10px;
}

.profile-form {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(680px, 2fr);
  gap: 14px;
  align-items: start;
}


.name-badge-row {
  display: grid;
  grid-template-columns: minmax(330px, 1fr) minmax(330px, 1fr);
  gap: 8px 18px;
  align-items: center;
  margin-top: 6px;
  font-size: 14px;
}

.badge-name-row {
  display: grid;
  grid-template-columns: 98px 1fr;
  gap: 8px 14px;
  align-items: center;
}

.badge-name-row.wide {
  grid-column: 1 / -1;
}

.badge-name-row input {
  width: 100%;
  min-width: 0;
}

@media (max-width: 430px) {
  .name-badge-row {
      display: block;
    }
}

@media (max-width: 1000px) {
  .name-badge-row {
      grid-template-columns: 1fr 1fr;
    }
}


.measurement-layout {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 10px;
  min-height: 430px;
}

.standard-size-panel,
.detail-size-panel {
  border-right: 1px solid #9ca9ba;
  padding: 4px 8px;
}

.detail-size-panel {
  border-right: 0;
}

.measurement-heading {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 700;
}

.standard-size-title {
  font-size: 14px;
  font-weight: 700;
}

.std-size-table table {
  min-width: 455px;
}

.std-size-table th,
.std-size-table td {
  padding: 2px 4px;
}

.measurement-detail-grid {
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 12px;
  align-items: start;
}

.measure-table {
  border: 1px solid #9ca9ba;
  padding: 6px 10px;
}

.measure-table table {
  min-width: 240px;
  font-size: 14px;
}

.measure-table th,
.measure-table td {
  height: 32px;
  font-size: 14px;
}

.measure-table input {
  width: 100%;
  min-height: 28px;
  border: 0;
  background: transparent;
  padding: 2px 6px;
}

.remarks-panel {
  display: grid;
  gap: 4px;
}

.remarks-panel textarea {
  height: 110px;
  border: 1px solid #9ca9ba;
  resize: vertical;
  font: inherit;
}

@media (max-width: 430px) {
  .measurement-layout,
  .measurement-detail-grid,
  .measurement-heading {
    display: block;
  }
}

@media (max-width: 1000px) {
  .measurement-layout,
  .measurement-detail-grid {
    grid-template-columns: 1fr;
  }
}


.delivery-title {
  margin-bottom: 16px;
  font-weight: 700;
  text-align: center;
}

.delivery-title span {
  display: inline-block;
}

.delivery-form {
  display: none;
}

.delivery-table {
  width: 100%;
  border: 1px solid rgba(31, 111, 139, 0.14);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.delivery-table table {
  min-width: 820px;
}

.delivery-form label {
  color: #7b8795;
  text-align: center;
}

.delivery-form input,
.delivery-form select {
  width: 100%;
}

.delivery-open-button {
  min-width: 44px;
  width: auto;
  height: 28px;
  padding: 0 8px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #b9d8e1;
  border-radius: 9px;
  background: #eaf8fa;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.delivery-open-button::before {
  content: none;
}

.delivery-open-button:hover,
.delivery-open-button:focus {
  background: #d9f0f4;
  outline: 1px solid #bdd5df;
}

.delivery-form .delivery-open-button ~ .delivery-open-button {
  display: none;
}

@media (max-width: 430px) {
  .delivery-form {
    display: block;
  }
}

@media (max-width: 640px) {
  #beneficiary-info .std-size-table {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  #beneficiary-info .std-size-table table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  #beneficiary-info .std-size-table :is(th, td):nth-child(1) { width: 48%; }
  #beneficiary-info .std-size-table :is(th, td):nth-child(2) { width: 32%; }
  #beneficiary-info .std-size-table :is(th, td):nth-child(3) { width: 20%; }

  /* Update metadata is already shown below the size table. Repeating it as
     narrow columns on phones creates empty border strips and hides item data. */
  #beneficiary-info .std-size-table th:nth-child(4),
  #beneficiary-info .std-size-table th:nth-child(5),
  #beneficiary-info .std-size-table td:nth-child(4):not([colspan]),
  #beneficiary-info .std-size-table td:nth-child(5):not([colspan]) {
    display: none;
  }

  .delivery-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  /* The delivery-form markup lists all labels first, then all values.
     On mobile the single column would separate every label from its value,
     so pair them back up with order: label, its input, label, its input... */
  .delivery-form > span {
    display: none;
  }

  .delivery-form label {
    text-align: left;
    margin-top: 8px;
    font-size: 12px;
  }

  .delivery-form input {
    width: 100%;
    box-sizing: border-box;
  }

  .delivery-form label:nth-of-type(1) { order: 1; }
  .delivery-form input:nth-of-type(1) { order: 2; }
  .delivery-form label:nth-of-type(2) { order: 3; }
  .delivery-form input:nth-of-type(2) { order: 4; }
  .delivery-form label:nth-of-type(3) { order: 5; }
  .delivery-form input:nth-of-type(3) { order: 6; }
  .delivery-form label:nth-of-type(4) { order: 7; }
  .delivery-form input:nth-of-type(4) { order: 8; }
  .delivery-form label:nth-of-type(5) { order: 9; }
  .delivery-form input:nth-of-type(5) { order: 10; }
  .delivery-form label:nth-of-type(6) { order: 11; }
  .delivery-form input:nth-of-type(6) { order: 12; }

  .delivery-form .delivery-open-button {
    order: 20;
    justify-self: start;
    margin-top: 10px;
  }

  #beneficiary-info {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  #beneficiary-info .profile-top {
    grid-template-columns: 1fr !important;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 14px;
    box-sizing: border-box;
  }

  #beneficiary-info .profile-top > *,
  #beneficiary-info .profile-top > div:nth-child(2),
  #beneficiary-info .profile-meta,
  #beneficiary-info .profile-actions,
  #beneficiary-info .profile-body,
  #beneficiary-info .profile-form,
  #beneficiary-info .profile-form > *,
  #beneficiary-info .name-badge-row,
  #beneficiary-info .badge-name-row {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  #beneficiary-info .profile-top > *,
  #beneficiary-info .profile-meta,
  #beneficiary-info .profile-form,
  #beneficiary-info .name-badge-row,
  #beneficiary-info .badge-name-row {
    grid-column: 1 / -1;
    grid-template-columns: 1fr !important;
    gap: 8px;
  }

  #beneficiary-info .profile-title {
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  #beneficiary-info .profile-actions {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  #beneficiary-info .profile-actions .exit-button {
    margin-left: auto !important;
  }

  #beneficiary-info input,
  #beneficiary-info select,
  #beneficiary-info textarea,
  #beneficiary-info .ts-control,
  #beneficiary-info .ts-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
  }
}


#beneficiary-info .profile-top {
  grid-template-columns: 72px minmax(0, 1fr) auto;
  width: 100%;
  min-width: 0;
}

#beneficiary-info .profile-top > div:nth-child(2) {
  min-width: 0;
}

#beneficiary-info .profile-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 6px;
  width: auto;
  max-width: 390px;
  min-width: 0;
}

#beneficiary-info .profile-actions .small-button:not(.exit-button) {
  width: auto;
  min-width: 70px;
  padding-inline: 8px;
  white-space: nowrap;
}

#beneficiary-info .profile-actions .exit-button {
  flex: 0 0 40px;
  position: relative !important;
  top: auto !important;
  right: auto !important;
  margin: 0;
}

#beneficiary-info .profile-meta {
  grid-template-columns: auto minmax(100px, 130px) minmax(145px, 188px) auto minmax(145px, 188px);
  min-width: 0;
}

@media (max-width: 1120px) {
  #beneficiary-info .profile-actions {
    max-width: 230px;
  }
}


/* ==========================================================================
   search-beneficiary — compact mobile TABLE (module-scoped, <=640px).
   Shows only the most useful columns on phones; other desktop columns are hidden
   VISUALLY (kept in the DOM, still populated, reachable after Open). Desktop
   table unchanged above 640px. Shared compact-table styling for consistency.
   ========================================================================== */
@media (max-width: 640px) {
  #search-beneficiary .grid-wrap {
    border-top: 0;
    max-height: 70vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
  }
  #search-beneficiary .grid-wrap > table {
    min-width: 480px;
    width: 480px;
    table-layout: fixed;
    border-collapse: collapse;
  }
  #search-beneficiary .grid-wrap > table > thead {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    clip: auto;
  }
  #search-beneficiary .grid-wrap > table > thead > tr > th {
    background: #eef2f7;
    color: #213247;
    font-size: 12px;
    font-weight: 700;
    padding: 8px 5px;
    white-space: normal;
    text-align: left;
    vertical-align: middle;
  }
  #search-beneficiary .grid-wrap > table > tbody > tr > td {
    display: table-cell;
    padding: 8px 5px;
    font-size: 13px;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: break-word;
    text-align: left;
    vertical-align: middle;
    border: 0;
    border-bottom: 1px solid #e3e8ee;
    max-width: none;
    min-width: 0;
    width: auto;
  }
  #search-beneficiary .grid-wrap > table > tbody > tr > td::before { content: none; }
  #search-beneficiary .grid-wrap > table > thead > tr > th:nth-child(1),
  #search-beneficiary .grid-wrap > table > tbody > tr > td:nth-child(1):not([colspan]) { display: none; }
  #search-beneficiary .grid-wrap > table > thead > tr > th:nth-child(5),
  #search-beneficiary .grid-wrap > table > tbody > tr > td:nth-child(5):not([colspan]) { display: none; }
  #search-beneficiary .grid-wrap > table > thead > tr > th:nth-child(7),
  #search-beneficiary .grid-wrap > table > tbody > tr > td:nth-child(7):not([colspan]) { display: none; }
  #search-beneficiary .grid-wrap > table > thead > tr > th:nth-child(8),
  #search-beneficiary .grid-wrap > table > tbody > tr > td:nth-child(8):not([colspan]) { display: none; }
  #search-beneficiary .grid-wrap > table > thead > tr > th:nth-child(9),
  #search-beneficiary .grid-wrap > table > tbody > tr > td:nth-child(9):not([colspan]) { display: none; }
  #search-beneficiary .grid-wrap > table > thead > tr > th:nth-child(10),
  #search-beneficiary .grid-wrap > table > tbody > tr > td:nth-child(10):not([colspan]) { display: none; }
  #search-beneficiary .grid-wrap > table > thead > tr > th:nth-child(2),
  #search-beneficiary .grid-wrap > table > tbody > tr > td:nth-child(2) { width: 44px; }
  #search-beneficiary .grid-wrap > table > thead > tr > th:nth-child(3),
  #search-beneficiary .grid-wrap > table > tbody > tr > td:nth-child(3) { width: 88px; }
  #search-beneficiary .grid-wrap > table > thead > tr > th:nth-child(4),
  #search-beneficiary .grid-wrap > table > tbody > tr > td:nth-child(4) { width: 220px; }
  #search-beneficiary .grid-wrap > table > thead > tr > th:nth-child(6),
  #search-beneficiary .grid-wrap > table > tbody > tr > td:nth-child(6) { width: 128px; }
  /* Keep the short primary identifier on one line */
  #search-beneficiary .grid-wrap > table > thead > tr > th:nth-child(3),
  #search-beneficiary .grid-wrap > table > tbody > tr > td:nth-child(3) { white-space: nowrap; }
  /* Action / Open control: compact, centered, touch-friendly */
  #search-beneficiary .grid-wrap > table .open-cell,
  #search-beneficiary .grid-wrap > table .edit-cell,
  #search-beneficiary .grid-wrap > table .pd-open-cell,
  #search-beneficiary .grid-wrap > table .po-icon-cell {
    width: 1%;
    white-space: nowrap;
    text-align: center;
    padding: 6px 5px;
  }
  #search-beneficiary .grid-wrap > table .open-cell a,
  #search-beneficiary .grid-wrap > table .edit-cell button,
  #search-beneficiary .grid-wrap > table .pd-open-cell button,
  #search-beneficiary .grid-wrap > table .po-icon-cell a {
    display: inline-block;
    min-width: 36px;
    min-height: 32px;
    line-height: 1.5;
    padding: 3px 6px;
  }
  #search-beneficiary .grid-wrap > table > tbody > tr > td[colspan] {
    text-align: center;
    color: #6a7785;
    white-space: normal;
  }
}
