@import url("/theme/tokens/tokens.css");

*,
*::before,
*::after { box-sizing: border-box; }

/* Scrollbar padrão Kangaroo Desk (fina, discreta) — use em qualquer overflow */
:root {
  --kd-scrollbar-size: 5px;
  --kd-scrollbar-thumb: color-mix(in srgb, var(--text-muted) 28%, transparent);
  --kd-scrollbar-thumb-hover: color-mix(in srgb, var(--text-muted) 50%, transparent);
}
* {
  scrollbar-width: thin;
  scrollbar-color: var(--kd-scrollbar-thumb) transparent;
}
::-webkit-scrollbar {
  width: var(--kd-scrollbar-size);
  height: var(--kd-scrollbar-size);
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--kd-scrollbar-thumb);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--kd-scrollbar-thumb-hover);
}

html, body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body:has(.kd-shell) {
  overflow: hidden;
}

#app {
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.kd-shell {
  display: grid;
  grid-template-columns: minmax(min(260px, 100%), var(--kd-sidebar-width, 340px)) minmax(0, 1fr);
  width: 100%;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  gap: 0;
  border-top: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  padding-top: env(safe-area-inset-top, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  background: var(--bg);
}

.kd-col {
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.kd-col:last-child { border-right: 0; }

.kd-sidebar {
  background: var(--surface);
  box-shadow: 1px 0 0 color-mix(in srgb, var(--border) 70%, transparent);
}
.kd-shell:not(.kd-admin-shell) {
  /* piso; JS syncDeskHeadHeights iguala à altura real do chat head */
  --kd-desk-head-min-h: calc(max(40px, var(--kd-avatar-size, 36px)) + 3.25rem);
}
.kd-sidebar .kd-head-brand {
  border-bottom-color: color-mix(in srgb, var(--border) 55%, transparent);
  min-height: var(--kd-desk-head-min-h);
  box-sizing: border-box;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}
.kd-chat {
  background:
    radial-gradient(ellipse 70% 45% at 85% 0%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
    var(--bg);
  position: relative;
}
.kd-chat-work {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  height: 100%;
  padding-bottom: 4px;
}
.kd-chat-work[hidden],
.kd-chat.is-empty .kd-chat-work {
  display: none !important;
}
.kd-chat:not(.is-empty) .kd-chat-empty {
  display: none !important;
}
.kd-chat[data-kd-dropzone].is-drag,
.kd-chat[data-kd-dropzone].is-drag-available {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: -2px;
}
.kd-chat-empty {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 48px 28px;
  text-align: center;
}
.kd-chat-empty[hidden] { display: none !important; }
.kd-chat-empty-title {
  margin: 0;
  max-width: 240px;
  font-size: 0.92em;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.45;
  color: var(--text-muted);
}
.kd-list-empty {
  display: grid;
  place-items: center;
  padding: 28px 16px 36px;
  text-align: center;
}
.kd-list-empty-label {
  margin: 0;
  font-size: 0.86em;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-muted);
}

.kd-head {
  padding: var(--kd-head-pad, 12px 16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65em;
  background: var(--surface);
  flex: 0 0 auto;
}
.kd-chat .kd-head,
.kd-chat-head {
  min-height: var(--kd-desk-head-min-h, calc(max(40px, var(--kd-avatar-size, 36px)) + 3.25rem));
  box-sizing: border-box;
  padding: 0.75rem clamp(14px, 2.5vw, 22px);
  align-items: center;
}
.kd-head-brand { align-items: center; }
.kd-head-text {
  min-width: 0;
  flex: 1;
}
.kd-head h1, .kd-head h2 {
  margin: 0;
  font-size: 0.95em;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kd-brand {
  font-size: 1.05em;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}
.kd-brand.has-logo {
  display: flex;
  align-items: center;
  color: inherit;
}
.kd-brand-logo {
  display: block;
  max-height: var(--kd-brand-logo, 28px);
  max-width: min(12em, 100%);
  width: auto;
  height: auto;
  object-fit: contain;
}
.kd-login .kd-brand-logo {
  max-height: 44px;
  max-width: 200px;
  margin: 0 auto;
}
.kd-login .kd-brand.has-logo {
  justify-content: center;
}

.kd-chat-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.kd-back-btn {
  display: none;
  appearance: none;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.kd-back-btn svg {
  width: 22px;
  height: 22px;
  display: block;
}
.kd-back-btn:hover,
.kd-back-btn:focus-visible {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
  outline: none;
}
.kd-avatar {
  position: relative;
  width: var(--kd-avatar-size, 36px);
  height: var(--kd-avatar-size, 36px);
  flex: 0 0 auto;
}
.kd-avatar-letters {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--kd-avatar-size, 36px);
  height: var(--kd-avatar-size, 36px);
  border-radius: 30px;
  background: var(--kd-avatar-bg, var(--accent));
  color: #fff;
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.02em;
  user-select: none;
}
.kd-avatar-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--accent);
}
.kd-avatar-badge.is-whatsapp {
  color: #25d366;
}
.kd-avatar-badge.is-chat {
  color: var(--accent);
}
.kd-avatar-badge svg {
  width: 10px;
  height: 10px;
  display: block;
}
.kd-chat-title-line {
  display: flex !important;
  align-items: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
}
.kd-chat-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  font-size: 1.02em;
  font-weight: 650;
  letter-spacing: -0.015em;
}
.kd-status-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--surface-2);
  font-size: 0.7em;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-transform: none;
  line-height: 1;
}
.kd-status-pill[hidden] {
  display: none !important;
}
.kd-status-pill.is-closed {
  background: color-mix(in srgb, #10b981 14%, var(--surface));
  color: #047857;
}
.kd-status-pill.is-assigned {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--accent);
}
.kd-status-pill.is-queued {
  background: color-mix(in srgb, #d97706 14%, var(--surface));
  color: #b45309;
}
.kd-status-pill.is-bot {
  background: color-mix(in srgb, #6366f1 12%, var(--surface));
  color: #4f46e5;
}
.kd-chat-head-aside {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
}
.kd-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  flex: 0 0 auto;
}
.kd-chat-head .kd-toolbar .kd-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  opacity: 0.75;
}
.kd-chat-head .kd-toolbar .kd-icon-btn svg {
  width: 21px;
  height: 21px;
}
.kd-chat-head .kd-toolbar .kd-icon-btn:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 0;
  opacity: 1;
}
.kd-chat-head .kd-toolbar .kd-act-close-chat:hover {
  color: #059669;
  background: color-mix(in srgb, #10b981 12%, var(--surface));
}
.kd-chat-head .kd-toolbar .kd-act-ban:hover {
  color: #b91c1c;
  background: color-mix(in srgb, #ef4444 12%, var(--surface));
}
.kd-chat-head .kd-toolbar #btn-reopen:hover {
  color: var(--accent);
}

.kd-nav {
  display: flex;
  align-items: stretch;
  gap: 2px;
  flex: 0 0 auto;
  margin: 0.55em 0.7em 0.35em;
  padding: 3px;
  border: 0;
  border-radius: 14px;
  background: color-mix(in srgb, var(--text-muted) 8%, var(--bg));
  box-shadow: none;
}
.kd-nav.kd-nav-2 {
  /* same flex layout */
}
.kd-nav-item {
  appearance: none;
  position: relative;
  flex: 1 1 0;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.78em;
  font-weight: 550;
  letter-spacing: -0.01em;
  padding: 0.5em 0.45em;
  min-height: var(--kd-nav-min-h, 34px);
  cursor: pointer;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.32em;
  transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.kd-nav-item:hover {
  color: var(--kd-user-text, var(--text));
  background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.kd-nav-item.is-active {
  color: var(--kd-user-text, var(--text));
  background: var(--surface);
  box-shadow:
    0 1px 2px color-mix(in srgb, #000 6%, transparent),
    0 0 0 1px color-mix(in srgb, var(--border) 45%, transparent);
  font-weight: 650;
}
html[data-theme="dark"] .kd-nav {
  background: color-mix(in srgb, #fff 5%, var(--bg));
}
html[data-theme="dark"] .kd-nav-item:hover {
  background: color-mix(in srgb, #fff 4%, transparent);
}
html[data-theme="dark"] .kd-nav-item.is-active {
  background: color-mix(in srgb, #fff 9%, var(--surface));
  box-shadow:
    0 1px 3px color-mix(in srgb, #000 28%, transparent),
    0 0 0 1px color-mix(in srgb, #fff 6%, transparent);
  color: #fff;
}
.kd-nav-ico {
  display: inline-flex;
  width: var(--kd-nav-icon, 14px);
  height: var(--kd-nav-icon, 14px);
  flex: 0 0 auto;
  opacity: 0.82;
}
.kd-nav-item.is-active .kd-nav-ico {
  opacity: 1;
}
.kd-nav-ico svg {
  width: var(--kd-nav-icon, 14px);
  height: var(--kd-nav-icon, 14px);
  display: block;
}
.kd-nav-ico-open { color: #22c55e; }
.kd-nav-ico-pending { color: #eab308; }
.kd-nav-ico-closed { color: color-mix(in srgb, var(--text-muted) 80%, #fff); }
.kd-nav-item.is-active .kd-nav-ico-closed { color: #a3a3a3; }
.kd-nav-label {
  line-height: 1;
  white-space: nowrap;
}
.kd-nav-count {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--kd-nav-count, 16px);
  height: var(--kd-nav-count, 16px);
  padding: 0 0.35em;
  margin-left: 0.05em;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 82%, #000);
  border: 0;
  font-size: 0.7em;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  text-align: center;
  box-sizing: border-box;
  flex: 0 0 auto;
}
.kd-nav-item.is-active .kd-nav-count {
  background: color-mix(in srgb, var(--accent) 88%, #000);
  color: #fff;
}
.kd-nav-item.has-alert .kd-nav-count {
  background: #16a34a;
  color: #fff;
}
html[data-theme="dark"] .kd-nav-count {
  border-color: transparent;
}

.kd-list {
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  padding: 0.45em 0.55em 0.85em 0.45em;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.kd-item {
  position: relative;
  padding: 0.95em 0.75em 0.95em 0.8em;
  margin: 0;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  border-left: 2.5px solid transparent;
  border-radius: 0;
  cursor: pointer;
  min-height: calc(var(--kd-avatar-size, 24px) + 2.45em);
  display: flex;
  align-items: center;
  gap: 0.75em;
  background: transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.kd-item:last-child {
  border-bottom-color: transparent;
}
.kd-item:hover {
  background: color-mix(in srgb, var(--text-muted) 6%, var(--surface));
}
.kd-item.is-active {
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  border-left-color: var(--accent);
  box-shadow: none;
}
.kd-item-pending,
.kd-item-row {
  /* herda flex do .kd-item */
}
.kd-item-pending {
  cursor: default;
}
.kd-item-pending.is-bot-queue {
  border-left-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.kd-item-pending.is-bot-queue .kd-badge {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
/* Cor do departamento prevalece (bot ou fila humana) */
.kd-item-pending.is-bot-queue.has-dept-color {
  border-left-color: color-mix(in srgb, var(--kd-dept-color) 55%, transparent);
}
.kd-item-pending.is-bot-queue .kd-badge.has-dept-color {
  color: var(--kd-dept-color);
  background: color-mix(in srgb, var(--kd-dept-color) 12%, transparent);
}
.kd-item-pending.has-dept-color {
  border-left-color: color-mix(in srgb, var(--kd-dept-color) 55%, transparent);
}
.kd-badge.has-dept-color {
  color: var(--kd-dept-color);
  background: color-mix(in srgb, var(--kd-dept-color) 12%, transparent);
}
.kd-item-avatar {
  position: relative;
  width: var(--kd-avatar-size, 24px);
  height: var(--kd-avatar-size, 24px);
  border-radius: 30px;
  background: var(--kd-avatar-bg, var(--accent));
  color: #fff;
  font-size: 0.68em;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  user-select: none;
}
.kd-item-avatar-letters {
  line-height: 1;
}
.kd-item-avatar .kd-avatar-badge {
  right: -3px;
  bottom: -3px;
  width: 15px;
  height: 15px;
  box-shadow: 0 0 0 2px var(--surface);
}
.kd-item-avatar .kd-avatar-badge svg {
  width: 9px;
  height: 9px;
}
.kd-item-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35em;
}
.kd-item-line {
  display: flex;
  align-items: center;
  gap: 0.4em;
  min-width: 0;
}
.kd-item-line strong {
  flex: 1 1 auto;
  font-size: 0.9em;
  font-weight: 650;
  letter-spacing: -0.015em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  color: var(--kd-user-text, var(--text));
}
.kd-item-sub {
  display: flex;
  align-items: center;
  gap: 0.4em;
  min-width: 0;
}
.kd-item-sub .kd-badge {
  margin-right: 0;
  flex: 0 0 auto;
}
.kd-item-meta {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.74em;
  font-weight: 450;
  color: color-mix(in srgb, var(--text-muted) 92%, transparent);
  line-height: 1.3;
}
.kd-item-meta .kd-item-status {
  color: var(--text-muted);
  font-weight: 500;
}
.kd-item-meta .kd-item-proto::before {
  content: " · ";
  opacity: 0.65;
  font-weight: 400;
}
.kd-item-meta .kd-item-proto {
  color: color-mix(in srgb, var(--text-muted) 78%, transparent);
  font-weight: 450;
  letter-spacing: 0.01em;
}
.kd-item-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 0.12em;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 9em;
  margin-left: auto;
  text-align: right;
}
.kd-item-side .kd-assignee-inline {
  margin: 0;
  max-width: 100%;
}
.kd-item-side .kd-item-brand {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.62em;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: color-mix(in srgb, var(--text-muted) 62%, transparent);
}
.kd-item-actions {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 0 0 auto;
  align-self: center;
  margin-left: 0.15em;
}
/* Ações da lista: só ícone suave — sem borda, sem “botão” (ver docs/ui/ICON_BUTTONS.md) */
.kd-item-actions .kd-icon-btn,
.kd-item .kd-act-force-close {
  appearance: none;
  width: var(--kd-icon-btn, 30px);
  height: var(--kd-icon-btn, 30px);
  flex: 0 0 auto;
  border: 0 !important;
  box-shadow: none !important;
  outline: none;
  border-radius: 0;
  background: transparent !important;
  opacity: 0.45;
  color: var(--text-muted);
}
.kd-item-actions .kd-icon-btn svg,
.kd-item .kd-act-force-close svg {
  width: var(--kd-icon-svg, 17px);
  height: var(--kd-icon-svg, 17px);
}
.kd-item-actions .kd-icon-btn:hover,
.kd-item-actions .kd-icon-btn:focus-visible,
.kd-item .kd-act-force-close:hover,
.kd-item .kd-act-force-close:focus-visible {
  opacity: 1;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  color: var(--text);
}
.kd-item-actions .kd-act-peek:hover,
.kd-item-actions .kd-act-peek:focus-visible {
  color: var(--text);
}
.kd-item-actions .kd-act-claim {
  color: var(--accent);
  opacity: 0.7;
}
.kd-item-actions .kd-act-claim:hover,
.kd-item-actions .kd-act-claim:focus-visible {
  color: var(--accent);
  opacity: 1;
}
.kd-item .kd-act-force-close {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 3;
  width: 40px;
  height: 40px;
  /* Cruzamento perto do canto — sem gerar scroll horizontal */
  transform: translate(38%, -42%);
  color: var(--danger);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.kd-item .kd-act-force-close svg {
  width: 20px;
  height: 20px;
}
.kd-item:hover .kd-act-force-close,
.kd-item:focus-within .kd-act-force-close {
  opacity: 0.55;
  pointer-events: auto;
}
.kd-item .kd-act-force-close:hover,
.kd-item .kd-act-force-close:focus-visible {
  opacity: 1;
  color: var(--danger);
  background: transparent !important;
}
.kd-assignee {
  margin-top: 0;
  font-size: 0.8em;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kd-assignee-inline {
  display: inline-block;
  margin: 0;
  font-size: 0.68em;
  font-weight: 500;
  color: color-mix(in srgb, var(--text-muted) 90%, transparent);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 1 auto;
  line-height: 1.2;
}
.kd-meta-inline {
  color: var(--text-muted);
  font-size: 0.8em;
}
.kd-chat-id {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: 0.95em;
  font-weight: 550;
  letter-spacing: 0.02em;
  color: color-mix(in srgb, var(--text-muted) 78%, transparent);
  cursor: pointer;
  vertical-align: baseline;
}
.kd-chat-id:hover {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.kd-chat-meta-line {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.45em;
  min-width: 0;
  max-width: 100%;
}
.kd-chat-meta-row {
  display: flex;
  align-items: center;
  gap: 0.65em;
  width: 100%;
  min-width: 0;
}
.kd-chat-meta-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15em;
}
.kd-chat-visitor-fp {
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--muted, #64748b);
  word-break: break-word;
  max-width: 100%;
}
.kd-chat-meta-line > .kd-chat-proto,
.kd-chat-meta-line > .kd-chat-dept {
  position: relative;
  padding-left: 0.55em;
}
.kd-chat-meta-line > .kd-chat-proto::before,
.kd-chat-meta-line > .kd-chat-dept::before {
  content: "·";
  position: absolute;
  left: 0;
  opacity: 0.55;
  font-weight: 400;
}
.kd-chat-proto {
  font-weight: 550;
  letter-spacing: 0.015em;
  color: color-mix(in srgb, var(--text-muted) 70%, var(--kd-user-text, var(--text)));
  font-variant-numeric: tabular-nums;
}
.kd-chat-dept {
  font-weight: 450;
  color: var(--text-muted);
}
.kd-chat-who {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.3em;
  min-width: 0;
  max-width: 100%;
  line-height: 1.2;
}
.kd-chat-who[hidden] {
  display: none !important;
}
.kd-chat-assignee {
  display: inline;
  max-width: 12em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78em;
  font-weight: 500;
  color: color-mix(in srgb, var(--text-muted) 88%, transparent);
  line-height: 1.2;
}
.kd-chat-brand {
  display: inline;
  max-width: 10em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.72em;
  font-weight: 400;
  color: color-mix(in srgb, var(--text-muted) 58%, transparent);
  letter-spacing: 0.01em;
  line-height: 1.2;
}
.kd-chat-brand::before {
  content: "·";
  margin-right: 0.3em;
  opacity: 0.55;
}
.kd-peek-banner {
  padding: 9px 16px;
  font-size: 0.88em;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.kd-peek-banner[hidden] {
  display: none !important;
}
.kd-lunch-banner {
  padding: 9px 16px;
  font-size: 0.88em;
  font-weight: 600;
  color: #0f766e;
  background: color-mix(in srgb, #14b8a6 12%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, #14b8a6 28%, var(--border));
}
.kd-lunch-banner[hidden] {
  display: none !important;
}
[data-theme="dark"] .kd-lunch-banner {
  color: #5eead4;
}
.kd-work-tol {
  margin: 10px 0 12px;
  max-width: 220px;
}
.kd-work-tol input[type="number"] {
  width: 100%;
  min-height: 36px;
  margin-top: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.kd-work-schedule-wrap {
  /* overflow-x:auto sozinho força overflow-y:auto no browser → 2ª barra vertical */
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  margin-top: 4px;
}
.kd-work-schedule-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  margin: 0 0 8px;
}
.kd-work-schedule-tools .kd-btn-ghost {
  font-size: 12px;
  min-height: 28px;
  padding: 2px 8px;
}
.kd-work-day-name {
  font-weight: 600;
  color: var(--text);
  width: 72px;
}
.kd-work-day-label {
  display: block;
  line-height: 1.2;
}
.kd-work-copy-btn {
  margin-top: 2px;
  padding: 0 4px !important;
  min-height: 22px !important;
  font-size: 10px !important;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent) !important;
}
.kd-work-copy-btn:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent) !important;
}
.kd-work-schedule {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
.kd-work-schedule th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 6px 8px 0;
}
.kd-work-schedule td {
  padding: 6px 6px 6px 0;
  vertical-align: middle;
  border-top: 1px solid var(--border-soft, var(--border));
}
.kd-work-schedule input[type="time"] {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 12px;
}
.kd-idle-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  background: color-mix(in srgb, #d97706 14%, var(--surface));
  color: #b45309;
  border-bottom: 1px solid color-mix(in srgb, #d97706 28%, var(--border));
}
.kd-idle-banner[hidden] {
  display: none !important;
}
.kd-idle-banner-text {
  font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .kd-idle-banner {
  color: #fbbf24;
}
.kd-badge {
  display: inline-block;
  font-size: 0.68em;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 10%, transparent);
  color: var(--text-muted);
  margin-right: 0;
  letter-spacing: 0.01em;
}
/* Flex no wrapper interno — nunca no <td> (quebra vertical-align da tabela) */
.kd-dept-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.kd-dept-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: 0 0 auto;
  background: var(--kd-dept-color, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text-muted) 35%, transparent);
}
.kd-dept-swatch.is-empty {
  background: transparent;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text-muted) 28%, transparent);
}
.kd-dept-idle {
  display: grid;
  gap: 2px;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text);
}
.kd-dept-idle .kd-meta {
  margin: 0;
  font-size: 11px;
}
.kd-dept-status {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 12%, transparent);
  color: var(--text-muted);
}
.kd-dept-status.is-on {
  background: color-mix(in srgb, #16a34a 14%, transparent);
  color: #4ade80;
}
[data-theme="light"] .kd-dept-status.is-on {
  color: #15803d;
}
.kd-dept-sound {
  font-size: 12px;
  color: var(--text-muted);
}
.kd-dept-sound.is-on {
  color: var(--text);
}
.kd-form-section {
  display: grid;
  gap: 10px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--border-soft, var(--border));
}
.kd-form-section:first-child {
  border-top: 0;
  padding-top: 0;
}
.kd-form-section .kd-admin-section-title {
  margin: 0;
}
.kd-form-section > .kd-meta {
  margin: -2px 0 2px;
  line-height: 1.45;
}
.kd-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 560px) {
  .kd-form-row { grid-template-columns: 1fr; }
}
.kd-modal-lg .kd-admin-form {
  max-width: none;
}
.kd-form-section textarea {
  min-height: 68px;
}
.kd-meta {
  color: var(--text-muted);
  font-size: 0.82em;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kd-chat-head #chat-meta,
.kd-chat-head .kd-meta {
  display: block;
  margin-top: 5px;
  line-height: 1.35;
  overflow: visible;
  white-space: normal;
  font-size: 0.88em;
  color: var(--text-muted);
}
.kd-support-key {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  flex: 0 0 auto;
  white-space: nowrap;
  min-height: 32px;
  padding: 0.2em 0.55em 0.2em 0.6em;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.kd-support-key[hidden] {
  display: none !important;
}
.kd-support-key:hover,
.kd-support-key:focus-visible {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 36%, var(--border));
  outline: none;
}
.kd-support-key.is-copied {
  background: color-mix(in srgb, #10b981 14%, var(--surface));
  border-color: color-mix(in srgb, #10b981 30%, var(--border));
  color: #047857;
}
[data-theme="dark"] .kd-support-key.is-copied {
  color: #6ee7b7;
}
.kd-support-key-val {
  font-size: 0.92em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  line-height: 1;
}
.kd-support-key-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1em;
  height: 1.1em;
  opacity: 0.75;
  pointer-events: none;
}
.kd-support-key:hover .kd-support-key-copy,
.kd-support-key.is-copied .kd-support-key-copy {
  opacity: 1;
}
.kd-support-key-copy svg {
  width: 0.95em;
  height: 0.95em;
  display: block;
}

.kd-messages {
  flex: 1;
  overflow: auto;
  padding: 20px clamp(16px, 3vw, 28px) 28px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
  align-items: stretch;
  font-family: var(--kd-user-font, var(--font));
  font-size: var(--kd-user-font-size, 15px);
  color: var(--kd-user-text, var(--text));
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}
.kd-messages.is-scrolling {
  scrollbar-color: color-mix(in srgb, var(--text-muted) 45%, transparent) transparent;
}
.kd-messages::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
.kd-messages::-webkit-scrollbar-track {
  background: transparent;
}
.kd-messages::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 999px;
}
.kd-messages.is-scrolling::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-muted) 40%, transparent);
}
.kd-messages.is-scrolling::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--text-muted) 60%, transparent);
}
.kd-msg {
  display: inline-flex;
  flex-direction: column;
  flex: 0 0 auto;
  width: fit-content;
  max-width: min(76%, 440px);
  height: auto;
  min-height: 0;
  padding: 9px 12px 8px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border-soft, var(--border));
  box-shadow: var(--shadow);
  box-sizing: border-box;
  position: relative;
  cursor: default;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
.kd-msg:hover {
  box-shadow: var(--shadow-md);
}
.kd-msg-caret {
  appearance: none;
  position: absolute;
  top: 4px;
  z-index: 2;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ease), color var(--ease);
  box-shadow: none;
}
.kd-msg-caret svg {
  width: 14px;
  height: 14px;
  display: block;
}
.kd-msg.inbound .kd-msg-caret {
  right: 4px;
}
.kd-msg.inbound .kd-msg-name {
  padding-right: 22px; /* espaço pro caret no hover — não cobre o nome */
}
.kd-msg.outbound .kd-msg-caret {
  /* Dentro do balão, canto superior direito — não cobre o avatar (à esquerda) e continua clicável */
  left: auto;
  right: 4px;
  top: 4px;
}
.kd-msg.outbound .kd-msg-head {
  padding-right: 22px; /* espaço pro caret no hover */
}
.kd-msg:hover .kd-msg-caret,
.kd-msg:focus-within .kd-msg-caret,
.kd-msg-caret:focus {
  opacity: 1;
  pointer-events: auto;
  background: transparent;
  box-shadow: none;
}
.kd-msg-caret:hover,
.kd-msg-caret:focus {
  color: var(--accent);
  background: transparent !important;
  box-shadow: none !important;
}
@media (hover: none), (pointer: coarse) {
  .kd-item .kd-act-force-close {
    opacity: 0.55;
    pointer-events: auto;
  }
}

@media (hover: none) {
  .kd-msg-caret {
    opacity: 0.72;
    pointer-events: auto;
    background: transparent;
    box-shadow: none;
  }
  .kd-msg:hover .kd-msg-caret,
  .kd-msg:focus-within .kd-msg-caret {
    opacity: 1;
  }
}
.kd-msg.inbound {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.kd-msg.outbound {
  align-self: flex-end;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 18%, transparent);
  border-bottom-right-radius: 4px;
}
.kd-msg.system {
  align-self: center;
  display: block;
  width: auto;
  max-width: 90%;
  font-size: 0.85em;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  padding: 4px 8px;
  text-align: center;
  cursor: default;
}
.kd-msg-name {
  font-size: 0.75em;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
  line-height: 1.2;
}
.kd-msg-body {
  font-size: 1em;
  font-family: var(--kd-user-font, var(--font)), "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
  color: inherit;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.kd-msg.is-emoji-heavy .kd-msg-body {
  font-size: 2.2em;
  line-height: 1.2;
  letter-spacing: 0.02em;
}
.kd-msg.is-emoji-heavy .kd-msg-name {
  margin-bottom: 4px;
}
.kd-msg-body strong {
  font-weight: 700;
}
.kd-msg-body em {
  font-style: italic;
}
.kd-msg-body s {
  text-decoration: line-through;
}
.kd-msg-body code,
.kd-mono-block {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  border-radius: 4px;
  padding: 0 4px;
}
.kd-bot-typing .kd-msg-body {
  padding: 2px 0;
}
.kd-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 1em;
}
.kd-typing-dots i {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted, #888);
  animation: kd-typing-bounce 1.2s infinite ease-in-out;
}
.kd-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.kd-typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes kd-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-3px); opacity: 1; }
}
.kd-msg-quote {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  cursor: pointer;
  border: 0;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  border-radius: 0 8px 8px 0;
  padding: 6px 8px;
  margin: 0 0 6px;
  max-width: 100%;
  box-sizing: border-box;
  color: inherit;
}
.kd-msg.outbound .kd-msg-quote {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface));
}
.kd-msg-quote:hover {
  filter: brightness(0.97);
}
.kd-msg-quote-name {
  font-size: 0.8em;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 2px;
  line-height: 1.2;
}
.kd-msg-quote-body {
  font-size: 0.88em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.kd-msg.is-flash {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  transition: outline-color .2s ease;
}
.kd-msg-menu {
  position: fixed;
  z-index: 80;
  min-width: 160px;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow), 0 8px 24px rgba(0, 0, 0, 0.12);
  font-family: var(--kd-user-font, var(--font));
  font-size: var(--kd-user-font-size, 15px);
}
.kd-msg-menu[hidden] {
  display: none !important;
}
.kd-msg-menu.is-emoji-expanded {
  min-width: min(340px, calc(100vw - 16px));
  width: min(340px, calc(100vw - 16px));
  padding: 0;
  overflow: hidden;
}
.kd-msg-menu-main[hidden],
.kd-msg-menu-emoji[hidden] {
  display: none !important;
}
.kd-msg-menu-emoji-picker {
  position: static !important;
  inset: auto !important;
  left: auto !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  width: 100% !important;
  max-height: min(360px, 70vh);
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  z-index: auto !important;
}
.kd-msg-menu-react {
  display: flex;
  gap: 2px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.kd-msg-menu-react[hidden] {
  display: none !important;
}
.kd-msg-react-pick,
.kd-msg-react-more {
  width: 32px !important;
  min-width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  margin: 0 !important;
  font-size: 18px;
  line-height: 1;
  justify-content: center !important;
  align-items: center !important;
  border: 0 !important;
  border-radius: 8px !important;
  background: transparent !important;
  box-shadow: none !important;
}
.kd-msg-react-more {
  color: var(--text-muted) !important;
  font-weight: 500;
  font-size: 20px !important;
}
.kd-msg-react-pick:hover,
.kd-msg-react-more:hover,
.kd-msg-react-pick:focus,
.kd-msg-react-more:focus {
  background: transparent !important;
  color: inherit !important;
}
.kd-msg-react-more:hover,
.kd-msg-react-more:focus {
  color: var(--text-muted) !important;
}
.kd-msg.has-reactions {
  margin-bottom: 10px;
  padding-bottom: 14px;
}
.kd-msg-reactions {
  position: absolute;
  bottom: -10px;
  left: 10px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 0;
  max-width: calc(100% - 16px);
  pointer-events: none;
}
.kd-msg.outbound .kd-msg-reactions {
  left: auto;
  right: 10px;
}
.kd-msg-reaction {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px color-mix(in srgb, var(--text) 12%, transparent);
  font-size: 13px;
  line-height: 1.3;
  pointer-events: auto;
}
.kd-msg-reaction small {
  font-size: 10px;
  opacity: 0.7;
}
.kd-msg.outbound .kd-msg-reaction {
  background: color-mix(in srgb, var(--accent, #0f7a5a) 12%, var(--surface));
}
.kd-msg.outbound.is-continued {
  margin-top: 1px;
}
.kd-msg:not(.is-continued) {
  margin-top: 8px;
}
.kd-msg:first-child {
  margin-top: 0;
}
.kd-msg-menu-main > button {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--kd-user-text, var(--text));
  font: inherit;
  font-size: 0.9em;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.kd-msg-menu-main > button[hidden] {
  display: none !important;
}
.kd-msg-menu-main > button:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
}
.kd-msg-menu-main > button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}
.kd-msg-foot {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 4px;
  font-size: 0.72em;
  line-height: 1.2;
  color: var(--text-muted);
  align-self: flex-end;
  white-space: nowrap;
}
.kd-msg.outbound .kd-msg-foot {
  color: color-mix(in srgb, var(--text-muted) 80%, var(--accent));
}
.kd-msg-ticks {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 14px;
  opacity: 0.75;
  flex: 0 0 auto;
}
.kd-msg-ticks svg {
  width: 14px;
  height: 14px;
  display: block;
}
.kd-msg-ticks.is-delivered svg,
.kd-msg-ticks.is-read svg {
  width: 16px;
}
.kd-msg-ticks.is-read {
  color: #53bdeb;
  opacity: 1;
}
.kd-msg-ticks.is-pending {
  opacity: 0.65;
}
.kd-msg-ticks.is-fail {
  color: #b42318;
  font-weight: 700;
  opacity: 1;
  width: auto;
}
@keyframes kd-spin {
  to { transform: rotate(360deg); }
}
.kd-spin {
  animation: kd-spin 0.75s linear infinite;
  transform-origin: 50% 50%;
}

.kd-item-top {
  display: none;
}
.kd-wait {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0;
  border-radius: 0;
  background: transparent;
  opacity: 0.9;
  white-space: nowrap;
}
.kd-wait svg {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
}
.kd-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: #16a34a;
  color: #fff;
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
.kd-unread svg {
  width: 12px;
  height: 12px;
}
.kd-unread-count {
  background: #16a34a;
  color: #fff;
}
.kd-has-unread {
  font-weight: 700;
}
.kd-item.is-unread {
  background: color-mix(in srgb, #16a34a 7%, var(--surface));
  box-shadow: inset 2.5px 0 0 color-mix(in srgb, #16a34a 75%, transparent);
}
.kd-item.is-unread.is-active {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  box-shadow: none;
  border-left-color: var(--accent);
}

.kd-attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 2px 8px;
  max-height: 140px;
  overflow-y: auto;
}
.kd-attach-preview[hidden] {
  display: none !important;
}
.kd-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 6px 8px 6px 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 6%, transparent);
  position: relative;
}
.kd-attach-chip.is-thumb {
  padding: 0;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
}
.kd-attach-chip.is-thumb .kd-attach-thumb {
  width: 100%;
  height: 100%;
  border-radius: 0;
}
.kd-attach-chip.is-thumb .kd-attach-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  opacity: 1;
}
.kd-attach-thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--bg);
}
.kd-attach-file-ico {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  flex: 0 0 auto;
  font-size: 16px;
}
.kd-attach-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kd-attach-remove {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex: 0 0 auto;
  opacity: 0.72;
  line-height: 0;
}
.kd-attach-remove svg {
  display: block;
  width: 12px;
  height: 12px;
}
.kd-msg-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.kd-msg-ava {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
}
.kd-msg-ava.is-letter,
.kd-msg-ava.is-bot {
  display: inline-grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}
.kd-msg-ava.is-bot { font-size: 12px; }
.kd-msg.has-media {
  padding: 5px;
  max-width: min(72%, 300px);
}
.kd-msg.has-media:not(.is-sticker-msg):not(.is-audio-msg) {
  min-width: min(200px, 72%);
}
.kd-msg.has-media .kd-msg-name,
.kd-msg.has-media .kd-msg-head {
  padding: 2px 6px 0;
}
.kd-msg.has-media .kd-msg-body {
  padding: 6px 8px 2px;
}
.kd-msg.has-media .kd-msg-foot {
  padding: 0 8px 4px;
}
.kd-msg-media-grid {
  display: grid;
  gap: 3px;
  grid-template-columns: 1fr;
}
.kd-msg-media-grid:has(.kd-msg-image:nth-child(2)) {
  grid-template-columns: 1fr 1fr;
}
.kd-msg-media-grid:has(.kd-msg-image:only-child),
.kd-msg-media-grid:has(.kd-msg-file:only-child) {
  grid-template-columns: 1fr;
}
button.kd-msg-media {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  text-align: left;
  line-height: 0;
  max-width: 100%;
  overflow: hidden;
  border-radius: 10px;
}
.kd-msg-media.kd-msg-image:not(.is-sticker) {
  display: block;
  width: 100%;
  min-height: 148px;
  background:
    linear-gradient(110deg,
      color-mix(in srgb, var(--text-muted) 8%, transparent) 25%,
      color-mix(in srgb, var(--text-muted) 14%, transparent) 37%,
      color-mix(in srgb, var(--text-muted) 8%, transparent) 63%);
  background-size: 200% 100%;
  animation: kd-media-shimmer 1.1s ease-in-out infinite;
}
.kd-msg-media.kd-msg-image.is-pending {
  min-height: 168px;
  border-radius: 10px;
  cursor: default;
}
.kd-msg-media.kd-msg-image.is-pending.is-sticker {
  min-width: 112px;
  min-height: 112px;
  animation: kd-media-shimmer 1.1s ease-in-out infinite;
  background:
    linear-gradient(110deg,
      color-mix(in srgb, var(--text-muted) 8%, transparent) 25%,
      color-mix(in srgb, var(--text-muted) 14%, transparent) 37%,
      color-mix(in srgb, var(--text-muted) 8%, transparent) 63%);
  background-size: 200% 100%;
}
.kd-msg-media.kd-msg-image.is-loaded,
.kd-msg-media.kd-msg-image.is-gif.is-loaded {
  min-height: 0;
  background: transparent;
  animation: none;
}
@keyframes kd-media-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.kd-msg-media img {
  width: 100%;
  height: auto;
  max-height: 280px;
  object-fit: cover;
  display: block;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s ease;
}
.kd-msg-media.is-loaded img,
.kd-msg-media.is-sticker img {
  opacity: 1;
}
.kd-msg-media-grid:has(.kd-msg-image:only-child) .kd-msg-media img {
  width: 100%;
  max-width: min(280px, 70vw);
  object-fit: contain;
  border-radius: 10px;
}
.kd-msg-media.is-sticker {
  cursor: zoom-in;
  background: transparent;
  border-radius: 0;
  overflow: visible;
  max-width: 112px;
}
.kd-msg-media.is-sticker img {
  width: 112px !important;
  max-width: 112px !important;
  max-height: 112px !important;
  height: auto !important;
  object-fit: contain;
  border-radius: 0;
  background: transparent;
}
.kd-msg-media.is-gif img {
  width: auto !important;
  max-width: min(200px, 55vw) !important;
  max-height: 200px !important;
  object-fit: contain;
  border-radius: 10px;
}
.kd-msg-video {
  display: block;
  max-width: 100%;
  line-height: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}
.kd-msg-video video {
  display: block;
  width: auto;
  max-width: min(280px, 70vw);
  max-height: 280px;
  height: auto;
  border-radius: 10px;
}
.kd-msg-video.is-gif {
  background: transparent;
}
.kd-msg-video.is-gif video {
  max-width: min(200px, 55vw);
  max-height: 200px;
  background: transparent;
}
.kd-msg.is-sticker-msg {
  max-width: fit-content;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 2px 4px;
}
.kd-msg.is-sticker-msg .kd-msg-media-grid {
  display: block;
  width: fit-content;
}
.kd-msg.is-sticker-msg:hover {
  box-shadow: none;
}
.kd-msg.is-sticker-msg .kd-msg-foot {
  padding: 0 4px;
}
.kd-msg.is-sticker-msg .kd-msg-head,
.kd-msg.is-sticker-msg .kd-msg-name {
  padding: 0 4px 2px;
}
.kd-msg-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--text-muted) 10%, transparent);
  text-decoration: none;
  color: inherit;
  font-size: 13px;
}
.kd-msg.is-audio-msg {
  max-width: min(78%, 320px);
  padding: 8px 10px 6px;
}
.kd-msg.is-audio-msg .kd-msg-media-grid {
  display: block;
}
.kd-audio {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  max-width: 280px;
  padding: 2px 0;
  user-select: none;
}
.kd-audio audio {
  display: none;
}
.kd-audio-play {
  appearance: none;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  color: var(--accent);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.kd-msg.outbound .kd-audio-play {
  background: color-mix(in srgb, #fff 18%, transparent);
  color: inherit;
}
.kd-audio-play svg {
  width: 16px;
  height: 16px;
  display: block;
}
.kd-audio-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kd-audio-wave {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 28px;
  overflow: hidden;
}
.kd-audio-wave::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--progress, 0%);
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  pointer-events: none;
  border-radius: 2px;
}
.kd-msg.outbound .kd-audio-wave::after {
  background: color-mix(in srgb, #fff 28%, transparent);
}
.kd-audio-wave i {
  flex: 1 1 0;
  height: var(--h, 40%);
  min-width: 2px;
  border-radius: 1px;
  background: color-mix(in srgb, var(--text-muted) 55%, transparent);
  opacity: 0.85;
}
.kd-msg.outbound .kd-audio-wave i {
  background: color-mix(in srgb, currentColor 45%, transparent);
}
.kd-audio-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.kd-audio-time {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.kd-msg.outbound .kd-audio-time {
  color: color-mix(in srgb, var(--text-muted) 70%, currentColor);
}
.kd-audio-rate {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.kd-msg.outbound .kd-audio-rate {
  color: inherit;
  opacity: 0.9;
}
/* Barra de gravação estilo WhatsApp (pausar / ouvir / continuar / excluir) */
.kd-voice-rec-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 4px;
  margin-bottom: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 10%, var(--surface));
  border: 1px solid var(--border);
  min-height: 44px;
}
.kd-voice-rec-bar[hidden] {
  display: none !important;
}
.kd-voice-rec-bar > #kd-voice-trash { order: 1; }
.kd-voice-rec-bar > #kd-voice-play { order: 2; }
.kd-voice-rec-bar > #kd-voice-dot { order: 3; }
.kd-voice-rec-bar > #kd-voice-rec-time { order: 4; }
.kd-voice-rec-bar > #kd-voice-wave { order: 5; }
.kd-voice-rec-bar > #kd-voice-pause,
.kd-voice-rec-bar > #kd-voice-resume { order: 6; }
.kd-voice-rec-bar > #kd-voice-rec-send { order: 7; }
.kd-voice-rec-bar.is-paused > #kd-voice-wave { order: 4; }
.kd-voice-rec-bar.is-paused > #kd-voice-rec-time { order: 5; }
.kd-voice-icon-btn {
  appearance: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
  padding: 0;
  transition: color 0.12s ease, background 0.12s ease;
}
.kd-voice-icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}
.kd-voice-icon-btn:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text-muted) 12%, transparent);
}
.kd-voice-icon-btn.is-danger {
  color: #dc2626;
}
.kd-voice-icon-btn.is-danger:hover {
  background: color-mix(in srgb, #dc2626 12%, transparent);
  color: #b91c1c;
}
.kd-voice-icon-btn.is-pause {
  color: #dc2626;
}
.kd-voice-icon-btn.is-pause:hover {
  background: color-mix(in srgb, #dc2626 12%, transparent);
}
.kd-voice-icon-btn.is-mic {
  color: #dc2626;
}
.kd-voice-icon-btn.is-mic:hover {
  background: color-mix(in srgb, #dc2626 12%, transparent);
}
.kd-voice-icon-btn.is-playing {
  color: var(--accent);
}
.kd-voice-icon-btn[hidden] {
  display: none !important;
}
.kd-voice-rec-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #dc2626;
  flex: 0 0 auto;
  animation: kd-voice-pulse 1s ease-in-out infinite;
}
.kd-voice-rec-dot.is-paused {
  background: #22c55e;
  animation: none;
}
@keyframes kd-voice-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}
.kd-voice-rec-time {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  flex: 0 0 auto;
  min-width: 2.6em;
}
.kd-voice-wave {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  height: 26px;
  min-width: 72px;
  max-width: 100%;
  padding: 0 4px;
}
.kd-voice-wave i {
  display: block;
  flex: 1 1 0;
  max-width: 3px;
  height: 100%;
  border-radius: 2px;
  background: color-mix(in srgb, var(--text-muted) 55%, transparent);
  transform: scaleY(0.18);
  transform-origin: center;
  transition: transform 0.08s linear;
}
.kd-voice-rec-bar.is-paused .kd-voice-wave i {
  background: color-mix(in srgb, var(--text-muted) 45%, transparent);
}
.kd-voice-send-btn {
  appearance: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast, #fff);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
  padding: 0;
  transition: filter 0.12s ease, transform 0.12s ease;
}
.kd-voice-send-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}
.kd-voice-send-btn:hover {
  filter: brightness(1.06);
}
.kd-voice-send-btn:active {
  transform: scale(0.96);
}
#btn-composer-mic[hidden] {
  display: none !important;
}
#btn-composer-mic.is-recording {
  color: #dc2626;
}
.kd-attach-chip.is-audio .kd-attach-file-ico {
  background: color-mix(in srgb, var(--accent) 14%, var(--bg));
}
.kd-media-lightbox {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.88);
  padding: 0;
  overscroll-behavior: contain;
}
.kd-media-lightbox[hidden] { display: none !important; }
.kd-media-lightbox-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.45);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  z-index: 5;
  pointer-events: auto;
}
.kd-media-lightbox-toolbar-spacer { flex: 1 1 auto; pointer-events: none; }
.kd-media-lightbox-tool,
.kd-media-lightbox-close {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
  position: relative;
  z-index: 6;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}
.kd-media-lightbox-tool:hover,
.kd-media-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.24);
}
.kd-media-lightbox-zoom-label {
  width: auto;
  min-width: 64px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.kd-media-lightbox-close svg {
  display: block;
  width: 18px;
  height: 18px;
}
.kd-media-lightbox-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 16px;
  cursor: zoom-out;
  -webkit-overflow-scrolling: touch;
}
.kd-media-lightbox-stage img {
  max-width: min(960px, 100%);
  max-height: calc(100vh - 88px);
  width: auto;
  height: auto;
  border-radius: 10px;
  transform-origin: center center;
  transition: transform 0.15s ease;
  cursor: default;
  user-select: none;
  -webkit-user-drag: none;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
body.kd-lightbox-open {
  overflow: hidden;
}

.kd-proto-filters {
  display: grid;
  gap: 14px;
  margin-bottom: 4px;
}
.kd-proto-filters .kd-proto-q input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  box-sizing: border-box;
}
.kd-proto-filter-row {
  grid-template-columns: 1.2fr 1fr 0.9fr 0.9fr;
  gap: 12px;
}
.kd-proto-filter-row label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 0;
}
.kd-proto-filter-row select,
.kd-proto-filter-row input[type="date"] {
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  box-sizing: border-box;
}
@media (max-width: 900px) {
  .kd-proto-filter-row {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 560px) {
  .kd-proto-filter-row {
    grid-template-columns: 1fr;
  }
}
.kd-proto-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.kd-proto-results > .kd-meta {
  margin-bottom: 4px;
}
.kd-proto-results #proto-more {
  align-self: flex-start;
  margin-top: 4px;
}
.kd-proto-detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.kd-proto-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.kd-proto-row:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.kd-proto-detail {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--text-muted) 4%, var(--surface));
}
.kd-proto-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0;
  max-height: 420px;
  overflow: auto;
}
.kd-proto-msg {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
}
.kd-admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}
.kd-admin-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}
.kd-admin-filters input,
.kd-admin-filters select {
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

.kd-closed-tools {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  padding: 0.35em 0.75em 0.7em;
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.kd-closed-tools[hidden] { display: none !important; }
.kd-outbound-tabs {
  display: flex;
  gap: 0.4em;
  margin: 0.35em 0 0.65em;
}
.kd-outbound-tabs .is-active {
  border-color: var(--accent);
  color: var(--accent);
}
.kd-agenda-tools {
  margin-bottom: 0.75em;
}
.kd-agenda-tools select {
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  min-width: 220px;
}
.kd-agenda-pick {
  max-height: 220px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  margin-top: 0.35em;
}
.kd-agenda-pick-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1em;
  text-align: left;
  padding: 0.55em 0.65em;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.kd-agenda-pick-item:hover {
  border-color: var(--accent);
}
.kd-agenda-pick-item.is-selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}
.kd-agenda-pick-item span {
  font-size: 0.88em;
  color: var(--muted, #667);
}
.kd-closed-search {
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  overflow: hidden;
  transition: border-color var(--ease);
}
.kd-closed-search:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.kd-closed-dept {
  width: 100%;
  min-height: 32px;
  padding: 0.3em 0.55em;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.84em;
  color-scheme: inherit;
}
.kd-closed-dept:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.kd-closed-search .kd-closed-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  min-height: 34px;
  padding: 0.4em 0.65em;
}
.kd-closed-search .kd-closed-input:focus {
  outline: none;
}
.kd-closed-go {
  appearance: none;
  flex: 0 0 auto;
  width: 34px;
  border: 0;
  border-left: 1px solid var(--border-soft, var(--border));
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--ease), background var(--ease);
}
.kd-closed-go:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.kd-closed-go svg {
  width: 15px;
  height: 15px;
}
.kd-closed-input {
  width: 100%;
  min-height: 34px;
  padding: 0.35em 0.55em;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.84em;
}
.kd-closed-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45em;
}
.kd-closed-date {
  display: flex;
  flex-direction: column;
  gap: 0.2em;
  min-width: 0;
  font-size: 0.72em;
  font-weight: 550;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}
.kd-closed-date input[type="date"] {
  width: 100%;
  min-height: 32px;
  padding: 0.3em 0.45em;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.92em;
  font-weight: 400;
  letter-spacing: 0;
}
.kd-closed-date input[type="date"]:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.kd-closed-more {
  display: flex;
  justify-content: center;
  padding: 0.75em 0.85em 1em;
  border-bottom: 0;
}
.kd-closed-more-btn {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.82em;
  font-weight: 550;
  padding: 0.45em 1em;
  min-height: 32px;
  cursor: pointer;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
}
.kd-closed-more-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}
.kd-closed-more-btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.kd-btn-sm {
  min-height: var(--kd-nav-min-h, 34px);
  padding: 0.4em 0.65em;
  font-size: 0.87em;
}
.kd-chat-admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 22px;
  align-items: start;
}
@media (max-width: 980px) {
  .kd-chat-admin-grid { grid-template-columns: 1fr; }
}
.kd-head-sub {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  max-width: 42rem;
  line-height: 1.4;
}
.kd-cw-form {
  display: grid;
  gap: 14px;
  margin: 0;
  max-width: none;
  width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
}
.kd-cw-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  padding: 16px 0 18px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-soft, var(--border));
  border-radius: 0;
}
.kd-cw-card:last-of-type { border-bottom: 0; }
.kd-cw-step {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  flex: 0 0 auto;
  margin-top: 2px;
}
.kd-cw-card-body {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.kd-cw-card-body h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.kd-cw-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.kd-cw-form input,
.kd-cw-form select,
.kd-cw-form textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.kd-cw-form textarea { min-height: 88px; resize: vertical; }
.kd-cw-form .kd-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.kd-cw-form .kd-check input { width: auto; min-height: 0; }
.kd-cw-colors {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.kd-cw-colors-2 { grid-template-columns: 1fr 1fr; }
.kd-cw-colors-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .kd-cw-colors-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .kd-cw-colors,
  .kd-cw-colors-2,
  .kd-cw-colors-4 { grid-template-columns: 1fr; }
}
.kd-cw-swatch {
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}
.kd-cw-swatch input[type="color"] {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.kd-cw-more {
  margin-top: 4px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}
.kd-cw-more summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  user-select: none;
}
.kd-cw-more[open] summary { margin-bottom: 10px; }
.kd-cw-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.kd-cw-savebar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px 0 4px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.kd-btn-lg {
  min-height: 44px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 800;
}
.kd-cw-preview-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 800;
}
.kd-chat-admin-side {
  position: sticky;
  top: 8px;
}
.kd-cw-stage {
  position: relative;
  margin-top: 10px;
  padding: 18px 16px 72px;
  min-height: 420px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background:
    radial-gradient(ellipse 70% 50% at 80% 20%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%),
    color-mix(in srgb, var(--text) 4%, var(--bg));
}
.kd-cw-phone {
  max-width: 320px;
  margin: 0 auto;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  min-height: 360px;
}
.kd-cw-phone-header {
  padding: 14px 16px 12px;
  display: grid;
  gap: 2px;
}
.kd-cw-phone-header strong {
  font-size: 15px;
  font-weight: 800;
}
.kd-cw-phone-header span {
  font-size: 12px;
  opacity: 0.85;
}
.kd-cw-phone-msgs {
  flex: 1;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 220px;
}
.kd-cw-bubble {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.kd-cw-radios {
  display: grid;
  gap: 10px;
  margin: 4px 0 8px;
  border: 0;
  padding: 0;
}
.kd-cw-radio {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--border-soft, var(--border));
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}
.kd-cw-radio:last-child { border-bottom: 0; }
.kd-cw-radio:has(input:checked) {
  border-color: var(--border-soft, var(--border));
  background: transparent;
}
.kd-cw-radio:has(input:checked) strong { color: var(--accent); }
.kd-cw-radio input {
  width: auto;
  min-height: 0;
  margin-top: 3px;
}
.kd-cw-radio span {
  display: grid;
  gap: 4px;
}
.kd-cw-radio strong {
  font-size: 14px;
}
.kd-cw-radio small {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}
.kd-cw-welcome-fields {
  display: grid;
  gap: 10px;
}
.kd-cw-bubble.agent {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.kd-cw-bubble-ava {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
}
.kd-dropzone {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 120px;
  border: 1px dashed color-mix(in srgb, var(--border) 88%, var(--accent));
  border-radius: 14px;
  background:
    linear-gradient(
      165deg,
      color-mix(in srgb, var(--accent) 5%, var(--surface)) 0%,
      var(--surface) 55%
    );
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  outline: none;
  box-sizing: border-box;
  overflow: hidden;
}
.kd-dropzone:hover,
.kd-dropzone:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}
.kd-dropzone.is-drag,
.kd-dropzone.is-drag-available {
  border-color: var(--accent);
  border-style: solid;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.kd-dropzone.is-compact {
  min-height: 100px;
  border-radius: 12px;
}
.kd-dropzone.has-file {
  border-style: solid;
  border-color: var(--border);
}
.kd-dropzone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 18px 18px;
  min-height: inherit;
  box-sizing: border-box;
  text-align: center;
}
.kd-dropzone-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  color: color-mix(in srgb, var(--accent) 72%, var(--text-muted));
}
.kd-dropzone-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}
.kd-dropzone-thumb {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  overflow: hidden;
  flex: 0 0 auto;
  background: var(--bg);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: color-mix(in srgb, var(--accent) 72%, var(--text-muted));
}
.kd-dropzone-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.kd-dropzone-thumb.is-contain img {
  object-fit: contain;
  padding: 6px;
}
.kd-dropzone-thumb.is-favicon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}
.kd-dropzone-thumb.is-audio {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}
.kd-dropzone-thumb.is-audio svg {
  width: 22px;
  height: 22px;
  display: block;
}
.kd-dropzone-text {
  display: grid;
  gap: 3px;
  min-width: 0;
  width: 100%;
  justify-items: center;
  text-align: center;
}
.kd-dropzone-title {
  margin: 0;
  font-size: 0.9em;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--kd-user-text, var(--text));
}
.kd-dropzone-sub {
  font-size: 0.82em;
  font-weight: 500;
  color: var(--text-muted);
}
.kd-dropzone-hint {
  margin-top: 2px;
  font-size: 0.78em;
  color: color-mix(in srgb, var(--text-muted) 88%, transparent);
}
.kd-upload-field {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}
.kd-sound-row {
  display: grid;
  gap: 10px;
  padding-top: 6px;
}
.kd-sound-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
body.kd-is-dragging-file .kd-drop-overlay {
  display: grid;
}
.kd-drop-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 12000;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(2px);
  pointer-events: none;
}
.kd-drop-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 36px;
  border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--text-muted);
  box-shadow: 0 18px 50px color-mix(in srgb, #000 22%, transparent);
}
.kd-drop-overlay-card p {
  margin: 0;
  font-size: 0.92em;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--kd-user-text, var(--text));
}
.kd-cw-upload {
  display: grid;
  gap: 10px;
}
.kd-cw-upload-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--kd-user-text, var(--text));
  letter-spacing: -0.01em;
}
.kd-cw-upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.kd-cw-thumb {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg);
}
.kd-cw-thumb-sm {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}
.kd-cw-bubble.visitor { align-self: flex-end; border-bottom-right-radius: 4px; }
.kd-cw-bubble-name {
  display: block;
  font-size: 11px;
  font-weight: 800;
  opacity: 0.75;
  margin-bottom: 2px;
}
.kd-cw-phone-composer {
  padding: 12px 14px;
  border-top: 1px solid #e2e8f0;
  color: #94a3b8;
  font-size: 13px;
  background: #fff;
}
.kd-cw-fab {
  position: absolute;
  bottom: 16px;
  z-index: 2;
  min-width: 52px;
  height: 52px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  font: 700 13px/1.2 system-ui, sans-serif;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
  pointer-events: none;
}
.kd-cw-fab.is-right { right: 16px; }
.kd-cw-fab.is-left { left: 16px; right: auto; }
.kd-cw-fab.is-icon-only { width: 52px; padding: 0; }
.kd-cw-fab svg { width: 20px; height: 20px; fill: currentColor; flex: 0 0 auto; }
.kd-cw-fab img { width: 20px; height: 20px; object-fit: contain; border-radius: 4px; }
.kd-cw-fab-label { white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.kd-chat-preview-frame {
  width: 100%;
  height: 520px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
}
.kd-pending-avatar-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.kd-pending-avatar-row img,
.kd-pending-ava-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  object-fit: cover;
  flex: 0 0 auto;
  background: color-mix(in srgb, var(--text-muted) 12%, transparent);
}
.kd-pending-avatar-info {
  flex: 1;
  min-width: 0;
}
.kd-pending-avatar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.kd-avatar-upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}
.kd-profile-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.kd-profile-ava {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  overflow: hidden;
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 22px;
  color: var(--accent);
}
.kd-profile-ava img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.kd-profile-name {
  font-weight: 700;
  font-size: 16px;
}
.kd-profile-status {
  margin: 0 0 12px;
}
.kd-profile-pending-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0 14px;
  margin-bottom: 4px;
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid var(--border-soft, var(--border));
  background: transparent;
}
.kd-profile-pending-ico {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--accent);
  flex: 0 0 auto;
}
.kd-profile-pending-ico svg {
  width: 20px;
  height: 20px;
}
.kd-user-name-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.kd-profile-alert {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: var(--accent);
}
.kd-profile-alert svg {
  width: 16px;
  height: 16px;
}
.kd-profile-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.kd-profile-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}
.kd-table tr.has-profile-pending td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}
.kd-profile-review-cell {
  white-space: nowrap;
}
.kd-profile-review-btn {
  white-space: nowrap;
}
.kd-profile-review-block {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.kd-profile-review-block h4 {
  margin: 0 0 8px;
  font-size: 14px;
}
.kd-profile-review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.kd-profile-review-photos {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}
.kd-composer {
  margin: 0 clamp(12px, 2.5vw, 22px) clamp(12px, 2vw, 18px);
  padding: 14px 16px 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 18px;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 4%, transparent);
  flex: 0 0 auto;
  font-family: var(--kd-user-font, var(--font));
  font-size: var(--kd-user-font-size, 15px);
  color: var(--kd-user-text, var(--text));
}
.kd-composer[hidden] {
  display: none !important;
}
.kd-composer.is-sending #btn-composer-send:disabled,
.kd-composer.is-sending #kd-team-send:disabled {
  cursor: wait;
  opacity: 0.65;
}
.kd-msg.is-sending {
  opacity: 0.92;
}
.kd-msg.is-sending .kd-msg-media.kd-msg-image {
  animation: none;
  background: transparent;
  min-height: 0;
}
.kd-msg.is-sending .kd-msg-media img {
  opacity: 1;
}
.kd-reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
}
.kd-reply-bar[hidden] {
  display: none !important;
}
.kd-reply-bar-main {
  flex: 1;
  min-width: 0;
}
.kd-reply-bar-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}
.kd-reply-bar-text {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kd-reply-bar .kd-icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
}
.kd-composer-field {
  min-width: 0;
}
.kd-composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 2px;
}
.kd-composer-tools {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
}
.kd-char-count {
  flex: 0 1 auto;
  margin-left: auto;
  margin-right: 6px;
  text-align: right;
  font-size: 11px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  opacity: 0.42;
  line-height: 1;
  padding: 0 2px;
  pointer-events: none;
  user-select: none;
  min-width: 1.25em;
  transition: opacity 0.15s ease, color 0.15s ease;
}
.kd-char-count[hidden] {
  display: none !important;
}
.kd-char-count.is-warn {
  opacity: 0.85;
  color: #b45309;
}
.kd-modal-actions .kd-char-count {
  margin-right: auto;
  margin-left: 0;
  text-align: left;
}
.kd-format-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 2px 0;
}
.kd-format-btn {
  appearance: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  opacity: 0.72;
  transition: opacity 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.kd-format-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}
.kd-format-btn:hover,
.kd-format-btn.is-active {
  opacity: 1;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, transparent);
}
.kd-format-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.kd-emoji-picker {
  position: fixed;
  z-index: 10050;
  width: min(340px, calc(100vw - 16px));
  max-height: min(380px, 70vh);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  min-height: 0;
}
.kd-emoji-cats {
  display: flex;
  gap: 2px;
  padding: 8px 8px 6px;
  border-bottom: 1px solid var(--border-soft, var(--border));
  overflow-x: auto;
  flex: 0 0 auto;
}
.kd-emoji-cat {
  appearance: none;
  border: 0;
  background: transparent;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
.kd-emoji-cat:hover,
.kd-emoji-cat.is-active {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}
.kd-emoji-label {
  padding: 6px 12px 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  flex: 0 0 auto;
}
.kd-emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 6px 8px 10px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.kd-emoji-item {
  appearance: none;
  border: 0;
  background: transparent;
  border-radius: 8px;
  font-size: 22px;
  line-height: 1.2;
  padding: 6px 0;
  cursor: pointer;
  font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
}
.kd-emoji-item:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}
.kd-composer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.kd-composer-mic {
  appearance: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 8%, transparent);
  color: var(--text-muted);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}
.kd-composer-mic svg {
  width: 18px;
  height: 18px;
  display: block;
}
.kd-composer-mic:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text-muted) 14%, transparent);
}
.kd-composer-mic:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.kd-composer-mic.is-recording,
#btn-composer-mic.is-recording {
  color: #dc2626;
  background: color-mix(in srgb, #dc2626 12%, transparent);
}
.kd-composer-send {
  appearance: none;
  border: 0;
  border-radius: 999px;
  min-height: 42px;
  padding: 0 16px 0 14px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
  font: inherit;
  font-size: 0.92em;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 0 0 auto;
  transition: filter 0.12s ease, transform 0.12s ease, opacity 0.12s ease;
  box-shadow: none;
}
.kd-composer-send svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}
.kd-composer-send:hover {
  filter: brightness(1.05);
}
.kd-composer-send:active {
  transform: translateY(1px);
}
.kd-composer-send:disabled {
  opacity: 0.65;
  cursor: wait;
}
.kd-composer-expand-btn {
  flex: 0 0 auto;
}
.kd-composer-input {
  min-width: 0;
  width: 100%;
  min-height: 72px;
  max-height: 180px;
  overflow: auto;
  border: 0;
  border-radius: 0;
  padding: 4px 2px 8px;
  background: transparent;
  color: var(--kd-user-text, var(--text));
  font: inherit;
  font-family: var(--kd-user-font, var(--font)), "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
  box-shadow: none;
}
.kd-composer-expand-backdrop {
  background: rgba(15, 23, 20, 0.52);
  z-index: 95;
}
.kd-composer-expand-modal {
  width: min(720px, 100%);
  max-height: min(92dvh, 900px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 45% at 85% 0%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
    var(--bg);
  border: 1px solid var(--border);
}
.kd-composer-expand-modal .kd-modal-head {
  margin: 0;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.kd-composer-expand-shell {
  margin: 14px clamp(12px, 2.5vw, 18px) clamp(12px, 2vw, 18px);
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.kd-composer-expand-shell .kd-composer-field {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.kd-composer-expand-input {
  flex: 1 1 auto;
  min-height: min(42vh, 320px);
  max-height: none;
  height: auto;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 4px 2px 8px;
  background: transparent;
  overflow: auto;
}
.kd-composer-expand-shell .kd-composer-toolbar {
  flex-wrap: wrap;
}
.kd-composer-expand-shell .kd-composer-actions {
  flex-wrap: wrap;
  gap: 8px;
}
.kd-composer-input:focus {
  outline: none;
  box-shadow: none;
}
.kd-composer-input.is-empty:before {
  content: attr(data-placeholder);
  color: color-mix(in srgb, var(--text-muted) 88%, transparent);
  pointer-events: none;
}
.kd-composer-input b,
.kd-composer-input strong {
  font-weight: 700;
}
.kd-composer-input i,
.kd-composer-input em {
  font-style: italic;
}
.kd-composer-input s,
.kd-composer-input strike,
.kd-composer-input del {
  text-decoration: line-through;
}
.kd-composer-input code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  border-radius: 4px;
  padding: 0 4px;
}
.kd-btn {
  border: 0;
  border-radius: 10px;
  padding: 9px 16px;
  min-height: 38px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: filter var(--ease), background var(--ease), transform var(--ease);
  box-shadow: none;
}
.kd-btn svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}
.kd-btn:hover {
  filter: brightness(1.04);
}
.kd-btn:active {
  transform: translateY(1px);
}
.kd-btn.secondary {
  background: var(--surface);
  color: var(--kd-user-text, var(--text));
  border: 1px solid var(--border);
  filter: none;
}
.kd-btn.secondary:hover {
  background: var(--surface-2);
}
.kd-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.kd-icon-btn {
  appearance: none;
  width: var(--kd-icon-btn, 32px);
  height: var(--kd-icon-btn, 32px);
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: color var(--ease), background var(--ease), opacity var(--ease);
  opacity: 0.78;
}
.kd-icon-btn[hidden] {
  display: none !important;
}
.kd-icon-btn svg {
  width: var(--kd-icon-svg, 18px);
  height: var(--kd-icon-svg, 18px);
  display: block;
  flex-shrink: 0;
  overflow: visible;
}
.kd-icon-btn:hover,
.kd-more.is-open .kd-icon-btn {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  opacity: 1;
  border: 0;
}

.kd-more {
  position: relative;
  flex: 0 0 auto;
}
.kd-menu-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: min(220px, calc(100vw - 24px));
  padding: 6px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  z-index: 40;
  display: grid;
  gap: 2px;
}
.kd-menu-pop[hidden] {
  display: none !important;
}
.kd-menu-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  padding: 12px 10px;
  min-height: 44px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}
.kd-menu-item svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex: 0 0 auto;
}
.kd-menu-item:hover {
  background: var(--surface-2);
}
.kd-menu-item:hover svg {
  color: var(--accent);
}
.kd-menu-item.is-sound-on,
.kd-btn.is-sound-on {
  color: var(--accent);
}
.kd-menu-item.is-sound-on svg,
.kd-btn.is-sound-on svg {
  color: var(--accent);
}
.kd-sound-toast {
  position: fixed;
  z-index: 90;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
}
.kd-perm-steps {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}
.kd-perm-steps li {
  margin: 0 0 8px;
}
.kd-perm-steps code {
  font-size: 12px;
}
.kd-menu-danger {
  color: #c04444;
}
.kd-menu-danger svg {
  color: #c04444;
}
.kd-menu-sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--border);
}

.kd-admin-section-title {
  margin: 8px 0 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.7;
}

.kd-login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0));
  color: var(--kd-user-text, var(--text));
  font-family: var(--kd-user-font, var(--font));
  font-size: var(--kd-user-font-size, 15px);
  background:
    linear-gradient(
      165deg,
      color-mix(in srgb, var(--accent) 7%, var(--bg)) 0%,
      var(--bg) 48%,
      var(--bg) 100%
    );
  overflow: auto;
}
.kd-boot {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  color: var(--kd-user-text, var(--text));
  font-family: var(--kd-user-font, var(--font));
  font-size: var(--kd-user-font-size, 15px);
  background:
    linear-gradient(
      165deg,
      color-mix(in srgb, var(--accent) 7%, var(--bg)) 0%,
      var(--bg) 48%,
      var(--bg) 100%
    );
}
.kd-boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}
.kd-boot .kd-brand,
.kd-boot .kd-brand.has-logo {
  margin: 0;
}
.kd-boot .kd-brand-logo {
  max-height: 48px;
  max-width: 220px;
}
.kd-boot-track {
  width: 64px;
  height: 2px;
  border-radius: 1px;
  overflow: hidden;
  background: color-mix(in srgb, var(--accent) 16%, var(--border));
}
.kd-boot-fill {
  display: block;
  width: 36%;
  height: 100%;
  background: var(--accent);
  animation: kd-boot-slide 1.05s ease-in-out infinite;
}
@keyframes kd-boot-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(280%); }
}
@media (prefers-reduced-motion: reduce) {
  .kd-boot-fill {
    width: 100%;
    animation: none;
    opacity: 0.55;
  }
}
.kd-login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-soft, var(--border));
  border-radius: 20px;
  padding: 40px 32px 32px;
  box-shadow: none;
  color: var(--kd-user-text, var(--text));
}
.kd-login .kd-brand,
.kd-login-brand {
  text-align: center;
  font-size: 1.4em;
  font-weight: 700;
  letter-spacing: -0.045em;
  margin: 0 0 28px;
  color: var(--accent);
  white-space: normal;
  line-height: 1.15;
}
.kd-login .kd-brand.has-logo {
  justify-content: center;
  margin-bottom: 32px;
}
.kd-login .kd-brand-logo {
  max-height: 44px;
  max-width: 200px;
}
.kd-login-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.kd-turnstile {
  min-height: 65px;
  display: flex;
  justify-content: flex-start;
}
.kd-meta.kd-warn {
  color: #b45309;
}
.kd-login-card label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 0;
  font-size: 0.78em;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-muted);
}
.kd-login-card input {
  width: 100%;
  padding: 12px 14px;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--kd-user-text, var(--text));
  font: inherit;
  font-size: 0.98em;
  font-weight: 500;
  transition: border-color var(--ease), background var(--ease);
  box-shadow: none;
}
.kd-login-card input::placeholder {
  color: color-mix(in srgb, var(--text-muted) 70%, transparent);
  font-weight: 400;
}
.kd-login-card input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  background: var(--surface);
  box-shadow: none;
}
.kd-login-submit {
  width: 100%;
  margin-top: 22px;
  min-height: 46px;
  border-radius: 12px;
  font-size: 0.95em;
  letter-spacing: -0.01em;
}
.kd-login-submit.is-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  opacity: 0.88;
  cursor: wait;
  pointer-events: none;
}
.kd-login-spinner {
  width: 1em;
  height: 1em;
  border: 2px solid color-mix(in srgb, currentColor 28%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: kd-login-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes kd-login-spin {
  to { transform: rotate(360deg); }
}
.kd-login-status {
  margin: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88em;
  font-weight: 500;
}
.kd-login-card .kd-error {
  margin-top: 14px;
  text-align: center;
}

/* legado: kd-card só na tela de login */
.kd-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-soft, var(--border));
  border-radius: 20px;
  padding: 40px 32px 32px;
  box-shadow: none;
  color: var(--kd-user-text, var(--text));
}
.kd-error { color: var(--danger); font-size: 0.85em; margin-top: 10px; }

.kd-debug-body .kd-admin-block { max-width: min(960px, 100%); }
.kd-debug-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.kd-debug-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  background: var(--text-muted);
  vertical-align: middle;
}
.kd-debug-status-dot.on { background: var(--queue); }
.kd-debug-note {
  margin: 0;
  padding: 0;
  max-width: 640px;
  background: transparent;
  border-radius: 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}
.kd-cache-box {
  margin-top: 0;
}
.kd-cache-title {
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  text-transform: uppercase;
  color: var(--text);
}
.kd-cache-hist {
  margin-top: 10px;
  max-height: 140px;
  overflow: auto;
  border: 0;
  border-top: 1px solid var(--border-soft, var(--border));
  border-radius: 0;
  background: transparent;
  padding: 8px 0 0;
}
.kd-cache-hist-item {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.kd-cache-hist-item:last-child { border-bottom: 0; }

/* Admin: sidebar fixa + conteúdo ocupa o restante da viewport */
.kd-admin-shell {
  grid-template-columns: var(--kd-admin-sidebar-width, 260px) minmax(0, 1fr);
  width: 100%;
}
.kd-admin-shell .kd-sidebar {
  width: var(--kd-admin-sidebar-width, 260px);
  min-width: var(--kd-admin-sidebar-width, 260px);
  max-width: var(--kd-admin-sidebar-width, 260px);
  flex: 0 0 auto;
}
.kd-admin-shell .kd-admin-main {
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
}
.kd-admin-nav {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 6px 8px 12px;
  gap: 0;
  max-height: none;
  border-bottom: 0;
  min-height: 0;
}
.kd-admin-nav-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 0 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.kd-admin-nav-group + .kd-admin-nav-group {
  border-top: 1px solid var(--border-soft, var(--border));
  margin-top: 4px;
  padding-top: 12px;
}
.kd-admin-nav-label {
  padding: 0 10px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.55;
}
.kd-admin-nav-item {
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  padding: 7px 10px;
  min-height: 34px;
  font: inherit;
  font-weight: 500;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: color var(--ease), background var(--ease);
  box-shadow: none;
}
.kd-admin-nav-item svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  opacity: 0.55;
}
.kd-admin-nav-item span {
  min-width: 0;
  line-height: 1.25;
  flex: 1;
}
.kd-admin-nav-badge {
  flex: 0 0 auto;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  line-height: 1;
}
.kd-admin-nav-item:hover {
  background: transparent;
  color: var(--text);
}
.kd-admin-nav-item:hover svg { opacity: 0.9; }
.kd-admin-nav-item.is-active {
  color: var(--accent);
  background: transparent;
  font-weight: 600;
  box-shadow: none;
}
.kd-admin-nav-item.is-active svg {
  opacity: 1;
  color: var(--accent);
}
.kd-admin-hint {
  display: none;
}
.kd-mime-groups {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kd-mime-groups legend {
  padding: 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.kd-r2-cors {
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--text-muted) 6%, var(--surface));
  border: 1px solid var(--border);
}
.kd-code-block {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--text) 6%, var(--surface));
  font-size: 12px;
  overflow: auto;
  white-space: pre-wrap;
}
.kd-modal-lg {
  width: min(720px, calc(100vw - 24px));
  max-height: min(88vh, 900px);
  overflow: auto;
}
.kd-modal-xl {
  width: min(920px, calc(100vw - 24px));
  max-height: min(92dvh, 980px);
  overflow: auto;
}
/* Operador / formulários longos: mais largura e um único scroll no corpo */
.kd-modal-lg.kd-modal-admin,
.kd-modal-xl.kd-modal-admin {
  width: min(920px, calc(100vw - 24px));
  max-height: min(92dvh, 980px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 18px 22px 14px;
}
.kd-modal-lg.kd-modal-admin .kd-modal-form,
.kd-modal-xl.kd-modal-admin .kd-modal-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  gap: 0;
  max-width: none;
  width: 100%;
}
.kd-modal-lg.kd-modal-admin .kd-admin-modal-body,
.kd-modal-xl.kd-modal-admin .kd-admin-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
}
.kd-modal-lg.kd-modal-admin .kd-modal-actions,
.kd-modal-xl.kd-modal-admin .kd-modal-actions {
  flex: 0 0 auto;
  margin-top: 8px;
}
/* Escopos: sem barra interna — o scroll é só do corpo do modal */
.kd-modal-lg.kd-modal-admin .kd-scope-list,
.kd-modal-xl.kd-modal-admin .kd-scope-list {
  max-height: none;
  overflow: visible;
  width: 100%;
  box-sizing: border-box;
}
.kd-modal-xl.kd-modal-admin .kd-scope-list {
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}
.kd-modal-lg.kd-modal-admin #modal-user-scopes,
.kd-modal-xl.kd-modal-admin #modal-user-scopes {
  width: 100%;
  min-width: 0;
}
/* Conta: 2 colunas no modal largo (só bloco com campos simples) */
.kd-modal-xl.kd-modal-admin .kd-admin-modal-block:not(:has(.kd-scope-list)):not(:has(.kd-admin-modal-switches)):not(:has(.kd-work-schedule-wrap)) {
  grid-template-columns: 1fr 1fr;
  column-gap: 14px;
}
.kd-modal-xl.kd-modal-admin .kd-admin-modal-block:not(:has(.kd-scope-list)):not(:has(.kd-admin-modal-switches)):not(:has(.kd-work-schedule-wrap)) > .kd-admin-modal-block-head {
  grid-column: 1 / -1;
}
.kd-modal-lg.kd-modal-admin .kd-admin-modal-block > label,
.kd-modal-xl.kd-modal-admin .kd-admin-modal-block > label {
  width: 100%;
  min-width: 0;
}
.kd-modal-lg.kd-modal-admin .kd-work-schedule-wrap,
.kd-modal-xl.kd-modal-admin .kd-work-schedule-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  width: 100%;
}
.kd-modal-xl.kd-modal-admin .kd-work-schedule-wrap {
  overflow: visible;
}
.kd-modal-xl.kd-modal-admin .kd-work-schedule {
  min-width: 0;
  width: 100%;
}
.kd-modal-lg.kd-modal-admin .kd-work-schedule {
  min-width: 640px;
  width: 100%;
}
.kd-modal-lg.kd-modal-admin .kd-work-tol,
.kd-modal-xl.kd-modal-admin .kd-work-tol {
  max-width: 280px;
}
.kd-admin-view .kd-proto-timeline {
  max-height: 50vh;
}
.kd-admin-main { background: var(--bg); width: 100%; min-width: 0; }
.kd-admin-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  width: 100%;
  max-width: 100%;
}

/* Cabeçalho padrão de todas as páginas admin */
.kd-admin-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border-soft, var(--border));
  background: transparent;
  flex: 0 0 auto;
}
.kd-admin-page-titles {
  min-width: 0;
  flex: 1;
}
.kd-admin-page-titles h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.25;
}
.kd-admin-page-sub {
  margin: 5px 0 0;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.4;
  max-width: 42rem;
}
.kd-admin-page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  padding-top: 2px;
}
.kd-admin-page-actions .kd-select,
.kd-select {
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  max-width: min(280px, 100%);
}

.kd-admin-body {
  padding: 18px 22px 40px;
  overflow: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Blocos / seções — mesmo gesto dos departamentos (sem card) */
.kd-admin-block {
  display: grid;
  gap: 12px;
  padding: 0 0 20px;
  border-bottom: 1px solid var(--border-soft, var(--border));
  max-width: none;
  width: 100%;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}
.kd-admin-block:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.kd-admin-block-head {
  display: grid;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft, var(--border));
  margin-bottom: 2px;
}
.kd-admin-block-head .kd-admin-section-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.kd-admin-block-head .kd-meta {
  margin: 0;
  line-height: 1.4;
}
.kd-admin-block--form {
  max-width: min(720px, 100%);
}
.kd-admin-block label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.kd-admin-form .kd-admin-block {
  max-width: none;
}
.kd-admin-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding-top: 4px;
}
.kd-admin-block input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]),
.kd-admin-block select,
.kd-admin-block textarea {
  width: 100%;
  padding: 10px 12px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  box-sizing: border-box;
}
.kd-admin-block textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.4;
}
.kd-admin-kv {
  display: grid;
  gap: 2px;
}
.kd-admin-kv .row,
.kd-debug-body .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft, var(--border));
  color: var(--text-muted);
  font-size: 13px;
}
.kd-admin-kv .row:last-child,
.kd-debug-body .kd-admin-kv .row:last-child { border-bottom: 0; }
.kd-admin-kv .row strong,
.kd-debug-body .row strong { color: var(--text); font-weight: 600; }

.kd-admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.kd-admin-toolbar input[type="search"],
.kd-admin-toolbar input[type="date"],
.kd-admin-toolbar select {
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.kd-admin-toolbar input[type="search"] {
  flex: 1 1 180px;
  min-width: 140px;
}

.kd-admin-form {
  display: grid;
  gap: 14px;
  margin-bottom: 0;
  max-width: min(720px, 100%);
  width: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.kd-admin-form-wide {
  max-width: min(720px, 100%);
}
.kd-admin-block > .kd-admin-section-title:first-child {
  margin: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.kd-wa-hook-fields {
  display: grid;
  gap: 12px;
}
.kd-wa-hook-fields label {
  display: grid;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.kd-wa-hook-fields .kd-wa-secret-input {
  flex: 1 1 180px;
  min-width: 12em;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.kd-admin-form textarea {
  width: 100%;
  padding: 10px 12px;
  min-height: 120px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
  line-height: 1.4;
  box-sizing: border-box;
}
.kd-admin-form-card { /* alias kept for JS class */ }
.kd-brand-assets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.kd-brand-asset {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 0 12px;
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid var(--border-soft, var(--border));
  background: transparent;
}
.kd-brand-asset-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--kd-user-text, var(--text));
  letter-spacing: -0.01em;
}
.kd-brand-asset-preview {
  min-height: 64px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--bg);
  border: 1px dashed var(--border);
  padding: 12px;
}
.kd-brand-asset-preview img {
  max-height: 48px;
  max-width: 100%;
  object-fit: contain;
}
.kd-brand-asset-preview.is-favicon img {
  max-height: 32px;
  max-width: 32px;
}
.kd-brand-asset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.kd-admin-form-grid {
  display: grid;
  gap: 14px;
  max-width: min(960px, 100%);
  grid-template-columns: 1fr 1fr;
}
.kd-admin-form-grid .kd-channel-fields {
  display: contents;
}
.kd-admin-form-grid .kd-channel-fields[hidden],
.kd-admin-form-grid .kd-channel-fields[hidden] * {
  display: none !important;
}
.kd-admin-form label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.kd-admin-form label[hidden] {
  display: none !important;
}
.kd-admin-form input,
.kd-admin-form select {
  width: 100%;
  padding: 10px 12px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.kd-admin-form-grid .kd-btn { grid-column: 1 / -1; justify-self: start; }
.kd-head-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.kd-head-actions h2 { margin: 0; }
.kd-row-actions {
  /* NÃO usar display:flex no <td> — quebra o modelo de tabela e desalinha border-bottom */
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
}
.kd-row-actions-inner {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  max-width: 100%;
}
.kd-row-actions .kd-btn {
  padding: 6px 10px;
  font-size: 12px;
}
.kd-row-actions-ghost .kd-row-actions-inner {
  gap: 2px;
}
.kd-btn-ghost {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 4px 8px;
  min-height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: color var(--ease), background var(--ease), opacity var(--ease);
}
.kd-btn-ghost:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 5%, transparent);
}
.kd-btn-ghost.is-accent {
  color: var(--accent);
}
.kd-btn-ghost.is-accent:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.kd-btn-ghost.is-danger:hover {
  color: #f87171;
  background: color-mix(in srgb, #b42318 12%, transparent);
}
.kd-btn-ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.kd-btn-ghost.kd-modal-x {
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  color: var(--text-muted);
}
.kd-table tr.is-off td { opacity: 0.55; }
.kd-table tr.is-off td:has(.kd-switch) { opacity: 1; }
.kd-check {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
}
.kd-check input { width: auto !important; }

/* Toggle on/off — substitui checkbox em forms admin */
.kd-switch-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--text-muted) 5%, transparent);
  border: 1px solid var(--border-soft, var(--border));
}
.kd-switch-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.kd-switch-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.kd-switch-row .kd-meta {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
}
.kd-switch {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  width: 40px;
  height: 22px;
  cursor: pointer;
}
.kd-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100% !important;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}
.kd-switch-ui {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 28%, transparent);
  transition: background var(--ease);
  pointer-events: none;
}
.kd-switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform var(--ease);
}
.kd-switch input:checked + .kd-switch-ui {
  background: var(--accent);
}
.kd-switch input:checked + .kd-switch-ui::after {
  transform: translateX(18px);
}
.kd-switch input:focus-visible + .kd-switch-ui {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}
.kd-switch-sm {
  width: 34px;
  height: 18px;
}
.kd-switch-sm .kd-switch-ui::after {
  width: 14px;
  height: 14px;
}
.kd-switch-sm input:checked + .kd-switch-ui::after {
  transform: translateX(16px);
}

/* Departamentos — blocos por empresa */
.kd-dept-groups {
  display: grid;
  gap: 22px;
}
.kd-dept-brand-block {
  display: grid;
  gap: 10px;
}
.kd-dept-brand-head {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.kd-dept-brand-titles {
  min-width: 0;
}
.kd-dept-brand-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.25;
}
.kd-dept-brand-titles .kd-meta {
  margin: 2px 0 0;
}
.kd-dept-empty {
  margin: 0;
  padding: 10px 0 4px;
}
.kd-dept-table th:nth-child(5),
.kd-dept-table td:nth-child(5) {
  width: 56px;
  text-align: center;
}

/* Modal admin refinado */
.kd-modal-titles {
  min-width: 0;
  flex: 1;
}
.kd-modal-sub {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.4;
}
.kd-modal-refined {
  border-radius: 14px;
  padding: 20px 22px 18px;
}
.kd-modal-refined .kd-modal-head {
  margin-bottom: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft, var(--border));
  align-items: flex-start;
}
.kd-modal-refined .kd-modal-head h3 {
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}
.kd-modal-refined .kd-admin-form {
  gap: 0;
}
.kd-modal-actions-compact {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft, var(--border));
  gap: 10px;
}

/* Modal admin (Departamentos = referência; .kd-modal-admin em todos os CRUD) */
.kd-modal-dept,
.kd-modal-admin {
  width: min(560px, calc(100vw - 24px));
  padding: 18px 20px 16px;
  background: var(--bg);
  border-color: var(--border-soft, var(--border));
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}
/* lg/xl já definem a largura — não deixar .kd-modal-admin esmagar de volta para 560px */
.kd-modal-lg.kd-modal-admin,
.kd-modal-xl.kd-modal-admin {
  width: min(920px, calc(100vw - 24px));
}
.kd-modal-lg.kd-modal-admin .kd-modal-sub,
.kd-modal-xl.kd-modal-admin .kd-modal-sub {
  max-width: none;
}
.kd-modal-dept .kd-modal-head,
.kd-modal-admin .kd-modal-head {
  margin-bottom: 4px;
  padding-bottom: 14px;
}
.kd-modal-dept .kd-modal-sub,
.kd-modal-admin .kd-modal-sub {
  max-width: 36rem;
}
.kd-dept-modal-body,
.kd-admin-modal-body {
  display: grid;
  gap: 18px;
  padding: 4px 0 8px;
}
.kd-dept-modal-block,
.kd-admin-modal-block {
  display: grid;
  gap: 10px;
}
.kd-dept-modal-block-head,
.kd-admin-modal-block-head {
  display: grid;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.kd-dept-modal-block-head .kd-admin-section-title,
.kd-admin-modal-block-head .kd-admin-section-title {
  margin: 0;
}
.kd-dept-modal-block-head .kd-meta,
.kd-admin-modal-block-head .kd-meta {
  margin: 0;
  line-height: 1.4;
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
}
.kd-dept-modal-switches,
.kd-admin-modal-switches {
  display: grid;
  gap: 0;
  margin-top: 2px;
}
.kd-modal-refined .kd-switch-row,
.kd-modal-dept .kd-switch-row,
.kd-modal-admin .kd-switch-row {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border-soft, var(--border));
  border-radius: 0;
  padding: 11px 0;
}
.kd-modal-refined .kd-admin-modal-switches .kd-switch-row:first-child,
.kd-modal-refined .kd-dept-modal-switches .kd-switch-row:first-child,
.kd-modal-dept .kd-dept-modal-switches .kd-switch-row:first-child,
.kd-modal-admin .kd-admin-modal-switches .kd-switch-row:first-child {
  border-top: 0;
  padding-top: 4px;
}
.kd-modal-refined .kd-switch-label,
.kd-modal-dept .kd-switch-label,
.kd-modal-admin .kd-switch-label {
  font-size: 13px;
  font-weight: 600;
}
.kd-modal-dept label,
.kd-modal-admin label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--text-muted);
}
.kd-modal-dept .kd-admin-form input,
.kd-modal-dept .kd-admin-form select,
.kd-modal-dept .kd-admin-form textarea,
.kd-modal-admin .kd-admin-form input,
.kd-modal-admin .kd-admin-form select,
.kd-modal-admin .kd-admin-form textarea {
  border-radius: 8px;
  background: var(--surface);
  border-color: var(--border);
  min-height: 38px;
  font-size: 13px;
}
.kd-modal-dept .kd-admin-form textarea,
.kd-modal-admin .kd-admin-form textarea {
  min-height: 64px;
  padding: 9px 11px;
}
.kd-modal-dept .kd-color-row,
.kd-modal-admin .kd-color-row {
  gap: 8px;
}
.kd-modal-dept .kd-color-row input[type="color"],
.kd-modal-admin .kd-color-row input[type="color"] {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--surface);
}
.kd-modal-dept .kd-modal-actions-compact .kd-btn,
.kd-modal-admin .kd-modal-actions-compact .kd-btn,
.kd-modal-refined .kd-modal-actions-compact .kd-btn {
  min-height: 32px;
  padding: 0.35em 0.9em;
  font-size: 13px;
  border-radius: 8px;
}
.kd-active-cell {
  width: 56px;
  text-align: center;
  vertical-align: middle;
}
/* Forms embutidos (Ajustes / Marca): switches no mesmo gesto */
.kd-admin-form .kd-admin-modal-switches,
.kd-admin-form .kd-switch-stack {
  display: grid;
  gap: 0;
  margin: 4px 0 12px;
}
.kd-admin-form .kd-switch-row {
  background: transparent;
  border: 0;
  border-top: 1px solid var(--border-soft, var(--border));
  border-radius: 0;
  padding: 11px 0;
}
.kd-admin-form .kd-switch-stack .kd-switch-row:first-child,
.kd-admin-form .kd-admin-modal-switches .kd-switch-row:first-child {
  border-top: 0;
  padding-top: 4px;
}
.kd-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(15, 23, 20, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
}
.kd-modal {
  width: min(520px, 100%);
  max-height: min(90dvh, 900px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 18px 20px 20px;
}
.kd-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.kd-modal-head h3 {
  margin: 0;
  font-size: 1.05em;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.kd-modal-x {
  min-width: 36px;
  padding: 4px 10px;
  font-size: 1.25rem;
  line-height: 1;
}
.kd-modal-form .kd-channel-fields {
  display: grid;
  gap: 10px;
}
.kd-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}
.kd-modal-body {
  margin-bottom: 4px;
}
.kd-modal-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
}
.kd-btn-danger {
  background: #b42318 !important;
  color: #fff !important;
  border-color: #b42318 !important;
}
.kd-btn-danger:hover {
  background: #912018 !important;
}
.kd-transfer-tabs {
  display: flex;
  gap: 2px;
  margin: 0 0 16px;
  padding: 3px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--text-muted) 8%, var(--bg));
  flex-wrap: nowrap;
}
.kd-transfer-tab {
  appearance: none;
  position: relative;
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: 36px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.84em;
  font-weight: 550;
  letter-spacing: -0.01em;
  text-align: center;
  transition: background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}
.kd-transfer-tab:has(input:checked) {
  background: var(--surface);
  color: var(--kd-user-text, var(--text));
  box-shadow: 0 1px 2px color-mix(in srgb, #000 10%, transparent);
  border-color: transparent;
}
.kd-transfer-tab:hover {
  color: var(--kd-user-text, var(--text));
}
html[data-theme="dark"] .kd-transfer-tabs {
  background: color-mix(in srgb, #fff 9%, var(--bg));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #fff 8%, transparent);
}
html[data-theme="dark"] .kd-transfer-tab {
  color: color-mix(in srgb, #fff 68%, transparent);
}
html[data-theme="dark"] .kd-transfer-tab:hover {
  color: #fff;
  background: color-mix(in srgb, #fff 5%, transparent);
}
html[data-theme="dark"] .kd-transfer-tab:has(input:checked) {
  background: color-mix(in srgb, #fff 14%, var(--surface));
  color: #fff;
  box-shadow:
    0 1px 3px color-mix(in srgb, #000 32%, transparent),
    0 0 0 1px color-mix(in srgb, #fff 10%, transparent);
}
.kd-transfer-tab input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
  margin: 0;
}
.kd-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.kd-color-row input[type="color"] {
  width: 40px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}
.kd-color-row input[type="text"] {
  flex: 1;
  min-width: 0;
}
.kd-ui-prefs-preview {
  margin-top: 4px;
  padding: 12px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: var(--bg);
  line-height: 1.45;
}
.kd-transfer-pane select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--kd-user-text, var(--text));
  font: inherit;
  font-size: 0.95em;
  font-weight: 450;
}
.kd-transfer-pane select:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.kd-transfer-pane label {
  display: grid;
  gap: 6px;
  font-size: 0.84em;
  font-weight: 550;
  color: var(--text-muted);
}
.kd-transfer-pane .kd-meta {
  margin: 10px 0 0;
  font-size: 0.8em;
  font-weight: 450;
  color: color-mix(in srgb, var(--text-muted) 88%, transparent);
  line-height: 1.4;
}
#kd-transfer-modal .kd-modal {
  border-radius: 16px;
}
#kd-transfer-modal .kd-modal-head h3 {
  font-size: 1.05em;
  font-weight: 650;
  letter-spacing: -0.02em;
}
#kd-transfer-modal .kd-modal-form {
  padding-top: 4px;
}
#kd-transfer-modal .kd-modal-actions {
  margin-top: 18px;
  gap: 8px;
}
.kd-scope-list {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.kd-alias-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.kd-alias-row:last-child { border-bottom: 0; }
.kd-alias-row-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}
.kd-alias-row-head label { flex: 1; min-width: 12rem; }
.kd-alias-depts { max-height: 140px; }
.kd-alias-list-name {
  display: flex;
  align-items: center;
  gap: 10px;
}
.kd-alias-list-ava,
.kd-alias-modal-ava {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.kd-alias-photo-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.kd-alias-photo-controls { flex: 1; min-width: 12rem; }
.kd-alias-pick-opt {
  display: flex !important;
  align-items: center;
  gap: 8px;
}
.kd-alias-pick-ava {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}
.kd-alias-pick-ava img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.kd-api-box {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.kd-api-token-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.kd-api-token-value {
  flex: 1 1 180px;
  min-width: 0;
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-soft, var(--border));
  background: var(--bg);
  font-size: 12px;
  word-break: break-all;
}
.kd-api-box .kd-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.kd-api-box label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted, inherit);
}
.kd-api-box textarea {
  width: 100%;
  min-height: 88px;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--border-soft, var(--border));
  border-radius: 8px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  font-size: 13px;
  box-sizing: border-box;
}
.kd-code-block {
  margin: 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface-2, var(--bg));
  border: 1px solid var(--border-soft, var(--border));
  font-size: 12px;
  overflow: auto;
  white-space: pre-wrap;
}
.kd-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0;
}
.kd-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: visible;
}
.kd-table th, .kd-table td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--border-soft, var(--border));
  font-size: 13px;
  vertical-align: middle;
}
.kd-table th {
  background: transparent;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.75;
  padding-top: 4px;
  padding-bottom: 8px;
}
.kd-table tr:last-child td { border-bottom: 0; }
.kd-table tr:hover td { background: color-mix(in srgb, var(--text) 2.5%, transparent); }
.kd-table code { font-size: 12px; }

.kd-mon-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px 28px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.kd-mon-kpi {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.kd-mon-kpi .kd-meter {
  padding: 0;
  border-bottom: 0;
}
.kd-mon-kpi .kd-meter-top strong {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}
.kd-mon-kpi .kd-meter-top span {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.kd-mon-spark {
  width: 100%;
  height: 24px;
  display: block;
  opacity: 0.7;
}
.kd-mon-extra-disks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.kd-mon-split {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 28px;
  margin-bottom: 16px;
}
.kd-mon-col .kd-admin-section-title {
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.kd-svc-list {
  display: grid;
  gap: 0;
}
.kd-svc-row {
  display: grid;
  grid-template-columns: 110px 64px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft, var(--border));
  font-size: 13px;
}
.kd-svc-row:last-child { border-bottom: 0; }
.kd-svc-name { font-weight: 700; color: var(--text); }
.kd-svc-state { font-weight: 600; color: var(--text-muted); }
.kd-svc-row.is-ok .kd-svc-state { color: var(--accent); }
.kd-svc-row.is-bad .kd-svc-state { color: #f87171; }
.kd-mon-app-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.kd-mon-app-stat {
  display: grid;
  gap: 2px;
  padding: 4px 0;
}
.kd-mon-app-stat strong {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.kd-mon-foot {
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft, var(--border));
}
@media (max-width: 900px) {
  .kd-mon-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kd-mon-split { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .kd-mon-kpis { grid-template-columns: 1fr; }
  .kd-mon-app-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kd-svc-row { grid-template-columns: 1fr; gap: 2px; }
}
.kd-debug-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.kd-debug-filters input[type="search"],
.kd-debug-filters select {
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.kd-debug-filters input[type="search"] {
  flex: 1 1 180px;
  min-width: 140px;
}
.kd-debug-live-toggle {
  padding: 4px 0 !important;
  border: 0 !important;
  min-width: 110px;
}
.kd-debug-log {
  display: grid;
  gap: 0;
  max-height: min(52vh, 520px);
  overflow: auto;
  border: 1px solid var(--border-soft, var(--border));
  border-radius: 8px;
  background: var(--bg);
}
.kd-debug-entry {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft, var(--border));
  display: grid;
  gap: 4px;
}
.kd-debug-entry:last-child { border-bottom: 0; }
.kd-debug-entry header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  font-size: 11px;
  color: var(--text-muted);
}
.kd-debug-entry p {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}
.kd-debug-cat {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}
.kd-debug-ctx {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 4.5em;
  overflow: hidden;
}
.kd-debug-cat-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0;
}
.kd-debug-cat-chip strong {
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}
.kd-meter {
  padding: 14px 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border-soft, var(--border));
  border-radius: 0;
}
.kd-meter-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 13px;
}
.kd-meter-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.kd-meter-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width .35s ease, background .2s ease;
}
.kd-meter-fill.is-ok { background: var(--accent); }
.kd-meter-fill.is-warn { background: #c98a1a; }
.kd-meter-fill.is-crit { background: #c04444; }
.kd-svc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 10px 0 16px;
}
.kd-svc {
  padding: 12px 0;
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid var(--border-soft, var(--border));
  background: transparent;
  display: grid;
  gap: 4px;
}
.kd-svc strong { font-size: 13px; }
.kd-svc span { font-size: 12px; color: var(--text-muted); }
.kd-svc.is-ok { border-color: transparent; }
.kd-svc.is-ok strong { color: var(--accent); }
.kd-svc.is-bad { border-color: transparent; }
.kd-svc.is-bad strong { color: #c04444; }
.kd-live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  align-self: center;
}
.kd-live-dot.is-pulse {
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
}
.kd-mon-php { line-height: 1.5; }

.kd-channel-fields {
  display: contents;
}
.kd-channel-fields[hidden] {
  display: none !important;
}
.kd-channel-fields[hidden] * {
  display: none !important;
}
.kd-channel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.kd-channel-name-cell {
  max-width: 28rem;
  vertical-align: middle;
}
.kd-channel-name {
  font-weight: 600;
}
.kd-channel-name-cell .kd-meta {
  margin-top: 2px;
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.kd-table tr:hover td.kd-row-actions {
  background: color-mix(in srgb, var(--text) 2.5%, transparent);
}
.kd-channel-created {
  margin: 0;
  padding: 14px 0;
  border-radius: 0;
  border: 0;
  border-bottom: 1px solid var(--border-soft, var(--border));
  background: transparent;
}
.kd-inline-chat {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  overflow: hidden;
}
.kd-inline-chat-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.kd-inline-chat-head .kd-btn { margin-left: auto; }
.kd-inline-chat-msgs {
  height: 220px;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kd-inline-bubble {
  max-width: 85%;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  word-break: break-word;
}
.kd-inline-bubble.me {
  align-self: flex-end;
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
}
.kd-inline-chat-start,
.kd-inline-chat-send {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.kd-inline-chat-start input,
.kd-inline-chat-send input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

/* iPad landscape / tablet: duas colunas, sidebar mais estreita */
@media (max-width: 1100px) and (min-width: 901px) {
  .kd-shell:not(.kd-admin-shell) {
    grid-template-columns: minmax(220px, min(280px, 34vw)) minmax(0, 1fr);
  }
  .kd-admin-shell {
    grid-template-columns: minmax(200px, 220px) minmax(0, 1fr);
  }
  .kd-admin-shell .kd-sidebar {
    width: auto;
    min-width: 0;
    max-width: none;
  }
  .kd-msg { max-width: 82%; }
}

/* Celular + iPad retrato: lista OU chat; admin com abas horizontais */
@media (max-width: 900px) {
  .kd-shell:not(.kd-admin-shell) {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }
  .kd-shell:not(.kd-admin-shell) .kd-sidebar,
  .kd-shell:not(.kd-admin-shell) .kd-chat {
    border-right: 0;
    border-bottom: 0;
    height: 100%;
    min-height: 0;
  }
  .kd-shell:not(.kd-admin-shell) .kd-chat { display: none; }
  .kd-shell:not(.kd-admin-shell).is-chat-open .kd-sidebar { display: none; }
  .kd-shell:not(.kd-admin-shell).is-chat-open .kd-chat { display: flex; }

  .kd-back-btn {
    display: inline-flex;
  }
  .kd-chat-title-wrap {
    cursor: pointer;
    gap: 6px;
  }
  .kd-chat-head {
    gap: 6px;
    padding-left: 8px;
    padding-right: 8px;
  }
  .kd-chat .kd-head {
    flex-wrap: nowrap;
    align-items: center;
  }
  .kd-chat-head-aside {
    gap: 4px;
    max-width: min(58vw, 260px);
  }
  .kd-chat .kd-support-key {
    min-height: 30px;
    padding: 0.15em 0.4em 0.15em 0.45em;
    font-size: 0.92em;
  }
  .kd-chat .kd-support-key-val {
    font-size: 0.88em;
    max-width: 7.5em;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .kd-chat .kd-toolbar {
    width: auto;
    max-width: none;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0;
    flex: 1 1 auto;
  }
  .kd-chat .kd-toolbar::-webkit-scrollbar { display: none; }
  .kd-chat-head .kd-toolbar .kd-icon-btn {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
  }
  .kd-status-pill {
    display: none;
  }

  .kd-brand { font-size: 1.05em; }
  .kd-nav {
    margin: 0.45em 0.55em 0.3em;
  }
  .kd-nav-item {
    font-size: 0.75em;
    padding: 0.5em 0.2em;
    min-height: 44px;
  }
  .kd-closed-tools {
    padding: 0.3em 0.65em 0.55em;
    gap: 0.4em;
  }
  .kd-item {
    padding-right: 12px;
  }
  .kd-msg { max-width: 88%; }
  .kd-messages {
    padding: 14px 12px 20px;
  }
  .kd-composer {
    margin: 0 8px 10px;
    padding: 10px 10px 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    border-radius: 16px;
  }
  .kd-composer-toolbar {
    flex-wrap: wrap;
    gap: 6px;
  }
  .kd-composer-tools {
    flex-wrap: wrap;
    gap: 2px;
  }
  .kd-composer-actions {
    margin-left: auto;
  }
  .kd-composer-send-label {
    display: none;
  }
  .kd-composer-send {
    width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 999px;
  }
  .kd-format-btn {
    width: 36px;
    height: 36px;
  }
  .kd-menu-pop {
    max-height: min(70dvh, 480px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .kd-modal-backdrop {
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
    align-items: flex-end;
  }
  .kd-modal {
    width: 100%;
    max-height: min(92dvh, 900px);
    border-radius: 16px 16px 12px 12px;
  }
  .kd-modal-lg {
    width: 100%;
  }

  /* Admin: nav em faixa horizontal */
  .kd-admin-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .kd-admin-shell .kd-sidebar {
    width: 100%;
    min-width: 0;
    max-width: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: none;
    flex: 0 0 auto;
  }
  .kd-admin-shell .kd-admin-hint { display: none; }
  .kd-admin-shell .kd-head-brand {
    padding: 10px 12px;
    min-height: 0;
  }
  .kd-admin-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-height: none;
    gap: 0;
    padding: 4px 8px 8px;
  }
  .kd-admin-nav::-webkit-scrollbar { display: none; }
  .kd-admin-nav-group {
    flex-direction: row;
    align-items: center;
    border: 0;
    background: transparent;
    padding: 0;
    gap: 0;
    flex: 0 0 auto;
    margin: 0;
  }
  .kd-admin-nav-group + .kd-admin-nav-group {
    border-top: 0;
    border-left: 1px solid var(--border-soft, var(--border));
    padding-left: 4px;
    margin-left: 4px;
    padding-top: 0;
  }
  .kd-admin-nav-label {
    display: none;
  }
  .kd-admin-nav-item {
    white-space: nowrap;
    padding: 10px 12px;
    min-height: 44px;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    font-size: 13px;
  }
  .kd-admin-nav-item.is-active {
    border-bottom-color: var(--accent);
    background: transparent;
  }
  .kd-admin-form,
  .kd-admin-form-grid {
    max-width: none;
    grid-template-columns: 1fr;
  }
  .kd-admin-page-head {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 14px 12px;
    gap: 10px;
  }
  .kd-admin-page-actions {
    justify-content: flex-start;
    width: 100%;
  }
  .kd-admin-page-actions .kd-btn-ghost,
  .kd-admin-page-actions .kd-btn {
    min-height: 40px;
  }
  .kd-admin-body { padding: 14px 14px 28px; }
  .kd-admin-page-actions .kd-select,
  .kd-select { max-width: none; width: 100%; }
  .kd-table {
    min-width: 420px;
  }
  .kd-table th,
  .kd-table td {
    padding: 10px 8px;
    font-size: 12px;
  }
  .kd-row-actions {
    white-space: normal;
  }
  .kd-row-actions-inner,
  .kd-row-actions-ghost .kd-row-actions-inner {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
  }
  .kd-proto-filter-row {
    grid-template-columns: 1fr 1fr;
  }
  .kd-stats-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 560px) {
  .kd-proto-filter-row {
    grid-template-columns: 1fr;
  }
  .kd-composer-tools .kd-format-btn[data-fmt] {
    display: none;
  }
  .kd-modal-backdrop {
    padding: 0;
    align-items: stretch;
  }
  .kd-modal {
    max-height: 100dvh;
    height: 100%;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
}

@media (max-width: 420px) {
  .kd-login-card,
  .kd-card { padding: 32px 22px 26px; }
  .kd-nav-item { letter-spacing: 0; }
  .kd-chat-head .kd-toolbar .kd-icon-btn {
    width: 36px;
    height: 36px;
  }
}

/* —— Estatísticas (admin) — flat, sem cards —— */
.kd-stats-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.kd-stats-presets {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.kd-stats-preset {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  min-height: 28px;
  transition: color var(--ease), background var(--ease);
}
.kd-stats-preset:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 5%, transparent);
}
.kd-stats-preset.is-active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.kd-stats-custom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.kd-stats-custom label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0;
}
.kd-stats-custom input[type="date"] {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--kd-user-text, var(--text));
  font: inherit;
  font-size: 12px;
}
.kd-stats-body {
  display: grid;
  gap: 8px;
}
.kd-stats-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--border-soft, var(--border));
  margin-bottom: 8px;
}
.kd-stats-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px 14px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  min-height: 0;
  border-right: 1px solid var(--border-soft, var(--border));
  padding-right: 14px;
  margin-right: 14px;
}
.kd-stats-kpi:last-child {
  border-right: 0;
  margin-right: 0;
}
.kd-stats-kpi-label {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.3;
  letter-spacing: 0.02em;
}
.kd-stats-kpi-value {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--kd-user-text, var(--text));
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.kd-stats-kpi-sub {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
}
.kd-stats-spark {
  width: 100%;
  height: 28px;
  margin-top: 6px;
  display: block;
}
.kd-stats-charts-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}
.kd-stats-charts-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.kd-stats-charts-3 > .kd-admin-block,
.kd-stats-charts-2 > .kd-admin-block {
  border-bottom: 0;
  padding-bottom: 0;
  min-width: 0;
}
.kd-stats-card {
  /* legado — preferir .kd-admin-block */
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
  min-width: 0;
}
.kd-stats-donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  min-height: 0;
}
.kd-stats-donut {
  width: min(140px, 100%);
  height: auto;
  display: block;
}
.kd-stats-legend {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 100%;
}
.kd-stats-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 12px;
  color: var(--text-muted);
}
.kd-stats-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}
.kd-stats-legend-label {
  flex: 1 1 auto;
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kd-stats-legend-count {
  font-weight: 650;
  color: var(--kd-user-text, var(--text));
  font-variant-numeric: tabular-nums;
}
.kd-stats-chart-lg,
.kd-stats-chart-md {
  width: 100%;
  min-height: 200px;
  overflow: hidden;
}
.kd-stats-area,
.kd-stats-bars {
  width: 100%;
  height: auto;
  display: block;
  max-height: 280px;
}
.kd-stats-grid {
  stroke: var(--border-soft, var(--border));
  stroke-dasharray: 3 3;
  stroke-width: 1;
}
.kd-stats-axis {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: inherit;
  font-weight: 500;
}
.kd-stats-empty {
  display: grid;
  place-items: center;
  min-height: 140px;
  color: var(--text-muted);
  font-size: 0.85em;
}
.kd-stats-table .kd-num,
.kd-table .kd-num {
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.kd-stats-agent {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.kd-stats-agent-ava {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  color: var(--accent);
  font-size: 0.72em;
  font-weight: 700;
}
.kd-stats-agent-name {
  font-weight: 600;
  font-size: 0.9em;
  color: var(--kd-user-text, var(--text));
}
@media (max-width: 960px) {
  .kd-stats-charts-3,
  .kd-stats-charts-2 {
    grid-template-columns: 1fr;
  }
  .kd-stats-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 16px;
    padding-bottom: 12px;
  }
  .kd-stats-kpi {
    border-right: 0;
    margin-right: 0;
    padding-right: 0;
    border-bottom: 1px solid var(--border-soft, var(--border));
    padding-bottom: 10px;
  }
}
@media (max-width: 640px) {
  .kd-stats-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .kd-stats-presets {
    width: 100%;
    justify-content: space-between;
  }
  .kd-stats-custom {
    width: 100%;
  }
  .kd-stats-custom label {
    flex: 1 1 auto;
  }
  .kd-stats-custom input[type="date"] {
    flex: 1;
    width: 100%;
  }
}

/* —— Chat interno (equipe) —— */
#btn-more {
  position: relative;
}
.kd-team-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid var(--surface);
  pointer-events: none;
}
.kd-team-badge.is-mention {
  background: #16a34a;
  box-shadow: 0 0 0 2px color-mix(in srgb, #22c55e 35%, transparent);
}
.kd-team-badge[hidden] {
  display: none !important;
}
.kd-menu-team-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #22c55e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}
.kd-menu-team-badge[hidden] {
  display: none !important;
}
.kd-team-chat {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(15, 23, 20, 0.52);
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top, 0px))
    max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px));
  animation: kd-team-backdrop-in 0.18s ease;
}
.kd-team-chat[hidden] {
  display: none !important;
}
.kd-team-panel {
  width: min(980px, 100%);
  height: min(760px, 90dvh);
  max-height: 90dvh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 16px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: kd-team-panel-in 0.22s ease;
}
@keyframes kd-team-backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes kd-team-panel-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.kd-team-empty {
  padding: 18px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}
.kd-team-empty-main {
  margin: auto;
  align-self: center;
  width: 100%;
}
.kd-team-empty .kd-btn {
  margin-top: 10px;
}
.kd-team-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
}
.kd-team-sidebar {
  overflow: auto;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 0;
}
.kd-team-side-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.kd-team-side-head strong {
  font-size: 1.02em;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}
.kd-team-side-head .kd-meta {
  margin: 0;
  font-size: 0.78em;
}
.kd-team-section {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 14px 6px;
}
.kd-team-chat-head .kd-team-close,
.kd-team-close {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  opacity: 0.72;
  color: var(--text-muted);
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
.kd-team-chat-head .kd-team-close svg,
.kd-team-close svg {
  width: 20px;
  height: 20px;
}
.kd-team-chat-head .kd-team-close:hover,
.kd-team-chat-head .kd-team-close:focus-visible,
.kd-team-close:hover,
.kd-team-close:focus-visible {
  opacity: 0.72;
  color: var(--text-muted);
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
#kd-team-mention {
  font-size: 0;
  line-height: 0;
}
.kd-team-room {
  appearance: none;
  width: 100%;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  border-left: 2.5px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.75em;
  padding: 0.85em 0.75em 0.85em 0.8em;
  border-radius: 0;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.kd-team-room:hover {
  background: color-mix(in srgb, var(--text-muted) 6%, var(--surface));
}
.kd-team-room.is-active {
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  border-left-color: var(--accent);
}
.kd-team-room-ava {
  position: relative;
  width: var(--kd-avatar-size, 36px);
  height: var(--kd-avatar-size, 36px);
  border-radius: 30px;
  background: var(--kd-avatar-bg, color-mix(in srgb, var(--accent) 14%, var(--bg)));
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-size: 0.72em;
  font-weight: 700;
  flex: 0 0 auto;
}
.kd-team-room-ava.is-group {
  color: var(--accent-contrast, #fff);
  background: var(--accent);
}
.kd-team-room-ava.is-group svg {
  width: 18px;
  height: 18px;
  display: block;
}
.kd-team-online {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94a3b8;
  border: 2px solid var(--surface);
}
.kd-team-online.is-on {
  background: #22c55e;
}
.kd-team-room-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.kd-team-room-meta strong {
  font-size: 0.95em;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kd-team-room-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast, #fff);
  font-size: 11px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}
.kd-team-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(ellipse 70% 45% at 85% 0%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%),
    var(--bg);
  padding-bottom: 4px;
}
.kd-team-chat-head {
  flex: 0 0 auto;
  border-radius: 0;
}
.kd-team-chat-head .kd-avatar-letters.is-icon {
  font-size: 0;
}
.kd-team-chat-head .kd-avatar-letters.is-icon svg {
  width: 18px;
  height: 18px;
  display: block;
  color: #fff;
}
.kd-team-main > .kd-messages {
  flex: 1;
  min-height: 0;
}
.kd-team-main > .kd-composer {
  position: relative;
}
.kd-team-main textarea.kd-composer-input {
  resize: none;
  field-sizing: content;
}
.kd-team-main textarea.kd-composer-input::placeholder {
  color: color-mix(in srgb, var(--text-muted) 88%, transparent);
}
.kd-msg-body .kd-team-mention {
  color: var(--accent);
  font-weight: 700;
}
.kd-team-audio {
  width: min(240px, 100%);
  margin: 4px 0;
  display: block;
}
.kd-team-main .kd-audio {
  width: min(260px, 100%);
}
.kd-team-main .kd-attach-preview {
  margin: 0 2px 2px;
}
.kd-team-mention-jump {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  margin: 0 0 8px;
  padding: 6px 10px 6px 8px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  animation: kd-mention-pulse 1.15s ease-in-out infinite;
}
.kd-team-mention-jump[hidden] {
  display: none !important;
}
.kd-team-mention-jump:hover,
.kd-team-mention-jump:focus-visible {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface));
  outline: none;
}
.kd-team-mention-jump-ico {
  display: inline-flex;
  width: 18px;
  height: 18px;
}
.kd-team-mention-jump-ico svg {
  width: 18px;
  height: 18px;
  display: block;
}
.kd-team-mention-jump-count {
  min-width: 1.25em;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}
@keyframes kd-mention-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.62; transform: scale(1.04); }
}
#kd-team-messages .kd-msg.is-mention-flash {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 12px;
  animation: kd-mention-msg-flash 1.6s ease;
}
@keyframes kd-mention-msg-flash {
  0% { background: color-mix(in srgb, var(--accent) 22%, transparent); }
  100% { background: transparent; }
}
#kd-team-composer.is-drop {
  outline: 2px dashed color-mix(in srgb, var(--accent) 50%, transparent);
  outline-offset: 2px;
}
.kd-team-mention-pop {
  position: absolute;
  left: 16px;
  bottom: calc(100% - 8px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 6px;
  display: grid;
  gap: 2px;
  max-height: 200px;
  overflow: auto;
  z-index: 5;
}
.kd-team-mention-pop[hidden] {
  display: none !important;
}
.kd-team-mention-pop button {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: left;
  font: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
}
.kd-team-mention-pop button:hover,
.kd-team-mention-pop button.is-active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
#kd-team-mention.is-static,
#kd-team-mention:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--text-muted);
}
/* Voice bar do chat interno (mesma ordem do desk) */
#kd-team-voice-rec-bar > #kd-team-voice-trash { order: 1; }
#kd-team-voice-rec-bar > #kd-team-voice-play { order: 2; }
#kd-team-voice-rec-bar > #kd-team-voice-dot { order: 3; }
#kd-team-voice-rec-bar > #kd-team-voice-time { order: 4; }
#kd-team-voice-rec-bar > #kd-team-voice-wave { order: 5; }
#kd-team-voice-rec-bar > #kd-team-voice-pause,
#kd-team-voice-rec-bar > #kd-team-voice-resume { order: 6; }
#kd-team-voice-rec-bar > #kd-team-voice-send { order: 7; }
#kd-team-voice-rec-bar.is-paused > #kd-team-voice-wave { order: 4; }
#kd-team-voice-rec-bar.is-paused > #kd-team-voice-time { order: 5; }
#kd-team-msg-menu {
  z-index: 80;
}
.kd-team-spy-banner {
  flex: 0 0 auto;
  margin: 0 12px 8px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.35;
  color: #7a4a00;
  background: color-mix(in srgb, #f59e0b 16%, var(--surface));
  border: 1px solid color-mix(in srgb, #f59e0b 35%, var(--border));
}
.kd-team-spy-banner[hidden] {
  display: none !important;
}
.kd-team-section-spy {
  margin-top: 10px;
  color: color-mix(in srgb, #b45309 70%, var(--muted, #6b7280));
}
.kd-team-room.is-spy .kd-team-room-ava.is-spy {
  outline: 2px solid color-mix(in srgb, #f59e0b 55%, transparent);
  outline-offset: 1px;
}
#kd-team-composer[hidden] {
  display: none !important;
}
@media (max-width: 720px) {
  .kd-team-panel {
    width: 100%;
  height: min(92dvh, 100%);
  max-height: 92dvh;
  border-radius: 14px;
  }
  .kd-team-body {
    grid-template-columns: 1fr;
  }
  .kd-team-sidebar {
    max-height: 30vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}

/* Encaminhar msg do cliente → chat interno */
.kd-forward-team-ctx {
  margin: 0 0 10px;
}
.kd-forward-team-quote {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
}
.kd-forward-team-quote-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}
.kd-forward-team-quote-body {
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  max-height: 120px;
  overflow: auto;
}
.kd-forward-team-media {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.kd-forward-team-thumb {
  max-width: 120px;
  max-height: 90px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
}
.kd-forward-team-file {
  font-size: 12px;
  color: var(--text-muted);
}
.kd-forward-team-mentions {
  margin: 0 0 12px;
}
.kd-forward-team-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.kd-forward-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.kd-forward-chip:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  color: var(--accent);
}
.kd-forward-chip.is-on {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--accent);
  font-weight: 600;
}
