.apps-popup {
  width: min(760px, 94vw);
  height: min(78dvh, 640px);
  max-width: 94vw;
  min-width: 320px;
  max-height: calc(100dvh - 80px);
  display: flex;
  flex-direction: column;
}

.apps-popup .xp-popup-content {
  padding: 12px;
  overflow: auto;
  max-height: none;
  min-height: 0;
  flex: 1 1 auto;
  background: #edead8;
}

.apps-sections {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.apps-section {
  border: 1px solid #a8bfe1;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #edf5ff 100%);
  padding: 10px;
}

.apps-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #234f86;
  margin: 0 0 8px;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 9px;
}

.apps-tile {
  position: relative;
  border: 2px solid #7aa6de;
  border-radius: 9px;
  min-height: 92px;
  background: linear-gradient(180deg, #ffffff 0%, #ddeeff 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  color: #17457f;
  font-weight: 700;
  cursor: pointer;
  padding: 8px;
  text-decoration: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
}

.apps-tile:hover,
.apps-tile:focus-visible {
  border-color: #3f79c5;
  box-shadow: 0 3px 10px rgba(26, 68, 127, 0.25);
}

.apps-tile:active {
  transform: translateY(1px);
}

.apps-tile-icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.apps-tile-title {
  font-size: 12px;
  line-height: 1.2;
  word-break: break-word;
}

.apps-tile.is-dev {
  border-style: dashed;
}

.apps-tile-tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 7px);
  transform: translateX(-50%);
  border: 1px solid #2d5b9a;
  border-radius: 6px;
  padding: 6px 9px;
  background: linear-gradient(180deg, #fffff7 0%, #ffe9b0 100%);
  color: #3d3d26;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  box-shadow: 0 4px 12px rgba(20, 40, 80, 0.22);
  z-index: 3;
}

.apps-tile.is-dev:hover .apps-tile-tip,
.apps-tile.is-dev:focus-visible .apps-tile-tip,
.apps-tile.is-dev.show-tip .apps-tile-tip {
  opacity: 1;
}

.apps-loading,
.apps-empty,
.apps-error {
  border: 1px dashed #aac3e6;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  color: #4b6588;
  background: #f8fbff;
}

.apps-error {
  border-color: #d7a6a6;
  color: #8f2a2a;
  background: #fff1f1;
}

.apps-embed-popup {
  width: min(980px, 96vw);
  height: min(82dvh, 760px);
  max-width: 96vw;
  max-height: calc(100dvh - 64px);
  display: flex;
  flex-direction: column;
}

.apps-embed-popup.is-maximized {
  width: calc(100vw - 16px) !important;
  height: calc(100dvh - 64px) !important;
  max-width: calc(100vw - 16px) !important;
  max-height: calc(100dvh - 64px) !important;
}

.apps-embed-max-btn {
  margin: 0;
  width: 22px;
  height: 20px;
  border: 1px solid #3d6ea4;
  border-radius: 3px;
  background: linear-gradient(180deg, #f8fbff 0%, #d8e8fb 100%);
  color: #1e4f8e;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.apps-embed-max-btn:hover {
  background: linear-gradient(180deg, #ffffff 0%, #cfe5ff 100%);
}

.apps-embed-controls {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.apps-embed-controls .xp-popup-close {
  margin-left: 0;
}

.apps-embed-popup .xp-popup-content {
  padding: 0;
  overflow: hidden;
  max-height: none;
  height: 100%;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.apps-embed-frame {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.apps-panel-list {
  display: block;
}

#apps-panel .apps-panel-list .apps-section {
  margin-bottom: 10px;
}

#apps-panel .apps-panel-list .apps-section:last-child {
  margin-bottom: 0;
}

@media (max-width: 900px) {
  .apps-popup {
    width: min(88vw, 520px);
    height: min(70dvh, 560px);
    min-width: 0;
    max-width: 88vw;
  }

  .apps-popup .xp-popup-content {
    max-height: none;
  }

  .apps-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .apps-tile {
    min-height: 84px;
  }

  .apps-tile-icon {
    width: 30px;
    height: 30px;
  }

  .apps-embed-frame {
    height: 100%;
  }
}
