* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* 不然 .login / .send-form 的 display 会盖掉 hidden，登录后登录框还挡在前面 */
body { margin: 0; font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color: #1f2329; background: #f5f6f8; }
button, input, select, textarea { font: inherit; }
button { padding: 5px 12px; border: 1px solid #d0d3d6; border-radius: 6px; background: #fff; cursor: pointer; }
button:hover { border-color: #1677ff; color: #1677ff; }
button.primary { background: #1677ff; border-color: #1677ff; color: #fff; }
button.primary:hover { background: #0f62d6; color: #fff; }
button.link { border: none; background: none; color: #1677ff; padding: 0 4px; }
button.danger { color: #d4380d; }
input, select, textarea { padding: 5px 8px; border: 1px solid #d0d3d6; border-radius: 6px; background: #fff; }
textarea { width: 100%; resize: vertical; }
.mono { font-family: Consolas, Menlo, monospace; font-size: 12px; }
.muted { color: #8a8f99; }
.err { color: #d4380d; min-height: 20px; }
.grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; }

.login { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-box { width: 320px; padding: 32px; background: #fff; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,.06); display: flex; flex-direction: column; gap: 12px; }
.login-box h1 { margin: 0; font-size: 20px; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 0 20px; height: 52px; background: #fff; border-bottom: 1px solid #e5e6eb; }
.brand { font-weight: 600; }
#nav { display: flex; gap: 4px; flex: 1; }
#nav button { border: none; background: none; }
#nav button.active { color: #1677ff; background: #e8f1ff; }
.badge { padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.badge.on { background: #fff1f0; color: #d4380d; }
.badge.off { background: #f0f5ff; color: #1677ff; }

main { padding: 16px 20px; }
.page[hidden] { display: none !important; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.card { background: #fff; border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.out { white-space: pre-wrap; background: #f7f8fa; padding: 10px; border-radius: 6px; min-height: 40px; margin: 10px 0 0; }

table.grid { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
.grid th, .grid td { padding: 8px 10px; border-bottom: 1px solid #f0f1f3; text-align: left; vertical-align: top; }
.grid th { background: #fafbfc; font-weight: 500; color: #5c6370; white-space: nowrap; }
.grid td.clip { max-width: 360px; white-space: pre-wrap; word-break: break-all; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; background: #c9cdd4; }
.dot.on { background: #52c41a; }

.chat-page { display: flex; gap: 12px; height: calc(100vh - 84px); }
.thread-list { width: 320px; display: flex; flex-direction: column; background: #fff; border-radius: 10px; overflow: hidden; }
.filters { padding: 10px; display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid #f0f1f3; }
.filters select, .filters input { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.threads { overflow-y: auto; flex: 1; }
.thread { padding: 10px 12px; border-bottom: 1px solid #f5f5f5; cursor: pointer; }
.thread:hover { background: #f7f9fc; }
.thread.active { background: #e8f1ff; }
.thread .t1 { display: flex; justify-content: space-between; gap: 6px; }
.thread .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread .t2 { color: #8a8f99; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 11px; padding: 0 6px; border-radius: 8px; background: #f2f3f5; color: #5c6370; white-space: nowrap; }
.tag.red { background: #fff1f0; color: #d4380d; }
.tag.orange { background: #fff7e6; color: #d46b08; }
.tag.blue { background: #e8f1ff; color: #1677ff; }

.thread-view { flex: 1; display: flex; flex-direction: column; background: #fff; border-radius: 10px; overflow: hidden; }
.thread-head { padding: 12px 16px; border-bottom: 1px solid #f0f1f3; display: flex; gap: 10px; align-items: center; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 70%; }
.msg .bubble { padding: 8px 12px; border-radius: 10px; white-space: pre-wrap; word-break: break-word; background: #f2f3f5; }
.msg .meta { font-size: 12px; color: #8a8f99; margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.msg.mine { align-self: flex-end; }
.msg.mine .bubble { background: #e8f1ff; }
.msg.sim .bubble { background: #fff; border: 1px dashed #91caff; color: #5c6370; }
.msg.bad .bubble { background: #fff1f0; }
.send-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #f0f1f3; align-items: flex-end; }

dialog { border: none; border-radius: 12px; padding: 20px; width: 560px; max-width: 95vw; }
dialog::backdrop { background: rgba(0,0,0,.3); }
dialog h3 { margin-top: 0; }
#dlgBody label { display: block; margin-bottom: 10px; }
#dlgBody label > span { display: block; font-size: 13px; color: #5c6370; margin-bottom: 2px; }
#dlgBody input:not([type=checkbox]), #dlgBody select, #dlgBody textarea { width: 100%; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.toast { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); background: #1f2329; color: #fff; padding: 8px 16px; border-radius: 8px; z-index: 99; }
