/* Total-console display fixes, verified with production assets and synthetic data.
   Append after the existing styles; preserve table scrolling and business actions. */

/* Long account names, request IDs and notes must remain inside their columns. */
.console-shell .withdrawal-row {
  min-width: 860px;
}
.console-shell .withdrawal-row > *,
.console-shell .audit-row > * {
  min-width: 0;
  overflow-wrap: anywhere;
}
.console-shell .withdrawal-row > div:first-child > *,
.console-shell .audit-row > div > * {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
.console-shell .audit-table {
  max-width: 100%;
  overflow-x: auto;
}

/* The native customer dialog focuses its close button on open. A long email in
   the flex heading previously widened the content and scrolled the dialog sideways. */
.console-shell .ao-dialog header > div {
  min-width: 0;
  overflow-wrap: anywhere;
}
.console-shell .ao-dialog header > button {
  flex-shrink: 0;
  white-space: nowrap;
}
.console-shell .ao-dialog .ao-details > div {
  min-width: 0;
}

/* A long invitation label must not become the minimum width of the whole page. */
.console-shell :is(.ap-workspace, .ap-invites, .mp-workspace) {
  min-width: 0;
  max-width: 100%;
  grid-template-columns: minmax(0, 1fr);
}
.console-shell .mp-workspace > *,
.console-shell .mp-target {
  min-width: 0;
}
.console-shell .mp-target select {
  min-width: 0;
  max-width: 100%;
}

/* Preserve readable actions while the existing conversation title truncates. */
.ts-admin-dialog .ts-conversation-head > button {
  flex-shrink: 0;
  white-space: nowrap;
}
.ts-admin-dialog .ts-conversation-title {
  min-width: 0;
}

/* The retained maintenance field is hidden; the invitation list has five visible columns. */
.ui-agent .pricing-module > .panel {
  min-width: 0;
}

@media (min-width: 651px) {
  .ui-agent .invitation-columns,
  .ui-agent .invitation-row {
    grid-template-columns: minmax(132px, 1fr) minmax(148px, .9fr) minmax(102px, .72fr) minmax(174px, 1.15fr) 124px;
    min-width: 768px;
  }
}

/* Keep long prices and their discount action inside the same cell. */
.ui-agent .invitation-flow-main {
  max-width: 100%;
  flex-wrap: wrap;
}

.ui-agent .invitation-row .invitation-flow-main > [data-price-key] {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.ui-agent .invitation-code > [data-invite-code] {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Expanded actions take up row space so the scroll container cannot clip them. */
.ui-agent .invitation-more {
  display: grid;
  justify-items: end;
}

.ui-agent .invitation-more[open] > .invitation-delete {
  position: static;
  margin-top: 4px;
}

/* Status badges retain their compact shape beside a multi-line ticket title. */
.ui-agent .ticket-card > header {
  align-items: flex-start;
}

.ui-agent .ticket-card > header > .status {
  flex: 0 0 auto;
}

.ui-agent .ticket-card > header > div,
.ui-agent .ticket-message > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Keep every script tab visible and related paging actions on the same row. */
@media (max-width: 640px) {
  .ui-script-settings .account-page-tools {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    align-items: center;
  }
  .ui-script-settings .account-page-tools > span[id$="PageSummary"] {
    grid-column: 1 / -1;
    order: 0;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .ui-script-settings .account-page-tools > button {
    order: 1;
    min-width: 0;
    min-height: 40px;
    padding: 7px 5px;
    font-size: 13px;
    white-space: nowrap;
  }
  .ui-script-settings .account-page-tools > label {
    display: flex;
    align-items: center;
    gap: 6px;
    order: 2;
    grid-column: span 2;
    min-width: 0;
    margin: 0;
  }
  .ui-script-settings .account-page-tools > label:has(input[type="checkbox"]) {
    order: 3;
    grid-column: 1 / -1;
  }
  .ui-script-settings .account-page-tools > :is(#retireSelectedAccounts, #refreshAccountPool) {
    order: 4;
    grid-column: span 2;
  }
}
@media (max-width: 480px) {
  .ui-script-settings .page-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    overflow: visible;
  }
  .ui-script-settings .page-tabs > button {
    min-width: 0;
    min-height: 44px;
    padding-inline: 4px;
    font-size: 14px;
    white-space: nowrap;
  }
}

/* Long category and pack names stay inside the voice-library surface. */
.ui-voice-library .category {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
}
.ui-voice-library .detail-info {
  min-width: 0;
  overflow-wrap: anywhere;
}
@media (max-width: 420px) {
  .ui-voice-library .section-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  .ui-voice-library .section-title .search,
  .ui-voice-library .search input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
}
.ui-voice-library .breadcrumb > :not(.current) {
  flex: 0 0 auto;
}
.ui-voice-library .breadcrumb .current {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Keep the fixed protocol label readable in the narrow extraction form. */
@media (max-width: 480px) {
  #manual-panel .extract-grid > label:has(#proxy-protocol) {
    grid-column: 1 / -1;
  }
}
