/* ============================================================
   Layout · 应用外壳 / 侧边栏 / 顶栏 / 页面容器
   方案 B：白侧栏 + 透明顶栏 + 大留白内容区
   ============================================================ */

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--c-bg);
}

/* ---------------- 侧边栏 ---------------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #FFFFFF;
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  transition: width var(--tr);
  z-index: 30;
}
.sidebar.is-collapsed { width: 68px; }

.brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  flex-shrink: 0;
  overflow: hidden;
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  background: var(--grad-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(109, 106, 240, .26);
}
.brand-logo {
  width: 32px; height: 32px;
  border-radius: var(--r-md);
  flex-shrink: 0;
  display: block;
  box-shadow: 0 4px 10px rgba(109, 106, 240, .22);
}
.brand-text { min-width: 0; }
.brand-title {
  font-size: var(--fs-md);
  font-weight: 650;
  letter-spacing: -.2px;
  white-space: nowrap;
  line-height: 1.25;
  color: var(--c-text);
}
.brand-title.brand-company {
  font-size: 13px;
  letter-spacing: -.2px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub {
  font-size: 11px;
  color: var(--c-text-3);
  white-space: nowrap;
  letter-spacing: .2px;
  line-height: 1.35;
}
.sidebar.is-collapsed .brand { padding: 0 18px; }
.sidebar.is-collapsed .brand-text { display: none; }

.nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 12px 16px;
}
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: #DFE4EF; border-radius: 999px; }
.nav-group { margin-top: 18px; }
.nav-group:first-child { margin-top: 4px; }
.nav-group-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .16em;
  color: #A3A9BC;
  padding: 0 10px 7px;
  text-transform: none;
  white-space: nowrap;
}
.sidebar.is-collapsed .nav-group-label { text-align: center; font-size: 9px; padding: 0 0 6px; letter-spacing: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--r-md);
  color: var(--c-text-2);
  font-size: 13.5px;
  cursor: pointer;
  transition: background var(--tr-fast), color var(--tr-fast);
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  margin-bottom: 2px;
}
.nav-item:hover { background: #F5F6FC; color: var(--c-text); }
.nav-item.is-active {
  background: var(--c-primary-soft);
  color: var(--c-primary);
  font-weight: 600;
}
.nav-item.is-active .nav-icon { color: var(--c-primary); }
.nav-item.is-active .nav-icon svg { stroke-width: 2; }
.nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #9AA0B4;
}
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  min-width: 18px; height: 18px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--c-primary-soft);
  color: var(--c-primary);
  font-size: 10px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.nav-badge.is-soft { background: var(--c-bg-deep); color: var(--c-text-2); }
.sidebar.is-collapsed .nav-label,
.sidebar.is-collapsed .nav-badge { display: none; }
.sidebar.is-collapsed .nav-item { justify-content: center; padding: 0; }

.sidebar-foot {
  padding: 8px 12px 12px;
  flex-shrink: 0;
}
.side-foot-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 32px; padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--c-text-3);
  white-space: nowrap; overflow: hidden;
}
.side-foot-btn:hover { background: #F5F6FC; color: var(--c-text-2); }
.sidebar.is-collapsed .side-foot-btn { justify-content: center; padding: 0; }
.sidebar.is-collapsed .side-foot-btn span { display: none; }

/* ---------------- 主区域 ---------------- */
.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  background: transparent;
  border-bottom: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px 0 14px;
  z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.crumb { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--c-text-3); min-width: 0; }
.crumb-sep { color: var(--c-text-4); }
.crumb-cur { color: var(--c-text); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-sep { width: 1px; height: 26px; background: var(--c-border-strong); margin: 0 4px; }

.icon-btn {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--c-text-2);
  transition: background var(--tr-fast), color var(--tr-fast);
  position: relative;
}
.icon-btn:hover { background: var(--c-bg-deep); color: var(--c-text); }
.icon-btn .dot {
  position: absolute; top: 5px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--c-danger);
  border: 1.5px solid #fff;
}

/* 顶栏右侧：胶囊搜索 + 圆形铃铛 */
.topbar-right > .icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--c-border);
  box-shadow: var(--sh-xs);
}
.topbar-right > .icon-btn:hover { background: #fff; color: var(--c-primary); border-color: var(--c-primary-line); }
.topbar-right > .icon-btn .dot { top: 6px; right: 8px; }

.tb-search {
  display: flex; align-items: center; gap: 9px;
  width: 300px; height: 38px;
  padding: 0 15px;
  border-radius: var(--r-pill);
  background: #F1F3F9;
  color: var(--c-text-3);
  font-size: 12.5px;
  text-align: left;
  transition: background var(--tr-fast), box-shadow var(--tr-fast);
}
.tb-search:hover { background: #EAEDF6; color: var(--c-text-2); }
.tb-search svg { color: #A9B2C4; flex-shrink: 0; }
.tb-search .tb-search-kbd {
  margin-left: auto;
  font-size: 10px; color: #AEB7C6;
  border: 1px solid #E3E7F0; background: #fff;
  border-radius: var(--r-pill);
  padding: 0 6px; line-height: 16px;
}

/* 身份切换器 */
.role-switch {
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 4px 0 0;
  border: none;
  border-radius: var(--r-pill);
  background: transparent;
  transition: opacity var(--tr-fast);
  max-width: 320px;
  flex-shrink: 0;
}
.role-switch:hover { background: transparent; box-shadow: none; opacity: .88; }
.avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--c-primary-soft2);
  color: var(--c-primary);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.avatar.is-lg { width: 44px; height: 44px; font-size: 16px; }
.role-switch .avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--grad-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(109, 106, 240, .24);
}
/* 身份块给足最小宽度：「行政人事专员」6 字不能被压成「行政人事专…」 */
.role-switch-txt { min-width: 128px; max-width: 196px; text-align: left; flex: 0 0 auto; }
.role-switch-name {
  font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--c-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.role-switch-role {
  font-size: 11px; color: var(--c-text-3); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------------- 页面容器 ---------------- */
.view-root {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 24px 48px;
  scroll-behavior: smooth;
}
.view-inner { max-width: var(--max-w); margin: 0 auto; }
.view-inner.is-narrow { max-width: 1080px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-title {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -.01em;
  line-height: 1.3;
  display: flex; align-items: center; gap: 10px;
  color: #0E1729;
}
.page-title .badge { transform: translateY(1px); }
.page-desc {
  font-size: 13px;
  color: var(--c-text-3);
  margin-top: 3px;
}
.page-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* 栅格 */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.grid-3-2 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

@media (max-width: 1400px) {
  .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-1, .grid-1-2, .grid-3-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4, .grid-5, .grid-6 { grid-template-columns: minmax(0, 1fr); }
  .view-root { padding: 16px; }
}

/* ---------------- 移动端（员工自助） ---------------- */
body.is-mobile .sidebar { display: none; }
body.is-mobile .topbar { display: none; }
body.is-mobile .view-root { padding: 0; background: var(--c-bg); }
.mobile-shell {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: #fff;
  box-shadow: 0 0 40px rgba(16, 24, 40, .08);
  padding-bottom: 64px;
  position: relative;
}
.mobile-hero {
  background: var(--grad-primary);
  color: #fff;
  padding: 20px 18px 26px;
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.mobile-body { padding: 16px 14px; }
.mobile-tabbar {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px;
  height: 58px;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--c-border);
  display: flex;
  z-index: 40;
}
.mobile-tab {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  font-size: 10px;
  color: var(--c-text-3);
}
.mobile-tab.is-active { color: var(--c-primary); font-weight: 600; }
