


#search-customer.customer-search-active-fallback {
  display: block;
}

body:has(#search-customer.customer-search-active-fallback) .dashboard {
  display: none;
}

.customer-info-screen {
  width: min(100%, 1290px);
  display: none;
  background: #f6f6f6;
  border: 1px solid #aeb7c4;
}

.customer-info-top {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 6px 180px 2px 12px;
  background: #e3e9f1;
  border-top: 0;
}

.customer-info-title {
  margin: 0;
  font-size: 22px;
  font-weight: 400;
}

.customer-info-actions {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 8px;
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
}

.customer-info-actions .small-button:not(.exit-button) {
  width: auto;
  min-width: 108px;
  white-space: normal;
}

.customer-info-top .customer-info-actions .exit-button {
  position: relative !important;
  top: auto !important;
  right: auto !important;
  margin: 0;
}

.customer-info-body {
  padding: 8px 12px 0;
}

.customer-fields {
  display: grid;
  grid-template-columns: minmax(440px, 1fr) minmax(500px, 1fr);
  gap: 54px;
  align-items: start;
}

.customer-field-grid {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 4px;
  align-items: center;
  font-size: 14px;
}

.customer-field-grid label {
  color: #000;
}

.customer-code-row {
  display: grid;
  grid-template-columns: 58px 116px 64px 98px 64px 100px;
  gap: 4px;
  align-items: center;
}

.po-panel {
  margin-top: 12px;
  border: 1px solid #aeb7c4;
  background: #ffffff;
  max-width: 1100px;
  min-height: 520px;
  padding: 8px 16px 0;
}

.po-heading {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 12px;
  color: #001c9f;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 10px;
}

.po-heading-title {
  grid-column: 1 / -1;
}

.po-search-row {
  display: grid;
  grid-template-columns: auto minmax(220px, 360px) auto;
  gap: 6px;
  align-items: center;
  justify-self: start;
  color: #062f43;
  font-weight: 400;
  text-align: left;
}

.po-search-row input {
  width: 100%;
}

.customer-save-status {
  grid-column: 1 / -1;
  min-height: 22px;
  color: #1f6f4a;
  font-size: 13px;
  font-weight: 700;
}

.po-create-form {
  display: none;
  grid-template-columns: 160px 140px 1fr 120px 96px;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid rgba(31, 111, 139, 0.14);
  border-radius: 12px;
  background: #f8fbfb;
}

.po-create-form.open {
  display: grid;
}

.po-create-form input {
  width: 100%;
}

.po-grid {
  overflow: auto;
  max-height: 440px;
}

.po-grid table {
  min-width: 1040px;
}

.po-icon-cell {
  width: auto;
  text-align: center;
  background: transparent;
}

.po-icon-cell a {
  min-width: 34px;
  width: auto;
  padding: 0 8px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #04719a;
  border-radius: 8px;
  background: #057da8;
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 2px 5px rgba(0, 63, 87, 0.18);
}

.po-icon-cell a:hover,
.po-icon-cell a:focus {
  background: #026487;
  outline: 1px solid #81c7d8;
}

.po-icon-cell.delivery a {
  background: #f4b400;
  border-color: #d99d00;
  color: #1d1600;
  box-shadow: 0 2px 5px rgba(96, 70, 0, 0.2);
}


#search-customer.screen {
  box-sizing: border-box;
  width: min(100%, 1060px);
  max-width: 1060px;
  min-width: 0;
  padding-inline: 24px;
}

#search-customer .screen-header {
  width: 100%;
  min-width: 0;
  padding: 10px 18px 16px 18px;
}

#search-customer .screen-header > div:not(.utility-actions) {
  width: 100%;
  min-width: 0;
}

#search-customer .search-fields {
  width: min(100%, 610px);
  min-width: 0;
  grid-template-columns: auto minmax(260px, 420px) auto auto;
  justify-content: start;
}

#search-customer .grid-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  scrollbar-gutter: stable;
}

#search-customer .grid-wrap table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

#search-customer .grid-wrap th,
#search-customer .grid-wrap td {
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


#search-customer .grid-wrap th:nth-child(1),
#search-customer .grid-wrap td:nth-child(1) {
  width: 68px;
}

#search-customer .grid-wrap th:nth-child(2),
#search-customer .grid-wrap td:nth-child(2) {
  width: 58px;
  text-align: center;
}

#search-customer .grid-wrap th:nth-child(3),
#search-customer .grid-wrap td:nth-child(3) {
  width: 36%;
}

#search-customer .grid-wrap th:nth-child(4),
#search-customer .grid-wrap td:nth-child(4) {
  width: 26%;
}

#search-customer .grid-wrap th:nth-child(5),
#search-customer .grid-wrap td:nth-child(5) {
  width: 28%;
}

#search-customer .grid-wrap td:nth-child(2) .small-button,
#search-customer .grid-wrap td:nth-child(2) button,
#search-customer .grid-wrap td:nth-child(2) a {
  margin-inline: auto;
}

@media (max-width: 640px) {
  .customer-info-screen {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .customer-info-top {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px;
  }

  .customer-info-top > div,
  .customer-info-title,
  .profile-meta,
  .customer-info-actions {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .customer-info-title {
    overflow-wrap: anywhere;
    line-height: 1.2;
  }

  .customer-info-actions {
    position: static;
    padding-top: 0;
    justify-content: flex-start;
  }

  .customer-info-actions .exit-button {
    margin-left: auto !important;
  }

  .customer-info-body {
    padding: 10px;
  }

  .customer-fields,
  .customer-field-grid,
  .customer-code-row,
  .po-heading,
  .po-search-row,
  .po-create-form.open {
    grid-template-columns: 1fr;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .customer-field-grid input,
  .customer-field-grid select,
  .customer-field-grid textarea,
  .customer-code-row input,
  .po-search-row input,
  .po-create-form input {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .po-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 10px;
    min-height: 0;
    box-sizing: border-box;
  }

  .po-grid table {
    min-width: 760px;
  }

  #search-customer.screen {
    padding-inline: 10px;
  }

  #search-customer .screen-header {
    padding-inline: 10px;
  }

  #search-customer .search-fields {
    width: 100%;
    grid-template-columns: 1fr;
  }

  #search-customer .grid-wrap table {
    min-width: 760px;
  }
}



/* ==========================================================================
   customer-info — 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) {
  #customer-info .po-grid {
    border-top: 0;
    max-height: 70vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
  }
  #customer-info .po-grid > table {
    min-width: 0;
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
  }
  #customer-info .po-grid > table > thead {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    clip: auto;
  }
  #customer-info .po-grid > 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;
  }
  #customer-info .po-grid > 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;
  }
  #customer-info .po-grid > table > tbody > tr > td::before { content: none; }
  #customer-info .po-grid > table > thead > tr > th:nth-child(4),
  #customer-info .po-grid > table > tbody > tr > td:nth-child(4):not([colspan]) { display: none; }
  #customer-info .po-grid > table > thead > tr > th:nth-child(5),
  #customer-info .po-grid > table > tbody > tr > td:nth-child(5):not([colspan]) { display: none; }
  #customer-info .po-grid > table > thead > tr > th:nth-child(7),
  #customer-info .po-grid > table > tbody > tr > td:nth-child(7):not([colspan]) { display: none; }
  #customer-info .po-grid > table > thead > tr > th:nth-child(8),
  #customer-info .po-grid > table > tbody > tr > td:nth-child(8):not([colspan]) { display: none; }
  #customer-info .po-grid > table > thead > tr > th:nth-child(9),
  #customer-info .po-grid > table > tbody > tr > td:nth-child(9):not([colspan]) { display: none; }
  /* Keep the short primary identifier on one line */
  #customer-info .po-grid > table > thead > tr > th:nth-child(3),
  #customer-info .po-grid > table > tbody > tr > td:nth-child(3) { white-space: nowrap; }
  /* Action / Open control: compact, centered, touch-friendly */
  #customer-info .po-grid > table .open-cell,
  #customer-info .po-grid > table .edit-cell,
  #customer-info .po-grid > table .pd-open-cell,
  #customer-info .po-grid > table .po-icon-cell {
    width: 1%;
    white-space: nowrap;
    text-align: center;
    padding: 6px 5px;
  }
  #customer-info .po-grid > table .open-cell a,
  #customer-info .po-grid > table .edit-cell button,
  #customer-info .po-grid > table .pd-open-cell button,
  #customer-info .po-grid > table .po-icon-cell a {
    display: inline-block;
    min-width: 36px;
    min-height: 32px;
    line-height: 1.5;
    padding: 3px 6px;
  }
  #customer-info .po-grid > table > tbody > tr > td[colspan] {
    text-align: center;
    color: #6a7785;
    white-space: normal;
  }
}

/* ==========================================================================
   search-customer — 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-customer .grid-wrap {
    border-top: 0;
    max-height: 70vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
  }
  #search-customer .grid-wrap > table {
    min-width: 0;
    width: 100%;
    table-layout: auto;
    border-collapse: collapse;
  }
  #search-customer .grid-wrap > table > thead {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    overflow: visible;
    clip: auto;
  }
  #search-customer .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-customer .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-customer .grid-wrap > table > tbody > tr > td::before { content: none; }
  #search-customer .grid-wrap > table > thead > tr > th:nth-child(1),
  #search-customer .grid-wrap > table > tbody > tr > td:nth-child(1):not([colspan]) { display: none; }
  #search-customer .grid-wrap > table > thead > tr > th:nth-child(4),
  #search-customer .grid-wrap > table > tbody > tr > td:nth-child(4):not([colspan]) { display: none; }
  /* Action / Open control: compact, centered, touch-friendly */
  #search-customer .grid-wrap > table .open-cell,
  #search-customer .grid-wrap > table .edit-cell,
  #search-customer .grid-wrap > table .pd-open-cell,
  #search-customer .grid-wrap > table .po-icon-cell {
    width: 1%;
    white-space: nowrap;
    text-align: center;
    padding: 6px 5px;
  }
  #search-customer .grid-wrap > table .open-cell a,
  #search-customer .grid-wrap > table .edit-cell button,
  #search-customer .grid-wrap > table .pd-open-cell button,
  #search-customer .grid-wrap > table .po-icon-cell a {
    display: inline-block;
    min-width: 36px;
    min-height: 32px;
    line-height: 1.5;
    padding: 3px 6px;
  }
  #search-customer .grid-wrap > table > tbody > tr > td[colspan] {
    text-align: center;
    color: #6a7785;
    white-space: normal;
  }
}
