/* ==========================================================================
   应用外壳：侧边栏 / 顶栏 / 品牌区
   尺寸严格对齐设计稿：侧栏 240、顶栏 56、分割线 1
   ========================================================================== */

.app {
  position: relative;   /* 弹窗/抽屉的定位上下文 */
  display: flex;
  width: 100%;
  min-height: 100vh;
  background: var(--bg-page);
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: var(--w-sidebar);
  flex: none;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  padding: var(--s-8);
  gap: var(--s-1);
  overflow: hidden;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  padding: var(--s-2);
  width: 100%;
}

.sidebar__logo {
  width: 28px;
  height: 28px;
  border-radius: var(--r-btn);
  background: var(--primary);
  display: grid;
  place-items: center;
  flex: none;
}

.sidebar__logo svg {
  display: block;
}

.sidebar__brand-name {
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: var(--text-1);
  white-space: nowrap;
}

.sidebar__divider {
  height: 1px;
  background: var(--stroke-subtle);
  margin: var(--s-4) 0;
  flex: none;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

.sidebar__group-label {
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
  color: var(--text-4);
  padding: var(--s-5) var(--s-2) var(--s-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  height: 38px;
  padding: 0 var(--s-5);
  border-radius: var(--r-pill-lg);
  font-size: 14px;
  line-height: 20px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: var(--bg-muted);
}

.nav-item svg {
  flex: none;
  display: block;
}

.nav-item.is-active {
  background: var(--primary);
  color: var(--text-invert);
  font-weight: 500;
  box-shadow: 0 4px 12px -4px rgba(99, 91, 255, .45);
}

.nav-item.is-active:hover {
  background: var(--primary);
}

.sidebar__spacer {
  flex: 1;
  min-height: 0;
}

.sidebar__foot {
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.sidebar__foot p {
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-4);
}

.sidebar__foot p:last-child {
  color: var(--text-5);
}

/* ---------- 主列 ---------- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
}

/* ---------- 顶栏 ---------- */
.topbar {
  height: var(--h-topbar);
  flex: none;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-8);
  padding: 0 var(--s-10);
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  min-width: 0;
}

.topbar__crumb {
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  color: var(--text-1);
  white-space: nowrap;
}

.topbar__sync {
  font-size: 13px;
  line-height: 20px;
  color: var(--text-3);
  white-space: nowrap;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: var(--s-6);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-muted);
}

.icon-btn__dot {
  position: absolute;
  top: 7px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid var(--bg-surface);
}

.avatar {
  width: 32px;
  height: 32px;
  flex: none;          /* 不加会被 flex 容器压缩变形（挤成椭圆/换行） */
  border-radius: 50%;
  background: var(--primary);
  color: var(--text-invert);
  display: grid;
  place-items: center;
  font-family: var(--font-num);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
}

.topbar__user {
  font-size: 13px;
  line-height: 20px;
  color: var(--text-2);
  white-space: nowrap;
}

/* ---------- 搜索框 ---------- */
.search {
  width: 320px;
  height: 36px;
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 0 var(--s-5);
  border-radius: var(--r-pill);
  background: var(--bg-muted);
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

/* 聚焦时浮起：底色变白 + 主色描边，明确告诉用户「输入生效中」 */
.search:focus-within {
  background: var(--bg-surface);
  border-color: var(--primary);
  box-shadow: var(--sh-focus);
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-family: var(--font-cn);
  font-size: 13px;
  line-height: 16px;
  color: var(--text-1);
}

.search input::placeholder {
  color: var(--text-4);
}

/* ---------- 内容区 ---------- */
.content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-9);
  padding: var(--s-10);
  overflow: hidden;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-8);
  flex: none;
}

.page-header__title {
  font-size: var(--fs-h1);
  line-height: var(--lh-h1);
  letter-spacing: var(--ls-h1);
  font-weight: 500;
  color: var(--text-1);
}

.page-header__sub {
  margin: var(--s-2) 0 0;
  font-size: 13px;
  line-height: 20px;
  color: var(--text-3);
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  flex: none;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: var(--h-control);
  padding: 0 var(--sp-4);
  border: 1px solid var(--stroke-default);
  border-radius: var(--r-btn);
  background: var(--bg-surface);
  color: var(--text-2);
  font-family: inherit;
  font-size: var(--fs-body);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--bg-hover); border-color: var(--stroke-strong); }

.btn--ghost {
  background: var(--bg-surface);
  border-color: var(--stroke-subtle);
  color: var(--text-1);
}

.btn--ghost:hover {
  border-color: var(--stroke-strong);
}

.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 500;
}
.btn--primary:hover { background: var(--primary-press); border-color: var(--primary-press); }

.btn--primary:hover {
  background: var(--primary-ink);
}

.btn--select {
  background: var(--bg-surface);
  border-color: var(--stroke-subtle);
  color: var(--text-1);
  justify-content: space-between;
  width: 150px;
}

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  background: var(--bg-subtle);
  color: var(--text-2);
}

.btn--icon:hover {
  background: var(--bg-muted);
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg-surface);
  border-radius: var(--r-card);
  box-shadow: var(--sh-card);
}

.card--pad {
  padding: var(--s-8);
}

/* ---------- 分段控件 / Chip ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 32px;
  padding: 0 var(--s-5);
  border-radius: var(--r-pill);
  font-size: 12px;
  line-height: 16px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chip--primary {
  background: var(--primary);
  color: var(--text-invert);
  font-weight: 500;
}

.chip--ghost {
  background: var(--bg-surface);
  border-color: var(--stroke-subtle);
  color: var(--text-2);
}

.chip--ghost:hover {
  border-color: var(--stroke-strong);
}

.chip--sm {
  height: auto;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-chip);
  font-size: 11px;
  font-weight: 500;
}

/* 语义徽标 */
.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--r-chip);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  font-weight: 500;
  white-space: nowrap;
}

.badge--sm { height: 20px; padding: 0 7px; font-size: var(--fs-xs); }

.badge--success { background: var(--bg-teal-weak); color: var(--success-deep); }
.badge--warning { background: var(--bg-amber-weak); color: var(--warning-deep); }
.badge--danger  { background: var(--bg-red-weak); color: var(--danger-deep); }
.badge--primary { background: var(--bg-violet-weak); color: var(--primary-ink); }
.badge--neutral { background: var(--bg-muted); color: var(--text-2); }
.badge--muted   { background: var(--bg-subtle); color: var(--text-2); }

/* ---------- 卡片标题 ---------- */
.card-title {
  font-size: var(--fs-h3);
  line-height: var(--lh-h3);
  font-weight: 500;
  color: var(--text-1);
}

.card-title--sm {
  font-size: 15px;
  line-height: 20px;
}

.card-link {
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
}

.card-link:hover {
  text-decoration: underline;
}