/* Final phone and tablet interaction layer. Loaded after module and icon styles. */
#app :is(button, a[href], input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid #2563eb !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, .18) !important;
}

@media (prefers-reduced-motion: reduce) {
  #app *,
  #app *::before,
  #app *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 768px) {
  html,
  body,
  #app,
  .layout {
    overscroll-behavior-y: none !important;
  }

  .main {
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: auto !important;
    touch-action: pan-y !important;
    scrollbar-gutter: stable;
    scroll-padding-top: calc(64px + env(safe-area-inset-top, 0px));
    scroll-padding-bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  }

  .page,
  .page.active {
    height: auto !important;
    min-height: min-content !important;
    overflow-y: visible !important;
    touch-action: pan-y !important;
  }

  .auris-mobile-table-scroll,
  #page-esg .card:has(> table.auris-esg-s-0ae64748d8) {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-x: contain !important;
    touch-action: pan-x pan-y !important;
  }

  .auris-mobile-table-scroll > table {
    margin-bottom: 0 !important;
  }

  /* The drawer remains mounted so its closing transform can animate. */
  #mobile-modules-drawer {
    display: block !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity .22s ease, visibility 0s linear .3s !important;
  }

  #mobile-modules-drawer.open {
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    transition-delay: 0s !important;
  }

  #mobile-modules-panel {
    visibility: hidden !important;
    transform: translate3d(0, 105%, 0) !important;
    transition: transform .3s cubic-bezier(.4, 0, .2, 1), visibility 0s linear .3s !important;
    will-change: transform;
  }

  #mobile-modules-drawer.open #mobile-modules-panel,
  #mobile-modules-panel.open {
    visibility: visible !important;
    transform: translate3d(0, 0, 0) !important;
    transition-delay: 0s !important;
  }

  #mobile-modules-grid {
    align-items: stretch !important;
  }

  .mob-module-btn {
    min-width: 0 !important;
    min-height: 82px !important;
    padding: 10px 5px !important;
  }

  .mob-module-icon-shell {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mob-module-label {
    max-width: 100%;
    color: var(--text);
    font-size: 10px;
    font-weight: 650;
    line-height: 1.2;
    text-align: center;
    overflow-wrap: anywhere;
  }

  .mob-search-result > i.auris-module-icon {
    margin-inline: 4px;
  }

  .mobile-logo {
    font-size: 14px !important;
    line-height: 1.2 !important;
  }

  #app .page .page-title,
  #app #page-kpi .kpi-x-title,
  #app .page :is(.se-title, .noise-title, .bbs-title, .hse-cc-title),
  #app .page :is(.rax-hero, .legx-hero, .swx-hero, .ccu-hero, .cmu-hero, .teu-hero, .lcu-hero, .sov-hero, .dcx-module-head) h1,
  #app .page [class*="-hero"] h1,
  #app .page [class*="-module-head"] h1 {
    font-size: 21px !important;
    line-height: 1.14 !important;
    letter-spacing: -.02em !important;
  }

  .page-header > div:first-child > div:not(.page-title),
  .page [class*="-hero"] p,
  .page [class*="-module-head"] p {
    font-size: 11.5px !important;
    line-height: 1.42 !important;
  }

  #app .page :is(.tab-btn, [role="tab"], .mtg-tab, [class*="-tabs"] > button, .rax-nav > button, .se-tab, .noise-tab, .kpi-tab) {
    font-size: 10.5px !important;
  }

  #app .page :is(.tab-btn.active, [role="tab"].active, [role="tab"][aria-selected="true"], .mtg-tab.active, [class*="-tabs"] > button.active, .rax-nav > button.active, .se-tab.active, .noise-tab.active, .kpi-tab.active) {
    font-size: 11.5px !important;
  }

  .page :is(.card-title, [class*="-panel-title"], [class*="-card-title"], [class*="-section-title"]),
  .page [class*="-panel"] h3 {
    font-size: 13px !important;
  }

  #app .page :is(button, .btn) {
    font-size: 11.5px !important;
  }

  #app .page :is(
    button,
    .btn,
    input:not([type="checkbox"]):not([type="radio"]),
    select
  ) {
    min-height: 42px !important;
    touch-action: manipulation !important;
  }

  #app .page input:not([type="checkbox"]):not([type="radio"]),
  #app .page select,
  #app .page textarea {
    min-width: 0 !important;
    max-width: 100% !important;
    font-size: 16px !important;
  }

  #app .page :is(
    [class*="-filters"],
    [class*="-filter-row"],
    [class*="-toolbar"]
  ) {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  #app :is([id$="-modal"], [id$="modal"]) {
    max-width: 100vw !important;
    max-height: 100dvh !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }

  #app :is([id$="-modal"], [id$="modal"]) > :first-child {
    box-sizing: border-box !important;
    width: min(100%, calc(100vw - 20px)) !important;
    max-width: calc(100vw - 20px) !important;
    max-height: calc(100dvh - 20px) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  #app :is(
    .bbs-drawer,
    .noise-drawer,
    .se-drawer,
    .imx-drawer
  ) {
    box-sizing: border-box !important;
    width: min(100vw, 520px) !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }
}

@media (max-width: 480px) {
  #app .page :is(
    [class*="-filters"],
    [class*="-filter-row"],
    [class*="-toolbar"]
  ) {
    grid-template-columns: minmax(0, 1fr) !important;
    flex-wrap: wrap !important;
  }

  #app .page :is(
    [class*="-filters"],
    [class*="-filter-row"],
    [class*="-toolbar"]
  ) > :is(input, select, textarea, button, .btn, .form3group) {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Keep both mobile navigation surfaces independently touch-scrollable. The
   page now uses native document scrolling, so fixed navigation must own its
   own bounded scroll area instead of relying on the page underneath it. */
@media (max-width: 768px) {
  #app .sidebar,
  #app .sidebar.open {
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 0 !important;
    overflow-x: clip !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-x: none !important;
    overscroll-behavior-y: contain !important;
    touch-action: pan-y !important;
    scroll-padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)) !important;
  }

  #app .sidebar > :is(
    .sidebar-top,
    #sb-role-changer,
    .nav-section,
    .nav-item,
    .sb-footer,
    #pwa-install-btn
  ) {
    flex-shrink: 0 !important;
  }

  #mobile-modules-panel {
    display: flex !important;
    flex-direction: column !important;
    height: min(78dvh, 640px) !important;
    max-height: calc(100dvh - 72px) !important;
    min-height: 0 !important;
    overflow: hidden !important;
    touch-action: pan-y !important;
  }

  #mobile-modules-panel > :first-child {
    flex: 0 0 auto !important;
  }

  #mobile-modules-grid {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-x: clip !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior-y: contain !important;
    touch-action: pan-y !important;
    scroll-padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important;
  }

  #mobile-modules-grid .mob-module-btn {
    touch-action: pan-y !important;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  #mobile-modules-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}

/* Phones use native document scrolling. Fixed nested scrollers can stop receiving
   touch movement after a route change or PWA resume on iOS and Android. */
@media (max-width: 480px) {
  html,
  body {
    height: auto !important;
    min-height: 100% !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
  }

  #app {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    overflow: visible !important;
  }

  #app .layout {
    height: auto !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    overflow: visible !important;
  }

  #app .main {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: calc(100dvh - 110px) !important;
    max-height: none !important;
    overflow-x: clip !important;
    overflow-y: visible !important;
    touch-action: pan-y !important;
    transform: none !important;
    padding-top: calc(52px + env(safe-area-inset-top, 0px)) !important;
    padding-bottom: calc(74px + env(safe-area-inset-bottom, 0px)) !important;
  }

  #app .page,
  #app .page.active {
    height: auto !important;
    min-height: 0 !important;
    overflow-y: visible !important;
  }
}
