: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;
}

.admin-profile-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.admin-profile-badge {
  position: absolute;
  top: -6px;
  right: -2px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  border-radius: 999px;
  border: 1px solid #fff;
  box-shadow: 0 1px 3px rgba(15, 35, 29, 0.14);
  font-size: 10px;
  line-height: 1.25;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  background: #e1f3ec;
  color: #13594d;
}

.admin-profile-badge[hidden] {
  display: none;
}

.admin-profile-badge.is-warn {
  background: #fde8e8;
  color: #b42318;
}

.admin-customer-profile-dialog {
  width: min(580px, calc(100vw - 20px));
  max-height: min(88dvh, 820px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(15, 35, 29, 0.22);
  background: #fff;
  color: var(--text);
}

.admin-customer-profile-dialog[open] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-customer-profile-dialog::backdrop {
  background: rgba(15, 28, 24, 0.44);
}

.profile-dialog-shell {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(88dvh, 820px);
  overflow: hidden;
}

.profile-dialog-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.profile-dialog-head h2 {
  margin: 0;
  font-size: 17px;
}

.profile-dialog-sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.admin-customer-profile-dialog .profile-dialog-close {
  flex: 0 0 auto;
  min-height: 32px;
  font-size: 20px;
  line-height: 1;
  padding: 4px 10px;
  white-space: nowrap;
}

.profile-dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 18px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 14px;
}

.profile-alert-banner {
  padding: 9px 12px;
  border-radius: 8px;
  background: #fff8eb;
  border: 1px solid #f5d393;
  color: #8a4b08;
  font-size: 13px;
}

.profile-section {
  border: 1px solid #e2ece8;
  border-radius: 10px;
  padding: 12px 14px;
  background: #fbfdfc;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  gap: 10px;
}

.profile-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-section-head h3 {
  margin: 0;
  font-size: 14px;
  color: #1f352e;
}

.profile-cred-list,
.profile-candidate-list,
.profile-merge-search-results {
  display: grid;
  gap: 8px;
}

.profile-cred-chip,
.profile-candidate-row,
.profile-search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #dce8e3;
}

.profile-cred-chip.is-locked {
  border-color: #f3b4b4;
  background: #fffafa;
}

.profile-cred-info,
.profile-candidate-main,
.profile-search-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.profile-cred-info strong,
.profile-merge-chip strong {
  overflow-wrap: anywhere;
}

.profile-cred-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.profile-role-tag,
.profile-reason-tag,
.profile-warn-tag,
.profile-danger-tag {
  font-size: 11.5px;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
}

.profile-role-tag {
  background: #e8f3ef;
  color: #13594d;
}

.profile-reason-tag {
  background: #e6f0ff;
  color: #1d4ed8;
}

.profile-warn-tag {
  background: #fef3c7;
  color: #92400e;
}

.profile-danger-tag {
  background: #fee2e2;
  color: #b91c1c;
}

.profile-candidate-jump {
  border: 0;
  padding: 0;
  background: none;
  color: #13594d;
  font-weight: 700;
  font-size: 14px;
  text-decoration: underline;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.profile-candidate-time {
  font-size: 12px;
  color: var(--muted);
}

.profile-candidate-Pick {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.profile-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 560px) {
  .profile-form-grid {
    grid-template-columns: 1fr;
  }
}

.profile-inline-actions,
.profile-security-actions,
.profile-danger-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-merge-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.profile-merge-primary {
  font-size: 13px;
  font-weight: 600;
  color: #30423b;
  min-width: 0;
}

.profile-merge-primary:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.profile-merge-primary select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.profile-merge-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e8f4f0;
  border: 1px solid #c3dfd6;
  font-size: 12.5px;
}

.admin-customer-profile-dialog .profile-merge-chip button {
  min-height: 20px;
  padding: 0 4px;
  line-height: 1.1;
}

.profile-merge-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-merge-search-bar .input {
  flex: 1 1 auto;
  min-width: 0;
}

.profile-merge-search-bar button {
  flex: 0 0 auto;
  min-width: 64px;
  white-space: nowrap;
}

.admin-customer-profile-dialog .profile-mini-btn {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.profile-empty-inline {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.admin-customer-profile-dialog .primary.profile-unlock-highlight {
  background: #b42318;
  border-color: #b42318;
  color: #fff;
}

.admin-customer-profile-dialog .primary.profile-unlock-highlight:hover:not(:disabled) {
  background: #912018;
  border-color: #912018;
}

.profile-danger-zone {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed #d9e4df;
}

.profile-danger-zone summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.client-pwd-verify-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.client-pwd-verify-row .input {
  flex: 1 1 auto;
  min-width: 0;
}

.client-pwd-verify-row button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.client-pwd-show-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.client-pwd-verified-tip,
.client-pwd-success {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #ecfdf3;
  color: #067647;
  font-size: 13px;
}

.client-pwd-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.client-pwd-footer-right {
  display: flex;
  gap: 8px;
}

.forgot-confirm-box {
  padding: 14px;
  border-radius: 10px;
  background: #fff9eb;
  border: 1px solid #f4d28c;
  display: grid;
  gap: 12px;
}

.forgot-confirm-text {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  color: #5c3b09;
}

.forgot-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.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);
}

.primary:disabled,
.secondary:disabled,
.danger:disabled,
.ghost:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.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 .client-change-password-button,
.client-account-actions > #logoutBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1;
}

.client-wechat-bound {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  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-submit-action {
  border-color: #16794f;
  background: #16794f;
  color: #fff;
}

.message-action.topup-submit-action:hover:not(:disabled) {
  background: #126441;
}

.message-action:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.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;
}

.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 {
  position: relative;
  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[data-suggestion-dismiss]:not(:disabled):hover { background: #fdeeee; color: #b53d3d; border-color: #eababa; }
.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; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@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-thumb {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  object-fit: cover;
}

.selected-file-meta {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  gap: 2px;
}

.selected-file-kind {
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--accent-2);
}

.selected-file-name {
  flex: 1 1 auto;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-paste-hint {
  margin-top: 6px;
  padding: 6px 10px;
  border: 1px solid #f0d7a7;
  border-radius: 7px;
  background: #fff7e6;
  color: #7c5412;
  font-size: 12px;
  line-height: 1.4;
}

.composer-paste-hint[hidden] {
  display: none;
}

.chat.is-drop-active,
.admin-main.is-drop-active,
.composer.is-drop-active {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
  background-color: #f3faf6;
}

.chat.is-drop-active .composer,
.admin-main.is-drop-active .composer {
  background: #eef8f2;
  border-top-color: var(--accent);
}

.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: minmax(72px, 1.1fr) minmax(90px, 1.6fr) repeat(3, minmax(38px, .65fr));
  align-items: center;
  gap: 8px;
  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-tiers { min-width: 0; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; 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,
.topup-inventory-channel-add {
  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(auto-fit, minmax(136px, 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: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.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(180px, 1fr) minmax(180px, 230px) 130px auto;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.topup-manage-toolbar .select {
  font-size: 14px;
  padding: 8px 10px;
}

.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(200px, 1fr) minmax(52px, auto) minmax(56px, auto) 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); }

/* 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-flex; align-items: center; justify-content: center; flex: 0 0 auto; gap: 4px; min-width: 62px; height: 34px; min-height: 34px; margin: 0; padding: 0 9px; 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; }
.published-announcements-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],
.client-wechat-bind-dialog[open] { animation: client-dialog-pop-in 180ms ease-out both; }
.published-announcements-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 { display: grid; gap: 0; max-height: inherit; }
.published-announcements-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; }

@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 { min-width: 56px; height: 34px; min-height: 34px; padding: 0 7px; }
  .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;
  flex-wrap: wrap;
  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;
}

.pill.client-channel {
  border: 1px solid transparent;
  font-weight: 750;
}

.pill.client-channel.is-miniprogram {
  background: #e8f5ee;
  color: #166534;
  border-color: #c3e2cf;
}

.pill.client-channel.is-web {
  background: #eef4fb;
  color: #26517c;
  border-color: #c9dced;
}

.pill.client-channel.is-recent {
  opacity: 0.85;
}

.admin-client-channel-wrap {
  display: inline-flex;
  align-items: center;
}

.admin-client-channel-wrap[hidden] {
  display: none;
}

.admin-head-compact .identity .pill.client-channel {
  padding: 1px 6px;
  font-size: 11px;
  line-height: 1.35;
}

.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;
  }

  .composer {
    display: flex;
    flex-direction: column;
  }

  .composer .file-name {
    order: -1;
    margin: 0 0 8px;
  }

  .composer .file-name:empty {
    display: none;
    margin: 0;
  }

  .composer .composer-paste-hint {
    order: -1;
    margin: 0 0 8px;
  }

  .selected-file-thumb {
    width: 40px;
    height: 40px;
  }

  .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: 0 0 5px;
    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-channel-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .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,
  .topup-inventory-channel-manage,
  .topup-inventory-channel-add {
    min-height: 29px;
    padding: 0 7px;
    font-size: 11px;
  }

  .topup-inventory-columns,
  .topup-inventory-channel-row {
    grid-template-columns: minmax(58px, .9fr) minmax(72px, 1.25fr) repeat(3, minmax(30px, .55fr));
    gap: 4px;
  }

  .topup-inventory-columns { font-size: 9px; }
  .topup-inventory-channel-tiers { font-size: 10px; }

  .topup-manage-toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    padding: 10px;
  }

  #topupManageSearch {
    grid-column: 1 / -1;
  }

  .topup-manage-refresh {
    grid-column: 1 / -1;
    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; }

/* Top-up inventory and channel flows use separate visual systems. Fei2 keeps
   the compact in-site inventory card while custom channels use a strict five-
   column data grid. */
.topup-inventory {
  padding: 14px;
  border: 1px solid #cfe3dc;
  border-radius: 16px;
  background: #f8fcfa;
  color: #173f34;
  box-shadow: 0 8px 24px rgba(25, 78, 60, 0.06);
}

.topup-inventory-head {
  display: grid;
  gap: 12px;
  align-items: stretch;
}

.topup-inventory-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.topup-inventory-heading strong {
  font-size: 16px;
  letter-spacing: .01em;
}

.topup-inventory-heading span,
.topup-inventory-section-head > span {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.topup-inventory-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.topup-inventory-actions button {
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 12px;
}

.topup-inventory-actions .topup-inventory-channel-manage {
  grid-column: 1 / -1;
  border-color: #b8d9cd;
  background: #e6f5ee;
  color: #175d4c;
}

.topup-inventory-channels {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.topup-inventory-fei2,
.topup-inventory-custom {
  min-width: 0;
  padding: 12px;
  border: 1px solid #d7e8df;
  border-radius: 12px;
  background: #fff;
}

.topup-inventory-fei2.low,
.topup-inventory-fei2.empty {
  border-color: #e3d0a6;
  background: #fffaf0;
}

.topup-inventory-fei2.empty {
  border-color: #edc8c8;
  background: #fff6f6;
}

.topup-inventory-fei2-head,
.topup-inventory-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.topup-inventory-fei2-head > div,
.topup-inventory-section-head > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.topup-inventory-fei2-head strong,
.topup-inventory-section-head strong {
  font-size: 15px;
  line-height: 1.35;
}

.topup-inventory-kicker {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  letter-spacing: .04em;
}

.topup-inventory-fei2-note,
.topup-channel-manage-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef7f2;
  color: #2a765e;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.topup-inventory-fei2-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.topup-inventory-fei2-stats .topup-inventory-stat {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  padding: 9px 6px;
  border-radius: 10px;
  background: #f4faf7;
}

.topup-inventory-fei2-stats .topup-inventory-stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.topup-inventory-fei2-stats .topup-inventory-stat strong {
  font-size: 20px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.topup-inventory-custom {
  display: grid;
  gap: 10px;
}

.topup-inventory-custom-empty {
  padding-bottom: 14px;
}

.topup-inventory-custom-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.topup-inventory-columns,
.topup-inventory-custom-row {
  display: grid;
  grid-template-columns: minmax(70px, 1.25fr) minmax(72px, 1.4fr) repeat(3, minmax(40px, .72fr));
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.topup-inventory-columns {
  padding: 0 0 7px;
  border-bottom: 1px solid #e2eee8;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
  text-align: center;
  white-space: nowrap;
}

.topup-inventory-columns > :first-child,
.topup-inventory-columns > :nth-child(2) {
  text-align: left;
}

.topup-inventory-custom-row {
  min-height: 38px;
  padding: 5px 0;
  border-bottom: 1px solid #eef4f0;
}

.topup-inventory-custom-row:last-child {
  border-bottom: 0;
}

.topup-inventory-custom-row.low {
  color: #684a11;
}

.topup-inventory-custom-row.empty {
  color: var(--danger);
}

.topup-inventory-channel-name,
.topup-inventory-channel-tiers {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topup-inventory-channel-name {
  font-size: 12px;
  font-weight: 750;
}

.topup-inventory-channel-tiers {
  color: var(--muted);
  font-size: 11px;
}

.topup-inventory-custom-row .topup-inventory-stat {
  display: grid;
  justify-items: center;
  min-width: 0;
  text-align: center;
}

.topup-inventory-custom-row .topup-inventory-stat span {
  display: none;
}

.topup-inventory-custom-row .topup-inventory-stat strong {
  font-size: 14px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.topup-channel-dialog {
  width: min(560px, calc(100% - 32px));
  max-width: 560px;
  max-height: min(760px, calc(100dvh - 32px));
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #d5e4dd;
  border-radius: 20px;
  background: #fbfdfc;
  color: var(--text);
  box-shadow: 0 28px 90px rgba(10, 24, 18, 0.28);
}

.topup-channel-dialog::backdrop {
  background: rgba(12, 22, 18, 0.52);
  backdrop-filter: blur(3px);
}

.topup-channel-dialog-form,
.topup-channel-manage-form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  max-height: inherit;
}

.topup-channel-dialog-head,
.topup-channel-manage-form > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid #e2ece7;
  background: #fff;
}

.topup-channel-dialog-head > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.topup-channel-dialog-kicker {
  color: #2b7c63;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
}

.topup-channel-dialog-head h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.35;
}

.topup-channel-dialog-note {
  max-width: 44ch;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.topup-channel-dialog-close {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  background: #f1f6f3;
  color: #31584d;
  font-size: 24px;
  line-height: 1;
}

.topup-channel-dialog-body,
.topup-channel-manage-body {
  min-height: 0;
  overflow: auto;
  padding: 20px 22px;
}

.topup-channel-dialog-body {
  display: grid;
  align-content: start;
  gap: 16px;
}

.topup-channel-dialog-result {
  color: var(--danger);
  font-size: 13px;
}

.topup-channel-dialog-result:empty {
  display: none;
}

.topup-channel-dialog footer,
.topup-channel-manage-form > footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid #e2ece7;
  background: #fff;
}

.topup-channel-dialog footer button,
.topup-channel-manage-form > footer button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 10px;
}

.topup-channel-choice-list {
  display: grid;
  gap: 10px;
  max-height: none;
  overflow: auto;
  padding: 18px 22px 22px;
}

.topup-channel-choice {
  display: grid;
  gap: 6px;
  width: 100%;
  min-height: 78px;
  padding: 14px 16px;
  border: 1px solid #d7e6df;
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  text-align: left;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.topup-channel-choice:hover,
.topup-channel-choice:focus-visible {
  border-color: #8dc4ae;
  background: #f4fbf7;
  transform: translateY(-1px);
}


.topup-channel-choice-main strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}


.topup-channel-choice-tiers {
  color: #2b765e;
  font-size: 12px;
  line-height: 1.45;
}

.topup-channel-choice small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topup-channel-manage-dialog {
  width: min(660px, calc(100% - 32px));
  max-width: 660px;
}

.topup-channel-manage-body {
  display: grid;
  align-content: start;
  gap: 12px;
}

.topup-channel-manage-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 12px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid #d7e6df;
  border-radius: 14px;
  background: #fff;
}

.topup-channel-manage-copy {
  display: grid;
  gap: 5px;
  width: 100%;
  min-width: 0;
}

.topup-channel-manage-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-width: 0;
}

.topup-channel-manage-status {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef6f2;
  color: #2b6a54;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.topup-channel-manage-copy strong {
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
  font-size: 16px;
}

.topup-channel-manage-copy > span {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: normal;
}

.topup-channel-manage-copy small {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: normal;
}

.topup-channel-manage-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #edf4f0;
}

.topup-channel-manage-actions button {
  min-height: 35px;
  height: 35px;
  min-width: 60px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
}

.topup-channel-manage-empty {
  padding: 28px 14px;
  border: 1px dashed #c5ddd2;
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

.topup-channel-archived-section {
  margin-top: 12px;
  padding: 12px 0 8px;
  border-top: 1px dashed var(--border);
}

.topup-channel-archived-summary {
  display: flex;
  align-items: center;
  min-height: 36px;
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 4px;
  user-select: none;
}

.topup-channel-archived-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-bottom: 6px;
}

.topup-channel-manage-item.is-archived {
  opacity: 0.82;
  background: color-mix(in srgb, var(--surface-2, var(--surface)) 60%, transparent);
}

@media (max-width: 600px) {
  .topup-inventory {
    padding: 12px;
    border-radius: 14px;
  }

  .topup-inventory-heading span {
    display: none;
  }

  .topup-inventory-actions button {
    min-height: 44px;
  }

  .topup-inventory-columns,
  .topup-inventory-custom-row {
    grid-template-columns: minmax(68px, 1.2fr) minmax(70px, 1.3fr) repeat(3, minmax(38px, .72fr));
    gap: 5px;
  }

  .topup-inventory-columns {
    font-size: 9px;
  }

  .topup-inventory-channel-name {
    font-size: 11px;
  }

  .topup-inventory-channel-tiers {
    font-size: 10px;
  }

  .topup-inventory-custom-row .topup-inventory-stat strong {
    font-size: 13px;
  }

  .topup-channel-dialog,
  .topup-channel-manage-dialog {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    max-width: none;
    max-height: min(88dvh, 760px);
    margin: 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -18px 60px rgba(10, 24, 18, .24);
  }

  .topup-channel-dialog-head,
  .topup-channel-manage-form > header {
    padding: 18px 16px 14px;
  }

  .topup-channel-dialog-head h2 {
    font-size: 19px;
  }

  .topup-channel-dialog-body,
  .topup-channel-manage-body {
    padding: 16px 16px 26px;
    overscroll-behavior: contain;
  }

  .topup-channel-choice-list {
    padding: 14px 16px 16px;
  }

  .topup-channel-choice {
    min-height: 82px;
    padding: 14px;
  }

  .topup-channel-dialog footer,
  .topup-channel-manage-form > footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  }

  .topup-channel-dialog footer button,
  .topup-channel-manage-form > footer button {
    width: 100%;
  }

  .topup-channel-choice-footer {
    grid-template-columns: 1fr !important;
  }

  .topup-channel-manage-item {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
  }

  .topup-channel-manage-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topup-channel-manage-actions button {
    width: 100%;
    height: auto;
    min-height: 40px;
    font-size: 13px;
    white-space: nowrap;
  }

  .topup-channel-manage-actions button:only-child {
    grid-column: 1 / -1;
  }
}
.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; grid-template-columns: minmax(0, 1fr); gap: 8px; max-height: 250px; overflow: auto; overflow-x: hidden; 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; width: 100%; grid-template-columns: minmax(0, 1fr); 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; }
#plusAgentHandoffs .agent-task-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; color: inherit; }
#plusAgentHandoffs .agent-task-count { padding: 1px 6px; border-radius: 999px; background: #f4e5ca; color: #714b24; font-size: 11px; font-style: normal; font-weight: 600; white-space: nowrap; }
#plusAgentHandoffs .agent-task-sublist { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 2px; padding-inline-start: 7px; border-inline-start: 2px solid #e6d5b9; }
#plusAgentHandoffs .agent-task-sublist > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #806950; font-size: 11px; }
#plusAgentHandoffs .agent-task-sublist > span.agent-task-more { color: #9a7d5e; }
.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; }
.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-conversation-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; width: 100%; padding-top: 2px; }
.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 { position: relative; justify-content: center; overflow: visible; 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-close { flex-shrink: 0; width: 32px; height: 32px; padding: 0; background: #f1f5f9; border: 1px solid #dce5ed; border-radius: 7px; color: #496078; font-size: 22px; }
.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 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; min-width: 0; 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; white-space: nowrap; flex-shrink: 0; }
.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; align-items: center; gap: 8px; flex-wrap: wrap; color: #6a7d70; font-size: 11px; }
.operator-author time { color: #93a097; }
.operator-stop-btn { margin-left: auto; min-height: 24px; padding: 2px 10px; font-size: 12px; color: #b53d3d; border: 1px solid #eababa; border-radius: 6px; background: #fff5f5; white-space: nowrap; cursor: pointer; }
.operator-stop-btn:hover:not(:disabled) { background: #fdeaea; border-color: #df9c9c; }
.operator-stop-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.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-message.cancelled { border-color: #e5d8c8; background: #fcf9f5; }
.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 strong { white-space: nowrap; flex-shrink: 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; }
.client-register-confirm-copy { margin: 0; font-size: 13.5px; line-height: 1.65; color: #3d546a; }
.client-register-confirm-error { margin: 0; }
.client-register-confirm-error[hidden] { display: none; }
.client-wechat-bind-dialog.client-password-dialog footer.client-pwd-footer,
.client-password-dialog footer.client-pwd-footer { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.client-pwd-footer button { white-space: nowrap; }
@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],
  .client-wechat-bind-dialog[open],
  .published-announcements-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 .client-change-password-button,
  .client-account-actions > #logoutBtn { min-height: 30px; height: 30px; padding: 0 9px; border-radius: 8px; font-size: 11px; white-space: nowrap; }
  .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-card-instructions { margin-top: 8px; padding-top: 8px; border-top: 1px dashed #d5e0db; font-size: 12px; line-height: 1.5; color: #475f55; white-space: pre-wrap; word-break: break-word; }
.voucher-card-instructions strong { font-weight: 600; color: #365246; }
.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, .is-used .voucher-card-instructions { 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(440px, calc(100vw - 32px)); max-height: 90dvh; overflow-y: auto; 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: 8px 0 14px; }
.voucher-quantity-dialog label { display: grid; gap: 8px; font-size: 13px; }
.voucher-send-section { display: grid; gap: 8px; margin-bottom: 14px; }
.voucher-send-label { font-size: 13px; font-weight: 600; color: #2c4a3e; }
.voucher-channel-options { display: grid; gap: 8px; max-height: 180px; overflow-y: auto; }
.voucher-channel-option { display: flex !important; align-items: center; justify-content: space-between; gap: 10px !important; padding: 9px 11px; border: 1px solid #d5e0db; border-radius: 10px; background: #f8fbfa; cursor: pointer; }
.voucher-channel-option.is-selected { border-color: #2c7a5f; background: #eef7f3; }
.voucher-channel-option.is-empty { opacity: 0.68; }
.voucher-channel-option input { margin: 0; accent-color: #258669; }
.voucher-channel-option-main { display: flex; flex: 1 1 auto; align-items: baseline; gap: 6px; min-width: 0; }
.voucher-channel-option-main small { color: #6c7c75; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voucher-channel-stock { flex-shrink: 0; font-size: 12px; font-weight: 600; color: #2c7a5f; font-variant-numeric: tabular-nums; }
.voucher-qty-control { display: flex; align-items: center; gap: 8px; }
.voucher-qty-control .input { text-align: center; flex: 1 1 auto; min-width: 0; }
.voucher-qty-step { min-width: 40px; min-height: 38px; font-size: 16px; font-weight: 700; }
.voucher-send-preview { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid #dce5e2; border-radius: 10px; background: #f7faf9; font-size: 12px; line-height: 1.5; color: #455b52; }
.voucher-preview-row { display: grid; gap: 2px; word-break: break-word; }
.voucher-preview-row > span:first-child { font-weight: 600; color: #2f4d41; }
.voucher-preview-row code { font-size: 11px; color: #245f4a; word-break: break-all; }
.voucher-send-error { margin-top: 8px; min-height: 18px; font-size: 12px; color: #b54032; }
.voucher-dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.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; } }

/* weak-network-20261104 start */
.image-preview { position: relative; display: flex; align-items: center; justify-content: center; }
.image-preview img { width: auto; height: auto; max-width: 100%; max-height: 100%; }
.image-preview-hint { position: absolute; right: 4px; bottom: 4px; padding: 2px 5px; color: #fff; background: rgba(0, 0, 0, .58); border-radius: 3px; font-size: 10px; }
/* weak-network-20261104 end */

/* The desktop admin shell keeps the customer list in a narrow rail. Keep the
   five custom-channel columns inside that rail instead of allowing the final
   stat to be clipped by the panel edge. */
.topup-inventory-columns > *,
.topup-inventory-custom-row > * {
  min-width: 0;
}

@media (min-width: 601px) {
  .topup-inventory-columns,
  .topup-inventory-custom-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) repeat(3, 32px);
    gap: 4px;
  }

  .topup-inventory-columns {
    font-size: 9px;
  }

  .topup-inventory-channel-name {
    font-size: 11px;
  }

  .topup-inventory-channel-tiers {
    font-size: 10px;
  }

  .topup-inventory-custom-row .topup-inventory-stat strong {
    font-size: 13px;
  }
}

/* Keep the customer list visible by making inventory a compact summary first.
   Detailed cards and management actions only appear after the user expands it. */
.topup-inventory-head {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.topup-inventory-toggle {
  min-height: 36px;
  padding: 0 12px;
  border-color: #b8d9cd;
  background: #e6f5ee;
  color: #175d4c;
  white-space: nowrap;
}

.topup-inventory-summary {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.topup-inventory-summary-fei2,
.topup-inventory-summary-custom {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #d7e8df;
  border-radius: 11px;
  background: #fff;
}

.topup-inventory-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.topup-inventory-summary-head > div {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.topup-inventory-summary-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.topup-inventory-summary-head > span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.topup-inventory-summary-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin-top: 8px;
}

.topup-inventory-summary-stats .topup-inventory-stat {
  display: grid;
  justify-items: center;
  gap: 3px;
  min-width: 0;
  padding: 5px 2px;
  border-radius: 8px;
  background: #f4faf7;
}

.topup-inventory-summary-stats .topup-inventory-stat span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topup-inventory-summary-stats .topup-inventory-stat strong {
  font-size: 15px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.topup-inventory-summary-custom {
  display: grid;
  gap: 6px;
}

.topup-inventory-summary-custom-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-top: 5px;
  border-top: 1px solid #eef4f0;
}

.topup-inventory-summary-custom-row > div {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.topup-inventory-summary-custom-row strong:first-child,
.topup-inventory-summary-custom-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topup-inventory-summary-custom-row strong:first-child {
  font-size: 11px;
}

.topup-inventory-summary-custom-row span {
  color: var(--muted);
  font-size: 10px;
}

.topup-inventory-summary-available {
  color: #176148;
  font-size: 14px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.topup-inventory-summary-custom-row.low .topup-inventory-summary-available {
  color: #8a5a00;
}

.topup-inventory-summary-custom-row.empty .topup-inventory-summary-available {
  color: var(--danger);
}

.topup-inventory-summary-empty {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.topup-inventory-details[hidden] {
  display: none;
}

.topup-inventory-details {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #dfece5;
}

.topup-inventory-detail-head {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.topup-inventory-detail-head > strong {
  font-size: 13px;
}

.topup-inventory-detail-head > span {
  color: var(--muted);
  font-size: 10px;
}

.topup-inventory-detail-head .topup-inventory-actions {
  margin-top: 2px;
}

@media (max-width: 600px) {
  .topup-inventory-summary-stats {
    gap: 3px;
  }

  .topup-inventory-summary-stats .topup-inventory-stat {
    padding-left: 1px;
    padding-right: 1px;
  }

  .topup-inventory-summary-stats .topup-inventory-stat span {
    font-size: 8px;
  }

  .topup-inventory-summary-stats .topup-inventory-stat strong {
    font-size: 14px;
  }

  .topup-inventory-toggle {
    min-height: 40px;
  }
}

/* Inventory now lives in a dedicated right rail. Keep the left trigger short
   enough that the customer list remains the primary surface on mobile. */
body.topup-inventory-rail-open {
  overflow: hidden;
}

.customer-sidebar .topup-inventory {
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.customer-sidebar .topup-inventory-compact-trigger {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  width: 100%;
  min-width: 0;
  min-height: 32px;
  gap: 6px;
  padding: 4px 2px 4px 0;
  border: 0;
  border-top: 1px solid #e3ece7;
  border-bottom: 1px solid #e3ece7;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.customer-sidebar .topup-inventory-compact-trigger:hover,
.customer-sidebar .topup-inventory-compact-trigger:focus-visible {
  background: #f1f8f4;
}

.topup-inventory-compact-summary {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
}

.topup-inventory-compact-fei2,
.topup-inventory-compact-custom {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}

.topup-inventory-compact-fei2 strong,
.topup-inventory-compact-custom strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 10px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topup-inventory-compact-fei2 span,
.topup-inventory-compact-custom span,
.topup-inventory-compact-custom em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topup-inventory-compact-custom {
  max-width: 138px;
  padding-left: 8px;
  border-left: 1px solid #dfe9e4;
}

.topup-inventory-compact-custom em {
  color: #176148;
  font-size: 10px;
  font-style: normal;
  font-variant-numeric: tabular-nums;
}

.topup-inventory-compact-custom.low em { color: #8a5a00; }
.topup-inventory-compact-custom.empty em { color: var(--danger); }

.topup-inventory-compact-empty {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topup-inventory-compact-title {
  grid-column: 2;
  justify-self: end;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.topup-inventory-compact-trigger.error .topup-inventory-compact-summary {
  color: var(--danger);
}

.topup-inventory-rail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1298;
  background: rgba(16, 32, 25, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.topup-inventory-rail-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.topup-inventory-rail {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 1299;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(440px, 92vw);
  min-width: 0;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  border-left: 1px solid #cfe1d8;
  background: var(--surface);
  box-shadow: -16px 0 42px rgba(18, 43, 33, 0.16);
  transform: translateX(102%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 200ms ease;
  contain: layout paint;
}

.topup-inventory-rail.is-open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.topup-inventory-rail-head {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: max(8px, env(safe-area-inset-top)) 16px 8px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, var(--accent) 6%);
}

.topup-inventory-rail-head strong {
  color: var(--accent-2);
  font-size: 17px;
}

.topup-inventory-rail-head button {
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.topup-inventory-rail-body {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px 14px max(14px, env(safe-area-inset-bottom));
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.topup-inventory-rail-intro {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.topup-inventory-rail-list {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.topup-inventory-rail-channel {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  min-width: 0;
  min-height: 54px;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid #e0ebe5;
  border-radius: 11px;
  background: #fbfdfc;
  cursor: pointer;
  /* touch-action:none lets the browser pass all touch events to JS so our
     long-press drag can fire without being preempted by the parent pan-y */
  touch-action: none;
  /* prevent text selection on long-press */
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
/* Long-press feedback: scale down slightly so user knows drag is primed */
.topup-inventory-rail-channel.is-drag-pending {
  transform: scale(0.985);
  transition: transform 150ms ease;
  box-shadow: 0 2px 10px rgba(18,43,33,0.10);
}

.topup-inventory-rail-channel:has(input:checked) {
  border-color: #b9d9cb;
  background: #eff8f3;
}

.topup-inventory-rail-channel input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.topup-inventory-rail-switch {
  position: relative;
  display: block;
  width: 32px;
  height: 20px;
  border-radius: 999px;
  background: #c7d4ce;
  transition: background 160ms ease;
}

.topup-inventory-rail-switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(25, 42, 35, 0.18);
  content: "";
  transition: transform 160ms ease;
}

.topup-inventory-rail-channel:has(input:checked) .topup-inventory-rail-switch {
  background: var(--accent);
}

.topup-inventory-rail-channel:has(input:checked) .topup-inventory-rail-switch::after {
  transform: translateX(12px);
}

.topup-inventory-rail-channel-info {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(72px, 0.8fr) minmax(55px, 1fr);
  align-items: baseline;
  gap: 4px 8px;
}

.topup-inventory-rail-channel-info strong,
.topup-inventory-rail-channel-info span,
.topup-inventory-rail-channel-info em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topup-inventory-rail-channel-info strong {
  font-size: 13px;
}

.topup-inventory-rail-channel-info span {
  color: var(--muted);
  font-size: 11px;
}

.topup-inventory-rail-channel-info em {
  grid-column: 1 / -1;
  color: #176148;
  font-size: 11px;
  font-style: normal;
  font-variant-numeric: tabular-nums;
}

.topup-inventory-rail-channel.low .topup-inventory-rail-channel-info em { color: #8a5a00; }
.topup-inventory-rail-channel.empty .topup-inventory-rail-channel-info em { color: var(--danger); }

.topup-inventory-rail-actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: auto;
  padding: 10px 0 max(2px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: linear-gradient(to bottom, rgba(255,255,255,0), var(--surface) 18%);
}

.topup-inventory-rail-actions .topup-inventory-actions {
  display: contents;
}

.topup-inventory-rail-actions .topup-inventory-channel-manage {
  grid-column: auto;
}

.topup-inventory-rail-actions button {
  min-width: 0;
  min-height: 42px;
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .customer-sidebar .topup-inventory-compact-trigger {
    min-height: 30px;
    gap: 4px;
  }

  .topup-inventory-compact-summary {
    gap: 5px;
    font-size: 9px;
  }

  .topup-inventory-compact-custom {
    max-width: 112px;
    padding-left: 5px;
  }

  .topup-inventory-compact-title {
    font-size: 10px;
  }

  .topup-inventory-rail {
    width: min(440px, 92vw);
  }

  .topup-inventory-rail-body {
    padding-right: 12px;
    padding-left: 12px;
  }

  .topup-inventory-rail-actions button {
    min-height: 40px;
    padding: 0 6px;
    font-size: 12px;
  }
}

/* Final compact inventory pass. The left sidebar keeps only a short trigger
   plus the selected rows. Full labels and per-channel actions live in the
   independently scrolling rail so the customer list keeps its height. */
.customer-sidebar .topup-inventory-compact-trigger {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 25px;
  padding: 1px 0;
  border-top: 1px solid #e3ece7;
  border-bottom: 1px solid #e3ece7;
  background: transparent;
}

.customer-sidebar .topup-inventory-compact-title {
  font-size: 10px;
  line-height: 1.2;
}

.topup-inventory-visible-list {
  display: grid;
  gap: 1px;
  min-width: 0;
  padding: 2px 0 3px;
}

.topup-inventory-visible-row {
  display: grid;
  grid-template-columns: minmax(42px, 34%) minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  min-height: 17px;
  padding: 1px 0;
  border-bottom: 1px solid #eef4f0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.2;
  white-space: nowrap;
}

.topup-inventory-visible-row:last-child { border-bottom: 0; }
.topup-inventory-visible-row > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topup-inventory-visible-row strong { color: var(--text); font-size: 9px; font-weight: 750; }
.topup-inventory-visible-row em { color: #176148; font-style: normal; font-variant-numeric: tabular-nums; }
.topup-inventory-visible-row.low em { color: #8a5a00; }
.topup-inventory-visible-row.empty em { color: var(--danger); }

.topup-inventory-rail {
  width: min(560px, calc(100vw - 12px));
}

.topup-inventory-rail-body {
  gap: 6px;
  padding: 8px 10px max(10px, env(safe-area-inset-bottom));
}

.topup-inventory-rail-list { gap: 4px; }

.topup-inventory-rail-channel {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 56px;
  padding: 6px 7px;
  border-radius: 9px;
}

.topup-inventory-rail-toggle {
  display: grid;
  place-items: center;
  width: 24px;
  min-width: 24px;
  min-height: 28px;
  cursor: pointer;
}

.topup-inventory-rail-toggle .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;
}

.topup-inventory-rail-switch { width: 25px; height: 16px; }
.topup-inventory-rail-switch::after { top: 2px; left: 2px; width: 12px; height: 12px; }
.topup-inventory-rail-channel:has(input:checked) .topup-inventory-rail-switch::after { transform: translateX(9px); }

.topup-inventory-rail-channel-info {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.topup-inventory-rail-channel-head {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
  white-space: nowrap;
}

.topup-inventory-rail-channel-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.2;
}

.topup-inventory-rail-channel-head > span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topup-inventory-rail-channel-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  min-width: 0;
}

.topup-inventory-rail-channel.is-fei2 .topup-inventory-rail-channel-stats,
.topup-inventory-rail-channel.has-sold .topup-inventory-rail-channel-stats {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.topup-inventory-rail-channel-stats > span {
  display: flex;
  align-items: baseline;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 8.5px;
  line-height: 1.15;
  white-space: nowrap;
}

.topup-inventory-rail-channel-stats strong {
  overflow: hidden;
  color: #176148;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
}

.topup-inventory-rail-channel.low .topup-inventory-rail-channel-stats strong { color: #8a5a00; }
.topup-inventory-rail-channel.empty .topup-inventory-rail-channel-stats strong { color: var(--danger); }

.topup-inventory-rail-manage {
  min-width: 36px;
  min-height: 28px;
  padding: 0 7px;
  border-radius: 7px;
  font-size: 10px;
  line-height: 1;
}

.topup-inventory-rail-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  padding-top: 7px;
}

.topup-inventory-rail-actions button {
  min-height: 34px;
  padding: 0 7px;
  font-size: 11px;
}

@media (max-width: 600px) {
  .topup-inventory-rail { width: min(560px, calc(100vw - 8px)); }
  .topup-inventory-rail-head { min-height: 42px; padding: max(5px, env(safe-area-inset-top)) 10px 5px; }
  .topup-inventory-rail-head strong { font-size: 14px; }
  .topup-inventory-rail-body { padding-right: 7px; padding-left: 7px; }
  .topup-inventory-rail-channel { grid-template-columns: 22px minmax(0, 1fr) auto; min-height: 53px; gap: 5px; padding: 5px 6px; }
  .topup-inventory-rail-toggle { width: 22px; min-width: 22px; }
  .topup-inventory-rail-channel-head strong { font-size: 11px; }
  .topup-inventory-rail-channel-head > span { font-size: 8px; }
  .topup-inventory-rail-channel-stats { gap: 2px; }
  .topup-inventory-rail-channel-stats > span { font-size: 7.5px; gap: 1px; }
  .topup-inventory-rail-channel-stats strong { font-size: 9px; }
  .topup-inventory-rail-manage { min-width: 34px; min-height: 26px; padding: 0 6px; font-size: 9px; }
}

/* Inventory rail card polish. Keep actions in the header and let the full
   statistics row use the card width so every value stays readable. */
.topup-inventory-rail {
  width: min(680px, calc(100vw - 8px));
}

.topup-inventory-rail-channel {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: start;
  column-gap: 12px;
  row-gap: 10px;
  min-height: 0;
  padding: 14px;
  border-radius: 14px;
}

.topup-inventory-rail-toggle {
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: start;
  margin-top: 4px;
}

.topup-inventory-rail-channel-info {
  display: contents;
}

.topup-inventory-rail-channel-head {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 9px;
  min-width: 0;
  padding: 3px 0;
  white-space: normal;
}

.topup-inventory-rail-channel-heading {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 9px;
  min-width: 0;
}

.topup-inventory-rail-channel-head strong {
  min-width: 0;
  overflow: visible;
  color: var(--text);
  font-size: 16px;
  line-height: 1.25;
  text-overflow: clip;
  white-space: normal;
}

.topup-inventory-rail-channel-head > span {
  min-width: 0;
  overflow: visible;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  text-overflow: clip;
  white-space: normal;
}

.topup-inventory-rail-channel-head .topup-inventory-rail-channel-url {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--accent-2);
  font-size: 11px;
  line-height: 1.3;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topup-inventory-rail-channel-head .topup-inventory-rail-channel-url:hover,
.topup-inventory-rail-channel-head .topup-inventory-rail-channel-url:focus-visible {
  text-decoration: underline;
}

.topup-inventory-rail-channel-head .topup-inventory-rail-channel-url span {
  flex: 0 0 auto;
  font-size: 13px;
}

.topup-inventory-rail-channel-head .topup-inventory-rail-channel-url.is-empty {
  color: var(--muted);
}

.topup-inventory-rail-channel-actions .topup-inventory-priority {
  width: auto;
  min-width: max-content;
  padding: 0 10px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.topup-inventory-rail-channel-actions .topup-inventory-priority[aria-pressed="true"] {
  border: 1px solid #96c7b4;
  background: #dff2ea;
  color: #0f5e4d;
  font-weight: 750;
  opacity: 1;
  cursor: default;
}

.topup-inventory-rail-channel-actions {
  grid-column: 3;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: max-content;
}

.topup-inventory-rail-channel-actions button {
  width: 68px;
  min-width: 68px;
  min-height: 36px;
  padding: 0 8px;
  border-radius: 9px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}

.topup-inventory-rail-import {
  border-color: #c6ddd3;
  background: #f7fbf9;
  color: #176148;
}

.topup-inventory-rail-channel-stats {
  grid-column: 2 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.topup-inventory-rail-channel.is-fei2 .topup-inventory-rail-channel-stats,
.topup-inventory-rail-channel.has-sold .topup-inventory-rail-channel-stats {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.topup-inventory-rail-channel-stats > span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 54px;
  padding: 7px 5px;
  overflow: visible;
  border-radius: 9px;
  background: #f3faf6;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
}

.topup-inventory-rail-channel-stats strong {
  display: block;
  overflow: visible;
  color: #176148;
  font-size: 18px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  text-overflow: clip;
  white-space: nowrap;
}

.topup-inventory-rail-channel.low .topup-inventory-rail-channel-stats strong { color: #8a5a00; }
.topup-inventory-rail-channel.empty .topup-inventory-rail-channel-stats strong { color: var(--danger); }

.topup-inventory-rail-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 10px;
}

@media (max-width: 600px) {
  .topup-inventory-rail {
    width: min(680px, calc(100vw - 8px));
  }

  .topup-inventory-rail-body {
    padding-right: 8px;
    padding-left: 8px;
  }

  .topup-inventory-rail-channel {
    grid-template-columns: 28px minmax(0, 1fr) auto;
    column-gap: 9px;
    row-gap: 9px;
    padding: 12px 10px;
  }

  .topup-inventory-rail-toggle {
    width: 28px;
    min-width: 28px;
    margin-top: 3px;
  }

  .topup-inventory-rail-channel-head {
    gap: 3px 7px;
    padding: 2px 0;
  }

  .topup-inventory-rail-channel-head strong {
    font-size: 14px;
  }

  .topup-inventory-rail-channel-head > span {
    font-size: 11px;
  }

  .topup-inventory-rail-channel-actions {
    gap: 6px;
  }

  .topup-inventory-rail-channel-actions button {
    width: 60px;
    min-width: 60px;
    min-height: 34px;
    padding: 0 6px;
    font-size: 11px;
  }

  .topup-inventory-rail-channel-stats {
    gap: 4px;
  }

  .topup-inventory-rail-channel-stats > span {
    min-height: 48px;
    padding: 6px 3px;
    font-size: 10px;
  }

  .topup-inventory-rail-channel-stats strong {
    font-size: 16px;
  }
}
.topup-inventory-rail-probe-warning,
.topup-inventory-rail-probe-hint {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.25;
}
.topup-inventory-rail-reprobe {
  min-height: 20px;
  padding: 1px 6px;
  font-size: 10px;
  border-radius: 999px;
}

/* The tier is the decision point in a channel choice. Keep the provider name
   and inventory count secondary while preserving the compact rail layout. */
.topup-channel-choice-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-width: 0;
}
.topup-channel-choice-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.topup-channel-choice {
  grid-template-rows: auto auto auto;
  align-items: start;
  min-height: 0;
}
.topup-channel-choice-tier { color: var(--accent-2) !important; font-size: 16px !important; font-weight: 800; line-height: 1.25; }
.topup-channel-choice-channel { color: var(--muted) !important; font-size: 11px !important; font-weight: 650; }
.topup-channel-choice-arrow { flex: 0 0 auto; margin-top: 1px; color: var(--accent-2) !important; font-size: 22px !important; line-height: 1; }
.topup-channel-choice-available { display: inline-flex; width: fit-content; padding: 2px 7px; border: 1px solid color-mix(in srgb, var(--accent-2) 24%, var(--border)); border-radius: 999px; background: color-mix(in srgb, var(--accent-2) 7%, var(--surface)); color: var(--accent-2) !important; font-size: 11px !important; font-variant-numeric: tabular-nums; font-weight: 750; }
.topup-channel-choice small { min-width: 0; max-width: 100%; line-height: 1.35; }
.topup-channel-manage-tier,
.topup-inventory-channel-tier,
.topup-inventory-visible-tier,
.topup-inventory-rail-channel-tier { color: var(--accent-2) !important; font-weight: 800 !important; }
.topup-channel-manage-name,
.topup-inventory-channel-name,
.topup-inventory-visible-name,
.topup-inventory-rail-channel-name { color: var(--muted) !important; font-size: 11px !important; font-weight: 650; }
.topup-channel-manage-tier { font-size: 16px !important; line-height: 1.25; }
.topup-inventory-visible-tier { font-size: 10px !important; }
.topup-inventory-visible-name { font-size: 9px !important; }
.topup-inventory-rail-channel-tier { font-size: 16px !important; line-height: 1.25; }

.topup-inventory-rail-channel {
  grid-template-columns: 18px 24px minmax(0, 1fr) auto;
}
.topup-inventory-rail-drag {
  display: grid;
  place-items: center;
  width: 18px;
  min-width: 18px;
  min-height: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #c3d8d0;
  font-size: 13px;
  letter-spacing: -2px;
  line-height: 1;
}
/* is-dragging: row acts as a low-opacity placeholder; the real visual follows the pointer as a clone */
/* Whole card is the drag zone — show grab cursor on info area, keep pointer on action buttons */
.topup-inventory-rail-channel-info,
.topup-inventory-rail-drag { cursor: grab; }
.topup-inventory-rail-channel-actions,
.topup-inventory-rail-channel-actions button { cursor: pointer; }
.topup-inventory-rail-toggle { cursor: pointer; }
.topup-inventory-rail-channel.is-dragging { opacity: .25; background: transparent; box-shadow: none; border: 1.5px dashed var(--accent); }
.topup-inventory-rail-channel.is-dragging * { visibility: hidden; }
body.topup-inventory-dragging,
body.topup-inventory-dragging * { cursor: grabbing !important; user-select: none !important; }

.client-app .client-presence-row { flex-wrap: nowrap; min-width: 0; overflow: hidden; }
.client-app .client-presence-person { flex: 0 0 auto; flex-wrap: nowrap; white-space: nowrap; }
.client-app .client-presence-person .presence-last-seen { white-space: nowrap; }
.client-announcement.permanent-announcement { gap: 0; padding: 10px 13px; }
.client-announcement .announcement-bar { align-items: flex-start; gap: 10px; }
.client-announcement .presence-message { flex: 1 1 auto; min-width: 0; max-height: 5.2em; margin: 0; overflow: auto; line-height: 1.45; }
/* merged into base .published-announcement-trigger rule above */
.published-announcement-trigger .announcement-trigger-glyph { width: 15px; height: 15px; }
.announcement-trigger-label { font-size: 12px; font-weight: 750; line-height: 1; }
@media (max-width: 600px) {
  .topup-channel-choice-tier { font-size: 15px !important; }
  .topup-channel-choice-main { gap: 8px; }
  .client-announcement.permanent-announcement { padding: 8px 10px; }
  .published-announcement-trigger { min-width: 58px; padding: 0 8px; }
  html:not(.client-keyboard-compact) .client-app .client-topbar {
    flex-wrap: wrap;
    row-gap: 7px;
    padding: 8px 12px;
  }
  html:not(.client-keyboard-compact) .client-app .client-brand {
    flex: 1 1 100%;
    max-width: none;
    min-width: 0;
  }
  html:not(.client-keyboard-compact) .client-app .client-username {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  html:not(.client-keyboard-compact) .client-app .client-presence-row {
    flex-wrap: wrap;
    overflow: visible;
    gap: 4px 12px;
  }
  html:not(.client-keyboard-compact) .client-app .client-account-actions {
    flex: 1 1 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px;
  }
  .profile-dialog-head {
    padding: 14px 14px 10px;
  }
  .profile-dialog-body {
    padding: 12px 14px 18px;
  }
}

/* Keep the inventory rail scrollable while placing the drag handle, switch,
   channel content, and actions in stable columns. The drag animation remains
   owned by the existing pointer handlers. */
.topup-inventory-rail-channel {
  grid-template-columns: 18px 24px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 10px;
  touch-action: pan-y;
}

.topup-inventory-rail-drag {
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: start;
  margin-top: 4px;
}

.topup-inventory-rail-toggle {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: start;
  margin-top: 4px;
}

.topup-inventory-rail-channel-head {
  grid-column: 3;
  grid-row: 1;
}

.topup-inventory-rail-channel-actions {
  grid-column: 4;
  grid-row: 1;
}

.topup-inventory-rail-channel-stats {
  grid-column: 3 / -1;
  grid-row: 2;
}

@media (max-width: 600px) {
  .topup-inventory-rail-channel {
    grid-template-columns: 18px 26px minmax(0, 1fr);
    column-gap: 6px;
    row-gap: 8px;
  }

  .topup-inventory-rail-drag,
  .topup-inventory-rail-toggle {
    grid-row: 1;
  }

  .topup-inventory-rail-drag {
    width: 18px;
    min-width: 18px;
  }

  .topup-inventory-rail-toggle {
    width: 26px;
    min-width: 26px;
  }

  .topup-inventory-rail-channel-stats {
    grid-column: 1 / -1;
  }

  .topup-inventory-rail-channel-actions {
    grid-column: 1 / -1;
    grid-row: 3;
    flex-wrap: wrap;
    min-width: 0;
    gap: 6px;
  }

  .topup-inventory-rail-channel-actions .topup-inventory-priority {
    font-size: 11px;
    padding: 0 8px;
  }
}
