.surface-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1090;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(47, 43, 61, .55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.surface-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.surface-backdrop.is-closing {
  opacity: 0;
}

.surface-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 32px);
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(47, 43, 61, .28);
  box-sizing: border-box;
  overflow: hidden;
  transform: translateY(18px) scale(.97);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
  font-family: "Public Sans", sans-serif;
}

.surface-backdrop.is-visible .surface-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Belka nagłówka jest "sztywna" (position: sticky) względem scrolla `.surface-panel__body` —
   krzyżyk i tytuł zostają zawsze widoczne na górze, niezależnie od przewinięcia treści. */
.surface-panel__header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 20px 40px;
  background: #fff;
  border-bottom: 1px solid var(--divider, rgba(47, 43, 61, .12));
}

.surface-panel__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary, rgba(47, 43, 61, .9));
}

.surface-panel__close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary, rgba(47, 43, 61, .7));
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.surface-panel__close:hover {
  background: rgba(47, 43, 61, .08);
  color: var(--text-primary, rgba(47, 43, 61, .9));
}

.surface-panel__body {
  flex: 1 1 auto;
  min-height: 24px;
  overflow-y: auto;
  padding: 28px 40px 40px;
}

.surface-panel--wide {
  max-width: 960px;
}

@media (max-width: 575.98px) {
  .surface-panel__header {
    padding: 16px 20px;
  }

  .surface-panel__body {
    padding: 20px 20px 28px;
  }
}

/* Uniwersalny preloader (sekcja 52.2 spec) — blokuje całą stronę od kliknięcia akcji
   otwierającej popup aż do załadowania jego treści, żeby uniknąć "martwego" kliku bez
   informacji zwrotnej podczas fetchy w tle. */
.app-preloader {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .6);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.app-preloader.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.app-preloader__spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid rgba(115, 103, 240, .18);
  border-top-color: var(--primary, #7367f0);
  animation: app-preloader-spin 700ms linear infinite;
}

@keyframes app-preloader-spin {
  to {
    transform: rotate(360deg);
  }
}
