/* ============================================================
   layout.css · 应用外壳：侧边栏 / 顶栏 / 内容区
   ============================================================ */

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width .18s ease, flex-basis .18s ease;
  overflow: hidden;
}
.app.collapsed .sidebar { width: var(--sidebar-w-min); flex-basis: var(--sidebar-w-min); }

.sidebar-brand {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-2);
  white-space: nowrap;
}
.sidebar-brand .logo {
  width: 28px; height: 28px; flex: 0 0 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--brand), #3b82f6);
  color: #fff; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-brand .name { font-weight: 600; font-size: 14px; }
.sidebar-brand .sub  { font-size: 11px; color: var(--muted); }
.app.collapsed .sidebar-brand .name,
.app.collapsed .sidebar-brand .sub { display: none; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px 20px;
}

.nav-group { margin-bottom: 6px; }
.nav-group-title {
  font-size: 11px;
  color: var(--muted);
  padding: 10px 10px 6px;
  letter-spacing: .4px;
  white-space: nowrap;
}
.app.collapsed .nav-group-title { opacity: 0; height: 8px; padding: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--panel-2); color: var(--text); }
.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 600;
}
.nav-item.active::before {
  content: "";
  position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--brand);
}
.nav-item .ico { width: 18px; flex: 0 0 18px; text-align: center; font-size: 14px; }
.nav-item .txt { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-item .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--warn); flex: 0 0 6px;
}
.app.collapsed .nav-item .txt,
.app.collapsed .nav-item .dot { display: none; }
.app.collapsed .nav-item { justify-content: center; padding: 9px 0; }

.sidebar-foot {
  flex: 0 0 auto;
  padding: 10px;
  border-top: 1px solid var(--border-2);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.app.collapsed .sidebar-foot { text-align: center; }

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

.topbar {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
}

.topbar .crumb { font-size: 13px; color: var(--muted); }
.topbar .crumb b { color: var(--text); font-weight: 600; }

.icon-btn {
  width: 32px; height: 32px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-2);
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
}
.user-chip:hover { background: var(--panel-2); }
.user-chip .avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--brand); color: #fff;
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.user-chip .uname { font-size: 12.5px; }
.user-chip .role { font-size: 11px; color: var(--muted); }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
}

/* ---------- 页面容器 ---------- */
.page { max-width: 1400px; margin: 0 auto; }

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-head .title { font-size: 18px; font-weight: 600; }
.page-head .desc  { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.section { margin-bottom: 18px; }

/* 栅格 */
.grid { display: grid; gap: 14px; }
.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)); }

@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ============================================================
   登录遮罩（session.js 动态创建）
   ============================================================ */
.login-mask {
  position: fixed; inset: 0; z-index: 900;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
  animation: fade-in .2s ease-out;
}
.login-box {
  width: 380px; max-width: calc(100vw - 32px);
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow-3);
  padding: 26px 26px 22px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.login-brand .logo {
  width: 42px; height: 42px; border-radius: 9px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600;
}
.login-brand .n { font-size: 16px; font-weight: 600; }
.login-brand .s { font-size: 12px; color: var(--muted); }

.login-tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 3px;
}
.login-tabs .lt {
  flex: 1; text-align: center; padding: 6px 0;
  font-size: 13px; color: var(--text-2);
  border-radius: 4px; cursor: pointer; user-select: none;
}
.login-tabs .lt.active {
  background: var(--panel); color: var(--brand-dark);
  font-weight: 600; box-shadow: var(--shadow-1);
}

.login-box .field { margin-bottom: 12px; }
.login-box .flabel { font-size: 12.5px; color: var(--text-2); margin-bottom: 4px; }
.login-box .btn.w-full { width: 100%; margin-top: 4px; }

.login-err {
  min-height: 18px; font-size: 12.5px; color: var(--danger);
  margin-bottom: 6px;
}
.login-hint {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--border-2);
  font-size: 12px; color: var(--muted); line-height: 1.8;
}
.login-hint code {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 3px; padding: 1px 5px; color: var(--brand-dark);
}
