/*
  Stage 105.3B CLEAN — Menu / Dropdown / Sidebar Contrast Recovery
  Scope: navigation shell only.
  Purpose: recover washed-out Tools/Reports/Setup flyout menus and protect
  page/sidebar layering without changing page content, tables, buttons, routes,
  popups, API calls, app.js, or backend logic.
*/

:root {
  --ui1053b-menu-bg: #ffffff;
  --ui1053b-menu-text: #152238;
  --ui1053b-menu-muted: #475569;
  --ui1053b-menu-border: rgba(148, 163, 184, 0.34);
  --ui1053b-menu-hover-bg: rgba(20, 184, 166, 0.12);
  --ui1053b-menu-hover-text: #0f766e;
  --ui1053b-menu-active-bg: rgba(37, 99, 235, 0.12);
  --ui1053b-menu-active-text: #1d4ed8;
  --ui1053b-shadow: 0 24px 64px rgba(15, 23, 42, 0.26);
}

/* Keep the left shell above page content, while flyouts remain above the shell. */
#app-screen .topbar,
.topbar {
  z-index: 2000 !important;
  isolation: isolate;
}

#app-screen #top-menu,
#top-menu,
.top-menu {
  position: relative !important;
  z-index: 2010 !important;
  color: #e5f0ff !important;
}

/* Strictly scoped flyout/dropdown recovery. This avoids broad button/table rules. */
#top-menu .stage831-dropdown,
.top-menu .stage831-dropdown {
  background: var(--ui1053b-menu-bg) !important;
  color: var(--ui1053b-menu-text) !important;
  border: 1px solid var(--ui1053b-menu-border) !important;
  box-shadow: var(--ui1053b-shadow) !important;
  opacity: 1 !important;
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  mix-blend-mode: normal !important;
  z-index: 2300 !important;
}

#top-menu .stage831-dropdown *,
.top-menu .stage831-dropdown * {
  opacity: 1 !important;
  filter: none !important;
  mix-blend-mode: normal !important;
}

#top-menu .stage831-sub-link,
.top-menu .stage831-sub-link,
#top-menu .stage831-dropdown a,
.top-menu .stage831-dropdown a,
#top-menu .stage831-dropdown button,
.top-menu .stage831-dropdown button {
  color: var(--ui1053b-menu-text) !important;
  background: transparent !important;
  text-shadow: none !important;
  opacity: 1 !important;
}

#top-menu .stage831-sub-link:hover,
#top-menu .stage831-sub-link:focus,
.top-menu .stage831-sub-link:hover,
.top-menu .stage831-sub-link:focus,
#top-menu .stage831-dropdown a:hover,
#top-menu .stage831-dropdown a:focus,
.top-menu .stage831-dropdown a:hover,
.top-menu .stage831-dropdown a:focus {
  color: var(--ui1053b-menu-hover-text) !important;
  background: var(--ui1053b-menu-hover-bg) !important;
  border-color: rgba(20, 184, 166, 0.34) !important;
  outline: none !important;
}

#top-menu .stage831-sub-link.active,
.top-menu .stage831-sub-link.active,
#top-menu .stage831-dropdown a.active,
.top-menu .stage831-dropdown a.active {
  color: var(--ui1053b-menu-active-text) !important;
  background: var(--ui1053b-menu-active-bg) !important;
  border-color: rgba(37, 99, 235, 0.32) !important;
}

#top-menu .stage831-menu-separator,
.top-menu .stage831-menu-separator {
  background: rgba(148, 163, 184, 0.28) !important;
}

/* Keep main content and status footer out from under the fixed sidebar on desktop. */
@media (min-width: 760px) {
  #app-screen .page,
  .page {
    margin-left: var(--sidebar-width, 141px) !important;
    position: relative;
    z-index: 1;
  }

  #app-screen .submenu-bar,
  .submenu-bar {
    margin-left: var(--sidebar-width, 141px) !important;
    position: sticky;
    z-index: 1200 !important;
  }

  #app-screen .footer,
  .footer {
    left: var(--sidebar-width, 141px) !important;
    z-index: 1900 !important;
  }
}

/* Narrow windows: keep dropdowns readable and within the viewport. */
@media (max-width: 900px) {
  #top-menu .stage831-dropdown,
  .top-menu .stage831-dropdown {
    width: min(320px, calc(100vw - 32px)) !important;
    max-height: 70vh !important;
  }
}
