/* 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: 9px;
  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: 9px;
  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: 9px;
  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: 9px;
  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; }
}
