:root {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #332c39;
  background: #f8f6fa;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { outline-color: #8d70c9; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid rgba(142, 110, 203, .24);
  outline-offset: 2px;
}
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
.plain { border: 0; background: transparent; color: #6d6272; cursor: pointer; }
.outline { color: #73578f !important; background: #fff !important; border: 1px solid #d9cde3 !important; }
.danger { color: #bd444c !important; background: #fff !important; border: 1px solid #e7b5b8 !important; }
.danger-solid { color: #fff; background: #bd5159; border: 1px solid #bd5159; }

/* Login */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px 16px;
  background:
    radial-gradient(circle at 12% 10%, rgba(217, 202, 250, .75), transparent 34%),
    radial-gradient(circle at 90% 90%, rgba(255, 211, 204, .72), transparent 32%),
    #fbf9fc;
}
.login-card {
  width: min(430px, 94vw);
  padding: 44px;
  background: rgba(255, 255, 255, .96);
  border: 1px solid #eee8f1;
  border-radius: 26px;
  box-shadow: 0 24px 70px rgba(76, 49, 86, .11);
  text-align: center;
}
.logo, .brand b, .sidebar-brand b {
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #9474d2, #ee8d91);
  border-radius: 13px;
  font-weight: 800;
}
.logo { width: 54px; height: 54px; font-size: 25px; }
.login-kicker { margin-top: 18px !important; color: #8a699d !important; font-weight: 700; }
.login h1 { margin: 6px 0 8px; color: #3f3445; font-size: 27px; }
.login p, .login small { display: block; color: #817786; font-size: 13px; line-height: 1.6; }
.login label, .profile label {
  display: block;
  margin: 20px 0 0;
  color: #5e5362;
  font-size: 13px;
  text-align: left;
}
.login input, .profile textarea, .profile input {
  width: 100%;
  margin-top: 7px;
  padding: 12px 13px;
  color: #3d3541;
  background: #fff;
  border: 1px solid #ddd4e1;
  border-radius: 10px;
}
.login button, .composer button, #accept {
  border: 0;
  border-radius: 10px;
  background: linear-gradient(110deg, #9475d5, #ed8b91);
  color: #fff;
  padding: 12px;
  font-weight: 700;
}
.login button { width: 100%; margin: 24px 0 13px; }
.error { min-height: 18px; margin-top: 10px; color: #c9444d; font-size: 13px; }

/* Customer service desk */
.desk-header {
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: #fff;
  border-bottom: 1px solid #eae4ec;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.brand b { width: 34px; height: 34px; }
.brand em { margin-left: 2px; padding-left: 12px; border-left: 1px solid #e2dce5; color: #9a909e; font-size: 12px; font-style: normal; }
.desk-account { display: flex; align-items: center; gap: 14px; color: #605565; font-size: 13px; }
.desk-live { display: inline-flex; align-items: center; gap: 6px; color: #3d8f68; }
.desk-live i { width: 8px; height: 8px; background: #42b77c; border-radius: 50%; box-shadow: 0 0 0 4px #e1f5e9; }
.management-link { padding: 8px 12px; color: #745a90; background: #f3eef8; border-radius: 9px; font-weight: 600; }
.desk-grid { height: calc(100vh - 66px); display: grid; grid-template-columns: 310px minmax(470px, 1fr) 290px; }
.conversations, .profile { overflow: auto; background: #fff; }
.conversations { border-right: 1px solid #e9e3eb; }
.profile { padding: 24px; border-left: 1px solid #e9e3eb; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 16px 12px; }
.panel-head > div { display: flex; flex-direction: column; gap: 4px; }
.panel-head small { color: #968c9a; font-size: 11px; }
.filters { display: flex; gap: 8px; padding: 8px 12px 13px; border-bottom: 1px solid #f0ebf2; }
.filter { padding: 7px 10px; color: #716777; background: #f5f2f7; border: 0; border-radius: 8px; font-size: 12px; }
.filter.active { color: #765893; background: #eee6f8; font-weight: 700; }
.conv { width: 100%; padding: 15px 16px; background: #fff; border: 0; border-bottom: 1px solid #f0ecf2; text-align: left; }
.conv:hover, .conv.selected { background: #faf6fc; }
.conv.selected { box-shadow: inset 3px 0 #9c78ce; }
.conv-line { display: flex; align-items: center; gap: 9px; }
.mini-avatar, .profile-avatar { display: grid; place-items: center; color: #765893; background: #eee7f8; border-radius: 50%; font-weight: 700; }
.mini-avatar { width: 36px; height: 36px; }
.conv-name { flex: 1; font-size: 14px; font-weight: 700; }
.badge { padding: 1px 6px; color: #fff; background: #df5d65; border-radius: 10px; font-size: 11px; }
.conv-preview { margin: 6px 0 0 45px; overflow: hidden; color: #928895; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.chat { min-width: 0; display: flex; flex-direction: column; background: linear-gradient(180deg, #f5f0fa, #fbf9fc 35%); }
.chat #chatContent { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.empty { margin: auto; padding: 30px; color: #958a99; text-align: center; }
.empty h2 { margin: 12px 0 7px; color: #55495b; font-size: 18px; }
.empty h3 { color: #55495b; }
.empty p { max-width: 390px; margin: 0; font-size: 13px; line-height: 1.7; }
.empty-kicker { display: inline-flex; padding: 7px 12px; color: #795d94; background: #eee7f8; border-radius: 999px; font-size: 12px; font-weight: 700; }
.small { padding-top: 86px; }
.chat-head { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 11px 22px; background: rgba(255, 255, 255, .94); border-bottom: 1px solid #e9e3eb; }
.chat-head span { margin-left: 9px; color: #3e946b; font-size: 12px; }
.chat-actions { display: flex; align-items: center; gap: 8px; }
.chat-head button { width: auto; margin: 0; padding: 8px 13px; font-size: 13px; }
.chat-head select { max-width: 150px; padding: 8px; border: 1px solid #dcd3e0; border-radius: 9px; background: #fff; }
.messages { flex: 1; display: flex; flex-direction: column; gap: 16px; min-height: 0; overflow: auto; padding: 24px; }
.message { max-width: 72%; display: flex; align-items: flex-start; gap: 10px; }
.message.me { align-self: flex-end; flex-direction: row-reverse; }
.bubble { padding: 10px 13px; color: #493f4d; background: #fff; border: 1px solid #ece6ee; border-radius: 5px 13px 13px; box-shadow: 0 4px 12px rgba(71, 50, 79, .04); font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.me .bubble { background: linear-gradient(120deg, #eee5ff, #ffe4e1); border-color: #e8dceb; border-radius: 13px 5px 13px 13px; }
.msg-image { display: block; max-width: 230px; border-radius: 10px; }
.quick-replies { display: flex; gap: 7px; overflow: auto; padding: 8px 16px; background: #fff; }
.quick-replies button { padding: 5px 10px; color: #71558c; background: #faf7fc; border: 1px solid #ded2e6; border-radius: 13px; font-size: 12px; white-space: nowrap; }
.composer { display: flex; gap: 10px; padding: 12px 16px; background: #fff; border-top: 1px solid #e7e0e9; }
.composer textarea { flex: 1; padding: 10px 12px; resize: none; border: 1px solid #ddd4e2; border-radius: 11px; }
.composer button { width: 74px; margin: 0; padding: 0; }
.upload { display: grid; place-items: center; width: 52px; color: #72588a; background: #f2ebf7; border-radius: 10px; font-size: 12px; font-weight: 700; cursor: pointer; }
.profile-avatar { width: 68px; height: 68px; margin: auto; font-size: 24px; }
.profile h3 { margin: 12px 0 3px; text-align: center; }
.profile > div > p { color: #958b99; font-size: 12px; text-align: center; word-break: break-all; }
.profile dl { margin: 28px 0; font-size: 13px; }
.profile dt { float: left; margin-bottom: 15px; color: #8c8290; }
.profile dd { margin: 0 0 15px; text-align: right; }
.wide { width: 100%; margin-top: 10px; padding: 10px; border-radius: 9px; }
.notice { padding: 30px; color: #908694; text-align: center; }

/* Management shell */
.management-page { overflow: hidden; background: #f8f6fa; }
.manage-shell { min-height: 100vh; display: flex; }
.manage-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 268px;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  overflow-y: auto;
  color: #4b3f50;
  background: #fff;
  border-right: 1px solid #ebe5ed;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.sidebar-brand b { width: 38px; height: 38px; }
.sidebar-brand span { display: flex; flex-direction: column; gap: 2px; }
.sidebar-brand strong { font-size: 16px; }
.sidebar-brand small { color: #958a99; font-size: 11px; }
.side-nav { display: flex; flex-direction: column; gap: 18px; }
.side-nav-group h2 { margin: 0 10px 7px; color: #a198a5; font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.side-nav-item { width: 100%; min-height: 42px; display: flex; align-items: center; margin: 2px 0; padding: 10px 12px; color: #5e5363; background: transparent; border: 0; border-radius: 10px; text-align: left; }
.side-nav-item:hover { background: #f8f4fa; }
.side-nav-item.active { color: #6f518c; background: linear-gradient(100deg, #f0e9fa, #fff0f2); font-weight: 700; }
.workbench-item { color: #fff; background: linear-gradient(110deg, #8e70ca, #e9878d); font-weight: 700; box-shadow: 0 9px 24px rgba(143, 94, 147, .18); }
.workbench-item:hover { background: linear-gradient(110deg, #8264c0, #df7c82); }
.sidebar-help { margin-top: auto; padding: 16px; background: #faf7fb; border: 1px solid #eee7f0; border-radius: 15px; }
.sidebar-help strong { font-size: 13px; }
.sidebar-help p { margin: 7px 0 12px; color: #8e8492; font-size: 11px; line-height: 1.55; }
.sidebar-help a { color: #765993; font-size: 12px; font-weight: 700; }
.manage-stage { min-width: 0; flex: 1; margin-left: 268px; }
.manage-topbar { position: sticky; top: 0; z-index: 10; height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 28px; background: rgba(255, 255, 255, .94); border-bottom: 1px solid #ebe5ed; backdrop-filter: blur(10px); }
.topbar-context { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.topbar-context strong { color: #403546; font-size: 17px; }
.topbar-context span { overflow: hidden; color: #8c8290; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.manager-account { display: flex; align-items: center; gap: 10px; color: #5e5362; font-size: 12px; }
.presence-dot { width: 9px; height: 9px; background: #42b57a; border-radius: 50%; box-shadow: 0 0 0 4px #e2f5e9; }
.manager-copy { display: flex; flex-direction: column; }
.manager-copy small { color: #978d9b; }
.mobile-menu { display: none; padding: 7px 10px; color: #72558e; background: #f1eaf7; border: 0; border-radius: 8px; }
.manage-main { max-width: 1440px; margin: 0 auto; padding: 28px; }
.manage-content { min-height: calc(100vh - 128px); padding: 24px; background: #fff; border: 1px solid #ece6ee; border-radius: 20px; }
.manage-content.view-dashboard { padding: 0; background: transparent; border: 0; }
.form-notice { min-height: 0; margin-bottom: 10px; padding: 0; font-size: 13px; }
.form-notice:empty { display: none; }
.form-notice.success:not(:empty), .form-notice.error:not(:empty) { padding: 11px 14px; border-radius: 10px; }
.form-notice.success:not(:empty) { color: #267a55; background: #eaf7ef; }
.form-notice.error:not(:empty) { color: #ad3f47; background: #fff0f1; }

/* Dashboard */
.dashboard { display: flex; flex-direction: column; gap: 20px; }
.dashboard-hero { display: flex; align-items: center; justify-content: space-between; gap: 30px; min-height: 230px; padding: 34px 38px; overflow: hidden; background: linear-gradient(125deg, #eee8fb, #fff8fb 54%, #ffe2dd); border: 1px solid #e9dfee; border-radius: 22px; }
.dashboard-kicker { display: inline-flex; padding: 6px 10px; color: #775b90; background: rgba(255, 255, 255, .68); border-radius: 999px; font-size: 11px; font-weight: 700; }
.dashboard-hero h1 { margin: 14px 0 7px; color: #3e3344; font-size: clamp(25px, 3vw, 36px); }
.dashboard-hero p { margin: 0 0 22px; color: #776c7b; font-size: 14px; }
.primary-link { display: inline-flex; align-items: center; min-height: 42px; padding: 0 18px; color: #fff; background: linear-gradient(110deg, #8f70ca, #eb898e); border-radius: 11px; font-size: 13px; font-weight: 700; box-shadow: 0 10px 24px rgba(145, 92, 143, .2); }
.queue-summary { display: flex; gap: 1px; overflow: hidden; background: rgba(255, 255, 255, .65); border: 1px solid rgba(255, 255, 255, .8); border-radius: 18px; }
.queue-summary div { min-width: 135px; display: flex; flex-direction: column; padding: 24px; background: rgba(255, 255, 255, .42); }
.queue-summary strong { color: #49384f; font-size: 32px; }
.queue-summary span { margin-top: 4px; color: #837587; font-size: 12px; }
.dashboard-section { padding: 24px; background: #fff; border: 1px solid #ece6ee; border-radius: 18px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.section-heading h2, .system-panel h2 { margin: 0; color: #453a4a; font-size: 17px; }
.section-heading p { margin: 5px 0 0; color: #968c99; font-size: 12px; }
.metric-list { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)); border-top: 1px solid #f0ebf2; border-left: 1px solid #f0ebf2; }
.metric-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 66px; padding: 14px 16px; border-right: 1px solid #f0ebf2; border-bottom: 1px solid #f0ebf2; }
.metric-row span { color: #776d7b; font-size: 12px; }
.metric-row b { color: #5f4776; font-size: 23px; }
.dashboard-lower { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, .7fr); gap: 20px; }
.onboarding-steps { margin: 0; padding: 0; list-style: none; }
.onboarding-steps li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid #f0ebf2; }
.onboarding-steps li:last-child { border-bottom: 0; }
.onboarding-steps li > span { width: 28px; height: 28px; display: grid; place-items: center; color: #74558e; background: #f0e9f7; border-radius: 50%; font-size: 12px; font-weight: 700; }
.onboarding-steps li div { display: flex; flex-direction: column; gap: 3px; }
.onboarding-steps strong { font-size: 13px; }
.onboarding-steps small { color: #958b98; font-size: 11px; }
.step-action { padding: 7px 10px; color: #73568e; background: #fff; border: 1px solid #dcd0e4; border-radius: 8px; font-size: 11px; }
.system-panel { align-self: start; }
.system-panel p { color: #827783; font-size: 13px; line-height: 1.65; }
.system-ok { display: inline-flex; margin-top: 18px; padding: 7px 10px; color: #2e8059; background: #e7f6ed; border-radius: 999px; font-size: 12px; }
.system-panel button { padding: 8px 11px; border-radius: 8px; font-size: 12px; }

/* Management forms and tables */
.editor { margin-bottom: 24px; padding: 20px; background: #fcfafc; border: 1px solid #ece6ee; border-radius: 15px; }
.editor h2 { margin: 0 0 16px; color: #4a3e4f; font-size: 16px; }
.editor-form, .filter-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; gap: 13px; }
.filter-form { margin-bottom: 20px; padding: 17px; background: #faf7fb; border: 1px solid #eee8f0; border-radius: 14px; }
.field { display: flex !important; flex-direction: column; gap: 7px; margin: 0 !important; color: #5c5161; font-size: 12px; }
.field input, .field textarea, .field select { width: 100%; min-height: 40px; padding: 9px 10px; color: #413745; background: #fff; border: 1px solid #dcd3e0; border-radius: 9px; }
.field textarea { resize: vertical; }
.field-checkbox { flex-direction: row !important; align-items: center; justify-content: flex-start; padding-top: 25px; }
.field-checkbox input { width: auto; min-height: auto; }
.field small { color: #958b99; font-size: 11px; line-height: 1.45; }
.form-actions, .table-actions, .pager { display: flex; align-items: center; gap: 8px; }
.form-actions button, .filter-form button, .table-actions button, .pager button { width: auto; min-height: 38px; margin: 0; padding: 8px 12px; border-radius: 8px; }
.form-actions button:first-child, .filter-form > button { color: #fff; background: linear-gradient(110deg, #8e70ca, #e9898e); border: 0; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { max-width: 320px; padding: 12px 11px; border-bottom: 1px solid #f0ebf2; text-align: left; vertical-align: top; word-break: break-word; }
th { color: #7e7381; background: #faf8fb; font-size: 11px; font-weight: 700; }
td { color: #4f4553; }
.table-empty { padding: 42px 20px; color: #918694; text-align: center; }
.material-thumb { width: 58px; height: 58px; object-fit: cover; border-radius: 10px; }
.pager { margin-top: 17px; color: #817683; font-size: 12px; }
.load-error { display: grid; place-items: center; min-height: 360px; color: #827784; text-align: center; }
.load-error strong { color: #514557; font-size: 17px; }
.load-error p { margin: 8px 0 14px; }
.load-error button { padding: 8px 12px; border-radius: 8px; }
.sidebar-mask { position: fixed; inset: 0; z-index: 15; background: rgba(40, 30, 44, .34); }

@media (max-width: 1120px) {
  .desk-grid { grid-template-columns: 270px 1fr; }
  .profile { display: none; }
  .metric-list { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
}

@media (max-width: 860px) {
  .management-page { overflow: auto; }
  .manage-sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 16px 0 40px rgba(49, 34, 55, .15); }
  .manage-sidebar.open { transform: translateX(0); }
  .manage-stage { margin-left: 0; }
  .mobile-menu { display: inline-flex; }
  .manage-topbar { padding: 0 16px; }
  .topbar-context { flex: 1; }
  .manager-copy, .presence-dot { display: none; }
  .manage-main { padding: 18px; }
  .dashboard-hero { align-items: stretch; flex-direction: column; }
  .queue-summary { align-self: stretch; }
  .queue-summary div { flex: 1; }
  .dashboard-lower { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .desk-account .desk-live, .desk-account #agentName { display: none; }
  .desk-grid { grid-template-columns: 1fr; }
  .conversations { display: none; }
  .chat { height: calc(100vh - 66px); }
  .chat-head { align-items: flex-start; flex-direction: column; }
  .chat-actions { width: 100%; overflow-x: auto; }
  .manage-main { padding: 12px; }
  .manage-content { padding: 15px; border-radius: 15px; }
  .dashboard-hero { padding: 25px; }
  .queue-summary div { min-width: 0; padding: 17px; }
  .metric-list { grid-template-columns: 1fr; }
  .editor-form, .filter-form { grid-template-columns: 1fr; }
  .onboarding-steps li { grid-template-columns: 30px minmax(0, 1fr); }
  .onboarding-steps .step-action { grid-column: 2; justify-self: start; }
}
.field .field-error {
  color: #b4233e;
  min-height: 1.2em;
}
