* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; background: #f5f6fa; color: #333; font-size: 14px; }
a { text-decoration: none; color: inherit; cursor: pointer; }
button { cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid #d9dce3; border-radius: 6px; outline: none; background: #fff; }
input:focus, select:focus, textarea:focus { border-color: #2f7cf6; }
input[type="number"] { -moz-appearance: textfield; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 16px; border: 1px solid transparent; border-radius: 6px; font-size: 13px; line-height: 1.4; transition: .15s; }
.btn-primary { background: #2f7cf6; color: #fff; }
.btn-primary:hover { background: #1f6ce6; }
.btn-primary:disabled { background: #a8c7f7; cursor: not-allowed; }
.btn-ghost { background: #fff; border-color: #d9dce3; color: #555; }
.btn-ghost:hover { border-color: #2f7cf6; color: #2f7cf6; }
.btn-danger { background: #fff; border-color: #f56c6c; color: #f56c6c; }
.btn-danger:hover { background: #f56c6c; color: #fff; }
.btn-warn { background: #fff; border-color: #e6a23c; color: #e6a23c; }
.btn-warn:hover { background: #e6a23c; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn + .btn { margin-left: 6px; }

/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #2f7cf6 0%, #4aa3ff 60%, #7cc4ff 100%); }
.login-card { width: 380px; background: #fff; border-radius: 12px; padding: 40px 36px; box-shadow: 0 12px 40px rgba(0,0,0,.15); }
.login-title { font-size: 26px; color: #1f6ce6; text-align: center; }
.login-sub { text-align: center; color: #888; margin: 6px 0 28px; }
.form-item { margin-bottom: 16px; }
.form-item label { display: block; margin-bottom: 6px; color: #555; font-size: 13px; }
.form-item input { width: 100%; }
.err-text { color: #f56c6c; margin-top: 12px; font-size: 13px; }
.login-tip { margin-top: 18px; color: #999; font-size: 12px; line-height: 1.7; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 210px; background: #1d2330; color: #cfd3dc; display: flex; flex-direction: column; transition: width .2s; position: sticky; top: 0; height: 100vh; }
.sidebar.collapsed { width: 60px; }
.logo { height: 60px; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; color: #fff; gap: 6px; white-space: nowrap; overflow: hidden; }
.logo-sub { font-size: 12px; font-weight: 400; color: #7cc4ff; }
.menu { flex: 1; padding: 8px 0; overflow-y: auto; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 12px 20px; color: #cfd3dc; white-space: nowrap; overflow: hidden; }
.menu-item:hover { background: #2a3242; color: #fff; }
.menu-item.active { background: #2f7cf6; color: #fff; }
.menu-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar.collapsed .menu-text { display: none; }
.sidebar-foot { padding: 12px; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 60px; background: #fff; border-bottom: 1px solid #e6e8ee; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; }
.topbar-title { font-size: 17px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.admin-name { color: #666; }
.content { flex: 1; padding: 20px 24px; }

/* 卡片 */
.card { background: #fff; border-radius: 10px; box-shadow: 0 1px 6px rgba(31,45,61,.06); padding: 18px; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }

/* 工具条 */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.toolbar input, .toolbar select { min-width: 140px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
.table th { background: #f7f8fa; color: #555; font-weight: 600; text-align: left; padding: 10px 12px; border-bottom: 1px solid #e6e8ee; white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid #f0f1f4; vertical-align: middle; }
.table tr:hover td { background: #fafbfd; }
.table .empty { text-align: center; color: #999; padding: 40px 0; }

/* 标签 */
.tag { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; background: #eef2f8; color: #555; }
.tag-blue { background: #e8f1ff; color: #2f7cf6; }
.tag-green { background: #e6f7ed; color: #1f9d55; }
.tag-red { background: #fdecec; color: #f56c6c; }
.tag-orange { background: #fdf3e5; color: #e6a23c; }
.tag-gray { background: #f1f2f5; color: #888; }

/* 分页 */
.pager { display: flex; align-items: center; gap: 10px; margin-top: 14px; justify-content: flex-end; color: #666; }
.pager button { min-width: 64px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 10px; width: 420px; max-width: 92vw; box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid #eef0f4; font-weight: 600; }
.modal-close { border: none; background: none; font-size: 20px; color: #999; }
.modal-body { padding: 18px; max-height: 60vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid #eef0f4; }

/* 表单弹窗 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: block; margin-bottom: 5px; color: #555; font-size: 13px; }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; }

/* 看板 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat-card { background: #fff; border-radius: 10px; padding: 18px; box-shadow: 0 1px 6px rgba(31,45,61,.06); }
.stat-card .num { font-size: 26px; font-weight: 700; color: #1d2330; margin-top: 6px; }
.stat-card .num small { font-size: 13px; font-weight: 400; color: #999; }
.stat-card .label { color: #888; font-size: 13px; }
.stat-blue { border-left: 3px solid #2f7cf6; }
.stat-green { border-left: 3px solid #1f9d55; }
.stat-orange { border-left: 3px solid #e6a23c; }
.stat-purple { border-left: 3px solid #8b5cf6; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart-card { background: #fff; border-radius: 10px; padding: 16px; box-shadow: 0 1px 6px rgba(31,45,61,.06); }
.chart-card h3 { font-size: 14px; margin-bottom: 10px; color: #444; }
.chart { width: 100%; height: 300px; }

/* 其他 */
.mt10 { margin-top: 10px; }
.mb10 { margin-bottom: 10px; }
.text-right { text-align: right; }
.muted { color: #999; font-size: 12px; }
.flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mono { font-family: Consolas, monospace; font-size: 12px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c7ccd6; border-radius: 4px; }

/* ==================== 客服消息 ==================== */
.chat-wrap { display: flex; height: calc(100vh - 220px); min-height: 480px; border: 1px solid #eee; border-radius: 10px; overflow: hidden; background: #fff; }
.chat-side { width: 300px; flex: 0 0 300px; border-right: 1px solid #eee; display: flex; flex-direction: column; background: #fafbfc; }
.chat-side-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid #eee; }
.chat-side-title { font-weight: 600; }
.chat-sound { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #666; cursor: pointer; }
.chat-convs { flex: 1; overflow-y: auto; }
.chat-conv { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; cursor: pointer; transition: background .15s; }
.chat-conv:hover { background: #f0f2f5; }
.chat-conv.active { background: #e6f4ff; }
.chat-conv-top { display: flex; align-items: center; gap: 6px; }
.chat-conv-name { font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-conv-last { margin-top: 3px; font-size: 12px; color: #999; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-badge { background: #f5222d; color: #fff; font-size: 11px; line-height: 16px; min-width: 16px; height: 16px; border-radius: 8px; text-align: center; padding: 0 5px; }
.chat-main { flex: 1; display: flex; flex-direction: column; background: #f7f8fa; }
.chat-head { padding: 10px 14px; border-bottom: 1px solid #eee; background: #fff; display: flex; align-items: center; gap: 10px; font-weight: 600; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.chat-msg { max-width: 70%; display: flex; flex-direction: column; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg.theirs { align-self: flex-start; align-items: flex-start; }
.chat-bubble { padding: 8px 12px; border-radius: 8px; font-size: 14px; word-break: break-word; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.chat-msg.mine .chat-bubble { background: #1677ff; color: #fff; }
.chat-msg.theirs .chat-bubble { background: #fff; color: #333; }
.chat-bubble-img { padding: 4px; background: #fff; }
.chat-img { max-width: 220px; max-height: 220px; display: block; border-radius: 6px; cursor: zoom-in; }
.chat-time { margin-top: 2px; font-size: 11px; color: #bbb; }
.chat-input { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid #eee; background: #fff; align-items: center; }
.chat-input input { flex: 1; }
.chat-input .file-btn { cursor: pointer; }
.chat-empty { height: 100%; display: flex; align-items: center; justify-content: center; }
