/* ============================================================
 * main.css —— 全局基础 / 布局 / 导航
 * ============================================================ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e4e7ec;
  --border-light: #f0f2f5;
  --text: #101828;
  --text-2: #475467;
  --text-3: #98a2b3;
  --sidebar-bg: #111827;
  --sidebar-hover: #1f2937;
  --sidebar-text: #cbd5e1;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 48px rgba(16, 24, 40, .18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---------------- 应用骨架 ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 244px;
  flex: 0 0 244px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}
.brand {
  height: 68px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.brand-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}
.brand-logo svg { width: 21px; height: 21px; }
.brand-text strong { display: block; color: #fff; font-size: 15px; letter-spacing: .5px; }
.brand-text small { display: block; color: #7c8aa3; font-size: 10px; letter-spacing: 1.2px; margin-top: 1px; }

.nav { flex: 1; overflow-y: auto; padding: 14px 12px 24px; }
.nav::-webkit-scrollbar { width: 5px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }
.nav-group { margin-bottom: 20px; }
.nav-group-title {
  font-size: 11px; color: #6b7a94; text-transform: uppercase;
  letter-spacing: 1.4px; padding: 0 12px; margin-bottom: 8px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin-bottom: 3px;
  border-radius: 8px; cursor: pointer;
  color: var(--sidebar-text); font-size: 13.5px;
  transition: background .16s, color .16s;
  position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.nav-item .nav-icon svg { width: 17px; height: 17px; }
.nav-badge {
  margin-left: auto; background: #ef4444; color: #fff;
  font-size: 10px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.sidebar-footer {
  padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.07);
  font-size: 11px; color: #6b7a94; flex-shrink: 0;
}

/* ---------------- 主内容区 ---------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 68px; flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 12px; color: var(--text-2); font-size: 13px; }
.crumb-root { color: var(--text-3); }
.crumb-sep { color: #d0d5dd; }
.crumb-current { color: var(--text); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-date { color: var(--text-3); font-size: 12.5px; }
.icon-btn {
  width: 36px; height: 36px; border: 1px solid var(--border);
  background: #fff; border-radius: 9px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); position: relative; transition: .15s;
}
.icon-btn:hover { background: var(--primary-soft); border-color: #bfdbfe; color: var(--primary); }
.icon-btn svg { width: 18px; height: 18px; }
.notif-dot {
  position: absolute; top: 6px; right: 7px; width: 7px; height: 7px;
  background: #ef4444; border-radius: 50%; border: 1.5px solid #fff;
}
.user-chip {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 5px 10px 5px 5px; border-radius: 20px; border: 1px solid var(--border);
  background: #fff; transition: .15s;
}
.user-chip:hover { background: var(--bg); }
.user-meta { line-height: 1.25; }
.user-meta strong { font-size: 12.5px; display: block; }
.user-meta small { font-size: 10.5px; color: var(--text-3); }

.content { padding: 24px 28px 40px; flex: 1; }
.view-container { max-width: 1440px; margin: 0 auto; animation: viewIn .25s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------- 通用工具类 ---------------- */
.row { display: flex; gap: 16px; }
.col { flex: 1; min-width: 0; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-3); }
.ta-right { text-align: right; }
.ta-center { text-align: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* ---------------- 弹出菜单（用户/通知） ---------------- */
.popover {
  position: absolute; top: 58px; right: 28px;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  min-width: 240px; padding: 8px; z-index: 60;
}
.popover-title { font-size: 11px; color: var(--text-3); padding: 8px 10px 6px; letter-spacing: .5px; }
.popover-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 7px; cursor: pointer; font-size: 13px;
}
.popover-item:hover { background: var(--bg); }
.popover-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.popover-sep { height: 1px; background: var(--border-light); margin: 6px 0; }

/* ---------------- 用户下拉菜单（优化） ---------------- */
.popover.user-popover { width: 262px; padding: 10px; }
.user-popover svg { width: 15px; height: 15px; flex-shrink: 0; }
.up-header {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 4px 12px; border-bottom: 1px solid var(--border-light);
}
.up-header .avatar { width: 34px; height: 34px; font-size: 12px; }
.up-id { flex: 1; min-width: 0; line-height: 1.35; }
.up-id strong { display: block; font-size: 13px; color: var(--text); }
.up-id small { font-size: 10.5px; color: var(--text-3); }
.up-logout {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 9px; font-size: 12px; font-weight: 600;
  color: #d92d20; background: #fef3f2; border: 1px solid #fecdca;
  border-radius: 8px; cursor: pointer; transition: .15s;
}
.up-logout:hover { background: #fee4e2; border-color: #fda29b; }
.up-logout svg { width: 14px; height: 14px; }
.up-section {
  font-size: 10.5px; color: var(--text-3); letter-spacing: .6px;
  padding: 12px 5px 5px; font-weight: 600;
}
.up-users { display: flex; flex-direction: column; gap: 2px; max-height: 190px; overflow-y: auto; }
.up-user {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 8px; border: 0; border-radius: 8px; cursor: pointer;
  background: transparent; text-align: left; font-size: 12.5px; color: var(--text-2);
  transition: .12s;
}
.up-user .up-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.up-user span { flex: 1; text-align: left; }
.up-user small { font-size: 10.5px; color: var(--text-3); }
.up-user:hover { background: var(--bg); }
.up-user.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.up-user.active small { color: var(--primary); }
.up-tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 2px 2px; }
.up-tool {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 62px; padding: 8px 4px; border: 1px solid var(--border); border-radius: 9px;
  background: #fff; cursor: pointer; color: var(--text-2); transition: .15s;
}
.up-tool span { font-size: 11px; white-space: nowrap; }
.up-tool svg { width: 17px; height: 17px; color: var(--primary); }
.up-tool:hover { background: var(--primary-soft); border-color: #bfdbfe; color: var(--primary); }

.notif-item { padding: 10px; border-radius: 8px; cursor: pointer; }
.notif-item:hover { background: var(--bg); }
.notif-item strong { font-size: 12.5px; display: block; }
.notif-item small { color: var(--text-3); font-size: 11px; }

@media (max-width: 1024px) {
  .sidebar { width: 68px; flex-basis: 68px; }
  .brand-text, .nav-group-title, .nav-item span:not(.nav-icon), .nav-badge, .sidebar-footer { display: none; }
  .brand { justify-content: center; padding: 0; }
  .nav-item { justify-content: center; padding: 10px; }
  .content { padding: 20px; }
}
