/* Marca Spartans Digital: escuro + dourado (padrão) e uma versão clara opcional.
   Fontes: Archivo nos títulos, Manrope no texto (as mesmas do site da agência). */
:root {
  --bg: #0b0a08;
  --panel: #14120e;
  --panel-2: #1c1914;
  --line: #2b261d;
  --text: #efe8d9;
  --muted: #a69d8b;
  --accent: #d6b26a;
  --accent-hi: #f0d79b;
  --accent-lo: #8c6d33;
  --accent-ink: #0b0a08;
  --accent-soft: #2a2416;
  --bubble-in: #1c1914;
  --bubble-out: #2e2716;
  --chat-bg: #0f0d0a;
  --danger: #e58a72;
  --ok: #7fbf8a;
  --warn: #f0d79b;
  --wait: #f0a35e;
  --wait-soft: #3a2614;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5);
  --f-body: "Manrope", "Segoe UI", system-ui, sans-serif;
  --f-display: "Archivo", "Arial Narrow", Arial, sans-serif;
  font-family: var(--f-body);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4efe4;
  --panel: #fffdf8;
  --panel-2: #f7f1e5;
  --line: #e6dccb;
  --text: #1a1712;
  --muted: #6f6656;
  --accent: #8c6d33;
  --accent-hi: #b8913f;
  --accent-lo: #6d5426;
  --accent-ink: #ffffff;
  --accent-soft: #f3e9d2;
  --bubble-in: #fffdf8;
  --bubble-out: #f3e7c9;
  --chat-bg: #efe7d8;
  --danger: #b4432c;
  --ok: #2f7d43;
  --warn: #8a6510;
  --wait: #b9560c;
  --wait-soft: #fdeedd;
  --shadow: 0 1px 2px rgba(60, 45, 20, .1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn { color: var(--warn); }

/* ---------- botões ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.sm { padding: 4px 10px; font-size: 13px; }

input, select, textarea {
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  padding: 8px 10px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow);
}
.login-card label, .stack label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card .btn { margin-top: 6px; padding: 10px; }
.form-error { color: var(--danger); margin: 0; font-size: 13px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand-logo { width: 26px; height: auto; display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.brand { font-family: var(--f-display); letter-spacing: .02em; text-transform: uppercase; font-weight: 800; }
.brand span { color: var(--accent); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; height: 100vh; height: 100dvh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.side-top .brand { flex: none; white-space: nowrap; }
.me { display: flex; align-items: center; gap: 2px; min-width: 0; }
.me-name { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 4px; max-width: 120px; }
/* menu principal: três botões do mesmo tamanho, sempre visíveis */
.side-nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.nav-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 0;
  padding: 7px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: border-color .12s, background .12s, color .12s;
}
.nav-btn span { font-size: 14px; line-height: 1; }
.nav-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.nav-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.unit-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.unit-bar select { flex: 1; min-width: 0; padding: 6px 8px; }
.conn { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: #9aa39e; }
.conn-open i { background: #1fb36b; }
.conn-connecting i { background: #e5a100; }
.conn-close i { background: var(--danger); }
.conn-simulation i { background: #7b6cd9; }

.sim-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 14px;
  background: var(--accent-soft); color: var(--text); font-size: 12px; border-bottom: 1px solid var(--line);
}


.search { padding: 10px 14px; }
.conv-list { flex: 1; overflow-y: auto; min-height: 0; }
.empty-list { padding: 24px; color: var(--muted); text-align: center; line-height: 1.5; }

.conv {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 10px 14px;
  border: 0; background: none; cursor: pointer; border-bottom: 1px solid var(--line);
}
.conv:hover { background: var(--panel-2); }
.conv.active { background: var(--accent-soft); }
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.conv-top, .conv-bottom { display: flex; align-items: center; gap: 6px; }
.conv-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 12px; color: var(--muted); }
.conv.unread .conv-time { color: var(--accent); font-weight: 600; }
.conv-preview { flex: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.unread .conv-preview { color: var(--text); }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.wait-chip { background: var(--wait-soft); color: var(--wait); border-radius: 10px; font-size: 11px; font-weight: 600; padding: 1px 7px; white-space: nowrap; }

.avatar {
  --h: 150; flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: hsl(var(--h) 45% 88%); color: hsl(var(--h) 45% 28%); font-weight: 700; font-size: 15px;
}
:root:not([data-theme="light"]) .avatar { background: hsl(var(--h) 30% 24%); color: hsl(var(--h) 50% 82%); }
.avatar.sm { width: 38px; height: 38px; font-size: 13px; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--chat-bg); }
.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 24px; }
.chat-empty h2 { color: var(--text); font-size: 18px; margin: 8px 0 4px; }
.chat-empty-icon { font-size: 40px; }

.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.chat-title { min-width: 0; }
.chat-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-sub { font-size: 12px; color: var(--muted); }
.back { display: none; }

.messages { flex: 1; overflow-y: auto; padding: 16px 6%; display: flex; flex-direction: column; gap: 3px; min-height: 0; }
.no-msgs { margin: auto; color: var(--muted); }
.day-sep { text-align: center; margin: 12px 0 6px; }
.day-sep span { background: var(--panel); color: var(--muted); font-size: 12px; padding: 4px 10px; border-radius: 8px; box-shadow: var(--shadow); }

.msg { display: flex; }
.msg.out { justify-content: flex-end; }
.bubble {
  max-width: min(560px, 78%); padding: 6px 9px 4px; border-radius: var(--radius); box-shadow: var(--shadow);
  background: var(--bubble-in); overflow-wrap: anywhere;
}
.msg.out .bubble { background: var(--bubble-out); }
.sender { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
.text { line-height: 1.4; white-space: normal; }
.meta { display: flex; justify-content: flex-end; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); margin-top: 2px; }
.meta .by { font-style: italic; }
.tick { font-size: 11px; }
.deleted, .unsupported { color: var(--muted); font-style: italic; }

.text.special { white-space: normal; }
.tick.read { color: #2b8fe0; }
.quote {
  display: flex; flex-direction: column; gap: 1px; margin: 2px 0 5px; padding: 5px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, .05); border-left: 3px solid var(--accent); font-size: 12px; max-width: 100%;
}
.quote b { color: var(--accent); }
.quote span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root:not([data-theme="light"]) .quote { background: rgba(255, 255, 255, .06); }

.media { display: block; margin: 2px 0 4px; }
.media-img img, .media-video { display: block; max-width: 100%; width: 320px; max-height: 360px; object-fit: cover; border-radius: 7px; background: rgba(0, 0, 0, .06); }
.media-img img { width: auto; min-width: 120px; min-height: 80px; }
.media-ptv { width: 220px; height: 220px; border-radius: 50%; object-fit: cover; background: #000; }
.sticker { width: 140px; height: 140px; object-fit: contain; }
.msg.kind-sticker .bubble { background: transparent; box-shadow: none; }
.media-audio { width: 280px; max-width: 100%; height: 40px; }
.doc {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 7px; min-width: 220px;
  background: rgba(0, 0, 0, .05); color: var(--text); text-decoration: none;
}
.doc:hover { background: rgba(0, 0, 0, .09); }
.doc-icon { font-size: 22px; }
.doc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.doc-dl { color: var(--muted); }
.media-missing { padding: 14px; border-radius: 7px; background: rgba(0, 0, 0, .05); color: var(--muted); font-size: 12px; font-style: italic; }
.chat.drop .messages { outline: 3px dashed var(--accent); outline-offset: -10px; }

/* ---------- ações nas mensagens ---------- */
.bubble { position: relative; }
.msg-menu-btn {
  position: absolute; top: 2px; right: 2px; z-index: 2; border: 0; border-radius: 50%; width: 24px; height: 24px;
  background: inherit; color: var(--muted); cursor: pointer; opacity: 0; transition: opacity .12s; font-size: 14px; line-height: 1;
}
.msg:hover .msg-menu-btn, .msg-menu-btn:focus-visible { opacity: 1; }
@media (hover: none) { .msg-menu-btn { opacity: .7; } }
.msg.is-hidden .bubble { opacity: .55; border: 1px dashed var(--muted); }
.msg.flash .bubble { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); } 100% { box-shadow: var(--shadow); } }

.msg-menu {
  position: fixed; z-index: 70; min-width: 210px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 28px rgba(0, 0, 0, .18); padding: 6px; display: flex; flex-direction: column;
}
.msg-menu > button { border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.msg-menu > button:hover { background: var(--panel-2); }
.msg-menu > button.danger { color: var(--danger); }
.emoji-row { display: flex; gap: 2px; padding: 2px 2px 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.emoji-row button { border: 0; background: none; font-size: 20px; padding: 4px; border-radius: 8px; cursor: pointer; flex: 1; }
.emoji-row button:hover { background: var(--panel-2); }
.emoji-row button.mine { background: var(--accent-soft); }

.reactions { display: flex; gap: 4px; flex-wrap: wrap; margin: 4px 0 -2px; }
.reaction {
  border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 1px 7px; font-size: 13px; cursor: pointer;
}
.reaction small { margin-left: 3px; color: var(--muted); }
.reaction.mine { border-color: var(--accent); background: var(--accent-soft); }

.quote[data-jump] { cursor: pointer; }
.pinned-bar { display: flex; flex-direction: column; background: var(--panel); border-bottom: 1px solid var(--line); }
.pinned-item {
  border: 0; background: none; text-align: left; padding: 6px 16px; cursor: pointer; font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted);
}
.pinned-item:hover { background: var(--panel-2); }
.pinned-item span { color: var(--text); }
.head-btn { margin-left: auto; }

.compose-ctx {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: var(--panel); border-top: 1px solid var(--line);
}
.ctx-body {
  flex: 1; min-width: 0; display: flex; flex-direction: column; border-left: 3px solid var(--accent); padding: 2px 8px; font-size: 13px;
}
.ctx-body b { color: var(--accent); }
.ctx-body span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-ctx + .composer { border-top: 0; }

button.media { border: 0; padding: 0; background: none; cursor: zoom-in; }
.sticker-btn { display: block; }

.fwd-preview { background: var(--panel-2); padding: 8px 10px; border-radius: 8px; color: var(--muted); margin: 0 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fwd-list { max-height: 320px; overflow-y: auto; margin-top: 8px; display: flex; flex-direction: column; }
.fwd-item { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 8px; border-radius: 8px; cursor: pointer; text-align: left; }
.fwd-item:hover { background: var(--panel-2); }
.fwd-item:disabled { opacity: .5; }

.modal-backdrop.viewer { padding: 0; background: rgba(0, 0, 0, .9); }
.viewer .modal { max-width: none; width: 100%; height: 100%; border-radius: 0; background: transparent; box-shadow: none; padding: 0; display: flex; flex-direction: column; }
.viewer-top { display: flex; align-items: center; gap: 8px; padding: 10px 16px; color: #fff; }
.viewer-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-top .btn { background: rgba(255, 255, 255, .12); border-color: transparent; color: #fff; text-decoration: none; }
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 16px 16px; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- passo 4: filtros, etiquetas, painel, atalhos, figurinhas ---------- */
.filters { padding: 0 14px 8px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 3px 10px;
  font-size: 12px; cursor: pointer; white-space: nowrap;
}
.chip small { color: var(--muted); margin-left: 2px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.on small { color: inherit; opacity: .85; }
.filter-row { display: flex; gap: 6px; align-items: center; }
.filter-row select { flex: 1; min-width: 0; padding: 4px 8px; font-size: 13px; }
.filter-row .btn { font-size: 12px; }

.conv-pin { font-size: 11px; }
.conv-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.label-chip {
  --c: #888; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 0 7px; border-radius: 9px;
  background: color-mix(in srgb, var(--c) 18%, transparent); color: color-mix(in srgb, var(--c) 75%, var(--text)); white-space: nowrap;
}
.label-chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.tag-user, .tag-closed { font-size: 11px; color: var(--muted); white-space: nowrap; }
.tag-closed { background: var(--panel-2); border-radius: 9px; padding: 0 6px; }

.head-spacer { flex: 1; }
.head-icon { font-size: 16px; padding: 4px 8px; }

.chat { position: relative; }
.side-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(340px, 100%); z-index: 20; overflow-y: auto;
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: -6px 0 24px rgba(0, 0, 0, .08); padding: 0 16px 16px;
}
.panel-head { position: sticky; top: 0; background: var(--panel); display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); z-index: 1; }
.side-panel section { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.side-panel section:last-child { border-bottom: 0; }
.side-panel h4 { margin: 0; font-size: 13px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: none; padding: 6px; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.label-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.label-toggle {
  --c: #888; border: 1px solid color-mix(in srgb, var(--c) 50%, transparent); background: none; border-radius: 12px;
  padding: 3px 10px; font-size: 12px; cursor: pointer; color: var(--text);
}
.label-toggle.on { background: color-mix(in srgb, var(--c) 22%, transparent); border-color: var(--c); font-weight: 600; }
.notes { display: flex; flex-direction: column; gap: 8px; }
.note { background: #fff6d6; border: 1px solid #f0dc9a; border-radius: 8px; padding: 8px 10px; color: #4a3f17; }
:root:not([data-theme="light"]) .note { background: #3a3218; border-color: #5c4f22; color: #f1e6c0; }
.note-body { line-height: 1.4; overflow-wrap: anywhere; }
.note-meta { font-size: 11px; opacity: .75; margin-top: 4px; }
.link-btn { border: 0; background: none; color: var(--danger); cursor: pointer; padding: 0; font-size: 11px; text-decoration: underline; }
.sticker-pop-head .link-btn { color: var(--accent); font-size: 12px; }

.qr-suggest {
  background: var(--panel); border-top: 1px solid var(--line); max-height: 260px; overflow-y: auto; padding: 4px 8px;
}
.qr-item { display: flex; gap: 10px; width: 100%; border: 0; background: none; text-align: left; padding: 7px 8px; border-radius: 6px; cursor: pointer; }
.qr-item.on, .qr-item:hover { background: var(--accent-soft); }
.qr-item b { color: var(--accent); flex: none; }
.qr-item span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-hint, .qr-empty { font-size: 11px; color: var(--muted); padding: 4px 8px; }

.sticker-pop { width: 320px; padding: 10px; }
.sticker-pop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sticker-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-height: 280px; overflow-y: auto; }
.sticker-grid button { border: 0; background: none; padding: 4px; border-radius: 8px; cursor: pointer; aspect-ratio: 1; }
.sticker-grid button:hover { background: var(--panel-2); }
.sticker-grid img { width: 100%; height: 100%; object-fit: contain; }
.sticker-grid.big { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); max-height: 320px; margin-bottom: 12px; }
.sticker-cell { position: relative; aspect-ratio: 1; background: var(--panel-2); border-radius: 8px; padding: 6px; }
.sticker-cell img { width: 100%; height: 100%; object-fit: contain; }
.sticker-del { position: absolute; top: 2px; right: 2px; border: 0; border-radius: 50%; width: 22px; height: 22px; background: var(--danger); color: #fff; cursor: pointer; font-size: 11px; }

.check { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--text) !important; }
.check input { width: auto; }
.msg-menu > button.danger { color: var(--danger); }

.modal-backdrop.wide .modal { max-width: 640px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.settings-head { display: flex; align-items: center; justify-content: space-between; }
.settings-head h3 { margin: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 12px 0; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.settings-body { overflow-y: auto; min-height: 0; }
.set-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; }
.set-item { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.set-item:last-child { border-bottom: 0; }
.set-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.set-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13px; }
.set-form { border-top: 1px solid var(--line); padding-top: 12px; }
.set-form h4 { margin: 0; }
.set-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.row2 { display: flex; gap: 10px; }
.row2 label:first-child { flex: 1; }
.color-label input { width: 56px; height: 38px; padding: 2px; }
.danger-text { color: var(--danger); }
.stack label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

@media (max-width: 799px) {
  .me-name { display: none; }
  .side-panel { width: 100%; }
}

/* ---------- passo 5: anúncio, lead e venda ---------- */
.tag-ad, .tag-sale, .tag-good, .tag-bad { font-size: 11px; border-radius: 9px; padding: 0 6px; white-space: nowrap; }
.tag-ad { background: #fdf0d5; color: #8a5a00; }
.tag-sale { background: #dcf5e6; color: #0f6b3f; font-weight: 600; }
.tag-good { background: #e3f1fb; color: #1d5f8f; }
.tag-bad { background: #fbe4e4; color: #9b2c2c; }
:root:not([data-theme="light"]) .tag-ad { background: #3d2e10; color: #f3c26b; }
:root:not([data-theme="light"]) .tag-sale { background: #143826; color: #7ddca4; }
:root:not([data-theme="light"]) .tag-good { background: #15304a; color: #8cc4ef; }
:root:not([data-theme="light"]) .tag-bad { background: #3f1d1d; color: #f1a1a1; }
.ad-strip {
  padding: 6px 16px; font-size: 13px; background: #fdf0d5; color: #6b4600; border-bottom: 1px solid var(--line);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ad-strip a { color: inherit; }
:root:not([data-theme="light"]) .ad-strip { background: #3d2e10; color: #f3c26b; }
.origin { font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.origin.ad { background: #fdf0d5; color: #6b4600; padding: 8px 10px; border-radius: 8px; }
:root:not([data-theme="light"]) .origin.ad { background: #3d2e10; color: #f3c26b; }
.seg button.on.good { background: #1d78c1; color: #fff; }
.seg button.on.bad { background: var(--danger); color: #fff; }
.sale-box { display: flex; flex-direction: column; gap: 2px; background: var(--accent-soft); padding: 8px 10px; border-radius: 8px; }
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- passo 6: administração e grupo ---------- */
.set-item.inactive { opacity: .55; }
.unit-checks { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; margin: 0; }
.unit-checks legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.unit-checks[hidden] { display: none; }
.group-head { display: flex; align-items: center; gap: 10px; }
.group-pic { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; }
.group-desc { font-size: 13px; background: var(--panel-2); border-radius: 8px; padding: 8px 10px; max-height: 140px; overflow-y: auto; overflow-wrap: anywhere; }
.media-count { font-size: 13px; color: var(--muted); }
.participants { display: flex; flex-direction: column; max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.participant { display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.participant:last-child { border-bottom: 0; }
.participant .adm { font-size: 11px; color: var(--accent); font-weight: 600; background: var(--accent-soft); border-radius: 8px; padding: 0 6px; }

/* ---------- passo 7: métricas ---------- */
.metrics-page { min-height: 100%; background: var(--bg); }
.metrics-head {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.metrics-head h1 { font-size: 18px; margin: 0; flex: 1; }
.metrics-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.metrics-filters select { width: auto; padding: 6px 8px; }
.metrics-filters .seg { min-width: 220px; }
.metrics-body { max-width: 1120px; margin: 0 auto; padding: 16px 24px 48px; display: flex; flex-direction: column; gap: 16px; }
.metrics-note { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.accent { border-color: var(--accent); background: var(--accent-soft); }
.stat.warn .stat-value { color: var(--wait); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.card h2 { font-size: 15px; margin: 0 0 4px; }
.card > p { margin: 0 0 10px; }
.table-wrap { overflow-x: auto; }
.mtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.mtable th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.mtable td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.mtable tr:last-child td { border-bottom: 0; }
.mtable .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mtable .ad-title { max-width: 360px; overflow-wrap: anywhere; }
.hero-num { font-size: 44px; font-weight: 700; display: flex; align-items: baseline; gap: 10px; font-variant-numeric: tabular-nums; }
.hero-num span { font-size: 14px; font-weight: 400; color: var(--muted); }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--accent); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .baseline { stroke: var(--muted); stroke-width: 1; opacity: .5; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit.on { fill: var(--text); opacity: .05; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, .12); white-space: nowrap; line-height: 1.4;
}
.table-view { margin-top: 8px; font-size: 13px; }
.table-view summary { cursor: pointer; color: var(--muted); }
.table-view table { margin-top: 6px; max-width: 360px; }
@media (max-width: 799px) {
  .metrics-head { padding: 10px 16px; }
  .metrics-body { padding: 12px 16px 40px; }
  .stat-value { font-size: 22px; }
}

/* ---------- pipeline (kanban) ---------- */
.pipeline-page { height: 100%; display: flex; flex-direction: column; background: var(--bg); }
.pipeline-page .metrics-filters input[type=search] { width: 200px; padding: 6px 10px; }
.board {
  flex: 1; min-height: 0; display: flex; gap: 12px; padding: 16px 24px; overflow-x: auto; overflow-y: hidden;
  align-items: stretch; scroll-snap-type: x proximity;
}
.col {
  --c: #64748b; flex: 0 0 280px; display: flex; flex-direction: column; min-height: 0; scroll-snap-align: start;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; border-top: 3px solid var(--c);
}
.col.drop-on { outline: 2px dashed var(--c); outline-offset: -4px; background: color-mix(in srgb, var(--c) 8%, var(--panel-2)); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 4px; }
.col-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.col-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.col-count { font-size: 12px; color: var(--muted); background: var(--panel); border-radius: 10px; padding: 1px 8px; font-variant-numeric: tabular-nums; }
.col-value { padding: 0 12px 4px 30px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col.kind-won .col-value { color: var(--accent); font-weight: 600; }
.col-cards { flex: 1; min-height: 80px; overflow-y: auto; padding: 6px 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.col-empty { margin: 8px 4px; color: var(--muted); font-size: 12px; text-align: center; }
.card-k {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; cursor: pointer;
  display: flex; flex-direction: column; gap: 5px; box-shadow: var(--shadow); transition: box-shadow .12s, transform .12s;
}
.card-k:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, .1); }
.card-k:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.card-k.dragging { opacity: .45; transform: rotate(1.5deg); }
.card-k-top { display: flex; align-items: center; gap: 6px; }
.card-k-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.card-k-move { border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; padding: 2px 6px; font-size: 13px; }
.card-k-move:hover { background: var(--panel-2); color: var(--text); }
.card-k-sale { font-size: 13px; font-weight: 600; color: var(--accent); }
.card-k-preview { font-size: 12px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.card-k-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.card-k-tags:empty { display: none; }
.card-k-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.card-k-unit { font-size: 11px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 4px; }
@media (max-width: 799px) {
  .board { padding: 12px 16px; }
  .col { flex-basis: 85vw; }
  .pipeline-page .metrics-filters input[type=search] { width: 100%; }
}

/* ---------- Meta (API de Conversões) ---------- */
.meta-intro p { margin: 0 0 6px; }
.meta-intro ul { margin: 0 0 6px; padding-left: 18px; line-height: 1.6; }
.meta-status { padding: 8px 12px; border-radius: 8px; background: var(--panel-2); font-size: 13px; margin: 8px 0; }
.meta-status.on { background: var(--accent-soft); }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 560px) { .row3 { grid-template-columns: 1fr; } }
.help { background: var(--panel-2); border-radius: 8px; padding: 6px 10px; }
.help summary { cursor: pointer; color: var(--accent); }
.help ol { margin: 6px 0 2px; padding-left: 18px; line-height: 1.6; }
.meta-log-title { margin: 16px 0 6px; }
.meta-evs { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.meta-ev.st-error { color: var(--danger); }

/* ---------- queixa, agendamento, links, métricas novas ---------- */
.tag-appt, .tag-complaint { font-size: 11px; border-radius: 9px; padding: 0 6px; white-space: nowrap; }
.tag-appt { background: #ede7fb; color: #5b3aa8; }
.tag-complaint { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
:root:not([data-theme="light"]) .tag-appt { background: #2c2347; color: #c7b6f5; }
.appt-date { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.appt-date.disabled { opacity: .5; }
.reason-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; }
.link-url { overflow-wrap: anywhere; }

.funnel { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.funnel-row { display: grid; grid-template-columns: 130px 1fr 210px; align-items: center; gap: 10px; }
.funnel-label { font-size: 13px; }
.funnel-track { background: var(--panel-2); border-radius: 6px; height: 22px; overflow: hidden; }
.funnel-bar { height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.funnel-num { font-size: 13px; font-variant-numeric: tabular-nums; }
@media (max-width: 700px) { .funnel-row { grid-template-columns: 100px 1fr; } .funnel-num { grid-column: 2; } }

.speed { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.speed-tile { border-radius: 10px; padding: 10px 12px; border: 1px solid var(--line); border-left-width: 4px; }
.speed-head { font-size: 13px; font-weight: 600; }
.sp-excellent { border-left-color: #1f9d55; }
.sp-good { border-left-color: #4c9be8; }
.sp-attention { border-left-color: #e5a100; }
.sp-critical { border-left-color: var(--danger); }

.heat-wrap { overflow-x: auto; }
.heat { border-collapse: separate; border-spacing: 2px; font-size: 11px; }
.heat th { color: var(--muted); font-weight: 400; padding: 0 4px; text-align: left; white-space: nowrap; }
.heat td { width: 22px; height: 18px; border-radius: 3px; background: color-mix(in srgb, var(--accent) calc(var(--a) * 100%), var(--panel-2)); }
.heat-legend { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.heat-scale { display: inline-block; width: 90px; height: 10px; border-radius: 3px; background: linear-gradient(90deg, var(--panel-2), var(--accent)); }

.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .two-cols { grid-template-columns: 1fr; } }
.small-stats { grid-template-columns: repeat(2, 1fr); }
.small-stats .stat-value { font-size: 20px; }

.attach { font-size: 18px; padding: 6px 8px; }
.attach-box { text-align: center; margin-bottom: 12px; }
.attach-box audio { width: 100%; }
.attach-preview { max-width: 100%; max-height: 280px; border-radius: 8px; }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px; background: var(--panel); border-top: 1px solid var(--line); }
.composer textarea { resize: none; max-height: 160px; line-height: 1.4; }
.composer .send { padding: 9px 16px; }

/* ---------- modal / toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border-radius: 14px; padding: 22px; width: 100%; max-width: 420px; box-shadow: 0 10px 40px rgba(0, 0, 0, .3); }
.modal h3 { margin: 0 0 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.qr-body { text-align: center; }
.qr { width: 260px; max-width: 100%; background: #fff; padding: 8px; border-radius: 8px; }
.code { font-family: ui-monospace, monospace; letter-spacing: 2px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 32px);
  padding: 10px 16px; border-radius: 8px; color: #fff; background: var(--danger); box-shadow: 0 6px 20px rgba(0, 0, 0, .25); z-index: 60;
}
.toast.ok { background: var(--accent); color: var(--accent-ink); }

/* ---------- celular ---------- */
@media (max-width: 799px) {
  .app { grid-template-columns: 1fr; }
  .app .chat { display: none; }
  .app.has-chat .sidebar { display: none; }
  .app.has-chat .chat { display: flex; }
  .back { display: inline-block; }
  .messages { padding: 12px; }
  .bubble { max-width: 88%; }
}

/* ---------- marca Spartans: tipografia, login e detalhes ---------- */
h1, h2, h3, .chat-name, .stat-value, .hero-num, .col-name, .metrics-head h1 { font-family: var(--f-display); }
.metrics-head h1 { text-transform: uppercase; letter-spacing: .03em; }
.login-wrap { background:
  radial-gradient(900px 500px at 50% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%), var(--bg); }
.login-card { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.login-logo { width: 84px; height: auto; margin: 0 auto 4px; display: block; filter: drop-shadow(0 6px 18px rgba(0,0,0,.45)); }
.login-title { text-align: center; }
.login-title b { display: block; font-family: var(--f-display); font-size: 20px; text-transform: uppercase; letter-spacing: .04em; }
.login-title span { color: var(--accent); font-size: 12px; letter-spacing: .24em; text-transform: uppercase; }
.btn.primary { font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hi); border-color: var(--accent-hi); filter: none; }
.side-head { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 7%, var(--panel)), var(--panel)); }
.conv.active { box-shadow: inset 3px 0 0 var(--accent); }
.theme-btn { font-size: 15px; padding: 4px 8px; }
.stat { border-top: 2px solid color-mix(in srgb, var(--accent) 55%, var(--line)); }
.card h2 { letter-spacing: .01em; }
::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }
* { scrollbar-color: color-mix(in srgb, var(--accent) 35%, var(--line)) transparent; }
/* iniciais do contato no dourado da marca (em vez de uma cor por contato) */
.avatar { background: var(--accent-soft) !important; color: var(--accent) !important; border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
