/* Legacy mapping / rule tables used by early wizard surfaces. */
.mapping-table {
  margin-top: 18px;
  border: var(--border-line);
  border-radius: 6px;
  overflow: hidden;
}
.mapping-header,
.mapping-row {
  display: grid;
  grid-template-columns: 1.3fr 1.3fr .8fr 1fr .6fr;
  align-items: center;
}
.mapping-header {
  background: var(--bar);
  color: var(--text-label);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.mapping-header span,
.mapping-row span {
  padding: 12px 14px;
  border-right: var(--border-line);
}
.mapping-row {
  background: var(--surface);
  border-top: var(--border-line);
}
.attachment-rule-card {
  margin: 18px 0;
  background: var(--surface);
  border: var(--border-line);
  border-radius: 6px;
  padding: 18px;
}
.attachment-rule-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

/* Application data tables, visually aligned with the SaaS-style reference table. */
.app-table-wrap {
  margin: -22px -24px;
  overflow-x: auto;
}
.app-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
.app-table thead {
  background: var(--bar);
  color: var(--text-table-heading);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.app-table th {
  height: 40px;
  padding: 0 16px;
  border-right: var(--border-line-dark);
  font-weight: 800;
  text-align: left;
  white-space: nowrap;
}
.app-table th:last-child { border-right: 0; }
.app-table td {
  min-height: 56px;
  padding: 16px;
  border-top: var(--border-line);
  vertical-align: middle;
}
.app-table tbody tr:hover { background: var(--panel-soft); }

.table-primary-link,
.table-action-link {
  color: var(--text-strong);
  font-weight: 800;
  text-decoration: none;
}
.table-primary-link:hover,
.table-action-link:hover { text-decoration: underline; }
.table-subline {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

/* Campaign list table; the containing card/sticky behavior lives in campaign-workspace.css. */
.campaign-table-wrap {
  margin: 0;
  overflow-x: auto;
  overflow-y: visible;
}
.campaign-table {
  table-layout: fixed;
}
.campaign-table thead tr {
  box-shadow: var(--shadow-data-header);
}
.campaign-table thead th {
  background: var(--bar);
  border-right: var(--border-line-dark);
}
.campaign-table th:nth-child(1),
.campaign-table td:nth-child(1) { width: auto; min-width: 360px; }
.campaign-table th:nth-child(2),
.campaign-table td:nth-child(2) { width: 150px; }
.campaign-table th:nth-child(3),
.campaign-table td:nth-child(3) { width: 230px; }
.campaign-table th:nth-child(4),
.campaign-table td:nth-child(4) { width: 230px; }
.campaign-table th:nth-child(5),
.campaign-table td:nth-child(5) { width: 105px; text-align: right; }
.campaign-table td.updated-cell {
  color: var(--text-subtle);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
}
.campaign-table td.version-cell {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Reusable data grid */
.data-grid-shell {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: var(--border-line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.data-grid-scroll-region {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: auto;
  scrollbar-gutter: stable;
}

.admin-table-surface {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.admin-table-surface > .data-grid-shell {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-shadow: var(--shadow-card);
}

.card-body > .admin-table-surface:only-child {
  margin: -22px -24px;
  width: calc(100% + 48px);
  max-width: inherit;
}

.card-body > .admin-table-surface:only-child > .data-grid-shell {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.card-body > .data-grid-shell:only-child {
  margin: -22px -24px;
  width: calc(100% + 48px);
  border: 0;
  border-radius: 0;
}

.card-body > .connection-tree:only-child {
  margin: -22px -24px;
  width: calc(100% + 48px);
  border: 0;
  border-radius: 0;
}

.card-body > .loading-frame:only-child > .connection-tree:only-child {
  margin: -22px -24px;
  width: calc(100% + 48px);
  border: 0;
  border-radius: 0;
}

.data-grid-container {
  height: 100%;
}

.data-grid {
  display: grid;
  align-items: stretch;
  min-width: 0;
}

.data-grid-fit-container,
.data-grid-fit-content,
.data-grid-has-flex,
.data-grid-fixed-only {
  max-width: none;
}

/* initialFit controls only the first layout. resizeBehavior controls the
   persistent width invariant after that initial measurement. */
.data-grid-resize-free {
  width: max-content;
  min-width: 0;
}

.data-grid-resize-free.data-grid-initial-fit-container {
  min-width: 100%;
}

.data-grid-resize-cover,
.data-grid-resize-constrained {
  width: 100%;
  min-width: 100%;
}

.data-grid-container .data-grid {
  min-height: 100%;
}

.data-grid-cell {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 11px 12px;
  border-right: var(--border-muted-line);
  border-bottom: var(--border-line);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ui-compact-tables .data-grid-cell {
  padding: 7px 10px;
  gap: 6px;
}

.ui-compact-tables .data-grid-header-cell {
  font-size: 11px;
}

.data-grid-cell:last-child {
  border-right: 0;
}

.data-grid-cell > * {
  min-width: 0;
  max-width: 100%;
}

.data-grid-body-cell.is-last-row {
  border-bottom: 0;
}

.data-grid-header-cell {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--bar);
  border-bottom: var(--border-line-dark);
  color: var(--text-table-heading);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  box-shadow: none;
}

.data-grid-body-cell {
  color: var(--text);
}

.data-grid-body-cell.data-grid-row-odd {
  background: var(--surface-raised);
}

.data-grid-body-cell.data-grid-row-even {
  background: var(--surface);
}

.data-grid-body-cell.align-center,
.data-grid-header-cell.align-center {
  justify-content: center;
  text-align: center;
}

.data-grid-body-cell.align-right,
.data-grid-header-cell.align-right {
  justify-content: flex-end;
  text-align: right;
}

.data-grid-header-button {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  flex: 1 1 auto;
  min-width: 0;
  color: inherit;
  cursor: default;
}

.data-grid-header-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.data-grid-header-label {
  display: inline-flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.data-grid-header-label > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.data-grid-header-cell.is-sortable .data-grid-header-button {
  cursor: pointer;
}

.data-grid-header-cell.is-sorted .data-grid-header-button {
  color: var(--text-strong);
}

.data-grid-resize-handle,
.data-grid-filter-trigger {
  border: 0;
  background: transparent;
  color: var(--text-table-heading-muted);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 999px;
}

.data-grid-resize-handle {
  cursor: col-resize;
  width: 16px;
  align-self: stretch;
}

.data-grid-filter-trigger {
  width: 24px;
  height: 24px;
  cursor: pointer;
}

.data-grid-filter-trigger:hover,
.data-grid-filter-trigger:focus-visible,
.data-grid-filter-trigger.is-open {
  color: var(--text-strong);
  background: var(--panel-glass-muted);
  outline: none;
}

.data-grid-filter-trigger.has-filter {
  color: var(--text-strong);
  background: var(--panel-glass);
  box-shadow: inset 0 0 0 1px var(--text-table-heading-muted-border);
}

.data-grid-filter-popover {
  position: fixed;
  z-index: 12000;
  border: var(--border-line-dark);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-menu);
  padding: 12px;
  color: var(--text);
}

.data-grid-filter-popover-header {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 10px;
  color: var(--text-strong);
}

.data-grid-filter-popover-header strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-grid-filter-popover-header button,
.data-grid-filter-input-wrap button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.data-grid-filter-popover-header button:hover,
.data-grid-filter-input-wrap button:hover,
.data-grid-filter-popover-header button:focus-visible,
.data-grid-filter-input-wrap button:focus-visible {
  color: var(--text-strong);
  background: var(--panel-soft);
  outline: none;
}

.data-grid-filter-stack {
  display: grid;
  gap: 10px;
}

.data-grid-filter-field {
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.data-grid-filter-field input,
.data-grid-filter-field select {
  width: 100%;
  border: var(--border-line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  padding: 8px 10px;
}

.data-grid-filter-field input:focus,
.data-grid-filter-field select:focus {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--blue);
}

.data-grid-filter-input-wrap {
  position: relative;
}

.data-grid-filter-input-wrap input {
  padding-right: 32px;
}

.data-grid-filter-input-wrap button {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
}

.data-grid-empty {
  grid-column: 1 / -1;
  padding: 20px;
  color: var(--muted);
  background: var(--surface);
  border-bottom: var(--border-line);
}

.data-grid-cell.is-sticky-start,
.data-grid-cell.is-sticky-end {
  position: sticky;
  z-index: 2;
  background-clip: padding-box;
}

.data-grid-cell.is-sticky-start {
  border-right: var(--border-line-dark);
  box-shadow: var(--shadow-sticky-start);
}

.data-grid-cell.is-sticky-end {
  border-left: var(--border-line-dark);
  box-shadow: var(--shadow-sticky-end);
}

.data-grid-header-cell.is-sticky-start,
.data-grid-header-cell.is-sticky-end {
  z-index: 5;
  border-bottom: var(--border-line-dark);
  background: var(--bar);
}

.data-grid-body-cell.current-version-row,
.data-grid-body-cell.current-recipient-row,
.data-grid-body-cell.current-row {
  font-weight: 700;
}


/* List-valued DataGrid columns and checkbox filters. */
.data-grid-list-select {
  width: 100%;
  min-width: 0;
  border: var(--border-line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  padding: 6px 28px 6px 8px;
}

.data-grid-list-select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: var(--focus-ring);
}

.data-grid-list-filter {
  display: grid;
  gap: 10px;
}

.data-grid-list-filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.data-grid-list-filter-actions button {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.data-grid-list-filter-actions button:hover,
.data-grid-list-filter-actions button:focus-visible {
  color: var(--text-strong);
  text-decoration: underline;
  outline: none;
}

.data-grid-list-filter-options {
  max-height: 230px;
  overflow: auto;
  border: var(--border-line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.data-grid-list-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 8px;
  border-bottom: var(--border-line);
}

.data-grid-list-filter-row:last-child {
  border-bottom: 0;
}

.data-grid-list-filter-row > label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
  cursor: pointer;
}

.data-grid-list-filter-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: 0 0 auto;
}

.data-grid-list-option-remove,
.data-grid-list-option-add button {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.data-grid-list-option-remove:hover,
.data-grid-list-option-remove:focus-visible,
.data-grid-list-option-add button:hover,
.data-grid-list-option-add button:focus-visible {
  color: var(--text-strong);
  background: var(--panel-soft);
  outline: none;
}

.data-grid-list-option-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}

.data-grid-list-option-add input {
  width: 100%;
  border: var(--border-line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  padding: 8px 10px;
}

/* Consistent, context-aware row actions for tables and DataGrids. */
.table-action-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: end;
  gap: 4px;
  width: 100%;
}

.table-action-button.btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
}

.table-action-button.btn:disabled {
  opacity: .45;
}

.table-action-button.btn svg {
  width: 17px;
  height: 17px;
}

.table-action-icon {
  display: inline-grid;
  place-items: center;
}

.table-action-placeholder {
  display: block;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  visibility: hidden;
  pointer-events: none;
}

.data-grid-empty-message {
  color: var(--muted);
  min-height: 64px;
}

.data-grid-empty-action-cell {
  justify-content: flex-end;
  min-height: 64px;
}

.data-grid-empty-row-actions {
  justify-content: end;
}


.data-grid-pagination {
  min-height: 52px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
}

.data-grid-pagination-summary {
  margin-right: auto;
  font-variant-numeric: tabular-nums;
}

.data-grid-page-size,
.data-grid-page-controls {
  display: grid;
  align-items: center;
  gap: 8px;
  grid-auto-flow: column;
}

.data-grid-page-size select {
  min-width: 72px;
  height: 34px;
}

.data-grid-page-controls > span {
  min-width: 88px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.data-grid-page-controls button {
  width: 32px;
  height: 32px;
  border: var(--border-line);
  border-radius: var(--radius-xs, 5px);
  background: var(--surface);
  color: var(--text);
  display: inline-grid;
  place-items: center;
}

.data-grid-page-controls button:hover:not(:disabled),
.data-grid-page-controls button:focus-visible {
  border-color: var(--line-dark);
  background: var(--surface-strong);
}

.data-grid-page-controls button:disabled {
  opacity: .42;
  cursor: not-allowed;
}

@media (max-width: 700px) {
  .data-grid-pagination {
    flex-wrap: wrap;
    justify-content: space-between;
  }
  .data-grid-pagination-summary {
    width: 100%;
  }
}

/* Reusable two-level connection/credential tree. */
.connection-tree {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: var(--border-line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.connection-tree-header,
.connection-tree-row {
  display: grid;
  align-items: stretch;
  min-width: 0;
}

.connection-tree-header {
  min-height: 40px;
  border-bottom: var(--border-line-dark);
  background: var(--bar);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.connection-tree-row {
  min-height: 58px;
  border-bottom: var(--border-line);
  background: var(--surface);
}

.connection-tree-row:last-child {
  border-bottom: 0;
}

.connection-tree-row.is-child {
  background: var(--panel-soft);
}

.connection-tree-cell {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 10px 12px;
  border-right: var(--border-line);
}

.connection-tree-cell:last-child {
  border-right: 0;
}

.connection-tree-primary-cell {
  font-weight: 700;
}

.connection-tree-primary-content {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  padding-left: calc(var(--connection-tree-depth, 0) * 22px);
}

.connection-tree-cell.align-center {
  justify-content: center;
  text-align: center;
}

.connection-tree-cell.align-right {
  justify-content: flex-end;
  text-align: right;
}

.connection-tree-cell > * {
  min-width: 0;
}

.connection-tree-actions {
  min-width: 0;
}

.connection-tree-empty {
  padding: 18px;
  color: var(--muted);
  font-weight: 700;
}

.connection-tree-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.connection-tree-main strong,
.connection-tree-main small,
.connection-tree-muted-line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-tree-main small,
.connection-tree-muted-line {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

@media (max-width: 820px) {
  .connection-tree {
    overflow-x: auto;
  }

  .connection-tree-header,
  .connection-tree-row {
    min-width: 760px;
  }
}
