:root {
  --ux-header-height: 88px;
  --ux-header-sidebar-width: var(--ux-sidebar-width, 280px);
  --ux-header-gap: 24px;
}

.upyx-v4-header[data-ux-header] {
  position: sticky;
  top: 0;
  z-index: 1200;
  width: 100%;
  min-width: 0;
  height: var(--ux-header-height);
  min-height: var(--ux-header-height);
  color: #fff;
  background:
    radial-gradient(circle at 10% 20%, rgba(32, 183, 255, .42) 0, rgba(32, 183, 255, 0) 30%),
    linear-gradient(135deg, #1cbcff 0%, #0864f7 36%, #004bd9 100%);
  border-bottom: 1px solid rgba(255, 255, 255, .22);
  box-shadow: 0 10px 28px rgba(2, 35, 102, .2);
}

.upyx-v4-header-inner[data-ux-header] {
  display: grid;
  grid-template-columns: var(--ux-header-sidebar-width) minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--ux-header-gap);
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 28px 0 0;
}

.upyx-v4-brand[data-ux-header] {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--ux-header-sidebar-width);
  min-width: 0;
  height: 100%;
  margin: 0;
  padding: 8px 16px;
  overflow: hidden;
  background: #fff;
  border: 0;
  border-right: 1px solid rgba(15, 23, 42, .12);
  border-bottom: 1px solid rgba(15, 23, 42, .12);
  border-radius: 0;
  box-shadow: none;
}

.upyx-v4-brand-logo[data-ux-header] {
  display: block;
  width: min(220px, calc(var(--ux-header-sidebar-width) - 32px));
  max-width: 100%;
  max-height: calc(var(--ux-header-height) - 16px);
  object-fit: contain;
  object-position: center;
}

.upyx-v4-project-switcher[data-ux-header] {
  position: static;
  display: flex;
  align-items: center;
  gap: 14px;
  justify-self: stretch;
  width: 100%;
  min-width: 0;
  max-width: 620px;
  min-height: 64px;
  margin: 0;
  padding: 10px 16px;
  color: #fff;
  background: rgba(0, 72, 220, .2);
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(0, 54, 170, .14);
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease;
}

.upyx-v4-project-switcher[data-ux-header]:hover {
  background: rgba(255, 255, 255, .1);
  border-color: #fff;
}

.upyx-v4-project-switcher[data-ux-header] > div {
  min-width: 0;
}

.upyx-v4-project-switcher[data-ux-header] strong,
.upyx-v4-project-switcher[data-ux-header] small {
  display: block;
  overflow: hidden;
  color: #fff;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upyx-v4-project-switcher[data-ux-header] strong {
  font-size: 18px;
  line-height: 1.15;
}

.upyx-v4-project-switcher[data-ux-header] small {
  margin-top: 3px;
  color: rgba(255, 255, 255, .9);
  font-size: 13px;
}

.upyx-v4-header-actions[data-ux-header] {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 12px;
  min-width: max-content;
  margin: 0;
  padding: 0;
}

@media (max-width: 900px) {
  :root {
    --ux-header-height: 72px;
    --ux-header-sidebar-width: 188px;
    --ux-header-gap: 12px;
  }

  .upyx-v4-header-inner[data-ux-header] {
    padding-right: 14px;
  }

  .upyx-v4-brand[data-ux-header] {
    padding: 6px 12px;
  }

  .upyx-v4-brand-logo[data-ux-header] {
    width: 164px;
    max-height: 58px;
  }

  .upyx-v4-project-switcher[data-ux-header] {
    gap: 10px;
    min-height: 52px;
    padding: 8px 12px;
    border-radius: 14px;
  }

  .upyx-v4-project-switcher[data-ux-header] strong {
    font-size: 15px;
  }

  .upyx-v4-project-switcher[data-ux-header] small {
    font-size: 11px;
  }

  .upyx-v4-header-actions[data-ux-header] {
    gap: 6px;
  }

  .upyx-v4-env-badge {
    display: none !important;
  }

  .upyx-v4-notification,
  .upyx-v4-menu-button {
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
  }
}

@media (max-width: 640px) {
  :root {
    --ux-header-height: auto;
    --ux-header-sidebar-width: 132px;
  }

  .upyx-v4-header-inner[data-ux-header] {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "project project";
    gap: 8px;
    height: auto;
    padding: 8px 12px 9px;
  }

  .upyx-v4-brand[data-ux-header] {
    grid-area: brand;
    width: var(--ux-header-sidebar-width);
    height: 48px;
    padding: 4px 8px;
    border-radius: 10px;
  }

  .upyx-v4-brand-logo[data-ux-header] {
    width: 116px;
    max-height: 40px;
  }

  .upyx-v4-project-switcher[data-ux-header] {
    grid-area: project;
    max-width: none;
    min-height: 48px;
  }

  .upyx-v4-header-actions[data-ux-header] {
    grid-area: actions;
  }
}

body.auth-pending .upyx-v4-header[data-ux-header],
body.auth-login .upyx-v4-header[data-ux-header] {
  display: none;
}

@media print {
  .upyx-v4-header[data-ux-header] {
    display: none !important;
  }
}
