* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  font-size: 14px;
}

/* ───── Layout ───── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: #1a1a2e;
  color: #c8cdd8;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}
.main { margin-left: 220px; flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-x: hidden; }
.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid #e8eaed;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.content { padding: 24px; flex: 1; }

/* ───── Sidebar ───── */
.sidebar-logo { padding: 20px 20px 16px; border-bottom: 1px solid #2d2d4e; }
.sidebar-logo .bot-icon { font-size: 22px; margin-right: 8px; }
.sidebar-logo .title { font-size: 15px; font-weight: 600; color: #fff; }
.sidebar-logo .sub { font-size: 11px; color: #666b80; margin-top: 2px; }
.nav-section { padding: 12px 0 4px; }
.nav-label { font-size: 10px; letter-spacing: 1px; color: #4a4f6a; text-transform: uppercase; padding: 0 16px 6px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: #252545; color: #e0e4f0; }
.nav-item.active { background: #1e3a5f; color: #4da6ff; border-left-color: #4da6ff; }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }
.nav-item .label { font-size: 13px; }

/* ───── Topbar ───── */
.topbar-title { font-size: 16px; font-weight: 600; color: #1a1a2e; flex: 1; }
.time-filter { display: flex; gap: 2px; background: #f0f2f5; border-radius: 6px; padding: 3px; }
.time-btn {
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: #666;
  border: none;
  background: none;
  transition: all 0.15s;
}
.time-btn.active { background: #fff; color: #1a1a2e; font-weight: 500; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.badge { background: #ff4d4f; color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 11px; }

/* ───── Stat cards ───── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-grid-5 { grid-template-columns: repeat(5, 1fr); }
.stat-grid-6 { grid-template-columns: repeat(6, 1fr); }
.stat-card { background: #fff; border-radius: 10px; padding: 20px; position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.stat-card.blue::before  { background: linear-gradient(90deg, #4da6ff, #1677ff); }
.stat-card.green::before { background: linear-gradient(90deg, #52c41a, #73d13d); }
.stat-card.orange::before{ background: linear-gradient(90deg, #fa8c16, #ffc53d); }
.stat-card.red::before   { background: linear-gradient(90deg, #ff4d4f, #ff7875); }
.stat-card.gray::before  { background: linear-gradient(90deg, #bfbfbf, #d9d9d9); }
.stat-card.purple::before{ background: linear-gradient(90deg, #722ed1, #b37feb); }
.stat-label { font-size: 12px; color: #8c8c8c; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: #1a1a2e; }
.stat-sub { font-size: 12px; color: #52c41a; margin-top: 6px; }
.stat-sub.down { color: #ff4d4f; }

/* ───── Chart cards ───── */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-card { background: #fff; border-radius: 10px; padding: 20px; }
.chart-card.full { grid-column: 1 / -1; }
.chart-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.chart-title .dot { width: 8px; height: 8px; border-radius: 50%; background: #4da6ff; }
canvas { max-height: 260px; }

/* ───── Tables ───── */
.table-card { background: #fff; border-radius: 10px; overflow: hidden; margin-bottom: 24px; }
.table-header { padding: 16px 20px; border-bottom: 1px solid #f0f0f0; display: flex; align-items: center; justify-content: space-between; }
.table-header h3 { font-size: 14px; font-weight: 600; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
td, th { word-break: break-word; }
th { background: #fafafa; padding: 10px 16px; text-align: left; font-size: 12px; color: #8c8c8c; font-weight: 500; border-bottom: 1px solid #f0f0f0; }
td { padding: 12px 16px; border-bottom: 1px solid #f7f7f7; font-size: 13px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbff; }
.rank { font-weight: 700; color: #8c8c8c; }
.rank-1 { color: #f5a623; }
.rank-2 { color: #9b9b9b; }
.rank-3 { color: #cd7f32; }

/* ───── User cells ───── */
.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  color: #fff; flex-shrink: 0;
}
.user-name { font-weight: 500; }
.user-id { font-size: 11px; color: #aaa; }

/* ───── Tags ───── */
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; }
.tag-green  { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.tag-blue   { background: #e6f4ff; color: #1677ff; border: 1px solid #91caff; }
.tag-orange { background: #fff7e6; color: #fa8c16; border: 1px solid #ffd591; }
.tag-red    { background: #fff2f0; color: #ff4d4f; border: 1px solid #ffccc7; }
.tag-gray   { background: #f5f5f5; color: #8c8c8c; border: 1px solid #d9d9d9; }
.tag-purple { background: #f9f0ff; color: #722ed1; border: 1px solid #d3adf7; }

/* ───── Links ───── */
.link-btn { color: #1677ff; cursor: pointer; font-size: 12px; font-weight: 500; white-space: nowrap; }
.link-btn:hover { text-decoration: underline; }

/* ───── Trace log ───── */
.trace-item {
  background: #fff;
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid #f0f0f0;
  transition: box-shadow 0.15s;
}
.trace-item:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.trace-header { padding: 12px 16px; display: flex; align-items: center; gap: 16px; cursor: pointer; }
.trace-time { font-size: 12px; color: #8c8c8c; width: 130px; flex-shrink: 0; }
.trace-user { display: flex; align-items: center; gap: 8px; width: 130px; flex-shrink: 0; }
.trace-input { flex: 1; min-width: 0; color: #1a1a2e; font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 400px; }
.trace-skills { display: flex; gap: 4px; flex-wrap: wrap; width: 220px; flex-shrink: 0; }
.skill-chip { background: #e6f4ff; color: #1677ff; padding: 1px 6px; border-radius: 3px; font-size: 11px; }
.skill-chip-err { background: #fff2f0; color: #ff4d4f; }
.trace-meta { display: flex; gap: 12px; font-size: 12px; color: #8c8c8c; width: 160px; flex-shrink: 0; justify-content: flex-end; align-items: center; }
.trace-meta .slow { color: #ff4d4f; font-weight: 600; }
.trace-link-btn {
  background: none; border: none; cursor: pointer; padding: 2px 4px;
  font-size: 13px; color: #8c8c8c; border-radius: 4px; line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.trace-link-btn:hover { background: #e6f4ff; color: #1677ff; }
.trace-detail { padding: 12px 16px 16px; border-top: 1px solid #f5f5f5; }
.log-block { background: #1a1a2e; border-radius: 6px; padding: 12px 16px; overflow-x: hidden; }
.log-line { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; padding: 2px 0; color: #c8cdd8; line-height: 1.6; word-break: break-all; white-space: pre-wrap; }
.log-line .ts { color: #5a6070; }
.log-line .level-info  { color: #4da6ff; }
.log-line .level-debug { color: #6b737e; }
.log-line .level-warn  { color: #ffc53d; }
.log-line .skill-hl    { color: #ffa940; font-weight: 600; }
.log-line .reply-hl    { color: #73d13d; }
.reply-expand { margin-top: 8px; background: #252545; border-radius: 6px; padding: 10px 14px; }
.reply-toggle { color: #4da6ff; cursor: pointer; font-size: 12px; margin-top: 4px; display: inline-block; }
.reply-toggle:hover { text-decoration: underline; }
.reply-full { font-size: 12px; color: #c8cdd8; line-height: 1.7; margin-top: 8px; white-space: pre-wrap; max-height: 400px; overflow-y: auto; }

/* ───── Skill list ───── */
.skill-group { margin-bottom: 16px; }
.skill-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 20px; background: #fff; border-radius: 10px;
  border: 1px solid #e8eaf0; cursor: pointer; user-select: none;
  transition: background 0.15s;
}
.skill-group-header-open { border-radius: 10px 10px 0 0; border-bottom-color: transparent; }
.skill-group-header:hover { background: #f7f8fc; }
.skill-group-title { font-size: 15px; font-weight: 700; color: #1a1a2e; }
.skill-group-count { font-size: 12px; color: #8c8c8c; }
.skill-group-calls { font-size: 12px; padding: 2px 8px; background: #e6f4ff; color: #1677ff; border-radius: 10px; font-weight: 600; }
.skill-group-owner { font-size: 12px; color: #8c8c8c; }
.skill-group-toggle { font-size: 12px; color: #aaa; flex-shrink: 0; }

.skill-table {
  width: 100%; border-collapse: collapse;
  background: #fff; border-radius: 0 0 10px 10px;
  border: 1px solid #e8eaf0; border-top: none;
  overflow: hidden;
}
.skill-table thead tr { background: #f7f8fc; }
.skill-table th {
  padding: 9px 16px; font-size: 12px; font-weight: 600;
  color: #8c8c8c; text-align: left; border-bottom: 1px solid #e8eaf0;
  white-space: nowrap;
}
.skill-table-row { cursor: pointer; transition: background 0.1s; }
.skill-table-row:hover { background: #f5f7ff; }
.skill-table-row-active { background: #f0f5ff; }
.skill-table-row td { padding: 11px 16px; border-bottom: 1px solid #f2f3f8; vertical-align: middle; white-space: nowrap; }
.skill-table-row td.skill-table-desc { white-space: normal; }
.skill-table-name { font-size: 13px; font-weight: 600; color: #1677ff; font-family: 'SF Mono', 'Fira Code', monospace; }
.skill-table-desc { font-size: 13px; color: #555; line-height: 1.4; }
.skill-table-calls { font-size: 13px; font-weight: 600; color: #1677ff; cursor: pointer; }
.skill-table-calls:hover { text-decoration: underline; }
.skill-table-detail-row td { padding: 0; border-bottom: 1px solid #e8eaf0; }
.skill-table-detail {
  padding: 14px 20px 16px; background: #f8f9ff;
  display: flex; gap: 32px;
}
.skill-table-detail-block { flex: 1; }
.skill-table-detail-label { font-size: 11px; color: #aaa; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.skill-table-detail-text { font-size: 12px; color: #444; line-height: 1.6; }

.prompt-item { font-size: 12px; color: #666; padding: 2px 0; }
.prompt-item::before { content: '💬 '; }

.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.skill-card {
  background: #fff;
  border-radius: 10px;
  padding: 18px;
  border: 1px solid #f0f0f0;
  transition: box-shadow 0.15s;
  cursor: pointer;
}
.skill-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
.skill-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.skill-name { font-size: 14px; font-weight: 600; color: #1a1a2e; font-family: 'SF Mono', monospace; }
.skill-desc { font-size: 13px; color: #666; margin-bottom: 10px; line-height: 1.5; }
.skill-links { display: flex; gap: 12px; margin-bottom: 10px; }
.skill-owner { font-size: 12px; color: #8c8c8c; }
.skill-count { font-size: 12px; color: #1677ff; font-weight: 500; cursor: pointer; }
.skill-count:hover { text-decoration: underline; }
.skill-detail-expand { margin-top: 12px; padding-top: 12px; border-top: 1px solid #f0f0f0; }
.skill-detail-section { margin-bottom: 12px; }
.skill-detail-label { font-size: 11px; color: #aaa; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.skill-detail-val { font-size: 13px; color: #333; line-height: 1.6; }
.skill-img-placeholder {
  background: linear-gradient(135deg, #e6f4ff 0%, #f0f9ff 100%);
  border: 1px dashed #91caff;
  border-radius: 8px;
  height: 120px;
  display: flex; align-items: center; justify-content: center;
  color: #1677ff; font-size: 13px;
  margin-top: 8px;
}

/* ───── Publish ───── */
.publish-layout { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: flex-start; }
.form-card { background: #fff; border-radius: 10px; padding: 28px; }
.side-card { background: #fff; border-radius: 10px; padding: 20px; }
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: #333; }
.form-label .req { color: #ff4d4f; margin-left: 2px; }
.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
.form-input:focus { border-color: #4da6ff; box-shadow: 0 0 0 2px rgba(77,166,255,0.15); }
textarea.form-input { resize: vertical; min-height: 80px; }
.btn { padding: 8px 20px; border-radius: 6px; font-size: 13px; cursor: pointer; border: none; font-weight: 500; transition: all 0.15s; }
.btn-primary { background: #1677ff; color: #fff; }
.btn-primary:hover { background: #0958d9; }
.btn-success { background: #52c41a; color: #fff; }
.btn-danger  { background: #ff4d4f; color: #fff; }
.btn-default { background: #fff; color: #333; border: 1px solid #d9d9d9; }
.btn-default:hover { border-color: #4da6ff; color: #4da6ff; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.tab-bar { display: flex; gap: 0; border-bottom: 2px solid #f0f0f0; margin-bottom: 24px; }
.tab-item { padding: 10px 20px; cursor: pointer; font-size: 14px; color: #666; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; }
.tab-item.active { color: #1677ff; border-bottom-color: #1677ff; font-weight: 500; }
.tab-item:hover { color: #1677ff; }
.upload-zone {
  border: 2px dashed #d9d9d9;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  color: #aaa;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 8px;
}
.upload-zone:hover { border-color: #4da6ff; color: #4da6ff; }

/* ───── Review ───── */
.review-item { background: #fff; border-radius: 10px; padding: 20px; margin-bottom: 12px; border: 1px solid #f0f0f0; }
.review-item.is-update { border-left: 3px solid #fa8c16; }
.review-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.review-field { margin-bottom: 10px; }
.review-field-label { font-size: 11px; color: #8c8c8c; margin-bottom: 4px; }
.review-field-value { font-size: 13px; color: #333; }
.review-edit-input { width: 100%; padding: 6px 10px; border: 1px solid #d9d9d9; border-radius: 5px; font-size: 13px; outline: none; font-family: inherit; }
.review-edit-input:focus { border-color: #4da6ff; }
.review-actions { display: flex; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid #f0f0f0; align-items: center; }
.diff-old { background: #fff2f0; color: #cf1322; text-decoration: line-through; padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.diff-new { background: #f6ffed; color: #389e0d; padding: 1px 4px; border-radius: 3px; font-size: 12px; }
.diff-row { display: flex; align-items: flex-start; gap: 8px; margin: 3px 0; }

/* ───── History expand ───── */
.history-row { cursor: pointer; }
.history-row:hover td { background: #f0f7ff; }
.history-detail { background: #fafbff; }
.history-detail td { padding: 12px 16px; }

/* ───── Drawer ───── */
.drawer-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.35);
  z-index: 200;
  display: flex;
  justify-content: flex-end;
}
.drawer {
  width: 540px;
  background: #fff;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,0.12);
}
.drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid #f0f0f0;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0;
  background: #fff; z-index: 1;
}
.drawer-title { font-size: 15px; font-weight: 600; }
.drawer-close { cursor: pointer; color: #aaa; font-size: 20px; line-height: 1; padding: 4px; }
.drawer-close:hover { color: #333; }
.drawer-body { padding: 16px 20px; flex: 1; overflow-y: auto; min-height: 0; }

/* ───── Search / filter bar ───── */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.search-input { padding: 7px 12px; border: 1px solid #d9d9d9; border-radius: 6px; font-size: 13px; outline: none; width: 240px; }
.search-input:focus { border-color: #4da6ff; }
.select-input { padding: 7px 12px; border: 1px solid #d9d9d9; border-radius: 6px; font-size: 13px; outline: none; background: #fff; }

/* ───── Alerts ───── */
.alert { padding: 10px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 13px; }
.alert-success { background: #f6ffed; border: 1px solid #b7eb8f; color: #389e0d; }
.alert-info    { background: #e6f4ff; border: 1px solid #91caff; color: #0958d9; }
.alert-warn    { background: #fffbe6; border: 1px solid #ffe58f; color: #d46b08; }

/* ───── Misc ───── */
.section-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.divider { height: 1px; background: #f0f0f0; margin: 16px 0; }

/* ───── Modal overlay ───── */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.35); z-index: 300; display: flex; align-items: center; justify-content: center; }
