.app-shell > .lg\:flex {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar-width);
  flex-direction: column;
  border-right: 1px solid var(--line-strong);
  background: var(--bg);
  padding: 10px 8px;
}

.sidebar-brand-wrapper {
  display: flex;
  flex-direction: column;
  padding: 0px 8px 0;
}

.sidebar-logo {
  font-family: var(--font-sans);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.04em;
  padding: 4px 12px;
  margin-bottom: 8px;
}

.sidebar-workspace-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  padding: 0 12px;
  margin-bottom: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sidebar-workspace-selector:hover {
  background: var(--surface-muted);
  border-color: var(--text-muted);
}

.workspace-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
}

.workspace-avatar.avatar-admin {
  background: #F27A54; /* ElevenLabs Orange Circle */
}

.workspace-avatar.avatar-worker {
  background: #4DABF7; /* Worker Blue Circle */
}

.workspace-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
}

.sidebar-brand-name,
.brand-name {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-family: var(--font-sans);
}

.sidebar-nav {
  display: grid;
  gap: 6px;
  padding: 0 8px;
}

.sidebar-nav-label {
  margin: 16px 16px 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-link {
  display: flex;
  height: 42px;
  align-items: center;
  gap: 12px;
  border-radius: var(--radius-sm); /* 10px */
  border: 1px solid transparent;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 500;
  padding: 0 15px; /* Adjust slightly for 1px border */
  transition: all 0.2s ease;
}

.sidebar-link i {
  color: var(--text-muted);
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
  transition: color 0.2s ease;
}

.sidebar-link:hover {
  background: var(--surface-muted); /* #F4F4F4 */
  color: var(--text);
  transform: translateY(-1px);
}

.sidebar-link:hover i {
  color: var(--text);
}

.sidebar-link.active {
  background: var(--surface-muted);
  border-color: transparent;
  color: var(--text);
  font-weight: 600;
}

.sidebar-link.active i {
  color: var(--text);
}

.sidebar-link:active,
.drawer-nav-link:active {
  transform: translateY(0);
}

.main-content {
  min-width: 0;
  min-height: 100vh;
  background: var(--surface);
}

.app-shell .main-content {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
}

.top-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface);
  padding: 0 var(--content-pad) 0 16px;
}

.top-header-actions,
.mobile-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-header-actions form {
  display: inline-flex;
  align-items: center;
  margin: 0;
}

.content-pad {
  width: min(100%, calc(var(--content-width) + (2 * var(--content-pad))));
  margin: 0 auto;
  padding: var(--content-pad);
}

.mobile-topbar {
  display: flex;
  position: fixed;
  inset: 0 0 auto;
  z-index: 40;
  height: 56px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line-strong);
  background: var(--surface);
  padding: 0 16px;
}

.mobile-menu-toggle-btn,
.mobile-icon-btn {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-menu-toggle-btn:hover,
.mobile-icon-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.mobile-menu-toggle-btn:active,
.mobile-icon-btn:active {
  transform: scale(0.95);
}

.mobile-menu-toggle-btn svg,
.mobile-icon-btn svg {
  stroke-width: 1.8;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 49;
  visibility: hidden;
  background: rgba(15, 23, 42, 0.22);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 280ms ease, visibility 280ms ease;
}

.drawer-backdrop.is-open,
body.menu-open .drawer-backdrop {
  visibility: visible;
  opacity: 1;
}

.drawer-panel {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 50;
  width: min(80vw, 290px);
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--bg);
  box-shadow: 20px 0 80px rgba(0, 0, 0, 0.08);
  border-top-right-radius: 20px;
  border-bottom-right-radius: 20px;
  transform: translate3d(-102%, 0, 0);
  transition: transform 340ms cubic-bezier(0.22, 1, 0.36, 1);
}

.drawer-panel.is-open,
body.menu-open .drawer-panel {
  display: flex;
  transform: translate3d(0, 0, 0);
}

.drawer-header {
  display: flex;
  min-height: 70px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 0 20px;
}

.drawer-nav {
  display: grid;
  flex: 1;
  align-content: start;
  gap: 5px;
  overflow-y: auto;
  padding: 16px;
}

.drawer-nav-link {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--text-soft);
  font-size: 13.5px;
  font-weight: 600;
  padding: 0 15px;
  transition: all 180ms ease;
}

.drawer-nav-link i {
  color: var(--text-muted);
  transition: color 180ms ease;
}

.drawer-nav-link:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.drawer-nav-link.active {
  background: var(--surface-muted);
  border-color: transparent;
  color: var(--text);
}

.drawer-nav-link:hover i,
.drawer-nav-link.active i {
  color: var(--text);
}

.drawer-footer {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 14px;
}

.drawer-footer-action {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-subtle);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  transition: all 180ms ease;
}

.drawer-footer-action i {
  color: var(--text-muted);
  transition: color 180ms ease;
}

.drawer-footer-action:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
  color: var(--text);
}

.drawer-footer-action:hover i {
  color: var(--text);
}

.drawer-footer-action--danger {
  color: var(--danger);
  border-color: var(--danger-line);
  background: var(--danger-soft);
}

.drawer-footer-action--danger i {
  color: var(--danger);
}

.drawer-footer-action--danger:hover {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
}

.drawer-footer-action--danger:hover i {
  color: #ffffff;
}

@media (max-width: 767px) {
  .app-shell .main-content {
    width: 100%;
    margin-left: 0;
    padding-top: 58px;
  }

  .content-pad {
    padding: 18px;
  }
}

@media (max-width: 640px) {
  .content-pad {
    padding: 14px 12px 24px;
  }

  .mobile-topbar-brand .brand-name::before {
    width: 28px;
    height: 28px;
    margin-right: 7px;
  }
}
@media (min-width: 768px) {
  .sidebar.hidden,
  .top-header.hidden {
    display: flex !important;
  }

  .mobile-topbar,
  .drawer-backdrop,
  .drawer-panel {
    display: none !important;
  }

  .app-shell .main-content {
    width: calc(100% - var(--sidebar-width));
    margin-left: var(--sidebar-width);
    padding-top: 0;
  }
}
body.menu-open { overflow: hidden; }

/* Smooth mobile off-canvas navigation. */
@media (max-width: 767px) {
  .drawer-panel {
    display: flex;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translate3d(-102%, 0, 0);
    transition:
      transform 340ms cubic-bezier(0.22, 1, 0.36, 1),
      opacity 220ms ease,
      visibility 0s linear 340ms;
    will-change: transform;
  }

  body.menu-open .drawer-panel {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translate3d(0, 0, 0);
    transition-delay: 0s;
  }

  .drawer-backdrop {
    transition:
      opacity 280ms ease,
      visibility 0s linear 280ms;
  }

  body.menu-open .drawer-backdrop {
    transition-delay: 0s;
  }

  body.menu-open .drawer-nav-link {
    animation: drawer-link-in 300ms both;
  }

  body.menu-open .drawer-nav-link:nth-child(2) { animation-delay: 35ms; }
  body.menu-open .drawer-nav-link:nth-child(3) { animation-delay: 70ms; }
  body.menu-open .drawer-nav-link:nth-child(4) { animation-delay: 105ms; }
  body.menu-open .drawer-nav-link:nth-child(5) { animation-delay: 140ms; }
  body.menu-open .drawer-nav-link:nth-child(6) { animation-delay: 175ms; }
  body.menu-open .drawer-nav-link:nth-child(7) { animation-delay: 210ms; }
}

@keyframes drawer-link-in {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
/* Text-only wordmark and balanced mobile header. */
.sidebar-brand-name::before,
.brand-name::before {
  content: none !important;
  display: none !important;
}

.sidebar-brand-name,
.brand-name {
  font-family: "DM Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.055em;
  color: var(--text);
  text-wrap: balance;
}

@media (max-width: 767px) {
  .app-shell .main-content {
    width: 100%;
    margin-left: 0;
    padding-top: 56px; /* Adjusted to match new mobile topbar height of 56px */
  }

  .mobile-topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }
}
/* Balanced mobile drawer footer. */
@media (max-width: 767px) {
  .drawer-footer {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 11px 12px max(11px, env(safe-area-inset-bottom));
  }

  .drawer-footer-form,
  .drawer-footer > .drawer-footer-action,
  .drawer-footer-form .drawer-footer-action {
    width: 100%;
    min-width: 0;
    margin: 0;
  }

  .drawer-footer-action {
    min-height: 44px;
    justify-content: center;
    gap: 8px;
    border-color: var(--line);
    border-radius: 12px;
    background: var(--surface-subtle);
    color: var(--text-soft);
    padding: 0 12px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
  }

  .drawer-footer-action span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .drawer-footer-action svg {
    flex: 0 0 auto;
    stroke-width: 1.8;
  }

  .drawer-footer-action:hover {
    border-color: var(--line-strong);
    background: var(--surface-muted);
    color: var(--text);
  }

  .drawer-footer-action--danger {
    color: var(--danger);
    border-color: var(--danger-line);
    background: var(--danger-soft);
  }

  .drawer-footer-action--danger:hover {
    border-color: var(--danger);
    background: var(--danger);
    color: #ffffff;
  }
}

/* ══ Sidebar Collapse & Expand Animations ═════════════════════ */
.sidebar {
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), padding 0.25s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.25s ease;
  will-change: width;
}

.app-shell .main-content {
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: margin-left, width;
}

/* Collapsed State Styles */
body.sidebar-collapsed {
  --sidebar-width: 72px;
}

body.sidebar-collapsed .sidebar {
  width: 72px;
  padding: 16px 8px;
  align-items: center;
}

body.sidebar-collapsed .sidebar-logo {
  padding: 8px 0;
  justify-content: center;
  margin-bottom: 12px;
}

body.sidebar-collapsed .sidebar-logo-text {
  display: none !important;
}

body.sidebar-collapsed .sidebar-workspace-selector {
  width: 44px;
  height: 40px;
  padding: 0;
  justify-content: center;
  margin-bottom: 16px;
  border-radius: var(--radius-sm);
}

body.sidebar-collapsed .sidebar-workspace-selector .workspace-name,
body.sidebar-collapsed .sidebar-workspace-selector .workspace-chevron {
  display: none !important;
}

body.sidebar-collapsed .sidebar-nav-label {
  display: none !important;
}

body.sidebar-collapsed .sidebar-link {
  font-size: 0 !important;
  width: 44px;
  height: 44px;
  padding: 0;
  justify-content: center;
  border-radius: var(--radius-sm);
}

body.sidebar-collapsed .sidebar-link i {
  margin: 0 !important;
  width: 20px !important;
  height: 20px !important;
}

body.sidebar-collapsed .sidebar-link.active {
  background: var(--surface-muted);
}