:root{--nav:#0b1220;--nav2:#111c31;--blue:#2563eb;--bg:#eef3f8;--card:#fff;--line:#dce5ef;--text:#172033;--muted:#718096;--red:#dc2626;--redbg:#fef2f2;--green:#15803d;--greenbg:#f0fdf4;--amber:#b45309;--amberbg:#fff7ed;--gray:#64748b}*{box-sizing:border-box}body{margin:0;font:14px Inter,Segoe UI,Arial,sans-serif;background:var(--bg);color:var(--text)}.topbar{height:62px;background:linear-gradient(90deg,var(--nav),var(--nav2));color:#fff;display:flex;align-items:center;justify-content:space-between;padding:0 18px;position:sticky;top:0;z-index:20}.brand{display:flex;align-items:center;gap:10px}.brand-mark{width:36px;height:36px;display:grid;place-items:center;border-radius:10px;background:linear-gradient(135deg,#3b82f6,#1d4ed8);font-weight:900;font-size:20px}.brand strong{display:block;font-size:17px}.brand small{display:block;color:#98a8c0;font-size:11px}.topbar nav{display:flex;gap:4px}.topbar a{color:#cbd5e1;text-decoration:none;padding:8px 10px;border-radius:8px;font-size:12px}.topbar a.active,.topbar a:hover{background:#25344d;color:#fff}.monitor-toolbar{padding:18px 20px 10px;display:flex;align-items:center;justify-content:space-between}.toolbar-title h1{margin:0;font-size:23px}.toolbar-title p{margin:5px 0 0;color:var(--muted)}.toolbar-actions{display:flex;align-items:center;gap:8px}.toolbar-actions button,dialog menu button{border:0;background:#2563eb;color:#fff;border-radius:9px;padding:10px 14px;font-weight:700;cursor:pointer}.connection{padding:9px 12px;border-radius:20px;font-weight:800;font-size:12px}.connection.on{background:#dcfce7;color:#166534}.connection.off{background:#fee2e2;color:#991b1b}.summary-grid{display:grid;grid-template-columns:repeat(5,minmax(140px,1fr));gap:10px;padding:0 20px 10px}.summary-grid article{background:#fff;border:1px solid var(--line);border-radius:13px;padding:13px 15px;box-shadow:0 4px 15px #0f172a08}.summary-grid span{color:var(--muted);font-size:11px}.summary-grid b{display:block;font-size:25px;margin:4px 0}.summary-grid small{color:#94a3b8;font-size:10px}.danger-card{border-color:#fecaca!important;background:linear-gradient(135deg,#fff,#fff5f5)!important}.danger-card b{color:var(--red)}.active-filters{margin:0 20px 10px;padding:8px 12px;background:#e8f1ff;border:1px solid #cfe0fb;border-radius:10px;color:#40516a;font-size:11px;min-height:34px}.monitor-main{display:grid;gap:12px;padding:0 20px 24px}.monitor-card{background:#fff;border:1px solid var(--line);border-radius:14px;box-shadow:0 6px 20px #0f172a08;overflow:hidden}.monitor-card>header{padding:13px 16px;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--line)}.monitor-card h2{margin:0;font-size:16px}.monitor-card header p{margin:4px 0 0;color:var(--muted);font-size:11px}.count{min-width:36px;text-align:center;background:#edf2f9;color:#29415f;border-radius:18px;padding:7px 10px;font-weight:800}.table-wrap{overflow:auto;max-height:37vh}table{width:100%;border-collapse:collapse;table-layout:fixed}th{position:sticky;top:0;background:#f8fafc;color:#718096;font-size:10px;text-transform:uppercase;letter-spacing:.04em;text-align:left;padding:9px 12px;border-bottom:1px solid var(--line);z-index:2}td{padding:10px 12px;border-bottom:1px solid #edf1f5;vertical-align:middle;font-size:12px}tbody tr:hover{background:#f8fbff}.right{text-align:right}.client-cell b{display:block}.client-cell small,.sub{display:block;color:#8a98aa;font-size:10px;margin-top:2px}.dept-pill{display:inline-block;padding:5px 8px;border-radius:12px;background:#eef4ff;color:#31588a;font-size:10px;font-weight:700}.time-big{font-size:14px;font-weight:900}.time-hot{color:#c2410c}.last-message{border-left:4px solid #94a3b8;padding-left:9px;min-width:0}.last-message.customer{border-color:var(--red);color:#991b1b}.last-message.agent{border-color:var(--green);color:#166534}.last-message.system{border-color:#94a3b8;color:#475569}.last-message b{display:block;font-size:10px;text-transform:uppercase;margin-bottom:3px}.last-message p{margin:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.badge{display:inline-flex;align-items:center;gap:5px;border-radius:16px;padding:6px 9px;font-size:10px;font-weight:900}.badge.ok{background:var(--greenbg);color:var(--green)}.badge.danger{background:var(--redbg);color:var(--red);animation:pulse 1.6s infinite}.badge.neutral{background:#f1f5f9;color:#64748b}@keyframes pulse{50%{box-shadow:0 0 0 4px #fecaca88}}.empty{padding:24px!important;text-align:center;color:#8a98aa}.danger-row{background:#fffafa}.agents-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:10px;padding:12px}.agent-card{border:1px solid var(--line);border-radius:11px;padding:11px}.agent-card-head{display:flex;justify-content:space-between;gap:8px}.agent-card b{font-size:13px}.agent-card .load{font-weight:900;color:#334155}.agent-stats{display:flex;gap:8px;margin-top:8px;font-size:10px}.agent-stats span{background:#f1f5f9;padding:5px 7px;border-radius:10px}.agent-stats .risk{background:#fef2f2;color:#b91c1c}dialog{border:0;border-radius:15px;box-shadow:0 25px 90px #0006;width:min(900px,94vw);padding:0}dialog::backdrop{background:#0f172a80}dialog form{padding:20px}.dialog-head{display:flex;justify-content:space-between;align-items:flex-start}.dialog-head h3{margin:0;font-size:19px}.dialog-head p{margin:4px 0 0;color:var(--muted)}.x{border:0;background:#eef2f7;border-radius:50%;width:32px;height:32px;font-size:20px;cursor:pointer}.threshold{display:flex;align-items:center;gap:8px;padding:13px;background:#f8fafc;border-radius:10px;margin:15px 0;font-weight:700}.threshold input{width:72px;border:1px solid #cbd5e1;border-radius:7px;padding:8px}.filter-columns{display:grid;grid-template-columns:1fr 1fr;gap:16px}.filter-title{display:flex;align-items:center;gap:6px;margin-bottom:8px}.filter-title b{margin-right:auto}.filter-title button{border:1px solid #d8e1ec;background:#fff;border-radius:7px;padding:5px 7px;cursor:pointer;font-size:10px}.filter-help{color:#8491a4;font-size:10px;margin:0 0 8px}.check-list{border:1px solid var(--line);border-radius:10px;max-height:300px;overflow:auto;padding:7px}.check-list label{display:flex;align-items:center;gap:8px;padding:7px;border-radius:7px}.check-list label:hover{background:#f6f9fd}.check-list input{accent-color:#2563eb}.check-list small{color:#94a3b8;margin-left:auto}.check-list .none{color:#94a3b8;padding:10px}dialog menu{display:flex;justify-content:flex-end;gap:8px;padding:15px 0 0;margin:0}.muted{background:#e8eef6!important;color:#40516a!important}@media(max-width:1000px){.summary-grid{grid-template-columns:repeat(2,1fr)}.filter-columns{grid-template-columns:1fr}.topbar{height:auto;padding:10px;align-items:flex-start}.topbar nav{flex-wrap:wrap}.monitor-toolbar{align-items:flex-start}.toolbar-actions{flex-wrap:wrap}table{min-width:900px}}
/* V8.43 - grupos fixos por atendente */
.attendant-group-row td{background:#eef4ff!important;border-top:2px solid #d8e5fb;border-bottom:1px solid #d8e5fb;padding:8px 12px!important;position:sticky;top:0;z-index:2}
.attendant-group-head{display:flex;align-items:center;gap:12px;flex-wrap:wrap;color:#17315e}
.attendant-group-head strong{font-size:13px}
.attendant-group-head span{font-size:11px;background:#fff;border:1px solid #dbe5f2;border-radius:999px;padding:3px 8px}
.attendant-group-head .group-danger{color:#c62828;background:#fff1f1;border-color:#ffd0d0}
.active-card .table-wrap{overflow-anchor:none}


/* V8.55 - monitor-only */
.active-card .table-wrap{min-height:500px;max-height:70vh;overflow-anchor:none}.active-card{min-height:575px}.active-card table{min-width:1050px}.monitor-login{min-height:100vh;display:grid;place-items:center;background:radial-gradient(circle at top,#1e3a5f 0,#0b1220 48%,#080d16 100%)}.login-card{width:min(420px,92vw);background:#fff;border-radius:18px;padding:30px;box-shadow:0 30px 90px #0008}.login-logo{width:54px;height:54px;border-radius:15px;display:grid;place-items:center;background:#2563eb;color:#fff;font-size:26px;font-weight:900}.login-card h1{margin:16px 0 5px}.login-card p{margin:0 0 20px;color:#718096}.login-card label{display:block;font-size:11px;font-weight:800;color:#475569;margin:12px 0}.login-card input{width:100%;border:1px solid #cbd5e1;border-radius:9px;padding:11px;margin-top:6px}.login-card button{width:100%;border:0;background:#2563eb;color:#fff;border-radius:10px;padding:12px;font-weight:900;cursor:pointer}.login-error{background:#fff1f2;color:#b91c1c;border:1px solid #fecdd3;padding:10px;border-radius:9px;margin-bottom:10px}@media(max-height:900px){.active-card .table-wrap{min-height:420px;max-height:64vh}}@media(max-height:760px){.active-card .table-wrap{min-height:340px;max-height:58vh}}


/* V8.58 - Em atendimento ocupa melhor o espaço horizontal */
.active-card table{min-width:0;width:100%;table-layout:fixed}
.active-card col.col-client{width:17%}
.active-card col.col-dept{width:15%}
.active-card col.col-agent{width:16%}
.active-card col.col-message{width:34%}
.active-card col.col-age{width:9%}
.active-card col.col-status{width:9%}

.active-card th,
.active-card td{padding-left:10px;padding-right:10px}

.active-card .last-message{width:100%;min-width:0}
.active-card .last-message p{
  margin:0;
  white-space:normal;
  overflow:hidden;
  text-overflow:clip;
  display:-webkit-box;
  -webkit-box-orient:vertical;
  -webkit-line-clamp:2;
  line-clamp:2;
  line-height:1.35;
  min-height:1.35em;
  overflow-wrap:anywhere;
  word-break:break-word;
}
.active-card .client-cell,
.active-card td:nth-child(2),
.active-card td:nth-child(3){overflow:hidden}
.active-card .client-cell b,
.active-card td:nth-child(3)>b{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.active-card .dept-pill{
  max-width:100%;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  vertical-align:middle;
}
.active-card td:nth-child(5),
.active-card th:nth-child(5),
.active-card td:nth-child(6),
.active-card th:nth-child(6){white-space:nowrap}

@media (min-width:1500px){
  .active-card col.col-client{width:16%}
  .active-card col.col-dept{width:14%}
  .active-card col.col-agent{width:15%}
  .active-card col.col-message{width:38%}
  .active-card col.col-age{width:8%}
  .active-card col.col-status{width:9%}
}
@media (max-width:1000px){
  .active-card table{min-width:980px}
  .active-card col.col-client{width:170px}
  .active-card col.col-dept{width:145px}
  .active-card col.col-agent{width:155px}
  .active-card col.col-message{width:330px}
  .active-card col.col-age{width:95px}
  .active-card col.col-status{width:95px}
}


/* V8.59 - mensagem completa, sem limite de linhas */
.active-card .last-message p{
  display:block !important;
  white-space:pre-line !important;
  overflow:visible !important;
  text-overflow:clip !important;
  -webkit-line-clamp:unset !important;
  line-clamp:unset !important;
  -webkit-box-orient:unset !important;
  max-height:none !important;
  min-height:0 !important;
  line-height:1.35;
  overflow-wrap:anywhere;
  word-break:break-word;
}
.active-card tbody tr:not(.attendant-group-row) td{
  height:auto;
  min-height:48px;
  vertical-align:middle;
}
.active-card .last-message{
  padding-top:2px;
  padding-bottom:2px;
}


/* V8.61 - Última mensagem como coluna principal */
.active-card col.col-client{width:15% !important}
.active-card col.col-dept{width:11% !important}
.active-card col.col-agent{width:14% !important}
.active-card col.col-message{width:47% !important}
.active-card col.col-age{width:7% !important}
.active-card col.col-status{width:6% !important}

.active-card th:nth-child(1),
.active-card td:nth-child(1){padding-left:10px;padding-right:7px}
.active-card th:nth-child(2),
.active-card td:nth-child(2),
.active-card th:nth-child(3),
.active-card td:nth-child(3){padding-left:7px;padding-right:7px}
.active-card th:nth-child(4),
.active-card td:nth-child(4){padding-left:8px;padding-right:8px}
.active-card th:nth-child(5),
.active-card td:nth-child(5),
.active-card th:nth-child(6),
.active-card td:nth-child(6){padding-left:5px;padding-right:5px}

.active-card .last-message p{
  width:100%;
  max-width:none !important;
}
.active-card .last-message{
  max-width:none !important;
}

/* Em monitor largo, mensagem ganha ainda mais espaço */
@media (min-width:1250px){
  .active-card col.col-client{width:14% !important}
  .active-card col.col-dept{width:10% !important}
  .active-card col.col-agent{width:13% !important}
  .active-card col.col-message{width:51% !important}
  .active-card col.col-age{width:6% !important}
  .active-card col.col-status{width:6% !important}
}

/* Mantém leitura boa em telas menores */
@media (max-width:1000px){
  .active-card table{min-width:1050px}
  .active-card col.col-client{width:150px !important}
  .active-card col.col-dept{width:120px !important}
  .active-card col.col-agent{width:140px !important}
  .active-card col.col-message{width:470px !important}
  .active-card col.col-age{width:80px !important}
  .active-card col.col-status{width:90px !important}
}
