/* V3 sidebar (SFC-1647). Glyphs are single-colour masks, so one asset covers
 * every state and the colour comes from the row. */

/* Cormorant Garamond stands in for the unlicensed Canela Deck. */
@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,500;0,600&family=Inter:wght@400;500&display=swap");

/* On :root, not on the rail: the mobile bar and the page wrapper are siblings of
 * the sidebar, so anything scoped to it fails to resolve there. */
:root {
  /* Palette. Prefer a role token below so a colour re-points in one place. */
  --sf-navy-900: #041538;
  --sf-navy-700: #062060;
  --sf-blue-400: #6993ff;
  --sf-blue-300: #88a6db;
  --sf-grey-600: #495057;
  --sf-grey-300: #ced4da;
  --sf-ice-050: #f2f6fc;

  /* Roles. */
  --sb-bg: var(--sf-navy-900);
  --sb-active: var(--sf-navy-700);
  --sb-icon: var(--sf-blue-300);
  --sb-icon-active: var(--sf-blue-400);
  --sb-caption: var(--sf-grey-300);
  --sb-rule: rgba(136, 166, 219, 0.5);
  --sb-scroll-thumb: rgba(136, 166, 219, 0.4);

  /* Rail geometry. */
  --sb-width: 260px;
  --sb-width-collapsed: 104px;
  --sb-row-radius: 12px;
  --sb-row-radius-active: 6px;

  /* Mobile chrome. */
  --sb-bar-height: 68px;
  --sb-bar-pad-x: 16px;
  --sb-bar-pad-y: 12px;
  --sb-gap: 16px;
  --sb-brand-size: 44px;
  --sb-action-size: 40px;
  --sb-glyph-size: 24px;
  --sb-row-height: 50px;
  --sb-drill-row-height: 54px;
  --sb-drill-indent: 50px;

  /* Weather band. */
  --sb-weather-height: 33px;
  --sb-weather-bg: var(--sf-ice-050);
  --sb-weather-fg: var(--sf-navy-700);
  --sb-weather-glyph: 20px;

  /* .main-area's padding at <=991px; the mobile bar cancels it to go full-bleed. */
  --sb-page-pad-x: 15px;
  --sb-page-pad-y: 50px;

  --sb-avatar-ring: var(--sf-grey-600);
}

.sidebar.sidebar-v3 {
  top: 0;
  left: 0;
  width: var(--sb-width);
  height: 100vh;
  max-height: 100vh;
  background: var(--sb-bg);
  box-shadow: 3px 0 24px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 0;
  overflow: hidden !important;
  overflow-y: hidden !important;
  box-sizing: border-box;
}

/* Must match the rail's width exactly, or the fixed rail overlaps the page. */
#my_wrapper {
  padding-left: var(--sb-width);
}

#my_wrapper.open {
  padding-left: var(--sb-width-collapsed);
}

.sidebar.sidebar-v3.open {
  width: var(--sb-width-collapsed);
}

/* Header / brand */
.sidebar-v3__header {
  flex-shrink: 0;
  height: 110px;
  padding: 0 30px;
  position: relative;
}

.sidebar-v3__mobile-close {
  display: none;
}

.sidebar-v3__brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  text-decoration: none;
  color: #fff;
  transition: none;
}

.sidebar-v3__brand:hover {
  color: #fff;
  opacity: 0.92;
}

/* Expanded: wordmark lockup. */
.sidebar-v3__brand-wordmark {
  display: block;
  width: 200px;
  height: 57.56px;
  object-fit: contain;
}

/* Collapsed and mobile: circular monogram from Figma, ring and lettering included. */
.sidebar-v3__brand-mark {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: none;
  border-radius: 500px;
  object-fit: contain;
}

.sidebar-v3__brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sidebar-v3__brand-line {
  display: block;
  font-family: "Cormorant Garamond", "Times New Roman", serif;
  font-weight: 500;
  font-size: 0.8125rem;
  line-height: 1.15;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff;
}

/* Only the menu scrolls. */
.sidebar.sidebar-v3 .body-sidebar.sidebar-v3__scroll,
.sidebar-v3__scroll {
  flex: 1 1 0;
  min-height: 0;
  max-height: 100%;
  padding: 0 20px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  position: relative;
  /* Gutter reserved and paid out of the right padding, so rows stay 20px from both edges. */
  scrollbar-gutter: stable;
  padding-right: 14px;
}

.sidebar-v3__scroll::-webkit-scrollbar {
  width: 6px;
}

.sidebar-v3__scroll::-webkit-scrollbar-thumb {
  background: var(--sb-scroll-thumb);
  border-radius: 3px;
}

.sidebar-v3__scroll::-webkit-scrollbar-track {
  background: transparent;
}

/* Windows and Linux draw stepper arrows on a styled scrollbar; macOS does not. */
.sidebar-v3__scroll::-webkit-scrollbar-button,
.sidebar-v3__scroll::-webkit-scrollbar-corner {
  display: none;
  width: 0;
  height: 0;
}

.sidebar-v3__list {
  padding: 0;
  margin: 0;
}

/* Section captions */
.sidebar-v3__section {
  list-style: none;
  margin: 20px 0 0;
  padding: 0 14px;
  height: 15px;
  display: flex;
  align-items: center;
}

.sidebar-v3__section:first-child {
  margin-top: 0;
}

.sidebar-v3__section-text {
  display: block;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--sb-caption);
  line-height: 1.5;
}

/* Nav rows. Selectors carry the .sidebar.sidebar-v3 prefix throughout: style.css
 * targets .side-bar-item li a more specifically than a single class, and its
 * uppercase/padding/margin would otherwise bleed through. */
.sidebar-v3__item {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar.sidebar-v3 .sidebar-v3__link {
  position: relative;
  min-height: 44px;
  gap: 8px;
  padding: 10px 8px;
  margin: 0;
  border-radius: var(--sb-row-radius);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 16px;
  font-weight: 400;
  font-style: normal;
  line-height: 1.5;
  letter-spacing: 0;
  color: #fff !important;
  text-transform: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* A row must not change shape when it gains a background. */
.sidebar.sidebar-v3 .sidebar-v3__link:hover {
  background-color: var(--sb-active);
  border-radius: var(--sb-row-radius);
  color: #fff !important;
}

/* One mask per glyph; background-color paints it. No --modifier means a filled square. */
.sidebar.sidebar-v3 .sidebar-v3__icon {
  margin: 0;
  width: 24px;
  height: 24px;
  max-height: 24px !important;
  flex-shrink: 0;
  display: block;
  background-color: var(--sb-icon);
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 24px 24px;
  mask-size: 24px 24px;
  transition: background-color 0.2s ease;
}

.sidebar-v3__icon--back {
  -webkit-mask-image: url("../icons/sidebar-v3/back.svg");
  mask-image: url("../icons/sidebar-v3/back.svg");
}
.sidebar-v3__icon--search {
  -webkit-mask-image: url("../icons/sidebar-v3/search.svg");
  mask-image: url("../icons/sidebar-v3/search.svg");
}
.sidebar-v3__icon--dashboard {
  -webkit-mask-image: url("../icons/sidebar-v3/home.svg");
  mask-image: url("../icons/sidebar-v3/home.svg");
}
.sidebar-v3__icon--clients {
  -webkit-mask-image: url("../icons/sidebar-v3/clients.svg");
  mask-image: url("../icons/sidebar-v3/clients.svg");
}
.sidebar-v3__icon--partners {
  -webkit-mask-image: url("../icons/sidebar-v3/partners.svg");
  mask-image: url("../icons/sidebar-v3/partners.svg");
}
.sidebar-v3__icon--directories {
  -webkit-mask-image: url("../icons/sidebar-v3/directories.svg");
  mask-image: url("../icons/sidebar-v3/directories.svg");
}
.sidebar-v3__icon--forum {
  -webkit-mask-image: url("../icons/sidebar-v3/forum.svg");
  mask-image: url("../icons/sidebar-v3/forum.svg");
}
.sidebar-v3__icon--toolkits {
  -webkit-mask-image: url("../icons/sidebar-v3/toolkits.svg");
  mask-image: url("../icons/sidebar-v3/toolkits.svg");
}
.sidebar-v3__icon--trainings {
  -webkit-mask-image: url("../icons/sidebar-v3/trainings.svg");
  mask-image: url("../icons/sidebar-v3/trainings.svg");
}
.sidebar-v3__icon--content {
  -webkit-mask-image: url("../icons/sidebar-v3/content.svg");
  mask-image: url("../icons/sidebar-v3/content.svg");
}
.sidebar-v3__icon--settings {
  -webkit-mask-image: url("../icons/sidebar-v3/settings.svg");
  mask-image: url("../icons/sidebar-v3/settings.svg");
}
.sidebar-v3__icon--configurations {
  -webkit-mask-image: url("../icons/sidebar-v3/user-configurations.svg");
  mask-image: url("../icons/sidebar-v3/user-configurations.svg");
}

/* Permissions can put these in the expanded list, so they need glyphs too. */
.sidebar-v3__icon--faqs {
  -webkit-mask-image: url("../icons/sidebar-v3/faqs.svg");
  mask-image: url("../icons/sidebar-v3/faqs.svg");
}
.sidebar-v3__icon--marketing {
  -webkit-mask-image: url("../icons/sidebar-v3/marketing.svg");
  mask-image: url("../icons/sidebar-v3/marketing.svg");
}

/* Rows with no design glyph, on legacy artwork. The PNGs have an alpha channel,
 * so they mask like the SVGs and follow the row's colour. */
.sidebar-v3__icon--tasks {
  -webkit-mask-image: url("../icons/tasks-icon.png");
  mask-image: url("../icons/tasks-icon.png");
}
/* 16px artwork at native size, not upscaled. Scoped to out-specify the base
 * rule's 24px mask-size. */
.sidebar.sidebar-v3 .sidebar-v3__icon--inquiries,
.sidebar.sidebar-v3 .sidebar-v3__icon--pages {
  -webkit-mask-size: 16px 16px;
  mask-size: 16px 16px;
}
.sidebar-v3__icon--inquiries {
  -webkit-mask-image: url("../icons/inquiries-icon.png");
  mask-image: url("../icons/inquiries-icon.png");
}
.sidebar-v3__icon--pages {
  -webkit-mask-image: url("../icons/pages-icon.png");
  mask-image: url("../icons/pages-icon.png");
}

/* Unrecognised rows fall back to a runtime path, so they stay <img>. */
img.sidebar-v3__icon {
  background-color: transparent;
  -webkit-mask-image: none;
  mask-image: none;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.95;
}

/* Hover, current route and open parent share one glyph colour, so they cannot
 * drift apart. <img> is excluded: with no mask, background-color would paint a
 * square behind the artwork instead of recolouring it. */
.sidebar.sidebar-v3 .sidebar-v3__link:hover .sidebar-v3__icon:not(img),
.sidebar.sidebar-v3 .sidebar-v3__item.active > .sidebar-v3__link .sidebar-v3__icon:not(img),
.sidebar.sidebar-v3 .sidebar-v3__item--dropdown.active > .sidebar-v3__link .sidebar-v3__icon:not(img),
.sidebar.sidebar-v3 .side-bar-item li a.sidebar-v3__link--parent.show .sidebar-v3__icon:not(img) {
  background-color: var(--sb-icon-active);
  opacity: 1;
}

.sidebar.sidebar-v3 .sidebar-v3__label {
  margin-left: 0;
  margin-top: 0;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Active leaf item */
.sidebar-v3__item.active > .sidebar-v3__link {
  background-color: var(--sb-active);
  border-radius: var(--sb-row-radius);
  box-shadow: none;
}

/* Only the link paints the pill. A legacy rule fills the <li> behind it with
 * square corners, which showed through where the link's radius cuts away. */
.sidebar.sidebar-v3 .side-bar-item li.active,
.sidebar.sidebar-v3 .sidebar-v3__item.active {
  background-color: transparent !important;
}

/* Parent stays lit while a child route is active. */
.sidebar-v3__item--dropdown.active > .sidebar-v3__link {
  background-color: var(--sb-active);
  border-radius: var(--sb-row-radius);
  box-shadow: none;
}

/* style.css keeps .nextarrowbox hidden until hover; here it shows at rest. */
.sidebar.sidebar-v3 .sidebar-v3__chevron {
  /* style.css absolutes this to right:24; here it sits in the flex row. */
  position: static;
  right: auto;
  opacity: 1;
  visibility: visible;
  display: block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  /* Cancels style.css's 8px/5px span margin, which knocked it 3px off centre. */
  margin: 0 0 0 auto;
  background-color: #d9e2f3;
  -webkit-mask-image: url("../icons/sidebar-v3/chevron-up.svg?v=2");
  mask-image: url("../icons/sidebar-v3/chevron-up.svg?v=2");
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 12px 6px;
  mask-size: 12px 6px;
  transform: rotate(180deg);
  transition: transform 0.2s ease;
}

/* Bootstrap 5: open dropdown — parent <li.dropdown> receives .show */
.sidebar-v3__item--dropdown.dropdown.show > .sidebar-v3__link .sidebar-v3__chevron {
  transform: rotate(0deg);
}

/* Legacy script may add .show on the toggle link */
.sidebar-v3__item--dropdown .sidebar-v3__link.show .sidebar-v3__chevron {
  transform: rotate(0deg);
}

/* Submenus */
.sidebar.sidebar-v3 .listsubmenu {
  /* !important: .position-static would re-anchor the connector to the parent li. */
  position: relative !important;
  list-style: none;
  padding: 0;
  margin: 0;
  /* Cancels style.css's #025cf51c wash on the open block. */
  background-color: transparent;
}

/* Tree rule: a vertical line between the first and last child's centres, plus an
 * 8px tick per row. Rows are 44px, so every offset derives from a 22px centre. */
.sidebar.sidebar-v3 .listsubmenu.show::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 22px;
  bottom: 22px;
  border-left: 1px solid var(--sb-rule);
  pointer-events: none;
  /* Above the row fills, so a lit child never hides the connector. */
  z-index: 1;
}

.sidebar.sidebar-v3 .listsubmenu.show > li {
  position: relative;
}

.sidebar.sidebar-v3 .listsubmenu.show > li:first-child::before,
.sidebar.sidebar-v3 .listsubmenu.show > li:last-child::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 22px;
  width: 8px;
  border-top: 1px solid var(--sb-rule);
  pointer-events: none;
  z-index: 1;
}

.sidebar.sidebar-v3 .listsubmenu:not(.show) {
  display: none;
}

.sidebar.sidebar-v3 .listsubmenu.show {
  display: block;
}

.sidebar.sidebar-v3 .listsubmenu a.dropdown-item {
  display: flex;
  align-items: center;
  white-space: nowrap;
  min-height: 44px;
  color: #fff !important;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0;
  text-transform: none;
  padding: 8px 14px 8px 40px !important;
  background: transparent;
}

.sidebar.sidebar-v3 .listsubmenu a.dropdown-item:hover {
  background: var(--sb-active) !important;
  border-radius: var(--sb-row-radius-active);
  color: #fff !important;
}

.sidebar.sidebar-v3 .side-bar-item li.active > a.dropdown-item {
  background: var(--sb-active);
  border-radius: var(--sb-row-radius-active);
  color: #fff !important;
}

/* The open branch stays filled. */
.sidebar.sidebar-v3 .side-bar-item li a.dropdown-item.show {
  background-color: var(--sb-active);
  border-radius: var(--sb-row-radius-active);
}

/* An open group parent reads as engaged; its glyph follows via the shared rule. */
.sidebar.sidebar-v3 .side-bar-item li a.sidebar-v3__link--parent.show {
  background-color: var(--sb-active);
  border-radius: var(--sb-row-radius);
}

/* Third level opens as a flyout panel. position: fixed beats both Bootstrap's
 * !important .position-static and the rail's clipping; custom.js sets top/left. */
.sidebar.sidebar-v3 .listsubmenu.third-level-menu {
  position: fixed !important;
  transition: none;
  z-index: 1200;
  width: 324px;
  /* Anything longer scrolls inside the panel. */
  max-height: min(523px, calc(100vh - 48px));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(136, 166, 219, 0.4) transparent;
  padding: 12px;
  margin: 0;
  border: 0;
  border-radius: 14px;
  background: var(--sb-bg);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

/* Beak pointing back at the trigger row. A rotated square, not a border
 * triangle, so the tip can carry a rounded corner. On <body> rather than as a
 * panel pseudo-element: the panel is a scroll container and would clip it.
 * custom.js creates it and glues it to the panel. */
.sidebar-v3__flyout-beak {
  display: none;
  position: fixed;
  width: 10px;
  height: 10px;
  /* --sb-bg cannot reach a body child. */
  background: #041538;
  border-radius: 1px;
  transform: rotate(45deg);
  z-index: 1201;
  pointer-events: none;
  animation: sidebar-v3-fade-in 0.18s ease;
}

.sidebar.sidebar-v3 .listsubmenu.third-level-menu .sidebar-v3__flyout-title {
  list-style: none;
  display: flex;
  align-items: center;
  height: 15px;
  padding: 0 0 0 14px;
  margin: 0 0 9px;
}

.sidebar.sidebar-v3 .listsubmenu.third-level-menu .sidebar-v3__flyout-title-text {
  font-family: "Inter", system-ui, sans-serif;
  font-size: 10px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--sb-caption);
}

/* Drill-down eyebrow: mobile only. */
.sidebar-v3__flyout-eyebrow {
  display: none;
}

.sidebar.sidebar-v3 .listsubmenu.third-level-menu::-webkit-scrollbar {
  width: 6px;
}

.sidebar.sidebar-v3 .listsubmenu.third-level-menu::-webkit-scrollbar-thumb {
  background: rgba(136, 166, 219, 0.4);
  border-radius: 3px;
}

.sidebar.sidebar-v3 .listsubmenu.third-level-menu::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar.sidebar-v3 .listsubmenu.third-level-menu::-webkit-scrollbar-button,
.sidebar.sidebar-v3 .listsubmenu.third-level-menu::-webkit-scrollbar-corner {
  display: none;
  width: 0;
  height: 0;
}

/* No tree rule here. Out-specifies the :first-child tick above, which would
 * otherwise hang an 8px dash off the panel's caption. */
.sidebar.sidebar-v3 .listsubmenu.third-level-menu::before,
.sidebar.sidebar-v3 .listsubmenu.third-level-menu > li::before,
.sidebar.sidebar-v3 .listsubmenu.show.third-level-menu > li:first-child::before,
.sidebar.sidebar-v3 .listsubmenu.show.third-level-menu > li:last-child::before {
  content: none;
}

.sidebar.sidebar-v3 .listsubmenu.third-level-menu a.dropdown-item {
  gap: 12px;
  padding: 8px 14px !important;
  border-radius: var(--sb-row-radius-active);
}

.sidebar.sidebar-v3 .listsubmenu.third-level-menu > li.active > a.dropdown-item {
  background: var(--sb-active);
}

/* Branch chevrons: none on the desktop second level, present in flyouts and on mobile. */
.sidebar.sidebar-v3 .listsubmenu a.dropdown-item .nextarrowbox {
  margin-left: auto;
  flex-shrink: 0;
  opacity: 1;
  visibility: visible;
  width: 6px;
  height: 12px;
}

@media (min-width: 992px) {
  .sidebar.sidebar-v3 .listsubmenu:not(.third-level-menu) a.dropdown-item .nextarrowbox {
    display: none;
  }
}

/* Mouse click drops the focus ring; keyboard focus keeps it. */
.sidebar.sidebar-v3 .sidebar-v3__link:focus,
.sidebar.sidebar-v3 .listsubmenu a.dropdown-item:focus {
  outline: none;
  box-shadow: none;
}

.sidebar.sidebar-v3 .sidebar-v3__link:focus-visible,
.sidebar.sidebar-v3 .listsubmenu a.dropdown-item:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: -2px;
}

/* Transform is left alone here — style.css forces transform: none on submenus. */
@media (min-width: 992px) {
  .sidebar.sidebar-v3 {
    transition: width 0.25s ease;
  }

  #my_wrapper {
    transition: padding-left 0.25s ease;
  }
}

@keyframes sidebar-v3-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.sidebar.sidebar-v3 .listsubmenu.show {
  animation: sidebar-v3-fade-in 0.18s ease;
}

/* Footer collapse */
.sidebar-v3__footer {
  flex-shrink: 0;
  padding: 30px 20px 0;
  border-top: none;
}

.sidebar.sidebar-v3 .sidebar-v3__footer-toggle.collaps-arrow {
  /* style.css absolutes a.collaps-arrow to the top corner; this one is a footer control. */
  position: static;
  right: auto;
  top: auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 30px;
  height: 30px;
  padding: 0 0 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 500px;
  background: rgba(242, 246, 252, 0.1);
  overflow: hidden;
  cursor: pointer;
}

.sidebar.sidebar-v3 .sidebar-v3__footer-toggle.collaps-arrow:hover {
  background: rgba(242, 246, 252, 0.18);
}

.sidebar.sidebar-v3 .sidebar-v3__footer-toggle.collaps-arrow:focus {
  outline: none;
}

.sidebar.sidebar-v3 .sidebar-v3__footer-toggle.collaps-arrow:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
}

.sidebar.sidebar-v3 .sidebar-v3__footer-toggle.collaps-arrow {
  color: #fff;
}

.sidebar-v3__footer-chevron {
  width: 5px;
  height: 10px;
  flex-shrink: 0;
}

/* Collapsed: the chevron points right to expand. */
.sidebar.sidebar-v3.open .sidebar-v3__footer-chevron {
  transform: rotate(180deg);
}

.sidebar.sidebar-v3.open .sidebar-v3__footer-toggle.collaps-arrow {
  justify-content: flex-end;
  padding: 0 12px 0 0;
}

/* ---------- Collapsed rail (104px) ---------- */
.sidebar.sidebar-v3.open .sidebar-v3__header {
  padding: 0 30px;
}

/* Desktop collapsed: keep footer chevron anchored at the bottom (same position as expanded) */
@media (min-width: 992px) {
  .sidebar.sidebar-v3.open .sidebar-v3__footer {
    display: flex;
    justify-content: center;
    padding: 30px 0 0;
  }
}

.sidebar.sidebar-v3.open .sidebar-v3__brand-text,
.sidebar.sidebar-v3.open .sidebar-v3__brand-wordmark,
.sidebar.sidebar-v3.open .sidebar-v3__section {
  display: none !important;
}

.sidebar.sidebar-v3.open .sidebar-v3__brand-mark {
  display: block;
}

.sidebar.sidebar-v3.open .sidebar-v3__brand {
  flex-direction: column;
  align-items: center;
  gap: 0;
}

.sidebar.sidebar-v3.open .sidebar-v3__scroll {
  padding: 0 14px 0 20px;
}

.sidebar.sidebar-v3.open .sidebar-v3__list {
  padding: 0;
}

/* Centre the glyph: the rail's inner width moves with the scrollbar gutter. */
.sidebar.sidebar-v3.open .sidebar-v3__link {
  justify-content: center;
  padding: 10px 0;
  border-radius: 4px;
  gap: 0;
}

.sidebar.sidebar-v3.open .sidebar-v3__item.active > .sidebar-v3__link,
.sidebar.sidebar-v3.open .sidebar-v3__item--dropdown.active > .sidebar-v3__link {
  border-radius: 4px;
}

.sidebar.sidebar-v3.open .sidebar-v3__label,
.sidebar.sidebar-v3.open .sidebar-v3__chevron {
  display: none !important;
}

/* style.css hides every span in a collapsed row; the glyphs are spans, so they opt back in. */
.sidebar.sidebar-v3.open .sidebar-v3__icon {
  display: block !important;
  margin: 0;
}

.sidebar.sidebar-v3.open .listsubmenu {
  display: none !important;
}

/* Collapsed rail: the label returns as a tooltip beside the icon. */
.sidebar.sidebar-v3.open .sidebar-v3__link {
  position: relative;
}

.sidebar.sidebar-v3.open .sidebar-v3__link::after {
  content: attr(data-label);
  /* Fixed so the clipping scroll area cannot cut it off; JS fills the offsets. */
  position: fixed;
  left: var(--sb-tip-x, 72px);
  top: var(--sb-tip-y, 50%);
  transform: translateY(-50%);
  padding: 8px;
  background: #fff;
  color: #212529;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  white-space: nowrap;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 1100;
  transition: opacity 0.15s ease;
}

.sidebar.sidebar-v3.open .sidebar-v3__link::before {
  content: "";
  position: fixed;
  left: var(--sb-tip-beak-x, 64px);
  top: var(--sb-tip-y, 50%);
  transform: translateY(-50%);
  border: 4px solid transparent;
  border-right-color: #fff;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 1101;
  transition: opacity 0.15s ease;
}

.sidebar.sidebar-v3.open .sidebar-v3__link:hover::after,
.sidebar.sidebar-v3.open .sidebar-v3__link:hover::before,
.sidebar.sidebar-v3.open .sidebar-v3__link:focus-visible::after,
.sidebar.sidebar-v3.open .sidebar-v3__link:focus-visible::before {
  opacity: 1;
  visibility: visible;
}

/* Legacy top collapse control, replaced by the footer one. */
.sidebar.sidebar-v3 > a.collaps-arrow:not(.sidebar-v3__footer-toggle) {
  display: none !important;
}

/* Legacy overrides inside v3 */
.sidebar.sidebar-v3 a.logo {
  display: none !important;
}

.sidebar.sidebar-v3 .side-bar-item li a {
  display: flex;
  align-items: center;
}

.sidebar.sidebar-v3 .side-bar-item li.active .sidebar-v3__link {
  background-color: var(--sb-active);
}

.sidebar.sidebar-v3 .side-bar-item li.active .nextarrowbox.sidebar-v3__chevron {
  opacity: 1;
  visibility: visible;
}

/* Impersonation / search rows */
.sidebar.sidebar-v3 .sidebar-v3__item .sidebar-v3__link {
  text-decoration: none;
}

@media (max-width: 991px) {
  #my_wrapper:not(.p-0),
  #my_wrapper.open:not(.p-0) {
    padding-left: 0 !important;
  }

  .sidebar.sidebar-v3 {
    width: 100vw;
    max-width: 100%;
    padding: 0 0 12px;
    gap: 0;
    left: -100%;
    transition: left ease-in-out 0.35s;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  }

  .sidebar.sidebar-v3.active {
    left: 0;
  }

  .sidebar.sidebar-v3.open {
    width: 100vw;
  }

  .sidebar.sidebar-v3.open.active {
    left: 0;
  }

  /* If .open and .active overlap, keep the drawer expanded, not icons-only. */
  .sidebar.sidebar-v3.open.active .sidebar-v3__brand-text {
    display: flex !important;
  }

  .sidebar.sidebar-v3.open.active .sidebar-v3__section {
    display: list-item !important;
  }

  .sidebar.sidebar-v3.open.active .sidebar-v3__label {
    display: block !important;
  }

  .sidebar.sidebar-v3.open.active .sidebar-v3__chevron {
    display: flex !important;
  }

  .sidebar.sidebar-v3.open.active .sidebar-v3__link {
    justify-content: flex-start !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  .sidebar.sidebar-v3.open.active .sidebar-v3__icon {
    margin: 0 !important;
  }

  .sidebar.sidebar-v3.open.active .sidebar-v3__list {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .sidebar.sidebar-v3.open.active .listsubmenu {
    display: block !important;
  }

  /* Phone rows: 50px / 16px gap / Inter 500, against desktop's 44 / 8 / 400.
   * Matches the desktop rule's specificity, which also qualifies .body-sidebar. */
  .sidebar.sidebar-v3 .body-sidebar.sidebar-v3__scroll {
    padding: 0 var(--sb-bar-pad-x);
  }

  .sidebar.sidebar-v3 .sidebar-v3__link {
    min-height: 50px;
    gap: 16px;
    padding: 10px 8px;
    font-weight: 500;
  }

  .sidebar.sidebar-v3 .sidebar-v3__section {
    margin-top: 16px;
    padding: 0 14px 0 0;
  }

  .sidebar.sidebar-v3 .sidebar-v3__section:first-child {
    margin-top: 0;
  }

  .sidebar.sidebar-v3 .sidebar-v3__brand-wordmark {
    display: none;
  }

  .sidebar.sidebar-v3 .sidebar-v3__brand-mark {
    display: block;
  }

  .sidebar.sidebar-v3 .sidebar-v3__brand {
    flex-direction: row;
    align-items: center;
  }

  /* Second level on phones: no tree connector, flat indented rows, one closing rule. */
  .sidebar.sidebar-v3 .listsubmenu.show::before,
  .sidebar.sidebar-v3 .listsubmenu.show > li::before {
    content: none;
    display: none;
  }

  /* Flat, not pills: a rounded fill would curve away from the straight divider.
   * !important only because the desktop rule it overrides carries one. */
  .sidebar.sidebar-v3 .listsubmenu.show:not(.third-level-menu) > li > a.dropdown-item,
  .sidebar.sidebar-v3 .listsubmenu.show:not(.third-level-menu) > li > a.dropdown-item:hover {
    min-height: var(--sb-row-height);
    padding: 8px 8px 8px var(--sb-drill-indent) !important;
    gap: 8px;
    border-radius: 0;
    font: 500 14px/150% "Inter", sans-serif;
    color: #fff;
  }

  .sidebar.sidebar-v3 .listsubmenu.show:not(.third-level-menu) > li:last-child > a.dropdown-item {
    border-bottom: 1px solid var(--sb-rule);
  }

  /* An expanded parent is not an active row. */
  .sidebar.sidebar-v3 .sidebar-v3__item--dropdown:not(.active) > .sidebar-v3__link--parent.show {
    background-color: transparent;
  }

  /* Third level takes over the scroll body instead of the desktop's 324px flyout.
   * fixed, not absolute: the trigger row may be scrolled down when tapped, and an
   * absolute panel would inherit that offset and render off-screen.
   * The X acts as Back while this is open — crmSidebarResetMobileContentDrilldown. */
  .sidebar.sidebar-v3 .listsubmenu.third-level-menu:not(.show) {
    display: none;
  }

  .sidebar.sidebar-v3 .listsubmenu.third-level-menu.show {
    position: fixed;
    top: var(--sb-bar-height);
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    max-height: none !important;
    margin: 0;
    padding: 0 var(--sb-bar-pad-x) var(--sb-bar-pad-y);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: var(--sb-bg);
    overflow-y: auto;
    z-index: 5;
    display: block;
  }

  .sidebar.sidebar-v3 .listsubmenu.third-level-menu::after {
    content: none;
  }

  /* Flush left at the gutter, not centred like the desktop flyout. */
  .sidebar.sidebar-v3 .listsubmenu.third-level-menu .sidebar-v3__flyout-title {
    height: auto;
    min-height: 51px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 10px;
    text-align: left;
    padding: 0;
    margin: 0 0 8px;
  }

  .sidebar.sidebar-v3 .listsubmenu.third-level-menu .sidebar-v3__flyout-eyebrow {
    display: block;
    width: 100%;
    font-family: "Inter", system-ui, sans-serif;
    font-size: 10px;
    font-weight: 400;
    line-height: 1.5;
    text-transform: uppercase;
    color: var(--sb-caption);
  }

  .sidebar.sidebar-v3 .listsubmenu.third-level-menu .sidebar-v3__flyout-title-text {
    font-family: "Canela", "Cormorant Garamond", serif;
    font-weight: 300;
    font-size: 20px;
    letter-spacing: 0.6px;
    line-height: 1.3;
    text-transform: none;
    color: #fff;
  }

  .sidebar.sidebar-v3 .listsubmenu.third-level-menu a.dropdown-item {
    min-height: var(--sb-drill-row-height);
    padding: 8px 0 !important;
    border-radius: 0;
    border-bottom: 1px solid var(--sb-rule);
    font-size: 14px;
  }

  .sidebar.sidebar-v3 .listsubmenu.third-level-menu > li:last-child > a.dropdown-item {
    border-bottom: none;
  }

  /* The drawer closes with the X. */
  .sidebar.sidebar-v3 .sidebar-v3__footer {
    display: none !important;
  }

  /* The legacy floating "Menu" pill is hidden at this breakpoint (see below),
   * so it is not restyled here — the V3 toggle lives in .mobile-topbar-v3. */

  /* The close button is first in the DOM as the drawer's primary control for
   * assistive tech; `order` moves it right without reordering markup. */
  .sidebar.sidebar-v3 .sidebar-v3__header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--sb-gap);
    height: var(--sb-bar-height);
    min-height: var(--sb-bar-height);
    padding: var(--sb-bar-pad-y) var(--sb-bar-pad-x);
  }

  .sidebar.sidebar-v3 .sidebar-v3__brand {
    order: 1;
  }

  .sidebar.sidebar-v3 .sidebar-v3__mobile-close {
    order: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    position: static;
    width: var(--sb-action-size);
    height: var(--sb-action-size);
    padding: 10px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
    z-index: 6;
    transition: opacity 0.2s ease;
  }

  .sidebar.sidebar-v3 .sidebar-v3__mobile-close svg {
    width: 14px;
    height: 14px;
  }

  .sidebar.sidebar-v3 .sidebar-v3__mobile-close:hover {
    opacity: 0.75;
  }

  .sidebar.sidebar-v3 .sidebar-v3__mobile-close:focus {
    outline: none;
  }

  .sidebar.sidebar-v3 .sidebar-v3__mobile-close:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.45);
    outline-offset: 2px;
  }
}

@media (min-width: 992px) {
  .sidebar-v3__mobile-close {
    display: none !important;
  }

  /* The widget is split into spans so the mobile band can reorder it. Desktop
   * hides the band-only parts and restores the original separator. */
  .weather-content__sep,
  .weather-content__time,
  .weather-content__city {
    display: none;
  }

  .weather-content__icon + .weather-content__temp::before,
  .weather-content__temp::after {
    white-space: pre;
  }

  .weather-content__icon + .weather-content__temp::before {
    content: " ";
  }

  .weather-content__temp::after {
    content: " - ";
  }
}

/* The hamburger drives the drawer, so the footer collapse toggle would duplicate it. */
@media (max-width: 767px) {
  .sidebar.sidebar-v3 .sidebar-v3__footer {
    display: none !important;
  }
}

/* Mobile top bar, rendered inside .main-headerbar rather than as a second header.
 * The design's mail/bell actions have no counterpart here, so the CRM's existing
 * world clock takes that slot. */
.mobile-topbar-v3__brand {
  display: none;
}

@media (max-width: 991px) {
  /* Full-bleed: the negative margin cancels .main-area's page padding. flex-start
   * has to win over Bootstrap's .justify-content-md-end, which sits on the same
   * element at equal specificity and would pull the brand off the left edge. */
  .main-area .main-headerbar {
    justify-content: flex-start !important;
    flex-wrap: wrap;
    align-items: center;
    row-gap: 0;
    column-gap: var(--sb-gap);
    margin: calc(var(--sb-page-pad-y) * -1) calc(var(--sb-page-pad-x) * -1) 0;
    padding: var(--sb-bar-pad-y) var(--sb-bar-pad-x) 0;
    background: var(--sb-bg);
  }

  .mobile-topbar-v3__brand {
    display: flex;
    align-items: center;
    gap: var(--sb-gap);
    order: 1;
  }

  .mobile-topbar-v3__logo {
    display: block;
    width: var(--sb-brand-size);
    height: var(--sb-brand-size);
    flex-shrink: 0;
    border-radius: 500px;
    text-decoration: none;
  }

  .mobile-topbar-v3__logo:hover {
    opacity: 0.92;
  }

  .mobile-topbar-v3__logo-img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 500px;
    object-fit: contain;
  }

  .mobile-topbar-v3__menu-toggle {
    display: grid;
    place-items: center;
    width: var(--sb-action-size);
    height: var(--sb-action-size);
    flex-shrink: 0;
  }

  .mobile-topbar-v3__menu-icon {
    width: 28px;
    height: 28px;
  }

  .head-userdropdown {
    display: flex;
    align-items: center;
    gap: var(--sb-gap);
    order: 3;
    flex-shrink: 0;
  }

  /* Keeps the existing avatar menu, drops its trimmings: the caret is not in the
   * design, and the name/email block is navy and unreadable on the dark bar. */
  .head-userdropdown .userdropdown .btn {
    gap: 0;
  }

  .head-userdropdown .arrowdowndrop,
  .head-userdropdown .userdropdown::after,
  .head-userdropdown .userdropdown .dropdown-toggle::after {
    display: none;
  }

  .head-userdropdown .userdropdown .dropdown-toggle {
    padding-right: 0 !important;
    width: auto;
  }

  .head-userdropdown .userdropdown .dropdown-toggle h4 {
    display: none !important;
  }

  .head-userdropdown .userdropdown .btn > img {
    width: var(--sb-action-size);
    height: var(--sb-action-size);
    border: 0.75px solid var(--sb-avatar-ring);
    border-radius: 200px;
    object-fit: cover;
  }

  /* The legacy floating "Menu" pill, duplicated across ~60 templates. Hidden
   * rather than deleted so those templates stay untouched. */
  .collaps-arrow-two {
    display: none !important;
  }

  /* Clock and weather are two <li> in one <ul> but belong to different rows here.
   * display:contents promotes them to direct flex children of the bar, leaving the
   * markup — and the World Clock dropdown — untouched. */
  ul.right-bottom-order {
    display: contents;
  }

  ul.right-bottom-order > li.clock-dropdown {
    order: 2;
    margin-left: auto;
    flex-shrink: 0;
  }

  ul.right-bottom-order > li.clock-dropdown > .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    text-decoration: none;
  }

  ul.right-bottom-order > li.clock-dropdown > .dropdown-toggle svg {
    width: var(--sb-glyph-size);
    height: var(--sb-glyph-size);
  }

  ul.right-bottom-order > li.clock-dropdown > .dropdown-toggle p {
    margin: 0;
    font: 500 14px/150% "Inter", sans-serif;
    color: #fff;
    white-space: nowrap;
  }

  /* flex-basis gives the band its own row and spans the bar exactly: 100% is the
   * content box, the added padding is what the negative margins pull back.
   * min-width:0 is load-bearing — without it the nowrap label inflates the item
   * past the viewport. Square corners, or the dark bar shows through at the ends. */
  ul.right-bottom-order > li:not(.clock-dropdown) {
    order: 4;
    flex-basis: calc(100% + var(--sb-bar-pad-x) * 2);
    min-width: 0;
    box-sizing: border-box;
    height: var(--sb-weather-height);
    margin: var(--sb-bar-pad-y) calc(var(--sb-bar-pad-x) * -1) 0;
    padding: 6px 8px;
    background: var(--sb-weather-bg);
    backdrop-filter: blur(1px);
    border-radius: 0;
  }

  /* Glyph, city and time left; temperature right. DOM order stays icon → temp →
   * info so the desktop header still reads as one sentence. */
  ul.right-bottom-order > li:not(.clock-dropdown) .weather-content {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    overflow: hidden;
    text-decoration: none;
  }

  /* Scoped through the band to out-specify the admin theme, which sizes images in
   * .right-bottom-order and nudges them off the centre line with position:relative. */
  ul.right-bottom-order .weather-content .weather-content__icon {
    order: 1;
    flex-shrink: 0;
    width: var(--sb-weather-glyph);
    height: var(--sb-weather-glyph);
    object-fit: contain;
    position: static;
  }

  /* Desktop keeps the full location; the band shows the city. */
  .weather-content__place {
    display: none;
  }

  .weather-content__info {
    order: 2;
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
  }

  .weather-content__city {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font: 500 14px/150% "Inter", sans-serif;
    color: var(--sb-weather-fg);
  }

  .weather-content__sep,
  .weather-content__time {
    flex-shrink: 0;
    font: 400 12px/150% "Inter", sans-serif;
    color: var(--sb-weather-fg);
  }

  .weather-content__temp {
    order: 3;
    flex-shrink: 0;
    font: 500 14px/150% "Inter", sans-serif;
    color: var(--sb-weather-fg);
  }
}

/* Firefox only: Chrome and Edge drop webkit scrollbar rules once these are set. Keep last, same specificity as the collapsed padding above. */
@supports not selector(::-webkit-scrollbar) {
  .sidebar.sidebar-v3 .body-sidebar.sidebar-v3__scroll,
  .sidebar.sidebar-v3.open .sidebar-v3__scroll,
  .sidebar-v3__scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--sb-scroll-thumb) transparent;
    /* No reserved gutter: Firefox draws its own bar, both-edges added a dead band on the left. */
    scrollbar-gutter: auto;
    padding-right: 20px;
  }
}
