.app-shell,
.main,
.screen,
.tab-panel,
.panel,
.card,
.grid > * {
  min-width: 0;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 12px 18px;
  height: auto;
  min-height: 72px;
}

.top-spacer {
  display: none;
}

.top-title,
.topbar-user,
.panel-title,
.table-toolbar-title {
  min-width: 0;
}

.top-title h1,
.top-title p,
.panel-title strong,
.panel-title span {
  overflow-wrap: anywhere;
}

.topbar-user {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: min(58vw, 760px);
}

.topbar-user .pill {
  min-width: 0;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-topbar-actions {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.section-head,
.panel-head,
.table-toolbar,
.table-toolbar-actions,
.actions,
.row-actions {
  min-width: 0;
  flex-wrap: wrap;
  gap: 8px;
}

input,
select,
textarea {
  min-width: 0;
  max-width: 100%;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  width: 100%;
  min-width: 680px;
}

th,
td {
  vertical-align: top;
  overflow-wrap: anywhere;
}

.drawer,
.modal-dialog,
.modal-box {
  max-width: min(680px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
}

.drawer-body,
.modal-body {
  min-height: 0;
  overflow: auto;
}

@media (max-width: 1100px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar-user {
    justify-content: flex-start;
    max-width: none;
  }
}

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .mobile-topbar-actions {
    display: flex;
  }

  .topbar-user {
    grid-column: 1 / -1;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .section-head,
  .table-toolbar {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .mobile-topbar-actions {
    justify-content: flex-start;
  }

  .topbar-user #agent-role,
  .topbar-user #module-date {
    display: none;
  }
}
