:root {
  color-scheme: light;
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-2: #f0f4f2;
  --text: #16211d;
  --muted: #64736d;
  --border: #dce5e0;
  --accent: #16745f;
  --accent-2: #0f5e4d;
  --danger: #a33b3b;
  --shadow: 0 14px 40px rgba(25, 42, 35, 0.08);
  --app-height: 100vh;
  --admin-head-max-height: 42vh;
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
}

html.is-ios.is-client,
html.is-ios.is-client body {
  height: var(--app-height, 100vh);
  min-height: -webkit-fill-available;
  position: fixed;
  inset: 0;
  width: 100%;
}

#app {
  height: 100%;
  overflow: hidden;
}

html.is-ios.is-client #app {
  height: var(--app-height, 100vh);
}

body.image-viewer-open,
body.topup-import-open,
body.topup-manage-open,
body.quick-reply-open {
  overflow: hidden;
  overscroll-behavior: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button.is-clicked {
  animation: client-button-click 220ms ease-out both;
}

@keyframes client-button-click {
  0% { transform: scale(1); }
  45% { transform: scale(.94); }
  100% { transform: scale(1); }
}

a {
  color: var(--accent);
  text-decoration: none;
}

.shell {
  min-height: 100vh;
  min-height: 100dvh;
  min-height: var(--app-height, 100dvh);
  display: grid;
  place-items: center;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px;
}

html.is-ios.is-client .shell {
  height: var(--app-height, 100vh);
  min-height: var(--app-height, 100vh);
  padding-top: max(14px, env(safe-area-inset-top));
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}

.login-panel {
  width: min(440px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #dff3ec;
  color: var(--accent);
  font-weight: 800;
}

.brand-mark.small {
  width: 34px;
  height: 34px;
  font-size: 16px;
}

.brand h1,
.brand h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.muted {
  color: var(--muted);
}

.form {
  display: grid;
  gap: 14px;
}

.login-hint {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid #cfe8de;
  border-radius: 8px;
  background: #f1fbf7;
  color: #243b34;
  line-height: 1.45;
}

.login-hint strong {
  font-size: 15px;
}

.login-hint span {
  color: var(--muted);
  font-size: 13px;
}

.login-hint span + span {
  padding-top: 3px;
  border-top: 1px solid rgba(207, 232, 222, 0.75);
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: #30423b;
  font-size: 14px;
  font-weight: 650;
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  font-size: 16px;
}

.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 116, 95, 0.12);
}

.textarea {
  resize: none;
  min-height: 88px;
  max-height: 30vh;
  overflow: auto;
  line-height: 1.45;
}

.primary,
.secondary,
.ghost,
.danger {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
  transition: background 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease, color 0.16s ease;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-2);
}

.secondary {
  background: #e5efe9;
  color: #173f34;
}

.ghost {
  background: transparent;
  color: var(--accent);
}

.danger {
  background: #f5e3e3;
  color: var(--danger);
}

.status-ok {
  color: var(--accent-2);
  font-weight: 750;
}

.status-danger {
  color: var(--danger);
  font-weight: 750;
}

.error {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 14px;
}

.app-layout {
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.client-topbar {
  min-height: 68px;
  height: auto;
  gap: 16px;
  padding: 12px 22px;
}

.client-account-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
  flex: 0 0 auto;
}

.client-account-actions .client-wechat-bind-button,
.client-account-actions > #logoutBtn {
  white-space: nowrap;
  font-size: 12px;
}

.client-wechat-bound {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #bcd9c7;
  border-radius: 999px;
  color: #2d7651;
  background: #f1faf4;
  font-size: 12px;
  white-space: nowrap;
}
.client-wechat-bind-options { display: grid; grid-template-columns: 1fr; gap: 12px; margin: 12px 0 14px; }
.client-wechat-bind-option { display: grid; align-content: start; gap: 7px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: #fbfdfc; }
.client-wechat-bind-option strong { font-size: 12px; }
.client-wechat-bind-option img { width: min(190px, 100%); height: auto; aspect-ratio: 1; object-fit: contain; border-radius: 6px; background: #fff; -webkit-touch-callout: default; user-select: none; }
.client-wechat-bind-option p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.topbar-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-brand > div:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.topbar-brand strong {
  font-size: 16px;
}

.topbar-brand span {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-presence,
.service-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 700;
}

.presence-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  background: #16a36a;
  box-shadow: 0 0 0 4px rgba(22, 163, 106, 0.12);
}

.presence-dot.offline {
  background: #9aa5a0;
  box-shadow: 0 0 0 4px rgba(100, 115, 109, 0.12);
}

.client-workspace {
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-columns: 280px minmax(0, 920px);
  justify-content: center;
  gap: 18px;
  padding: 18px;
}

.client-panel {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 12px;
}

.service-card,
.info-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.service-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.service-avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #dff3ec;
  color: var(--accent-2);
  font-weight: 850;
}

.service-name {
  margin-bottom: 5px;
  font-size: 17px;
  font-weight: 800;
}

.info-panel {
  display: grid;
}

.info-row {
  display: grid;
  gap: 5px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.info-row:last-child {
  border-bottom: 0;
}

.info-row span {
  color: var(--muted);
  font-size: 12px;
}

.info-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.chat {
  min-height: 0;
  max-height: 100%;
  display: grid;
  grid-template-rows: 1fr auto;
  width: min(920px, 100%);
  margin: 0 auto;
}

.client-chat {
  width: 100%;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: var(--shadow);
  overflow: hidden;
  grid-template-rows: auto 1fr auto;
}

.conversation-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.conversation-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.conversation-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.presence-dot.busy { background: #dc3545; box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.12); }
.presence-dot.sleeping { background: #2878db; box-shadow: 0 0 0 4px rgba(40, 120, 219, 0.12); }
#conversationPresence.busy { color: #b72132; background: #fdecef; }
#conversationPresence.sleeping { color: #2167ba; background: #eaf2ff; }
.service-presence-copy { min-width: 0; }
.presence-message { margin-top: 7px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.presence-last-seen { margin-top: 6px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.admin-presence-trigger { display: inline-flex; align-items: center; gap: 8px; padding: 5px 3px; background: transparent; border: 0; color: var(--muted); font-size: 12px; }
.admin-presence-form { padding: 18px; border-top: 1px solid var(--border); }
.admin-presence-form fieldset { min-width: 0; margin: 0; padding: 0; border: 0; display: grid; gap: 14px; }
.admin-presence-form [hidden] { display: none; }
.admin-presence-form textarea { min-height: 80px; max-height: 160px; resize: vertical; }
.admin-totals-control { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.admin-totals-preview { margin: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
#adminPresenceFeedback { min-height: 20px; margin-top: 8px; overflow-wrap: anywhere; }
.notification-health { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; font-size: 12px; }
.notification-health summary { cursor: pointer; font-size: 14px; font-weight: 700; }
.notification-health dl > div { padding: 7px 0; border-bottom: 1px solid var(--border); }
.notification-health dt { color: var(--muted); }
.notification-health dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.notification-health-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.notification-health-actions button { font-size: 12px; padding: 7px 9px; }

.conversation-badges {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.messages {
  min-height: 0;
  overflow: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  min-width: 0;
  box-sizing: border-box;
  max-width: min(720px, 84%);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface);
}

.message.customer {
  align-self: flex-end;
  background: #e7f5ef;
  border-color: #c7e7dc;
}

.message.admin {
  align-self: flex-start;
}

.system-notice {
  align-self: center;
  max-width: min(520px, 92%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef3f1;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.system-notice span:first-child {
  color: #43564f;
  font-weight: 750;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
}

.message-meta > span:first-child {
  flex: 0 0 auto;
}

.meta-right {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.read-receipt {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 750;
}

.read-receipt.read {
  background: #e7f5ef;
  color: var(--accent-2);
}

.read-receipt.unread {
  background: #f1f4f2;
  color: var(--muted);
}

.revoke-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 7px;
  background: #f5e3e3;
  color: var(--danger);
  font-size: 11px;
  font-weight: 750;
}

.message.revoked {
  border-style: dashed;
}

.message-body {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}

.session-account-email {
  min-width: 0;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(22, 116, 95, 0.18);
  color: #173f34;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.session-account-email span {
  color: var(--muted);
  font-weight: 650;
}

.session-body {
  display: grid;
  gap: 8px;
}

.session-collapsed {
  display: grid;
  gap: 8px;
}

.session-label {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
}

.session-body pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
}

.session-tail {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.session-full {
  display: none;
  max-height: 48vh;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 10px;
  border: 1px solid #cfe4dc;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.session-body.expanded .session-collapsed {
  display: none;
}

.session-body.expanded .session-full {
  display: block;
}

.session-divider {
  color: var(--muted);
  font-weight: 850;
  letter-spacing: 0;
}

.session-toggle {
  width: fit-content;
  min-height: 30px;
  border: 1px solid #bbdacf;
  border-radius: 8px;
  padding: 0 11px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 800;
}

.session-toggle:hover {
  background: #f7fffb;
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.message-actions + .message-actions {
  margin-top: 8px;
}

.message-topup-actions {
  align-items: flex-start;
}

.message-action {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid #bbdacf;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 750;
}

.message-action:hover:not(:disabled) {
  background: #f7fffb;
}

.message-action.danger-action {
  border-color: #edc8c8;
  color: var(--danger);
}

.message-action.topup-action {
  border-color: #b6d4ff;
  background: #f5f9ff;
  color: #2463c7;
}

.message-action.topup-release-action {
  border-color: #efd6a2;
  color: #946100;
}

.message-action.topup-used-action {
  border-color: #b8d9c4;
  color: #24733f;
}

.message-action.subscription-action {
  border-color: #c8c3ef;
  background: #f8f7ff;
  color: #5444a8;
}

.message-action.subscription-action-free {
  border-color: #cfd4dc;
  background: #f1f3f5;
  color: #68717d;
}

.topup-state {
  min-height: 32px;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 0 10px;
  border: 1px solid #dbe7ff;
  border-radius: 8px;
  background: #f7fbff;
  color: #4d6385;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.45;
  white-space: normal;
  user-select: text;
}

.topup-state.used {
  border-color: #cce8d4;
  background: #f4fbf6;
  color: #24733f;
}

.topup-card-text {
  user-select: text;
  overflow-wrap: anywhere;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-weight: 800;
}

.message-action:disabled {
  cursor: default;
  opacity: 0.78;
}

.attachment {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 650;
}

.attachment-label,
.attachment-size {
  flex: 0 0 auto;
  white-space: nowrap;
}

.attachment-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-preview {
  display: block;
  /* Reserve the preview before lazy images load, including old attachments
     without dimensions. Keep scrolling stable on entry and while reading. */
  width: 340px;
  max-width: 100%;
  height: 280px;
  margin-top: 8px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  cursor: zoom-in;
  text-align: left;
}

.image-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: block;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  background: rgba(10, 16, 14, 0.9);
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  transition: opacity 120ms ease;
  contain: layout paint size;
}

.image-viewer.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.image-viewer-stage {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: contain;
  -webkit-tap-highlight-color: transparent;
  cursor: grab;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.image-viewer-stage:active {
  cursor: grabbing;
}

.image-viewer-img {
  max-width: 96vw;
  max-height: 92vh;
  object-fit: contain;
  opacity: 0;
  visibility: hidden;
  user-select: none;
  -webkit-user-drag: none;
  transform: translate3d(var(--pan-x, 0), var(--pan-y, 0), 0) scale(var(--zoom, 1));
  -webkit-transform: translate3d(var(--pan-x, 0), var(--pan-y, 0), 0) scale(var(--zoom, 1));
  transform-origin: center;
  -webkit-transform-origin: center;
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: opacity 80ms ease;
}

.image-viewer.open .image-viewer-img.ready {
  opacity: 1;
  visibility: visible;
}

.image-viewer-close {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 2;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.94);
  color: #16211d;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.24);
  font-size: 30px;
  line-height: 1;
  font-weight: 500;
}

.image-viewer-close:hover {
  background: #fff;
}

.reply-suggestion-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 34px;
  min-width: 0;
  height: 34px;
  padding: 2px 10px;
  border-top: 1px solid var(--border);
  background: #fbfcfb;
}
.reply-suggestion-text {
  flex: 1;
  min-width: 0;
  height: 28px;
  padding: 0 3px;
  border: 0;
  background: transparent;
  text-align: left;
  color: #235e46;
  font: inherit;
  font-size: 13px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
}
.reply-suggestion-text:disabled { cursor: default; }
.reply-suggestion-text.is-thinking { color: #7d8c83; }
.reply-suggestion-text.is-status { color: #7d8c83; font-size: 12px; cursor: default; }
.reply-suggestion-text:not(:disabled):hover { color: #153d2c; background: #edf5f0; border-radius: 5px; }
.reply-suggestion-actions { display: flex; flex: 0 0 auto; gap: 3px; }
.reply-suggestion-actions button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 4px;
  border: 1px solid #dce6df;
  border-radius: 7px;
  color: #52685b;
  background: #fff;
  cursor: pointer;
}
.reply-suggestion-actions button:not(:disabled):hover { background: #edf5f0; color: #235e46; }
.reply-suggestion-actions button:disabled { opacity: .35; cursor: default; }
.reply-suggestion-actions button.has-error { color: #9e6028; border-color: #d8b990; }
.reply-suggestion-actions svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.reply-suggestion-actions button.is-thinking svg { animation: suggestion-spin 1.1s linear infinite; }
.reply-suggestion-row button:focus-visible { outline: 2px solid #62a681; outline-offset: 1px; }
.reply-suggestion-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@keyframes suggestion-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .reply-suggestion-actions button.is-thinking svg { animation: none; } }

.quick-reply-bar {
  position: relative;
  z-index: 2;
  min-width: 0;
  flex: 0 0 auto;
  padding: 5px 10px 3px;
  border-top: 1px solid var(--border);
  background: #f7faf8;
}

.quick-reply-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 1px 2px;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 1px;
  scrollbar-width: thin;
  touch-action: pan-x;
  -webkit-overflow-scrolling: touch;
}

.quick-reply-scroll::-webkit-scrollbar {
  height: 4px;
}

.quick-reply-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.quick-reply-scroll::-webkit-scrollbar-thumb {
  border-radius: 4px;
  background: #b9cbc4;
}

.quick-reply-add,
.quick-reply-item {
  position: relative;
  width: 96px;
  height: 52px;
  min-width: 96px;
  min-height: 52px;
  max-width: 96px;
  flex: 0 0 96px;
  scroll-snap-align: start;
  overflow: hidden;
  border: 1px solid #cfe3dc;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.quick-reply-add {
  display: grid;
  grid-template-columns: auto auto;
  place-content: center;
  align-items: center;
  gap: 4px;
  color: var(--accent-2);
}

.quick-reply-add span {
  font-size: 20px;
  font-weight: 500;
  line-height: 1;
}

.quick-reply-add strong {
  font-size: 13px;
}

.quick-reply-item {
  display: grid;
  place-items: center;
  padding: 5px 7px;
  text-align: left;
}

.quick-reply-item.has-image {
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 6px;
}

.quick-reply-add:hover,
.quick-reply-item:hover {
  border-color: #9fc8b8;
  background: #f1f8f5;
}

.quick-reply-add:focus-visible,
.quick-reply-item:focus-visible {
  outline: 3px solid rgba(22, 116, 95, 0.2);
  outline-offset: -1px;
}

.quick-reply-add:disabled,
.quick-reply-item:disabled {
  cursor: wait;
  opacity: 0.62;
}

.quick-reply-media {
  width: 30px;
  height: 36px;
  display: block;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #eef3f0;
}

.quick-reply-media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  pointer-events: none;
}

.quick-reply-text {
  min-width: 0;
  max-width: 100%;
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.quick-reply-progress {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.92);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 800;
}

.quick-reply-status {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.quick-reply-status:empty {
  display: none;
}

.quick-reply-status.error {
  color: var(--danger);
}

.quick-reply-overlay {
  position: fixed;
  inset: 0;
  z-index: 1450;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(12, 22, 18, 0.58);
}

.quick-reply-dialog {
  width: min(520px, 100%);
  max-height: min(680px, calc(var(--app-height, 100dvh) - 32px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(10, 24, 18, 0.28);
}

.quick-reply-dialog-head {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--border);
}

.quick-reply-dialog-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.quick-reply-dialog-close {
  width: 36px;
  height: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 25px;
  line-height: 1;
}

.quick-reply-dialog-body {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 14px;
  overflow: auto;
  padding: 16px 18px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.quick-reply-dialog-text {
  min-height: 128px;
  max-height: 36vh;
  resize: vertical;
}

.quick-reply-image-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7faf8;
}

.quick-reply-image-row[hidden] {
  display: none;
}

.quick-reply-image-row img {
  width: 54px;
  height: 54px;
  display: block;
  object-fit: cover;
  border-radius: 6px;
  background: #eef3f0;
}

.quick-reply-image-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.quick-reply-image-row button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 22px;
}

.quick-reply-image-picker {
  width: fit-content;
  min-height: 40px;
  display: inline-grid;
  place-items: center;
  padding: 0 14px;
  cursor: pointer;
}

.quick-reply-dialog-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.quick-reply-dialog-status.error {
  color: var(--danger);
}

.quick-reply-dialog-actions {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  padding: 12px 18px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

.quick-reply-dialog-actions button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.composer {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  padding: 14px 16px 18px;
}

html.is-ios.is-client .client-chat .composer {
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  will-change: transform;
}

.composer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.composer-row > * {
  min-width: 0;
}

.file-name {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.file-name:empty {
  margin-top: 0;
}

.selected-file {
  display: flex;
  width: min(100%, 100%);
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
  align-items: center;
  gap: 8px;
  padding: 7px 8px 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7faf8;
  color: #173f34;
}

.selected-file-name {
  flex: 1 1 auto;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-clear {
  flex: 0 0 auto;
  min-height: 28px;
  border-radius: 7px;
  padding: 0 9px;
  background: #f5e3e3;
  color: var(--danger);
  font-weight: 750;
}

.file-clear:hover {
  background: #efd2d2;
}

.upload-button {
  display: grid;
  place-items: center;
}

.composer .primary {
  background: #9bb8ad;
  opacity: 0.72;
  box-shadow: none;
}

.composer .primary:hover {
  background: #8fad9f;
}

.composer.has-draft .primary,
.composer .primary.send-ready {
  background: #16745f;
  opacity: 1;
  box-shadow: 0 0 0 3px rgba(22, 116, 95, 0.14), 0 8px 18px rgba(22, 116, 95, 0.18);
}

.composer.has-draft .primary:hover,
.composer .primary.send-ready:hover {
  background: #0f5e4d;
}

.composer.is-sending .primary,
.composer .primary:disabled {
  cursor: wait;
  opacity: 0.72;
  box-shadow: none;
}

.client-empty {
  align-self: center;
  justify-self: center;
  width: min(360px, 100%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.client-empty div:last-child {
  display: grid;
  gap: 5px;
}

.client-empty strong {
  font-size: 16px;
}

.client-empty span {
  color: var(--muted);
  font-size: 13px;
}

.admin-layout {
  height: 100vh;
  height: 100svh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 340px 1fr;
  grid-template-rows: minmax(0, 1fr);
  background: var(--bg);
}

.admin-nav-scrim {
  position: fixed;
  inset: 0;
  z-index: 899;
  padding: 0;
  border-radius: 0;
  background: rgba(12, 22, 18, 0.42);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.admin-nav-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 900;
  width: min(280px, calc(100vw - 48px));
  min-width: 0;
  display: grid;
  grid-template-rows: repeat(4, max-content);
  align-content: start;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 18px 0 46px rgba(10, 24, 18, 0.2);
  transform: translateX(-101%);
  visibility: hidden;
  transition: transform 0.2s ease, visibility 0.2s ease;
}

.admin-layout.admin-nav-open .admin-nav-scrim {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.admin-layout.admin-nav-open .admin-nav-drawer {
  transform: translateX(0);
  visibility: visible;
}

.admin-nav-drawer-head {
  min-width: 0;
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.admin-nav-brand {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.admin-nav-brand strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
}

.admin-nav-brand span {
  color: var(--muted);
  font-size: 13px;
}

.admin-nav-sections {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 6px;
  overflow-y: auto;
  padding: 12px;
}

.admin-nav-item {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 15px;
  font-weight: 800;
}

.admin-nav-item:hover {
  background: var(--surface-2);
}

.admin-nav-item.active {
  border-color: #cfe3dc;
  background: #e5f3ed;
  color: var(--accent-2);
}

.admin-nav-toggle {
  width: 38px;
  height: 38px;
  min-height: 38px;
  flex: 0 0 38px;
  padding: 0;
  border: 1px solid transparent;
  font-size: 16px;
  line-height: 1;
}

.admin-nav-toggle:hover {
  border-color: #c5dfd6;
  background: #cfeadf;
}

.admin-nav-toggle:focus-visible {
  outline: 3px solid rgba(22, 116, 95, 0.2);
  outline-offset: 2px;
}

.sidebar {
  grid-column: 1;
  grid-row: 1;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.sidebar-head {
  padding: 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-titlebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
}

.sidebar-titlebar .brand {
  min-width: 0;
  margin-bottom: 0;
}

.relay-sidebar-titlebar {
  min-width: 0;
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.relay-sidebar-titlebar strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
}

.relay-customers-back {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid #cfe3dc;
  background: #f6fbf8;
  white-space: nowrap;
}

.archive-toggle {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #cfe3dc;
  background: #f6fbf8;
  white-space: nowrap;
}

.archive-toggle.active {
  background: #fff4db;
  color: #8a5a00;
  border-color: #ead5a8;
}

.filters {
  display: grid;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.topup-inventory {
  padding: 9px 10px;
  border: 1px solid #cfe3dc;
  border-radius: 8px;
  background: #f6fbf8;
  color: #173f34;
}

.topup-inventory.low {
  border-color: #e3d0a6;
  background: #fffaf0;
  color: #684a11;
}

.topup-inventory.empty,
.topup-inventory.error {
  border-color: #edc8c8;
  background: #fff6f6;
  color: var(--danger);
}

.topup-inventory-head,
.topup-inventory-error-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.topup-inventory-channels {
  display: grid;
  gap: 5px;
  margin-top: 7px;
}

.topup-inventory-columns,
.topup-inventory-channel-row {
  display: grid;
  grid-template-columns: 30px repeat(2, minmax(26px, .8fr)) minmax(42px, 1.2fr) repeat(2, minmax(34px, 1fr));
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.topup-inventory-columns {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
  padding-bottom: 3px;
  border-bottom: 1px solid #dfe9e4;
}

.topup-inventory-columns > :first-child { text-align: left; }
.topup-inventory-channel-name { font-size: 12px; white-space: nowrap; }
.topup-inventory-channel-row { min-height: 25px; }
.topup-inventory-channel-row .topup-inventory-stat span { display: none; }
.topup-inventory-channel-row .topup-inventory-stat strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.topup-inventory-channel-row .topup-inventory-stat:nth-child(2) strong { font-size: 16px; }

.topup-inventory-channel-row.low {
  color: #684a11;
}

.topup-inventory-channel-row.empty {
  color: var(--danger);
}

.topup-inventory-error-row {
  justify-content: space-between;
}

.topup-inventory-stat {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  white-space: nowrap;
}

.topup-inventory-stat.low {
  color: #8a5a00;
}

.topup-inventory-stat.empty {
  color: var(--danger);
}

.topup-inventory-main {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.topup-inventory-actions {
  display: flex;
  gap: 4px;
}

.topup-inventory-import,
.topup-inventory-manage {
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid rgba(22, 116, 95, 0.24);
  background: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
}

.topup-inventory-main span,
.topup-inventory-stat span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.topup-inventory-main strong {
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0;
}

.topup-inventory-stat strong {
  font-size: 15px;
  line-height: 1;
  letter-spacing: 0;
}

.topup-inventory-meta {
  color: inherit;
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.topup-import-overlay {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(12, 22, 18, 0.58);
}

.topup-import-dialog {
  width: min(520px, 100%);
  max-height: min(680px, calc(var(--app-height, 100dvh) - 32px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(10, 24, 18, 0.28);
}

.topup-import-head {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--border);
}

.topup-import-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.topup-import-close {
  width: 36px;
  height: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 25px;
  line-height: 1;
}

.topup-import-body {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 14px;
  overflow: auto;
  padding: 16px 18px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.topup-import-channel-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f3f6f4;
}

.topup-import-channel-picker button {
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.topup-import-channel-picker button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(14, 35, 28, 0.14);
}

.topup-import-textarea {
  min-height: 190px;
  max-height: 42vh;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  letter-spacing: 0;
}

.topup-import-validation {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.topup-import-validation.error {
  color: var(--danger);
}

.topup-import-counts {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.topup-import-counts span {
  min-width: 0;
  padding: 6px;
  border-bottom: 2px solid var(--border);
  text-align: center;
  white-space: nowrap;
}

.topup-import-invalid,
.topup-import-result {
  display: grid;
  gap: 4px;
  overflow-wrap: anywhere;
}

.topup-import-result {
  padding-left: 12px;
  border-left: 3px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.topup-import-result.success {
  border-left-color: var(--accent);
  color: #234b40;
}

.topup-import-result.error {
  border-left-color: var(--danger);
  color: var(--danger);
}

.topup-import-result strong {
  color: var(--text);
  font-size: 14px;
}

.topup-import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

.topup-import-actions .primary:disabled {
  cursor: default;
  opacity: 0.5;
}

.topup-manage-overlay {
  position: fixed;
  inset: 0;
  z-index: 1410;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(12, 22, 18, 0.58);
}

.topup-manage-dialog {
  width: min(980px, 100%);
  height: min(760px, calc(var(--app-height, 100dvh) - 32px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(10, 24, 18, 0.28);
}

.topup-manage-head {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--border);
}

.topup-manage-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.topup-manage-close {
  width: 36px;
  height: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 25px;
  line-height: 1;
}

.topup-manage-body {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  overflow: hidden;
}

.topup-manage-unlock {
  width: min(380px, calc(100% - 32px));
  align-self: center;
  justify-self: center;
  display: grid;
  gap: 14px;
  padding: 20px 0;
}

.topup-manage-error {
  margin: 0;
  color: var(--danger);
  font-size: 14px;
}

.topup-manage-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 150px 150px auto;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.topup-manage-refresh {
  min-height: 44px;
}

.topup-manage-overview {
  padding: 8px 14px;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.topup-manage-list {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.topup-manage-row {
  display: grid;
  grid-template-columns: 22px minmax(220px, 1fr) 52px 52px auto;
  align-items: center;
  gap: 10px;
  min-height: 62px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}

.topup-manage-card {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.topup-manage-select { width: 18px; height: 18px; accent-color: var(--accent, #258669); cursor: pointer; }
.topup-manage-batch { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 7px 14px; border-bottom: 1px solid var(--border); }
.topup-manage-batch label { display: flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 13px; }
.topup-manage-batch button, .topup-manage-pagination button { min-height: 32px; padding: 5px 9px; font-size: 12px; }
#topupManageSelectionCount { color: var(--muted); font-size: 12px; margin-right: auto; }
.topup-manage-pagination { display: flex; gap: 7px; align-items: center; padding: 6px 14px; border-top: 1px solid var(--border); }
.topup-manage-pagination span { flex: 1; font-size: 12px; color: var(--muted); }
.topup-shop-sales { padding: 5px 14px 8px; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }

/* Compact announcement and call surfaces. They stay beside the chat so the
   message column keeps its reading height. */
.permanent-announcement { display: grid; gap: 9px; padding: 13px 15px 14px; }
.announcement-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.announcement-label { display: inline-flex; align-items: center; gap: 8px; min-width: 0; color: var(--text); }
.announcement-label strong { font-size: 13px; letter-spacing: .02em; }
.announcement-label-glyph { display: inline-grid; place-items: center; width: 25px; height: 25px; border: 1px solid #c8ddd2; border: 1px solid color-mix(in srgb, var(--accent-2) 34%, var(--border)); border-radius: 8px; background: #f1f7f3; background: color-mix(in srgb, var(--accent-2) 8%, var(--surface)); color: var(--accent-2); }
.announcement-label-glyph svg, .announcement-trigger-glyph svg { display: block; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.permanent-announcement .announcement-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.permanent-announcement .announcement-hint { color: var(--accent-2); font-size: 12px; }
.published-announcement-trigger { position: relative; display: inline-grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; min-height: 34px; margin: 0; padding: 0; border: 1px solid #c8ddd2; border: 1px solid color-mix(in srgb, var(--accent-2) 24%, var(--border)); border-radius: 10px; background: #f1f7f3; background: color-mix(in srgb, var(--accent-2) 7%, var(--surface)); color: var(--accent-2); transition: border-color .16s ease, background .16s ease, transform .16s ease; }
.published-announcement-trigger:hover { border-color: #9fc4b2; border-color: color-mix(in srgb, var(--accent-2) 48%, var(--border)); background: #e7f2eb; background: color-mix(in srgb, var(--accent-2) 13%, var(--surface)); transform: translateY(-1px); }
.published-announcement-trigger:focus-visible { outline: 2px solid #9fc4b2; outline: 2px solid color-mix(in srgb, var(--accent-2) 60%, transparent); outline-offset: 2px; }
.announcement-trigger-glyph { display: inline-grid; place-items: center; width: 19px; height: 19px; }
.announcement-unread-dot { position: absolute; top: 3px; right: 3px; z-index: 2; display: block; width: 8px; height: 8px; border: 2px solid var(--surface); border-radius: 50%; background: #e04b54; box-shadow: 0 1px 5px rgba(155, 30, 44, .28); }
.announcement-unread-dot[hidden] { display: none; }
.customer-live-status { display: inline-flex; align-items: center; gap: 5px; }
.customer-live-status.is-online { color: var(--accent-2); font-weight: 750; }
.customer-live-status.is-offline { color: var(--muted); }
.customer-live-status .presence-dot { width: 7px; height: 7px; box-shadow: none; }
.call-user-button { min-height: 34px; padding: 0 12px; border-radius: 8px; background: #e5efe9; color: #173f34; font-weight: 800; }
.call-user-button:disabled { cursor: default; opacity: .5; }
.published-announcements-dialog,
.call-dialog { width: min(560px, calc(100% - 28px)); max-height: min(720px, calc(100dvh - 28px)); padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 24px 80px rgba(10,24,18,.26); }
.published-announcements-dialog[open],
.call-dialog[open],
.client-wechat-bind-dialog[open] { animation: client-dialog-pop-in 180ms ease-out both; }
.published-announcements-dialog::backdrop,
.call-dialog::backdrop,
.client-wechat-bind-dialog::backdrop { background: rgba(12,22,18,.5); animation: client-dialog-backdrop-in 180ms ease-out both; }
.published-announcements-dialog form,
.call-dialog form { display: grid; gap: 0; max-height: inherit; }
.published-announcements-dialog header,
.call-dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.published-announcements-dialog h2 { margin: 0; font-size: 19px; }
.published-announcements-dialog header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.published-announcements-list { min-height: 80px; max-height: 48vh; overflow: auto; padding: 8px 20px; }
.published-announcement-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.published-announcement-item > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.published-announcement-item time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.published-announcement-item p { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.published-announcements-empty { margin: 0; padding: 32px 0; color: var(--muted); text-align: center; }
.published-announcements-dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.admin-announcement-editor { display: grid; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.admin-announcement-editor-actions, .published-announcement-actions { display: flex; justify-content: flex-end; gap: 8px; }
.admin-announcement-editor-actions button, .published-announcement-actions button { min-height: 34px; padding: 0 10px; font-size: 12px; }
.admin-announcement-status { min-height: 18px; margin: 0; color: var(--muted); font-size: 12px; }
.call-dialog { width: min(420px, calc(100% - 28px)); }
.call-dialog header span { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }
.call-dialog-note { margin: 0; padding: 16px 20px; color: var(--muted); line-height: 1.5; }
.call-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.call-audio-output { position: fixed; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

@media (max-width: 760px) {
  .client-workspace { grid-template-columns: 1fr; padding: 10px; gap: 10px; }
  .client-panel { grid-template-columns: minmax(0,1fr) auto; align-items: start; }
  .published-announcement-trigger { width: 34px; height: 34px; min-height: 34px; }
  .permanent-announcement { min-width: 0; }
  .admin-composer-row { grid-template-columns: minmax(0,1fr) auto auto; }
}

.topup-manage-card code {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topup-manage-card span {
  color: var(--muted);
  font-size: 11px;
}

.topup-manage-channel,
.topup-manage-status {
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

.topup-manage-channel.black {
  color: #26332f;
}

.topup-manage-channel.fei2 {
  color: #8a5a00;
}

.topup-manage-channel.ios,
.topup-manage-channel.google,
.topup-manage-status.available {
  color: var(--accent);
}

.topup-manage-status.reserved {
  color: #8a5a00;
}

.topup-manage-status.used {
  color: var(--muted);
}

.topup-manage-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.topup-manage-row-actions button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

.topup-manage-row-actions button:disabled {
  cursor: default;
  opacity: 0.38;
}

.topup-manage-empty {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.customer-list {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.customer-row {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 14px 18px;
  text-align: left;
  background: transparent;
  border-bottom: 1px solid var(--border);
}

.customer-row:hover,
.customer-row.active {
  background: var(--surface-2);
}

.row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.customer-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.customer-note {
  color: var(--muted);
  font-weight: 650;
}

.row-badges {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf4f1;
  color: #315248;
  font-size: 12px;
  font-weight: 700;
}

.pill.unread {
  justify-content: center;
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: #fce8e6;
  color: #b9423a;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.pill.live {
  background: #e7f5ef;
  color: var(--accent-2);
}

.pill.live.offline {
  background: #f1f4f2;
  color: var(--muted);
}

.pill.banned {
  background: #f5e3e3;
  color: var(--danger);
}

.pill.archived {
  background: #eceff1;
  color: #53636d;
}

.admin-main {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.admin-head {
  display: grid;
  gap: 12px;
  padding: 18px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.admin-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.admin-title {
  min-width: 0;
}

.admin-title h2 {
  margin: 0 0 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill.reserved-topup {
  background: #fff4db;
  color: #8a5a00;
}

.admin-note-line {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 7px;
  padding: 4px 9px;
  border: 1px solid #d5eadf;
  border-radius: 999px;
  background: #eef7f2;
  font-size: 13px;
}

.admin-note-line span {
  color: var(--accent-2);
  font-weight: 800;
}

.admin-note-line strong {
  min-width: 0;
  color: var(--text);
  font-weight: 800;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.admin-back {
  display: none;
}

.identity {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.admin-more {
  display: grid;
  gap: 12px;
}

.admin-more > summary {
  display: none;
}

.admin-tools {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
}

.row-preview {
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}

.admin-composer-row {
  grid-template-columns: 1fr auto auto auto;
}

.admin-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.ban-reason {
  padding: 10px 12px;
  border: 1px solid #edc8c8;
  border-radius: 8px;
  background: #fff6f6;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.45;
}

.empty-state {
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 48px;
}

.relay-sidebar {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.relay-sidebar-tools {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.relay-subtabs,
.relay-app-mode {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
  background: #f5f8f6;
}

.relay-subtabs button,
.relay-app-mode button {
  min-width: 0;
  min-height: 34px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.relay-subtabs button + button,
.relay-app-mode button + button {
  border-left: 1px solid var(--border);
}

.relay-subtabs button.active,
.relay-app-mode button.active {
  background: #e5f3ed;
  color: var(--accent-2);
}

.relay-sidebar-status {
  min-width: 0;
  padding: 7px 9px;
  border-left: 3px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.relay-sidebar-status.error {
  border-left-color: var(--danger);
  color: var(--danger);
}

.relay-device-list,
.relay-detail-scroll,
.relay-history-scroll {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.relay-device-row {
  position: relative;
  width: 100%;
  min-width: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.relay-device-open {
  width: 100%;
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 13px 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.relay-device-row:hover,
.relay-device-row.active {
  background: var(--surface-2);
}

.relay-device-row.has-quick-control .relay-device-row-top {
  padding-right: 92px;
}

.relay-device-quick-control {
  position: absolute;
  top: 11px;
  right: 14px;
  min-width: 76px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid #9fc8b8;
  border-radius: 6px;
  color: var(--accent-2);
  background: #e5f3ed;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.relay-device-quick-control:active:not(:disabled) {
  background: #d7ebe3;
}

.relay-device-quick-control:disabled {
  border-color: var(--border);
  color: var(--muted);
  background: #f3f5f4;
}

.relay-device-row-top,
.relay-history-row-top,
.relay-section-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.relay-device-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.pill.relay-role.primary {
  background: #dff3ec;
  color: var(--accent-2);
}

.pill.relay-role.secondary {
  background: #edf4f1;
  color: #315248;
}

.pill.relay-role.unassigned {
  background: #fff4db;
  color: #8a5a00;
}

.relay-device-model,
.relay-device-last,
.relay-device-facts {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.relay-device-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 9px;
}

.relay-device-error,
.relay-detail-error,
.relay-action-status.error,
.relay-app-row-error,
.relay-main-state.error,
.relay-empty.error {
  color: var(--danger);
}

.relay-device-error {
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 12px;
  line-height: 1.4;
}

.relay-empty {
  min-height: 96px;
  padding: 24px 16px;
  text-align: center;
}

.relay-main-state {
  grid-row: 1 / -1;
  min-width: 0;
  min-height: 0;
}

.relay-detail-head,
.relay-history-head {
  min-width: 0;
}

.relay-detail-scroll,
.relay-history-scroll {
  background: var(--surface);
}

.relay-detail-section {
  min-width: 0;
  display: grid;
  gap: 14px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.relay-section-head h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
}

.relay-summary-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 28px;
}

.relay-summary-grid > div {
  min-width: 0;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #edf1ef;
}

.relay-summary-grid span,
.relay-detail-error span {
  color: var(--muted);
  font-size: 13px;
}

.relay-summary-grid strong,
.relay-detail-error strong {
  min-width: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.relay-remote-status {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--border);
}

.relay-remote-status > div {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  background: #f8fbf9;
}

.relay-remote-status span {
  color: var(--muted);
  font-size: 12px;
}

.relay-remote-status strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

body.relay-remote-viewer-open {
  overflow: hidden;
}

.relay-remote-viewer {
  position: fixed;
  inset: 0;
  z-index: 2400;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  color: #f4f7f5;
  background: #080b0a;
}

.relay-remote-viewer-head {
  min-width: 0;
  min-height: 30px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-bottom: 1px solid #303936;
  background: #141a18;
}

.relay-remote-viewer-head button {
  min-width: 0;
  min-height: 24px;
  border: 1px solid #47534f;
  border-radius: 7px;
  color: #f4f7f5;
  background: #222b28;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.relay-remote-viewer-head button:active {
  background: #33403c;
}

.relay-remote-viewer-head .relay-remote-stop-button {
  width: 20px;
  min-height: 20px;
  aspect-ratio: 1;
  justify-self: end;
  padding: 0;
  border-color: #8d4b4b;
  background: #5c2929;
  font-size: 8px;
  line-height: 1;
}

.relay-remote-viewer-title {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.relay-remote-viewer-title strong,
.relay-remote-viewer-status {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relay-remote-viewer-title strong {
  font-size: 12px;
}

.relay-remote-viewer-status {
  color: #aebbb6;
  font-size: 10px;
}

.relay-remote-viewer-status.ok {
  color: #75d5a7;
}

.relay-remote-viewer-status.error {
  color: #f3a2a2;
}

.relay-remote-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #030504;
}

.relay-remote-canvas,
.relay-remote-video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  opacity: 0;
  object-fit: contain;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.relay-remote-canvas.ready {
  opacity: 1;
}

.relay-remote-video {
  pointer-events: none;
}

.relay-remote-video.direct {
  opacity: 1;
  pointer-events: auto;
}

.relay-remote-canvas.relay-hidden {
  opacity: 0;
  pointer-events: none;
}

.relay-remote-stage-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: #aebbb6;
  font-size: 14px;
  text-align: center;
  pointer-events: none;
}

.relay-remote-stage-placeholder.hidden {
  display: none;
}

.relay-remote-toolbar {
  min-width: 0;
  min-height: 32px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 3px 8px max(3px, env(safe-area-inset-bottom));
  border-top: 1px solid #303936;
  background: #141a18;
}

.relay-remote-toolbar button {
  min-width: 0;
  min-height: 26px;
  padding: 0 6px;
  border: 1px solid #47534f;
  border-radius: 6px;
  color: #f4f7f5;
  background: #222b28;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.relay-remote-toolbar button:active {
  background: #33403c;
}

.relay-detail-error {
  min-width: 0;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0 0;
  overflow-wrap: anywhere;
}

.relay-rename {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 420px) auto;
  justify-content: start;
  gap: 10px;
}

.relay-command-row,
.relay-inline-status {
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.relay-lock-command-row {
	margin-top: 8px;
}

.relay-inline-status {
  color: var(--muted);
  font-size: 13px;
}

.relay-inline-status span {
  padding-right: 9px;
  border-right: 1px solid var(--border);
}

.relay-action-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.relay-action-status.success {
  color: var(--accent-2);
}

.relay-app-search {
  max-width: 520px;
}

.relay-app-list {
  min-width: 0;
  border-top: 1px solid var(--border);
}

.relay-app-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 38px minmax(150px, 1fr) auto 190px;
  grid-template-areas:
    "icon identity toggle mode"
    ". error error error";
  align-items: center;
  gap: 8px 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.relay-app-row[aria-busy="true"] {
  opacity: 0.68;
}

.relay-app-icon {
  grid-area: icon;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: #e5f3ed;
  color: var(--accent-2);
  font-size: 15px;
  font-weight: 800;
}

.relay-app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.relay-app-identity {
  grid-area: identity;
  min-width: 0;
  display: grid;
  gap: 3px;
}

.relay-app-identity strong,
.relay-app-identity span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relay-app-identity strong {
  font-size: 14px;
}

.relay-app-identity span {
  color: var(--muted);
  font-size: 12px;
}

.relay-switch {
  grid-area: toggle;
  position: relative;
  width: 42px;
  height: 24px;
  display: block;
  flex: 0 0 auto;
}

.relay-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.relay-switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #b9c5c0;
  transition: background 0.16s ease;
}

.relay-switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(18, 38, 31, 0.24);
  transition: transform 0.16s ease;
}

.relay-switch input:checked + span {
  background: var(--accent);
}

.relay-switch input:checked + span::after {
  transform: translateX(18px);
}

.relay-switch input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(22, 116, 95, 0.18);
}

.relay-switch input:disabled + span,
.relay-app-mode button:disabled {
  cursor: default;
  opacity: 0.48;
}

.relay-app-mode {
  grid-area: mode;
}

.relay-app-row-error {
  grid-area: error;
  min-width: 0;
  min-height: 0;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.relay-history-head .input {
  max-width: 560px;
}

.relay-history-notice {
  padding: 9px 22px;
  border-bottom: 1px solid #ead5a8;
  background: #fffaf0;
  color: #8a5a00;
  font-size: 13px;
}

.relay-history-row {
  min-width: 0;
  display: grid;
  gap: 7px;
  padding: 15px 22px;
  border-bottom: 1px solid var(--border);
  outline: none;
}

.relay-history-row.target {
  background: #eef8f4;
  box-shadow: inset 3px 0 0 var(--accent);
}

.relay-history-row:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.relay-history-row-top strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.relay-history-row-top time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.relay-history-meta {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.relay-history-content {
  min-width: 0;
  display: grid;
  gap: 4px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.relay-history-content strong {
  font-size: 14px;
}

.relay-history-content p {
  margin: 0;
  color: #30423b;
  white-space: pre-wrap;
}

.relay-history-more {
  display: flex;
  justify-content: center;
  padding: 14px;
}

@media (max-width: 860px) {
  .app-layout {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .client-topbar {
    flex-wrap: wrap;
    min-height: 58px;
    padding: 9px 14px;
    row-gap: 6px;
  }

  .brand-mark.small {
    width: 30px;
    height: 30px;
  }

  .topbar-brand {
    flex: 1 1 auto;
  }

  .topbar-brand strong {
    font-size: 15px;
  }

  .topbar-brand span {
    max-width: 230px;
    font-size: 12px;
  }

  .topbar-presence {
    display: none;
  }

  .client-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0;
    padding: 0;
  }

  .client-panel {
    display: block;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.86);
    border-bottom: 1px solid var(--border);
  }

  .client-panel .service-card {
    box-shadow: none;
    padding: 10px 12px;
  }

  .client-panel .service-avatar {
    width: 36px;
    height: 36px;
  }

  .service-name {
    font-size: 15px;
    margin-bottom: 3px;
  }

  .client-panel .info-panel {
    display: none;
  }

  .client-chat {
    border-right: 0;
    border-left: 0;
    border-bottom: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .conversation-head {
    align-items: center;
    padding: 12px 14px;
  }

  .conversation-badges {
    gap: 6px;
  }

  .conversation-head h2 {
    font-size: 16px;
  }

  .conversation-head p {
    font-size: 12px;
  }

  .messages {
    padding: 14px 12px;
    gap: 10px;
  }

  .client-chat .composer {
    padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  }

  .client-chat .composer-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .client-chat .composer-row .textarea {
    grid-column: 1 / -1;
    min-height: 72px;
    max-height: 22vh;
  }

  .client-chat .primary,
  .client-chat .secondary {
    min-height: 40px;
  }

  .admin-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    height: var(--app-height, 100dvh);
    overflow: hidden;
  }

  .admin-layout:not(.detail-open) .admin-main {
    display: none;
  }

  .admin-layout.detail-open .sidebar {
    display: none;
  }

  .sidebar {
    grid-column: 1;
    grid-row: 1;
    height: auto;
    min-height: 0;
    border-right: 0;
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .sidebar-head {
    padding: 12px 14px;
  }

  .sidebar-head .brand {
    margin-bottom: 0;
  }

  .sidebar-head .brand h1,
  .sidebar-head .brand h2 {
    font-size: 20px;
  }

  .filters {
    padding: 10px 12px;
  }

  .customer-list {
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  .customer-row {
    padding: 12px 14px;
    gap: 5px;
  }

  .customer-name {
    font-size: 15px;
  }

  .row-preview {
    -webkit-line-clamp: 2;
    font-size: 13px;
  }

  .admin-main {
    grid-column: 1;
    grid-row: 1;
    height: auto;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .admin-head {
    gap: 8px;
    padding: 8px 10px;
    max-height: var(--admin-head-max-height, 42vh);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  .admin-head-row {
    gap: 8px;
  }

  .admin-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 10px;
    background: #e5efe9;
    white-space: nowrap;
  }

  #logoutAdminBtn {
    flex: 0 0 auto;
    min-width: 52px;
    white-space: nowrap;
  }

  .admin-title {
    flex: 1 1 auto;
  }

  .admin-title h2 {
    margin-bottom: 3px;
    font-size: 17px;
    line-height: 1.25;
  }

  .identity {
    gap: 5px 7px;
    font-size: 12px;
  }

  .admin-more {
    display: block;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fbf9;
  }

  .admin-more > summary {
    min-height: 38px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    color: var(--accent-2);
    cursor: pointer;
    font-weight: 800;
  }

  .admin-more[open] > summary {
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
  }

  .admin-tools {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 0 10px 10px;
  }

  .admin-tools #resetPasswordBtn {
    grid-column: 1 / -1;
  }

  .admin-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 0 10px 10px;
  }

  .admin-actions button {
    min-width: 0;
  }

  .admin-actions #deleteCustomerBtn {
    grid-column: 1 / -1;
  }

  .ban-reason {
    margin: 0 10px 10px;
    padding: 8px 10px;
  }

  #adminMessages {
    padding: 10px 10px;
    gap: 10px;
    overscroll-behavior: contain;
  }

  #adminReplyForm {
    padding: 8px 10px max(10px, env(safe-area-inset-bottom));
  }

  .admin-main .admin-composer-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .admin-main .admin-composer-row .textarea {
    grid-column: 1 / -1;
    min-height: 64px;
    max-height: 28vh;
  }

  .composer-row {
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 94%;
  }

  .relay-sidebar-tools {
    padding: 10px 12px;
  }

  .relay-device-row {
    padding: 0;
  }

  .relay-device-open {
    padding: 12px 14px;
  }

  .relay-detail-section {
    gap: 12px;
    padding: 14px 12px;
  }

  .relay-summary-grid {
    grid-template-columns: 1fr;
  }

  .relay-remote-status {
    grid-template-columns: 1fr;
  }

  .relay-summary-grid > div,
  .relay-detail-error {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .relay-rename {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .relay-command-row button {
    min-width: 0;
  }

  .relay-app-search,
  .relay-history-head .input {
    max-width: none;
  }

  .relay-app-row {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    grid-template-areas:
      "icon identity toggle"
      ". mode mode"
      ". error error";
    gap: 8px 10px;
    padding: 10px 0;
  }

  .relay-app-icon {
    width: 36px;
    height: 36px;
  }

  .relay-history-row {
    padding: 13px 12px;
  }

  .relay-history-row-top {
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 9px 14px;
  }

  .topbar-brand {
    max-width: calc(100vw - 82px);
  }

  .conversation-head {
    padding: 11px 12px;
  }

  .message {
    max-width: 90%;
    padding: 10px 12px;
  }

  .relay-device-row-top,
  .relay-history-row-top {
    align-items: flex-start;
  }

  .relay-device-row-top {
    display: grid;
  }

  .relay-device-row-top .row-badges {
    justify-content: flex-start;
  }

  .relay-device-row.has-quick-control .relay-device-row-top {
    padding-right: 84px;
  }

  .relay-device-quick-control {
    top: 10px;
    right: 12px;
    min-width: 70px;
    min-height: 28px;
    padding: 3px 7px;
  }

  .relay-rename {
    grid-template-columns: 1fr;
  }

  .relay-rename button {
    width: 100%;
  }

  .relay-command-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .relay-command-row button {
    width: 100%;
    padding: 0 8px;
  }

  .relay-history-row-top {
    display: grid;
    gap: 4px;
  }

  .relay-history-row-top time {
    white-space: normal;
  }

  .relay-remote-viewer-head {
    min-height: 28px;
    gap: 3px;
    padding: 1px 5px;
  }

  .relay-remote-viewer-head .relay-remote-stop-button {
    width: 18px;
    min-height: 18px;
    font-size: 6px;
  }

  .relay-remote-toolbar {
    min-height: 30px;
    gap: 4px;
    padding: 2px 5px max(2px, env(safe-area-inset-bottom));
  }

  .relay-remote-toolbar button {
    min-height: 24px;
    font-size: 11px;
  }
}

@media (max-width: 860px) {
  html.client-keyboard-compact .client-topbar {
    min-height: 42px;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 5px 10px;
  }

  html.client-keyboard-compact .client-topbar .brand-mark.small {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    font-size: 13px;
  }

  html.client-keyboard-compact .client-topbar .topbar-brand {
    gap: 8px;
    max-width: calc(100vw - 74px);
  }

  html.client-keyboard-compact .client-topbar .topbar-brand > div:last-child {
    gap: 0;
  }

  html.client-keyboard-compact .client-topbar .topbar-brand strong {
    font-size: 14px;
    line-height: 1.1;
  }

  html.client-keyboard-compact .client-topbar .topbar-brand span {
    display: none;
  }

  html.client-keyboard-compact .client-topbar .ghost {
    min-height: 32px;
    padding: 0 9px;
    border-radius: 7px;
    font-size: 14px;
  }

  html.client-keyboard-compact .client-workspace {
    grid-template-rows: minmax(0, 1fr);
  }

  html.client-keyboard-compact .client-panel {
    display: none;
  }

  html.client-keyboard-compact .conversation-head {
    min-height: 40px;
    padding: 7px 10px;
  }

  html.client-keyboard-compact .conversation-head h2 {
    font-size: 15px;
    line-height: 1.15;
  }

  html.client-keyboard-compact .conversation-head p {
    display: none;
  }

  html.client-keyboard-compact .conversation-badges {
    gap: 4px;
  }

  html.client-keyboard-compact .conversation-badges .pill {
    padding: 2px 7px;
    font-size: 11px;
  }

  html.client-keyboard-compact .messages {
    padding: 8px 10px;
    gap: 6px;
  }

  html.client-keyboard-compact .message {
    max-width: 92%;
    padding: 7px 9px;
    border-radius: 7px;
  }

  html.client-keyboard-compact .message-meta {
    gap: 6px;
    margin-bottom: 3px;
    font-size: 11px;
  }

  html.client-keyboard-compact .message-body {
    line-height: 1.38;
  }

  html.client-keyboard-compact #messages .message-actions {
    display: none;
  }

  html.client-keyboard-compact .client-chat .composer {
    padding: 6px 8px max(6px, env(safe-area-inset-bottom));
  }

  html.client-keyboard-compact .client-chat .composer-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
    align-items: end;
  }

  html.client-keyboard-compact .client-chat .composer-row .textarea {
    grid-column: auto;
    min-height: 42px;
    max-height: 88px;
    padding: 8px 9px;
    line-height: 1.35;
  }

  html.client-keyboard-compact .client-chat .primary,
  html.client-keyboard-compact .client-chat .secondary {
    min-height: 42px;
    padding: 0 10px;
    font-size: 14px;
    white-space: nowrap;
  }

  html.client-keyboard-compact .client-chat .file-name {
    margin-top: 4px;
    font-size: 12px;
  }
}

@media (max-width: 600px) {
  .topup-import-overlay,
  .topup-manage-overlay,
  .quick-reply-overlay {
    place-items: end center;
    padding: max(10px, env(safe-area-inset-top)) 0 0;
  }

  .topup-import-dialog,
  .topup-manage-dialog,
  .quick-reply-dialog {
    width: 100%;
    max-height: calc(var(--app-height, 100dvh) - max(10px, env(safe-area-inset-top)));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
  }

  .quick-reply-bar {
    padding: 4px 8px 2px;
  }

  .quick-reply-scroll {
    scrollbar-width: none;
  }

  .quick-reply-scroll::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
  }

  .quick-reply-add,
  .quick-reply-item {
    width: 84px;
    height: 48px;
    min-width: 84px;
    min-height: 48px;
    max-width: 84px;
    flex-basis: 84px;
  }

  .quick-reply-item.has-image {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 5px;
  }

  .quick-reply-media {
    width: 28px;
    height: 34px;
  }

  .quick-reply-dialog-body {
    padding: 14px;
  }

  .quick-reply-dialog-actions {
    grid-template-columns: auto 1fr auto auto;
    gap: 8px;
    padding-right: 14px;
    padding-left: 14px;
  }

  .topup-import-body {
    padding: 14px;
  }

  .topup-import-textarea {
    min-height: 170px;
    max-height: 38vh;
  }

  .topup-import-actions {
    padding-right: 14px;
    padding-left: 14px;
  }

  .topup-import-actions button {
    flex: 1 1 0;
  }

  .topup-inventory-actions {
    display: flex;
    flex-direction: row;
    gap: 3px;
  }

  .topup-inventory-import,
  .topup-inventory-manage {
    min-height: 29px;
    padding: 0 7px;
    font-size: 11px;
  }

  .topup-manage-toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.72fr);
    padding: 10px;
  }

  .topup-manage-refresh {
    min-height: 40px;
  }

  .topup-manage-row {
    grid-template-columns: 22px minmax(0, 1fr) auto auto;
    gap: 7px;
    padding: 10px;
  }

  .topup-manage-card {
    grid-column: 2 / -1;
  }

  .topup-manage-select { grid-column: 1; grid-row: 1 / 3; }
  .topup-manage-channel { grid-column: 2; text-align: left; }
  .topup-manage-batch { padding: 6px 10px; gap: 5px; }

  .topup-manage-row-actions {
    grid-column: 2 / -1;
    justify-content: stretch;
  }

  .topup-manage-row-actions button {
    flex: 1 1 0;
  }
}
.session-info-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; width: 100%; max-width: 100%; box-sizing: border-box; margin-top: 18px; padding: 16px; border: 2px solid #e4b44d; border-left: 6px solid #c88209; border-radius: 12px; background: #fff9e9; color: #34290e; box-shadow: 0 3px 10px #8a610f12; }
.session-info-label { font-size: 17px; line-height: 1.4; font-weight: 800; color: #805008; }
.session-info-row { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.session-info-row > span:first-child { font-size: 12px; color: #756447; }
.session-identity { display: block; max-width: 100%; overflow-wrap: anywhere; font-size: 19px; line-height: 1.5; font-weight: 700; }
.session-email { font-size: 16px; }
.session-info-hint, .session-confirmed, .session-incomplete, .session-incorrect { font-size: 14px; line-height: 1.5; }
.session-confirmed { color: #12643d; font-weight: 700; }
.session-incomplete, .session-incorrect { color: #a3261a; font-weight: 700; }
.session-info-incorrect { border-color: #de9e99; border-left-color: #b42318; background: #fff2f0; }
.session-feedback-actions { display: flex; flex-wrap: wrap; gap: 9px; width: 100%; padding-top: 2px; }
.session-feedback-actions button { flex: 1 1 180px; min-width: 0; min-height: 44px; padding: 10px 12px; border-radius: 8px; font-size: 14px; line-height: 1.4; font-weight: 700; white-space: normal; cursor: pointer; }
.session-confirm-action { border: 1px solid #146747; background: #146747; color: #fff; }
.session-incorrect-action { border: 1px solid #b42318; background: #b42318; color: #fff; }
.session-feedback-actions button:disabled { opacity: .55; cursor: default; }
/* Compact agent control and independent owner tasks. */
.plus-agent-panel { margin: 0 16px 12px; padding: 10px 0; }
.plus-agent-controls { display: flex; align-items: center; gap: 7px; min-width: 0; }
.plus-agent-controls strong { font-size: 14px; white-space: nowrap; color: #145747; }
#plusAgentStatus { color: var(--muted); font-size: 11px; white-space: nowrap; }
.agent-switch { flex: 0 0 36px; margin-left: auto; width: 36px; height: 22px; padding: 3px; border: 0; border-radius: 20px; background: #bbc6c1; }
.agent-switch span { display: block; width: 16px; height: 16px; border-radius: 50%; background: white; transition: transform .15s; }
.agent-switch[aria-checked="true"] { background: #238b6c; }
.agent-switch[aria-checked="true"] span { transform: translateX(14px); }
#plusAgentHandoffs { display: grid; gap: 8px; max-height: 250px; overflow: auto; margin-top: 10px; font-size: 12px; }
#plusAgentHandoffs:empty { display: none; }
.plus-agent-task { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; border: 1px solid #e6d5b9; border-radius: 8px; background: #fffbf3; cursor: pointer; }
.plus-agent-task:hover, .plus-agent-task:focus-within { border-color: #c69957; background: #fff6e7; }
.plus-agent-handoff { display: grid; min-width: 0; gap: 4px; text-align: left; padding: 8px; background: transparent; border: 0; }
.plus-agent-handoff b { overflow-wrap: anywhere; }
.plus-agent-handoff span { font-size: 12px; color: #735338; overflow-wrap: anywhere; }
.agent-task-done { min-height: 32px; margin: 6px; padding: 6px 9px; border: 1px solid #41856b; border-radius: 6px; background: #fff; color: #23634b; font-size: 11px; }
.agent-task-done:hover { background: #edf7f1; }
.agent-takeover { flex-shrink: 0; min-height: 36px; border: 1px solid #c34c4c; border-radius: 6px; background: #fff0f0; color: #ad3030; font-size: 12px; font-weight: 700; padding: 8px 10px; }
.agent-takeover[data-agent-held="true"] { border-color: #288360; background: #e9f6ee; color: #176b48; }
.agent-takeover:disabled, .agent-task-done:disabled { opacity: .55; cursor: wait; }
.pill.agent-pending { color: #91551c; background: #fff0d6; border: 1px solid #e6c495; }
.client-chat { grid-template-rows: minmax(0,1fr) auto; }
.service-presence-copy { width: 100%; }
.service-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.service-heading .service-name { margin: 0; flex-shrink: 0; }
.service-heading .service-status { display: inline-flex; gap: 7px; align-items: center; font-size: 12px; }
.service-heading .presence-last-seen { margin: 0; font-size: 11px; }
.message-meta .meta-right { margin-left: auto; }
:root .plus-agent-learning { font-size: 12px; line-height: 1.6; margin-top: 8px; }
:root .plus-agent-learning summary { cursor: pointer; color: var(--muted, #64748b); }
:root .plus-agent-learning p { margin: 8px 0; overflow-wrap: anywhere; }
.agent-monitor-toggle { flex-shrink:0; border:1px solid #c6d0d9; border-radius:8px; background:#fff; color:#344552; padding:8px 10px; font-size:12px; cursor:pointer; }
.agent-monitor-toggle[aria-pressed="true"] { background:#edf5ff; border-color:#4589d8; color:#165592; }
.agent-monitor-window { position:fixed; z-index:180; top:max(90px,env(safe-area-inset-top)); right:16px; width:min(350px,calc(100vw - 24px)); max-height:55dvh; display:flex; flex-direction:column; border:1px solid #d9e2ea; border-radius:14px; background:#fff; box-shadow:0 12px 40px #142f4930; color:#243442; font-size:12px; overflow:hidden; }
.agent-monitor-window header { display:flex; justify-content:space-between; align-items:center; padding:12px 14px; border-bottom:1px solid #e8edf2; }
.agent-monitor-window header div { display:flex; flex-direction:column; gap:3px; min-width:0; }
.agent-monitor-window header strong { font-size:14px; }
.agent-monitor-window header span { color:#708090; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.agent-monitor-window header button { flex-shrink:0; width:32px; height:32px; border:1px solid #e0e6ed; background:#f7f9fb; border-radius:8px; color:#516273; font-size:22px; cursor:pointer; }
.agent-monitor-state { margin:0; padding:10px 14px; background:#f1f6fb; line-height:1.5; overflow-wrap:anywhere; }
.agent-monitor-events { list-style:none; padding:0 14px; margin:0; overflow:auto; overscroll-behavior:contain; min-height:85px; }
.agent-monitor-events li { display:flex; gap:10px; padding:11px 0; border-bottom:1px solid #eef1f5; line-height:1.5; }
.agent-monitor-events time { flex-shrink:0; color:#8190a0; font-variant-numeric:tabular-nums; }
.agent-monitor-events li div { min-width:0; }
.agent-monitor-events b { font-weight:500; }
.agent-monitor-events span { display:block; color:#657585; overflow-wrap:anywhere; }
.agent-monitor-empty { color:#8190a0; }
.agent-monitor-window footer { color:#7b8997; background:#fafbfd; border-top:1px solid #e8edf2; padding:8px 14px; font-size:11px; }
@media (max-width:520px) { .admin-head-row { column-gap:6px; } .agent-monitor-toggle,.agent-takeover { padding:7px 8px; font-size:12px; } .agent-monitor-window { right:12px; top:100px; max-height:48dvh; } }

.agent-task-actions { display: flex; gap: 5px; margin: 6px; align-items: center; }
.agent-task-actions .agent-task-done { margin: 0; white-space: nowrap; }
.agent-task-learn { min-height: 32px; padding: 6px 9px; border: 1px solid #5682af; border-radius: 6px; background: #f0f6ff; color: #265c91; font-size: 11px; white-space: nowrap; }
.agent-task-learn:hover { background: #e1edfc; }
.agent-task-learn:disabled { opacity: .55; cursor: wait; }
.agent-task-learning-error { grid-column: 1 / -1; margin: 0 8px 8px; color: #9b4b25; font-size: 11px; }
.agent-learned-cases { max-height: 300px; overflow: auto; margin-top: 8px; }
.agent-learned-cases > div { border-top: 1px solid #e3e8ed; padding: 8px 0; }
.agent-learned-cases blockquote { margin: 6px 0; padding-left: 8px; border-left: 2px solid #94adc5; color: #35526c; }

.agent-conversation-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; width: 100%; }
.agent-conversation-actions > button { min-width: 0; min-height: 36px; margin: 0; padding: 7px 6px; border-radius: 7px; font-size: 12px; line-height: 20px; white-space: nowrap; }
.admin-profile-toggle { border: 1px solid #c6d8cc; background: #f3f8f5; color: var(--accent-2); font-weight: 700; }
.admin-profile-toggle[aria-expanded="true"] { border-color: #72a88a; background: #e5f2e9; }
.admin-head-compact { gap: 6px; padding: 10px 16px; }
.admin-head-compact .admin-head-row { flex-wrap: nowrap; gap: 8px; }
.admin-head-compact .admin-customer-heading { display: flex; flex: 1; align-items: center; gap: 12px; min-width: 0; }
.admin-customer-name { flex: 0 1 auto; min-width: 0; max-width: 45%; }
.admin-head-compact .admin-title h2 { margin: 0; font-size: 18px; line-height: 1.3; }
.admin-head-compact .admin-note-line { display: flex; flex-wrap: nowrap; gap: 4px; max-width: 100%; margin: 3px 0 0; padding: 1px 6px; font-size: 11px; }
.admin-head-compact .admin-note-line span { flex-shrink: 0; }
.admin-head-compact .admin-note-line strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-head-compact .identity { flex: 1; min-width: 0; align-items: center; justify-content: flex-end; gap: 2px 8px; font-size: 11px; line-height: 1.4; }
.admin-head-compact .identity span { overflow-wrap: anywhere; }
.admin-head-compact .admin-more { min-width: 0; margin: 0; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: #f8fbf9; }
.admin-head-compact .admin-more:not([open]) { display: none; }
.admin-head-compact .admin-more[open] { display: grid; gap: 10px; }
.admin-head-compact .admin-more > summary { display: none; }
.admin-head-compact .admin-tools, .admin-head-compact .admin-actions { padding: 0; }
.agent-learning-feedback { margin: 4px 0 0; color: #64748b; font-size: 11px; text-align: right; }
.agent-learning-dialog { width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 20px; border: 1px solid #d8e1e9; border-radius: 14px; box-shadow: 0 18px 70px #172e4940; background: #fff; color: #23374d; }
.agent-learning-dialog::backdrop { background: #15283e66; }
.agent-learning-dialog form { display: grid; gap: 12px; }
.agent-learning-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.agent-learning-dialog h2 { margin: 0; font-size: 18px; }
.agent-learning-dialog p { margin: 0; font-size: 13px; line-height: 1.6; }
.agent-learning-dialog label { font-size: 14px; font-weight: 600; }
.agent-learning-dialog label span, .agent-learning-dialog small { color: #64748b; font-size: 12px; font-weight: 400; }
.agent-learning-dialog textarea { width: 100%; min-height: 110px; resize: vertical; }
.agent-learning-dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.agent-learning-close { width: 32px; height: 32px; padding: 0; background: #f1f5f9; border: 1px solid #dce5ed; border-radius: 7px; color: #496078; font-size: 22px; }
.agent-learning-dialog-error { color: #a64235; }
.agent-operator-entry { width: 100%; margin-top: 10px; min-height: 36px; font-size: 13px; }
.operator-compose .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.agent-operator-entry.active { border-color: #18765f; color: #12624e; background: #e9f3ef; }
.admin-notification-choice { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; color: #54675e; }
.admin-notification-choice .input { flex: 1; width: 0; min-height: 34px; padding: 6px 8px; font-size: 12px; }
.notification-mode-feedback { font-size: 11px; color: #65786e; line-height: 1.5; margin: 6px 0 0; }
.notification-mode-feedback:empty { display: none; }
.admin-layout.operator-mode { grid-template-columns: minmax(0,1fr); }
.operator-mode #adminSidebar { display: none; }
.operator-mode #adminMain { display: flex !important; grid-column: 1; grid-row: 1; min-width: 0; min-height: 0; }
.operator-chat { display: grid; grid-template-rows: auto auto minmax(0,1fr) auto; width: 100%; min-height: 0; max-width: 960px; margin: 0 auto; background: #f8faf9; }
.operator-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid #e3eae5; background: #fff; }
.operator-head>div { flex: 1; text-align: center; }
.operator-head h1 { margin: 0; font-size: 17px; }
.operator-head span { font-size: 11px; color: #75827b; }
.operator-head>.secondary { padding: 8px 10px; font-size: 12px; }
.operator-rules { padding: 10px 18px; font-size: 12px; border-bottom: 1px solid #e3eae5; background: #fff; }
.operator-rules summary { cursor: pointer; color: #52685b; }
#operatorRules { max-height: 190px; overflow: auto; }
#operatorRules p { white-space: pre-wrap; line-height: 1.7; margin: 12px 0; overflow-wrap: anywhere; }
.operator-rule-scope { display: block; font-size: 11px; color: #819086; }
.operator-transcript { overflow: auto; min-height: 0; padding: 22px 24px; overscroll-behavior: contain; }
.operator-turn { display: flex; flex-direction: column; gap: 14px; margin-bottom: 26px; }
.operator-message { max-width: 90%; padding: 14px 16px; border: 1px solid #e0e9e4; border-radius: 14px; background: #fff; align-self: flex-start; overflow-wrap: anywhere; }
.operator-message.owner { align-self: flex-end; background: #edf5f0; border-color: #dceae1; }
.operator-author { display: flex; flex-wrap: wrap; gap: 10px; color: #6a7d70; font-size: 11px; }
.operator-author time { color: #93a097; }
.operator-message p { white-space: pre-wrap; margin: 8px 0 0; line-height: 1.75; font-size: 14px; }
.operator-message.error { border-color: #d9ada3; }
.operator-action { font-size: 12px; margin-top: 10px; color: #587164; }
.operator-action summary { cursor: pointer; }
.operator-action.error { color: #9c5544; }
.operator-action p { font-size: 12px; }
.operator-customer-link { display: inline-block; padding: 5px 8px; margin: 8px 6px 0 0; background: #f2f7f4; color: #23715b; border: 1px solid #d9e7df; border-radius: 6px; font-size: 12px; }
.operator-compose { padding: 12px 18px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid #e3eae5; background: #fff; }
.operator-compose-row { display: flex; align-items: flex-end; gap: 10px; }
.conversation-operator-dialog { width: min(560px, calc(100vw - 24px)); height: min(680px, calc(100dvh - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid #d8e1e9; border-radius: 16px; background: #f8faf9; color: #23374d; box-shadow: 0 18px 70px #172e4940; }
.conversation-operator-dialog[open] { display: flex; flex-direction: column; }
.conversation-operator-dialog::backdrop { background: #15283e66; }
.conversation-operator-dialog > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; background: #fff; flex-shrink: 0; }
.conversation-operator-dialog > header div { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.conversation-operator-dialog > header span { color: #697a72; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-operator-hint { margin: 0; padding: 8px 16px; font-size: 12px; color: #697a72; line-height: 1.5; }
.conversation-operator-log { flex: 1; min-height: 0; overflow: auto; padding: 10px 14px; overscroll-behavior: contain; }
.conversation-operator-log .operator-message { max-width: 96%; }
.conversation-operator-dialog .operator-compose { flex-shrink: 0; padding: 10px 14px; }
.conversation-operator-feedback { margin: 4px 0 0; font-size: 12px; color: #697a72; }
.operator-turn-context { color: #657b6e; font-size: 11px; }
.operator-compose .textarea { flex: 1; min-width: 0; min-height: 58px; max-height: 150px; font-size: 14px; resize: vertical; }
.operator-compose .primary { min-height: 40px; padding: 8px 18px; }
#operatorFeedback { margin: 5px 0 0; font-size: 12px; color: #986241; }
#operatorFeedback:empty { display: none; }
.operator-empty { padding: 28px 0; text-align: center; color: #728277; font-size: 13px; line-height: 1.7; }
.operator-empty strong { color: #324f3d; font-size: 17px; }
.operator-empty .secondary { display: inline-block; margin: 7px; padding: 7px 12px; font-size: 12px; }
.operator-history { display: block; margin: 0 auto 18px; padding: 5px 10px; font-size: 11px; }
@media(max-width:600px) { .operator-head { padding: 10px 12px; } .operator-transcript { padding: 16px 12px; } .operator-message { max-width: 96%; padding: 12px; } .operator-compose { padding-left: 12px; padding-right: 12px; } }
.topup-card-query-dialog { width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 20px; border: 1px solid #d8e1e9; border-radius: 14px; box-shadow: 0 18px 70px #172e4940; background: #fff; color: #23374d; }
.topup-card-query-dialog::backdrop { background: #15283e66; }
.topup-card-query-dialog header, .topup-card-query-dialog footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topup-card-query-dialog h2 { margin: 0; font-size: 18px; }
.topup-card-query-code { font-family: monospace; font-size: 14px; overflow-wrap: anywhere; color: #64748b; }
.topup-card-query-result { min-height: 76px; margin: 18px 0; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.topup-card-query-result strong { font-size: 20px; }
.topup-card-query-result dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; }
.topup-card-query-result dt { color: #64748b; }
.topup-card-query-result dd { margin: 0; }
.topup-card-query-dialog footer { justify-content: flex-end; }
@media (max-width: 860px) {
  .admin-head-compact { padding: 7px 10px; }
  .admin-head-compact .admin-customer-heading { gap: 8px; }
  .admin-head-compact .admin-title h2 { font-size: 16px; }
  .admin-head-compact .identity { gap: 1px 6px; }
}

/* Customer header + collapsible announcement, shared by desktop and mobile. */
.client-app .client-topbar { flex-wrap: nowrap; align-items: flex-start; padding: 12px 18px; gap: 12px; }
.client-app .client-brand { flex: 1; align-items: flex-start; }
.client-app .client-brand-copy { flex: 1; gap: 8px; }
.client-title-row { display: flex; align-items: center; gap: 14px; min-width: 0; }
.client-title-row > strong { flex-shrink: 0; }
.client-app .client-username { flex: 1; min-width: 0; max-width: none; text-align: right; }
.client-presence-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; }
.client-presence-person { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: 12px; }
.client-presence-person b { font-weight: 650; color: var(--text); }
.client-app .client-presence-person span { max-width: none; font-size: 12px; }
.client-app .client-presence-person .presence-last-seen { margin: 0; font-size: 11px; }
.client-presence-person .presence-dot { width: 6px; height: 6px; box-shadow: none; }
.client-app .client-workspace { grid-template-columns: minmax(0, 1120px); grid-template-rows: auto minmax(0, 1fr); gap: 10px; padding: 12px 18px 18px; }
.client-app .client-panel { display: block; padding: 0; border: 0; background: transparent; }
.client-announcement { display: block; width: 100%; max-height: min(28vh, 230px); overflow: auto; text-align: left; padding: 12px 15px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.announcement-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; }
.announcement-heading strong { font-size: 13px; }
.announcement-hint { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 400; }
.client-announcement .presence-message { display: block; margin: 7px 0 0; line-height: 1.55; font-size: 13px; font-weight: 400; }
.client-announcement .presence-message[hidden] { display: none; }
.client-announcement.is-collapsed { width: auto; max-width: 100%; padding: 7px 12px; margin-left: auto; }
.client-announcement.is-collapsed .announcement-hint { display: none; }
.client-announcement:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.client-wechat-bind-dialog { width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 20px; border: 1px solid #d8e1e9; border-radius: 16px; box-shadow: 0 18px 70px #172e4940; background: #fff; color: #23374d; }
.client-wechat-bind-dialog::backdrop { background: #15283e66; }
.client-wechat-bind-dialog form { display: grid; gap: 14px; }
.client-wechat-bind-dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.client-wechat-bind-dialog h2 { margin: 0; font-size: 19px; }
.client-wechat-bind-subtitle { margin: 5px 0 0; color: #64748b; font-size: 12px; }
.client-wechat-bind-close { min-width: 34px; min-height: 34px; padding: 0; font-size: 20px; line-height: 1; }
.client-wechat-bind-account { display: flex; align-items: center; gap: 9px; padding: 11px 12px; border: 1px solid #dfe9e4; border-radius: 10px; background: #f7fbf8; }
.client-wechat-bind-account > span { color: #64736d; font-size: 12px; }
.client-wechat-bind-account > strong { min-width: 0; flex: 1; overflow-wrap: anywhere; color: #1e4939; }
.client-wechat-bind-account > button { flex: 0 0 auto; min-height: 30px; padding: 0 9px; font-size: 12px; }
.client-wechat-bind-description { margin: 0; padding: 10px 12px; border-radius: 9px; background: #f3f7ff; color: #455a70; font-size: 13px; line-height: 1.55; }
.client-wechat-bind-steps { margin: 0; padding-left: 22px; color: #3f5260; font-size: 13px; line-height: 1.7; }
.client-wechat-bind-status { margin: 0; padding: 10px 12px; border-radius: 9px; background: #f5f7fa; color: #566778; font-size: 13px; }
.client-wechat-bind-status.is-success { background: #eef9f1; color: #2d7651; }
.client-wechat-bind-note { margin: 0; color: #7a8791; font-size: 12px; line-height: 1.55; }
.client-wechat-bind-dialog footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding-top: 2px; }
@keyframes client-dialog-pop-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes client-dialog-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  button.is-clicked,
  .published-announcements-dialog[open],
  .call-dialog[open],
  .client-wechat-bind-dialog[open],
  .published-announcements-dialog::backdrop,
  .call-dialog::backdrop,
  .client-wechat-bind-dialog::backdrop { animation: none; }
}
@media (max-width: 860px) {
  .client-app .client-topbar { padding: 9px 12px; gap: 8px; }
  .client-app .client-brand { gap: 9px; }
  .client-app .client-title-row { gap: 8px; }
  .client-app .client-brand-copy { gap: 5px; }
  .client-app .client-username { font-size: 11px; }
  .client-app .client-workspace { padding: 7px 0 0; gap: 7px; }
  .client-account-actions { gap: 5px; }
  .client-account-actions .client-wechat-bind-button,
  .client-account-actions > #logoutBtn { min-height: 30px; padding: 0 9px; font-size: 11px; }
  .client-wechat-bound { min-height: 30px; padding: 0 8px; font-size: 11px; }
  .client-app .client-panel { padding: 0 10px; }
  .client-presence-row { gap: 5px 12px; }
  .client-app .client-presence-person span { font-size: 11px; }
  .client-announcement { padding: 9px 11px; }
}
.password-field { position: relative; display: flex; align-items: center; width: 100%; }
.password-field > .input { width: 100%; padding-right: 48px; }
.password-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); display: grid; place-items: center; width: 38px; height: 38px; padding: 8px; background: transparent; border: 0; border-radius: 8px; color: #60716a; cursor: pointer; }
.password-toggle:hover { background: #edf3ef; }
.password-toggle:focus-visible { outline: 2px solid #347b59; outline-offset: 1px; }
.password-toggle svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.password-toggle[aria-pressed="false"] .eye-slash { display: none; }

.voucher-message-card { width: min(350px, 100%); box-sizing: border-box; border: 1px solid #dce5e2; border-radius: 13px; background: #f8fbfa; padding: 14px; color: #243b32; }
.voucher-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; font-size: 11px; letter-spacing: .06em; font-weight: 650; color: #648074; }
.voucher-card-status { letter-spacing: 0; font-weight: 500; color: #4a7360; }
.voucher-card-code-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 12px; }
.voucher-card-code-row code { font-size: 14px; font-weight: 600; letter-spacing: .015em; overflow-wrap: anywhere; min-width: 0; }
.voucher-copy { flex-shrink: 0; min-width: 52px; border: 1px solid #bfd3c8; background: #fff; color: #28533e; border-radius: 7px; padding: 6px 9px; font-size: 12px; cursor: pointer; }
.voucher-copy:hover:not(:disabled) { background: #edf5f0; }
.voucher-copy:disabled { border-color: #e0e3e4; background: #ecefef; color: #92999c; cursor: default; }
.voucher-redeem-link { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: #527969; text-decoration: none; }
.voucher-message-card.is-used { background: #f7f8f8; border-color: #e3e6e5; color: #7c8581; }
.is-used .voucher-card-heading, .is-used .voucher-card-status, .is-used .voucher-redeem-link { color: #87928c; }
.voucher-send-button { touch-action: manipulation; user-select: none; -webkit-user-select: none; white-space: nowrap; background: #fff1c9; color: #71551b; }
.voucher-send-button:hover:not(:disabled) { background: #f9e8b3; }
.voucher-send-button:active:not(:disabled) { background: #f2dda0; }
.voucher-quantity-dialog { border: 1px solid #dce4df; border-radius: 16px; padding: 24px; width: min(360px, calc(100vw - 48px)); box-sizing: border-box; color: #243b32; }
.voucher-quantity-dialog::backdrop { background: #142a224d; }
.voucher-dialog-title { font-size: 18px; font-weight: 650; }
.voucher-quantity-dialog p { font-size: 13px; line-height: 1.7; color: #76847c; margin: 10px 0 20px; }
.voucher-quantity-dialog label { display: grid; gap: 8px; font-size: 13px; }
.voucher-dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.topup-manage-status.sold { color: #946b30; background: #fff6e7; }
@media (max-width: 540px) { .admin-composer-row .voucher-send-button { padding-left: 9px; padding-right: 9px; } .voucher-card-code-row code { font-size: 12px; } }
