/* Shared small-screen safety layer.  Desktop styles are intentionally untouched. */
@media (max-width: 1150px) {
  html, body { max-width: 100%; overflow-x: clip; }
  img, svg, video, canvas { max-width: 100%; }
  iframe { max-width: 100%; }
}

/* Never render the legacy menu until its JavaScript state explicitly opens it. */
.nav-bar-menu[hidden] { display: none !important; }

@media (max-width: 1259px) {
  /* A separate, explicit menu layer avoids conflicts with the legacy
     off-canvas positioning rules. The [hidden] state is the closed state. */
  .nav-bar-menu:not([hidden]) {
    display: block !important;
    position: fixed !important;
    top: 88px !important;
    right: 12px !important;
    left: 12px !important;
    width: auto !important;
    max-height: calc(100dvh - 100px);
    overflow-y: auto;
    background: #ffffff !important;
    border: 1px solid #dbe6f5;
    border-radius: 16px;
    box-shadow: 0 18px 42px rgba(20, 32, 57, .18);
    z-index: 10000 !important;
  }
  .nav-bar-menu #cssmenu,
  .nav-bar-menu #cssmenu ul { width: 100%; }
  .nav-bar-menu #cssmenu > ul {
    display: grid;
    gap: 4px;
    padding: 8px;
  }
  .nav-bar-menu #cssmenu > ul > li > a {
    display: flex !important;
    align-items: center;
    min-height: 48px;
    height: auto;
    padding: 13px 16px;
    border: 0;
    border-radius: 10px;
    color: #142039 !important;
    background: #f4f7fc;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
    text-align: left;
  }
  .nav-bar-menu #cssmenu > ul > li > a:hover,
  .nav-bar-menu #cssmenu > ul > li > a:focus-visible {
    color: #ffffff !important;
    background: #1769e0;
  }
  #nav-bar {
    appearance: none;
    -webkit-appearance: none;
    padding: 0;
    touch-action: manipulation;
    z-index: 10003 !important;
  }
  .jmt-public-header {
    padding-right: 64px !important;
  }
  .jmt-public-header #nav-bar {
    display: block !important;
    position: absolute !important;
    top: 50% !important;
    right: 14px !important;
    width: 40px !important;
    height: 40px !important;
    margin: 0 !important;
    transform: translateY(-50%);
    border: 1px solid #c9d9ee !important;
    border-radius: 10px !important;
    background: #f6f9ff !important;
  }
  .jmt-public-header #nav-bar::before {
    content: '';
    position: absolute;
    top: 10px;
    right: 8px;
    left: 8px;
    height: 4px;
    border-radius: 4px;
    background: #0864e8;
    box-shadow: 0 8px 0 #0864e8, 0 16px 0 #0864e8;
  }
}

@media (max-width: 767px) {
  body { min-width: 0; }
  input, select, textarea, button { max-width: 100%; }
  table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  /* Keep every mobile header control inside one compact white surface. */
  .jmt-public-header {
    width: calc(100% - 16px) !important;
    margin: 8px !important;
    padding: 0 64px 0 12px !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    z-index: 10002 !important;
  }
  .jmt-public-header__actions { min-width: 0; gap: 7px; }
  .jmt-public-header__brand span { max-width: 128px; }
  .nav-bar-menu:not([hidden]) { top: 82px !important; right: 8px !important; left: 8px !important; }
  #nav-bar { pointer-events: auto; }
  .jmt-public-header__actions.has-guest-auth .jmt-public-header__signin {
    position: static;
    z-index: auto;
  }
  .jmt-public-header__actions.has-guest-auth .jmt-public-header__divider {
    visibility: visible;
  }
}

/* Tablets and compact laptops use the same single, complete header surface as
   phones.  The menu trigger is inside that surface, so no empty strip remains
   on the right. */
@media (min-width: 601px) and (max-width: 1259px) {
  .jmt-public-header {
    width: calc(100% - 32px) !important;
    margin: 12px 16px !important;
    padding-right: 64px !important;
  }

  .jmt-public-header__actions > a.jmt-public-header__account {
    display: inline-flex !important;
    flex: 0 0 30px;
    width: 30px !important;
    height: 30px;
    margin-left: 8px !important;
    padding: 0 !important;
    box-sizing: border-box;
    justify-content: center;
  }

  .jmt-public-header__account svg {
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    padding: 6px;
    box-sizing: border-box;
  }
}

/* At phone widths the five header controls must remain readable without
   clipping the company name or competing with the menu trigger. */
@media (max-width: 390px) {
  .jmt-public-header {
    padding-right: 56px !important;
    padding-left: 8px !important;
  }

  .jmt-public-header #nav-bar {
    right: 8px !important;
    width: 38px !important;
    height: 38px !important;
  }

  .jmt-public-header__brand {
    gap: 5px;
  }

  .jmt-public-header__brand img {
    width: 42px;
    height: 37px;
  }

  .jmt-public-header__brand span {
    max-width: 102px;
    overflow: visible;
    color: #142039;
    font-size: 10px;
    letter-spacing: -.35px;
    line-height: 1.1;
    text-overflow: clip;
    white-space: normal;
  }

  .jmt-public-header__actions {
    gap: 4px;
  }

  .jmt-language-menu__toggle {
    min-width: 48px;
    padding-right: 6px;
    padding-left: 6px;
  }

  .jmt-public-header__actions.has-guest-auth .jmt-public-header__divider {
    margin-right: 4px;
    margin-left: 4px;
  }

  .jmt-public-header__actions .account-link,
  .jmt-public-header__actions > a.jmt-public-header__account {
    display: inline-flex !important;
    flex: 0 0 24px;
    width: 24px !important;
    height: 24px;
    margin-left: 4px !important;
    padding: 0 !important;
    box-sizing: border-box;
    justify-content: center;
  }

  .jmt-public-header__account svg {
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    padding: 4px;
    box-sizing: border-box;
  }
}
