/* OKKwork — стек открытых страниц (край предыдущей панели + сужение верхней) */

:root {
  --okkwork-page-stack-peek: 56px;
}

body.okkwork-profile-from-permissions.okkwork-profile-panel-open #okkwork-mkk-profile-panel.is-open,
body.okkwork-profile-from-permissions.okkwork-specialist-profile-panel-open #okkwork-specialist-profile-panel.is-open,
body.okkwork-profile-from-org.okkwork-profile-panel-open #okkwork-mkk-profile-panel.is-open,
body.okkwork-profile-from-org.okkwork-specialist-profile-panel-open #okkwork-specialist-profile-panel.is-open {
  right: 0 !important;
  max-width: min(var(--okkwork-profile-panel-max-width, 920px), 100vw) !important;
}

body.okkwork-profile-from-org .okkwork-page-stack-peek {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body.okkwork-profile-from-permissions.okkwork-page-stack-active
  #okkwork-permissions-page.is-open.is-okkwork-page-underlay
  .okkwork-permissions-page__shell {
  right: 0 !important;
  max-width: min(var(--okkwork-profile-panel-max-width, 920px), 100vw) !important;
}

body.okkwork-profile-from-permissions.okkwork-page-stack-active.okkwork-profile-panel-open
  #okkwork-mkk-profile-panel.is-open.is-okkwork-page-top,
body.okkwork-profile-from-permissions.okkwork-page-stack-active
  #okkwork-mkk-profile-panel.is-open.is-okkwork-page-top,
body.okkwork-profile-from-permissions.okkwork-page-stack-active.okkwork-specialist-profile-panel-open
  #okkwork-specialist-profile-panel.is-open.is-okkwork-page-top,
body.okkwork-profile-from-permissions.okkwork-page-stack-active
  #okkwork-specialist-profile-panel.is-open.is-okkwork-page-top {
  right: 0 !important;
  max-width: min(
    var(--okkwork-page-stack-top-width, 872px),
    calc(100vw - var(--okkwork-page-stack-peek, 56px))
  ) !important;
}

body.okkwork-page-stack-active.okkwork-profile-panel-open #okkwork-mkk-profile-panel.is-open.is-okkwork-page-underlay,
body.okkwork-page-stack-active #okkwork-mkk-profile-panel.is-open.is-okkwork-page-underlay {
  z-index: 101570 !important;
  pointer-events: auto;
  transform: translateX(0) !important;
  opacity: 1 !important;
  visibility: visible !important;
}

body.okkwork-page-stack-active #okkwork-permissions-page.is-open.is-okkwork-page-underlay {
  z-index: 101570 !important;
  pointer-events: auto;
  visibility: visible !important;
  opacity: 1 !important;
  display: block !important;
}

body.okkwork-page-stack-active #okkwork-permissions-page.is-open.is-okkwork-page-underlay .okkwork-permissions-page__shell {
  right: var(--okkwork-menu-rail-width, 280px) !important;
  width: var(--okkwork-profile-panel-width, 920px) !important;
  max-width: min(
    var(--okkwork-profile-panel-max-width, 920px),
    calc(100vw - var(--okkwork-menu-rail-width, 280px))
  ) !important;
  transform: translateX(0) !important;
}

body.okkwork-page-stack-active #okkwork-permissions-page.is-open.is-okkwork-page-underlay .okkwork-permissions-page__collapse {
  visibility: hidden;
  pointer-events: none;
}

body.okkwork-page-stack-active #okkwork-permissions-page.is-open.is-okkwork-page-underlay .okkwork-permissions-page__backdrop {
  opacity: 0 !important;
  pointer-events: none;
}

body.okkwork-page-stack-active.okkwork-profile-panel-open
  #okkwork-mkk-profile-panel.is-open.is-okkwork-page-top,
body.okkwork-page-stack-active #okkwork-mkk-profile-panel.is-open.is-okkwork-page-top {
  right: var(--okkwork-menu-rail-width, 280px) !important;
  left: auto !important;
  width: var(
    --okkwork-page-stack-top-width,
    calc(var(--okkwork-profile-panel-width, 920px) - var(--okkwork-page-stack-peek, 48px))
  ) !important;
  max-width: min(
    var(--okkwork-page-stack-top-width, 872px),
    calc(100vw - var(--okkwork-menu-rail-width, 280px) - var(--okkwork-page-stack-peek, 48px))
  ) !important;
  min-width: 0 !important;
  z-index: 101575 !important;
  box-shadow: -8px 0 28px rgba(15, 23, 42, 0.12) !important;
  transition:
    transform var(--okkwork-profile-slide-ms, 0.4s) var(--okkwork-profile-slide-ease, ease-in-out),
    width var(--okkwork-profile-slide-ms, 0.4s) var(--okkwork-profile-slide-ease, ease-in-out),
    opacity var(--okkwork-profile-slide-ms, 0.4s) var(--okkwork-profile-slide-ease, ease-in-out) !important;
}

body.okkwork-page-stack-active.okkwork-specialist-profile-panel-open
  #okkwork-specialist-profile-panel.is-open.is-okkwork-page-top,
body.okkwork-page-stack-active #okkwork-specialist-profile-panel.is-open.is-okkwork-page-top {
  right: var(--okkwork-menu-rail-width, 280px) !important;
  left: auto !important;
  width: var(
    --okkwork-page-stack-top-width,
    calc(var(--okkwork-profile-panel-width, 920px) - var(--okkwork-page-stack-peek, 48px))
  ) !important;
  max-width: min(
    var(--okkwork-page-stack-top-width, 872px),
    calc(100vw - var(--okkwork-menu-rail-width, 280px) - var(--okkwork-page-stack-peek, 48px))
  ) !important;
  min-width: 0 !important;
  z-index: 101575 !important;
  box-shadow: -8px 0 28px rgba(15, 23, 42, 0.12) !important;
  transition:
    transform var(--okkwork-profile-slide-ms, 0.4s) var(--okkwork-profile-slide-ease, ease-in-out),
    width var(--okkwork-profile-slide-ms, 0.4s) var(--okkwork-profile-slide-ease, ease-in-out),
    opacity var(--okkwork-profile-slide-ms, 0.4s) var(--okkwork-profile-slide-ease, ease-in-out) !important;
}

body.okkwork-page-stack-active #okkwork-mkk-profile-panel.is-open.is-okkwork-page-top .profile-panel__close,
body.okkwork-page-stack-active #okkwork-specialist-profile-panel.is-open.is-okkwork-page-top .profile-panel__close {
  top: 12px !important;
  right: 17px !important;
  left: auto !important;
  margin: 0 !important;
  transform: none !important;
}

.okkwork-page-stack-peek {
  position: fixed;
  top: 0;
  bottom: 0;
  left: var(--okkwork-profile-panel-left, 0);
  z-index: 101572;
  margin: 0;
  padding: 12px 0 10px;
  border: none;
  border-right: 1px solid rgba(6, 88, 162, 0.14);
  background: rgba(255, 255, 255, 0.96);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, background 0.15s ease;
}

.okkwork-page-stack-peek__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  margin: 0 auto;
  padding: 0;
  box-sizing: border-box;
}

.okkwork-page-stack-peek__label {
  display: block;
  width: max-content;
  max-width: calc(100% - 2px);
  margin: 0 auto;
  padding: 2px 0 8px;
  font-family: "Rubik-Bold", "Rubik-Medium", "Rubik", sans-serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.01em;
  color: rgba(6, 88, 162, 0.92);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: min(460px, calc(100vh - 72px));
  user-select: none;
}

.okkwork-page-stack-peek__avatar {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  flex-shrink: 0;
  background: #e8f4fc;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(6, 88, 162, 0.18);
  color: transparent;
  font-size: 0;
}

.okkwork-page-stack-peek__title-icon {
  display: none;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  user-select: none;
}

.okkwork-page-stack-peek.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.okkwork-page-stack-peek:hover {
  background: #fff;
}

.okkwork-page-stack-peek:focus-visible {
  outline: 2px solid rgba(6, 88, 162, 0.45);
  outline-offset: -2px;
}

.okkwork-page-stack-peek.is-permissions-underlay .okkwork-page-stack-peek__label {
  font-family: "Rubik-Bold", "Rubik-Medium", "Rubik", sans-serif;
  font-size: 16px;
  font-weight: 800;
}

.okkwork-page-stack-peek.is-permissions-underlay .okkwork-page-stack-peek__avatar,
.okkwork-page-stack-peek.is-referral-underlay .okkwork-page-stack-peek__avatar {
  display: none;
}

.okkwork-page-stack-peek.is-permissions-underlay .okkwork-page-stack-peek__title-icon {
  display: block;
}

body.okkwork-referral-terms-from-referral.okkwork-page-stack-active .okkwork-page-stack-peek,
body.okkwork-balance-deadline-terms-from-balance.okkwork-page-stack-active .okkwork-page-stack-peek {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

body.okkwork-page-stack-active #okkwork-referral-page.is-open.is-okkwork-page-underlay .okkwork-referral-page__shell {
  position: fixed !important;
  top: var(--okkwork-referral-header-offset, 71px) !important;
  left: 0 !important;
  right: auto !important;
  bottom: 0 !important;
  width: var(--okkwork-referral-split-half, 50vw) !important;
  max-width: var(--okkwork-referral-split-half, 50vw) !important;
  transform: translateX(0) !important;
}

body.okkwork-page-stack-active #okkwork-referral-terms-panel.is-open.is-okkwork-page-top {
  top: var(--okkwork-referral-header-offset, 71px) !important;
  right: 0 !important;
  left: auto !important;
  bottom: 0 !important;
  height: auto !important;
  width: var(--okkwork-referral-split-half, 50vw) !important;
  max-width: var(--okkwork-referral-split-half, 50vw) !important;
  min-width: 0 !important;
  z-index: 101575 !important;
  box-shadow: -8px 0 28px rgba(15, 23, 42, 0.12) !important;
  transition:
    transform var(--okkwork-profile-slide-ms, 0.4s) var(--okkwork-profile-slide-ease, ease-in-out),
    width var(--okkwork-profile-slide-ms, 0.4s) var(--okkwork-profile-slide-ease, ease-in-out) !important;
}

body.okkwork-page-stack-active #okkwork-balance-page.is-open.is-okkwork-page-underlay .okkwork-balance-page__shell {
  position: fixed !important;
  top: var(--okkwork-balance-header-offset, 71px) !important;
  left: 0 !important;
  right: auto !important;
  bottom: 0 !important;
  width: var(--okkwork-balance-split-half, 50vw) !important;
  max-width: var(--okkwork-balance-split-half, 50vw) !important;
  transform: translateX(0) !important;
}

body.okkwork-page-stack-active #okkwork-balance-deadline-terms-panel.is-open.is-okkwork-page-top {
  top: var(--okkwork-balance-header-offset, 71px) !important;
  right: 0 !important;
  left: auto !important;
  bottom: 0 !important;
  height: auto !important;
  width: var(--okkwork-balance-split-half, 50vw) !important;
  max-width: var(--okkwork-balance-split-half, 50vw) !important;
  min-width: 0 !important;
  z-index: 101575 !important;
  box-shadow: -8px 0 28px rgba(15, 23, 42, 0.12) !important;
  transition:
    transform var(--okkwork-profile-slide-ms, 0.4s) var(--okkwork-profile-slide-ease, ease-in-out),
    width var(--okkwork-profile-slide-ms, 0.4s) var(--okkwork-profile-slide-ease, ease-in-out) !important;
}

@media (prefers-reduced-motion: reduce) {
  .okkwork-page-stack-peek {
    transition: none;
  }
}
