* { box-sizing: border-box; }
:root {
  --c: #2f6bff; --c2: #e8efff; --bd: #e5e8ef; --bg: #f4f6fa; --tx: #1f2430; --mu: #8a92a6;
  --ok: #19b36b; --warn: #f5a623; --err: #e5484d;
}
html, body { margin: 0; height: 100%; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--tx); background: var(--bg); }
button { font: inherit; cursor: pointer; border: 1px solid var(--bd); background: #fff; border-radius: 6px; padding: 5px 12px; color: var(--tx); }
button:hover { border-color: var(--c); color: var(--c); }
button.primary { background: var(--c); border-color: var(--c); color: #fff; }
button.primary:hover { opacity: .9; color: #fff; }
button.danger { color: var(--err); }
button.danger:hover { border-color: var(--err); }
button.sm { padding: 2px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; border: 1px solid var(--bd); border-radius: 6px; padding: 6px 10px; outline: none; background: #fff; color: var(--tx); }
input:focus, select:focus, textarea:focus { border-color: var(--c); }
a { color: var(--c); }
.muted { color: var(--mu); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* login */
.login { height: 100%; display: flex; align-items: center; justify-content: center; }
.login form { width: 340px; background: #fff; padding: 32px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.06); display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin: 0 0 8px; font-size: 22px; text-align: center; }
.login input { padding: 10px 12px; }
.login button { padding: 10px; }

/* shell */
.shell { height: 100%; display: flex; flex-direction: column; }
.top { height: 52px; background: #1d2333; color: #fff; display: flex; align-items: center; padding: 0 16px; gap: 6px; flex-shrink: 0; }
.top .logo { font-weight: 600; font-size: 16px; margin-right: 18px; }
.top nav button { background: transparent; border: 0; color: #b8c0d4; padding: 6px 12px; }
.top nav button.on, .top nav button:hover { color: #fff; background: rgba(255,255,255,.08); }
.top .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.top select { background: #2a3146; color: #fff; border-color: #3a4260; padding: 4px 8px; }
.top .link { background: none; border: 0; color: #b8c0d4; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #c3c8d4; vertical-align: middle; }
.dot.online { background: var(--ok); } .dot.away { background: var(--warn); }
main { flex: 1; min-height: 0; overflow: auto; }
.page { padding: 20px 24px; max-width: 1200px; }
.page h2 { margin: 0 0 16px; font-size: 18px; }

/* workbench */
.work { display: flex; height: 100%; }
.list { width: 290px; background: #fff; border-right: 1px solid var(--bd); display: flex; flex-direction: column; }
.tabs { display: flex; border-bottom: 1px solid var(--bd); }
.tabs button { flex: 1; border: 0; border-radius: 0; padding: 10px 0; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--c); border-bottom-color: var(--c); }
.tabs .n { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bg); font-size: 12px; margin-left: 4px; }
.tabs .n.hot { background: var(--err); color: #fff; }
#convList { flex: 1; overflow: auto; }
.ci { padding: 10px 14px; border-bottom: 1px solid #f1f2f6; cursor: pointer; position: relative; }
.ci:hover { background: #f8f9fc; }
.ci.on { background: var(--c2); }
.ci .l1 { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.ci .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci .t { color: var(--mu); font-size: 12px; flex-shrink: 0; }
.ci .l2 { color: var(--mu); font-size: 12px; display: flex; gap: 6px; margin-top: 2px; }
.ci .l2 .last { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--err); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; line-height: 17px; }
.tag { display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px; background: var(--bg); color: var(--mu); line-height: 18px; }
.tag.blue { background: var(--c2); color: var(--c); }
.tag.green { background: #e3f7ee; color: var(--ok); }
.tag.orange { background: #fff4e0; color: #c7820f; }
.empty { padding: 40px 20px; text-align: center; color: var(--mu); }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.chat-hd { height: 56px; background: #fff; border-bottom: 1px solid var(--bd); display: flex; align-items: center; padding: 0 16px; gap: 10px; flex-shrink: 0; }
.chat-hd .title { font-weight: 600; font-size: 15px; }
.msgs { flex: 1; overflow: auto; padding: 16px 20px; }
.m { display: flex; flex-direction: column; margin: 10px 0; align-items: flex-start; }
.m.out { align-items: flex-end; }
.m .meta { font-size: 12px; color: var(--mu); margin-bottom: 3px; }
.bubble { max-width: 70%; padding: 8px 12px; border-radius: 10px; background: #fff; white-space: pre-wrap; word-break: break-word; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.m.out .bubble { background: var(--c); color: #fff; }
.bubble img { max-width: 240px; max-height: 240px; border-radius: 6px; display: block; cursor: zoom-in; }
.sys { text-align: center; color: var(--mu); font-size: 12px; margin: 12px 0; }
.sys span { background: #e9ecf3; padding: 2px 10px; border-radius: 10px; }
.typing { padding: 0 20px 6px; color: var(--mu); font-size: 12px; min-height: 0; }
.composer { background: #fff; border-top: 1px solid var(--bd); padding: 10px 14px; }
.composer textarea { width: 100%; border: 0; resize: none; height: 80px; padding: 4px 0; }
.composer .tools { display: flex; align-items: center; gap: 10px; }
.composer .tools label { cursor: pointer; color: var(--mu); }
.composer .tools label:hover { color: var(--c); }
.composer .quick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.composer .quick button { font-size: 12px; padding: 1px 8px; border-radius: 12px; color: var(--mu); }
.readonly { padding: 14px; text-align: center; color: var(--mu); background: #fff; border-top: 1px solid var(--bd); }

.info { width: 280px; background: #fff; border-left: 1px solid var(--bd); overflow: auto; padding: 16px; }
.info h4 { margin: 16px 0 8px; font-size: 13px; color: var(--mu); font-weight: 500; }
.info h4:first-child { margin-top: 0; }
.kv { display: grid; grid-template-columns: 64px 1fr; gap: 6px 8px; font-size: 13px; }
.kv .k { color: var(--mu); }
.kv .v { word-break: break-all; }

/* tables / cards */
.card { background: #fff; border-radius: 10px; border: 1px solid var(--bd); padding: 16px 18px; margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; border: 1px solid var(--bd); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #f0f1f5; font-size: 13px; }
th { background: #fafbfd; color: var(--mu); font-weight: 500; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f8f9fc; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--c2); color: var(--c); border-radius: 14px; padding: 2px 4px 2px 10px; font-size: 13px; }
.chip button { border: 0; background: none; color: var(--c); padding: 0 4px; line-height: 1; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: #f6f7fa; border: 1px solid var(--bd); border-radius: 6px; padding: 8px 10px; white-space: pre-wrap; word-break: break-all; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 13px; color: var(--mu); }
.stats { display: flex; gap: 16px; margin-bottom: 16px; }
.stats .card { flex: 1; margin: 0; }
.stats b { font-size: 24px; display: block; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }

/* modal */
.mask { position: fixed; inset: 0; background: rgba(15,20,35,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 12px; width: 520px; max-width: 94vw; max-height: 88vh; display: flex; flex-direction: column; }
.modal.wide { width: 760px; }
.modal .mh { padding: 14px 18px; border-bottom: 1px solid var(--bd); font-weight: 600; display: flex; justify-content: space-between; }
.modal .mh button { border: 0; font-size: 18px; padding: 0 6px; }
.modal .mb { padding: 18px; overflow: auto; }
.modal .mf { padding: 12px 18px; border-top: 1px solid var(--bd); display: flex; justify-content: flex-end; gap: 8px; }
.modal .msgs { background: var(--bg); border-radius: 8px; max-height: 60vh; }

#toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
#toast div { background: #1d2333; color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.15); }
#toast div.err { background: var(--err); }

@media (max-width: 900px) { .info { display: none; } .list { width: 230px; } }
.chat-hd > * { white-space: nowrap; flex-shrink: 0; }
.chat-hd .title { flex-shrink: 1; overflow: hidden; text-overflow: ellipsis; min-width: 40px; }
.chat-hd select { max-width: 180px; }
