:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --line: #d9e1ec;
  --text: #17202f;
  --muted: #667085;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #2563eb;
  --danger: #b42318;
  --ok: #067647;
}

/* Elementos ocultados pela busca e pelos filtros devem prevalecer sobre
   componentes que definem display (grid, flex etc.). */
[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .crm-filters {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .crm-filters {
    grid-template-columns: 1fr;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

@media (pointer: coarse) {
  html, body { touch-action: pan-y pinch-zoom; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.chat-layout, .chat-layout * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.chat-layout input, .chat-layout textarea, .chat-layout select, .chat-layout [contenteditable="true"] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }

a {
  color: var(--accent);
  text-decoration: none;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  background: #15202b;
  color: #eef2f7;
  padding: 24px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--primary);
  font-weight: 800;
}

.brand small {
  display: block;
  color: #aeb7c5;
  margin-top: 2px;
}

nav {
  display: grid;
  gap: 6px;
}

nav a,
.logout-form button {
  color: #d6dde8;
  padding: 11px 12px;
  border-radius: 8px;
}

nav a:hover,
.logout-form button:hover {
  background: #223142;
  color: #fff;
}

.logout-form {
  margin: 0;
}

.logout-form button {
  width: 100%;
  min-height: 0;
  justify-content: flex-start;
  border: 0;
  background: transparent;
  font-weight: 400;
}

.content {
  margin-left: 248px;
  padding: 32px;
}

.chat-page {
  overflow: hidden;
}

/* Keep list/conversation navigations polished without adding another loader. */
@view-transition {
  navigation: auto;
}

@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 160ms;
    animation-timing-function: ease-out;
  }
}

.chat-page .content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  padding-right: 0;
}

.central-loading {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(15, 118, 110, .96), rgba(17, 94, 89, .98));
  color: #fff;
  opacity: 1;
  visibility: visible;
  transition: opacity .28s ease, visibility .28s ease;
}

.central-loading.is-ready {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.central-loading-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 28px 34px;
  text-align: center;
}

.central-loading-card strong { font-size: 1.08rem; letter-spacing: .01em; }
.central-loading-card > span:last-child { color: rgba(255, 255, 255, .78); font-size: .88rem; }
.central-loading-mark { display: flex; align-items: end; gap: 4px; height: 30px; }
.central-loading-mark span { width: 6px; height: 12px; border-radius: 999px; background: #fff; animation: central-loading-wave 1s ease-in-out infinite; }
.central-loading-mark span:nth-child(2) { height: 24px; animation-delay: .14s; }
.central-loading-mark span:nth-child(3) { height: 17px; animation-delay: .28s; }
@keyframes central-loading-wave { 50% { transform: scaleY(.55); opacity: .55; } }

.chat-page .content > .page-header {
  flex: 0 0 auto;
}

.mobile-bottom-nav { display: none; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 18px;
  margin-bottom: 14px;
}

.button,
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  font: inherit;
  font-weight: 700;
}

.button.primary,
button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.button.primary:hover,
button.primary:hover {
  background: var(--primary-dark);
}

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

.metrics.dashboard-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.central-dashboard-cards { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.central-dashboard-cards .metric { min-height: 142px; padding: 18px; }
.central-dashboard-cards .metric strong { font-size: 30px; margin: 14px 0 4px; }
.central-dashboard-cards .metric small { color: var(--muted); font-size: 12px; }
.dashboard-heading-actions { align-items: end; display: flex; gap: 10px; }
.dashboard-period-filter { align-items: center; display: flex; gap: 7px; }
.dashboard-period-filter label { color: var(--muted); font-size: 12px; font-weight: 700; }
.dashboard-period-filter select { min-height: 40px; }
.dashboard-card-primary { background: linear-gradient(145deg, #0f766e, #115e59); border-color: #0f766e; color: #fff; }
.dashboard-card-primary small { color: rgba(255,255,255,.78) !important; }
.dashboard-card-warning strong { color: var(--danger); }
.dashboard-grid { display: grid; gap: 18px; }
.dashboard-main-grid { grid-template-columns: minmax(0, 1.7fr) minmax(280px, .9fr); margin-top: 18px; }
.dashboard-chart-panel, .dashboard-status-panel, .dashboard-recent-panel { padding: 20px; }
.dashboard-panel-heading { align-items: center; display: flex; gap: 16px; justify-content: space-between; margin-bottom: 18px; }
.dashboard-panel-heading h2 { margin: 0; }
.dashboard-panel-heading .eyebrow { margin-bottom: 4px; }
.dashboard-legend { align-items: center; color: var(--muted); display: flex; font-size: 11px; gap: 5px; white-space: nowrap; }
.dashboard-legend i { border-radius: 99px; display: inline-block; height: 8px; margin-left: 8px; width: 8px; }
.dashboard-legend i.incoming, .dashboard-bar.incoming { background: #14b8a6; }
.dashboard-legend i.outgoing, .dashboard-bar.outgoing { background: #60a5fa; }
.dashboard-bars { align-items: end; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(22px, 1fr)); height: 220px; padding-top: 14px; }
.dashboard-bar-day { align-items: center; display: flex; flex-direction: column; gap: 5px; height: 100%; justify-content: end; min-width: 0; }
.dashboard-bar-stack { align-items: end; display: flex; gap: 3px; height: 175px; justify-content: center; width: 100%; }
.dashboard-bar { border-radius: 5px 5px 2px 2px; display: block; max-height: 100%; min-height: 5px; width: min(22px, 42%); }
.dashboard-bar.outgoing { opacity: .7; }
.dashboard-bar-day strong { font-size: 12px; }
.dashboard-bar-day small { color: var(--muted); font-size: 11px; }
.dashboard-status-list { display: grid; gap: 14px; margin-top: 25px; }
.dashboard-donut-wrap { align-items: center; display: grid; gap: 22px; grid-template-columns: 130px 1fr; }
.dashboard-donut { align-items: center; background: conic-gradient(var(--status-chart)); border-radius: 50%; display: flex; height: 130px; justify-content: center; position: relative; width: 130px; }
.dashboard-donut::after { background: var(--surface); border-radius: 50%; content: ""; height: 86px; position: absolute; width: 86px; }
.dashboard-donut > span { align-items: center; display: flex; flex-direction: column; font-size: 24px; font-weight: 800; position: relative; z-index: 1; }
.dashboard-donut small { color: var(--muted); font-size: 10px; font-weight: 600; }
.dashboard-status-row { align-items: center; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; padding-bottom: 12px; }
.dashboard-status-row span { align-items: center; display: flex; gap: 8px; }
.status-dot { background: var(--muted); border-radius: 99px; display: inline-block; height: 9px; width: 9px; }
.status-dot.novo { background: #3b82f6; }.status-dot.em_atendimento { background: #14b8a6; }.status-dot.aguardando_cliente { background: #f59e0b; }.status-dot.finalizado { background: #94a3b8; }
.dashboard-recent-panel { margin-top: 18px; }
.dashboard-conversation-list { display: grid; }
.dashboard-conversation-row { align-items: center; border-top: 1px solid var(--line); color: var(--text); display: flex; gap: 12px; padding: 12px 0; text-decoration: none; }
.dashboard-conversation-avatar { align-items: center; background: #dbeafe; border-radius: 99px; color: #1d4ed8; display: flex; flex: 0 0 38px; font-weight: 800; height: 38px; justify-content: center; width: 38px; }
.dashboard-conversation-copy { display: grid; gap: 3px; min-width: 0; }
.dashboard-conversation-copy strong, .dashboard-conversation-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-conversation-copy small, .dashboard-conversation-meta small { color: var(--muted); font-size: 12px; }
.dashboard-conversation-meta { align-items: end; display: flex; flex-direction: column; gap: 5px; margin-left: auto; }
.dashboard-sellers-panel { margin-top: 18px; padding: 20px; }
.dashboard-seller-chart { display: grid; gap: 14px; }
.dashboard-seller-row { align-items: center; display: grid; gap: 10px; grid-template-columns: minmax(120px, 180px) minmax(100px, 1fr) 30px; }
.dashboard-seller-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-seller-track { background: color-mix(in srgb, var(--line) 55%, transparent); border-radius: 99px; height: 10px; overflow: hidden; }
.dashboard-seller-track i { background: linear-gradient(90deg, #0f766e, #60a5fa); border-radius: inherit; display: block; height: 100%; }
.dashboard-seller-row strong { text-align: right; }

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 22px;
}

.metric span,
.muted {
  color: var(--muted);
}

.metric strong {
  display: block;
  font-size: 30px;
  margin-top: 10px;
}

.panel {
  margin-bottom: 18px;
  padding: 18px;
}

.grid.two-columns {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 18px;
}

.actions {
  display: flex;
  gap: 10px;
}

.crm-filters {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(160px, 1fr) minmax(180px, 1fr) auto auto;
  align-items: end;
  gap: 12px;
}

.crm-filters > div {
  display: grid;
  gap: 6px;
}

.crm-filters label {
  font-size: 13px;
  font-weight: 700;
}

.compact-header {
  margin-bottom: 8px;
}

.table-scroll {
  overflow-x: auto;
}

.crm-nav { align-items: center; border-bottom: 1px solid var(--line); display: flex; gap: 24px; margin-bottom: 20px; }
.crm-nav a { color: var(--muted); padding: 10px 2px; text-decoration: none; }
.crm-nav a.active { border-bottom: 3px solid var(--primary); color: var(--text); font-weight: 700; }
.crm-metrics { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
.crm-metrics .metric strong { font-size: 22px; }
.crm-filters { margin-bottom: 18px; padding: 14px 18px; }
.crm-filters summary, .crm-report-details > summary { cursor: pointer; font-weight: 700; }
.crm-filters form { align-items: end; display: flex; flex-wrap: wrap; gap: 12px; padding-top: 16px; }
.crm-filters label { display: grid; gap: 5px; min-width: 150px; }
.crm-report-details { margin-top: 20px; }
.crm-report-details > summary { padding: 4px; }
.crm-secondary-metrics { grid-template-columns: repeat(5, minmax(140px, 1fr)); margin-top: 18px; }
.crm-reports { margin-top: 14px; }
.crm-customer-details dl { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.crm-customer-details dl > div { border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.crm-customer-details dl > div.full { grid-column: 1 / -1; }
.crm-customer-details dt, .crm-locked-fields span { color: var(--muted); font-size: 13px; margin-bottom: 5px; }
.crm-customer-details dd { font-size: 16px; margin: 0; }
.crm-locked-fields { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 16px; grid-template-columns: 1fr 1fr; margin-bottom: 12px; padding: 16px; }
.crm-locked-fields div { display: grid; gap: 4px; }
.kanban { display: flex; gap: 14px; overflow-x: auto; align-items: flex-start; padding-bottom: 18px; }
.kanban-column { background: #eef2f6; border-radius: 8px; flex: 0 0 300px; min-height: 280px; }
.kanban-column > header { border-top: 4px solid; display: flex; justify-content: space-between; padding: 12px; }
.kanban-column > header span { color: var(--muted); font-size: 12px; }
.kanban-dropzone { min-height: 220px; padding: 8px; }
.kanban-card { background: white; border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 8px; display: grid; gap: 7px; margin-bottom: 9px; padding: 12px; }
.kanban-card.priority-alta { border-left-color: #f97316; }
.kanban-card.priority-urgente { border-left-color: #dc2626; }
.crm-tag { background: color-mix(in srgb, var(--tag-color) 15%, white); border: 1px solid var(--tag-color); border-radius: 999px; color: var(--tag-color); display: inline-block; font-size: 11px; margin: 2px; padding: 2px 7px; }

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

.form-panel p,
.filters {
  display: grid;
  gap: 6px;
}

.form-panel label {
  font-weight: 700;
}

.form-panel .helptext {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.form-panel input[type="checkbox"] {
  width: auto;
  justify-self: start;
}

.setup-guide {
  margin-bottom: 18px;
}

.guide-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(320px, 1fr);
  gap: 20px;
}

.guide-grid p {
  color: var(--muted);
  margin: 8px 0;
}

.guide-grid ul {
  margin: 0;
  padding-left: 18px;
}

.guide-grid li {
  margin: 7px 0;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
  background: #eef2f7;
  color: #344054;
}

.badge.enviado,
.badge.em_atendimento {
  background: #ecfdf3;
  color: var(--ok);
}

.badge.erro {
  background: #fef3f2;
  color: var(--danger);
}

.badge.novo,
.badge.recebido {
  background: #eff6ff;
  color: #1d4ed8;
}

.badge.transferido {
  background: #f3e8ff;
  color: #7e22ce;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px 14px;
}

.review-mode-banner {
  align-items: center;
  background: #fffaeb;
  border: 1px solid #fedf89;
  border-radius: 10px;
  color: #7a2e0e;
  display: flex;
  font-size: 13px;
  font-weight: 600;
  gap: 8px;
  margin-bottom: 18px;
  padding: 9px 12px;
}

.status-dot {
  background: #f79009;
  border-radius: 999px;
  box-shadow: 0 0 0 3px #fef0c7;
  display: inline-block;
  height: 8px;
  width: 8px;
}

.message-template-layout {
  align-items: start;
}

.account-summary dl {
  display: grid;
  gap: 4px;
  margin: 20px 0;
}

.account-summary dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-top: 10px;
  text-transform: uppercase;
}

.account-summary dd {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  overflow-wrap: anywhere;
}

.message-template-tip {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 5px;
  padding: 14px;
}

.message-template-tip span {
  color: var(--muted);
  font-size: 13px;
}

.message.success {
  background: #ecfdf3;
  border-color: #abefc6;
  color: var(--ok);
}

.message.error {
  background: #fef3f2;
  border-color: #fecdca;
  color: var(--danger);
}

.chat-layout {
  display: grid;
  grid-template-columns: 300px minmax(520px, 1fr);
  gap: 18px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.seller-chat-layout {
  grid-template-columns: minmax(260px, 340px) minmax(360px, 1fr);
}

.conversation-list,
.client-panel,
.chat-panel {
  margin-bottom: 0;
  min-height: 0;
  overflow: auto;
}

.conversation-item {
  border-bottom: 1px solid var(--line);
  color: var(--text);
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  position: relative;
  padding: 12px 8px;
}

.conversation-copy { display: grid; gap: 3px; min-width: 0; }
.conversation-line { align-items: baseline; display: flex; gap: 8px; justify-content: space-between; }
.conversation-preview-line { align-items: center; display: flex; gap: 8px; min-width: 0; }
.conversation-line strong, .conversation-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-preview { flex: 1 1 auto; min-width: 0; }
.preview-media-icon { display: inline-flex; vertical-align: -3px; }
.preview-media-icon svg { fill: none; height: 15px; margin-right: 4px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; width: 15px; }
.conversation-line time { color: var(--muted); flex: 0 0 auto; font-size: 11px; }
.conversation-item.unread .conversation-line time { color: #00a884; font-weight: 700; }
.conversation-preview-status { color: #667781 !important; flex: 0 0 auto; font-size: 12px; font-weight: 800; }
.conversation-preview-status.read { color: #53bdeb !important; }
.conversation-preview-status.failed { color: var(--danger) !important; }
.chat-avatar { align-items: center; align-self: center; background: #dfe7ec; border-radius: 999px; color: #52606d; display: inline-flex; flex: 0 0 auto; font-size: 18px; font-weight: 800; height: 44px; justify-content: center; width: 44px; }
.chat-avatar img { border-radius: inherit; height: 100%; object-fit: cover; width: 100%; }
.header-avatar { height: 40px; width: 40px; }
.chat-contact-title { min-width: 0; }
.chat-search { align-items: center; display: flex; position: relative; }
.chat-search svg { fill: none; height: 18px; left: 12px; pointer-events: none; position: absolute; stroke: var(--muted); stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; width: 18px; z-index: 1; }
.chat-search input { background: #f0f2f5; border: 0; border-radius: 8px; min-height: 36px; padding-left: 40px; width: 100%; }
.chat-filters { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0; scrollbar-width: none; }
.chat-filters::-webkit-scrollbar { display: none; }
.chat-filters button { border-radius: 999px; min-height: 30px; padding: 0 13px; }
.chat-filters button.active { background: #00a884; border-color: #00a884; color: #fff; }
.notification-enable { background: transparent; border: 0; color: #008f72; font-size: 12px; min-height: 30px; padding: 3px 0; text-align: left; }
.notification-enable:disabled { color: var(--muted); cursor: default; opacity: 1; }

.in-app-notification {
  background: #fff;
  border: 1px solid #d9e1ec;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .3);
  color: #111b21;
  align-items: center;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 3px;
  left: 50%;
  max-width: min(420px, calc(100% - 24px));
  padding: 12px 15px;
  position: fixed;
  text-decoration: none;
  top: max(12px, env(safe-area-inset-top));
  transform: translateX(-50%);
  width: calc(100% - 24px);
  z-index: 1200;
}
.in-app-notification strong { color: #111b21; }
.notification-copy { display: grid; gap: 3px; min-width: 0; }
.notification-preview { color: #667781; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notification-avatar { align-items: center; background: #dfe7ec; border-radius: 999px; color: #52606d; display: flex; font-size: 18px; font-weight: 800; height: 40px; justify-content: center; overflow: hidden; width: 40px; }
.notification-avatar img { height: 100%; object-fit: cover; width: 100%; }

.conversation-item.active {
  background: #f0fdfa;
  border-radius: 8px;
}

.conversation-item span,
.conversation-item small {
  color: var(--muted);
}

/* Hierarquia visual da lista, como no WhatsApp: contato em destaque e
   informacoes secundarias em cinza. Esta regra precisa vir depois da regra
   generica de spans para o nome nao herdar a cor da previa. */
.conversation-item .conversation-line strong {
  color: #111b21;
}

.conversation-item .conversation-preview {
  color: #667781;
}

.conversation-item.unread {
  background: #f0fdfa;
  border-left: 4px solid #00a884;
  padding-left: 10px;
}

.conversation-item.unread strong {
  font-weight: 900;
}

.conversation-item.unread > span:first-of-type {
  color: var(--text);
  font-weight: 800;
}

.conversation-arrival,
.conversation-updated,
.message-arrival {
  animation: conversation-arrival .26s ease-out;
}

@keyframes conversation-arrival {
  from { opacity: .45; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .conversation-arrival,
  .conversation-updated,
  .message-arrival { animation: none; }
}

.unread-count {
  background: #00a884;
  border-radius: 999px;
  color: #fff !important;
  font-size: 10px;
  flex: 0 0 auto;
  height: 18px;
  line-height: 18px;
  min-width: 18px;
  padding: 0 5px;
  text-align: center;
}

.conversation-state { display: flex; gap: 7px; }
.conversation-state.is-empty { display: none; }
.favorite-label { color: #00a884 !important; font-weight: 700; }
.conversation-filter-empty { padding: 24px 10px; text-align: center; }

.favorite-chat-menu {
  align-items: end;
  background: rgba(0, 0, 0, .48);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 16px;
  position: fixed;
  z-index: 1000;
}

.favorite-chat-menu-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .25);
  display: grid;
  gap: 8px;
  max-width: 420px;
  padding: 18px;
  width: 100%;
}

.favorite-chat-menu-card strong { color: var(--text); padding: 2px 4px 10px; }
.favorite-chat-menu-card button { min-height: 44px; width: 100%; }
.share-message-menu { align-items: end; background: rgba(0, 0, 0, .48); display: flex; inset: 0; justify-content: center; padding: 16px; position: fixed; z-index: 1000; }
.share-message-card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); display: grid; gap: 14px; max-height: min(680px, 90vh); max-width: 440px; overflow: hidden; padding: 0 18px 18px; width: 100%; }
.share-message-header { align-items: center; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 40px 1fr 40px; margin: 0 -18px; min-height: 62px; padding: 0 14px; }
.share-message-header strong { color: var(--text); font-size: 17px; text-align: center; }
.share-message-header > span { display: block; }
.share-message-cancel { background: transparent; border: 0; color: var(--muted); font-size: 28px; line-height: 1; min-height: 38px; padding: 0; }
.share-message-preview { align-items: center; background: color-mix(in srgb, var(--primary) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--line)); border-radius: 14px; display: flex; gap: 12px; min-width: 0; padding: 12px; }
.share-message-preview > span:last-child { display: grid; gap: 3px; min-width: 0; }
.share-message-preview strong, .share-message-preview small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-message-preview strong { color: var(--text); font-size: 13px; }
.share-message-preview small { color: var(--muted); font-size: 12px; }
.share-message-preview-icon { align-items: center; background: var(--primary); border-radius: 10px; color: #fff; display: flex; flex: 0 0 38px; font-size: 22px; height: 38px; justify-content: center; }
.share-message-search { align-items: center; background: color-mix(in srgb, var(--line) 35%, var(--surface)); border: 1px solid var(--line); border-radius: 12px; color: var(--muted); display: flex; gap: 8px; padding: 0 12px; }
.share-message-search input { background: transparent; border: 0; min-height: 42px; padding: 8px 0; }
.share-message-search input:focus { box-shadow: none; outline: 0; }
.share-message-conversations { display: grid; gap: 4px; max-height: 310px; overflow-y: auto; }
.share-conversation-option { align-items: center; background: transparent; border: 1px solid transparent; border-radius: 12px; color: var(--text); display: grid; gap: 10px; grid-template-columns: 40px 1fr 26px; min-height: 56px; padding: 7px 9px; text-align: left; }
.share-conversation-option:hover, .share-conversation-option.selected { background: color-mix(in srgb, var(--primary) 11%, var(--surface)); border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); }
.share-conversation-option[hidden] { display: none; }
.share-conversation-avatar { align-items: center; background: #25343c; border-radius: 999px; color: #d6e1e8; display: flex; font-weight: 800; height: 40px; justify-content: center; width: 40px; }
.share-conversation-name { font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-conversation-check { align-items: center; border: 1px solid var(--line); border-radius: 999px; color: transparent; display: flex; height: 22px; justify-content: center; width: 22px; }
.share-conversation-option.selected .share-conversation-check { background: var(--primary); border-color: var(--primary); color: #fff; }
.share-message-send { min-height: 46px; }
.message-action-menu { align-items: flex-start; background: rgba(0, 0, 0, .48); backdrop-filter: blur(2px); display: flex; inset: 0; justify-content: flex-start; padding: 0; position: fixed; z-index: 1000; }
.message-action-sheet { display: grid; gap: 10px; left: var(--action-left); max-width: calc(100vw - 44px); position: absolute; top: var(--action-top); width: 470px; }
.message-action-sheet, .message-action-sheet * { -webkit-user-select: none; user-select: none; }
.message-reaction-bar { align-items: center; background: var(--surface); border-radius: 999px; box-shadow: 0 8px 24px rgba(0, 0, 0, .22); display: flex; justify-content: space-around; min-height: 54px; padding: 5px 8px; touch-action: manipulation; }
.message-reaction-bar button { background: transparent; border: 0; border-radius: 999px; cursor: pointer; font-size: 24px; height: 42px; line-height: 1; padding: 0; width: 42px; }
.message-reaction-bar button:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); transform: scale(1.08); }
.message-action-card { background: var(--surface); border-radius: 24px; box-shadow: 0 12px 36px rgba(0, 0, 0, .25); display: grid; gap: 0; max-width: 345px; overflow: hidden; padding: 0; width: 100%; }
.message-action-card button { align-items: center; background: transparent; border: 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); color: var(--text); display: flex; font-size: 17px; font-weight: 600; gap: 15px; min-height: 64px; padding: 8px 22px; text-align: left; width: 100%; }
.message-action-card button:last-child { border-bottom: 0; }
.message-action-card button:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.message-action-icon { align-items: center; display: inline-flex; justify-content: center; width: 25px; }
.message-action-icon svg { fill: none; height: 23px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; width: 23px; }
.message-action-card .message-action-cancel { color: var(--muted); }
@media (max-width: 600px) {
  .message-action-sheet { max-width: calc(100vw - 44px); width: 470px; }
  .message-action-card { max-width: 345px; }
  .message-action-card button { min-height: 61px; padding-left: 24px; }
}
.message-action-card { touch-action: manipulation; }

@media (max-width: 760px) {
  .client-header-trigger { background: transparent !important; border-radius: 0 !important; cursor: default; }
  .client-header-trigger::after { display: none; }
}
.reply-quote-preview { align-items: center; background: color-mix(in srgb, var(--primary) 12%, var(--surface)); border-left: 3px solid var(--primary); border-radius: 8px; display: flex; gap: 8px; justify-content: space-between; margin: 0 0 6px; padding: 7px 10px; }
.reply-quote-preview span { display: grid; gap: 2px; min-width: 0; }
.reply-quote-preview strong { color: var(--primary); font-size: 12px; }
.reply-quote-preview small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-quote-clear { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 20px; line-height: 1; }
.message-quote { border-left: 3px solid var(--primary); display: grid; gap: 2px; margin: 0 0 6px; padding: 4px 8px; }
.message-quote strong { color: var(--primary); font-size: 11px; }
.message-quote small { color: var(--muted); font-size: 10px; }
.message-reaction-badge { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; bottom: -14px; box-shadow: 0 2px 5px rgba(0,0,0,.16); font-size: 18px; line-height: 26px; min-width: 30px; padding: 0 5px; position: absolute; right: 18px; text-align: center; z-index: 2; }
.bubble { position: relative; }
.reaction-event-bubble { display: none !important; }
.message-selection-bar { align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; bottom: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); display: flex; gap: 10px; left: 50%; padding: 8px 10px 8px 14px; position: fixed; transform: translateX(-50%); z-index: 1002; }
.message-selection-bar strong { color: var(--text); font-size: 14px; white-space: nowrap; }
.message-selection-bar button { align-items: center; background: transparent; border: 0; border-radius: 999px; color: var(--text); display: flex; font-size: 22px; height: 36px; justify-content: center; width: 36px; }
.message-selection-bar button:hover { background: color-mix(in srgb, var(--primary) 16%, transparent); }
.message-selected { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 70%, transparent); }
.favorite-chat-toggle { background: #00a884; border-color: #00a884; color: #fff; }
.chat-close-service { color: var(--danger); }
.chat-contact-form { display: grid; gap: 8px; }
.chat-contact-form input { min-height: 44px; width: 100%; }
.record-audio-button.recording { background: #dc2626; border-color: #dc2626; color: #fff; animation: audio-record-pulse 1.2s ease-in-out infinite; }
.record-audio-button.hold-recording { box-shadow: 0 0 0 5px rgba(220, 38, 38, .2); }
@keyframes audio-record-pulse { 50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, .18); } }

.conversation-item .badge {
  justify-self: start;
}

.conversation-item > .badge.transferido { display: none; }

.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: hidden;
  position: relative;
}

.new-messages-button { background: var(--surface); border-radius: 999px; bottom: 78px; box-shadow: 0 3px 12px rgba(0,0,0,.18); color: var(--primary); left: 50%; min-height: 34px; padding: 0 14px; position: absolute; transform: translateX(-50%); z-index: 5; }
.new-messages-button[hidden] { display: none; }

.chat-header,
.status-form,
.reply-form {
  display: flex;
  gap: 10px;
}

.chat-header {
  align-items: center;
  justify-content: space-between;
}

.chat-message-search-toggle { flex: 0 0 auto; }
.message-search { align-items: center; background: var(--surface); display: flex; gap: 8px; padding: 8px 12px; }
.message-search[hidden] { display: none; }
.message-search input { flex: 1 1 auto; min-height: 36px; }
.message-search button { border: 0; font-size: 22px; min-height: 34px; padding: 0 10px; }
.message-search-count { color: var(--muted); font-size: 12px; min-width: 52px; text-align: center; white-space: nowrap; }
.message-search button { background: transparent; color: var(--text); cursor: pointer; }
.message-search mark.search-match { background: #f7d154; border-radius: 3px; color: #1b1b1b; padding: 1px 2px; }
.message-search mark.search-match.active { background: var(--primary); color: #fff; box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent); }

.chat-date-separator { display: flex; justify-content: center; margin: 4px 0; width: 100%; }
.chat-date-separator span { background: #fff; border-radius: 7px; box-shadow: 0 1px 1px rgba(0,0,0,.08); color: var(--muted); font-size: 11px; padding: 6px 10px; }

.handoff-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.handoff-meta small {
  color: var(--muted);
  font-weight: 600;
}

.messages-thread {
  background-color: #efeae2;
  background-image: url("../core/chat-wallpaper-light.08fcb6cd628e.svg");
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 14px;
  scroll-behavior: auto;
}

.chat-layout[data-scroll-state="loading"] .messages-thread {
  opacity: 0;
  visibility: hidden;
}

.chat-layout[data-scroll-state="ready"] .messages-thread {
  opacity: 1;
  visibility: visible;
}

.messages-thread::before {
  content: "";
  margin-top: auto;
}

.bubble {
  border: 1px solid var(--line);
  border-radius: 9px;
  display: grid;
  gap: 6px;
  max-width: 78%;
  min-width: 0;
  padding: 10px 12px;
}

.bubble.entrada {
  align-self: flex-start;
  background: #fff;
}

.bubble.saida {
  align-self: flex-end;
  background: #dcfce7;
  border-color: #bbf7d0;
}

.bubble.entrada + .bubble.entrada, .bubble.saida + .bubble.saida { margin-top: -6px; }

.bubble small {
  color: var(--muted);
  font-size: 12px;
}

.message-text { max-width: 100%; min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.message-text a { color: inherit; overflow-wrap: anywhere; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.bubble.entrada .message-text a { color: var(--accent); }
.bubble.saida .message-text a { color: inherit; }
.link-preview-card { align-items: center; background: rgba(0, 0, 0, .08); border: 1px solid rgba(127, 127, 127, .22); border-radius: 8px; box-sizing: border-box; color: inherit; display: flex; gap: 9px; margin-top: 2px; max-width: min(360px, 100%); min-width: 0; padding: 8px 10px; text-decoration: none !important; width: 100%; }
.link-preview-card:hover { background: rgba(0, 0, 0, .13); }
.link-preview-icon { align-items: center; background: var(--primary); border-radius: 7px; color: #fff; display: inline-flex; flex: 0 0 auto; font-size: 17px; height: 30px; justify-content: center; width: 30px; }
.link-preview-copy { display: grid; gap: 2px; min-width: 0; }
.link-preview-copy strong, .link-preview-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-preview-copy strong { font-size: 12px; }
.link-preview-copy small { color: var(--muted); font-size: 11px; }
.link-preview-rich { align-items: stretch; }
.link-preview-image { border-radius: 6px; flex: 0 0 58px; height: 58px; object-fit: cover; width: 58px; }
.link-preview-description { color: var(--muted); display: -webkit-box; font-size: 11px; line-height: 1.25; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

.message-meta {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
}

.client-panel details > summary { cursor: pointer; font-weight: 800; margin-bottom: 14px; }

.message-status {
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.message-status.read {
  color: #0ea5e9;
}

.message-status.failed {
  color: #dc2626;
}

.message-status.pending {
  color: #64748b;
}

.bubble.pending {
  opacity: 0.82;
}

.bubble.failed {
  border-color: #fecaca;
}

.composer {
  display: grid;
  flex: 1 1 auto;
  gap: 8px;
}

.composer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-menu { position: relative; }
.attachment-menu > summary { list-style: none; }
.attachment-menu > summary::-webkit-details-marker { display: none; }
.attachment-menu > div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; bottom: 48px; box-shadow: 0 5px 20px rgba(0,0,0,.18); display: grid; gap: 4px; left: 0; min-width: 170px; padding: 8px; position: absolute; z-index: 8; }
.attachment-menu .attach-button { justify-content: flex-start; width: 100%; }
.quick-replies-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; bottom: 76px; display: grid; gap: 6px; left: 12px; max-height: 280px; overflow: auto; padding: 8px; position: absolute; width: min(390px, calc(100% - 24px)); z-index: 7; }
.quick-replies-panel[hidden] { display: none; }
.quick-replies-panel button { align-items: flex-start; display: grid; gap: 2px; justify-content: stretch; min-height: 48px; padding: 8px 10px; text-align: left; }
.quick-replies-panel button span { color: var(--muted); font-size: 12px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-button {
  align-items: center;
  background: transparent;
  border: 0;
  display: inline-flex;
  height: 36px;
  justify-content: center;
  min-width: 36px;
  padding: 0;
  width: 36px;
}

.icon-button:hover,
.icon-button:focus-visible,
.back-to-list:hover,
.back-to-list:focus-visible {
  background: rgba(100, 116, 139, 0.14);
  border: 0;
  outline: none;
}

.icon-button svg,
.send-button svg {
  fill: none;
  height: 20px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 20px;
}

.send-button svg {
  fill: currentColor;
  stroke-width: 1.5;
}

.camera-button,
.gallery-button,
.document-button,
.mic-button {
  border-radius: 999px;
  font-size: 16px;
}

.menu-item {
  justify-content: flex-start;
  min-height: 36px;
  width: 100%;
}

.attach-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.back-to-list {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  display: none;
  font-size: 13px;
  font-weight: 800;
  min-height: 34px;
  padding: 0 10px;
}

.attachment-input {
  height: 1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  width: 1px;
}

.form-errors {
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #991b1b;
  font-size: 13px;
  grid-column: 1 / -1;
  padding: 8px 10px;
}

.form-errors ul {
  margin: 0;
  padding-left: 18px;
}

.attachment-status {
  min-height: 18px;
  font-size: 12px;
}

.reply-form textarea {
  background: #fff !important;
  border-color: rgba(127, 127, 127, .28) !important;
  max-height: 132px;
  min-height: 42px;
  overflow-y: auto;
  resize: none;
}

.send-button {
  align-self: end;
  background: var(--primary);
  border: 0;
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  height: 42px;
  justify-content: center;
  min-height: 42px;
  min-width: 42px;
  padding: 0;
  width: 42px;
}

.send-button:hover {
  background: var(--primary-dark);
}

.send-button:disabled,
.send-button.is-sending {
  cursor: wait;
  opacity: 0.65;
}

.send-button.is-sending svg { display: none; }
.send-button.is-sending::after {
  animation: send-button-spin .75s linear infinite;
  border: 2px solid rgba(255,255,255,.45);
  border-top-color: #fff;
  border-radius: 50%;
  content: "";
  height: 16px;
  width: 16px;
}
@keyframes send-button-spin { to { transform: rotate(360deg); } }

.send-button span {
  display: block;
  font-size: 18px;
  line-height: 1;
  transform: translateX(1px);
}

.message-media {
  border-radius: 8px;
  display: block;
  max-height: 260px;
  max-width: 100%;
  object-fit: contain;
}

.message-media-link {
  display: block;
  max-width: min(320px, 100%);
}

.message-media-link .message-media {
  width: 100%;
}

.image-preview-modal {
  align-items: center;
  background: rgba(15, 23, 42, 0.92);
  bottom: 0;
  display: flex;
  justify-content: center;
  left: 0;
  padding: 18px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 1000;
}

.image-preview-modal[hidden] {
  display: none;
}

.image-preview-content {
  border-radius: 8px;
  max-height: 92vh;
  max-width: 96vw;
  object-fit: contain;
}

.image-preview-close {
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  border: 0;
  border-radius: 999px;
  color: var(--text);
  display: inline-flex;
  font-size: 28px;
  font-weight: 700;
  height: 44px;
  justify-content: center;
  padding: 0;
  position: fixed;
  right: 14px;
  top: 14px;
  width: 44px;
  z-index: 1001;
}

body.preview-open {
  overflow: hidden;
}

.message-audio {
  accent-color: var(--primary);
  background: #e9edef;
  color-scheme: light;
  max-width: 100%;
  width: 280px;
}
.custom-audio-player { align-items: center; background: rgba(32, 44, 51, .12); border-radius: 12px; display: flex; gap: 9px; max-width: min(330px, 100%); padding: 8px 10px; width: 330px; }
.bubble.saida .custom-audio-player { background: color-mix(in srgb, var(--primary) 24%, transparent); }
.custom-audio-play { align-items: center; background: var(--primary); border: 0; border-radius: 999px; color: #fff; display: flex; flex: 0 0 34px; font-size: 14px; height: 34px; justify-content: center; padding: 0 0 0 2px; width: 34px; }
.custom-audio-main { display: grid; gap: 3px; min-width: 0; width: 100%; }
.custom-audio-waveform { align-items: center; cursor: pointer; display: flex; gap: 3px; height: 28px; justify-content: space-between; position: relative; }
.custom-audio-waveform::before { background: var(--primary); content: ""; height: 3px; left: 0; position: absolute; top: 50%; transform: translateY(-50%); width: var(--audio-progress, 0%); z-index: 0; }
.custom-audio-waveform i { background: color-mix(in srgb, var(--muted) 72%, transparent); border-radius: 999px; flex: 0 0 2px; min-width: 2px; position: relative; z-index: 1; }
.custom-audio-waveform i:nth-child(-n+1) { background: var(--primary); }
.custom-audio-times { color: var(--muted); display: flex; font-size: 10px; justify-content: space-between; }
.custom-audio-element { display: none; }
.pending-audio-player.audio-uploading { opacity: .82; position: relative; }
.pending-audio-player.audio-uploading .custom-audio-play { cursor: wait; opacity: .7; }
.audio-upload-state { align-items: center; color: var(--muted); display: inline-flex; font-size: 11px; gap: 5px; white-space: nowrap; }
.audio-upload-state::before { animation: audio-upload-spin .8s linear infinite; border: 2px solid color-mix(in srgb, var(--muted) 35%, transparent); border-radius: 50%; border-top-color: var(--primary); content: ""; height: 11px; width: 11px; }
@keyframes audio-upload-spin { to { transform: rotate(360deg); } }
.audio-download-pending { opacity: .72; }
.audio-download-pending .custom-audio-play { cursor: wait; }
.audio-download-state { color: var(--muted); font-size: 11px; }
.retry-message { background: transparent; border: 0; color: var(--danger); cursor: pointer; font-size: 12px; font-weight: 700; padding: 0 4px; }
.cancel-attachment-button { background: transparent; border: 0; color: var(--danger); cursor: pointer; font-size: 12px; font-weight: 700; padding: 2px 4px; }
.sticker-media { max-height: 150px; max-width: 150px; object-fit: contain; }

.pdf-preview-link {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  max-width: min(360px, 100%);
  overflow: hidden;
}

.pdf-preview {
  border: 0;
  display: block;
  height: 260px;
  pointer-events: none;
  width: 100%;
}

.pdf-preview span {
  align-items: center;
  color: var(--text);
  display: flex;
  font-weight: 700;
  min-height: 120px;
  justify-content: center;
}

.pending-file {
  align-items: center;
  color: var(--text);
  display: flex;
  font-weight: 700;
  min-height: 80px;
  justify-content: center;
  padding: 12px;
}

.attachment-link {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: inline-flex;
  font-weight: 700;
  min-height: 38px;
  padding: 0 12px;
}

.client-panel dl {
  display: grid;
  gap: 8px;
}

.client-header-trigger {
  cursor: pointer;
  position: relative;
}

.client-header-trigger:focus-visible,
.client-header-trigger:hover {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
  border-radius: 10px;
}

.client-header-trigger::after {
  border-bottom: 2px solid var(--muted);
  border-right: 2px solid var(--muted);
  content: "";
  height: 7px;
  margin-left: auto;
  transform: rotate(45deg) translateY(-2px);
  transition: transform .18s ease;
  width: 7px;
}

.client-header-trigger.is-expanded::after { transform: rotate(225deg) translate(-1px, -1px); }

.client-info-popover {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .16);
  max-height: min(58vh, 520px);
  overflow: auto;
  padding: 16px 18px;
  position: absolute;
  right: 18px;
  top: 76px;
  width: min(390px, calc(100% - 36px));
  z-index: 12;
}

.client-info-heading { display: grid; gap: 2px; margin-bottom: 14px; }
.client-info-heading strong { font-size: 16px; }
.client-info-heading span { color: var(--muted); font-size: 12px; }
.client-info-popover dl { display: grid; gap: 7px; margin: 0; }
.client-info-popover dt { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.client-info-popover dd { margin: 0 0 7px; overflow-wrap: anywhere; }
.client-info-popover h2 { border-top: 1px solid var(--line); font-size: 14px; margin: 15px 0 8px; padding-top: 13px; }
.client-info-popover table { border-collapse: collapse; font-size: 12px; width: 100%; }
.client-info-popover td { border-bottom: 1px solid var(--line); padding: 7px 3px; }
.client-info-popover td:last-child { text-align: right; }

/* A Central desktop deve ocupar todo o espaço restante depois da navegação
   fixa. Esta regra explícita evita que estilos gerais do conteúdo devolvam
   uma faixa vazia à direita. */
@media (min-width: 1101px) {
  .chat-page .content {
    max-width: none;
    padding-right: 0 !important;
    width: calc(100vw - 248px);
  }

  .chat-page .chat-layout { width: 100%; }
}


.client-panel dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.client-panel dd {
  margin: 0 0 8px;
}

.crm-customer-workspace { align-items: start; margin-top: 18px; }
.crm-related-row { border-bottom: 1px solid var(--line); color: var(--text); display: grid; gap: 4px; padding: 10px 0; text-decoration: none; }
.crm-related-row:last-child { border-bottom: 0; }
.crm-related-row strong { font-size: 14px; }
.crm-related-row span, .crm-related-row small { color: var(--muted); font-size: 12px; }
.crm-customer-actions { margin-top: 18px; }
.crm-inline-action { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.crm-inline-action summary { cursor: pointer; font-weight: 800; }
.crm-inline-action form { display: grid; gap: 8px; margin-top: 12px; }
.crm-inline-action form p { display: grid; gap: 5px; margin: 0; }
.crm-inline-action textarea { min-height: 78px; }

.erp-send {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.erp-send-form {
  display: grid;
  gap: 10px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.mini-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.erp-send-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

code {
  background: #eef2f7;
  border-radius: 6px;
  padding: 2px 5px;
}

@media (max-width: 1100px) {
  .metrics,
  .grid.two-columns,
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: auto;
  }

  .content {
    margin-left: 0;
    padding: 20px;
  }

  .chat-page {
    overflow: hidden;
  }

  .chat-page .content {
    height: 100dvh;
    overflow: hidden;
  }

  .chat-layout {
    flex: none;
    height: calc(100dvh - 116px);
    min-height: 0;
    overflow: hidden;
  }

  .conversation-list,
  .client-panel {
    max-height: none;
  }

  .chat-panel {
    min-height: 0;
  }
}

@media (max-width: 760px) {
  .metrics.dashboard-metrics {
    grid-template-columns: 1fr;
  }

  .central-dashboard-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .central-dashboard-cards .metric:first-child { grid-column: 1 / -1; }
  .dashboard-main-grid { grid-template-columns: 1fr; }
  .dashboard-panel-heading { align-items: flex-start; flex-direction: column; }
  .dashboard-bars { gap: 6px; }
  .dashboard-heading-actions { align-items: stretch; flex-direction: column; width: 100%; }
  .dashboard-period-filter { justify-content: space-between; }
  .dashboard-period-filter select { flex: 1; }
  .dashboard-donut-wrap { grid-template-columns: 1fr; justify-items: center; }
}

@media (max-width: 760px) and (prefers-color-scheme: light) {
  .message-audio { background: #e9edef !important; color-scheme: light; }
  .reply-form textarea { background: #fff !important; border-color: rgba(127, 127, 127, .28) !important; color: #111b21; }
  .record-audio-button, .camera-button { color: #54656f; }
}

@media (max-width: 760px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
    width: 100%;
  }

  .chat-page .sidebar {
    display: none;
  }

  .chat-page .content {
    height: 100dvh;
    inset: 0;
    margin-left: 0;
    padding: 0;
    padding-top: env(safe-area-inset-top);
    width: 100%;
  }

  .chat-page .content > .page-header {
    display: none;
  }

  .chat-page .content > .page-header h1 {
    font-size: 22px;
  }

  .chat-layout,
  .seller-chat-layout {
    display: flex;
    flex-direction: column;
    gap: 0;
    height: calc(100dvh - env(safe-area-inset-top));
    inset: 0;
    min-height: 0;
    overflow: hidden;
    width: 100%;
  }

  .conversation-list {
    background: var(--surface);
    flex: 1 1 auto;
    height: 100%;
    max-height: none;
    min-height: 0;
    overflow: auto;
    border: 0;
    border-radius: 0;
    padding: 12px;
  }

  .client-panel { display: none; }
  .client-info-popover { display: none !important; }

  .has-active-chat .conversation-list {
    display: none;
  }

  .chat-list-only .chat-panel {
    display: none;
  }

  .conversation-list .page-header {
    margin-bottom: 10px;
  }

  .conversation-list .page-header h2 {
    font-size: 22px;
  }

  .conversation-item {
    border-bottom: 1px solid #eef2f7;
    padding: 12px 4px;
  }

  .chat-panel {
    background: #eef2f7;
    flex: 1 1 auto;
    border: 0;
    border-radius: 0;
    display: flex;
    gap: 0;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    width: 100%;
  }

  .chat-header {
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
    gap: 8px;
    min-height: 54px;
    padding: 8px 10px;
  }

  .back-to-list {
    border: 0;
    border-radius: 999px;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 28px;
    min-height: 40px;
    min-width: 40px;
    padding: 0;
  }

  .chat-header h2 {
    font-size: 16px;
    margin: 0;
  }

  .handoff-meta {
    display: none;
  }

  .messages-thread {
    background-color: #efeae2;
    background-image: url("../core/chat-wallpaper-light.08fcb6cd628e.svg");
    border: 0;
    border-radius: 0;
    flex: 1 1 auto;
    min-height: 0;
    padding: 10px 8px;
  }

  .bubble {
    max-width: 92%;
  }

  .reply-form {
    align-items: end;
    background: #f0f2f5;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
    padding: 6px 8px max(6px, env(safe-area-inset-bottom));
    width: 100%;
  }

  .new-messages-button { bottom: 66px; }

  .reply-form > button.primary {
    display: none;
  }

  .composer {
    min-width: 0;
    display: grid;
    gap: 6px;
  }

  .composer-actions {
    display: contents;
  }

  .attachment-menu { order: 1; }
  .reply-form .composer { flex: 1 1 auto; min-width: 0; order: 2; }
  .reply-form .camera-button { order: 3; }
  .reply-form .record-audio-button { order: 4; }
  .reply-form > .send-button { order: 5; }

  .attach-button {
    flex: 0 0 auto;
    border-radius: 999px;
    font-size: 12px;
    min-height: 28px;
    padding: 0 7px;
  }

  .icon-button {
    height: 40px;
    min-width: 40px;
    width: 40px;
  }

  .reply-form textarea {
    border-radius: 20px;
    font-size: 16px;
    min-height: 42px;
    padding: 9px 10px;
  }

  .attachment-status {
    min-height: 0;
  }

  .reply-form[data-mode="text"] .send-button {
    display: inline-flex;
  }

  .reply-form[data-mode="media"] .send-button {
    display: none;
  }
}

@media (max-width: 760px) and (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --bg: #030608; --surface: #090e11; --line: #202b31; --text: #e9edef; --muted: #8696a0; --primary: #00a884; --primary-dark: #008f72; --accent: #53bdeb; --danger: #f15c6d; --ok: #00a884; }
  input, select, textarea { background: #141d22; border-color: var(--line); color: var(--text); }
  .message, .bubble.entrada { background: #141d22; }
  .message.success { background: #12372f; border-color: #276859; }
  .message.error { background: #3b2023; border-color: #7a373b; }
  .conversation-item { border-bottom-color: var(--line); }
  .conversation-item .conversation-line strong { color: #e9edef; }
  .conversation-item .conversation-preview { color: #8696a0; }
  .conversation-item.active, .conversation-item.unread { background: #141d22; }
  .chat-avatar { background: #202b31; color: #d1d7db; }
  .chat-search input { background: #141d22; }
  .chat-filters button.active { background: #00a884; border-color: #00a884; color: #fff; }
  .chat-panel { background: var(--bg); }
  .messages-thread { background-color: #000; background-image: url("../core/chat-wallpaper-dark.8517bf22f906.svg"); }
  .bubble.saida { background: #005c4b; border-color: #005c4b; }
  .chat-date-separator span { background: #11191d; }
  .reply-form { background: #090e11; }
  .message-audio { color-scheme: dark; }
  .record-audio-button, .camera-button { color: #d6e1e8; }
  .attachment-menu > div, .quick-replies-panel, .message-search { background: #090e11; }
  .chat-filters button,
  .attachment-menu .attach-button,
  .quick-replies-panel button,
  .message-search button { background: #243440; border-color: #425666; color: #edf2f7; }
  .chat-filters button:hover,
  .chat-filters button:focus-visible,
  .attachment-menu .attach-button:hover,
  .attachment-menu .attach-button:focus-visible,
  .quick-replies-panel button:hover,
  .quick-replies-panel button:focus-visible { background: #304553; border-color: #587080; }
  .chat-filters button.active { background: #00a884; border-color: #00a884; color: #fff; }
  .icon-button, .back-to-list { background: transparent; border: 0; color: #d6e1e8; }
  .icon-button:hover, .icon-button:focus-visible, .back-to-list:hover, .back-to-list:focus-visible { background: rgba(169, 181, 194, .16); border: 0; }
  .send-button { background: var(--primary); border: 0; color: #062923; }
  .badge, code { color-scheme: dark; }
  .favorite-chat-menu-card { background: #111b21; }
  .in-app-notification { background: #111b21; border-color: #202b31; color: #e9edef; }
  .in-app-notification strong { color: #e9edef; }
  .notification-preview { color: #8696a0; }
  .notification-avatar { background: #202b31; color: #d1d7db; }
}

@media (max-width: 760px) and (prefers-color-scheme: light) {
  .message-audio { background: #e9edef; color-scheme: light; }
  .reply-form textarea { background: #fff !important; border-color: rgba(127, 127, 127, .28) !important; color: #111b21; }
  .record-audio-button, .camera-button { color: #54656f; }
}

/* Ajustes visuais mobile inspirados na densidade do WhatsApp. Mantem a
   estrutura e os controles existentes, alterando apenas apresentacao. */
@media (max-width: 760px) {
  .conversation-list {
    padding: 8px 12px 18px;
  }

  .mobile-bottom-nav {
    align-items: stretch;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-top: 1px solid var(--line);
    bottom: 0;
    display: none;
    grid-template-columns: repeat(4, 1fr);
    left: 0;
    padding: 5px 6px max(5px, env(safe-area-inset-bottom));
    position: fixed;
    right: 0;
    z-index: 20;
  }

  .mobile-bottom-nav a {
    align-items: center;
    border-radius: 10px;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    font-size: 20px;
    gap: 2px;
    justify-content: center;
    min-height: 46px;
    text-decoration: none;
  }

  .mobile-bottom-nav a.active { color: var(--primary); }
  .mobile-bottom-nav a svg { fill: none; height: 21px; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; width: 21px; }
  .mobile-bottom-nav small { font-size: 10px; font-weight: 700; }
  .has-active-chat ~ .mobile-bottom-nav { display: none; }
  .chat-list-only .conversation-list { padding-bottom: max(18px, env(safe-area-inset-bottom)); }

  .conversation-list .page-header {
    align-items: center;
    margin: 4px 4px 12px;
  }

  .conversation-list .page-header h2 {
    font-size: 28px;
    letter-spacing: -.03em;
  }

  .conversation-list .filters select {
    min-height: 38px;
    max-width: 180px;
  }

  .chat-search input {
    border-radius: 10px;
    min-height: 40px;
  }

  .chat-filters {
    gap: 7px;
    padding: 10px 0 8px;
  }

  .chat-filters button {
    font-size: 13px;
    font-weight: 700;
    min-height: 32px;
    padding: 0 14px;
  }

  .notification-enable {
    min-height: 24px;
    padding: 0 2px 5px;
  }

  .conversation-item {
    border-bottom-color: var(--line);
    gap: 12px;
    grid-template-columns: 48px minmax(0, 1fr);
    min-height: 68px;
    padding: 10px 2px;
  }

  .conversation-item .chat-avatar {
    height: 48px;
    width: 48px;
  }

  .conversation-item .conversation-line strong {
    font-size: 16px;
  }

  .conversation-item .conversation-preview {
    font-size: 14px;
  }

  .conversation-item.unread {
    border-left: 0;
    padding-left: 2px;
  }

  .chat-header {
    min-height: 58px;
    padding: 7px 8px;
  }

  .chat-header .header-avatar {
    height: 36px;
    width: 36px;
  }

  .chat-header h2 {
    font-size: 15px;
    line-height: 1.1;
  }

  .chat-header .status-form {
    gap: 4px;
    margin-left: auto;
  }

  .chat-header .status-form select {
    font-size: 12px;
    min-height: 34px;
    max-width: 82px;
    padding: 0 5px;
  }

  .chat-header .status-form button {
    font-size: 0;
    min-height: 34px;
    min-width: 34px;
    padding: 0;
  }

  .chat-header .status-form button::before {
    content: "✓";
    font-size: 16px;
  }

  .chat-header .chat-message-search-toggle {
    height: 36px;
    min-width: 36px;
    width: 36px;
  }

  .chat-contact-title > .muted {
    font-size: 11px;
  }

  .messages-thread {
    gap: 7px;
    padding: 8px 6px;
  }

  .bubble {
    border-radius: 8px;
    max-width: 86%;
    padding: 8px 10px;
  }

  .bubble.entrada { border-radius: 3px 9px 9px 9px; }
  .bubble.saida { border-radius: 9px 3px 9px 9px; }
  .bubble > span { line-height: 1.35; }

  .chat-date-separator { margin: 7px 0 3px; }
  .chat-date-separator span { border-radius: 8px; font-size: 10px; padding: 5px 9px; }

  .bubble small {
    font-size: 11px;
  }

  .bubble .message-media {
    border-radius: 5px;
    max-height: 300px;
    max-width: min(280px, 72vw);
  }
  .bubble .sticker-media { max-height: 150px; max-width: 150px; }

  .message-audio {
    background: rgba(32, 44, 51, .88);
    border-radius: 999px;
    height: 40px;
    max-width: 100%;
    padding: 3px;
    width: min(280px, 72vw);
  }
  .custom-audio-player { max-width: min(310px, 80vw); width: min(310px, 80vw); }

  .bubble.entrada .message-audio { background: rgba(17, 27, 33, .9); }
  .bubble.saida .message-audio { background: rgba(0, 92, 75, .92); }
  .record-audio-button, .camera-button { color: #54656f; }

  .reply-form {
    gap: 5px;
    padding-bottom: max(14px, calc(env(safe-area-inset-bottom) + 6px));
    padding-left: 7px;
    padding-right: 7px;
  }

  .composer-actions {
    align-items: center;
    gap: 3px;
  }

  .reply-form textarea {
    background: #202b31 !important;
    border-color: #34434b !important;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, .16);
    min-height: 40px;
    padding: 9px 13px;
  }

  .reply-form .icon-button {
    height: 38px;
    min-width: 38px;
    width: 38px;
  }

  .send-button {
    height: 38px;
    min-height: 38px;
    min-width: 38px;
    width: 38px;
  }
}

/* The light composer must stay light even when the phone's OS is in dark mode.
   The app's chat theme is independent from the iOS keyboard appearance. */
@media (max-width: 760px) {
  .reply-form {
    color-scheme: light;
  }

  .reply-form textarea {
    background: #fff !important;
    border-color: rgba(127, 127, 127, .28) !important;
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, .06) !important;
    color: #111b21 !important;
    -webkit-text-fill-color: #111b21;
  }

  .reply-form textarea::placeholder {
    color: #667781 !important;
    opacity: 1;
  }
}

.load-older-messages { align-self: center; flex: 0 0 auto; max-width: 100%; margin: 4px auto; background: var(--surface); color: var(--text); border-color: var(--line); }

/* Keep touch gestures on the actual scrolling surfaces, not just the root. */
@media (pointer: coarse) {
  .content, .conversation-list, .conversation-items, .messages-thread,
  .chat-panel, .client-panel, .share-message-conversations, .quick-replies-panel {
    touch-action: pan-y pinch-zoom;
    overscroll-behavior-x: none;
    overflow-x: hidden;
    min-width: 0;
    max-width: 100%;
  }
  .chat-filters { flex-wrap: wrap; overflow-x: hidden; }
}
@media (max-width: 760px) {
  html { position: fixed; inset: 0; }
  body { position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; }
  body.chat-page { overflow: hidden; }
  .content, .chat-panel, .conversation-list { min-width: 0; max-width: 100%; }
}

/* Fit header, thread and composer inside the area above the iPhone keyboard. */
@media (max-width: 760px) {
  .chat-page .content {
    position: fixed;
    top: var(--chat-visible-top, 0px);
    bottom: auto;
    height: var(--chat-visible-height, 100dvh);
  }
  .chat-page .chat-layout, .chat-page .seller-chat-layout {
    height: 100%;
    flex: 1 1 auto;
    min-height: 0;
  }
  .chat-page .chat-header, .chat-page .reply-form { flex-shrink: 0; }
  .chat-page .messages-thread { min-height: 0; }
  .chat-page input, .chat-page textarea, .chat-page select { font-size: 16px; }
}
