/* ==========================================================================
   App Shell — Sidebar, Header, Content Grid
   ========================================================================== */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar (desktop) ---------- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-ink);
  color: #E9ECE9;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: transform var(--t-base) var(--ease-standard);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar__brand-mark {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-md);
  color: #fff;
  flex-shrink: 0;
}
.sidebar__brand-mark svg { width: 20px; height: 20px; }

.sidebar__brand-text {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__brand-sub {
  font-size: var(--fs-xs);
  color: rgba(233,236,233,0.55);
}

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-3);
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-3);
  border-radius: var(--radius-md);
  color: rgba(233,236,233,0.78);
  font-size: var(--fs-base);
  font-weight: 500;
  margin-bottom: 2px;
  transition: background var(--t-fast) var(--ease-standard), color var(--t-fast) var(--ease-standard);
}

.sidebar__link:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
  text-decoration: none;
}

.sidebar__link.is-active {
  background: var(--color-primary);
  color: #fff;
}

.sidebar__link svg {
  width: 19px; height: 19px;
  flex-shrink: 0;
  opacity: 0.9;
}

.sidebar__footer {
  padding: var(--sp-4);
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: var(--fs-xs);
  color: rgba(233,236,233,0.45);
}

/* ---------- Mobile drawer overlay ---------- */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(14, 20, 17, 0.45);
  z-index: 39;
  opacity: 0;
  transition: opacity var(--t-base) var(--ease-standard);
}
.drawer-backdrop.is-open {
  display: block;
  opacity: 1;
}

/* ---------- Header ---------- */
.topheader {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
}

.topheader__left {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-width: 0;
}

.topheader__menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}
.topheader__menu-btn svg { width: 19px; height: 19px; }
.topheader__menu-btn:hover { background: var(--color-surface-sunken); }

.topheader__titles { min-width: 0; }

.topheader__title {
  font-size: var(--fs-lg);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--color-ink-faint);
  margin-top: 2px;
}
.breadcrumbs a { color: var(--color-ink-faint); }
.breadcrumbs a:hover { color: var(--color-primary); }

.topheader__right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-shrink: 0;
}

.icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-ink-soft);
  transition: background var(--t-fast) var(--ease-standard);
}
.icon-btn:hover { background: var(--color-surface-sunken); }
.icon-btn svg { width: 18px; height: 18px; }

.icon-btn__badge {
  position: absolute;
  top: -4px; right: -4px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--color-danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--color-surface);
}

.profile-menu-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px 10px 4px 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}
.profile-menu-btn:hover { background: var(--color-surface-sunken); }

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  border: 1px solid var(--color-accent-soft-border);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm);
  font-weight: 700;
  flex-shrink: 0;
}

.profile-menu-btn__name {
  font-size: var(--fs-sm);
  font-weight: 600;
  display: none;
}

/* ---------- Main content ---------- */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content {
  flex: 1;
  padding: var(--sp-6);
  max-width: var(--content-max);
  width: 100%;
}

.page-head {
  margin-bottom: var(--sp-6);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

.page-head__title {
  font-size: var(--fs-2xl);
  margin-bottom: var(--sp-1);
}

.page-head__desc {
  color: var(--color-ink-soft);
  font-size: var(--fs-base);
}

.page-head__actions {
  display: flex;
  gap: var(--sp-3);
  flex-shrink: 0;
}

/* ==========================================================================
   Responsive — tablet & mobile
   ========================================================================== */

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-float);
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .main {
    margin-left: 0;
  }
  .topheader__menu-btn {
    display: flex;
  }
  .profile-menu-btn__name {
    display: inline;
  }
}

@media (max-width: 640px) {
  .topheader {
    height: var(--header-height-mobile);
    padding: 0 var(--sp-4);
  }
  .content {
    padding: var(--sp-4);
  }
  .page-head {
    flex-direction: column;
  }
  .page-head__actions {
    width: 100%;
  }
  .page-head__actions .btn {
    flex: 1;
  }
  .profile-menu-btn__name { display: none; }
  .breadcrumbs { display: none; }
}
