/* UEX Community 代理后台样式 */
:root {
  --bg: #0b0c0e;
  --panel: #121417;
  --panel-2: #171a1e;
  --line: #23272d;
  --text: #e9edf1;
  --muted: #8f9aa5;
  --primary: #05c3dd;
  --primary-dark: #0499ad;
  --primary-soft: rgba(5, 195, 221, .12);
  --danger: #ef4f6b;
  --gold: #d8a534;
}

* { box-sizing: border-box; }

/* hidden 属性要压过下面 .app / .modal / .emoji-panel 的 display 声明 */
[hidden] { display: none !important; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Roboto, Arial, sans-serif;
}

button, input, select, textarea { font: inherit; color: inherit; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { border-radius: 999px; background: rgba(5, 195, 221, .35); }
::-webkit-scrollbar-thumb:hover { background: rgba(5, 195, 221, .55); }
* { scrollbar-width: thin; scrollbar-color: rgba(5, 195, 221, .35) transparent; }

.brand { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 800; }
.brand span {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  color: #04252b; background: linear-gradient(135deg, #17e0e0, var(--primary)); font-weight: 900;
}

.btn {
  padding: 10px 16px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel-2); font-weight: 700; cursor: pointer;
}
.btn:hover { border-color: rgba(5, 195, 221, .4); }
.btn.primary { border-color: transparent; color: #04252b; background: linear-gradient(135deg, #17e0e0, var(--primary)); }
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.mini {
  padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel-2); font-size: 12px; font-weight: 700; cursor: pointer;
}
.mini:hover { border-color: rgba(5, 195, 221, .4); }
.mini.primary { border-color: transparent; color: #04252b; background: linear-gradient(135deg, #17e0e0, var(--primary)); }
.mini.danger { border-color: rgba(239, 79, 107, .4); color: var(--danger); }

.empty { padding: 28px 16px; color: var(--muted); text-align: center; }

/* 登录 */
.login-screen { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card {
  width: min(100%, 380px); padding: 26px; border: 1px solid var(--line);
  border-radius: 18px; background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}
.login-card h1 { margin: 18px 0 4px; font-size: 20px; }
.login-card p { margin: 0 0 18px; color: var(--muted); }
.login-card label, .modal-card label, .profile-form label { display: block; margin-bottom: 13px; font-size: 13px; color: var(--muted); }
.login-card input, .login-card select, .modal-card input, .modal-card select, .modal-card textarea,
.profile-form input, .profile-form select, .profile-form textarea, .start-chat input, .post-form textarea, .message-form textarea,
.ai-chat-controls select {
  width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); background: var(--panel-2);
}
.login-card input:focus, .modal-card input:focus, .profile-form input:focus, .profile-form textarea:focus,
.post-form textarea:focus, .message-form textarea:focus {
  outline: none; border-color: rgba(5, 195, 221, .5);
}
.login-card .btn { width: 100%; margin-top: 4px; }
.error { margin-top: 12px; color: var(--danger); font-size: 13px; min-height: 18px; }

/* 外壳 */
.app { display: flex; flex-direction: column; height: 100vh; min-height: 0; overflow: hidden; }
.app > header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-shrink: 0;
  padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.agent-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.agent-meta small { color: var(--muted); }
.agent-meta button {
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel-2); font-size: 12px; font-weight: 700; cursor: pointer;
}
.agent-meta button:hover { border-color: rgba(5, 195, 221, .4); }
.agent-meta b {
  display: inline-grid; min-width: 18px; height: 18px; place-items: center; margin-left: 5px;
  border-radius: 9px; color: #fff; background: var(--danger); font-size: 10px;
}
.product-switch {
  display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px;
}
.product-switch select {
  padding: 6px 28px 6px 10px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--text); background: var(--panel-2); font-weight: 700;
}

body[data-product="counseling"] {
  --primary: #66c7b5;
  --primary-dark: #3ba18f;
  --primary-soft: rgba(102, 199, 181, .13);
}
body[data-product="counseling"] .brand span,
body[data-product="counseling"] .avatar-fallback,
body[data-product="counseling"] .btn.primary,
body[data-product="counseling"] .mini.primary,
body[data-product="counseling"] .message.mine .bubble,
body[data-product="counseling"] .toast {
  background: linear-gradient(135deg, #a9e6d6, #66c7b5);
}
.tag.level-junior { color: #8ed7c8; background: rgba(102, 199, 181, .14); }
.tag.level-intermediate { color: #b8a7f2; background: rgba(139, 92, 246, .16); }
.tag.level-senior { color: #f0d089; background: rgba(216, 165, 52, .16); }
.interaction-alert b { background: #8b5cf6; }

main {
  display: grid; grid-template-columns: 288px minmax(0, 1fr); gap: 16px;
  flex: 1; min-height: 0; padding: 16px; align-items: stretch; overflow: hidden;
}

.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  border: 1px solid var(--line); border-radius: 16px; background: var(--panel); overflow: hidden;
}
.side-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 14px; border-bottom: 1px solid var(--line);
}
.account-list { flex: 1; min-height: 0; overflow: auto; }
.account-item {
  display: grid; grid-template-columns: 38px minmax(0, 1fr) auto auto; align-items: center; gap: 10px;
  width: 100%; padding: 11px 14px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; text-align: left; cursor: pointer;
}
.account-item:hover { background: var(--panel-2); }
.account-item.active { background: var(--primary-soft); }
.account-item img, .avatar-fallback {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
}
.avatar-fallback {
  display: grid; place-items: center; color: #04252b;
  background: linear-gradient(135deg, #17e0e0, var(--primary)); font-weight: 800;
}
.account-info { min-width: 0; }
.account-info strong, .account-info small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-info small { color: var(--muted); font-size: 12px; }
.tag {
  display: inline-block; margin-left: 5px; padding: 1px 6px; border-radius: 999px;
  font-size: 10px; font-style: normal; font-weight: 800;
  color: var(--muted); background: var(--panel-2);
}
.tag.verified { color: var(--primary); background: var(--primary-soft); }
.tag.member { color: #f0d089; background: rgba(216, 165, 52, .16); }
.unread {
  display: inline-grid; min-width: 19px; height: 19px; place-items: center; padding: 0 5px;
  border-radius: 10px; color: #fff; background: var(--danger); font-size: 10px;
}
.unread.soft { background: #8b5cf6; }

.workspace {
  display: flex; flex-direction: column; min-height: 0;
  border: 1px solid var(--line); border-radius: 16px; background: var(--panel); overflow: hidden;
}
.workspace-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  flex-shrink: 0;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
}
#accountWorkspace { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.selected-user { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.workspace-head nav { display: flex; gap: 8px; }
.workspace-head nav button {
  padding: 8px 15px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel-2); font-size: 13px; font-weight: 700; cursor: pointer;
}
.workspace-head nav button.active { border-color: rgba(5, 195, 221, .45); color: var(--primary); background: var(--primary-soft); }
.workspace-head nav button b {
  display: inline-grid; min-width: 18px; height: 18px; place-items: center; margin-left: 4px;
  border-radius: 9px; color: #fff; background: var(--danger); font-size: 10px;
}

.tab-panel { display: none; padding: 16px; }
.tab-panel.active { display: block; flex: 1; min-height: 0; overflow: auto; }
.tab-panel.active[data-panel="collect"] { display: flex; flex-direction: column; overflow: hidden; }
.tab-panel.active[data-panel="collect"] .post-toolbar,
.tab-panel.active[data-panel="collect"] #collectHint { flex-shrink: 0; }
#collectList { flex: 1; min-height: 0; overflow: auto; padding-right: 4px; }

.card { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); }

/* 聊天 */
.chat-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 14px; }
.threads { border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); overflow: hidden; }
.start-chat { display: flex; gap: 8px; padding: 11px; border-bottom: 1px solid var(--line); }
.start-chat input { margin-top: 0; }
.thread-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px;
  width: 100%; padding: 11px 12px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; text-align: left; cursor: pointer;
}
.thread-item:hover { background: var(--panel); }
.thread-item.active { background: var(--primary-soft); }
.thread-item strong, .thread-item small { display: block; grid-column: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-item small { color: var(--muted); font-size: 12px; }
.thread-item .unread { grid-column: 2; grid-row: 1 / span 2; }

.conversation {
  display: flex; flex-direction: column; min-height: 520px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2);
}
.chat-head { border-bottom: 1px solid var(--line); }
.chat-title { padding: 12px 14px 8px; font-weight: 700; }
.ai-chat-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 0 14px 11px; }
.ai-chat-controls select { width: auto; max-width: 150px; margin-top: 0; padding: 7px 9px; }
.ai-toggle { display: flex; align-items: center; gap: 5px; margin: 0; color: var(--muted); font-size: 12px; white-space: nowrap; }
.ai-toggle input, .switch-line input { width: auto; margin: 0; accent-color: var(--primary); }

.messages { flex: 1; min-height: 260px; max-height: 46vh; overflow: auto; padding: 14px; }
.message { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 12px; }
.message.mine { align-items: flex-end; }
.message .bubble {
  max-width: 72%; padding: 9px 12px; border-radius: 14px; background: var(--panel);
  border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word;
}
.message.mine .bubble { color: #04252b; border-color: transparent; background: linear-gradient(135deg, #17e0e0, var(--primary)); }
.message .bubble img, .message .bubble video { display: block; max-width: 260px; border-radius: 10px; }
.message small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.message .translated {
  display: block; margin-top: 7px; padding-top: 7px;
  border-top: 1px dashed rgba(143, 154, 165, .35); color: var(--muted); font-size: 12px; font-style: normal;
}
.message .translated::before { content: "译文"; margin-right: 6px; color: var(--primary); font-weight: 800; }

.ai-replies { max-height: 300px; overflow: auto; padding: 12px 14px; border-top: 1px solid var(--line); background: var(--panel); }
.ai-replies-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.ai-replies-head button { border: 0; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; }
.ai-reply-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.ai-reply {
  display: grid; gap: 5px; padding: 11px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel-2); text-align: left; cursor: pointer;
}
.ai-reply:hover { border-color: rgba(5, 195, 221, .45); }
.ai-reply strong { color: var(--primary); font-size: 12px; }
.ai-reply span { font-size: 13px; }
.ai-reply em { color: var(--muted); font-size: 12px; font-style: normal; }

.send-preview { padding: 12px 14px; border-top: 1px solid var(--line); background: var(--panel); }
.send-preview-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.send-preview-head small { color: var(--muted); }
.send-preview textarea {
  width: 100%; min-height: 72px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); background: var(--panel-2); resize: vertical;
}
.send-preview-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 9px; }

.message-form {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 9px;
  padding: 12px 14px; border-top: 1px solid var(--line);
}
.message-form textarea { min-height: 46px; max-height: 140px; margin-top: 0; resize: vertical; }
.message-tools { display: flex; align-items: center; gap: 5px; }
.emoji-button, .media-button { width: 38px; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); cursor: pointer; }
.emoji-button:hover, .media-button:hover { border-color: rgba(5, 195, 221, .5); background: rgba(5, 195, 221, .08); }
.media-button:disabled { opacity: .45; cursor: wait; }
.emoji-panel {
  position: absolute; bottom: 62px; left: 14px; z-index: 5;
  display: grid; grid-template-columns: repeat(8, 30px); gap: 3px; max-height: 190px; overflow: auto;
  padding: 9px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  box-shadow: 0 16px 36px rgba(0, 0, 0, .45);
}
.emoji-panel button { width: 30px; height: 30px; border: 0; border-radius: 7px; background: transparent; font-size: 17px; cursor: pointer; }
.emoji-panel button:hover { background: var(--panel-2); }

/* 帖子 */
.post-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.post-toolbar select {
  min-width: 220px; max-width: min(360px, 100%); padding: 7px 34px 7px 11px;
  border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); background: var(--panel-2);
}
.post-toolbar select:focus { outline: none; border-color: rgba(5, 195, 221, .55); }
.post-toolbar select option { color: #e9edf1; background: #171a1e; }
.post-toolbar b {
  display: inline-grid; min-width: 18px; height: 18px; place-items: center; margin-left: 5px;
  border-radius: 9px; color: #fff; background: #8b5cf6; font-size: 10px;
}
.post-form { margin-bottom: 14px; }
.post-form textarea { min-height: 78px; margin-top: 0; resize: vertical; }
.post-form .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.post { margin-bottom: 12px; }
.post header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.post header small { color: var(--muted); font-size: 12px; }
.post-body { white-space: pre-wrap; word-break: break-word; }
.post-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 10px; }
.post-images img { width: 100%; height: 110px; border-radius: 10px; object-fit: cover; }
.post footer { display: flex; gap: 8px; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
.comments { margin-top: 10px; padding-top: 9px; border-top: 1px dashed var(--line); }
.comment { color: var(--muted); font-size: 13px; margin-bottom: 5px; }
.comment strong { color: var(--text); }
.notification.unread-card { border-color: rgba(5, 195, 221, .4); }
.notification header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.notification header small { color: var(--muted); font-size: 12px; }
.notification footer { margin-top: 9px; }

/* 资料 */
.profile-form .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.profile-form textarea { min-height: 84px; resize: vertical; }

/* 弹层 */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); }
.modal-card {
  position: relative; width: min(100%, 560px); max-height: 88vh; overflow: auto;
  padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel);
  box-shadow: 0 26px 60px rgba(0, 0, 0, .5);
}
.modal-card h2 { margin: 0 0 6px; font-size: 18px; }
.modal-note { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.modal-card .close {
  position: absolute; top: 12px; right: 12px; width: 30px; height: 30px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); cursor: pointer;
}
.modal-card .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.modal-card textarea { min-height: 92px; resize: vertical; }
.modal-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.modal-card .btn { width: 100%; margin-top: 6px; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { width: auto; flex: 1; }
.modal-card.ask-card { width: min(100%, 420px); }
.modal-card.ask-card .modal-note { margin-bottom: 14px; }
.modal-card.ask-card textarea { min-height: 84px; }
.btn.danger { border-color: transparent; color: #fff; background: linear-gradient(135deg, #ff7a8a, var(--danger)); }
.btn.danger:hover { filter: brightness(1.06); }
.switch-line { display: flex; align-items: center; gap: 8px; color: var(--text) !important; }
.field-hint { display: block; margin: -8px 0 12px; color: var(--muted); font-size: 12px; }
.ai-provider-help { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 12px; }
.ai-provider-help a {
  padding: 6px 10px; border-radius: 9px; color: var(--primary); background: var(--primary-soft);
  font-size: 12px; font-weight: 800; text-decoration: none;
}
.batch-label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.batch-label-row small { margin: 0; color: var(--primary); font-weight: 800; white-space: nowrap; }
.batch-allocation { margin: 14px 0; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-2); }
.batch-allocation-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.batch-allocation-head small { color: var(--muted); }
.batch-allocation-list {
  max-height: 200px; overflow: auto; margin-top: 9px; padding: 4px 0;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
}
.batch-allocation-list div {
  padding: 6px 10px; border-bottom: 1px solid var(--line); color: var(--muted);
  font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.batch-allocation-list div:last-child { border-bottom: 0; }
.batch-allocation-list b { color: var(--primary); }

.toast {
  position: fixed; z-index: 240; top: 20px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: flex-start; gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px; border: 1px solid var(--line); border-radius: 14px;
  color: #04252b; background: linear-gradient(135deg, #17e0e0, var(--primary));
  font-size: 13px; font-weight: 700; line-height: 1.5; text-align: left;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
  cursor: pointer; animation: toast-in .18s ease-out;
}
.toast.error { color: #fff; background: var(--danger); border-color: transparent; }
.toast .toast-ico { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.toast .toast-ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toast .toast-text { min-width: 0; overflow-wrap: anywhere; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 1080px) {
  html, body { height: auto; }
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; overflow: visible; }
  main { grid-template-columns: 1fr; overflow: visible; }
  .account-list { max-height: 260px; }
  .workspace { min-height: calc(100vh - 120px); overflow: hidden; }
  .chat-layout { grid-template-columns: 1fr; }
  .product-switch { width: 100%; order: -1; }
}
