:root {
  --ea-side: #001529;
  --ea-side-2: #000c17;
  --ea-side-hover: rgba(255,255,255,.08);
  --ea-side-active: #1677ff;
  --ea-bg: #f5f7fb;
  --ea-card: #ffffff;
  --ea-text: #1f1f1f;
  --ea-muted: #8c8c8c;
  --ea-border: #eef0f4;
  --ea-primary: #1677ff;
  --ea-shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 16px rgba(15,23,42,.04);
  --ea-radius: 12px;
  --side-w: 232px;
  --side-w-mini: 72px;
  --top-h: 58px;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--ea-bg);
  color: var(--ea-text);
  -webkit-font-smoothing: antialiased;
}

/* ========== Login ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 12% 0%, rgba(22,119,255,.12), transparent 55%),
    radial-gradient(700px 380px at 100% 100%, rgba(0,21,41,.08), transparent 50%),
    #f5f7fb;
}
.login-card {
  width: min(420px, 100%);
  padding: 42px 38px 34px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0,21,41,.08);
  border: 1px solid #eef1f6;
}
.login-card .brand { text-align: center; margin-bottom: 28px; }
.login-card .brand img {
  width: 68px; height: 68px; border-radius: 18px;
  object-fit: contain; margin-bottom: 14px;
  box-shadow: 0 10px 24px rgba(22,119,255,.18);
}
.login-card .brand h1 {
  margin: 0; font-size: 24px; font-weight: 700; letter-spacing: .08em; color: #001529;
}
.login-card .brand p {
  margin: 10px 0 0; color: var(--ea-muted); font-size: 13px;
}
.login-card .el-button--primary {
  height: 44px; font-size: 15px; border-radius: 10px; font-weight: 600;
}

/* ========== Shell ========== */
.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--ea-bg);
}
.side {
  width: var(--side-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--ea-side) 0%, var(--ea-side-2) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
  transition: width .2s ease;
}
.layout.is-collapse .side { width: var(--side-w-mini); }
.side-brand {
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  overflow: hidden;
  white-space: nowrap;
}
.side-brand img {
  width: 36px; height: 36px; border-radius: 10px;
  object-fit: contain; flex-shrink: 0; background: #fff;
}
.side-brand .txt { line-height: 1.15; }
.side-brand .txt strong {
  display: block; font-size: 15px; font-weight: 700; letter-spacing: .04em;
}
.side-brand .txt small {
  color: rgba(255,255,255,.5); font-size: 11px;
}
.layout.is-collapse .side-brand .txt { display: none; }
.side-menu {
  flex: 1;
  overflow: auto;
  padding: 10px 10px 24px;
}
.side-menu::-webkit-scrollbar { width: 4px; }
.side-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 4px; }
.menu-group-title {
  padding: 16px 12px 8px;
  font-size: 11px;
  color: rgba(255,255,255,.35);
  letter-spacing: .1em;
}
.layout.is-collapse .menu-group-title { display: none; }
.side-menu .el-menu {
  border-right: 0 !important;
  background: transparent !important;
}
.side-menu .el-menu-item {
  height: 44px !important;
  line-height: 44px !important;
  margin: 3px 0 !important;
  border-radius: 10px !important;
  color: rgba(255,255,255,.72) !important;
  padding: 0 14px !important;
}
.side-menu .el-menu-item:hover {
  background: var(--ea-side-hover) !important;
  color: #fff !important;
}
.side-menu .el-menu-item.is-active {
  background: var(--ea-side-active) !important;
  color: #fff !important;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(22,119,255,.28);
}
.side-menu .menu-ico {
  display: inline-flex;
  width: 20px;
  margin-right: 10px;
  justify-content: center;
  opacity: .95;
}
.layout.is-collapse .side-menu .menu-ico { margin-right: 0; }
.layout.is-collapse .side-menu .menu-txt { display: none; }
.layout.is-collapse .side-menu .el-menu-item {
  justify-content: center;
  padding: 0 !important;
}

.main-wrap {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  height: var(--top-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid #eaecef;
  z-index: 20;
  backdrop-filter: blur(10px);
}
.topbar .left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar .collapse-btn {
  width: 36px; height: 36px;
  border: 0; border-radius: 10px;
  background: #f3f6fb; color: #334;
  cursor: pointer; font-size: 16px;
}
.topbar .collapse-btn:hover { background: #e8eef8; color: var(--ea-primary); }
.topbar .crumb {
  font-size: 17px;
  font-weight: 700;
  color: #141414;
}
.topbar .right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  background: #f3f6fb;
}
.user-chip .avatar-letter {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #1677ff, #69b1ff);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.user-chip .meta { line-height: 1.15; }
.user-chip .meta b { display: block; font-size: 13px; font-weight: 650; }
.user-chip .meta span { font-size: 11px; color: var(--ea-muted); }

.content {
  padding: 16px 20px 20px;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.content:has(.page.is-fill),
.content.is-fill {
  overflow: hidden;
}

/* ========== Page blocks ========== */
.page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}
.page.is-fill {
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.page-head .titles h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #141414;
}
.page-head .titles p {
  margin: 6px 0 0;
  color: var(--ea-muted);
  font-size: 13px;
}
.page-head .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.page-card {
  background: var(--ea-card);
  border-radius: var(--ea-radius);
  padding: 18px;
  box-shadow: var(--ea-shadow);
  border: 1px solid #eef0f4;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar .grow { flex: 1; min-width: 12px; }
.pager {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 4px;
}
.chat-side .pager {
  justify-content: center;
  margin: 0;
  padding: 8px 6px 10px;
  border-top: 1px solid #eef0f4;
  background: #fff;
}
.chat-side .pager .el-pagination {
  flex-wrap: wrap;
  justify-content: center;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.stat-item {
  background: #fff;
  border-radius: var(--ea-radius);
  padding: 20px 18px 18px;
  box-shadow: var(--ea-shadow);
  border: 1px solid #eef0f4;
  position: relative;
  overflow: hidden;
}
.stat-item::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent, var(--ea-primary));
}
.stat-item .label { color: var(--ea-muted); font-size: 13px; }
.stat-item .value {
  margin-top: 10px;
  font-size: 30px;
  font-weight: 750;
  color: #141414;
  letter-spacing: -.03em;
}
.stat-item .hint {
  margin-top: 8px;
  font-size: 12px;
  color: #bfbfbf;
}

.welcome-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-radius: var(--ea-radius);
  background: linear-gradient(135deg, #1677ff 0%, #4096ff 55%, #69b1ff 100%);
  color: #fff;
  box-shadow: 0 12px 28px rgba(22,119,255,.28);
}
.welcome-card h3 { margin: 0 0 8px; font-size: 20px; font-weight: 700; }
.welcome-card p { margin: 0; opacity: .92; font-size: 13px; line-height: 1.6; max-width: 720px; }

.thumb {
  width: 56px; height: 42px;
  object-fit: cover; border-radius: 8px;
  background: #f5f5f5; border: 1px solid #f0f0f0;
  vertical-align: middle;
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%; object-fit: cover;
  border: 1px solid #f0f0f0;
  vertical-align: middle;
}
.policy-tip {
  color: var(--ea-muted);
  font-size: 13px;
  line-height: 1.55;
}
.empty-box {
  padding: 48px 20px;
  text-align: center;
  color: var(--ea-muted);
}
.empty-box .ico {
  font-size: 34px;
  margin-bottom: 10px;
  opacity: .45;
}

/* Element Plus polish */
.ea-table {
  --el-table-header-bg-color: #fafbfc;
  --el-table-row-hover-bg-color: #f5f9ff;
  --el-table-border-color: #f0f2f5;
  border-radius: 10px;
  overflow: hidden;
}
.ea-table .el-table__header th {
  font-weight: 650 !important;
  color: #595959 !important;
  font-size: 13px;
}
.ea-table .el-table__cell {
  padding: 12px 0 !important;
}
.ea-table .el-button.is-link {
  padding: 0 6px;
  font-weight: 550;
}
.el-dialog {
  border-radius: 14px !important;
  overflow: hidden;
}
.el-dialog__header {
  border-bottom: 1px solid #f0f0f0;
  margin-right: 0 !important;
  padding: 18px 20px 14px !important;
}
.el-dialog__body { padding: 18px 20px !important; }
.el-dialog__footer {
  border-top: 1px solid #f0f0f0;
  padding: 14px 20px 18px !important;
}
.el-form-item { margin-bottom: 18px !important; }
.el-input-number { width: 100%; max-width: 220px; }
.perm-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 8px;
  width: 100%;
  padding: 12px 14px;
  background: #f7f9fc;
  border-radius: 10px;
  border: 1px solid #eef0f4;
}
.perm-box .el-checkbox {
  margin-right: 0 !important;
  height: 34px;
}

/* ========== Chat / Messages ========== */
.chat-wrap {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  background: #fff;
  border-radius: var(--ea-radius);
  box-shadow: var(--ea-shadow);
  border: 1px solid #eef0f4;
  overflow: hidden;
}
.chat-side {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid #eef0f4;
  background: #fbfcfe;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.chat-side-hd {
  flex-shrink: 0;
  padding: 14px 14px 12px;
  border-bottom: 1px solid #eef0f4;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chat-side-hd .t {
  font-size: 15px;
  font-weight: 700;
  color: #141414;
}
.chat-side-hd .s {
  font-size: 12px;
  color: var(--ea-muted);
  margin-top: 2px;
}
.chat-search {
  flex-shrink: 0;
  padding: 10px 12px;
  border-bottom: 1px solid #eef0f4;
  background: #fff;
}
.chat-sessions {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.chat-sessions::-webkit-scrollbar { width: 5px; }
.chat-sessions::-webkit-scrollbar-thumb { background: #d9d9d9; border-radius: 4px; }

.session-item {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f3f5f8;
  transition: background .15s;
  position: relative;
}
.session-item:hover { background: #f3f8ff; }
.session-item.active {
  background: #eaf3ff;
}
.session-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--ea-primary);
}
.session-avatar {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #69b1ff, #1677ff);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
.session-main { flex: 1; min-width: 0; }
.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.session-row .name {
  font-size: 14px;
  font-weight: 650;
  color: #1f1f1f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-row .time {
  font-size: 11px;
  color: #bfbfbf;
  flex-shrink: 0;
}
.session-row .uid {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ea-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.unread-dot {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ff4d4f;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #f7f8fa;
  overflow: hidden;
}
.chat-main-hd {
  height: 62px;
  flex-shrink: 0;
  padding: 0 18px;
  background: #fff;
  border-bottom: 1px solid #eef0f4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chat-main-hd .who {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.chat-main-hd .who .info { min-width: 0; }
.chat-main-hd .who .info b {
  display: block;
  font-size: 15px;
  font-weight: 700;
}
.chat-main-hd .who .info span {
  font-size: 12px;
  color: var(--ea-muted);
}
.chat-blank {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--ea-muted);
  gap: 8px;
}
.chat-blank .ico { font-size: 42px; opacity: .35; }
.chat-blank h4 { margin: 0; font-size: 16px; color: #595959; }
.chat-blank p { margin: 0; font-size: 13px; }

.chat-msgs {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 18px 20px;
}
.chat-msgs::-webkit-scrollbar { width: 6px; }
.chat-msgs::-webkit-scrollbar-thumb { background: #d0d5dd; border-radius: 4px; }

.msg-day {
  text-align: center;
  margin: 8px 0 16px;
}
.msg-day span {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.05);
  color: #8c8c8c;
  font-size: 12px;
}

.msg-row {
  display: flex;
  margin-bottom: 14px;
  gap: 10px;
}
.msg-row.is-admin { flex-direction: row-reverse; }
.msg-row .ava {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.msg-row.is-user .ava { background: #69b1ff; }
.msg-row.is-admin .ava { background: #1677ff; }
.msg-col { max-width: min(68%, 560px); min-width: 0; }
.msg-row.is-admin .msg-col { text-align: right; }
.msg-meta {
  font-size: 11px;
  color: #a0a5ad;
  margin-bottom: 4px;
}
.msg-bubble {
  display: inline-block;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15,23,42,.05);
  font-size: 14px;
  line-height: 1.55;
  color: #1f1f1f;
  word-break: break-word;
  white-space: pre-wrap;
}
.msg-row.is-admin .msg-bubble {
  background: #1677ff;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-row.is-user .msg-bubble {
  border-bottom-left-radius: 4px;
}

.chat-composer {
  flex-shrink: 0;
  padding: 12px 14px 14px;
  background: #fff;
  border-top: 1px solid #eef0f4;
}
.chat-composer .tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.chat-composer .box {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-composer .box .el-textarea {
  flex: 1;
}
.chat-composer .box .el-textarea__inner {
  border-radius: 10px;
  min-height: 74px !important;
  resize: none;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.settings-grid .full { grid-column: 1 / -1; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .chat-side { width: 240px; }
  .perm-box { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .stat-grid { grid-template-columns: 1fr; }
  .chat-wrap { flex-direction: column; }
  .chat-side {
    width: 100%;
    height: 38%;
    max-height: 240px;
    border-right: 0;
    border-bottom: 1px solid #eef0f4;
  }
  .chat-main { height: 62%; }
  .side { position: fixed; left: 0; }
  .layout.is-collapse .side { transform: translateX(-100%); width: var(--side-w); }
}
