:root {
  --app-sidebar-width: 288px;
  --app-bottom-nav-height: 68px;
  --sb-bg: #ffffff;
  --sb-bg-soft: #f8fafc;
  --sb-border: #e8edf3;
  --sb-text: #334155;
  --sb-muted: #94a3b8;
  --sb-accent: #0d6efd;
  --sb-accent-soft: rgba(13, 110, 253, 0.1);
  --app-accent: #0d6efd;
  --app-bottom-bg: rgba(255, 255, 255, 0.92);
  --app-bottom-border: rgba(15, 23, 42, 0.08);
}

body.app-shell {
  background: #f8fafc;
}

.app-layout {
  min-height: 100vh;
}

.app-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--app-sidebar-width);
  height: 100vh;
  background: var(--sb-bg);
  color: var(--sb-text);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--sb-border);
  box-shadow: -8px 0 28px rgba(15, 23, 42, 0.06);
}

.app-sidebar-offcanvas {
  background: var(--sb-bg);
  color: var(--sb-text);
  width: min(88vw, 340px);
  top: 0;
  right: 0 !important;
  left: auto !important;
  border-left: 1px solid var(--sb-border);
  border-right: 0;
  transform: translateX(100%);
  padding: 0;
}

.app-sidebar-offcanvas.showing,
.app-sidebar-offcanvas.show:not(.hiding) {
  transform: none;
}

.app-sidebar-offcanvas.hiding {
  transform: translateX(100%);
}

.sb-offcanvas-header {
  border-bottom: 1px solid var(--sb-border);
  padding: 1rem 1.1rem;
  color: #0f172a;
}

.sb-offcanvas-header .btn-close-white {
  filter: none;
}

.sb-brand {
  padding: 1.15rem 1.1rem 1rem;
  border-bottom: 1px solid var(--sb-border);
}

.sb-brand__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #0f172a;
}

.sb-brand__mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(145deg, #1d4ed8, #0d6efd);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(13, 110, 253, 0.25);
}

.sb-brand__mark img {
  width: 22px;
  height: 22px;
  filter: brightness(0) invert(1);
}

.sb-brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.sb-brand__text strong {
  font-size: 1rem;
  font-weight: 800;
}

.sb-brand__text small {
  color: var(--sb-muted);
  font-size: 0.75rem;
}

.sb-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.9rem;
}

.sb-scroll::-webkit-scrollbar {
  width: 5px;
}

.sb-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.sb-search {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
  border-radius: 0.9rem;
  background: var(--sb-bg-soft);
  border: 1px solid var(--sb-border);
  color: var(--sb-muted);
  text-decoration: none;
  transition: all 0.2s ease;
}

.sb-search:hover {
  color: #0f172a;
  border-color: #bfd3ff;
  background: #eef5ff;
}

.sb-section {
  margin-bottom: 1.15rem;
}

.sb-section__title {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  padding: 0 0.35rem 0.55rem;
}

.sb-nav {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.75rem;
  border-radius: 0.9rem;
  color: var(--sb-text);
  text-decoration: none;
  transition: all 0.18s ease;
  position: relative;
}

.sb-link__icon {
  width: 36px;
  height: 36px;
  border-radius: 0.7rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  color: #475569;
  flex-shrink: 0;
}

.sb-link__icon--soft {
  background: #eef5ff;
  color: #0d6efd;
}

.sb-link__icon i {
  font-size: 1.05rem;
}

.sb-link__label {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
}

.sb-link__arrow {
  color: #94a3b8;
  font-size: 0.85rem;
  opacity: 0;
  transform: translateX(4px);
  transition: all 0.18s ease;
}

.sb-link__badge {
  min-width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.35rem;
}

.sb-link:hover {
  background: #f8fafc;
  color: #0f172a;
}

.sb-link:hover .sb-link__arrow {
  opacity: 1;
  transform: none;
}

.sb-link.is-active {
  background: var(--sb-accent-soft);
  color: #0d6efd;
  box-shadow: inset 0 0 0 1px rgba(13, 110, 253, 0.18);
}

.sb-link.is-active .sb-link__icon {
  background: #0d6efd;
  color: #fff;
  box-shadow: 0 6px 14px rgba(13, 110, 253, 0.25);
}

.sb-link.is-active .sb-link__label {
  color: #0d6efd;
}

.sb-link.is-active::before {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 55%;
  border-radius: 999px;
  background: #0d6efd;
}

.sb-promo {
  margin-top: 0.35rem;
  padding: 1rem;
  border-radius: 1rem;
  background: linear-gradient(145deg, #eef5ff 0%, #f8fafc 100%);
  border: 1px solid #d6e4ff;
}

.sb-promo__eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  color: #0d6efd;
  margin-bottom: 0.25rem;
}

.sb-promo__title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.sb-promo__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55rem 0.8rem;
  border-radius: 0.7rem;
  background: #0d6efd;
  color: #fff;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
}

.sb-promo__btn:hover {
  background: #0b5ed7;
  color: #fff;
}

.sb-footer {
  padding: 0.9rem;
  border-top: 1px solid var(--sb-border);
  background: var(--sb-bg-soft);
}

.sb-user {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem;
  border-radius: 0.9rem;
  background: #fff;
  border: 1px solid var(--sb-border);
  text-decoration: none;
  color: #0f172a;
  margin-bottom: 0.5rem;
}

.sb-user__avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  object-fit: cover;
  border: 2px solid #e2e8f0;
}

.sb-user__meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.sb-user__meta strong {
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-user__meta small {
  color: var(--sb-muted);
  font-size: 0.72rem;
}

.sb-logout,
.sb-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 0.85rem;
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 700;
}

.sb-logout {
  background: #fff1f2;
  color: #e11d48;
  border: 1px solid #fecdd3;
}

.sb-logout:hover {
  background: #ffe4e6;
  color: #be123c;
}

.sb-login {
  background: #0d6efd;
  color: #fff;
}

.sb-login:hover {
  background: #0b5ed7;
  color: #fff;
}

.app-main {
  min-height: 100vh;
  transition: margin 0.25s ease;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--app-bottom-border);
}

.app-topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
  padding: 0.75rem 1rem;
}

.app-topbar__title {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.app-topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.app-icon-btn {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  position: relative;
}

.app-icon-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.app-icon-btn__badge {
  position: absolute;
  top: 2px;
  left: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.app-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1050;
  background: var(--app-bottom-bg);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--app-bottom-border);
  box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.08);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.app-bottom-nav__inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  min-height: var(--app-bottom-nav-height);
  max-width: 640px;
  margin: 0 auto;
}

.app-bottom-nav__item {
  border: 0;
  background: transparent;
  color: #64748b;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.45rem 0.25rem;
  position: relative;
  transition: color 0.2s ease, transform 0.2s ease;
}

.app-bottom-nav__item i {
  font-size: 1.25rem;
}

.app-bottom-nav__item span {
  font-size: 0.68rem;
  font-weight: 600;
}

.app-bottom-nav__item.is-active {
  color: var(--app-accent);
}

.app-bottom-nav__item.is-active::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  border-radius: 999px;
  background: var(--app-accent);
}

.app-bottom-nav__item:active {
  transform: scale(0.96);
}

.app-bottom-nav__badge {
  position: absolute;
  top: 0.35rem;
  left: calc(50% + 6px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 16px;
}

@media (min-width: 992px) {
  .app-main {
    margin-right: var(--app-sidebar-width);
  }

  .app-sidebar--desktop {
    display: flex;
  }

  .app-topbar__menu-btn {
    display: none !important;
  }

  .app-bottom-nav {
    display: none;
  }

  body.app-shell {
    padding-bottom: 0;
  }

  .app-shell .go-to {
    bottom: 2rem !important;
  }
}

@media (max-width: 991.98px) {
  .app-sidebar--desktop {
    display: none;
  }

  body.app-shell {
    padding-bottom: calc(var(--app-bottom-nav-height) + env(safe-area-inset-bottom, 0) + 12px);
  }

  .app-shell .go-to {
    bottom: calc(var(--app-bottom-nav-height) + env(safe-area-inset-bottom, 0) + 12px) !important;
  }

  .app-shell footer.border-top {
    margin-bottom: 0.5rem;
  }

  .app-sidebar-offcanvas .sb-brand {
    display: none;
  }
}
