.algorithm-ack-actions{
  margin-top:16px;
  padding-top:12px;
  border-top:1px solid rgba(27,82,79,.10);
}

.algorithm-ack-search-dialog{
  width:min(720px,calc(100vw - 32px));
  max-height:min(82vh,760px);
  padding:0;
  border:0;
  border-radius:18px;
  background:transparent;
  color:inherit;
}

.algorithm-ack-search-dialog::backdrop{
  background:rgba(16,35,34,.36);
  backdrop-filter:blur(2px);
}

.algorithm-ack-search-dialog__panel{
  display:grid;
  grid-template-rows:auto minmax(0,1fr) auto;
  max-height:min(82vh,760px);
  border:1px solid rgba(27,82,79,.14);
  border-radius:18px;
  background:var(--card-bg,var(--theme-surface,#fff));
  box-shadow:0 24px 64px rgba(24,48,46,.20);
  overflow:hidden;
}

.algorithm-ack-search-dialog__header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  padding:18px 20px 14px;
  border-bottom:1px solid rgba(27,82,79,.10);
}

.algorithm-ack-search-dialog__header p{
  margin:0 0 3px;
  color:#087c75;
  font-size:11px;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.05em;
}

.algorithm-ack-search-dialog__header h3{
  margin:0;
  font-size:18px;
}

.algorithm-ack-search-dialog__close{
  width:36px;
  height:36px;
  border:0;
  border-radius:10px;
  background:transparent;
  color:inherit;
  font-size:26px;
  line-height:1;
  cursor:pointer;
}

.algorithm-ack-search-dialog__body{
  display:grid;
  gap:10px;
  min-height:0;
  padding:16px 20px;
  overflow:auto;
}

.algorithm-ack-search-field{
  display:grid;
  gap:6px;
}

.algorithm-ack-search-field>span{
  font-size:12px;
  font-weight:700;
}

.algorithm-ack-search-field input{
  width:100%;
}

.algorithm-ack-search-dialog__counter{
  font-size:13px;
}

.algorithm-ack-search-progress{
  height:8px;
  overflow:hidden;
  border-radius:999px;
  background:rgba(35,140,132,.10);
}

.algorithm-ack-search-progress>span{
  display:block;
  width:0;
  height:100%;
  border-radius:inherit;
  background:#178f86;
  transition:width .2s ease;
}

.algorithm-ack-search-dialog__matched{
  min-height:16px;
  color:#68747d;
  font-size:11px;
}

.algorithm-ack-search-dialog__list{
  min-height:100px;
}

.algorithm-ack-search-people{
  display:grid;
  gap:0;
  margin:0;
  padding-left:28px;
}

.algorithm-ack-search-people li{
  padding:8px 4px;
  border-bottom:1px solid rgba(27,82,79,.08);
}

.algorithm-ack-search-empty{
  padding:18px;
  border-radius:12px;
  background:rgba(35,140,132,.055);
  color:#68747d;
  text-align:center;
}

.algorithm-ack-search-empty--error{
  color:#a54141;
  background:rgba(181,67,67,.08);
}

.algorithm-ack-search-dialog__footer{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 20px 16px;
  border-top:1px solid rgba(27,82,79,.10);
}

html[data-theme="dark"] .algorithm-ack-search-dialog__panel{
  background:var(--theme-surface,#121816);
}

html[data-theme="dark"] .algorithm-ack-search-progress{
  background:rgba(57,190,177,.14);
}

/*
 * Управление алгоритмами. Форма переводится на эти классы до
 * DOMContentLoaded, поэтому исторические цепочки правил для
 * #algorithm-create-form больше не участвуют в раскладке.
 */
.algorithm-editor-surface{
  display:grid;
  gap:20px;
  margin-bottom:20px;
}

.algorithm-editor-form{
  display:grid;
  gap:18px;
  margin:0;
  padding:0;
  border:0;
  background:transparent;
  box-shadow:none;
}

.algorithm-editor-form>.form-group{
  margin:0;
}

.algorithm-editor-attachments{
  display:grid;
  grid-template-columns:minmax(150px,max-content) minmax(0,1fr);
  align-items:center;
  gap:10px 14px;
  margin:0;
  padding:16px 0 0;
  border-top:1px solid var(--theme-border,rgba(27,82,79,.14));
}

.algorithm-editor-attachments>label{
  margin:0;
  font-weight:800;
}

.algorithm-editor-attachments>input[type="file"]{
  width:100%;
  min-width:0;
  margin:0;
}

.algorithm-editor-attachments>.muted,
.algorithm-editor-attachments>.ui-field__hint,
.algorithm-editor-attachments>.algorithm-attachment-list,
.algorithm-editor-attachments>.algorithm-pending-file-list{
  grid-column:1/-1;
  margin-top:0;
}

.algorithm-pending-file-list{
  display:grid;
  gap:7px;
}

.algorithm-pending-file{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto auto;
  align-items:center;
  gap:10px;
  padding:8px 10px;
  color:var(--theme-text,inherit);
  background:var(--theme-surface-soft,rgba(35,140,132,.06));
  border:1px solid var(--theme-border,rgba(27,82,79,.12));
  border-radius:10px;
}

.algorithm-pending-file>span{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.algorithm-pending-file>small{
  color:var(--theme-text-muted,#68747d);
  white-space:nowrap;
}

.algorithm-pending-file>button{
  width:auto;
  min-width:34px;
  min-height:32px;
  padding:5px 9px;
}

.algorithm-editor-options{
  display:flex;
  align-items:center;
  gap:10px 22px;
  flex-wrap:wrap;
  margin:0;
}

.algorithm-editor-options .checkbox-row{
  margin:0;
}

.algorithm-editor-audience{
  display:grid;
  gap:14px;
  min-width:0;
  margin:0;
  padding:18px 0 0;
  border:0;
  border-top:1px solid var(--theme-border,rgba(27,82,79,.14));
  background:transparent;
}

.algorithm-editor-audience>legend{
  margin:0;
  padding:0;
  color:var(--theme-text,inherit);
  font-size:1.05rem;
  font-weight:850;
}

.algorithm-editor-audience .algorithm-audience-builder__header{
  margin:0;
}

.algorithm-editor-actions{
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:12px;
  margin:0;
  padding:18px 0 0;
  border-top:1px solid var(--theme-border,rgba(27,82,79,.14));
}

.algorithm-editor-actions .btns{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
  margin:0;
}

.algorithm-results-clean{
  display:grid;
  gap:16px;
  margin-top:18px;
}

.algorithm-results-clean .algorithm-admin-list-header{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto minmax(260px,390px);
  align-items:center;
  gap:14px;
  margin:0;
}

.algorithm-results-clean .algorithm-admin-list-header h2{
  margin:0 0 4px;
}

.algorithm-results-clean .algorithm-admin-list-header p{
  margin:0;
}

.algorithm-results-toggle{
  white-space:nowrap;
}

.algorithm-results-clean.is-collapsed>.ui-stack,
.algorithm-results-clean.is-collapsed>.algorithm-pagination,
.algorithm-results-clean.is-collapsed>.empty-state,
.algorithm-results-clean.is-collapsed .algorithm-admin-search{
  display:none;
}

@media(max-width:760px){
  .algorithm-editor-attachments{
    grid-template-columns:1fr;
  }

  .algorithm-editor-attachments>label,
  .algorithm-editor-attachments>input[type="file"],
  .algorithm-editor-attachments>.muted,
  .algorithm-editor-attachments>.ui-field__hint,
  .algorithm-editor-attachments>.algorithm-attachment-list,
  .algorithm-editor-attachments>.algorithm-pending-file-list{
    grid-column:1;
  }

  .algorithm-editor-options,
  .algorithm-editor-actions .btns{
    align-items:stretch;
    flex-direction:column;
  }

  .algorithm-editor-options .checkbox-row,
  .algorithm-editor-actions .btns>*{
    width:100%;
  }

  .algorithm-results-clean .algorithm-admin-list-header{
    grid-template-columns:1fr;
  }

  .algorithm-results-toggle{
    width:100%;
  }

  .algorithm-pending-file{
    grid-template-columns:minmax(0,1fr) auto;
  }

  .algorithm-pending-file>small{
    grid-column:1/-1;
  }

  /* On phones the acknowledgement action must be visible immediately after
   * opening an algorithm instead of sitting below a potentially long text. */
  .ui-list-item__body{
    display:flex;
    flex-direction:column;
    min-width:0;
  }

  .ui-list-item__body>.algorithm-meta-line{
    order:0;
  }

  .ui-list-item__body>.algorithm-ack-actions{
    order:1;
    align-items:stretch;
    flex-direction:column;
    margin:0 0 14px;
    padding:12px;
    border:1px solid var(--theme-border,rgba(27,82,79,.14));
    border-radius:12px;
    background:var(--theme-primary-soft,rgba(35,140,132,.07));
  }

  .ui-list-item__body>.ui-rich-text{
    order:2;
  }

  .ui-list-item__body>.algorithm-attachment-list{
    order:3;
  }

  .algorithm-ack-actions>.btn,
  .algorithm-ack-actions>.button{
    width:100%;
  }

  .algorithm-ack-actions>.algorithm-ack-accepted,
  .algorithm-ack-actions>.algorithm-ack-counter{
    width:100%;
    min-width:0;
  }
}

@media(max-width:620px){
  .algorithm-ack-search-dialog__footer{
    flex-wrap:wrap;
  }
  .algorithm-ack-search-dialog__footer .btn{
    flex:1 1 140px;
  }
}
