@layer features {
  #testManagementView .workspace-grid {
    grid-template-columns: minmax(260px, 0.85fr) minmax(0, 2fr);
  }

  /* Run ticked cases from Test Cases Management: the "Selected for execution" box and the execute screen.
     This file loads after test-management.css, so its .workspace-grid rules (three columns, then the
     narrower breakpoints) deliberately replace the two-column ones there. */

  #testManagementView .workspace-grid {
    grid-template-columns: 300px minmax(0, 1fr) 300px;
  }

  #testManagementView .workspace-grid > .tm-exec-card {
    grid-column: 2 / -1;
  }

  #testManagementView .tm-exec-panel {
    position: sticky;
    top: var(--space-4);
  }

  #testManagementView .tm-exec-list {
    max-height: 340px;
    overflow-y: auto;
    border-bottom: var(--border-width-1) solid var(--color-divider);
  }

  #testManagementView .tm-exec-panel .section-card__body {
    display: grid;
    gap: var(--space-3);
  }

  #testManagementView .tm-exec-panel .ds-input {
    box-sizing: border-box;
    width: 100%;
  }

  #testManagementView .ex-selected-list {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  #testManagementView .ex-selected {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-bottom: var(--border-width-1) solid var(--color-divider);
  }

  #testManagementView .ex-selected:last-child {
    border-bottom: 0;
  }

  #testManagementView .ex-selected__text {
    display: grid;
    min-width: 0;
    gap: 2px;
  }

  #testManagementView .ex-selected__title {
    overflow-wrap: anywhere;
    font-size: var(--font-size-sm);
    line-height: 1.4;
  }

  #testManagementView .ex-selected__id {
    color: var(--color-accent);
    font-weight: var(--font-weight-semibold);
    font-variant-numeric: tabular-nums;
  }

  #testManagementView .ex-selected__suite {
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    overflow-wrap: anywhere;
  }

  #testManagementView .ex-selected.is-skipped .ex-selected__title {
    color: var(--color-text-secondary);
  }

  #testManagementView .ex-selected.is-skipped .ex-selected__suite {
    color: var(--color-warning-text);
  }

  #testManagementView .ex-selected__remove {
    flex: 0 0 auto;
    width: 24px;
    min-width: 0;
    height: 24px;
    padding: 0;
    border: 0;
    box-shadow: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
  }

  #testManagementView .ex-selected__remove:hover {
    background: var(--color-bg-surface-alt);
    color: var(--color-danger-text);
  }

  #testManagementView .ex-selected__remove:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
  }

  #testManagementView .ex-include {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    white-space: nowrap;
    cursor: pointer;
  }

  #testManagementView .ex-muted {
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
  }

  #testManagementView .ex-empty {
    margin: 0;
    padding: var(--space-4);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
  }

  #testManagementView .ex-points {
    min-width: 0;
  }

  #testManagementView .ex-table .ex-title {
    min-width: 220px;
  }

  #testManagementView .ex-table .ex-bug {
    width: 110px;
  }

  #testManagementView .ex-table td .ds-input,
  #testManagementView .ex-table td .ds-select {
    min-width: 140px;
  }

  #testManagementView .ex-bug-actions {
    margin-top: var(--space-1);
    font-size: var(--font-size-xs);
  }

  #testManagementView .ex-bug-link {
    color: var(--color-accent);
    font-weight: var(--font-weight-semibold);
  }

  #testManagementView .ex-steps-row > td {
    padding-top: 0;
    border-top: 0;
  }

  #testManagementView .ex-steps {
    margin: 0 0 var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: var(--border-width-1) solid var(--color-divider);
    border-radius: var(--radius-md);
    background: var(--color-bg-surface-alt);
    font-size: var(--font-size-xs);
  }

  #testManagementView .ex-steps > summary {
    color: var(--color-text-secondary);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
  }

  #testManagementView .ex-steps__table {
    width: 100%;
    margin-top: var(--space-2);
    border-collapse: collapse;
    table-layout: fixed;
  }

  #testManagementView .ex-steps__table th:nth-child(1) {
    width: 40px;
  }

  #testManagementView .ex-steps__table th:nth-child(2) {
    width: 38%;
  }

  #testManagementView .ex-steps__table th,
  #testManagementView .ex-steps__table td {
    padding: 4px var(--space-2);
    border-top: var(--border-width-1) solid var(--color-divider);
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
  }

  #testManagementView .ex-steps__table th {
    color: var(--color-text-secondary);
    font-weight: var(--font-weight-medium);
  }

  #testManagementView .ex-step-no {
    width: 32px;
    color: var(--color-text-secondary);
    font-variant-numeric: tabular-nums;
  }

  #testManagementView .ex-message {
    margin-bottom: var(--space-4);
    padding: 9px var(--space-3);
    border: var(--border-width-1) solid var(--c-brand-100);
    border-radius: var(--radius-md);
    background: var(--c-brand-50);
    color: var(--c-brand-800);
    font-size: var(--font-size-xs);
  }

  #testManagementView .ex-message--success {
    border-color: var(--color-success-bg);
    background: var(--color-success-bg);
    color: var(--color-success-text);
  }

  #testManagementView .ex-message--error {
    border-color: var(--color-danger-bg);
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
  }

  #testManagementView .ex-message a {
    color: inherit;
    font-weight: var(--font-weight-semibold);
    text-decoration: underline;
  }

  #testManagementView #tmExecBugDialog .ds-dialog__content {
    display: grid;
    gap: var(--space-3);
  }

  #testManagementView #tmExecBugDialog .ds-field {
    display: grid;
    gap: var(--space-1);
    width: 100%;
  }

  #testManagementView #tmExecBugDialog .ds-input {
    box-sizing: border-box;
    width: 100%;
  }

  #testManagementView #tmExecBugDialog textarea.ds-input {
    min-height: 110px;
    resize: vertical;
  }

  @media (max-width: 1280px) {
    #testManagementView .workspace-grid {
      grid-template-columns: 280px minmax(0, 1fr);
    }

    #testManagementView .workspace-grid > .tm-exec-panel {
      grid-column: 2;
      position: static;
    }
  }

  @media (max-width: 900px) {
    #testManagementView .workspace-grid {
      grid-template-columns: 1fr;
    }

    #testManagementView .workspace-grid > .tm-exec-panel,
    #testManagementView .workspace-grid > .tm-exec-card {
      grid-column: 1;
    }
  }

  /* The execution entry point moved off Test Cases Management; keep that library at two columns.
     This rule follows the breakpoints above, so the narrow stack has to be repeated after it. */
  #testManagementView .workspace-grid {
    grid-template-columns: minmax(260px, 0.85fr) minmax(0, 2fr);
  }

  @media (max-width: 900px) {
    #testManagementView .workspace-grid {
      grid-template-columns: 1fr;
    }
  }
} /* end @layer features */

/*
 * Test Management's shared suite renderer emits bare buttons. Keep this
 * compatibility reset unlayered so the global base button rule cannot turn
 * its flat navigation rows into filled cards. The structure and spacing
 * mirror the Test Cases Management tree rather than creating a second tree.
 */
#testExecutionView .te-suite-nav {
  min-width: 0;
  padding: 0;
  border: var(--border-width-1) solid var(--color-divider);
  border-radius: var(--radius-md);
  background: var(--color-bg-surface);
  overflow: visible;
}

#testExecutionView .te-suite-panel__header {
  padding: var(--space-3) var(--space-4);
}

#testExecutionView .te-suite-panel__toolbar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding: var(--space-3);
  border-bottom: var(--border-width-1) solid var(--color-divider);
}

#testExecutionView .te-suite-panel__toolbar .ds-field {
  width: 100%;
  min-width: 0;
}

#testExecutionView .te-suite-panel__toolbar .ds-field-label {
  margin: 0 0 var(--space-1);
}

#testExecutionView .te-suite-panel__menu .icon-button,
#testExecutionView .te-collapse-all {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text-secondary);
  box-shadow: none;
  font-size: var(--font-size-xl);
  line-height: 1;
}

#testExecutionView .te-suite-panel__menu .icon-button:hover,
#testExecutionView .te-suite-panel__menu .icon-button:focus-visible,
#testExecutionView .te-collapse-all:hover,
#testExecutionView .te-collapse-all:focus-visible {
  background: var(--color-bg-surface-alt);
  color: var(--color-text-primary);
  box-shadow: none;
}

#testExecutionView .te-suite-tree,
#testExecutionView .te-suite-tree ul,
#testExecutionView .te-suite-tree li {
  margin: 0;
  padding: 0;
  list-style: none;
}

#testExecutionView .te-suite-tree {
  padding: var(--space-2) 0;
}

#testExecutionView .te-suite-tree .tree-row {
  min-width: 0;
  padding-left: calc(var(--space-2) + (var(--tree-depth, 0) * var(--space-3)));
}

#testExecutionView .te-suite-tree button.tree-item,
#testExecutionView .te-suite-nav button.te-suite-nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-width: 0;
  padding: 8px var(--space-3) 8px var(--space-1);
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--color-text-secondary);
  font: inherit;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-regular);
  line-height: 1.45;
  text-align: left;
  box-shadow: none;
  cursor: pointer;
}

#testExecutionView .te-suite-tree button.tree-item:hover,
#testExecutionView .te-suite-tree button.tree-item:focus-visible,
#testExecutionView .te-suite-nav button.te-suite-nav__item:hover,
#testExecutionView .te-suite-nav button.te-suite-nav__item:focus-visible {
  background: var(--c-neutral-100);
  color: var(--color-text-primary);
  box-shadow: none;
}

#testExecutionView .te-suite-tree button.tree-item.is-active,
#testExecutionView .te-suite-nav button.te-suite-nav__item.is-active {
  border-left-color: var(--color-accent);
  background: var(--c-brand-50);
  color: var(--color-text-primary);
  font-weight: var(--font-weight-semibold);
}

#testExecutionView .te-suite-tree .tree-item__label {
  min-width: 0;
  flex: 1;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

#testExecutionView .te-suite-tree .tree-item__count {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: var(--font-weight-regular);
  font-variant-numeric: tabular-nums;
}

#testExecutionView .te-suite-tree button.tree-toggle,
#testExecutionView .te-suite-tree button.tree-toggle:hover,
#testExecutionView .te-suite-tree button.tree-toggle:focus-visible {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  box-shadow: none;
}

#testExecutionView .te-suite-tree button.tree-toggle:hover,
#testExecutionView .te-suite-tree button.tree-toggle:focus-visible {
  background: var(--c-neutral-100);
  color: var(--color-text-primary);
}

#testExecutionView .te-suite-tree .tree-item svg,
#testExecutionView .te-tree-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

#testExecutionView .te-suite-nav__empty {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}

#testExecutionView .te-suite-nav__item--orphan {
  margin-top: 0;
  border-top: 0;
  border-radius: 0;
  padding-top: 8px;
}

#testExecutionView .te-library-layout {
  grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

#testExecutionView .te-library-results {
  min-width: 0;
  border-left: var(--border-width-1) solid var(--color-divider);
}

@media (max-width: 1100px) {
  #testExecutionView .te-library-layout { grid-template-columns: minmax(260px, 300px) minmax(0, 1fr); }
}

@layer features {
  #testExecutionView .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    background: var(--color-bg-surface-alt);
    color: var(--color-text-secondary);
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
    white-space: nowrap;
  }

  #testExecutionView .status-pill::before {
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-radius: var(--radius-full);
    background: currentColor;
    content: "";
  }

  #testExecutionView .status-pill--success { background: var(--color-success-bg); color: var(--color-success-text); }
  #testExecutionView .status-pill--warning { background: var(--color-warning-bg); color: var(--color-warning-text); }
  #testExecutionView .status-pill--danger { background: var(--color-danger-bg); color: var(--color-danger-text); }
  #testExecutionView .status-pill--info { background: var(--color-info-bg); color: var(--color-info-text); }
  #testExecutionView .status-pill--neutral { background: var(--color-bg-surface-alt); color: var(--color-text-secondary); }

  #testExecutionView .te-suite-nav {
    min-width: 220px;
    padding: var(--space-3);
    border-right: var(--border-width-1) solid var(--color-divider);
    background: var(--color-bg-surface-alt);
  }

  #testExecutionView .te-suite-nav__title {
    margin: 0 var(--space-2) var(--space-2);
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  #testExecutionView .te-suite-nav__item,
  #testExecutionView .te-suite-tree .tree-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    min-width: 0;
    padding: 7px var(--space-2);
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text-secondary);
    font: inherit;
    font-size: var(--font-size-sm);
    text-align: left;
    cursor: pointer;
  }

  #testExecutionView .te-suite-nav__item > span:first-child,
  #testExecutionView .te-suite-tree .tree-item__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #testExecutionView .te-suite-nav__item > span:last-child,
  #testExecutionView .te-suite-tree .tree-item__count {
    margin-left: auto;
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-variant-numeric: tabular-nums;
  }

  #testExecutionView .te-suite-nav__item:hover,
  #testExecutionView .te-suite-tree .tree-item:hover,
  #testExecutionView .te-suite-nav__item.is-active,
  #testExecutionView .te-suite-tree .tree-item.is-active {
    background: var(--c-brand-50);
    color: var(--color-text-primary);
  }

  #testExecutionView .te-suite-nav__item.is-active,
  #testExecutionView .te-suite-tree .tree-item.is-active {
    color: var(--color-accent);
    font-weight: var(--font-weight-semibold);
  }

  #testExecutionView .te-suite-nav__item--orphan {
    margin-top: var(--space-2);
    border-top: var(--border-width-1) solid var(--color-divider);
    border-radius: 0;
    padding-top: var(--space-3);
  }

  #testExecutionView .te-suite-tree ul,
  #testExecutionView .te-suite-tree li {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  #testExecutionView .te-suite-tree .tree-row {
    display: flex;
    align-items: center;
    gap: 2px;
    padding-left: calc(var(--tree-depth, 0) * var(--space-3));
  }

  #testExecutionView .te-suite-tree .tree-toggle {
    display: inline-grid;
    width: 24px;
    height: 28px;
    flex: 0 0 24px;
    place-items: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
  }

  #testExecutionView .te-suite-tree .tree-toggle--spacer { cursor: default; }
  #testExecutionView .te-suite-tree .tree-item { flex: 1 1 auto; min-width: 0; }
  #testExecutionView .te-suite-nav__empty { margin: var(--space-2); color: var(--color-text-muted); font-size: var(--font-size-xs); }

  #testExecutionView .te-library-layout {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    min-width: 0;
  }

  #testExecutionView .te-library-results { min-width: 0; }
  #testExecutionView .te-library-results .te-empty { padding-inline: var(--space-5); }

  #testExecutionView .te-load-more {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-top: var(--border-width-1) solid var(--color-divider);
  }

  #testExecutionView .te-load-more__meta,
  #testExecutionView .te-inline-error,
  #testExecutionView .te-readonly-note,
  #testExecutionView .te-comment-text {
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
  }

  #testExecutionView .te-inline-error {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
  }

  #testExecutionView .te-inline-error .ds-btn { margin-left: auto; color: inherit; }
  #testExecutionView .te-readonly-note { margin-right: auto; color: var(--color-warning-text); }
  #testExecutionView .te-readonly-mark { color: var(--color-text-muted); }
  #testExecutionView .te-outcome-editor {
    --te-outcome-bg: var(--color-bg-surface-alt);
    --te-outcome-text: var(--color-text-secondary);
    position: relative;
    min-width: 145px;
  }
  #testExecutionView .te-outcome-editor::before {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: var(--space-3);
    width: 7px;
    height: 7px;
    border-radius: var(--radius-full);
    background: var(--te-outcome-text);
    content: "";
    pointer-events: none;
    transform: translateY(-50%);
  }
  #testExecutionView .te-outcome-editor--success { --te-outcome-bg: var(--color-success-bg); --te-outcome-text: var(--color-success-text); }
  #testExecutionView .te-outcome-editor--danger { --te-outcome-bg: var(--color-danger-bg); --te-outcome-text: var(--color-danger-text); }
  #testExecutionView .te-outcome-editor--warning { --te-outcome-bg: var(--color-warning-bg); --te-outcome-text: var(--color-warning-text); }
  #testExecutionView .te-outcome-editor--info { --te-outcome-bg: var(--color-info-bg); --te-outcome-text: var(--color-info-text); }
  #testExecutionView .te-result-select {
    width: 100%;
    padding-left: var(--space-6);
    border-color: var(--te-outcome-text);
    background-color: var(--te-outcome-bg);
    color: var(--te-outcome-text);
    font-weight: var(--font-weight-semibold);
  }
  #testExecutionView .te-result-select:hover:not(:disabled) { border-color: currentColor; }
  #testExecutionView .te-comment-text { display: block; max-width: 240px; overflow-wrap: anywhere; }
  #testExecutionView .te-result-table .te-result-select { min-width: 132px; }
  #testExecutionView .te-detail-toolbar .ds-btn--text,
  #testExecutionView .te-load-more .ds-btn--text { border: 0 !important; box-shadow: none; }

  @media (max-width: 800px) {
    #testExecutionView .te-library-layout { grid-template-columns: 1fr; }
    #testExecutionView .te-suite-nav { border-right: 0; border-bottom: var(--border-width-1) solid var(--color-divider); }
    #testExecutionView .te-suite-tree { max-height: 220px; overflow-y: auto; }
  }
}

@layer features {
  #testExecutionView .te-card {
    border: var(--border-width-1) solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    background: var(--color-bg-surface);
    overflow: hidden;
  }

  #testExecutionView .te-card__header {
    padding: var(--space-4) var(--space-5);
    border-bottom: var(--border-width-1) solid var(--color-divider);
  }

  #testExecutionView .te-card__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
  }

  #testExecutionView .te-run-list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    min-width: 0;
    flex: 1 1 auto;
  }

  #testExecutionView .te-run-list-toolbar .search-field {
    display: flex;
    align-items: center;
    position: relative;
    margin: 0;
    flex: 1 1 220px;
    min-width: min(260px, 100%);
    max-width: 320px;
    min-height: var(--tm-filter-control-height, 2rem);
  }

  #testExecutionView .te-run-list-toolbar .search-field svg {
    position: absolute;
    top: 50%;
    left: var(--space-3);
    z-index: 1;
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
    transform: translateY(-50%);
    pointer-events: none;
  }

  #testExecutionView .te-run-list-toolbar .search-field .ds-input {
    width: 100%;
    box-sizing: border-box;
    padding-left: 36px;
    min-height: var(--tm-filter-control-height, 2rem);
    height: var(--tm-filter-control-height, 2rem);
  }

  #testExecutionView .te-run-list-toolbar .ds-btn {
    flex: 0 0 auto;
    align-self: center;
  }

  #testExecutionView .te-project-field,
  #testExecutionView .te-plan-field {
    min-width: 210px;
  }

  #testExecutionView .ds-multiselect .ds-multiselect__trigger {
    padding: 8px 36px 8px 12px;
    border: var(--border-width-1) solid var(--color-border-default);
    background: var(--color-bg-surface);
  }

  #testExecutionView .ds-multiselect .ds-multiselect__trigger:hover {
    border-color: var(--color-text-secondary);
    background: var(--color-bg-surface);
  }

  #testExecutionView .te-run-table th,
  #testExecutionView .te-case-table th,
  #testExecutionView .te-result-table th {
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  #testExecutionView .te-run-metric {
    font-weight: var(--font-weight-semibold);
    font-variant-numeric: tabular-nums;
  }

  #testExecutionView .te-run-metric--muted { color: var(--color-text-muted); }
  #testExecutionView .te-run-metric--danger { color: var(--color-danger-text); }
  #testExecutionView .te-run-metric--warning { color: var(--color-warning-text); }
  #testExecutionView .te-run-metric--info { color: var(--color-info-text); }
  #testExecutionView .te-run-metric--success { color: var(--color-success-text); }

  #testExecutionView .te-run-table tbody tr[data-te-open-run] {
    cursor: pointer;
  }

  #testExecutionView .te-run-table tbody tr[data-te-open-run]:hover,
  #testExecutionView .te-run-table tbody tr[data-te-open-run]:focus-visible {
    background: var(--color-bg-surface-alt);
    outline: none;
  }

  #testExecutionView .te-run-actions-cell {
    width: 1%;
    white-space: nowrap;
  }

  #testExecutionView .te-run-row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-1);
  }

  #testExecutionView .te-run-row-actions .icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--color-text-secondary);
    box-shadow: none;
  }

  #testExecutionView .te-run-row-actions .icon-button:hover:not(:disabled) {
    background: var(--color-bg-surface-alt);
    color: var(--color-text-primary);
    box-shadow: none;
  }

  #testExecutionView .te-run-row-actions .icon-button:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
  }

  #testExecutionView .te-run-row-actions .icon-button--danger {
    color: var(--color-danger-text);
  }

  #testExecutionView .te-run-row-actions .icon-button--danger:hover:not(:disabled),
  #testExecutionView .te-run-row-actions .icon-button--danger:focus-visible {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
  }

  #testExecutionView .te-run-row-actions .icon-button svg {
    width: 16px;
    height: 16px;
  }

  #testExecutionView .te-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5) 0;
  }

  #testExecutionView .te-summary-card {
    min-width: 0;
    padding: var(--space-4) var(--space-5);
    border: var(--border-width-1) solid var(--color-border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: none;
  }

  #testExecutionView .te-summary-card .summary-card__icon {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    background: var(--color-accent);
  }

  #testExecutionView .te-summary-card .summary-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
  }

  #testExecutionView .te-summary-card .summary-card__icon--success {
    background: var(--color-success-text);
  }

  #testExecutionView .te-summary-card .summary-card__icon--danger {
    background: var(--color-danger-text);
  }

  #testExecutionView .te-summary-card .summary-card__icon--warning {
    background: var(--color-warning-text);
  }

  #testExecutionView .te-summary-card .summary-card__label {
    overflow: hidden;
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    letter-spacing: 0.04em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
  }

  #testExecutionView .te-summary-card .summary-card__value {
    margin-top: var(--space-2);
  }

  #testExecutionView .te-summary-card .summary-card__number {
    color: var(--color-text-primary);
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-semibold);
    line-height: 1.1;
  }

  #testExecutionView .te-summary-card .summary-card__caption {
    margin-top: var(--space-1);
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
  }

  #testExecutionView .te-run-summary-grid {
    padding-bottom: var(--space-4);
  }

  #testExecutionView .te-detail-toolbar__nav {
    flex: 1 1 auto;
    min-width: 0;
  }

  #testExecutionView .te-detail-toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    flex: 2 1 auto;
  }

  #testExecutionView .te-detail-toolbar__external {
    flex: 0 0 auto;
  }

  @media (max-width: 900px) {
    #testExecutionView .te-summary-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
  }

  @media (max-width: 700px) {
    #testExecutionView .te-summary-grid {
      grid-template-columns: 1fr;
      padding-inline: var(--space-4);
    }

    #testExecutionView .te-card__header {
      padding-inline: var(--space-4);
    }
  }
}

@layer features {
  #testExecutionView .te-result-table .te-create-bug {
    padding-inline: var(--space-2);
  }

  #testExecutionView .te-bug-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    min-width: 0;
  }

  #testExecutionView .te-bug-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  #testExecutionView .te-bug-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1);
  }

  #testExecutionView .te-bug-link {
    color: var(--color-accent);
    font-weight: var(--font-weight-semibold);
  }

  #testExecutionView .te-no-bug {
    color: var(--color-text-tertiary);
  }

  #testExecutionView .te-ado-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
  }

  #testExecutionView #teBugDialog .ds-dialog__content,
  #teBugDialog .ds-dialog__content {
    display: grid;
    gap: var(--space-3);
  }

  #testExecutionView #teBugDialog #teBugLinkFields.hidden,
  #testExecutionView #teBugDialog #teBugCreateFields.hidden,
  #teBugDialog #teBugLinkFields.hidden,
  #teBugDialog #teBugCreateFields.hidden {
    display: none;
  }

  #testExecutionView #teBugDialog .ds-field,
  #teBugDialog .ds-field {
    display: grid;
    gap: var(--space-1);
    width: 100%;
  }

  #testExecutionView #teBugDialog .te-bug-preview,
  #teBugDialog .te-bug-preview {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
  }

  #testExecutionView #teBugDialog .ds-input,
  #teBugDialog .ds-input {
    box-sizing: border-box;
    width: 100%;
  }

  #testExecutionView #teBugDialog textarea.ds-input,
  #teBugDialog textarea.ds-input {
    min-height: 110px;
    resize: vertical;
  }

  /* Execution modals inside .app-main must clear the app sidebar (same as Test Management). */
  body:has(#testExecutionView .ds-dialog-backdrop:not(.hidden)) .app-main {
    z-index: 2100;
  }
}

@layer features {
  #testExecutionView .te-page {
    max-width: 1480px;
    margin: 0 auto;
    padding: var(--space-6) var(--space-7) var(--space-8);
  }

  #testExecutionView .te-intro {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-6);
    margin-bottom: var(--space-5);
  }

  #testExecutionView .te-intro .page-intro__eyebrow {
    margin: 0 0 var(--space-1);
    color: var(--color-accent);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.08em;
    line-height: 1.5;
    text-transform: uppercase;
  }

  #testExecutionView .te-intro .page-intro__title {
    color: var(--color-text-primary);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    line-height: 1.35;
  }

  #testExecutionView .te-intro .page-intro__desc {
    max-width: 74ch;
    margin-top: var(--space-2);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    line-height: 1.55;
  }

  #testExecutionView .te-intro__actions,
  #testExecutionView .te-detail-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  #testExecutionView .te-project-field,
  #testExecutionView .te-plan-field,
  #testExecutionView .te-run-type-field {
    min-width: 190px;
  }

  #testExecutionView .te-message {
    margin-bottom: var(--space-4);
    padding: var(--space-3) var(--space-4);
    border: var(--border-width-1) solid var(--color-success-bg);
    border-radius: var(--radius-md);
    background: var(--color-success-bg);
    color: var(--color-success-text);
  }

  #testExecutionView .te-message--error {
    border-color: var(--color-danger-bg);
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
  }

  #testExecutionView .te-card {
    margin-bottom: var(--space-5);
  }

  #testExecutionView .te-card__body {
    padding: 0;
  }

  #testExecutionView .te-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
  }

  #testExecutionView .te-loading,
  #testExecutionView .te-error-state,
  #testExecutionView .te-empty {
    padding: var(--space-8) var(--space-5);
    text-align: center;
    color: var(--color-text-secondary);
  }

  #testExecutionView .te-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
  }

  #testExecutionView .te-error-state {
    color: var(--color-danger-text);
  }

  #testExecutionView .te-error-state p,
  #testExecutionView .te-empty p {
    max-width: 600px;
    margin: var(--space-2) auto var(--space-4);
  }

  #testExecutionView .te-empty__icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin: 0 auto var(--space-3);
    border-radius: var(--radius-full);
    background: var(--color-bg-surface-alt);
    color: var(--color-text-tertiary);
    font-size: var(--font-size-xl);
  }

  #testExecutionView .te-run-link {
    display: block;
    max-width: 360px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--color-text-primary);
    box-shadow: none;
    font: inherit;
    font-weight: var(--font-weight-semibold);
    text-align: left;
    cursor: pointer;
  }

  #testExecutionView .te-run-link:hover {
    color: var(--color-accent);
  }

  #testExecutionView .te-run-id,
  #testExecutionView .te-case-meta,
  #testExecutionView .te-counts,
  #testExecutionView .te-point-detail,
  #testExecutionView .te-status-label,
  #testExecutionView .te-detail-status small {
    display: block;
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
  }

  #testExecutionView .te-case-meta,
  #testExecutionView .te-point-detail {
    margin-top: 3px;
  }

  #testExecutionView .te-counts {
    margin-top: 3px;
    white-space: nowrap;
  }

  #testExecutionView .te-case-table td,
  #testExecutionView .te-result-table td {
    vertical-align: middle;
  }

  #testExecutionView .te-case-table tr.is-disabled {
    background: var(--color-bg-surface-alt);
  }

  #testExecutionView .te-case-table tr.is-disabled strong,
  #testExecutionView .te-case-table tr.is-disabled .ado-id {
    color: var(--color-text-secondary);
  }

  #testExecutionView .te-not-executable {
    color: var(--color-warning-text);
    font-size: var(--font-size-xs);
  }

  #testExecutionView .te-not-executable a {
    color: var(--color-accent);
    font-weight: var(--font-weight-semibold);
  }

  #testExecutionView .te-point-select {
    min-width: 290px;
    max-width: 430px;
  }

  #testExecutionView .te-result-select {
    min-width: 145px;
  }

  #testExecutionView .te-comment-input {
    min-width: 180px;
  }

  #testExecutionView .te-outcome-overview {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: var(--space-5);
    padding: var(--space-4) var(--space-5);
    border-bottom: var(--border-width-1) solid var(--color-divider);
    background: var(--color-bg-surface);
  }

  #testExecutionView .te-outcome-overview__counts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
  }

  #testExecutionView .te-outcome-count {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    background: var(--color-bg-surface-alt);
  }

  #testExecutionView .te-outcome-count__value {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    line-height: 1.2;
    color: var(--color-text-primary);
  }

  #testExecutionView .te-outcome-count__label {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
  }

  #testExecutionView .te-outcome-count--success .te-outcome-count__value { color: var(--color-success-text); }
  #testExecutionView .te-outcome-count--danger .te-outcome-count__value { color: var(--color-danger-text); }
  #testExecutionView .te-outcome-count--warning .te-outcome-count__value { color: var(--color-warning-text); }
  #testExecutionView .te-outcome-count--info .te-outcome-count__value { color: var(--color-info-text); }

  #testExecutionView .te-outcome-overview__bar {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--space-2);
    min-width: 0;
  }

  #testExecutionView .te-outcome-overview__chart {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-4);
    min-width: 0;
  }

  #testExecutionView .te-outcome-pie-wrap {
    flex: 0 0 auto;
  }

  #testExecutionView .te-outcome-pie {
    display: block;
    width: 120px;
    height: 120px;
  }

  #testExecutionView .te-outcome-pie__total {
    font-size: 11px;
    font-weight: var(--font-weight-semibold);
    fill: var(--color-text-primary);
  }

  #testExecutionView .te-outcome-pie-accessible {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  #testExecutionView .te-run-ado-link {
    color: var(--color-text-link);
    font-weight: var(--font-weight-semibold);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
  }

  #testExecutionView .te-run-ado-link:hover,
  #testExecutionView .te-run-ado-link:focus-visible {
    color: var(--color-text-link-hover);
  }

  #testExecutionView .te-run-ado-link__icon {
    margin-left: 0.15em;
    font-size: 0.9em;
  }

  #testExecutionView .te-bug-grid {
    width: 100%;
    max-width: 16rem;
    border-collapse: collapse;
    font-size: var(--font-size-xs);
  }

  #testExecutionView .te-bug-grid th {
    color: var(--color-text-secondary);
    font-weight: var(--font-weight-semibold);
    text-align: left;
    padding: 0 var(--space-2) var(--space-1) 0;
  }

  #testExecutionView .te-bug-grid td {
    padding: 0 var(--space-2) var(--space-1) 0;
    vertical-align: baseline;
  }

  #testExecutionView .te-bug-grid__id {
    min-width: 4.5rem;
    white-space: nowrap;
  }

  #testExecutionView .te-bug-state {
    color: var(--color-text-secondary);
    white-space: nowrap;
  }

  #testExecutionView .te-outcome-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
  }

  #testExecutionView .te-outcome-legend__item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
  }

  #testExecutionView .te-outcome-legend__dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
  }

  #testExecutionView .te-outcome-overview__total {
    margin: 0;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
  }

  #testExecutionView .te-outcome-bar__empty {
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--color-bg-surface-alt);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
  }

  #testExecutionView .te-outcome-overview__meta {
    margin: 0;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
  }

  #testExecutionView .te-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-5);
    border-bottom: var(--border-width-1) solid var(--color-divider);
  }

  #testExecutionView .te-detail-header__main {
    flex: 1 1 auto;
    min-width: 0;
  }

  #testExecutionView .te-detail-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex: 0 0 auto;
    min-width: 0;
    max-width: min(100%, 12rem);
    text-align: right;
  }

  #testExecutionView .te-detail-status .status-pill {
    margin-top: var(--space-1);
  }

  #testExecutionView .te-detail-status small {
    margin-top: var(--space-1);
  }

  #testExecutionView .te-detail-toolbar {
    justify-content: space-between;
    padding: var(--space-3) var(--space-5);
    border-bottom: var(--border-width-1) solid var(--color-divider);
    background: var(--color-bg-surface-alt);
  }

  #testExecutionView .te-create-notice {
    margin: var(--space-4) var(--space-5) 0;
    padding: var(--space-3) var(--space-4);
    border-left: 3px solid var(--color-accent);
    background: var(--color-bg-surface-alt);
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
  }

  #testExecutionView .te-create-toolbar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr) auto;
    align-items: end;
    gap: var(--space-3);
    padding: var(--space-5);
  }

  #testExecutionView .te-library-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-top: var(--border-width-1) solid var(--color-divider);
    border-bottom: var(--border-width-1) solid var(--color-divider);
    background: var(--color-bg-surface-alt);
  }

  #testExecutionView .te-library-toolbar .search-field {
    min-width: 300px;
  }

  #testExecutionView .te-library-toolbar .compact-select,
  #testExecutionView .te-detail-toolbar .compact-select {
    width: 180px;
    flex: 0 0 180px;
  }

  #testExecutionView .te-selection-summary {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
  }

  @media (max-width: 1050px) {
    #testExecutionView .te-intro,
    #testExecutionView .te-detail-header,
    #testExecutionView .te-outcome-overview {
      flex-direction: column;
    }

    #testExecutionView .te-outcome-overview {
      grid-template-columns: 1fr;
    }

    #testExecutionView .te-detail-status {
      min-width: 0;
      width: 100%;
    }

    #testExecutionView .te-create-toolbar {
      grid-template-columns: 1fr;
    }
  }

  @media (max-width: 700px) {
    #testExecutionView .te-page {
      padding: var(--space-4);
    }

    #testExecutionView .te-intro__actions,
    #testExecutionView .te-library-toolbar {
      align-items: stretch;
      flex-direction: column;
    }

    #testExecutionView .te-project-field,
    #testExecutionView .te-plan-field,
    #testExecutionView .te-library-toolbar .search-field {
      min-width: 0;
      width: 100%;
    }

    #testExecutionView .te-card__header {
      flex-direction: column;
      align-items: stretch;
    }

    #testExecutionView .te-run-list-toolbar {
      flex-direction: column;
      align-items: stretch;
      width: 100%;
    }

    #testExecutionView .te-run-list-toolbar .search-field {
      max-width: none;
      width: 100%;
    }

    #testExecutionView .te-library-toolbar .compact-select,
    #testExecutionView .te-detail-toolbar .compact-select {
      width: 100%;
      flex-basis: 100%;
    }

    #testExecutionView .te-detail-status {
      grid-template-columns: 1fr;
    }
  }

  /* Match TCM mock-table .cell-title; keep as button for drawer keyboard access */
  #testExecutionView .te-result-table .te-case-title-trigger {
    display: inline;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
    color: var(--color-text-primary);
    font: inherit;
    font-weight: var(--font-weight-medium);
    text-align: left;
    text-decoration: none;
    overflow-wrap: anywhere;
    white-space: normal;
    cursor: pointer;
  }

  #testExecutionView .te-result-table .te-case-title-trigger:hover {
    color: var(--color-text-primary);
  }

  #testExecutionView .te-result-table .te-case-title-trigger:focus-visible {
    outline: 2px solid var(--color-border-focus);
    outline-offset: 2px;
  }

} /* end @layer features */

body > #teCaseDrawerShell.tm-detail-shell {
  position: fixed;
  inset: 0;
  z-index: 10001;
}

body > #teCaseDrawerShell.tm-detail-shell.hidden {
  display: none;
}

body > #teCaseDrawerShell .tm-detail-backdrop {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--color-bg-overlay);
  cursor: pointer;
}

body > #teCaseDrawerShell .tm-detail-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(52rem, 100vw);
  max-width: 100%;
  overflow: hidden;
  background: var(--color-bg-surface);
  border-left: var(--border-width-1) solid var(--color-border-default);
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.12);
  outline: none;
}

body > #teCaseDrawerShell .tm-detail-panel .section-card__header.tm-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: var(--border-width-1) solid var(--color-divider);
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--color-bg-surface);
}

body > #teCaseDrawerShell .tm-detail-panel .section-card__title {
  margin: 0;
  color: var(--color-text-primary);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  line-height: 1.3;
}

body > #teCaseDrawerShell .tm-detail-panel .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--font-size-xl);
  line-height: 1;
  box-shadow: none;
  cursor: pointer;
}

body > #teCaseDrawerShell .tm-detail-panel .icon-button:hover,
body > #teCaseDrawerShell .tm-detail-panel .icon-button:focus-visible {
  background: var(--c-neutral-100);
  color: var(--color-text-primary);
  box-shadow: none;
}

body > #teCaseDrawerShell .tm-detail-panel .section-card__header.tm-detail-header > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

body > #teCaseDrawerShell .tm-detail-panel .section-card__actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: var(--space-2);
}

body > #teCaseDrawerShell .tm-detail-panel .tm-detail-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
}

body > #teCaseDrawerShell .tm-steps-grid textarea.tm-step-cell {
  cursor: default;
  background: var(--color-bg-surface-alt);
}

/* Body-portaled execution modals: full-viewport overlay stacks above .app-sidebar (2000). */
body > #teBugDialog.ds-dialog-backdrop .ds-dialog,
body > #tmRunDialog.ds-dialog-backdrop .ds-dialog,
body > #tmPlanDialog.ds-dialog-backdrop .ds-dialog {
  width: 100%;
  max-width: min(900px, calc(100vw - 2 * var(--space-4)));
  box-sizing: border-box;
}
