/* Command Mídia Chat v2: modelo de caixa de entrada (menu lateral com caixas e etiquetas, lista, conversa, painel do contato). */
:root {
  --bg: #ffffff; --side: #f6f7fa; --line: #e7e9f0; --line2: #d6d9e4; --hover: #eef0f6;
  --ink: #12133a; --ink2: #3f4266; --muted: #757896;
  --pri: #3442c6; --pri-soft: #eceefd;
  --cli: #f1f2f6; --nota: #fff4cf; --nota-line: #f2d77e;
  --ok: #1aa364; --warn: #d48a00; --crit: #e0414f;
  --shadow: 0 12px 32px rgba(18, 19, 58, .14);
  --f: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.45 var(--f); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--pri); outline-offset: 2px; }
svg { flex: none; }

.av { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: var(--c, #5b63c9); flex: none; position: relative; }
.av.p { width: 26px; height: 26px; font-size: 10px; }
.av.md { width: 30px; height: 30px; font-size: 11px; }
.av.g { width: 56px; height: 56px; font-size: 20px; }
.av .on { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #fff; background: var(--s, var(--ok)); }
.av .sub { position: absolute; right: -5px; bottom: -5px; width: 20px; height: 20px; border-radius: 50%; border: 2px solid #fff; font-size: 8px; display: grid; place-items: center; background: var(--c2, #3442c6); color: #fff; font-weight: 700; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line2); background: #fff; color: var(--ink2); font-weight: 600; font-size: 13px; white-space: nowrap; }
.btn:hover { background: var(--hover); color: var(--ink); }
.btn.pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.pri:hover { filter: brightness(1.08); }
.btn svg { width: 16px; height: 16px; }
.ic { width: 34px; height: 34px; border-radius: 9px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.ic:hover { background: var(--hover); color: var(--ink); }
.ic svg { width: 18px; height: 18px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 6px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff); white-space: nowrap; }
.tag button { border: 0; background: none; padding: 0 0 0 2px; color: inherit; opacity: .6; font-size: 14px; line-height: 1; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); z-index: 60; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; background: linear-gradient(180deg, #000035, #04053f); }
.login form { width: min(400px, 100%); background: #fff; border-radius: 20px; padding: 32px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login img { height: 30px; width: auto; align-self: flex-start; }
.login h1 { margin: 0; font-size: 22px; }
.login p { margin: 0 0 6px; color: var(--muted); }
.fld { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink2); }
.fld input, .fld textarea { height: 42px; border-radius: 10px; border: 1px solid var(--line2); background: var(--side); padding: 0 12px; font-size: 14px; font-weight: 400; color: var(--ink); }
.fld textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.login .btn.pri { height: 44px; }
.login small { color: var(--muted); text-align: center; }

/* app em 4 colunas */
.app { height: 100%; display: grid; grid-template-columns: 252px 340px minmax(0, 1fr) 320px; }
.app.sem-d { grid-template-columns: 252px 340px minmax(0, 1fr); }
.app.sem-d .det { display: none; }
.app.cfg-on { grid-template-columns: 252px minmax(0, 1fr); }

/* menu lateral */
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.ws { display: flex; align-items: center; gap: 10px; padding: 16px 16px 10px; }
.ws img { width: 34px; height: 34px; border-radius: 9px; }
.ws b { display: block; font-size: 14.5px; }
.ws small { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; }
.ws small i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.sd { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 10px 10px; scrollbar-width: thin; }
.sd h5 { margin: 16px 8px 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.sd h5 button { border: 0; background: none; color: var(--muted); font-size: 17px; line-height: 1; padding: 0 2px; }
.si { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 9px; background: none; color: var(--ink2); font-weight: 500; text-align: left; }
.si:hover { background: var(--hover); color: var(--ink); }
.si.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(18,19,58,.08), inset 0 0 0 1px var(--line); }
.si.prim.on { background: var(--pri); color: #fff; box-shadow: none; }
.si .e { width: 22px; text-align: center; font-size: 15px; flex: none; }
.si svg { width: 18px; height: 18px; }
.si span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.si em { font-style: normal; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.si.on em { color: inherit; }
.si em.r { color: #fff; background: var(--crit); border-radius: 99px; padding: 0 6px; min-width: 18px; text-align: center; }
.sd-b { border-top: 1px solid var(--line); padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.me { display: flex; align-items: center; gap: 10px; padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.me div { flex: 1; min-width: 0; }
.me b { display: block; font-size: 13.5px; }
.me select { border: 0; background: none; font-size: 12px; color: var(--muted); padding: 0; margin-left: -3px; }

/* lista */
.lst { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.lst-h { display: flex; align-items: center; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.lst-h select { height: 34px; border-radius: 9px; border: 1px solid var(--line2); background: #fff; font-weight: 600; padding: 0 8px; }
.lst-h .busca { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; height: 34px; border-radius: 9px; border: 1px solid var(--line); padding: 0 10px; color: var(--muted); }
.lst-h .busca input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); font-size: 13px; }
.lst-h .busca svg { width: 15px; height: 15px; }
.lst-t { padding: 12px 18px 6px; font-size: 13px; color: var(--ink); font-weight: 700; display: flex; justify-content: space-between; }
.lst-t span { color: var(--muted); font-weight: 600; }
.itens { flex: 1; overflow-y: auto; scrollbar-width: thin; padding: 0 8px 8px; }
.it { width: 100%; display: flex; gap: 12px; align-items: center; padding: 12px 10px; border: 0; border-radius: 12px; background: none; text-align: left; margin-bottom: 2px; }
.it:hover { background: var(--hover); }
.it.on { background: var(--pri-soft); }
.it-b { flex: 1; min-width: 0; }
.it-t { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.it-t b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.it-t .ag { color: var(--pri); font-weight: 600; font-size: 13px; white-space: nowrap; }
.it-t time { margin-left: auto; font-size: 11.5px; color: var(--muted); flex: none; }
.it-m { font-size: 13px; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.it.novo .it-m { color: var(--ink); font-weight: 600; }
.it-e { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.sit { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }
.sit svg { width: 13px; height: 13px; }
.sit.esp { background: var(--pri); } .sit.fila { background: var(--crit); } .sit.ok { background: var(--ok); } .sit.fim { background: var(--line2); }
.vazio { padding: 40px 20px; text-align: center; color: var(--muted); }

/* conversa */
.ch { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--line); }
.ch-h { display: flex; align-items: center; gap: 4px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 58px; }
.ch-h .id { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.ch-h .id b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-h .sep { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.ch-h .btn.pri { height: 34px; }
.msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 26px 12px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; }
.msgs > * { flex-shrink: 0; }
.dia { align-self: center; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.ev { align-self: center; font-size: 12px; color: var(--muted); text-align: center; }
.m { display: flex; align-items: flex-end; gap: 8px; max-width: 78%; }
.m.cli { align-self: flex-start; }
.m.nos, .m.nota, .m.lemb { align-self: flex-end; flex-direction: row-reverse; }
.m .col { display: flex; flex-direction: column; min-width: 0; }
.m.nos .col, .m.nota .col, .m.lemb .col { align-items: flex-end; }
.bal { padding: 10px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.45; }
.bal p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.bal .ass { display: block; font-weight: 700; margin-bottom: 4px; }
.m.cli .bal { background: var(--cli); border-bottom-left-radius: 4px; }
.m.nos .bal { background: var(--pri); color: #fff; border-bottom-right-radius: 4px; }
.m.nota .bal { background: var(--nota); border: 1px solid var(--nota-line); border-bottom-right-radius: 4px; }
.m.nota .bal u { display: flex; align-items: center; gap: 6px; font-weight: 700; margin-bottom: 4px; }
.m.nota .bal u i { width: 18px; height: 18px; border-radius: 50%; background: var(--warn); display: grid; place-items: center; color: #fff; font-style: normal; font-size: 10px; }
.men { background: color-mix(in srgb, var(--pri) 14%, #fff); color: var(--pri); border-radius: 5px; padding: 0 4px; font-weight: 600; }
.meta { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.meta svg { width: 15px; height: 10px; }
.meta .lida { color: var(--pri); }
.lembp { display: inline-flex; align-items: center; gap: 8px; background: #2b3550; color: #fff; padding: 9px 16px; border-radius: 99px; font-weight: 600; font-size: 13.5px; }
.lembp svg { width: 16px; height: 16px; }
.resumo-b { align-self: center; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line2); background: #fff; border-radius: 99px; padding: 6px 14px; font-size: 12.5px; font-weight: 600; color: var(--ink2); margin-top: 4px; }
.resumo-b svg { width: 15px; height: 15px; color: var(--pri); }
.resumo { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--side); font-size: 13.5px; }
.resumo b { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.resumo b svg { width: 15px; height: 15px; color: var(--pri); }
.resumo ul { margin: 0; padding-left: 18px; color: var(--ink2); }
.faixa { margin: 0 14px 10px; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 10%, #fff); border: 1px solid color-mix(in srgb, var(--warn) 30%, #fff); font-size: 13px; color: var(--ink2); }
.faixa .btn { margin-left: auto; height: 32px; }
.comp { margin: 0 14px 14px; border: 1px solid var(--line2); border-radius: 14px; position: relative; background: #fff; }
.comp.nota { background: #fffbea; border-color: var(--nota-line); }
.comp-t { display: flex; align-items: center; gap: 2px; padding: 8px 8px 0; flex-wrap: wrap; }
.comp-t .md { border: 0; background: none; border-radius: 8px; padding: 5px 10px; font-size: 13px; font-weight: 600; color: var(--ink2); }
.comp-t .md[aria-pressed="true"] { background: var(--pri-soft); color: var(--pri); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pri) 30%, #fff); }
.comp-t .ia { margin-left: auto; color: var(--pri); display: inline-flex; align-items: center; gap: 5px; }
.comp-t .ia svg { width: 15px; height: 15px; }
.comp textarea { display: block; width: 100%; min-height: 64px; max-height: 200px; resize: none; border: 0; outline: 0; background: none; padding: 10px 14px; font-size: 14.5px; line-height: 1.45; color: var(--ink); }
.comp-b { display: flex; align-items: center; gap: 8px; padding: 0 8px 8px 12px; }
.sw { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink2); cursor: pointer; user-select: none; }
.sw input { appearance: none; width: 32px; height: 18px; border-radius: 99px; background: var(--line2); position: relative; cursor: pointer; margin: 0; }
.sw input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.sw input:checked { background: var(--pri); }
.sw input:checked::after { transform: translateX(14px); }
.comp-b .esp { flex: 1; }
.comp-b small { color: var(--muted); font-size: 12px; }
.env { width: 40px; height: 36px; border-radius: 9px; border: 0; background: var(--pri); color: #fff; display: grid; place-items: center; }
.env svg { width: 18px; height: 18px; }
.comp.nota .env { background: var(--warn); }
.pop { position: absolute; bottom: calc(100% + 6px); background: #fff; border: 1px solid var(--line2); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 10; min-width: 230px; max-height: 300px; overflow-y: auto; }
.pop.dir { right: 8px; }
.pop.esq { left: 8px; right: 8px; }
.pop.abaixo { top: calc(100% + 6px); bottom: auto; left: 0; }
.pop button { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: none; border-radius: 8px; padding: 8px 10px; text-align: left; font-size: 13.5px; }
.pop button:hover, .pop button.sel { background: var(--hover); }
.pop button small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pop button div { min-width: 0; }
.pop button svg { width: 16px; height: 16px; color: var(--muted); }
.fim-bar { margin: 0 14px 14px; padding: 14px; border-radius: 14px; background: var(--side); display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.fim-bar .btn { margin-left: auto; }
.nada { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); }
.nada svg { width: 44px; height: 44px; }

/* painel do contato */
.det { overflow-y: auto; min-height: 0; scrollbar-width: thin; }
.det-top { padding: 18px 16px 14px; display: flex; flex-direction: column; gap: 14px; }
.det-top .who { display: flex; align-items: center; gap: 12px; }
.det-top b { display: block; font-size: 17px; }
.det-top small { color: var(--muted); }
.det-top .btn.pri { width: 100%; height: 40px; }
.det details { border-top: 1px solid var(--line); }
.det summary { list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; font-weight: 700; font-size: 13.5px; cursor: pointer; background: var(--side); }
.det summary::-webkit-details-marker { display: none; }
.det summary::after { content: "⌄"; color: var(--muted); font-size: 16px; transition: transform .15s; }
.det details[open] summary::after { transform: rotate(180deg); }
.det .bx { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.lin { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink2); }
.lin svg { width: 17px; height: 17px; color: var(--muted); }
.lin select { flex: 1; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: #fff; padding: 0 8px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; position: relative; }
.tags .add { border: 1px dashed var(--line2); background: none; border-radius: 8px; font-size: 12.5px; padding: 3px 10px; color: var(--muted); }
.kv { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.kv div { display: grid; grid-template-columns: 1fr 1fr; font-size: 13px; }
.kv div + div { border-top: 1px solid var(--line); }
.kv span { padding: 9px 12px; font-weight: 600; border-left: 3px solid var(--pri); }
.kv b { padding: 9px 12px; font-weight: 400; color: var(--muted); border-left: 1px solid var(--line); overflow-wrap: anywhere; }
.hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.hist li { border-left: 2px solid var(--line2); padding-left: 10px; }
.hist li span { display: block; color: var(--muted); font-size: 12px; }

/* configurações e respostas rápidas */
.cfg { overflow-y: auto; padding: 26px clamp(16px, 4vw, 40px) 48px; background: var(--side); }
.cfg-in { max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.cfg h1 { margin: 0; font-size: 22px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card > p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tab { width: 100%; border-collapse: collapse; font-size: 13px; }
.tab th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tab td { padding: 10px; border-bottom: 1px solid var(--line); }
.pes { display: flex; align-items: center; gap: 10px; }
.cel { background: var(--cli); border-radius: 14px; padding: 14px; }
.cel .bal { background: var(--pri); color: #fff; display: inline-block; border-radius: 16px 16px 4px 16px; }

.mnu { display: none; }
@media (max-width: 1360px) { .app, .app.sem-d { grid-template-columns: 232px 310px minmax(0, 1fr); } .det { display: none; } .app.d-aberto .det { display: block; position: fixed; right: 0; top: 0; bottom: 0; width: 320px; background: #fff; z-index: 30; box-shadow: var(--shadow); } }
@media (max-width: 1000px) {
  .app, .app.sem-d, .app.cfg-on { grid-template-columns: 300px minmax(0, 1fr); }
  .app.cfg-on { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .app.menu .side { transform: none; }
  .mnu { display: grid; }
}
@media (max-width: 720px) {
  .app, .app.sem-d { grid-template-columns: minmax(0, 1fr); }
  .ch { display: none; }
  .app.aberta .lst { display: none; }
  .app.aberta .ch { display: flex; }
  .m { max-width: 90%; }
  .msgs { padding: 16px 12px; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
}
/* editor de etiquetas */
.etqrow { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.etqrow input { height: 36px; border-radius: 9px; border: 1px solid var(--line2); background: var(--side); padding: 0 10px; color: var(--ink); }
.etqe { width: 52px; text-align: center; font-size: 17px; }
.etqn { flex: 1; min-width: 140px; }
.etqc { display: inline-flex; gap: 4px; }
.etqc button { width: 20px; height: 20px; border-radius: 50%; border: 2px solid #fff; background: var(--c); box-shadow: 0 0 0 1px var(--line2); padding: 0; }
.etqc button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--c); }
.etqrow .tag { min-width: 90px; }
.etqrow .ic { font-size: 20px; color: var(--crit); }
.etqrow .tag { display: none; }
