/* ==========================================================================
   素颜网 CRM — 视觉基线
   复刻 Element UI 后台观感：青绿主色、左侧菜单、浅灰内容区 + 白卡片
   ========================================================================== */

:root {
  --primary: #13a8a8;
  --primary-dark: #0e8c8c;
  --primary-light: #e6f7f7;
  --success: #52c41a;
  --warning: #fa8c16;
  --danger: #f5222d;
  --info: #8c8c8c;
  --purple: #722ed1;
  --blue: #2f54eb;

  --text-1: #1f2d3d;
  --text-2: #5a6c7d;
  --text-3: #8c9aa8;
  --text-4: #b4bfca;

  --border: #e4e8ee;
  --border-light: #eef1f5;
  --bg-page: #f0f2f5;
  --bg-card: #ffffff;
  --bg-hover: #f5f8fa;

  --sidebar-w: 216px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 56px;
  --radius: 4px;
  --shadow-card: 0 1px 3px rgba(31, 45, 61, 0.06);
  --shadow-pop: 0 6px 22px rgba(31, 45, 61, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-page);
  color: var(--text-1);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
               'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cdd5de; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b4bfca; }

/* ============================ 登录页 ============================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0e8c8c 0%, #13a8a8 45%, #2fc4b2 100%);
  position: relative;
  overflow: hidden;
}
.login-page::before,
.login-page::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .07);
}
.login-page::before { width: 520px; height: 520px; top: -180px; right: -120px; }
.login-page::after { width: 380px; height: 380px; bottom: -140px; left: -100px; }

.login-box {
  position: relative;
  z-index: 2;
  width: 400px;
  background: #fff;
  border-radius: 10px;
  padding: 40px 40px 30px;
  box-shadow: 0 18px 50px rgba(0, 40, 40, .28);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-logo {
  width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--primary), #2fc4b2);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 26px; font-weight: 700;
  box-shadow: 0 6px 16px rgba(19, 168, 168, .35);
}
.login-brand h1 { font-size: 20px; margin: 0 0 6px; font-weight: 600; letter-spacing: .5px; }
.login-brand p { margin: 0; color: var(--text-3); font-size: 12px; }
.login-field { margin-bottom: 18px; }
.login-field label { display: block; margin-bottom: 6px; color: var(--text-2); font-size: 12px; }
.login-field .el-input { height: 40px; }
.login-field .el-input input { height: 40px; font-size: 14px; }
.login-btn {
  width: 100%; height: 42px; font-size: 15px; letter-spacing: 4px;
  border-radius: var(--radius); margin-top: 6px;
}
.login-tip {
  margin-top: 20px; padding: 10px 12px; background: #f7fafb; border-radius: var(--radius);
  color: var(--text-3); font-size: 12px; line-height: 1.7; border: 1px dashed var(--border);
}
.login-tip b { color: var(--primary); }

/* ============================ 布局 ============================ */
.layout { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width .22s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }

.sidebar-logo {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  white-space: nowrap;
}
.sidebar-logo .mark {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), #2fc4b2);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px;
}
.sidebar-logo .name { font-size: 15px; font-weight: 600; color: var(--text-1); letter-spacing: .5px; }
.sidebar.collapsed .sidebar-logo { padding: 0 17px; }
.sidebar.collapsed .sidebar-logo .name { display: none; }

.sidebar-menu { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0 24px; }

.menu-group-title {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  font-size: 13px;
  transition: background .16s, color .16s;
}
.menu-group-title:hover { background: var(--bg-hover); color: var(--primary); }
.menu-group-title .ico { flex-shrink: 0; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; }
.menu-group-title .ico svg { width: 16px; height: 16px; }
.menu-group-title .txt { flex: 1; }
.menu-group-title .arrow { transition: transform .2s; color: var(--text-4); font-size: 10px; }
.menu-group.open .menu-group-title .arrow { transform: rotate(90deg); }
.menu-group.open .menu-group-title { color: var(--text-1); font-weight: 500; }

.menu-children { max-height: 0; overflow: hidden; transition: max-height .24s ease; }
.menu-group.open .menu-children { max-height: 460px; }

.menu-item {
  display: block;
  padding: 8px 18px 8px 46px;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
  border-right: 3px solid transparent;
  transition: all .16s;
}
.menu-item:hover { color: var(--primary); background: var(--bg-hover); }
.menu-item.active {
  color: var(--primary);
  background: var(--primary-light);
  border-right-color: var(--primary);
  font-weight: 500;
}

.sidebar.collapsed .menu-group-title { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .menu-group-title .txt,
.sidebar.collapsed .menu-group-title .arrow { display: none; }
.sidebar.collapsed .menu-children { max-height: 0 !important; }
.sidebar.collapsed .menu-group.single .menu-children { max-height: 0 !important; }

/* 主区 */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  transition: margin-left .22s ease;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.main.expanded { margin-left: var(--sidebar-w-collapsed); }

.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: sticky; top: 0; z-index: 90;
}
.icon-btn {
  width: 32px; height: 32px; border: none; background: transparent; border-radius: var(--radius);
  cursor: pointer; color: var(--text-2); display: flex; align-items: center; justify-content: center;
  transition: background .16s, color .16s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--primary); }
.icon-btn svg { width: 18px; height: 18px; }

.breadcrumb { flex: 1; display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13px; }
.breadcrumb b { color: var(--text-1); font-weight: 500; }
.breadcrumb .sep { color: var(--text-4); }

.topbar-user { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 5px 10px; border-radius: 16px; transition: background .16s; position: relative; }
.topbar-user:hover { background: var(--bg-hover); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), #2fc4b2);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
}
.topbar-user .uname { color: var(--text-1); font-size: 13px; }
.user-dropdown {
  position: absolute; top: 46px; right: 0; min-width: 168px; background: #fff;
  border-radius: var(--radius); box-shadow: var(--shadow-pop); border: 1px solid var(--border-light);
  padding: 5px 0; display: none; z-index: 200;
}
.user-dropdown.show { display: block; }
.user-dropdown .dd-item { padding: 9px 16px; color: var(--text-2); cursor: pointer; font-size: 13px; }
.user-dropdown .dd-item:hover { background: var(--bg-hover); color: var(--primary); }
.user-dropdown .dd-head { padding: 10px 16px; border-bottom: 1px solid var(--border-light); }
.user-dropdown .dd-head .n { color: var(--text-1); font-weight: 500; }
.user-dropdown .dd-head .p { color: var(--text-3); font-size: 12px; margin-top: 2px; }

.content { flex: 1; padding: 16px; min-width: 0; }

/* ============================ 卡片 ============================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  margin-bottom: 14px;
}
.card:last-child { margin-bottom: 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border-light);
}
.card-head h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text-1); display: flex; align-items: center; gap: 8px; }
.card-head h3::before { content: ''; width: 3px; height: 15px; background: var(--primary); border-radius: 2px; }
.card-body { padding: 16px 18px; }

/* ============================ 按钮 ============================ */
.el-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 32px; padding: 0 15px;
  border: 1px solid var(--border);
  background: #fff; color: var(--text-1);
  border-radius: var(--radius); cursor: pointer;
  font-size: 13px; white-space: nowrap;
  transition: all .16s;
  font-family: inherit;
}
.el-btn:hover { color: var(--primary); border-color: #9fd9d9; background: var(--primary-light); }
.el-btn:active { transform: translateY(1px); }
.el-btn:disabled { opacity: .5; cursor: not-allowed; }

.el-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.el-btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.el-btn.danger { color: var(--danger); border-color: #f8b4b8; background: #fef0f0; }
.el-btn.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.el-btn.success { color: var(--success); border-color: #b7e5a0; background: #f6ffed; }
.el-btn.success:hover { background: var(--success); border-color: var(--success); color: #fff; }
.el-btn.warning { color: var(--warning); border-color: #fcd9a8; background: #fff7e6; }
.el-btn.warning:hover { background: var(--warning); border-color: var(--warning); color: #fff; }
.el-btn.text { border-color: transparent; background: transparent; padding: 0 6px; height: 26px; color: var(--primary); }
.el-btn.text:hover { background: var(--primary-light); }
.el-btn.text.danger { color: var(--danger); background: transparent; border-color: transparent; }
.el-btn.text.danger:hover { background: #fef0f0; }
.el-btn.sm { height: 28px; padding: 0 11px; font-size: 12px; }
.el-btn + .el-btn { margin-left: 8px; }

/* ============================ 表单控件 ============================ */
.el-input, .el-select, .el-textarea { display: inline-block; width: 100%; position: relative; }
.el-input input, .el-select select, .el-textarea textarea {
  width: 100%; height: 32px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-1); font-size: 13px; font-family: inherit;
  background: #fff; outline: none; transition: border-color .16s, box-shadow .16s;
}
.el-textarea textarea { height: auto; min-height: 72px; padding: 7px 10px; resize: vertical; line-height: 1.6; }
.el-input input:focus, .el-select select:focus, .el-textarea textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 2px rgba(19, 168, 168, .12);
}
.el-input input::placeholder, .el-textarea textarea::placeholder { color: var(--text-4); }
.el-input input:disabled, .el-select select:disabled { background: #f7f8fa; color: var(--text-3); cursor: not-allowed; }
.el-select select { appearance: none; padding-right: 26px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5L6 8.5L10 4.5' stroke='%238c9aa8' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 12px;
}
.el-select select[multiple] { height: auto; min-height: 32px; padding: 3px; background-image: none; }

/* 搜索区 */
.search-card .card-body { padding: 16px 18px 6px; }
.search-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 0 18px; }
.search-item { display: flex; align-items: center; margin-bottom: 12px; gap: 8px; }
.search-item > label { width: 84px; flex-shrink: 0; text-align: right; color: var(--text-2); font-size: 13px; }
.search-item .ctrl { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.search-item .ctrl .sep { color: var(--text-4); }
.search-actions { display: flex; justify-content: flex-end; gap: 8px; padding-bottom: 10px; }
.search-toggle { color: var(--primary); cursor: pointer; font-size: 12px; user-select: none; }

/* 表单（弹窗内） */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 20px; }
.form-item { margin-bottom: 16px; display: flex; align-items: flex-start; gap: 8px; }
.form-item.full { grid-column: 1 / -1; }
.form-item > label {
  width: 92px; flex-shrink: 0; text-align: right; color: var(--text-2);
  font-size: 13px; line-height: 32px;
}
.form-item > label .req { color: var(--danger); margin-right: 2px; }
.form-item .ctrl { flex: 1; min-width: 0; }
.form-item .hint { color: var(--text-3); font-size: 12px; margin-top: 4px; }

/* ============================ 页签 ============================ */
.tabs {
  display: flex; gap: 2px; padding: 0 18px;
  border-bottom: 1px solid var(--border-light);
  overflow-x: auto; flex-wrap: nowrap;
}
.tabs::-webkit-scrollbar { height: 0; }
.tab {
  padding: 11px 14px; color: var(--text-2); cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; font-size: 13px; transition: all .16s;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.tab .cnt { color: var(--text-4); font-size: 12px; margin-left: 4px; }
.tab.active .cnt { color: var(--primary); }

/* ============================ 表格 ============================ */
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; gap: 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border-light);
}
.table-toolbar .left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.table-toolbar .right { color: var(--text-3); font-size: 12px; display: flex; align-items: center; gap: 12px; }
.table-toolbar .right b { color: var(--primary); font-weight: 600; }

.table-wrap { overflow-x: auto; }
table.el-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.el-table th {
  background: #fafbfc; color: var(--text-2); font-weight: 500;
  padding: 10px 10px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 2;
}
table.el-table th.sortable { cursor: pointer; user-select: none; }
table.el-table th.sortable:hover { color: var(--primary); }
table.el-table th .sort-ico { color: var(--text-4); font-size: 9px; margin-left: 3px; }
table.el-table th.sorted .sort-ico { color: var(--primary); }
table.el-table td {
  padding: 9px 10px; border-bottom: 1px solid var(--border-light);
  color: var(--text-1); vertical-align: middle;
}
table.el-table tbody tr:hover td { background: #f7fbfb; }
table.el-table tbody tr.checked td { background: var(--primary-light); }
table.el-table td.op-cell { white-space: nowrap; }
table.el-table td.op-cell .el-btn { margin-right: 2px; }
table.el-table .col-check { width: 40px; }
table.el-table .col-index { width: 62px; color: var(--text-3); }

.cell-sub { color: var(--text-3); font-size: 12px; margin-top: 1px; }
.cell-main { color: var(--text-1); }
.cell-ellipsis { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.money { color: var(--danger); font-weight: 500; font-variant-numeric: tabular-nums; }
.money.income { color: var(--success); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-4); }
.empty-row td { text-align: center; color: var(--text-4); padding: 46px 0 !important; }
.empty-row .big { font-size: 34px; margin-bottom: 8px; opacity: .35; }

/* 标签 */
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  font-size: 12px; line-height: 18px; white-space: nowrap;
  background: #f0f2f5; color: var(--text-2); border: 1px solid transparent;
}
.tag.primary { background: var(--primary-light); color: var(--primary-dark); border-color: #b8e6e6; }
.tag.success { background: #f6ffed; color: #389e0d; border-color: #b7eb8f; }
.tag.warning { background: #fff7e6; color: #d46b08; border-color: #ffd591; }
.tag.danger  { background: #fff1f0; color: #cf1322; border-color: #ffa39e; }
.tag.info    { background: #f5f5f5; color: #595959; border-color: #d9d9d9; }
.tag.purple  { background: #f9f0ff; color: #531dab; border-color: #d3adf7; }
.tag.blue    { background: #f0f5ff; color: #1d39c4; border-color: #adc6ff; }

/* 开关 */
.switch {
  display: inline-flex; align-items: center; width: 40px; height: 20px;
  border-radius: 10px; background: #c8d0d9; cursor: pointer;
  position: relative; transition: background .2s; vertical-align: middle;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(20px); }

/* 星级 */
.stars { color: #ffc53d; letter-spacing: 1px; font-size: 13px; }
.stars .off { color: #e0e4ea; }

/* 图片 */
.thumb {
  width: 38px; height: 38px; border-radius: var(--radius); object-fit: cover;
  border: 1px solid var(--border); background: #f7f8fa; cursor: pointer; display: block;
}
.thumb-ph {
  width: 38px; height: 38px; border-radius: var(--radius); border: 1px dashed var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--text-4); font-size: 15px;
}

/* 颜色块 */
.color-dot { display: inline-flex; align-items: center; gap: 6px; }
.color-dot i { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.08); display: inline-block; }

/* 树表 */
.tree-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-right: 4px; cursor: pointer;
  color: var(--text-3); border: 1px solid var(--border); border-radius: 2px;
  font-size: 10px; background: #fff; vertical-align: middle;
}
.tree-toggle:hover { color: var(--primary); border-color: var(--primary); }
.tree-toggle.leaf { visibility: hidden; }

/* 分页 */
.pagination {
  display: flex; align-items: center; justify-content: flex-end; gap: 6px;
  padding: 13px 18px; flex-wrap: wrap;
}
.pagination .pg-info { margin-right: auto; color: var(--text-3); font-size: 12px; }
.pg-btn {
  min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid var(--border);
  background: #fff; border-radius: var(--radius); cursor: pointer; color: var(--text-1);
  font-size: 13px; font-family: inherit; transition: all .16s;
}
.pg-btn:hover:not(:disabled) { color: var(--primary); border-color: var(--primary); }
.pg-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pg-btn:disabled { opacity: .45; cursor: not-allowed; }
.pagination select { height: 30px; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 6px; color: var(--text-2); font-family: inherit; font-size: 12px; background: #fff; }

/* ============================ 弹窗 ============================ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(31, 45, 61, .45);
  z-index: 1000; display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 20px 40px; overflow-y: auto;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideDown { from { transform: translateY(-16px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }

.modal {
  background: #fff; border-radius: 6px; width: 620px; max-width: 100%;
  box-shadow: var(--shadow-pop); animation: slideDown .22s ease; margin: auto 0;
}
.modal.wide { width: 900px; }
.modal.narrow { width: 460px; }
.modal-head {
  padding: 15px 20px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-close {
  border: none; background: transparent; cursor: pointer; color: var(--text-3);
  font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: var(--radius);
}
.modal-close:hover { color: var(--danger); background: #fef0f0; }
.modal-body { padding: 20px; max-height: 62vh; overflow-y: auto; }
.modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--border-light);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* 详情描述 */
.desc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.desc-item { display: flex; border-bottom: 1px solid var(--border); font-size: 13px; min-height: 38px; }
.desc-item:nth-last-child(-n+2) { border-bottom: none; }
.desc-item.full { grid-column: 1 / -1; }
.desc-item .k {
  width: 118px; flex-shrink: 0; background: #fafbfc; color: var(--text-2);
  padding: 9px 12px; border-right: 1px solid var(--border);
}
.desc-item .v { flex: 1; padding: 9px 12px; color: var(--text-1); word-break: break-all; }

/* 提示消息 */
.msg-stack { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.msg {
  padding: 10px 18px; border-radius: var(--radius); background: #fff;
  box-shadow: var(--shadow-pop); font-size: 13px; display: flex; align-items: center; gap: 8px;
  border-left: 3px solid var(--info); animation: slideDown .2s ease; min-width: 200px;
}
.msg.success { border-left-color: var(--success); color: #389e0d; background: #f6ffed; }
.msg.error   { border-left-color: var(--danger); color: #cf1322; background: #fff1f0; }
.msg.warning { border-left-color: var(--warning); color: #d46b08; background: #fff7e6; }
.msg.info    { border-left-color: var(--primary); color: var(--primary-dark); background: var(--primary-light); }

/* ============================ 首页 ============================ */
.welcome {
  background: linear-gradient(120deg, #0e8c8c 0%, #13a8a8 55%, #2fc4b2 100%);
  border-radius: var(--radius); padding: 22px 26px; color: #fff; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  position: relative; overflow: hidden;
}
.welcome::after {
  content: ''; position: absolute; width: 260px; height: 260px; border-radius: 50%;
  background: rgba(255,255,255,.08); top: -120px; right: -60px;
}
.welcome .wt { position: relative; z-index: 2; }
.welcome h2 { margin: 0 0 6px; font-size: 19px; font-weight: 600; }
.welcome p { margin: 0; opacity: .88; font-size: 13px; }
.welcome .wq { position: relative; z-index: 2; display: flex; gap: 26px; flex-wrap: wrap; }
.welcome .wq div { text-align: right; }
.welcome .wq .v { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }
.welcome .wq .l { font-size: 12px; opacity: .82; margin-top: 2px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpi {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-card);
  padding: 16px 18px; display: flex; align-items: center; gap: 14px;
  transition: transform .16s, box-shadow .16s; cursor: default;
}
.kpi:hover { transform: translateY(-2px); box-shadow: 0 5px 16px rgba(31,45,61,.1); }
.kpi .kico {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  background: var(--primary-light); color: var(--primary);
}
.kpi .kval { font-size: 21px; font-weight: 600; color: var(--text-1); font-variant-numeric: tabular-nums; line-height: 1.25; }
.kpi .klab { color: var(--text-3); font-size: 12px; margin-top: 3px; }
.kpi.g .kico { background: #f6ffed; color: var(--success); }
.kpi.o .kico { background: #fff7e6; color: var(--warning); }
.kpi.r .kico { background: #fff1f0; color: var(--danger); }
.kpi.p .kico { background: #f9f0ff; color: var(--purple); }
.kpi.b .kico { background: #f0f5ff; color: var(--blue); }

.chart-row { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 14px; }
.chart-row.eq { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .chart-row, .chart-row.eq { grid-template-columns: 1fr; } }
.chart { width: 100%; height: 280px; }
.chart.sm { height: 250px; }

/* 宫格导航 */
.nav-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 1200px) { .nav-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px)  { .nav-grid { grid-template-columns: repeat(2, 1fr); } }
.nav-cell {
  display: flex; align-items: center; gap: 12px; padding: 15px 16px;
  border: 1px solid var(--border-light); border-radius: var(--radius);
  cursor: pointer; transition: all .16s; background: #fff;
}
.nav-cell:hover {
  border-color: var(--primary); background: var(--primary-light);
  transform: translateY(-2px); box-shadow: 0 4px 12px rgba(19,168,168,.14);
}
.nav-cell .nico {
  width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0;
  background: #f2f6f8; color: var(--primary); display: flex; align-items: center; justify-content: center;
}
.nav-cell:hover .nico { background: #fff; }
.nav-cell .nico svg { width: 19px; height: 19px; }
.nav-cell .ntxt { min-width: 0; }
.nav-cell .nname { font-size: 13px; color: var(--text-1); font-weight: 500; }
.nav-cell .nsub { font-size: 12px; color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 排行列表 */
.rank-list { display: flex; flex-direction: column; gap: 2px; }
.rank-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border-light); }
.rank-item:last-child { border-bottom: none; }
.rank-no {
  width: 19px; height: 19px; border-radius: 4px; flex-shrink: 0;
  background: #f0f2f5; color: var(--text-3); font-size: 11px;
  display: flex; align-items: center; justify-content: center; font-weight: 600;
}
.rank-item:nth-child(1) .rank-no { background: #fff1f0; color: #cf1322; }
.rank-item:nth-child(2) .rank-no { background: #fff7e6; color: #d46b08; }
.rank-item:nth-child(3) .rank-no { background: #f6ffed; color: #389e0d; }
.rank-name { flex: 1; color: var(--text-1); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-val { color: var(--danger); font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 500; }
.rank-bar { height: 3px; background: var(--border-light); border-radius: 2px; overflow: hidden; margin-top: 3px; }
.rank-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #2fc4b2); border-radius: 2px; }

/* ============================ 其他 ============================ */
.loading-mask {
  position: absolute; inset: 0; background: rgba(255,255,255,.65);
  display: flex; align-items: center; justify-content: center; z-index: 50;
  color: var(--primary); font-size: 13px;
}
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--primary-light);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 0; }
.stat-mini { background: #fafbfc; border: 1px solid var(--border-light); border-radius: var(--radius); padding: 12px 14px; }
.stat-mini .v { font-size: 19px; font-weight: 600; color: var(--primary); font-variant-numeric: tabular-nums; }
.stat-mini .l { font-size: 12px; color: var(--text-3); margin-top: 3px; }

.badge-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); margin-left: 4px; vertical-align: middle; }

.pager-note { color: var(--text-3); font-size: 12px; padding: 10px 18px; }

@media (max-width: 780px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main { margin-left: 0 !important; }
  .form-grid { grid-template-columns: 1fr; }
  .search-grid { grid-template-columns: 1fr; }
  .desc-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   AI 助手
   整页占满可视高度（减掉顶栏与 content 内边距），让消息区自己滚动，
   而不是整页跟着内容变长——对话页最忌讳输入框被顶到屏幕外面去。
   ========================================================================== */
.ai-page {
  display: flex; gap: 14px;
  height: calc(100vh - var(--topbar-h) - 32px);
  min-height: 420px;
}

/* ---- 左：会话列表 ---- */
.ai-side {
  width: 240px; flex: none;
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; overflow: hidden;
}
.ai-side-head {
  display: flex; gap: 8px; padding: 12px;
  border-bottom: 1px solid var(--border-light);
}
.ai-side-head .el-btn { flex: 1; padding: 0 8px; }
.ai-conv-list { flex: 1; overflow-y: auto; padding: 6px; }
.ai-conv {
  position: relative; padding: 9px 26px 9px 10px; border-radius: var(--radius);
  cursor: pointer; margin-bottom: 2px;
}
.ai-conv:hover { background: var(--bg-hover); }
.ai-conv.active { background: var(--primary-light); }
.ai-conv .t {
  font-size: 13px; color: var(--text-1); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-conv.active .t { color: var(--primary-dark); }
.ai-conv .m { font-size: 11px; color: var(--text-4); margin-top: 2px; }
.ai-conv .x {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; line-height: 16px; text-align: center;
  border-radius: 50%; color: var(--text-4); font-size: 15px;
  opacity: 0; transition: opacity .15s;
}
.ai-conv:hover .x { opacity: 1; }
.ai-conv .x:hover { background: var(--danger); color: #fff; }

/* ---- 右：对话区 ---- */
.ai-chat {
  flex: 1; min-width: 0;
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column; overflow: hidden;
}
.ai-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-bottom: 1px solid var(--border-light);
}
.ai-head .ai-title {
  font-size: 15px; font-weight: 600; color: var(--text-1);
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.ai-msgs { flex: 1; overflow-y: auto; padding: 18px; background: #fbfcfd; }
.ai-row { display: flex; gap: 10px; margin-bottom: 16px; align-items: flex-start; }
.ai-row.me { justify-content: flex-end; }
.ai-avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.ai-bubble {
  max-width: 76%; padding: 10px 14px; border-radius: 8px;
  background: #fff; border: 1px solid var(--border);
  font-size: 13px; line-height: 1.75; color: var(--text-1);
  word-break: break-word;
}
.ai-bubble.me {
  background: var(--primary); border-color: var(--primary); color: #fff;
  border-top-right-radius: 2px;
}
.ai-bubble.err {
  background: #fff1f0; border-color: #ffa39e; color: #cf1322;
}
.ai-bubble.thinking { color: var(--text-4); font-style: italic; }
.ai-bubble .ai-list { margin: 6px 0; padding-left: 18px; }
.ai-bubble .ai-list li { margin: 3px 0; }
/* 回答被 max_tokens 截断时的标记：不加这个，用户会以为模型话说一半是风格 */
.ai-bubble .ai-cut {
  margin-top: 8px; padding-top: 7px; border-top: 1px dashed #ffd591;
  color: #d46b08; font-size: 12px;
}
.ai-bubble code {
  background: #f2f4f7; padding: 1px 5px; border-radius: 3px;
  font-size: 12px; font-family: Consolas, Monaco, monospace; color: #c7254e;
}
.ai-bubble pre.code {
  background: #2b3038; color: #e6e6e6; padding: 10px 12px; border-radius: 5px;
  font-size: 12px; line-height: 1.6; overflow-x: auto; margin: 8px 0;
  font-family: Consolas, Monaco, monospace; white-space: pre;
}
.ai-bubble pre.code:first-child { margin-top: 0; }
.ai-bubble pre.code:last-child { margin-bottom: 0; }

.ai-compose { border-top: 1px solid var(--border-light); padding: 12px 18px; }
.ai-compose .el-textarea textarea { min-height: 64px; }
.ai-compose-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 8px;
}
.ai-status { font-size: 12px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ai-empty { color: var(--text-3); font-size: 13px; text-align: center; padding: 40px 20px; }
.ai-empty.small { padding: 20px 10px; font-size: 12px; }
.ai-empty .big { font-size: 20px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.ai-hint { font-size: 12px; color: var(--text-4); line-height: 1.6; margin-top: 4px; }

/* 无子菜单的一级项高亮（首页 / AI 助手） */
.menu-group.single.active > .menu-group-title {
  color: var(--primary); font-weight: 600; background: var(--primary-light);
}
.menu-group.single.active > .menu-group-title .ico { color: var(--primary); }
