/* Only the React-Admin shell is themed; content, dialogs and login keep their current styles. */
#root .RaLayout-appFrame > .MuiAppBar-root {
  --shell-ink: #17345d;
  --shell-accent: #1d52b2;
  color: var(--shell-ink);
  background: linear-gradient(105deg, #f8fbff 0%, #fff 52%, #f6faff 100%);
  border-bottom: 1px solid #dfe9f7;
  box-shadow: 0 2px 10px rgb(31 73 128 / 7%);
}

#root .RaLayout-appFrame > .MuiAppBar-root .RaAppBar-toolbar {
  gap: 7px;
}

#root .RaLayout-appFrame > .MuiAppBar-root #react-admin-title {
  /* The active menu already labels the section. Keep the title for assistive technology. */
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

#root .RaLayout-appFrame > .MuiAppBar-root .RaAppBar-menuButton {
  margin-inline-end: auto;
}

#root .RaLayout-appFrame > .MuiAppBar-root .RaAppBar-menuButton,
#root .RaLayout-appFrame > .MuiAppBar-root .RaUserMenu-userButton {
  color: var(--shell-accent);
  background-color: #edf4ff;
  border-radius: 10px;
}

#root .RaLayout-appFrame > .MuiAppBar-root button:not(:disabled):hover {
  color: #174ba5;
  background-color: #e4efff;
}

:is(#root, .MuiDrawer-modal) .RaSidebar-paper {
  color: #294565;
  background: linear-gradient(180deg, #f8fbff 0%, #fff 42%, #fbfdff 100%);
  border-right: 1px solid #e3edf7;
  box-sizing: border-box;
}

:is(#root, .MuiDrawer-modal) .RaSidebar-paper :is(.RaMenu-open, .RaMenu-closed) {
  padding-top: 12px;
}

:is(#root, .MuiDrawer-modal) .RaSidebar-paper .MuiList-root .MuiMenuItem-root {
  min-width: 0;
  min-height: 40px;
  position: relative;
  margin: 2px 8px;
  border-radius: 9px;
  color: #345071;
  transition: color 120ms ease, background-color 120ms ease;
}

:is(#root, .MuiDrawer-modal) .RaSidebar-paper .RaMenu-closed .MuiMenuItem-root {
  margin-inline: 4px;
}

:is(#root, .MuiDrawer-modal) .RaSidebar-paper .MuiList-root .MuiMenuItem-root .MuiListItemIcon-root {
  color: #507598;
}

:is(#root, .MuiDrawer-modal) .RaSidebar-paper .MuiList-root .MuiMenuItem-root:hover {
  color: #174ba5;
  background-color: #eef5ff;
}

:is(#root, .MuiDrawer-modal) .RaSidebar-paper .MuiList-root .MuiMenuItem-root.RaMenuItemLink-active {
  color: #184b9e;
  background-color: #e6f0ff;
  font-weight: 700;
}

:is(#root, .MuiDrawer-modal) .RaSidebar-paper .MuiList-root .MuiMenuItem-root.RaMenuItemLink-active .MuiListItemIcon-root {
  color: #2460c3;
}

:is(#root, .MuiDrawer-modal) .RaSidebar-paper .MuiList-root .MuiMenuItem-root.RaMenuItemLink-active::before {
  content: "";
  position: absolute;
  inset: 10px auto 10px 0;
  width: 3px;
  border-radius: 0 8px 8px 0;
  background-color: #3976da;
}

#root .RaLayout-appFrame > .MuiAppBar-root button:focus-visible,
:is(#root, .MuiDrawer-modal) .RaSidebar-paper .MuiList-root .MuiMenuItem-root:focus-visible {
  outline: 2px solid #2460c3;
  outline-offset: -2px;
}

/* Desktop: the original React-Admin controls remain mounted and keep their
   handlers/permissions. Only their visual position changes. */
@media (min-width: 900px) {
  body:has(#root .RaLayout-appFrame .RaSidebar-fixed) {
    margin: 0;
  }

  #root .RaLayout-appFrame:has(> .RaLayout-contentWithSidebar .RaSidebar-fixed) {
    --nav-width: 240px;
    --nav-header: 58px;
    --nav-footer: 60px;
    --nav-border: #e3edf7;
    --nav-surface: #f8fbff;
    position: relative;
    margin-top: 0;
  }

  #root .RaLayout-appFrame:has(.RaSidebar-fixed .RaMenu-closed) {
    --nav-width: 55px;
    --nav-footer: 106px;
  }

  #root .RaLayout-appFrame:has(.RaSidebar-fixed) > .MuiAppBar-root {
    position: absolute;
    inset: 0 0 auto;
    width: 100%;
    height: var(--nav-header);
    background: none;
    border: 0;
    box-shadow: none;
    pointer-events: none;
    /* The rail remains available when React-Admin hides its AppBar on scroll. */
    transform: none !important;
    visibility: visible !important;
  }

  #root .RaLayout-appFrame:has(.RaSidebar-fixed) > .MuiAppBar-root .RaAppBar-toolbar {
    position: static;
    min-height: var(--nav-header);
    padding: 0;
  }

  #root .RaLayout-appFrame:has(.RaSidebar-fixed) .RaSidebar-fixed {
    top: var(--nav-header);
    bottom: var(--nav-footer);
    height: auto;
    width: var(--nav-width);
    box-sizing: border-box;
    border-inline-end: 1px solid var(--nav-border);
    background: linear-gradient(180deg, #f8fbff 0%, #fff 42%, #fbfdff 100%);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  #root .RaLayout-appFrame:has(.RaSidebar-fixed) .RaSidebar-paper {
    height: 100dvh;
    width: var(--nav-width);
    /* Keep the content, top controls and fixed rail aligned while toggling. */
    transition: none;
  }

  #root .RaLayout-appFrame:has(.RaSidebar-fixed) .RaSidebar-appBarCollapsed {
    margin-top: 0;
  }

  #root .RaLayout-appFrame:has(.RaSidebar-fixed) > .MuiAppBar-root::before,
  #root .RaLayout-appFrame:has(.RaSidebar-fixed) > .MuiAppBar-root::after {
    content: "";
    position: fixed;
    inset-inline-start: 0;
    box-sizing: border-box;
    width: var(--nav-width);
    border-inline-end: 1px solid var(--nav-border);
    background: var(--nav-surface);
    z-index: -1;
  }

  #root .RaLayout-appFrame:has(.RaSidebar-fixed) > .MuiAppBar-root::before {
    content: "易财云管理后台";
    top: 0;
    height: var(--nav-header);
    border-bottom: 1px solid var(--nav-border);
    display: flex;
    align-items: center;
    padding-inline-start: 58px;
    color: #17345d;
    font-size: 0.875rem;
    font-weight: 650;
    white-space: nowrap;
  }

  #root .RaLayout-appFrame:has(.RaMenu-closed) > .MuiAppBar-root::before {
    content: "";
    padding: 0;
  }

  #root .RaLayout-appFrame:has(.RaSidebar-fixed) > .MuiAppBar-root::after {
    bottom: 0;
    height: var(--nav-footer);
    border-top: 1px solid var(--nav-border);
  }

  #root .RaLayout-appFrame:has(.RaSidebar-fixed) .RaAppBar-menuButton,
  #root .RaLayout-appFrame:has(.RaSidebar-fixed) .RaAppBar-toolbar > div:has(.RaLoadingIndicator-loadedIcon),
  #root .RaLayout-appFrame:has(.RaSidebar-fixed) .RaAppBar-toolbar > div:last-child:has(> button) {
    position: fixed;
    pointer-events: auto;
  }

  #root .RaLayout-appFrame:has(.RaSidebar-fixed) .RaAppBar-menuButton {
    inset: 9px auto auto 8px;
    width: 40px;
    height: 40px;
  }

  #root .RaLayout-appFrame:has(.RaSidebar-fixed) .RaAppBar-toolbar > div:has(.RaLoadingIndicator-loadedIcon) {
    inset: auto auto 10px 8px;
  }

  #root .RaLayout-appFrame:has(.RaSidebar-fixed) .RaAppBar-toolbar > div:last-child:has(> button) {
    inset: auto auto 10px 54px;
    width: calc(var(--nav-width) - 63px);
  }

  #root .RaLayout-appFrame:has(.RaSidebar-fixed) .RaAppBar-toolbar > div:last-child > button {
    margin: 0;
    max-width: 100%;
    min-height: 40px;
    justify-content: flex-start;
    white-space: nowrap;
    overflow: hidden;
  }

  #root .RaLayout-appFrame:has(.RaMenu-closed) .RaAppBar-toolbar > div:has(.RaLoadingIndicator-loadedIcon) {
    bottom: 57px;
  }

  #root .RaLayout-appFrame:has(.RaMenu-closed) .RaAppBar-toolbar > div:last-child:has(> button) {
    left: 8px;
    width: 40px;
  }

  #root .RaLayout-appFrame:has(.RaMenu-closed) .RaAppBar-toolbar > div:last-child > button {
    width: 40px;
    min-width: 40px;
    padding: 0;
    font-size: 0;
    justify-content: center;
  }

  #root .RaLayout-appFrame:has(.RaMenu-closed) .RaAppBar-toolbar > div:last-child > button .MuiButton-startIcon {
    margin: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  :is(#root, .MuiDrawer-modal) .RaSidebar-paper .MuiList-root .MuiMenuItem-root {
    transition: none;
  }
}
