/* 15.4: адресная геометрия существующих модалок, без изменения действий. */

/* 06.10: manager choices remain one strip; the summary wraps separately. */
#requestDialog #requestActionManagerPersistent {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}
#requestDialog #requestActionManagerPersistent .request-action-manager-title-row { flex: 1 0 100%; min-width: 0; }
#requestDialog #requestActionManagerPersistent .manager-color-options {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 8px;
  max-width: 100%;
  padding: 3px;
  overflow-x: auto;
}
#requestDialog #requestActionManagerPersistent .manager-color-option { flex-shrink: 0; }
#requestDialog #requestActionManagerSummary { white-space: normal; font-weight: 500; }
#requestDialog #requestActionManagerPersistent.has-selected-manager #requestActionManagerSummary { font-weight: 600; }
#requestDialog #requestActionManagerPersistent h3 { font-weight: 600; }
#requestDialog .request-manager-feedback-slot { flex: 1 1 210px; min-width: 0; display: grid; align-items: center; }
#requestDialog .request-manager-feedback-slot > p { grid-area: 1 / 1; width: 100%; margin: 0; }
#requestDialog #requestActionManagerWarning { font-weight: 600 !important; }
#requestDialog #requestActionManagerWarning[hidden] { display: block !important; visibility: hidden; }
#requestDialog .has-manager-warning #requestActionManagerSummary { visibility: hidden; }

/* The request action overlay is portalled to body, outside the scroll layer. */
#requestActionOverlay { overscroll-behavior: contain; }
#requestActionOverlay .request-action-box { max-height: calc(100dvh - 36px); overflow-y: auto; }
@media (max-width: 760px) {
  #requestActionOverlay { padding: 12px; }
  #requestActionOverlay .request-action-box { max-height: calc(100dvh - 24px); }
  #requestActionOverlay #requestActionApplyButton { min-height: 40px; }
}
@media (min-width: 761px) {
  #appointmentDialog .appointment-dialog-head {
    position: relative;
    padding: 22px;
  }
  #appointmentDialog .appointment-dialog-head-tools {
    align-self: start;
    flex-wrap: nowrap;
    padding-right: 42px;
    min-width: 34px;
  }
  #appointmentDialog .appointment-dialog-head-tools > .appointment-head-relation,
  #appointmentDialog .appointment-ap-copy-button {
    min-width: 0;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #appointmentDialog #closeDialogButton {
    position: absolute;
    top: 22px;
    right: 22px;
    height: 34px;
  }
  #clientDialog .dialog-head {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    align-items: center;
    min-height: 84px;
    padding: 22px;
  }
  #clientDialog .client-dialog-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    margin: 1px;
  }
  #clientDialogTitle {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* Ось header совпадает с padding 24px основных блоков REQ. */
  #requestDialog .request-dialog-head {
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding-left: 24px;
    padding-right: 24px;
    padding-top: 24px;
  }
}

/* F10/F26: размер контролов существующих форм профиля/администрирования. */
#userAdminOverlay #userAdminCloseButton {
  flex: 0 0 34px;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
}
#profileOverlay .profile-form input {
  height: 34px;
  min-height: 34px;
  padding-block: 5px;
  padding-left: 8px;
}
@media (max-width: 760px) {
  #userAdminOverlay #userAdminCloseButton {
    flex-basis: 32px;
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
  }
  #profileOverlay .profile-form input {
    height: 32px;
    min-height: 32px;
    padding-block: 4px;
  }
  #profileOverlay .password-visibility-toggle {
    width: 32px;
    height: 32px;
    min-height: 32px;
  }
  html[data-phase10-mobile="true"] #requestDialog #requestDataOperationStatus {
    display: none !important;
  }
}

#appointmentDialog .appointment-work-controls .service-toggle-card[data-work-type="other_service"].appointment-other-estimate-row {
  gap: 8px;
}

.request-source-badge.source-manual {
  border-color: #b9d4fb;
  color: #073b91;
  background: #edf5ff;
}

#clientDialog .client-sale-history-meta {
  position: relative;
  min-width: 0;
  overflow: visible;
  display: grid;
  align-content: start;
  align-self: start;
  gap: 2px;
  -webkit-line-clamp: unset;
}
#clientDialog .client-sale-history-line {
  display: block;
  min-width: 0;
  line-height: 1.4;
}
#clientDialog .client-sale-history-role,
#clientDialog .client-sale-history-work {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#clientDialog .client-sale-history-details {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
#clientDialog .client-sale-history-work {
  flex: 1 1 auto;
}
#clientDialog .client-sale-history-amount {
  flex: 0 0 auto;
  white-space: nowrap;
}
#clientDialog .client-sale-history-meta:focus-within::after {
  content: attr(data-full-text);
  position: absolute;
  z-index: 2;
  bottom: calc(100% + 6px);
  right: 0;
  width: max-content;
  max-width: min(400px, 80vw);
  padding: 8px 10px;
  border: 1px solid #bed6fb;
  border-radius: 6px;
  color: #102033;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
  white-space: normal;
  overflow-wrap: anywhere;
  pointer-events: none;
}
#clientDialog .client-sale-history-role:focus-visible,
#clientDialog .client-sale-history-work:focus-visible {
  outline: 2px solid #5e9cf0;
  outline-offset: 1px;
}

/* 15.8 B17–B23: одинаковые отступы по краям и доступный профиль. */
@media (min-width: 761px) {
  #estimateDialog .estimate-dialog-head {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 34px;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    padding: 18px;
  }
  #estimateDialog .estimate-dialog-head > .dialog-entity-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }
  #estimateDialog .estimate-dialog-head > .dialog-close-button {
    position: static;
    justify-self: end;
    padding: 0;
  }
  #estimateDialog .estimate-dialog-actions {
    min-height: 70px;
    padding: 18px;
  }
  #appointmentDialog .appointment-dialog-actions {
    min-height: 78px;
    padding: 22px;
  }
  #requestDialog .request-dialog-actions {
    min-height: 82px;
    padding: 24px;
  }
  #requestDialog .request-dialog-head-tools {
    display: grid;
    grid-template-columns: repeat(3, max-content);
    grid-template-rows: 40px auto;
    justify-content: end;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 0;
  }
  #requestDialog #requestDialogOriginBadge {
    grid-column: 1;
    grid-row: 2;
    justify-self: end;
    width: max-content;
  }
  #requestDialog #requestDialogVirtualMarker {
    grid-column: 2;
    grid-row: 2;
  }
  #requestDialog #requestDialogClientBadge {
    grid-column: 3;
    grid-row: 2;
    margin-left: 0;
  }
  #requestDialog .request-dialog-head-tools:has(#requestDialogVirtualMarker[hidden]),
  #requestDialog .request-dialog-head-tools:has(#requestDialogClientBadge[hidden]) {
    grid-template-columns: repeat(2, max-content);
  }
  #requestDialog .request-dialog-head-tools:has(#requestDialogVirtualMarker[hidden]) #requestDialogClientBadge {
    grid-column: 2;
  }
  #requestDialog .request-dialog-head-tools:has(#requestDialogVirtualMarker[hidden]):has(#requestDialogClientBadge[hidden]) #requestDialogOriginBadge {
    grid-column: 1 / -1;
  }
}

#appointmentDialog .appointment-head-relation,
#appointmentDialog .appointment-ap-copy-button,
#requestDialog .request-dialog-head-tools > .request-source-badge,
#requestDialog .request-dialog-head-tools > .request-client-state-badge,
#requestDialog .request-dialog-head-tools > .request-virtual-marker-badge {
  justify-content: center;
  text-align: center;
}

#profileOverlay {
  display: flex;
  align-items: flex-start;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#profileOverlay[hidden] { display: none; }
#profileOverlay .profile-dialog {
  display: block;
  flex: 0 0 auto;
  margin: auto;
  height: auto;
  max-height: none;
  padding: 0;
  overflow: visible;
}
#profileOverlay .profile-dialog > header {
  position: relative;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  border-radius: 9px 9px 0 0;
  background: #ffffff;
}
#profileOverlay #profileCloseButton {
  flex: 0 0 34px;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
}
#profileOverlay .profile-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px 12px;
  margin: 18px;
}
#profileOverlay .profile-form > label,
#profileOverlay .profile-form > h4 {
  grid-column: 1 / -1;
  min-width: 0;
}
#profileOverlay .profile-form > h4 {
  margin: 0;
}
#profileOverlay .profile-form > .muted {
  grid-column: 1;
  grid-row: 4;
  min-width: 0;
  margin: 0;
}
#profileOverlay .profile-form > .profile-dialog-actions {
  grid-column: 2;
  grid-row: 4;
  align-self: start;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
#profileOverlay .profile-form > .form-message {
  grid-column: 1 / -1;
  grid-row: 5;
  margin: 0;
  overflow-wrap: anywhere;
}
#profileOverlay .profile-form > .form-message:empty {
  display: none;
}
#profileOverlay .profile-password-form {
  margin-top: 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
@media (max-width: 760px) {
  html[data-phase10-mobile="true"] #profileOverlay {
    padding: 0 0 env(safe-area-inset-bottom);
    z-index: 1000;
  }
  html[data-phase10-mobile="true"] #profileOverlay .profile-dialog {
    width: 100%;
    height: auto;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  html[data-phase10-mobile="true"] #profileOverlay .profile-dialog > header {
    padding: 12px;
    border-radius: 0;
  }
  html[data-phase10-mobile="true"] #profileOverlay #profileCloseButton {
    flex-basis: 40px;
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
  }
  html[data-phase10-mobile="true"] #profileOverlay .profile-form {
    gap: 8px;
    margin: 12px;
  }
  html[data-phase10-mobile="true"] #profileOverlay .profile-password-form {
    margin-top: 0;
    padding-top: 12px;
  }
  html[data-phase10-mobile="true"] #profileOverlay .profile-dialog-actions > button {
    min-height: 40px;
    padding: 5px 10px;
    font-size: 12px;
  }
}

/* Внешний слой прокручивает всю Проценку, как общий modal-layer. */
#estimateDialog.dialog {
  inset: 0 !important;
  top: 0 !important;
  left: 0 !important;
  transform: none !important;
  width: 100%;
  max-width: none;
  height: 100dvh !important;
  max-height: none !important;
  padding: 24px 12px;
  border: 0;
  border-radius: 0;
  overflow: auto !important;
  background: transparent;
  box-shadow: none;
  overscroll-behavior: contain;
}
#estimateDialog.dialog[open] { display: flex; flex-direction: column; }
#estimateDialog .estimate-dialog-shell {
  flex: 0 0 auto;
  width: min(720px, 100%);
  margin: auto;
  max-height: none;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
#estimateDialog .estimate-dialog-body { overflow: visible; }
#estimateDialog .estimate-dialog-head {
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
}
#estimateDialog .estimate-dialog-actions {
  border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px);
}
@media (max-width: 760px) {
  #estimateDialog.dialog { padding: 12px 8px; }
}

/* C01: одинаковые промежутки и общая правая колонка признаков работ. */
#appointmentDialog .appointment-work-controls .material-source-toggle,
#requestDialog .request-appointment-panel .appointment-work-controls .material-source-toggle {
  gap: 8px;
}
#appointmentDialog .appointment-work-controls .service-toggle-card[data-work-type="other_service"].appointment-other-estimate-row:not(:has(.appointment-estimate-button[hidden])) {
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
}

/* Внешний scroll сохраняется, полоса скрыта как в modal-layer. */
#profileOverlay, #estimateDialog.dialog { scrollbar-width: none; -ms-overflow-style: none; }
#profileOverlay::-webkit-scrollbar, #estimateDialog.dialog::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* E19–E20: создание клиента использует ту же высоту полей и close. */
#clientCreateOverlay #clientCreateCloseButton {
  flex: 0 0 34px;
  width: 34px;
  min-width: 34px;
  max-width: 34px;
  height: 34px;
  min-height: 34px;
  max-height: 34px;
  padding: 0;
  border-radius: 8px;
}
#clientCreateOverlay .client-create-fields input {
  height: 34px;
  min-height: 34px;
  padding: 5px 8px;
  font-size: 13px;
}
@media (max-width: 760px) {
  #clientCreateOverlay #clientCreateCloseButton {
    flex-basis: 32px;
    width: 32px;
    min-width: 32px;
    max-width: 32px;
    height: 32px;
    min-height: 32px;
    max-height: 32px;
  }
  #clientCreateOverlay .client-create-fields input {
    height: 32px;
    min-height: 32px;
    padding: 4px 8px;
    font-size: 12px;
  }
}
.request-client-stats-tooltip {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* H10: эффективная зона32px; рисуем hover внутри рамки34/32px поля. */
#profileOverlay .profile-form .password-input-control > input { padding-right: 40px; }
#profileOverlay .password-visibility-toggle {
  width: 32px; height: 32px; min-height: 32px; padding: 0;
  right: 2px; border-radius: 5px; isolation: isolate;
}
#profileOverlay .password-visibility-toggle:is(:hover,:focus-visible) { background: transparent; outline: none; }
#profileOverlay .password-visibility-toggle::before {
  content: ''; position: absolute; inset: 2px; z-index: -1; border-radius: 4px;
}
#profileOverlay .password-visibility-toggle:is(:hover,:focus-visible)::before { background: var(--surface-soft,#f1f5f4); }
#profileOverlay .password-visibility-toggle:focus-visible::before { outline: 2px solid var(--primary); outline-offset: -2px; }

/* H03: вся ось комментария; четыре действия в одном ряду. */
@media (max-width:760px) {
  html[data-phase10-mobile="true"] #requestDangerZone .request-danger-actions {
    display: grid; grid-column: 1 / -1;
    grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px;
    width: 100%; min-width: 0; justify-content: stretch;
  }
  html[data-phase10-mobile="true"] #requestDangerZone .request-danger-actions:not(:has([data-request-danger-action="test"]:not([hidden]))) { grid-template-columns: repeat(3,minmax(0,1fr)); }
  html[data-phase10-mobile="true"] #requestDangerZone .request-danger-actions .danger-button {
    min-width: 0; width: 100%; min-height: 40px; height: auto;
    padding: 5px 3px; font-size: 12px; line-height: 15px;
    display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 3px;
    white-space: normal; box-shadow: none;
  }
  html[data-phase10-mobile="true"] #requestDangerZone .request-danger-actions .button-icon { width:16px; height:16px; flex:0 0 16px; }
}

#requestDialog [aria-invalid="true"] { border-color: #dc2626; }
#requestActionOverlay .request-action-box { position: relative; }
/* Крестик подтверждения не зависит от прежнего родителя portal. */
#requestActionOverlay .request-action-close-button,
#appointmentHideDialog .dialog-close-button {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 8px;
}
#requestActionOverlay .request-action-box > h3 { padding-right: 42px; }
#appointmentHideDialog { border-radius: var(--radius); }
#appointmentHideDialog .appointment-hide-dialog-head {
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
}
#appointmentHideDialog .appointment-hide-dialog-actions {
  border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px);
}
@media (max-width: 760px) {
  html[data-phase10-mobile="true"] #requestActionOverlay .request-action-close-button,
  html[data-phase10-mobile="true"] #appointmentHideDialog .dialog-close-button {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
  }
}
#estimateDialog .estimate-dialog-body { padding-inline: 18px; }
@media (max-width: 760px) { #estimateDialog .estimate-dialog-body { padding-inline: 20px; } }
/* Сообщения не участвуют в геометрии формы. */
#requestDialog #requestFormMessage { display: none; }
#estimateDialog #estimateDialogMessage { display: none; }
.notice.is-modal-feedback {
  position: fixed; inset: 50% auto auto 50%; transform: translate(-50%, -50%);
  z-index: 12050; margin: 0; width: min(480px, calc(100vw - 32px));
  display: grid; grid-template-columns: minmax(0, 1fr) 32px; align-items: start; gap: 12px;
  max-height: calc(100dvh - 32px); overflow: auto; padding: 16px 16px 21px;
  background: #fff; color: #173b70; border: 1px solid #b8cdea; border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15,35,67,.28), 0 3px 10px rgba(15,35,67,.16);
  backdrop-filter: none; -webkit-backdrop-filter: none; line-height: 1.45;
}
.notice.is-modal-feedback.is-error { background: #fff8f8; color: #a72424; border-color: #e8b4b4; }
.notice.is-modal-feedback .notice-message { padding: 4px 0; min-width: 0; overflow-wrap: anywhere; }
.notice.is-modal-feedback .notice-close-button {
  display: grid; place-items: center; width: 32px; height: 32px; min-height: 32px;
  padding: 6px; border: 0; border-radius: 6px; background: transparent; color: inherit; box-shadow: none;
}
.notice.is-modal-feedback .notice-close-button:hover { background: rgba(23,59,112,.08); }
.notice.is-modal-feedback .notice-close-button:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
.notice.is-modal-feedback .notice-close-button svg { width: 20px; height: 20px; }
.notice.is-modal-feedback .notice-timer { grid-column: 1 / -1; }
.notice.is-modal-feedback .notice-timer-bar { background: #9cb3d5; }
.notice.is-modal-feedback.is-error .notice-timer-bar { background: #d16c6c; }#requestActionOverlay #requestActionMessage { display: none; }
.notice.is-modal-feedback .notice-message { color: inherit; line-height: inherit; }
.notice.is-modal-feedback .notice-close-button svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#managerConfirmOverlay #managerConfirmMessage { min-height: 48px; padding: 8px 10px; margin: 0; display: flex; align-items: center; border: 1px solid transparent; border-radius: 6px; font-weight: 600; }
#managerConfirmOverlay #managerConfirmMessage.has-manager-warning { color: #b42318; background: #fff1f2; border-color: #fecaca; }
@media (max-width: 760px) {
  #requestDialog #submitAppointmentFromRequestButton { min-height: 40px; }
  #requestDialog #requestActionManagerPersistent.is-in-appointment-panel { padding-inline: 0; }
  #requestDialog #requestActionManagerPersistent.is-in-appointment-panel .request-action-manager-title-row,
  #requestDialog #requestActionManagerPersistent.is-in-appointment-panel .request-manager-feedback-slot { margin-inline: 10px; }
  #requestDialog #requestActionManagerPersistent.is-in-appointment-panel .manager-color-options { padding: 2px; margin-inline: auto; }
}
#managerConfirmOverlay .manager-confirm-selection-row { flex-wrap: wrap; gap: 8px 12px; }
#managerConfirmOverlay .manager-confirm-selection-row .manager-color-options { flex: 0 0 auto; flex-wrap: nowrap; gap: 8px; max-width: 100%; overflow-x: auto; }
#managerConfirmOverlay #managerConfirmMessage { flex: 1 1 210px; min-width: 0; }

/* Фаза15.8: один индикатор цикла и стандартные окна данных/финализации. */
#requestDialog .request-lifecycle-actions .request-data-indicator {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  width: 10px; height: 10px; border-radius: 50%; background: #94a3b8;
  box-shadow: 0 0 0 2px rgba(148,163,184,.12); pointer-events: none;
}
#requestDialog .request-lifecycle-actions .request-data-indicator[hidden] { display: none; }
#requestDialog .request-data-indicator[data-state="pending"] { background: #d99a20; box-shadow: 0 0 0 2px rgba(217,154,32,.12); }
#requestDialog .request-data-indicator[data-state="sent"] { background: #22c7e8; box-shadow: 0 0 0 2px rgba(34,199,232,.16), 0 0 6px rgba(34,199,232,.28); }
#requestDialog .request-data-indicator[data-state="received"] { background: #22a468; box-shadow: 0 0 0 2px rgba(34,164,104,.12); }
#requestDialog .request-data-indicator[data-state="missing"] { background: #dc5353; box-shadow: 0 0 0 2px rgba(220,83,83,.12); }
#requestDialog .request-action-slot-placeholder.is-data-waiting {
  display: grid; place-items: center; padding: 6px 12px; color: var(--muted);
  font-size: 12px; font-weight: 400; line-height: 1.3; text-align: center;
}
.request-scenario-overlay { z-index: 12035; }
.request-scenario-box {
  display: flex; flex-direction: column; gap: 12px;
  max-height: calc(100dvh - 36px); min-height: 0;
}
.request-scenario-head { flex: 0 0 auto; min-width: 0; padding-right: 42px; }
.request-scenario-head h3 { margin: 0 0 4px; }
.request-scenario-head p { font-size: 12px; }
.request-scenario-head p.is-saving { color: var(--primary); }
#requestScenarioOverlay .request-action-close-button {
  position: absolute; top: 10px; right: 10px; width: 38px; min-width: 38px;
  height: 38px; min-height: 38px; padding: 0; border-radius: 8px;
}
.request-scenario-body { min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain; overflow-wrap: anywhere; }
#requestDataCyclePanel { display: grid; gap: 12px; }
#requestDataCyclePanel[hidden] { display: none; }
.request-data-cycle-status { font-size: 14px; font-weight: 600; color: var(--text); }
.request-data-cycle-status[data-state="received"] { color: #15803d; }
.request-data-cycle-status[data-state="missing"] { color: #b91c1c; }
.request-data-cycle-status[data-state="sent"] { color: #087d96; }
#requestDataCycleTime, .request-scenario-help { font-size: 12px; line-height: 1.45; color: var(--muted); }
.request-data-cycle-outcomes { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.request-data-cycle-outcomes[hidden] { display: none; }
.request-data-cycle-outcomes button { min-width: 0; justify-content: center; white-space: normal; }
.request-scenario-actions { flex: 0 0 auto; flex-wrap: wrap; gap: 8px; padding-top: 4px; }
#requestScenarioOverlay #requestDangerZone { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; }
#requestScenarioOverlay .request-danger-actions { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); width: 100%; gap: 8px; }
#requestScenarioOverlay .request-danger-actions:not(:has([data-request-danger-action="test"]:not([hidden]))) { grid-template-columns: repeat(3,minmax(0,1fr)); }
#requestScenarioOverlay .request-danger-actions button { min-width: 0; width: 100%; justify-content: center; white-space: normal; }
#requestScenarioOverlay .request-danger-guide { min-width: 0; }
#requestScenarioOverlay .request-danger-comment-field { display: grid; align-self: stretch; width: 100%; min-width: 0; }
#requestScenarioOverlay .request-danger-comment-field textarea { width: 100%; min-width: 0; }
#requestScenarioOverlay textarea { width: 100%; box-sizing: border-box; }
#requestScenarioOverlay [aria-invalid="true"] { border-color: #dc2626; }
.request-scenario-box [hidden] { display: none !important; }
@media (max-width: 760px) {
  .request-scenario-overlay { padding: 10px; }
  .request-scenario-box { max-height: calc(100dvh - 20px); }
  #requestScenarioOverlay .request-action-close-button { width: 32px; min-width: 32px; height: 32px; min-height: 32px; }
  #requestScenarioOverlay .request-scenario-actions button { min-height: 32px; font-size: 12px; }
  #requestScenarioOverlay .request-scenario-actions .primary-button,
  #requestScenarioOverlay .request-data-cycle-outcomes button { min-height: 40px; }
  html[data-phase10-mobile="true"] #requestDialog .request-lifecycle-actions [data-request-lifecycle-action="needs_data"] > .request-data-indicator {
    position: static; grid-column: 3; grid-row: 1; justify-self: center; transform: none;
    padding: 0; margin: 0; min-width: 10px; min-height: 10px;
  }
}
#managerConfirmOverlay .manager-confirm-selection-row { width: 100%; justify-self: stretch; }
@media (max-width: 760px) { #managerConfirmOverlay #managerConfirmApplyButton { min-height: 40px; } }

/* 15.8-RG/UI: верхний слой вынесен из прокручиваемого родителя; контент не создаёт второй выбор. */
#requestScenarioOverlay {
  position: fixed;
  inset: 0;
  padding: 18px 16px;
}
#requestScenarioOverlay .request-scenario-box {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 36px);
  padding: 16px;
  gap: 12px;
}
#requestScenarioOverlay .request-scenario-head {
  display: grid;
  gap: 4px;
}
#requestScenarioOverlay .request-scenario-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
#requestScenarioOverlay .request-scenario-head p { margin: 0; line-height: 1.4; }
.request-scenario-client { overflow-wrap: anywhere; }
#requestScenarioOverlay .request-final-instruction {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--text);
}
#requestScenarioOverlay #requestDangerZone { gap: 12px; }
#requestScenarioOverlay #requestDangerZone { align-items: stretch; text-align: left; }
#requestScenarioOverlay #requestFinalInstruction, #requestScenarioOverlay .request-scenario-help { text-align: left; }
#requestScenarioOverlay .request-danger-help { align-self: stretch; width: 100%; }
#requestScenarioOverlay #requestDangerZone[hidden] { display: none; }
#requestScenarioOverlay .request-danger-comment-field { gap: 6px; }
#requestScenarioOverlay .request-danger-comment-label { color: var(--muted); font-size: 12px; font-weight: 500; }
#requestScenarioOverlay .request-danger-comment-field textarea { min-height: 86px; line-height: 1.4; }
#requestScenarioOverlay .request-scenario-help { margin: 0; }
#requestScenarioOverlay .request-danger-actions { grid-template-columns: .8fr .95fr 1.6fr 1.35fr; align-items: stretch; }
#requestScenarioOverlay .request-danger-actions button { min-height: 40px; padding: 6px 8px; font-size: 12px; line-height: 15px; }
#requestScenarioOverlay .request-danger-actions button:disabled,
#requestScenarioOverlay .request-data-cycle-outcomes button:disabled,
#requestScenarioOverlay .request-scenario-actions button:disabled { opacity: .48; box-shadow: none; cursor: not-allowed; }
#requestScenarioOverlay .request-scenario-box[aria-busy="true"] button:disabled { cursor: progress; }
#requestDataCyclePanel { gap: 10px; }
#requestDataCyclePanel p { margin: 0; }
.request-data-cycle-freshness { line-height: 1.45; }
.request-data-cycle-author { font-size: 12px; line-height: 1.45; }
#requestDataCycleTime { white-space: pre-line; }
#requestDataCycleHistory { justify-self: start; }
#requestScenarioOverlay .request-data-cycle-outcomes .danger-button { border-color: #f2c4c8; background: #fff5f5; color: var(--danger); }
#requestScenarioOverlay .request-data-cycle-outcomes .danger-button:not(:disabled):hover { border-color: #eaa7ae; background: #ffeded; }
#requestScenarioOverlay .request-scenario-actions { display: flex; flex-wrap: nowrap; justify-content: flex-end; }
#requestScenarioOverlay .request-scenario-actions button { min-width: 0; white-space: normal; }
#requestActionOverlay.has-alternate-action .request-action-dialog-actions { flex-wrap: wrap; gap: 8px; }
#requestActionOverlay .request-action-text { white-space: pre-line; }

/* Действующий state pill занимает свою ячейку, а не абсолютное место поверх подписи. */
#requestDialog .request-appointment-panel .appointment-work-controls .service-toggle-button {
  grid-template-columns: 32px minmax(0, 1fr) auto;
  column-gap: 8px;
}
#requestDialog .request-appointment-panel .appointment-work-controls .service-flag-icon {
  grid-column: 1; grid-row: 1; width: 32px; min-width: 32px; max-width: 32px;
}
#requestDialog .request-appointment-panel .appointment-work-controls .service-toggle-title {
  grid-column: 2; grid-row: 1; font-weight: 600; white-space: normal; overflow: visible;
}
#requestDialog .request-appointment-panel .appointment-work-controls .service-toggle-state {
  position: static; transform: none; grid-column: 3; grid-row: 1; margin: 0;
}
@media (max-width: 760px) {
  #requestScenarioOverlay { padding: 10px; }
  #requestScenarioOverlay .request-scenario-box { width: 100%; max-height: calc(100dvh - 20px); padding: 16px; gap: 12px; }
  html[data-phase10-mobile="true"] #requestScenarioOverlay #requestDangerZone .request-danger-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html[data-phase10-mobile="true"] #requestScenarioOverlay #requestDangerZone .request-danger-actions button { padding: 6px; height: 40px; min-height: 40px; font-size: 12px; line-height: 15px; white-space: nowrap; }
  html[data-phase10-mobile="true"] #requestScenarioOverlay #requestDangerZone .request-danger-actions button .button-icon { display: inline-flex; flex: 0 0 16px; width: 16px; height: 16px; }
  html[data-phase10-mobile="true"] #requestScenarioOverlay #requestDangerZone .request-danger-actions:not(:has([data-request-danger-action="test"]:not([hidden]))) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  html[data-phase10-mobile="true"] #requestScenarioOverlay #requestDangerZone .request-danger-actions:not(:has([data-request-danger-action="test"]:not([hidden]))) [data-request-danger-action="customer_refused"] { grid-column: 1 / -1; }
  #requestScenarioOverlay .request-scenario-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  #requestDataStatusRefresh { grid-column: 1; grid-row: 1; justify-self: start; }
  #requestScenarioCancelButton { grid-column: 2; grid-row: 1; justify-self: end; }
  #requestDataCycleAgain { grid-column: 1 / -1; grid-row: 2; width: 100%; min-height: 40px; }
  #requestScenarioOverlay .request-data-cycle-outcomes { grid-template-columns: 1fr; }
  #requestScenarioOverlay .request-data-cycle-outcomes button { white-space: nowrap; min-height: 40px; }
  #requestActionOverlay.has-alternate-action .request-action-dialog-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #requestActionOverlay.has-alternate-action #requestActionCancelButton { grid-column: 1 / -1; }
  #requestActionOverlay.has-alternate-action .request-action-dialog-actions button { min-width: 0; white-space: normal; }
  #requestDialog .request-appointment-panel .appointment-work-controls .service-toggle-button { grid-template-columns: 32px minmax(0, 1fr); row-gap: 3px; }
  #requestDialog .request-appointment-panel .appointment-work-controls .service-flag-icon { grid-row: 1 / span 2; }
  #requestDialog .request-appointment-panel .appointment-work-controls .service-toggle-state { grid-column: 2; grid-row: 2; justify-self: start; }
}

/* 08.10, R02: место для обычного внешнего outline без сдвига оси поля. */
#requestScenarioOverlay .request-scenario-body {
  padding: 4px;
  margin: -4px;
}

/* R03: исходы принадлежат тому же опасному действию «Зафиналить». */
#requestScenarioOverlay [data-request-danger-action] {
  border-color: #fecaca;
  color: #991b1b;
  background: #fff1f2;
}

/* R04: выбранный цвет виден по всему блоку; тени кружков не режутся scrollport. */
#requestDialog .request-action-manager-persistent.has-selected-manager,
#appointmentDialog .appointment-manager-controls.has-selected-manager,
#requestDialog .request-appointment-panel .appointment-manager-controls.has-selected-manager,
#managerConfirmOverlay .manager-confirm-manager-controls.has-selected-manager {
  background: linear-gradient(135deg,
    rgba(var(--appointment-manager-section-rgb), .13),
    rgba(var(--appointment-manager-section-rgb), .055));
}
.manager-color-option { box-shadow: none; flex-shrink: 0; scroll-margin: 3px; }
.manager-color-options { scroll-padding: 3px; }
.manager-color-option .appointment-color-dot { box-shadow: 0 0 0 1px #d8e3ee; }
.manager-color-option.is-active .appointment-color-dot {
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px #0b4ea2;
}
.manager-color-option.has-matching-color:not(.is-active) .appointment-color-dot {
  box-shadow: 0 0 0 2px #647386;
}
#managerConfirmOverlay .manager-confirm-selection-row .manager-color-options {
  padding: 3px;
  min-width: 0;
  flex-shrink: 1;
}
#managerConfirmOverlay .manager-confirm-box { min-width: 0; max-width: 100%; }
#managerConfirmOverlay .manager-confirm-manager-controls { min-width: 0; }

/* R05: адресное оформление «?» истории, прямо заданное владельцем. */
#requestDialog .request-history-help,
#appointmentDialog .appointment-history-help,
#requestDialog .request-history-help:hover,
#appointmentDialog .appointment-history-help:hover,
#requestDialog .request-history-help:focus-visible,
#appointmentDialog .appointment-history-help:focus-visible {
  border: 1px solid #073b91;
  color: #fff;
  background: linear-gradient(180deg, #0e5fc2, #073b91);
  font-weight: 600;
}
#requestDialog .request-history-help:focus-visible,
#appointmentDialog .appointment-history-help:focus-visible {
  outline: 2px solid rgba(11, 78, 162, .46);
  outline-offset: 2px;
}

/* R06: фактическая рамка dialog input (styles.css), доступность прежняя. */
#requestDialog #requestRetailClientButton,
#appointmentDialog #appointmentRetailClientButton {
  border-color: #a9bfdc;
  font-weight: 600;
}
