/* Phone layout for public pages (max-width 767px). Desktop is unchanged.
   One compact header row: logo, login button, menu button. Navigation opens as a drawer.
   Every tap target is at least 44px. Tables become stacked cards that are easy to read.
   Each rule is written for both the home header and the public-subnav header bar, so it wins on every page. */

@media (max-width: 767px) {
  /* Header: one row, fixed height instead of the 116-130px two-row bar. */
  html body .site-header,
  html body .public-header,
  html body > header.top,
  html[data-ar-public-nav="active"]:not(:has(.hero-wrap,.login-page,.app-shell)) [data-ar-public-nav-bar="true"] {
    min-height: 56px !important;
    height: auto !important;
    padding: 8px 14px !important;
    box-sizing: border-box !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
  }

  /* Navigation becomes a drawer under the header. */
  html body .site-header nav,
  html body .public-header nav,
  html body > header.top nav,
  html[data-ar-public-nav="active"]:not(:has(.hero-wrap,.login-page,.app-shell)) [data-ar-public-nav-bar="true"] nav {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    display: none !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0 !important;
    width: auto !important;
    margin: 0 !important;
    padding: 6px 10px 14px !important;
    max-height: calc(100vh - 56px) !important;
    overflow-y: auto !important;
    background: #fff !important;
    border-bottom: 1px solid #e6e9ef !important;
    box-shadow: 0 18px 36px -18px rgba(24, 39, 68, 0.28) !important;
    z-index: 200 !important;
    white-space: normal !important;
  }
  html body .site-header[data-m-open='true'] nav { display: flex !important; }
  html body .public-header[data-m-open='true'] nav { display: flex !important; }
  html body > header.top[data-m-open='true'] nav { display: flex !important; }
  html[data-ar-public-nav="active"]:not(:has(.hero-wrap,.login-page,.app-shell)) [data-ar-public-nav-bar="true"][data-m-open='true'] nav { display: flex !important; }

  html body .site-header nav > a,
  html body .public-header nav > a,
  html body > header.top nav > a,
  html[data-ar-public-nav="active"]:not(:has(.hero-wrap,.login-page,.app-shell)) [data-ar-public-nav-bar="true"] nav > a {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: left !important;
    min-height: 48px !important;
    padding: 0 12px !important;
    border-radius: 10px !important;
    font-size: 16px !important;
    line-height: 1.3 !important;
    text-decoration: none !important;
  }
  html body .site-header nav > a:active { background: #f0f2f7 !important; }
  html body .public-header nav > a:active { background: #f0f2f7 !important; }
  html body > header.top nav > a:active { background: #f0f2f7 !important; }
  html[data-ar-public-nav="active"]:not(:has(.hero-wrap,.login-page,.app-shell)) [data-ar-public-nav-bar="true"] nav > a:active { background: #f0f2f7 !important; }

  /* Header actions: login button and menu button, grouped at the right. */
  html body .site-header .m-actions,
  html body .public-header .m-actions,
  html body > header.top .m-actions,
  html[data-ar-public-nav="active"]:not(:has(.hero-wrap,.login-page,.app-shell)) [data-ar-public-nav-bar="true"] .m-actions {
    display: flex !important;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex: 0 0 auto;
  }
  html body .m-cta, html[data-ar-public-nav="active"]:not(:has(.hero-wrap,.login-page,.app-shell)) .m-cta {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    background: #3e5bf2;
    color: #fff !important;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
  }
  html body .m-toggle, html[data-ar-public-nav="active"]:not(:has(.hero-wrap,.login-page,.app-shell)) .m-toggle {
    width: 44px;
    height: 44px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
    border: 1px solid #e6e9ef;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
  }
  html body .m-toggle span, html[data-ar-public-nav="active"]:not(:has(.hero-wrap,.login-page,.app-shell)) .m-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: #1f2329;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  html body [data-m-open='true'] .m-toggle span:nth-child(1), html[data-ar-public-nav="active"]:not(:has(.hero-wrap,.login-page,.app-shell)) [data-m-open='true'] .m-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  html body [data-m-open='true'] .m-toggle span:nth-child(2), html[data-ar-public-nav="active"]:not(:has(.hero-wrap,.login-page,.app-shell)) [data-m-open='true'] .m-toggle span:nth-child(2) { opacity: 0; }
  html body [data-m-open='true'] .m-toggle span:nth-child(3), html[data-ar-public-nav="active"]:not(:has(.hero-wrap,.login-page,.app-shell)) [data-m-open='true'] .m-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  /* The pages' own menu buttons were hidden on phones; the drawer above replaces them. */
  html body .public-menu-button, html[data-ar-public-nav="active"]:not(:has(.hero-wrap,.login-page,.app-shell)) .public-menu-button {
    display: none !important;
  }

  /* The header already shows the login button, so the drawer's duplicate is hidden. */
  html body .m-login-dupe.m-login-dupe, html body nav a.m-login-dupe.m-login-dupe, html[data-ar-public-nav="active"]:not(:has(.hero-wrap,.login-page,.app-shell)) [data-ar-public-nav-bar="true"] nav a.m-login-dupe {
    display: none !important;
  }

  /* Footer links: 40px+ tap height. */
  html body footer a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
  }

  /* Home: the first screen starts right under the compact header instead of a 100vh blank band. */
  html body .hero-wrap {
    min-height: auto !important;
    padding-top: 122px !important;
    padding-bottom: 24px !important;
  }

  /* Home: the SLA card is a bottom bar on phones, so it never covers the headline. It only shows at the top of the page. */
  html body #home-sla-float {
    position: fixed !important;
    top: auto !important;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
    left: 14px !important;
    right: 14px !important;
    width: auto !important;
    z-index: 120 !important;
  }

  /* Tables: each row becomes a labelled card. The models page keeps its own card layout. */
  html body .dx-table:not(.mp-table) > table {
    display: block;
    width: 100%;
    min-width: 0 !important;
    border: 0;
  }
  html body .dx-table:not(.mp-table) > table > thead {
    display: none;
  }
  html body .dx-table:not(.mp-table) > table > tbody,
  html body .dx-table:not(.mp-table) > table > tbody > tr {
    display: block;
  }
  html body .dx-table:not(.mp-table) > table > tbody > tr {
    padding: 10px 14px;
    border-top: 1px solid #e6e9ef;
  }
  html body .dx-table:not(.mp-table) > table > tbody > tr:first-child {
    border-top: 0;
  }
  html body .dx-table:not(.mp-table) td {
    display: block !important;
    padding: 4px 0 !important;
    border: 0 !important;
    white-space: normal !important;
    word-break: break-word;
  }
  html body .dx-table:not(.mp-table) td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: 12px;
    line-height: 1.5;
    color: #6b7385;
  }
}

@media (min-width: 768px) {
  html body .m-actions, html[data-ar-public-nav="active"]:not(:has(.hero-wrap,.login-page,.app-shell)) .m-actions {
    display: none !important;
  }
}
