:root {
  --c: #2f6bff;
  --c2: #4f3bd6;
  --bg: #f4f6fb;
  --line: #e7eaf2;
  --text: #1f2937;
  --muted: #8b93a7;
  --side: #ffffff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text); background: var(--bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* 登录 */
.login { height: 100%; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, #dfe7ff, transparent 50%), radial-gradient(circle at 80% 80%, #e8e1ff, transparent 50%), var(--bg); padding: 16px; }
.login-box { width: 100%; max-width: 340px; background: #fff; padding: 36px 28px 28px; border-radius: 20px;
  box-shadow: 0 24px 60px -20px rgba(15, 23, 42, .25); text-align: center; }
.logo { width: 60px; height: 60px; margin: 0 auto 14px; border-radius: 18px; color: #fff;
  background: linear-gradient(135deg, var(--c), var(--c2)); display: flex; align-items: center; justify-content: center; }
.logo svg { width: 30px; height: 30px; }
.login-box h1 { font-size: 20px; margin-bottom: 22px; }
.login-box input { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; outline: none; }
.login-box input:focus { border-color: var(--c); }
.login-box button { width: 100%; margin-top: 14px; padding: 11px; border: 0; border-radius: 12px; color: #fff;
  background: linear-gradient(135deg, var(--c), var(--c2)); font-weight: 600; }
.err { color: #ef4444; font-size: 13px; margin-top: 10px; min-height: 20px; }

/* 布局 */
.app { display: flex; height: 100%; }
.side { width: 300px; flex: none; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.side-hd { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.conn { width: 9px; height: 9px; border-radius: 50%; background: #f59e0b; }
.conn.ok { background: #22c55e; }
.conn.bad { background: #ef4444; }
.icon-btn { width: 34px; height: 34px; border: 0; background: transparent; border-radius: 10px; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }

.filters { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.filters select, .filters input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none; }
.tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 6px; border-radius: 8px; color: var(--muted); }
.tabs button.on { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.list { list-style: none; flex: 1; overflow-y: auto; }
.list li { display: flex; gap: 10px; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid #f3f4f8; position: relative; }
.list li:hover { background: #f8f9fc; }
.list li.on { background: #eef3ff; }
.list li.on::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c); }
.ava { position: relative; width: 40px; height: 40px; flex: none; border-radius: 50%; color: #fff; font-weight: 600;
  display: flex; align-items: center; justify-content: center; font-size: 15px; }
.ava i { position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: #cbd2e0; border: 2px solid #fff; }
.ava i.on { background: #22c55e; }
.li-main { flex: 1; min-width: 0; }
.li-top { display: flex; justify-content: space-between; gap: 6px; }
.li-top b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-top time { font-size: 11px; color: var(--muted); flex: none; }
.li-bot { display: flex; justify-content: space-between; gap: 6px; margin-top: 2px; }
.li-bot span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { font-size: 10.5px; padding: 0 6px; border-radius: 6px; background: #eef1f7; color: #66708a; flex: none; line-height: 18px; }
.unread { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #ff3b30; color: #fff; font-size: 11px;
  font-weight: 700; line-height: 18px; text-align: center; flex: none; }
.list .none { color: var(--muted); justify-content: center; text-align: center; padding: 40px 0; cursor: default; border: 0; }
.list .none:hover { background: none; }
.side-ft { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--muted); }
.side-ft label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.link { border: 0; background: none; color: var(--c); }

/* 聊天 */
.chat { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); gap: 12px; }
.empty svg { width: 64px; height: 64px; opacity: .5; }
.chat-in { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-hd { display: flex; align-items: center; gap: 10px; padding: 12px 18px; background: #fff; border-bottom: 1px solid var(--line); }
.back { display: none; }
.who { flex: 1; min-width: 0; }
.who b { display: block; font-size: 15px; }
.who span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-sm { border: 1px solid var(--line); background: #fff; padding: 5px 12px; border-radius: 8px; font-size: 13px; }
.btn-sm:hover { border-color: var(--c); color: var(--c); }

.msgs { flex: 1; overflow-y: auto; padding: 18px 22px; }
.time { text-align: center; font-size: 11.5px; color: var(--muted); margin: 14px 0 8px; }
.row { display: flex; margin: 6px 0; }
.row.me { justify-content: flex-end; }
.bb { max-width: 68%; padding: 9px 13px; border-radius: 14px 14px 14px 4px; background: #fff; box-shadow: 0 1px 2px rgba(15,23,42,.06);
  white-space: pre-wrap; word-break: break-word; }
.row.me .bb { color: #fff; background: linear-gradient(135deg, var(--c), var(--c2)); border-radius: 14px 14px 4px 14px; }
.bb a { color: inherit; }
.typing { padding: 0 22px 6px; font-size: 12px; color: var(--muted); }
.composer { display: flex; gap: 10px; padding: 12px 18px 16px; background: #fff; border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; outline: none; max-height: 160px; }
.composer textarea:focus { border-color: var(--c); }
.composer button { border: 0; color: #fff; background: linear-gradient(135deg, var(--c), var(--c2)); padding: 10px 22px; border-radius: 12px; font-weight: 600; }

/* 访客信息 */
.info { width: 280px; flex: none; background: #fff; border-left: 1px solid var(--line); padding: 18px; overflow-y: auto; }
.info h3 { font-size: 15px; margin-bottom: 14px; }
.info dl { font-size: 13px; }
.info dt { color: var(--muted); font-size: 12px; margin-top: 12px; }
.info dd { word-break: break-all; margin-top: 2px; }
.info dd a { color: var(--c); }
.danger { margin-top: 24px; width: 100%; padding: 8px; border: 1px solid #fecaca; color: #dc2626; background: #fff; border-radius: 10px; }
.danger:hover { background: #fef2f2; }

/* 手机 */
@media (max-width: 900px) {
  .info { position: fixed; right: 0; top: 0; bottom: 0; z-index: 10; box-shadow: -10px 0 30px rgba(0,0,0,.12); }
}
@media (max-width: 700px) {
  .side { width: 100%; }
  .app.in-chat .side { display: none; }
  .app:not(.in-chat) .chat { display: none; }
  .back { display: inline-flex; }
  .msgs { padding: 14px; }
  .bb { max-width: 82%; }
  .info { width: 86%; }
}
.composer textarea:disabled { background: #f6f7fa; cursor: not-allowed; }
.composer button:disabled { opacity: .4; cursor: not-allowed; }
.who .st::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #cbd2e0; margin-right: 5px; vertical-align: 0; }
.who .st.on { color: #16a34a; }
.who .st.on::before { background: #22c55e; }
.who .st { display: inline; }

/* ===== 站点管理 ===== */
.side-hd > div { display: flex; gap: 2px; }
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { width: 100%; max-width: 980px; max-height: 100%; background: #fff; border-radius: 18px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 30px 80px -20px rgba(0,0,0,.4); }
.modal-hd { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 16px; }
.modal-bd { padding: 18px; overflow-y: auto; }
.sm-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 13px; }
code { background: #f1f3f8; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.primary { border: 0; color: #fff; background: linear-gradient(135deg, var(--c), var(--c2)); padding: 8px 16px; border-radius: 10px; font-weight: 600; white-space: nowrap; }
#smCards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.site-card { border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.site-card .sc-hd { display: flex; align-items: center; gap: 10px; }
.site-card .sw { width: 26px; height: 26px; border-radius: 8px; flex: none; }
.site-card .sc-hd b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-card .sc-id { color: var(--muted); font-size: 12px; }
.site-card .sc-or { font-size: 12px; color: #475569; word-break: break-all; }
.site-card .sc-act { display: flex; gap: 6px; margin-top: 4px; }
.site-card .sc-act .del { margin-left: auto; color: #dc2626; border-color: #fecaca; }
.empty-sites { color: var(--muted); text-align: center; padding: 40px 0; grid-column: 1 / -1; }

.sm-grid { display: grid; grid-template-columns: 1fr 380px; gap: 22px; }
.sm-form { display: flex; flex-direction: column; gap: 14px; }
.sm-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #334155; }
.sm-form input:not([type=color]), .sm-form textarea, .sm-form select { font-weight: 400; padding: 8px 11px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: #fff; resize: vertical; }
.sm-form input:focus, .sm-form textarea:focus, .sm-form select:focus { border-color: var(--c); }
.sm-form input:read-only { background: #f6f7fa; color: var(--muted); }
.sm-form small { font-weight: 400; color: var(--muted); font-size: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.colors { display: flex; gap: 6px; flex-wrap: wrap; }
.colors button { width: 24px; height: 24px; border-radius: 7px; border: 2px solid transparent; padding: 0; }
.colors button.on { border-color: #fff; box-shadow: 0 0 0 2px var(--text); }
.sm-form input[type=color] { width: 100%; height: 30px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; }
.sm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.sm-side { display: flex; flex-direction: column; gap: 14px; }
.code-box, .preview { border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.code-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }
.code-hd small { color: var(--muted); }
#smCode { background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 12px; font: 12px/1.6 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.code-box > small { display: block; margin-top: 8px; font-size: 12px; color: var(--muted); }
#smPreview { width: 100%; height: 470px; border: 0; border-radius: 10px; background: #f8fafc; }
.toast { position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 9px 18px; border-radius: 10px; font-size: 13px; z-index: 100; }

@media (max-width: 820px) {
  .modal { padding: 0; }
  .modal-box { border-radius: 0; height: 100%; }
  .sm-grid { grid-template-columns: 1fr; }
  .sm-top { flex-direction: column; align-items: stretch; }
}
