:root {
  --hemsa-sidebar-width: 292px;
  --hemsa-sidebar-collapsed-offset: -292px;
  --hemsa-header-height: 62px;
  --hemsa-footer-height: 42px;
  --hemsa-sidebar-bg: #f8faf9;
  --hemsa-sidebar-border: #dfe8e5;
  --hemsa-sidebar-text: #15332f;
  --hemsa-sidebar-muted: #63736f;
  --hemsa-sidebar-active: #e7f6f1;
  --hemsa-sidebar-accent: #2ea88d;
}

.hemsa-sidebar {
  position: fixed;
  top: var(--hemsa-header-height);
  bottom: var(--hemsa-footer-height);
  left: 0;
  z-index: 90;
  width: var(--hemsa-sidebar-width);
  background: var(--hemsa-sidebar-bg);
  border-right: 1px solid var(--hemsa-sidebar-border);
  box-shadow: none;
  color: var(--hemsa-sidebar-text);
  display: flex;
  flex-direction: column;
  transform: translateX(var(--hemsa-sidebar-collapsed-offset));
  transition: transform 220ms ease, box-shadow 220ms ease;
}

.hemsa-sidebar__header {
  min-height: 64px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  border-bottom: 1px solid var(--hemsa-sidebar-border);
}

.hemsa-sidebar__brand {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--hemsa-sidebar-text);
  text-decoration: none;
  font-family: "Poppins", sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
}

.hemsa-sidebar__brand img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.hemsa-sidebar__toggle,
.hemsa-sidebar-rail {
  border: 1px solid var(--hemsa-sidebar-border);
  background: #ffffff;
  color: var(--hemsa-sidebar-text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.hemsa-sidebar__toggle {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 2.2rem;
  line-height: 1;
}

.hemsa-sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(21, 51, 47, 0.18) transparent;
}

.hemsa-sidebar__nav::-webkit-scrollbar {
  width: 8px;
}

.hemsa-sidebar__nav::-webkit-scrollbar-track {
  background: transparent;
}

.hemsa-sidebar__nav::-webkit-scrollbar-thumb {
  background: rgba(21, 51, 47, 0.16);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

.hemsa-sidebar__nav:hover::-webkit-scrollbar-thumb {
  background: rgba(21, 51, 47, 0.28);
  border: 2px solid transparent;
  background-clip: content-box;
}

.hemsa-sidebar__section {
  margin-bottom: 4px;
}

.hemsa-sidebar__section-link,
.hemsa-sidebar__child {
  font-family: "Poppins", sans-serif;
  text-decoration: none;
  color: var(--hemsa-sidebar-text);
  border-radius: 8px;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.hemsa-sidebar__section-link {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  font-size: 1.28rem;
  font-weight: 500;
}

.hemsa-sidebar__section-button {
  width: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.hemsa-sidebar__text {
  flex: 1;
  min-width: 0;
}

.hemsa-sidebar__chevron {
  flex: 0 0 auto;
  color: var(--hemsa-sidebar-muted);
  font-size: 1.8rem;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 160ms ease;
}

.hemsa-sidebar__section.is-expanded .hemsa-sidebar__chevron {
  transform: rotate(90deg);
}

.hemsa-sidebar__section-link:hover,
.hemsa-sidebar__child:hover,
.hemsa-sidebar__section-link.is-active,
.hemsa-sidebar__child.is-active {
  background: var(--hemsa-sidebar-active);
  color: #0f6d5c;
}

.hemsa-sidebar__section-link.is-active,
.hemsa-sidebar__child.is-active {
  box-shadow: inset 1px 0 0 var(--hemsa-sidebar-accent);
}

.hemsa-sidebar__icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ddf3ed;
  color: #0f7b68;
}

.hemsa-sidebar__icon::before {
  font-size: 1.25rem;
  line-height: 1;
}

.hemsa-sidebar__icon--dashboard::before { content: "▦"; }
.hemsa-sidebar__icon--settings::before { content: "⚙"; }
.hemsa-sidebar__icon--briefcase::before { content: "▣"; }
.hemsa-sidebar__icon--home::before { content: "⌂"; }
.hemsa-sidebar__icon--users::before { content: "♟"; }
.hemsa-sidebar__icon--id::before { content: "▤"; }
.hemsa-sidebar__icon--legal::before { content: "§"; }
.hemsa-sidebar__icon--finance::before { content: "€"; }
.hemsa-sidebar__icon--book::before { content: "□"; }
.hemsa-sidebar__icon--org::before { content: "◇"; }
.hemsa-sidebar__icon--profile::before { content: "●"; }
.hemsa-sidebar__icon--document::before { content: "▤"; }
.hemsa-sidebar__icon--calendar::before { content: "▦"; }
.hemsa-sidebar__icon--people::before { content: "♟"; }
.hemsa-sidebar__icon--alert::before { content: "!"; }
.hemsa-sidebar__icon--map::before { content: "⌖"; }
.hemsa-sidebar__icon--dot::before { content: "•"; }
.hemsa-sidebar__icon--notes::before { content: "\2709"; }

.hemsa-sidebar__children {
  display: none;
  margin: 2px 0 8px 32px;
  padding-left: 8px;
  border-left: 1px solid var(--hemsa-sidebar-border);
}

.hemsa-sidebar__section.is-expanded .hemsa-sidebar__children {
  display: block;
}

.hemsa-sidebar__child {
  display: flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 9px;
  color: var(--hemsa-sidebar-muted);
  font-size: 1.16rem;
  font-weight: 500;
}

.hemsa-sidebar__child--external {
  justify-content: space-between;
  gap: 8px;
}

.hemsa-sidebar__external-icon {
  flex: 0 0 auto;
  color: #6f827d;
  font-size: 1.15rem;
  line-height: 1;
}

.hemsa-sidebar-rail {
  position: fixed;
  left: 12px;
  top: calc(var(--hemsa-header-height) + 12px);
  z-index: 91;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 2.2rem;
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) rotate(180deg);
  transition: opacity 180ms ease, transform 180ms ease;
}

.hemsa-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding-left: 0;
  box-sizing: border-box;
}

body.hemsa-has-sidebar:not(.hemsa-sidebar-is-collapsed) > .hemsa-workspace,
html.hemsa-menu-expanded body > .hemsa-workspace,
html.hemsa-menu-expanded .hemsa-workspace {
  margin-left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  padding-left: var(--hemsa-sidebar-width);
  min-width: 0;
  overflow-x: auto;
  box-sizing: border-box;
}

body.hemsa-has-sidebar > .hemsa-workspace,
html.hemsa-menu-expanded body > .hemsa-workspace,
html.hemsa-menu-expanded .hemsa-workspace,
html.hemsa-menu-collapsed body > .hemsa-workspace,
html.hemsa-menu-collapsed .hemsa-workspace {
  transition: padding-left 220ms ease, margin-left 220ms ease, width 220ms ease, max-width 220ms ease;
}

html.hemsa-menu-collapsed .hemsa-sidebar {
  transform: translateX(var(--hemsa-sidebar-collapsed-offset));
  box-shadow: none;
}

html.hemsa-menu-expanded .hemsa-sidebar {
  transform: translateX(0);
}

body.hemsa-sidebar-is-collapsed > .hemsa-workspace,
html.hemsa-menu-collapsed body > .hemsa-workspace,
html.hemsa-menu-collapsed .hemsa-workspace {
  margin-left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  padding-left: 0;
}

html.hemsa-menu-collapsed .hemsa-sidebar-rail {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) rotate(180deg);
}

html.hemsa-menu-expanded .hemsa-sidebar-rail {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-8px) rotate(180deg);
}

@media (max-width: 900px) {
  :root {
    --hemsa-sidebar-width: min(86vw, 310px);
    --hemsa-sidebar-collapsed-offset: calc(-1 * var(--hemsa-sidebar-width));
  }

  body.hemsa-has-sidebar:not(.hemsa-sidebar-is-collapsed) > .hemsa-workspace,
  html.hemsa-menu-expanded body > .hemsa-workspace,
  html.hemsa-menu-expanded .hemsa-workspace {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 0;
  }

  .hemsa-sidebar--personal .hemsa-sidebar__nav {
    padding: 14px 12px;
  }

  .hemsa-sidebar--personal .hemsa-sidebar__section {
    margin-bottom: 8px;
  }

  .hemsa-sidebar--personal .hemsa-sidebar__section-link {
    min-height: 54px;
    padding: 12px 14px;
    border: 1px solid #e1ebe8;
    border-radius: 12px;
    background: #ffffff;
    font-size: 1.5rem;
  }

  .hemsa-sidebar--personal .hemsa-sidebar__section-link.is-active {
    border-color: #9ed9ca;
    background: var(--hemsa-sidebar-active);
  }

  .hemsa-sidebar--personal .hemsa-sidebar__icon {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }

  body:has(.hemsa-sidebar--personal) .dashboard-heading,
  body:has(.hemsa-sidebar--personal) .top-bar > div:first-child {
    padding-left: 54px;
  }

  body:has(.hemsa-sidebar--personal) .top-bar > h1:first-child {
    margin-left: 54px;
  }
}
