/*
 * HT ERP owner mobile header, single row. Keep all original desktop controls
 * and shift only secondary mobile actions into the Bootstrap More dropdown.
 */
@media (max-width: 767.98px) {
  :root { --ht-topbar-height: 60px; }

  html .app-topbar {
    display: flex !important;
    grid-template-columns: none !important;
    grid-template-rows: none !important;
    height: var(--ht-topbar-height);
    min-height: var(--ht-topbar-height);
    flex-wrap: nowrap !important;
    align-content: center;
    align-items: center;
    justify-content: space-between;
    gap: 3px;
    padding: 0 8px !important;
  }

  html .app-topbar .topbar-start,
  html .app-topbar .topbar-end {
    display: flex !important;
    align-items: center;
    flex-wrap: nowrap !important;
    justify-content: flex-start;
    flex: 0 0 auto;
    width: auto !important;
    min-width: 0;
    max-width: 100%;
    gap: 3px !important;
    margin: 0 !important;
  }

  html .app-topbar .topbar-start {
    flex: 0 1 auto;
    overflow: visible;
  }

  html .app-topbar .topbar-end > .topbar-logout-form,
  html .app-topbar .topbar-end > .ui-locale-switcher,
  html .app-topbar .topbar-end > .module-guidance-actions,
  html .app-topbar .topbar-end > .dropdown:not(.ht-org-context-switcher):not(.ht-mobile-tools),
  html .app-topbar .topbar-end > button.btn.btn-outline-primary {
    display: none !important;
  }

  html .app-topbar .icon-button,
  html .app-topbar .ht-mobile-tools-button {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    display: inline-grid;
    place-items: center;
    border-radius: 11px;
  }

  html .app-topbar .topbar-mobile-brand {
    display: block !important;
    flex: 0 1 auto !important;
    width: auto;
    max-width: clamp(22px, 18vw, 95px);
    font-size: .72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  html .app-topbar .ht-mobile-tools {
    display: block !important;
    flex: 0 0 auto;
  }

  html .app-topbar .ht-mobile-tools-panel {
    width: min(284px, calc(100vw - 20px)) !important;
    min-width: 0 !important;
    max-height: min(72vh, 540px);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1066;
    padding: 8px !important;
    line-height: 1.7;
    border-radius: 14px;
    text-align: start;
  }

  html .app-topbar .ht-mobile-tools-panel .dropdown-item {
    min-height: 42px;
    width: 100%;
    white-space: normal;
    border-radius: 8px;
    text-align: start;
  }

  html .app-topbar .ht-mobile-tools-panel form {
    margin: 0;
  }

  html .app-topbar .ht-mobile-tools-panel .dropdown-header {
    white-space: normal;
    font-weight: 650;
  }

  html .app-topbar .notification-dropdown {
    width: min(360px, calc(100vw - 20px)) !important;
    max-width: calc(100vw - 20px);
  }

  /* Content starts below the genuinely shorter header, not the old 112px grid. */
  html .app-main { padding-top: var(--ht-topbar-height); }
}

@media (max-width: 360px) {
  html .app-topbar { gap: 2px; padding-inline: 5px !important; }
  html .app-topbar .topbar-start,
  html .app-topbar .topbar-end { gap: 2px !important; }
  html .app-topbar .topbar-mobile-brand { max-width: 48px; font-size: .68rem; }
  html .app-topbar .icon-button,
  html .app-topbar .ht-mobile-tools-button {
    width: 38px !important;
    height: 40px !important;
    min-width: 38px !important;
  }
}

/* Canonical corporate mark; rightmost menu, then brand in the RTL flex row. */
.ht-org-brand-mark {
  padding: 0 !important;
  background: none !important;
  border: 0 !important;
  box-shadow: none !important;
}
.ht-org-brand-mark::after { display: none !important; }
.ht-org-brand-mark img {
  display: block;
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 13px;
}
.ht-org-login-mark {
  padding: 0 !important;
  background: none !important;
  border: 0 !important;
  box-shadow: none !important;
}
.ht-org-login-mark img {
  display: block;
  width: 68px;
  height: 68px;
  border-radius: 19px;
  object-fit: contain;
}
@media (max-width: 767.98px) {
  html .app-topbar .topbar-start .topbar-mobile-brand {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px !important;
    width: 40px !important;
    min-width: 40px;
    max-width: 40px !important;
    height: 40px;
    overflow: visible;
    text-decoration: none;
  }
  html .app-topbar .topbar-start .topbar-mobile-brand img {
    display: block;
    width: 38px;
    height: 38px;
    object-fit: contain;
    border-radius: 11px;
  }
  html .app-topbar .topbar-start > [data-theme-toggle],
  html .app-topbar .topbar-start > .ht-header-mobile-help {
    display: inline-grid !important;
    place-items: center;
    flex: 0 0 40px;
    text-decoration: none;
  }
  html .app-topbar .ht-mobile-quick-command {
    display: none;
  }
}
@media (max-width: 390px) {
  /* Prioritize the requested visible help and theme actions over quick command. */
  html .app-topbar .topbar-start > button[data-command-open] {
    display: none !important;
  }
  html .app-topbar .ht-mobile-quick-command {
    display: block;
  }
  html .app-topbar .topbar-start .topbar-mobile-brand {
    flex: 0 0 36px !important;
    width: 36px !important;
    min-width: 36px;
    max-width: 36px !important;
  }
  html .app-topbar .topbar-start .topbar-mobile-brand img {
    width: 35px;
    height: 35px;
  }
  html .app-topbar .topbar-start > [data-theme-toggle],
  html .app-topbar .topbar-start > .ht-header-mobile-help {
    flex: 0 0 36px;
  }
}
@media (max-width: 360px) {
  html .app-topbar .topbar-start .topbar-mobile-brand {
    flex: 0 0 36px !important;
    width: 36px !important;
    min-width: 36px;
  }
}

/* ERP73 final mobile organization: menu and the same-size corporate mark
   remain together at inline-start; action buttons consume the far inline-end. */
@media (max-width: 767.98px) {
  html .app-topbar .topbar-start {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0;
    justify-content: flex-start !important;
  }
  html .app-topbar .topbar-end {
    flex: 0 0 auto !important;
    width: auto !important;
    justify-content: flex-end !important;
  }
  html .app-topbar .topbar-start > .topbar-mobile-brand {
    flex: 0 0 40px !important;
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    height: 40px !important;
    margin-inline-start: 0 !important;
    margin-inline-end: auto !important;
  }
  html .app-topbar .topbar-start > .topbar-mobile-brand img {
    width: 40px !important;
    height: 40px !important;
    border-radius: 11px;
  }
}
@media (max-width: 390px) and (min-width: 361px) {
  html .app-topbar .topbar-start > .topbar-mobile-brand {
    flex-basis: 40px !important;
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
  }
  html .app-topbar .topbar-start > .topbar-mobile-brand img {
    width: 40px !important;
    height: 40px !important;
  }
}
@media (max-width: 360px) {
  html .app-topbar .topbar-start > .topbar-mobile-brand {
    flex: 0 0 38px !important;
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
  }
  html .app-topbar .topbar-start > .topbar-mobile-brand img {
    width: 38px !important;
    height: 38px !important;
  }
}
