/* UPA — Sidebar: unified admin shell, nav, subscriber layout/profile */

/* ==============================
   Unified admin shell
   ============================== */
body.upa-page {
  overflow-x: clip;
}

body.upa-page .upa-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

body.upa-page .upa-shell.is-sidebar-collapsed {
  grid-template-columns: 64px 1fr;
}

body.upa-page .upa-shell__sidebar {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid #dbe4ef;
  padding: 1.1rem 0.8rem;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
  z-index: 10;
}

body.upa-page .upa-shell__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1rem;
  font-weight: 700;
  color: #1a2433;
  padding: 0.2rem 0.4rem 1rem;
}

body.upa-page .upa-shell__menu-toggle {
  display: grid;
  margin-left: auto;
  background: transparent;
  border: 1px solid #dbe4ef;
  border-radius: 0.5rem;
  color: #42546c;
  width: 2rem;
  height: 2rem;
  padding: 0;
  box-sizing: border-box;
  line-height: 0;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  z-index: 20;
  transition: background 0.15s, color 0.15s;
}

body.upa-page .upa-shell__menu-toggle:hover {
  background: #f1f5f9;
  color: #1e40af;
}

body.upa-page .upa-shell__menu-toggle-icon { display: none; }
body.upa-page .upa-shell__menu-toggle-icon--open { display: block; }
body.upa-page .upa-shell__menu-chevron {
  display: none;
  width: 1.05rem;
  height: 1.05rem;
}

body.upa-page .upa-shell__sidebar.is-open .upa-shell__menu-toggle-icon--open {
  display: none;
}

body.upa-page .upa-shell__sidebar.is-open .upa-shell__menu-toggle-icon--close {
  display: block;
}

body.upa-page .upa-shell__sidebar-collapsible {
  display: contents;
}

body.upa-page .upa-shell__logo {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.48rem;
  display: block;
  object-fit: contain;
}

body.upa-page .upa-shell__nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

body.upa-page .upa-shell__nav-link {
  display: flex;
  align-items: center;
  gap: 0.62rem;
  text-decoration: none;
  color: #42546c;
  font-size: 0.92rem;
  padding: 0.48rem 0.58rem;
  border-radius: 0.6rem;
  border: 1px solid transparent;
}

body.upa-page .upa-shell__nav-link.is-active {
  color: #1f6feb;
  background: #edf4ff;
  border-color: #d6e7ff;
}


body.upa-page .upa-shell__nav-link.is-disabled {
  opacity: 0.56;
  pointer-events: none;
}

body.upa-page .upa-shell__nav-icon {
  position: relative;
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
  color: inherit;
  display: grid;
  place-items: center;
}

body.upa-page .upa-shell__nav-icon svg {
  width: 1rem;
  height: 1rem;
}

body.upa-page .upa-shell__nav-badge,
body.upa-page .upa-action-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--upa-danger, #cf334d);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
}

body.upa-page .upa-shell__nav-badge {
  position: absolute;
  top: -0.2rem;
  right: -0.35rem;
}

body.upa-page .upa-shell__sidebar-footer {
  margin-top: auto;
  border: 1px solid #dbe4ef;
  border-radius: 0.7rem;
  background: #f8fbff;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--upa-text);
  text-decoration: none;
  transition: border-color 150ms ease, background-color 150ms ease;
}

body.upa-page .upa-shell__sidebar-footer:hover,
body.upa-page .upa-shell__sidebar-footer:focus-visible {
  border-color: color-mix(in srgb, var(--upa-primary) 30%, var(--upa-border));
  background: color-mix(in srgb, var(--upa-primary) 6%, var(--upa-surface));
  outline: none;
}

body.upa-page .upa-shell__avatar {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  background: #e0edff;
  color: #1f6feb;
  font-size: 0.72rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

body.upa-page .upa-shell__profile {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

body.upa-page .upa-shell__profile strong {
  font-size: 0.76rem;
  color: #1a2433;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.upa-page .upa-shell__profile span {
  color: #64748b;
  font-size: 0.72rem;
}

body.upa-page .upa-shell__sidebar.is-collapsed {
  align-items: center;
  padding-right: 0.45rem;
  padding-left: 0.45rem;
  overflow: visible;
}

body.upa-page .upa-shell__sidebar.is-collapsed .upa-shell__brand {
  justify-content: center;
  padding-right: 0;
  padding-left: 0;
  width: 100%;
}

body.upa-page .upa-shell__sidebar.is-collapsed .upa-shell__brand > span,
body.upa-page .upa-shell__sidebar.is-collapsed .upa-shell__nav-link > span:last-child,
body.upa-page .upa-shell__sidebar.is-collapsed .upa-shell__profile {
  display: none;
}

body.upa-page .upa-shell__sidebar.is-collapsed .upa-shell__menu-toggle {
  position: absolute;
  top: 1rem;
  right: -1rem;
  background: #fff;
  box-shadow: 0 8px 20px rgba(49, 79, 124, 0.12);
}

body.upa-page .upa-shell__sidebar.is-collapsed .upa-shell__sidebar-collapsible,
body.upa-page .upa-shell__sidebar.is-collapsed .upa-shell__nav,
body.upa-page .upa-shell__sidebar.is-collapsed .upa-shell__sidebar-footer {
  width: 100%;
}

body.upa-page .upa-shell__sidebar.is-collapsed .upa-shell__nav-link {
  justify-content: center;
  padding: 0.58rem 0;
}

body.upa-page .upa-shell__sidebar.is-collapsed .upa-shell__sidebar-footer {
  justify-content: center;
  padding: 0.55rem 0;
}

@media (min-width: 961px) {
  body.upa-page .upa-shell__menu-toggle-icon {
    display: none;
  }

  body.upa-page .upa-shell__menu-chevron--collapse {
    display: block;
  }

  body.upa-page .upa-shell__sidebar.is-collapsed .upa-shell__menu-chevron--collapse {
    display: none;
  }

  body.upa-page .upa-shell__sidebar.is-collapsed .upa-shell__menu-chevron--expand {
    display: block;
  }
}

body.upa-page .upa-shell__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

body.upa-page .upa-shell__header {
  height: 76px;
  border-bottom: 1px solid #dbe4ef;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.4rem;
}

body.upa-page .upa-shell__header-main h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.1;
}

body.upa-page .upa-shell__header-main p {
  margin: 0.22rem 0 0;
  font-size: 0.78rem;
  color: #7488a3;
}

body.upa-page .upa-shell__header-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

body.upa-page .upa-shell__icon-badge {
  width: 1.9rem;
  height: 1.9rem;
  border: 1px solid #dbe4ef;
  border-radius: 999px;
  color: #64748b;
  font-weight: 700;
  display: grid;
  place-items: center;
}

body.upa-page .upa-shell__user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid #dbe4ef;
  border-radius: 999px;
  padding: 0.22rem 0.55rem 0.22rem 0.25rem;
  color: #334155;
  font-size: 0.8rem;
}

body.upa-page .upa-shell__content {
  padding: 1.2rem 1.4rem;
}

body.upa-page .upa-shell__content > .tg-container {
  width: 100%;
  max-width: none;
  margin: 0;
}

body.upa-page .upa-shell__content .tg-header {
  display: none;
}

/* ── Settings page ──────────────────────────────────────────────────────── */

body.upa-page .upa-settings {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

body.upa-page .upa-settings__form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

body.upa-page .upa-settings__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

body.upa-page .upa-settings__tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid #dbe4ef;
  width: 100%;
}

body.upa-page .upa-settings__tab {
  display: inline-flex;
  align-items: center;
  height: 2.25rem;
  padding: 0 0.65rem;
  text-decoration: none;
  color: #64748b;
  border-bottom: 2px solid transparent;
  font-size: 0.92rem;
  font-weight: 600;
}

body.upa-page .upa-settings__tab.is-active {
  color: #1f6feb;
  border-bottom-color: #1f6feb;
}

body.upa-page .upa-settings__grid {
  display: grid;
  gap: 1rem;
}

body.upa-page .upa-settings__grid--primary {
  grid-template-columns: minmax(0, 1fr);
}

body.upa-page .upa-settings__grid--secondary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.upa-page .upa-settings__grid--auto {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

body.upa-page .upa-settings__section {
  background: #fff;
  border: 1px solid #dbe4ef;
  border-radius: 0.85rem;
  padding: 1rem;
}

body.upa-page .upa-settings__section.is-danger {
  border: 0;
  padding: 1rem;
  background: #fff;
}

body.upa-page .upa-settings__section-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

body.upa-page .upa-settings__section-head p {
  margin: 0.25rem 0 0;
  color: #64748b;
  font-size: 0.86rem;
}

body.upa-page .upa-settings__section-body {
  margin-top: 0.9rem;
}

body.upa-page .upa-settings-profile {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 1rem;
}

body.upa-page .upa-settings-profile__avatar-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

body.upa-page .upa-settings-profile__avatar-image,
body.upa-page .upa-settings-profile__avatar-fallback {
  width: 96px;
  height: 96px;
  border-radius: 999px;
}

body.upa-page .upa-settings-profile__avatar-image {
  object-fit: cover;
  border: 1px solid #dbe4ef;
}

body.upa-page .upa-settings-profile__avatar-fallback {
  display: grid;
  place-items: center;
  background: #e8f0ff;
  color: #1f6feb;
  font-size: 1.7rem;
  font-weight: 700;
  border: 1px solid #dbe4ef;
}

body.upa-page .upa-settings-profile__fields {
  display: grid;
  gap: 0.8rem;
}

body.upa-page .upa-settings-preferences {
  display: grid;
  gap: 0.8rem;
}

body.upa-page .upa-connected-accounts,
body.upa-page .upa-connected-account--stacked,
body.upa-page .upa-notification-preferences {
  display: grid;
  gap: 0.8rem;
}

body.upa-page .upa-connected-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  border: 1px solid #dbe4ef;
  border-radius: 0.8rem;
  background: #f8fbff;
  padding: 0.75rem;
}

body.upa-page .upa-connected-account--compact {
  justify-content: flex-start;
}

body.upa-page .upa-connected-account--notifications {
  align-items: stretch;
  display: grid;
}

body.upa-page .upa-connected-account__summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

body.upa-page .upa-connected-account__label,
body.upa-page .upa-connected-account__value,
body.upa-page .upa-connected-account__empty {
  display: block;
}

body.upa-page .upa-connected-account__label {
  font-weight: 700;
}

body.upa-page .upa-connected-account__value {
  margin-top: 0.25rem;
  color: #24405f;
}

body.upa-page .upa-connected-account__empty {
  margin-top: 0.25rem;
  color: #64748b;
}

body.upa-page .upa-connected-account__icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.7rem;
  background: #eef4ff;
  color: #1f6feb;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

body.upa-page .upa-connected-account__icon img {
  width: 1.1rem;
  height: 1.1rem;
  filter: invert(39%) sepia(98%) saturate(1637%) hue-rotate(205deg) brightness(95%) contrast(94%);
}

body.upa-page .upa-connected-account__info {
  min-width: 0;
  flex: 1 1 auto;
}

body.upa-page .upa-connected-account__actions {
  margin-left: auto;
  flex: 0 0 auto;
}

body.upa-page .upa-notification-preferences {
  border-top: 1px solid #dbe4ef;
  padding-top: 0.75rem;
}

body.upa-page .upa-notification-preferences__hint {
  margin: 0;
  color: #64748b;
  font-size: 0.86rem;
}

body.upa-page .upa-notification-preferences__options {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

body.upa-page .upa-notification-preferences__option {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid #dbe4ef;
  border-radius: 0.7rem;
  background: #f8fbff;
  padding: 0.45rem 0.65rem;
  color: #24405f;
  font-weight: 600;
}

body.upa-page .upa-settings-sessions {
  display: grid;
  gap: 0.7rem;
}

body.upa-page .upa-settings-session {
  display: flex;
  gap: 0.7rem;
  border: 1px solid #dbe4ef;
  border-radius: 0.7rem;
  padding: 0.65rem;
  background: #f9fbff;
}

body.upa-page .upa-settings-session__icon {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.45rem;
  background: #eef4ff;
  color: #5978aa;
  display: grid;
  place-items: center;
  font-size: 0.6rem;
}

body.upa-page .upa-settings-session__meta {
  min-width: 0;
}

body.upa-page .upa-settings-session__meta p {
  margin: 0.08rem 0 0;
  color: #64748b;
  font-size: 0.82rem;
}

body.upa-page .upa-settings-session__top {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

body.upa-page .upa-settings-session__badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #dcfce7;
  color: #1d6c45;
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
}

body.upa-page .upa-settings-sessions__actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

body.upa-page .upa-settings-danger {
  display: grid;
  gap: 0.9rem;
}

body.upa-page .upa-settings-danger__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  border: 1px solid #dbe4ef;
  border-radius: 0.7rem;
  padding: 0.75rem;
}

body.upa-page .upa-settings-danger__row h3 {
  margin: 0;
  font-size: 0.92rem;
  color: color-mix(in srgb, var(--upa-danger) 85%, #1a2433 15%);
}

body.upa-page .upa-settings-danger__row p {
  margin: 0.16rem 0 0;
  color: #64748b;
  font-size: 0.82rem;
  max-width: 32ch;
}

body.upa-page .upa-settings__section.is-danger .upa-settings__section-head h2 {
  color: color-mix(in srgb, var(--upa-danger) 85%, #1a2433 15%);
}

@media (max-width: 960px) {
  body.upa-page .upa-shell {
    grid-template-columns: 1fr;
    align-content: start;
  }

  body.upa-page .upa-shell.is-sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  body.upa-page .upa-shell__sidebar {
    border-right: 0;
    border-bottom: 1px solid #dbe4ef;
    padding: 0.35rem 0.75rem;
    gap: 0;
    position: static;
    height: auto;
    overflow-y: visible;
  }

  body.upa-page .upa-shell__brand {
    justify-content: flex-start;
    padding: 0;
    font-size: 0.875rem;
    min-height: 2rem;
  }

  body.upa-page .upa-shell__logo {
    width: 1.35rem;
    height: 1.35rem;
  }

  body.upa-page .upa-shell__menu-toggle {
    display: grid;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    box-sizing: border-box;
    line-height: 0;
    place-items: center;
  }

  body.upa-page .upa-shell__menu-toggle-icon {
    width: 1rem;
    height: 1rem;
  }

  body.upa-page .upa-shell__menu-toggle-icon--open {
    display: block;
  }

  body.upa-page .upa-shell__sidebar.is-open .upa-shell__menu-toggle-icon--open {
    display: none;
  }

  body.upa-page .upa-shell__sidebar.is-open .upa-shell__menu-toggle-icon--close {
    display: block;
  }

  body.upa-page .upa-shell__sidebar .upa-shell__brand > span,
  body.upa-page .upa-shell__sidebar .upa-shell__nav-link > span:last-child,
  body.upa-page .upa-shell__sidebar .upa-shell__profile {
    display: flex;
  }

  body.upa-page .upa-shell__sidebar .upa-shell__menu-toggle {
    position: static;
    box-shadow: none;
  }

  body.upa-page .upa-shell__sidebar-collapsible {
    display: none;
    flex-direction: column;
    gap: 0.7rem;
    padding-top: 0.7rem;
  }

  body.upa-page .upa-shell__sidebar.is-open .upa-shell__sidebar-collapsible {
    display: flex;
  }

  body.upa-page .upa-shell__nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
  }

  body.upa-page .upa-shell__sidebar-footer {
    margin-top: 0;
  }

  body.upa-page .upa-shell__header {
    height: auto;
    padding: 0.4rem 0.9rem;
    min-height: 0;
  }

  body.upa-page .upa-shell__header-main p {
    display: none;
  }

  body.upa-page .upa-shell__header-main h1 {
    font-size: 1.05rem;
  }

  body.upa-page.upa-page--dashboard .upa-shell__header {
    padding: 0.8rem 0.9rem;
  }

  body.upa-page.upa-page--dashboard .upa-shell__header-main p {
    display: block;
  }

  body.upa-page.upa-page--dashboard .upa-shell__header-main h1 {
    font-size: 1.25rem;
  }

  body.upa-page .upa-shell__content {
    padding: 0.9rem;
  }

  body.upa-page .upa-settings__head {
    flex-direction: column;
    align-items: stretch;
  }

  body.upa-page .upa-settings__grid--secondary {
    grid-template-columns: minmax(0, 1fr);
  }

  body.upa-page .upa-settings__grid--auto {
    grid-template-columns: minmax(0, 1fr);
  }

  body.upa-page .upa-settings-profile {
    grid-template-columns: minmax(0, 1fr);
  }

  body.upa-page .upa-settings-profile__avatar-wrap {
    justify-content: flex-start;
  }

  body.upa-page .upa-settings-danger__row {
    flex-direction: column;
    align-items: flex-start;
  }
}
