:root {
  --primary: #1677ff;
  --primary-dark: #0958d9;
  --text: #1f1f1f;
  --secondary: #8c8c8c;
  --border: #f0f0f0;
  --bg: #f5f7fa;
  --green: #52c41a;
  --orange: #faad14;
  --red: #ff4d4f;
  --purple: #722ed1;
  --cyan: #13c2c2;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body { min-width: 320px; background: var(--bg); font-size: 14px; }
a { color: var(--primary); cursor: pointer; text-decoration: none; }
a:hover { color: #4096ff; }
svg { flex: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d9d9d9; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #bfbfbf; }

.layout { display: flex; min-height: 100vh; }
.mask { display: none; }

.sider {
  width: 232px;
  flex: none;
  background: #fff;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 20;
  transition: width .2s;
}
.sider.collapsed { width: 64px; }
.sider.collapsed .brand-text,
.sider.collapsed .menu-group-title span,
.sider.collapsed .menu-item-text { display: none; }
.sider.collapsed .brand { padding: 0; justify-content: center; }
.sider.collapsed .menu-group-title { justify-content: center; padding: 10px 0; }
.sider.collapsed .menu-item { justify-content: center; padding: 10px 0; }

.brand {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.brand-logo {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, #1677ff, #0958d9);
  color: #fff; display: grid; place-items: center;
}
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--secondary); }

.menu { padding: 8px 0 24px; }
.menu-group { margin-bottom: 2px; }
.menu-group-title {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: #5f6672; font-size: 13px; font-weight: 600;
  cursor: pointer; user-select: none;
}
.menu-group-title:hover { color: var(--primary); }
.menu-group-arrow { margin-left: auto; transition: transform .2s; color: #bfbfbf; }
.menu-group.open .menu-group-arrow { transform: rotate(90deg); }
.menu-items { display: none; }
.menu-group.open .menu-items { display: block; }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px 9px 44px; font-size: 13px; color: #434950;
  cursor: pointer; border-left: 3px solid transparent;
}
.menu-item:hover { background: #f5f8ff; color: var(--primary); }
.menu-item.active { background: #e6f4ff; color: var(--primary); border-left-color: var(--primary); font-weight: 600; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.header {
  height: 60px; flex: none;
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 0 24px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.header-left, .header-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  border: 0; background: transparent; cursor: pointer; color: #5f6672;
  width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center;
  position: relative;
}
.icon-btn:hover { background: #f5f5f5; color: var(--primary); }
.badge {
  position: absolute; top: -1px; right: -2px; min-width: 16px; height: 16px;
  background: var(--red); color: #fff; border-radius: 8px; font-size: 10px;
  display: grid; place-items: center; padding: 0 4px; border: 1px solid #fff;
}
.crumb { color: var(--secondary); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.crumb b { color: var(--text); font-weight: 500; }
.crumb .sep { color: #d9d9d9; }
.lang-switch { display: inline-flex; border: 1px solid #d9d9d9; border-radius: 6px; overflow: hidden; margin-right: 4px; }
.lang-btn {
  border: 0; background: #fff; color: #5f6672; font-size: 11px; padding: 4px 9px;
  cursor: pointer; font-family: inherit; line-height: 18px;
}
.lang-btn + .lang-btn { border-left: 1px solid #d9d9d9; }
.lang-btn.active { background: var(--primary); color: #fff; }
.demo-badge {
  font-size: 11px; color: #0958d9; background: #e6f4ff;
  border: 1px solid #91caff; border-radius: 10px; padding: 2px 8px; margin-right: 4px;
}
.user { display: flex; align-items: center; gap: 8px; cursor: pointer; margin-left: 4px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--primary);
  color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.user-name { font-size: 13px; }

.content { margin: 20px; min-height: 0; flex: 1; }
.content-inner { max-width: 1680px; margin: 0 auto; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 16px; flex-wrap: wrap;
}
.page-title { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.page-sub { font-size: 13px; color: var(--secondary); }
.page-extra { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.02);
}
.card-head {
  min-height: 42px; padding: 10px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-weight: 600; font-size: 14px;
}
.card-head .extra { font-size: 13px; font-weight: 400; }
.card-body { padding: 16px; }
.card-body.tight { padding: 12px; }
.card-body.nopad { padding: 0; }

.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-32 { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.grid-chat { grid-template-columns: minmax(0, 1fr) 320px; }

.stat-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; min-height: 118px; display: flex; flex-direction: column;
  justify-content: space-between; box-shadow: 0 1px 2px rgba(0,0,0,.02);
}
.stat-top { display: flex; justify-content: space-between; align-items: center; }
.stat-title { color: #5f6672; font-size: 13px; }
.stat-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: #f0f5ff; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.25; margin-top: 10px; }
.stat-suffix { font-size: 13px; font-weight: 400; color: var(--secondary); margin-left: 2px; }
.stat-hint { font-size: 12px; color: var(--secondary); margin-top: 6px; }

.tag {
  display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 4px;
  font-size: 12px; line-height: 20px; white-space: nowrap;
}
.tag-blue { background: #e6f4ff; color: #1677ff; }
.tag-green { background: #f6ffed; color: #52c41a; }
.tag-gold { background: #fffbe6; color: #d48806; }
.tag-orange { background: #fff7e6; color: #d46b08; }
.tag-red { background: #fff1f0; color: #ff4d4f; }
.tag-purple { background: #f9f0ff; color: #722ed1; }
.tag-cyan { background: #e6fffb; color: #13c2c2; }
.tag-default { background: #f5f5f5; color: #595959; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 600; white-space: nowrap; color: #5f6672;
  background: #fafafa; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
td { padding: 10px 12px; border-bottom: 1px solid #f5f5f5; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafafa; }
.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub-text { color: var(--secondary); font-size: 12px; margin-top: 2px; }
.right { text-align: right; }
.link-btn {
  border: 0; background: transparent; color: var(--primary); cursor: pointer;
  padding: 0 6px; font-size: 13px;
}
.link-btn:hover { color: #4096ff; }
.link-btn.danger { color: var(--red); }
.empty { color: var(--secondary); font-size: 13px; padding: 32px 12px; text-align: center; }

.progress-row { margin-bottom: 14px; }
.progress-row:last-child { margin-bottom: 0; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.progress-track { height: 8px; background: #f5f5f5; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; background: var(--primary); transition: width .4s; }

.alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px;
  border-radius: 6px; font-size: 13px; margin-bottom: 16px; line-height: 1.6;
}
.alert-info { background: #e6f4ff; border: 1px solid #91caff; color: #0958d9; }
.alert-warning { background: #fffbe6; border: 1px solid #ffe58f; color: #ad6800; }
.alert-success { background: #f6ffed; border: 1px solid #b7eb8f; color: #389e0d; }
.alert-error { background: #fff2f0; border: 1px solid #ffccc7; color: #cf1322; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.input, .select {
  height: 32px; border: 1px solid #d9d9d9; border-radius: 6px; padding: 0 10px;
  font-size: 13px; background: #fff; color: var(--text); outline: none; font-family: inherit;
}
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(22,119,255,.1); }
.input::placeholder { color: #bfbfbf; }
.input-search { width: 240px; }
.btn {
  height: 32px; padding: 0 14px; border-radius: 6px; border: 1px solid #d9d9d9;
  background: #fff; color: var(--text); font-size: 13px; cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #4096ff; border-color: #4096ff; color: #fff; }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.input-group { display: inline-flex; }
.input-group .input { border-radius: 6px 0 0 6px; }
.input-group .btn { border-radius: 0 6px 6px 0; }

.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 8px 0; font-size: 13px; color: #5f6672; cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.donut-wrap { display: grid; place-items: center; padding: 4px 0; }
.donut-center { font-size: 12px; color: var(--secondary); text-align: center; }
.donut-center b { display: block; font-size: 24px; color: var(--text); }
.legend { display: flex; justify-content: center; gap: 18px; font-size: 12px; color: #5f6672; margin-top: 4px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }

.bar-chart { display: grid; gap: 18px; padding: 8px 4px; }
.bar-item { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 10px; font-size: 12px; }
.bar-track { height: 18px; background: #f5f5f5; border-radius: 4px; position: relative; }
.bar-fill { height: 100%; border-radius: 4px; min-width: 2px; }
.bar-value { position: absolute; right: 6px; top: 1px; font-size: 11px; color: #5f6672; }

.chat-box { border: 1px solid var(--border); border-radius: var(--radius); background: #fff; overflow: hidden; }
.chat-list { max-height: 520px; min-height: 380px; overflow-y: auto; padding: 16px; }
.chat-row { display: flex; margin-bottom: 16px; }
.chat-row.user { justify-content: flex-end; }
.chat-row.assistant { justify-content: flex-start; }
.bubble {
  max-width: 86%; padding: 10px 14px; border-radius: 10px; line-height: 1.7; font-size: 14px;
  white-space: pre-wrap;
}
.chat-row.user .bubble { background: var(--primary); color: #fff; }
.chat-row.assistant .bubble { background: #f5f7fa; color: var(--text); }
.chat-meta { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.chat-input { border-top: 1px solid var(--border); padding: 12px; display: flex; gap: 8px; }
.chat-input textarea {
  flex: 1; resize: none; height: 56px; border: 1px solid #d9d9d9; border-radius: 6px;
  padding: 8px 10px; font-size: 13px; font-family: inherit; outline: none;
}
.chat-input textarea:focus { border-color: var(--primary); }
.suggestion {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 8px 4px; font-size: 13px; cursor: pointer; color: var(--text);
  font-family: inherit; line-height: 1.5;
}
.suggestion:hover { color: var(--primary); }

.kv { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0; font-size: 13px; }
.kv-item { display: flex; border: 1px solid var(--border); margin: -1px 0 0 -1px; }
.kv-key { width: 120px; flex: none; background: #fafafa; padding: 8px 12px; color: #5f6672; }
.kv-val { padding: 8px 12px; flex: 1; }

.stat-note { font-size: 12px; color: var(--secondary); text-align: center; margin-top: 6px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: #5f6672; }
.hint-line { font-size: 12px; color: var(--secondary); padding: 12px; }

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3, .grid-32 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-chat { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sider { position: fixed; left: 0; top: 0; transform: translateX(-100%); }
  .sider.open-mobile { transform: translateX(0); }
  .mask.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 15; }
  .grid-3, .grid-32, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid-4 { grid-template-columns: 1fr; }
  .content { margin: 12px; }
  .header { padding: 0 12px; }
  .user-name, .demo-badge { display: none; }
  .lang-btn { padding: 4px 6px; }
  .crumb { font-size: 12px; }
}
