/* ===== 基础 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif;
  background: #f0f2f5;
  color: #1f2533;
  font-size: 14px;
}
a { text-decoration: none; color: inherit; }

/* ===== 后台布局 ===== */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px; flex-shrink: 0;
  background: #1f2533; color: #c7cdd9;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px; }
.sidebar-logo { font-size: 26px; }
.sidebar-title { color: #fff; font-weight: 600; font-size: 16px; }
.sidebar-desc { font-size: 12px; color: #8b93a7; }
.sidebar-nav { flex: 1; padding: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px; margin-bottom: 4px;
  color: #c7cdd9; transition: .15s;
}
.nav-item:hover { background: #2b3242; color: #fff; }
.nav-item.active { background: linear-gradient(135deg, #4f7cff, #6a5cff); color: #fff; }
.nav-icon { font-size: 16px; }
.sidebar-foot { padding: 14px; border-top: 1px solid #2b3242; }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: #2b3242; display: flex; align-items: center; justify-content: center; }
.u-name { color: #fff; font-size: 13px; }
.u-role { color: #8b93a7; font-size: 11px; }
.logout-btn { display: block; text-align: center; padding: 8px; border-radius: 8px; background: #2b3242; color: #c7cdd9; font-size: 13px; }
.logout-btn:hover { background: #3a4256; }

.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 26px; background: #fff; border-bottom: 1px solid #eef0f3;
}
.topbar h2 { font-size: 18px; }
.topbar-date { color: #8b93a7; font-size: 13px; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.search {
  border: 1px solid #e3e6ec; border-radius: 8px; padding: 8px 12px;
  width: 240px; outline: none; font-size: 13px;
}
.search:focus { border-color: #4f7cff; }
.content { padding: 24px 26px; }

/* ===== 统计卡片 ===== */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card {
  background: #fff; border-radius: 14px; padding: 18px;
  display: flex; align-items: center; gap: 14px; box-shadow: 0 4px 18px rgba(31,37,51,.04);
}
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.stat-num { font-size: 24px; font-weight: 700; }
.stat-label { color: #8b93a7; font-size: 13px; }

/* ===== 面板 / 网格 ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.panel { background: #fff; border-radius: 14px; padding: 18px; box-shadow: 0 4px 18px rgba(31,37,51,.04); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.panel-head h3 { font-size: 15px; }
.link { color: #4f7cff; font-size: 13px; }
.list { list-style: none; }
.list li { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px dashed #f0f2f5; }
.list li:last-child { border-bottom: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #4f7cff; }
.list-title { flex: 1; font-weight: 500; }
.list-meta { color: #8b93a7; font-size: 12px; }
.tag { background: #eef2ff; color: #4f7cff; padding: 3px 10px; border-radius: 20px; font-size: 12px; }
.empty { color: #b3b9c7; text-align: center; padding: 24px 0; }

/* ===== 表格 ===== */
.table-wrap { background: #fff; border-radius: 14px; padding: 6px 8px; box-shadow: 0 4px 18px rgba(31,37,51,.04); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 13px 14px; text-align: left; border-bottom: 1px solid #f3f4f7; }
.table th { color: #8b93a7; font-weight: 500; font-size: 13px; }
.table tr:last-child td { border-bottom: none; }
.t-right { text-align: right; }
.muted { color: #8b93a7; }

/* ===== 按钮 / 表单 ===== */
.btn {
  border: 1px solid #e3e6ec; background: #fff; color: #1f2533;
  padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; transition: .15s;
}
.btn:hover { border-color: #c7cdd9; }
.btn-primary { background: linear-gradient(135deg, #4f7cff, #6a5cff); color: #fff; border: none; }
.btn-primary:hover { opacity: .92; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger { color: #e5484d; border-color: #f3c2c4; }
.btn-danger:hover { background: #fdeced; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; margin-top: 8px; }
.mt-3 { margin-top: 14px; }

.field {
  width: 100%; border: 1px solid #e3e6ec; border-radius: 8px;
  padding: 9px 12px; margin: 6px 0 14px; font-size: 14px; outline: none; font-family: inherit;
}
.field:focus { border-color: #4f7cff; }
.form-pad { padding: 6px 4px; }
.form-pad label { font-size: 13px; color: #5b6478; }
.switch-row { display: flex; justify-content: space-between; align-items: center; margin: 10px 0; }
.rich-preview {
  background: #f8f9fc; border: 1px solid #eef0f3; border-radius: 8px;
  padding: 10px 12px; margin: 4px 0 8px; max-height: 200px; overflow: auto; font-size: 13px; line-height: 1.6;
}
.rich-preview p { margin: 0 0 6px; }
.rich-preview ul, .rich-preview ol { margin: 0 0 6px; padding-left: 20px; }
.rich-preview a { color: #4f7cff; text-decoration: underline; }

/* ===== 弹窗 ===== */
.modal {
  position: fixed; inset: 0; background: rgba(20,25,40,.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-box { background: #fff; border-radius: 14px; width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #f0f2f5; }
.modal-head h3 { font-size: 16px; }
.modal-close { cursor: pointer; color: #8b93a7; font-size: 18px; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.modal-body label { font-size: 13px; color: #5b6478; display: block; margin-top: 6px; }

/* 消息气泡（对话详情） */
.msg { padding: 10px 12px; border-radius: 10px; margin-bottom: 10px; max-width: 85%; }
.msg-role { font-size: 11px; color: #8b93a7; display: block; margin-bottom: 3px; }
.msg-user { background: #eef2ff; margin-left: auto; }
.msg-ai { background: #f2f4f8; }
.msg p { white-space: pre-wrap; line-height: 1.6; }
.msg-rate { display: inline-block; margin-top: 6px; font-size: 12px; padding: 2px 8px; border-radius: 10px; }
.rate-up { background: #e6f7ec; color: #1a9d54; }
.rate-down { background: #fdeaea; color: #d23b3b; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; top: 24px; transform: translateX(-50%);
  background: rgba(31,37,51,.9); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; opacity: 0; transition: opacity .2s; z-index: 100; pointer-events: none;
}

/* ===== 登录页 ===== */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #4f7cff, #6a5cff); }
.login-card { background: #fff; border-radius: 18px; padding: 38px 34px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.login-logo { font-size: 46px; text-align: center; }
.login-card h1 { text-align: center; font-size: 22px; margin-top: 6px; }
.login-sub { text-align: center; color: #8b93a7; margin-bottom: 22px; }
.login-form label { font-size: 13px; color: #5b6478; display: block; margin: 12px 0 6px; }
.login-form input {
  width: 100%; border: 1px solid #e3e6ec; border-radius: 9px; padding: 11px 13px; font-size: 14px; outline: none;
}
.login-form input:focus { border-color: #4f7cff; }
.login-tip { text-align: center; color: #b3b9c7; font-size: 12px; margin-top: 16px; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert-error { background: #fdeced; color: #e5484d; }

/* ===== 响应式 ===== */
@media (max-width: 860px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .sidebar { width: 64px; }
  .sidebar-title, .sidebar-desc, .nav-item span:last-child, .sidebar-user div, .logout-btn { display: none; }
  .nav-item { justify-content: center; }
  .search { width: 150px; }
}
