/* Tema claro/escuro por prefers-color-scheme; sem estilos inline (CSP style-src 'self'). */
:root {
  color-scheme: light dark;
  --bg: #f4f6f9; --surface: #ffffff; --surface2: #eceff4; --text: #111827; --muted: #4b5563; --border: #b9c2cf;
  --accent: #1d4ed8; --accent-fg: #ffffff; --danger: #b42318; --danger-bg: #fdecea; --warn: #8a4b00; --warn-bg: #fff4dc; --ok: #0f6b3a; --ok-bg: #e3f6ea; --info-bg: #e8f0fe;
  --focus: #0b57d0;
  --st-disponivel: #1b7f4b; --st-trabalhando: #1d5fc4; --st-aguardando_resposta: #9a6700; --st-aguardando_aprovacao: #7e3fb0; --st-pausado: #5f6b7a; --st-falha: #b42318;
  --st-fila: #5f6b7a; --st-executando: #1d5fc4; --st-pausada: #5f6b7a; --st-concluida: #1b7f4b; --st-falhou: #b42318; --st-cancelada: #6b7280;
  --st-pendente: #9a6700; --st-aprovada: #1b7f4b; --st-rejeitada: #b42318; --st-expirada: #6b7280; --st-executada: #1d5fc4; --st-invalidada: #6b7280;
  --cv-bg: #e9edf3; --cv-room: #ffffff; --cv-line: #9aa6b8; --cv-desk: #c9a77c; --cv-ring: #1f2937; --cv-warn: #9a4a00;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b; --surface: #171e28; --surface2: #202a37; --text: #eef2f7; --muted: #aeb9c8; --border: #475467;
    --accent: #7aa7ff; --accent-fg: #0b1220; --danger: #ff9b90; --danger-bg: #3a1a18; --warn: #ffcb6b; --warn-bg: #3a2c10; --ok: #7be0a1; --ok-bg: #12301f; --info-bg: #16263f;
    --focus: #9cc0ff;
    --st-disponivel: #2fa66a; --st-trabalhando: #3b82e6; --st-aguardando_resposta: #c68a00; --st-aguardando_aprovacao: #a56ad6; --st-pausado: #7c8898; --st-falha: #e0554a;
    --st-fila: #7c8898; --st-executando: #3b82e6; --st-pausada: #7c8898; --st-concluida: #2fa66a; --st-falhou: #e0554a; --st-cancelada: #8a94a3;
    --st-pendente: #c68a00; --st-aprovada: #2fa66a; --st-rejeitada: #e0554a; --st-expirada: #8a94a3; --st-executada: #3b82e6; --st-invalidada: #8a94a3;
    --cv-bg: #0b0f15; --cv-room: #1b2431; --cv-line: #5b6b82; --cv-desk: #7a6244; --cv-ring: #eef2f7; --cv-warn: #ffcb6b;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 1.6rem; margin: .4rem 0 .8rem; } h2 { font-size: 1.2rem; margin: 1.2rem 0 .6rem; } h3 { font-size: 1.02rem; margin: .8rem 0 .4rem; } h4 { margin: .6rem 0 .3rem; }
a { color: var(--accent); } a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-fg); padding: .6rem 1rem; z-index: 100; } .skip:focus { left: 0; }
.muted { color: var(--muted); } .hint { color: var(--muted); font-size: .88rem; margin: .25rem 0; } .strong { font-weight: 700; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: .3rem 0; } .clip { max-height: 5.5em; overflow: hidden; }
code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
.code { background: var(--surface2); padding: .6rem; border-radius: 8px; overflow: auto; max-height: 22rem; white-space: pre-wrap; overflow-wrap: anywhere; }
code.block { display: block; background: var(--surface2); padding: .6rem; border-radius: 8px; overflow-wrap: anywhere; margin: .3rem 0; user-select: all; }
.loading, .empty { color: var(--muted); }
.noscript { padding: 1rem; background: var(--warn-bg); }

/* cabeçalho / navegação */
.top { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; padding: .5rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; gap: .5rem; align-items: center; font-weight: 800; color: var(--text); text-decoration: none; font-size: 1.15rem; }
.brand.big { font-size: 1.5rem; margin-bottom: .5rem; }
.logo { display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: 8px; background: var(--accent); color: var(--accent-fg); font-weight: 800; }
.top-ctl { display: flex; gap: .5rem; align-items: center; flex: 1 1 18rem; min-width: 0; }
.top-ctl select { max-width: 100%; min-width: 0; flex: 1 1 10rem; }
.user { display: flex; gap: .6rem; align-items: center; margin-left: auto; }
.who { font-size: .9rem; }
.rt { display: inline-flex; gap: .4rem; align-items: center; font-size: .85rem; padding: .2rem .6rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface2); }
.rt .dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--st-pausado); }
.rt-open .dot { background: var(--st-disponivel); } .rt-retry .dot, .rt-connecting .dot { background: var(--st-aguardando_resposta); }
.nav { background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.nav ul { display: flex; list-style: none; margin: 0; padding: 0 .5rem; gap: .1rem; min-width: max-content; }
.nav a { display: flex; gap: .4rem; align-items: center; padding: .7rem .8rem; color: var(--text); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; }
.nav a:hover { background: var(--surface2); } .nav a[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 700; }
.count { background: #b42318; color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .75rem; font-weight: 700; }
.banner { padding: .6rem 1rem; } .banner.warn { background: var(--warn-bg); color: var(--text); border-bottom: 2px solid var(--warn); }
.banner.sim { background: var(--warn-bg); border: 2px dashed var(--warn); border-radius: var(--radius); margin: .5rem 0 1rem; }
main#main { max-width: 1400px; margin: 0 auto; padding: 1rem; }
.subnav ul { display: flex; flex-wrap: wrap; gap: .3rem; list-style: none; padding: 0; margin: 0 0 1rem; }
.subnav a { display: inline-block; padding: .4rem .8rem; border-radius: 999px; border: 1px solid var(--border); text-decoration: none; color: var(--text); background: var(--surface); }
.subnav a[aria-current="page"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 700; }

/* formulários e botões */
.btn { font: inherit; cursor: pointer; padding: .5rem .9rem; min-height: 2.5rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn:hover:not(:disabled) { background: var(--surface2); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; } .btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); font-weight: 600; }
.btn.ghost { border-color: transparent; background: transparent; } .btn.small { min-height: 2rem; padding: .25rem .6rem; font-size: .88rem; } .btn.block { width: 100%; }
.btn:disabled, input:disabled, select:disabled, textarea:disabled { opacity: .6; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; text-align: left; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .45rem .6rem; min-height: 2.5rem; max-width: 100%; }
textarea { width: 100%; resize: vertical; } input[type=checkbox] { min-height: 0; width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
input::placeholder { color: var(--muted); }
.field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; } .field label { font-weight: 600; font-size: .92rem; }
.field input, .field select { width: 100%; }
.check { display: grid; grid-template-columns: auto 1fr; gap: .1rem .5rem; align-items: start; } .check .hint { grid-column: 2; margin: 0; }
fieldset.fs { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem .9rem; } fieldset.fs legend { font-weight: 700; padding: 0 .4rem; }
.stack { display: flex; flex-direction: column; gap: .8rem; } .stack.narrow { max-width: 34rem; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; } .row.end { justify-content: flex-end; } .row.between, .between { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; align-items: start; } .grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .8rem; align-items: end; margin-bottom: .6rem; } .filters .field { min-width: 12rem; }
.form-error { color: var(--danger); background: var(--danger-bg); border: 1px solid var(--danger); padding: .5rem .7rem; border-radius: 8px; margin: 0; } .form-error[hidden] { display: none; }
.danger-t { color: var(--danger); font-weight: 700; }
.box { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 1rem; }
.callout { padding: .6rem .8rem; border-radius: 8px; border-left: 5px solid var(--accent); background: var(--info-bg); margin: .4rem 0; }
.callout.warn { border-color: var(--warn); background: var(--warn-bg); } .callout.danger { border-color: var(--danger); background: var(--danger-bg); }

/* selos e badges */
.badge { display: inline-flex; gap: .25rem; align-items: center; padding: .1rem .55rem; border-radius: 999px; border: 2px solid var(--c, var(--border)); background: color-mix(in srgb, var(--c, var(--border)) 14%, var(--surface)); color: var(--text); font-size: .82rem; font-weight: 600; white-space: nowrap; }
.badge .ic { color: var(--c); font-weight: 900; }
.pill { display: inline-block; padding: 0 .5rem; border-radius: 6px; background: var(--surface2); border: 1px solid var(--border); font-size: .78rem; font-weight: 600; }
.pill.ok { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); } .pill.warn { border-color: var(--warn); color: var(--warn); background: var(--warn-bg); } .pill.danger { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); font-weight: 800; }
.seal { display: inline-block; padding: .15rem .6rem; border: 2px dashed var(--warn); color: var(--warn); background: var(--warn-bg); border-radius: 6px; font-weight: 800; font-size: .8rem; letter-spacing: .02em; }
.st-disponivel { --c: var(--st-disponivel); } .st-trabalhando { --c: var(--st-trabalhando); } .st-aguardando_resposta { --c: var(--st-aguardando_resposta); } .st-aguardando_aprovacao { --c: var(--st-aguardando_aprovacao); } .st-pausado { --c: var(--st-pausado); } .st-falha { --c: var(--st-falha); }
.st-fila { --c: var(--st-fila); } .st-executando { --c: var(--st-executando); } .st-pausada { --c: var(--st-pausada); } .st-concluida { --c: var(--st-concluida); } .st-falhou { --c: var(--st-falhou); } .st-cancelada { --c: var(--st-cancelada); }
.st-pendente { --c: var(--st-pendente); } .st-aprovada { --c: var(--st-aprovada); } .st-rejeitada { --c: var(--st-rejeitada); } .st-expirada { --c: var(--st-expirada); } .st-executada { --c: var(--st-executada); } .st-invalidada { --c: var(--st-invalidada); }

/* listas, tabelas, cartões */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; } .list > li { padding: .4rem .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: .8rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; display: flex; flex-direction: column; gap: .4rem; min-width: 0; } .card.alert { border: 2px solid var(--danger); }
.card h2 { margin: 0; font-size: 1.1rem; }
.approval { grid-column: 1 / -1; } .sendbox { background: var(--surface2); border-radius: 8px; padding: .6rem .8rem; } blockquote.pre { margin: .3rem 0; padding: .5rem .8rem; border-left: 4px solid var(--accent); background: var(--surface); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; } th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; } th { background: var(--surface2); white-space: nowrap; }
tr.efeito { background: color-mix(in srgb, var(--warn-bg) 55%, transparent); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .15rem 1rem; margin: .4rem 0; } .kv dt { color: var(--muted); font-weight: 600; } .kv dd { margin: 0; overflow-wrap: anywhere; }
.modes { display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem 1rem; } .modes dt { font-weight: 800; font-family: ui-monospace, monospace; } .modes dd { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 3px solid var(--border); display: flex; flex-direction: column; gap: .6rem; } .timeline > li { padding-left: .4rem; } .timeline p { margin: .2rem 0; }
.steps { margin: .3rem 0; padding-left: 1.2rem; font-size: .88rem; }
.results > li { padding: .6rem .8rem; }
details > summary { cursor: pointer; font-weight: 600; padding: .2rem 0; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .8rem; } .tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; } .tile.wide { grid-column: span 2; } @media (max-width: 640px) { .tile.wide { grid-column: auto; } }
.tile h2 { margin: 0 0 .4rem; font-size: 1rem; color: var(--muted); } .big { font-size: 2rem; font-weight: 800; margin: 0; } .big.small { font-size: 1.4rem; }
.stats { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .5rem; } .stats li a { display: flex; gap: .5rem; align-items: center; text-decoration: none; color: var(--text); padding: .3rem; border-radius: 8px; } .stats li a:hover { background: var(--surface2); }
.stats .num { font-size: 1.4rem; font-weight: 800; min-width: 2ch; text-align: right; } .stats.small li { display: flex; gap: .5rem; align-items: center; }
.meter { height: .8rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin: .4rem 0; } .meter .fill { display: block; height: 100%; width: var(--w, 0%); background: var(--accent); }
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(16rem, 1fr); gap: .8rem; overflow-x: auto; padding-bottom: .6rem; align-items: start; }
.col { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem; } .col h2 { margin: 0 0 .5rem; font-size: .95rem; display: flex; gap: .5rem; align-items: center; justify-content: space-between; } .col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.kcard { width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .6rem; cursor: pointer; display: flex; flex-direction: column; gap: .1rem; } .kcard:hover { border-color: var(--accent); }

/* organograma */
.tree-wrap { overflow-x: auto; padding: .5rem 0 1rem; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; } .tree ul { padding-left: 2rem; position: relative; }
.tree li { position: relative; padding: .35rem 0 .35rem 1.2rem; } .tree li::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; border-left: 2px solid var(--border); } .tree li::after { content: ""; position: absolute; left: 0; top: 1.5rem; width: 1rem; border-top: 2px solid var(--border); } .tree li:last-child::before { bottom: auto; height: 1.5rem; }
.tree > li { padding-left: 0; } .tree > li::before, .tree > li::after { display: none; }
.node { display: inline-flex; flex-wrap: wrap; gap: .1rem .6rem; align-items: center; padding: .4rem .8rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; min-width: 12rem; } a.node:hover { border-color: var(--accent); } .node.owner { background: var(--info-bg); border-color: var(--accent); }

/* escritório */
.office { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
.office:has(.agent-panel:not([hidden])) { grid-template-columns: minmax(0, 1fr) minmax(20rem, 28rem); }
@media (max-width: 1000px) { .office:has(.agent-panel:not([hidden])) { grid-template-columns: minmax(0, 1fr); } }
.office-main { min-width: 0; } .stage { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--cv-bg); } .office-canvas { display: block; } .office-canvas:focus-visible { outline-offset: -3px; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem .8rem; list-style: none; padding: 0; margin: .4rem 0; align-items: center; }
.lg { display: inline-block; padding: 0 .5rem; border-radius: 6px; border: 2px solid var(--accent); font-size: .8rem; font-weight: 600; } .lg-apr { border-style: dashed; border-color: var(--cv-warn); } .lg-msg { border-style: dotted; border-color: var(--muted); }
.team { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: .4rem; }
.team-btn { width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .7rem; cursor: pointer; display: flex; flex-wrap: wrap; gap: .2rem .5rem; align-items: center; } .team-btn:hover, .team-btn.sel { border-color: var(--accent); background: var(--info-bg); }
.agent-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; position: sticky; top: .5rem; max-height: calc(100vh - 1rem); overflow-y: auto; } .agent-panel[hidden] { display: none; }
@media (max-width: 1000px) { .agent-panel { position: static; max-height: none; } }
.ap-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; } .ap-head h2 { margin: 0; } .agent-panel section { border-top: 1px solid var(--border); padding-top: .4rem; }
.chat-list { display: flex; flex-direction: column; gap: 1rem; margin-bottom: .8rem; max-height: 28rem; overflow-y: auto; }
.chat-item { border: 1px solid var(--border); border-radius: 10px; padding: .6rem; display: flex; flex-direction: column; gap: .4rem; background: var(--bg); }
.bubble { padding: .5rem .7rem; border-radius: 10px; max-width: 94%; } .bubble.me { align-self: flex-end; background: var(--accent); color: var(--accent-fg); } .bubble.ia { align-self: flex-start; background: var(--surface2); border: 1px solid var(--border); } .bubble .who { font-size: .75rem; font-weight: 700; opacity: .85; display: block; }

/* diálogos e avisos */
dialog.dlg { border: 1px solid var(--border); border-radius: 12px; padding: 0; background: var(--surface); color: var(--text); width: min(34rem, 96vw); max-height: 92vh; } dialog.dlg.wide { width: min(56rem, 96vw); } dialog.dlg::backdrop { background: rgba(0, 0, 0, .55); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .6rem 1rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; } .dlg-head h2 { margin: 0; font-size: 1.1rem; } .dlg-body { padding: 1rem; overflow-y: auto; max-height: calc(92vh - 4rem); }
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 200; max-width: min(24rem, 92vw); }
.toast { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 5px solid var(--accent); border-radius: 8px; padding: .6rem .8rem; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); } .toast.erro { border-left-color: var(--danger); }

/* autenticação */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; } .auth-card { width: min(26rem, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1.5rem; display: flex; flex-direction: column; gap: .8rem; } .auth-card h1 { margin: 0; }
.cards .card strong { overflow-wrap: anywhere; }
@media (max-width: 600px) { main#main { padding: .6rem; } .user .who { display: none; } h1 { font-size: 1.35rem; } .kv { grid-template-columns: 1fr; } .kv dd { margin-bottom: .3rem; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
@media (forced-colors: active) { .badge, .pill, .seal { border: 2px solid CanvasText; } }
