/* ═══════════════════════════════════════════════════════════════
   WPP Connect dashboard
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;

  --bg: #f3f5f4;
  --panel: #ffffff;
  --panel-2: #f7f8f8;
  --elev: #eef1f2;
  --hover: rgba(11, 20, 26, 0.045);
  --active: rgba(11, 20, 26, 0.08);
  --border: rgba(11, 20, 26, 0.08);
  --border-strong: rgba(11, 20, 26, 0.14);
  --text: #111b21;
  --text-2: #3b4a54;
  --muted: #667781;
  --brand: #25d366;
  --brand-strong: #00a884;
  --brand-ink: #ffffff;
  --brand-soft: rgba(0, 168, 132, 0.1);
  --ok: #00a884;
  --ok-soft: rgba(0, 168, 132, 0.12);
  --warn: #c98a00;
  --warn-soft: rgba(233, 165, 0, 0.14);
  --bad: #e5484d;
  --bad-soft: rgba(229, 72, 77, 0.1);
  --info: #3b82f6;
  --info-soft: rgba(59, 130, 246, 0.12);
  --code-bg: #0f1a20;
  --code-text: #d7e0e5;
  --shadow-sm: 0 1px 2px rgba(11, 20, 26, 0.06);
  --shadow: 0 1px 2px rgba(11, 20, 26, 0.05), 0 8px 24px rgba(11, 20, 26, 0.06);
  --shadow-lg: 0 24px 64px rgba(11, 20, 26, 0.18);

  /* WhatsApp chat surface */
  --chat-bg: #efeae2;
  --chat-doodle: rgba(11, 20, 26, 0.06);
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --bubble-text: #111b21;
  --bubble-meta: #667781;
  --tick-read: #53bdeb;
  --quote-bg: rgba(11, 20, 26, 0.05);
  --pill-bg: #ffffff;

  --doodle: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 32a13 13 0 1 1 6 11l-8 3 2-8z'/%3E%3Ccircle cx='150' cy='30' r='7'/%3E%3Cpath d='M150 16v-4M150 48v-4M136 30h-4M168 30h-4'/%3E%3Cpath d='M96 66l5 11 12 2-9 8 2 12-10-6-10 6 2-12-9-8 12-2z'/%3E%3Cpath d='M28 118c0-8 11-8 11 0 0-8 11-8 11 0 0 9-11 15-11 15s-11-6-11-15z'/%3E%3Crect x='132' y='106' width='20' height='30' rx='4'/%3E%3Cpath d='M139 130h6'/%3E%3Crect x='70' y='146' width='44' height='30' rx='5'/%3E%3Cpath d='M74 170l10-10 8 7 10-11 10 12'/%3E%3Ccircle cx='58' cy='74' r='3'/%3E%3Ccircle cx='182' cy='96' r='3'/%3E%3Ccircle cx='14' cy='182' r='3'/%3E%3Cpath d='M96 16q6-7 12 0t12 0'/%3E%3Cpath d='M160 184l7-12 7 12z'/%3E%3Cpath d='M178 140a8 8 0 1 0 0.1 0'/%3E%3Cpath d='M40 160h14M47 153v14'/%3E%3C/svg%3E");
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --rail: 236px;
  --topbar: 64px;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #0b1115;
  --panel: #111b21;
  --panel-2: #0f171c;
  --elev: #1a262d;
  --hover: rgba(255, 255, 255, 0.04);
  --active: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #e9edef;
  --text-2: #c4cdd2;
  --muted: #8696a0;
  --brand-soft: rgba(0, 168, 132, 0.16);
  --ok: #21c08b;
  --ok-soft: rgba(33, 192, 139, 0.14);
  --warn: #f2b33d;
  --warn-soft: rgba(242, 179, 61, 0.14);
  --bad: #ff6369;
  --bad-soft: rgba(255, 99, 105, 0.13);
  --info: #6aa7ff;
  --info-soft: rgba(106, 167, 255, 0.14);
  --code-bg: #0a1014;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.55);

  --chat-bg: #0b141a;
  --chat-doodle: rgba(255, 255, 255, 0.028);
  --bubble-in: #202c33;
  --bubble-out: #005c4b;
  --bubble-text: #e9edef;
  --bubble-meta: rgba(233, 237, 239, 0.6);
  --quote-bg: rgba(0, 0, 0, 0.18);
  --pill-bg: #182229;
  color-scheme: dark;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--brand-strong);
}

code,
pre,
kbd {
  font-family: var(--mono);
}

:focus-visible {
  outline: 2px solid var(--brand-strong);
  outline-offset: 2px;
}

.i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.i-sm {
  width: 15px;
  height: 15px;
}
.i-lg {
  width: 22px;
  height: 22px;
}
.i-xl {
  width: 30px;
  height: 30px;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-track {
  background: transparent;
}

/* ── App shell ─────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 20px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(140deg, #25d366, #00a884);
  box-shadow: 0 6px 16px rgba(0, 168, 132, 0.35);
}
.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.2px;
}
.brand-sub {
  font-size: 11.5px;
  color: var(--muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.nav-item:hover {
  background: var(--hover);
  color: var(--text);
}
.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 600;
}
.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.nav-badge:empty {
  display: none;
}

.rail-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.rail-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 0;
  background: none;
  color: var(--text-2);
  cursor: pointer;
  text-align: left;
  font-weight: 500;
}
.rail-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.rail-btn .key-state {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.rail-btn .key-state.ok {
  background: var(--ok);
}
.rail-btn .key-state.bad {
  background: var(--bad);
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.topbar {
  height: var(--topbar);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  border-bottom: 1px solid var(--border);
}
.topbar-title {
  min-width: 0;
}
.topbar-title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.topbar-title p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.view.flush {
  overflow: hidden;
}
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 28px 64px;
}

/* ── Session switcher ──────────────────────────────────────── */
.switcher {
  position: relative;
}
.switcher-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  cursor: pointer;
  min-width: 200px;
  max-width: 280px;
  box-shadow: var(--shadow-sm);
}
.switcher-btn:hover {
  border-color: var(--brand-strong);
}
.switcher-text {
  min-width: 0;
  text-align: left;
  line-height: 1.25;
  flex: 1;
}
.switcher-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.switcher-sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 260px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.14s ease;
}
.menu[hidden] {
  display: none;
}
.menu.up {
  top: auto;
  bottom: calc(100% + 8px);
  left: 0;
  right: auto;
}
.menu-label {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
}
.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: none;
  cursor: pointer;
  text-align: left;
  color: var(--text);
}
.menu-item:hover {
  background: var(--hover);
}
.menu-item.selected {
  background: var(--brand-soft);
}
.menu-item .grow {
  flex: 1;
  min-width: 0;
}
.menu-item small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
}
.menu-item.danger {
  color: var(--bad);
}
.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}
.menu-ico {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}

/* ── Avatars & dots ────────────────────────────────────────── */
.avatar {
  --size: 40px;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
  font-size: calc(var(--size) * 0.38);
  background: var(--av, #6b7c85);
  position: relative;
  user-select: none;
}
.avatar.sm {
  --size: 32px;
}
.avatar.lg {
  --size: 48px;
}
.avatar .dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  border: 2px solid var(--panel);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.dot.ok {
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-soft);
}
.dot.warn {
  background: var(--warn);
  animation: pulse 1.4s infinite;
}
.dot.info {
  background: var(--info);
  animation: pulse 1.4s infinite;
}
.dot.bad {
  background: var(--bad);
}
@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.08s;
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--brand-strong);
  color: var(--brand-ink);
}
.btn-primary:hover:not(:disabled) {
  background: #008f70;
}
.btn-secondary {
  background: var(--panel);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--hover);
}
.btn-ghost {
  background: none;
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--hover);
  color: var(--text);
}
.btn-danger {
  background: var(--bad-soft);
  color: var(--bad);
}
.btn-danger:hover:not(:disabled) {
  background: var(--bad);
  color: #fff;
}
.btn-danger-solid {
  background: var(--bad);
  color: #fff;
}
.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: 8px;
}
.btn-lg {
  height: 44px;
  padding: 0 20px;
  font-size: 14.5px;
}
.btn-block {
  width: 100%;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background: none;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.icon-btn.sq {
  border-radius: 10px;
}
.icon-btn.sm {
  width: 32px;
  height: 32px;
}
.btn .spinner,
.icon-btn .spinner {
  width: 15px;
  height: 15px;
  border-width: 2px;
}

/* ── Forms ─────────────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.field > label,
.label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.label-opt {
  font-weight: 500;
  color: var(--muted);
}
.hint {
  font-size: 12px;
  color: var(--muted);
}
.hint.err {
  color: var(--bad);
}
.input,
.textarea,
.select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea {
  height: auto;
  min-height: 84px;
  padding: 10px 12px;
  resize: vertical;
}
.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--brand-strong);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.input.mono {
  font-family: var(--mono);
  font-size: 13px;
}
.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.input-row .input {
  flex: 1;
  min-width: 0;
}
.input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}
.input-wrap > .i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.input-wrap > span[data-icon] {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  color: var(--muted);
  pointer-events: none;
}
.input-wrap .input {
  padding-left: 38px;
}

/* ── Sign in ───────────────────────────────────────────────── */
body.locked .app {
  display: none;
}
.login {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  overflow-y: auto;
  background:
    radial-gradient(1100px 520px at 12% -10%, var(--brand-soft), transparent 60%),
    radial-gradient(900px 480px at 110% 110%, var(--info-soft), transparent 60%),
    var(--bg);
}
.login[hidden] {
  display: none;
}
.login-card {
  width: 100%;
  max-width: 400px;
  padding: 32px 30px 30px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 28px;
}
.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: -0.3px;
}
.login-sub {
  margin: 0 0 22px;
  color: var(--muted);
}
.login-error {
  margin-bottom: 16px;
}
.login-error[hidden] {
  display: none;
}
.login-btn {
  width: 100%;
  margin-top: 6px;
  justify-content: center;
}
.rail-user {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--elev);
}
.segmented button {
  flex: 1 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  background: none;
  color: var(--text-2);
  font-weight: 600;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.segmented button:hover {
  color: var(--text);
}
.segmented button.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.dropzone {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 12px;
  border: 1.5px dashed var(--border-strong);
  background: var(--panel-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover,
.dropzone.drag {
  border-color: var(--brand-strong);
  background: var(--brand-soft);
}
.dropzone .dz-ico {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--panel);
  color: var(--brand-strong);
  flex-shrink: 0;
  overflow: hidden;
}
.dropzone .dz-ico img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.dropzone strong {
  display: block;
  font-size: 13.5px;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-pad {
  padding: 22px;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.card-head h2,
.card-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}
.card-head p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}
.card-head .actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.card-ico {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-strong);
  flex-shrink: 0;
}

.section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 36px 0 14px;
}
.section-title:first-child {
  margin-top: 0;
}
.section-title h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.section-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.grid {
  display: grid;
  gap: 16px;
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ── Pills / badges ────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--elev);
  color: var(--text-2);
}
.pill .dot {
  width: 7px;
  height: 7px;
  box-shadow: none;
}
.pill.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.pill.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.pill.info {
  background: var(--info-soft);
  color: var(--info);
}
.pill.bad {
  background: var(--bad-soft);
  color: var(--bad);
}
.method {
  display: inline-block;
  min-width: 58px;
  padding: 3px 0;
  text-align: center;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}
.method.get {
  background: var(--info-soft);
  color: var(--info);
}
.method.post {
  background: var(--ok-soft);
  color: var(--ok);
}
.method.put {
  background: var(--warn-soft);
  color: var(--warn);
}
.method.delete {
  background: var(--bad-soft);
  color: var(--bad);
}

/* ── Stats ─────────────────────────────────────────────────── */
.stat {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
}
.stat-ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.stat-ico.ok {
  background: var(--ok-soft);
  color: var(--ok);
}
.stat-ico.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.stat-ico.info {
  background: var(--info-soft);
  color: var(--info);
}
.stat-ico.brand {
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.stat-num {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.5px;
}
.stat-label {
  font-size: 12.5px;
  color: var(--muted);
}

/* ── Session cards ─────────────────────────────────────────── */
.session-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.session-card {
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 16px;
  transition: border-color 0.15s, transform 0.15s;
}
.session-card:hover {
  border-color: var(--border-strong);
}
.session-card.current {
  border-color: color-mix(in srgb, var(--brand-strong) 45%, transparent);
}
.sc-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sc-name {
  font-weight: 650;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sc-phone {
  font-size: 12.5px;
  color: var(--muted);
}
.sc-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.sc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-2);
  min-width: 0;
}
.sc-row .i {
  color: var(--muted);
}
.sc-row span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.sc-row .muted {
  color: var(--muted);
}
.sc-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}
.sc-actions .btn-primary,
.sc-actions .btn-secondary.grow {
  flex: 1;
}
.new-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 220px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.new-card:hover {
  border-color: var(--brand-strong);
  color: var(--brand-strong);
  background: var(--brand-soft);
}
.new-card .nc-ico {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
}
.new-card strong {
  color: var(--text);
  font-size: 14px;
}

/* ── Empty states ──────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 56px 24px;
  color: var(--muted);
}
.empty-ico {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  margin-bottom: 8px;
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.empty h3 {
  margin: 0;
  font-size: 18px;
  color: var(--text);
  font-weight: 650;
}
.empty p {
  margin: 0 0 12px;
  max-width: 420px;
}

/* ── Callouts ──────────────────────────────────────────────── */
.callout {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  background: var(--info-soft);
  color: var(--text-2);
  align-items: flex-start;
}
.callout .i {
  color: var(--info);
  margin-top: 1px;
}
.callout.ok {
  background: var(--ok-soft);
}
.callout.ok .i {
  color: var(--ok);
}
.callout.warn {
  background: var(--warn-soft);
}
.callout.warn .i {
  color: var(--warn);
}
.callout.bad {
  background: var(--bad-soft);
}
.callout.bad .i {
  color: var(--bad);
}
.callout strong {
  color: var(--text);
}

/* ── Code ──────────────────────────────────────────────────── */
.code {
  position: relative;
  border-radius: 12px;
  background: var(--code-bg);
  color: var(--code-text);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.code-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 12px;
  color: #8696a0;
}
.code-head .copy {
  margin-left: auto;
}
.code pre {
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
  font-size: 12.5px;
  line-height: 1.65;
  max-height: 440px;
}
.code .copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  border: 0;
  background: rgba(255, 255, 255, 0.07);
  color: #c4cdd2;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.code .copy:hover {
  background: rgba(255, 255, 255, 0.13);
}
.code .copy .i {
  width: 14px;
  height: 14px;
}
.tok-key {
  color: #7dd3fc;
}
.tok-str {
  color: #a7f3d0;
}
.tok-num {
  color: #fcd34d;
}
.tok-lit {
  color: #f9a8d4;
}
.tok-com {
  color: #6b7f8a;
  font-style: italic;
}
.tok-kw {
  color: #c4b5fd;
}
.inline-code,
p code,
li code,
td code,
.hint code,
.callout code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--elev);
  font-size: 0.88em;
  color: var(--text);
}

.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tabs button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tabs button:hover {
  color: var(--text);
  background: var(--hover);
}
.tabs button.active {
  color: var(--brand-strong);
  background: var(--brand-soft);
}
.code .tabs button {
  color: #8696a0;
}
.code .tabs button:hover {
  color: #e9edef;
  background: rgba(255, 255, 255, 0.06);
}
.code .tabs button.active {
  color: #25d366;
  background: rgba(37, 211, 102, 0.12);
}

/* ── Tables ────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}
.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table tr:last-child td {
  border-bottom: 0;
}
.table td:first-child {
  white-space: nowrap;
}
.table-wrap {
  overflow-x: auto;
}

/* ── Modal ─────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 14, 18, 0.55);
  backdrop-filter: blur(4px);
  animation: fade 0.15s ease;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}
.modal {
  width: 100%;
  max-width: 480px;
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: rise 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.modal.wide {
  max-width: 820px;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}
.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 22px 22px 0;
}
.modal-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.modal-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.modal-head .icon-btn {
  margin: -6px -6px 0 auto;
}
.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 22px 22px;
}

.steps {
  display: flex;
  gap: 8px;
  padding: 18px 22px 0;
}
.steps span {
  flex: 1;
  height: 4px;
  border-radius: 4px;
  background: var(--elev);
  transition: background 0.3s;
}
.steps span.done {
  background: var(--brand-strong);
}

/* QR step */
.qr-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 28px;
  align-items: center;
}
.qr-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: s;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.qr-steps li {
  counter-increment: s;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  color: var(--text-2);
}
.qr-steps li::before {
  content: counter(s);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 12.5px;
  font-weight: 700;
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.qr-steps strong {
  color: var(--text);
}
.qr-box {
  width: 280px;
  height: 280px;
  border-radius: 18px;
  background: #fff;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
}
.qr-box .qr-wait {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #667781;
  font-size: 13px;
  text-align: center;
  padding: 20px;
}
.qr-box .qr-wait .spinner {
  border-color: rgba(0, 0, 0, 0.1);
  border-top-color: var(--brand-strong);
}
.qr-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-2);
}

.success-burst {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 10px 0 4px;
}
.success-burst .ring {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ok-soft);
  color: var(--ok);
  margin-bottom: 10px;
  animation: rise 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
.success-burst h3 {
  margin: 0;
  font-size: 20px;
}
.success-burst p {
  margin: 0;
  color: var(--muted);
}

/* ── Toasts ────────────────────────────────────────────────── */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  pointer-events: auto;
  animation: toastIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.toast.out {
  animation: toastOut 0.2s ease forwards;
}
.toast .i {
  color: var(--ok);
}
.toast.error .i {
  color: var(--bad);
}
.toast.info .i {
  color: var(--info);
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }
}
@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--brand-strong);
  animation: spin 0.7s linear infinite;
}
.btn-primary .spinner {
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--elev) 25%, var(--hover) 50%, var(--elev) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ═══════════════════════════════════════════════════════════════
   Chats (WhatsApp Web look)
   ═══════════════════════════════════════════════════════════════ */
.chats {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}
.chat-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
}
.cl-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 12px 8px 18px;
}
.cl-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-right: auto;
}
.cl-search {
  padding: 4px 12px 8px;
}
.cl-search .input {
  height: 38px;
  border-radius: 10px;
  background: var(--elev);
  border-color: transparent;
}
.cl-search .input:focus {
  background: var(--panel);
}
.chips {
  display: flex;
  gap: 6px;
  padding: 2px 12px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chip {
  height: 30px;
  padding: 0 13px;
  border-radius: 999px;
  border: 0;
  background: var(--elev);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover {
  background: var(--active);
}
.chip.active {
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 600;
}
.cl-items {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.cl-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px 10px 14px;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
  color: var(--text);
}
.cl-item:hover {
  background: var(--hover);
}
.cl-item.active {
  background: var(--active);
}
.cl-item .avatar {
  --size: 48px;
}
.cl-body {
  flex: 1;
  min-width: 0;
  padding: 2px 0;
}
.cl-line {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cl-name {
  flex: 1;
  min-width: 0;
  font-size: 15.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cl-time {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}
.cl-item.unread .cl-time {
  color: var(--brand);
  font-weight: 600;
}
.cl-preview {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}
.cl-preview > span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.cl-preview .i {
  width: 16px;
  height: 16px;
}
.cl-unread {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.cl-empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.cl-offline {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0 12px 8px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--warn-soft);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.45;
}
.cl-offline .i {
  color: var(--warn);
  margin-top: 1px;
}
.composer-off {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
.cl-more {
  display: flex;
  justify-content: center;
  padding: 14px 0 18px;
  color: var(--muted);
  font-size: 12px;
}
.cl-more:empty {
  padding: 0;
}
.thread-top {
  display: flex;
  justify-content: center;
  min-height: 44px;
  padding: 4px 0 2px;
}
.thread-top .btn {
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.cl-foot {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Chat pane */
.chat-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background-color: var(--chat-bg);
}
.chat-pane::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-color: var(--chat-doodle);
  -webkit-mask: var(--doodle) repeat;
  mask: var(--doodle) repeat;
  -webkit-mask-size: 260px;
  mask-size: 260px;
}
.chat-pane > * {
  position: relative;
}
.cp-head {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  flex-shrink: 0;
  padding: 0 12px 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.cp-head .back {
  display: none;
}
.cp-title {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}
.cp-name {
  font-weight: 600;
  font-size: 15.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cp-sub {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cp-msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 7% 10px;
  display: flex;
  flex-direction: column;
}
.day {
  align-self: center;
  margin: 12px 0 8px;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--pill-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  position: sticky;
  top: 4px;
  z-index: 2;
}
.sys-note {
  align-self: center;
  max-width: 520px;
  margin: 6px 0 12px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--pill-bg);
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  display: flex;
  gap: 8px;
  align-items: center;
}
.sys-note .i {
  width: 14px;
  height: 14px;
  color: var(--warn);
}

.msg {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  max-width: 100%;
}
.msg.tail {
  margin-top: 10px;
}
.msg.out {
  flex-direction: row-reverse;
}
.bubble {
  position: relative;
  max-width: min(65%, 560px);
  padding: 6px 8px 8px 9px;
  border-radius: 8px;
  background: var(--bubble-in);
  color: var(--bubble-text);
  font-size: 14.2px;
  line-height: 1.42;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  overflow-wrap: anywhere;
  animation: bub 0.16s ease;
}
@keyframes bub {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}
.msg.out .bubble {
  background: var(--bubble-out);
}
.msg.tail.in .bubble {
  border-top-left-radius: 0;
}
.msg.tail.out .bubble {
  border-top-right-radius: 0;
}
.msg.tail .bubble::before {
  content: '';
  position: absolute;
  top: 0;
  width: 8px;
  height: 13px;
  background: inherit;
}
.msg.tail.in .bubble::before {
  left: -8px;
  clip-path: polygon(100% 0, 0 0, 100% 100%);
}
.msg.tail.out .bubble::before {
  right: -8px;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.bubble.media-only {
  padding: 3px;
}
.bubble.sticker {
  background: none !important;
  box-shadow: none;
  padding: 0;
}
.bubble.sticker::before {
  display: none;
}
.b-sender {
  font-size: 12.8px;
  font-weight: 600;
  margin-bottom: 2px;
}
.b-text {
  white-space: pre-wrap;
}
.b-text a {
  color: #027eb5;
}
:root[data-theme='dark'] .b-text a {
  color: #53bdeb;
}
.b-text code {
  font-size: 13px;
  padding: 0 3px;
  background: var(--quote-bg);
  border-radius: 4px;
}
.b-meta {
  float: right;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 6px 0 -4px 10px;
  font-size: 11px;
  color: var(--bubble-meta);
  line-height: 1;
  position: relative;
  top: 2px;
}
.b-meta .i {
  width: 16px;
  height: 16px;
}
.b-meta .tick {
  color: var(--tick-read);
}
.b-meta .fail {
  color: var(--bad);
}
.overlay-meta .b-meta,
.b-meta.on-media {
  position: absolute;
  right: 8px;
  bottom: 7px;
  float: none;
  margin: 0;
  top: auto;
  padding: 3px 6px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.35));
}
.bubble.media-only .b-meta.on-media {
  right: 10px;
  bottom: 9px;
}
.b-quote {
  display: block;
  margin: 0 0 5px;
  padding: 6px 10px;
  border-radius: 6px;
  border-left: 4px solid var(--brand-strong);
  background: var(--quote-bg);
  font-size: 13px;
  color: var(--bubble-meta);
  max-height: 64px;
  overflow: hidden;
}
.b-quote b {
  display: block;
  font-size: 12.5px;
  color: var(--brand-strong);
}
.b-img {
  display: block;
  max-width: 100%;
  width: 330px;
  max-height: 360px;
  object-fit: cover;
  border-radius: 6px;
  cursor: zoom-in;
  background: var(--quote-bg);
}
.bubble.sticker .b-img {
  width: 160px;
  height: 160px;
  object-fit: contain;
  background: none;
  cursor: default;
}
.b-video {
  display: block;
  width: 330px;
  max-width: 100%;
  max-height: 360px;
  border-radius: 6px;
  background: #000;
}
.b-media {
  position: relative;
  margin-bottom: 4px;
}
.bubble.media-only .b-media {
  margin-bottom: 0;
}
.bubble:not(.media-only) .b-media {
  margin: -3px -5px 5px -6px;
}
.b-missing {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 6px;
  background: var(--quote-bg);
  font-size: 13px;
  color: var(--bubble-meta);
}

.b-doc {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 300px;
  max-width: 100%;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: var(--quote-bg);
  color: inherit;
  text-decoration: none;
}
.b-doc:hover {
  filter: brightness(0.97);
}
.b-doc .doc-ico {
  width: 36px;
  height: 42px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: #e5484d;
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.b-doc .doc-name {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.b-doc .doc-meta {
  font-size: 11.5px;
  color: var(--bubble-meta);
}
.b-doc .grow {
  flex: 1;
  min-width: 0;
}
.b-doc .dl {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--bubble-meta);
  display: grid;
  place-items: center;
  color: var(--bubble-meta);
  flex-shrink: 0;
}

/* Voice note */
.voice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 300px;
  max-width: 100%;
  padding: 4px 2px 2px;
}
.voice .v-av {
  --size: 46px;
}
.voice .v-av .mic {
  position: absolute;
  right: -4px;
  bottom: -3px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: var(--brand);
}
.voice .v-av .mic .i {
  width: 15px;
  height: 15px;
  stroke-width: 2.6;
}
.v-play {
  width: 34px;
  height: 34px;
  border: 0;
  background: none;
  color: var(--bubble-meta);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.v-play .i {
  width: 26px;
  height: 26px;
  fill: currentColor;
  stroke: none;
}
.v-main {
  flex: 1;
  min-width: 0;
}
.v-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 30px;
  cursor: pointer;
}
.v-wave i {
  flex: 1;
  min-width: 2px;
  border-radius: 2px;
  background: var(--bubble-meta);
  opacity: 0.45;
  transition: opacity 0.1s, background 0.1s;
}
.v-wave i.on {
  opacity: 1;
  background: var(--brand-strong);
}
.msg.out .v-wave i.on {
  background: #53bdeb;
}
.v-foot {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--bubble-meta);
  margin-top: 1px;
}

.msg-act {
  opacity: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: var(--pill-bg);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(11, 20, 26, 0.15);
  transition: opacity 0.12s;
  flex-shrink: 0;
}
.msg:hover .msg-act,
.msg-act:focus-visible {
  opacity: 1;
}
.msg-act .i {
  width: 15px;
  height: 15px;
}
.msg.pending .bubble {
  opacity: 0.85;
}
.msg.failed .bubble {
  cursor: pointer;
  outline: 1.5px solid var(--bad);
}

.jump {
  position: absolute;
  right: 22px;
  bottom: 84px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0;
  background: var(--panel);
  color: var(--muted);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 5;
}
.jump[hidden] {
  display: none;
}

/* Composer */
.composer {
  flex-shrink: 0;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
  padding: 8px 12px;
  position: relative;
  z-index: 6;
}
.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 4px 8px;
}
.reply-bar .b-quote {
  flex: 1;
  margin: 0;
  background: var(--elev);
}
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.composer-input {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0 4px 0 14px;
}
.composer-input textarea {
  flex: 1;
  border: 0;
  outline: none;
  resize: none;
  background: none;
  padding: 10px 0;
  max-height: 140px;
  min-height: 42px;
  line-height: 1.45;
  font-size: 14.5px;
}
.composer .icon-btn {
  width: 42px;
  height: 42px;
}
.send-fab {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--brand-strong);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.1s, background 0.15s;
}
.send-fab:hover {
  background: #008f70;
}
.send-fab:active {
  transform: scale(0.94);
}
.send-fab:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.send-fab .i {
  width: 20px;
  height: 20px;
}
.rec-row {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 6px;
}
.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bad);
  animation: pulse 1s infinite;
}
.rec-time {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.rec-hint {
  flex: 1;
  color: var(--muted);
  font-size: 13px;
}

.attach-menu {
  left: 0;
  right: auto;
  min-width: 230px;
}
.attach-menu .menu-ico .i {
  width: 17px;
  height: 17px;
}

/* Attachment preview (covers the chat pane) */
.preview-sheet {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--panel-2);
  animation: fade 0.15s ease;
}
.ps-head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 60px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.ps-head .ps-title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ps-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 24px;
}
.ps-stage img,
.ps-stage video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.ps-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 36px 48px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
}
.ps-file .big {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.ps-file audio {
  margin-top: 6px;
  width: 280px;
}
.ps-foot {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.ps-foot .input {
  height: 46px;
  border-radius: 12px;
}
.ps-foot .send-fab {
  width: 50px;
  height: 50px;
}

.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  gap: 8px;
  background: var(--panel-2);
  border-bottom: 6px solid var(--brand);
}
.chat-welcome .art {
  width: 132px;
  height: 132px;
  border-radius: 40px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand-strong);
  margin-bottom: 16px;
}
.chat-welcome .art .i {
  width: 58px;
  height: 58px;
  stroke-width: 1.5;
}
.chat-welcome h2 {
  margin: 0;
  font-size: 26px;
  font-weight: 300;
  letter-spacing: -0.3px;
}
.chat-welcome p {
  margin: 0;
  max-width: 460px;
  color: var(--muted);
}
.chat-welcome .foot {
  margin-top: 28px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  background: rgba(8, 12, 15, 0.94);
  animation: fade 0.15s ease;
}
.lb-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  color: #e9edef;
}
.lb-head .grow {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}
.lb-head .icon-btn {
  color: #c4cdd2;
}
.lb-head .icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.lb-stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0 24px 24px;
}
.lb-stage img,
.lb-stage video {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
}

/* ═══════════════════════════════════════════════════════════════
   Webhooks guide
   ═══════════════════════════════════════════════════════════════ */
.flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  position: relative;
}
.flow-step {
  position: relative;
  padding: 18px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
}
.flow-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 36px;
  right: -12px;
  width: 10px;
  height: 10px;
  border-top: 2px solid var(--border-strong);
  border-right: 2px solid var(--border-strong);
  transform: rotate(45deg);
  z-index: 1;
}
.flow-num {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.4px;
}
.flow-ico {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  margin: 8px 0 10px;
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.flow-step h4 {
  margin: 0 0 4px;
  font-size: 14px;
}
.flow-step p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
}

.example {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
}
.example-side {
  padding: 18px;
  min-width: 0;
}
.example-side + .example-side {
  border-left: 1px solid var(--border);
  background: var(--panel-2);
}
.example-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 10px;
}

/* Phone mock that renders a webhook reply */
.phone {
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background-color: var(--chat-bg);
  box-shadow: var(--shadow);
  position: relative;
}
.phone::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-color: var(--chat-doodle);
  -webkit-mask: var(--doodle) repeat;
  mask: var(--doodle) repeat;
  -webkit-mask-size: 220px;
  mask-size: 220px;
}
.phone > * {
  position: relative;
}
.phone-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.phone-head .avatar {
  --size: 32px;
}
.phone-head b {
  display: block;
  font-size: 13.5px;
}
.phone-head small {
  font-size: 11.5px;
  color: var(--muted);
}
.phone-body {
  display: flex;
  flex-direction: column;
  padding: 12px 14px 14px;
  min-height: 230px;
}
.phone-body .bubble {
  max-width: 82%;
  font-size: 13.5px;
}
.phone-body .b-img {
  width: 220px;
  max-height: 160px;
}
.phone-body .voice {
  width: 220px;
}
.phone-body .b-doc {
  width: 230px;
}
.phone-note {
  align-self: center;
  margin-top: auto;
  padding-top: 12px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
}
.fields div {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  min-width: 0;
}
.fields div:nth-child(odd) {
  border-right: 1px solid var(--border);
}
.fields code {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--brand-strong);
  min-width: 92px;
}
.fields span {
  color: var(--text-2);
  min-width: 0;
}

.status-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  margin-bottom: 18px;
}
.status-banner .card-ico.off {
  background: var(--elev);
  color: var(--muted);
}
.status-banner b {
  display: block;
}
.status-banner span {
  font-size: 12.5px;
  color: var(--muted);
  word-break: break-all;
}
.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.fact {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--elev);
  font-size: 12px;
  color: var(--text-2);
}
.fact .i {
  width: 14px;
  height: 14px;
  color: var(--muted);
}
.test-result {
  margin-top: 14px;
}

/* ── API page ──────────────────────────────────────────────── */
.kv {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  min-width: 0;
}
.kv .k {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.kv .v {
  font-family: var(--mono);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kv .grow {
  flex: 1;
  min-width: 0;
}
.playground {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.playground > div {
  padding: 22px;
  min-width: 0;
}
.playground > div + div {
  border-left: 1px solid var(--border);
  background: var(--panel-2);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.endpoint {
  border-bottom: 1px solid var(--border);
}
.endpoint:last-child {
  border-bottom: 0;
}
.endpoint summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  cursor: pointer;
  list-style: none;
}
.endpoint summary::-webkit-details-marker {
  display: none;
}
.endpoint summary:hover {
  background: var(--hover);
}
.endpoint summary .path {
  font-family: var(--mono);
  font-size: 13px;
  white-space: nowrap;
}
.endpoint summary .desc {
  color: var(--muted);
  font-size: 13px;
  margin-left: auto;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.endpoint summary .chev {
  color: var(--muted);
  transition: transform 0.15s;
}
.endpoint[open] summary .chev {
  transform: rotate(90deg);
}
.endpoint .ep-body {
  padding: 0 18px 16px;
}
.ep-group {
  padding: 14px 18px 6px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}

.check-result {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
}
.check-result b {
  display: block;
}
.check-result span {
  font-size: 12.5px;
  color: var(--muted);
  word-break: break-all;
}

.muted {
  color: var(--muted);
}
.mt-0 {
  margin-top: 0;
}
.mb-0 {
  margin-bottom: 0;
}
.row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.wrap {
  flex-wrap: wrap;
}
.grow {
  flex: 1;
  min-width: 0;
}
.hidden {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .flow-step:nth-child(2)::after {
    display: none;
  }
  .example,
  .playground {
    grid-template-columns: minmax(0, 1fr);
  }
  .example-side + .example-side,
  .playground > div + div {
    border-left: 0;
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 860px) {
  :root {
    --topbar: 58px;
  }
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .rail {
    order: 2;
    flex-direction: row;
    justify-content: space-around;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--border);
    gap: 0;
  }
  .brand,
  .rail-foot {
    display: none;
  }
  .nav-item {
    flex-direction: column;
    gap: 3px;
    padding: 6px 4px;
    font-size: 11px;
    flex: 1;
    max-width: 96px;
  }
  .nav-badge {
    position: absolute;
    top: 2px;
    left: 54%;
    margin: 0;
    min-width: 17px;
    height: 17px;
    font-size: 10px;
  }
  .topbar {
    padding: 0 16px;
    gap: 10px;
  }
  .topbar-title p {
    display: none;
  }
  .topbar-title h1 {
    font-size: 17px;
  }
  .topbar .mobile-only {
    display: grid !important;
  }
  .switcher-btn {
    min-width: 0;
    max-width: 190px;
  }
  .page {
    padding: 18px 16px 40px;
  }
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
  .flow {
    grid-template-columns: minmax(0, 1fr);
  }
  .flow-step::after {
    display: none;
  }
  .fields {
    grid-template-columns: minmax(0, 1fr);
  }
  .fields div:nth-child(odd) {
    border-right: 0;
  }
  .qr-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .qr-box {
    margin: 0 auto;
    width: 250px;
    height: 250px;
  }
  .chats {
    grid-template-columns: minmax(0, 1fr);
  }
  .chats.open .chat-list {
    display: none;
  }
  .chats:not(.open) .chat-pane {
    display: none;
  }
  .cp-head .back {
    display: grid;
  }
  .cp-msgs {
    padding: 12px 12px 8px;
  }
  .bubble {
    max-width: 85%;
  }
  .endpoint summary .desc {
    display: none;
  }
  .toasts {
    left: 16px;
    right: 16px;
    bottom: 84px;
  }
  .toast {
    max-width: none;
  }
  .modal {
    border-radius: 18px;
  }
}

@media (max-width: 520px) {
  .grid-4 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
  }
  .stat {
    padding: 14px;
    gap: 10px;
  }
  .stat-ico {
    width: 36px;
    height: 36px;
  }
  .stat-num {
    font-size: 20px;
  }
  .switcher-btn .switcher-text {
    display: none;
  }
  .switcher-btn {
    padding: 4px;
  }
  .session-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .input-row.stack {
    flex-direction: column;
  }
}

.mobile-only {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
