:root {
  --brand: #1e6bff;
  --brand-dark: #1557d6;
  --brand-soft: #eaf1ff;
  --bg: #f4f6fa;
  --card: #fff;
  --text: #1f2329;
  --muted: #8a919f;
  --line: #e6e8ee;
  --danger: #e5484d;
  --success: #16a34a;
  --warn: #d97706;
  --radius: 10px;
  --side: 220px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif; font-size: 14px; line-height: 1.6; color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, Menlo, monospace; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }
[hidden] { display: none !important; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; white-space: nowrap; font-size: 14px; color: var(--text); text-decoration: none !important; }
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f3c4c6; }
.btn.danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.link { border: 0; background: none; color: var(--brand); padding: 0 4px; height: auto; }
.btn.link.danger { color: var(--danger); }
.btn.link:hover { text-decoration: underline; background: none; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* 表单 */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: #4e5969; margin-bottom: 5px; font-weight: 500; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=url], input:not([type]), select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; outline: none; font-size: 14px;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(30,107,255,.12); }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; margin-right: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.form-err { color: var(--danger); font-size: 13px; margin: -4px 0 12px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* 登录 */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(135deg, #eaf1ff, #f4f6fa 60%); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 32px 28px; box-shadow: 0 10px 40px rgba(30,107,255,.12); }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; }
.login-brand b { display: block; font-size: 18px; }
.login-brand span { color: var(--muted); font-size: 13px; }

/* 首页 */
.home-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: #fff; border-bottom: 1px solid var(--line); }
.home-brand { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.home-main { max-width: 1040px; margin: 0 auto; padding: 32px 20px 80px; }
.hero h1 { font-size: 30px; margin: 10px 0 12px; line-height: 1.35; }
.hero p { color: #4e5969; font-size: 15px; max-width: 760px; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 28px 0; }
.features div { background: #fff; border-radius: var(--radius); padding: 16px; border: 1px solid var(--line); }
.features b { display: block; margin-bottom: 4px; }
.features span { color: var(--muted); font-size: 13px; }
.demo-list { display: flex; gap: 14px; flex-wrap: wrap; }
.demo { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; min-width: 240px; text-decoration: none !important; color: var(--text); }
.demo:hover { border-color: var(--brand); }
.demo b { display: block; }
.demo span { color: var(--brand); font-size: 13px; }
.home footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

/* 后台布局 */
.layout { display: flex; min-height: 100vh; }
.side { width: var(--side); background: #fff; border-right: 1px solid var(--line); position: fixed; top: 0; bottom: 0; left: 0; display: flex; flex-direction: column; z-index: 30; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; font-weight: 600; font-size: 15px; border-bottom: 1px solid var(--line); }
.side nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.side nav a { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px; color: #4e5969; margin-bottom: 2px; text-decoration: none; }
.side nav a:hover { background: var(--bg); }
.side nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.side .foot { padding: 12px 18px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.main { flex: 1; margin-left: var(--side); min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 20px; gap: 12px; position: sticky; top: 0; z-index: 20; }
.topbar .title { font-size: 16px; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .user { display: flex; gap: 8px; align-items: center; }
.menu-btn { display: none; border: 0; background: none; font-size: 22px; cursor: pointer; padding: 4px 8px; }
.content { padding: 20px; flex: 1; }
.banner { background: #fff7e6; border: 1px solid #ffe0a3; color: #8a5300; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.banner.info { background: var(--brand-soft); border-color: #c7d9ff; color: #1d4fb8; }
.side-mask { display: none; }

/* 卡片 */
.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); padding: 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 15px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar select, .toolbar input { width: auto; min-width: 140px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 24px; font-weight: 600; margin-top: 2px; }
.stat .s { font-size: 12px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .bar i { display: block; width: 70%; max-width: 32px; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar span { font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.bars .bar em { font-style: normal; font-size: 11px; color: #4e5969; }

.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.bot-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.bot-card .head { display: flex; gap: 10px; align-items: center; }
.bot-card .nums { display: flex; gap: 14px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.bot-card .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.bot-avatar { width: 40px; height: 40px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; overflow: hidden; flex: none; }
.bot-avatar img { width: 100%; height: 100%; object-fit: cover; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: #4e5969; border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none !important; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }

/* 表格 */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; min-width: 640px; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { background: #fafbfc; font-weight: 500; color: #4e5969; font-size: 13px; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: #fafcff; }
.tbl .ellipsis { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .actions { white-space: nowrap; text-align: right; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 12px 0 0; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.loading { text-align: center; color: var(--muted); padding: 40px 10px; }
.tag { display: inline-block; padding: 0 8px; border-radius: 10px; font-size: 12px; background: #f0f1f5; color: #4e5969; line-height: 20px; white-space: nowrap; }
.tag.blue { background: var(--brand-soft); color: var(--brand); }
.tag.green { background: #e7f8ee; color: var(--success); }
.tag.red { background: #fdecec; color: var(--danger); }
.tag.orange { background: #fff3e0; color: var(--warn); }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head b { font-size: 15px; }
.modal-head button { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 18px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #1f2329; color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 90vw; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.chunk { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.chunk .ch { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 6px; }
.chunk .ch b { font-size: 13px; }
.chunk .cc { white-space: pre-wrap; word-break: break-word; font-size: 13px; color: #333; max-height: 220px; overflow-y: auto; }
.msg { margin-bottom: 12px; }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.msg .txt { background: #f6f7f9; border-radius: 8px; padding: 8px 12px; white-space: pre-wrap; word-break: break-word; }
.msg.user .txt { background: var(--brand-soft); }
.code-box { background: #0f172a; color: #e2e8f0; border-radius: 8px; padding: 12px 14px; font-family: Consolas, Menlo, monospace; font-size: 13px; white-space: pre-wrap; word-break: break-all; margin: 6px 0 10px; }
.qr { display: inline-block; background: #fff; padding: 6px; border: 1px solid var(--line); border-radius: 8px; }
.qr svg { display: block; }
.decision { background: #f6f9ff; border: 1px solid #d7e4ff; border-radius: 8px; padding: 12px; margin-bottom: 14px; }
.kv { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.avatar-row { display: flex; gap: 10px; align-items: center; }
.avatar-row input[type=text] { flex: 1; }

@media (max-width: 900px) {
  .features { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .side { transform: translateX(-100%); transition: transform .2s; }
  .layout.nav-open .side { transform: none; box-shadow: 0 0 30px rgba(0,0,0,.15); }
  .layout.nav-open .side-mask { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 25; }
  .main { margin-left: 0; }
  .menu-btn { display: block; }
  .content { padding: 12px; }
  .topbar { padding: 0 10px; }
  .topbar .user .uname { display: none; }
  .grid2, .grid3, .features { grid-template-columns: 1fr; }
  .hero h1 { font-size: 23px; }
  .toolbar select, .toolbar input { min-width: 0; flex: 1 1 140px; }
  .modal-mask { padding: 12px 8px; }
  .card { padding: 14px; }
}
