/* WhatsApp Gateway v6 — 3-column layout: sidebar | chat | CRM panel */

/* ═══ SHELL ═══ */
.gw-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
}
.gw-shell .page-header {
  flex-shrink: 0;
  padding-bottom: 10px !important;
}
.gw-shell .page-header__title {
  font-size: clamp(20px, 4.5vw, 26px) !important;
}
.gw-shell .page-header__eyebrow { margin-bottom: 2px; }

/* ═══ CHROME (stats + tools — collapsed by default) ═══ */
.gw-chrome {
  flex-shrink: 0;
  display: none;
  flex-direction: column;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.gw-chrome.gw-chrome--open { display: flex; }

.gw-conn-banner {
  flex-shrink: 0;
  margin: 0 var(--page-x, 16px) 4px;
}

.gw-stats {
  display: flex;
  gap: 6px;
  padding: 6px var(--page-x, 16px) 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.gw-stats::-webkit-scrollbar { display: none; }

.gw-stat {
  flex: 1;
  min-width: 72px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}
.gw-stat:hover { border-color: var(--brand); }
.gw-stat-val {
  font-size: 17px;
  font-weight: 900;
  color: var(--text);
  line-height: 1.1;
}
.gw-stat-lbl {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}
.gw-stat--warn .gw-stat-val { color: var(--danger); }
.gw-stat--ok .gw-stat-val { color: var(--brand); }

.gw-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px var(--page-x, 16px) 8px;
  scrollbar-width: none;
  flex-shrink: 0;
}
.gw-pills::-webkit-scrollbar { display: none; }

.gw-pill {
  background: var(--bg-3);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  flex-shrink: 0;
}
.gw-pill.active, .gw-pill:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

/* ═══ FILTERS ═══ */
.gw-filters {
  display: flex;
  gap: 5px;
  padding: 10px 12px 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.gw-filters::-webkit-scrollbar { display: none; }

.gw-filter {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text-3);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.15s;
}
.gw-filter.active {
  background: rgba(0, 132, 95, 0.12);
  border-color: var(--brand);
  color: var(--brand);
}
.gw-filter-count {
  display: inline-block;
  min-width: 16px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 8px;
  font-size: 10px;
  background: var(--brand);
  color: #fff;
}

/* ═══ 3-COLUMN MESSENGER ═══ */
.gw-messenger {
  flex: 1;
  display: flex;
  min-height: 0;
  margin: 0;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
  background: var(--surface);
}

/* ── Column 1: Sidebar ── */
.gw-sidebar {
  width: 320px;
  min-width: 280px;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg);
  min-height: 0;
  flex-shrink: 0;
}

.gw-sidebar-toolbar {
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.gw-sidebar-toolbar .form-input {
  flex: 1;
  border-radius: 12px;
  font-size: 13px;
  padding: 8px 12px;
  background: var(--bg-3);
  border: 1px solid transparent;
  transition: border-color 0.2s, background 0.2s;
}
.gw-sidebar-toolbar .form-input:focus {
  border-color: var(--brand);
  background: var(--surface);
}

.gw-contact-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

/* ── Contact Cards ── */
.gw-contact {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.12s, border-color 0.12s;
  position: relative;
}
.gw-contact:hover { background: var(--bg-2); }
.gw-contact.active {
  background: var(--bg-2);
  border-left-color: var(--brand);
}

.gw-contact-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bg-3), var(--border));
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 18px;
  color: var(--text-2);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}
.gw-contact.active .gw-contact-avatar { border-color: var(--brand); }
.gw-contact-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gw-contact-avatar .gw-dot-human {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 14px;
  height: 14px;
  background: var(--danger);
  border-radius: 50%;
  border: 2.5px solid var(--bg);
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

.gw-contact-body { flex: 1; min-width: 0; }

.gw-contact-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 3px;
}
.gw-contact-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gw-contact-name.unread { font-weight: 900; }
.gw-contact-time {
  font-size: 10px;
  color: var(--text-4);
  font-weight: 600;
  flex-shrink: 0;
}

.gw-contact-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.gw-contact-preview span {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* ── Badges ── */
.gw-badge {
  flex-shrink: 0;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.gw-badge--client { background: rgba(212, 175, 55, 0.15); color: #b8860b; }
.gw-badge--lead { background: rgba(59, 130, 246, 0.12); color: #2563eb; }
.gw-badge--team { background: rgba(168, 85, 247, 0.12); color: #9333ea; }
.gw-badge--24h { background: rgba(22, 163, 74, 0.12); color: #16a34a; }
.gw-badge--tpl { background: var(--bg-3); color: var(--text-4); }

.gw-unread {
  background: #25D366;
  color: #ffffff !important;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(37, 211, 102, 0.3);
}

/* ── Column 2: Chat ── */
.gw-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #ECE5DD;
  position: relative;
}

.gw-chat-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%2300845f' fill-opacity='1'%3E%3Cpath d='M0 0h10v10H0zM20 20h10v10H20zM40 0h10v10H40zM60 20h10v10H60zM0 40h10v10H0zM20 60h10v10H20zM40 40h10v10H40zM60 60h10v10H60z'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.gw-chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
  color: var(--text-3);
  z-index: 1;
}
.gw-chat-empty-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(0, 132, 95, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
}

/* ── Chat Header ── */
.gw-chat-header {
  position: relative;
  z-index: 2;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.gw-chat-back {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
}

.gw-chat-title { flex: 1; min-width: 0; }
.gw-chat-name {
  font-weight: 900;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gw-chat-sub {
  font-size: 11px;
  color: var(--text-4);
  font-weight: 600;
}

.gw-chat-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.gw-chat-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.gw-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: all 0.15s;
}
.gw-icon-btn:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.gw-icon-btn.active {
  background: rgba(0, 132, 95, 0.15);
  color: var(--brand);
  border-color: var(--brand);
}

/* ── CRM Bar (inline, toggled) ── */
.gw-crm-bar {
  position: relative;
  z-index: 2;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: none;
  gap: 16px;
  flex-shrink: 0;
  font-size: 12.5px;
}
.gw-crm-bar.open { display: flex; flex-wrap: wrap; }

.gw-crm-block { flex: 1; min-width: 180px; }
.gw-crm-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand);
  margin-bottom: 4px;
}
.gw-crm-text {
  color: var(--text-2);
  line-height: 1.45;
  max-height: 60px;
  overflow-y: auto;
}
.gw-crm-context {
  width: 100%;
  min-height: 44px;
  max-height: 80px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text);
  resize: vertical;
  padding: 4px;
}
.gw-crm-context:focus {
  outline: none;
  border-color: rgba(0, 132, 95, 0.35);
  background: var(--surface);
}

/* ── Quick Actions Bar ── */
.gw-quick-bar {
  position: relative;
  z-index: 2;
  display: none;
  gap: 6px;
  padding: 8px 14px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.gw-quick-bar.open { display: flex; }
.gw-quick-bar.collapsed { display: none; }
.gw-quick-bar::-webkit-scrollbar { display: none; }

.gw-contact-alert {
  margin: 0 14px 8px;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.45;
  background: rgba(14, 165, 233, 0.08);
  border: 1px solid rgba(14, 165, 233, 0.25);
  color: var(--text-2);
  flex-shrink: 0;
}
.gw-contact-alert strong {
  display: block;
  font-size: 12.5px;
  color: var(--text);
  margin-bottom: 2px;
}
.gw-contact-alert--warn {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.35);
}

.gw-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: all 0.15s;
}
.gw-quick-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: rgba(0, 132, 95, 0.08);
}

/* ═══ MESSAGES ═══ */
.gw-messages {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

/* Date dividers */
.gw-date-divider {
  align-self: center;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  padding: 5px 16px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-4);
  border: 1px solid rgba(0, 0, 0, 0.06);
  margin: 8px 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Message bubbles — WhatsApp style */
.gw-msg-wrap {
  display: flex;
  flex-direction: column;
  max-width: min(680px, 75%);
  position: relative;
}
.gw-msg-wrap.out { align-self: flex-end; align-items: flex-end; }
.gw-msg-wrap.in { align-self: flex-start; align-items: flex-start; }

.wa-chat-bubble {
  word-break: break-word;
  padding: 8px 12px;
  font-size: 13.5px;
  line-height: 1.45;
  position: relative;
}
/* Outbound — green like WhatsApp */
.gw-msg-wrap.out .wa-chat-bubble {
  background: #D9FDD3;
  color: var(--text);
  border-radius: 10px 10px 2px 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
/* Inbound — white */
.gw-msg-wrap.in .wa-chat-bubble {
  background: var(--surface);
  color: var(--text);
  border-radius: 10px 10px 10px 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Tail triangles */
.gw-msg-wrap.out .wa-chat-bubble::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: -6px;
  width: 0;
  height: 0;
  border-left: 6px solid #D9FDD3;
  border-top: 6px solid transparent;
}
.gw-msg-wrap.in .wa-chat-bubble::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -6px;
  width: 0;
  height: 0;
  border-right: 6px solid var(--surface);
  border-top: 6px solid transparent;
}

.wa-chat-bubble.failed {
  opacity: 0.8;
  border: 1px dashed var(--danger) !important;
}
.wa-chat-bubble.deleted {
  opacity: 0.45;
  font-style: italic;
  background: var(--bg-3) !important;
  color: var(--text-3) !important;
  border: 1px dashed var(--border) !important;
}
.gw-msg-wrap.deleted .gw-msg-time { opacity: 0.4; }

.wa-msg-failed {
  font-size: 11px;
  color: var(--danger);
  margin-top: 4px;
  font-weight: 600;
  line-height: 1.35;
  max-width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

/* Message context menu */
.gw-msg-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  padding: 4px;
  min-width: 160px;
}
.gw-msg-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 9px 14px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}
.gw-msg-menu button:hover { background: var(--bg-3); }

.wa-chat-bubble[data-msg-body] { cursor: pointer; }

.wa-meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 800;
  opacity: 0.85;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.gw-msg-time {
  font-size: 10px;
  color: var(--text-4);
  margin-top: 3px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
}

/* ── Message reactions ── */
.gw-msg-reactions {
  display: flex;
  gap: 3px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.gw-msg-reaction {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* ═══ COMPOSER ═══ */
.gw-composer {
  position: relative;
  z-index: 2;
  display: none;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.gw-composer.open { display: flex; }

.gw-composer-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.gw-composer-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.gw-composer-chips {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.gw-composer-chips::-webkit-scrollbar { display: none; }
.gw-composer-chip {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.gw-composer-chip:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: rgba(0, 132, 95, 0.06);
}

.gw-composer-tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.gw-composer-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border-radius: 22px;
  padding: 10px 18px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s;
}
.gw-composer-input:focus {
  outline: none;
  border-color: var(--brand);
}

.gw-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 132, 95, 0.25);
  transition: transform 0.15s, box-shadow 0.15s;
}
.gw-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 132, 95, 0.35);
}

/* ═══ STATUS CHIPS ═══ */
.gw-status-chip {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  font-weight: 800;
  vertical-align: middle;
}
.gw-status-chip.live {
  background: rgba(0, 132, 95, 0.12);
  color: var(--brand);
}
.gw-status-chip.off {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

.gw-banner {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.gw-banner-text { flex: 1; min-width: 0; }
.gw-banner-title { font-weight: 800; font-size: 13px; color: var(--text); }
.gw-banner-hint { font-size: 11.5px; color: var(--text-3); line-height: 1.4; }

/* ═══ CRM SIDE PANEL (3rd column on desktop) ═══ */
.gw-crm-panel {
  width: 280px;
  min-width: 240px;
  max-width: 320px;
  display: none;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--bg);
  overflow-y: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.gw-crm-panel.open { display: flex; }

.gw-crm-panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.gw-crm-panel-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-4);
}

.gw-crm-panel-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.gw-crm-panel-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand);
  margin-bottom: 8px;
}
.gw-crm-panel-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
}
.gw-crm-panel-textarea {
  width: 100%;
  min-height: 60px;
  max-height: 120px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-3);
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text);
  resize: vertical;
  padding: 8px 10px;
}
.gw-crm-panel-textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: var(--surface);
}

.gw-crm-panel-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

/* ═══ FOCUS MODE (mobile — hide chrome, nav) ═══ */
.gw-shell.gw-focus-chat .page-header,
.gw-shell.gw-focus-chat .gw-chrome {
  display: none !important;
}
.gw-shell.gw-focus-chat .gw-messenger { border-top: none; }
body:has(.gw-focus-chat) .bottom-nav {
  transform: translateY(110%);
  pointer-events: none;
}
body:has(.gw-focus-chat) #app {
  padding-bottom: 0 !important;
}

#btn-gw-chrome.active {
  background: rgba(0, 132, 95, 0.12);
  color: var(--brand);
}

/* ═══ RESPONSIVE ═══ */
@media (min-width: 1200px) {
  .gw-crm-panel.open { display: flex; }
  .gw-messages { padding: 18px 28px 28px; }
  .gw-msg-wrap { max-width: min(680px, 68%); }
}

@media (min-width: 900px) and (max-width: 1199px) {
  .gw-messages { padding: 16px 20px 24px; }
  .gw-msg-wrap { max-width: min(680px, 72%); }
  /* CRM panel hidden on medium screens — use inline CRM bar instead */
  .gw-crm-panel { display: none !important; }
}

@media (max-width: 899px) {
  .gw-shell .page-header {
    padding-top: 8px !important;
    padding-bottom: 6px !important;
  }
  .gw-messenger {
    flex-direction: column;
    margin: 0;
    border-radius: 0;
  }
  .gw-sidebar {
    width: 100%;
    max-width: none;
    min-width: 0;
    flex: 1;
    border-right: none;
  }
  .gw-chat {
    display: none;
    flex: 1;
    min-height: 0;
  }
  .gw-messenger.gw-chat-open .gw-sidebar { display: none; }
  .gw-messenger.gw-chat-open .gw-chat { display: flex; }
  .gw-messenger.gw-chat-open .gw-chat-back { display: flex !important; }
  .gw-messages {
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .gw-msg-wrap { max-width: 88%; }
  .gw-composer {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .gw-crm-panel { display: none !important; }

  /* On mobile, show CRM bar inline (existing behavior) */
  .gw-crm-bar.open { display: flex; flex-wrap: wrap; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODÈLES DE MESSAGES (écran #templates) — portefeuille Meta / suggestions
   ═══════════════════════════════════════════════════════════════════════════ */
.wt-body { display: flex; flex-direction: column; gap: 16px; max-width: 1180px; }
.wt-body > * { flex-shrink: 0; }
.wt-mono, .wt-card__name, .wt-account code { font-family: var(--font-mono); }

/* Compte connecté */
.wt-account {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; border-radius: var(--radius-lg);
  background: var(--bg-2); border: 1px solid var(--border);
}
.wt-account__icon {
  flex-shrink: 0; width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; background: var(--bg-3); color: var(--text-3);
}
.wt-account--on .wt-account__icon { background: var(--success-bg); color: var(--success); }
.wt-account--off { border-style: dashed; }
.wt-account--off .wt-account__icon { background: var(--warning-bg); color: var(--warning); }
.wt-account__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.wt-account__title { font-size: 15px; font-weight: 800; color: var(--text); line-height: 1.3; }
.wt-account__sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.wt-account__sub code { font-size: 12px; color: var(--text-2); }
.wt-account__side { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.wt-account__side--stack { flex-direction: column; align-items: stretch; gap: 8px; }
.wt-account__side--stack .btn { justify-content: center; white-space: nowrap; }
.wt-account__sub--stack { flex-direction: column; align-items: flex-start; gap: 6px; max-width: 78ch; }
.wt-account__hint { display: block; color: var(--text-2); }
.wt-account__sync { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.wt-outline { border: 1px solid var(--border) !important; }

/* Pastilles et étiquettes */
.wt-pill {
  display: inline-flex; align-items: center; padding: 4px 10px; border-radius: var(--radius-pill, 999px);
  font-size: 11px; font-weight: 700; white-space: nowrap; background: var(--bg-3); color: var(--text-2);
}
.wt-pill--ok { background: var(--success-bg); color: var(--success); }
.wt-pill--warn { background: var(--warning-bg); color: var(--warning); }
.wt-pill--bad { background: var(--danger-bg); color: var(--danger); }
.wt-tag {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; color: var(--text-3); background: var(--bg-3);
}
.wt-tag--util { color: var(--info, #2563EB); background: var(--info-bg, rgba(37, 99, 235, .10)); }
.wt-tag--mkt { color: #9333EA; background: rgba(147, 51, 234, .10); }
.wt-tag--edited { color: var(--warning); background: var(--warning-bg); }
.wt-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--text-4); }
.wt-ready__stat { display: inline-flex; align-items: center; white-space: nowrap; margin-right: 16px; }
.wt-dot--warn { background: var(--warning); }
.wt-dot--bad { background: var(--danger); }
.wt-dot--neutral { background: var(--border-3, var(--text-4)); }

/* État du câblage */
.wt-ready { padding: 16px 18px; border-radius: var(--radius-lg); background: var(--bg-2); border: 1px solid var(--border); }
.wt-ready__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.wt-ready__title { font-size: 14px; font-weight: 800; color: var(--text); }
.wt-ready__sub { font-size: 12.5px; color: var(--text-3); margin-top: 4px; line-height: 1.5; max-width: 62ch; }
.wt-ready__score { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; color: var(--text-3); font-size: 12.5px; }
.wt-ready__score strong { font-size: 26px; font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1; }
.wt-ready__bar { height: 6px; border-radius: 999px; background: var(--bg-3); overflow: hidden; margin: 14px 0 12px; }
.wt-ready__bar span { display: block; height: 100%; border-radius: 999px; background: var(--success); transition: width .4s var(--ease-out, ease); }
.wt-ready__foot { display: flex; flex-wrap: wrap; align-items: center; row-gap: 8px; font-size: 12.5px; color: var(--text-2); }
.wt-ready__foot .btn { margin-left: auto; }

/* Onglets */
.wt-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-top: 4px; overflow-x: auto; scrollbar-width: none; }
.wt-tabs::-webkit-scrollbar { display: none; }
.wt-tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 14px; margin-bottom: -1px;
  background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 700; color: var(--text-3); white-space: nowrap; min-height: 46px; flex-shrink: 0;
}
.wt-tab:hover { color: var(--text); }
.wt-tab.active { color: var(--text); border-bottom-color: var(--brand); }
.wt-tab:focus-visible, .wt-chip:focus-visible, .wt-icon-action:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.wt-tab__count {
  min-width: 22px; padding: 1px 7px; border-radius: 999px; text-align: center;
  font-size: 11.5px; font-weight: 800; background: var(--bg-3); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.wt-tab.active .wt-tab__count { background: var(--brand); color: var(--text-on-brand, #fff); }
.wt-tab-help { margin: -4px 0 0; font-size: 12.5px; color: var(--text-3); line-height: 1.5; }

/* Recherche et filtres */
.wt-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.wt-search {
  display: flex; align-items: center; gap: 8px; flex: 1 1 240px; max-width: 340px; height: 40px; padding: 0 12px;
  border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); color: var(--text-3);
}
.wt-search:focus-within { border-color: var(--brand); }
.wt-search input { flex: 1; min-width: 0; border: none; outline: none; background: none; font: inherit; font-size: 13.5px; color: var(--text); }
.wt-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.wt-chip {
  display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--border); cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-2); white-space: nowrap;
}
.wt-chip:hover { border-color: var(--border-3, var(--text-4)); }
.wt-chip.active { background: var(--text); border-color: var(--text); color: var(--bg-2); }

/* Cartes */
.wt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr)); gap: 14px; align-items: start; }
.wt-card {
  display: flex; flex-direction: column; gap: 12px; padding: 16px;
  border-radius: var(--radius-lg); background: var(--bg-2); border: 1px solid var(--border);
}
.wt-card--bad { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.wt-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.wt-card__titles { min-width: 0; }
.wt-card__title { margin: 0; font-size: 15px; font-weight: 800; color: var(--text); line-height: 1.3; }
.wt-card__name { display: block; margin-top: 3px; font-size: 11.5px; color: var(--text-3); word-break: break-all; }
.wt-card__meta { display: flex; flex-wrap: wrap; gap: 6px; }
.wt-card__foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding-top: 12px; border-top: 1px solid var(--border); margin-top: auto;
}
.wt-card__use { display: flex; align-items: flex-start; gap: 6px; flex: 1 1 200px; font-size: 12px; color: var(--text-3); line-height: 1.45; }
.wt-card__use svg { flex-shrink: 0; margin-top: 2px; }
.wt-card__use strong { color: var(--text-2); font-weight: 700; }
.wt-card__actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.wt-card__actions .btn { gap: 6px; }
.wt-icon-action {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: none; border: 1px solid var(--border); color: var(--text-3); cursor: pointer;
}
.wt-icon-action:hover { color: var(--text); border-color: var(--border-3, var(--text-4)); }
.wt-icon-action--danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }

/* Bulle façon WhatsApp */
.wt-bubble {
  align-self: flex-start; max-width: 100%; padding: 10px 12px 8px; border-radius: 4px 14px 14px 14px;
  background: #E7FFDB; color: #111B21; font-size: 13.5px; line-height: 1.5; box-shadow: 0 1px 1px rgba(11, 20, 26, .10);
}
[data-theme="dark"] .wt-bubble { background: #005C4B; color: #E9EDEF; box-shadow: none; }
.wt-bubble__body { white-space: normal; overflow-wrap: anywhere; }
.wt-bubble__body--muted { opacity: .75; font-style: italic; }
.wt-bubble__footer { margin-top: 6px; font-size: 11.5px; opacity: .62; }
.wt-bubble__btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; margin: 8px -12px -8px; padding: 9px 12px;
  border-top: 1px solid rgba(11, 20, 26, .10); font-size: 13px; font-weight: 600; color: #027EB5;
}
[data-theme="dark"] .wt-bubble__btn { border-top-color: rgba(255, 255, 255, .12); color: #53BDEB; }
.wt-var { padding: 0 4px; border-radius: 4px; background: rgba(2, 126, 181, .14); color: inherit; font-weight: 600; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
[data-theme="dark"] .wt-var { background: rgba(255, 255, 255, .16); }

/* Notes (rejet, reclassement, contrôle) */
.wt-note { display: flex; align-items: flex-start; gap: 8px; padding: 9px 11px; border-radius: 10px; font-size: 12.5px; line-height: 1.5; color: var(--text-2); background: var(--bg-3); }
.wt-note[hidden] { display: none; }
.wt-note svg { flex-shrink: 0; margin-top: 2px; }
.wt-note--bad { background: var(--danger-bg); } .wt-note--bad svg { color: var(--danger); }
.wt-note--warn { background: var(--warning-bg); } .wt-note--warn svg { color: var(--warning); }
.wt-note--ok { background: var(--success-bg); } .wt-note--ok svg { color: var(--success); }

/* États vides et chargement */
.wt-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 48px 20px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius-lg); }
.wt-empty__icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--bg-3); color: var(--text-3); }
.wt-empty__title { font-size: 15px; font-weight: 800; color: var(--text); }
.wt-empty__text { font-size: 13px; color: var(--text-3); line-height: 1.55; max-width: 52ch; }
.wt-empty .btn { margin-top: 8px; }
.wt-skel { border-radius: 8px; background: var(--bg-3); animation: wt-pulse 1.2s ease-in-out infinite; }
.wt-skel--line { height: 12px; margin-bottom: 8px; }
.wt-skel--block { height: 84px; }
@keyframes wt-pulse { 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .wt-skel { animation: none; } .wt-ready__bar span { transition: none; } }

/* Éditeur et test (dans une feuille) */
.wt-editor { padding: 22px 22px 28px; display: flex; flex-direction: column; gap: 14px; }
.wt-editor--narrow { max-width: 520px; margin: 0 auto; width: 100%; }
.wt-editor__title { margin: 0; font-size: 19px; font-weight: 900; color: var(--text); }
.wt-editor__lead { margin: -8px 0 0; font-size: 13px; color: var(--text-3); line-height: 1.55; }
.wt-editor__cols { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.wt-editor__form { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.wt-editor__form .form-group, .wt-editor .form-group { margin: 0; }
.wt-editor__side { position: sticky; top: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.wt-editor__label { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.wt-editor__issues { display: flex; flex-direction: column; gap: 6px; }
.wt-editor__actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.wt-editor__actions .btn { gap: 6px; }
.wt-phone { padding: 16px 14px; border-radius: 16px; background: #EFE7DD; min-height: 120px; display: flex; }
[data-theme="dark"] .wt-phone { background: #0B141A; }
.wt-hint { font-size: 12px; color: var(--text-3); line-height: 1.45; margin-top: 5px; }
.wt-optional { font-weight: 500; color: var(--text-4); font-size: 11.5px; }
.wt-varbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.wt-varbar .wt-hint { margin: 0; }
.wt-examples { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.wt-example { display: flex; align-items: center; gap: 8px; }
.wt-example span { flex-shrink: 0; min-width: 40px; font-family: var(--font-mono); font-size: 12px; color: var(--text-3); }

@media (max-width: 760px) {
  .wt-account { flex-wrap: wrap; }
  .wt-account__side { width: 100%; justify-content: space-between; }
  .wt-account > .btn { width: 100%; justify-content: center; }
  .wt-ready__head { flex-direction: column; gap: 10px; }
  .wt-ready__foot .btn { margin-left: 0; width: 100%; justify-content: center; }
  .wt-search { max-width: none; }
  .wt-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; width: calc(100% + 32px); }
  .wt-chips::-webkit-scrollbar { display: none; }
  .wt-editor { padding: 18px 16px 24px; }
  .wt-editor__cols { grid-template-columns: 1fr; }
  .wt-editor__side { position: static; }
  .wt-editor__actions .btn { flex: 1 1 100%; justify-content: center; }
  .wt-card__actions .btn span { white-space: nowrap; }
  #wt-new span { display: none; }
}

/* Sélecteur de modèle dans une conversation */
.gw-tplpick { padding: 20px 20px 28px; display: flex; flex-direction: column; gap: 12px; max-width: 560px; margin: 0 auto; width: 100%; }
.gw-tplpick .form-group { margin: 0; }
.gw-tplpick__title { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 900; color: var(--text); }
.gw-tplpick__lead, .gw-tplpick__empty { font-size: 13px; color: var(--text-3); line-height: 1.55; }
.gw-tplpick__list { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow-y: auto; }
.gw-tplpick__item {
  display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; text-align: left; cursor: pointer;
  border-radius: 12px; border: 1px solid var(--border); background: var(--bg-2); font: inherit; color: inherit;
}
.gw-tplpick__item[hidden] { display: none; }
.gw-tplpick__item:hover { border-color: var(--brand); }
.gw-tplpick__name { font-size: 14px; font-weight: 800; color: var(--text); }
.gw-tplpick__body { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
.gw-tplpick__preview { padding: 12px 14px; border-radius: 4px 14px 14px 14px; background: #E7FFDB; color: #111B21; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
[data-theme="dark"] .gw-tplpick__preview { background: #005C4B; color: #E9EDEF; }
.gw-tplpick__ex { font-weight: 500; color: var(--text-4); font-size: 11.5px; }
.gw-tplpick__actions { display: flex; justify-content: flex-end; gap: 10px; }
.gw-tplpick__actions .btn { gap: 6px; }

/* ═══════════════════════════════════════════════════════════════════════════
   CONFIGURATION WHATSAPP (feuille) — sections à onglets
   Les règles !important neutralisent les styles en ligne hérités du formulaire d'origine.
   ═══════════════════════════════════════════════════════════════════════════ */
.sheet.gwc-sheet { max-width: 760px; width: 100%; }
.sheet.gwc-sheet .sheet-body { padding: 0 !important; }
.gwc { display: flex; flex-direction: column; gap: 0; padding: 0 20px; min-height: 100%; }
.gwc-head { position: sticky; top: 0; z-index: 3; margin: 0 -20px; padding: 20px 20px 0; background: var(--bg); border-bottom: 1px solid var(--border); }
.gwc-title { margin: 0 0 12px; font-size: 20px; font-weight: 900; color: var(--text); }
.gwc-tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.gwc-tabs::-webkit-scrollbar { display: none; }
.gwc-tab {
  flex-shrink: 0; min-height: 44px; padding: 0 14px; margin-bottom: -1px; background: none; border: none; border-bottom: 2px solid transparent;
  font: inherit; font-size: 13.5px; font-weight: 700; color: var(--text-3); cursor: pointer; white-space: nowrap;
}
.gwc-tab:hover { color: var(--text); }
.gwc-tab.active { color: var(--text); border-bottom-color: var(--brand); }
.gwc-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.gwc-panes { padding-top: 18px; }
.gwc-pane { display: flex; flex-direction: column; gap: 14px; }
.gwc-pane[hidden] { display: none; }
.gwc-lead { margin: 0; font-size: 13px; color: var(--text-3); line-height: 1.55; }
.gwc .gwc-card {
  margin: 0 !important; padding: 18px !important; border-radius: var(--radius-lg) !important;
  background: var(--bg-2) !important; border: 1px solid var(--border) !important; box-shadow: none !important;
}
.gwc .gwc-card h3 {
  margin: 0 0 14px !important; padding: 0 !important; border: none !important;
  font-size: 14.5px !important; font-weight: 800 !important; text-transform: none !important; letter-spacing: 0 !important; color: var(--text) !important;
}
.gwc #gw-account-status > div:first-child { margin-bottom: 10px !important; font-size: 14.5px !important; font-weight: 800 !important; text-transform: none !important; color: var(--text) !important; }
.gwc .gwc-card p, .gwc .gwc-card .form-group > div:not([style*="position:relative"]) { font-size: 12px !important; color: var(--text-3) !important; }
.gwc .form-label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.gwc .cfg-set-badge { background: var(--success-bg) !important; color: var(--success) !important; font-size: 10.5px !important; font-weight: 700 !important; }
.gwc .cfg-toggle-eye { display: grid; place-items: center; width: 30px; height: 30px; }
.gwc--evo .gwc-pane[data-pane="canaux"] .gwc-evo-note { display: block; }
.gwc-evo-note { display: none; padding: 14px 16px; border-radius: 12px; background: var(--bg-3); font-size: 13px; color: var(--text-2); line-height: 1.55; }
.gwc-tools { display: flex; flex-wrap: wrap; gap: 10px; }
.gwc-tools .btn { flex: 1 1 220px; margin: 0 !important; min-height: 44px; }
.gwc-tools #gw-test-result { flex: 1 1 100%; order: 3; margin: 0 !important; }
.gwc--evo .gwc-tools { display: none; }
.gwc-panes { flex: 1; }
.gwc-footer { position: sticky; bottom: 0; z-index: 3; margin: 18px -20px 0; padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--bg); border-top: 1px solid var(--border); }
.gwc-footer .btn { height: 48px !important; }
@media (max-width: 760px) { .gwc-tab { padding: 0 11px; } }

/* Diffusions (onglet de l'écran Modèles) */
.wt-toolbar[hidden] { display: none; }
.wt-history { grid-column: 1 / -1; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-2); overflow: hidden; }
.wt-history__row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-top: 1px solid var(--border); }
.wt-history__row:first-child { border-top: none; }
.wt-history__main { flex: 1; min-width: 0; }
.wt-history__title { font-size: 14px; font-weight: 800; color: var(--text); }
.wt-history__sub { font-size: 12px; color: var(--text-3); margin-top: 3px; line-height: 1.45; }
.wt-history__stats { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.wt-history__failed { color: var(--danger); }
.wt-inline { display: flex; gap: 8px; }
.wt-inline .form-input { flex: 1; min-width: 0; }
.wt-inline .btn { flex-shrink: 0; white-space: nowrap; }
.wt-b-text { margin-top: 8px; }
@media (max-width: 760px) {
  .wt-history__row { flex-wrap: wrap; gap: 8px 14px; }
  .wt-history__main { flex-basis: 100%; }
  .wt-inline { flex-direction: column; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   NAVIGATION DU MODULE WHATSAPP — la même barre sur tous ses écrans
   ═══════════════════════════════════════════════════════════════════════════ */
.wa-nav {
  flex-shrink: 0; display: flex; gap: 4px; padding: 8px var(--page-x, 16px);
  overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); background: var(--bg);
}
.wa-nav::-webkit-scrollbar { display: none; }
.wa-nav__item {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 12px;
  border-radius: 10px; border: 1px solid transparent; background: none; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text-3); white-space: nowrap;
}
.wa-nav__item:hover { color: var(--text); background: var(--bg-3); }
.wa-nav__item.active { color: var(--text); background: var(--bg-2); border-color: var(--border); font-weight: 700; }
.wa-nav__item.active svg { color: var(--brand); }
.wa-nav__item:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ═══════════════════════════════════════════════════════════════════════════
   LABORATOIRE DE L'ASSISTANT (écran #sabi-lab)
   ═══════════════════════════════════════════════════════════════════════════ */
.sl-body { display: flex; flex-direction: column; gap: 14px; max-width: 1240px; }
.sl-body > * { flex-shrink: 0; }
.sl-intro, .sl-engine-help { margin: 0; font-size: 13px; color: var(--text-3); line-height: 1.55; }
.sl-engine-help strong { color: var(--warning); font-weight: 700; }
.sl-setup { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.sl-field { display: flex; flex-direction: column; gap: 5px; flex: 1 1 200px; max-width: 280px; font-size: 12px; font-weight: 700; color: var(--text-3); }
.sl-field .form-input { height: 40px; }
.sl-setup > .btn { height: 40px; gap: 6px; }
.sl-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.sl-chat { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-2); overflow: hidden; }
.sl-thread { display: flex; flex-direction: column; gap: 8px; padding: 16px; height: min(52vh, 520px); overflow-y: auto; background: #EFE7DD; }
[data-theme="dark"] .sl-thread { background: #0B141A; }
.sl-thread__empty { margin: auto; max-width: 34ch; text-align: center; font-size: 13px; line-height: 1.55; color: #54656F; }
[data-theme="dark"] .sl-thread__empty { color: #8696A0; }
.sl-msg { max-width: 82%; padding: 8px 11px; border-radius: 12px; font: inherit; font-size: 13.5px; line-height: 1.5; text-align: left; overflow-wrap: anywhere; border: 2px solid transparent; }
.sl-msg--in { align-self: flex-end; background: #D9FDD3; color: #111B21; border-bottom-right-radius: 4px; }
.sl-msg--out { align-self: flex-start; background: #fff; color: #111B21; border-bottom-left-radius: 4px; cursor: pointer; box-shadow: 0 1px 1px rgba(11, 20, 26, .10); }
.sl-msg--out.selected { border-color: var(--brand); }
.sl-msg--typing { cursor: default; letter-spacing: 3px; color: #54656F; }
[data-theme="dark"] .sl-msg--in { background: #005C4B; color: #E9EDEF; }
[data-theme="dark"] .sl-msg--out { background: #202C33; color: #E9EDEF; box-shadow: none; }
.sl-composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.sl-composer .form-input { flex: 1; min-width: 0; height: 44px; }
.sl-composer .btn { width: 48px; height: 44px; padding: 0; justify-content: center; flex-shrink: 0; }
.sl-trace { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-2); min-height: 220px; }
.sl-trace__empty { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 30ch; text-align: center; font-size: 13px; color: var(--text-3); line-height: 1.5; }
.sl-trace__head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.sl-trace__label { font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.sl-trace__intent { font-size: 18px; font-weight: 900; color: var(--text); margin-top: 2px; }
.sl-conf { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.sl-conf__bar { width: 90px; height: 6px; border-radius: 999px; background: var(--bg-3); overflow: hidden; }
.sl-conf__bar span { display: block; height: 100%; border-radius: 999px; background: var(--success); }
.sl-conf__bar span.low { background: var(--warning); }
.sl-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sl-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.sl-steps li { display: flex; gap: 10px; align-items: flex-start; }
.sl-steps__icon { flex-shrink: 0; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--bg-3); color: var(--text-3); }
.sl-steps__title { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.35; }
.sl-steps__detail { font-size: 12px; color: var(--text-3); line-height: 1.45; margin-top: 2px; overflow-wrap: anywhere; }
.sl-tool { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.sl-tool summary { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; cursor: pointer; font-size: 12px; color: var(--text-3); list-style: none; }
.sl-tool summary::-webkit-details-marker { display: none; }
.sl-tool summary code, .sl-tools code { font-family: var(--font-mono); font-size: 12.5px; color: var(--text); font-weight: 600; }
.sl-tool pre { margin: 0; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--bg-3); font-family: var(--font-mono); font-size: 11.5px; line-height: 1.5; color: var(--text-2); overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; }
.sl-effects { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.sl-effects li { display: flex; align-items: flex-start; gap: 6px; line-height: 1.45; }
.sl-effects svg { flex-shrink: 0; margin-top: 3px; color: var(--warning); }
.sl-trace__actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); margin-top: auto; }
.sl-trace__actions .btn { gap: 6px; }
.sl-listhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.sl-listhead p { margin: 0; font-size: 13px; color: var(--text-3); line-height: 1.55; max-width: 70ch; }
.sl-listhead__actions { display: flex; gap: 8px; flex-shrink: 0; }
.sl-listhead__actions .form-input { height: 36px; min-width: 200px; }
.sl-listhead .btn { gap: 6px; flex-shrink: 0; }
.sl-off { opacity: .55; }
.sl-fail { margin-top: 6px; font-size: 12px; color: var(--danger); line-height: 1.45; }
.sl-quote { padding: 10px 12px; border-radius: 10px; background: var(--bg-3); font-size: 13.5px; color: var(--text); }
.sl-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 14px; align-items: start; }
.sl-cards .wt-ready { display: flex; flex-direction: column; gap: 10px; }
.sl-cards .wt-ready__sub { margin: 0; max-width: none; }
.sl-cards .wt-ready__sub code { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); }
.sl-cards > section:last-child { grid-column: 1 / -1; }
.sl-radios { display: flex; flex-direction: column; gap: 6px; }
.sl-radio { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 13.5px; color: var(--text); }
.sl-radio:has(input:checked) { border-color: var(--brand); background: var(--success-bg); font-weight: 700; }
.sl-radio input { width: 18px; height: 18px; accent-color: var(--brand); }
.sl-checks { display: flex; flex-direction: column; gap: 10px; }
.sl-check { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--text); }
.sl-tools { border: 1px solid var(--border); }
@media (max-width: 900px) {
  .sl-grid { grid-template-columns: 1fr; }
  .sl-thread { height: 44vh; }
  .sl-field { max-width: none; flex-basis: 100%; }
  .sl-setup > .btn { width: 100%; justify-content: center; }
  .sl-listhead { flex-direction: column; }
  .sl-listhead__actions { width: 100%; }
  .sl-listhead__actions .form-input { flex: 1; min-width: 0; }
}

/* Connaissances de l'assistant (feuille ouverte depuis la navigation WhatsApp) */
.kb { max-width: 760px; margin: 0 auto; width: 100%; }
.kb .form-group { margin: 0; }
.kb-test { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: var(--radius-lg); background: var(--bg-2); border: 1px solid var(--border); }
.kb-pane { display: flex; flex-direction: column; gap: 12px; }
.kb-pane[hidden] { display: none; }
.kb-pane .btn, .kb-test .btn { align-self: flex-start; gap: 6px; }
.kb-listtitle { margin-top: 6px; }
.kb-base { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-2); margin-bottom: 10px; overflow: hidden; }
.kb-base__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; }
.kb-base__head strong { display: block; font-size: 14px; color: var(--text); }
.kb-base__head span { font-size: 12px; color: var(--text-3); }
.kb-doc { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-top: 1px solid var(--border); }
.kb-doc__name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; background: none; border: none; padding: 0; cursor: pointer; font: inherit; font-size: 13px; color: var(--text); text-align: left; }
.kb-doc__name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-doc__name:hover span { text-decoration: underline; }
.kb-doc__meta { flex-shrink: 0; font-size: 11.5px; color: var(--text-3); }
.kb-doc .wt-icon-action { width: 28px; height: 28px; }
.kb-preview { margin: 0; padding: 12px 14px; border-top: 1px solid var(--border); background: var(--bg-3); font: 12.5px/1.55 var(--font-body, inherit); color: var(--text-2); white-space: pre-wrap; max-height: 260px; overflow-y: auto; }
.kb-hit { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); margin-top: 6px; }
.kb-hit--used { border-color: var(--brand); background: var(--success-bg); }
.kb-hit__head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); }
.kb-hit__head strong { color: var(--text); font-size: 13px; }
.kb-hit p { margin: 6px 0 0; font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.ord-ref { font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; color: var(--text-3); margin-left: 6px; }
.ord-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ord-actions .btn { gap: 6px; }
#ord-list .wt-history__row { flex-wrap: wrap; row-gap: 10px; }
#ord-list .wt-history__main { flex: 1 1 100%; }
#ord-list .ord-actions { margin-left: auto; }
.sl-pair__controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 8px; }
.sl-pair__controls .form-input { height: 36px; max-width: 260px; }
.sl-pair__check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.sl-pair__check input { width: 16px; height: 16px; accent-color: var(--brand); }
#sl-imp-team { height: auto; }
.sl-team { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; margin: 0; display: flex; flex-direction: column; gap: 8px; background: var(--bg-2); }
.sl-team legend { padding: 0 6px; font-size: 13px; font-weight: 700; color: var(--text); }
