/* Desk — layout do app, construído sobre o design system Ly (ly.css) */
:root {
  --bubble-in: var(--ly-surface);
  --bubble-out: var(--ly-accent-soft);
  --chat-bg: var(--ly-bg);
  --gap: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 400 14px/1.5 var(--ly-font); color: var(--ly-text); background: var(--ly-bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
h1, h2, h3, h4 { color: var(--ly-title); letter-spacing: -.03em; font-weight: 600; line-height: 1.1; }
input, select, textarea {
  font: 400 14px/1.4 var(--ly-font); color: var(--ly-title); background: var(--ly-surface);
  border: 1px solid var(--ly-border); border-radius: 12px; padding: 10px 13px; width: 100%; transition: border-color .15s;
}
input::placeholder, textarea::placeholder { color: var(--ly-muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ly-accent); box-shadow: 0 0 0 3px var(--ly-accent-soft); }
label { display: block; font-size: 13px; color: var(--ly-title); font-weight: 500; margin-bottom: 14px; }
label > input, label > textarea, label > select { margin-top: 6px; }
.muted { color: var(--ly-muted); }
.small { font-size: 13px; }

/* Botões (mesma linguagem do .ly-btn) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 14px/1 var(--ly-font); padding: 11px 20px; border-radius: 999px;
  border: 1px solid var(--ly-title); background: transparent; color: var(--ly-title);
  transition: background .15s, transform .1s; white-space: nowrap;
}
.btn:hover { background: var(--ly-hover); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ly-accent); border-color: var(--ly-accent); color: var(--ly-on-accent); }
.btn.primary:hover { background: var(--ly-accent-hover); border-color: var(--ly-accent-hover); }
.btn.danger { border-color: var(--ly-border); color: var(--ly-danger-fg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--ly-hover); }
.btn.sm { padding: 8px 14px; font-size: 13px; }
.btn.full { width: 100%; }
.btn.icon { padding: 8px; width: 34px; height: 34px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Marca */
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand .ly-mark { font-size: 40px; }
.brand-name { font-weight: 600; color: var(--ly-title); font-size: 15px; letter-spacing: -.01em; }

/* Overlays / modais */
.overlay { position: fixed; inset: 0; background: rgba(15, 13, 12, .45); display: grid; place-items: center; z-index: 50; padding: 16px; backdrop-filter: blur(2px); }
.modal { background: var(--ly-surface); border: 1px solid var(--ly-border); border-radius: 20px; padding: 32px; width: 100%; max-width: 460px; box-shadow: var(--ly-shadow-lg); }
.modal h3 { margin: 0 0 18px; font-size: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.modal-actions #modalCancel { border-color: transparent; }

/* Layout */
.app { display: flex; height: 100vh; padding: var(--gap); gap: var(--gap); }
.rail { width: 56px; display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 6px; }
.rail .ly-mark { font-size: 30px; margin: 4px 0 18px; }
.rail-btn { width: 42px; height: 42px; border-radius: 12px; border: 0; background: transparent; display: grid; place-items: center; color: var(--ly-muted); }
.rail-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.rail-btn:hover { background: var(--ly-surface); color: var(--ly-title); }
.rail-btn.active { background: var(--ly-surface); color: var(--ly-title); box-shadow: var(--ly-shadow); border: 1px solid var(--ly-border); }
.rail-spacer { flex: 1; }
.agent-pill { width: 38px; height: 38px; border-radius: 50%; background: var(--ly-accent-soft); color: var(--ly-accent); display: grid; place-items: center; font-weight: 600; font-size: 13px; cursor: pointer; position: relative; margin-top: 6px; }
.agent-pill::after { content: ''; position: absolute; right: 0; bottom: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--ly-ok-fg); border: 2px solid var(--ly-bg); }
.view { flex: 1; display: flex; min-width: 0; gap: var(--gap); }
.panel { background: var(--ly-surface); border: 1px solid var(--ly-border); border-radius: var(--ly-radius); box-shadow: var(--ly-shadow); overflow: hidden; }

/* Lista de tickets */
.list-col { width: 350px; display: flex; flex-direction: column; min-height: 0; }
.list-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 18px 12px; }
.list-head h2 { margin: 0; font-size: 22px; }
.tabs { display: flex; gap: 4px; padding: 0 12px 10px; border-bottom: 1px solid var(--ly-border); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 7px 11px; color: var(--ly-muted); font-weight: 500; font-size: 13px; border-radius: 999px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.tabs button:hover { color: var(--ly-title); }
.tabs button.active { color: var(--ly-title); background: var(--ly-bg); }
.count { font-family: var(--ly-mono); font-size: 11px; color: var(--ly-muted); }
.tabs button.active .count { color: var(--ly-accent); }
.filters { display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--ly-muted); fill: none; stroke-width: 2; }
.search-wrap input { padding-left: 38px; border-radius: 999px; }
.filters select { border-radius: 999px; }
.ticket-list { list-style: none; margin: 0; padding: 0 6px 6px; overflow-y: auto; flex: 1; }
.ticket { display: flex; gap: 12px; padding: 12px; border-radius: 12px; cursor: pointer; position: relative; margin-bottom: 2px; }
.ticket:hover { background: var(--ly-hover); box-shadow: var(--ly-shadow-hover); }
.ticket.active { background: var(--ly-bg); }
.ticket.active::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 3px; background: var(--ly-accent); }
.ticket-body { flex: 1; min-width: 0; }
.ticket-row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ticket-name { font-weight: 600; color: var(--ly-title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-time { font-family: var(--ly-mono); font-size: 11px; color: var(--ly-muted); flex-shrink: 0; }
.ticket-last { color: var(--ly-muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-meta { display: flex; gap: 6px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.unread { background: var(--ly-accent); color: var(--ly-on-accent); border-radius: 999px; min-width: 20px; height: 20px; font-size: 11px; display: grid; place-items: center; padding: 0 6px; font-weight: 600; font-family: var(--ly-mono); }
.wait-time { font-family: var(--ly-mono); font-size: 11px; color: var(--ly-muted); }
.wait-time.late { color: var(--ly-danger-fg); font-weight: 500; }
.list-empty { padding: 40px 16px; text-align: center; color: var(--ly-muted); }

/* Status: mapeia os estados do ticket para as pílulas Ly */
.badge { display: inline-flex; align-items: center; gap: 6px; font: 500 12px/1 var(--ly-font); padding: 5px 10px; border-radius: 999px; background: var(--ly-draft-bg); color: var(--ly-draft-fg); white-space: nowrap; }
.badge.waiting, .badge.open, .badge.closed { }
.badge.waiting::before, .badge.open::before, .badge.closed::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.waiting { background: var(--ly-warn-bg); color: var(--ly-warn-fg); }
.badge.open { background: var(--ly-new-bg); color: var(--ly-new-fg); }
.badge.closed { background: var(--ly-draft-bg); color: var(--ly-draft-fg); }
.badge.queue { background: transparent; border: 1px solid var(--ly-border); color: var(--ly-muted); padding: 4px 9px; }
.badge.tag { background: var(--ly-ok-bg); color: var(--ly-ok-fg); }

.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 14px; flex-shrink: 0; }
.avatar.lg { width: 68px; height: 68px; font-size: 22px; margin: 0 auto 12px; }

/* Chat */
.chat-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.empty-state { margin: auto; text-align: center; padding: 24px; }
.empty-state .ly-mark { font-size: 64px; display: block; margin-bottom: 18px; }
.empty-state h3 { font-size: 22px; margin: 0 0 6px; }
.chat { display: flex; flex-direction: column; height: 100%; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--ly-border); }
.chat-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ly-title); font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.chat-title .small { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub-mono { font-family: var(--ly-mono); }
.chat-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.messages { flex: 1; overflow-y: auto; padding: 24px 7%; display: flex; flex-direction: column; gap: 6px; background: var(--chat-bg); }
.msg { max-width: 66%; padding: 10px 14px 7px; border-radius: 16px; position: relative; word-wrap: break-word; line-height: 1.5; color: var(--ly-title); }
.msg-text { white-space: pre-wrap; }
.msg.in { align-self: flex-start; background: var(--bubble-in); border: 1px solid var(--ly-border); border-bottom-left-radius: 6px; }
.msg.out { align-self: flex-end; background: var(--bubble-out); border-bottom-right-radius: 6px; }
.msg.template { border: 1px dashed var(--ly-accent); }
.msg-meta { display: flex; gap: 6px; justify-content: flex-end; align-items: center; font-family: var(--ly-mono); font-size: 10.5px; color: var(--ly-muted); margin-top: 3px; }
.msg-agent { font-size: 12px; font-weight: 600; color: var(--ly-accent); margin-bottom: 2px; }
.tick { font-size: 12px; letter-spacing: -3px; }
.tick.read { color: var(--ly-accent); }
.tick.failed { color: var(--ly-danger-fg); letter-spacing: 0; }
.msg-error { font-size: 12px; color: var(--ly-danger-fg); margin-top: 3px; }
.sys { align-self: center; font-size: 12px; color: var(--ly-muted); padding: 4px 12px; margin: 6px 0; }
.day { align-self: center; font-size: 12px; font-weight: 500; color: var(--ly-muted); background: var(--ly-surface); border: 1px solid var(--ly-border); padding: 4px 12px; border-radius: 999px; margin: 12px 0 8px; }
.day::first-letter { text-transform: uppercase; }
.window-warn { margin: 0; padding: 12px 16px; background: var(--ly-warn-bg); color: var(--ly-warn-fg); font-size: 13px; display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.window-warn .btn { border-color: currentColor; color: inherit; }
.composer { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--ly-border); position: relative; align-items: flex-end; }
.composer textarea { resize: none; overflow-y: hidden; max-height: 160px; border-radius: 22px; padding: 11px 18px; background: var(--ly-bg); border-color: transparent; }
.composer textarea:focus { background: var(--ly-surface); }
.send { width: 44px; height: 44px; border-radius: 50%; padding: 0; flex-shrink: 0; }
.send svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.closed-bar { padding: 14px 16px; border-top: 1px solid var(--ly-border); text-align: center; color: var(--ly-muted); display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; }

/* Info do contato */
.info-col { width: 300px; padding: 24px 18px; overflow-y: auto; }
.info-head { position: relative; text-align: center; margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--ly-border); }
.info-head h3 { margin: 0 0 4px; font-size: 18px; }
.info-head .small { font-family: var(--ly-mono); font-size: 12px; }
.info-col h4 { margin: 24px 0 10px; font-size: 13px; color: var(--ly-muted); font-weight: 500; letter-spacing: 0; }
.history { list-style: none; padding: 0; margin: 0; }
.history li { padding: 10px 12px; border: 1px solid var(--ly-border); border-radius: 12px; margin-bottom: 8px; font-size: 12px; }
.history li .h-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.history li b { font-family: var(--ly-mono); font-size: 12px; color: var(--ly-title); font-weight: 500; }

/* Painel */
.dash { padding: 20px 28px; overflow-y: auto; width: 100%; }
.dash-head { margin-bottom: 24px; }
.dash h2 { font-size: 40px; margin: 0; line-height: 1.1; }
.dash-head p { margin: 4px 0 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--ly-surface); border: 1px solid var(--ly-border); border-radius: var(--ly-radius); padding: 22px 24px; box-shadow: var(--ly-shadow); }
.card .k { font-size: 14px; color: var(--ly-muted); }
.card .v { font-size: 36px; font-weight: 600; color: var(--ly-title); margin-top: 6px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.card .d { font-size: 13px; color: var(--ly-muted); margin-top: 6px; }
.card .d.pos { color: var(--ly-positive); }
.table-card { padding: 0; overflow: hidden; }
.table-card h3 { margin: 0; padding: 20px 24px 8px; font-size: 18px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 14px 24px; border-bottom: 1px solid var(--ly-border); }
.table tr:last-child td { border-bottom: 0; }
.table th { font-size: 13px; color: var(--ly-muted); font-weight: 400; }
.table td { color: var(--ly-title); font-weight: 500; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Demo */
.sim-btn { color: var(--ly-accent); background: var(--ly-accent-soft); }
.sim-btn:hover { background: var(--ly-accent-soft); color: var(--ly-accent); filter: brightness(.97); }
.demo-badge { position: fixed; bottom: 18px; left: 76px; z-index: 20; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(80px); background: var(--ly-title); color: var(--ly-bg); padding: 11px 20px; border-radius: 999px; font-weight: 500; transition: .25s; z-index: 60; max-width: 90vw; opacity: 0; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: var(--ly-danger-fg); color: #fff; }

/* Responsivo */
.back-btn { display: none !important; }
@media (max-width: 1100px) {
  .info-col { position: fixed; right: var(--gap); top: var(--gap); bottom: var(--gap); z-index: 15; box-shadow: var(--ly-shadow-lg); }
}
@media (max-width: 760px) {
  :root { --gap: 0px; }
  .app { flex-direction: column-reverse; }
  .rail { width: 100%; flex-direction: row; justify-content: space-around; padding: 6px 12px; border-top: 1px solid var(--ly-border); background: var(--ly-surface); }
  .rail .ly-mark, .rail-spacer { display: none; }
  .agent-pill { margin: 0; }
  .view { min-height: 0; }
  .panel { border-radius: 0; border: 0; box-shadow: none; }
  .list-col { width: 100%; }
  .view.chat-open .list-col { display: none; }
  .view:not(.chat-open) .chat-col { display: none; }
  .back-btn { display: inline-flex !important; }
  .messages { padding: 14px 12px; }
  .msg { max-width: 86%; }
  .chat-head { padding: 10px 12px; gap: 8px; }
  .chat-actions .btn.sm:not(.icon) { padding: 7px 10px; font-size: 12px; }
  .dash { padding: 20px 16px; }
  .dash h2 { font-size: 30px; }
    .demo-badge { top: 10px; bottom: auto; left: auto; right: 12px; }
  .info-col { inset: 0; width: auto; border-radius: 0; }
  .demo-badge { display: none !important; }
}

/* Ícone do botão de tema: sol no escuro, lua no claro */
#themeBtn .i-sun { display: none; }
:root[data-theme="dark"] #themeBtn .i-sun { display: block; }
:root[data-theme="dark"] #themeBtn .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #themeBtn .i-sun { display: block; }
  :root:not([data-theme="light"]) #themeBtn .i-moon { display: none; }
}

.info-close { position: absolute; top: -10px; right: -6px; display: none; }
@media (max-width: 1100px) { .info-close { display: inline-flex; } }

/* Assinatura */
.dash-sign { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--ly-border); }
.rail .ly-mark { font-size: 28px; }

/* ---------- Login / cadastro ---------- */
.auth { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 100dvh; background: var(--ly-bg); }
.auth-main { display: flex; flex-direction: column; padding: 28px clamp(16px, 5vw, 64px); gap: 24px; }
.auth-top { display: flex; align-items: center; justify-content: space-between; }
.auth-top .ly-mark { font-size: 34px; }
.auth-box { width: 100%; max-width: 400px; margin: auto; padding: 12px 0; }
.auth-box h1, .setup-card h1 { font-size: 40px; margin: 18px 0 8px; }
.auth-box > p { margin: 0 0 24px; font-size: 15px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; background: var(--ly-surface); border: 1px solid var(--ly-border); border-radius: 999px; margin-bottom: 22px; }
.segmented button { border: 0; background: transparent; padding: 9px 12px; border-radius: 999px; font-weight: 500; color: var(--ly-muted); transition: background .15s, color .15s; }
.segmented button.active { background: var(--ly-title); color: var(--ly-bg); }
.form-error { display: flex; gap: 8px; align-items: flex-start; padding: 10px 14px; border-radius: 12px; background: var(--ly-danger-bg); color: var(--ly-danger-fg); font-size: 13px; margin-bottom: 16px; }
.form-error svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.pw-wrap { position: relative; display: block; margin-top: 6px; }
.pw-wrap input { margin: 0; padding-right: 80px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--ly-muted); font-size: 12px; font-weight: 500; padding: 6px 10px; border-radius: 999px; }
.pw-toggle:hover { color: var(--ly-title); background: var(--ly-hover); }
#loginForm .btn, #registerForm .btn { margin-top: 6px; }
.auth-switch { text-align: center; font-size: 13px; margin: 18px 0 0; }
a { color: var(--ly-accent); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
.ly-signature:hover { text-decoration: none; }
input.invalid { border-color: var(--ly-danger-fg); }

/* Bloco de contraste */
.auth-side { padding: 10px; display: flex; }
.auth-side-inner { flex: 1; border-radius: 24px; background: var(--ly-contrast); color: var(--ly-on-contrast); padding: clamp(28px, 5vw, 64px); display: flex; flex-direction: column; justify-content: flex-end; gap: 14px; }
.auth-side h2 { color: var(--ly-on-contrast); font-size: clamp(30px, 3.4vw, 46px); margin: 0; max-width: 14ch; }
.auth-side p { margin: 0 0 18px; opacity: .72; max-width: 40ch; font-size: 15px; line-height: 1.6; }
.mock { display: flex; flex-direction: column; gap: 8px; max-width: 440px; }
.mock-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--ly-on-contrast) 7%, transparent); border: 1px solid color-mix(in srgb, var(--ly-on-contrast) 10%, transparent); }
.mock-av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.mock-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.mock-txt b { font-weight: 600; font-size: 14px; }
.mock-txt i { font-style: normal; font-size: 13px; opacity: .65; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Primeiro acesso ---------- */
.setup { min-height: 100dvh; display: flex; flex-direction: column; gap: 24px; padding: 28px clamp(16px, 5vw, 64px); background: var(--ly-bg); }
.setup-card { width: 100%; max-width: 480px; margin: auto; background: var(--ly-surface); border: 1px solid var(--ly-border); border-radius: 20px; padding: clamp(22px, 4vw, 36px); }
.setup-card h1 { font-size: 32px; margin-top: 4px; }
.setup-card .lead { margin: 0 0 24px; font-size: 15px; }
#setupHello { margin: 0; font-size: 14px; }
.stepper { list-style: none; display: flex; align-items: center; gap: 10px; padding: 0; margin: 0 0 26px; font-size: 13px; font-weight: 500; color: var(--ly-muted); }
.stepper li { display: flex; align-items: center; gap: 8px; }
.stepper li + li::before { content: ''; width: 32px; height: 1px; background: var(--ly-border); margin-right: 2px; }
.stepper span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font: 500 12px/1 var(--ly-mono); border: 1px solid var(--ly-border); }
.stepper .done span { background: var(--ly-ok-bg); color: var(--ly-ok-fg); border-color: transparent; }
.stepper .done svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.stepper .current { color: var(--ly-title); }
.stepper .current span { background: var(--ly-accent); color: var(--ly-on-accent); border-color: transparent; }
.phone-field { display: flex; gap: 8px; margin-top: 6px; }
.phone-field select { width: 112px; flex-shrink: 0; margin: 0; }
.phone-field input { margin: 0; font-family: var(--ly-mono); letter-spacing: .02em; }
.mono-input { font-family: var(--ly-mono) !important; font-size: 13px !important; }
.api-details { border: 1px solid var(--ly-border); border-radius: 12px; padding: 0 14px; margin: 4px 0 20px; }
.api-details summary { cursor: pointer; padding: 12px 0; font-weight: 500; color: var(--ly-title); font-size: 13px; list-style: none; display: flex; gap: 6px; align-items: center; }
.api-details summary::-webkit-details-marker { display: none; }
.api-details summary::before { content: '+'; font: 500 16px/1 var(--ly-mono); color: var(--ly-accent); width: 14px; }
.api-details[open] summary::before { content: '–'; }
.api-details > p { margin: 0 0 14px; }
.center { text-align: center; }
.setup-card .btn.primary { margin-bottom: 12px; }
.list-sub { margin: 2px 0 0; font: 400 12px/1.3 var(--ly-mono); color: var(--ly-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.list-head > div { min-width: 0; }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-box h1, .setup-card h1 { font-size: 30px; }
}

/* ==================== Modos: celular x central ==================== */
body.mode-qr .api-only, body.mode-api .qr-only { display: none !important; }

/* ---------- Primeiro acesso: escolha de modo e QR ---------- */
.setup-card.wide { max-width: 760px; }
.setup-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--ly-border); flex-wrap: wrap; }
.setup-foot .btn { color: var(--ly-muted); }
.setup-foot .btn:hover { color: var(--ly-title); }
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mode-card { text-align: left; background: var(--ly-surface); border: 1px solid var(--ly-border); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; gap: 10px; color: var(--ly-text); transition: border-color .15s, box-shadow .15s, transform .1s; }
.mode-card:hover { border-color: var(--ly-accent); box-shadow: var(--ly-shadow-hover); }
.mode-card:active { transform: translateY(1px); }
.mode-card b { color: var(--ly-title); font-size: 18px; letter-spacing: -.02em; }
.mode-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--ly-accent-soft); color: var(--ly-accent); display: grid; place-items: center; }
.mode-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mode-desc { font-size: 14px; line-height: 1.55; }
.mode-card ul { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.mode-card li { display: flex; gap: 8px; align-items: baseline; }
.mode-card li::before { content: '✓'; color: var(--ly-ok-fg); font-weight: 600; }
.mode-card li.warn { color: var(--ly-warn-fg); }
.mode-card li.warn::before { content: '!'; color: var(--ly-warn-fg); }
.mode-card li.muted-li { color: var(--ly-muted); }
.mode-card li.muted-li::before { content: '·'; color: var(--ly-muted); }
.mode-cta { margin-top: auto; padding-top: 8px; font-weight: 600; color: var(--ly-accent); font-size: 14px; }
.mode-cta::after { content: ' →'; }

.qr-layout { display: grid; grid-template-columns: 1fr 300px; gap: 28px; align-items: start; margin-top: 8px; }
.qr-form { margin-bottom: 18px; }
.qr-steps { margin: 0 0 18px; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--ly-text); }
.qr-steps li::marker { font-family: var(--ly-mono); color: var(--ly-accent); }
.qr-steps b { color: var(--ly-title); font-weight: 600; }
.qr-side { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.qr-box { width: 280px; height: 280px; border-radius: 16px; border: 1px dashed var(--ly-border); background: var(--ly-bg); display: grid; place-items: center; overflow: hidden; }
.qr-box svg { width: 72px; height: 72px; fill: none; stroke: var(--ly-border); stroke-width: 1.4; }
.qr-box.ready { border-style: solid; background: #fff; padding: 10px; }
.qr-box img { width: 100%; height: 100%; image-rendering: pixelated; }
.qr-status { margin: 0; font-size: 13px; text-align: center; color: var(--ly-muted); min-height: 20px; }
.qr-status.qr { color: var(--ly-title); }
.qr-status.connected { color: var(--ly-ok-fg); font-weight: 600; }
.qr-status.error, .qr-status.logged_out { color: var(--ly-danger-fg); }
.qr-modal { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.qr-modal .qr-box { width: 260px; height: 260px; background: #fff; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--ly-border); border-top-color: var(--ly-accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.note { padding: 12px 14px; border-radius: 12px; background: var(--ly-bg); border: 1px solid var(--ly-border); font-size: 13px; line-height: 1.55; color: var(--ly-text); }
.note.warn-note { background: var(--ly-warn-bg); border-color: transparent; color: var(--ly-warn-fg); }
.note b { color: inherit; }

/* ---------- Lista: aviso de conexão e filtros do modo celular ---------- */
.conn-banner { margin: 0 12px 10px; padding: 10px 12px; border-radius: 12px; background: var(--ly-danger-bg); color: var(--ly-danger-fg); font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.conn-banner .btn { border-color: currentColor; color: inherit; flex-shrink: 0; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chip { border: 1px solid var(--ly-border); background: var(--ly-surface); color: var(--ly-text); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.chip:hover { border-color: var(--ly-title); }
.chip.active { background: var(--ly-title); color: var(--ly-bg); border-color: var(--ly-title); }
body.mode-qr .tabs { display: none; }

/* densidade compacta */
.density-compact .ticket, .preview-list.compact .ticket { padding: 8px 12px; gap: 10px; }
.density-compact .ticket .avatar, .preview-list.compact .avatar { width: 32px; height: 32px; font-size: 12px; }
.density-compact .ticket-meta, .preview-list.compact .ticket-meta { margin-top: 4px; }

/* ---------- Compositor: templates e IA ---------- */
.composer-tools { display: flex; gap: 2px; padding-bottom: 4px; }
.tool-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--ly-muted); display: grid; place-items: center; transition: background .15s, color .15s; }
.tool-btn:hover { background: var(--ly-hover); color: var(--ly-title); }
.tool-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool-btn.ai { color: var(--ly-accent); }
.tool-btn.ai:hover { background: var(--ly-accent-soft); color: var(--ly-accent); }
.ai-icon { color: var(--ly-accent) !important; }
.composer.ai-busy textarea { background: var(--ly-accent-soft); }
.composer.ai-busy textarea::placeholder { color: var(--ly-accent); }
.pop { position: absolute; bottom: 100%; left: 14px; right: 14px; max-width: 520px; background: var(--ly-surface); border: 1px solid var(--ly-border); border-radius: 14px; box-shadow: var(--ly-shadow-lg); max-height: 320px; overflow-y: auto; margin-bottom: 8px; padding: 6px; z-index: 5; }
.pop-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px 8px; font-size: 12px; font-weight: 600; color: var(--ly-muted); }
.pop-item { padding: 9px 12px; cursor: pointer; border-radius: 10px; display: flex; flex-direction: column; gap: 2px; }
.pop-item.sel, .pop-item:hover { background: var(--ly-accent-soft); }
.pop-row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.pop-row b { color: var(--ly-title); font-weight: 600; font-size: 14px; }
.pop[data-kind="tpl"] .pop-row b { font-family: var(--ly-mono); font-weight: 500; color: var(--ly-accent); font-size: 13px; }
.pop-cat { font-size: 11px; color: var(--ly-muted); }
.pop-text { font-size: 13px; color: var(--ly-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pop-empty, .pop-hint { padding: 10px 12px; font-size: 13px; color: var(--ly-muted); }
.link-btn { border: 0; background: none; color: var(--ly-accent); font-size: 12px; font-weight: 600; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.msg.bot { background: var(--ly-surface); border: 1px dashed var(--ly-border); }
.msg.bot .msg-agent { color: var(--ly-muted); }
.ai-out { min-height: 80px; }
.ai-text { white-space: pre-wrap; line-height: 1.6; color: var(--ly-title); }
.ai-loading { display: flex; align-items: center; gap: 4px; color: var(--ly-muted); font-size: 14px; }
.ai-loading span { width: 6px; height: 6px; border-radius: 50%; background: var(--ly-accent); animation: blink 1.2s infinite; }
.ai-loading span:nth-child(2) { animation-delay: .2s; }
.ai-loading span:nth-child(3) { animation-delay: .4s; margin-right: 8px; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* ---------- Configurações ---------- */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--gap); width: 100%; min-height: 0; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; padding: 16px 8px; }
.settings-nav button { border: 0; background: transparent; text-align: left; padding: 10px 14px; border-radius: 999px; color: var(--ly-muted); font-weight: 500; }
.settings-nav button:hover { color: var(--ly-title); background: var(--ly-surface); }
.settings-nav button.active { background: var(--ly-surface); color: var(--ly-title); border: 1px solid var(--ly-border); }
.settings-body { overflow-y: auto; padding: 20px 28px 40px; max-width: 860px; }
.set-head { margin-bottom: 18px; }
.set-head.row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.set-head h2 { font-size: 32px; margin: 0 0 4px; }
.set-head p { margin: 0; }
.set-card { padding: 22px 24px; margin-bottom: 14px; }
.set-card h3 { font-size: 16px; margin: 0 0 12px; }
.set-card h3.mt { margin-top: 22px; }
.set-card textarea { margin: 0 0 14px; }
.save-bar { display: flex; justify-content: flex-end; margin-top: 6px; }
code { font-family: var(--ly-mono); font-size: 12px; background: var(--ly-bg); border: 1px solid var(--ly-border); padding: 1px 6px; border-radius: 6px; color: var(--ly-title); }

.conn-row { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.conn-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--ly-accent-soft); color: var(--ly-accent); display: grid; place-items: center; flex-shrink: 0; }
.conn-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.conn-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.conn-info b { color: var(--ly-title); }
.conn-info .ly-mono { font-size: 12px; }
.conn-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.choice { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1px solid var(--ly-border); border-radius: 14px; cursor: pointer; margin: 0; color: var(--ly-text); transition: border-color .15s, background .15s; }
.choice:hover { border-color: var(--ly-title); }
.choice.active { border-color: var(--ly-accent); background: var(--ly-accent-soft); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice b { color: var(--ly-title); font-size: 14px; }
.choice small { font-size: 12px; line-height: 1.5; font-weight: 400; color: var(--ly-muted); }
.choice-icon { width: 34px; height: 34px; border-radius: 10px; background: var(--ly-surface); border: 1px solid var(--ly-border); display: grid; place-items: center; color: var(--ly-accent); }
.choice-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.inline-num { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 0; }
.inline-num input { width: 90px; margin: 0; font-family: var(--ly-mono); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--ly-border); margin: 0; cursor: pointer; }
.switch-row:first-of-type { border-top: 0; }
.switch-row > span { display: flex; flex-direction: column; gap: 2px; }
.switch-row b { color: var(--ly-title); font-weight: 500; font-size: 14px; }
.switch-row small { font-size: 12px; color: var(--ly-muted); font-weight: 400; line-height: 1.5; }
.switch { appearance: none; -webkit-appearance: none; width: 42px !important; height: 24px; border-radius: 999px; background: var(--ly-border); position: relative; cursor: pointer; flex-shrink: 0; padding: 0 !important; border: 0 !important; margin: 0 !important; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch:checked { background: var(--ly-accent); }
.switch:checked::after { transform: translateX(18px); }
.switch:disabled { opacity: .5; cursor: not-allowed; }

.queue-editor { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.queue-chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 6px 6px 12px; border-radius: 999px; background: var(--ly-bg); border: 1px solid var(--ly-border); font-size: 13px; font-weight: 500; color: var(--ly-title); }
.queue-chip button { border: 0; background: none; color: var(--ly-muted); width: 22px; height: 22px; border-radius: 50%; font-size: 15px; line-height: 1; }
.queue-chip button:hover { background: var(--ly-danger-bg); color: var(--ly-danger-fg); }
#queueAdd { width: 150px; border-radius: 999px; padding: 6px 12px; font-size: 13px; }

.display-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.preview-wrap { position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px; }
.preview-list { background: var(--ly-surface); border: 1px solid var(--ly-border); border-radius: 16px; padding: 6px !important; pointer-events: none; }

.var-help { font-size: 13px; color: var(--ly-muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 14px; }
.tpl-cat { font-size: 13px; color: var(--ly-muted); font-weight: 500; margin: 18px 0 8px; letter-spacing: 0; }
.tpl-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.tpl-card { padding: 14px 16px; }
.tpl-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.tpl-top b { color: var(--ly-accent); font-weight: 500; font-size: 13px; }
.tpl-top .btn { padding: 5px 10px; font-size: 12px; }
.tpl-card p { margin: 0; font-size: 14px; color: var(--ly-text); white-space: pre-wrap; line-height: 1.5; }
.danger-text { color: var(--ly-danger-fg) !important; }

@media (max-width: 900px) {
  .mode-cards, .qr-layout, .choices, .display-grid { grid-template-columns: 1fr; }
  .qr-side { order: -1; }
  .settings { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; padding: 8px; scrollbar-width: none; }
  .settings-nav button { white-space: nowrap; }
  .settings-body { padding: 8px 16px 32px; }
  .set-head h2 { font-size: 26px; }
  .preview-wrap { position: static; }
}
@media (max-width: 760px) {
  .qr-box { width: 240px; height: 240px; }
  .composer-tools { padding-bottom: 6px; }
  .tool-btn { width: 34px; height: 34px; }
}
@media (max-width: 480px) {
  .stepper { gap: 6px; font-size: 12px; }
  .stepper li + li::before { width: 14px; }
}

/* Importação do histórico do celular */
.sync-banner { margin: 0 12px 10px; padding: 10px 12px; border-radius: 12px; background: var(--ly-accent-soft); color: var(--ly-accent); font-size: 13px; display: flex; flex-direction: column; gap: 8px; }
.sync-banner.done { background: var(--ly-ok-bg); color: var(--ly-ok-fg); }
.sync-row { display: flex; justify-content: space-between; gap: 8px; }
.sync-bar { height: 4px; border-radius: 999px; background: color-mix(in srgb, currentColor 18%, transparent); overflow: hidden; }
.sync-bar span { display: block; height: 100%; width: 6%; background: currentColor; border-radius: inherit; transition: width .4s ease; }

/* ==================== Mídia no chat ==================== */
.msg.has-media { padding: 4px 4px 6px; }
.msg.has-media .msg-agent { padding: 4px 8px 2px; }
.msg.has-media .msg-text { padding: 6px 8px 0; }
.msg.has-media .msg-meta { padding: 0 8px; }
.media-img { display: block; border: 0; padding: 0; background: var(--ly-bg); border-radius: 12px; overflow: hidden; cursor: zoom-in; max-width: 300px; min-width: 120px; min-height: 80px; }
.media-img img { display: block; width: 100%; max-height: 360px; object-fit: cover; }
.media-video { display: block; width: 300px; max-width: 100%; max-height: 360px; border-radius: 12px; background: #000; }

/* figurinha: sem balão, só a imagem */
.msg.media-sticker { background: transparent !important; border: 0 !important; box-shadow: none; padding: 0; }
.media-sticker { display: block; width: 150px; height: 150px; object-fit: contain; }
.msg.media-sticker .msg-meta { justify-content: flex-start; padding: 2px 4px; }
.msg.out.media-sticker .msg-meta { justify-content: flex-end; }
.msg.media-sticker .msg-agent { display: none; }

.media-missing { padding: 18px 16px; border-radius: 12px; background: var(--ly-bg); color: var(--ly-muted); font-size: 13px; text-align: center; min-width: 160px; }

/* documento */
.media-doc { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--ly-bg); color: var(--ly-title); text-decoration: none !important; min-width: 220px; max-width: 300px; }
.msg.out .media-doc { background: color-mix(in srgb, var(--ly-surface) 55%, transparent); }
.doc-ext { width: 38px; height: 46px; border-radius: 8px; background: var(--ly-accent); color: var(--ly-on-accent); display: grid; place-items: center; font: 600 10px/1 var(--ly-mono); text-transform: uppercase; flex-shrink: 0; }
.doc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-info b { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-info small { color: var(--ly-muted); font-size: 12px; }
.doc-dl svg, .audio-mic svg { width: 18px; height: 18px; fill: none; stroke: var(--ly-muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* áudio */
.audio { display: flex; align-items: center; gap: 10px; padding: 6px 8px 2px; width: 280px; max-width: 100%; --progress: 0%; }
.audio-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--ly-accent); color: var(--ly-on-accent); display: grid; place-items: center; flex-shrink: 0; }
.audio-btn svg { width: 16px; height: 16px; fill: currentColor; }
.audio-track { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.audio-seek { -webkit-appearance: none; appearance: none; width: 100%; height: 4px; padding: 0; border: 0; border-radius: 999px; margin: 8px 0 0;
  background: linear-gradient(to right, var(--ly-accent) var(--progress), var(--ly-border) var(--progress)); cursor: pointer; }
.audio-seek:focus { box-shadow: none; outline: none; }
.audio-seek::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--ly-accent); border: 0; }
.audio-seek::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--ly-accent); border: 0; }
.audio-meta { display: flex; justify-content: space-between; align-items: center; font: 400 11px/1 var(--ly-mono); color: var(--ly-muted); }
.audio-speed { border: 0; background: var(--ly-bg); color: var(--ly-title); font: 600 11px/1 var(--ly-mono); padding: 3px 7px; border-radius: 999px; }
.audio.voice .audio-mic { display: grid; place-items: center; width: 22px; }
.audio.playing .audio-mic svg { stroke: var(--ly-accent); }
.audio.failed { opacity: .5; }

/* foto em tela cheia */
.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(10, 8, 7, .88); display: grid; place-items: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; box-shadow: var(--ly-shadow-lg); }
.lightbox-dl { position: absolute; top: 16px; right: 16px; background: var(--ly-surface) !important; color: var(--ly-title) !important; border-color: transparent !important; text-decoration: none !important; }

/* simulador */
.check-row { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--ly-text); margin-bottom: 8px; cursor: pointer; }
.check-row input { width: auto; margin: 0; accent-color: var(--ly-accent); }

@media (max-width: 760px) {
  .media-img, .media-video { max-width: 100%; }
  .audio { width: 240px; }
}

/* ==================== Envio de mídia ==================== */
.send.mic { background: var(--ly-accent); }
.composer.recording > :not(.rec-bar):not(.pop) { visibility: hidden; }
.rec-bar { position: absolute; inset: 0; display: flex; align-items: center; gap: 12px; padding: 0 14px; background: var(--ly-surface); }
.rec-cancel { color: var(--ly-danger-fg); }
.rec-cancel:hover { background: var(--ly-danger-bg); color: var(--ly-danger-fg); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ly-danger-fg); animation: blink 1.2s infinite; }
.rec-time { font-size: 14px; color: var(--ly-title); min-width: 40px; }
.rec-wave { flex: 1; height: 24px; border-radius: 999px;
  background: repeating-linear-gradient(90deg, var(--ly-accent) 0 3px, transparent 3px 7px);
  -webkit-mask: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent); mask: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
  opacity: .5; animation: wave 1.1s linear infinite; }
@keyframes wave { to { background-position: 28px 0; } }
.drop-hint { position: absolute; inset: -1px; display: grid; place-items: center; background: var(--ly-accent-soft); color: var(--ly-accent); font-weight: 600; border: 2px dashed var(--ly-accent); border-radius: 0 0 var(--ly-radius) var(--ly-radius); z-index: 6; pointer-events: none; }

/* prévia antes de enviar */
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; max-height: 50vh; overflow-y: auto; }
.att-grid.single { grid-template-columns: 1fr; }
.att-grid figure { margin: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.att-grid img, .att-grid video { width: 100%; max-height: 320px; object-fit: contain; border-radius: 12px; background: var(--ly-bg); border: 1px solid var(--ly-border); }
.att-grid:not(.single) img, .att-grid:not(.single) video { height: 120px; object-fit: cover; }
.att-grid figcaption { font-size: 12px; color: var(--ly-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-file { display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: 12px; background: var(--ly-bg); border: 1px solid var(--ly-border); min-width: 0; }
.att-file b { width: 38px; height: 46px; border-radius: 8px; background: var(--ly-accent); color: var(--ly-on-accent); display: grid; place-items: center; font: 600 10px/1 var(--ly-mono); text-transform: uppercase; flex-shrink: 0; }
.att-file span { font-size: 14px; color: var(--ly-title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ==================== Conta ==================== */
.account-menu { position: fixed; left: 72px; bottom: 14px; z-index: 40; width: 260px; background: var(--ly-surface); border: 1px solid var(--ly-border); border-radius: 16px; box-shadow: var(--ly-shadow-lg); padding: 8px; display: flex; flex-direction: column; }
.am-head { display: flex; gap: 10px; align-items: center; padding: 8px 8px 6px; }
.am-id { display: flex; flex-direction: column; min-width: 0; }
.am-id b { color: var(--ly-title); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.am-id span { font-size: 12px; color: var(--ly-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.am-role { align-self: flex-start; margin: 0 8px 8px 58px; }
.account-menu button { display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 9px 10px; border-radius: 10px; color: var(--ly-title); font-size: 14px; }
.account-menu button:hover { background: var(--ly-hover); }
.account-menu svg { width: 18px; height: 18px; fill: none; stroke: var(--ly-muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.account-menu hr { border: 0; border-top: 1px solid var(--ly-border); margin: 6px 4px; }
.account-menu .am-logout, .account-menu .am-logout svg { color: var(--ly-danger-fg); stroke: var(--ly-danger-fg); }
.agent-pill { border: 0; }
.agent-pill:hover { box-shadow: 0 0 0 3px var(--ly-accent-soft); }

.profile-row { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.profile-row .avatar.lg { margin: 0; }
.profile-row > div:last-child { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.profile-row b { color: var(--ly-title); font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.danger-zone { border-color: color-mix(in srgb, var(--ly-danger-fg) 35%, var(--ly-border)); }
.danger-zone h3 { color: var(--ly-danger-fg); }
.btn.danger-solid { background: var(--ly-danger-fg); border-color: var(--ly-danger-fg); color: #fff; }
.btn.danger-solid:hover { background: var(--ly-danger-fg); filter: brightness(1.1); }

.copy-row { display: flex; gap: 8px; }
.copy-row input { font-family: var(--ly-mono); font-size: 13px; }
.team-card { padding: 8px; }
.team-list { list-style: none; margin: 0; padding: 0; }
.team-list li { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; }
.team-list li + li { border-top: 1px solid var(--ly-border); }
.team-list .avatar { position: relative; }
.online-dot { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--ly-ok-fg); border: 2px solid var(--ly-surface); }
.team-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.team-info b { color: var(--ly-title); font-weight: 500; }
.team-info .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team-list select { width: 150px; flex-shrink: 0; }
.team-spacer { width: 84px; flex-shrink: 0; }

@media (max-width: 760px) {
  .account-menu { left: auto; right: 8px; bottom: 64px; }
  .team-list li { flex-wrap: wrap; }
  .team-list select { width: auto; flex: 1; }
  .team-spacer { display: none; }
}

/* Nome do atendente nas mensagens: prévia estilo WhatsApp */
.sign-opts { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.sign-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sign-grid label { margin-bottom: 4px; }
.wa-preview { background: #efeae2; border-radius: 14px; padding: 18px 16px; display: flex; justify-content: flex-start; }
.wa-bubble { position: relative; max-width: 320px; background: #fff; color: #111b21; border-radius: 0 10px 10px 10px; padding: 8px 10px 18px; font: 400 14px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); }
.wa-bubble b { font-weight: 700; }
.wa-time { position: absolute; right: 8px; bottom: 4px; font-size: 11px; color: #667781; }
:root[data-theme="dark"] .wa-preview { background: #0b141a; }
:root[data-theme="dark"] .wa-bubble { background: #202c33; color: #e9edef; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wa-preview { background: #0b141a; }
  :root:not([data-theme="light"]) .wa-bubble { background: #202c33; color: #e9edef; }
}
@media (max-width: 760px) { .sign-grid { grid-template-columns: 1fr; } }

/* ==================== Análise da IA (painel lateral) ==================== */
.insights { border: 1px solid var(--ly-border); border-radius: 14px; padding: 14px; margin-bottom: 18px; display: flex; flex-direction: column; gap: 12px; background: var(--ly-surface); }
.ins-head { display: flex; justify-content: space-between; align-items: center; }
.ins-title { font-weight: 600; color: var(--ly-accent); font-size: 14px; }
.ins-meta { font-size: 12px; color: var(--ly-muted); margin-top: -8px; }
.ins-meta b { color: var(--ly-warn-fg); font-weight: 500; }
.ins-empty { margin: 0; }
.insights .k { display: block; font-size: 11px; color: var(--ly-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.ins-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ins-metric { background: var(--ly-bg); border-radius: 10px; padding: 10px; min-width: 0; cursor: help; }
.ins-metric .v { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ins-metric i { font-style: normal; font-size: 18px; line-height: 1; }
.ins-intent .row { display: flex; justify-content: space-between; align-items: baseline; }
.ins-intent b { font: 600 13px/1 var(--ly-mono); color: var(--ly-title); }
.ins-intent .bar { height: 6px; border-radius: 999px; background: var(--ly-bg); overflow: hidden; margin: 4px 0 6px; }
.ins-intent .bar span { display: block; height: 100%; border-radius: inherit; background: var(--ly-muted); transition: width .5s ease; }
.ins-intent.lvl-alta .bar span { background: var(--ly-ok-fg); }
.ins-intent.lvl-media .bar span { background: var(--ly-warn-fg); }
.ins-intent small { font-size: 12px; color: var(--ly-text); line-height: 1.45; display: block; }
.ins-topic { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ins-topic b { color: var(--ly-title); font-size: 14px; font-weight: 600; }
.ins-summary { margin: 0; font-size: 13px; line-height: 1.6; color: var(--ly-text); }
.ins-products { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.ins-products li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--ly-bg); }
.ins-products li > div:first-child { min-width: 0; display: flex; flex-direction: column; }
.ins-products b { font-size: 13px; color: var(--ly-title); font-weight: 500; }
.ins-products small { font-size: 12px; color: var(--ly-muted); }
.ip-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.ip-price { font: 500 12px/1 var(--ly-mono); color: var(--ly-title); }
.ins-next { background: var(--ly-accent-soft); color: var(--ly-title); border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.5; }
.ins-next .k { color: var(--ly-accent); }
.ins-alerts { display: flex; flex-direction: column; gap: 6px; }
.ins-alert { font-size: 12px; color: var(--ly-danger-fg); background: var(--ly-danger-bg); border-radius: 8px; padding: 6px 10px; line-height: 1.45; }
.ins-foot { font-size: 11px; margin: 0; }
.ins-loading { display: flex; flex-direction: column; gap: 8px; }
.sk { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--ly-bg), var(--ly-hover), var(--ly-bg)); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
.sk.short { width: 60%; }
@keyframes sk { to { background-position: -200% 0; } }
.info-col h4.contact-h { margin-top: 4px; }
.badge.hot { background: var(--ly-ok-bg); color: var(--ly-ok-fg); }
.badge.sad { background: var(--ly-danger-bg); color: var(--ly-danger-fg); }
.info-col { width: 320px; }

/* Convite para a equipe */
.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.5; color: var(--ly-text); margin: 4px 0 8px; font-weight: 400; }
.check-row input { width: 16px; height: 16px; margin: 2px 0 0; flex-shrink: 0; padding: 0; }
.verify-banner { margin: 0 12px 10px; padding: 10px 8px 10px 12px; border-radius: 12px; background: var(--ly-warn-bg); color: var(--ly-warn-fg);
  font-size: 13px; line-height: 1.45; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.verify-banner b { display: block; overflow-wrap: anywhere; }
.verify-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.verify-banner .link-btn { color: inherit; text-decoration: underline; }
.verify-close { border: 0; background: transparent; color: inherit; font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 999px; }
.verify-close:hover { background: rgba(0, 0, 0, .08); }
.invite-banner { padding: 12px 14px; border-radius: 12px; background: var(--ly-accent-soft); color: var(--ly-title); font-size: 14px; line-height: 1.5; margin-bottom: 16px; }
.invite-banner b { color: var(--ly-accent); }
.invite-reset { margin-top: 10px; font-weight: 500; }

/* ==================== Resumo sem IA ==================== */
.csum { border: 1px solid var(--ly-border); border-radius: 14px; padding: 14px; margin-bottom: 18px; display: flex; flex-direction: column; gap: 12px; background: var(--ly-surface); }
.csum .k { display: block; font-size: 11px; color: var(--ly-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.sum-title { font-weight: 600; color: var(--ly-title); font-size: 14px; }
.sum-toggle { display: inline-flex; padding: 2px; border-radius: 999px; background: var(--ly-bg); }
.sum-toggle button { border: 0; background: none; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; color: var(--ly-muted); }
.sum-toggle button.active { background: var(--ly-surface); color: var(--ly-title); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.sum-empty { margin: 0; }
.sum-flags { display: flex; flex-wrap: wrap; gap: 6px; }
.sum-text { margin: 0; font-size: 13px; line-height: 1.6; color: var(--ly-text); }
.sum-stats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--ly-muted); }
.sum-stats b { color: var(--ly-title); font-family: var(--ly-mono); font-weight: 500; }
.sum-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sum-chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--ly-bg); color: var(--ly-title); border: 1px solid var(--ly-border); }
.sum-chip.ref { font-family: var(--ly-mono); background: var(--ly-accent-soft); border-color: transparent; color: var(--ly-accent); }
.sum-chip.money { font-family: var(--ly-mono); background: var(--ly-ok-bg); border-color: transparent; color: var(--ly-ok-fg); }
.sum-chips.big .sum-chip { font-size: 13px; padding: 6px 12px; }
.sum-chip b { font-family: var(--ly-mono); font-weight: 500; color: var(--ly-muted); margin-left: 4px; }
.sum-list { margin: 0; padding-left: 18px; font-size: 13px; color: var(--ly-title); display: flex; flex-direction: column; gap: 4px; }
.sum-quotes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sum-quotes li { font-size: 13px; line-height: 1.5; color: var(--ly-text); padding: 8px 10px; border-left: 3px solid var(--ly-accent); background: var(--ly-bg); border-radius: 0 10px 10px 0; }
.sum-quotes .ly-mono { font-size: 11px; color: var(--ly-muted); margin-right: 8px; }

/* tela Resumo */
.sum-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.sum-periods { width: 270px; margin: 0; grid-template-columns: repeat(3, 1fr); }
.sum-peak { font-size: 26px !important; }
.sum-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.sum-card { padding: 20px 22px; min-width: 0; }
.sum-card h3 { font-size: 16px; margin: 0 0 12px; }
.sum-card h3 .muted { font-family: var(--ly-mono); font-size: 13px; font-weight: 500; }
.sum-card h3.mt { margin-top: 18px; }
.sum-rows { list-style: none; margin: 0; padding: 0; }
.sum-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 8px; border-radius: 12px; cursor: pointer; }
.sum-row + .sum-row { border-top: 1px solid var(--ly-border); }
.sum-row:hover { background: var(--ly-hover); }
.sum-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sum-row-top { display: flex; justify-content: space-between; gap: 8px; }
.sum-row-top b { color: var(--ly-title); font-weight: 600; }
.sum-row-top .ly-mono { font-size: 11px; }
.sum-row-last { font-size: 13px; color: var(--ly-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sum-row-flags { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.sum-empty-card { padding: 28px; text-align: center; }
@media (max-width: 1000px) { .sum-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .sum-periods { width: 100%; } .sum-row-flags { display: none; } }

/* ==================== Catálogo, pedidos e Pix ==================== */
.pix-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.pix-actions { gap: 8px; align-items: center; }
.cat-head { margin-bottom: 12px; }
.cat-head h3 { margin: 0; }
.cat-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-search { margin-bottom: 12px; }
.cat-table td { vertical-align: top; font-weight: 400; }
.cat-table td b { font-weight: 500; display: block; }
.cat-table td small { display: block; font-size: 12px; }
.cat-table tr.inactive td { opacity: .55; }
.cat-row-actions { white-space: nowrap; text-align: right; }
.cat-row-actions .btn { padding: 5px 10px; font-size: 12px; }
.cat-empty { text-align: center; padding: 24px 8px; }
.cat-empty p { margin: 4px 0; }

/* catálogo no chat */
.pop-head-actions { display: inline-flex; gap: 12px; }
.cat-item .pop-row b { font-family: var(--ly-font) !important; color: var(--ly-title) !important; font-weight: 500 !important; font-size: 14px !important; }
.cat-price { color: var(--ly-title); font-size: 13px; white-space: nowrap; }
.cat-price small { color: var(--ly-muted); }
.cat-item .link-btn { flex-shrink: 0; }

/* montar pedido */
.order-items { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 40vh; overflow-y: auto; }
.order-items li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--ly-bg); }
.oi-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.oi-name b { font-weight: 500; color: var(--ly-title); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oi-name small { font-size: 12px; }
.oi-qty { display: inline-flex; align-items: center; gap: 2px; background: var(--ly-surface); border: 1px solid var(--ly-border); border-radius: 999px; padding: 2px; }
.oi-qty button { width: 26px; height: 26px; border: 0; border-radius: 50%; background: none; color: var(--ly-title); font-size: 16px; line-height: 1; }
.oi-qty button:hover { background: var(--ly-hover); }
.oi-qty span { min-width: 26px; text-align: center; font-size: 13px; }
.oi-sub { width: 90px; text-align: right; font-size: 13px; color: var(--ly-title); }
.oi-del { border: 0; background: none; color: var(--ly-muted); width: 26px; height: 26px; border-radius: 50%; font-size: 16px; }
.oi-del:hover { background: var(--ly-danger-bg); color: var(--ly-danger-fg); }
.oi-empty { background: none !important; justify-content: center; }
.order-add { margin-bottom: 8px; }
.order-custom { border: 1px solid var(--ly-border); border-radius: 12px; padding: 0 12px; margin-bottom: 12px; }
.order-custom summary { cursor: pointer; padding: 10px 0; font-size: 13px; font-weight: 500; color: var(--ly-title); }
.order-custom .pix-grid input { margin-bottom: 8px; }
.order-custom .btn { margin-bottom: 12px; }
.order-total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 4px; border-top: 1px solid var(--ly-border); margin-bottom: 12px; }
.order-total span { color: var(--ly-muted); }
.order-total b { font-size: 22px; color: var(--ly-title); font-weight: 600; }

/* pedidos no painel do cliente */
.history.orders li { display: flex; flex-direction: column; gap: 4px; }
.ord-items { font-size: 12px; color: var(--ly-text); }
.ord-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.ord-actions .btn { padding: 5px 10px; font-size: 12px; }

/* resumo: produtos mais procurados */
.sum-products { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sum-products li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--ly-bg); }
.sum-products b { flex: 1; font-weight: 500; color: var(--ly-title); font-size: 14px; }
.sum-products .ly-mono { font-size: 12px; }
@media (max-width: 760px) { .pix-grid { grid-template-columns: 1fr; } .oi-sub { width: auto; } }
#catList { overflow-x: auto; }
.cat-table td:first-child { min-width: 200px; }

/* ---------- editar / apagar mensagem ---------- */
.msg-menu-btn { position: absolute; top: 4px; right: 6px; width: 24px; height: 22px; border: 0; border-radius: 8px; background: inherit; color: var(--ly-muted); font-size: 14px; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .12s; }
.msg:hover .msg-menu-btn, .msg-menu-btn:focus-visible { opacity: 1; }
.msg-menu-btn:hover { color: var(--ly-title); }
@media (hover: none) { .msg-menu-btn { opacity: .7; } }
.msg-pop { position: fixed; z-index: 60; min-width: 190px; padding: 6px; background: var(--ly-surface); border: 1px solid var(--ly-border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.16); display: flex; flex-direction: column; }
.msg-pop button { text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 13.5px; color: var(--ly-title); cursor: pointer; }
.msg-pop button:hover { background: rgba(127,127,127,.12); }
.msg-pop button.danger { color: var(--ly-danger-fg); }
.msg-pop-note { font-size: 11.5px; color: var(--ly-muted); padding: 6px 10px 4px; border-top: 1px solid var(--ly-border); margin-top: 4px; max-width: 220px; }
.msg .edited { font-family: inherit; font-style: italic; margin-right: 2px; cursor: help; }
.msg.deleted { background: transparent; border: 1px dashed var(--ly-border); color: var(--ly-muted); }
.msg.deleted .del-label { display: block; font-style: italic; font-size: 13px; }
.msg.deleted .del-orig { display: block; margin-top: 4px; font-size: 12.5px; text-decoration: line-through; opacity: .7; }

/* ---------- foto de perfil dos contatos ---------- */
.avatar { position: relative; overflow: hidden; }
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 50%; background: inherit; }

/* ---------- grupos ---------- */
.msg-sender { font-size: 12px; font-weight: 600; margin-bottom: 2px; padding-right: 22px; }
