/* ===== 设计令牌 ===== */
:root {
  --bg-body: #ffffff;
  --bg-subtle: #f8f9fb;
  --bg-hover: #f3f4f6;
  --bg-active: #e8f0fe;
  --bg-active-strong: #d7e5fd;

  --text-primary: #1f2328;
  --text-secondary: #5f6368;
  --text-muted: #8b8f96;
  --text-active: #1a63d8;

  --border: #ebedf0;
  --border-strong: #dfe2e7;

  --accent: #1a73e8;
  --accent-soft: #e8f0fe;
  --success: #12a150;
  --success-soft: #e6f6ec;
  --warning: #e08600;
  --warning-soft: #fdf3e2;
  --danger: #d93025;
  --danger-soft: #fdecea;
  --purple: #7c4dff;
  --purple-soft: #f0ebff;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --sidebar-w: 236px;
  --header-h: 60px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 2px 8px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 8px 28px rgba(16, 24, 40, 0.1);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-body);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

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

/* ===== 侧边栏 ===== */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--bg-body);
  border-right: 1px solid var(--border);
  padding: 16px 12px 20px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 16px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1a73e8, #5b8def);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  flex: 0 0 28px;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-title { font-size: 14px; font-weight: 600; }
.brand-sub { font-size: 11px; color: var(--text-muted); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  text-align: left;
  transition: background 0.14s ease, color 0.14s ease;
}

.nav-item:hover { background: var(--bg-hover); }

.nav-item.is-active {
  background: var(--bg-active);
  color: var(--text-active);
  font-weight: 500;
}

.nav-item.is-active .icon { stroke: var(--text-active); }

.nav-item .icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  stroke: var(--text-secondary);
  stroke-width: 1.6;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.14s ease;
}

.nav-item:hover .icon { stroke: var(--text-primary); }

.nav-item.is-active:hover .icon { stroke: var(--text-active); }

.nav-item .chevron {
  margin-left: auto;
  width: 14px;
  height: 14px;
  stroke: var(--text-muted);
  stroke-width: 1.8;
  fill: none;
}

.nav-item .nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 20px;
  padding: 1px 7px;
}

.nav-group-label {
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 10px;
  margin: 22px 0 6px;
  letter-spacing: 0.2px;
}

.nav-group-label:first-of-type { margin-top: 14px; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 18px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e8f0fe, #c7dbfa);
  color: var(--text-active);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  flex: 0 0 28px;
}

.user-chip-meta { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.user-chip-name { font-size: 13px; font-weight: 500; }
.user-chip-role { font-size: 11px; color: var(--text-muted); }

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

.topbar {
  height: var(--header-h);
  flex: 0 0 var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

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

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.content {
  padding: 26px 28px 56px;
  max-width: 1320px;
  width: 100%;
}

.view { display: none; }
.view.is-active { display: block; animation: fadeUp 0.22s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ===== 页面标题区 ===== */
.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}

.page-title { margin: 0 0 4px; font-size: 22px; font-weight: 650; letter-spacing: -0.2px; }
.page-desc { margin: 0; font-size: 13px; color: var(--text-secondary); }
.page-head-actions { margin-left: auto; display: flex; gap: 10px; flex: 0 0 auto; }

/* ===== 卡片 ===== */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-pad { padding: 20px; }

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head .sub { font-size: 12px; color: var(--text-muted); }
.card-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
  white-space: nowrap;
}

.btn:hover { background: var(--bg-hover); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(26, 115, 232, 0.24);
}

.btn-primary:hover { background: #1b66cf; border-color: #1b66cf; }

.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-danger { color: var(--danger); border-color: #f3c9c5; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); }

.btn .icon { width: 15px; height: 15px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ===== 表单控件 ===== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }

.input, .select, .textarea {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.6; }

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.12);
}

.input::placeholder, .textarea::placeholder { color: #a8adb5; }

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search .icon {
  position: absolute;
  left: 11px;
  width: 15px;
  height: 15px;
  stroke: var(--text-muted);
  stroke-width: 1.8;
  fill: none;
}

.search .input { padding-left: 34px; width: 240px; }

/* ===== 徽标 ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--bg-hover);
  color: var(--text-secondary);
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}

.badge.no-dot::before { display: none; }
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--accent-soft); color: var(--accent); }
.badge.purple { background: var(--purple-soft); color: var(--purple); }

/* ===== 表格 ===== */
.table-wrap { width: 100%; overflow-x: auto; }

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tbl th {
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--text-muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  white-space: nowrap;
}

.tbl td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: #fcfcfd; }
.tbl .num { font-variant-numeric: tabular-nums; }
.tbl .mono { font-family: var(--mono); font-size: 12px; color: var(--text-secondary); }
.tbl .right { text-align: right; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ===== 空态 ===== */
.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-muted);
}

/* ===== 提示条 ===== */
.notice {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: #17457f;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid #d5e4fb;
}

.notice .icon { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 2px; stroke: currentColor; stroke-width: 1.8; fill: none; }
.notice.warn { background: var(--warning-soft); color: #8a5600; border-color: #f6e0bb; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d8dbe0; border-radius: 10px; border: 3px solid #fff; }
::-webkit-scrollbar-thumb:hover { background: #c2c6cd; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== 响应式 ===== */
@media (max-width: 1024px) {
  :root { --sidebar-w: 200px; }
  .content { padding: 20px 18px 48px; }
}

@media (max-width: 780px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px;
  }
  .sidebar-footer { display: none; }
  .nav-group-label { margin-top: 14px; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px 16px 40px; }
  .page-head { flex-wrap: wrap; }
  .page-head-actions { margin-left: 0; width: 100%; }
}
