:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --border: #2a2f3a;
  --text: #e6e8ee; --muted: #8b93a7; --accent: #ff4d5e; --green: #3ecf8e;
  --yellow: #f5c542; --red: #ff5c5c; --gray: #6b7280; --blue: #5aa9ff;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0; z-index: 5; }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
button, .btn { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; font: inherit; cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap; }
button:hover, .btn:hover { border-color: #3a4150; background: #252a35; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.1); }
button.small { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: wait; }
input, select, textarea { background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font: inherit; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); }
.banner { padding: 8px 20px; background: #1d2b45; color: #b9d4ff; font-size: 13px; }
.banner.warn { background: #45301d; color: #ffd9a8; }
.hidden { display: none !important; }
.tabs { display: flex; gap: 4px; padding: 12px 20px 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: 8px 12px; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.pill { background: var(--panel2); border-radius: 10px; padding: 1px 7px; font-size: 12px; margin-left: 4px; }
.alerts { margin: 14px 20px 0; padding: 10px 14px; background: #2a1a1d; border: 1px solid #5a2a31; border-radius: 10px; }
.alerts strong { color: #ffb3bb; }
.alerts ul { margin: 6px 0 0; padding-left: 18px; }
.alerts a { color: var(--text); cursor: pointer; text-decoration: underline; }
.toolbar { display: flex; gap: 8px; padding: 14px 20px; flex-wrap: wrap; }
.toolbar input { flex: 1 1 220px; width: auto; }
.toolbar select { flex: 0 1 190px; width: auto; }
.table-wrap { overflow-x: auto; margin: 0 20px 20px; border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; min-width: 1100px; }
th, td { padding: 9px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--panel); color: var(--muted); font-weight: 600; font-size: 12px; position: sticky; top: 0; cursor: pointer; user-select: none; }
thead th:hover { color: var(--text); }
thead th.sorted { color: var(--text); }
tbody tr:hover { background: #151922; }
tfoot td { background: var(--panel); font-weight: 600; }
.ch { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.ch img { width: 34px; height: 34px; border-radius: 50%; background: var(--panel2); flex-shrink: 0; }
.ch .nm { font-weight: 600; cursor: pointer; }
.ch .nm:hover { text-decoration: underline; }
.ch .sub { font-size: 12px; color: var(--muted); }
.ch a { color: var(--muted); text-decoration: none; }
.ch a:hover { color: var(--blue); }
.delta { font-size: 11px; display: block; }
.pos { color: var(--green); } .neg { color: var(--red); }
.score { display: inline-flex; align-items: center; gap: 6px; }
.bar { width: 46px; height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; }
.st { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--panel2); }
.st.performando { color: var(--green); } .st.estavel { color: var(--yellow); } .st.queda { color: var(--red); } .st.parado { color: #a3a9b6; }
.err { color: var(--red); }
.actions { display: flex; gap: 4px; justify-content: flex-end; }
.empty { text-align: center; color: var(--muted); padding: 40px; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 20px; width: min(520px, 94vw); max-height: 90vh; }
dialog.wide { width: min(1000px, 96vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog label { display: block; margin-bottom: 10px; color: var(--muted); font-size: 13px; }
dialog label input, dialog label textarea { margin-top: 4px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
#addResult div { font-size: 13px; padding: 4px 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--panel2); border-radius: 10px; padding: 10px 12px; }
.kpi b { display: block; font-size: 18px; }
.kpi span { color: var(--muted); font-size: 12px; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }
.chart { background: var(--panel2); border-radius: 10px; padding: 10px; }
.chart svg { width: 100%; height: 160px; display: block; }
.chart .ttl { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.vidcards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vidcard { background: var(--panel2); border-radius: 10px; padding: 10px 12px; }
.vidcard a { color: var(--text); }
.detail-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.detail-head img { width: 64px; height: 64px; border-radius: 50%; }
.detail-head a { color: var(--blue); }
.detail-table table { min-width: 600px; }
.detail-table td a { color: var(--text); text-decoration: none; }
.detail-table td a:hover { text-decoration: underline; }
.detail-table td:first-child { max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; z-index: 50; max-width: 360px; }
@media (max-width: 640px) {
  header { padding: 10px 12px; } .toolbar, .tabs { padding-left: 12px; padding-right: 12px; }
  .table-wrap { margin: 0 8px 16px; } .vidcards { grid-template-columns: 1fr; }
}
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 28px; width: min(360px, 100%); }
.login-card h1 { margin-bottom: 4px; }
.login-card label { display: block; margin: 14px 0; color: var(--muted); font-size: 13px; }
.login-card input { margin-top: 4px; }
.login-card button { width: 100%; margin-top: 6px; padding: 10px; }
.login-card .err { min-height: 18px; font-size: 13px; }
.money { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #12351f; color: var(--green); margin-left: 6px; font-weight: 600; white-space: nowrap; }
.money.no { background: var(--panel2); color: var(--muted); font-weight: 400; }
.userbox { display: flex; align-items: center; gap: 8px; padding-left: 8px; border-left: 1px solid var(--border); }
.check { display: flex !important; align-items: center; gap: 8px; color: var(--text) !important; }
.check input { width: auto; margin: 0; }
/* ---------- quartinho do agente ---------- */
.agent-room { display: flex; gap: 14px; margin: 14px 20px 0; padding: 12px 14px; background: linear-gradient(0deg, #161b26, #1a2030); border: 1px solid #2c3550; border-radius: 14px; }
.room-art { flex: 0 0 74px; height: 74px; border-radius: 12px; background: #222a3d; border: 1px solid #333d58; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.room-art::before { content: ""; position: absolute; top: 6px; right: 8px; width: 14px; height: 10px; border-radius: 2px; background: #3a4a6e; box-shadow: -20px 0 0 #3a4a6e; }
.robot { font-size: 30px; line-height: 1; animation: bob 2.4s ease-in-out infinite; }
.desk { font-size: 13px; letter-spacing: 2px; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .robot { animation: none; } }
.room-main { flex: 1; min-width: 0; }
.room-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.room-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.room-insight { margin: 8px 0; font-size: 13.5px; line-height: 1.55; }
.room-insight.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.room-ask { display: flex; gap: 6px; }
.room-ask input { flex: 1; }
.room-chat { max-height: 320px; overflow-y: auto; margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 8px 10px; border-radius: 10px; background: var(--panel2); font-size: 13.5px; max-width: 92%; }
.msg.user { align-self: flex-end; background: #23314d; }
.msg.thinking { color: var(--muted); font-style: italic; }
.room-notes { font-size: 13px; background: var(--panel2); border-radius: 10px; padding: 8px 12px; }
.room-notes ul { margin: 6px 0 0; padding-left: 18px; }
.link-btn { background: none; border: none; color: var(--muted); padding: 0 4px; }
.small { font-size: 12px; }
/* ---------- todos os canais ---------- */
.all-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 20px 14px; }
.sum-box { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; }
.sum-box b { font-size: 22px; }
.sum-ico { font-size: 18px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; margin: 0 20px 24px; }
.ch-card { background: var(--panel); border: 1px solid var(--border); border-top: 3px solid var(--mc); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.ch-card.archived { opacity: .7; }
.ch-card-head { display: flex; gap: 10px; align-items: flex-start; }
.ch-card-head img { width: 48px; height: 48px; border-radius: 50%; background: var(--panel2); flex-shrink: 0; }
.ch-card-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ch-card-title b.link { font-size: 15px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-card-title b.link:hover { text-decoration: underline; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.tags .money { margin-left: 0; }
.ch-score { text-align: center; background: var(--panel2); border-radius: 10px; padding: 4px 10px; border: 2px solid var(--mc); }
.ch-score b { display: block; font-size: 20px; color: var(--mc); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.stat { background: var(--panel2); border-radius: 10px; padding: 7px 8px; display: flex; flex-direction: column; min-width: 0; }
.stat b { font-size: 16px; }
.stat .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.best { background: var(--panel2); border-radius: 10px; padding: 7px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.best a { color: var(--text); }
.ch-card-foot { display: flex; gap: 6px; align-items: center; }
/* ---------- ativos: atenção e personagens ---------- */
.alerts.ok { background: #12281d; border-color: #1f5136; }
.att-title { margin-bottom: 8px; }
.alerts.ok .att-title { margin: 0; }
.att-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.att-item { display: flex; gap: 10px; background: #1f1416; border: 1px solid #4a252b; border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.att-item:hover { border-color: #7a3540; }
.att-face { font-size: 28px; line-height: 1; }
.sec-title { margin: 18px 20px 8px; }
.mood-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 0 20px; }
.mood-card { background: var(--panel); border: 1px solid var(--border); border-left: 4px solid var(--mc); border-radius: 12px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.mood-card:hover { background: #1b1f28; }
.mood-top { display: flex; gap: 10px; align-items: center; }
.mood-face { font-size: 36px; line-height: 1; }
.mood-name { display: flex; flex-direction: column; min-width: 0; }
.mood-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bubble { position: relative; background: var(--panel2); border-radius: 10px; padding: 7px 10px; font-size: 13px; }
.bubble::before { content: ""; position: absolute; top: -6px; left: 16px; border: 6px solid transparent; border-top: 0; border-bottom-color: var(--panel2); }
.spark { width: 100%; height: 48px; display: block; }
.spark-empty { height: 48px; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); background: var(--panel2); border-radius: 8px; }
@media (max-width: 640px) {
  .agent-room { margin: 10px 8px 0; flex-direction: column; } .room-art { flex-basis: auto; height: 56px; flex-direction: row; gap: 8px; }
  .stats { grid-template-columns: repeat(2, 1fr); } .card-grid, .mood-grid, .all-summary { margin-left: 8px; margin-right: 8px; } .card-grid { grid-template-columns: 1fr; }
}
.btn-fire { background: #3a1a12; border-color: #8a3a1e; color: #ffb38a; font-weight: 600; }
.btn-fire:hover { background: #5a2414; border-color: #e0662e; color: #fff; }
.btn-restore { background: #14301f; border-color: #2c6b45; color: #9fe6bd; }
.btn-restore:hover { background: #1c4a2f; }

.btn-close { background: var(--panel2); font-weight: 600; padding: 6px 12px; }
.btn-close:hover { background: #3a2026; border-color: #7a3540; }
.all-summary { display: flex; flex-direction: column; gap: 10px; }
.sum-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.sum-row.three { grid-template-columns: repeat(3, 1fr); }
.sum-box.clickable { cursor: pointer; }
.sum-box.clickable:hover { border-color: #3a4150; background: #1b1f28; }
.sum-box.on { border-color: var(--accent); background: #2a1a1f; }
.sum-row.three .sum-box b { font-size: 26px; }
.tag-new { font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #13323a; color: #7fe0f0; font-weight: 600; }
.zoom { display: flex; align-items: center; gap: 4px; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 2px 4px; }
.zoom button { border: none; background: none; font-size: 14px; }
.zoom span { min-width: 38px; text-align: center; }
.card-grid { grid-template-columns: repeat(auto-fill, minmax(var(--card-min, 340px), 1fr)); }
.card-grid.compact .stats { grid-template-columns: repeat(2, 1fr); }
.card-grid.compact .stat b { font-size: 14px; }
.card-grid.compact .best, .card-grid.compact .ch-card-foot .muted { display: none; }
.card-grid.big .stat b { font-size: 19px; }
.card-grid.big .ch-card-head img { width: 60px; height: 60px; }
@media (max-width: 640px) { .sum-row, .sum-row.three { grid-template-columns: repeat(2, 1fr); } }
.scope-label { font-size: 13px; color: var(--muted); padding: 2px 4px; }
.scope-label.on { color: #ffd0a8; }
.sum-box.scoped { border-color: #6b4a2a; background: #1f1a14; }
.share { font-size: 11px; color: #ffcf99; margin-top: 2px; }
.st.em_alta { color: #4fc3f7; }

.plaza-wrap { position: relative; margin: 0 20px; }
.plaza-canvas { width: 100%; display: block; border-radius: 14px; border: 1px solid #2c3550; }
.plaza-tip { position: absolute; display: none; pointer-events: none; background: #141824; color: #f3f0e6; border: 2px solid #e8c547; padding: 8px 10px; font-family: 'Segoe UI', 'Inter', system-ui, sans-serif; font-size: 13.5px; line-height: 1.55; min-width: 210px; border-radius: 10px; z-index: 5; }
.plaza-tip-sub { color: #b9c2d6; font-size: 12px; }
@media (max-width: 640px) { .plaza-wrap { margin: 0 8px; } }
.sync-info { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; }
#lastSync { color: var(--green); }
.toast { white-space: pre-line; }

.ticker { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; background: #0d1018; border: 1px solid #2c3550; border-radius: 8px; overflow: hidden; height: 32px; }
.ticker-tag { flex: 0 0 auto; background: #c0392b; color: #fff; font-size: 11px; font-weight: 700; padding: 0 10px; height: 100%; display: flex; align-items: center; letter-spacing: .05em; }
.ticker-track { flex: 1; overflow: hidden; position: relative; height: 100%; }
.ticker-text { position: absolute; white-space: nowrap; height: 100%; display: flex; align-items: center; font-size: 13.5px; animation: tick 60s linear infinite; padding-left: 100%; }
.ticker:hover .ticker-text { animation-play-state: paused; }
@keyframes tick { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .ticker-text { animation: none; padding-left: 8px; } }
.tk-head { color: #ffd86b; font-weight: 600; }
.tk-ch { color: #fff; margin-right: 4px; }
.tk-sep { color: #e8c547; margin: 0 18px; }

.ins-sum { display: flex; flex-direction: column; gap: 3px; }
.ins-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-insight.clamp { display: block; -webkit-line-clamp: unset; }
