/* Central LinkedVix — leiaute no padrão WhatsApp Web, tons de baixo contraste para uso prolongado */
:root {
  --font: 'Open Sans', system-ui, sans-serif;
  --blue: #0D7AD9; --navy: #16466F; --green: #38A668; --lime: #75D966; --teal: #1C8B8B;
  --radius: 10px;
  --rail-w: 232px;
}
[data-theme='dark'] {
  --bg: #0c151d; --rail: #0f1b25; --panel: #111e29; --panel-2: #16242f; --hover: #1a2a37; --active: #1e3242;
  --line: #20303d; --text: #d9e2e9; --muted: #8597a6; --faint: #5f7383;
  --chat: #0d1922; --dots: rgba(140, 170, 195, .045);
  --in: #182633; --out: #123b57; --out-text: #e3eef6; --quote: rgba(255,255,255,.06);
  --accent: #4aa3ee; --accent-ink: #08243a; --ok: #5cc68a; --warn: #e3b25a; --bad: #e0767f;
  --shadow: 0 10px 30px rgba(0,0,0,.35); --tick-read: #5bb8ff;
  color-scheme: dark;
}
[data-theme='light'] {
  --bg: #e6ebef; --rail: #eef2f5; --panel: #f6f8f9; --panel-2: #edf1f4; --hover: #e9eef2; --active: #dde6ee;
  --line: #d9e1e7; --text: #1e2d38; --muted: #5f7180; --faint: #8a9aa7;
  --chat: #e9eef1; --dots: rgba(22, 70, 111, .05);
  --in: #fbfcfc; --out: #d5e9f9; --out-text: #10324d; --quote: rgba(22,70,111,.07);
  --accent: #0D7AD9; --accent-ink: #ffffff; --ok: #2f9a5c; --warn: #b07a12; --bad: #c2434e;
  --shadow: 0 10px 30px rgba(30,45,56,.14); --tick-read: #1a8be6;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
[hidden] { display: none !important; }
i[data-i] { display: inline-flex; width: 20px; height: 20px; flex: none; }
i[data-i] svg { width: 100%; height: 100%; }
kbd { font: 600 11px var(--font); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel-2); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(13,122,217,.18), transparent 60%), radial-gradient(900px 500px at 110% 110%, rgba(56,166,104,.14), transparent 60%), var(--bg); }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow); display: grid; gap: 10px; }
.login-card h1 { margin: 6px 0 0; font-size: 22px; font-weight: 500; }
.login-card p { margin: 0 0 10px; color: var(--muted); }
.login-card label { font-size: 12px; color: var(--muted); font-weight: 600; }
.login-card input { padding: 11px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); outline: none; }
.login-card input:focus { border-color: var(--accent); }
.err { color: var(--bad); min-height: 1.2em; margin: 0; }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, var(--blue), var(--teal) 55%, var(--green)); box-shadow: inset 0 0 0 2px rgba(255,255,255,.15); }
.brand-mark.big { width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 6px; }
.btn { padding: 10px 16px; border-radius: 8px; font-weight: 600; border: 1px solid var(--line); background: var(--panel-2); }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- grade ---------- */
.app { height: 100vh; display: grid; grid-template-columns: var(--rail-w) minmax(300px, 380px) 1fr auto; grid-template-rows: minmax(0, 1fr); transition: grid-template-columns .2s ease; overflow: hidden; }
.app > * { min-height: 0; }
.app.collapsed { --rail-w: 68px; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }

/* ---------- barra de números ---------- */
.rail { background: var(--rail); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.rail-top { display: flex; align-items: center; gap: 6px; padding: 12px 14px 8px; min-height: 58px; }
.rail-brand { font-size: 15px; white-space: nowrap; color: var(--muted); }
.rail-brand b { color: var(--text); font-weight: 700; }
.app.collapsed .rail-brand, .app.collapsed .rail-events, .app.collapsed .rail-act span, .app.collapsed .inst-meta, .app.collapsed .inst-count { display: none; }
.inst-list { list-style: none; margin: 0; padding: 4px 8px; display: grid; gap: 2px; overflow-y: auto; }
.inst { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; position: relative; }
.inst:hover { background: var(--hover); }
.inst.active { background: var(--active); }
.inst.active::before { content: ''; position: absolute; left: -8px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--c, var(--accent)); }
.inst-badge { width: 36px; height: 36px; border-radius: 10px; flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 700; letter-spacing: .02em; color: #fff; background: var(--c, var(--navy)); position: relative; overflow: hidden; }
.inst-badge img { width: 100%; height: 100%; object-fit: cover; }
.inst-badge .dot { position: absolute; right: 2px; bottom: 2px; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--rail); background: var(--faint); }
.inst-badge .dot.open { background: var(--ok); }
.inst-badge .dot.connecting { background: var(--warn); }
.inst-badge .dot.close { background: var(--bad); }
.inst-meta { min-width: 0; flex: 1; }
.inst-meta b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inst-meta small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inst-count { min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px; font-size: 11px; font-weight: 700; display: grid; place-items: center; background: var(--ok); color: #06210f; }
.app.collapsed .inst .inst-badge::after { content: attr(data-n); position: absolute; top: -2px; right: -2px; }
.inst-all .inst-badge { background: linear-gradient(135deg, var(--blue), var(--green)); }
.rail-events { margin-top: auto; padding: 10px 14px; border-top: 1px solid var(--line); max-height: 30vh; overflow-y: auto; }
.rail-events h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 0 0 6px; font-weight: 700; }
.rail-events ul { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--muted); display: grid; gap: 4px; }
.rail-bottom { padding: 8px; border-top: 1px solid var(--line); display: grid; gap: 2px; }
.app.collapsed .rail-events { display: none; }
.app.collapsed .rail-bottom { margin-top: auto; }
.rail-act { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; color: var(--muted); white-space: nowrap; }
.rail-act:hover { background: var(--hover); color: var(--text); }

/* ---------- lista de conversas ---------- */
.list { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.list-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 6px 18px; min-height: 58px; }
.list-head h2 { margin: 0; font-size: 19px; font-weight: 700; }
.search { margin: 4px 12px 8px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 9px; background: var(--panel-2); color: var(--faint); }
.search input { flex: 1; border: 0; background: none; padding: 9px 0; outline: none; color: var(--text); }
.chips { display: flex; gap: 6px; padding: 0 12px 8px; flex-wrap: wrap; }
.chip { padding: 5px 12px; border-radius: 16px; background: var(--panel-2); color: var(--muted); font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.chip:hover { color: var(--text); }
.chip.on { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.chip.toggle input { accent-color: var(--accent); margin: 0; }
.banner { margin: 0 12px 8px; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); font-size: 13px; }
.chats { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.chat { display: flex; gap: 12px; padding: 0 0 0 14px; cursor: pointer; align-items: center; }
.chat:hover { background: var(--hover); }
.chat.active { background: var(--active); }
.chat-main { flex: 1; min-width: 0; padding: 11px 14px 11px 0; border-bottom: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 8px; }
.row .name { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .time { font-size: 12px; color: var(--faint); flex: none; }
.chat.unread .time { color: var(--ok); font-weight: 600; }
.row .last { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.row .last i[data-i] { width: 16px; height: 16px; }
.badge-n.dot { min-width: 12px; width: 12px; height: 12px; padding: 0; }
.tag-inst.off { opacity: .55; text-decoration: line-through; }
.ctx-menu { position: fixed; z-index: 50; min-width: 190px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); display: grid; }
.ctx-menu[hidden] { display: none; }
.ctx-menu button { text-align: left; padding: 9px 12px; border-radius: 7px; white-space: nowrap; }
.ctx-menu button:hover { background: var(--hover); }
input.secret { -webkit-text-security: disc; }
.badge-n {min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--ok); color: #06210f; font-size: 11px; font-weight: 700; display: grid; place-items: center; flex: none; }
.tag-inst { font-size: 10px; font-weight: 700; letter-spacing: .03em; padding: 1px 6px; border-radius: 5px; color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); flex: none; }
.tag-owner { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 5px; color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); flex: none; }
.more { margin: 8px auto 12px; color: var(--accent); font-weight: 600; padding: 6px 12px; border-radius: 8px; }
.more:hover { background: var(--hover); }
.list-empty { padding: 30px 20px; text-align: center; color: var(--muted); }

.avatar { width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 600; color: #fff; overflow: hidden; background: var(--c, #3b5568); font-size: 16px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 38px; height: 38px; font-size: 14px; }
.avatar.xl { width: 120px; height: 120px; font-size: 40px; }

/* ---------- conversa ---------- */
.thread { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--chat);
  background-image: radial-gradient(var(--dots) 1.2px, transparent 1.3px); background-size: 22px 22px; }
.thread.empty > :not(.empty-state) { display: none !important; }
.thread:not(.empty) .empty-state { display: none; }
.empty-state { margin: auto; text-align: center; color: var(--muted); padding: 30px; max-width: 460px; }
.empty-state h2 { color: var(--text); font-weight: 500; font-size: 26px; margin: 8px 0; }
.kbd-hint { font-size: 12px; color: var(--faint); margin-top: 22px; }
.thread-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-height: 58px; background: var(--panel); border-bottom: 1px solid var(--line); }
.thread-head .back { display: none; }
.head-info { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-align: left; border-radius: 8px; padding: 2px 4px; }
.head-text { min-width: 0; display: grid; }
.head-text b { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-text small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.via { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 14px; color: var(--c); background: color-mix(in srgb, var(--c) 15%, transparent); white-space: nowrap; }
.owner-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 16px; font-size: 13px; background: color-mix(in srgb, var(--warn) 13%, var(--panel)); border-bottom: 1px solid var(--line); }
.owner-bar .btn { padding: 4px 10px; font-size: 12px; }
.messages { flex: 1; overflow-y: auto; padding: 16px 7% 10px; display: flex; flex-direction: column; gap: 2px; scroll-behavior: auto; }
.day { align-self: center; margin: 12px 0 8px; padding: 4px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel); box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.loading-older { align-self: center; color: var(--faint); font-size: 12px; padding: 6px; }
.msg { max-width: min(68%, 560px); align-self: flex-start; position: relative; margin-top: 1px; }
.msg.me { align-self: flex-end; }
.msg.first { margin-top: 8px; }
.bubble { position: relative; display: flow-root; padding: 6px 8px 8px 9px; border-radius: 9px; background: var(--in); box-shadow: 0 1px .5px rgba(0,0,0,.13); word-wrap: break-word; overflow-wrap: anywhere; }
.msg.me .bubble { background: var(--out); color: var(--out-text); }
.msg.first:not(.me) .bubble { border-top-left-radius: 0; }
.msg.first.me .bubble { border-top-right-radius: 0; }
.msg.first:not(.me) .bubble::before, .msg.first.me .bubble::before { content: ''; position: absolute; top: 0; width: 9px; height: 12px; background: inherit; }
.msg.first:not(.me) .bubble::before { left: -8px; clip-path: polygon(100% 0, 0 0, 100% 100%); }
.msg.first.me .bubble::before { right: -8px; clip-path: polygon(0 0, 100% 0, 0 100%); }
.who { font-size: 12.5px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
.fwd { font-size: 12px; color: var(--muted); font-style: italic; display: flex; align-items: center; gap: 4px; margin-bottom: 2px; }
.text { white-space: pre-wrap; font-size: 14.2px; }
.text a { color: var(--accent); }
.meta { float: right; margin: 6px 0 -4px 10px; font-size: 11px; color: var(--faint); display: inline-flex; align-items: center; gap: 3px; position: relative; top: 4px; }
.msg.me .meta { color: color-mix(in srgb, var(--out-text) 55%, transparent); }
.tick { width: 16px; height: 11px; display: inline-flex; }
.tick.read { color: var(--tick-read); }
.quote { display: block; border-left: 4px solid var(--c, var(--accent)); background: var(--quote); border-radius: 6px; padding: 5px 8px; margin: 1px 0 5px; font-size: 13px; cursor: pointer; max-height: 70px; overflow: hidden; }
.quote b { display: block; font-size: 12px; color: var(--c, var(--accent)); }
.quote span { color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reacts { position: absolute; bottom: -14px; left: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1px 6px; font-size: 13px; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.msg.me .reacts { left: auto; right: 8px; }
.msg.has-react { margin-bottom: 14px; }
.media { display: block; margin: -2px -4px 4px; border-radius: 7px; overflow: hidden; background: var(--panel-2); min-width: 220px; min-height: 140px; position: relative; cursor: pointer; }
.media img, .media video { display: block; width: 100%; max-height: 340px; object-fit: cover; }
.media.loading::after { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.05) 50%, transparent 70%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.media .play { position: absolute; inset: 0; display: grid; place-items: center; }
.media .play i { width: 54px; height: 54px; color: #fff; filter: drop-shadow(0 2px 6px rgba(0,0,0,.4)); }
.sticker { width: 150px; height: 150px; object-fit: contain; display: block; }
.msg.is-sticker .bubble { background: none; box-shadow: none; padding: 0; }
.msg.is-sticker .bubble::before { display: none; }
.audio { display: flex; align-items: center; gap: 8px; min-width: 260px; padding: 2px 0; }
.audio audio { height: 34px; width: 240px; }
.audio .load { display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 600; padding: 6px 4px; }
.doc { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; background: var(--quote); min-width: 240px; margin-bottom: 4px; }
.doc i[data-i] { width: 30px; height: 30px; color: var(--accent); }
.doc b { display: block; font-weight: 600; font-size: 13.5px; word-break: break-all; }
.doc small { color: var(--muted); }
.loc a { color: var(--accent); font-weight: 600; }
.hover-acts { position: absolute; top: -14px; right: 6px; display: none; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 2px 4px; box-shadow: var(--shadow); z-index: 2; }
.msg.me .hover-acts { right: auto; left: 6px; }
.msg:hover .hover-acts, .msg:focus-within .hover-acts { display: flex; }
.hover-acts button { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); font-size: 16px; }
.hover-acts button:hover { background: var(--hover); color: var(--text); }
.hover-acts i[data-i] { width: 18px; height: 18px; }
.react-pick { position: absolute; top: -48px; display: flex; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 4px 6px; box-shadow: var(--shadow); z-index: 3; }
.react-pick button { font-size: 22px; width: 38px; height: 38px; border-radius: 50%; transition: transform .1s; }
.react-pick button:hover { transform: scale(1.18); background: var(--hover); }
.msg.flash .bubble { animation: flash 1.2s ease; }
.to-bottom { position: absolute; right: 22px; bottom: 82px; width: 42px; height: 42px; border-radius: 50%; background: var(--panel); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--muted); }

/* ---------- compositor ---------- */
.composer { display: flex; align-items: flex-end; gap: 4px; padding: 8px 12px 10px; background: var(--panel); border-top: 1px solid var(--line); position: relative; }
.composer textarea { flex: 1; resize: none; border: 0; outline: none; border-radius: 9px; background: var(--panel-2); padding: 10px 14px; max-height: 160px; line-height: 1.4; margin: 0 4px; font-size: 14.5px; }
.composer .send { color: var(--accent); }
.composer .send.recording { color: #fff; background: var(--bad); }
.rec { flex: 1; display: flex; align-items: center; gap: 10px; padding: 0 10px; height: 42px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); animation: pulse 1s infinite; }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; background: var(--panel); }
.reply-quote { flex: 1; min-width: 0; border-left: 4px solid var(--accent); background: var(--panel-2); border-radius: 6px; padding: 6px 10px; }
.reply-quote b { display: block; color: var(--accent); font-size: 12.5px; }
.reply-quote span { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.pop { position: absolute; left: 12px; bottom: 64px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); z-index: 5; }
.quick-pop { right: 12px; max-height: 320px; overflow-y: auto; padding: 6px; }
.quick-item { display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px; }
.quick-item b { color: var(--accent); font-weight: 600; margin-right: 8px; }
.quick-item span { color: var(--text); }
.quick-item small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-item.sel, .quick-item:hover { background: var(--hover); }
.emoji-pop { width: 340px; padding: 8px; }
.emoji-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 6px; }
.emoji-tabs button { flex: 1; padding: 4px; border-radius: 6px; font-size: 18px; opacity: .55; }
.emoji-tabs button.on { opacity: 1; background: var(--hover); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 220px; overflow-y: auto; }
.emoji-grid button { font-size: 22px; height: 38px; border-radius: 6px; }
.emoji-grid button:hover { background: var(--hover); }
.attach-pop { left: 52px; padding: 6px; display: grid; }
.attach-pop button { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: 8px; white-space: nowrap; }
.attach-pop button:hover { background: var(--hover); }
.attach-pop i[data-i] { color: var(--accent); }
.drop-zone { position: absolute; inset: 58px 0 0; background: color-mix(in srgb, var(--accent) 18%, transparent); border: 3px dashed var(--accent); display: grid; place-items: center; font-size: 20px; font-weight: 600; color: var(--accent); z-index: 6; pointer-events: none; }

/* ---------- painel do contato ---------- */
.panel { width: 340px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 58px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.panel-body { overflow-y: auto; padding: 20px; display: grid; gap: 16px; align-content: start; }
.panel-hero { text-align: center; display: grid; justify-items: center; gap: 4px; }
.panel-hero h3 { margin: 10px 0 0; font-size: 19px; font-weight: 600; }
.panel-hero p { margin: 0; color: var(--muted); }
.pcard { background: var(--panel-2); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; }
.pcard h4 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 700; }
.pcard .kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.pcard .kv span:first-child { color: var(--muted); }
.pcard .kv span:last-child { text-align: right; word-break: break-word; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tags span { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.pcard select, .field input, .field textarea, .field select { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); outline: none; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.link { color: var(--accent); font-weight: 600; }

/* ---------- modal, visualizador, avisos ---------- */
.modal { position: fixed; inset: 0; background: rgba(5,12,18,.55); display: grid; place-items: center; z-index: 20; padding: 16px; backdrop-filter: blur(2px); }
.modal-card { width: min(640px, 100%); max-height: min(86vh, 860px); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; animation: rise .16s ease; }
.modal-card > header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px 20px; }
.modal-card h2 { margin: 0; font-size: 18px; font-weight: 600; }
.modal-body { padding: 4px 20px 20px; overflow-y: auto; display: grid; gap: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { padding: 8px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--accent); border-color: var(--accent); }
.field { display: grid; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field textarea { min-height: 90px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inst-row { display: grid; grid-template-columns: 1.3fr 1fr 70px 46px; gap: 8px; align-items: end; padding: 10px; border-radius: 10px; background: var(--panel-2); }
.inst-row input[type=color] { height: 38px; padding: 2px; }
.qr-row { display: grid; gap: 6px; padding: 10px; border-radius: 10px; background: var(--panel-2); }
.qr-row .grid2 { grid-template-columns: 140px 1fr auto; align-items: center; }
.result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 300px; overflow-y: auto; }
.result-list li { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
.result-list li:hover, .result-list li.sel { background: var(--hover); }
.result-list .src { margin-left: auto; display: flex; gap: 4px; }
.src span { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: var(--panel-2); color: var(--muted); text-transform: uppercase; }
.files-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.files-preview figure { margin: 0; background: var(--panel-2); border-radius: 8px; overflow: hidden; aspect-ratio: 1; display: grid; place-items: center; text-align: center; font-size: 12px; color: var(--muted); padding: 6px; }
.files-preview img, .files-preview video { width: 100%; height: 100%; object-fit: cover; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
.viewer { position: fixed; inset: 0; background: rgba(4,9,13,.92); z-index: 30; display: grid; place-items: center; }
.viewer #viewerClose { position: absolute; top: 14px; right: 14px; color: #fff; }
.viewer img, .viewer video { max-width: 92vw; max-height: 88vh; border-radius: 6px; }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 40; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 14px; box-shadow: var(--shadow); animation: rise .18s ease; max-width: 90vw; }
.toast.bad { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }

@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
@keyframes flash { 30% { filter: brightness(1.35); } }

/* ---------- responsivo ---------- */
@media (max-width: 1200px) { .app { grid-template-columns: var(--rail-w) minmax(280px, 340px) 1fr; } .panel { position: fixed; right: 0; top: 0; bottom: 0; z-index: 10; box-shadow: var(--shadow); } }
@media (max-width: 900px) {
  .app, .app.collapsed { grid-template-columns: 68px 1fr; }
  .app .rail-brand, .app .rail-events, .app .rail-act span, .app .inst-meta, .app .inst-count { display: none; }
  .thread { position: fixed; inset: 0; z-index: 8; }
  .thread.empty { display: none; }
  .thread-head .back { display: inline-grid; }
  .messages { padding: 12px 10px; }
  .msg { max-width: 86%; }
  .panel { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
