html.dai-shell-embedded,
html.dai-shell-embedded body {
  width: 100%;
  min-width: 0;
  min-height: 100%;
}

html.dai-shell-embedded body {
  overflow-x: hidden;
}

html.dai-shell-embedded .side,
html.dai-shell-embedded .app-sidebar {
  display: none !important;
}

/* Внешняя оболочка уже показывает presence и переключатель темы. Дочерние копии
   внутри iframe создавали визуальные дубли и накладывались на правый верхний угол. */
html.dai-shell-embedded .presence,
html.dai-shell-embedded .dnpg-wrap,
html.dai-shell-embedded .dai-theme-toggle {
  display: none !important;
}

html.dai-shell-embedded .wrap,
html.dai-shell-embedded .layout,
html.dai-shell-embedded .app-layout {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  min-height: 100vh !important;
}

html.dai-shell-embedded .main,
html.dai-shell-embedded .sites-workspace {
  width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
}

html.dai-shell-embedded .sites-workspace {
  height: 100vh !important;
}

html.dai-shell-embedded .back[href*="app.html"] {
  display: none !important;
}

.app-shell-frame-wrap {
  position: relative;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  background: #f5f7fa;
}

.app-shell-frame-wrap[hidden] {
  display: none !important;
}

.app-shell-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  opacity: 1;
  transition: opacity 150ms ease;
}

.app-shell-frame-wrap.is-loading .app-shell-frame {
  opacity: 1;
}

.app-shell-frame-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  place-items: center;
  pointer-events: none;
  background: transparent;
  color: #64748b;
}

.app-shell-frame-wrap.is-loading .app-shell-frame-loading {
  display: grid;
}

.app-shell-frame-loading::before {
  content: "";
  width: 24px;
  height: 24px;
  border: 2px solid #cbd5e1;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: dai-shell-spin 700ms linear infinite;
}

@keyframes dai-shell-spin {
  to { transform: rotate(360deg); }
}

body.dai-shell-external #stateDashboard > .app-workspace,
body.dai-shell-external main.shell > :not(#stateDashboard) {
  display: none !important;
}

body.dai-shell-external #stateDashboard > .app-workspace {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  overflow: hidden !important;
}

body.dai-shell-external #stateDashboard {
  display: grid !important;
  grid-template-rows: minmax(100vh, 1fr) !important;
  min-height: 100vh;
}

body.dai-shell-external #stateDashboard > .app-sidebar {
  grid-column: 1 !important;
  grid-row: 1 !important;
}

body.dai-shell-external #stateDashboard > .app-shell-frame-wrap {
  display: block !important;
  grid-column: 2 !important;
  grid-row: 1 !important;
  align-self: stretch;
  width: 100% !important;
  height: 100vh !important;
  min-height: 100vh;
}

body.dai-shell-external > .dai-theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 120;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 50%;
  background: rgba(255, 255, 255, .05);
  color: rgba(238, 244, 240, .8);
  cursor: pointer;
}

body.dai-shell-external > .dai-theme-toggle:hover {
  border-color: rgba(244, 203, 146, .35);
  color: #eef4f0;
}

body.dai-shell-external > .dai-theme-toggle svg {
  display: block;
  width: 21px;
  height: 21px;
}

body.is-dashboard-light.dai-shell-external > .dai-theme-toggle {
  border-color: rgba(26, 39, 63, .12);
  background: #fff;
  color: #3a3f47;
  box-shadow: 0 8px 20px rgba(33, 43, 67, .08);
}

body.is-dashboard-light.dai-shell-external > .dai-theme-toggle:hover {
  border-color: rgba(35, 60, 200, .28);
  color: #233cc8;
}

body:not(.dai-shell-external) > .dai-theme-toggle {
  display: none !important;
}

body.dai-shell-external .app-side-link.is-active:not(.is-shell-active) {
  background: transparent !important;
  color: #64748b !important;
  font-weight: 500 !important;
}

body.dai-shell-external .app-side-link.is-shell-active {
  background: transparent !important;
  color: #0f172a !important;
  font-weight: 650 !important;
}

body.dai-shell-external .app-side-link.is-shell-active .app-side-ico {
  color: #40516a !important;
}

html[data-theme="dark"] .app-shell-frame-wrap,
body.is-dashboard-dark .app-shell-frame-wrap {
  background: #202329;
  color: #aeb7c4;
}

html[data-theme="dark"] .app-shell-frame-loading,
body.is-dashboard-dark .app-shell-frame-loading {
  background: transparent;
  color: #aeb7c4;
}

html[data-theme="dark"] body.dai-shell-external .app-side-link.is-active:not(.is-shell-active),
body.is-dashboard-dark.dai-shell-external .app-side-link.is-active:not(.is-shell-active) {
  color: #b7bec8 !important;
}

html[data-theme="dark"] body.dai-shell-external .app-side-link.is-shell-active,
body.is-dashboard-dark.dai-shell-external .app-side-link.is-shell-active {
  color: #ffffff !important;
}

html[data-theme="dark"] body.dai-shell-external .app-side-link.is-shell-active .app-side-ico,
body.is-dashboard-dark.dai-shell-external .app-side-link.is-shell-active .app-side-ico {
  color: #d7dde6 !important;
}

@media (max-width: 860px) {
  .app-shell-frame-wrap {
    height: 100dvh;
  }
}
