/* ============================================================
   AICOR 知识库平台 · 统一样式
   设计系统：藏蓝品牌色 + 浅色专业后台 + 圆角卡片
   ============================================================ */
:root {
  --brand: #16324f;          /* AICOR 藏蓝 */
  --brand-2: #1e3a5f;
  --brand-3: #2f6fae;        /* 强调蓝 */
  --accent: #2f6fae;
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e3e8f0;
  --text: #1a2333;
  --text-2: #5a6b82;
  --text-3: #8a97ab;
  --green: #1f9d62;
  --green-bg: #e6f6ee;
  --amber: #c98a1b;
  --amber-bg: #fdf3e0;
  --red: #d64545;
  --red-bg: #fdeaea;
  --blue-bg: #e8f1fa;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(22, 50, 79, .08), 0 4px 14px rgba(22, 50, 79, .06);
  --shadow-lg: 0 8px 30px rgba(22, 50, 79, .16);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-3); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); font-size: 14px; }

/* ============ 布局 ============ */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 232px; min-width: 232px;
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  color: #fff;
  display: flex; flex-direction: column;
}
.brand { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-logo { font-size: 22px; font-weight: 800; letter-spacing: 1px; }
.brand-logo span { color: #7fb3e8; }
.brand-sub { font-size: 11px; color: rgba(255,255,255,.55); margin-top: 4px; }

.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; margin-bottom: 4px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.78);
  cursor: pointer;
  transition: background .15s, color .15s;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--brand-3); color: #fff; font-weight: 600; }
.nav-ico { width: 20px; text-align: center; font-size: 15px; }
.nav-sep { height: 1px; background: rgba(255,255,255,.12); margin: 10px 8px; }

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.12); }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand-3); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
}
.user-name { font-size: 14px; font-weight: 600; }
.user-role { font-size: 11px; color: rgba(255,255,255,.55); }
.btn-logout {
  width: 100%; padding: 8px; border: 1px solid rgba(255,255,255,.25);
  background: transparent; color: rgba(255,255,255,.85);
  border-radius: var(--radius-sm); font-size: 13px;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.1); }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 58px; min-height: 58px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
}
.page-title { font-size: 17px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.view { flex: 1; overflow-y: auto; padding: 22px 24px 40px; display: none; }
.view.active { display: block; }

/* ============ 通用组件 ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-title .sub { font-size: 12px; color: var(--text-3); font-weight: 400; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--card);
  color: var(--text); font-size: 13px; font-weight: 500;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--brand-3); color: var(--brand-3); }
.btn-primary { background: var(--brand-3); border-color: var(--brand-3); color: #fff; }
.btn-primary:hover { background: #2a6399; color: #fff; }
.btn-danger { color: var(--red); border-color: #f0c9c9; }
.btn-danger:hover { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.input, .select, .textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-3);
  box-shadow: 0 0 0 3px rgba(47,111,174,.12);
}
.textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.label { display: block; font-size: 12px; color: var(--text-2); margin: 12px 0 6px; font-weight: 600; }
.label:first-child { margin-top: 0; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1.6;
}
.badge-blue { background: var(--blue-bg); color: var(--brand-3); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-gray { background: #eef1f5; color: var(--text-2); }
.badge-red { background: var(--red-bg); color: var(--red); }

.empty {
  text-align: center; color: var(--text-3);
  padding: 48px 0; font-size: 13px;
}
.empty .big { font-size: 34px; margin-bottom: 10px; }

.spinner {
  width: 26px; height: 26px; margin: 40px auto;
  border: 3px solid var(--border); border-top-color: var(--brand-3);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 模态框 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 28, 45, .45);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 100; padding: 40px 20px; overflow-y: auto;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--card); border-radius: 14px;
  width: 100%; max-width: 720px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s ease-out;
}
.modal-lg { max-width: 920px; }
.modal-sm { max-width: 440px; }
@keyframes modalIn { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; }
.modal-x { border: none; background: none; font-size: 20px; color: var(--text-3); cursor: pointer; line-height: 1; }
.modal-x:hover { color: var(--red); }
.modal-body { padding: 20px 22px; max-height: 62vh; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px; border-top: 1px solid var(--border);
}

/* ============ Toast ============ */
#toast-root { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--brand-2); color: #fff; font-size: 13px;
  box-shadow: var(--shadow-lg); animation: toastIn .2s ease-out;
  max-width: 340px;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.warn { background: var(--amber); }
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ 驾驶舱 ============ */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 14px; margin-bottom: 4px;
}
.kpi-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--brand-3);
}
.kpi-card.warn::before { background: var(--amber); }
.kpi-card.ok::before { background: var(--green); }
.kpi-name { font-size: 12px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 26px; font-weight: 800; margin: 8px 0 2px; letter-spacing: -.5px; }
.kpi-value .unit { font-size: 13px; font-weight: 500; color: var(--text-2); margin-left: 3px; }
.kpi-meta { font-size: 11px; color: var(--text-3); }
.kpi-rate { position: absolute; right: 14px; top: 14px; text-align: center; }
.ring { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #eef1f5; stroke-width: 4; }
.ring-fg { fill: none; stroke: var(--brand-3); stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset .6s; }
.ring-text { position: absolute; }
.ring-wrap { position: relative; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.ring-num { position: absolute; font-size: 10px; font-weight: 700; color: var(--text-2); }

.chart-wrap { position: relative; height: 320px; }
.chart-tip {
  position: absolute; background: var(--brand-2); color: #fff;
  padding: 6px 10px; border-radius: 6px; font-size: 12px;
  pointer-events: none; display: none; z-index: 5; white-space: nowrap;
}
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.seg {
  display: inline-flex; background: #eef1f5; border-radius: var(--radius-sm); padding: 3px;
  gap: 2px;
}
.seg button {
  border: none; background: transparent; padding: 6px 13px;
  border-radius: 6px; font-size: 12px; color: var(--text-2); font-weight: 600;
  transition: all .15s;
}
.seg button.active { background: var(--card); color: var(--brand-3); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }

/* ============ 表格 ============ */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 10px 12px; background: #f7f9fc;
  color: var(--text-2); font-size: 12px; font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid #f0f3f8; vertical-align: middle; }
.table tr:hover td { background: #fafbfd; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ============ 知识库 ============ */
.kb-layout { display: flex; gap: 18px; }
.kb-cats { width: 218px; min-width: 218px; }
.kb-cat {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-2); font-size: 13px; margin-bottom: 2px;
  transition: all .12s;
}
.kb-cat:hover { background: #eef2f8; color: var(--text); }
.kb-cat.active { background: var(--blue-bg); color: var(--brand-3); font-weight: 600; }
.kb-cat .cnt { font-size: 11px; background: #eef1f5; border-radius: 999px; padding: 1px 8px; }
.kb-cat.active .cnt { background: var(--brand-3); color: #fff; }
.kb-main { flex: 1; min-width: 0; }

.kb-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.kb-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform .12s, box-shadow .12s, border-color .12s;
  display: flex; flex-direction: column; gap: 8px;
}
.kb-item:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: #c9d8ea; }
.kb-item h4 { font-size: 14px; line-height: 1.45; }
.kb-item .sum { font-size: 12px; color: var(--text-2); line-height: 1.6; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.kb-item .meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-3); flex-wrap: wrap; }
.kb-item .ops { display: none; gap: 6px; }
.kb-item:hover .ops { display: flex; }

.kb-detail { line-height: 1.8; font-size: 13.5px; }
.kb-detail h1, .kb-detail h2, .kb-detail h3, .kb-detail h4 { margin: 18px 0 10px; line-height: 1.4; }
.kb-detail h1 { font-size: 18px; } .kb-detail h2 { font-size: 16px; } .kb-detail h3 { font-size: 15px; } .kb-detail h4 { font-size: 14px; }
.kb-detail p { margin: 8px 0; }
.kb-detail ul, .kb-detail ol { margin: 8px 0 8px 22px; }
.kb-detail li { margin: 4px 0; }
.kb-detail table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; }
.kb-detail th, .kb-detail td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.kb-detail th { background: #f7f9fc; font-weight: 600; }
.kb-detail img { max-width: 100%; border-radius: 8px; }
.kb-detail blockquote { border-left: 3px solid var(--brand-3); padding: 8px 14px; background: var(--blue-bg); border-radius: 0 8px 8px 0; margin: 10px 0; color: var(--text-2); }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 20px; }
.pager .info { font-size: 12px; color: var(--text-3); }

/* ============ 文件区 ============ */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 26px; text-align: center; color: var(--text-3);
  cursor: pointer; transition: all .15s; background: #fbfcfe;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--brand-3); background: var(--blue-bg); color: var(--brand-3); }
.upload-zone .big { font-size: 30px; margin-bottom: 8px; }
.file-row { display: flex; align-items: center; gap: 14px; }
.file-ico {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: var(--blue-bg);
}
.file-name { font-weight: 600; font-size: 13px; word-break: break-all; }
.file-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ============ 团队 ============ */
.dept-block { margin-bottom: 20px; }
.dept-head {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 700; margin-bottom: 12px;
}
.dept-head .cnt { font-size: 12px; color: var(--text-3); font-weight: 400; }
.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.staff-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; gap: 12px; box-shadow: var(--shadow);
}
.staff-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue-bg); color: var(--brand-3);
  font-size: 16px; font-weight: 700;
}
.staff-avatar.ai { background: linear-gradient(135deg, #e8eef7, #d5e4f5); }
.staff-info { min-width: 0; flex: 1; }
.staff-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.staff-pos { font-size: 12px; color: var(--brand-3); margin: 3px 0; }
.staff-duty { font-size: 12px; color: var(--text-2); line-height: 1.6; }

.report-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.report-author { font-weight: 700; font-size: 13px; }
.report-period { font-size: 12px; color: var(--text-3); }
.report-body { font-size: 13px; color: var(--text); line-height: 1.7; }
.report-body .fld { margin-top: 8px; }
.report-body .fld b { color: var(--brand-3); font-size: 12px; margin-right: 6px; }

.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; text-align: center;
  box-shadow: var(--shadow);
}
.stat-box .n { font-size: 24px; font-weight: 800; color: var(--brand-3); }
.stat-box .t { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ============ 登录页 ============ */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #16324f 0%, #1e3a5f 55%, #2f6fae 130%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 400px; background: var(--card);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 38px 36px 32px;
}
.login-logo { text-align: center; margin-bottom: 6px; }
.login-logo .name { font-size: 26px; font-weight: 800; color: var(--brand); letter-spacing: 1px; }
.login-logo .name span { color: var(--brand-3); }
.login-logo .sub { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.login-title { text-align: center; font-size: 15px; font-weight: 700; margin: 18px 0 22px; color: var(--text); }
.login-err {
  background: var(--red-bg); color: var(--red); font-size: 12px;
  padding: 9px 12px; border-radius: var(--radius-sm); margin-bottom: 14px; display: none;
}
.login-foot { text-align: center; font-size: 11px; color: var(--text-3); margin-top: 22px; line-height: 1.7; }

/* ============ 响应式 ============ */
@media (max-width: 960px) {
  .sidebar { width: 64px; min-width: 64px; }
  .brand-sub, .nav-item span:not(.nav-ico), .user-chip > div:last-child, .btn-logout { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .kb-layout { flex-direction: column; }
  .kb-cats { width: 100%; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px; }
  .kb-cat { margin-bottom: 0; }
}
