@layer layout {
  .app-sidebar {
    background: var(--app-sidebar-background-color);
    --app-sidebar-gap: 0.5rem;
    --app-sidebar-item-gap: 10px;
    --app-sidebar-title-size: 10px;
    --app-sidebar-summary-size: 12px;
    --app-sidebar-tenant-size: 14px;
    --app-sidebar-titlebar-height: 30px;
    --app-sidebar-border-width: 2px;
    --app-sidebar-summary-max-width: 142px;
    --app-sidebar-section-gap: 2rem;
    --app-sidebar-section-space: 5px;
    --app-sidebar-hover-bg: transparent;
  }

  .app-sidebar .brand {
    padding: var(--app-spacing);
  }

  .app-sidebar-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--app-sidebar-gap);
    padding: 0 var(--app-spacing);
    margin-bottom: 0;
    min-height: var(--app-sidebar-titlebar-height);
  }

  .aside-pending .app-sidebar-titlebar {
    visibility: hidden;
  }

  .app-sidebar .app-sidebar-panel {
    display: block;
  }

  .app-sidebar-group.app-sidebar-admin-group details summary i {
    font-size: 10px;
    position: relative;
    top: -4px;
    margin-right: 3px;
  }

  aside.app-sidebar li:has(> .app-empty-state) {
    padding-inline: 19px;
  }

  .app-sidebar .app-sidebar-panel[hidden] {
    display: none !important;
  }

  .app-sidebar.is-collapsed .app-sidebar-panels,
  .app-sidebar.is-collapsed .app-sidebar-titlebar,
  .sidebar-collapsed .app-sidebar .app-sidebar-titlebar,
  .sidebar-collapsed .app-sidebar .app-sidebar-panels {
    display: none;
  }

  .app-sidebar-tenant-logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--app-sidebar-gap);
    padding: var(--app-spacing);
  }

  .app-sidebar .app-sidebar-tenant-logo a:hover {
    background: transparent;
    border: 0;
  }

  .app-sidebar .app-sidebar-tenant-logo > a {
    padding: 0;
    flex: 1;
    border: 0;
    text-decoration: none;
  }

  .app-sidebar .app-sidebar-tenant-logo img {
    display: block;
    max-width: 100%;
    max-height: 48px;
    width: auto;
    height: auto;
    object-fit: contain;
  }

  .app-sidebar-tenant-toggle {
    display: none;
    border: 1px solid var(--app-border);
    background: transparent;
    margin: 0;
  }

  .app-sidebar-tenant-toggle:hover {
    color: var(--app-contrast);
    border-color: var(--app-contrast);
  }

  .app-sidebar-tenant-name {
    font-weight: 600;
    font-size: 17px;
    color: var(--app-contrast);
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-sidebar-title {
    text-transform: uppercase;
    font-size: var(--app-sidebar-title-size);
    color: var(--app-muted-color);
  }

  .app-sidebar-tools {
    display: flex;
    align-items: center;
    gap: 0.35rem;
  }

  .app-sidebar-tools .icon-button {
    border: 0;
    background: transparent;
    color: var(--app-muted-color);
    padding: 0.25rem;
    font-size: 0.9rem;
    cursor: pointer;
    margin-bottom: 0;
  }

  .app-sidebar-tools .icon-button:hover {
    color: var(--app-contrast);
  }

  @media (min-width: 768px) {
    .app-sidebar .brand {
      margin-bottom: 1rem;
      padding-block-start: 0.5rem;
    }

    .app-sidebar-title {
      display: block;
    }

    .app-sidebar {
      position: sticky;
      top: 0;
      z-index: 1;
      height: 100vh;
      overflow-y: auto;
    }
  }

  @media (max-width: 767px) {
    .app-sidebar-tenant-toggle {
      display: inline-flex;
      align-items: center;
      justify-content: center;
    }
    .app-sidebar-tenant-logo img {
      max-width: 120px;
      max-height: 40px;
      flex-shrink: 0;
    }
    .app-sidebar {
      border-bottom: 1px solid var(--app-border);
    }

    .app-sidebar-panels {
      padding-block-end: var(--app-spacing);
    }
  }

  .app-sidebar a {
    color: inherit;
    display: block;
    padding: 5px var(--app-spacing);
    border-radius: 0;
    margin: 0;
    border-left: var(--app-sidebar-border-width) solid transparent;
    width: 100%;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .app-sidebar a:hover,
  .app-sidebar a.active,
  .app-sidebar .active > a {
    color: var(--app-primary);
    background: var(--app-sidebar-hover-bg);
    border-left: var(--app-sidebar-border-width) solid var(--app-primary);
  }

  aside.app-sidebar ul,
  aside.app-sidebar li {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .app-sidebar small {
    margin-top: var(--app-sidebar-section-gap);
    margin-bottom: var(--app-sidebar-section-space);
    display: block;
    padding-inline: var(--app-spacing);
  }

  .app-sidebar .app-sidebar-group small {
    margin-top: 0;
    margin-bottom: 0;
    display: block;
    padding-inline: 0;
    opacity: 1;
  }

  .app-sidebar .app-sidebar-group details {
    padding: 0;
    margin: 0;
  }

  .app-sidebar .app-sidebar-group summary {
    padding: 0 var(--app-spacing);
    font-size: var(--app-sidebar-summary-size);
    color: var(--app-muted-color);
  }

  nav#aside-panel-people {
    margin-top: var(--app-spacing);
  }

  .app-sidebar .app-sidebar-group summary::-webkit-details-marker {
    display: none;
  }

  .app-sidebar .app-sidebar-group details > ul {
    margin: 0;
    padding: 0;
  }

  .app-sidebar .app-sidebar-group summary > span {
    text-overflow: ellipsis;
    display: inline-block;
    max-width: var(--app-sidebar-summary-max-width);
    overflow: hidden;
    white-space: nowrap;
  }

  .app-sidebar #aside-panel-admin > ul {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
  }

  .app-sidebar #aside-panel-admin .app-sidebar-admin-group {
    margin-bottom: 5px;
    width: 100%;
  }

  .app-sidebar
    #aside-panel-admin
    .app-sidebar-admin-group
    details
    > ul
    li:first-child {
    margin-top: 0;
  }

  .app-sidebar
    #aside-panel-admin
    .app-sidebar-admin-group
    details
    > ul
    li:last-child {
    margin-bottom: 0.35rem;
  }

  .app-sidebar .app-sidebar-group details > ul li:first-child {
    margin-top: 10px;
  }

  .app-sidebar .app-sidebar-saved-filters {
    margin-bottom: var(--app-spacing);
  }

  .app-sidebar .app-sidebar-saved-filter-item:before {
    content: "";
    display: none;
  }

  .app-sidebar .app-sidebar-group.app-sidebar-saved-filters > small {
    padding: 5px var(--app-spacing);
  }

  .app-sidebar .app-sidebar-saved-filter-item {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: space-between;
    padding-right: 10px;
  }

  .app-sidebar .app-sidebar-saved-filter-item > a {
    flex: 1;
    min-width: 0;
  }

  .app-sidebar .app-sidebar-saved-filter-delete {
    margin: 0;
    display: flex;
    align-items: center;
  }

  .app-sidebar .app-sidebar-saved-filter-delete button {
    margin: 0;
    border: 0;
    background: transparent;
    color: var(--app-muted-color);
    padding: 4px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 120ms ease;
  }

  .app-sidebar .app-sidebar-saved-filter-delete button:hover {
    color: var(--app-contrast);
  }

  .app-sidebar
    .app-sidebar-saved-filter-item:hover
    .app-sidebar-saved-filter-delete
    button,
  .app-sidebar
    .app-sidebar-saved-filter-item:focus-within
    .app-sidebar-saved-filter-delete
    button {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  aside.app-sidebar li.app-sidebar-group {
    margin-bottom: var(--app-spacing);
  }
}
