.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px);
  padding: 20px;
  overflow: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 26px;
}

.brand img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(24, 32, 27, 0.12);
}

.brand strong, .brand span { display: block; }
.brand strong { line-height: 1.2; }

.project-meta {
  background: var(--soft);
  border: 1px solid var(--line);
  border-left: 4px solid var(--coral);
  border-radius: 8px;
  margin: 14px 0 24px;
  padding: 12px;
  line-height: 1.5;
}

@media (max-width: 1040px) {
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  .sidebar { padding: 14px; }
}

.app-sidebar {
  width: 264px;
  flex: 0 0 264px;
  border-right: 1px solid #dbe4df;
  background: #fff;
  min-height: 100vh;
}

.app-sidebar {
  display: none;
}

.app-sidebar {
  width: 220px;
  flex-basis: 220px;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 30, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  z-index: 19;
}

.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.app-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 80px;
  height: 100vh;
  padding: 10px 8px;
  background: rgba(255, 255, 255, 0.98);
  border-right: 1px solid #dbe4df;
  box-shadow: 12px 0 36px rgba(8, 20, 42, 0.12);
  transform: translateX(-104%);
  transition: transform 180ms ease, width 180ms ease, padding 180ms ease;
  z-index: 50;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 8px;
  overflow: hidden;
}

.app-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.drawer-brand.loading .drawer-brand-mark {
  background: linear-gradient(90deg, #eef3fb 0%, #f7f9fc 50%, #eef3fb 100%);
  background-size: 200% 100%;
  color: transparent;
  animation: drawer-skeleton-shift 1.4s ease-in-out infinite;
}

.drawer-brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #eff8f3 0%, #e1f3ea 100%);
  color: #14724f;
  font-weight: 800;
  flex-shrink: 0;
}

.drawer-brand-copy {
  min-width: 0;
}

.drawer-brand strong,
.drawer-brand span {
  display: block;
}

.drawer-brand strong {
  font-size: 15px;
  color: #08142a;
  line-height: 1.12;
}

.drawer-brand span {
  margin-top: 3px;
  color: #64736b;
  font-size: 12px;
}

.drawer-brand.loading strong,
.drawer-brand.loading span:not(#drawerBrandInitials) {
  color: transparent;
  border-radius: 999px;
  background: linear-gradient(90deg, #eef3fb 0%, #f7f9fc 50%, #eef3fb 100%);
  background-size: 200% 100%;
  animation: drawer-skeleton-shift 1.4s ease-in-out infinite;
}

.drawer-brand.loading strong {
  width: 160px;
  max-width: 100%;
}

.drawer-brand.loading span:not(#drawerBrandInitials) {
  width: 190px;
  max-width: 100%;
  min-height: 14px;
}

@keyframes drawer-skeleton-shift {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.drawer-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.drawer-close-btn {
  --btn-bg: #fff;
  --btn-color: #4a5f78;
  --btn-border: #dbe4df;
  --btn-hover-bg: #f4f7fb;
  --btn-hover-color: #08142a;
  --btn-hover-border: #dbe4df;
  min-height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 12px;
  box-shadow: none;
  font-size: 18px;
  line-height: 1;
}

.drawer-close-btn:hover {
  background: #f4f7fb;
  color: #08142a;
  box-shadow: none;
}

.collapse-right {
  display: none;
}

.mobile-close-btn {
  display: inline-flex;
}

.drawer-profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  position: sticky;
  bottom: 8px;
  background: rgba(255,255,255,0.98);
  border: 1px solid #dbe4df;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(8, 20, 42, 0.04);
}

.drawer-profile-avatar {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: linear-gradient(180deg, #239062 0%, #14724f 100%);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}

.drawer-profile-copy {
  min-width: 0;
  flex: 1;
}

.drawer-profile-copy strong,
.drawer-profile-copy span {
  display: block;
}

.drawer-profile-copy strong {
  font-size: 14px;
  color: #0f172a;
}

.drawer-profile-copy span {
  margin-top: 2px;
  font-size: 12px;
  color: #64736b;
}

.drawer-profile-chevron {
  color: #6d7f92;
  font-size: 16px;
}

body.sidebar-collapsed .app-drawer {
  width: 80px;
  padding: 12px 8px;
}

body.sidebar-collapsed .drawer-brand-copy,
body.sidebar-collapsed .drawer-section-label,
body.sidebar-collapsed .drawer-project-copy,
body.sidebar-collapsed .drawer-project-chevron,
body.sidebar-collapsed .drawer-profile-copy,
body.sidebar-collapsed .drawer-profile-chevron,
body.sidebar-collapsed .drawer-label-text,
body.sidebar-collapsed .drawer-project-btn .btn-icon + span,
body.sidebar-collapsed .drawer-group-chevron {
  display: none !important;
}

body.sidebar-collapsed .drawer-header {
  justify-content: center;
}

body.sidebar-collapsed .drawer-header-actions {
  width: 100%;
  justify-content: center;
}

body.sidebar-collapsed .drawer-brand {
  display: none;
}

body.sidebar-collapsed .collapse-left {
  display: none;
}

body.sidebar-collapsed .collapse-right {
  display: inline;
}

body.sidebar-collapsed .drawer-profile-card {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

body.sidebar-collapsed .drawer-project-actions {
  justify-items: center;
}

body.sidebar-collapsed .drawer-profile-card {
  padding: 8px 0;
}

@media (min-width: 1100px) {
  .sidebar-overlay {
    display: none;
  }

  .app-drawer {
    transform: translateX(0);
  }

  body:not(.sidebar-collapsed) .app-drawer {
    width: 280px;
  }

  .mobile-close-btn {
    display: none;
  }
}

@media (max-width: 1099px) {
  .collapse-btn {
    display: none;
  }

  .app-drawer {
    width: min(280px, calc(100vw - 24px));
    transform: translateX(-104%);
  }

  .app-drawer.open {
    transform: translateX(0);
  }
}
