:root {
  --bg: #0d0d0d;
  --nav: #111111;
  --surface: #1a1a1a;
  --card: #1e1e1e;
  --input: #2a2a2a;
  --line: #333333;
  --line-strong: #444444;
  --text: #ffffff;
  --muted: #b3b3b3;
  --hint: #8a8a8a;
  --blue: #3b82f6;
  --danger: #e5534b;
  --ok: #3dd68c;
  --warn: #e8b849;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Tahoma", sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.8;
}
body { display: flex; min-height: 100vh; }
.nav {
  width: 276px;
  background: var(--nav);
  border-left: 0.5px solid var(--line);
  padding: 16px 12px;
  flex-shrink: 0;
}
.brand { font-size: 19px; font-weight: 500; }
.nav .hint { color: var(--hint); font-size: 13px; margin: 4px 0 16px; }
.nav button {
  display: block;
  width: 100%;
  text-align: right;
  background: transparent;
  color: #d6d6d6;
  border: 0;
  height: 44px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
}
.nav button.active { background: #2a2a2a; color: #fff; font-weight: 500; }
body.nav-collapsed .nav {
  display: none;
}
main { flex: 1; padding: 16px 24px 32px; min-width: 0; }
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 0.5px solid var(--line);
  height: 56px;
  margin-bottom: 16px;
}
.top-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.nav-collapse-btn {
  color: var(--muted);
}
.nav-collapse-btn:hover { color: var(--text); }
.nav-collapse-btn:focus-visible {
  outline: 0.5px solid var(--text);
  outline-offset: 2px;
  border-color: var(--line-strong);
}
.nav-collapse-chevron { display: block; }
body.nav-collapsed .nav-collapse-chevron {
  transform: scaleX(-1);
}
h1 { font-size: 21px; font-weight: 500; margin: 0; }
h2 { font-size: 17px; font-weight: 500; margin: 0 0 8px; }
h3 { font-size: 19px; font-weight: 500; margin: 0 0 8px; }
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.card {
  background: var(--card);
  border: 0.5px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 8px;
}
.card.wide { grid-column: 1 / -1; }
.muted, .hint { color: var(--muted); font-size: 14px; }
.mono { font-size: 14px; word-break: break-all; }
.banner {
  background: #242424;
  border: 0.5px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
}
.banner.warn { border-color: var(--warn); }
button {
  height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  border: 0.5px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  font-family: inherit;
}
button.primary { background: var(--blue); color: #fff; border: 0; }
button.danger { background: var(--danger); color: #fff; border: 0; }
button.ghost { border-color: var(--line-strong); }
button:active { transform: scale(0.98); }
label { display: block; font-size: 14px; color: var(--muted); margin: 8px 0; }
input, select, textarea {
  width: 100%;
  margin-top: 4px;
  background: var(--input);
  color: var(--text);
  border: 0.5px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 15px;
  font-family: inherit;
}
input, select { height: 44px; }
textarea { min-height: 100px; resize: vertical; }
.form-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; align-items: end; }
#page-tenants .onboard-grid { grid-template-columns: repeat(2, 1fr); }
#agents-table select { min-width: 180px; max-width: 260px; height: 40px; padding: 4px 8px; font-size: 13px; }
.callback-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.generated-fields { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.generated-fields[hidden] { display: none; }
.copy-field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 13px; color: var(--muted); }
.callback-value {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 220px;
  background: #242424;
  border: 0.5px solid var(--line-strong);
  border-radius: 8px;
  padding: 4px 8px 4px 4px;
  min-height: 44px;
}
.callback-value[hidden] { display: none; }
#dash-callback, #dash-verify {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  word-break: break-all;
  text-align: left;
  user-select: all;
}
#dash-verify { cursor: text; }
#dash-verify.editing {
  outline: 0.5px solid var(--line-strong);
  background: var(--input);
  border-radius: 6px;
  padding: 2px 6px;
}
.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0.5px solid var(--line-strong);
  border-radius: 8px;
  color: var(--text);
  flex-shrink: 0;
}
.icon-btn:hover { background: #2a2a2a; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: right; color: var(--muted); font-weight: 400; font-size: 14px; }
th, td { padding: 8px 6px; border-bottom: 0.5px solid var(--line); }
tr:hover td { background: #2a2a2a; }
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
}
.pill.ok { color: var(--ok); border: 0.5px solid var(--ok); }
.pill.bad { color: var(--danger); border: 0.5px solid var(--danger); }
.pill.warn { color: var(--warn); border: 0.5px solid var(--warn); }
.pill.unknown { color: var(--hint); border: 0.5px solid var(--line-strong); }
.toggle {
  width: 44px;
  height: 24px;
  border-radius: 99px;
  background: #3a3a3a;
  border: 0;
  position: relative;
  padding: 0;
}
.toggle.on { background: var(--blue); }
.toggle::after {
  content: "";
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  right: 2px;
}
.toggle.on::after { right: auto; left: 2px; }
.check { display: flex; gap: 8px; align-items: center; }
.check input { width: auto; height: auto; }
.danger-check { color: var(--danger); }
#sb-permission { max-width: 220px; }
#sb-cred-status p { margin: 6px 0; }
#sb-test-result, #st-test-result { margin-top: 8px; min-height: 1.5em; }
#page-storage .form-row { grid-template-columns: repeat(2, 1fr); }
#st-cred-status p { margin: 6px 0; }
tr.selected td { background: #2a2a2a; }
.toast {
  background: #2a2a2a;
  border: 0.5px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  margin-left: 8px;
}
.top-actions { display: flex; align-items: center; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: none;
  place-items: center;
  z-index: 20;
}
.modal:not([hidden]) {
  display: grid;
}
.modal-card {
  width: 380px;
  background: #242424;
  border-radius: 12px;
  padding: 24px;
}
.modal-actions { display: flex; justify-content: flex-start; gap: 8px; margin-top: 16px; }
pre { white-space: pre-wrap; font-size: 14px; color: var(--muted); }
html:has(body.inbox-active),
body.inbox-active {
  height: 100%;
  overflow: hidden;
}
body.inbox-active {
  height: 100vh;
  height: 100dvh;
}
body.inbox-active main {
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
body.inbox-active .top {
  height: 56px;
  margin: 0;
  padding: 0 16px;
  flex-shrink: 0;
  background: #202c33;
  border-bottom-color: #2a3942;
}
body.inbox-active #page-inbox:not([hidden]) {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}
.inbox-page[hidden],
#page-inbox[hidden] {
  display: none !important;
}
.inbox-page:not([hidden]) {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 0;
  flex: 1;
  display: flex;
}
.wa-shell {
  display: flex;
  width: 100%;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  background: #111b21;
}
.wa-list {
  width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: #111b21;
  border-left: 0.5px solid #2a3942;
  position: relative;
}
.wa-list-top {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 16px;
  flex-shrink: 0;
  background: #202c33;
}
.wa-list-top h2 { margin: 0; font-size: 17px; }
#inbox-account-filter {
  max-width: 180px;
  height: 32px;
  border: 0;
  border-radius: 6px;
  background: #111b21;
  color: #e9edef;
  padding: 0 8px;
}
.inbox-account-empty {
  margin: 0;
  padding: 8px 16px;
  flex-shrink: 0;
}
.wa-search {
  padding: 8px 12px;
  flex-shrink: 0;
  background: #111b21;
}
.wa-search input {
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: #202c33;
  color: #e9edef;
  padding: 0 12px;
  font-size: 15px;
}
.wa-chats {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
button.wa-chat {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  width: 100%;
  height: auto;
  padding: 10px 12px;
  cursor: pointer;
  border: 0;
  border-bottom: 0.5px solid #222d34;
  border-radius: 0;
  align-items: center;
  text-align: right;
  font: inherit;
  color: inherit;
  background: transparent;
}
.wa-chat:hover { background: #202c33; }
.wa-chat.active { background: #2a3942; }
.wa-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #6b7c85;
  color: #111b21;
  display: grid;
  place-items: center;
  font-weight: 500;
  font-size: 17px;
}
.wa-chat-name {
  font-size: 16px;
  color: #e9edef;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-chat-preview {
  font-size: 14px;
  color: #8696a0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-chat-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-size: 13px;
  color: #8696a0;
}
.wa-unread {
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  background: #00a884;
  color: #111b21;
  font-size: 13px;
  font-weight: 500;
  display: grid;
  place-items: center;
  padding: 0 6px;
  line-height: 1;
}
button.wa-chat.has-unread .wa-chat-name {
  font-weight: 500;
  color: #fff;
}
.wa-mode {
  font-size: 12px;
  color: #00a884;
}
.wa-mode.manual { color: #e8b849; }
.wa-mode.assist { color: #53bdeb; }
.wa-thread {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0b141a;
}
.wa-thread-top {
  min-height: 60px;
  height: auto;
  background: #202c33;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
  border-bottom: 0.5px solid #2a3942;
}
.wa-peer { display: flex; align-items: center; gap: 10px; min-width: 0; }
#inbox-title { font-size: 17px; font-weight: 500; }
.wa-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.wa-tools > button {
  height: 40px;
  padding: 0 10px;
  border-radius: 6px;
  border: 0.5px solid #3b4a54;
  background: transparent;
  color: #e9edef;
  font-size: 13px;
  cursor: pointer;
}
.wa-select {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
}
.wa-select span {
  font-size: 12px;
  color: #8696a0;
  line-height: 1.2;
}
.wa-select select {
  height: 40px;
  margin: 0;
  width: 200px;
  background: #111b21;
  color: #e9edef;
  border: 0.5px solid #3b4a54;
  border-radius: 6px;
  padding: 0 8px;
  font-size: 13px;
}
.wa-send-col {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
#inbox-generate {
  height: 40px;
  min-width: 88px;
  border: 0.5px solid #3b4a54;
  background: #2a3942;
  color: #00a884;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
#inbox-generate[hidden] { display: none; }
#inbox-generate:hover { background: #334650; }
#inbox-generate:disabled { opacity: 0.45; cursor: wait; }
.wa-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.wa-actions button {
  height: 40px;
  padding: 0 10px;
  border-radius: 6px;
  border: 0.5px solid #3b4a54;
  background: transparent;
  color: #e9edef;
  font-size: 13px;
  cursor: pointer;
}
.wa-pills {
  display: flex;
  background: #111b21;
  border-radius: 8px;
  overflow: hidden;
}
.wa-pills button {
  border: 0;
  height: 40px;
  padding: 0 12px;
  background: transparent;
  color: #8696a0;
}
.wa-pills button.on {
  background: #00a884;
  color: #111b21;
  font-weight: 500;
}
.wa-messages {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 8%;
  background-color: #0b141a;
  background-image: radial-gradient(rgba(255,255,255,0.03) 0.6px, transparent 0.6px);
  background-size: 18px 18px;
}
.wa-empty {
  color: #8696a0;
  text-align: center;
  margin-top: 20vh;
  font-size: 15px;
}
.wa-bubble {
  max-width: 65%;
  width: fit-content;
  padding: 6px 10px 4px;
  border-radius: 8px;
  margin: 3px 0;
  font-size: 15px;
  line-height: 1.65;
  position: relative;
}
.wa-bubble.in {
  background: #202c33;
  margin-left: 0;
  margin-right: auto;
  border-top-left-radius: 0;
}
.wa-bubble.out {
  background: #005c4b;
  margin-left: auto;
  margin-right: 0;
  border-top-right-radius: 0;
}
.wa-caption { white-space: pre-wrap; word-break: break-word; }
.wa-media img, .wa-media video {
  max-width: 280px;
  max-height: 280px;
  border-radius: 6px;
  display: block;
}
.wa-media img.wa-lazy:not([src]),
.wa-media img.wa-local-preview:not([src]) {
  min-width: 160px;
  min-height: 120px;
  background: #1f2c33;
}
.wa-file, .wa-audio {
  color: #e9edef;
  font-size: 14px;
}
.wa-media-wait {
  color: #8696a0;
}
.wa-load-older {
  display: block;
  margin: 0 auto 12px;
  background: transparent;
  border: 0.5px solid #333333;
  color: #b3b3b3;
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 13px;
}
.wa-ticks {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  font-size: 12px;
  color: #ffffff99;
  margin-top: 2px;
}
.wa-ticks.read { color: #53bdeb; }
.wa-ticks.failed { color: #ea4335; }
.wa-compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px 12px;
  flex-shrink: 0;
  background: #202c33;
}
.wa-compose[hidden] { display: none; }
.wa-compose textarea {
  flex: 1;
  line-height: 28px;
  min-height: 132px;
  max-height: 132px;
  height: 132px;
  overflow-y: auto;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  resize: none;
  border: 0;
  border-radius: 8px;
  background: #2a3942;
  color: #e9edef;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
}
#inbox-attach, #inbox-mic {
  width: 48px;
  height: 48px;
  border: 0;
  background: transparent;
  color: #8696a0;
  cursor: pointer;
  display: grid;
  place-items: center;
}
#inbox-mic.live { color: #ea4335; }
.wa-rec {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.wa-rec button {
  height: 40px;
  padding: 0 10px;
  border: 0.5px solid #3b4a54;
  background: #2a3942;
  color: #e9edef;
  border-radius: 6px;
  font-size: 13px;
}
#inbox-rec-preview { height: 32px; max-width: 180px; }
#inbox-send { height: 48px; min-width: 88px; }
@media (max-width: 1023px) {
  .wa-list { width: 100%; max-width: 100%; }
  body.inbox-active .wa-shell { flex-direction: column; }
  .wa-thread { min-height: 55vh; }
}
@media (max-width: 1023px) {
  .grid, .form-row { grid-template-columns: 1fr; }
  body { flex-direction: column; }
  .nav { width: 100%; }
}
.wa-select-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  flex-shrink: 0;
  background: #1a1a1a;
  border-bottom: 0.5px solid #333;
}
.wa-select-bar[hidden] { display: none; }
.wa-select-bar #inbox-select-cancel {
  height: 32px;
  padding: 0 12px;
  border: 0.5px solid #444;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font-size: 11px;
  cursor: pointer;
  margin-inline-start: auto;
}
.wa-select-count {
  font-size: 11px;
  color: #cfcfcf;
}
.wa-select-delete {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #e5534b;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.wa-select-delete[hidden] { display: none; }
.wa-select-delete:active { transform: scale(0.98); }
.wa-select-delete svg {
  width: 16px;
  height: 16px;
  display: block;
}
button.wa-chat {
  user-select: none;
  -webkit-user-select: none;
}
.wa-list.is-selecting button.wa-chat {
  grid-template-columns: 16px 48px 1fr auto;
}
.wa-check {
  width: 16px;
  height: 16px;
  border: 0.5px solid #444;
  border-radius: 4px;
  background: transparent;
  display: none;
  place-items: center;
  flex-shrink: 0;
}
.wa-list.is-selecting .wa-check { display: grid; }
.wa-check.on {
  background: #fff;
  border-color: #fff;
}
.wa-check.on::after {
  content: "";
  width: 8px;
  height: 5px;
  border-right: 1.5px solid #111;
  border-bottom: 1.5px solid #111;
  transform: rotate(45deg);
  margin-top: -2px;
}
button.wa-chat.is-checked { background: #2a2a2a; }
.wa-pin {
  width: 14px;
  height: 14px;
  color: #8696a0;
}
.wa-menu {
  position: fixed;
  z-index: 30;
  min-width: 196px;
  background: #2a2a2a;
  border: 0.5px solid #333;
  border-radius: 8px;
  padding: 4px 0;
}
.wa-menu[hidden] { display: none; }
.wa-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-size: 11px;
  font-weight: 400;
  text-align: right;
  cursor: pointer;
}
.wa-menu button:hover { background: #3a3a3a; }
.wa-menu button.danger { color: #e5534b; }
.wa-menu-sep {
  height: 0;
  margin: 4px 0;
  border-top: 0.5px solid #333;
}
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-gate[hidden] { display: none; }
.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 0.5px solid var(--line);
  border-radius: 10px;
  padding: 24px;
}
.auth-card h2 { margin: 0 0 8px; font-size: 20px; font-weight: 500; }
.auth-card label {
  display: block;
  margin: 12px 0;
  color: var(--muted);
  font-size: 14px;
}
.auth-card input {
  display: block;
  width: 100%;
  margin-top: 6px;
  height: 40px;
  border: 0.5px solid var(--line);
  border-radius: 6px;
  background: var(--input);
  color: var(--text);
  padding: 0 10px;
  font-size: 15px;
}
.auth-error { color: var(--danger); min-height: 1.4em; }
.auth-tenant-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.auth-tenant-list button {
  height: 44px;
  text-align: right;
}
#auth-tenant-switch {
  max-width: 220px;
  height: 36px;
  background: var(--input);
  color: var(--text);
  border: 0.5px solid var(--line);
  border-radius: 6px;
}
#btn-logout {
  height: 36px;
  background: transparent;
  color: var(--muted);
  border: 0.5px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  cursor: pointer;
}
