/* 企业知识库管理后台 —— 纯本地样式，无任何外部依赖 */
:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #1c2430;
  --muted: #667085;
  --line: #e4e8ef;
  --brand: #2f6bff;
  --brand-dark: #1f4fd8;
  --ok: #17915c;
  --warn: #b54708;
  --danger: #c4323a;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .05);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
}
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

.app { display: flex; min-height: 100vh; }

/* 侧栏 */
.sidebar {
  width: 220px; flex: 0 0 220px;
  background: #10192c; color: #e8edf7;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px; flex: 0 0 36px;
  background: linear-gradient(135deg, #4d8bff, #2f6bff);
  display: grid; place-items: center; font-weight: 700; letter-spacing: .5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 15px; }
.brand-text span { font-size: 12px; color: #94a3c4; }
.nav { padding: 10px 10px; flex: 1; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin: 2px 0; border: 0; border-radius: 8px;
  background: transparent; color: #c7d0e2; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-ico { width: 18px; text-align: center; font-size: 16px; opacity: .9; }
.sidebar-foot { padding: 14px 18px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.who { font-size: 12px; color: #a9b6d0; margin-bottom: 8px; word-break: break-all; }
.login-link { color: #8fb4ff; font-size: 12px; text-decoration: none; }
.login-link:hover { text-decoration: underline; }

/* 主区 */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; flex: 0 0 58px; background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
}
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.menu-btn { display: none; border: 0; background: transparent; font-size: 20px; padding: 4px 8px; }
.refresh-btn { border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 6px 12px; }
.refresh-btn:hover { border-color: var(--brand); color: var(--brand); }
.content { padding: 22px 24px 32px; flex: 1; }
.foot { padding: 14px 24px 22px; color: var(--muted); font-size: 12px; }

/* 提示条 */
.banner-wrap { padding: 12px 24px 0; }
.banner {
  border-radius: 8px; padding: 10px 14px; font-size: 13px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.banner.error { background: #fef3f2; color: var(--danger); border: 1px solid #fecdca; }
.banner.info { background: #eff8ff; color: #175cd3; border: 1px solid #b2ddff; }
.banner button { border: 0; background: transparent; font-size: 16px; line-height: 1; }

/* 卡片与网格 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px;
}
.card-label { color: var(--muted); font-size: 13px; }
.card-value { font-size: 30px; font-weight: 700; margin-top: 4px; letter-spacing: -.5px; }
.card-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card.accent .card-value { color: var(--brand); }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-top: 16px; overflow: hidden;
}
.panel-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-body { padding: 18px; }

/* 进度条 */
.progress { height: 12px; border-radius: 999px; background: #eceff5; overflow: hidden; margin: 12px 0 6px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #2f6bff, #55a5ff); border-radius: 999px; transition: width .3s; }
.progress.warn > span { background: linear-gradient(90deg, #f79009, #fdb022); }
.progress.danger > span { background: linear-gradient(90deg, #d92d20, #f97066); }
.progress-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select {
  border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px;
  background: #fff; width: 100%;
}
.field input:focus, .field select:focus { outline: 2px solid rgba(47,107,255,.25); border-color: var(--brand); }
.btn {
  border: 0; border-radius: 7px; padding: 8px 15px; background: var(--brand); color: #fff; font-weight: 600;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); font-weight: 400; }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #a52b32; }
.btn.tiny { padding: 4px 9px; font-size: 12px; font-weight: 400; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: #fafbfd; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbff; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.dim { color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; border: 1px solid transparent; }
.badge.active { color: var(--ok); background: #ecfdf3; border-color: #abefc6; }
.badge.disabled { color: var(--danger); background: #fef3f2; border-color: #fecdca; }
.badge.role { color: #175cd3; background: #eff8ff; border-color: #b2ddff; }
.badge.perm { color: #6941c6; background: #f4f3ff; border-color: #d9d6fe; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* 空间树 */
.tree { list-style: none; margin: 0; padding-left: 0; }
.tree ul { list-style: none; margin: 0; padding-left: 22px; border-left: 1px dashed var(--line); margin-left: 8px; }
.tree li { margin: 2px 0; }
.tree-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; }
.tree-row:hover { background: #f5f7fb; }
.tree-row.selected { background: #eaf1ff; }
.space-name { flex: 1; cursor: pointer; }
.space-id { font-size: 11px; color: var(--muted); }
.split { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 16px; align-items: start; }

.note {
  background: #fffaeb; border: 1px solid #fedf89; color: #7a4b06;
  padding: 10px 14px; border-radius: 8px; font-size: 12px; margin-bottom: 14px;
}
.note.info { background: #eff8ff; border-color: #b2ddff; color: #175cd3; }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 999;
  background: #10192c; color: #fff; padding: 10px 16px; border-radius: 8px;
  box-shadow: var(--shadow); font-size: 13px; max-width: 360px;
}

@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .menu-btn { display: block; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .split { grid-template-columns: 1fr; }
}
