/* ==========================================================================
   MIA 2.0 — Painel de Atendimento
   Identidade visual: Design System MSE "Capex Seguro"
   - Tema claro (padrão MSE) e tema escuro opcional (html[data-theme="dark"]).
   - Layout em tela cheia: cabeçalho compacto + lista e conversa ocupando a janela.
   ========================================================================== */

:root {
  /* tokens MSE */
  --bg: #e8eaee; --card: #fff; --line: #e4e7ec; --line-2: #eef0f3; --chip: #eef0f3;
  --navy: #16243c; --navy-2: #1f3a63;
  --ink: #192231; --body: #4d5868; --mut: #98a1b0; --mut-2: #aab2bf;
  --blue: #2563eb; --green: #1f9d57; --amber: #d9911a; --red: #d23b3b;
  --r: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.04);
  --shadow-pop: 0 6px 20px -8px rgba(16,24,40,.18), 0 1px 3px rgba(16,24,40,.04);

  /* superfícies auxiliares */
  --card-2: #fbfcfd;
  --hover: #f1f3f5;
  --seg-bg: #dde1e7; --seg-tx: #5a6573;
  --input-bg: #fff;
  --search-bg: #eef0f3; --search-hover: #e3e6ea;
  --title: #394263; --title-sub: #9aa0b5;
  --ico-a: #4d5a89; --ico-b: #394263;
  --thumb: #dfe3e8;
  --backdrop: rgba(22,36,60,.45);

  /* tints semânticos */
  --ok-bg: rgba(31,157,87,.10);   --ok-tx: #197a45;
  --warn-bg: rgba(217,145,26,.12); --warn-tx: #b8780f;
  --crit-bg: rgba(210,59,59,.09); --crit-tx: #bf3a3a;
  --blue-bg: #e9f1fe;             --blue-tx: #1a4fd6;

  /* balões */
  --b-in: #fff;      --b-in-line: #e4e7ec;
  --b-bot: #f4f5f7;  --b-bot-line: #eceef1;
  --b-ai: #f2f6fe;   --b-ai-line: #dde7fb;
  --b-op: #e9f1fe;   --b-op-line: #d3e1fc;

  /* avatares */
  --av-1-bg: #e9f1fe; --av-1-tx: #1a4fd6;
  --av-2-bg: #eef0f3; --av-2-tx: #394263;
  --av-3-bg: #e7f3ec; --av-3-tx: #197a45;
  --av-4-bg: #eef3fe; --av-4-tx: #2563eb;
  --av-5-bg: #edf0f7; --av-5-tx: #4d5a89;
  --av-6-bg: #f3f4f6; --av-6-tx: #4d5868;

  --sans: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  color-scheme: light;
}

/* ------------------------------------------------------- tema escuro --- */
html[data-theme="dark"] {
  --bg: #0d1420; --card: #141d2c; --line: #243045; --line-2: #1c2638; --chip: #1f2a3d;
  --ink: #e6ebf3; --body: #b3bdcc; --mut: #8492a8; --mut-2: #66758c;
  --blue: #3b82f6;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 1px 3px rgba(0,0,0,.25);
  --shadow-pop: 0 10px 30px -10px rgba(0,0,0,.6), 0 1px 3px rgba(0,0,0,.3);
  --card-2: #18233a;
  --hover: #1b2639;
  --seg-bg: #0f1725; --seg-tx: #9aa6b8;
  --input-bg: #0f1725;
  --search-bg: #0f1725; --search-hover: #1f2a3d;
  --title: #e6ebf3; --title-sub: #8492a8;
  --ico-a: #3a4a7a; --ico-b: #24304f;
  --thumb: #2a364b;
  --backdrop: rgba(0,0,0,.6);
  --ok-bg: rgba(31,157,87,.18);   --ok-tx: #5fd394;
  --warn-bg: rgba(217,145,26,.18); --warn-tx: #f1b44c;
  --crit-bg: rgba(210,59,59,.18); --crit-tx: #f08a8a;
  --blue-bg: rgba(59,130,246,.16); --blue-tx: #8db4ff;
  --b-in: #18233a;   --b-in-line: #243045;
  --b-bot: #1b2536;  --b-bot-line: #243045;
  --b-ai: #172540;   --b-ai-line: #22365c;
  --b-op: #1a2d52;   --b-op-line: #26407a;
  --av-1-bg: rgba(59,130,246,.18); --av-1-tx: #8db4ff;
  --av-2-bg: #1f2a3d; --av-2-tx: #c3cbe0;
  --av-3-bg: rgba(31,157,87,.18); --av-3-tx: #5fd394;
  --av-4-bg: rgba(59,130,246,.12); --av-4-tx: #a9c4ff;
  --av-5-bg: #222c45; --av-5-tx: #aab4d6;
  --av-6-bg: #1c2638; --av-6-tx: #b3bdcc;
  color-scheme: dark;
}

/* ---------------------------------------------------------------- base --- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
kbd { font-family: var(--mono); font-size: 10px; color: var(--mut); background: var(--card); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }
.noscript { padding: 24px; text-align: center; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lbl { font-family: var(--mono); font-size: 9.5px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; color: var(--mut); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--thumb); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------------------------------------- spinner --- */
.spinner { display: inline-block; width: 14px; height: 14px; flex: none; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; opacity: .8; }
.spinner-sm { width: 11px; height: 11px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; color: var(--blue); }
@keyframes spin { to { transform: rotate(360deg); } }
.btn .spinner, .icon-btn .spinner { display: none; }
.is-loading .spinner { display: inline-block; }
.is-loading > svg, .is-loading > .icon { display: none; }

/* ------------------------------------------------------------- botões --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 9px; padding: 8px 12px; cursor: pointer; color: #fff; white-space: nowrap; font-family: var(--mono); font-size: 10.5px; letter-spacing: .7px; text-transform: uppercase; font-weight: 600; text-decoration: none; transition: filter .15s, transform .15s; }
.btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover:not(:disabled) { filter: brightness(1.07); transform: translateY(-1px); }
.btn:disabled, .btn.is-loading { opacity: .5; cursor: not-allowed; transform: none; filter: none; }
.btn-blue   { background: linear-gradient(135deg,#2563eb,#1a4fd6); box-shadow: 0 8px 20px -6px rgba(37,99,235,.75); }
.btn-green  { background: linear-gradient(135deg,#1f9d57,#157a42); box-shadow: 0 8px 20px -6px rgba(31,157,87,.75); }
.btn-orange { background: linear-gradient(135deg,#d9911a,#b8780f); box-shadow: 0 8px 20px -6px rgba(217,145,26,.75); }
.btn-red    { background: linear-gradient(135deg,#d23b3b,#b02a2a); box-shadow: 0 8px 20px -6px rgba(210,59,59,.75); }
.btn-gray   { background: linear-gradient(135deg,#5a6578,#3d4654); box-shadow: 0 8px 20px -6px rgba(61,70,84,.75); }
.btn-black  { background: linear-gradient(135deg,#2a3140,#192231); box-shadow: 0 8px 20px -6px rgba(25,34,49,.75); }
html[data-theme="dark"] .btn { box-shadow: none; }
html[data-theme="dark"] .btn-gray { background: linear-gradient(135deg,#3a4558,#2b3444); }
.btn-sm { padding: 8px 11px; }
.btn-xs { padding: 6px 10px; font-size: 10px; box-shadow: none; }
.btn-lg { padding: 13px 16px; font-size: 11.5px; }
.btn-block { width: 100%; }

.icon-btn { width: 36px; height: 36px; flex: none; border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--mut); display: grid; place-items: center; transition: .15s; }
.icon-btn:hover { color: var(--blue); border-color: var(--blue); }
.icon-btn .icon { width: 17px; height: 17px; }
.icon-btn-sm { width: 30px; height: 30px; }
.icon-btn-sm .icon { width: 15px; height: 15px; }
#theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] #theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] #theme-toggle .icon-sun { display: block; }
#mute-toggle .icon-bell-off { display: none; }
#mute-toggle[aria-pressed="true"] .icon-bell { display: none; }
#mute-toggle[aria-pressed="true"] .icon-bell-off { display: block; }

/* ------------------------------------------------------- tags / status --- */
.tag { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .8px; text-transform: uppercase; padding: 4px 9px; border-radius: 7px; background: var(--chip); color: var(--body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 0; }
.tag .d { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.tag.ok   { background: var(--ok-bg);   color: var(--ok-tx); }
.tag.warn { background: var(--warn-bg); color: var(--warn-tx); }
.tag.crit { background: var(--crit-bg); color: var(--crit-tx); }
.tag.sim  { background: var(--blue-bg); color: var(--blue-tx); }
.conn-status { cursor: pointer; }
.tag-wait    { background: var(--warn-bg); color: var(--warn-tx); }
.tag-wait.is-late { background: var(--crit-bg); color: var(--crit-tx); }
.tag-robo    { background: var(--chip); color: var(--body); }
.tag-subject { background: var(--card-2); color: var(--body); border: 1px solid var(--line); text-transform: none; letter-spacing: 0; font-family: var(--sans); font-size: 11.5px; }
.tag-ia      { background: var(--blue-bg); color: var(--blue-tx); }
.tag-mine    { background: var(--ok-bg); color: var(--ok-tx); }

.chip { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 9.5px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; background: var(--chip); color: var(--body); white-space: nowrap; }
.chip-ia   { background: var(--blue-bg); color: var(--blue-tx); }
.chip-auto { background: var(--chip); color: var(--body); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; padding: 4px 9px; border-radius: 7px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-pre_triagem, .badge-triagem_ia { background: var(--chip); color: var(--body); }
.badge-aguardando_humano { background: var(--warn-bg); color: var(--warn-tx); }
.badge-em_atendimento    { background: var(--blue-bg); color: var(--blue-tx); }
.badge-concluido         { background: var(--ok-bg);   color: var(--ok-tx); }

.alert { padding: 10px 12px; border-radius: 10px; font-size: 13px; margin: 0; }
.alert-info  { background: var(--blue-bg); color: var(--blue-tx); }
.alert-error { background: var(--crit-bg); color: var(--crit-tx); }

/* ---------------------------------------------------------------- marca --- */
.brand-mark { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 36px; height: 36px; border-radius: 10px; overflow: hidden; background: linear-gradient(180deg,var(--ico-a),var(--ico-b)); color: #fff; font-weight: 700; font-size: 13px; letter-spacing: .5px; }
.brand-mark.has-logo { background: transparent; }
.brand-mark-lg { width: 64px; height: 64px; border-radius: 22px; font-size: 18px; box-shadow: inset 0 1px 1px rgba(255,255,255,.3), inset 0 -2px 4px rgba(0,0,0,.25), 0 8px 18px -6px rgba(57,66,99,.25); }
.brand-logo { width: 100%; height: 100%; object-fit: contain; }

/* -------------------------------------------------------- carregamento --- */
.boot { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.boot-card { text-align: center; max-width: 380px; display: grid; justify-items: center; gap: 10px; }
.boot-message { margin: 6px 0 0; font-family: var(--mono); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--mut); }
.boot-detail { margin: 0; color: var(--body); font-size: 13px; }
.boot-error-icon { display: none; width: 34px; height: 34px; color: var(--crit-tx); }
.boot-card.is-error .boot-spinner { display: none; }
.boot-card.is-error .boot-error-icon { display: block; }

/* --------------------------------------------------- entrada (nome) --- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.login-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 30px 28px 22px; }
.login-header { text-align: center; margin-bottom: 20px; }
.login-brand { margin: 14px 0 0; font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 2px; text-transform: uppercase; color: var(--mut); }
.login-title { margin: 6px 0; font-size: 22px; font-weight: 600; color: var(--title); }
.login-subtitle { margin: 0; color: var(--title-sub); font-size: 13.5px; }
.login-form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: 1.2px; text-transform: uppercase; color: var(--mut); }
.field input { width: 100%; height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--input-bg); color: var(--ink); font-size: 14.5px; transition: border-color .15s, box-shadow .15s; }
.field input::placeholder { color: var(--mut-2); }
.field input:focus, .search-input:focus, .composer-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.input-group { position: relative; }
.input-group input { padding-right: 46px; }
.input-addon { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--mut); display: grid; place-items: center; }
.input-addon:hover { color: var(--blue); }
.input-addon .icon-eye-off { display: none; }
.input-addon[aria-pressed="true"] .icon-eye { display: none; }
.input-addon[aria-pressed="true"] .icon-eye-off { display: block; }
.login-footer { display: flex; gap: 8px; align-items: flex-start; margin: 20px 0 0; padding-top: 14px; border-top: 1px solid var(--line-2); color: var(--mut); font-size: 12.5px; }
.login-footer .icon { width: 15px; height: 15px; margin-top: 2px; }

/* ================================================ PAINEL (tela cheia) === */
.app { height: 100vh; min-height: 560px; display: flex; flex-direction: column; overflow: hidden; }

/* cabeçalho compacto (padrão .pheader do portal, em uma linha) */
.pwrap { flex: none; width: 100%; }
.pheader { display: flex; align-items: center; gap: 14px; padding: 10px 18px; background: var(--card); border-bottom: 1px solid var(--line); }
.pheader-ico { flex: none; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; color: #fff; background: linear-gradient(180deg,var(--ico-a) 0%,var(--ico-b) 100%); border-radius: 13px; box-shadow: inset 0 1px 1px rgba(255,255,255,.3), inset 0 -2px 4px rgba(0,0,0,.25), 0 6px 14px -6px rgba(57,66,99,.35); }
.pheader-ico svg { width: 20px; height: 20px; stroke-width: 1.8; filter: drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
/* logo MSE no canto superior esquerdo */
.pheader-logo { display: block; flex: none; height: 22px; width: auto; }
.pheader-sep { flex: none; width: 1px; height: 30px; background: var(--line); }
.pheader-title { min-width: 0; }
.pheader-title h1 { margin: 0; font-size: 18px; font-weight: 600; color: var(--title); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pheader-title small { display: block; margin-top: 1px; font-size: 12.5px; font-weight: 400; color: var(--title-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pheader-bar { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px 14px; font-size: 13px; }
.pheader-nav { display: flex; align-items: center; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.pheader-nav li { color: var(--title); font-weight: 600; }
.pheader-nav li + li::before { content: "\203A"; margin: 0 8px; color: var(--title-sub); font-weight: 400; }
.pheader-nav li a { color: #1f6fde; text-decoration: none; font-weight: 600; }
.pheader-btns { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.operator { display: flex; align-items: center; gap: 9px; padding: 0 6px 0 12px; border-left: 1px solid var(--line-2); }
.operator-info { display: grid; line-height: 1.2; }
.operator-name { font-weight: 600; font-size: 13px; color: var(--ink); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.operator-email { font-family: var(--mono); font-size: 9.5px; letter-spacing: .5px; color: var(--mut); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; border-radius: 10px; font-weight: 700; font-size: 13px; letter-spacing: .5px; background: var(--av-2-bg); color: var(--av-2-tx); }
.avatar-sm { width: 32px; height: 32px; font-size: 11.5px; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.avatar.tone-1 { background: var(--av-1-bg); color: var(--av-1-tx); }
.avatar.tone-2 { background: var(--av-2-bg); color: var(--av-2-tx); }
.avatar.tone-3 { background: var(--av-3-bg); color: var(--av-3-tx); }
.avatar.tone-4 { background: var(--av-4-bg); color: var(--av-4-tx); }
.avatar.tone-5 { background: var(--av-5-bg); color: var(--av-5-tx); }
.avatar.tone-6 { background: var(--av-6-bg); color: var(--av-6-tx); }

/* área de trabalho: ocupa toda a janela abaixo do cabeçalho */
.layout { flex: 1 1 0; min-height: 0; display: grid; grid-template-columns: var(--side-w, 360px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }

/* ------------------------------------------------------------- lista --- */
.sidebar { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--card); border-right: 1px solid var(--line); }
.sidebar-top { padding: 14px 14px 10px; border-bottom: 1px solid var(--line-2); }
.search { position: relative; }
.search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--mut); pointer-events: none; }
.search-input { width: 100%; height: 40px; padding: 0 38px; border-radius: 999px; border: 1px solid transparent; background: var(--search-bg); color: var(--ink); font-size: 13.5px; transition: border-color .15s, box-shadow .15s, background .15s; }
.search-input:focus { background: var(--input-bg); }
.search-input::placeholder { color: var(--mut-2); }
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; border-radius: 999px; background: transparent; color: var(--mut); display: grid; place-items: center; }
.search-clear:hover { color: var(--ink); background: var(--search-hover); }
.search-clear .icon { width: 15px; height: 15px; }

.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; margin-top: 12px; padding: 3px; background: var(--seg-bg); border-radius: 10px; }
.tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; padding: 6px 3px 5px; border: 0; border-radius: 8px; background: transparent; color: var(--seg-tx); transition: .15s; }
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--blue); color: #fff; box-shadow: 0 1px 3px rgba(37,99,235,.4); }
.tab-dot { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; }
.tab-aguardando .tab-dot { background: var(--amber); }
.tab-atendimento .tab-dot { background: var(--blue); }
.tab-robo .tab-dot { background: var(--mut-2); }
.tab-concluidos .tab-dot { background: var(--green); }
.tab.is-active .tab-dot { background: #fff; opacity: .8; }
.tab-label { display: flex; align-items: center; justify-content: center; min-height: 2.4em; max-width: 100%; padding: 0 2px; font-family: var(--mono); font-size: 9px; font-weight: 500; letter-spacing: .6px; text-transform: uppercase; line-height: 1.2; text-align: center; white-space: normal; }
.tab-count { font-size: 16px; font-weight: 700; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.tab-aguardando:not(.is-active) .tab-count.has-items { color: var(--warn-tx); }
.sort-row { margin-top: 10px; }
.sort-row .sort-seg { display: flex; width: 100%; }
.sort-row .sort-btn { flex: 1; }
.sort-label { font-family: var(--mono); font-size: 9px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; color: var(--mut); }
.sort-seg { display: inline-flex; flex: none; padding: 2px; background: var(--seg-bg); border-radius: 8px; }
.sort-btn { border: 0; border-radius: 6px; padding: 5px 9px; background: transparent; color: var(--seg-tx); font-family: var(--mono); font-size: 9.5px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; transition: .15s; }
.sort-btn:hover { color: var(--ink); }
.sort-btn[aria-pressed="true"] { background: var(--card); color: var(--blue-tx); box-shadow: var(--shadow); }
.list-caption { margin: 9px 2px 0; font-family: var(--mono); font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--mut-2); }

.ticket-panel { position: relative; flex: 1; min-height: 0; overflow-y: auto; }

.list-progress { position: sticky; top: 0; height: 2px; z-index: 2; }
.ticket-panel.is-refreshing .list-progress { background: linear-gradient(90deg, transparent, var(--blue), transparent); background-size: 200% 100%; animation: progress 1s linear infinite; }
@keyframes progress { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.ticket-list { list-style: none; margin: 0; padding: 6px 8px; }
.ticket-list li + li { border-top: 1px solid var(--line-2); }
.ticket { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 11px; width: 100%; padding: 12px 10px; border: 0; border-radius: 12px; background: transparent; text-align: left; color: inherit; transition: background-color .13s; }
.ticket:hover { background: var(--hover); }
.ticket.is-selected { background: var(--blue-bg); }
.ticket.is-selected .ticket-name { color: var(--blue-tx); }
.ticket-main { min-width: 0; display: grid; gap: 2px; }
.ticket-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ticket-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; color: var(--ink); }
.ticket-time { margin-left: auto; flex: none; font-family: var(--mono); font-size: 10px; color: var(--mut); white-space: nowrap; }
.ticket.has-unread .ticket-time { color: var(--blue); font-weight: 600; }
.ticket-company { font-family: var(--mono); font-size: 10px; letter-spacing: .6px; text-transform: uppercase; color: var(--mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-preview { flex: 1; min-width: 0; color: var(--body); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket.has-unread .ticket-preview { color: var(--ink); font-weight: 600; }
.ticket-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.ticket-tags .tag { padding: 3px 7px; font-size: 9.5px; }
.ticket-tags .tag-subject { font-size: 11px; }
.unread { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--blue); color: #fff; font-family: var(--mono); font-size: 10px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }

.list-loading { padding: 8px; }
.skeleton-card { display: flex; gap: 11px; padding: 12px 10px; }
.skeleton { display: block; background: var(--chip); border-radius: 6px; animation: pulse-bg 1.4s ease-in-out infinite; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.skeleton-lines { flex: 1; display: grid; gap: 7px; align-content: center; }
.skeleton-line { height: 9px; }
.w-30 { width: 30%; } .w-40 { width: 40%; } .w-50 { width: 50%; } .w-60 { width: 60%; } .w-70 { width: 70%; } .w-80 { width: 80%; } .w-90 { width: 90%; }
@keyframes pulse-bg { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

.empty-state { display: grid; justify-items: center; text-align: center; gap: 6px; margin: 14px; padding: 30px 20px; border: 1px dashed var(--line); border-radius: 10px; }
.empty-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--chip); color: var(--mut); margin-bottom: 4px; }
.empty-icon .icon { width: 22px; height: 22px; }
.empty-state-error .empty-icon { background: var(--crit-bg); color: var(--crit-tx); }
.empty-title { margin: 0; font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 1.4px; text-transform: uppercase; color: var(--body); }
.empty-text { margin: 0 0 6px; font-size: 13px; color: var(--mut); max-width: 270px; }

/* ---------------------------------------------------------- conversa --- */
.chat { min-height: 0; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.chat-empty { flex: 1; display: grid; place-items: center; padding: 28px; overflow-y: auto; }
.chat-empty-inner { max-width: 560px; text-align: center; }
.chat-empty-art { width: 150px; height: auto; margin-bottom: 6px; }
.art-bg { fill: var(--card); }
.art-bubble-a { fill: var(--blue-bg); }
.art-bubble-b { fill: var(--blue); opacity: .85; }
.art-dot { fill: #fff; }
.art-line { fill: var(--blue); opacity: .35; }
.chat-empty-title { margin: 0 0 6px; font-size: 22px; font-weight: 600; color: var(--title); }
.chat-empty-text { margin: 0 auto 22px; color: var(--body); max-width: 420px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat { display: grid; gap: 4px; padding: 13px 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--card); transition: .15s; }
.stat:hover { border-color: var(--mut-2); box-shadow: var(--shadow-pop); transform: translateY(-2px); }
.stat-value { order: 2; font-size: 24px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; color: var(--ink); }
.stat-label { order: 1; font-family: var(--mono); font-size: 9.5px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; color: var(--mut); }
.stat-aguardando .stat-value { color: var(--amber); }
.stat-atendimento .stat-value { color: var(--blue); }
.stat-concluidos .stat-value { color: var(--green); }
.chat-empty-tip { margin: 20px 0 0; font-family: var(--mono); font-size: 10px; letter-spacing: .5px; color: var(--mut-2); }

.chat-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-header { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
.chat-back { display: none; }
.chat-ident { flex: 1; min-width: 0; }
.chat-title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-name { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; outline: none; }
.chat-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .3px; color: var(--mut); }
.meta-item { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.meta-item .icon { width: 13px; height: 13px; }
.chat-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* resumo da triagem — destaque */
.summary-card { flex: none; margin: 14px 20px 0; display: flex; flex-direction: column; max-height: 40vh; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: 12px; box-shadow: var(--shadow); }
.summary-card.is-auto { border-left-color: var(--mut-2); }
.summary-head { display: flex; align-items: center; gap: 10px; padding: 11px 14px 9px; }
.ia-icon { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 7px; background: var(--blue); color: #fff; font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .8px; }
.ia-icon .icon { width: 13px; height: 13px; }
.summary-heading { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.summary-title { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.2px; }
.summary-time { font-family: var(--mono); font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--mut); }
.summary-toggle .icon { transition: transform .2s; }
.summary-card.is-collapsed .summary-toggle .icon { transform: rotate(-90deg); }
.summary-card.is-collapsed .summary-body { display: none; }
.summary-body { padding: 0 14px 12px; overflow-y: auto; }
.summary-loading { display: grid; gap: 8px; padding: 4px 0 8px; }
.pt-chips { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pt-chip { display: grid; gap: 1px; max-width: 100%; padding: 6px 10px; background: var(--card-2); border: 1px solid var(--line); border-radius: 9px; }
.pt-chip b { font-family: var(--mono); font-size: 9px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; color: var(--mut); }
.pt-chip span { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.6; color: var(--ink); }
.summary-state { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 2px 0 6px; font-size: 13px; color: var(--body); }
.summary-state strong { font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; color: var(--mut); }
.summary-state-busy { color: var(--blue-tx); }
.summary-foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.summary-reason { font-family: var(--mono); font-size: 10px; letter-spacing: .5px; color: var(--mut); }
.summary-refresh { margin-left: auto; }

/* mensagens */
.chat-body { position: relative; flex: 1; min-height: 0; display: flex; }
.messages-scroll { flex: 1; overflow-y: auto; padding: 16px 20px 12px; }
.messages-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 30px; font-family: var(--mono); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--mut); }
.messages-empty { margin: 0; padding: 30px; text-align: center; font-family: var(--mono); font-size: 11px; letter-spacing: .5px; color: var(--mut-2); }
.messages { display: flex; flex-direction: column; gap: 4px; max-width: 980px; margin: 0 auto; }
.day-sep { align-self: center; margin: 14px 0 8px; font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: 1.4px; text-transform: uppercase; color: var(--mut-2); }
.msg { display: flex; flex-direction: column; max-width: min(76%, 640px); }
.msg-in { align-self: flex-start; }
.msg-out { align-self: flex-end; align-items: flex-end; }
.msg-sender { display: inline-flex; align-items: center; gap: 6px; margin: 8px 4px 3px; font-family: var(--mono); font-size: 9.5px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; color: var(--mut); }
.msg-continued .msg-sender { display: none; }
.msg-sender .chip { padding: 1px 6px; font-size: 8.5px; }
.bubble { position: relative; padding: 9px 12px 6px; border-radius: 12px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); background: var(--b-in); border: 1px solid var(--b-in-line); box-shadow: var(--shadow); }
.msg-in .bubble { border-top-left-radius: 4px; }
.msg-out .bubble { border-top-right-radius: 4px; }
.msg-bot .bubble { background: var(--b-bot); border-color: var(--b-bot-line); }
.msg-ai .bubble { background: var(--b-ai); border-color: var(--b-ai-line); }
.msg-operator .bubble { background: var(--b-op); border-color: var(--b-op-line); }
.msg-ai .msg-sender, .msg-operator .msg-sender { color: var(--blue-tx); }
.bubble a { color: var(--blue); word-break: break-all; }
html[data-theme="dark"] .bubble a { color: var(--blue-tx); }
.bubble code { font-family: var(--mono); font-size: 12.5px; background: var(--chip); padding: 1px 4px; border-radius: 4px; }
.bubble-time { display: block; margin-top: 3px; text-align: right; font-family: var(--mono); font-size: 9.5px; color: var(--mut); white-space: nowrap; }
.msg-media { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 2px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .5px; text-transform: uppercase; color: var(--body); }
.msg-media .icon { width: 14px; height: 14px; }
.msg-failed .bubble { border-color: rgba(210,59,59,.45); }
.msg-error { display: inline-flex; align-items: center; gap: 4px; margin: 4px 4px 0; font-family: var(--mono); font-size: 10px; color: var(--crit-tx); }
.msg-error .icon { width: 12px; height: 12px; }
.msg-system { align-self: center; max-width: 92%; margin: 8px 0; }
.msg-system .bubble { padding: 5px 12px; border: 1px dashed var(--line); border-radius: 999px; background: var(--card-2); box-shadow: none; text-align: center; font-size: 12px; color: var(--body); }
.msg-system .bubble-time { display: inline; margin-left: 8px; }
.msg.is-new { animation: msg-in .22s ease-out; }
@keyframes msg-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.new-messages-pill { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); border: 0; border-radius: 9px; padding: 8px 14px; background: linear-gradient(135deg,#2563eb,#1a4fd6); color: #fff; font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .7px; text-transform: uppercase; box-shadow: 0 8px 20px -6px rgba(37,99,235,.75); }

/* resposta */
.chat-footer { flex: none; padding: 12px 20px 14px; background: var(--card); border-top: 1px solid var(--line); }
.composer { display: flex; align-items: flex-end; gap: 10px; max-width: 980px; margin: 0 auto; }
.composer-input { flex: 1; min-height: 44px; max-height: 180px; resize: none; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--input-bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
.composer-input::placeholder { color: var(--mut-2); }
.composer-send { width: 46px; height: 44px; padding: 0; }
.composer-send svg { width: 16px; height: 16px; }
.composer-meta { display: flex; justify-content: space-between; max-width: 980px; margin: 6px auto 0; }
.composer-hint { margin: 0; font-family: var(--mono); font-size: 10px; color: var(--mut-2); }
.composer-count { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--mut); }
.composer-count.is-near { color: var(--warn-tx); }
.composer-blocked { display: flex; align-items: center; gap: 10px; max-width: 980px; margin: 0 auto; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; color: var(--body); font-size: 13px; }
.composer-blocked > .icon { color: var(--mut); }
.composer-blocked-text { flex: 1; }

/* ---------------------------------------------------------------- modal --- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: var(--backdrop); animation: fade .15s ease-out; }
.modal-dialog { position: relative; width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-pop); padding: 24px; animation: pop .16s ease-out; }
.modal-icon:empty { display: none; }
.modal-icon { width: 44px; height: 44px; margin-bottom: 12px; border-radius: 12px; display: grid; place-items: center; background: var(--blue-bg); color: var(--blue-tx); }
.modal-icon.is-success { background: var(--ok-bg); color: var(--ok-tx); }
.modal-icon.is-warning { background: var(--warn-bg); color: var(--warn-tx); }
.modal-icon .icon { width: 22px; height: 22px; }
.modal-title { margin: 0 0 6px; font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.modal-text { margin: 0; color: var(--body); }
.check-row { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card-2); cursor: pointer; font-size: 13.5px; }
.check-row input { width: 17px; height: 17px; accent-color: var(--blue); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

/* --------------------------------------------------------------- toasts --- */
.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 60; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-left: 3px solid var(--blue); border-radius: 12px; background: var(--card); color: var(--ink); font-size: 13.5px; box-shadow: var(--shadow-pop); animation: pop .18s ease-out; }
.toast .icon { margin-top: 1px; color: var(--blue); }
.toast-success { border-left-color: var(--green); }
.toast-success .icon { color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-error .icon { color: var(--crit-tx); }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }


/* ------------------------------------------- recolher / redimensionar --- */
.sidebar-toggle { margin-right: -2px; }
.sidebar-toggle[aria-pressed="true"] { color: var(--blue-tx); border-color: var(--blue); background: var(--blue-bg); }
.sidebar-resizer { position: absolute; top: 0; right: -4px; bottom: 0; width: 8px; z-index: 5; cursor: col-resize; touch-action: none; }
.sidebar-resizer::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background .15s; }
.sidebar-resizer:hover::after, .sidebar-resizer:focus-visible::after, .app.is-resizing .sidebar-resizer::after { background: var(--blue); }
.sidebar-resizer:focus-visible { outline: none; }
.app.is-resizing, .app.is-resizing * { cursor: col-resize !important; user-select: none !important; }
.app.side-collapsed .layout { grid-template-columns: 0 minmax(0, 1fr); }
.app.side-collapsed .sidebar { visibility: hidden; overflow: hidden; border-right: 0; }

/* seletor Atendimentos / Dashboard (toggle .seg do portal) */
.view-seg { display: inline-flex; flex: none; padding: 3px; background: var(--seg-bg); border-radius: 10px; }
.view-btn { border: 0; border-radius: 8px; padding: 6px 13px; background: transparent; color: var(--seg-tx); font-family: var(--mono); font-size: 10px; font-weight: 600; letter-spacing: .7px; text-transform: uppercase; transition: .15s; }
.view-btn:hover { color: var(--ink); }
.view-btn[aria-pressed="true"] { background: var(--blue); color: #fff; box-shadow: 0 1px 3px rgba(37,99,235,.4); }

/* ============================================================ DASHBOARD === */
.dashboard { flex: 1 1 0; min-height: 0; overflow-y: auto; }
.dash-inner { max-width: 1440px; margin: 0 auto; padding: 20px 24px 48px; }
.dash-head { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 4px; }
.dash-title h2 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.3px; }
.dash-updated { font-family: var(--mono); font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--mut); }
.dash-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#dash-refresh.is-loading .icon { display: none; }
#dash-refresh .spinner { display: none; }
#dash-refresh.is-loading .spinner { display: inline-block; }
.dash-body.is-loading { opacity: .55; transition: opacity .15s; }
.dash-sec { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 2px; text-transform: uppercase; color: var(--mut); margin: 26px 2px 12px; display: flex; align-items: center; gap: 12px; }
.dash-sec .ct { margin-left: auto; color: var(--mut-2); letter-spacing: .5px; }

/* KPIs: grade com divisórias de 1px (padrão .kpis do guia) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.kpi { background: var(--card); padding: 14px 15px; }
.kpi .lbl { display: block; margin-bottom: 7px; }
.kpi .kv { font-size: 24px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1.1; }
.kpi .kv.blue { color: var(--blue); } .kpi .kv.green { color: var(--green); } .kpi .kv.amber { color: var(--amber); }
.kpi .kd { font-family: var(--mono); font-size: 10px; margin-top: 5px; color: var(--mut); }

.dgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px 22px; min-width: 0; }
.dcard.wide { grid-column: 1 / -1; }
.chead { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; }
.chead .ti2 { font-weight: 700; font-size: 16px; letter-spacing: -.2px; }
.chead .lbl { margin-left: auto; }
.dempty { padding: 26px 16px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; font-family: var(--mono); font-size: 10.5px; letter-spacing: .5px; color: var(--mut-2); }

/* gráfico de barras agrupadas */
.legend { display: flex; gap: 20px; justify-content: center; margin-bottom: 6px; font-family: var(--mono); font-size: 10.5px; color: var(--body); letter-spacing: .3px; }
.legend i.sq { display: inline-block; width: 11px; height: 11px; border-radius: 3px; vertical-align: middle; margin-right: 7px; }
.legend i.gray { background: #c2c8d0; } .legend i.blu { background: var(--blue); } .legend i.amb { background: var(--amber); }
html[data-theme="dark"] .legend i.gray { background: #4a5568; }
.chart { display: block; width: 100%; height: 230px; }
.chart text { font-family: var(--mono); font-size: 10px; fill: var(--mut); }
.chart .val { fill: var(--body); font-weight: 600; }
.chart .gl-line { stroke: var(--line-2); stroke-width: 1; }
.chart .ax { stroke: var(--line); stroke-width: 1; }
.chart .bar-prev { fill: #c2c8d0; }
html[data-theme="dark"] .chart .bar-prev { fill: #4a5568; }
.chart .bar-real { fill: var(--blue); }

/* barras horizontais */
.hb { margin: 13px 0; }
.hb .hl { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.hb .hl .nm { color: var(--body); font-weight: 500; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb .hl .vv { font-family: var(--mono); font-size: 11px; color: var(--ink); font-weight: 600; white-space: nowrap; }
.hb .track { height: 12px; background: var(--chip); border-radius: 7px; overflow: hidden; }
.hb .fill { height: 100%; border-radius: 7px; width: 0; transition: width .9s cubic-bezier(.2,.7,.2,1); }

/* donut */
.donutrow { display: flex; align-items: center; gap: 22px; }
.donutrow svg { flex: none; }
.dcenter { display: grid; gap: 4px; }
.dbig { font-weight: 700; font-size: 36px; letter-spacing: -1px; line-height: 1; }
.dlegend { display: grid; gap: 8px; margin-top: 12px; font-family: var(--mono); font-size: 11px; color: var(--body); }
.dlegend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 8px; vertical-align: middle; }
.dlegend b { color: var(--ink); font-weight: 600; margin-left: 6px; }

/* tabela de atendentes */
.op-table { width: 100%; border-collapse: collapse; }
.op-table th { text-align: left; padding: 0 0 8px; font-family: var(--mono); font-size: 9.5px; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; color: var(--mut); }
.op-table th.n, .op-table td.n { text-align: right; }
.op-table td { padding: 10px 0; border-top: 1px solid var(--line-2); font-size: 13.5px; color: var(--body); }
.op-table td.nm { font-weight: 600; color: var(--ink); }
.op-table td.n { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink); }

@media (max-width: 980px) { .dgrid { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .sidebar-toggle, .sidebar-resizer { display: none; }
  .app.side-collapsed .layout { grid-template-columns: 1fr; }
  .app.side-collapsed .sidebar { visibility: visible; }
  .view-btn { padding: 6px 9px; }
}
@media (max-width: 560px) {
  .dash-inner { padding: 14px 12px 32px; }
  .donutrow { flex-direction: column; align-items: flex-start; }
}


/* ======================================================= TREINAMENTO === */
/* botão "Treinar" nas respostas da conversa */
.msg-train { display: inline-flex; align-items: center; gap: 5px; margin: 4px 4px 0; padding: 3px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); color: var(--mut); font-family: var(--mono); font-size: 9.5px; font-weight: 600; letter-spacing: .7px; text-transform: uppercase; opacity: 0; transition: opacity .15s, color .15s, border-color .15s; }
.msg-train .icon { width: 12px; height: 12px; }
.msg:hover .msg-train, .msg-train:focus-visible { opacity: 1; }
.msg-train:hover { color: var(--blue-tx); border-color: var(--blue); }
.msg-train.is-trained { opacity: 1; cursor: default; color: var(--ok-tx); background: var(--ok-bg); border-color: transparent; }
@media (hover: none) { .msg-train { opacity: 1; } }

.modal-wide { max-width: 600px; }
.train-loading { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-family: var(--mono); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--mut); }
.train-form { display: grid; gap: 14px; margin-top: 16px; }
.train-form textarea, .kb-edit textarea, .kb-edit input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--input-bg); color: var(--ink); font-size: 14px; line-height: 1.45; resize: vertical; }
.train-form textarea:focus, .kb-edit textarea:focus, .kb-edit input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.train-suggestion { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; font-size: 13px; color: var(--body); }
.train-suggestion .train-new { width: 100%; margin-top: 2px; }
.train-form .modal-actions { margin-top: 4px; }
#train-submit .spinner { display: none; }
#train-submit.is-loading .spinner { display: inline-block; }

/* tela de treinamento */
.kb-search { width: 260px; }
.kb-search .search-input { height: 36px; }
#kb-refresh.is-loading .icon { display: none; }
#kb-refresh .spinner { display: none; }
#kb-refresh.is-loading .spinner { display: inline-block; }
.kb-list { display: grid; gap: 12px; }
.kb-topic { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 18px; }
.kb-topic-head { display: flex; align-items: flex-start; gap: 12px; }
.kb-topic-title { flex: 1; min-width: 0; margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.2px; color: var(--ink); }
.kb-tags { display: flex; flex-wrap: wrap; gap: 6px; flex: none; }
.kb-answer { margin: 10px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.55; color: var(--body); }
.kb-meta { margin-top: 10px; font-family: var(--mono); font-size: 9.5px; letter-spacing: .8px; text-transform: uppercase; color: var(--mut); }
.kb-err { margin-top: 8px; font-family: var(--mono); font-size: 10.5px; color: var(--crit-tx); }
.kb-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.kb-edit { display: grid; gap: 10px; margin-top: 12px; }
.kb-examples { margin-top: 12px; border-top: 1px solid var(--line-2); }
.kb-example { padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.kb-example:last-child { border-bottom: 0; }
.kb-example .q { color: var(--ink); font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }
.kb-example .a { margin-top: 4px; color: var(--body); white-space: pre-wrap; overflow-wrap: anywhere; }
.kb-example .lbl { display: block; margin-top: 6px; }
@media (max-width: 720px) { .kb-search { width: 100%; } .dash-tools { width: 100%; } .kb-topic-head { flex-direction: column; } }

/* ----------------------------------------------------------- responsivo --- */
@media (max-width: 1180px) {
  .operator-info { display: none; }
}
@media (max-width: 920px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .pheader-title small { display: none; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr !important; }
  .sidebar { border-right: 0; }
  .chat { display: none; }
  .app.show-chat .sidebar { display: none; }
  .app.show-chat .chat { display: flex; }
  .chat-back { display: grid; }
  .chat-actions { width: 100%; }
  .chat-actions .btn { flex: 1; }
  .summary-card { margin: 12px 12px 0; max-height: 30vh; }
  .messages-scroll { padding: 12px; }
  .chat-header, .chat-footer { padding-left: 12px; padding-right: 12px; }
  .msg { max-width: 88%; }
  .composer-hint { display: none !important; }
}
@media (max-width: 820px) {
  .pheader-btns .btn-label { display: none; }
}
@media (max-width: 560px) {
  .pheader { padding: 8px 12px; gap: 10px; }
  .pheader-sep, .pheader-title small { display: none; }
  .pheader-logo { height: 18px; }
  .pheader-title h1 { font-size: 16px; }
  .operator { border-left: 0; padding: 0; }
  .pheader-btns { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
