:root {
  --brand-blue: #2F7CF6;
  --brand-purple: #7C5CFC;
  --ink: #1f2937;
  --ink-2: #4b5563;
  --bg: #f5f7fb;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  margin: 0;
}

/* ---------- 布局 ---------- */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: #151e2d;
  color: #cbd5e1;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 14px;
}
.sidebar .brand .logo-badge {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-purple));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px;
}
.sidebar .brand b { color: #fff; font-size: 16px; display: block; line-height: 1.2; }
.sidebar .brand small { font-size: 11px; color: #94a3b8; }

.sidebar .menu-group {
  font-size: 11px; color: #64748b; letter-spacing: .5px;
  padding: 14px 14px 4px; text-transform: uppercase;
}
.sidebar .menu a {
  display: flex; align-items: center; gap: 10px;
  color: #cbd5e1; text-decoration: none;
  padding: 9px 14px; border-radius: 10px; font-size: 14px;
  transition: background .15s;
  margin-bottom: 2px;
}
.sidebar .menu a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .menu a.active {
  background: var(--brand-blue); color: #fff; font-weight: 600;
}

.sidebar .side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }

/* 菜单区：占满侧边栏剩余空间，超出时侧边栏内滚动，保证黑色背景始终覆盖全部菜单 */
.sidebar .menu {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.18) transparent;
}
.sidebar .menu::-webkit-scrollbar { width: 5px; }
.sidebar .menu::-webkit-scrollbar-track { background: transparent; }
.sidebar .menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }
.sidebar .menu::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.3); }
.sidebar .side-foot .user {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px;
}
.sidebar .side-foot .user .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #12B886, #2F7CF6);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.sidebar .side-foot .user .name { font-size: 13px; color: #e2e8f0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .side-foot .user .role { font-size: 11px; color: #94a3b8; }
.sidebar .side-foot .logout {
  display: block; text-align: center; margin-top: 10px;
  color: #94a3b8; text-decoration: none; font-size: 13px;
  padding: 8px; border-radius: 8px; border: 1px solid rgba(255,255,255,.12);
  transition: all .15s;
}
.sidebar .side-foot .logout:hover { color: #fca5a5; border-color: #f87171; background: rgba(248,113,113,.08); }

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: #fff;
  border-bottom: 1px solid #eef1f6;
  padding: 0 28px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .page-title { font-size: 18px; font-weight: 700; }
.topbar .top-actions { display: flex; align-items: center; gap: 12px; }
.topbar .site-link { color: var(--ink-2); text-decoration: none; font-size: 13px; }
.topbar .site-link:hover { color: var(--brand-blue); }

.content { padding: 24px 28px; }

/* ---------- 指标卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border-radius: 14px; padding: 20px; border: 1px solid #eef1f6;
  box-shadow: 0 2px 10px rgba(31,41,55,.04);
}
.stat-card .label { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.stat-card .value { font-size: 26px; font-weight: 800; }
.stat-card .value small { font-size: 14px; font-weight: 600; color: var(--ink-3); }

/* ---------- 面板 ---------- */
.panel {
  background: #fff; border-radius: 14px; border: 1px solid #eef1f6;
  padding: 20px; margin-bottom: 24px;
}
.panel .panel-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.panel .panel-title { font-size: 16px; font-weight: 700; }

/* ---------- 表格 ---------- */
.table > :not(caption) > * > * { padding: 12px 14px; vertical-align: middle; }
.table thead th { background: #f8fafc; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.table tbody td { font-size: 14px; }
.table tbody tr:hover { background: #fafbfd; }

/* ---------- 徽章 ---------- */
.badge-soft { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.badge-soft.blue { background: #eef3ff; color: #2F7CF6; }
.badge-soft.green { background: #e6f7f1; color: #12B886; }
.badge-soft.purple { background: #f3f0ff; color: #7C5CFC; }
.badge-soft.orange { background: #fff4e6; color: #FF9F43; }
.badge-soft.red { background: #fdeaea; color: #e03131; }
.badge-soft.gray { background: #f1f3f8; color: #64748b; }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #2F7CF6 0%, #7C5CFC 100%);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  background: #fff; border-radius: 18px; width: 100%; max-width: 400px;
  padding: 36px 34px; box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
}
.login-card .brand { text-align: center; margin-bottom: 26px; }
.login-card .brand .logo-badge {
  width: 60px; height: 60px; border-radius: 16px;
  background: linear-gradient(135deg, #2F7CF6, #7C5CFC);
  color: #fff; font-size: 30px;
  display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.login-card .brand h4 { font-weight: 800; margin-bottom: 4px; }
.login-card .brand p { color: var(--ink-3); font-size: 13px; margin-bottom: 0; }

/* ---------- 通用 ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.quick-item {
  background: #fff; border: 1px solid #eef1f6; border-radius: 12px;
  padding: 16px; text-align: center; text-decoration: none; color: var(--ink);
  transition: transform .15s, box-shadow .15s; display: block;
}
.quick-item:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(31,41,55,.08); color: var(--ink); }
.quick-item .qi { font-size: 24px; margin-bottom: 8px; display: block; }
.quick-item .qn { font-size: 13px; font-weight: 600; }

.audit-card { display: flex; align-items: center; gap: 14px; }
.audit-card .ai { width: 42px; height: 42px; border-radius: 12px; background: #f3f0ff; color: #7C5CFC; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.audit-card .ab { flex: 1; min-width: 0; }
.audit-card .ab .at { font-weight: 600; font-size: 14px; }
.audit-card .ab .am { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.empty { text-align: center; color: var(--ink-3); padding: 36px 0; }
.empty i { font-size: 40px; display: block; margin-bottom: 10px; }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  overflow-y: auto; /* 内容超高时遮罩可滚动 */
}
.modal-box {
  background: #fff; border-radius: 16px; width: 100%; max-width: 460px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .3);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 40px); /* 限制最大高度，超高由内容区滚动 */
}
.modal-box .modal-title {
  font-size: 16px; font-weight: 700; padding: 18px 22px 0;
  flex-shrink: 0;
}
.modal-box .modal-body { padding: 14px 22px 6px; font-size: 14px; color: var(--ink-2); flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.modal-box .modal-foot { flex-shrink: 0; }
.modal-box .modal-foot {
  display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px;
}
.modal-box .modal-body .form-label { font-weight: 600; color: var(--ink); }

/* ---------- 图片上传字段 ---------- */
.img-upload { display: flex; gap: 12px; }
.img-upload-preview {
  width: 84px; height: 84px; border-radius: 10px; overflow: hidden; flex-shrink: 0;
  background: #f1f3f5; display: flex; align-items: center; justify-content: center;
}
.img-upload-preview .img-preview { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-upload-preview .img-placeholder { font-size: 12px; color: #adb5bd; text-align: center; line-height: 1.4; }
.img-upload-preview .img-placeholder i { font-size: 20px; display: block; margin-bottom: 4px; }
.img-upload-actions { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.img-upload-actions .form-control { width: 100%; }
.img-upload-actions small { font-size: 12px; color: #868e96; }
.img-upload-btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- 媒体库选择 ---------- */
.media-lib-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.media-lib-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px; max-height: 46vh; overflow-y: auto; padding: 2px;
}
.media-lib-item {
  border: 1px solid #eef1f6; border-radius: 10px; overflow: hidden; cursor: pointer;
  background: #f8fafc; transition: border-color .15s, box-shadow .15s;
}
.media-lib-item:hover { border-color: #2f7cf6; box-shadow: 0 4px 14px rgba(47, 124, 246, .18); }
.media-lib-item img { width: 100%; height: 86px; object-fit: cover; display: block; background: #fff; }
.media-lib-name {
  font-size: 10px; color: #868e96; padding: 4px 6px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* ---------- 订单详情 ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.detail-item { background: #f8fafc; border-radius: 10px; padding: 12px 14px; }
.detail-item .dk { font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.detail-item .dv { font-size: 14px; font-weight: 600; word-break: break-all; }

/* ---------- 轮播图 ---------- */
.banner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.banner-card { border: 1px solid #eef1f6; border-radius: 14px; overflow: hidden; background: #fff; }
.banner-card .banner-img { height: 150px; background: #f8fafc; overflow: hidden; }
.banner-card .banner-img img { width: 100%; height: 100%; object-fit: cover; }
.banner-card .banner-img .banner-ph { height: 100%; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 13px; }
.banner-card .banner-body { padding: 14px 16px; }
.banner-card .banner-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.banner-card .banner-meta { font-size: 12px; color: var(--ink-2); margin-bottom: 10px; }
.banner-card .banner-meta div { margin-bottom: 2px; }
.banner-card .banner-ops { display: flex; }

/* ---------- 会话列表 ---------- */
.chat-layout { display: flex; gap: 18px; height: calc(100vh - 110px); min-height: 480px; }
.chat-list-panel {
  width: 320px; flex-shrink: 0; background: #fff; border-radius: 14px;
  border: 1px solid #eef1f6; display: flex; flex-direction: column; overflow: hidden;
}
.chat-tabs { display: flex; gap: 6px; padding: 14px 14px 10px; border-bottom: 1px solid #f1f3f8; flex-wrap: wrap; }
.chat-tabs .btn { font-size: 13px; }
#sessionList { flex: 1; overflow-y: auto; padding: 10px; }
.session-item {
  padding: 12px 14px; border-radius: 12px; cursor: pointer; margin-bottom: 6px;
  border: 1px solid transparent; transition: background .15s;
}
.session-item:hover { background: #f8fafc; }
.session-item.active { background: #eef3ff; border-color: #d6e4ff; }
.session-item .si-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.session-item .si-name { font-weight: 600; font-size: 14px; }
.session-item .si-meta { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-item .si-time { font-size: 11px; color: #94a3b8; margin-top: 4px; }

.chat-detail-panel {
  flex: 1; min-width: 0; background: #fff; border-radius: 14px;
  border: 1px solid #eef1f6; display: flex; flex-direction: column; overflow: hidden;
}
.chat-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid #f1f3f8;
}
.chat-user { font-weight: 700; font-size: 15px; }
.chat-info { padding: 10px 20px; font-size: 12px; color: var(--ink-2); border-bottom: 1px solid #f1f3f8; background: #fafbfd; }
.chat-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.chat-input { display: flex; gap: 10px; padding: 14px 20px; border-top: 1px solid #f1f3f8; }
.chat-input input { flex: 1; }

/* ---------- 会话消息 ---------- */
.chat-msg { display: flex; margin-bottom: 14px; }
.chat-msg.user { justify-content: flex-start; }
.chat-msg.manager { justify-content: flex-end; }
.chat-msg .bubble {
  max-width: 70%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.6;
}
.chat-msg.user .bubble { background: #f1f3f8; color: var(--ink); border-top-left-radius: 4px; }
.chat-msg.manager .bubble { background: var(--brand-blue); color: #fff; border-top-right-radius: 4px; }
.chat-msg .tm { font-size: 11px; color: #94a3b8; margin-top: 4px; }

@media (max-width: 900px) {
  .sidebar { width: 64px; padding: 16px 8px; }
  .sidebar .brand b, .sidebar .brand small { display: none; }
  .sidebar .menu-group { display: none; }
  .sidebar .menu a span, .sidebar .side-foot .user .name, .sidebar .side-foot .user .role, .sidebar .side-foot .logout { display: none; }
  .content { padding: 18px; }
}
