:root {
  --brand: #10b981;
  --brand-dark: #0e9f6e;
  --brand-soft: #ecfdf5;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #7b8794;
  --border: #e4e7eb;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.08);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select {
  font-family: inherit; font-size: 14px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px; outline: none; width: 100%;
  background: #fff; color: var(--text);
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); }
.btn {
  border: none; border-radius: 8px; padding: 10px 16px; font-size: 14px; font-weight: 600;
  background: var(--brand); color: #fff; transition: background .15s;
}
.btn:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: #f0f2f5; }
.btn.danger { background: #ef4444; }
.btn.danger:hover { background: #dc2626; }
.btn.sm { padding: 6px 10px; font-size: 13px; }

/* ---------- 登录 ---------- */
.login-wrap {
  height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, #0e9f6e 0%, #10b981 50%, #34d399 100%);
}
.login-card {
  width: 380px; max-width: 100%; background: #fff; border-radius: 16px; padding: 36px 32px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand .logo {
  width: 44px; height: 44px; border-radius: 12px; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 800;
}
.brand .name { font-size: 22px; font-weight: 800; }
.brand .sub { font-size: 12px; color: var(--muted); }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.login-card .btn { width: 100%; margin-top: 6px; }
.login-tip { font-size: 12px; color: var(--muted); text-align: center; margin-top: 16px; cursor: pointer; }
.login-tip:hover { color: var(--brand); }
.err { color: #ef4444; font-size: 13px; min-height: 18px; margin-bottom: 6px; }

/* ---------- 主框架 ---------- */
.topbar {
  height: 56px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
}
.topbar .brand .logo { width: 34px; height: 34px; font-size: 17px; border-radius: 9px; }
.topbar .brand .name { font-size: 17px; }
.spacer { flex: 1; }
.badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.topbar .uname { font-size: 14px; color: var(--muted); }

.layout { display: flex; height: calc(100vh - 56px); }
.sidebar {
  width: 268px; background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.sidebar .sb-head { padding: 14px 16px 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.agent-list { flex: 1; overflow-y: auto; padding: 0 10px; }
.agent-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  cursor: pointer; margin-bottom: 4px;
}
.agent-item:hover { background: #f0f2f5; }
.agent-item.active { background: var(--brand-soft); }
.agent-item .ava { width: 34px; height: 34px; border-radius: 9px; background: #f0f2f5; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.agent-item.active .ava { background: #fff; }
.agent-item .meta { overflow: hidden; }
.agent-item .nm { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-item .ds { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .sb-foot { padding: 12px; border-top: 1px solid var(--border); }

.chat { flex: 1; display: flex; flex-direction: column; background: var(--bg); }
.chat-head { padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--panel); font-weight: 600; display:flex; align-items:center; gap:10px; }
.chat-head .ava { width: 32px; height: 32px; border-radius: 8px; background: var(--brand-soft); display:flex; align-items:center; justify-content:center; font-size:16px; }
.messages { flex: 1; overflow-y: auto; padding: 22px; }
.msg { display: flex; gap: 12px; margin-bottom: 18px; }
.msg .ava { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.msg.user .ava { background: var(--brand); color: #fff; }
.msg.bot .ava { background: #fff; border: 1px solid var(--border); }
.bubble { max-width: 720px; padding: 12px 14px; border-radius: 12px; line-height: 1.6; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.msg.user .bubble { background: var(--brand); color: #fff; border-top-left-radius: 2px; }
.msg.bot .bubble { background: #fff; border: 1px solid var(--border); border-top-left-radius: 2px; }
.empty { color: var(--muted); text-align: center; margin-top: 18vh; font-size: 14px; }
.composer { padding: 14px 20px; background: var(--panel); border-top: 1px solid var(--border); }
.composer .box { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { resize: none; height: 48px; max-height: 140px; }
.composer .btn { height: 48px; white-space: nowrap; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { width: 720px; max-width: 100%; max-height: 86vh; background: #fff; border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; }
.modal .m-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal .m-head .t { font-weight: 700; font-size: 16px; }
.modal .m-close { margin-left: auto; background: none; border: none; font-size: 22px; color: var(--muted); line-height: 1; }
.modal .m-tabs { display: flex; gap: 4px; padding: 10px 20px 0; border-bottom: 1px solid var(--border); }
.modal .m-tab { padding: 10px 14px; border: none; background: none; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.modal .m-tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.modal .m-body { padding: 20px; overflow-y: auto; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.section-title { font-size: 13px; font-weight: 700; color: var(--muted); margin: 4px 0 12px; text-transform: none; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; }
.list-item .ava { width: 32px; height: 32px; border-radius: 8px; background: var(--brand-soft); display:flex; align-items:center; justify-content:center; font-size:16px; }
.list-item .meta { flex: 1; overflow: hidden; }
.list-item .nm { font-weight: 600; font-size: 14px; }
.list-item .ds { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #f0f2f5; color: var(--muted); }
.pwd-wrap { position: relative; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }

/* ICP 备案号占位 */
.icp-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 8px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255,255,255,0.9);
  border-top: 1px solid var(--border);
  z-index: 1000;
}
