/* Apex Desk — painel. Identidade: headset, bordô #E0507A / #7A0F33. */
:root {
  --bg: #0f0d12;
  --panel: #16131b;
  --panel-2: #1c1822;
  --panel-3: #25202c;
  --hover: #211c28;
  --line: #2b2533;
  --line-soft: #221d29;
  --text: #f3edf3;
  --muted: #a99eae;
  --muted-2: #7b7183;
  --brand: #e0507a;
  --brand-2: #c43d66;
  --brand-deep: #7a0f33;
  --brand-soft: rgba(224, 80, 122, .14);
  --brand-line: rgba(224, 80, 122, .38);
  --out: #46192d;
  --out-2: #3b1426;
  --in: #221e2a;
  --ok: #3ddc97;
  --warn: #ffbf47;
  --danger: #ff5d6c;
  --read: #53bdeb;
  --radius: 14px;
  --shadow: 0 18px 40px rgba(0, 0, 0, .45);
  --font: 'Inter', -apple-system, 'Segoe UI', system-ui, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14.5px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
svg { flex: none; }
::selection { background: var(--brand-soft); }
* { scrollbar-width: thin; scrollbar-color: #3a3242 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #3a3242; border-radius: 8px; }

/* ---------- Estrutura ---------- */
.shell { display: grid; grid-template-columns: 76px 1fr; height: 100vh; height: 100dvh; }
.view { min-width: 0; min-height: 0; }

.rail {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 0; background: #0b0a0e; border-right: 1px solid var(--line-soft);
}
.rail-brand { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 10px; }
.brand-mark { width: 38px; height: auto; filter: drop-shadow(0 4px 12px rgba(224, 80, 122, .35)); }
.tabs { display: flex; flex-direction: column; gap: 6px; }
.tab {
  width: 60px; padding: 9px 0 7px; border: 0; border-radius: 14px; background: transparent; color: var(--muted-2);
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 600; letter-spacing: .2px;
  transition: background .15s, color .15s;
}
.tab svg { width: 24px; height: 24px; }
.tab:hover { color: var(--text); background: var(--hover); }
.tab[aria-current="true"] { color: var(--text); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-line); }
.tab[aria-current="true"] svg { color: var(--brand); }
.rail-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.rail-btn { width: 44px; height: 44px; border-radius: 12px; }
.rail-btn svg { width: 22px; height: 22px; }

.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.badge {
  position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; padding: 0 5px;
  background: var(--brand); color: #fff; border-radius: 9px; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px #0b0a0e;
}

/* ---------- Conversas ---------- */
#view-inbox { display: grid; grid-template-columns: 370px minmax(0, 1fr) 0; height: 100%; }
#view-inbox.show-details { grid-template-columns: 370px minmax(0, 1fr) 340px; }

.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-right: 1px solid var(--line-soft); }
.sidebar-head { padding: 18px 16px 10px; display: flex; flex-direction: column; gap: 10px; }
.sidebar-title { display: flex; align-items: center; gap: 10px; }
.sidebar-title h1 { margin: 0; font-size: 21px; letter-spacing: -.2px; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; }
.stat {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line-soft); font-size: 12px; color: var(--muted);
}
.stat b { color: var(--text); font-size: 12.5px; }
.stat-dot { width: 7px; height: 7px; border-radius: 50%; }
.stat-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(61, 220, 151, .15); }
.stat-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(255, 191, 71, .15); }

.filters { padding: 0 16px 10px; display: flex; flex-direction: column; gap: 8px; }
.search { position: relative; display: block; }
.search svg { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); color: var(--muted-2); }
.search .inp { padding-left: 38px; }
.sel, .inp {
  width: 100%; padding: 9px 12px; border-radius: 11px; background: var(--panel-2);
  border: 1px solid var(--line-soft); color: var(--text); font-size: 14px; outline: none;
}
.sel:focus, .inp:focus { border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; flex: none; }
.chip {
  flex: none; border: 1px solid var(--line-soft); background: transparent; color: var(--muted);
  padding: 5px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; transition: all .15s;
}
.chip:hover { color: var(--text); border-color: var(--line); }
.chip-on { background: var(--brand); border-color: var(--brand); color: #fff; }

.conv-list { list-style: none; margin: 0; padding: 0 8px 12px; overflow-y: auto; flex: 1; }
.conv-empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.conv {
  display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; align-items: center;
  padding: 10px 10px; border-radius: 12px; cursor: pointer; transition: background .12s;
}
.conv:hover { background: var(--hover); }
.conv.active { background: var(--panel-3); }
.conv-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.conv-top, .conv-bottom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.conv-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.conv-time { font-size: 11.5px; color: var(--muted-2); flex: none; }
.conv-time.unread { color: var(--brand); font-weight: 700; }
.conv-preview {
  flex: 1; min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 4px;
}
.conv-preview > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.conv-preview .ico svg, .conv-preview .ticks svg { width: 15px; height: 15px; }
.conv-marks { display: flex; gap: 6px; align-items: center; flex: none; }
.num-tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 600; color: var(--muted);
  max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.num-tag::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--tag, var(--brand)); flex: none; }
.pill-unread {
  background: var(--brand); color: #fff; min-width: 20px; height: 20px; border-radius: 10px;
  font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 6px;
}
.dot-human { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(255, 191, 71, .18); }

/* Avatar com foto + iniciais por baixo (fallback) e bolinha da cor do número */
.avatar {
  position: relative; width: 48px; height: 48px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px;
  background: linear-gradient(140deg, var(--av, #5b4a63), color-mix(in srgb, var(--av, #5b4a63) 55%, #000));
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar-badge {
  position: absolute; right: -1px; bottom: -1px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--tag, var(--brand)); box-shadow: 0 0 0 3px var(--panel);
}
.avatar-ico svg { width: 55%; height: 55%; display: block; margin: auto; }
.avatar-ico { display: grid; place-items: center; width: 100%; height: 100%; opacity: .9; }
.avatar.sm { width: 40px; height: 40px; font-size: 14px; }
.avatar.lg { width: 92px; height: 92px; font-size: 30px; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); position: relative; }
.chat-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; color: var(--muted); padding: 24px; }
.chat-empty h2 { margin: 10px 0 0; color: var(--text); font-size: 20px; }
.chat-empty p { margin: 0; line-height: 1.6; }
.empty-art {
  width: 108px; height: 108px; border-radius: 30px; display: grid; place-items: center;
  background: radial-gradient(circle at 30% 20%, rgba(224, 80, 122, .3), transparent 70%), var(--panel-2);
  border: 1px solid var(--line-soft);
}
.empty-art img { width: 58px; }
.chat-pane { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 64px;
  border-bottom: 1px solid var(--line-soft); background: var(--panel); flex: none;
}
.chat-avatar .avatar { width: 42px; height: 42px; font-size: 15px; }
.chat-head-info { min-width: 0; display: flex; flex-direction: column; flex: 1; }
.chat-head-info strong { font-size: 15.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat-sub { font-size: 12.5px; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; }
.chat-head-actions { display: flex; align-items: center; gap: 8px; }
.mode-pill {
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); white-space: nowrap; letter-spacing: .2px;
}
.mode-pill.auto { color: var(--ok); border-color: rgba(61, 220, 151, .4); }
.mode-pill.copiloto { color: var(--brand); border-color: var(--brand-line); }
.mode-pill.manual { color: #f6ced9; border-color: var(--brand-line); background: var(--brand-soft); }

.agent-strip { padding: 8px 16px; font-size: 13px; display: flex; align-items: center; gap: 10px; flex: none; }
.agent-strip.waiting, .agent-strip.thinking { background: var(--brand-soft); color: var(--brand); }
.agent-strip.human { background: rgba(255, 191, 71, .1); color: var(--warn); }
.agent-strip.error { background: rgba(255, 93, 108, .12); color: var(--danger); }
.agent-strip button { margin-left: auto; }

.messages-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.messages {
  flex: 1; overflow-y: auto; padding: 18px 6% 14px; display: flex; flex-direction: column; gap: 3px;
  background:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, .035) 1px, transparent 0) 0 0 / 22px 22px,
    radial-gradient(1000px 500px at 100% 0%, rgba(224, 80, 122, .05), transparent 60%);
}
.load-older { align-self: center; margin: 4px 0 12px; }
.day-sep {
  align-self: center; margin: 12px 0 8px; padding: 4px 12px; border-radius: 8px; font-size: 11.5px; font-weight: 600;
  color: var(--muted); background: var(--panel-2); border: 1px solid var(--line-soft);
}
.history-sep { align-self: center; margin: 6px 0; font-size: 11px; color: var(--muted-2); }
.msg {
  max-width: min(68%, 560px); padding: 6px 9px 5px 10px; border-radius: 12px; position: relative;
  overflow-wrap: anywhere; line-height: 1.42; box-shadow: 0 1px 1px rgba(0, 0, 0, .25);
}
.msg + .msg.same { margin-top: -1px; }
.msg.first { margin-top: 6px; }
.msg.in { align-self: flex-start; background: var(--in); border-top-left-radius: 4px; }
.msg.out { align-self: flex-end; background: linear-gradient(160deg, var(--out), var(--out-2)); border-top-right-radius: 4px; }
.msg.same.in { border-top-left-radius: 12px; }
.msg.same.out { border-top-right-radius: 12px; }
.msg.agente { background: linear-gradient(160deg, #2c2440, #251f37); }
.msg.erro { box-shadow: inset 0 0 0 1px rgba(255, 93, 108, .6); }
.msg-text { white-space: pre-wrap; }
.msg-text a { color: #ffb3c8; }
.msg-meta { display: flex; justify-content: flex-end; align-items: center; gap: 5px; font-size: 10.5px; color: rgba(243, 237, 243, .55); margin-top: 2px; float: right; margin-left: 10px; position: relative; top: 4px; }
.msg-meta .err { color: var(--danger); font-weight: 600; }
.msg-meta .unsure { color: var(--warn); font-weight: 600; }
.msg::after { content: ''; display: block; clear: both; }
.tick svg { width: 16px; height: 16px; display: block; }
.tick.read { color: var(--read); }
.author-tag { font-weight: 600; }
.author-agente { color: #c6b3ff; }
.author-celular { color: var(--ok); }
.msg-author { font-size: 11.5px; font-weight: 700; margin-bottom: 2px; }

/* Mídia na bolha */
.media-img, .media-video { display: block; max-width: 100%; width: 320px; max-height: 360px; object-fit: cover; border-radius: 9px; margin: 2px 0 4px; background: #000; cursor: zoom-in; }
.media-video { cursor: default; }
.sticker { width: 150px; height: 150px; object-fit: contain; display: block; }
.media-missing { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 9px; background: rgba(0, 0, 0, .2); color: var(--muted); font-size: 13px; margin: 2px 0 4px; }
.media-missing svg { width: 20px; height: 20px; }
.doc-card {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; margin: 2px 0 4px;
  background: rgba(0, 0, 0, .22); color: inherit; text-decoration: none; min-width: 230px;
}
.doc-card:hover { background: rgba(0, 0, 0, .32); }
.doc-icon { width: 38px; height: 44px; border-radius: 6px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 800; letter-spacing: .3px; flex: none; }
.doc-info { display: flex; flex-direction: column; min-width: 0; }
.doc-info strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.doc-info span { font-size: 11.5px; color: var(--muted); }
.audio-player { display: flex; align-items: center; gap: 10px; min-width: 250px; padding: 4px 2px 6px; }
.ap-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; }
.ap-btn svg { width: 18px; height: 18px; }
.ap-track { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ap-bar { position: relative; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .18); cursor: pointer; }
.ap-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 4px; background: #fff; }
.ap-row { display: flex; justify-content: space-between; font-size: 11px; color: rgba(243, 237, 243, .6); }
.ap-speed { border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 9px; }
.location-link { color: #ffb3c8; }

.to-bottom {
  position: absolute; right: 22px; bottom: 16px; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); display: grid; place-items: center; box-shadow: var(--shadow);
}
.to-bottom svg { width: 24px; height: 24px; }
.to-bottom .badge { top: -4px; right: -4px; }

/* Rascunhos (copiloto, fora do piloto) */
.drafts { flex: none; padding: 0 16px; display: flex; flex-direction: column; gap: 8px; }
.draft { background: linear-gradient(180deg, rgba(224, 80, 122, .12), rgba(224, 80, 122, .05)); border: 1px solid var(--brand-line); border-radius: 12px; padding: 10px 12px; margin-top: 8px; }
.draft-label { font-size: 11px; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.draft textarea { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; resize: vertical; min-height: 54px; }
.draft-actions { display: flex; gap: 8px; margin-top: 8px; }

/* Composer */
#send-error { margin: 0; padding: 8px 16px; font-size: 13px; color: var(--danger); background: rgba(255, 93, 108, .08); border-top: 1px solid rgba(255, 93, 108, .25); }
.composer, .recorder {
  flex: none; display: flex; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--line-soft); background: var(--panel); align-items: flex-end;
}
.composer-field { flex: 1; min-width: 0; display: flex; background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 22px; padding: 2px 6px 2px 14px; }
.composer-field:focus-within { border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-soft); }
.composer textarea { flex: 1; resize: none; max-height: 150px; padding: 9px 0; background: transparent; border: 0; outline: none; line-height: 1.4; }
.composer textarea:disabled { opacity: .55; }
.composer-btn { width: 44px; height: 44px; border-radius: 50%; }
.send-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; transition: transform .1s, background .15s; }
.send-btn svg { width: 21px; height: 21px; margin-left: 2px; }
.send-btn:hover { background: var(--brand-2); }
.send-btn:active { transform: scale(.95); }
.send-btn:disabled { opacity: .45; cursor: default; }
.composer:not(.has-text) .send-btn { display: none; }
.composer.has-text .mic-btn { display: none; }
.mic-btn { background: var(--brand-soft); color: var(--brand); }
.mic-btn:hover { background: var(--brand); color: #fff; }
.recorder { align-items: center; }
.rec-live { flex: 1; display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 44px; border-radius: 22px; background: var(--panel-2); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
#rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 38px; }
.rec-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 26px; overflow: hidden; }
.rec-wave span { width: 3px; border-radius: 2px; background: var(--brand); flex: none; }
@keyframes pulse { 50% { opacity: .3; } }

/* Prévia do anexo */
.attach-preview { display: grid; place-items: center; background: var(--bg); border-radius: 12px; padding: 12px; min-height: 120px; }
.attach-preview img, .attach-preview video { max-width: 100%; max-height: 320px; border-radius: 8px; }
.attach-preview audio { width: 100%; }

/* ---------- Detalhes ---------- */
.details { border-left: 1px solid var(--line-soft); background: var(--panel); overflow-y: auto; }
.details-head, .drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); min-height: 64px; }
.details-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.contact-card { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 6px 0 14px; border-bottom: 1px solid var(--line-soft); }
.contact-card strong { font-size: 17px; margin-top: 6px; }
.contact-card .muted { font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input, .field textarea, .field select {
  background: var(--panel-2); border: 1px solid var(--line-soft); color: var(--text); border-radius: 10px; padding: 9px 11px; outline: none;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-soft); }
.field textarea { resize: vertical; min-height: 84px; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Botões ---------- */
.btn-primary { background: var(--brand); color: #fff; border: 0; padding: 9px 16px; border-radius: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: background .15s; }
.btn-primary:hover { background: var(--brand-2); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); padding: 8px 14px; border-radius: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: background .15s; }
.btn-ghost:hover { background: var(--panel-3); }
.btn-ghost:disabled { opacity: .5; cursor: default; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(255, 93, 108, .4); }
.btn-danger:hover { background: rgba(255, 93, 108, .12); }

/* ---------- Números ---------- */
#view-numbers { overflow-y: auto; height: 100%; }
.numbers-page { max-width: 1240px; margin: 0 auto; padding: 26px 28px 60px; }
.numbers-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.numbers-head h1 { margin: 0; font-size: 24px; letter-spacing: -.3px; }
.numbers-head p { margin: 4px 0 0; }
.tip {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin-bottom: 20px; border-radius: 12px;
  background: rgba(255, 191, 71, .07); border: 1px solid rgba(255, 191, 71, .25); font-size: 13.5px;
}
.tip svg { width: 20px; height: 20px; color: var(--warn); margin-top: 1px; }
.tip div { display: flex; flex-direction: column; gap: 2px; }
.tip span { color: var(--muted); }
.numbers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.numbers-empty { grid-column: 1 / -1; padding: 50px 20px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.ncard {
  position: relative; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 16px; padding: 18px;
  display: flex; flex-direction: column; gap: 14px; overflow: hidden;
}
.ncard::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--tag, var(--brand)); opacity: .9; }
.ncard-top { display: flex; align-items: center; gap: 12px; }
.ncard .avatar { width: 46px; height: 46px; border-radius: 14px; font-size: 15px; }
.ncard-title { min-width: 0; flex: 1; }
.ncard h3 { margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ncard .sub { font-size: 12.5px; color: var(--muted); }
.status-pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line-soft); }
.status-pill small { font-weight: 500; color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.st-open .status-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(61, 220, 151, .18); }
.st-close .status-dot, .st-refused .status-dot { background: var(--danger); }
.st-connecting .status-dot { background: var(--warn); animation: pulse 1.2s infinite; }
.st-novo .status-dot { background: #8f7cff; }
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr-box { background: #fff; padding: 10px; border-radius: 14px; box-shadow: 0 8px 26px rgba(0, 0, 0, .35); }
.qr-box img { display: block; width: 220px; height: 220px; }
.qr-steps { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.ncard-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ncard-stats div { background: var(--panel-2); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.ncard-stats b { font-size: 17px; }
.ncard-stats span { font-size: 11.5px; color: var(--muted); }
.ncard-note { font-size: 12px; color: var(--muted-2); }
.ncard-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

.connect-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.connect-option {
  display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel-2); transition: border-color .15s, background .15s;
}
.connect-option:hover { border-color: var(--brand-line); background: var(--panel-3); }
.connect-option svg { width: 28px; height: 28px; color: var(--brand); }
.connect-option strong { font-size: 15px; }
.connect-option span { font-size: 12.5px; color: var(--muted); }

/* ---------- Login ---------- */
.login {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(900px 520px at 50% -10%, rgba(224, 80, 122, .2), transparent 65%), var(--bg);
}
.login-card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 22px; padding: 34px 30px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login-logo { height: 42px; align-self: center; }
.login-sub { text-align: center; color: var(--muted); margin: -4px 0 8px; font-size: 13.5px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input { background: var(--panel-2); border: 1px solid var(--line-soft); color: var(--text); border-radius: 11px; padding: 11px 12px; font-size: 15px; outline: none; }
.login-card input:focus { border-color: var(--brand-line); box-shadow: 0 0 0 3px var(--brand-soft); }
.login-card .btn-primary { padding: 11px; margin-top: 4px; }
.login-error { color: var(--danger); font-size: 13px; text-align: center; margin: 0; }

/* ---------- Drawer / popover / modal / toast / lightbox ---------- */
.drawer { position: fixed; top: 0; right: 0; width: 380px; max-width: 92vw; height: 100vh; height: 100dvh; background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow); z-index: 40; display: flex; flex-direction: column; }
.alerts-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.alert-item { padding: 12px; border-radius: 10px; font-size: 13.5px; display: flex; gap: 10px; }
.alert-item:hover { background: var(--hover); }
.alert-item .k { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--muted-2); }
.k-desconectado, .k-erro_agente { background: var(--danger) !important; }
.k-reconectado { background: var(--ok) !important; }
.k-humano { background: var(--warn) !important; }
.alert-item.unseen { background: var(--brand-soft); }
.alert-time { color: var(--muted-2); font-size: 11.5px; margin-top: 2px; }

.popover { position: fixed; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 50; min-width: 200px; }
.popover-name { padding: 8px 10px; color: var(--muted); font-size: 13px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.popover-item { display: block; width: 100%; text-align: left; background: transparent; border: 0; padding: 9px 10px; border-radius: 8px; }
.popover-item:hover { background: var(--panel-3); }

.modal-back { position: fixed; inset: 0; background: rgba(5, 3, 8, .66); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; width: 100%; max-width: 540px; max-height: 90vh; max-height: 90dvh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line-soft); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 10px; }
#pairing-code { color: var(--text); background: var(--panel-2); border-radius: 12px; padding: 6px 0; }
#pairing-code:empty { display: none; }

.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 80; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--panel-3); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; animation: pop .2s ease; }
.toast.err { border-color: rgba(255, 93, 108, .6); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .9); display: grid; place-items: center; padding: 24px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.lightbox .icon-btn { position: absolute; top: 14px; right: 14px; color: #fff; }

.only-mobile { display: none; }

/* ---------- Celular ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr 62px; }
  .rail { grid-row: 2; flex-direction: row; justify-content: space-around; padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line-soft); }
  .rail-brand { display: none; }
  .tabs { flex-direction: row; gap: 4px; }
  .rail-bottom { margin: 0; flex-direction: row; }
  .view { grid-row: 1; }
  #view-inbox, #view-inbox.show-details { grid-template-columns: 1fr; position: relative; }
  .chat, .details { position: absolute; inset: 0; z-index: 10; }
  #view-inbox:not(.chat-open) .chat { display: none; }
  #view-inbox.chat-open .sidebar { display: none; }
  .details { z-index: 20; }
  .only-mobile { display: inline-flex; }
  .chat-head { padding: 8px 10px; gap: 8px; }
  .chat-head #chat-mode { display: none; } /* o selo do piloto já aparece na lista */
  .messages { padding: 14px 10px; }
  .msg { max-width: 86%; }
  .media-img, .media-video { width: 260px; max-height: 300px; }
  .composer { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .numbers-page { padding: 18px 14px 40px; }
  .numbers-head { align-items: flex-start; flex-direction: column; }
  .connect-options { grid-template-columns: 1fr; }
  .shell.chat-focused .rail { display: none; }
  .shell.chat-focused { grid-template-rows: 1fr; }
}
