/* Ilumina Tarot · CRM de atendimento
   Escuro e minimalista, no formato do Chatwoot. Linhas de 1px no lugar de sombras;
   um único lilás para seleção e ação principal; cores de estado só onde significam algo. */

:root {
  --rail: #121119;
  --panel: #18171f;
  --canvas: #1d1c26;
  --raised: #262532;
  --raised-2: #2e2d3c;
  --line: #2a2936;
  --line-2: #393848;

  --text: #ecebf2;
  --text-2: #b0aec2;
  --text-3: #8f8da4;

  --accent: #a594ff;
  --accent-ink: #16131f;
  --accent-hover: #b7a9ff;
  --accent-soft: rgb(165 148 255 / 0.14);

  --out: #352f5c;
  --out-text: #f3f1fb;

  --ok: #5fcb93;
  --warn: #e9b65a;
  --danger: #f27b7b;
  --danger-soft: rgb(242 123 123 / 0.12);
  --warn-soft: rgb(233 182 90 / 0.12);

  --r-sm: 6px;
  --r: 8px;
  --r-lg: 12px;

  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, sans-serif;
  --fs-xs: 0.75rem;   /* 12 */
  --fs-sm: 0.8125rem; /* 13 */
  --fs: 0.875rem;     /* 14 */
  --fs-md: 0.9375rem; /* 15 */
  --fs-lg: 1.0625rem; /* 17 */
  --fs-xl: 1.25rem;   /* 20 */

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 400 var(--fs)/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
::selection { background: rgb(165 148 255 / 0.35); color: #fff; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
[hidden] { display: none !important; }

* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.i {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.i-sm { width: 14px; height: 14px; }

/* ---------- controles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: transparent; color: var(--text);
  font-size: var(--fs-sm); font-weight: 600; white-space: nowrap;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease);
}
.btn:hover { background: var(--raised); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn .i { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--text); }
.btn-block { width: 100%; height: 40px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: var(--r); background: transparent; color: var(--text-2);
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.icon-btn:hover { background: var(--raised); color: var(--text); }
.icon-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }

.input, .select, .textarea {
  width: 100%; min-height: 36px; padding: 7px 11px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--panel); color: var(--text);
  transition: border-color 150ms var(--ease);
}
.textarea { resize: vertical; min-height: 88px; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: #4a4960; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.select { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23b0aec2' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.select option { background: var(--panel); }

.field { display: grid; gap: 6px; }
.field > span, .field-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.field small { color: var(--text-3); font-size: var(--fs-xs); line-height: 1.4; }
.form-error { min-height: 1.2em; color: var(--danger); font-size: var(--fs-sm); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--accent)); flex: none; }

.avatar {
  display: grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--raised-2); color: var(--text-2);
  font-size: var(--fs-sm); font-weight: 600; letter-spacing: 0.01em;
}
.avatar-lg { width: 64px; height: 64px; font-size: var(--fs-xl); }

.brand {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: var(--r);
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: var(--fs-sm); letter-spacing: 0.02em;
}

/* ---------- estrutura ---------- */
.app { display: grid; grid-template-columns: 56px 1fr; height: 100dvh; overflow: hidden; }
.view { min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.view > * { flex: 1; min-height: 0; }
.view > .banner { flex: none; }

.rail {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 0; background: var(--rail); border-right: 1px solid var(--line);
}
.rail .brand { margin-bottom: 10px; }
.rail-btn {
  position: relative; display: grid; place-items: center;
  width: 40px; height: 40px; border: 0; border-radius: var(--r);
  background: transparent; color: var(--text-3);
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.rail-btn .i { width: 20px; height: 20px; }
.rail-btn:hover { color: var(--text); background: var(--raised); }
.rail-btn[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.rail-count {
  position: absolute; top: 3px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; font-variant-numeric: tabular-nums;
}
.rail-spacer { flex: 1; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); margin-bottom: 6px; }
.conn[data-state="on"] { background: var(--ok); }
.conn[data-state="off"] { background: var(--danger); }
.me {
  display: grid; place-items: center; width: 32px; height: 32px; margin-top: 6px; border-radius: 50%;
  background: var(--raised-2); color: var(--text-2); font-size: var(--fs-xs); font-weight: 600;
}

/* ---------- caixa de entrada ---------- */
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr) auto; height: 100%; }

.list-col { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line); }
.list-head { display: grid; gap: 10px; padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.list-title { display: flex; align-items: center; justify-content: space-between; }
.list-title h1 { font-size: var(--fs-lg); font-weight: 650; letter-spacing: -0.01em; }
.search { position: relative; display: block; }
.search .i { position: absolute; left: 10px; top: 50%; translate: 0 -50%; color: var(--text-3); width: 16px; height: 16px; pointer-events: none; }
.search .input { padding-left: 32px; background: var(--canvas); }
.list-filters { display: flex; gap: 8px; }
.list-filters .select { flex: 1; min-width: 0; min-height: 32px; padding-block: 5px; font-size: var(--fs-sm); background-color: var(--canvas); }

.tabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--line); }
.tab {
  position: relative; padding: 10px 8px; border: 0; background: none;
  color: var(--text-3); font-size: var(--fs-sm); font-weight: 600;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }

.conv-list { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; flex: 1; }
.conv {
  display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start;
  padding: 10px 14px; cursor: pointer; text-decoration: none; color: inherit;
  transition: background-color 120ms var(--ease);
}
.conv:hover { background: var(--raised); }
.conv[aria-current="true"] { background: var(--raised); border-left-color: var(--accent); }
.conv-main { min-width: 0; display: grid; gap: 2px; }
.conv-top, .conv-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.conv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.conv.unread .conv-name { font-weight: 700; }
.conv-time { color: var(--text-3); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; flex: none; }
.conv.unread .conv-time { color: var(--accent); }
.conv-preview { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: var(--fs-sm); }
.conv.unread .conv-preview { color: var(--text); }
.conv-preview .you { color: var(--text-3); }
.conv-badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; flex: none;
  background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums;
}
.conv-inbox { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: var(--fs-xs); min-width: 0; }
.conv-inbox span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-inbox .dot { width: 6px; height: 6px; }

.list-empty { padding: 32px 20px; color: var(--text-3); font-size: var(--fs-sm); text-align: center; line-height: 1.6; }
.list-empty strong { display: block; color: var(--text-2); font-size: var(--fs); margin-bottom: 4px; }

.skeleton-row { display: grid; grid-template-columns: 38px 1fr; gap: 10px; padding: 12px 14px; }
.sk { border-radius: 6px; background: var(--raised); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* ---------- conversa ---------- */
.chat-col { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--canvas); position: relative; }

.chat-empty { margin: auto; max-width: 340px; padding: 24px; text-align: center; color: var(--text-3); line-height: 1.6; }
.chat-empty .i { width: 36px; height: 36px; stroke-width: 1.25; margin-bottom: 12px; color: var(--line-2); }
.chat-empty h2 { color: var(--text-2); font-size: var(--fs-md); font-weight: 600; margin-bottom: 4px; }

.chat-head {
  display: flex; align-items: center; gap: 12px; flex: none;
  height: 64px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--line); background: var(--canvas);
}
.chat-head .back { display: none; }
.chat-title { min-width: 0; flex: 1; display: grid; gap: 1px; }
.chat-title strong { font-size: var(--fs-md); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: var(--fs-xs); min-width: 0; }
.chat-sub span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-actions { display: flex; align-items: center; gap: 6px; flex: none; }

.window-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border-radius: 13px; border: 1px solid var(--line-2);
  color: var(--text-2); font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.window-chip .i { width: 14px; height: 14px; }
.window-chip[data-level="warn"] { color: var(--warn); border-color: rgb(233 182 90 / 0.4); background: var(--warn-soft); }
.window-chip[data-level="closed"] { color: var(--danger); border-color: rgb(242 123 123 / 0.4); background: var(--danger-soft); }

.messages { flex: 1; overflow-y: auto; padding: 16px 24px 8px; display: flex; flex-direction: column; gap: 2px; }
.older-note { align-self: center; color: var(--text-3); font-size: var(--fs-xs); padding: 6px 0 12px; }
.day {
  align-self: center; margin: 14px 0 10px; padding: 3px 10px; border-radius: 10px;
  background: var(--raised); color: var(--text-2); font-size: var(--fs-xs); font-weight: 600;
}

.msg { display: flex; align-items: center; gap: 6px; max-width: min(72%, 620px); margin-top: 4px; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; flex-direction: row-reverse; }
.msg.grouped { margin-top: 0; }
.bubble {
  position: relative; min-width: 72px; padding: 7px 10px 6px; border-radius: var(--r-lg);
  background: var(--raised); color: var(--text); overflow-wrap: anywhere;
}
.msg.in .bubble { border-top-left-radius: 4px; }
.msg.out .bubble { background: var(--out); color: var(--out-text); border-top-right-radius: 4px; }
.msg.grouped.in .bubble { border-top-left-radius: var(--r-lg); }
.msg.grouped.out .bubble { border-top-right-radius: var(--r-lg); }
.msg.failed .bubble { box-shadow: inset 0 0 0 1px var(--danger); }
.bubble .text { white-space: pre-wrap; font-size: var(--fs-md); line-height: 1.45; }
.bubble .text a { color: inherit; text-decoration: underline; }
.bubble .text code { font-family: ui-monospace, Consolas, monospace; font-size: 0.9em; background: rgb(0 0 0 / 0.25); padding: 1px 4px; border-radius: 4px; }
.bubble .label { display: block; margin-bottom: 3px; color: var(--text-3); font-size: var(--fs-xs); font-weight: 600; }
.msg.out .bubble .label { color: #b9b2e0; }
.meta {
  display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 2px;
  color: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.msg.out .meta { color: #a9a2d4; }
.meta .who { margin-right: 4px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.meta .i { width: 14px; height: 14px; stroke-width: 2; }
.meta .tick-read { color: var(--accent-hover); }
.meta .tick-failed { color: var(--danger); }
.msg-error { display: flex; align-items: center; gap: 4px; margin-top: 4px; color: var(--danger); font-size: var(--fs-xs); }
.msg-col { display: flex; flex-direction: column; min-width: 0; }
.msg.out .msg-col { align-items: flex-end; }

.msg-reply {
  opacity: 0; width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--text-3);
  display: grid; place-items: center; transition: opacity 120ms var(--ease), background-color 120ms var(--ease);
}
.msg-reply .i { width: 16px; height: 16px; }
.msg:hover .msg-reply, .msg-reply:focus-visible { opacity: 1; }
.msg-reply:hover { background: var(--raised); color: var(--text); }

.quote {
  display: block; margin: 0 0 6px; padding: 5px 8px; border-radius: var(--r-sm);
  background: rgb(0 0 0 / 0.22); font-size: var(--fs-sm); color: var(--text-2);
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.msg.out .quote { color: #cfc9ef; }
.quote b { display: block; font-size: var(--fs-xs); color: var(--accent); }

.reacts {
  position: absolute; bottom: -12px; right: 8px; padding: 1px 5px; border-radius: 10px;
  background: var(--raised-2); border: 2px solid var(--canvas); font-size: 12px; line-height: 16px;
}
.msg.has-react { margin-bottom: 12px; }

.media-img { display: block; max-width: 100%; width: 320px; max-height: 360px; object-fit: cover; border-radius: var(--r); margin: -2px -4px 4px; background: var(--raised-2); min-height: 120px; }
.sticker { width: 140px; height: 140px; object-fit: contain; }
.msg.t-sticker .bubble { background: transparent; padding: 0; }
.media-video { display: block; width: 320px; max-width: 100%; border-radius: var(--r); margin: -2px -4px 4px; background: #000; }
.media-audio { display: block; width: 280px; max-width: 100%; height: 40px; margin: 2px 0; color-scheme: dark; }
.doc {
  display: flex; align-items: center; gap: 10px; min-width: 220px; padding: 8px 10px; margin-bottom: 4px;
  border-radius: var(--r); background: rgb(0 0 0 / 0.2); color: inherit; text-decoration: none;
}
.doc:hover { background: rgb(0 0 0 / 0.3); }
.doc span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.doc .i { width: 20px; height: 20px; }
.bubble.unsupported .text { color: var(--text-3); font-style: italic; }

/* compositor */
.composer-wrap { flex: none; padding: 0 16px 14px; }
.reply-bar, .attach-bar {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 12px; margin-bottom: 6px;
  border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); font-size: var(--fs-sm); color: var(--text-2);
}
.reply-bar > div, .attach-bar > div { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar b { color: var(--accent); margin-right: 6px; }
.attach-bar .i { color: var(--text-2); }
.composer {
  display: flex; align-items: flex-end; gap: 4px; padding: 6px;
  border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--panel);
  transition: border-color 150ms var(--ease);
}
.composer:focus-within { border-color: #4f4d69; }
.composer textarea {
  flex: 1; min-height: 34px; max-height: 180px; padding: 7px 6px; border: 0; outline: 0; resize: none;
  background: transparent; font-size: var(--fs-md); line-height: 1.4;
}
.composer textarea::placeholder { color: var(--text-3); }
.send-btn {
  display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: var(--r);
  background: var(--accent); color: var(--accent-ink); transition: background-color 150ms var(--ease), opacity 150ms;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.4; cursor: default; }
.send-btn .i { width: 17px; height: 17px; stroke-width: 2; }
.composer-hint { margin-top: 6px; color: var(--text-3); font-size: 11px; }
.composer-hint kbd { font-family: inherit; padding: 0 4px; border: 1px solid var(--line-2); border-radius: 4px; }

.recording { flex: 1; display: flex; align-items: center; gap: 10px; padding: 0 8px; min-height: 34px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s ease-in-out infinite; }

.window-closed {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid rgb(242 123 123 / 0.35); border-radius: var(--r-lg); background: var(--danger-soft);
  color: var(--text-2); font-size: var(--fs-sm); line-height: 1.45;
}
.window-closed .i { color: var(--danger); }
.window-closed p { flex: 1; }
.window-closed strong { color: var(--text); }

/* painel de modelo */
.tpl-panel {
  margin-bottom: 8px; padding: 14px; border-radius: var(--r-lg);
  background: var(--panel); border: 1px solid var(--line-2); display: grid; gap: 12px;
  max-height: 60vh; overflow-y: auto;
}
.tpl-panel header { display: flex; align-items: center; justify-content: space-between; }
.tpl-panel h3 { font-size: var(--fs); font-weight: 650; }
.tpl-vars { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.tpl-preview {
  padding: 10px 12px; border-radius: var(--r); background: var(--out); color: var(--out-text);
  white-space: pre-wrap; font-size: var(--fs-sm); line-height: 1.5;
}
.tpl-preview .var { color: var(--warn); }
.tpl-preview .tpl-foot { display: block; margin-top: 6px; color: #a9a2d4; font-size: var(--fs-xs); }
.tpl-preview .tpl-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tpl-preview .tpl-btns span { padding: 3px 8px; border-radius: 6px; background: rgb(0 0 0 / 0.2); font-size: var(--fs-xs); }
.tpl-actions { display: flex; justify-content: flex-end; gap: 8px; }
.note { color: var(--text-3); font-size: var(--fs-sm); line-height: 1.5; }
.note-error { color: var(--danger); }

/* painel do contato */
.details-col { width: 300px; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; overflow-y: auto; }
.details-head { display: flex; align-items: center; justify-content: space-between; height: 64px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--line); flex: none; }
.details-head h2 { font-size: var(--fs); font-weight: 650; }
.details-id { display: grid; justify-items: center; gap: 8px; padding: 20px 16px 16px; text-align: center; border-bottom: 1px solid var(--line); }
.name-input {
  width: 100%; padding: 4px 8px; border: 1px solid transparent; border-radius: var(--r-sm);
  background: transparent; text-align: center; font-size: var(--fs-lg); font-weight: 650;
}
.name-input:hover { border-color: var(--line-2); }
.name-input:focus { outline: none; border-color: var(--accent); background: var(--canvas); }
.details-phone { color: var(--text-2); font-variant-numeric: tabular-nums; }
.details-list { margin: 0; padding: 12px 16px; display: grid; grid-template-columns: 1fr; gap: 12px; border-bottom: 1px solid var(--line); }
.details-list dt { color: var(--text-3); font-size: var(--fs-xs); font-weight: 600; }
.details-list dd { margin: 2px 0 0; display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.details-notes { padding: 14px 16px 20px; display: grid; gap: 6px; }
.details-notes .textarea { min-height: 140px; background: var(--canvas); }
.save-state { color: var(--text-3); font-size: var(--fs-xs); min-height: 1.2em; }

/* nova conversa */
.new-conv { flex: 1; overflow-y: auto; padding: 28px 32px; }
.new-conv-inner { max-width: 560px; display: grid; gap: 18px; }
.new-conv h1 { font-size: var(--fs-xl); font-weight: 650; letter-spacing: -0.01em; }
.new-conv .lead { color: var(--text-2); line-height: 1.55; margin-top: 4px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- administração ---------- */
.admin { height: 100%; overflow-y: auto; background: var(--canvas); }
.admin-inner { max-width: 960px; margin: 0 auto; padding: 32px 32px 64px; display: grid; gap: 24px; }
.admin-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.admin-head h1 { font-size: 1.5rem; font-weight: 650; letter-spacing: -0.015em; }
.admin-head p { color: var(--text-2); margin-top: 6px; max-width: 60ch; line-height: 1.55; }
.section-title { font-size: var(--fs-md); font-weight: 650; margin-bottom: 4px; }

.panel { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--panel); }
.panel-body { padding: 18px 20px; display: grid; gap: 14px; }
.panel-body > p { color: var(--text-2); line-height: 1.55; }

.kv { display: grid; grid-template-columns: 160px 1fr auto; align-items: center; gap: 12px; }
.kv > span { color: var(--text-3); font-size: var(--fs-sm); font-weight: 600; }
.kv code {
  min-width: 0; padding: 7px 10px; border-radius: var(--r); background: var(--canvas); border: 1px solid var(--line);
  font-family: ui-monospace, Consolas, monospace; font-size: var(--fs-sm); overflow-x: auto; white-space: nowrap;
}
.steps { margin: 0; padding-left: 20px; color: var(--text-2); line-height: 1.7; }
.steps b { color: var(--text); font-weight: 600; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows > li + li { border-top: 1px solid var(--line); }
.inbox-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; padding: 16px 20px; align-items: start; }
.inbox-row .dot { width: 12px; height: 12px; margin-top: 5px; }
.ir-main { display: grid; gap: 4px; min-width: 0; }
.ir-name { font-weight: 650; font-size: var(--fs-md); }
.ir-sub { color: var(--text-2); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.status-line { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); }
.status-line .i { width: 15px; height: 15px; }
.status-ok { color: var(--ok); }
.status-err { color: var(--danger); }
.status-warn { color: var(--warn); }
.ir-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ir-agents { grid-column: 2 / -1; display: grid; gap: 8px; margin-top: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; }
.chip span {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border-radius: 15px; border: 1px solid var(--line-2); color: var(--text-2); font-size: var(--fs-sm); font-weight: 500;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease);
}
.chip span .i { width: 14px; height: 14px; display: none; }
.chip:hover span { border-color: #4f4d69; color: var(--text); }
.chip input:checked + span { background: var(--accent-soft); border-color: rgb(165 148 255 / 0.55); color: var(--text); }
.chip input:checked + span .i { display: block; color: var(--accent); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { position: relative; width: 28px; height: 28px; }
.swatch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.swatch span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px var(--panel); }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--c); }
.swatch input:focus-visible + span { outline: 2px solid var(--text); outline-offset: 4px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th { text-align: left; padding: 10px 20px; color: var(--text-3); font-size: var(--fs-xs); font-weight: 600; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .muted { color: var(--text-3); }
.agent-name { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: var(--fs); }
.agent-name .avatar { width: 30px; height: 30px; font-size: var(--fs-xs); }
.role { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: var(--fs-xs); font-weight: 600; background: var(--raised); color: var(--text-2); }
.role-admin { background: var(--accent-soft); color: var(--accent); }
.inbox-dots { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.inbox-dots span { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.inactive td { opacity: 0.55; }

.code-box {
  display: flex; align-items: center; gap: 16px; padding: 16px 20px;
  border: 1px solid rgb(165 148 255 / 0.45); border-radius: var(--r-lg); background: var(--accent-soft);
}
.code-box p { flex: 1; color: var(--text-2); line-height: 1.5; }
.code-box strong { color: var(--text); }
.code-value { font-size: 1.75rem; font-weight: 700; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; color: var(--text); }

/* ---------- avisos ---------- */
.banner {
  display: flex; align-items: center; gap: 10px; padding: 9px 16px;
  background: var(--danger-soft); border-bottom: 1px solid rgb(242 123 123 / 0.35);
  color: var(--text); font-size: var(--fs-sm);
}
.banner .i { color: var(--danger); }
.banner a { color: var(--text); font-weight: 600; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--r);
  background: var(--raised-2); border: 1px solid var(--line-2); color: var(--text); font-size: var(--fs-sm); line-height: 1.45;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  animation: toast-in 200ms var(--ease);
}
.toast .i { margin-top: 1px; }
.toast-error .i { color: var(--danger); }
.toast-ok .i { color: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100dvh; background: var(--rail); }
.login { width: min(360px, calc(100vw - 40px)); display: grid; gap: 6px; }
.brand-lg { width: 44px; height: 44px; font-size: var(--fs-md); margin-bottom: 14px; }
.login h1 { font-size: 1.5rem; font-weight: 650; letter-spacing: -0.015em; }
.login-sub { color: var(--text-2); margin-bottom: 22px; }
.login form { display: grid; gap: 8px; }
.login label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.login input {
  height: 52px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--panel); font-size: 1.375rem; font-weight: 600; letter-spacing: 0.12em; font-variant-numeric: tabular-nums;
}
.login input::placeholder { color: #4d4b62; }
.login input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login input[aria-invalid="true"] { border-color: var(--danger); }
.login-help { margin-top: 18px; color: var(--text-3); font-size: var(--fs-sm); }

/* ---------- telas menores ---------- */
@media (max-width: 1279px) {
  .details-col { position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; box-shadow: -12px 0 32px rgb(0 0 0 / 0.4); }
  .inbox { position: relative; grid-template-columns: 320px minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { order: 2; flex-direction: row; justify-content: space-around; padding: 6px 8px; border-right: 0; border-top: 1px solid var(--line); }
  .rail .brand, .rail-spacer, .me { display: none; }
  .conn { margin: 0; }
  .inbox { grid-template-columns: 1fr; }
  .inbox .chat-col { display: none; }
  .inbox.has-chat .list-col { display: none; }
  .inbox.has-chat .chat-col { display: flex; }
  .chat-head .back { display: grid; }
  .chat-head { padding-left: 6px; }
  .messages { padding: 12px 12px 6px; }
  .msg { max-width: 88%; }
  .composer-wrap { padding: 0 8px 8px; }
  .composer-hint { display: none; }
  .details-col { width: 100%; }
  .admin-inner { padding: 20px 16px 48px; }
  .admin-head { flex-direction: column; }
  .kv { grid-template-columns: 1fr auto; }
  .kv > span { grid-column: 1 / -1; }
  .form-grid, .row-2 { grid-template-columns: 1fr; }
  .inbox-row { grid-template-columns: auto minmax(0, 1fr); }
  .ir-actions { grid-column: 2; justify-content: flex-start; }
  .table thead { display: none; }
  .table tr { display: grid; grid-template-columns: 1fr auto; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table td { padding: 2px 0; border: 0; }
  .table td.hide-sm { display: none; }
  .new-conv { padding: 20px 16px; }
}

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

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ajustes após a primeira revisão visual */
.btn { text-decoration: none; }
.row-2 { align-items: start; }
.name-input::placeholder { color: var(--text-2); }
.msg.in .reacts { right: auto; left: 8px; }
.media-missing {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 4px;
  border-radius: var(--r); background: rgb(0 0 0 / 0.2); color: var(--text-3); font-size: var(--fs-sm);
}

/* celular: nada pode passar da largura da tela */
html, body { max-width: 100%; overflow-x: hidden; }
.admin { overflow-x: hidden; }
.composer textarea, .chat-title, .conv-main, .ir-main, .kv code { min-width: 0; }
.chip-extra { margin-left: 4px; }
@media (max-width: 860px) {
  .chat-head { gap: 8px; padding-right: 8px; }
  .chat-head .avatar, .chip-extra, #statusBtn .btn-label { display: none; }
  #statusBtn { width: 34px; padding: 0; }
  .window-chip { padding: 0 8px; }
  .chat-actions { gap: 4px; }
  .msg-reply { display: none; }
  .composer { gap: 2px; padding: 4px; }
  .composer .icon-btn { width: 32px; }
  .tpl-vars { grid-template-columns: 1fr; }
  .media-img, .media-video { width: 100%; }
  .doc { min-width: 0; }
  .code-box { flex-wrap: wrap; }
  .admin-head .btn { width: 100%; }
  .table td:last-child { justify-self: end; }
  .row-actions .btn { padding: 0 8px; }
  .toasts { left: 12px; right: 12px; bottom: 72px; }
}
@media (max-width: 860px) {
  .window-closed { flex-wrap: wrap; }
  .window-closed p { flex-basis: calc(100% - 30px); }
  .window-closed .btn { width: 100%; }
}

/* ajustes do verificador de design */
.rec-dot { animation: none; }
.login input::placeholder { color: var(--text-3); }
.quote { border-left: 0; }
.conv { border-left: 0; }
.conv[aria-current="true"] { background: var(--raised-2); }

/* ---------- configurações ---------- */
.settings { display: grid; grid-template-columns: 232px minmax(0, 1fr); height: 100%; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; padding: 18px 10px; background: var(--panel); border-right: 1px solid var(--line); }
.settings-nav h1 { font-size: var(--fs-lg); font-weight: 650; padding: 0 10px 14px; letter-spacing: -0.01em; }
.settings-nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r);
  color: var(--text-2); text-decoration: none; font-weight: 500;
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}
.settings-nav a:hover { background: var(--raised); color: var(--text); }
.settings-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--text); }
.settings-nav a[aria-current="page"] .i { color: var(--accent); }
.settings-main { overflow-y: auto; overflow-x: hidden; min-width: 0; }
.page-title { font-size: 1.375rem; font-weight: 650; letter-spacing: -0.015em; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); text-decoration: none; font-size: var(--fs-sm); font-weight: 500; justify-self: start; margin-bottom: -8px; }
.back-link:hover { color: var(--text); }
.back-link .i { width: 16px; height: 16px; }
.muted { color: var(--text-3); }

.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 11px; font-size: var(--fs-xs); font-weight: 600; background: var(--raised); color: var(--text-2); white-space: nowrap; }
.badge-ok { background: rgb(95 203 147 / 0.14); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-err { background: var(--danger-soft); color: var(--danger); }

.dot-lg { width: 12px; height: 12px; }
.inbox-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto auto; align-items: center; gap: 16px;
  padding: 16px 20px; color: inherit; text-decoration: none; transition: background-color 150ms var(--ease);
}
.inbox-item:hover { background: var(--raised); }
.ii-main { display: grid; gap: 2px; min-width: 0; }
.ii-main strong { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ii-main span { color: var(--text-2); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.ii-agents { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); }
.ii-go { color: var(--text-3); }
.stack { display: flex; }
.stack .avatar + .avatar { margin-left: -6px; }
.avatar-xs { width: 24px; height: 24px; font-size: 10px; box-shadow: 0 0 0 2px var(--panel); }
.empty-panel .panel-body { justify-items: start; padding: 28px; }
.empty-panel h3 { font-size: var(--fs-md); font-weight: 650; }

/* assistente */
.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stepper li { display: flex; align-items: center; gap: 8px; padding-top: 10px; border-top: 2px solid var(--line-2); color: var(--text-3); font-size: var(--fs-sm); font-weight: 600; min-width: 0; }
.stepper li span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-num { display: grid; place-items: center; flex: none; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-2); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.step-num .i { width: 13px; height: 13px; stroke-width: 2.5; }
.stepper li.done { border-top-color: var(--accent); color: var(--text-2); }
.stepper li.done .step-num { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.stepper li.current { border-top-color: var(--accent); color: var(--text); }
.stepper li.current .step-num { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.wizard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; }
.wizard-grid > form { border-right: 1px solid var(--line); }
.help { padding: 18px 20px; display: grid; gap: 10px; align-content: start; }
.help h3 { font-size: var(--fs); font-weight: 650; }
.help .steps { font-size: var(--fs-sm); line-height: 1.6; }
.probe { list-style: none; margin: 0; padding: 12px 14px; display: grid; gap: 8px; border-radius: var(--r); background: var(--canvas); border: 1px solid var(--line); font-size: var(--fs-sm); line-height: 1.45; }
.probe li { display: flex; gap: 8px; align-items: flex-start; }
.probe li span { color: var(--text-2); }
.probe li b { color: var(--text); }
.probe .i { margin-top: 1px; width: 16px; height: 16px; }
#probe:empty, #credProbe:empty { display: none; }
.preview-row { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: var(--r); background: var(--canvas); border: 1px solid var(--line); justify-self: start; font-weight: 500; }
.result { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-lg); }
.result .i { width: 20px; height: 20px; margin-top: 1px; }
.result p { color: var(--text-2); margin-top: 2px; line-height: 1.5; }
.result-ok { background: rgb(95 203 147 / 0.1); border: 1px solid rgb(95 203 147 / 0.35); }
.result-ok .i { color: var(--ok); }
.result-warn { background: var(--warn-soft); border: 1px solid rgb(233 182 90 / 0.4); }
.result-warn .i { color: var(--warn); }
.webhook { display: grid; gap: 12px; }

/* página do número */
.inbox-head { align-items: center; }
.inbox-title { display: flex; align-items: center; gap: 12px; min-width: 0; flex-wrap: wrap; }
.inbox-title p { margin-top: 2px; font-variant-numeric: tabular-nums; }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); font-size: var(--fs-sm); line-height: 1.5; }
.callout .i { width: 16px; height: 16px; margin-top: 2px; }
.callout-err { background: var(--danger-soft); border: 1px solid rgb(242 123 123 / 0.35); }
.callout-err .i { color: var(--danger); }
.callout-warn { background: var(--warn-soft); border: 1px solid rgb(233 182 90 / 0.35); color: var(--text); }
.callout-warn .i { color: var(--warn); }
.facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 24px; }
.facts dt { color: var(--text-3); font-size: var(--fs-xs); font-weight: 600; }
.facts dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.panel-danger { border-color: rgb(242 123 123 / 0.3); }
.danger-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

/* etiquetas */
.label-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; border-radius: 10px;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c);
  font-size: 11px; font-weight: 600; line-height: 1; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.label-x { display: grid; place-items: center; width: 14px; height: 14px; margin-right: -4px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; }
.label-x:hover { background: color-mix(in srgb, var(--c) 30%, transparent); }
.label-x .i { width: 10px; height: 10px; stroke-width: 2.5; }
.label-more { color: var(--text-3); font-size: 11px; font-weight: 600; }
.conv-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; margin-top: 2px; }
.details-labels { padding: 14px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.dl-head { display: flex; align-items: center; justify-content: space-between; }
.btn-sm { height: 28px; padding: 0 8px; font-size: var(--fs-xs); }
.label-list { display: flex; flex-wrap: wrap; gap: 6px; }
.label-list .label-chip { height: 24px; padding: 0 10px; font-size: var(--fs-xs); }
.label-picker { display: grid; gap: 2px; padding: 6px; border-radius: var(--r); background: var(--canvas); border: 1px solid var(--line); max-height: 220px; overflow-y: auto; }
.picker-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer; }
.picker-item:hover { background: var(--raised); }
.picker-item input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.label-form { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: end; gap: 16px; }
.label-form .form-actions { padding-bottom: 1px; }
.label-row { display: flex; align-items: center; gap: 12px; padding: 12px 20px; }
.label-row .label-chip { height: 24px; padding: 0 10px; font-size: var(--fs-xs); }
.label-row .muted { flex: 1; font-size: var(--fs-sm); }
.label-row-edit { display: block; padding: 16px 20px; }

@media (max-width: 1100px) {
  .wizard-grid { grid-template-columns: 1fr; }
  .wizard-grid > form { border-right: 0; border-bottom: 1px solid var(--line); }
  .inbox-item { grid-template-columns: auto minmax(0, 1fr) auto auto; }
  .ii-agents { display: none; }
}
@media (max-width: 860px) {
  .settings { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .settings-nav { flex-direction: row; padding: 8px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--line); }
  .settings-nav h1 { display: none; }
  .settings-nav a { flex: 1; min-width: 0; justify-content: center; flex-direction: column; gap: 3px; padding: 6px 4px; font-size: 11px; text-align: center; }
  .settings-nav a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
  .stepper { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stepper li span:last-child { display: none; }
  .stepper li.current span:last-child { display: inline; }
  .stepper li.current { grid-column: span 1; }
  .inbox-item { grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; padding: 14px 16px; }
  .ii-go { display: none; }
  .danger-row { flex-direction: column; align-items: stretch; }
  .label-form { grid-template-columns: 1fr; align-items: stretch; }
  .label-row { padding: 12px 16px; flex-wrap: wrap; }
  .inbox-head { flex-direction: column; align-items: stretch; }
}

/* exclusão a pedido do cliente (só administradores) */
.details-delete { padding: 16px; border-top: 1px solid var(--line); display: grid; gap: 6px; justify-items: start; }
.details-delete p { margin: 0; color: var(--text-3); font-size: var(--fs-xs); line-height: 1.5; }
