.stakeholderTable {
  table-layout: fixed;
}

.stakeholderTable th:nth-child(1),
.stakeholderTable td:nth-child(1) {
  width: 11%;
}

.stakeholderTable th:nth-child(2),
.stakeholderTable td:nth-child(2) {
  width: 13%;
}

.stakeholderTable th:nth-child(3),
.stakeholderTable td:nth-child(3) {
  width: 11%;
}

.stakeholderTable th:nth-child(4),
.stakeholderTable td:nth-child(4) {
  width: 16%;
}

.stakeholderTable th:nth-child(5),
.stakeholderTable td:nth-child(5) {
  width: 26%;
}

.stakeholderTable th:nth-child(6),
.stakeholderTable td:nth-child(6) {
  width: 18%;
}

.stakeholderTable th:nth-child(7),
.stakeholderTable td:nth-child(7) {
  width: 80px;
}

.stakeholderDomainSelect {
  position: relative;
  width: 100%;
  max-width: 100%;
}

.stakeholderDomainField {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.stakeholderDomainFieldHead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.stakeholderDomainFieldLabel {
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
}

.stakeholderDomainFieldHint {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.25;
  white-space: nowrap;
}

.stakeholderDomainSummary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}

.stakeholderDomainSummary::-webkit-details-marker {
  display: none;
}

.stakeholderDomainSummary::after {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-right: 2px solid var(--blue);
  border-bottom: 2px solid var(--blue);
  transform: rotate(45deg) translateY(-2px);
}

.stakeholderDomainSelect[open] .stakeholderDomainSummary::after {
  transform: rotate(225deg) translateY(-1px);
}

.stakeholderDomainSummary span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.stakeholderDomains {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: grid;
  gap: 6px;
  max-height: 280px;
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(69, 111, 143, .26);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(34, 42, 52, .16);
}

/* An open selector owns its row height so every domain remains readable and
   the following contact cannot paint over the menu at narrower widths. */
.stakeholderDomainSelect[open] .stakeholderDomains {
  position: static;
  width: max(100%, 360px);
  max-width: min(420px, calc(100vw - 32px));
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: none;
  overflow: visible;
  margin-top: 6px;
  box-shadow: none;
}

.stakeholderDomainToggle {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.3;
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 0;
  cursor: pointer;
}

.artifactTable .stakeholderDomainToggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  flex: 0 0 16px;
  border-radius: 4px;
  accent-color: var(--blue);
}

/* The desktop register becomes contact cards before tablet widths so the
   domain selector never opens off-screen inside a horizontally scrolled row. */
@media (max-width: 1300px) {
  .workflowTable.stakeholderTable {
    display: block;
    min-width: 0;
  }

  .stakeholderTable thead {
    display: none;
  }

  .stakeholderTable tbody,
  .stakeholderTable tr {
    display: block;
  }

  .stakeholderTable tbody tr {
    margin-bottom: 12px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
  }

  .stakeholderTable td,
  .stakeholderTable td:nth-child(-n + 4),
  .stakeholderTable td:nth-child(6),
  .stakeholderTable td:nth-child(7) {
    display: grid;
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    width: auto;
    padding: 8px 0;
    border-bottom: 1px solid rgba(63, 83, 106, .1);
  }

  .stakeholderTable td:last-child {
    border-bottom: 0;
  }

  .stakeholderTable td::before {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  .stakeholderTable td:nth-child(1)::before { content: "Name"; }
  .stakeholderTable td:nth-child(2)::before { content: "Role"; }
  .stakeholderTable td:nth-child(3)::before { content: "Organization"; }
  .stakeholderTable td:nth-child(4)::before { content: "Decision authority"; }
  .stakeholderTable td:nth-child(6)::before { content: "Notes"; }
  .stakeholderTable td:nth-child(7)::before { content: "Action"; }

  .stakeholderTable td:nth-child(5) {
    display: block;
    width: auto;
    padding: 8px 0;
    border-bottom: 1px solid rgba(63, 83, 106, .1);
  }

  .stakeholderTable td:nth-child(5)::before {
    content: "Owned domains";
    display: block;
    margin-bottom: 6px;
  }

  .stakeholderDomainSelect[open] .stakeholderDomains {
    width: 100%;
    max-width: 100%;
    grid-template-columns: 1fr;
  }
}
