:root {
  --fs: 1.15;
  --bg: #f0f2f5; --panel: #ffffff; --panel2: #f7f8fa; --line: #e2e5ea; --text: #111b21; --muted: #667781;
  --accent: #453796; --accent-ink: #ffffff; --accent-soft: #e9e7f6; --in: #ffffff; --out: #e9e7f6; --accent2: #00aaf0;
  --danger: #d9303a; --warn: #b45309; --warn-bg: #fef3c7; --blue: #0a7fc4; --read: #00aaf0; --shadow: 0 1px 2px rgba(0,0,0,.12);
  --radius: 10px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0e1c; --panel: #17152b; --panel2: #1e1c38; --line: #2f2c52; --text: #ecebf8; --muted: #a29fc8;
    --accent: #a79bf2; --accent-ink: #120f2e; --accent-soft: #262051; --in: #1e1c38; --out: #3a2f85; --accent2: #36c0ff;
    --danger: #ff7b82; --warn: #fbbf24; --warn-bg: #3a2e0b; --blue: #5cc8ff; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f0e1c; --panel: #17152b; --panel2: #1e1c38; --line: #2f2c52; --text: #ecebf8; --muted: #a29fc8;
  --accent: #a79bf2; --accent-ink: #120f2e; --accent-soft: #262051; --in: #1e1c38; --out: #3a2f85; --accent2: #36c0ff;
  --danger: #ff7b82; --warn: #fbbf24; --warn-bg: #3a2e0b; --blue: #5cc8ff; --shadow: none;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: calc(14px * var(--fs, 1)); line-height: 1.45; }
#app { height: 100%; display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: calc(18px * var(--fs, 1)); } h3 { font-size: calc(15px * var(--fs, 1)); margin-bottom: 10px; }

.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 14px; }
.btn:hover { background: var(--panel2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 10px; font-size: calc(13px * var(--fs, 1)); }
.btn.danger { color: var(--danger); }
.btn[disabled] { opacity: .55; cursor: default; }
input[type=text], input[type=email], input[type=number], input[type=password], input[type=url], input[type=time], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); min-height: 36px;
}
select { width: auto; }

/* casca */
.top { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; flex-wrap: wrap; }
.brand { color: var(--accent); font-size: calc(18px * var(--fs, 1)); }
.logo { height: 38px; width: auto; display: block; background: #fff; border-radius: 8px; padding: 2px 6px; }
.logo-login { height: 84px; width: auto; display: block; margin: 0 auto 12px; background: #fff; border-radius: 10px; padding: 4px 10px; }
.top .brand { display: none; }
.bell { min-width: 34px; }
.fs-btn { min-width: 30px; font-weight: 700; }
.bell[hidden] { display: none; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tab { border: 0; background: none; padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tab.on { background: var(--accent-soft); color: var(--text); }
.me { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.main { flex: 1; min-height: 0; overflow: auto; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.empty.small { padding: 12px; font-size: calc(13px * var(--fs, 1)); }
.hint { color: var(--muted); margin: 8px 0 14px; }

/* inbox */
.inbox { display: grid; grid-template-columns: 360px 1fr; height: 100%; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.chips { display: flex; gap: 6px; padding: 10px 12px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 4px 12px; font-size: calc(13px * var(--fs, 1)); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); }
.conv-list { overflow: auto; flex: 1; }
.conv { display: flex; gap: 12px; width: 100%; text-align: left; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line); background: var(--panel); }
.conv:hover { background: var(--panel2); } .conv.sel { background: var(--accent-soft); }
.avatar { flex: none; width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; }
.avatar.sm { width: 28px; height: 28px; font-size: calc(12px * var(--fs, 1)); }
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.conv-top, .conv-bottom { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.conv-top time, .card-foot time { color: var(--muted); font-size: calc(12px * var(--fs, 1)); flex: none; }
.preview { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; min-width: 20px; padding: 0 6px; text-align: center; font-size: calc(12px * var(--fs, 1)); font-weight: 700; }

.chat { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.placeholder { margin: auto; color: var(--muted); }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.who { display: flex; flex-direction: column; flex: 1; min-width: 120px; } .who small { color: var(--muted); }
.ctrls { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: none; border: 0; background: none; font-size: calc(20px * var(--fs, 1)); }
.pill { display: inline-block; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: calc(12px * var(--fs, 1)); color: var(--muted); }
.msgs { flex: 1; overflow: auto; padding: 14px 6%; display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; background: var(--panel); color: var(--muted); font-size: calc(12px * var(--fs, 1)); border-radius: 8px; padding: 2px 10px; margin: 8px 0; box-shadow: var(--shadow); }
.bubble { max-width: min(560px, 80%); padding: 6px 9px 4px; border-radius: 9px; box-shadow: var(--shadow); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.in { align-self: flex-start; background: var(--in); border-top-left-radius: 2px; }
.bubble.out { align-self: flex-end; background: var(--out); border-top-right-radius: 2px; }
.mtype { color: var(--muted); }
.bubble.note { background: var(--warn-bg); color: var(--text); border: 1px dashed var(--warn); }
.note-label { color: var(--warn); font-size: calc(12px * var(--fs, 1)); }
.meta { display: inline-flex; gap: 4px; float: right; margin: 6px 0 0 12px; color: var(--muted); font-size: calc(11px * var(--fs, 1)); align-items: center; }
.tick.read { color: var(--read); } .tick.failed { color: var(--danger); }
.older { align-self: center; }
.composer { display: flex; gap: 8px; padding: 10px 14px; background: var(--panel); border-top: 1px solid var(--line); align-items: flex-end; }
.composer textarea { resize: none; max-height: 140px; min-height: 40px; flex: 1; }
.file-input { display: none; }
.btn.attach { padding: 6px 10px; font-size: calc(18px * var(--fs, 1)); line-height: 1; }
.media-img { display: block; max-width: min(320px, 100%); max-height: 320px; border-radius: 6px; margin: 2px 0 4px; }
.doc { display: inline-block; padding: 6px 10px; margin: 2px 0 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); text-decoration: none; }
.doc:hover { background: var(--panel2); }
.media-audio { display: block; width: min(300px, 100%); margin: 2px 0 4px; }
.notice { color: var(--warn); background: var(--warn-bg); padding: 10px 12px; border-radius: 8px; width: 100%; }

/* kanban */
.lanes { display: flex; gap: 12px; padding: 14px; height: 100%; overflow-x: auto; align-items: flex-start; }
.lane { flex: none; width: 290px; max-height: 100%; display: flex; flex-direction: column; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); }
.lane.over { outline: 2px dashed var(--accent); }
.lane-head { display: flex; justify-content: space-between; padding: 10px 12px; border-top: 4px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; background: var(--panel); }
.count { color: var(--muted); }
.lane-body { overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; cursor: grab; box-shadow: var(--shadow); }
.card.unread { border-left: 3px solid var(--accent); }
.card-top { display: flex; align-items: center; gap: 8px; } .card-top strong { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }

/* dashboard */
.dash { padding: 16px; max-width: 980px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.dash-head { display: flex; justify-content: space-between; align-items: center; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; }
.kpi-v { font-size: calc(26px * var(--fs, 1)); font-weight: 700; } .kpi-l { color: var(--muted); font-size: calc(13px * var(--fs, 1)); } .kpi.warn .kpi-v { color: var(--warn); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.chart { width: 100%; height: auto; max-height: 240px; }
.axis { stroke: var(--line); } .bar.in { fill: var(--accent); } .bar.out { fill: var(--blue); } .tick-label { fill: var(--muted); font-size: calc(10px * var(--fs, 1)); }
.legend { display: flex; gap: 14px; align-items: center; color: var(--muted); font-size: calc(13px * var(--fs, 1)); margin-top: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; } .sw.in { background: var(--accent); } .sw.out { background: var(--blue); }
.tbl { width: 100%; border-collapse: collapse; } .tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); } .tbl .num { text-align: right; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--muted); } .dot.online { background: #22c55e; } .dot.away { background: #f59e0b; }

/* configuracoes */
.settings { max-width: 860px; margin: 0 auto; padding: 14px 16px 40px; }
.settings-body { display: flex; flex-direction: column; gap: 14px; }
.bar-actions { display: flex; justify-content: space-between; align-items: center; }
.rules, .plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rules li, .plain li { display: flex; justify-content: space-between; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.rules li.off { opacity: .55; } .rules p, .plain p { color: var(--muted); }
.row-actions { display: flex; gap: 6px; flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-end; }
.form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; } .field > span { font-weight: 600; font-size: calc(13px * var(--fs, 1)); } .field small { color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 6px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; } legend { padding: 0 6px; font-weight: 600; }
.targets { display: flex; flex-direction: column; gap: 10px; } .days { display: flex; gap: 10px; flex-wrap: wrap; } .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 8px; }
.warn-box { background: var(--warn-bg); color: var(--warn); padding: 8px 10px; border-radius: 8px; }
.secret { background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 8px; }

/* login e avisos */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { color: var(--accent); }
.form-error { color: var(--danger); min-height: 1.2em; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.2); max-width: 340px; }
.toast.erro { border-left-color: var(--danger); }

@media (max-width: 760px) {
  .inbox { grid-template-columns: 1fr; }
  .inbox .chat { display: none; } .inbox.open-chat .side { display: none; } .inbox.open-chat .chat { display: flex; }
  .back { display: inline-block; } .msgs { padding: 10px 8px; } .bubble { max-width: 90%; }
  .top { gap: 8px; } .me span { display: none; } .two { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: no-preference) { .btn, .chip, .conv { transition: background .12s, filter .12s; } }

/* ferramentas do agente */
.conv-search { margin: 10px 12px 0; width: calc(100% - 24px); }
.conv.hit .preview { white-space: normal; }
.lbl-dots { display: inline-flex; gap: 3px; margin-left: 6px; align-items: center; }
.lbl-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.lbl-chip { display: inline-block; color: #fff; border-radius: 999px; padding: 0 8px; font-size: calc(11px * var(--fs, 1)); margin-right: 4px; line-height: 18px; }
.lbl-row-chips { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 2px; }
.lbl-list { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.lbl-row { display: flex; align-items: center; gap: 8px; }
.composer { flex-direction: column; align-items: stretch; position: relative; gap: 6px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer .modes { display: flex; gap: 6px; }
.composer.notemode { background: var(--warn-bg); }
.composer.notemode textarea { border-color: var(--warn); }
.popmenu { position: absolute; left: 14px; bottom: 100%; z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); min-width: 260px; max-width: calc(100% - 28px); overflow: hidden; }
.popmenu[hidden] { display: none; }
.pop-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 7px 12px; }
.pop-item.on, .pop-item:hover { background: var(--accent-soft); }
.hist li { align-items: flex-start; }
.badge.mbadge { margin-left: 6px; }
.preview.late { color: var(--warn); font-weight: 600; }
.badge.warnb { background: var(--warn); color: #fff; margin-left: 6px; }
.dash-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.kpis.small { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.kpi-n { color: var(--muted); font-size: calc(12px * var(--fs, 1)); }
.dash h3 { margin: 6px 0 0; color: var(--muted); font-size: calc(13px * var(--fs, 1)); text-transform: uppercase; letter-spacing: .04em; }
.dash .panel h3 { margin: 0 0 10px; color: var(--text); font-size: calc(15px * var(--fs, 1)); text-transform: none; letter-spacing: 0; }

/* parametros de operacao */
.param .param-row { display: flex; gap: 8px; align-items: center; }
.param .param-row input, .param .param-row textarea { flex: 1; min-width: 0; }
.param .unit { color: var(--muted, #667); white-space: nowrap; }
.param .tag { font-style: normal; font-size: calc(12px * var(--fs, 1)); background: #fff3cd; color: #664d03; border-radius: 4px; padding: 0 6px; margin-left: 6px; }
.ok-text { color: #0a7a3d; }
.warn-text { color: #b45309; }
.field input[type=checkbox] { width: auto; align-self: flex-start; transform: scale(1.3); margin: 4px 2px; }
.conv-search { width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); min-height: 36px; }

.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; align-items: start; }
.cols2 > .field { min-width: 0; }
.field.inline { flex-direction: row; align-items: center; gap: 10px; }
.field.inline > span { font-weight: 600; }
@media (max-width: 600px) { .cols2 { grid-template-columns: 1fr; } }

.tpl-preview { white-space: pre-wrap; background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin: 0; }

.pending-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 10px 0; }
.pending-files[hidden] { display: none; }
.pf-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; max-width: 260px; }
.pf-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
.pf-icon { font-size: 22px; }
.pf-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.pf-chip small { color: var(--muted); }
.pf-x { border: 0; background: none; font-size: 18px; line-height: 1; cursor: pointer; color: var(--muted); }

.qr-box { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr-box:empty { display: none; }
.qr { width: 260px; height: 260px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--line); }

.health-top { font-size: calc(18px * var(--fs, 1)); font-weight: 700; margin: 8px 0; }
.health-errs { margin-top: 18px; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
ul.plain li > .btn.danger { order: 99; margin-left: 10px; }

@keyframes flashmsg { 0%, 60% { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); } 100% { background: transparent; box-shadow: none; } }
.flash-msg { animation: flashmsg 2.6s ease-out; }

/* caixa de mensagem que cresce com o texto (e pode ser redimensionada) */
.tm-comp textarea, .composer textarea { resize: vertical; min-height: 38px; max-height: 45vh; overflow-y: auto; }
.tcall-head { user-select: none; }
.build { color: var(--muted); font-size: calc(11px * var(--fs, 1)); opacity: .8; }

.chan-state { display: inline-block; font-size: calc(12px * var(--fs, 1)); padding: 1px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); vertical-align: middle; }
.chan-state:empty { display: none; }
.chan-state.ok { color: #15803d; border-color: #15803d; }
.chan-state.warn { color: var(--warn); border-color: var(--warn); background: var(--warn-bg); }
.chan-state.bad { color: var(--danger); border-color: var(--danger); }

/* lista de canais: nada passa da borda do cartao; texto longo (ID da instancia) quebra e os botoes descem para a linha de baixo */
.plain li { flex-wrap: wrap; }
.plain li > div:first-child { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }

/* nome do usuario com o atalho de senha logo abaixo */
.me-user { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
.me-user .link-btn { background: none; border: 0; padding: 0; margin: 0; font: inherit; font-size: 0.8em; color: inherit; opacity: 0.85; text-decoration: underline; cursor: pointer; }
.me-user .link-btn:hover, .me-user .link-btn:focus-visible { opacity: 1; }
.view-host { display: contents; }

/* menu na lateral esquerda (a barra do topo vira coluna); em telas estreitas volta a ser barra no topo */
#app.shell { flex-direction: row; }
#app.shell > .top { flex-direction: column; align-items: stretch; flex-wrap: nowrap; flex: none; width: 216px; height: 100%; overflow-y: auto; padding: 12px 10px; gap: 12px; border-bottom: 0; border-right: 1px solid var(--line); }
#app.shell .logo { align-self: flex-start; }
#app.shell .tabs { flex-direction: column; flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; gap: 2px; }
#app.shell .tab { width: 100%; display: flex; align-items: center; justify-content: flex-start; flex-wrap: wrap; gap: 6px; text-align: left; white-space: normal; }
#app.shell .tab .badge { margin-left: auto; }
#app.shell .me { flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
#app.shell .me .me-user { flex: 1 1 100%; order: -1; }
#app.shell .me .my-status { flex: 1 1 100%; }
#app.shell .me .build { flex: 1 1 100%; }
#app.shell .main { min-width: 0; }
@media (max-width: 760px) {
  #app.shell { flex-direction: column; }
  #app.shell > .top { flex-direction: row; flex-wrap: wrap; align-items: center; width: auto; height: auto; overflow: visible; padding: 8px 12px; gap: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  #app.shell .tabs { flex-direction: row; flex: 1 1 100%; order: 3; overflow-x: auto; overflow-y: hidden; }
  #app.shell .tab { width: auto; white-space: nowrap; flex-wrap: nowrap; }
  #app.shell .me { border-top: 0; padding-top: 0; margin-left: auto; }
  #app.shell .me .me-user, #app.shell .me .my-status, #app.shell .me .build { flex: 0 1 auto; order: 0; }
}

/* botao que recolhe o menu lateral */
.side-toggle { position: relative; align-self: flex-end; border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 8px; width: 32px; height: 32px; padding: 0; font-size: 16px; line-height: 1; cursor: pointer; flex: none; }
.side-toggle:hover, .side-toggle:focus-visible { color: var(--text); background: var(--accent-soft); }
#app.shell.side-collapsed > .top { width: 52px; padding: 12px 8px; overflow: hidden; }
#app.shell.side-collapsed > .top > :not(.side-toggle) { display: none; }
#app.shell.side-collapsed > .top .side-toggle { align-self: center; }
/* recolhido: ponto de aviso se ha contador (nao lidas, mencoes, atrasos) em alguma aba */
#app.shell.side-collapsed > .top:has(.tab .badge) .side-toggle::after { content: ''; position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border-radius: 50%; background: var(--warn, #d32f2f); border: 2px solid var(--panel); }
@media (max-width: 760px) {
  #app.shell > .top { position: relative; }
  #app.shell:not(.side-collapsed) .side-toggle { order: 0; align-self: flex-start; }
  #app.shell.side-collapsed > .top { width: auto; height: auto; flex-direction: row; justify-content: space-between; padding: 8px 12px; }
  #app.shell.side-collapsed > .top > .logo { display: block; }
}

/* botao "Livre para atender" */
.free-btn { text-align: left; }
.free-btn.on { background: var(--accent-soft); border-color: var(--accent); font-weight: 700; }
#app.shell .me .free-btn { flex: 1 1 100%; display: none; }
.who-bar .free-btn { width: 100%; text-align: left; }
.who-bar.closed .free-btn { width: 28px; padding: 3px 0; text-align: center; }
.who-bar.closed .free-btn .fb-txt { display: none; }
@media (max-width: 1000px) { #app.shell .me .free-btn { display: block; } }

/* barra "Equipe" na direita: nomes reduzidos em duas colunas, estado e tempo */
.who-bar { flex: none; width: 240px; height: 100%; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); padding: 10px 8px; display: flex; flex-direction: column; gap: 8px; }
.who-head { display: flex; align-items: center; gap: 6px; border: 0; background: none; padding: 2px 4px; color: var(--text); cursor: pointer; font: inherit; text-align: left; }
.who-head strong { font-size: calc(13px * var(--fs, 1)); }
.who-count { margin-left: auto; font-size: calc(12px * var(--fs, 1)); color: var(--muted); white-space: nowrap; }
.who-arrow { color: var(--muted); font-size: 16px; line-height: 1; }
.who-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-content: start; }
.who-card { display: grid; grid-template-columns: 9px 1fr; column-gap: 6px; align-items: center; padding: 5px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2, var(--panel)); min-width: 0; }
.who-card.free { border-color: #2e9e5b; background: rgba(46, 158, 91, .1); }
.who-card.offline { opacity: .65; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: calc(12.5px * var(--fs, 1)); font-weight: 600; }
.who-time { grid-column: 1 / -1; color: var(--muted); font-size: calc(11px * var(--fs, 1)); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.who-dot { width: 8px; height: 8px; border-radius: 50%; background: #b8c0c8; }
.who-dot.free { background: #2e9e5b; box-shadow: 0 0 0 2px rgba(46, 158, 91, .25); }
.who-dot.online { background: #4c8bf5; }
.who-dot.away { background: #e0a82e; }
.who-dot.offline { background: #b8c0c8; }
.who-bar.closed { width: 34px; padding: 10px 4px; align-items: center; overflow: hidden; }
.who-bar.closed .who-grid, .who-bar.closed .who-head strong, .who-bar.closed .who-count { display: none; }
@media (max-width: 1000px) { .who-bar { display: none; } }

.who-top { display: flex; align-items: center; gap: 4px; }
.who-top .who-head { flex: 1 1 auto; min-width: 0; }
.who-gear { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; border-radius: 6px; }
.who-gear:hover, .who-gear:focus-visible { color: var(--text); background: var(--accent-soft); }
.who-bar.closed .who-gear { display: none; }
.who-card.online { border-color: #d64545; background: rgba(214, 69, 69, .09); }
.who-dot.online { background: #d64545; box-shadow: 0 0 0 2px rgba(214, 69, 69, .22); }
.who-dot { width: 10px; height: 10px; }
.who-card { grid-template-columns: 10px 1fr; }
.who-time { font-size: calc(12px * var(--fs, 1)); font-weight: 600; color: var(--text); }

/* resumo por dia (disponivel / ocupado) */
.sum-scroll { overflow: auto; max-height: 60vh; border: 1px solid var(--line); border-radius: 8px; }
.sum-table { border-collapse: collapse; width: 100%; font-size: calc(12.5px * var(--fs, 1)); }
.sum-table th, .sum-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; vertical-align: top; }
.sum-table thead th { position: sticky; top: 0; background: var(--panel); z-index: 1; }
.sum-table tbody th { text-align: left; position: sticky; left: 0; background: var(--panel); font-weight: 600; }
.sum-table td span { display: block; line-height: 1.3; }
.sum-ds { color: #2e9e5b; font-weight: 600; }
.sum-oc { color: #d64545; font-weight: 600; }
.sum-empty { color: var(--muted); }
.sum-total { background: var(--panel2, var(--panel)); }

/* botao Copiar do aviso de erro com codigo */
.toast-copy { margin-left: 6px; border: 1px solid currentColor; background: transparent; color: inherit; border-radius: 6px; padding: 1px 8px; font: inherit; font-size: .85em; cursor: pointer; }
.toast-copy:hover, .toast-copy:focus-visible { background: rgba(255, 255, 255, .18); }

.free-btn[hidden], #app.shell .me .free-btn[hidden] { display: none !important; }

.notif-row { margin: 6px 0; line-height: 1.4; }

/* zoom de imagens */
.media-img, .bl-img { cursor: zoom-in; }
.lb-overlay { position: fixed; inset: 0; z-index: 3000; background: rgba(8, 8, 20, .92); display: flex; flex-direction: column; }
.lb-bar { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 10px; flex-wrap: wrap; }
.lb-btn { border: 1px solid #55558a; background: #23234a; color: #fff; border-radius: 8px; padding: 6px 12px; min-width: 38px; cursor: pointer; font-size: 15px; }
.lb-btn:hover { background: #34346a; }
.lb-pct { color: #c9c8e8; min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; }
.lb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; }
.lb-stage.drag { cursor: grabbing; }
.lb-img { max-width: 96%; max-height: 100%; object-fit: contain; user-select: none; transform-origin: center center; cursor: zoom-in; }
.lb-stage.drag .lb-img { cursor: grabbing; }
.notif-sec { margin: 10px 0 2px; }
.notif-vol { display: flex; align-items: center; gap: 10px; }
.notif-vol input[type=range] { flex: 1; }
.notif-vol-txt { min-width: 44px; text-align: right; }

/* miniblog: documento HTML e confirmacao de leitura */
.bl-doc { margin: 8px 0; border: 1px solid var(--line, #c9c8e8); border-radius: 8px; overflow: hidden; }
.bl-doc-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 10px; background: var(--bg, #f4f3fb); }
.bl-doc-inline { background: #fff; min-height: 60px; }
.bl-frame-inline { display: block; width: 100%; height: 400px; border: 0; background: #fff; }
.bl-doc-name { flex: 1; min-width: 160px; word-break: break-all; }
.bl-read { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; padding: 8px 10px; border-radius: 8px; background: #fff4d6; color: #5b4300; }
.bl-read.done { background: #e4f6ec; color: #124d2e; }
.bl-readers { width: 100%; border-collapse: collapse; }
.bl-readers td { padding: 4px 8px; border-bottom: 1px solid var(--line, #e1e0f0); }
.bl-doc-view { width: 100%; }
.bl-frame { width: 100%; height: 70vh; border: 1px solid var(--line, #c9c8e8); border-radius: 6px; background: #fff; }
.tm-modal.bl-wide { width: min(1100px, 96vw); max-width: 96vw; }
.bl-pending { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 14px; background: #fff4d6; color: #5b4300; border-bottom: 1px solid #e6c66a; }

/* editor de informativo (HTML) */
.he-choose { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.he-box { margin: 8px 0; }
.he { border: 1px solid var(--line, #c9c8e8); border-radius: 8px; overflow: hidden; background: #fff; }
.he-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px; background: var(--bg, #f4f3fb); border-bottom: 1px solid var(--line, #c9c8e8); }
.he-btn { border: 1px solid var(--line, #c9c8e8); background: #fff; border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 13px; min-width: 30px; }
.he-btn:hover { background: #ece9fb; }
.he-btn.b { font-weight: 700; } .he-btn.i { font-style: italic; } .he-btn.u { text-decoration: underline; }
.he-btn.on { background: #d9d2f7; }
.he-select { border: 1px solid var(--line, #c9c8e8); border-radius: 6px; padding: 4px; background: #fff; }
.he-color { width: 34px; height: 28px; padding: 0; border: 1px solid var(--line, #c9c8e8); border-radius: 6px; background: #fff; cursor: pointer; }
.he-stage { position: relative; }
.he-frame { display: block; width: 100%; height: 52vh; border: 0; background: #fff; }
.he-source { display: block; width: 100%; height: 52vh; border: 0; padding: 10px; font: 13px/1.5 ui-monospace, Consolas, monospace; resize: vertical; box-sizing: border-box; }

/* nova conversa (ticket), assunto e prioridade */
.side-head { padding: 6px 8px 0; }
.new-conv { width: 100%; }
.conv-subject { display: block; font-size: calc(12px * var(--fs, 1)); font-weight: 600; color: var(--text, #213147); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-subject { display: block; font-size: calc(13px * var(--fs, 1)); font-weight: 600; }
.prio { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 8px; margin-right: 6px; background: #e8e6f5; color: #3a3470; }
.prio.high { background: #ffe2b3; color: #6b3b00; }
.prio.urgent { background: #ffc9c9; color: #7a0a0a; }
.prio.low { background: #e2f1e4; color: #20502b; }
.nc-chosen { margin: 6px 0 2px; font-size: 13px; color: var(--muted, #6b7280); }
.nc-chosen.on { color: #124d2e; font-weight: 600; }
.nc-results { display: flex; flex-direction: column; gap: 2px; max-height: 180px; overflow: auto; }
.nc-item { text-align: left; border: 1px solid var(--line, #d9d7ee); background: #fff; border-radius: 6px; padding: 6px 8px; cursor: pointer; }
.nc-item:hover { background: #f1effd; }

.nc-add { margin-top: 4px; align-self: flex-start; }
.nc-register { margin-top: 8px; padding: 10px; border: 1px dashed var(--line, #c9c8e8); border-radius: 8px; display: flex; flex-direction: column; gap: 6px; }
.nc-register-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* link de conversa e cartao de previa */
.cp-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 2px; max-width: 520px; }
.cp-link { word-break: break-all; }
.cp-card { display: flex; flex-direction: column; gap: 2px; text-align: left; width: 100%; border: 1px solid var(--line, #d9d7ee); border-left: 4px solid var(--accent, #4a3a9a); background: var(--card, #fff); color: inherit; border-radius: 8px; padding: 8px 10px; cursor: pointer; font: inherit; }
.cp-card:hover { background: var(--accent-soft, #f1effd); }
.cp-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cp-status { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 8px; background: #e8e6f5; color: #3a3470; }
.cp-status.open { background: #e2f1e4; color: #20502b; }
.cp-status.pending { background: #fff0c9; color: #6b4b00; }
.cp-subject { font-size: calc(13px * var(--fs, 1)); font-weight: 600; }
.cp-last { font-size: calc(13px * var(--fs, 1)); color: var(--muted, #5b6475); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-meta { font-size: 11px; color: var(--muted, #5b6475); }
.cp-load, .cp-plain { font-size: 13px; color: var(--muted, #5b6475); }

/* lista de pessoas com busca incremental */
.ss { position: relative; display: inline-block; max-width: 100%; }
.ss-btn { width: 100%; text-align: left; border: 1px solid var(--line, #cfcde6); background: var(--card, #fff); color: inherit; border-radius: 8px; padding: 6px 28px 6px 10px; font: inherit; cursor: pointer; position: relative; min-height: 34px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-btn::after { content: '▾'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); opacity: .7; }
.field .ss { display: block; }
.ss-pop { position: fixed; z-index: 4000; background: var(--card, #fff); color: var(--text, #1d2433); border: 1px solid var(--line, #cfcde6); border-radius: 10px; box-shadow: 0 10px 30px rgba(20, 16, 60, .25); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.ss-pop[hidden] { display: none; }
.ss-in { width: 100%; padding: 6px 8px; border: 1px solid var(--line, #cfcde6); border-radius: 6px; font: inherit; }
.ss-list { overflow-y: auto; }
.ss-opt { display: flex; justify-content: space-between; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.ss-opt.on, .ss-opt:hover { background: var(--accent-soft, #ece9fb); }
.ss-opt.cur { font-weight: 700; }
.ss-hint { color: var(--muted, #6b7280); font-size: 12px; align-self: center; }
.ss-none { padding: 8px; color: var(--muted, #6b7280); }

/* o atributo hidden precisa vencer o display das caixas que abrem e fecham */
.nc-register[hidden], .ss-pop[hidden], .he-box[hidden], .he-frame[hidden], .he-source[hidden] { display: none !important; }

/* acesso remoto (MeshCentral) */
.rm .rm-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.rm .rm-sug { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line, #d9d7ee); border-left: 4px solid var(--accent, #4a3a9a); border-radius: 8px; background: var(--accent-soft, #f1effd); }
.rm .rm-pick { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.rm .rm-pick[hidden] { display: none; }
.rm .rm-link { width: 100%; }

/* arquivo grande por link: painel de progresso */
.big-up { position: fixed; left: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 6px; width: min(360px, calc(100vw - 32px)); padding: 10px 12px; border: 1px solid var(--line, #d9d7ee); border-radius: 10px; background: var(--card, #fff); box-shadow: 0 6px 24px rgba(0, 0, 0, .18); }
.big-up .big-track { height: 6px; border-radius: 3px; background: var(--accent-soft, #ece9fb); overflow: hidden; }
.big-up .big-bar { height: 100%; width: 0; background: var(--accent, #4a3a9a); transition: width .2s; }

/* painel Meta */
.mp-pay { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 12px; margin: 10px 0; border-radius: 8px; background: var(--accent-soft, #ece9fb); }
.mp-add { display: flex; gap: 8px; flex-wrap: wrap; }
.mp-add input { flex: 1 1 220px; min-width: 180px; }
.mp-card { border: 1px solid var(--line, #d9d7ee); border-radius: 10px; padding: 12px 14px; margin: 14px 0; background: var(--card, #fff); }
.mp-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.mp-badges { display: flex; gap: 6px; flex-wrap: wrap; flex: 1 1 auto; }
.mp-actions { display: flex; gap: 6px; }
.mp-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--accent-soft, #ece9fb); color: var(--text, #222); }
.mp-pill.ok { background: #d9f2e1; color: #135b2d; }
.mp-pill.warn { background: #fff0c9; color: #6b4a00; }
.mp-pill.bad { background: #fbd9d9; color: #8a1c1c; }
.mp-numbers td, .mp-numbers th { vertical-align: middle; }
.mp-has { color: #135b2d; font-weight: 600; }
.mp-tpl { margin-top: 10px; }
.mp-tpl summary { cursor: pointer; font-weight: 600; }

/* Painel Meta: contas encontradas pelo token */
.mp-found { margin: 8px 0 12px; display: grid; gap: 8px; }
.mp-found-item { border: 1px solid var(--line, #d8dee6); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; }
.mp-found-nums { margin: 0; padding-left: 18px; font-size: 13px; }

/* Equipe: quem tem a permissao clica na pessoa para ocupar/liberar */
.who-card.who-set { cursor: pointer; }
.who-card.who-set:hover, .who-card.who-set:focus-visible { outline: 2px solid var(--brand, #453796); outline-offset: 1px; }

.mp-step { border: 1px solid var(--line, #dcdfe6); border-radius: 8px; padding: 8px 12px 10px; margin: 0 0 12px; min-width: 0; }
.mp-step legend { font-weight: 700; padding: 0 6px; }
.mp-or { margin: 4px 0 8px; font-weight: 600; opacity: .8; }
.mp-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }

/* Lembrete de tarefa: faixa no topo com o alarme ativo */
.td-remind { display: grid; gap: 6px; padding: 8px 14px; background: #ffe9e6; color: #7a1a0f; border-bottom: 1px solid #e8a79d; }
.td-remind-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.mp-fb { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.mp-fb .field { align-self: stretch; }

/* busca dentro da conversa / do canal */
.msgsearch { display: flex; align-items: center; gap: 8px; padding: 6px 14px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.msgsearch[hidden] { display: none; }
.msgsearch .ms-input { flex: 1; min-width: 120px; max-width: 420px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: inherit; font: inherit; }
.msgsearch .ms-count { color: var(--muted, #6b7280); font-size: 13px; min-width: 90px; }

/* a faixa fica acima da area principal (e nao como mais uma coluna do menu lateral) */
.main-col { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
/* faixa fixa: o navegador ainda nao liberou os avisos */
.notify-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 14px; background: #fff4d6; color: #5b4300; border-bottom: 1px solid #f0d78a; font-size: 14px; }
.notify-bar[hidden] { display: none; }
.notify-bar span { flex: 1; min-width: 240px; }
@media (prefers-color-scheme: dark) { .notify-bar { background: #3a2f10; color: #f5e3a8; border-color: #6a5420; } }

/* Celular: largura e altura acompanhando a area visivel do navegador. */
@media (max-width: 760px) {
  #app.shell { height: 100vh; height: 100dvh; min-width: 0; }
  #app.shell > .top { min-width: 0; max-width: 100%; gap: 6px; padding: 6px 8px; }
  #app.shell .tabs { min-width: 0; width: 100%; flex-shrink: 0; }
  #app.shell .tab { flex-shrink: 0; padding: 7px 10px; }
  #app.shell .me { min-width: 0; max-width: 100%; flex: 1 1 100%; gap: 6px; margin-left: 0; }
  #app.shell .me .me-user { min-width: 0; }
  #app.shell .me .build { display: none; }
  #app.shell .me .btn { padding: 5px 9px; }
  #app.shell .main-col, #app.shell .main { min-height: 0; min-width: 0; }
  .composer { flex-wrap: wrap; padding: 8px; }
  .composer textarea { min-width: 0; flex: 1 1 100%; order: -1; }
  .msgsearch { flex-wrap: wrap; padding: 6px 8px; }
  .msgsearch .ms-input { min-width: 0; flex: 1 1 140px; }
  .notify-bar span { min-width: 0; }
}
