:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #75809a;
  --line: #e7ebf2;
  --primary: #246bfd;
  --primary-dark: #1c56ca;
  --danger: #e5484d;
  --success: #18a66a;
  --bubble: #eef2f8;
  --shadow: 0 12px 36px rgba(28, 39, 62, .10);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif; background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-page { min-height: 100%; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #e9f0ff 0, var(--bg) 45%); }
.login-card { width: min(420px, 100%); background: var(--panel); padding: 34px; border-radius: 22px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.brand-logo { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--primary); color: #fff; font-weight: 800; }
.brand h1 { font-size: 21px; margin: 0; }
.brand p { color: var(--muted); margin: 3px 0 0; font-size: 13px; }
.field { margin: 15px 0; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; }
.input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px 14px; outline: none; }
.input:focus { border-color: #9bb9ff; box-shadow: 0 0 0 3px rgba(36,107,253,.09); }
.btn { border: 0; border-radius: 11px; padding: 11px 16px; background: #edf1f7; color: var(--text); font-weight: 650; }
.btn:hover { filter: brightness(.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fff0f0; color: var(--danger); }
.btn-wide { width: 100%; }
.error { color: var(--danger); font-size: 13px; min-height: 20px; }

.admin-shell { height: 100%; display: grid; grid-template-columns: 330px 1fr; }
.sidebar { background: #fff; border-right: 1px solid var(--line); min-width: 0; display: flex; flex-direction: column; }
.side-head { padding: 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-head .title { font-weight: 800; font-size: 18px; }
.room-tools { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.room-list { overflow: auto; flex: 1; }
.room-item { padding: 14px 16px; border-bottom: 1px solid #f0f2f6; cursor: pointer; }
.room-item:hover, .room-item.active { background: #f5f8ff; }
.room-row { display: flex; gap: 10px; align-items: center; }
.room-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 20px; display: grid; place-items: center; background: var(--primary); color: #fff; font-size: 11px; font-weight: 800; }
.room-meta { margin-top: 6px; display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.room-preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 205px; }
.status-dot { width: 8px; height: 8px; border-radius: 999px; background: #b7bfce; display: inline-block; margin-right: 6px; }
.status-dot.online { background: var(--success); box-shadow: 0 0 0 3px rgba(24,166,106,.12); }

.chat-panel { min-width: 0; display: flex; flex-direction: column; height: 100%; }
.empty-state { height: 100%; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 30px; }
.chat-head { height: 72px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; gap: 12px; }
.chat-title { font-size: 17px; font-weight: 800; }
.chat-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.chat-actions { display: flex; gap: 8px; align-items: center; }
.messages { flex: 1; overflow: auto; padding: 24px; background: linear-gradient(#f7f9fc, #f2f5fa); }
.msg { display: flex; margin: 9px 0; }
.msg.mine { justify-content: flex-end; }
.msg-bubble { max-width: min(680px, 78%); border-radius: 16px; background: #fff; padding: 10px 13px; box-shadow: 0 2px 10px rgba(34,45,70,.05); word-break: break-word; white-space: pre-wrap; }
.msg.mine .msg-bubble { background: var(--primary); color: #fff; }
.msg-time { font-size: 10px; opacity: .65; margin-top: 6px; }
.file-card { display: block; color: inherit; text-decoration: none; border: 1px solid rgba(127,139,165,.25); border-radius: 10px; padding: 10px; background: rgba(255,255,255,.12); }
.msg-image { display: block; max-width: min(360px, 100%); max-height: 360px; border-radius: 10px; object-fit: contain; background: #fff; }
.typing { height: 22px; padding: 0 24px; color: var(--muted); font-size: 12px; background: #f2f5fa; }
.composer { background: #fff; border-top: 1px solid var(--line); padding: 12px 16px; display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { flex: 1; min-height: 44px; max-height: 130px; resize: vertical; }
.icon-btn { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; }
.closed-bar { padding: 11px; text-align: center; background: #fff4e5; color: #8c5a0a; border-top: 1px solid #f4d8a7; }

.client-page { min-height: 100%; display: grid; place-items: center; padding: 16px; background: #eef3fa; }
.client-card { width: min(760px, 100%); height: min(860px, calc(100vh - 32px)); background: #fff; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.client-head { height: 72px; padding: 0 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.client-head h1 { margin: 0; font-size: 18px; }
.client-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.online-pill { font-size: 12px; color: var(--success); background: #ecfbf4; padding: 7px 10px; border-radius: 20px; }
.client-page .messages { padding: 18px; }
.client-page .msg.mine .msg-bubble { background: var(--primary); }
.client-page .msg:not(.mine) .msg-bubble { background: #fff; }
.client-page .composer { padding: 10px; }
.system-msg { text-align: center; color: var(--muted); font-size: 12px; margin: 12px; }

.modal-wrap { position: fixed; inset: 0; background: rgba(15,23,42,.38); display: grid; place-items: center; padding: 20px; z-index: 20; }
.modal { width: min(460px, 100%); background: #fff; border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.share-box { padding: 10px 12px; border-radius: 10px; border: 1px dashed #b9c6df; background: #f7f9fd; word-break: break-all; font-size: 13px; }

@media (max-width: 780px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: absolute; inset: 0; z-index: 5; }
  .sidebar.mobile-hidden { display: none; }
  .chat-panel { position: absolute; inset: 0; background: var(--bg); }
  .chat-head { height: 66px; padding: 0 12px; }
  .messages { padding: 14px 10px; }
  .msg-bubble { max-width: 86%; }
  .chat-actions .label { display: none; }
  .client-page { padding: 0; }
  .client-card { width: 100%; height: 100vh; border-radius: 0; }
}
.flex-1 { flex: 1; }
.chat-view { height: 100%; display: flex; flex-direction: column; }
.back-btn { margin-right: 8px; }
.share-help { color: var(--muted); font-size: 13px; }
button:disabled { opacity: .55; cursor: not-allowed; }
