/* ============================================================
   layout.css · 应用外壳：统一侧栏 / 主区 / 右侧面板
   结构：一个侧栏（品牌 + 模块切换 + 功能列表 + 用户）+ 主区 + 可选右面板
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr) 0px;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
}
.app.panel-open { grid-template-columns: var(--nav-w) minmax(0, 1fr) var(--panel-w); }
.app.nav-collapsed { grid-template-columns: 0px minmax(0, 1fr) 0px; }
.app.nav-collapsed.panel-open { grid-template-columns: 0px minmax(0, 1fr) var(--panel-w); }
.app.nav-collapsed .navbar { opacity: 0; pointer-events: none; }

/* ---------------- 侧栏 ---------------- */
.navbar {
  display: flex; flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  transition: opacity .18s var(--ease);
  overflow: hidden;
}

/* 品牌行 */
.nb-top {
  flex: none;
  height: 58px;
  display: flex; align-items: center; gap: 4px;
  padding: 0 10px 0 14px;
}
.nb-brand {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0;
  cursor: pointer;
  border-radius: var(--r-md);
  padding: 4px 6px 4px 0;
}
.nb-brand__mark {
  width: 32px; height: 32px; flex: none;
  border-radius: 9px;
  background: var(--ai-grad);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 16px; letter-spacing: -.02em;
  box-shadow: 0 3px 9px rgba(99, 102, 241, .28);
  user-select: none;
}
.nb-brand__text { min-width: 0; }
.nb-brand__name {
  display: block;
  font-size: var(--fs-15); font-weight: 700;
  letter-spacing: -.01em; color: var(--text); line-height: 1.2;
}
.nb-brand__sub {
  display: block;
  font-size: 11px; color: var(--text-4);
  letter-spacing: .04em; line-height: 1.3;
}

/* 模块切换 */
.nb-switch {
  flex: none;
  display: flex; gap: 3px;
  margin: 0 12px 12px;
  padding: 3px;
  background: var(--surface-3);
  border-radius: var(--r-md);
}
.nb-switch__item {
  flex: 1; min-width: 0;
  height: 30px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border-radius: var(--r-sm);
  font-size: var(--fs-12); font-weight: 400; color: var(--text-2);
  white-space: nowrap;
  transition: background .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
}
.nb-switch__item:hover { color: var(--text); }
.nb-switch__item.is-active {
  background: var(--surface); color: var(--brand-700);
  font-weight: 600; box-shadow: var(--sh-1);
}
.nb-switch__item .count { transform: scale(.85); margin-left: -1px; }

/* 用户行 */
.nb-user {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  transition: background .15s var(--ease);
}
.nb-user:hover { background: var(--surface-2); }
.nb-user__main { min-width: 0; flex: 1; }
.nb-user__name { font-size: var(--fs-13); font-weight: 600; color: var(--text); line-height: 1.3; }
.nb-user__sub { font-size: var(--fs-11); color: var(--text-4); }

/* 角标小圆点：不依赖任何容器的背景色 */
.dot-badge {
  position: absolute; top: 3px; right: 4px;
  width: 7px; height: 7px; border-radius: 50%;
  background: #f97316;
  border: 1.5px solid var(--surface);
  pointer-events: none;
}

.navbar__body { flex: 1; min-height: 0; padding: 0 12px 16px; }
.nb-foot { flex: none; padding: 0 12px 10px; }
.nb-foot:empty { display: none; }

/* ---------------- 功能列表 ---------------- */
/* 侧栏骨架样式见文件顶部；这里只放列表项本身 */

/* 分组标题 */
.nav-group { margin-bottom: 14px; }
.nav-group__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px 6px;
  font-size: var(--fs-11); font-weight: 600;
  color: var(--text-4);
}
.nav-group__head button { color: var(--text-4); border-radius: var(--r-xs); }
.nav-group__head button:hover { color: var(--brand-600); background: var(--brand-50); }

/* 列表项 */
.nav-item {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 8px 9px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background .14s var(--ease);
  position: relative;
}
.nav-item:hover { background: var(--surface-3); }
.nav-item.is-active { background: var(--brand-50); }
.nav-item.is-active .nav-item__title { color: var(--brand-700); font-weight: 600; }
.nav-item__ico {
  width: 28px; height: 28px; flex: none;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--text-3);
  margin-top: 1px;
}
.nav-item.is-active .nav-item__ico { background: #fff; color: var(--brand-600); box-shadow: var(--sh-1); }
.nav-item__main { min-width: 0; flex: 1; }
.nav-item__title { font-size: var(--fs-13); color: var(--text); line-height: 1.45; }
.nav-item__sub { font-size: var(--fs-11); color: var(--text-4); margin-top: 1px; }
.nav-item__meta { flex: none; display: flex; align-items: center; gap: 4px; margin-top: 3px; }

/* ---------------- 主区 ---------------- */
.main {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  background: var(--bg);
}
.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  z-index: 20;
}
.topbar__crumbs { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: var(--fs-13); color: var(--text-3); }
.topbar__crumbs b { color: var(--text); font-weight: 600; }
.topbar__crumbs .sep { color: var(--line-dark); }
.topbar__spacer { flex: 1; }

.viewport { flex: 1; min-height: 0; position: relative; }
/* 内容上限只是防止超宽屏上行长过长；给得宽松一些，避免大屏两侧空太多 */
/* 内容一律铺满可用宽度，只保留内边距作为留白。
   注意：不要给内容块加 max-width 再 margin:auto —— 那样不同页面会有不同的
   左右留白，看起来像"右侧空白来回变动"。 */
.viewport__inner { padding: 22px 24px 40px; }
.viewport__inner--flush { padding: 0; max-width: none; height: 100%; }

/* 页头 */
.page-head { margin-bottom: 20px; }
.page-head__title {
  font-size: var(--fs-24); font-weight: 700;
  letter-spacing: -.02em; line-height: 1.3;
  display: flex; align-items: center; gap: 10px;
}
.page-head__desc { color: var(--text-3); font-size: var(--fs-13); margin-top: 5px; }

/* ---------------- 右侧面板 ---------------- */
.sidepanel {
  display: flex; flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border-left: 1px solid var(--line);
  overflow: hidden;
  opacity: 0;
  transition: opacity .2s var(--ease);
}
.app.panel-open .sidepanel { opacity: 1; }
.sidepanel__head {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 0 10px 0 16px;
  border-bottom: 1px solid var(--line);
}
.sidepanel__title { font-size: var(--fs-14); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.sidepanel__body { flex: 1; min-height: 0; padding: 16px; }
.sidepanel__body--flush { padding: 0; }

/* ---------------- 空态 ---------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 56px 24px; color: var(--text-3);
  gap: 10px;
}
.empty__art {
  width: 76px; height: 76px; border-radius: 22px;
  background: var(--surface-3); display: grid; place-items: center;
  color: var(--text-4); margin-bottom: 4px;
}
.empty__title { font-size: var(--fs-15); font-weight: 600; color: var(--text-2); }
.empty__desc { font-size: var(--fs-13); max-width: 380px; }

/* ---------------- 响应式收敛 ---------------- */
@media (max-width: 1360px) {
  .app.panel-open { grid-template-columns: var(--nav-w) minmax(0, 1fr) 312px; }
}
@media (max-width: 1180px) {
  /* 窄屏优先保住主区：面板打开时收起侧栏 */
  .app.panel-open { grid-template-columns: 0px minmax(0, 1fr) var(--panel-w); }
  .app.panel-open .navbar { opacity: 0; pointer-events: none; }
}
