html{
  height:100%;
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
}
*{box-sizing:border-box}
body{
  min-height:100%;
  margin:0;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans SC",sans-serif;
  background:#f1f2f4;
  color:#222;
}
button{
  border:0;
  background:#2aae67;
  color:white;
  border-radius:6px;
  padding:8px 12px;
  cursor:pointer;
  font-size:14px;
  touch-action:manipulation;
}
button:hover{opacity:.9}
button:disabled{opacity:.55;cursor:not-allowed}
button.secondary{background:#778}
input,textarea,select{
  border:1px solid #ddd;
  border-radius:6px;
  padding:9px;
  font-size:16px;
  line-height:1.35;
}
textarea{resize:none}
.hidden{display:none!important}
.msg{color:#d33;margin-top:10px}

.login-card{
  width:360px;
  max-width:calc(100vw - 40px);
  margin:10vh auto;
  background:white;
  border-radius:12px;
  padding:28px;
  box-shadow:0 8px 30px rgba(0,0,0,.08);
}
.login-card h1{margin:0 0 10px}
.login-card input,.login-card button{width:100%;margin-top:12px}
.topbar{height:54px;background:#202c33;color:#fff;display:flex;gap:16px;align-items:center;padding:0 18px}
.topbar button{margin-left:auto}
.admin-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px;padding:16px}
.panel{background:#fff;border-radius:10px;padding:16px;box-shadow:0 2px 12px rgba(0,0,0,.05)}
.panel.wide{grid-column:1/-1}
.form-row{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:12px}
.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.stat{background:#f6f7f8;border-radius:8px;padding:12px}
.table{width:100%;border-collapse:collapse}
.table td,.table th{border-bottom:1px solid #eee;padding:9px;text-align:left}

/* 客服端：整屏固定，左侧列表、中间消息、右侧资料分别独立滚动 */
.staff-body{
  height:100%;
  overflow:hidden;
}
.staff-shell{
  width:100vw;
  height:100vh;
  height:100dvh;
  height:var(--app-height,100dvh);
  display:grid;
  grid-template-columns:300px minmax(0,1fr) 300px;
  background:#e5ddd5;
  overflow:hidden;
  min-height:0;
}
.conversation-sidebar{
  background:#f7f7f7;
  border-right:1px solid #ddd;
  display:flex;
  flex-direction:column;
  min-width:0;
  min-height:0;
  height:100%;
  overflow:hidden;
}
.sidebar-head{
  flex:0 0 56px;
  display:flex;
  align-items:center;
  gap:8px;
  padding:10px;
  background:#ededed;
}
.sidebar-head strong{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.conversation-sidebar input{flex:0 0 auto;margin:10px;min-width:0}
.conversation-list{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
}
.conversation-item{display:flex;gap:10px;padding:12px;border-bottom:1px solid #eee;cursor:pointer;background:#fff}
.conversation-item:hover,.conversation-item.active{background:#e8f3ee}
.conversation-item img{width:42px;height:42px;border-radius:50%;flex:0 0 auto}
.conversation-main{flex:1;min-width:0}
.conversation-title{display:flex;align-items:center;justify-content:space-between;font-weight:600;gap:8px}
.conversation-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.conversation-time{flex:0 0 auto;color:#999;font-weight:400;font-size:12px;line-height:1.2}
.conversation-preview-row{display:flex;align-items:center;gap:8px;margin-top:4px;min-width:0}
.conversation-preview{flex:1 1 auto;min-width:0;color:#777;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;font-size:13px}
.badge{background:#e74856;color:white;border-radius:12px;padding:1px 7px;font-size:12px;flex:0 0 auto}
.chat-panel{
  display:flex;
  flex-direction:column;
  background:#efeae2;
  min-width:0;
  min-height:0;
  height:100%;
  overflow:hidden;
}
.chat-head{
  flex:0 0 56px;
  background:#f0f2f5;
  border-bottom:1px solid #ddd;
  display:flex;
  align-items:center;
  padding:0 16px;
  font-weight:700;
}
.messages{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:10px;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
  overflow-anchor:none;
}
.message-time{
  align-self:center;
  max-width:86%;
  margin:8px auto 2px;
  padding:3px 8px;
  border-radius:10px;
  background:rgba(0,0,0,.08);
  color:#888;
  font-size:12px;
  line-height:1.4;
  text-align:center;
}
.message{
  max-width:68%;
  padding:9px 12px;
  border-radius:8px;
  box-shadow:0 1px 1px rgba(0,0,0,.06);
  word-break:break-word;
  overflow-anchor:none;
}
.message.staff{align-self:flex-end;background:#d9fdd3}
.message.visitor{align-self:flex-start;background:#fff}
.message img{max-width:260px;max-height:260px;height:auto;border-radius:8px;display:block;overflow-anchor:none}
.input-bar{
  flex:0 0 auto;
  min-height:74px;
  background:#f0f2f5;
  border-top:1px solid #ddd;
  display:flex;
  gap:8px;
  align-items:center;
  padding:10px;
}
.input-bar textarea{flex:1 1 auto;min-width:0;height:52px}
.profile-panel{
  background:#fff;
  border-left:1px solid #ddd;
  padding:16px;
  min-height:0;
  height:100%;
  overflow-y:auto;
  overflow-x:hidden;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain;
}
.profile-row{margin:10px 0}
.profile-label{font-size:12px;color:#777}
.profile-value{margin-top:3px;word-break:break-word}
.profile-panel textarea{width:100%;height:72px}
.preview{
  flex:0 0 auto;
  background:#fffbe6;
  border-top:1px solid #ddd;
  padding:10px;
  display:flex;
  gap:10px;
  align-items:center;
  overflow:hidden;
}
.preview span{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.preview img{max-height:96px;max-width:160px;border-radius:8px;flex:0 0 auto}
.modal{position:fixed;inset:0;background:rgba(0,0,0,.35);display:flex;align-items:center;justify-content:center;z-index:20}
.modal-card{width:430px;max-width:calc(100vw - 24px);max-height:calc(100vh - 24px);overflow:auto;background:#fff;border-radius:12px;padding:18px}
.modal-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}
.share-box{display:flex;flex-direction:column;gap:10px;margin-top:10px}
.share-box img{width:220px;height:220px;align-self:center;border:1px solid #eee}

/* 用户 H5：页面固定，只有消息区域滚动；刷新和聚焦输入框后不放大 */
.visitor-body{
  position:fixed;
  inset:0;
  width:100%;
  height:100vh;
  height:100dvh;
  height:var(--app-height,100dvh);
  overflow:hidden;
  background:#f5f6f7;
}
.visitor-chat{
  width:100%;
  max-width:680px;
  height:100%;
  margin:0 auto;
  background:#efeae2;
  display:flex;
  flex-direction:column;
  overflow:hidden;
  min-height:0;
}
.visitor-head{
  flex:0 0 auto;
  min-height:56px;
  background:#f0f2f5;
  display:flex;
  gap:10px;
  align-items:center;
  padding:calc(0px + env(safe-area-inset-top)) 14px 0;
  border-bottom:1px solid #ddd;
}
.visitor-head img{width:36px;height:36px;border-radius:50%;flex:0 0 auto}
.visitor-messages{padding-bottom:12px}
.visitor-input{padding-bottom:calc(10px + env(safe-area-inset-bottom))}
.visitor-input textarea{height:48px;font-size:16px}

@media(max-width:900px){
  .staff-shell{grid-template-columns:260px minmax(0,1fr)}
  .profile-panel{display:none}
  .admin-grid{grid-template-columns:1fr}
  .stats{grid-template-columns:1fr 1fr}
}
@media(max-width:640px){
  .staff-shell{grid-template-columns:1fr}
  .conversation-sidebar{display:none}
  .message{max-width:86%}
  .login-card{margin-top:5vh}
  .visitor-chat{max-width:none}
  .visitor-head{min-height:52px}
  .visitor-input{gap:6px;padding-left:8px;padding-right:8px}
  .visitor-input button{padding:8px 10px;white-space:nowrap}
  .preview{padding-left:8px;padding-right:8px}
  .preview img{max-width:108px;max-height:86px}
}

/* 管理后台：日期选择与域名客服权限弹窗 */
.staff-create-row input{min-width:180px}
.date-field{
  display:flex;
  align-items:center;
  gap:8px;
  border:1px solid #ddd;
  border-radius:6px;
  padding:0 9px;
  min-height:41px;
  background:#fff;
}
.date-field span{
  color:#667;
  font-size:14px;
  white-space:nowrap;
}
.date-field input{
  border:0;
  padding:8px 0;
  min-width:150px;
  outline:none;
}
.admin-perm-card{
  width:620px;
  max-width:calc(100vw - 24px);
}
.modal-subtitle{
  margin:4px 0 0;
  color:#666;
  font-size:13px;
}
.perm-mode-box{
  display:flex;
  gap:16px;
  flex-wrap:wrap;
  padding:12px;
  border:1px solid #eee;
  border-radius:8px;
  background:#fafafa;
  margin-bottom:12px;
}
.radio-row{
  display:flex;
  align-items:center;
  gap:6px;
  cursor:pointer;
  user-select:none;
}
.perm-toolbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  margin:10px 0;
}
button.small{
  padding:5px 8px;
  font-size:12px;
}
.staff-check-list{
  border:1px solid #eee;
  border-radius:8px;
  max-height:360px;
  overflow-y:auto;
  background:#fff;
}
.staff-check-list.disabled-list{
  opacity:.6;
}
.staff-check-item{
  display:grid;
  grid-template-columns:auto minmax(0,1fr) auto;
  gap:10px;
  align-items:center;
  padding:10px 12px;
  border-bottom:1px solid #f0f0f0;
  cursor:pointer;
}
.staff-check-item:last-child{border-bottom:0}
.staff-check-item:hover{background:#f7fbf9}
.staff-check-main{
  display:flex;
  flex-direction:column;
  gap:2px;
  min-width:0;
}
.staff-check-main strong,
.staff-check-main span{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.staff-check-meta{
  color:#777;
  font-size:12px;
  white-space:nowrap;
}
.loading-row,.empty-row{
  padding:18px;
  color:#777;
  text-align:center;
}
.modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:14px;
}
@media (max-width:720px){
  .staff-check-item{grid-template-columns:auto minmax(0,1fr)}
  .staff-check-meta{grid-column:2;color:#777}
  .perm-toolbar{align-items:flex-start;flex-direction:column}
  .date-field{width:100%}
  .date-field input{flex:1}
}
