:root {
  --sb-collapsed-w: 64px;
  --sb-expanded-w: 240px;
  --sb-bg: rgba(0, 186, 189, 0.05);
  --sb-bg-dark: rgba(0, 186, 189, 0.07);
  --sb-text: #1a1a1a;
  --sb-text-dark: #f2f2f2;
  --sb-accent: #00babd;
  --sb-sep: rgba(255, 255, 255, 0.18);
}

.app-shell {
  display: flex;
  width: 100%;
  gap: 0;
  flex: 1 1 auto;
  min-height: 0;
}

.app-shell--with-sidebar {
  align-items: stretch;
}

.app-shell--full-width {
  flex-direction: column;
}

.app-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  flex: 1 1 auto;
  min-height: calc(100vh - var(--navbar-height, 70px));
}

.sidebar {
  position: sticky;
  top: 1rem;
  margin-left: 1rem;
  display: flex;
  flex: 0 0 var(--sb-collapsed-w);
  width: var(--sb-collapsed-w);
  max-width: var(--sb-expanded-w);
  height: calc(100vh - var(--navbar-height, 70px) - 2rem);
  z-index: 1049;
  isolation: isolate;
  overflow: visible;
}

.sidebar .sidebar-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 10px;
  width: var(--sb-expanded-w);
  min-width: var(--sb-expanded-w);
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--sb-bg);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.15);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  clip-path: inset(
    0 calc(var(--sb-expanded-w) - var(--sb-collapsed-w)) 0 0 round 18px
  );
  transition: clip-path 0.2s ease, box-shadow 0.2s ease;
}

.dark-mode .sidebar .sidebar-inner {
  background: var(--sb-bg-dark);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  border-color: rgba(255, 255, 255, 0.06);
}

.sidebar .sb-section {
  border-radius: 14px;
  overflow: hidden;
  background: transparent;
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.sidebar .sb-section.active {
  box-shadow: 0 0 0 1px rgba(0, 186, 189, 0.25) inset;
}

.sidebar .sb-section.active .sb-btn {
  background: rgba(0, 186, 189, 0.15);
  color: var(--sb-accent);
}

.sidebar .sb-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 500;
  color: var(--sb-text);
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.dark-mode .sb-btn {
  color: var(--sb-text-dark);
}

.sidebar .sb-btn:hover {
  background: rgba(0, 186, 189, 0.2);
  transform: translateX(2px);
}

.sidebar .sb-btn.active {
  background: rgba(0, 186, 189, 0.15);
  color: var(--sb-accent);
  box-shadow: 0 0 0 1px rgba(0, 186, 189, 0.2) inset;
}

.dark-mode .sidebar .sb-btn.active {
  color: var(--sb-accent);
  background: rgba(0, 186, 189, 0.18);
}

body.sidebar-expanded .sidebar .sb-home-btn {
  justify-content: flex-start;
}

.sidebar .sb-home-divider {
  border: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  margin: 10px 0 12px;
}

.dark-mode .sidebar .sb-home-divider {
  border-top-color: rgba(255, 255, 255, 0.12);
}

.sidebar .sb-ico {
  width: 28px;
  text-align: center;
  font-size: 18px;
  flex: 0 0 28px;
}

.sidebar .sb-label {
  opacity: 0;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.sidebar .sb-submenu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-6px);
  pointer-events: none;
  transition: max-height 0.3s ease, opacity 0.2s ease, margin 0.3s ease,
    transform 0.3s ease;
}

.sidebar .sb-section.open .sb-submenu {
  max-height: 600px;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

body.sidebar-expanded .sidebar .sb-section.open .sb-submenu {
  margin: 6px 0 10px 36px;
}

.sidebar .sb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  padding: 6px 10px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
  opacity: 0.85;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.sidebar .sb-link i {
  flex: 0 0 24px;
  text-align: center;
  font-size: 16px;
}

.sidebar .sb-link .sb-link-label {
  flex: 1 1 auto;
  white-space: nowrap;
}

.sidebar .sb-link:hover {
  background: rgba(0, 0, 0, 0.1);
  opacity: 1;
}

.dark-mode .sb-link:hover {
  background: rgba(255, 255, 255, 0.12);
}

.sidebar .sb-link.highlight {
  font-weight: 600;
}

.sidebar .sb-link.active {
  color: var(--sb-accent);
  font-weight: 600;
}

.sidebar hr.sb-sep {
  border: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  margin: 6px 0;
}

.dark-mode .sidebar hr.sb-sep {
  border-top-color: rgba(255, 255, 255, 0.12);
}

body.sidebar-expanded .sidebar .sidebar-inner {
  clip-path: inset(0 0 0 0 round 18px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25);
}

body.sidebar-expanded .sidebar .sb-label {
  opacity: 1;
  pointer-events: auto;
}

body:not(.sidebar-expanded) .sidebar .sb-submenu {
  width: 100%;
}

body:not(.sidebar-expanded) .sidebar .sb-section.open .sb-submenu {
  width: var(--sb-collapsed-w);
  margin: 6px 0 10px 0;
}

body:not(.sidebar-expanded) .sidebar .sb-section.open .sb-link {
  justify-content: center;
  gap: 0;
  padding: 8px 0;
  width: 100%;
}

body:not(.sidebar-expanded) .sidebar .sb-section.open .sb-link i {
  flex: 0 0 auto;
}

body:not(.sidebar-expanded) .sidebar .sb-section.open .sb-link i.small {
  font-size: 0.875rem;
}

body:not(.sidebar-expanded) .sidebar .sb-section.open .sb-link .sb-link-label {
  display: none;
}

body:not(.sidebar-expanded) .sidebar .sb-section.open .sb-submenu .sb-sep {
  display: none;
}

@media (max-width: 991.98px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    display: none;
  }
  .app-content {
    min-height: calc(100vh - var(--navbar-height, 70px));
  }
}
