:root {
  --apms-global-header-height: calc(76px + env(safe-area-inset-top));
}

body.apms-global-nav-shell {
  --topbar-height: var(--apms-global-header-height);
}

.apms-global-header {
  position: sticky;
  z-index: 55;
  top: 0;
  min-height: var(--apms-global-header-height);
  color: #ffffff;
  background: #1e232a;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.apms-global-header::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  content: "";
  background: linear-gradient(90deg, #ff5a00 0 150px, #39414b 150px 100%);
}

.apms-global-header__inner {
  display: flex;
  width: min(100%, 1240px);
  min-height: var(--apms-global-header-height);
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: env(safe-area-inset-top) max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left));
}

.apms-global-header__brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.apms-global-header__logo {
  display: block;
  width: 136px;
  max-width: 100%;
  height: auto;
  flex: 0 0 auto;
  object-fit: contain;
}

.apms-global-header__module {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding-left: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.22);
  line-height: 1.08;
}

.apms-global-header__module small {
  color: #aeb5be;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.apms-global-header__module strong {
  overflow: hidden;
  margin-top: 2px;
  font-family: Montserrat, "Arial Narrow", Arial, sans-serif;
  font-size: 17px;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.apms-global-header__actions {
  display: flex;
  min-width: 0;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.apms-global-header__identity {
  max-width: 220px;
  overflow: hidden;
  color: #cbd0d6;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.apms-global-header__button,
.apms-global-header .apms-theme-toggle {
  display: grid;
  width: 48px;
  height: 48px;
  min-height: 48px;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  border: 1px solid #444b55;
  border-radius: 5px;
  background: #252b33;
  color: #ffffff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.apms-global-header__button svg,
.apms-global-header .apms-theme-toggle svg {
  width: 22px;
  height: 22px;
  fill: none !important;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.apms-global-header__button:focus-visible,
.apms-global-header .apms-theme-toggle:focus-visible {
  outline: 3px solid rgba(255, 90, 0, 0.46);
  outline-offset: 2px;
}

.apms-global-header__button:active,
.apms-global-header .apms-theme-toggle:active { transform: scale(0.97); }

:root[data-theme="light"] .apms-global-header {
  color: #171a1f;
  background: #ffffff;
  border-bottom-color: #d9dde2;
}

:root[data-theme="light"] .apms-global-header::after {
  background: linear-gradient(90deg, #ff5a00 0 150px, #d9dde2 150px 100%);
}

:root[data-theme="light"] .apms-global-header__logo {
  content: url("/assets/brand/apms-wordmark-grey.png");
}

:root[data-theme="light"] .apms-global-header__module {
  border-left-color: #d2d7dd;
}

:root[data-theme="light"] .apms-global-header__module small,
:root[data-theme="light"] .apms-global-header__identity {
  color: #606874;
}

:root[data-theme="light"] .apms-global-header__button,
:root[data-theme="light"] .apms-global-header .apms-theme-toggle {
  border-color: #cfd5dc;
  background: #f3f5f7;
  color: #252b33;
}

body[data-apms-module="operations"] .section-nav { top: var(--apms-global-header-height); }

@media (max-width: 600px) {
  .apms-global-header__inner {
    gap: 10px;
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }
  .apms-global-header__logo { width: 118px; }
  .apms-global-header__module,
  .apms-global-header__identity { display: none; }
  .apms-global-header__actions { gap: 7px; }
}

@media (min-width: 900px) {
  .apms-global-header__inner { padding-inline: max(24px, calc((100vw - 1324px) / 2)); }
}

@media (prefers-reduced-motion: reduce) {
  .apms-global-header__button,
  .apms-global-header .apms-theme-toggle { transition: none; }
}
