.topbar.portal-header {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  align-items: end;
  gap: 16px;
  height: auto;
  min-height: 110px;
  padding: 8px 24px 12px;
  background: #fff;
  border-bottom: 1px solid #d8e4f3;
}

.portal-header .portal-header-brand {
  display: grid;
  grid-template-columns: minmax(0, 270fr) 1px minmax(0, 144fr);
  align-items: end;
  gap: 12px;
  width: 439px;
  max-width: 100%;
  min-height: 110px;
  min-width: 0;
  color: #17283e;
  text-decoration: none;
}

.portal-header-wordmark {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 270 / 58;
  margin-bottom: 5px;
  object-fit: contain;
}

.portal-header-divider {
  display: block;
  width: 1px;
  height: 34px;
  margin-bottom: 7px;
  background: #c6d8ef;
}

.portal-header-robot {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 760 / 517;
  object-fit: contain;
}

.portal-header-art {
  position: relative;
  display: grid;
  grid-template-columns: 88fr 104fr 95fr 137fr 101fr 99fr 82fr;
  grid-template-rows: minmax(0, 1fr);
  align-items: end;
  column-gap: 4px;
  align-self: end;
  min-width: 0;
  height: 90px;
  pointer-events: none;
}

.portal-header-art::after {
  position: absolute;
  inset: auto 0 0;
  border-bottom: 1px solid #dbe8fa;
  content: "";
}

.portal-header-art svg {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  overflow: visible;
  fill: none;
  stroke: #a6c5f2;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.portal-header-art .portal-art-villa { height: 64%; }
.portal-header-art .portal-art-stepped { height: 76%; }
.portal-header-art .portal-art-contract { height: 69%; }
.portal-header-art .portal-art-notary { height: 74%; }
.portal-header-art .portal-art-apartment { height: 72%; }
.portal-header-art .portal-art-keys { height: 60%; }

body.portal-ui .topbar.portal-header .portal-sections {
  align-self: end;
  align-items: end;
  flex-wrap: nowrap;
  gap: 8px;
  width: auto;
}

body.portal-ui .portal-header .portal-sections .portal-button {
  white-space: nowrap;
}

/* Decorative Lucide icons inherit both active and inactive button colors. */
.portal-header .portal-sections .portal-button::before {
  display: block;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: var(--portal-nav-icon) center / contain no-repeat;
  mask: var(--portal-nav-icon) center / contain no-repeat;
  content: "";
}

.portal-header .portal-sections a[href="/cases/"] { --portal-nav-icon: url("/static/brand/nav-file-pen-line.svg"); }
.portal-header .portal-sections a[href="/staff/"] { --portal-nav-icon: url("/static/brand/nav-contact-round.svg"); }
.portal-header .portal-sections a[href="/tariffs/"] { --portal-nav-icon: url("/static/brand/nav-sliders-horizontal.svg"); }
.portal-header .portal-sections form[action="/logout/"] button { --portal-nav-icon: url("/static/brand/nav-door-open.svg"); }

.topbar.portal-header--standalone {
  grid-template-columns: max-content minmax(0, 1fr);
  padding-inline: max(calc((100% - 1100px) / 2), 24px);
}

@media (max-width: 1599px) {
  .topbar.portal-header {
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 12px 24px;
  }

  body.portal-ui .topbar.portal-header .portal-sections {
    grid-column: 1 / -1;
    justify-content: flex-end;
    padding-top: 10px;
    border-top: 1px solid #e8eef6;
  }
}

@media (max-width: 1000px) {
  .portal-header .portal-header-brand {
    width: 393px;
    min-height: 98px;
  }

  .portal-header-art { column-gap: 2px; }
}

@media (max-width: 650px) {
  .topbar.portal-header {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
    gap: 12px;
    padding: 10px 14px 12px;
  }

  .portal-header .portal-header-brand {
    justify-self: center;
    width: 292px;
    min-height: 80px;
    gap: 8px;
  }

  .portal-header-divider { height: 27px; }

  .portal-header-art { display: none; }

  body.portal-ui .topbar.portal-header .portal-sections {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    justify-content: stretch;
    gap: 8px;
  }

  body.portal-ui .portal-header .portal-sections .portal-button {
    min-height: 52px;
    height: 100%;
    white-space: normal;
    overflow-wrap: normal;
    padding: 5px 8px;
  }

  body.portal-ui .portal-header .portal-sections form { min-width: 0; }
  body.portal-ui .portal-header .portal-sections form .portal-button { width: 100%; }
}

@media (forced-colors: active) {
  .portal-header .portal-sections .portal-button::before { background: ButtonText; }
}
